@infekted11/stillnote 0.0.0-stage → 1.1.0

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.
@@ -0,0 +1,57 @@
1
+ var QA=Object.defineProperty;var my=u=>{throw TypeError(u)};var ZA=(u,t,e)=>t in u?QA(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var O=(u,t,e)=>ZA(u,typeof t!="symbol"?t+"":t,e),_g=(u,t,e)=>t.has(u)||my("Cannot "+e);var r=(u,t,e)=>(_g(u,t,"read from private field"),e?e.call(u):t.get(u)),y=(u,t,e)=>t.has(u)?my("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,e),p=(u,t,e,s)=>(_g(u,t,"write to private field"),s?s.call(u,e):t.set(u,e),e),b=(u,t,e)=>(_g(u,t,"access private method"),e);var Ft=(u,t,e,s)=>({set _(i){p(u,t,i,e)},get _(){return r(u,t,s)}});var t_={463(u){var t=TypeError;u.exports=function(e){if(typeof e=="string")return e;throw new t("Argument is not a string")}},804(u){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=t+"+/",s=t+"-_",i=function(n){for(var a={},o=0;o<64;o++)a[n.charAt(o)]=o;return a};u.exports={i2c:e,c2i:i(e),i2cUrl:s,c2iUrl:i(s)}},529(u){u.exports=function(t,e){return{value:t,done:e}}},837(u){var t=TypeError,e=9007199254740991;u.exports=function(s){if(s>e)throw new t("Maximum allowed index exceeded");return s}},2(u){u.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},944(u){var t=TypeError;u.exports=function(e){var s=e&&e.alphabet;if(s===void 0||s==="base64"||s==="base64url")return s||"base64";throw new t("Incorrect `alphabet` option")}},767(u){u.exports=function(t){return{iterator:t,next:t.next,done:!1}}},117(u){u.exports=function(t){return t==null}},859(u){u.exports=function(t){t.iterator=t.next=t.nextHandler=t.mapper=t.predicate=t.inner=t.iterables=t.iters=t.openIters=t.padding=t.finishResults=t.buffer=null}},684(u){u.exports=function(t,e){var s=typeof Iterator=="function"&&Iterator.prototype[t];if(s)try{s.call({next:null},e).next()}catch{return!0}}},269(u){u.exports=Object.create?Object.create(null):{}},741(u){var t=Math.ceil,e=Math.floor;u.exports=Math.trunc||function(i){var n=+i;return(n>0?e:t)(n)}},149(u){var t=RangeError;u.exports=function(e){if(e===e)return e;throw new t("NaN is not allowed")}},717(u,t){t.f=Object.getOwnPropertySymbols},103(u){u.exports=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}}},750(u,t,e){var s=e(117),i=TypeError;u.exports=function(n){if(s(n))throw new i("Can't call method on "+n);return n}},835(u){u.exports=function(t){try{var e=new Set,s={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return e.clear(),e.add(4),function(){return{done:!0}}}})}},i=e[t](s);return i.size===1&&i.values().next().value===4}catch{return!1}}},291(u,t,e){var s=e(741);u.exports=function(i){var n=+i;return n!==n||n===0?0:s(n)}},14(u,t,e){var s=e(291),i=Math.min;u.exports=function(n){var a=s(n);return a>0?i(a,9007199254740991):0}},981(u,t,e){var s=e(750),i=Object;u.exports=function(n){return i(s(n))}},590(u,t,e){var s=e(291),i=RangeError;u.exports=function(n){var a=s(n);if(a<0)throw new i("The argument can't be less than 0");return a}},812(u){var t=TypeError;u.exports=function(e,s){if(e<s)throw new t("Not enough arguments");return e}}};const vy={};function P(u){const t=vy[u];if(t!==void 0)return t.exports;const e=vy[u]={exports:{}};return t_[u](e,e.exports,P),e.exports}P.cw=u=>{var t;return()=>{if(u){var e=u;u=0,t={exports:{}},e.call(t.exports,t,t.exports)}return t.exports}};P.d=(u,t)=>{for(var e in t)P.o(t,e)&&!P.o(u,e)&&Object.defineProperty(u,e,{enumerable:!0,get:t[e]})};P.o=(u,t)=>Object.prototype.hasOwnProperty.call(u,t);var cs=P.cw(function(u,t){var e=Se(),s=ig(),i=TypeError;u.exports=function(n){if(e(n))return n;throw new i(s(n)+" is not a function")}}),e_=P.cw(function(u,t){var e=R_(),s=String,i=TypeError;u.exports=function(n){if(e(n))return n;throw new i("Can't set "+s(n)+" as a prototype")}}),_l=P.cw(function(u,t){var e=_r().has;u.exports=function(s){return e(s),s}}),qy=()=>P(463),s_=P.cw(function(u,t){var e=ng(),s=new e.WeakMap,i=e.set,n=e.remove;u.exports=function(a){return i(s,a,1),n(s,a),a}}),i_=P.cw(function(u,t){var e=ng().has;u.exports=function(s){return e(s),s}}),r_=P.cw(function(u,t){var e=Ni(),s=Qp(),i=Ia().f,n=e("unscopables"),a=Array.prototype;a[n]===void 0&&i(a,n,{configurable:!0,value:s(null)}),u.exports=function(o){a[n][o]=!0}}),Jy=P.cw(function(u,t){var e=Zp(),s=TypeError;u.exports=function(i,n){if(e(n,i))return i;throw new s("Incorrect invocation")}}),Qy=P.cw(function(u,t){var e=ds(),s=String,i=TypeError;u.exports=function(n){if(n===void 0||e(n))return n;throw new i(s(n)+" is not an object or undefined")}}),ae=P.cw(function(u,t){var e=ds(),s=String,i=TypeError;u.exports=function(n){if(e(n))return n;throw new i(s(n)+" is not an object")}}),Gp=P.cw(function(u,t){var e=Vp(),s=TypeError;u.exports=function(i){if(e(i)==="Uint8Array")return i;throw new s("Argument is not an Uint8Array")}}),Zy=P.cw(function(u,t){u.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"}),n_=P.cw(function(u,t){var e=Bt(),s=Rv(),i=Sl(),n=e.ArrayBuffer,a=e.TypeError;u.exports=n&&s(n.prototype,"byteLength","get")||function(o){if(i(o)!=="ArrayBuffer")throw new a("ArrayBuffer expected");return o.byteLength}}),a_=P.cw(function(u,t){var e=Bt(),s=Zy(),i=n_(),n=e.DataView;u.exports=function(a){if(!s||i(a)!==0)return!1;try{return new n(a),!1}catch{return!0}}}),zp=P.cw(function(u,t){var e=a_(),s=TypeError;u.exports=function(i){if(e(i))throw new s("ArrayBuffer is detached");return i}}),o_=P.cw(function(u,t){var e=Zy(),s=hs(),i=Bt(),n=Se(),a=ds(),o=us(),l=Vp(),c=ig(),h=Wp(),d=Yp(),f=sb(),g=Zp(),m=Bv(),v=pb(),w=Ni(),A=rg(),_=Jp(),E=_.enforce,S=_.get,x=i.Int8Array,T=x&&x.prototype,C=i.Uint8ClampedArray,I=C&&C.prototype,k=x&&m(x),M=T&&m(T),R=Object.prototype,N=i.TypeError,F=w("toStringTag"),j=A("TYPED_ARRAY_TAG"),U="TypedArrayConstructor",D=e&&!!v&&l(i.opera)!=="Opera",H=!1,X,nt,gt,mt={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},ht={BigInt64Array:8,BigUint64Array:8},at=function(ut){if(!a(ut))return!1;var xt=l(ut);return xt==="DataView"||o(mt,xt)||o(ht,xt)},Ee=function(tt){var ut=m(tt);if(a(ut)){var xt=S(ut);return xt&&o(xt,U)?xt[U]:Ee(ut)}},G=function(tt){if(!a(tt))return!1;var ut=l(tt);return o(mt,ut)||o(ht,ut)},L=function(tt){if(G(tt))return tt;throw new N("Target is not a typed array")},B=function(tt){if(n(tt)&&(!v||g(k,tt)))return tt;throw new N(c(tt)+" is not a typed array constructor")},it=function(tt,ut,xt,xe){if(s){if(xt)for(var ve in mt){var he=i[ve];if(he&&o(he.prototype,tt))try{delete he.prototype[tt]}catch{try{he.prototype[tt]=ut}catch{}}}(!M[tt]||xt)&&d(M,tt,xt?ut:D&&T[tt]||ut,xe)}},bt=function(tt,ut,xt){var xe,ve;if(s){if(v){if(xt){for(xe in mt)if(ve=i[xe],ve&&o(ve,tt))try{delete ve[tt]}catch{}}if(!k[tt]||xt)try{return d(k,tt,xt?ut:D&&k[tt]||ut)}catch{}else return}for(xe in mt)ve=i[xe],ve&&(!ve[tt]||xt)&&d(ve,tt,ut)}};for(X in mt)nt=i[X],gt=nt&&nt.prototype,gt?E(gt)[U]=nt:D=!1;for(X in ht)nt=i[X],gt=nt&&nt.prototype,gt&&(E(gt)[U]=nt);if((!D||!n(k)||k===Function.prototype)&&(k=function(){throw new N("Incorrect invocation")},D))for(X in mt)i[X]&&v(i[X],k);if((!D||!M||M===R)&&(M=k.prototype,D))for(X in mt)i[X]&&v(i[X].prototype,M);if(D&&m(I)!==M&&v(I,M),s&&!o(M,F)){H=!0,f(M,F,{configurable:!0,get:function(){return a(this)?this[j]:void 0}});for(X in mt)i[X]&&h(i[X].prototype,j,X)}u.exports={NATIVE_ARRAY_BUFFER_VIEWS:D,TYPED_ARRAY_TAG:H&&j,aTypedArray:L,aTypedArrayConstructor:B,exportTypedArrayMethod:it,exportTypedArrayStaticMethod:bt,getTypedArrayConstructor:Ee,isView:at,isTypedArray:G,TypedArray:k,TypedArrayPrototype:M}}),l_=P.cw(function(u,t){var e=Sh();u.exports=function(s,i,n){for(var a=0,o=arguments.length>2?n:e(i),l=new s(o);o>a;)l[a]=i[a++];return l}}),Iv=P.cw(function(u,t){var e=eg(),s=i0(),i=Sh(),n=function(a){return function(o,l,c){var h=e(o),d=i(h);if(d===0)return!a&&-1;var f=s(c,d),g;if(a&&l!==l){for(;d>f;)if(g=h[f++],g!==g)return!0}else for(;d>f;f++)if((a||f in h)&&h[f]===l)return a||f||0;return!a&&-1}};u.exports={includes:n(!0),indexOf:n(!1)}}),c_=P.cw(function(u,t){var e=hs(),s=Lv(),i=TypeError,n=Object.getOwnPropertyDescriptor,a=e&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(o){return o instanceof TypeError}})();u.exports=a?function(o,l){if(s(o)&&!n(o,"length").writable)throw new i("Cannot set read only .length");return o.length=l}:function(o,l){return o.length=l}}),h_=P.cw(function(u,t){var e=Nt();u.exports=e([].slice)}),tb=()=>P(804),eb=P.cw(function(u,t){var e=ae(),s=fs();u.exports=function(i,n,a,o){try{return o?n(e(a)[0],a[1]):n(a)}catch(l){s(i,"throw",l)}}}),Sl=P.cw(function(u,t){var e=Nt(),s=e({}.toString),i=e("".slice);u.exports=function(n){return i(s(n),8,-1)}}),Vp=P.cw(function(u,t){var e=a0(),s=Se(),i=Sl(),n=Ni(),a=n("toStringTag"),o=Object,l=i((function(){return arguments})())==="Arguments",c=function(h,d){try{return h[d]}catch{}};u.exports=e?i:function(h){var d,f,g;return h===void 0?"Undefined":h===null?"Null":typeof(f=c(d=o(h),a))=="string"?f:l?i(d):(g=i(d))==="Object"&&s(d.callee)?"Arguments":g}}),u_=P.cw(function(u,t){var e=us(),s=W_(),i=db(),n=Ia();u.exports=function(a,o,l){for(var c=s(o),h=n.f,d=i.f,f=0;f<c.length;f++){var g=c[f];!e(a,g)&&!(l&&e(l,g))&&h(a,g,d(o,g))}}}),d_=P.cw(function(u,t){var e=le();u.exports=!e(function(){function s(){}return s.prototype.constructor=null,Object.getPrototypeOf(new s)!==s.prototype})}),f_=()=>P(529),Wp=P.cw(function(u,t){var e=hs(),s=Ia(),i=Xp();u.exports=e?function(n,a,o){return s.f(n,a,i(1,o))}:function(n,a,o){return n[a]=o,n}}),Xp=P.cw(function(u,t){u.exports=function(e,s){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:s}}}),kv=P.cw(function(u,t){var e=hs(),s=Ia(),i=Xp();u.exports=function(n,a,o){e?s.f(n,a,i(0,o)):n[a]=o}}),sb=P.cw(function(u,t){var e=lb(),s=Ia();u.exports=function(i,n,a){return a.get&&e(a.get,n,{getter:!0}),a.set&&e(a.set,n,{setter:!0}),s.f(i,n,a)}}),Yp=P.cw(function(u,t){var e=Se(),s=Ia(),i=lb(),n=Mv();u.exports=function(a,o,l,c){c||(c={});var h=c.enumerable,d=c.name!==void 0?c.name:o;if(e(l)&&i(l,d,c),c.global)h?a[o]=l:n(o,l);else{try{c.unsafe?a[o]&&(h=!0):delete a[o]}catch{}h?a[o]=l:s.f(a,o,{value:l,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return a}}),p_=P.cw(function(u,t){var e=Yp();u.exports=function(s,i,n){for(var a in i)e(s,a,i[a],n);return s}}),Mv=P.cw(function(u,t){var e=Bt(),s=Object.defineProperty;u.exports=function(i,n){try{s(e,i,{value:n,configurable:!0,writable:!0})}catch{e[i]=n}return n}}),hs=P.cw(function(u,t){var e=le();u.exports=!e(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),ib=P.cw(function(u,t){var e=Bt(),s=ds(),i=e.document,n=s(i)&&s(i.createElement);u.exports=function(a){return n?i.createElement(a):{}}}),g_=()=>P(837),m_=()=>P(2),Ov=P.cw(function(u,t){u.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]}),v_=P.cw(function(u,t){var e=Bt(),s=e.navigator,i=s&&s.userAgent;u.exports=i?String(i):""}),y_=P.cw(function(u,t){var e=Bt(),s=v_(),i=e.process,n=e.Deno,a=i&&i.versions||n&&n.version,o=a&&a.v8,l,c;o&&(l=o.split("."),c=l[0]>0&&l[0]<4?1:+(l[0]+l[1])),!c&&s&&(l=s.match(/Edge\/(\d+)/),(!l||l[1]>=74)&&(l=s.match(/Chrome\/(\d+)/),l&&(c=+l[1]))),u.exports=c}),b_=P.cw(function(u,t){var e=Nt(),s=Error,i=e("".replace),n=(function(l){return String(new s(l).stack)})("zxcasd"),a=/\n\s*at [^:]*:[^\n]*/,o=a.test(n);u.exports=function(l,c){if(o&&typeof l=="string"&&!s.prepareStackTrace)for(;c--;)l=i(l,a,"");return l}}),pt=P.cw(function(u,t){var e=Bt(),s=db().f,i=Wp(),n=Yp(),a=Mv(),o=u_(),l=O_();u.exports=function(c,h){var d=c.target,f=c.global,g=c.stat,m,v,w,A,_,E;if(f?v=e:g?v=e[d]||a(d,{}):v=e[d]&&e[d].prototype,v)for(w in h){if(_=h[w],c.dontCallGetSet?(E=s(v,w),A=E&&E.value):A=v[w],m=l(f?w:d+(g?".":"#")+w,c.forced),!m&&A!==void 0){if(typeof _==typeof A)continue;o(_,A)}(c.sham||A&&A.sham)&&i(_,"sham",!0),n(v,w,_,c)}}}),le=P.cw(function(u,t){u.exports=function(e){try{return!!e()}catch{return!0}}}),w_=P.cw(function(u,t){var e=Kp(),s=Function.prototype,i=s.apply,n=s.call;u.exports=typeof Reflect=="object"&&Reflect.apply||(e?n.bind(i):function(){return n.apply(i,arguments)})}),A_=P.cw(function(u,t){var e=S_(),s=cs(),i=Kp(),n=e(e.bind);u.exports=function(a,o){return s(a),o===void 0?a:i?n(a,o):function(){return a.apply(o,arguments)}}}),Kp=P.cw(function(u,t){var e=le();u.exports=!e(function(){var s=(function(){}).bind();return typeof s!="function"||s.hasOwnProperty("prototype")})}),ce=P.cw(function(u,t){var e=Kp(),s=Function.prototype.call;u.exports=e?s.bind(s):function(){return s.apply(s,arguments)}}),__=P.cw(function(u,t){var e=hs(),s=us(),i=Function.prototype,n=e&&Object.getOwnPropertyDescriptor,a=s(i,"name"),o=a&&(!e||e&&n(i,"name").configurable);u.exports={CONFIGURABLE:o}}),Rv=P.cw(function(u,t){var e=Nt(),s=cs();u.exports=function(i,n,a){try{return e(s(Object.getOwnPropertyDescriptor(i,n)[a]))}catch{}}}),S_=P.cw(function(u,t){var e=Sl(),s=Nt();u.exports=function(i){if(e(i)==="Function")return s(i)}}),Nt=P.cw(function(u,t){var e=Kp(),s=Function.prototype,i=s.call,n=e&&s.bind.bind(i,i);u.exports=e?n:function(a){return function(){return i.apply(a,arguments)}}}),rb=()=>P(944),Pa=P.cw(function(u,t){var e=Bt(),s=Se(),i=function(n){return s(n)?n:void 0};u.exports=function(n,a){return arguments.length<2?i(e[n]):e[n]&&e[n][a]}}),gi=()=>P(767),E_=P.cw(function(u,t){var e=ce(),s=ae(),i=gi(),n=Dv();u.exports=function(a,o){(!o||typeof a!="string")&&s(a);var l=n(a);return i(s(l!==void 0?e(l,a):a))}}),x_=P.cw(function(u,t){var e=ce(),s=Se(),i=ae(),n=ig(),a=Dv(),o=TypeError;u.exports=function(l,c){var h=arguments.length<2?a(l):c;if(s(h))return i(e(h,l));throw new o(n(l)+" is not iterable")}}),Dv=P.cw(function(u,t){var e=Sl(),s=ab(),i=qp(),n=Ni(),a=n("iterator"),o=Array.prototype;u.exports=function(l){if(!s(l))return i(l,a)||i(l,"@@iterator")||(e(l)==="Arguments"?o[a]:void 0)}}),qp=P.cw(function(u,t){var e=cs(),s=ab();u.exports=function(i,n){var a=i[n];return s(a)?void 0:e(a)}}),El=P.cw(function(u,t){var e=cs(),s=ae(),i=ce(),n=$v(),a=gi(),o="Invalid size",l=RangeError,c=TypeError,h=Math.max,d=function(f,g){this.set=f,this.size=h(g,0),this.has=e(f.has),this.keys=e(f.keys)};d.prototype={getIterator:function(){return a(s(i(this.keys,this.set)))},includes:function(f){return i(this.has,this.set,f)}},u.exports=function(f){s(f);var g=+f.size;if(g!==g)throw new c(o);var m=n(g);if(m<0)throw new l(o);return new d(f,m)}}),Bt=P.cw(function(u,t){var e=function(s){return s&&s.Math===Math&&s};u.exports=e(typeof globalThis=="object"&&globalThis)||e(typeof window=="object"&&window)||e(typeof self=="object"&&self)||e(typeof global=="object"&&global)||e(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()}),us=P.cw(function(u,t){var e=Nt(),s=Gv(),i=e({}.hasOwnProperty);u.exports=Object.hasOwn||function(a,o){return i(s(a),o)}}),Fv=P.cw(function(u,t){u.exports={}}),T_=P.cw(function(u,t){var e=Pa();u.exports=e("document","documentElement")}),nb=P.cw(function(u,t){var e=hs(),s=le(),i=ib();u.exports=!e&&!s(function(){return Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a!==7})}),C_=P.cw(function(u,t){var e=Nt(),s=le(),i=Sl(),n=Object,a=e("".split);u.exports=s(function(){return!n("z").propertyIsEnumerable(0)})?function(o){return i(o)==="String"?a(o,""):n(o)}:n}),P_=P.cw(function(u,t){var e=Se(),s=ds(),i=pb();u.exports=function(n,a,o){var l,c;return i&&e(l=a.constructor)&&l!==o&&s(c=l.prototype)&&c!==o.prototype&&i(n,c),n}}),I_=P.cw(function(u,t){var e=Nt(),s=Se(),i=jv(),n=e(Function.toString);s(i.inspectSource)||(i.inspectSource=function(a){return n(a)}),u.exports=i.inspectSource}),Jp=P.cw(function(u,t){var e=h0(),s=Bt(),i=ds(),n=Wp(),a=us(),o=jv(),l=Hv(),c=Fv(),h="Object already initialized",d=s.TypeError,f=s.WeakMap,g,m,v,w=function(S){return v(S)?m(S):g(S,{})},A=function(S){return function(x){var T;if(!i(x)||(T=m(x)).type!==S)throw new d("Incompatible receiver, "+S+" required");return T}};if(e||o.state){var _=o.state||(o.state=new f);_.get=_.get,_.has=_.has,_.set=_.set,g=function(S,x){if(_.has(S))throw new d(h);return x.facade=S,_.set(S,x),x},m=function(S){return _.get(S)||{}},v=function(S){return _.has(S)}}else{var E=l("state");c[E]=!0,g=function(S,x){if(a(S,E))throw new d(h);return x.facade=S,n(S,E,x),x},m=function(S){return a(S,E)?S[E]:{}},v=function(S){return a(S,E)}}u.exports={set:g,get:m,has:v,enforce:w,getterFor:A}}),k_=P.cw(function(u,t){var e=Ni(),s=N_(),i=e("iterator"),n=Array.prototype;u.exports=function(a){return a!==void 0&&(s.Array===a||n[i]===a)}}),Lv=P.cw(function(u,t){var e=Sl();u.exports=Array.isArray||function(i){return e(i)==="Array"}}),M_=P.cw(function(u,t){var e=Vp();u.exports=function(s){var i=e(s);return i==="BigInt64Array"||i==="BigUint64Array"}}),Se=P.cw(function(u,t){var e=typeof document=="object"&&document.all;u.exports=typeof e>"u"&&e!==void 0?function(s){return typeof s=="function"||s===e}:function(s){return typeof s=="function"}}),O_=P.cw(function(u,t){var e=le(),s=Se(),i=/#|\.prototype\./,n=function(h,d){var f=o[a(h)];return f===c?!0:f===l?!1:s(d)?e(d):!!d},a=n.normalize=function(h){return String(h).replace(i,".").toLowerCase()},o=n.data={},l=n.NATIVE="N",c=n.POLYFILL="P";u.exports=n}),ab=()=>P(117),ds=P.cw(function(u,t){var e=Se();u.exports=function(s){return typeof s=="object"?s!==null:e(s)}}),R_=P.cw(function(u,t){var e=ds();u.exports=function(s){return e(s)||s===null}}),xs=P.cw(function(u,t){u.exports=!1}),D_=P.cw(function(u,t){var e=ds(),s=Jp().get;u.exports=function(n){if(!e(n))return!1;var a=s(n);return!!a&&a.type==="RawJSON"}}),Nv=P.cw(function(u,t){var e=Pa(),s=Se(),i=Zp(),n=Sb(),a=Object;u.exports=n?function(o){return typeof o=="symbol"}:function(o){var l=e("Symbol");return s(l)&&i(l.prototype,a(o))}}),xl=P.cw(function(u,t){var e=ce();u.exports=function(s,i,n){for(var a=n?s:s.iterator,o=s.next,l,c;!(l=e(o,a)).done;)if(c=i(l.value),c!==void 0)return c}}),_h=P.cw(function(u,t){var e=A_(),s=ce(),i=ae(),n=ig(),a=k_(),o=Sh(),l=Zp(),c=x_(),h=Dv(),d=fs(),f=TypeError,g=function(v,w){this.stopped=v,this.result=w},m=g.prototype;u.exports=function(v,w,A){var _=A&&A.that,E=!!(A&&A.AS_ENTRIES),S=!!(A&&A.IS_RECORD),x=!!(A&&A.IS_ITERATOR),T=!!(A&&A.INTERRUPTED),C=e(w,_),I,k,M,R,N,F,j,U=function(X){var nt=I;return I=void 0,nt&&d(nt,"normal"),new g(!0,X)},D=function(X){return E?(i(X),T?C(X[0],X[1],U):C(X[0],X[1])):T?C(X,U):C(X)};if(S)I=v.iterator;else if(x)I=v;else{if(k=h(v),!k)throw new f(n(v)+" is not iterable");if(a(k)){for(M=0,R=o(v);R>M;M++)if(N=D(v[M]),N&&l(m,N))return N;return new g(!1)}I=c(v,k)}for(F=S?v.next:I.next;!(j=s(F,I)).done;){var H=j.value;try{N=D(H)}catch(X){if(I)d(I,"throw",X);else throw X}if(typeof N=="object"&&N&&l(m,N))return N}return new g(!1)}}),F_=()=>P(859),L_=P.cw(function(u,t){var e=fs();u.exports=function(s,i,n){for(var a=s.length-1;a>=0;a--)if(s[a]!==void 0)try{n=e(s[a].iterator,i,n)}catch(o){i="throw",n=o}if(i==="throw")throw n;return n}}),fs=P.cw(function(u,t){var e=ce(),s=ae(),i=qp();u.exports=function(n,a,o){var l,c;s(n);try{if(l=i(n,"return"),!l){if(a==="throw")throw o;return o}l=e(l,n)}catch(h){c=!0,l=h}if(a==="throw")throw o;if(c)throw l;return s(l),o}}),sf=P.cw(function(u,t){var e=ce(),s=Qp(),i=Wp(),n=p_(),a=Ni(),o=Jp(),l=qp(),c=ob().IteratorPrototype,h=f_(),d=fs(),f=L_(),g=F_(),m=a("toStringTag"),v="IteratorHelper",w="WrapForValidIterator",A="normal",_="throw",E=o.set,S=function(C){var I=o.getterFor(C?w:v);return n(s(c),{next:function(){var M=I(this);if(C)return M.nextHandler();if(M.done)return h(void 0,!0);try{var R=M.nextHandler();return M.done&&g(M),M.returnHandlerResult?R:h(R,M.done)}catch(N){throw M.done=!0,g(M),N}},return:function(){var k=I(this),M=k.iterator,R=k.inner,N=k.openIters,F=k.done;if(k.done=!0,C){var j=l(M,"return");return j?e(j,M):h(void 0,!0)}if(g(k),F)return h(void 0,!0);if(R)try{d(R.iterator,A)}catch(U){return d(M,_,U)}if(N)try{f(N,A)}catch(U){if(M)return d(M,_,U);throw U}return M&&d(M,A),h(void 0,!0)}})},x=S(!0),T=S(!1);i(T,m,"Iterator Helper"),u.exports=function(C,I,k){var M=function(N,F){F?(F.iterator=N.iterator,F.next=N.next):F=N,F.type=I?w:v,F.returnHandlerResult=!!k,F.nextHandler=C,F.counter=0,F.done=!1,E(this,F)};return M.prototype=I?x:T,M}}),rf=()=>P(684),yn=P.cw(function(u,t){var e=Bt();u.exports=function(s,i){var n=e.Iterator,a=n&&n.prototype,o=a&&a[s],l=!1;if(o)try{o.call({next:function(){return{done:!0}},return:function(){l=!0}},-1)}catch(c){c instanceof i||(l=!1)}if(!l)return o}}),ob=P.cw(function(u,t){var e=le(),s=Se(),i=ds(),n=Qp(),a=Bv(),o=Yp(),l=Ni(),c=xs(),h=l("iterator"),d,f,g;[].keys&&(g=[].keys(),"next"in g&&(f=a(a(g)),f!==Object.prototype&&(d=f)));var m=!i(d)||e(function(){var v={};return d[h].call(v)!==v});m?d={}:c&&(d=n(d)),s(d[h])||o(d,h,function(){return this}),u.exports={IteratorPrototype:d}}),N_=()=>P(269),Sh=P.cw(function(u,t){var e=n0();u.exports=function(s){return e(s.length)}}),lb=P.cw(function(u,t){var e=Nt(),s=le(),i=Se(),n=us(),a=hs(),o=__().CONFIGURABLE,l=I_(),c=Jp(),h=c.enforce,d=c.get,f=String,g=Object.defineProperty,m=e("".slice),v=e("".replace),w=e([].join),A=a&&!s(function(){return g(function(){},"length",{value:8}).length!==8}),_=String(String).split("String"),E=u.exports=function(S,x,T){m(f(x),0,7)==="Symbol("&&(x="["+v(f(x),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),T&&T.getter&&(x="get "+x),T&&T.setter&&(x="set "+x),(!n(S,"name")||o&&S.name!==x)&&(a?g(S,"name",{value:x,configurable:!0}):S.name=x),A&&T&&n(T,"arity")&&S.length!==T.arity&&g(S,"length",{value:T.arity});try{T&&n(T,"constructor")&&T.constructor?a&&g(S,"prototype",{writable:!1}):S.prototype&&(S.prototype=void 0)}catch{}var C=h(S);return n(C,"source")||(C.source=w(_,typeof x=="string"?x:"")),S};Function.prototype.toString=E(function(){return i(this)&&d(this).source||l(this)},"toString")}),cb=P.cw(function(u,t){var e=Nt(),s=Map.prototype;u.exports={Map,set:e(s.set),get:e(s.get),has:e(s.has),remove:e(s.delete),proto:s}}),B_=P.cw(function(u,t){var e=le();u.exports=!e(function(){var s="9007199254740993",i=JSON.rawJSON(s);return!JSON.isRawJSON(i)||JSON.stringify(i)!==s})}),hb=P.cw(function(u,t){var e=cs(),s=TypeError,i=function(n){var a,o;this.promise=new n(function(l,c){if(a!==void 0||o!==void 0)throw new s("Bad Promise constructor");a=l,o=c}),this.resolve=e(a),this.reject=e(o)};u.exports.f=function(n){return new i(n)}}),U_=P.cw(function(u,t){var e=sg();u.exports=function(s,i){return s===void 0?arguments.length<2?"":i:e(s)}}),ub=()=>P(149),Qp=P.cw(function(u,t){var e=ae(),s=H_(),i=Ov(),n=Fv(),a=T_(),o=ib(),l=Hv(),c=">",h="<",d="prototype",f="script",g=l("IE_PROTO"),m=function(){},v=function(S){return h+f+c+S+h+"/"+f+c},w=function(S){S.write(v("")),S.close();var x=S.parentWindow.Object;return S=null,x},A=function(){var S=o("iframe"),x="java"+f+":",T;return S.style.display="none",a.appendChild(S),S.src=String(x),T=S.contentWindow.document,T.open(),T.write(v("document.F=Object")),T.close(),T.F},_,E=function(){try{_=new ActiveXObject("htmlfile")}catch{}E=typeof document<"u"?document.domain&&_?w(_):A():w(_);for(var S=i.length;S--;)delete E[d][i[S]];return E()};n[g]=!0,u.exports=Object.create||function(x,T){var C;return x!==null?(m[d]=e(x),C=new m,m[d]=null,C[g]=x):C=E(),T===void 0?C:s.f(C,T)}}),H_=P.cw(function(u,t){var e=hs(),s=Eb(),i=Ia(),n=ae(),a=eg(),o=G_();t.f=e&&!s?Object.defineProperties:function(c,h){n(c);for(var d=a(h),f=o(h),g=f.length,m=0,v;g>m;)i.f(c,v=f[m++],d[v]);return c}}),Ia=P.cw(function(u,t){var e=hs(),s=nb(),i=Eb(),n=ae(),a=Ab(),o=TypeError,l=Object.defineProperty,c=Object.getOwnPropertyDescriptor,h="enumerable",d="configurable",f="writable";t.f=e?i?function(m,v,w){if(n(m),v=a(v),n(w),typeof m=="function"&&v==="prototype"&&"value"in w&&f in w&&!w[f]){var A=c(m,v);A&&A[f]&&(m[v]=w.value,w={configurable:d in w?w[d]:A[d],enumerable:h in w?w[h]:A[h],writable:!1})}return l(m,v,w)}:l:function(m,v,w){if(n(m),v=a(v),n(w),s)try{return l(m,v,w)}catch{}if("get"in w||"set"in w)throw new o("Accessors not supported");return"value"in w&&(m[v]=w.value),m}}),db=P.cw(function(u,t){var e=hs(),s=ce(),i=z_(),n=Xp(),a=eg(),o=Ab(),l=us(),c=nb(),h=Object.getOwnPropertyDescriptor;t.f=e?h:function(f,g){if(f=a(f),g=o(g),c)try{return h(f,g)}catch{}if(l(f,g))return n(!s(i.f,f,g),f[g])}}),j_=P.cw(function(u,t){var e=fb(),s=Ov(),i=s.concat("length","prototype");t.f=Object.getOwnPropertyNames||function(a){return e(a,i)}}),$_=()=>P(717),Bv=P.cw(function(u,t){var e=us(),s=Se(),i=Gv(),n=Hv(),a=d_(),o=n("IE_PROTO"),l=Object,c=l.prototype;u.exports=a?l.getPrototypeOf:function(h){var d=i(h);if(e(d,o))return d[o];var f=d.constructor;return s(f)&&d instanceof f?f.prototype:d instanceof l?c:null}}),Zp=P.cw(function(u,t){var e=Nt();u.exports=e({}.isPrototypeOf)}),fb=P.cw(function(u,t){var e=Nt(),s=us(),i=eg(),n=Iv().indexOf,a=Fv(),o=e([].push);u.exports=function(l,c){var h=i(l),d=0,f=[],g;for(g in h)!s(a,g)&&s(h,g)&&o(f,g);for(;c.length>d;)s(h,g=c[d++])&&(~n(f,g)||o(f,g));return f}}),G_=P.cw(function(u,t){var e=fb(),s=Ov();u.exports=Object.keys||function(n){return e(n,s)}}),z_=P.cw(function(u,t){var e={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,i=s&&!e.call({1:2},1);t.f=i?function(a){var o=s(this,a);return!!o&&o.enumerable}:e}),pb=P.cw(function(u,t){var e=Rv(),s=ds(),i=mb(),n=e_();u.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var a=!1,o={},l;try{l=e(Object.prototype,"__proto__","set"),l(o,[]),a=o instanceof Array}catch{}return function(h,d){return i(h),n(d),s(h)&&(a?l(h,d):h.__proto__=d),h}})():void 0)}),V_=P.cw(function(u,t){var e=ce(),s=Se(),i=ds(),n=TypeError;u.exports=function(a,o){var l,c;if(o==="string"&&s(l=a.toString)&&!i(c=e(l,a))||s(l=a.valueOf)&&!i(c=e(l,a))||o!=="string"&&s(l=a.toString)&&!i(c=e(l,a)))return c;throw new n("Can't convert object to primitive value")}}),W_=P.cw(function(u,t){var e=Pa(),s=Nt(),i=j_(),n=$_(),a=ae(),o=s([].concat);u.exports=e("Reflect","ownKeys")||function(c){var h=i.f(a(c)),d=n.f;return d?o(h,d(c)):h}}),gb=P.cw(function(u,t){var e=Nt(),s=us(),i=SyntaxError,n=parseInt,a=String.fromCharCode,o=e("".charAt),l=e("".slice),c=e(/./.exec),h={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
2
+ `,"\\r":"\r","\\t":" "},d=/^[\da-f]{4}$/i,f=/^[\u0000-\u001F]$/;u.exports=function(g,m){for(var v=!0,w="";m<g.length;){var A=o(g,m);if(A==="\\"){var _=l(g,m,m+2);if(s(h,_))w+=h[_],m+=2;else if(_==="\\u"){m+=2;var E=l(g,m,m+4);if(!c(d,E))throw new i("Bad Unicode escape at: "+m);w+=a(n(E,16)),m+=4}else throw new i('Unknown escape sequence: "'+_+'"')}else if(A==='"'){v=!1,m++;break}else{if(c(f,A))throw new i("Bad control character in string literal at: "+m);w+=A,m++}}if(v)throw new i("Unterminated string at: "+m);return{value:w,end:m}}}),X_=()=>P(103),Y_=P.cw(function(u,t){var e=ae(),s=ds(),i=hb();u.exports=function(n,a){if(e(n),s(a)&&a.constructor===n)return a;var o=i.f(n),l=o.resolve;return l(a),o.promise}}),mb=()=>P(750),Uv=P.cw(function(u,t){var e=_r(),s=nf(),i=e.Set,n=e.add;u.exports=function(a){var o=new i;return s(a,function(l){n(o,l)}),o}}),K_=P.cw(function(u,t){var e=_l(),s=_r(),i=Uv(),n=af(),a=El(),o=nf(),l=xl(),c=s.has,h=s.remove;u.exports=function(f){var g=e(this),m=a(f),v=i(g);return n(v)<=m.size?o(v,function(w){m.includes(w)&&h(v,w)}):l(m.getIterator(),function(w){c(v,w)&&h(v,w)}),v}}),_r=P.cw(function(u,t){var e=Nt(),s=Set.prototype;u.exports={Set,add:e(s.add),has:e(s.has),remove:e(s.delete),proto:s}}),q_=P.cw(function(u,t){var e=_l(),s=_r(),i=af(),n=El(),a=nf(),o=xl(),l=s.Set,c=s.add,h=s.has;u.exports=function(f){var g=e(this),m=n(f),v=new l;return i(g)>m.size?o(m.getIterator(),function(w){h(g,w)&&c(v,w)}):a(g,function(w){m.includes(w)&&c(v,w)}),v}}),J_=P.cw(function(u,t){var e=_l(),s=_r().has,i=af(),n=El(),a=nf(),o=xl(),l=fs();u.exports=function(h){var d=e(this),f=n(h);if(i(d)<=f.size)return a(d,function(m){if(f.includes(m))return!1},!0)!==!1;var g=f.getIterator();return o(g,function(m){if(s(d,m))return l(g.iterator,"normal",!1)})!==!1}}),Q_=P.cw(function(u,t){var e=_l(),s=af(),i=nf(),n=El();u.exports=function(o){var l=e(this),c=n(o);return s(l)>c.size?!1:i(l,function(h){if(!c.includes(h))return!1},!0)!==!1}}),Z_=P.cw(function(u,t){var e=_l(),s=_r().has,i=af(),n=El(),a=xl(),o=fs();u.exports=function(c){var h=e(this),d=n(c);if(i(h)<d.size)return!1;var f=d.getIterator();return a(f,function(g){if(!s(h,g))return o(f.iterator,"normal",!1)})!==!1}}),nf=P.cw(function(u,t){var e=Nt(),s=xl(),i=_r(),n=i.Set,a=i.proto,o=e(a.forEach),l=e(a.keys),c=l(new n).next;u.exports=function(h,d,f){return f?s({iterator:l(h),next:c},d):o(h,d)}}),Tl=P.cw(function(u,t){var e=Pa(),s=function(n){return{size:n,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},i=function(n){return{size:n,has:function(){return!0},keys:function(){throw new Error("e")}}};u.exports=function(n,a){var o=e("Set");try{new o()[n](s(0));try{return new o()[n](s(-1)),!1}catch{if(!a)return!0;try{return new o()[n](i(-1/0)),!1}catch{var l=new o([1,2]);return a(l[n](i(1/0)))}}}catch{return!1}}}),vb=()=>P(835),af=P.cw(function(u,t){var e=Rv(),s=_r();u.exports=e(s.proto,"size","get")||function(i){return i.size}}),t0=P.cw(function(u,t){var e=_l(),s=_r(),i=Uv(),n=El(),a=xl(),o=s.add,l=s.has,c=s.remove;u.exports=function(d){var f=e(this),g=n(d).getIterator(),m=i(f);return a(g,function(v){l(f,v)?c(m,v):o(m,v)}),m}}),e0=P.cw(function(u,t){var e=_l(),s=_r().add,i=Uv(),n=El(),a=xl();u.exports=function(l){var c=e(this),h=n(l).getIterator(),d=i(c);return a(h,function(f){s(d,f)}),d}}),Hv=P.cw(function(u,t){var e=yb(),s=rg(),i=e("keys");u.exports=function(n){return i[n]||(i[n]=s(n))}}),jv=P.cw(function(u,t){var e=xs(),s=Bt(),i=Mv(),n="__core-js_shared__",a=u.exports=s[n]||i(n,{});(a.versions||(a.versions=[])).push({version:"3.50.0",mode:e?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.50.0/LICENSE",source:"https://github.com/zloirock/core-js"})}),yb=P.cw(function(u,t){var e=jv(),s=Object.create||Object;u.exports=function(i,n){return e[i]||(e[i]=n||s(null))}}),tg=P.cw(function(u,t){var e=y_(),s=le(),i=Bt(),n=i.String;u.exports=!!Object.getOwnPropertySymbols&&!s(function(){var a=Symbol("symbol detection");return!n(a)||!(Object(a)instanceof Symbol)||!Symbol.sham&&e&&e<41})}),s0=P.cw(function(u,t){var e=Nt();u.exports=e(1.1.valueOf)}),i0=P.cw(function(u,t){var e=$v(),s=Math.max,i=Math.min;u.exports=function(n,a){var o=e(n);return o<0?s(o+a,0):i(o,a)}}),r0=P.cw(function(u,t){var e=wb(),s=TypeError;u.exports=function(i){var n=e(i,"number");if(typeof n=="number")throw new s("Can't convert number to bigint");return BigInt(n)}}),eg=P.cw(function(u,t){var e=C_(),s=mb();u.exports=function(i){return e(s(i))}}),$v=()=>P(291),n0=()=>P(14),Gv=()=>P(981),bb=()=>P(590),wb=P.cw(function(u,t){var e=ce(),s=ds(),i=Nv(),n=qp(),a=V_(),o=Ni(),l=TypeError,c=o("toPrimitive");u.exports=function(h,d){if(!s(h)||i(h))return h;var f=n(h,c),g;if(f){if(d===void 0&&(d="default"),g=e(f,h,d),!s(g)||i(g))return g;throw new l("Can't convert object to primitive value")}return d===void 0&&(d="number"),a(h,d)}}),Ab=P.cw(function(u,t){var e=wb(),s=Nv();u.exports=function(i){var n=e(i,"string");return s(n)?n:n+""}}),a0=P.cw(function(u,t){var e=Ni(),s=e("toStringTag"),i={};i[s]="z",u.exports=String(i)==="[object z]"}),sg=P.cw(function(u,t){var e=Vp(),s=String;u.exports=function(i){if(e(i)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return s(i)}}),ig=P.cw(function(u,t){var e=String;u.exports=function(s){try{return e(s)}catch{return"Object"}}}),rg=P.cw(function(u,t){var e=Nt(),s=0,i=Math.random(),n=e(1.1.toString);u.exports=function(a){return"Symbol("+(a===void 0?"":a)+")_"+n(++s+i,36)}}),_b=P.cw(function(u,t){var e=Bt(),s=Nt(),i=Qy(),n=qy(),a=us(),o=tb(),l=rb(),c=zp(),h=o.c2i,d=o.c2iUrl,f=e.SyntaxError,g=e.TypeError,m=e.Array,v=s("".charAt),w=Math.floor,A=function(S,x){for(var T=S.length;x<T;x++){var C=v(S,x);if(C!==" "&&C!==" "&&C!==`
3
+ `&&C!=="\f"&&C!=="\r")break}return x},_=function(S,x,T){var C=S.length;C<4&&(S+=C===2?"AA":"A");var I=(x[v(S,0)]<<18)+(x[v(S,1)]<<12)+(x[v(S,2)]<<6)+x[v(S,3)],k=[I>>16&255,I>>8&255,I&255];if(C===2){if(T&&k[1]!==0)throw new f("Extra bits");return[k[0]]}if(C===3){if(T&&k[2]!==0)throw new f("Extra bits");return[k[0],k[1]]}return k},E=function(S,x,T){for(var C=x.length,I=0;I<C;I++)S[T+I]=x[I];return T+C};u.exports=function(S,x,T,C){n(S),i(x);var I=l(x)==="base64"?h:d,k=x?x.lastChunkHandling:void 0;if(k===void 0&&(k="loose"),k!=="loose"&&k!=="strict"&&k!=="stop-before-partial")throw new g("Incorrect `lastChunkHandling` option");T&&c(T.buffer);var M=S.length,R=T||m(w(M*3/4)),N=0,F=0,j="",U=0;if(C)for(;;){if(U=A(S,U),U===M){if(j.length>0){if(k==="stop-before-partial")break;if(k==="loose"){if(j.length===1)throw new f("Malformed padding: exactly one additional character");N=E(R,_(j,I,!1),N)}else throw new f("Missing padding")}F=M;break}var D=v(S,U);if(++U,D==="="){if(j.length<2)throw new f("Padding is too early");if(U=A(S,U),j.length===2){if(U===M){if(k==="stop-before-partial")break;throw new f("Malformed padding: only one =")}v(S,U)==="="&&(++U,U=A(S,U))}if(U<M)throw new f("Unexpected character after padding");N=E(R,_(j,I,k==="strict"),N),F=M;break}if(!a(I,D))throw new f("Unexpected character");var H=C-N;if(H===1&&j.length===2||H===2&&j.length===3||(j+=D,j.length===4&&(N=E(R,_(j,I,!1),N),j="",F=U,N===C)))break}return T||(R.length=N),{bytes:R,read:F,written:N}}}),o0=P.cw(function(u,t){var e=Bt(),s=Nt(),i=e.Uint8Array,n=e.SyntaxError,a=Math.min,o=s("".match);u.exports=function(l,c){var h=l.length;if(h%2!==0)throw new n("String should be an even number of characters");for(var d=c?a(c.length,h/2):h/2,f=c||new i(d),g=o(l,/[\S\s]{2}/g),m=0;m<d;m++){var v=+("0x"+g[m]+"0");if(v!==v)throw new n("String should only contain hex characters");f[m]=v>>4}return{bytes:f,read:m<<1}}}),l0=P.cw(function(u,t){var e=le(),s=Ni(),i=hs(),n=xs(),a=s("iterator");u.exports=!e(function(){var o=new URL("b?a=1&b=2&c=3","https://a"),l=o.searchParams,c=new URLSearchParams("a=1&a=2&b=3"),h="";return o.pathname="c%20d",l.forEach(function(d,f){l.delete("b"),h+=f+d}),c.delete("a",2),c.delete("b",void 0),n&&(!o.toJSON||!c.has("a",1)||c.has("a",2)||!c.has("a",void 0)||c.has("b"))||!l.size&&(n||!i)||!l.sort||o.href!=="https://a/c%20d?a=1&c=3"||l.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!l[a]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||h!=="a1c3"||new URL("https://x",void 0).host!=="x"})}),Sb=P.cw(function(u,t){var e=tg();u.exports=e&&!Symbol.sham&&typeof Symbol.iterator=="symbol"}),Eb=P.cw(function(u,t){var e=hs(),s=le();u.exports=e&&s(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})}),c0=()=>P(812),h0=P.cw(function(u,t){var e=Bt(),s=Se(),i=e.WeakMap;u.exports=s(i)&&/native code/.test(String(i))}),ng=P.cw(function(u,t){var e=Nt(),s=WeakMap.prototype;u.exports={WeakMap,set:e(s.set),get:e(s.get),has:e(s.has),remove:e(s.delete)}}),Ni=P.cw(function(u,t){var e=Bt(),s=yb(),i=us(),n=rg(),a=tg(),o=Sb(),l=e.Symbol,c=s("wks"),h=o?l.for||l:l&&l.withoutSetter||n;u.exports=function(d){return i(c,d)||(c[d]=a&&i(l,d)?l[d]:h("Symbol."+d)),c[d]}}),u0=P.cw(function(u,t){var e=pt(),s=Iv().includes,i=le(),n=r_(),a=i(function(){return!Array(1).includes()}),o=i(function(){return[,1].includes(void 0,1)});e({target:"Array",proto:!0,forced:a||o},{includes:function(c){return s(this,c,arguments.length>1?arguments[1]:void 0)}}),n("includes")}),d0=P.cw(function(u,t){var e=pt(),s=Gv(),i=Sh(),n=c_(),a=g_(),o=le(),l=o(function(){return[].push.call({length:4294967296},1)!==4294967297}),c=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(d){return d instanceof TypeError}},h=l||!c();e({target:"Array",proto:!0,arity:1,forced:h},{push:function(f){var g=s(this),m=i(g),v=arguments.length;a(m+v);for(var w=0;w<v;w++)g[m]=arguments[w],m++;return n(g,m),m}})}),f0=P.cw(function(u,t){var e=pt(),s=Bt(),i=Jy(),n=ae(),a=Se(),o=Bv(),l=sb(),c=kv(),h=le(),d=us(),f=Ni(),g=ob().IteratorPrototype,m=hs(),v=xs(),w="constructor",A="Iterator",_=f("toStringTag"),E=TypeError,S=s[A],x=v||!a(S)||S.prototype!==g||!h(function(){S({})}),T=function(){if(i(this,g),o(this)===g)throw new E("Abstract class Iterator not directly constructable")},C=function(I,k){m?l(g,I,{configurable:!0,get:function(){return k},set:function(M){if(n(this),this===g)throw new E("You can't redefine this property");d(this,I)?this[I]=M:c(this,I,M)}}):g[I]=k};d(g,_)||C(_,A),(x||!d(g,w)||g[w]===Object)&&C(w,T),T.prototype=g,e({global:!0,constructor:!0,forced:x},{Iterator:T})}),p0=P.cw(function(u,t){var e=pt(),s=ce(),i=ae(),n=gi(),a=ub(),o=bb(),l=fs(),c=sf(),h=rf(),d=yn(),f=xs(),g=RangeError,m=1/0,v=!f&&!h("drop",0),w=!f&&!v&&d("drop",RangeError),A=f||v||w||!(function(){try{Iterator.prototype.drop.call({next:function(){return{done:!0}}},9007199254740992)}catch(E){return E instanceof g}})(),_=c(function(){for(var E=this.iterator,S=this.next,x,T;this.remaining;)if(this.remaining--,x=i(s(S,E)),T=this.done=!!x.done,T)return;if(x=i(s(S,E)),T=this.done=!!x.done,!T)return x.value});e({target:"Iterator",proto:!0,real:!0,forced:A},{drop:function(S){i(this);var x;try{if(x=o(a(+S)),x>9007199254740991&&x!==m)throw new g("The argument should be a safe integer")}catch(T){l(this,"throw",T)}return w?s(w,this,x):new _(n(this),{remaining:x})}})}),g0=P.cw(function(u,t){var e=pt(),s=ce(),i=_h(),n=cs(),a=ae(),o=gi(),l=fs(),c=yn(),h=c("every",TypeError);e({target:"Iterator",proto:!0,real:!0,forced:h},{every:function(f){a(this);try{n(f)}catch(v){l(this,"throw",v)}if(h)return s(h,this,f);var g=o(this),m=0;return!i(g,function(v,w){if(!f(v,m++))return w()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),m0=P.cw(function(u,t){var e=pt(),s=ce(),i=cs(),n=ae(),a=gi(),o=sf(),l=eb(),c=xs(),h=fs(),d=rf(),f=yn(),g=!c&&!d("filter",function(){}),m=!c&&!g&&f("filter",TypeError),v=c||g||m,w=o(function(){for(var A=this.iterator,_=this.predicate,E=this.next,S,x,T;;){if(S=n(s(E,A)),x=this.done=!!S.done,x)return;if(T=S.value,l(A,_,[T,this.counter++],!0))return T}});e({target:"Iterator",proto:!0,real:!0,forced:v},{filter:function(_){n(this);try{i(_)}catch(E){h(this,"throw",E)}return m?s(m,this,_):new w(a(this),{predicate:_})}})}),v0=P.cw(function(u,t){var e=pt(),s=ce(),i=_h(),n=cs(),a=ae(),o=gi(),l=fs(),c=yn(),h=c("find",TypeError);e({target:"Iterator",proto:!0,real:!0,forced:h},{find:function(f){a(this);try{n(f)}catch(v){l(this,"throw",v)}if(h)return s(h,this,f);var g=o(this),m=0;return i(g,function(v,w){if(f(v,m++))return w(v)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})}),y0=P.cw(function(u,t){var e=pt(),s=ce(),i=cs(),n=ae(),a=gi(),o=E_(),l=sf(),c=fs(),h=le(),d=xs(),f=rf(),g=yn(),m=!d&&h(function(){return[1].values().flatMap(function(){return[1]}).find(function(){return!0})!==1}),v=!d&&!m&&!f("flatMap",function(){}),w=!d&&!m&&!v&&g("flatMap",TypeError),A=d||m||v||w,_=l(function(){for(var E=this.iterator,S=this.mapper,x,T;;){if(T=this.inner)try{if(x=n(s(T.next,T.iterator)),!x.done)return x.value;this.inner=null}catch(C){c(E,"throw",C)}if(x=n(s(this.next,E)),this.done=!!x.done)return;try{this.inner=o(S(x.value,this.counter++),!1)}catch(C){c(E,"throw",C)}}});e({target:"Iterator",proto:!0,real:!0,forced:A},{flatMap:function(S){n(this);try{i(S)}catch(x){c(this,"throw",x)}return w?s(w,this,S):new _(a(this),{mapper:S,inner:null})}})}),b0=P.cw(function(u,t){var e=pt(),s=ce(),i=_h(),n=cs(),a=ae(),o=gi(),l=fs(),c=yn(),h=c("forEach",TypeError);e({target:"Iterator",proto:!0,real:!0,forced:h},{forEach:function(f){a(this);try{n(f)}catch(v){l(this,"throw",v)}if(h)return s(h,this,f);var g=o(this),m=0;i(g,function(v){f(v,m++)},{IS_RECORD:!0})}})}),w0=P.cw(function(u,t){var e=pt(),s=ce(),i=cs(),n=ae(),a=gi(),o=sf(),l=eb(),c=fs(),h=rf(),d=yn(),f=xs(),g=!f&&!h("map",function(){}),m=!f&&!g&&d("map",TypeError),v=f||g||m,w=o(function(){var A=this.iterator,_=n(s(this.next,A)),E=this.done=!!_.done;if(!E)return l(A,this.mapper,[_.value,this.counter++],!0)});e({target:"Iterator",proto:!0,real:!0,forced:v},{map:function(_){n(this);try{i(_)}catch(E){c(this,"throw",E)}return m?s(m,this,_):new w(a(this),{mapper:_})}})}),A0=P.cw(function(u,t){var e=pt(),s=ce(),i=_h(),n=cs(),a=ae(),o=gi(),l=fs(),c=yn(),h=c("some",TypeError);e({target:"Iterator",proto:!0,real:!0,forced:h},{some:function(f){a(this);try{n(f)}catch(v){l(this,"throw",v)}if(h)return s(h,this,f);var g=o(this),m=0;return i(g,function(v,w){if(f(v,m++))return w()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),_0=P.cw(function(u,t){var e=pt(),s=ce(),i=ae(),n=gi(),a=ub(),o=bb(),l=sf(),c=fs(),h=rf(),d=yn(),f=xs(),g=RangeError,m=1/0,v=!f&&!h("take",1),w=!f&&!v&&d("take",RangeError),A=f||v||w||!(function(){try{Iterator.prototype.take.call({next:function(){return{done:!0}}},9007199254740992)}catch(E){return E instanceof g}})(),_=l(function(){var E=this.iterator;if(!this.remaining--)return this.done=!0,c(E,"normal",void 0);var S=i(s(this.next,E)),x=this.done=!!S.done;if(!x)return S.value});e({target:"Iterator",proto:!0,real:!0,forced:A},{take:function(S){i(this);var x;try{if(x=o(a(+S)),x>9007199254740991&&x!==m)throw new g("The argument should be a safe integer")}catch(T){c(this,"throw",T)}return w?s(w,this,x):new _(n(this),{remaining:x})}})}),S0=P.cw(function(u,t){var e=pt(),s=ae(),i=kv(),n=_h(),a=gi();e({target:"Iterator",proto:!0,real:!0},{toArray:function(){var l=[],c=0;return n(a(s(this)),function(h){i(l,c++,h)},{IS_RECORD:!0}),l}})}),E0=P.cw(function(u,t){var e=pt(),s=hs(),i=Bt(),n=Pa(),a=Nt(),o=ce(),l=Se(),c=ds(),h=Lv(),d=us(),f=sg(),g=Sh(),m=kv(),v=le(),w=gb(),A=tg(),_=i.JSON,E=i.Number,S=i.SyntaxError,x=_&&_.parse,T=n("Object","keys"),C=Object.getOwnPropertyDescriptor,I=a("".charAt),k=a("".slice),M=a(/./.exec),R=a([].push),N=/^\d$/,F=/^[1-9]$/,j=/^[\d-]$/,U=/^[\t\n\r ]$/,D=0,H=1,X=function(G,L){G=f(G);var B=new ht(G,0),it=B.parse(),bt=it.value,tt=B.skip(U,it.end);if(tt<G.length)throw new S('Unexpected extra character: "'+I(G,tt)+'" after the parsed data at: '+tt);return l(L)?nt({"":bt},"",L,it):bt},nt=function(G,L,B,it){var bt=G[L],tt=it&&bt===it.value,ut=tt&&typeof it.source=="string"?{source:it.source}:{},xt,xe,ve,he,mi;if(c(bt)){var Th=h(bt),Il=tt?it.nodes:Th?[]:{};if(Th)for(xt=Il.length,ve=g(bt),he=0;he<ve;he++)gt(bt,he,nt(bt,""+he,B,he<xt?Il[he]:void 0));else for(xe=T(bt),ve=g(xe),he=0;he<ve;he++)mi=xe[he],gt(bt,mi,nt(bt,mi,B,d(Il,mi)?Il[mi]:void 0))}return o(B,G,L,bt,ut)},gt=function(G,L,B){if(s){var it=C(G,L);if(it&&!it.configurable)return}B===void 0?delete G[L]:m(G,L,B)},mt=function(G,L,B,it){this.value=G,this.end=L,this.source=B,this.nodes=it},ht=function(G,L){this.source=G,this.index=L};ht.prototype={fork:function(G){return new ht(this.source,G)},parse:function(){var G=this.source,L=this.skip(U,this.index),B=this.fork(L),it=I(G,L);if(M(j,it))return B.number();switch(it){case"{":return B.object();case"[":return B.array();case'"':return B.string();case"t":return B.keyword(!0);case"f":return B.keyword(!1);case"n":return B.keyword(null)}throw new S('Unexpected character: "'+it+'" at: '+L)},node:function(G,L,B,it,bt){return new mt(L,it,G?null:k(this.source,B,it),bt)},object:function(){for(var G=this.source,L=this.index+1,B=!1,it={},bt={},tt=!1;L<G.length;){if(L=this.until(['"',"}"],L),I(G,L)==="}"&&!B){L++,tt=!0;break}var ut=this.fork(L).string(),xt=ut.value;L=ut.end,L=this.until([":"],L)+1,L=this.skip(U,L),ut=this.fork(L).parse(),m(bt,xt,ut),m(it,xt,ut.value),L=this.until([",","}"],ut.end);var xe=I(G,L);if(xe===",")B=!0,L++;else if(xe==="}"){L++,tt=!0;break}}if(!tt)throw new S("Unterminated object at: "+L);return this.node(H,it,this.index,L,bt)},array:function(){for(var G=this.source,L=this.index+1,B=!1,it=[],bt=[],tt=!1;L<G.length;){if(L=this.skip(U,L),I(G,L)==="]"&&!B){L++,tt=!0;break}var ut=this.fork(L).parse();if(R(bt,ut),R(it,ut.value),L=this.until([",","]"],ut.end),I(G,L)===",")B=!0,L++;else if(I(G,L)==="]"){L++,tt=!0;break}}if(!tt)throw new S("Unterminated array at: "+L);return this.node(H,it,this.index,L,bt)},string:function(){var G=this.index,L=w(this.source,this.index+1);return this.node(D,L.value,G,L.end)},number:function(){var G=this.source,L=this.index,B=L;if(I(G,B)==="-"&&B++,I(G,B)==="0")B++;else if(M(F,I(G,B)))B=this.skip(N,B+1);else throw new S("Failed to parse number at: "+B);if(I(G,B)==="."){var it=B+1;if(B=this.skip(N,it),it===B)throw new S("Failed to parse number's fraction at: "+B)}if(I(G,B)==="e"||I(G,B)==="E"){B++,(I(G,B)==="+"||I(G,B)==="-")&&B++;var bt=B;if(B=this.skip(N,B),bt===B)throw new S("Failed to parse number's exponent value at: "+B)}return this.node(D,E(k(G,L,B)),L,B)},keyword:function(G){var L=""+G,B=this.index,it=B+L.length;if(k(this.source,B,it)!==L)throw new S("Failed to parse value at: "+B);return this.node(D,G,B,it)},skip:function(G,L){for(var B=this.source;L<B.length&&M(G,I(B,L));L++);return L},until:function(G,L){L=this.skip(U,L);for(var B=I(this.source,L),it=0;it<G.length;it++)if(G[it]===B)return L;throw new S('Unexpected character: "'+B+'" at: '+L)}};var at=v(function(){var G="9007199254740993",L;return x(G,function(B,it,bt){L=bt.source}),L!==G}),Ee=A&&!v(function(){return 1/x("-0 ")!==-1/0});e({target:"JSON",stat:!0,forced:at},{parse:function(L,B){return Ee&&!l(B)?x(L):X(L,B)}})}),x0=P.cw(function(u,t){var e=pt(),s=Pa(),i=ce(),n=Nt(),a=le(),o=Lv(),l=Se(),c=ds(),h=Qp(),d=D_(),f=Nv(),g=Sl(),m=s0(),v=Iv().includes,w=us(),A=sg(),_=gb(),E=rg(),S=tg(),x=B_(),T=String,C=TypeError,I=s("JSON","stringify"),k=s("BigInt"),M=n("".valueOf),R=n((!0).valueOf),N=k&&n(k.prototype.valueOf),F=n(/./.exec),j=n("".charAt),U=n("".charCodeAt),D=n("".replace),H=n("".slice),X=n([].push),nt=n([].pop),gt=n(1.1.toString),mt=/[\uD800-\uDFFF]/g,ht=/^[\uD800-\uDBFF]$/,at=/^[\uDC00-\uDFFF]$/,Ee=/^\d+$/,G=E(),L=E(),B=E(),it=G.length,bt=L.length,tt=!S||a(function(){var ft=s("Symbol")("stringify detection");return I([ft])!=="[null]"||I({a:ft})!=="{}"||I(Object(ft))!=="{}"}),ut=a(function(){return I("\uDF06\uD834")!=='"\\udf06\\ud834"'||I("\uDEAD")!=='"\\udead"'}),xt=x?s("JSON","isRawJSON"):d,xe=tt?function(ft,Dt,Yt){return I(ft,function(qe,Je){var Te=i(Dt,this,qe,Je);if(!f(Te))return Te},Yt)}:I,ve=function(ft,Dt,Yt){var qe=j(Yt,Dt-1),Je=j(Yt,Dt+1);return F(ht,ft)&&!F(at,Je)||F(at,ft)&&!F(ht,qe)?"\\u"+gt(U(ft,0),16):ft},he=function(ft){if(o(ft)){for(var Dt=ft.length,Yt=[],qe=h(null),Je=0;Je<Dt;Je++){var Te=ft[Je],vi;if(typeof Te=="string")vi=Te;else if(typeof Te=="number"||g(Te)==="Number"||g(Te)==="String")vi=A(Te);else continue;w(qe,vi)||(qe[vi]=!0,X(Yt,vi))}return Yt}},mi=function(ft,Dt){try{return ft(Dt),!0}catch{return!1}},Th=function(ft){var Dt=g(ft);return Dt==="Number"&&mi(m,ft)||Dt==="String"&&mi(M,ft)||Dt==="Boolean"&&mi(R,ft)||!!N&&Dt==="BigInt"&&mi(N,ft)},Il=function(ft){if(!c(ft)||l(ft)||o(ft))return!1;try{return!Th(ft)}catch{return!0}},YA=function(ft,Dt){return{toJSON:function(){var Yt=ft[Dt];if(c(Yt)||typeof Yt=="bigint"){var qe=Yt.toJSON;l(qe)&&(Yt=i(qe,Yt,Dt))}return Yt}}},KA=function(ft){for(var Dt=0,Yt=ft.length;Dt<Yt;Dt++)if(F(Ee,ft[Dt]))return L;return""},qA=function(ft,Dt,Yt){for(var qe=h(null),Je=0,Te=Dt.length;Je<Te;Je++){var vi=Dt[Je];qe[Yt+vi]=YA(ft,vi)}return qe[B]=null,qe};I&&e({target:"JSON",stat:!0,arity:3,forced:tt||ut||!x},{stringify:function(Dt,Yt,qe){var Je=l(Yt)?Yt:void 0,Te=Je?void 0:he(Yt),vi=Te&&KA(Te),hy=[],wg=[],uy=[],hf,Ag=!1,dy=!0,Sr=xe(Dt,function(Ih,Bi){if(Ih=T(Ih),Te){if(Ih===B){nt(wg),hf=nt(uy);return}if(dy)dy=!1;else if(this!==hf&&!o(this)&&!v(Te,Ih))return}else Je&&(Bi=i(Je,this,Ih,Bi));if(xt(Bi))return x?Bi:(Ag=!0,G+(X(hy,Bi.rawJSON)-1));if(Te&&Il(Bi)){if(v(wg,Bi))throw new C("Converting circular structure to JSON");var gy=qA(Bi,Te,vi);return X(wg,Bi),X(uy,hf),hf=gy,vi&&(Ag=!0),gy}return Bi},qe);if(typeof Sr!="string"||(ut&&(Sr=D(Sr,mt,ve)),!Ag))return Sr;for(var Ch="",JA=Sr.length,kl=0;kl<JA;kl++){var fy=j(Sr,kl);if(fy==='"'){var py=_(Sr,++kl).end-1,Ph=H(Sr,kl,py);H(Ph,0,it)===G?Ch+=hy[H(Ph,it)]:H(Ph,0,bt)===L?Ch+='"'+H(Ph,bt)+'"':Ch+='"'+Ph+'"',kl=py}else Ch+=fy}return Ch}})}),T0=P.cw(function(u,t){var e=pt(),s=cs(),i=cb(),n=xs(),a=i.get,o=i.has,l=i.set;e({target:"Map",proto:!0,real:!0,forced:n},{getOrInsertComputed:function(h,d){var f=o(this,h);if(s(d),f)return a(this,h);h===0&&1/h===-1/0&&(h=0);var g=d(h);return l(this,h,g),g}})}),C0=P.cw(function(u,t){var e=pt(),s=cb(),i=xs(),n=s.get,a=s.has,o=s.set;e({target:"Map",proto:!0,real:!0,forced:i},{getOrInsert:function(c,h){return a(this,c)?n(this,c):(o(this,c,h),h)}})}),P0=P.cw(function(u,t){var e=pt(),s=Nt(),i=_h(),n=RangeError,a=TypeError,o=1/0,l=NaN,c=Math.abs,h=Math.pow,d=s([].push),f=h(2,1023),g=h(2,53)-1,m=Number.MAX_VALUE,v=h(2,971),w={},A={},_={},E={},S={},x=function(T,C){var I=T+C,k=C-(I-T);return{hi:I,lo:k}};e({target:"Math",stat:!0},{sumPrecise:function(C){var I=[],k=0,M=E;switch(i(C,function(G){if(++k>g)throw new n("Maximum allowed index exceeded");if(typeof G!="number")throw new a("Value is not a number");M!==w&&(G!==G?M=w:G===o?M=M===A?w:_:G===-o?M=M===_?w:A:(G!==0||1/G===o)&&(M===E||M===S)&&(M=S,d(I,G)))}),M){case w:return l;case A:return-o;case _:return o;case E:return-0}for(var R=[],N=0,F,j,U,D,H,X,nt=0;nt<I.length;nt++){F=I[nt];for(var gt=0,mt=0;mt<R.length;mt++){if(j=R[mt],c(F)<c(j)&&(X=F,F=j,j=X),U=x(F,j),D=U.hi,H=U.lo,c(D)===o){var ht=D===o?1:-1;N+=ht,F=F-ht*f-ht*f,c(F)<c(j)&&(X=F,F=j,j=X),U=x(F,j),D=U.hi,H=U.lo}H!==0&&(R[gt++]=H),F=D}R.length=gt,F!==0&&d(R,F)}var at=R.length-1;if(D=0,H=0,N!==0){var Ee=at>=0?R[at]:0;if(at--,c(N)>1||N>0&&Ee>0||N<0&&Ee<0)return N>0?o:-o;if(U=x(N*f,Ee/2),D=U.hi,H=U.lo,H*=2,c(2*D)===o)return D>0?D===f&&H===-(v/2)&&at>=0&&R[at]<0?m:o:D===-f&&H===v/2&&at>=0&&R[at]>0?-m:-o;H!==0&&(R[++at]=H,H=0),D*=2}for(;at>=0&&(U=x(D,R[at--]),D=U.hi,H=U.lo,H===0););return at>=0&&(H<0&&R[at]<0||H>0&&R[at]>0)&&(j=H*2,F=D+j,j===F-D&&(D=F)),D}})}),I0=P.cw(function(u,t){var e=pt(),s=Bt(),i=w_(),n=h_(),a=Y_(),o=hb(),l=cs(),c=X_(),h=le(),d=s.Promise,f=!1,g=!d||!d.try||h(function(){var m=d.resolve();return d.try(function(v){return f=v===8,m},8)!==m})||!f;e({target:"Promise",stat:!0,forced:g},{try:function(m){var v=arguments.length>1?n(arguments,1):[],w=c(function(){return i(l(m),void 0,v)});if(!w.error)return a(this,w.value);var A=o.f(this),_=A.reject;return _(w.value),A.promise}})}),k0=P.cw(function(u,t){var e=pt(),s=K_(),i=le(),n=Tl(),a=!n("difference",function(l){return l.size===0}),o=a||i(function(){var l={size:1,has:function(){return!0},keys:function(){var h=0;return{next:function(){var d=h++>1;return c.has(1)&&c.clear(),{done:d,value:2}}}}},c=new Set([1,2,3,4]);return c.difference(l).size!==3});e({target:"Set",proto:!0,real:!0,forced:o},{difference:s})}),M0=P.cw(function(u,t){var e=pt(),s=le(),i=q_(),n=Tl(),a=!n("intersection",function(o){return o.size===2&&o.has(1)&&o.has(2)})||s(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});e({target:"Set",proto:!0,real:!0,forced:a},{intersection:i})}),O0=P.cw(function(u,t){var e=pt(),s=J_(),i=Tl(),n=!i("isDisjointFrom",function(a){return!a});e({target:"Set",proto:!0,real:!0,forced:n},{isDisjointFrom:s})}),R0=P.cw(function(u,t){var e=pt(),s=Q_(),i=Tl(),n=!i("isSubsetOf",function(a){return a});e({target:"Set",proto:!0,real:!0,forced:n},{isSubsetOf:s})}),D0=P.cw(function(u,t){var e=pt(),s=Z_(),i=Tl(),n=!i("isSupersetOf",function(a){return!a});e({target:"Set",proto:!0,real:!0,forced:n},{isSupersetOf:s})}),F0=P.cw(function(u,t){var e=pt(),s=t0(),i=vb(),n=Tl(),a=!n("symmetricDifference")||!i("symmetricDifference");e({target:"Set",proto:!0,real:!0,forced:a},{symmetricDifference:s})}),L0=P.cw(function(u,t){var e=pt(),s=e0(),i=vb(),n=Tl(),a=!n("union")||!i("union");e({target:"Set",proto:!0,real:!0,forced:a},{union:s})}),N0=P.cw(function(u,t){var e=o_(),s=M_(),i=Sh(),n=$v(),a=r0(),o=e.aTypedArray,l=e.getTypedArrayConstructor,c=e.exportTypedArrayMethod,h=RangeError,d=(function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(g){return g===8}})(),f=d&&(function(){try{new Int8Array(1).with(-.5,1)}catch{return!0}})();c("with",function(g,m){var v=o(this),w=i(v),A=n(g),_=A<0?w+A:A,E=s(v)?a(m):+m;if(_>=w||_<0)throw new h("Incorrect index");for(var S=new(l(v))(w),x=0;x<w;x++)S[x]=x===_?E:v[x];return S},!d||f)}),B0=P.cw(function(u,t){var e=pt(),s=Bt(),i=l_(),n=_b(),a=s.Uint8Array,o=!a||!a.fromBase64||!(function(){try{a.fromBase64("a");return}catch{}try{a.fromBase64("",null)}catch{return!0}})();a&&e({target:"Uint8Array",stat:!0,forced:o},{fromBase64:function(c){var h=n(c,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return i(a,h.bytes)}})}),U0=P.cw(function(u,t){var e=pt(),s=Bt(),i=_b(),n=Gp(),a=s.Uint8Array,o=!a||!a.prototype.setFromBase64||!(function(){var l=new a([255,255,255,255,255]);try{l.setFromBase64("",null);return}catch{}try{l.setFromBase64("a");return}catch{}try{l.setFromBase64("MjYyZg===")}catch{return l[0]===50&&l[1]===54&&l[2]===50&&l[3]===255&&l[4]===255}})();a&&e({target:"Uint8Array",proto:!0,forced:o},{setFromBase64:function(c){n(this);var h=i(c,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:h.read,written:h.written}}})}),H0=P.cw(function(u,t){var e=pt(),s=Bt(),i=qy(),n=Gp(),a=zp(),o=o0();function l(){try{var c=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(c).setFromHex("cafed00d")}catch{return!0}}s.Uint8Array&&e({target:"Uint8Array",proto:!0,forced:l()},{setFromHex:function(h){n(this),i(h),a(this.buffer);var d=o(h,this).read;return{read:d,written:d/2}}})}),j0=P.cw(function(u,t){var e=pt(),s=Bt(),i=Nt(),n=Qy(),a=Gp(),o=zp(),l=tb(),c=rb(),h=l.i2c,d=l.i2cUrl,f=Math.floor,g=Math.ceil,m=i("".charAt),v=s.Uint8Array,w=s.Array,A=i([].join),_=!v||!v.prototype.toBase64||!(function(){try{var E=new v;E.toBase64(null)}catch{return!0}})();v&&e({target:"Uint8Array",proto:!0,forced:_},{toBase64:function(){var S=a(this),x=arguments.length?n(arguments[0]):void 0,T=c(x)==="base64"?h:d,C=!!x&&!!x.omitPadding;o(this.buffer);for(var I=0,k=S.length,M=w(C?f(k/3)*4+(k%3?k%3+1:0):g(k/3)*4),R=0,N,F=function(j){return m(T,N>>6*j&63)};I+2<k;I+=3)N=(S[I]<<16)+(S[I+1]<<8)+S[I+2],M[R++]=F(3),M[R++]=F(2),M[R++]=F(1),M[R++]=F(0);return I+2===k?(N=(S[I]<<16)+(S[I+1]<<8),M[R++]=F(3),M[R++]=F(2),M[R++]=F(1),C||(M[R++]="=")):I+1===k&&(N=S[I]<<16,M[R++]=F(3),M[R++]=F(2),C||(M[R++]="=",M[R++]="=")),A(M,"")}})}),$0=P.cw(function(u,t){var e=pt(),s=Bt(),i=Nt(),n=Gp(),a=zp(),o=i(1.1.toString),l=i([].join),c=Array,h=s.Uint8Array,d=!h||!h.prototype.toHex||!(function(){try{var f=new h([255,255,255,255,255,255,255,255]);return f.toHex()==="ffffffffffffffff"}catch{return!1}})();h&&e({target:"Uint8Array",proto:!0,forced:d},{toHex:function(){n(this),a(this.buffer);for(var g=c(this.length),m=0,v=this.length;m<v;m++){var w=o(this[m],16);g[m]=w.length===1?"0"+w:w}return l(g,"")}})}),G0=P.cw(function(u,t){var e=pt(),s=cs(),i=i_(),n=s_(),a=ng(),o=xs(),l=a.get,c=a.has,h=a.set,d=o||!(function(){try{WeakMap.prototype.getOrInsertComputed&&new WeakMap().getOrInsertComputed(1,function(){throw 1})}catch(f){return f instanceof TypeError}})();e({target:"WeakMap",proto:!0,real:!0,forced:d},{getOrInsertComputed:function(g,m){if(o||i(this),n(g),s(m),c(this,g))return l(this,g);var v=m(g);return h(this,g,v),v}})}),z0=P.cw(function(u,t){var e=pt(),s=ng(),i=xs(),n=s.get,a=s.has,o=s.set;e({target:"WeakMap",proto:!0,real:!0,forced:i},{getOrInsert:function(c,h){return a(this,c)?n(this,c):(o(this,c,h),h)}})}),V0=P.cw(function(u,t){var e=pt(),s=Bt(),i=Pa(),n=Xp(),a=Ia().f,o=us(),l=Jy(),c=P_(),h=U_(),d=m_(),f=b_(),g=hs(),m=xs(),v="DOMException",w=i("Error"),A=i(v),_=function(){l(this,E);var U=arguments.length,D=h(U<1?void 0:arguments[0]),H=h(U<2?void 0:arguments[1],"Error"),X=new A(D,H),nt=new w(D);return nt.name=v,a(X,"stack",n(1,f(nt.stack,1))),c(X,this,_),X},E=_.prototype=A.prototype,S="stack"in new w(v),x="stack"in new A(1,2),T=A&&g&&Object.getOwnPropertyDescriptor(s,v),C=!!T&&!(T.writable&&T.configurable),I=S&&!C&&!x;e({global:!0,constructor:!0,forced:m||I},{DOMException:I?_:A});var k=i(v),M=k.prototype;if(M.constructor!==k){m||a(M,"constructor",n(1,k));for(var R in d)if(o(d,R)){var N=d[R],F=N.s;o(k,F)||a(k,F,n(6,N.c))}}}),W0=P.cw(function(u,t){var e=pt(),s=Pa(),i=c0(),n=sg(),a=l0(),o=s("URL");e({target:"URL",stat:!0,forced:!a},{parse:function(c){var h=i(arguments.length,1),d=n(c),f=h<2||arguments[1]===void 0?void 0:n(arguments[1]);try{return new o(d,f)}catch{return null}}})});u0();d0();f0();m0();C0();T0();k0();M0();O0();R0();D0();F0();L0();N0();U0();H0();j0();$0();W0();const Gs=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),yr=[1/0,1/0,-1/0,-1/0],Ha=new Float32Array(yr),kg=[.001,0,0,.001,0,0],ns="http://www.w3.org/2000/svg",$s={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},An={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Nl="pdfjs_internal_id_",yh="pdfjs_internal_editor_",rt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},dt={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},X0={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},ye={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},wf={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Kt={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,RICHMEDIA:27},Ol={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},ag={ERRORS:0,WARNINGS:1,INFOS:5},zi={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},kh={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},Y0={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let og=ag.WARNINGS;function K0(u){Number.isInteger(u)&&(og=u)}function q0(){return og}function lg(u){og>=ag.INFOS&&console.info(`Info: ${u}`)}function st(u){og>=ag.WARNINGS&&console.warn(`Warning: ${u}`)}function vt(u){throw new Error(u)}function ne(u,t){u||vt(t)}function J0(u){switch(u==null?void 0:u.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function xb(u,t=null,e=null){if(!u)return null;if(e&&typeof u=="string"){if(e.addDefaultProtocol&&u.startsWith("www.")){const i=u.match(/\./g);(i==null?void 0:i.length)>=2&&(u=`http://${u}`)}if(e.tryConvertEncoding)try{u=tS(u)}catch{}}const s=t?URL.parse(u,t):URL.parse(u);return J0(s)?s:null}function Tb(u,t,e=!1){const s=URL.parse(u);return s?(s.hash=t,s.href):e&&xb(u,"http://example.com")?u.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Mg(u){return u.substring(u.lastIndexOf("/")+1)}function V(u,t,e,s=!1){return Object.defineProperty(u,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Cl=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Og extends Cl{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Sg extends Cl{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Rg extends Cl{constructor(t){super(t,"InvalidPDFException")}}class ap extends Cl{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class Q0 extends Cl{constructor(t){super(t,"FormatError")}}class Ta extends Cl{constructor(t){super(t,"AbortException")}}function Z0(u){(typeof u!="object"||(u==null?void 0:u.length)===void 0)&&vt("Invalid argument for bytesToString");const t=u.length,e=8192;if(t<e)return String.fromCharCode.apply(null,u);const s=[];for(let i=0;i<t;i+=e){const n=Math.min(i+e,t),a=u.subarray(i,n);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function cg(u){typeof u!="string"&&vt("Invalid argument for stringToBytes");const t=u.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=u.charCodeAt(s)&255;return e}class Et{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return V(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return V(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return V(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return V(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return V(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return V(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),V(this,"isCanvasFilterSupported",(t==null?void 0:t.filter)!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return V(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",V(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return V(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}var fn,Af,Dg;class ${static get hexNums(){return V(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){const i=t[s],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],n=e[1],a=e[2],o=e[3],l=e[4],c=e[5];for(let h=0;h<6;h+=2){const d=t[s+h],f=t[s+h+1];t[s+h]=d*i+f*a+l,t[s+h+1]=d*n+f*o+c}}static applyInverseTransform(t,e){const s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){const i=e[0],n=e[1],a=e[2],o=e[3],l=e[4],c=e[5],h=t[0],d=t[1],f=t[2],g=t[3];let m=i*h+l,v=m,w=i*f+l,A=w,_=o*d+c,E=_,S=o*g+c,x=S;if(n!==0||a!==0){const T=n*h,C=n*f,I=a*d,k=a*g;m+=I,A+=I,w+=k,v+=k,_+=T,x+=T,S+=C,E+=C}s[0]=Math.min(s[0],m,w,v,A),s[1]=Math.min(s[1],_,S,E,x),s[2]=Math.max(s[2],m,w,v,A),s[3]=Math.max(s[3],_,S,E,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 s=t[0],i=t[1],n=t[2],a=t[3],o=s**2+i**2,l=s*n+i*a,c=n**2+a**2,h=(o+c)/2,d=Math.sqrt(h**2-(o*c-l**2));e[0]=Math.sqrt(h+d||1),e[1]=Math.sqrt(h-d||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[s,n,i,a]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static bezierBoundingBox(t,e,s,i,n,a,o,l,c){c[0]=Math.min(c[0],t,o),c[1]=Math.min(c[1],e,l),c[2]=Math.max(c[2],t,o),c[3]=Math.max(c[3],e,l),b(this,fn,Dg).call(this,t,s,n,o,e,i,a,l,3*(-t+3*(s-n)+o),6*(t-2*s+n),3*(s-t),c),b(this,fn,Dg).call(this,t,s,n,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),c)}}fn=new WeakSet,Af=function(t,e,s,i,n,a,o,l,c,h){if(c<=0||c>=1)return;const d=1-c,f=c*c,g=f*c,m=d*(d*(d*t+3*c*e)+3*f*s)+g*i,v=d*(d*(d*n+3*c*a)+3*f*o)+g*l;h[0]=Math.min(h[0],m),h[1]=Math.min(h[1],v),h[2]=Math.max(h[2],m),h[3]=Math.max(h[3],v)},Dg=function(t,e,s,i,n,a,o,l,c,h,d,f){if(Math.abs(c)<1e-12){Math.abs(h)>=1e-12&&b(this,fn,Af).call(this,t,e,s,i,n,a,o,l,-d/h,f);return}const g=h**2-4*d*c;if(g<0)return;const m=Math.sqrt(g),v=2*c;b(this,fn,Af).call(this,t,e,s,i,n,a,o,l,(-h+m)/v,f),b(this,fn,Af).call(this,t,e,s,i,n,a,o,l,(-h-m)/v,f)},y($,fn);function tS(u){return decodeURIComponent(escape(u))}let Eg=null,yy=null;function eS(u){return Eg||(Eg=/([\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,yy=new Map([["ſt","ſt"]])),u.replaceAll(Eg,(t,e,s)=>e?e.normalize("NFKC"):yy.get(s))}function Cb(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const u=new Uint8Array(32);return crypto.getRandomValues(u),Z0(u)}function sS(u,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...n]=e;if(!u(s)&&!Number.isInteger(s)||!t(i))return!1;const a=n.length;let o=!0;switch(i.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of n)if(!(typeof l=="number"||o&&l===null))return!1;return!0}const Eh=()=>[],zv=()=>new Map,Fg=()=>Object.create(null),iS=()=>new Set;typeof Blob.prototype.bytes!="function"&&(Blob.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())});typeof Response.prototype.bytes!="function"&&(Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())});typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(u){return[...this].join(u)});w0();function jt(u,t,e){return Math.min(Math.max(u,t),e)}class of{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,c=(t[3]+t[1])/2;let h,d,f,g;switch(i%=360,i<0&&(i+=360),i){case 180:h=-1,d=0,f=0,g=1;break;case 90:h=0,d=1,f=1,g=0;break;case 270:h=0,d=-1,f=-1,g=0;break;case 0:h=1,d=0,f=0,g=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(f=-f,g=-g);let m,v,w,A;h===0?(m=Math.abs(c-t[1])*s+n,v=Math.abs(l-t[0])*s+a,w=(t[3]-t[1])*s,A=(t[2]-t[0])*s):(m=Math.abs(l-t[0])*s+n,v=Math.abs(c-t[1])*s+a,w=(t[2]-t[0])*s,A=(t[3]-t[1])*s),this.transform=[h*s,d*s,f*s,g*s,m-h*s*l-f*s*c,v-d*s*l-g*s*c],this.width=w,this.height=A}get rawDims(){const t=this.viewBox;return V(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:n=!1}={}){return new of({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){const s=[t,e];return $.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return $.applyInverseTransform(s,this.transform),s}}class au{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){var l;if(!n)return;let a=null;const o=n.name;if(o==="#text")a=n.value;else if(au.shouldBuildText(o))(l=n==null?void 0:n.attributes)!=null&&l.textContent?a=n.attributes.textContent:n.value&&(a=n.value);else return;if(a!==null&&e.push({str:a}),!!n.children)for(const c of n.children)i(c)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const rS=/url\(|image-set\(/i,nS=/^on/i;var du,Lg;class Vv{static get _allowedHtmlElements(){return V(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return V(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return V(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return V(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return V(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,n){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),n==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),n==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),n==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:Object.hasOwn(o.attributes,"selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:c})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,c]of Object.entries(a))if(!(c==null||nS.test(l))&&!(i==="richText"&&!this._allowedRichTextAttributes.has(l)))switch(l){case"class":c.length&&t.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":if(i==="richText"){const h=this._allowedRichTextStyles;for(const[d,f]of Object.entries(c))h.has(d)&&!rS.test(f)&&(t.style[d]=f)}else Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,c)}o&&(n==null||n.addLinkAttributes(t,a.href,a.newWindow)),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var d,f,g;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",a=b(this,du,Lg).call(this,i.name,(d=i.attributes)==null?void 0:d.xmlns,n)??document.createElement("div");i.attributes&&this.setAttributes({html:a,element:i,intent:n,linkService:s});const o=n!=="richText",l=t.div;if(l.append(a),t.viewport){const m=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=m}o&&l.setAttribute("class","xfaLayer xfaFont");const c=[];if(i.children.length===0){if(i.value){const m=document.createTextNode(i.value);a.append(m),o&&au.shouldBuildText(i.name)&&c.push(m)}return{textDivs:c}}const h=[[i,-1,a]];for(;h.length>0;){const[m,v,w]=h.at(-1);if(v+1===m.children.length){h.pop();continue}const A=m.children[++h.at(-1)[1]];if(A===null)continue;const{name:_}=A;if(_==="#text"){const S=document.createTextNode(A.value);c.push(S),w.append(S);continue}const E=b(this,du,Lg).call(this,_,(f=A.attributes)==null?void 0:f.xmlns,n);if(E){if(w.append(E),A.attributes&&this.setAttributes({html:E,element:A,storage:e,intent:n,linkService:s}),((g=A.children)==null?void 0:g.length)>0)h.push([A,-1,E]);else if(A.value){const S=document.createTextNode(A.value);o&&au.shouldBuildText(_)&&c.push(S),E.append(S)}}}for(const m of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))m.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:n}=t.attributes.style;return new of({viewBox:[0,0,parseInt(i,10),parseInt(n,10)],userUnit:1,scale:e,rotation:s})}}du=new WeakSet,Lg=function(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===ns&&this._allowedSvgElements.has(t)?document.createElementNS(ns,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null},y(Vv,du);const La=class La{};O(La,"CSS",96),O(La,"PDF",72),O(La,"PDF_TO_CSS_UNITS",La.CSS/La.PDF);let Ca=La;async function Wv(u,t="text"){if(tu(u,document.baseURI)){const e=await fetch(u);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",u,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class Xv extends Cl{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function hg(u){const t=u.length;let e=0;for(;e<t&&u[e].trim()==="";)e++;return u.substring(e,e+5).toLowerCase()==="data:"}function Yv(u){return typeof u=="string"&&/\.pdf$/i.test(u)}function aS(u){return[u]=u.split(/[#?]/,1),Mg(u)}function oS(u,t="document.pdf"){if(typeof u!="string")return t;if(hg(u))return st('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(o=>{try{return new URL(o)}catch{}try{return new URL(decodeURIComponent(o))}catch{}try{return new URL(o,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{}return null})(u);if(!s)return t;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=Mg(l),l.length===4&&n.test(l))?o:l}catch{return o}},n=/\.pdf$/i,a=Mg(s.pathname);if(n.test(a))return i(a);if(s.searchParams.size>0){const o=c=>[...c].findLast(h=>n.test(h)),l=o(s.searchParams.values())??o(s.searchParams.keys());if(l)return i(l)}if(s.hash){const{hash:o}=s;let l=-1;for(const{index:c}of o.matchAll(/\.pdf\b/gi))l=c;if(l>0){let c=l;for(;c>0&&!"/?#=".includes(o[c-1]);)c--;if(c<l)return i(o.slice(c,l+4))}}return t}var _n;class by{constructor(){y(this,_n,new Map);O(this,"times",[])}time(t){r(this,_n).has(t)&&st(`Timer is already running for ${t}`),r(this,_n).set(t,Date.now())}timeEnd(t){r(this,_n).has(t)||st(`Timer has not been started for ${t}`),this.times.push({name:t,start:r(this,_n).get(t),end:Date.now()}),r(this,_n).delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
4
+ `).join("")}}_n=new WeakMap;function tu(u,t){const e=t?URL.parse(u,t):URL.parse(u);return/https?:/.test((e==null?void 0:e.protocol)??"")}function Li(u){u.preventDefault()}function Ae(u){u.preventDefault(),u.stopPropagation()}var fu;class op{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;r(this,fu)||p(this,fu,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?"));const e=r(this,fu).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const c=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,c==="-"?(a+=h,o+=d):c==="+"&&(a-=h,o-=d),new Date(Date.UTC(s,i,n,a,o,l))}}fu=new WeakMap,y(op,fu);function xh(u){if(u.startsWith("#")){const e=u.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(u.startsWith("rgb(")){const[e,s,i]=u.slice(4,-1).split(",").map(n=>parseInt(n,10));return[e,s,i,1]}if(u.startsWith("rgba(")){const e=u.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=u.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function lf(u){const t=xh(u);return t?t.slice(0,3):(st(`Not a valid color format: "${u}"`),[0,0,0])}function lS(u){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of u.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;u.set(e,lf(s))}t.remove()}function Ot(u){const{a:t,b:e,c:s,d:i,e:n,f:a}=u.getTransform();return[t,e,s,i,n,a]}function Ui(u){const{a:t,b:e,c:s,d:i,e:n,f:a}=u.getTransform().invertSelf();return[t,e,s,i,n,a]}function vl(u,t,e=!1,s=!0){if(t instanceof of){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:a}=u,o=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${n}px, var(--scale-round-y))`;!e||t.rotation%180===0?(a.width=o,a.height=l):(a.width=l,a.height=o)}s&&u.setAttribute("data-main-rotation",t.rotation)}class fi{constructor(){const{pixelRatio:t}=fi;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,n=-1){let a=1/0,o=1/0,l=1/0;s=fi.capPixels(s,n),s>0&&(a=Math.sqrt(s/(t*e))),i!==-1&&(o=i/t,l=i/e);const c=Math.min(a,o,l);return this.sx>c||this.sy>c?(this.sx=c,this.sy=c,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const Ng=new Set(["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"]);class cS{static get isDarkMode(){var t;return V(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class hS{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:s}=window.getComputedStyle(t);return t.remove(),V(this,"commentForegroundColor",lf(s))}}function uS(u,t){t=jt(t??1,0,1);const e=255*(1-t);return u.map(s=>Math.round(s*t+e))}function wy(u,t){const e=u[0]/255,s=u[1]/255,i=u[2]/255,n=Math.max(e,s,i),a=Math.min(e,s,i),o=(n+a)/2;if(n===a)t[0]=t[1]=0;else{const l=n-a;switch(t[1]=o<.5?l/(n+a):l/(2-n-a),n){case e:t[0]=((s-i)/l+(s<i?6:0))*60;break;case s:t[0]=((i-e)/l+2)*60;break;case i:t[0]=((e-s)/l+4)*60;break}}t[2]=o}function Bg(u,t){const e=u[0],s=u[1],i=u[2],n=(1-Math.abs(2*i-1))*s,a=n*(1-Math.abs(e/60%2-1)),o=i-n/2;switch(Math.floor(e/60)){case 0:t[0]=n+o,t[1]=a+o,t[2]=o;break;case 1:t[0]=a+o,t[1]=n+o,t[2]=o;break;case 2:t[0]=o,t[1]=n+o,t[2]=a+o;break;case 3:t[0]=o,t[1]=a+o,t[2]=n+o;break;case 4:t[0]=a+o,t[1]=o,t[2]=n+o;break;case 5:case 6:t[0]=n+o,t[1]=o,t[2]=a+o;break}}function Ug(u){return u<=.03928?u/12.92:((u+.055)/1.055)**2.4}function Ay(u,t,e){Bg(u,e),e.map(Ug);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];Bg(t,e),e.map(Ug);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const _y=new Map;function dS(u,t){const e=u[0]+u[1]*256+u[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=_y.get(e);if(s)return s;const i=new Float32Array(9),n=i.subarray(0,3),a=i.subarray(3,6);wy(u,a);const o=i.subarray(6,9);wy(t,o);const l=o[2]<.5,c=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),Ay(a,o,n)<c){let h,d;l?(h=a[2],d=1):(h=0,d=a[2]);const f=.005;for(;d-h>f;){const g=a[2]=(h+d)/2;l===Ay(a,o,n)<c?h=g:d=g}a[2]=l?d:h}return Bg(a,n),s=$.makeHexColor(Math.round(n[0]*255),Math.round(n[1]*255),Math.round(n[2]*255)),_y.set(e,s),s}function Pb({html:u,dir:t,className:e},s){const i=document.createDocumentFragment();if(typeof u=="string"){const n=document.createElement("p");n.dir=t||"auto";const a=u.split(/\r\n?|\n/);for(let o=0,l=a.length;o<l;++o){const c=a[o];n.append(document.createTextNode(c)),o<l-1&&n.append(document.createElement("br"))}i.append(n)}else Vv.render({xfaHtml:u,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}function Ib(u){const t=new Path2D;if(!u)return t;for(let e=0,s=u.length;e<s;)switch(u[e++]){case kh.moveTo:t.moveTo(u[e++],u[e++]);break;case kh.lineTo:t.lineTo(u[e++],u[e++]);break;case kh.curveTo:t.bezierCurveTo(u[e++],u[e++],u[e++],u[e++],u[e++],u[e++]);break;case kh.quadraticCurveTo:t.quadraticCurveTo(u[e++],u[e++],u[e++],u[e++]);break;case kh.closePath:t.closePath();break;default:st(`Unrecognized drawing path operator: ${u[e-1]}`);break}return t}_0();z0();G0();V0();A0();x0();p0();g0();v0();E0();var Sn,En,qs,Js,pu,xn,jl,$l,gu,pp,kb,je,Mb,Ob,Rl,Rh;const Tr=class Tr{constructor(t){y(this,je);y(this,Sn,null);y(this,En,null);y(this,qs);y(this,Js,null);y(this,pu,null);y(this,xn,null);y(this,jl,null);y(this,$l,null);p(this,qs,t),r(Tr,gu)||p(Tr,gu,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,Sn,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=r(this,qs)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",Li,{signal:e}),t.addEventListener("pointerdown",b(Tr,pp,kb),{signal:e}));const s=p(this,Js,document.createElement("div"));s.className="buttons",t.append(s);const i=r(this,qs).toolbarPosition;if(i){const{style:n}=t,a=r(this,qs)._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*a}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return r(this,Sn)}hide(){var t;r(this,Sn).classList.add("hidden"),(t=r(this,En))==null||t.hideDropdown()}show(){var t,e;r(this,Sn).classList.remove("hidden"),(t=r(this,pu))==null||t.shown(),(e=r(this,xn))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=r(this,qs),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",r(Tr,gu)[t]),b(this,je,Rl).call(this,s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),r(this,Js).append(s)}async addAltText(t){const e=await t.render();b(this,je,Rl).call(this,e),r(this,Js).append(e,r(this,je,Rh)),p(this,pu,t)}addComment(t,e=null){if(r(this,xn))return;const s=t.renderForToolbar();if(!s)return;b(this,je,Rl).call(this,s);const i=p(this,jl,r(this,je,Rh));e?(r(this,Js).insertBefore(s,e),r(this,Js).insertBefore(i,e)):r(this,Js).append(s,i),p(this,xn,t),t.toolbar=this}addColorPicker(t){if(r(this,En))return;p(this,En,t);const e=t.renderButton();b(this,je,Rl).call(this,e),r(this,Js).append(e,r(this,je,Rh))}async addEditSignatureButton(t){const e=p(this,$l,await t.renderEditButton(r(this,qs)));e&&(b(this,je,Rl).call(this,e),r(this,Js).append(e,r(this,je,Rh)))}removeButton(t){var e,s;switch(t){case"comment":(e=r(this,xn))==null||e.removeToolbarCommentButton(),p(this,xn,null),(s=r(this,jl))==null||s.remove(),p(this,jl,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,s){if(!e&&t==="comment")return;const i=r(this,Js).querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){r(this,$l)&&(r(this,$l).title=t)}remove(){var t;r(this,Sn).remove(),(t=r(this,En))==null||t.destroy(),p(this,En,null)}};Sn=new WeakMap,En=new WeakMap,qs=new WeakMap,Js=new WeakMap,pu=new WeakMap,xn=new WeakMap,jl=new WeakMap,$l=new WeakMap,gu=new WeakMap,pp=new WeakSet,kb=function(t){t.stopPropagation()},je=new WeakSet,Mb=function(t){r(this,qs)._focusEventsAllowed=!1,Ae(t)},Ob=function(t){r(this,qs)._focusEventsAllowed=!0,Ae(t)},Rl=function(t){const e=r(this,qs)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",b(this,je,Mb).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,je,Ob).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Li,{signal:e}),!0)},Rh=function(){const t=document.createElement("div");return t.className="divider",t},y(Tr,pp),y(Tr,gu,null);let Hg=Tr;var mu,ja,Vi,gn,Rb,Db,jg;class fS{constructor(t){y(this,gn);y(this,mu,null);y(this,ja,null);y(this,Vi);p(this,Vi,t)}show(t,e,s){const[i,n]=b(this,gn,Db).call(this,e,s),{style:a}=r(this,ja)||p(this,ja,b(this,gn,Rb).call(this));t.append(r(this,ja)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){r(this,ja).remove()}}mu=new WeakMap,ja=new WeakMap,Vi=new WeakMap,gn=new WeakSet,Rb=function(){const t=p(this,ja,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=r(this,Vi).direction;const e=r(this,Vi)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Li,{signal:e});const s=p(this,mu,document.createElement("div"));return s.className="buttons",t.append(s),r(this,Vi).hasCommentManager()&&b(this,gn,jg).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{r(this,Vi).commentSelection("floating_button")}),b(this,gn,jg).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{r(this,Vi).highlightSelection("floating_button")}),t},Db=function(t,e){let s=0,i=0;for(const n of t){const a=n.y+n.height;if(a<s)continue;const o=n.x+(e?n.width:0);if(a>s){i=o,s=a;continue}e?o>i&&(i=o):o<i&&(i=o)}return[e?1-i:i,s]},jg=function(t,e,s,i){const n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);const a=document.createElement("span");n.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",s);const o=r(this,Vi)._signal;o instanceof AbortSignal&&!o.aborted&&(n.addEventListener("contextmenu",Li,{signal:o}),n.addEventListener("click",i,{signal:o})),r(this,mu).append(n)};const pS="2837668c-d334-48d1-ba74-aa7deba483da",xg=Object.freeze({internal:pS});function Fb(u,t,e){for(const s of e)t.addEventListener(s,u[s].bind(u))}var $a,Ga,Gl,za;const Tt=class Tt{static initializeAndAddPointerId(t){(r(Tt,Ga)||p(Tt,Ga,new Set)).add(t)}static setPointer(t,e){r(Tt,$a)||p(Tt,$a,e),r(Tt,za)??p(Tt,za,t)}static setTimeStamp(t){p(Tt,Gl,t)}static isSamePointerId(t){return r(Tt,$a)===t}static isSamePointerIdOrRemove(t){var e;return r(Tt,$a)===t?!0:((e=r(Tt,Ga))==null||e.delete(t),!1)}static isSamePointerType(t){return r(Tt,za)===t}static isInitializedAndDifferentPointerType(t){return r(Tt,za)!==null&&!Tt.isSamePointerType(t)}static isSameTimeStamp(t){return r(Tt,Gl)===t}static isUsingMultiplePointers(){var t;return((t=r(Tt,Ga))==null?void 0:t.size)>=1}static clearPointerType(){p(Tt,za,null)}static clearPointerIds(){p(Tt,$a,NaN),p(Tt,Ga,null)}static clearTimeStamp(){p(Tt,Gl,NaN)}};$a=new WeakMap,Ga=new WeakMap,Gl=new WeakMap,za=new WeakMap,y(Tt,$a,NaN),y(Tt,Ga,null),y(Tt,Gl,NaN),y(Tt,za,null);let ze=Tt;var gp;class gS{constructor(){y(this,gp,0)}get id(){return`${yh}${Ft(this,gp)._++}`}}gp=new WeakMap;var zl,vu,Ve,Vl,_f;const ry=class ry{constructor(){y(this,Vl);y(this,zl,Cb());y(this,vu,0);y(this,Ve,null)}static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${ns}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const n=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return V(this,"_isSVGFittingCanvas",n)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return b(this,Vl,_f).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return b(this,Vl,_f).call(this,t,t)}async getFromBlob(t,e){const s=await e;return b(this,Vl,_f).call(this,t,s)}async getFromId(t){r(this,Ve)||p(this,Ve,new Map);const e=r(this,Ve).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){r(this,Ve)||p(this,Ve,new Map);let s=r(this,Ve).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${r(this,zl)}_${Ft(this,vu)._++}`,refCounter:1,isSvg:!1},r(this,Ve).set(t,s),r(this,Ve).set(s.id,s),s}getSvgUrl(t){const e=r(this,Ve).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;r(this,Ve)||p(this,Ve,new Map);const e=r(this,Ve).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const n=new OffscreenCanvas(s.width,s.height);n.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=n.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${r(this,zl)}_`)}};zl=new WeakMap,vu=new WeakMap,Ve=new WeakMap,Vl=new WeakSet,_f=async function(t,e){r(this,Ve)||p(this,Ve,new Map);let s=r(this,Ve).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${r(this,zl)}_${Ft(this,vu)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await Wv(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const n=ry._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((c,h)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,c()},a.onload=async()=>{const d=s.svgUrl=a.result;o.src=await n?`${d}#svgView(preserveAspectRatio(none))`:d},o.onerror=a.onerror=h});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){st(i),s=null}return r(this,Ve).set(t,s),s&&r(this,Ve).set(s.id,s),s};let $g=ry;var oe,Tn,yu,qt;class mS{constructor(t=128){y(this,oe,[]);y(this,Tn,!1);y(this,yu);y(this,qt,-1);p(this,yu,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),r(this,Tn))return;const l={cmd:t,undo:e,post:s,type:n};if(r(this,qt)===-1){r(this,oe).length>0&&(r(this,oe).length=0),p(this,qt,0),r(this,oe).push(l);return}if(a&&r(this,oe)[r(this,qt)].type===n){o&&(l.undo=r(this,oe)[r(this,qt)].undo),r(this,oe)[r(this,qt)]=l;return}const c=r(this,qt)+1;c===r(this,yu)?r(this,oe).splice(0,1):(p(this,qt,c),c<r(this,oe).length&&r(this,oe).splice(c)),r(this,oe).push(l)}undo(){if(r(this,qt)===-1)return;p(this,Tn,!0);const{undo:t,post:e}=r(this,oe)[r(this,qt)];t(),e==null||e(),p(this,Tn,!1),p(this,qt,r(this,qt)-1)}redo(){if(r(this,qt)<r(this,oe).length-1){p(this,qt,r(this,qt)+1),p(this,Tn,!0);const{cmd:t,post:e}=r(this,oe)[r(this,qt)];t(),e==null||e(),p(this,Tn,!1)}}hasSomethingToUndo(){return r(this,qt)!==-1}hasSomethingToRedo(){return r(this,qt)<r(this,oe).length-1}cleanType(t){if(r(this,qt)!==-1){for(let e=r(this,qt);e>=0;e--)if(r(this,oe)[e].type!==t){r(this,oe).splice(e+1,r(this,qt)-e),p(this,qt,e);return}r(this,oe).length=0,p(this,qt,-1)}}destroy(){p(this,oe,null)}}oe=new WeakMap,Tn=new WeakMap,yu=new WeakMap,qt=new WeakMap;var bh,Lb,Nb;const ms=class ms{constructor(t){var s;this.callbacks=new Map;const{isMac:e}=Et.platform;for(const[i,n,a={}]of t){const o=i.some(l=>l.startsWith("mac+"));for(const l of i){let c=l;if(o){const f=l.startsWith("mac+");if(e!==f)continue;f&&(c=l.slice(4))}const[h,d]=b(s=ms,bh,Lb).call(s,c);h!==null&&this.callbacks.getOrInsertComputed(h,Eh).push({callback:n,options:a,modifiers:d})}}}exec(t,e){var h;let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const d=b(h=ms,bh,Nb).call(h,e.code);if(d===null||d===e.key||(s=this.callbacks.get(d),!s))return}const i=(e.altKey?ms.ALT:0)|(e.ctrlKey?ms.CTRL:0)|(e.metaKey?ms.META:0)|(e.shiftKey?ms.SHIFT:0),n=s.find(d=>d.modifiers===i);if(!n)return;const{callback:a,options:{bubbles:o=!1,args:l=[],checker:c=null}}=n;c&&!c(t,e)||(a.bind(t,...l,e)(),o||Ae(e))}};bh=new WeakSet,Lb=function(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;const n=i.toUpperCase(),a=ms[n];if(a){s|=a;continue}if(e!==null){st(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=n==="SPACE"?" ":i}return e===null&&st(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]},Nb=function(t){var s;const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?((s=e[1])==null?void 0:s.toLowerCase())??e[2]:null},y(ms,bh),O(ms,"ALT",1),O(ms,"CTRL",2),O(ms,"META",4),O(ms,"SHIFT",8);let yl=ms;const mp=class mp{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return lS(t),V(this,"_colors",t)}convert(t){const e=lf(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((n,a)=>n===e[a]))return mp._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?$.makeHexColor(...e):t}};O(mp,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Gg=mp;var Wl,Cs,Xl,$t,Jt,Yl,Kl,ql,We,Jl,Qs,Ie,Cn,Pn,In,kn,Wi,Zs,Va,bu,wu,Ql,Au,Xi,Mn,Zl,On,Yi,vp,Pr,tc,_u,Rn,Wa,ec,Dn,Su,de,Ct,Ir,Fn,Ln,Eu,sc,xu,Nn,Ki,kr,Tu,Cu,ti,W,Sf,zg,Bb,Ub,Dh,Hb,jb,$b,Vg,Gb,zb,Vb,Wb,Qe,Er,Xb,Yb,Wg,Kb,Fh,Xg;const Bl=class Bl{constructor(t,e,s,i,n,a,o,l,c,h,d,f,g,m,v,w){y(this,W);y(this,Wl,new AbortController);y(this,Cs,null);y(this,Xl,null);y(this,$t,new Map);y(this,Jt,new Map);y(this,Yl,null);y(this,Kl,null);y(this,ql,null);y(this,We,null);y(this,Jl,null);y(this,Qs,new mS);y(this,Ie,null);y(this,Cn,null);y(this,Pn,null);y(this,In,0);y(this,kn,new Set);y(this,Wi,null);y(this,Zs,null);y(this,Va,new Set);O(this,"_editorUndoBar",null);y(this,bu,!1);y(this,wu,!1);y(this,Ql,!1);y(this,Au,null);y(this,Xi,null);y(this,Mn,null);y(this,Zl,null);y(this,On,!1);y(this,Yi,null);y(this,vp,new gS);y(this,Pr,!1);y(this,tc,!1);y(this,_u,!1);y(this,Rn,null);y(this,Wa,null);y(this,ec,null);y(this,Dn,null);y(this,Su,null);y(this,de,rt.NONE);y(this,Ct,new Set);y(this,Ir,null);y(this,Fn,null);y(this,Ln,null);y(this,Eu,null);y(this,sc,null);y(this,xu,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});y(this,Nn,[0,0]);y(this,Ki,null);y(this,kr,null);y(this,Tu,null);y(this,Cu,null);y(this,ti,null);const A=this._signal=r(this,Wl).signal;p(this,kr,t),p(this,Tu,e),p(this,Cu,s),p(this,ql,i),p(this,Ie,n),p(this,Fn,a),p(this,sc,l),this._eventBus=o;const _={signal:A,...xg};o.on("editingaction",this.onEditingAction.bind(this),_),o.on("pagechanging",this.onPageChanging.bind(this),_),o.on("scalechanging",this.onScaleChanging.bind(this),_),o.on("rotationchanging",this.onRotationChanging.bind(this),_),o.on("setpreference",this.onSetPreference.bind(this),_),o.on("switchannotationeditorparams",E=>this.updateParams(E.type,E.value),_),window.addEventListener("pointerdown",()=>{p(this,tc,!0)},{capture:!0,signal:A}),window.addEventListener("pointerup",()=>{p(this,tc,!1)},{capture:!0,signal:A}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:A}),b(this,W,Hb).call(this),b(this,W,Wb).call(this),b(this,W,Vg).call(this),p(this,We,l.annotationStorage),p(this,Au,l.filterFactory),p(this,Ln,c),p(this,Zl,h||null),p(this,bu,d),p(this,wu,f),p(this,Ql,g),p(this,Su,m||null),this.viewParameters={realScale:Ca.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=v||null,this._supportsPinchToZoom=w!==!1,n==null||n.setSidebarUiManager(this)}static get _keyboardManager(){const t=Bl.prototype,e=a=>r(a,kr).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return V(this,"_keyboardManager",new yl([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,kr).contains(o)&&!a.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,kr).contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}destroy(){var t,e,s,i,n,a,o,l,c;(t=r(this,ti))==null||t.resolve(),p(this,ti,null),(e=r(this,Wl))==null||e.abort(),p(this,Wl,null),this._signal=null;for(const h of r(this,Jt).values())h.destroy();r(this,Jt).clear(),r(this,$t).clear(),r(this,Va).clear(),(s=r(this,Dn))==null||s.clear(),p(this,Cs,null),r(this,Ct).clear(),r(this,Qs).destroy(),(i=r(this,ql))==null||i.destroy(),(n=r(this,Ie))==null||n.destroy(),(a=r(this,Fn))==null||a.destroy(),(o=r(this,Yi))==null||o.hide(),p(this,Yi,null),(l=r(this,ec))==null||l.destroy(),p(this,ec,null),p(this,Xl,null),r(this,Xi)&&(clearTimeout(r(this,Xi)),p(this,Xi,null)),r(this,Ki)&&(clearTimeout(r(this,Ki)),p(this,Ki,null)),(c=this._editorUndoBar)==null||c.destroy(),p(this,sc,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return r(this,Su)}get useNewAltTextFlow(){return r(this,wu)}get useNewAltTextWhenAddingImage(){return r(this,Ql)}get hcmFilter(){return V(this,"hcmFilter",r(this,Ln)?r(this,Au).addHCMFilter(r(this,Ln).foreground,r(this,Ln).background):"none")}get direction(){return V(this,"direction",getComputedStyle(r(this,kr)).direction)}get _highlightColors(){return V(this,"_highlightColors",r(this,Zl)?new Map(r(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 V(this,"highlightColors",null);const e=new Map,s=!!r(this,Ln);for(const[i,n]of t){const a=i.endsWith("_HCM");if(s&&a){e.set(i.replace("_HCM",""),n);continue}!s&&!a&&e.set(i,n)}return V(this,"highlightColors",e)}get highlightColorNames(){return V(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),p(this,Pn,t)}setMainHighlightColorPicker(t){p(this,ec,t)}editAltText(t,e=!1){var s;(s=r(this,ql))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!r(this,Ie)}editComment(t,e,s,i){var n;(n=r(this,Ie))==null||n.showDialog(this,t,e,s,i)}selectComment(t,e){const s=r(this,Jt).get(t),i=s==null?void 0:s.getEditorByUID(e);i==null||i.toggleComment(!0,!0)}updateComment(t){var e;(e=r(this,Ie))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=r(this,Ie))==null||e.updatePopupColor(t)}removeComment(t){var e;(e=r(this,Ie))==null||e.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},i=()=>{var n;(n=this._editorUndoBar)==null||n.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){var i;(i=r(this,Ie))==null||i.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){var s;return t&&((s=r(this,Ie))==null?void 0:s.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=r(this,Ie))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(r(this,Jt).has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=n=>{n.pageNumber===t&&(this._eventBus.off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i,xg),await s}getSignature(t){var e;(e=r(this,Fn))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return r(this,Fn)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...xg}),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,Ql,e);break}}onPageChanging({pageNumber:t}){p(this,In,t-1)}deletePage(t){for(const e of this.getEditors(t))e.remove();r(this,Jt).delete(t),r(this,In)===t&&p(this,In,0)}focusMainContainer(){r(this,kr).focus()}findParent(t,e){for(const s of r(this,Jt).values()){const{x:i,y:n,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=n&&e<=n+o)return s}return null}disableUserSelect(t=!1){r(this,Tu).classList.toggle("noUserSelect",t)}addShouldRescale(t){r(this,Va).add(t)}removeShouldRescale(t){r(this,Va).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Ca.PDF_TO_CSS_UNITS;for(const s of r(this,Va))s.onScaleChanging();(e=r(this,Pn))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:n,focusNode:a,focusOffset:o}=s,l=s.toString(),h=b(this,W,Sf).call(this,s).closest(".textLayer"),d=this.getSelectionBoxes(h);if(!d)return;s.empty();const f=b(this,W,zg).call(this,h),g=r(this,de)===rt.NONE,m=()=>{const v=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:i,anchorOffset:n,focusNode:a,focusOffset:o,text:l});g&&this.showAllEditors("highlight",!0,!0),e&&(v==null||v.editComment())};if(g){this.switchToMode(rt.HIGHLIGHT,m);return}m()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){var t;this.commitOrRemove(),(t=this.currentLayer)==null||t.endDrawingSession(!1)}getAndRemoveDataFromAnnotationStorage(t){if(!r(this,We))return null;const e=`${yh}${t}`,s=r(this,We).getRawValue(e);return s&&r(this,We).remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&r(this,We)&&!r(this,We).has(t.id)&&r(this,We).setValue(t.id,t)}a11yAlert(t,e=null){const s=r(this,Cu);s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,r(this,On)&&(p(this,On,!1),b(this,W,Dh).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of r(this,Ct))if(e.div.contains(t)){p(this,Wa,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!r(this,Wa))return;const[t,e]=r(this,Wa);p(this,Wa,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,W,Vg).call(this),this.setEditingState(!0)}removeEditListeners(){b(this,W,Gb).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of r(this,Zs))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of r(this,Zs))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=r(this,Cs))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of r(this,Ct)){const n=i.serialize(!0);n&&e.push(n)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const n of e.items)for(const a of r(this,Zs))if(a.isHandlingMimeForPasting(n.type)){a.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){st(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const l of s){const c=await i.deserialize(l);if(!c)return;n.push(c)}const a=()=>{for(const l of n)b(this,W,Wg).call(this,l);b(this,W,Xg).call(this,n)},o=()=>{for(const l of n)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(n){st(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),r(this,de)!==rt.NONE&&!this.isEditorHandlingKeyboard&&Bl._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,r(this,On)&&(p(this,On,!1),b(this,W,Dh).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}}updatePageIndex(t,e){for(const i of r(this,Kl).get(t)||[])i.pageIndex=e;const s=r(this,Yl).get(t);s&&(s.pageIndex=e,r(this,Jt).set(e,s),r(this,Pr)?s.enable():s.disable())}startUpdatePages(){p(this,Yl,new Map(r(this,Jt))),r(this,Jt).clear();const t=p(this,Kl,new Map),e=s=>{t.getOrInsertComputed(s.pageIndex,Eh).push(s)};for(const s of r(this,$t).values())e(s);for(const[s,i]of r(this,We))s.startsWith(yh)&&!r(this,$t).has(s)&&Number.isInteger(i==null?void 0:i.pageIndex)&&e(i)}endUpdatePages(){p(this,Yl,null),p(this,Kl,null)}clonePage(t,e){for(const s of this.getEditors(t)){const i=s.serialize(s.mode!==rt.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,r(this,We).setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[i,n]of r(this,We))n.pageIndex===s&&n.isClone&&(r(this,We).remove(i),e.push(t.deserialize(n).then(a=>{a&&(a.isClone=!0,t.addOrRebuild(a))})));return Promise.all(e)}setEditingState(t){t?(b(this,W,jb).call(this),b(this,W,zb).call(this),b(this,W,Qe).call(this,{isEditing:r(this,de)!==rt.NONE,isEmpty:b(this,W,Fh).call(this),hasSomethingToUndo:r(this,Qs).hasSomethingToUndo(),hasSomethingToRedo:r(this,Qs).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,W,$b).call(this),b(this,W,Vb).call(this),b(this,W,Qe).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!r(this,Zs)){p(this,Zs,t);for(const e of r(this,Zs))b(this,W,Er).call(this,e.defaultPropertiesToUpdate)}}getId(){return r(this,vp).id}get currentLayer(){return r(this,Jt).get(r(this,In))}getLayer(t){return r(this,Jt).get(t)}get currentPageIndex(){return r(this,In)}addLayer(t){r(this,Jt).set(t.pageIndex,t),r(this,Pr)?t.enable():t.disable()}removeLayer(t){r(this,Jt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,n=!1,a=!1){var o,l,c,h,d,f;if(r(this,de)!==t&&!(r(this,ti)&&(await r(this,ti).promise,!r(this,ti)))){if(p(this,ti,Promise.withResolvers()),(o=r(this,Pn))==null||o.commitOrRemove(),r(this,de)===rt.POPUP&&((l=r(this,Ie))==null||l.hideSidebar()),(c=r(this,Ie))==null||c.destroyPopup(),p(this,de,t),t===rt.NONE){this.setEditingState(!1),b(this,W,Yb).call(this);for(const g of r(this,$t).values())g.hideStandaloneCommentButton();(h=this._editorUndoBar)==null||h.hide(),this.toggleComment(null),r(this,ti).resolve();return}for(const g of r(this,$t).values())g.addStandaloneCommentButton();t===rt.SIGNATURE&&await((d=r(this,Fn))==null?void 0:d.loadSignatures()),s&&ze.clearPointerType(),this.setEditingState(!0),await b(this,W,Xb).call(this),this.unselectAll();for(const g of r(this,Jt).values())g.updateMode(t);if(t===rt.POPUP){r(this,Xl)||p(this,Xl,await r(this,sc).getAnnotationsByType(new Set(r(this,Zs).map(v=>v._editorType))));const g=new Set,m=[];for(const v of r(this,$t).values()){const{annotationElementId:w,hasComment:A,deleted:_}=v;w&&g.add(w),A&&!_&&m.push(v.getData())}for(const v of r(this,Xl)){const{id:w,popupRef:A,contentsObj:_}=v;A&&(_!=null&&_.str)&&!g.has(w)&&!r(this,kn).has(w)&&m.push(v)}(f=r(this,Ie))==null||f.showSidebar(m)}if(!e){i&&this.addNewEditorFromKeyboard(),r(this,ti).resolve();return}for(const g of r(this,$t).values())g.uid===e?(this.setSelected(g),a?g.editComment():n?g.enterInEditMode():g.focus()):g.unselect();r(this,ti).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==r(this,de)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(r(this,Zs)){switch(t){case dt.CREATE:this.currentLayer.addNewEditor(e);return;case dt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(r(this,Eu)||p(this,Eu,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of r(this,Ct))s.updateParams(t,e);else for(const s of r(this,Zs))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var n;for(const a of r(this,$t).values())a.editorType===t&&a.show(e);(((n=r(this,Eu))==null?void 0:n.get(dt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,W,Er).call(this,[[dt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(r(this,_u)!==t){p(this,_u,t);for(const e of r(this,Jt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of r(this,$t).values())e.pageIndex===t&&(yield e)}getEditor(t){return r(this,$t).get(t)}addEditor(t){r(this,$t).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(r(this,Xi)&&clearTimeout(r(this,Xi)),p(this,Xi,setTimeout(()=>{this.focusMainContainer(),p(this,Xi,null)},0))),r(this,$t).delete(t.id),t.annotationElementId&&((e=r(this,Dn))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!r(this,kn).has(t.annotationElementId))&&((s=r(this,We))==null||s.remove(t.id))}addDeletedAnnotationElement(t){r(this,kn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return r(this,kn).has(t)}removeDeletedAnnotationElement(t){r(this,kn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){r(this,Cs)!==t&&(p(this,Cs,t),t&&b(this,W,Er).call(this,t.propertiesToUpdate))}updateUI(t){r(this,W,Kb)===t&&b(this,W,Er).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,W,Er).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(r(this,Ct).has(t)){r(this,Ct).delete(t),t.unselect(),b(this,W,Qe).call(this,{hasSelectedEditor:this.hasSelection});return}r(this,Ct).add(t),t.select(),b(this,W,Er).call(this,t.propertiesToUpdate),b(this,W,Qe).call(this,{hasSelectedEditor:!0})}setSelected(t){var e,s;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=r(this,Pn))==null||e.commitOrRemove();for(const i of r(this,Ct))i!==t&&i.unselect();(s=r(this,Ie))==null||s.destroyPopup(),r(this,Ct).clear(),r(this,Ct).add(t),t.select(),b(this,W,Er).call(this,t.propertiesToUpdate),b(this,W,Qe).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return r(this,Ct).values().next().value}unselect(t){t.unselect(),r(this,Ct).delete(t),b(this,W,Qe).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return r(this,Ct).size!==0}get isEnterHandled(){return r(this,Ct).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;r(this,Qs).undo(),b(this,W,Qe).call(this,{hasSomethingToUndo:r(this,Qs).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,W,Fh).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){r(this,Qs).redo(),b(this,W,Qe).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:r(this,Qs).hasSomethingToRedo(),isEmpty:b(this,W,Fh).call(this)})}addCommands(t){r(this,Qs).add(t),b(this,W,Qe).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,W,Fh).call(this)})}cleanUndoStack(t){r(this,Qs).cleanType(t)}delete(){var n;this.commitOrRemove();const t=(n=this.currentLayer)==null?void 0:n.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...r(this,Ct)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(i,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},i=()=>{for(const a of e)b(this,W,Wg).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=r(this,Cs))==null||t.commitOrRemove()}hasSomethingToControl(){return r(this,Cs)||this.hasSelection}selectAll(){for(const t of r(this,Ct))t.commit();b(this,W,Xg).call(this,r(this,$t).values())}unselectAll(){var t,e;if(!(r(this,Cs)&&(r(this,Cs).commitOrRemove(),r(this,de)!==rt.NONE))&&!((t=r(this,Pn))!=null&&t.commitOrRemove())&&((e=r(this,Ie))==null||e.destroyPopup(),!!this.hasSelection)){for(const s of r(this,Ct))s.unselect();r(this,Ct).clear(),b(this,W,Qe).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;r(this,Nn)[0]+=t,r(this,Nn)[1]+=e;const[i,n]=r(this,Nn),a=[...r(this,Ct)],o=1e3;r(this,Ki)&&clearTimeout(r(this,Ki)),p(this,Ki,setTimeout(()=>{p(this,Ki,null),r(this,Nn)[0]=r(this,Nn)[1]=0,this.addCommands({cmd:()=>{for(const l of a)r(this,$t).has(l.id)&&(l.translateInPage(i,n),l.translationDone())},undo:()=>{for(const l of a)r(this,$t).has(l.id)&&(l.translateInPage(-i,-n),l.translationDone())},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,Wi,new Map);for(const t of r(this,Ct))r(this,Wi).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!r(this,Wi))return!1;this.disableUserSelect(!1);const t=r(this,Wi);p(this,Wi,null);let e=!1;for(const[{x:i,y:n,pageIndex:a},o]of t)o.newX=i,o.newY=n,o.newPageIndex=a,e||(e=i!==o.savedX||n!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,n,a,o)=>{if(r(this,$t).has(i.id)){const l=r(this,Jt).get(o);l?i._setParentAndPosition(l,n,a):(i.pageIndex=o,i.x=n,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:a,newPageIndex:o}]of t)s(i,n,a,o)},undo:()=>{for(const[i,{savedX:n,savedY:a,savedPageIndex:o}]of t)s(i,n,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(r(this,Wi))for(const s of r(this,Wi).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||r(this,Ct).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return r(this,Cs)===t}getActive(){return r(this,Cs)}getMode(){return r(this,de)}isEditingMode(){return r(this,de)!==rt.NONE}get imageManager(){return V(this,"imageManager",new $g)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,h=e.rangeCount;c<h;c++)if(!t.contains(e.getRangeAt(c).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(c,h,d,f)=>({x:(h-i)/a,y:1-(c+d-s)/n,width:f/a,height:d/n});break;case"180":o=(c,h,d,f)=>({x:1-(c+d-s)/n,y:1-(h+f-i)/a,width:d/n,height:f/a});break;case"270":o=(c,h,d,f)=>({x:1-(h+f-i)/a,y:(c-s)/n,width:f/a,height:d/n});break;default:o=(c,h,d,f)=>({x:(c-s)/n,y:(h-i)/a,width:d/n,height:f/a});break}const l=[];for(let c=0,h=e.rangeCount;c<h;c++){const d=e.getRangeAt(c);if(!d.collapsed)for(const{x:f,y:g,width:m,height:v}of d.getClientRects())m===0||v===0||l.push(o(f,g,m,v))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(r(this,Jl)||p(this,Jl,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=r(this,Jl))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=r(this,Jl))==null?void 0:i.get(t.data.id);if(!e)return;const s=r(this,We).getRawValue(e);s&&(r(this,de)===rt.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var n;const i=(n=r(this,Dn))==null?void 0:n.get(t);i&&(i.setCanvas(e,s),r(this,Dn).delete(t))}addMissingCanvas(t,e){(r(this,Dn)||p(this,Dn,new Map)).set(t,e)}};Wl=new WeakMap,Cs=new WeakMap,Xl=new WeakMap,$t=new WeakMap,Jt=new WeakMap,Yl=new WeakMap,Kl=new WeakMap,ql=new WeakMap,We=new WeakMap,Jl=new WeakMap,Qs=new WeakMap,Ie=new WeakMap,Cn=new WeakMap,Pn=new WeakMap,In=new WeakMap,kn=new WeakMap,Wi=new WeakMap,Zs=new WeakMap,Va=new WeakMap,bu=new WeakMap,wu=new WeakMap,Ql=new WeakMap,Au=new WeakMap,Xi=new WeakMap,Mn=new WeakMap,Zl=new WeakMap,On=new WeakMap,Yi=new WeakMap,vp=new WeakMap,Pr=new WeakMap,tc=new WeakMap,_u=new WeakMap,Rn=new WeakMap,Wa=new WeakMap,ec=new WeakMap,Dn=new WeakMap,Su=new WeakMap,de=new WeakMap,Ct=new WeakMap,Ir=new WeakMap,Fn=new WeakMap,Ln=new WeakMap,Eu=new WeakMap,sc=new WeakMap,xu=new WeakMap,Nn=new WeakMap,Ki=new WeakMap,kr=new WeakMap,Tu=new WeakMap,Cu=new WeakMap,ti=new WeakMap,W=new WeakSet,Sf=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},zg=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of r(this,Jt).values())if(s.hasTextLayer(t))return s;return null},Bb=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=b(this,W,Sf).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(r(this,Yi)||p(this,Yi,new fS(this)),r(this,Yi).show(s,i,this.direction==="ltr"))},Ub=function(){var n,a,o;const t=document.getSelection();if(!t||t.isCollapsed){r(this,Ir)&&((n=r(this,Yi))==null||n.hide(),p(this,Ir,null),b(this,W,Qe).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===r(this,Ir))return;const i=b(this,W,Sf).call(this,t).closest(".textLayer");if(!i){r(this,Ir)&&((a=r(this,Yi))==null||a.hide(),p(this,Ir,null),b(this,W,Qe).call(this,{hasSelectedText:!1}));return}if((o=r(this,Yi))==null||o.hide(),p(this,Ir,e),b(this,W,Qe).call(this,{hasSelectedText:!0}),!(r(this,de)!==rt.HIGHLIGHT&&r(this,de)!==rt.NONE)&&(r(this,de)===rt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,On,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=r(this,de)===rt.HIGHLIGHT?b(this,W,zg).call(this,i):null;if(l==null||l.toggleDrawing(),r(this,tc)){const c=new AbortController,h=this.combinedSignal(c),d=f=>{f.type==="pointerup"&&f.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&b(this,W,Dh).call(this,"main_toolbar"))};window.addEventListener("pointerup",d,{signal:h}),window.addEventListener("blur",d,{signal:h})}else l==null||l.toggleDrawing(!0),b(this,W,Dh).call(this,"main_toolbar")}},Dh=function(t=""){r(this,de)===rt.HIGHLIGHT?this.highlightSelection(t):r(this,bu)&&b(this,W,Bb).call(this)},Hb=function(){document.addEventListener("selectionchange",b(this,W,Ub).bind(this),{signal:this._signal})},jb=function(){if(r(this,Mn))return;p(this,Mn,new AbortController);const t=this.combinedSignal(r(this,Mn));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},$b=function(){var t;(t=r(this,Mn))==null||t.abort(),p(this,Mn,null)},Vg=function(){if(r(this,Rn))return;p(this,Rn,new AbortController);const t=this.combinedSignal(r(this,Rn));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Gb=function(){var t;(t=r(this,Rn))==null||t.abort(),p(this,Rn,null)},zb=function(){if(r(this,Cn))return;p(this,Cn,new AbortController);const t=this.combinedSignal(r(this,Cn));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})},Vb=function(){var t;(t=r(this,Cn))==null||t.abort(),p(this,Cn,null)},Wb=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Qe=function(t){Object.entries(t).some(([s,i])=>r(this,xu)[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(r(this,xu),t)}),r(this,de)===rt.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,W,Er).call(this,[[dt.HIGHLIGHT_FREE,!0]]))},Er=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Xb=async function(){if(!r(this,Pr)){p(this,Pr,!0);const t=[];for(const e of r(this,Jt).values())t.push(e.enable());await Promise.all(t);for(const e of r(this,$t).values())e.enable()}},Yb=function(){if(this.unselectAll(),r(this,Pr)){p(this,Pr,!1);for(const t of r(this,Jt).values())t.disable();for(const t of r(this,$t).values())t.disable()}},Wg=function(t){const e=r(this,Jt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Kb=function(){let t=null;for(t of r(this,Ct));return t},Fh=function(){if(r(this,$t).size===0)return!0;if(r(this,$t).size===1)for(const t of r(this,$t).values())return t.isEmpty();return!1},Xg=function(t){for(const e of r(this,Ct))e.unselect();r(this,Ct).clear();for(const e of t)e.isEmpty()||(r(this,Ct).add(e),e.select());b(this,W,Qe).call(this,{hasSelectedEditor:this.hasSelection})},O(Bl,"TRANSLATE_SMALL",1),O(Bl,"TRANSLATE_BIG",10);let bl=Bl;var ke,qi,wi,ic,Ji,Ps,rc,Qi,ys,Mr,Xa,Zi,Bn,Fi,Lh,Ef;const Ze=class Ze{constructor(t){y(this,Fi);y(this,ke,null);y(this,qi,!1);y(this,wi,null);y(this,ic,null);y(this,Ji,null);y(this,Ps,null);y(this,rc,!1);y(this,Qi,null);y(this,ys,null);y(this,Mr,null);y(this,Xa,null);y(this,Zi,!1);p(this,ys,t),p(this,Zi,t._uiManager.useNewAltTextFlow),r(Ze,Bn)||p(Ze,Bn,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){Ze._l10n??(Ze._l10n=t)}async render(){const t=p(this,wi,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,ic,document.createElement("span"));t.append(e),r(this,Zi)?(t.classList.add("new"),t.setAttribute("data-l10n-id",r(Ze,Bn).missing),e.setAttribute("data-l10n-id",r(Ze,Bn)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=r(this,ys)._uiManager._signal;t.addEventListener("contextmenu",Li,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),r(this,ys)._uiManager.editAltText(r(this,ys)),r(this,Zi)&&r(this,ys)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:r(this,Fi,Lh)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(p(this,rc,!0),i(n))},{signal:s}),await b(this,Fi,Ef).call(this),t}finish(){r(this,wi)&&(r(this,wi).focus({focusVisible:r(this,rc)}),p(this,rc,!1))}isEmpty(){return r(this,Zi)?r(this,ke)===null:!r(this,ke)&&!r(this,qi)}hasData(){return r(this,Zi)?r(this,ke)!==null||!!r(this,Mr):this.isEmpty()}get guessedText(){return r(this,Mr)}async setGuessedText(t){r(this,ke)===null&&(p(this,Mr,t),p(this,Xa,await Ze._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,Fi,Ef).call(this))}toggleAltTextBadge(t=!1){var e;if(!r(this,Zi)||r(this,ke)){(e=r(this,Qi))==null||e.remove(),p(this,Qi,null);return}if(!r(this,Qi)){const s=p(this,Qi,document.createElement("div"));s.className="noAltTextBadge",r(this,ys).div.append(s)}r(this,Qi).classList.toggle("hidden",!t)}serialize(t){let e=r(this,ke);return!t&&r(this,Mr)===e&&(e=r(this,Xa)),{altText:e,decorative:r(this,qi),guessedText:r(this,Mr),textWithDisclaimer:r(this,Xa)}}get data(){return{altText:r(this,ke),decorative:r(this,qi)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(p(this,Mr,s),p(this,Xa,i)),!(r(this,ke)===t&&r(this,qi)===e)&&(n||(p(this,ke,t),p(this,qi,e)),b(this,Fi,Ef).call(this))}toggle(t=!1){r(this,wi)&&(!t&&r(this,Ps)&&(clearTimeout(r(this,Ps)),p(this,Ps,null)),r(this,wi).disabled=!t)}shown(){r(this,ys)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:r(this,Fi,Lh)}})}destroy(){var t,e;(t=r(this,wi))==null||t.remove(),p(this,wi,null),p(this,ic,null),p(this,Ji,null),(e=r(this,Qi))==null||e.remove(),p(this,Qi,null)}};ke=new WeakMap,qi=new WeakMap,wi=new WeakMap,ic=new WeakMap,Ji=new WeakMap,Ps=new WeakMap,rc=new WeakMap,Qi=new WeakMap,ys=new WeakMap,Mr=new WeakMap,Xa=new WeakMap,Zi=new WeakMap,Bn=new WeakMap,Fi=new WeakSet,Lh=function(){return r(this,ke)&&"added"||r(this,ke)===null&&this.guessedText&&"review"||"missing"},Ef=async function(){var i,n,a;const t=r(this,wi);if(!t)return;if(r(this,Zi)){if(t.classList.toggle("done",!!r(this,ke)),t.setAttribute("data-l10n-id",r(Ze,Bn)[r(this,Fi,Lh)]),(i=r(this,ic))==null||i.setAttribute("data-l10n-id",r(Ze,Bn)[`${r(this,Fi,Lh)}-label`]),!r(this,ke)){(n=r(this,Ji))==null||n.remove();return}}else{if(!r(this,ke)&&!r(this,qi)){t.classList.remove("done"),(a=r(this,Ji))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=r(this,Ji);if(!e){p(this,Ji,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${r(this,ys).id}`;const o=100,l=r(this,ys)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(r(this,Ps)),p(this,Ps,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,Ps,setTimeout(()=>{p(this,Ps,null),r(this,Ji).classList.add("show"),r(this,ys)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var c;r(this,Ps)&&(clearTimeout(r(this,Ps)),p(this,Ps,null)),(c=r(this,Ji))==null||c.classList.remove("show")},{signal:l})}r(this,qi)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=r(this,ke)),e.parentNode||t.append(e);const s=r(this,ys).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},y(Ze,Bn,null),O(Ze,"_l10n",null);let lp=Ze;var De,ei,Ya,Lt,Pu,Un,si,Hn,jn,Ka,Iu,Yg;class uf{constructor(t){y(this,Iu);y(this,De,null);y(this,ei,null);y(this,Ya,!1);y(this,Lt,null);y(this,Pu,null);y(this,Un,null);y(this,si,null);y(this,Hn,null);y(this,jn,!1);y(this,Ka,null);p(this,Lt,t)}renderForToolbar(){const t=p(this,ei,document.createElement("button"));return t.className="comment",b(this,Iu,Yg).call(this,t,!1)}renderForStandalone(){const t=p(this,De,document.createElement("button"));t.className="annotationCommentButton";const e=r(this,Lt).commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(r(this,Lt)._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=r(this,Lt).commentButtonColor;i&&(s.backgroundColor=i)}return b(this,Iu,Yg).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=r(this,De)??r(this,ei))==null||t.focus()},0)}onUpdatedColor(){if(!r(this,De))return;const t=r(this,Lt).commentButtonColor;t&&(r(this,De).style.backgroundColor=t),r(this,Lt)._uiManager.updatePopupColor(r(this,Lt))}get commentButtonWidth(){var t;return(((t=r(this,De))==null?void 0:t.getBoundingClientRect().width)??0)/r(this,Lt).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(r(this,Ka))return r(this,Ka);if(!r(this,De))return null;const{x:t,y:e,height:s}=r(this,De).getBoundingClientRect(),{x:i,y:n,width:a,height:o}=r(this,Lt).parent.boundingClientRect;return[(t-i)/a,(e+s-n)/o]}set commentPopupPositionInLayer(t){p(this,Ka,t)}hasDefaultPopupPosition(){return r(this,Ka)===null}removeStandaloneCommentButton(){var t;(t=r(this,De))==null||t.remove(),p(this,De,null)}removeToolbarCommentButton(){var t;(t=r(this,ei))==null||t.remove(),p(this,ei,null)}setCommentButtonStates({selected:t,hasPopup:e}){r(this,De)&&(r(this,De).classList.toggle("selected",t),r(this,De).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=r(this,Lt).commentButtonPosition;const{width:h,height:d,x:f,y:g}=r(this,Lt);s=f+s*h,i=g+i*d}const n=r(this,Lt).parent.boundingClientRect,{x:a,y:o,width:l,height:c}=n;r(this,Lt)._uiManager.editComment(r(this,Lt),a+s*l,o+i*c,{...t,parentDimensions:n})}finish(){r(this,ei)&&(r(this,ei).focus({focusVisible:r(this,Ya)}),p(this,Ya,!1))}isDeleted(){return r(this,jn)||r(this,si)===""}isEmpty(){return r(this,si)===null}hasBeenEdited(){return this.isDeleted()||r(this,si)!==r(this,Pu)}serialize(){return this.data}get data(){return{text:r(this,si),richText:r(this,Un),date:r(this,Hn),deleted:this.isDeleted()}}set data(t){if(t!==r(this,si)&&p(this,Un,null),t===null){p(this,si,""),p(this,jn,!0);return}p(this,si,t),p(this,Hn,new Date),p(this,jn,!1)}restoreData({text:t,richText:e,date:s}){p(this,si,t),p(this,Un,e),p(this,Hn,s),p(this,jn,!1)}setInitialText(t,e=null){p(this,Pu,t),this.data=t,p(this,Hn,null),p(this,Un,e)}shown(){}destroy(){var t,e;(t=r(this,ei))==null||t.remove(),p(this,ei,null),(e=r(this,De))==null||e.remove(),p(this,De,null),p(this,si,""),p(this,Un,null),p(this,Hn,null),p(this,Lt,null),p(this,Ya,!1),p(this,jn,!1)}}De=new WeakMap,ei=new WeakMap,Ya=new WeakMap,Lt=new WeakMap,Pu=new WeakMap,Un=new WeakMap,si=new WeakMap,Hn=new WeakMap,jn=new WeakMap,Ka=new WeakMap,Iu=new WeakSet,Yg=function(t,e){if(!r(this,Lt)._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=[r(this,Lt)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=r(this,Lt)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",Li,{signal:s}),e&&(t.addEventListener("focusin",n=>{r(this,Lt)._focusEventsAllowed=!1,Ae(n)},{capture:!0,signal:s}),t.addEventListener("focusout",n=>{r(this,Lt)._focusEventsAllowed=!0,Ae(n)},{capture:!0,signal:s})),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),t===r(this,ei)?this.edit():r(this,Lt).toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(p(this,Ya,!0),i(n))},{signal:s}),t.addEventListener("pointerenter",()=>{r(this,Lt).toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{r(this,Lt).toggleComment(!1,!1)},{signal:s}),t};function Sy(u){u.preventDefault()}const Ey=1e-4;function Tg(u){return u.cancelable?(Ae(u),!0):(u.stopPropagation(),!1)}var nc,$n,ku,Mu,Ou,Ru,Du,qa,Gn,Or,Ja,tr,Rr,Qa,Dr,zn,Xt,Jb,Kg,qg,Jg,xf,Qb,Zb,Qg;class qb{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:a=null,onPanning:o=null,signal:l}){y(this,Xt);y(this,nc);y(this,$n,!1);y(this,ku,null);y(this,Mu);y(this,Ou);y(this,Ru);y(this,Du);y(this,qa);y(this,Gn,!1);y(this,Or,null);y(this,Ja);y(this,tr,new Set);y(this,Rr,null);y(this,Qa);y(this,Dr,null);y(this,zn,0);p(this,nc,t),p(this,ku,s),p(this,Mu,e),p(this,Ou,i),p(this,Ru,n),p(this,Du,a),p(this,qa,o),p(this,Qa,new AbortController),p(this,Ja,AbortSignal.any([l,r(this,Qa).signal])),t.addEventListener("touchstart",b(this,Xt,Jb).bind(this),{passive:!1,signal:r(this,Ja)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/fi.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/fi.pixelRatio}destroy(){var t,e;b(this,Xt,Qg).call(this),r(this,tr).clear(),(t=r(this,Qa))==null||t.abort(),p(this,Qa,null),(e=r(this,Or))==null||e.abort(),p(this,Or,null)}}nc=new WeakMap,$n=new WeakMap,ku=new WeakMap,Mu=new WeakMap,Ou=new WeakMap,Ru=new WeakMap,Du=new WeakMap,qa=new WeakMap,Gn=new WeakMap,Or=new WeakMap,Ja=new WeakMap,tr=new WeakMap,Rr=new WeakMap,Qa=new WeakMap,Dr=new WeakMap,zn=new WeakMap,Xt=new WeakSet,Jb=function(t){var s,i;if((s=r(this,Mu))!=null&&s.call(this))return;b(this,Xt,qg).call(this,t);const e=r(this,tr);for(const{identifier:n}of t.changedTouches)e.add(n);if(e.size===1){b(this,Xt,Kg).call(this);return}if(!r(this,Dr)){p(this,Dr,new AbortController);const n=AbortSignal.any([r(this,Ja),r(this,Dr).signal]),a=r(this,nc),o={signal:n,capture:!1,passive:!1};a.addEventListener("touchmove",b(this,Xt,Qb).bind(this),o);const l=b(this,Xt,Zb).bind(this);a.addEventListener("touchend",l,o),a.addEventListener("touchcancel",l,o),o.capture=!0,a.addEventListener("pointerdown",Ae,o),a.addEventListener("pointermove",Ae,o),a.addEventListener("pointercancel",Sy,o),a.addEventListener("pointerup",Sy,o),(i=r(this,Ou))==null||i.call(this)}p(this,Gn,Tg(t)),b(this,Xt,xf).call(this,t)},Kg=function(){if(r(this,Or))return;const t=p(this,Or,new AbortController),e=AbortSignal.any([r(this,Ja),t.signal]),s=r(this,nc),i={capture:!0,signal:e,passive:!1},n=a=>{var o;a.pointerType==="touch"&&((o=r(this,Or))==null||o.abort(),p(this,Or,null))};s.addEventListener("pointerdown",a=>{a.pointerType==="touch"&&(Ae(a),n(a))},i),s.addEventListener("pointerup",n,i),s.addEventListener("pointercancel",n,i)},qg=function(t){const e=r(this,tr);if(e.size===0)return;const s=p(this,tr,new Set);for(const{identifier:i}of t.touches)e.has(i)&&s.add(i)},Jg=function(t){const e=r(this,tr),s=[];for(const i of t.touches)e.has(i.identifier)&&s.push(i);return s},xf=function(t){var n;const e=b(this,Xt,Jg).call(this,t);if(e.length!==2||(n=r(this,ku))!=null&&n.call(this)){p(this,Rr,null);return}const[s,i]=e;p(this,Rr,{touch0X:s.screenX,touch0Y:s.screenY,touch1X:i.screenX,touch1Y:i.screenY,panX:(s.clientX+i.clientX)/2,panY:(s.clientY+i.clientY)/2,screenPanX:(s.screenX+i.screenX)/2,screenPanY:(s.screenY+i.screenY)/2})},Qb=function(t){var D,H,X,nt;if(!r(this,Rr))return;const e=b(this,Xt,Jg).call(this,t);if(e.length!==2)return;const s=r(this,Gn);if(p(this,Gn,Tg(t)),!r(this,Gn))return;if(!s){b(this,Xt,xf).call(this,t);return}const[i,n]=e,{screenX:a,screenY:o}=i,{screenX:l,screenY:c}=n,h=r(this,Rr),{touch0X:d,touch0Y:f,touch1X:g,touch1Y:m,panX:v,panY:w}=h,A=g-d,_=m-f,E=l-a,S=c-o,x=(i.clientX+n.clientX)/2,T=(i.clientY+n.clientY)/2;h.panX=x,h.panY=T;const C=x-v,I=T-w,k=(a+l)/2,M=(o+c)/2,R=Math.hypot(k-h.screenPanX,M-h.screenPanY);h.screenPanX=k,h.screenPanY=M;const N=Math.hypot(E,S),F=Math.hypot(A,_),j=r(this,$n)?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*R;if(N<Ey||F<Ey||Math.abs(F-N)<=j){(C||I)&&((D=r(this,qa))==null||D.call(this,C,I));return}h.touch0X=a,h.touch0Y=o,h.touch1X=l,h.touch1Y=c;const U=Math.sign(N-F);if(!r(this,$n)){p(this,$n,!0),p(this,zn,U),(C||I)&&((H=r(this,qa))==null||H.call(this,C,I));return}if(r(this,zn)){const gt=r(this,zn);if(p(this,zn,0),U!==gt&&Math.abs(N-F)<=2*R){p(this,$n,!1),(C||I)&&((X=r(this,qa))==null||X.call(this,C,I));return}}(nt=r(this,Ru))==null||nt.call(this,[v,w],F,N,C,I)},Zb=function(t){if(b(this,Xt,qg).call(this,t),r(this,tr).size>=2){b(this,Xt,xf).call(this,t);return}const e=!!r(this,Rr);b(this,Xt,Qg).call(this),r(this,tr).size===1&&b(this,Xt,Kg).call(this),e&&Tg(t)},Qg=function(){var t;p(this,Rr,null),p(this,$n,!1),p(this,zn,0),p(this,Gn,!1),r(this,Dr)&&(r(this,Dr).abort(),p(this,Dr,null),(t=r(this,Du))==null||t.call(this))};var Za,Ai,Gt,St,Fr,ac,Vn,Fu,Fe,to,Lr,ii,Wn,Lu,eo,Is,Nu,so,Nr,er,oc,lc,ri,Xn,Bu,yp,Q,Zg,Uu,tm,Tf,tw,ew,em,Cf,sm,sw,iw,rw,im,nw,rm,nm,aw,ow,lw,am,Nh;const et=class et{constructor(t){y(this,Q);y(this,Za,null);y(this,Ai,null);y(this,Gt,null);y(this,St,null);y(this,Fr,null);y(this,ac,!1);y(this,Vn,null);y(this,Fu,"");y(this,Fe,null);y(this,to,null);y(this,Lr,null);y(this,ii,null);y(this,Wn,null);y(this,Lu,"");y(this,eo,!1);y(this,Is,null);y(this,Nu,!1);y(this,so,!1);y(this,Nr,!1);y(this,er,null);y(this,oc,0);y(this,lc,0);y(this,ri,null);y(this,Xn,null);O(this,"isSelected",!1);O(this,"_isCopy",!1);O(this,"_editToolbar",null);O(this,"_initialOptions",Object.create(null));O(this,"_initialData",null);O(this,"_isVisible",!0);O(this,"_uiManager",null);O(this,"_focusEventsAllowed",!0);y(this,Bu,!1);y(this,yp,et._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:s,pageHeight:i,pageX:n,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=et.prototype._resizeWithKeyboard,e=bl.TRANSLATE_SMALL,s=bl.TRANSLATE_BIG;return V(this,"_resizerKeyboardManager",new yl([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],et.prototype._stopResizingWithKeyboard]]))}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return V(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new vS({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(et._l10n??(et._l10n=t),et._l10nAlert??(et._l10nAlert=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"})),et._l10nResizer??(et._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"})),et._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);et._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){vt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return r(this,Bu)}set _isDraggable(t){var e;p(this,Bu,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=r(this,yp)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(b(this,Q,Nh).call(this),(e=r(this,ii))==null||e.remove(),p(this,ii,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(r(this,eo)?p(this,eo,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){b(this,Q,Zg).call(this,this.parentDimensions,t,e)}translateInPage(t,e){r(this,Is)||p(this,Is,[this.x,this.y,this.width,this.height]),b(this,Q,Zg).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){r(this,Is)||p(this,Is,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,c]=this.getBaseTranslation();a+=l,o+=c;const{style:h}=s;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!r(this,Is)&&(r(this,Is)[0]!==this.x||r(this,Is)[1]!==this.y)}get _hasBeenResized(){return!!r(this,Is)&&(r(this,Is)[2]!==this.width||r(this,Is)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=et,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:n,y:a,width:o,height:l}=this;if(o*=s,l*=i,n*=s,a*=i,this._mustFixPosition)switch(t){case 0:n=jt(n,0,s-o),a=jt(a,0,i-l);break;case 90:n=jt(n,0,s-l),a=jt(a,o,i);break;case 180:n=jt(n,o,s),a=jt(a,l,i);break;case 270:n=jt(n,l,s),a=jt(a,0,i-o);break}this.x=n/=s,this.y=a/=i;const[c,h]=this.getBaseTranslation();n+=c,a+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return b(s=et,Uu,tm).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=et,Uu,tm).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=r(this,Gt))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||r(this,so))return this._editToolbar;this._editToolbar=new Hg(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this.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=r(this,Gt))==null||e.destroy()}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return r(this,Gt)||(lp.initialize(et._l10n),p(this,Gt,new lp(this)),r(this,Za)&&(r(this,Gt).data=r(this,Za),p(this,Za,null))),r(this,Gt)}get altTextData(){var t;return(t=r(this,Gt))==null?void 0:t.data}set altTextData(t){r(this,Gt)&&(r(this,Gt).data=t)}get guessedAltText(){var t;return(t=r(this,Gt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=r(this,Gt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=r(this,Gt))==null?void 0:e.serialize(t)}hasAltText(){return!!r(this,Gt)&&!r(this,Gt).isEmpty()}hasAltTextData(){var t;return((t=r(this,Gt))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=r(this,St))==null||t.focusButton()}addCommentButton(){return this.canAddComment?r(this,St)||p(this,St,new uf(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(r(this,Fr)){this._uiManager.isEditingMode()&&r(this,Fr).classList.remove("hidden");return}this.hasComment&&(p(this,Fr,r(this,St).renderForStandalone()),this.div.append(r(this,Fr)))}}removeStandaloneCommentButton(){r(this,St).removeStandaloneCommentButton(),p(this,Fr,null)}hideStandaloneCommentButton(){var t;(t=r(this,Fr))==null||t.classList.add("hidden")}get comment(){if(!r(this,St))return null;const{data:{richText:t,text:e,date:s,deleted:i}}=r(this,St);return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){r(this,St)||p(this,St,new uf(this)),typeof t=="object"&&t!==null?r(this,St).restoreData(t):r(this,St).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:s}){if(!e||(r(this,St)||p(this,St,new uf(this)),r(this,St).setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){var t;return(t=r(this,St))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=r(this,St))==null?void 0:t.isDeleted()}get hasComment(){return!!r(this,St)&&!r(this,St).isEmpty()&&!r(this,St).isDeleted()}async editComment(t){r(this,St)||p(this,St,new uf(this)),r(this,St).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){r(this,St).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[n]=this.pageDimensions,[a]=this.pageTranslation,o=a+n+1,l=i-100,c=o+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,c,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){r(this,St).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var a;const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=r(this,ac)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),b(this,Q,rm).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,n]=this.getInitialTranslation();return this.translate(i,n),Fb(this,t,["keydown","pointerdown","dblclick"]),b(this,Q,nm).call(this),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=Et.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,eo,!0),this._isDraggable){b(this,Q,nw).call(this,t);return}b(this,Q,im).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){r(this,er)&&clearTimeout(r(this,er)),p(this,er,setTimeout(()=>{var t;p(this,er,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,a]=this.pageDimensions,[o,l]=this.pageTranslation,c=t/i,h=e/i,d=this.x*n,f=this.y*a,g=this.width*n,m=this.height*a;switch(s){case 0:return[d+c+o,a-f-h-m+l,d+c+g+o,a-f-h+l];case 90:return[d+h+o,a-f+c+l,d+h+m+o,a-f+c+g+l];case 180:return[d-c-g+o,a-f+h+l,d-c+o,a-f+h+m+l];case 270:return[d-h-m+o,a-f-c-g+l,d-h+o,a-f-c+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,a]=t,o=n-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[n,e-i,o,l];case 270:return[n,e-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&et._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=r(this,St))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:n,richText:a},uid:o,pageIndex:l,creationDate:c,modificationDate:h}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:a,contentsObj:{str:t},creationDate:c,modificationDate:s||h,popupRef:!n,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),p(this,so,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),p(this,so,!1),!0):!1}isInEditMode(){return r(this,so)}shouldGetKeyboardEvents(){return r(this,Nr)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:a}=window;return e<a&&i>0&&t<n&&s>0}rebuild(){b(this,Q,rm).call(this),b(this,Q,nm).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 s;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((s=this._initialData)==null?void 0:s.popupRef)||""}}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,p(i,Za,t.accessibilityData),i._isCopy=t.isCopy||!1;const[n,a]=i.pageDimensions,[o,l,c,h]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/n,i.y=l/a,i.width=c/n,i.height=h/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e,s;if((t=r(this,Wn))==null||t.abort(),p(this,Wn,null),this.isEmpty()||this.commit(),(e=r(this,Xn))==null||e.destroy(),p(this,Xn,null),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),r(this,er)&&(clearTimeout(r(this,er)),p(this,er,null)),b(this,Q,Nh).call(this),this.removeEditToolbar(),r(this,ri)){for(const i of r(this,ri).values())clearTimeout(i);p(this,ri,null)}this.parent=null,(s=r(this,ii))==null||s.remove(),p(this,ii,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,Q,tw).call(this),r(this,Fe).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,[s,i,n,a]=this.getPDFRect();return[et._round(s+(n-s)*t),et._round(i+(a-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return r(this,St).commentPopupPositionInLayer}set commentPopupPosition(t){r(this,St).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return r(this,St).hasDefaultPopupPosition()}get commentButtonWidth(){return r(this,St).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=r(this,St))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,Lr,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=r(this,Fe).children;if(!r(this,Ai)){p(this,Ai,Array.from(e));const a=b(this,Q,aw).bind(this),o=b(this,Q,ow).bind(this),l=this._uiManager._signal;for(const c of r(this,Ai)){const h=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",a,{signal:l}),c.addEventListener("blur",o,{signal:l}),c.addEventListener("focus",b(this,Q,lw).bind(this,h),{signal:l}),c.setAttribute("data-l10n-id",et._l10nResizer[h])}}const s=r(this,Ai)[0];let i=0;for(const a of e){if(a===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(r(this,Ai).length/4);if(n!==i){if(n<i)for(let o=0;o<i-n;o++)r(this,Fe).append(r(this,Fe).firstElementChild);else if(n>i)for(let o=0;o<n-i;o++)r(this,Fe).firstElementChild.before(r(this,Fe).lastElementChild);let a=0;for(const o of e){const c=r(this,Ai)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",et._l10nResizer[c])}}b(this,Q,am).call(this,0),p(this,Nr,!0),r(this,Fe).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){r(this,Nr)&&b(this,Q,sm).call(this,r(this,Lu),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,Q,Nh).call(this),this.div.focus()}select(){var t,e,s;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 i,n;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((n=this._editToolbar)==null||n.show())});return}(e=this._editToolbar)==null||e.show(),(s=r(this,Gt))==null||s.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,s,i,n;this.isSelected&&(this.isSelected=!1,(t=r(this,Fe))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(n=r(this,Gt))==null||n.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 r(this,Nu)}set isEditing(t){p(this,Nu,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){r(this,ri)||p(this,ri,new Map);const{action:s}=t;let i=r(this,ri).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),r(this,ri).delete(s),r(this,ri).size===0&&p(this,ri,null)},et._telemetryTimeout),r(this,ri).set(s,i);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),p(this,ac,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,ac,!0)}updateFakeAnnotationElement(t){if(!r(this,ii)&&!this.deleted){p(this,ii,t.addFakeAnnotation(this));return}if(this.deleted){r(this,ii).remove(),p(this,ii,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&r(this,ii).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 s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};Za=new WeakMap,Ai=new WeakMap,Gt=new WeakMap,St=new WeakMap,Fr=new WeakMap,ac=new WeakMap,Vn=new WeakMap,Fu=new WeakMap,Fe=new WeakMap,to=new WeakMap,Lr=new WeakMap,ii=new WeakMap,Wn=new WeakMap,Lu=new WeakMap,eo=new WeakMap,Is=new WeakMap,Nu=new WeakMap,so=new WeakMap,Nr=new WeakMap,er=new WeakMap,oc=new WeakMap,lc=new WeakMap,ri=new WeakMap,Xn=new WeakMap,Bu=new WeakMap,yp=new WeakMap,Q=new WeakSet,Zg=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},Uu=new WeakSet,tm=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},Tf=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},tw=function(){if(r(this,Fe))return;p(this,Fe,document.createElement("div")),r(this,Fe).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");r(this,Fe).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,Q,ew).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Li,{signal:e}),i.tabIndex=-1}this.div.prepend(r(this,Fe))},ew=function(t,e){var h;e.preventDefault();const{isMac:s}=Et.platform;if(e.button!==0||e.ctrlKey&&s)return;(h=r(this,Gt))==null||h.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,p(this,to,[e.screenX,e.screenY]);const n=new AbortController,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,Q,sm).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Ae,{passive:!1,signal:a}),window.addEventListener("contextmenu",Li,{signal:a}),p(this,Lr,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const c=()=>{var d;n.abort(),this.parent.togglePointerEvents(!0),(d=r(this,Gt))==null||d.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,Q,Cf).call(this)};window.addEventListener("pointerup",c,{signal:a}),window.addEventListener("blur",c,{signal:a})},em=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Cf=function(){if(!r(this,Lr))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=r(this,Lr);p(this,Lr,null);const n=this.x,a=this.y,o=this.width,l=this.height;n===t&&a===e&&o===s&&l===i||this.addCommands({cmd:b(this,Q,em).bind(this,n,a,o,l),undo:b(this,Q,em).bind(this,t,e,s,i),mustExec:!0})},sm=function(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,o=this.width,l=this.height,c=et.MIN_SIZE/s,h=et.MIN_SIZE/i,d=b(this,Q,Tf).call(this,this.rotation),f=(D,H)=>[d[0]*D+d[2]*H,d[1]*D+d[3]*H],g=b(this,Q,Tf).call(this,360-this.rotation),m=(D,H)=>[g[0]*D+g[2]*H,g[1]*D+g[3]*H];let v,w,A=!1,_=!1;switch(t){case"topLeft":A=!0,v=(D,H)=>[0,0],w=(D,H)=>[D,H];break;case"topMiddle":v=(D,H)=>[D/2,0],w=(D,H)=>[D/2,H];break;case"topRight":A=!0,v=(D,H)=>[D,0],w=(D,H)=>[0,H];break;case"middleRight":_=!0,v=(D,H)=>[D,H/2],w=(D,H)=>[0,H/2];break;case"bottomRight":A=!0,v=(D,H)=>[D,H],w=(D,H)=>[0,0];break;case"bottomMiddle":v=(D,H)=>[D/2,H],w=(D,H)=>[D/2,0];break;case"bottomLeft":A=!0,v=(D,H)=>[0,H],w=(D,H)=>[D,0];break;case"middleLeft":_=!0,v=(D,H)=>[0,H/2],w=(D,H)=>[D,H/2];break}const E=v(o,l),S=w(o,l);let x=f(...S);const T=et._round(n+x[0]),C=et._round(a+x[1]);let I=1,k=1,M,R;if(e.fromKeyboard)({deltaX:M,deltaY:R}=e);else{const{screenX:D,screenY:H}=e,[X,nt]=r(this,to);[M,R]=this.screenToPageTranslation(D-X,H-nt),r(this,to)[0]=D,r(this,to)[1]=H}if([M,R]=m(M/s,R/i),A){const D=Math.hypot(o,l);I=k=Math.max(Math.min(Math.hypot(S[0]-E[0]-M,S[1]-E[1]-R)/D,1/o,1/l),c/o,h/l)}else _?I=jt(Math.abs(S[0]-E[0]-M),c,1)/o:k=jt(Math.abs(S[1]-E[1]-R),h,1)/l;const N=et._round(o*I),F=et._round(l*k);x=f(...w(N,F));const j=T-x[0],U=C-x[1];r(this,Is)||p(this,Is,[this.x,this.y,this.width,this.height]),this.width=N,this.height=F,this.x=j,this.y=U,this.setDims(),this.fixAndSetPosition(),this._onResizing()},sw=function(){var t;p(this,Lr,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=r(this,Gt))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},iw=function(t,e,s){let n=.7*(s/e)+1-.7;if(n===1)return;const a=b(this,Q,Tf).call(this,this.rotation),o=(T,C)=>[a[0]*T+a[2]*C,a[1]*T+a[3]*C],[l,c]=this.parentDimensions,h=this.x,d=this.y,f=this.width,g=this.height,m=et.MIN_SIZE/l,v=et.MIN_SIZE/c;n=Math.max(Math.min(n,1/f,1/g),m/f,v/g);const w=et._round(f*n),A=et._round(g*n);if(w===f&&A===g)return;r(this,Is)||p(this,Is,[h,d,f,g]);const _=o(f/2,g/2),E=et._round(h+_[0]),S=et._round(d+_[1]),x=o(w/2,A/2);this.x=E-x[0],this.y=S-x[1],this.width=w,this.height=A,this.setDims(),this.fixAndSetPosition(),this._onResizing()},rw=function(){var t;(t=r(this,Gt))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,Q,Cf).call(this)},im=function(t){const{isMac:e}=Et.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},nw=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,n=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:n},o=c=>{i.abort(),p(this,Vn,null),p(this,eo,!1),this._uiManager.endDragSession()||b(this,Q,im).call(this,c),s&&this._onStopDragging()};e&&(p(this,oc,t.clientX),p(this,lc,t.clientY),p(this,Vn,t.pointerId),p(this,Fu,t.pointerType),window.addEventListener("pointermove",c=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:h,clientY:d,pointerId:f}=c;if(f!==r(this,Vn)){Ae(c);return}const[g,m]=this.screenToPageTranslation(h-r(this,oc),d-r(this,lc));p(this,oc,h),p(this,lc,d),this._uiManager.dragSelectedEditors(g,m),this.div.scrollIntoView({block:"nearest"})},a),window.addEventListener("touchmove",Ae,a),window.addEventListener("pointerdown",c=>{c.pointerType===r(this,Fu)&&(r(this,Xn)||c.isPrimary)&&o(c),Ae(c)},a));const l=c=>{if(!r(this,Vn)||r(this,Vn)===c.pointerId){o(c);return}Ae(c)};window.addEventListener("pointerup",l,{signal:n}),window.addEventListener("blur",l,{signal:n})},rm=function(){if(r(this,Wn)||!this.div)return;p(this,Wn,new AbortController);const t=this._uiManager.combinedSignal(r(this,Wn));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},nm=function(){r(this,Xn)||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom||p(this,Xn,new qb({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,Q,sw).bind(this),onPinching:b(this,Q,iw).bind(this),onPinchEnd:b(this,Q,rw).bind(this),signal:this._uiManager._signal}))},aw=function(t){et._resizerKeyboardManager.exec(this,t)},ow=function(t){var e;r(this,Nr)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==r(this,Fe)&&b(this,Q,Nh).call(this)},lw=function(t){p(this,Lu,r(this,Nr)?t:"")},am=function(t){if(r(this,Ai))for(const e of r(this,Ai))e.tabIndex=t},Nh=function(){p(this,Nr,!1),b(this,Q,am).call(this,-1),b(this,Q,Cf).call(this)},y(et,Uu),O(et,"_l10n",null),O(et,"_l10nAlert",null),O(et,"_l10nResizer",null),O(et,"_borderLineWidth",-1),O(et,"_colorManager",new Gg),O(et,"_zIndex",1),O(et,"_telemetryTimeout",1e3);let Mt=et;class vS extends Mt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const xy=3285377520,Ys=4294901760,Hi=65535;class om{constructor(t){this.h1=t?t&4294967295:xy,this.h2=t?t&4294967295:xy}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let v=0,w=t.length;v<w;v++){const A=t.charCodeAt(v);A<=255?e[s++]=A:(e[s++]=A>>>8,e[s++]=A&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,n=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,c=this.h1,h=this.h2;const d=3432918353,f=461845907,g=d&Hi,m=f&Hi;for(let v=0;v<i;v++)v&1?(o=a[v],o=o*d&Ys|o*g&Hi,o=o<<15|o>>>17,o=o*f&Ys|o*m&Hi,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(l=a[v],l=l*d&Ys|l*g&Hi,l=l<<15|l>>>17,l=l*f&Ys|l*m&Hi,h^=l,h=h<<13|h>>>19,h=h*5+3864292196);switch(o=0,n){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*d&Ys|o*g&Hi,o=o<<15|o>>>17,o=o*f&Ys|o*m&Hi,i&1?c^=o:h^=o}this.h1=c,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Ys|t*36045&Hi,e=e*4283543511&Ys|((e<<16|t>>>16)*2950163797&Ys)>>>16,t^=e>>>1,t=t*444984403&Ys|t*60499&Hi,e=e*3301882366&Ys|((e<<16|t>>>16)*3120437893&Ys)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const ou=Object.freeze({map:null,hash:"",transfer:void 0});var io,ro,Br,Le,bp,cw;class Kv{constructor(){y(this,bp);y(this,io,!1);y(this,ro,null);y(this,Br,null);y(this,Le,new Map);O(this,"onSetModified",null);O(this,"onResetModified",null);O(this,"onAnnotationEditor",null)}getValue(t,e){const s=r(this,Le).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return r(this,Le).get(t)}remove(t){var s;const e=r(this,Le).get(t);e!==void 0&&(e instanceof Mt&&r(this,Br).delete(e.annotationElementId),r(this,Le).delete(t),r(this,Le).size===0&&this.resetModified(),!r(this,Le).values().some(i=>i instanceof Mt)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(t,e){var n;const s=r(this,Le).get(t);let i=!1;if(s!==void 0)for(const[a,o]of Object.entries(e))s[a]!==o&&(i=!0,s[a]=o);else i=!0,r(this,Le).set(t,e);i&&b(this,bp,cw).call(this),e instanceof Mt&&((r(this,Br)||p(this,Br,new Map)).set(e.annotationElementId,e),(n=this.onAnnotationEditor)==null||n.call(this,e.constructor._type))}has(t){return r(this,Le).has(t)}get size(){return r(this,Le).size}resetModified(){var t;r(this,io)&&(p(this,io,!1),(t=this.onResetModified)==null||t.call(this))}get print(){return new hw(this)}get serializable(){if(r(this,Le).size===0)return ou;const t=new Map,e=new om,s=[],i=Object.create(null);let n=!1;for(const[a,o]of r(this,Le)){const l=o instanceof Mt?o.serialize(!1,i):o;o.page&&(o.pageIndex=o.page._pageIndex,delete o.page),l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),n||(n=!!l.bitmap))}if(n)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:ou}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const n of r(this,Le).values()){if(!(n instanceof Mt)){n.popup&&(n.popup.deleted?i+=1:s+=1);continue}n.isCommentDeleted?i+=1:n.hasEditedComment&&(s+=1);const a=n.telemetryFinalData;if(!a)continue;const{type:o}=a;e.getOrInsertComputed(o,()=>Object.getPrototypeOf(n).constructor),t||(t=Object.create(null));const l=t[o]||(t[o]=new Map);for(const[c,h]of Object.entries(a)){if(c==="type")continue;const d=l.getOrInsertComputed(c,zv);d.set(h,(d.get(h)??0)+1)}}if((i>0||s>0)&&(t||(t=Object.create(null)),t.comments={deleted:i,edited:s}),!t)return null;for(const[n,a]of e)t[n]=a.computeTelemetryFinalData(t[n]);return t}resetModifiedIds(){p(this,ro,null)}updateEditor(t,e){var i;const s=(i=r(this,Br))==null?void 0:i.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=r(this,Br))==null?void 0:e.get(t))||null}get modifiedIds(){if(r(this,ro))return r(this,ro);const t=[];if(r(this,Br))for(const s of r(this,Br).values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new om;s.update(t.join(",")),e=s.hexdigest()}return p(this,ro,{ids:new Set(t),hash:e})}[Symbol.iterator](){return r(this,Le).entries()}}io=new WeakMap,ro=new WeakMap,Br=new WeakMap,Le=new WeakMap,bp=new WeakSet,cw=function(){var t;r(this,io)||(p(this,io,!0),(t=this.onSetModified)==null||t.call(this))};var Hu;class hw extends Kv{constructor(e){super();y(this,Hu,ou);const{serializable:s}=e;if(s===ou)return;const{map:i,hash:n,transfer:a}=s,o=structuredClone(i,a?{transfer:a}:null);p(this,Hu,{map:o,hash:n,transfer:[]})}get print(){vt("Should not call PrintAnnotationStorage.print")}get serializable(){return r(this,Hu)}get modifiedIds(){return V(this,"modifiedIds",{ids:new Set,hash:""})}}Hu=new WeakMap;b0();const Ml="__forcedDependency",{floor:Ty,ceil:Cy}=Math;function Py(u,t,e,s,i,n){u[t*4+0]=Math.min(u[t*4+0],e),u[t*4+1]=Math.min(u[t*4+1],s),u[t*4+2]=Math.max(u[t*4+2],i),u[t*4+3]=Math.max(u[t*4+3],n)}function yS(u,t,e,s,i){let n;u?(u<0&&(n=i[0],i[0]=i[2],i[2]=n),i[0]*=u,i[2]*=u,t<0&&(n=i[1],i[1]=i[3],i[3]=n),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=e,i[1]+=s,i[2]+=e,i[3]+=s}const lm=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var cc,Yn;class bS{constructor(t,e){y(this,cc);y(this,Yn);p(this,cc,t),p(this,Yn,e)}get length(){return r(this,cc).length}isEmpty(t){return r(this,cc)[t]===lm}minX(t){return r(this,Yn)[t*4+0]/256}minY(t){return r(this,Yn)[t*4+1]/256}maxX(t){return(r(this,Yn)[t*4+2]+1)/256}maxY(t){return(r(this,Yn)[t*4+3]+1)/256}}cc=new WeakMap,Yn=new WeakMap;const Iy=(u,t)=>u==null?void 0:u.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var Ur,At,Ht,no,ao,oo,Xe,ju,cm;class wS{constructor(t,e){y(this,ju);y(this,Ur,[[1,0,0,1,0,0]]);y(this,At,[-1/0,-1/0,1/0,1/0]);y(this,Ht,new Float64Array(yr));O(this,"_pendingBBoxIdx",-1);y(this,no);y(this,ao);y(this,oo);y(this,Xe);O(this,"_savesStack",[]);O(this,"_markedContentStack",[]);p(this,no,t.width),p(this,ao,t.height),b(this,ju,cm).call(this,e)}growOperationsCount(t){t>=r(this,Xe).length&&b(this,ju,cm).call(this,t,r(this,Xe))}get clipBox(){return r(this,At)}save(t){return p(this,At,{__proto__:r(this,At)}),this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(r(this,At));if(s===null)return this;p(this,At,s);const i=this._savesStack.pop();return i!==void 0&&(e==null||e(i,t),r(this,Xe)[t]=r(this,Xe)[i]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const s=this._savesStack.pop();return s!==void 0&&(e==null||e(s,t),r(this,Xe)[t]=r(this,Xe)[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e==null||e(s,t),r(this,Xe)[t]=r(this,Xe)[s]),this}pushBaseTransform(t){return r(this,Ur).push($.multiplyByDOMMatrix(r(this,Ur).at(-1),t.getTransform())),this}popBaseTransform(){return r(this,Ur).length>1&&r(this,Ur).pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,r(this,Ht).set(yr,0)),this}recordClipBox(t,e,s,i,n,a){const o=$.multiplyByDOMMatrix(r(this,Ur).at(-1),e.getTransform()),l=yr.slice();$.axialAlignedBoundingBox([s,n,i,a],o,l);const c=$.intersect(r(this,At),l);return c?(r(this,At)[0]=c[0],r(this,At)[1]=c[1],r(this,At)[2]=c[2],r(this,At)[3]=c[3]):(r(this,At)[0]=r(this,At)[1]=1/0,r(this,At)[2]=r(this,At)[3]=-1/0),this}recordBBox(t,e,s,i,n,a){const o=r(this,At);if(o[0]===1/0)return this;const l=$.multiplyByDOMMatrix(r(this,Ur).at(-1),e.getTransform());if(o[0]===-1/0)return $.axialAlignedBoundingBox([s,n,i,a],l,r(this,Ht)),this;const c=yr.slice();return $.axialAlignedBoundingBox([s,n,i,a],l,c),r(this,Ht)[0]=jt(c[0],o[0],r(this,Ht)[0]),r(this,Ht)[1]=jt(c[1],o[1],r(this,Ht)[1]),r(this,Ht)[2]=jt(c[2],r(this,Ht)[2],o[2]),r(this,Ht)[3]=jt(c[3],r(this,Ht)[3],o[3]),this}recordFullPageBBox(t){return r(this,Ht)[0]=Math.max(0,r(this,At)[0]),r(this,Ht)[1]=Math.max(0,r(this,At)[1]),r(this,Ht)[2]=Math.min(r(this,no),r(this,At)[2]),r(this,Ht)[3]=Math.min(r(this,ao),r(this,At)[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=Ty(r(this,Ht)[0]*256/r(this,no)),n=Ty(r(this,Ht)[1]*256/r(this,ao)),a=Cy(r(this,Ht)[2]*256/r(this,no)),o=Cy(r(this,Ht)[3]*256/r(this,ao));if(Py(r(this,oo),t,i,n,a,o),s)for(const l of s)for(const c of l)c!==t&&Py(r(this,oo),c,i,n,a,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,r(this,At)[0]=Math.max(r(this,At)[0],r(this,Ht)[0]),r(this,At)[1]=Math.max(r(this,At)[1],r(this,Ht)[1]),r(this,At)[2]=Math.min(r(this,At)[2],r(this,Ht)[2]),r(this,At)[3]=Math.min(r(this,At)[3],r(this,Ht)[3])),this}take(){return new bS(r(this,Xe),r(this,oo))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,n=0,a=0,o){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}Ur=new WeakMap,At=new WeakMap,Ht=new WeakMap,no=new WeakMap,ao=new WeakMap,oo=new WeakMap,Xe=new WeakMap,ju=new WeakSet,cm=function(t,e){const s=new ArrayBuffer(t*4);p(this,oo,new Uint8ClampedArray(s)),p(this,Xe,new Uint32Array(s)),e&&e.length>0?(r(this,Xe).set(e),r(this,Xe).fill(lm,e.length)):r(this,Xe).fill(lm)};var bs,ws,lo,_i,hc,Kn,qn,Pt;class AS{constructor(t,e=!1){y(this,bs,{__proto__:null});y(this,ws,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Ml]:[]});y(this,lo,new Map);y(this,_i,new Set);y(this,hc,new Map);y(this,Kn);y(this,qn);y(this,Pt);p(this,Pt,t),e&&(p(this,Kn,new Map),p(this,qn,(s,i)=>{Iy(r(this,Kn),i).dependencies.add(s)}))}get clipBox(){return r(this,Pt).clipBox}growOperationsCount(t){r(this,Pt).growOperationsCount(t)}save(t){return p(this,bs,{__proto__:r(this,bs)}),p(this,ws,{__proto__:r(this,ws),transform:{__proto__:r(this,ws).transform},moveText:{__proto__:r(this,ws).moveText},sameLineText:{__proto__:r(this,ws).sameLineText},[Ml]:{__proto__:r(this,ws)[Ml]}}),r(this,Pt).save(t),this}restore(t){r(this,Pt).restore(t,r(this,qn));const e=Object.getPrototypeOf(r(this,bs));return e===null?this:(p(this,bs,e),p(this,ws,Object.getPrototypeOf(r(this,ws))),this)}recordOpenMarker(t){return r(this,Pt).recordOpenMarker(t,r(this,qn)),this}getOpenMarker(){return r(this,Pt).getOpenMarker()}recordCloseMarker(t){return r(this,Pt).recordCloseMarker(t,r(this,qn)),this}beginMarkedContent(t){return r(this,Pt).beginMarkedContent(t),this}endMarkedContent(t){return r(this,Pt).endMarkedContent(t,r(this,qn)),this}pushBaseTransform(t){return r(this,Pt).pushBaseTransform(t),this}popBaseTransform(){return r(this,Pt).popBaseTransform(),this}recordSimpleData(t,e){return r(this,bs)[t]=e,this}recordIncrementalData(t,e){return r(this,ws)[t].push(e),this}resetIncrementalData(t,e){return r(this,ws)[t].length=0,this}recordNamedData(t,e){return r(this,lo).set(t,e),this}recordSimpleDataFromNamed(t,e,s){r(this,bs)[t]=r(this,lo).get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Ml,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in r(this,bs)&&this.recordFutureForcedDependency(e,r(this,bs)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of r(this,_i))this.recordFutureForcedDependency(Ml,t);return this}resetBBox(t){return r(this,Pt).resetBBox(t),this}recordClipBox(t,e,s,i,n,a){return r(this,Pt).recordClipBox(t,e,s,i,n,a),this}recordBBox(t,e,s,i,n,a){return r(this,Pt).recordBBox(t,e,s,i,n,a),this}recordCharacterBBox(t,e,s,i=1,n=0,a=0,o){const l=s.bbox;let c,h;if(l&&(c=l[2]!==l[0]&&l[3]!==l[1]&&r(this,hc).get(s),c!==!1&&(h=[0,0,0,0],$.axialAlignedBoundingBox(l,s.fontMatrix,h),(i!==1||n!==0||a!==0)&&yS(i,-i,n,a,h),c)))return this.recordBBox(t,e,h[0],h[2],h[1],h[3]);if(!o)return this.recordFullPageBBox(t);const d=o();return l&&h&&c===void 0&&(c=h[0]<=n-d.actualBoundingBoxLeft&&h[2]>=n+d.actualBoundingBoxRight&&h[1]<=a-d.actualBoundingBoxAscent&&h[3]>=a+d.actualBoundingBoxDescent,r(this,hc).set(s,c),c)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,n-d.actualBoundingBoxLeft,n+d.actualBoundingBoxRight,a-d.actualBoundingBoxAscent,a+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return r(this,Pt).recordFullPageBBox(t),this}getSimpleIndex(t){return r(this,bs)[t]}recordDependencies(t,e){const s=r(this,_i),i=r(this,bs),n=r(this,ws);for(const a of e)a in r(this,bs)?s.add(i[a]):a in n&&n[a].forEach(s.add,s);return this}recordNamedDependency(t,e){return r(this,lo).has(e)&&r(this,_i).add(r(this,lo).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Ml]),r(this,Kn)){const i=Iy(r(this,Kn),t),{dependencies:n}=i;r(this,_i).forEach(n.add,n),r(this,Pt)._savesStack.forEach(n.add,n),r(this,Pt)._markedContentStack.forEach(n.add,n),n.delete(t),i.isRenderingOperation=!0}const s=!e&&t===r(this,Pt)._pendingBBoxIdx;return r(this,Pt).recordOperation(t,e,[r(this,_i),r(this,Pt)._savesStack,r(this,Pt)._markedContentStack]),s&&r(this,_i).clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(r(this,_i));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===r(this,Pt)._pendingBBoxIdx;return r(this,Pt).bboxToClipBoxDropOperation(t),s&&r(this,_i).clear(),this}take(){return r(this,hc).clear(),r(this,Pt).take()}takeDebugMetadata(){return r(this,Kn)}}bs=new WeakMap,ws=new WeakMap,lo=new WeakMap,_i=new WeakMap,hc=new WeakMap,Kn=new WeakMap,qn=new WeakMap,Pt=new WeakMap;var It,ee,Si,uc,dc;const ny=class ny{constructor(t,e,s){y(this,It);y(this,ee);y(this,Si);y(this,uc,0);y(this,dc,0);if(t instanceof ny&&r(t,Si)===!!s)return t;p(this,It,t),p(this,ee,e),p(this,Si,!!s)}get clipBox(){return r(this,It).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return Ft(this,dc)._++,r(this,It).save(r(this,ee)),this}restore(t){return r(this,dc)>0&&(r(this,It).restore(r(this,ee)),Ft(this,dc)._--),this}recordOpenMarker(t){return Ft(this,uc)._++,this}getOpenMarker(){return r(this,uc)>0?r(this,ee):r(this,It).getOpenMarker()}recordCloseMarker(t){return Ft(this,uc)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return r(this,It).pushBaseTransform(t),this}popBaseTransform(){return r(this,It).popBaseTransform(),this}recordSimpleData(t,e){return r(this,It).recordSimpleData(t,r(this,ee)),this}recordIncrementalData(t,e){return r(this,It).recordIncrementalData(t,r(this,ee)),this}resetIncrementalData(t,e){return r(this,It).resetIncrementalData(t,r(this,ee)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return r(this,It).recordSimpleDataFromNamed(t,e,r(this,ee)),this}recordFutureForcedDependency(t,e){return r(this,It).recordFutureForcedDependency(t,r(this,ee)),this}inheritSimpleDataAsFutureForcedDependencies(t){return r(this,It).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return r(this,It).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return r(this,Si)||r(this,It).resetBBox(r(this,ee)),this}recordClipBox(t,e,s,i,n,a){return r(this,Si)||r(this,It).recordClipBox(r(this,ee),e,s,i,n,a),this}recordBBox(t,e,s,i,n,a){return r(this,Si)||r(this,It).recordBBox(r(this,ee),e,s,i,n,a),this}recordCharacterBBox(t,e,s,i,n,a,o){return r(this,Si)||r(this,It).recordCharacterBBox(r(this,ee),e,s,i,n,a,o),this}recordFullPageBBox(t){return r(this,Si)||r(this,It).recordFullPageBBox(r(this,ee)),this}getSimpleIndex(t){return r(this,It).getSimpleIndex(t)}recordDependencies(t,e){return r(this,It).recordDependencies(r(this,ee),e),this}recordNamedDependency(t,e){return r(this,It).recordNamedDependency(r(this,ee),e),this}recordOperation(t){return r(this,It).recordOperation(r(this,ee),!0),this}recordShowTextOperation(t){return r(this,It).recordShowTextOperation(r(this,ee),!0),this}bboxToClipBoxDropOperation(t){return r(this,Si)||r(this,It).bboxToClipBoxDropOperation(r(this,ee),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};It=new WeakMap,ee=new WeakMap,Si=new WeakMap,uc=new WeakMap,dc=new WeakMap;let lu=ny;const Ks={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","filter","fillColor"]};var co,ho,uo,fo,po,$u;const iu=class iu{constructor(t){y(this,co);y(this,ho);y(this,uo,4);y(this,fo,0);y(this,po,new(r(iu,$u))(r(this,uo)*6));p(this,co,t.width),p(this,ho,t.height)}record(t,e,s,i){if(r(this,fo)===r(this,uo)){p(this,uo,r(this,uo)*2);const o=new(r(iu,$u))(r(this,uo)*6);o.set(r(this,po)),p(this,po,o)}const n=Ot(t);let a;if(i[0]!==1/0){const o=yr.slice();$.axialAlignedBoundingBox([0,-s,e,0],n,o);const l=$.intersect(i,o);if(!l)return;const[c,h,d,f]=l;if(c!==o[0]||h!==o[1]||d!==o[2]||f!==o[3]){const g=Math.atan2(n[1],n[0]),m=Math.abs(Math.sin(g)),v=Math.abs(Math.cos(g));if(m<1e-6||v<1e-6||Math.abs(m-v)<1e-6)a=[c,h,c,f,d,h];else{const w=d-c,A=f-h,_=m*m,E=v*v,S=v*m,x=E-_,T=(A*E-w*S)/x,C=(A*S-w*_)/x;a=[c+C,h,c,h+T,d,f-T]}}}a||(a=[0,-s,0,0,e,-s],$.applyTransform(a,n,0),$.applyTransform(a,n,2),$.applyTransform(a,n,4)),a[0]/=r(this,co),a[1]/=r(this,ho),a[2]/=r(this,co),a[3]/=r(this,ho),a[4]/=r(this,co),a[5]/=r(this,ho),r(this,po).set(a,r(this,fo)*6),Ft(this,fo)._++}take(){return r(this,po).subarray(0,r(this,fo)*6)}};co=new WeakMap,ho=new WeakMap,uo=new WeakMap,fo=new WeakMap,po=new WeakMap,$u=new WeakMap,y(iu,$u,Et.isFloat16ArraySupported?Float16Array:Float32Array);let hm=iu;const ky=new RegExp("\\p{Cc}","u");function _S(u){const t=u[0];if(u.length<2||t!=='"'&&t!=="'"||u.at(-1)!==t)return!1;const e=u.length-1;for(let s=1;s<e;s++){const i=u[s];if(i===t||ky.test(i)||i==="\\"&&(++s>=e||ky.test(u[s])))return!1}return!0}function My(u){return _S(u)?u:`"${u.replaceAll(/["\\\p{Cc}]/gu,e=>e==='"'||e==="\\"?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}var go,fc,Ei,wh,uw,dw;class SS{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){y(this,wh);y(this,go,new Set);y(this,fc,new Set);y(this,Ei,null);this._document=t,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){r(this,go).add(t),this._document.fonts.add(t)}removeNativeFontFace(t){r(this,go).delete(t),this._document.fonts.delete(t)}insertRule(t){const e=b(this,wh,uw).call(this);e.insertRule(t,e.cssRules.length)}clear(){var t;for(const e of r(this,go))this._document.fonts.delete(e);if(r(this,go).clear(),r(this,fc).clear(),r(this,Ei)){const{adoptedStyleSheets:e}=this._document;e!=null&&e.includes(r(this,Ei))&&(this._document.adoptedStyleSheets=e.filter(s=>s!==r(this,Ei))),p(this,Ei,null)}(t=this.styleElement)==null||t.remove(),this.styleElement=null}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||r(this,fc).has(t.loadedName))){if(ne(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:n,style:a}=t,o=new FontFace(i,n,a);this.addNativeFontFace(o);try{await o.load(),r(this,fc).add(i),s==null||s(t)}catch{st(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}vt("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw st(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await b(this,wh,dw).call(this,t)}}get isFontLoadingAPISupported(){var t;return V(this,"isFontLoadingAPISupported",!!((t=this._document)!=null&&t.fonts))}get isSyncFontLoadingSupported(){return V(this,"isSyncFontLoadingSupported",Gs||Et.platform.isFirefox)}}go=new WeakMap,fc=new WeakMap,Ei=new WeakMap,wh=new WeakSet,uw=function(){var e;if(r(this,Ei))return r(this,Ei);const t=((e=this._document.defaultView)==null?void 0:e.CSSStyleSheet)||globalThis.CSSStyleSheet;if(!this.styleElement&&t){const{adoptedStyleSheets:s}=this._document;if(s){const i=new t;return s.push(i),p(this,Ei,i)}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),p(this,Ei,this.styleElement.sheet)},dw=function(t){function e(){for(ne(!a.done,"completeRequest() cannot be called twice."),a.done=!0;s.length>0&&s[0].done;){const k=s.shift();setTimeout(k.resolve,0)}}const{loadingRequests:s}=this,{promise:i,resolve:n}=Promise.withResolvers(),a={done:!1,resolve:n};s.push(a),this._loadTestFont??(this._loadTestFont=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="));function o(k,M){return k.charCodeAt(M)<<24|k.charCodeAt(M+1)<<16|k.charCodeAt(M+2)<<8|k.charCodeAt(M+3)&255}function l(k){return String.fromCharCode(k>>24&255,k>>16&255,k>>8&255,k&255)}function c(k,M,R,N){const F=k.substring(0,M),j=k.substring(M+R);return F+N+j}let h,d;const f=this._document.createElement("canvas");f.width=1,f.height=1;const g=f.getContext("2d");let m=0;function v(k,M){if(++m>30){st("Load test font never loaded."),M();return}if(g.font="30px "+k,g.fillText(".",0,20),g.getImageData(0,0,1,1).data[3]>0){M();return}setTimeout(v.bind(null,k,M))}const w=`lt${Date.now()}${this.loadTestFontId++}`;let A=this._loadTestFont;A=c(A,976,w.length,w);const E=16,S=1482184792;let x=o(A,E);for(h=0,d=w.length-3;h<d;h+=4)x=x-S+o(w,h)|0;h<w.length&&(x=x-S+o(w+"XXX",h)|0),A=c(A,E,4,l(x));const T=`url(data:font/opentype;base64,${btoa(A)});`,C=`@font-face {font-family:"${w}";src:${T}}`;this.insertRule(C);const I=this._document.createElement("div");I.style.visibility="hidden",I.style.width=I.style.height="10px",I.style.position="absolute",I.style.top=I.style.left="0px";for(const k of[t.loadedName,w]){const M=this._document.createElement("span");M.textContent="Hi",M.style.fontFamily=k,I.append(M)}return this._document.body.append(I),v(w,()=>{I.remove(),e()}),i};var Gu,se;class ES{constructor(t,e=null,s,i){y(this,Gu,new Map);y(this,se);p(this,se,t),this._inspectFont=e,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){var s;const{data:t}=this;if(!t||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,t,{});else{const i={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(i.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(My(this.cssFontInfo.fontFamily),t,i)}return(s=this._inspectFont)==null||s.call(this,this),e}createFontFaceRule(){var i;const{data:t}=this;if(!t||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${t.toBase64()});`;let s;if(!this.cssFontInfo)s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:${My(this.cssFontInfo.fontFamily)};${n}src:${e}}`}return(i=this._inspectFont)==null||i.call(this,this,e),s}getPathGenerator(t,e){let s=r(this,Gu).get(e);if(s)return s;const i=`${this.loadedName}_path_${e}`;let n;try{n=t.get(i)}catch(a){st(`getPathGenerator - ignoring character: "${a}".`)}return s=Ib(n==null?void 0:n.path),this.fontExtraProperties||t.delete(i),r(this,Gu).set(e,s),s}get black(){return r(this,se).black}get bold(){return r(this,se).bold}get disableFontFace(){return r(this,se).disableFontFace}set disableFontFace(t){V(this,"disableFontFace",!!t)}get fontExtraProperties(){return r(this,se).fontExtraProperties}get isInvalidPDFjsFont(){return r(this,se).isInvalidPDFjsFont}get isType3Font(){return r(this,se).isType3Font}get italic(){return r(this,se).italic}get missingFile(){return r(this,se).missingFile}get remeasure(){return r(this,se).remeasure}get vertical(){return r(this,se).vertical}get bbox(){return r(this,se).bbox}get fontMatrix(){return r(this,se).fontMatrix}get fallbackName(){return r(this,se).fallbackName}get loadedName(){return r(this,se).loadedName}get mimetype(){return this.missingFile?null:"font/opentype"}get data(){return r(this,se).data}clearData(){r(this,se).clearData()}get cssFontInfo(){return r(this,se).cssFontInfo}get systemFontInfo(){return r(this,se).systemFontInfo}}Gu=new WeakMap,se=new WeakMap;class fw{}O(fw,"strings",["fontFamily","fontWeight","italicAngle"]);class pw{}O(pw,"strings",["css","loadedName","baseFontName","src"]);const Gi=class Gi{};O(Gi,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),O(Gi,"strings",["fallbackName","loadedName"]),O(Gi,"OFFSET_BBOX",Math.ceil(Gi.bools.length*2/8)),O(Gi,"OFFSET_FONT_MATRIX",Gi.OFFSET_BBOX+1+8),O(Gi,"OFFSET_STRINGS",Gi.OFFSET_FONT_MATRIX+1+48);let wn=Gi;class as{}O(as,"KIND",0),O(as,"HAS_BBOX",1),O(as,"HAS_BACKGROUND",2),O(as,"SHADING_TYPE",3),O(as,"N_COORD",4),O(as,"N_COLOR",8),O(as,"N_STOP",12),O(as,"N_FIGURES",16);class xS{static get decoder(){return V(this,"decoder",new TextDecoder)}static get encoder(){return V(this,"encoder",new TextEncoder)}}function eu(u,t,e,s=0){const{decoder:i}=xS;for(let a=0;a<e;a++)s+=t.getUint32(s)+4;const n=t.getUint32(s);return i.decode(new Uint8Array(u,s+4,n))}var zu,Vu,pc,Pf;class TS{constructor(t){y(this,pc);y(this,zu);y(this,Vu);p(this,zu,t),p(this,Vu,new DataView(t))}get fontFamily(){return V(this,"fontFamily",b(this,pc,Pf).call(this,0))}get fontWeight(){return V(this,"fontWeight",b(this,pc,Pf).call(this,1))}get italicAngle(){return V(this,"italicAngle",b(this,pc,Pf).call(this,2))}}zu=new WeakMap,Vu=new WeakMap,pc=new WeakSet,Pf=function(t){return ne(t<fw.strings.length,"Invalid string index"),eu(r(this,zu),r(this,Vu),t)};var mo,Jn,vo,Bh;class CS{constructor(t){y(this,vo);y(this,mo);y(this,Jn);p(this,mo,t),p(this,Jn,new DataView(t))}get css(){return V(this,"css",b(this,vo,Bh).call(this,0))}get loadedName(){return V(this,"loadedName",b(this,vo,Bh).call(this,1))}get baseFontName(){return V(this,"baseFontName",b(this,vo,Bh).call(this,2))}get src(){return V(this,"src",b(this,vo,Bh).call(this,3))}get style(){let t=0;t+=4+r(this,Jn).getUint32(t);const e=eu(r(this,mo),r(this,Jn),0,t),s=eu(r(this,mo),r(this,Jn),1,t);return V(this,"style",{style:e,weight:s})}}mo=new WeakMap,Jn=new WeakMap,vo=new WeakSet,Bh=function(t){return ne(t<pw.strings.length,"Invalid string index"),eu(r(this,mo),r(this,Jn),t,4)};var xi,ni,Vt,yi,um,dm,Uh;class PS{constructor(t){y(this,Vt);y(this,xi);y(this,ni);p(this,xi,t),p(this,ni,new DataView(t))}get black(){return V(this,"black",b(this,Vt,yi).call(this,0))}get bold(){return V(this,"bold",b(this,Vt,yi).call(this,1))}get disableFontFace(){return V(this,"disableFontFace",b(this,Vt,yi).call(this,2))}get fontExtraProperties(){return V(this,"fontExtraProperties",b(this,Vt,yi).call(this,3))}get isInvalidPDFjsFont(){return V(this,"isInvalidPDFjsFont",b(this,Vt,yi).call(this,4))}get isType3Font(){return V(this,"isType3Font",b(this,Vt,yi).call(this,5))}get italic(){return V(this,"italic",b(this,Vt,yi).call(this,6))}get missingFile(){return V(this,"missingFile",b(this,Vt,yi).call(this,7))}get remeasure(){return V(this,"remeasure",b(this,Vt,yi).call(this,8))}get vertical(){return V(this,"vertical",b(this,Vt,yi).call(this,9))}get bbox(){return V(this,"bbox",b(this,Vt,um).call(this,wn.OFFSET_BBOX,4,"getInt16",2))}get fontMatrix(){return V(this,"fontMatrix",b(this,Vt,um).call(this,wn.OFFSET_FONT_MATRIX,6,"getFloat64",8))}get fallbackName(){return V(this,"fallbackName",b(this,Vt,dm).call(this,0))}get loadedName(){return V(this,"loadedName",b(this,Vt,dm).call(this,1))}get data(){const{offset:t,length:e}=b(this,Vt,Uh).call(this,2);return e?new Uint8Array(r(this,xi),t+4,e):void 0}clearData(){const{offset:t,length:e}=b(this,Vt,Uh).call(this,2);e&&(r(this,ni).setUint32(t,0),p(this,xi,new Uint8Array(r(this,xi),0,t+4).slice().buffer),p(this,ni,new DataView(r(this,xi))))}get cssFontInfo(){const{offset:t,length:e}=b(this,Vt,Uh).call(this,1);let s=null;if(e){const i=new Uint8Array(r(this,xi),t+4,e).slice();s=new TS(i.buffer)}return V(this,"cssFontInfo",s)}get systemFontInfo(){const{offset:t,length:e}=b(this,Vt,Uh).call(this,0);let s=null;if(e){const i=new Uint8Array(r(this,xi),t+4,e).slice();s=new CS(i.buffer)}return V(this,"systemFontInfo",s)}}xi=new WeakMap,ni=new WeakMap,Vt=new WeakSet,yi=function(t){ne(t<wn.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=r(this,ni).getUint8(e)>>s&3;return i===0?void 0:i===2},um=function(t,e,s,i){const n=r(this,ni).getUint8(t++);if(n===0)return;ne(n===e,"Invalid array length.");const a=new Array(n);for(let o=0;o<n;o++)a[o]=r(this,ni)[s](t,!0),t+=i;return a},dm=function(t){return ne(t<wn.strings.length,"Invalid string index"),eu(r(this,xi),r(this,ni),t,wn.OFFSET_STRINGS+4)},Uh=function(t){let e=wn.OFFSET_STRINGS;for(let i=0;i<=t;i++)e+=4+r(this,ni).getUint32(e);const s=r(this,ni).getUint32(e);return{offset:e,length:s}};class IS{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[as.KIND],s=!!this.data[as.HAS_BBOX],i=!!this.data[as.HAS_BACKGROUND],n=t.getUint32(as.N_COORD,!0),a=t.getUint32(as.N_COLOR,!0),o=t.getUint32(as.N_STOP,!0);let l=20;const c=new Float32Array(this.buffer,l,n*2);l+=n*8;const h=new Uint8Array(this.buffer,l,a*4);l+=a*4;const d=[];for(let m=0;m<o;++m){const v=t.getFloat32(l,!0);l+=4;const w=t.getUint32(l,!0);l+=4,d.push([v,`#${w.toString(16).padStart(6,"0")}`])}let f=null;if(s){f=[];for(let m=0;m<4;++m)f.push(t.getFloat32(l,!0)),l+=4}let g=null;if(i&&(g=new Uint8Array(this.buffer,l,3),l+=3),e===1)return["RadialAxial","axial",f,d,[c[0],c[1]],[c[2],c[3]],null,null];if(e===2)return["RadialAxial","radial",f,d,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(e===3){const m=this.data[as.SHADING_TYPE];let v=null;if(c.length>0){v=yr.slice();for(let w=0,A=c.length;w<A;w+=2)$.pointBoundingBox(c[w],c[w+1],v)}return["Mesh",m,c,h,n,v,f,g]}throw new Error(`Unsupported pattern kind: ${e}`)}}var gc;class kS{constructor(t){y(this,gc);p(this,gc,t)}get path(){return Et.isFloat16ArraySupported?new Float16Array(r(this,gc)):new Float32Array(r(this,gc))}}gc=new WeakMap;function MS(u){if(u instanceof URL)return u;if(typeof u=="string"){if(Gs){if(/^[a-z][a-z0-9\-+.]+:/i.test(u))return new URL(u);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(u))}const t=URL.parse(u,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function OS(u){if(Gs&&typeof Buffer<"u"&&u instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength)return u;if(typeof u=="string")return cg(u);if(u instanceof ArrayBuffer||ArrayBuffer.isView(u)||typeof u=="object"&&!isNaN(u==null?void 0:u.length))return new Uint8Array(u);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function df(u){if(typeof u!="string")return null;if(u.endsWith("/"))return u;throw new Error(`Invalid factory url: "${u}" must include trailing slash.`)}const fm=u=>typeof u=="object"&&Number.isInteger(u==null?void 0:u.num)&&u.num>=0&&Number.isInteger(u==null?void 0:u.gen)&&u.gen>=0,RS=u=>typeof u=="object"&&typeof(u==null?void 0:u.name)=="string",DS=sS.bind(null,fm,RS);var Hr,wp;class FS{constructor(){y(this,Hr,new Map);y(this,wp,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};r(this,wp).then(()=>{for(const[i]of r(this,Hr))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:n}=s;if(n.aborted){st("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}r(this,Hr).set(e,i)}removeEventListener(t,e){const s=r(this,Hr).get(e);s==null||s(),r(this,Hr).delete(e)}terminate(){for(const[,t]of r(this,Hr))t==null||t();r(this,Hr).clear()}}Hr=new WeakMap,wp=new WeakMap;I0();const ff={DATA:1,ERROR:2},ue={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Oy(){}function gs(u){if(u instanceof Ta||u instanceof Rg||u instanceof Og||u instanceof ap||u instanceof Sg)return u;switch(u instanceof Error||typeof u=="object"&&u!==null||vt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new Ta(u.message);case"InvalidPDFException":return new Rg(u.message);case"PasswordException":return new Og(u.message,u.code);case"ResponseException":return new ap(u.message,u.status,u.missing);case"UnknownErrorException":return new Sg(u.message,u.details)}return new Sg(u.message,u.toString())}var mc,vc,Ap,sr,yc,Ti,jr,_p,bc,yo,pi,gw,mw,vw,If;class Hh{constructor(t,e,s){y(this,pi);y(this,mc,new Map);y(this,vc,new Map);y(this,Ap,1);y(this,sr);y(this,yc,new AbortController);y(this,Ti);y(this,jr,new Map);y(this,_p,1);y(this,bc,new Map);y(this,yo);p(this,Ti,t),p(this,yo,e),p(this,sr,s),s.addEventListener("message",b(this,pi,gw).bind(this),{signal:r(this,yc).signal})}on(t,e){const s=r(this,mc);if(s.has(t))throw new Error(`There is already a "${t}" handler.`);s.set(t,e)}send(t,e,s){r(this,sr).postMessage({sourceName:r(this,Ti),targetName:r(this,yo),action:t,data:e},s)}sendWithPromise(t,e,s){const i=Ft(this,Ap)._++,n=Promise.withResolvers();r(this,vc).set(i,n);try{r(this,sr).postMessage({sourceName:r(this,Ti),targetName:r(this,yo),action:t,callbackId:i,data:e},s)}catch(a){n.reject(a)}return n.promise}sendWithStream(t,e,s,i){const n=Ft(this,_p)._++,a=r(this,Ti),o=r(this,yo),l=r(this,sr);return new ReadableStream({start:c=>{const h=Promise.withResolvers();return r(this,jr).set(n,{controller:c,startCall:h,pullCall:null,cancelCall:null,isClosed:!1}),l.postMessage({sourceName:a,targetName:o,action:t,streamId:n,data:e,desiredSize:c.desiredSize},i),h.promise},pull:c=>{const h=Promise.withResolvers();return r(this,jr).get(n).pullCall=h,l.postMessage({sourceName:a,targetName:o,stream:ue.PULL,streamId:n,desiredSize:c.desiredSize}),h.promise},cancel:c=>{ne(c instanceof Error,"cancel must have a valid reason");const h=Promise.withResolvers();return r(this,jr).get(n).cancelCall=h,r(this,jr).get(n).isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:ue.CANCEL,streamId:n,reason:gs(c)}),h.promise}},s)}destroy(){var t;(t=r(this,yc))==null||t.abort(),p(this,yc,null)}}mc=new WeakMap,vc=new WeakMap,Ap=new WeakMap,sr=new WeakMap,yc=new WeakMap,Ti=new WeakMap,jr=new WeakMap,_p=new WeakMap,bc=new WeakMap,yo=new WeakMap,pi=new WeakSet,gw=function({data:t}){if(t.targetName!==r(this,Ti))return;if(t.stream){b(this,pi,vw).call(this,t);return}if(t.callback){const{callbackId:s,callback:i}=t,n=r(this,vc).get(s);if(!n)throw new Error(`Cannot resolve callback ${s}`);if(r(this,vc).delete(s),i===ff.DATA)n.resolve(t.data);else if(i===ff.ERROR)n.reject(gs(t.reason));else throw new Error("Unexpected callback case");return}const e=r(this,mc).get(t.action);if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=r(this,Ti),i=t.sourceName,n=r(this,sr);Promise.try(e,t.data).then(a=>{n.postMessage({sourceName:s,targetName:i,callback:ff.DATA,callbackId:t.callbackId,data:a})},a=>{n.postMessage({sourceName:s,targetName:i,callback:ff.ERROR,callbackId:t.callbackId,reason:gs(a)})});return}if(t.streamId){b(this,pi,mw).call(this,t);return}e(t.data)},mw=function(t){const e=t.streamId,s=r(this,Ti),i=t.sourceName,n=r(this,sr),a=r(this,bc),o=r(this,mc).get(t.action),l={enqueue(c,h=1,d){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=h,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:ue.ENQUEUE,streamId:e,chunk:c},d)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:ue.CLOSE,streamId:e}),a.delete(e))},error(c){ne(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:ue.ERROR,streamId:e,reason:gs(c)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,a.set(e,l),Promise.try(o,t.data,l).then(()=>{n.postMessage({sourceName:s,targetName:i,stream:ue.START_COMPLETE,streamId:e,success:!0})},c=>{n.postMessage({sourceName:s,targetName:i,stream:ue.START_COMPLETE,streamId:e,reason:gs(c)})})},vw=function(t){const e=t.streamId,s=r(this,Ti),i=t.sourceName,n=r(this,sr),a=r(this,jr).get(e),o=r(this,bc).get(e);switch(t.stream){case ue.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(gs(t.reason));break;case ue.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(gs(t.reason));break;case ue.PULL:if(!o){n.postMessage({sourceName:s,targetName:i,stream:ue.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||Oy).then(()=>{n.postMessage({sourceName:s,targetName:i,stream:ue.PULL_COMPLETE,streamId:e,success:!0})},c=>{n.postMessage({sourceName:s,targetName:i,stream:ue.PULL_COMPLETE,streamId:e,reason:gs(c)})});break;case ue.ENQUEUE:if(ne(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case ue.CLOSE:if(ne(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,pi,If).call(this,a,e);break;case ue.ERROR:ne(a,"error should have stream controller"),a.controller.error(gs(t.reason)),b(this,pi,If).call(this,a,e);break;case ue.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(gs(t.reason)),b(this,pi,If).call(this,a,e);break;case ue.CANCEL:if(!o)break;const l=gs(t.reason);Promise.try(o.onCancel||Oy,l).then(()=>{n.postMessage({sourceName:s,targetName:i,stream:ue.CANCEL_COMPLETE,streamId:e,success:!0})},c=>{n.postMessage({sourceName:s,targetName:i,stream:ue.CANCEL_COMPLETE,streamId:e,reason:gs(c)})}),o.sinkCapability.reject(l),o.isCancelled=!0,r(this,bc).delete(e);break;default:throw new Error("Unexpected stream case")}},If=async function(t,e){var s,i,n;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(n=t.cancelCall)==null?void 0:n.promise]),r(this,jr).delete(e)};var Sp;class yw{constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){y(this,Sp,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:vt(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const i=`${s}${e}`;return this._fetch(i,t).catch(n=>{throw new Error(`Unable to load ${r(this,Sp)[t]} data at: ${i}`)})}async _fetch(t,e){vt("Abstract method `_fetch` called.")}}Sp=new WeakMap;class Ry extends yw{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await Wv(t,s);return i instanceof Uint8Array?i:cg(i)}}var Wu;class bw{constructor({enableHWA:t=!1}){y(this,Wu,!1);p(this,Wu,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!r(this,Wu)})}}reset({canvas:t},e,s){if(!t)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){vt("Abstract method `_createCanvas` called.")}}Wu=new WeakMap;class LS extends bw{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class ww{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}var bo,wc,$r,ir,Me,wo,Qn,z,Ce,jh,ji,kf,Ma,Aw,pm,Oa,$h,Gh,gm,zh,_w,mm,Sw;class NS extends ww{constructor({docId:e,ownerDocument:s=globalThis.document}){super();y(this,z);y(this,bo);y(this,wc);y(this,$r);y(this,ir);y(this,Me);y(this,wo);y(this,Qn,0);p(this,ir,e),p(this,Me,s)}addFilter(e){if(!e)return"none";let s=r(this,z,Ce).get(e);if(s)return s;const[i,n,a]=b(this,z,kf).call(this,e),o=e.length===1?i:`${i}${n}${a}`;if(s=r(this,z,Ce).get(o),s)return r(this,z,Ce).set(e,s),s;const l=`g_${r(this,ir)}_transfer_map_${Ft(this,Qn)._++}`,c=b(this,z,Ma).call(this,l);r(this,z,Ce).set(e,c),r(this,z,Ce).set(o,c);const h=b(this,z,Oa).call(this,l);return b(this,z,Gh).call(this,i,n,a,h),c}addHCMFilter(e,s){var m;const i=`${e}-${s}`,n="base";let a=r(this,z,jh).get(n);if((a==null?void 0:a.key)===i||(a?((m=a.filter)==null||m.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},r(this,z,jh).set(n,a)),!e||!s))return a.url;const o=b(this,z,zh).call(this,e);e=$.makeHexColor(...o);const l=b(this,z,zh).call(this,s);if(s=$.makeHexColor(...l),b(this,z,mm).call(this),e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=Array.from({length:256},(v,w)=>Ug(w/255)).join(","),d=`g_${r(this,ir)}_hcm_filter`,f=a.filter=b(this,z,Oa).call(this,d);b(this,z,Gh).call(this,h,h,h,f),b(this,z,pm).call(this,f);const g=(v,w)=>{const A=o[v]/255,_=l[v]/255,E=new Array(w+1);for(let S=0;S<=w;S++)E[S]=A+S/w*(_-A);return E.join(",")};return b(this,z,Gh).call(this,g(0,5),g(1,5),g(2,5),f),a.url=b(this,z,Ma).call(this,d),a.url}addSelectionHCMFilter(e,s){return this.addHighlightHCMFilter("selection",e,s,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(e=null){const s=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return s==="none"||!Et.platform.isFirefox?null:{"backdrop-filter":s,"background-color":"transparent"}}addAlphaFilter(e){let s=r(this,z,Ce).get(e);if(s)return s;const[i]=b(this,z,kf).call(this,[e]),n=`alpha_${i}`;if(s=r(this,z,Ce).get(n),s)return r(this,z,Ce).set(e,s),s;const a=`g_${r(this,ir)}_alpha_map_${Ft(this,Qn)._++}`,o=b(this,z,Ma).call(this,a);r(this,z,Ce).set(e,o),r(this,z,Ce).set(n,o);const l=b(this,z,Oa).call(this,a);return b(this,z,gm).call(this,i,l),o}addLuminosityFilter(e){let s=r(this,z,Ce).get(e||"luminosity");if(s)return s;let i,n;if(e?([i]=b(this,z,kf).call(this,[e]),n=`luminosity_${i}`):n="luminosity",s=r(this,z,Ce).get(n),s)return r(this,z,Ce).set(e,s),s;const a=`g_${r(this,ir)}_luminosity_map_${Ft(this,Qn)._++}`,o=b(this,z,Ma).call(this,a);r(this,z,Ce).set(e,o),r(this,z,Ce).set(n,o);const l=b(this,z,Oa).call(this,a);return b(this,z,Aw).call(this,l),e&&b(this,z,gm).call(this,i,l),o}addKnockoutFilter(e=0){const s=e>0?Math.min(1/e,1e6):1e6,i=`knockout_${s}`,n=r(this,z,Ce).get(i);if(n)return n;const a=`g_${r(this,ir)}_knockout_filter_${Ft(this,Qn)._++}`,o=b(this,z,Ma).call(this,a);r(this,z,Ce).set(i,o);const l=b(this,z,Oa).call(this,a),c=r(this,Me).createElementNS(ns,"feComponentTransfer");l.append(c);const h=r(this,Me).createElementNS(ns,"feFuncA");return h.setAttribute("type","linear"),h.setAttribute("slope",`${s}`),h.setAttribute("intercept","0"),c.append(h),o}addHighlightHCMFilter(e,s,i,n,a){var _;const o=`${s}-${i}-${n}-${a}`;let l=r(this,z,jh).get(e);if((l==null?void 0:l.key)===o||(l?((_=l.filter)==null||_.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},r(this,z,jh).set(e,l)),!s||!i))return l.url;const[c,h]=[s,i].map(b(this,z,zh).bind(this));let d=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),f=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[g,m]=[n,a].map(b(this,z,Sw).bind(this));f<d&&([d,f,g,m]=[f,d,m,g]),b(this,z,mm).call(this);const v=(E,S,x)=>{const T=new Array(256),C=(f-d)/x,I=E/255,k=(S-E)/(255*x);let M=0;for(let R=0;R<=x;R++){const N=Math.round(d+R*C),F=I+R*k;for(let j=M;j<=N;j++)T[j]=F;M=N+1}for(let R=M;R<256;R++)T[R]=T[M-1];return T.join(",")},w=`g_${r(this,ir)}_hcm_${e}_filter`,A=l.filter=b(this,z,Oa).call(this,w);return b(this,z,pm).call(this,A),b(this,z,Gh).call(this,v(g[0],m[0],5),v(g[1],m[1],5),v(g[2],m[2],5),A),l.url=b(this,z,Ma).call(this,w),l.url}destroy(e=!1){var s,i,n,a;e&&((s=r(this,wo))!=null&&s.size)||((i=r(this,$r))==null||i.parentNode.parentNode.remove(),p(this,$r,null),(n=r(this,wc))==null||n.clear(),p(this,wc,null),(a=r(this,wo))==null||a.clear(),p(this,wo,null),p(this,Qn,0))}}bo=new WeakMap,wc=new WeakMap,$r=new WeakMap,ir=new WeakMap,Me=new WeakMap,wo=new WeakMap,Qn=new WeakMap,z=new WeakSet,Ce=function(){return r(this,wc)||p(this,wc,new Map)},jh=function(){return r(this,wo)||p(this,wo,new Map)},ji=function(){if(!r(this,$r)){const e=r(this,Me).createElement("div"),{style:s}=e;s.colorScheme="only light",s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=r(this,Me).createElementNS(ns,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,$r,r(this,Me).createElementNS(ns,"defs")),e.append(i),i.append(r(this,$r)),r(this,Me).body.append(e)}return r(this,$r)},kf=function(e){const s=o=>o&&Array.from(o,l=>l/255).join(",");if(e.length===1){const o=s(e[0]);return[o,o,o]}const[i,n,a]=e;return[s(i),s(n),s(a)]},Ma=function(e){if(r(this,bo)===void 0){p(this,bo,"");const s=r(this,Me).URL;s!==r(this,Me).baseURI&&(hg(s)?st('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,bo,Tb(s,"")))}return`url(${r(this,bo)}#${e})`},Aw=function(e){const s=r(this,Me).createElementNS(ns,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(s)},pm=function(e){const s=r(this,Me).createElementNS(ns,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(s)},Oa=function(e){const s=r(this,Me).createElementNS(ns,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),r(this,z,ji).append(s),s},$h=function(e,s,i){if(!i)return;const n=r(this,Me).createElementNS(ns,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},Gh=function(e,s,i,n){const a=r(this,Me).createElementNS(ns,"feComponentTransfer");n.append(a),b(this,z,$h).call(this,a,"feFuncR",e),b(this,z,$h).call(this,a,"feFuncG",s),b(this,z,$h).call(this,a,"feFuncB",i)},gm=function(e,s){const i=r(this,Me).createElementNS(ns,"feComponentTransfer");s.append(i),b(this,z,$h).call(this,i,"feFuncA",e)},zh=function(e){return r(this,z,ji).style.color="CanvasText",r(this,z,ji).style.backgroundColor=e,lf(getComputedStyle(r(this,z,ji)).getPropertyValue("background-color"))},_w=function(e){return r(this,z,ji).style.color="CanvasText",r(this,z,ji).style.backgroundColor=e,xh(getComputedStyle(r(this,z,ji)).getPropertyValue("background-color"))},mm=function(){r(this,z,ji).style.color="",r(this,z,ji).style.backgroundColor=""},Sw=function(e){const[s,i,n,a]=b(this,z,_w).call(this,e);if(a===1)return[s,i,n];const[o,l,c]=b(this,z,zh).call(this,"Canvas");return[Cg(s,o,a),Cg(i,l,a),Cg(n,c,a)]};function Cg(u,t,e){return Math.round(e*u+(1-e)*t)}var Yy;if(Gs){let u;try{const t=process.getBuiltinModule("module").createRequire(import.meta.url);try{u=t("@napi-rs/canvas")}catch(e){st(`Cannot load "@napi-rs/canvas" package: "${e}".`)}}catch(t){st(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(u!=null&&u.DOMMatrix?globalThis.DOMMatrix=u.DOMMatrix:st("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.Path2D||(u!=null&&u.Path2D?globalThis.Path2D=u.Path2D:st("Cannot polyfill `Path2D`, rendering may be broken.")),(Yy=globalThis.navigator)!=null&&Yy.language||(globalThis.navigator={language:"en-US",platform:"",userAgent:""})}async function BS(u){const e=await process.getBuiltinModule("fs/promises").readFile(u);return new Uint8Array(e)}class US extends ww{}class HS extends bw{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class jS extends yw{async _fetch(t,e){return BS(t)}}function Ew({src:u,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:a=!1}){const o=Et.isLittleEndian?4278190080:255,[l,c]=a?[n,o]:[o,n],h=s>>3,d=s&7,f=l^c,g=u.length;e=new Uint32Array(e.buffer);let m=0;for(let v=0;v<i;++v){for(const A=t+h;t<A;++t,m+=8){const _=u[t];e[m]=l^-(_>>7&1)&f,e[m+1]=l^-(_>>6&1)&f,e[m+2]=l^-(_>>5&1)&f,e[m+3]=l^-(_>>4&1)&f,e[m+4]=l^-(_>>3&1)&f,e[m+5]=l^-(_>>2&1)&f,e[m+6]=l^-(_>>1&1)&f,e[m+7]=l^-(_&1)&f}if(d===0)continue;const w=t<g?u[t++]:255;for(let A=0;A<d;++A,++m)e[m]=l^-(w>>7-A&1)&f}return{srcPos:t,destPos:m}}function $S({src:u,srcPos:t=0,dest:e,destPos:s=0,width:i,height:n}){let a=0;const o=i*n*3,l=o>>2,c=new Uint32Array(u.buffer,t,l),h=Et.isLittleEndian?4278190080:255;if(Et.isLittleEndian){for(;a<l-2;a+=3,s+=4){const d=c[a],f=c[a+1],g=c[a+2];e[s]=d|h,e[s+1]=d>>>24|f<<8|h,e[s+2]=f>>>16|g<<16|h,e[s+3]=g>>>8|h}for(let d=t+a*4,f=t+o;d<f;d+=3)e[s++]=u[d]|u[d+1]<<8|u[d+2]<<16|h}else{for(;a<l-2;a+=3,s+=4){const d=c[a],f=c[a+1],g=c[a+2];e[s]=d|h,e[s+1]=d<<24|f>>>8|h,e[s+2]=f<<16|g>>>16|h,e[s+3]=g<<8|h}for(let d=t+a*4,f=t+o;d<f;d+=3)e[s++]=u[d]<<24|u[d+1]<<16|u[d+2]<<8|h}return{srcPos:t+o,destPos:s}}const GS=`
5
+ struct Uniforms {
6
+ offsetX : f32,
7
+ offsetY : f32,
8
+ scaleX : f32,
9
+ scaleY : f32,
10
+ paddedWidth : f32,
11
+ paddedHeight : f32,
12
+ borderSize : f32,
13
+ _pad : f32,
14
+ };
15
+
16
+ @group(0) @binding(0) var<uniform> u : Uniforms;
17
+
18
+ struct VertexInput {
19
+ @location(0) position : vec2<f32>,
20
+ @location(1) color : vec4<f32>,
21
+ };
22
+
23
+ struct VertexOutput {
24
+ @builtin(position) position : vec4<f32>,
25
+ @location(0) color : vec3<f32>,
26
+ };
27
+
28
+ @vertex
29
+ fn vs_main(in : VertexInput) -> VertexOutput {
30
+ var out : VertexOutput;
31
+ let cx = (in.position.x + u.offsetX) * u.scaleX;
32
+ let cy = (in.position.y + u.offsetY) * u.scaleY;
33
+ out.position = vec4<f32>(
34
+ ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
35
+ 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
36
+ 0.0,
37
+ 1.0
38
+ );
39
+ out.color = in.color.rgb;
40
+ return out;
41
+ }
42
+
43
+ @fragment
44
+ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
45
+ return vec4<f32>(in.color, 1.0);
46
+ }
47
+ `;var Ep,Gr,Ao,Ac,xp,xw;class zS{constructor(){y(this,xp);y(this,Ep,null);y(this,Gr,null);y(this,Ao,null);y(this,Ac,null)}init(){return r(this,Ep)||p(this,Ep,b(this,xp,xw).call(this))}get isReady(){return r(this,Gr)!==null}loadMeshShader(){if(!r(this,Gr)||r(this,Ao))return;const t=r(this,Gr).createShaderModule({code:GS});p(this,Ao,r(this,Gr).createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:r(this,Ac)}]},primitive:{topology:"triangle-list"}}))}draw(t,e,s,i,n,a,o,l){this.loadMeshShader();const c=r(this,Gr),{offsetX:h,offsetY:d,scaleX:f,scaleY:g}=i,m=c.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&c.queue.writeBuffer(m,0,t);const v=c.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&c.queue.writeBuffer(v,0,e);const w=c.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});c.queue.writeBuffer(w,0,new Float32Array([h,d,f,g,a,o,l,0]));const A=c.createBindGroup({layout:r(this,Ao).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:w}}]}),_=new OffscreenCanvas(a,o),E=_.getContext("webgpu");E.configure({device:c,format:r(this,Ac),alphaMode:n?"opaque":"premultiplied"});const S=n?{r:n[0]/255,g:n[1]/255,b:n[2]/255,a:1}:{r:0,g:0,b:0,a:0},x=c.createCommandEncoder(),T=x.beginRenderPass({colorAttachments:[{view:E.getCurrentTexture().createView(),clearValue:S,loadOp:"clear",storeOp:"store"}]});return s>0&&(T.setPipeline(r(this,Ao)),T.setBindGroup(0,A),T.setVertexBuffer(0,m),T.setVertexBuffer(1,v),T.draw(s)),T.end(),c.queue.submit([x.finish()]),m.destroy(),v.destroy(),w.destroy(),_.transferToImageBitmap()}}Ep=new WeakMap,Gr=new WeakMap,Ao=new WeakMap,Ac=new WeakMap,xp=new WeakSet,xw=async function(){var t;if(!((t=globalThis.navigator)!=null&&t.gpu))return!1;try{const e=await navigator.gpu.requestAdapter();return e?(p(this,Ac,navigator.gpu.getPreferredCanvasFormat()),p(this,Gr,await e.requestDevice()),!0):!1}catch{return!1}};const ug=new zS;function VS(){return ug.init()}function WS(){return ug.isReady}function XS(){ug.loadMeshShader()}function YS(u,t,e,s,i,n,a,o){return ug.draw(u,t,e,s,i,n,a,o)}const Ue={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Mf(u,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),u.clip(i)}class qv{constructor(){O(this,"matrix",null)}isModifyingCurrentTransform(){return!1}getPattern(){vt("Abstract method `getPattern` called.")}}class KS extends qv{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]}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"}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,i=this._p0,n=this._p1;if(e&&(i=i.slice(),n=n.slice(),$.applyTransform(i,e),$.applyTransform(n,e)),this._type==="axial")s=t.createLinearGradient(i[0],i[1],n[0],n[1]);else if(this._type==="radial"){let a=this._r0,o=this._r1;if(e){const l=new Float32Array(2);$.singularValueDecompose2dScale(e,l),a*=l[0],o*=l[0]}s=t.createRadialGradient(i[0],i[1],a,n[0],n[1],o)}for(const a of this._colorStops)s.addColorStop(a[0],a[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,i=this._p0;e&&(s=s.slice(),i=i.slice(),$.applyTransform(s,e),$.applyTransform(i,e));let n=this._r1,a=this._r0;if(e){const c=new Float32Array(2);$.singularValueDecompose2dScale(e,c),n*=c[0],a*=c[0]}const o=t.createRadialGradient(s[0],s[1],n,i[0],i[1],a),l=this._colorStops.map(([c,h])=>[1-c,h]).reverse();for(const[c,h]of l)o.addColorStop(c,h);return o}_createRasterPattern(t,e,s,i,n,a){const o=Math.ceil(i[2]-i[0])||1,l=Math.ceil(i[3]-i[1])||1,c=e.canvasFactory.create(o,l),h=c.context;h.clearRect(0,0,o,l),h.beginPath(),h.rect(0,0,o,l),h.translate(-i[0],-i[1]),s=$.transform(s,[1,0,0,1,i[0],i[1]]),h.transform(...n),Mf(h,this._bbox),this.areConic()&&(h.fillStyle=this._createReversedGradient(h),h.fill()),h.fillStyle=this._createGradient(h),h.fill(),a==null||a.applyToCanvas(h);const d=t.createPattern(c.canvas,"no-repeat");return e.canvasFactory.destroy(c),d.setTransform(new DOMMatrix(s)),d}getPattern(t,e,s,i){const n=e.current.transferMapsFallback;if(i===Ue.STROKE||i===Ue.FILL){if(this.isOriginBased()&&!n){let l=$.transform(s,e.baseTransform);this.matrix&&(l=$.transform(l,this.matrix));const c=.001,h=Math.hypot(l[0],l[1]),d=Math.hypot(l[2],l[3]),f=(l[0]*l[2]+l[1]*l[3])/(h*d);if(Math.abs(f)<c)if(this.isRadial()){if(Math.abs(h-d)<c)return this._createGradient(t,l)}else return this._createGradient(t,l)}const a=e.current.getClippedPathBoundingBox(i,Ot(t))||[0,0,0,0],o=this.matrix?$.transform(e.baseTransform,this.matrix):e.baseTransform;return this._createRasterPattern(t,e,s,a,o,n)}return n&&s?this._createRasterPattern(t,e,s,e.current.clipBox,Ot(t),n):(this.areConic()&&(t.save(),Mf(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),Mf(t,this._bbox),this._createGradient(t))}}function qS(u,t,e,s,i,n,a,o){const l=t.coords,c=t.colors,h=u.data,d=u.width*4;let f;l[e*2+1]>l[s*2+1]&&(f=e,e=s,s=f,f=n,n=a,a=f),l[s*2+1]>l[i*2+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[e*2+1]>l[s*2+1]&&(f=e,e=s,s=f,f=n,n=a,a=f);const g=(l[e*2]+t.offsetX)*t.scaleX,m=(l[e*2+1]+t.offsetY)*t.scaleY,v=(l[s*2]+t.offsetX)*t.scaleX,w=(l[s*2+1]+t.offsetY)*t.scaleY,A=(l[i*2]+t.offsetX)*t.scaleX,_=(l[i*2+1]+t.offsetY)*t.scaleY;if(m>=_)return;const E=c[n*4],S=c[n*4+1],x=c[n*4+2],T=c[a*4],C=c[a*4+1],I=c[a*4+2],k=c[o*4],M=c[o*4+1],R=c[o*4+2],N=Math.round(m),F=Math.round(_);let j,U,D,H,X,nt,gt,mt;for(let ht=N;ht<=F;ht++){if(ht<w){const B=ht<m?0:(m-ht)/(m-w);j=g-(g-v)*B,U=E-(E-T)*B,D=S-(S-C)*B,H=x-(x-I)*B}else{let B;ht>_?B=1:w===_?B=0:B=(w-ht)/(w-_),j=v-(v-A)*B,U=T-(T-k)*B,D=C-(C-M)*B,H=I-(I-R)*B}let at;ht<m?at=0:ht>_?at=1:at=(m-ht)/(m-_),X=g-(g-A)*at,nt=E-(E-k)*at,gt=S-(S-M)*at,mt=x-(x-R)*at;const Ee=Math.round(Math.min(j,X)),G=Math.round(Math.max(j,X));let L=d*ht+Ee*4;for(let B=Ee;B<=G;B++)at=(j-B)/(j-X),at<0?at=0:at>1&&(at=1),h[L++]=U-(U-nt)*at|0,h[L++]=D-(D-gt)*at|0,h[L++]=H-(H-mt)*at|0,h[L++]=255}}class JS extends qv{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],XS()}_createMeshCanvas(t,e,s,i=null){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)||1,g=Math.min(Math.ceil(Math.abs(d*t[1]*1.1)),3e3)||1,m=h?h/f:1,v=d?d/g:1,w={coords:this._posData,colors:this._colData,offsetX:-l,offsetY:-c,scaleX:1/m,scaleY:1/v},A=f+4,_=g+4,E=s.create(A,_);if(WS()&&this._vertexCount>48)E.context.drawImage(YS(this._posData,this._colData,this._vertexCount,w,e,A,_,2),0,0);else{const S=E.context.createImageData(f,g);if(e){const x=S.data;for(let T=0,C=x.length;T<C;T+=4)x[T]=e[0],x[T+1]=e[1],x[T+2]=e[2],x[T+3]=255}for(let x=0,T=this._vertexCount;x<T;x+=3)qS(S,w,x,x+1,x+2,x,x+1,x+2);E.context.putImageData(S,2,2)}return i==null||i.applyToCanvas(E.context),{canvas:E.canvas,offsetX:l-2*m,offsetY:c-2*v,scaleX:m,scaleY:v}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){Mf(t,this._bbox);const n=new Float32Array(2);if(i===Ue.SHADING)$.singularValueDecompose2dScale(Ot(t),n);else if(this.matrix){$.singularValueDecompose2dScale(this.matrix,n);const[l,c]=n;$.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=l,n[1]*=c}else $.singularValueDecompose2dScale(e.baseTransform,n);const a=this._createMeshCanvas(n,i===Ue.SHADING?null:this._background,e.canvasFactory,e.current.transferMapsFallback);i!==Ue.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY);const o=t.createPattern(a.canvas,"no-repeat");return e.canvasFactory.destroy(a),o}}class QS extends qv{getPattern(){return"hotpink"}}function ZS(u){switch(u[0]){case"RadialAxial":return new KS(u);case"Mesh":return new JS(u);case"Dummy":return new QS}throw new Error(`Unknown IR type: ${u[0]}`)}const Dy={COLORED:1,UNCOLORED:2},Tp=class Tp{constructor(t,e,s,i){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i,this.patternBaseMatrix=this.matrix?$.transform(i,this.matrix):i}canSkipPatternCanvas([t,e,s,i]){const[n,a,o,l]=this.bbox,c=Math.abs(this.xstep),h=Math.abs(this.ystep);if(t>c+1e-6||e>h+1e-6)return null;const d=Math.floor((s-o)/c)+1,f=Math.ceil((s+t-n)/c)-1,g=Math.floor((i-l)/h)+1,m=Math.ceil((i+e-a)/h)-1;return f<=d&&m<=g?[d,g]:null}updatePatternDims(t,e){const s=yr.slice();$.axialAlignedBoundingBox(t,$.inverseTransform(this.patternBaseMatrix),s),e[0]=s[2]-s[0],e[1]=s[3]-s[1],e[2]=s[0],e[3]=s[1]}_renderTileCanvas(t,e,s,i){var f,g;const[n,a,o,l]=this.bbox,c=t.canvasFactory.create(s.size,i.size),h=c.context,d=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return d.groupLevel=t.groupLevel,d.current.transferMapsFallback=t.current.transferMapsFallback,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),h.translate(-s.scale*n,-i.scale*a),d.transform(0,s.scale,0,0,i.scale,0,0),h.save(),(f=d.dependencyTracker)==null||f.save(),this.clipBbox(d,n,a,o,l),d.baseTransform=Ot(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),(g=d.dependencyTracker)==null||g.restore(),h.restore(),c}_getCombinedScales(){const t=new Float32Array(2);$.singularValueDecompose2dScale(this.matrix,t);const[e,s]=t;return $.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[i,n],a){const[o,l,c,h]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new lu(d,a)),t.save(),s?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(i*this.xstep,n*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){const f=c-o,g=h-l,[m,v]=this._getCombinedScales(),w=this.getSizeAndScale(f,this.ctx.canvas.width,m),A=this.getSizeAndScale(g,this.ctx.canvas.height,v),_=this._renderTileCanvas(t,a,w,A);t.ctx.drawImage(_.canvas,o,l,f,g),t.canvasFactory.destroy(_)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,o,l,c,h),t.baseTransformStack.push(t.baseTransform),t.baseTransform=Ot(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){const[s,i,n,a]=this.bbox,o=n-s,l=a-i;let{xstep:c,ystep:h}=this;c=Math.abs(c),h=Math.abs(h),lg("TilingType: "+this.tilingType);const[d,f]=this._getCombinedScales();let g=o,m=l,v=!1,w=!1;Math.ceil(c*d)>=Math.ceil(o*d)?g=c:v=!0,Math.ceil(h*f)>=Math.ceil(l*f)?m=h:w=!0;const A=this.getSizeAndScale(g,this.ctx.canvas.width,d),_=this.getSizeAndScale(m,this.ctx.canvas.height,f),E=this._renderTileCanvas(t,e,A,_);if(v||w){const S=E.canvas;v&&(g=c),w&&(m=h);const x=this.getSizeAndScale(g,this.ctx.canvas.width,d),T=this.getSizeAndScale(m,this.ctx.canvas.height,f),C=x.size,I=T.size,k=t.canvasFactory.create(C,I),M=k.context,R=v?Math.min(Math.floor(o/c),Math.ceil(S.width/C)):0,N=w?Math.min(Math.floor(l/h),Math.ceil(S.height/I)):0;let F=S,j=null;if(w){j=t.canvasFactory.create(S.width,I);const U=j.context;for(let D=N;D>=0;D--)U.drawImage(S,0,I*D,S.width,I,0,0,S.width,I);F=j.canvas}for(let U=R;U>=0;U--)M.drawImage(F,C*U,0,C,I,0,0,C,I);return j&&t.canvasFactory.destroy(j),t.canvasFactory.destroy(E),{canvas:k.canvas,canvasEntry:k,scaleX:x.scale,scaleY:T.scale,offsetX:s,offsetY:i}}return{canvas:E.canvas,canvasEntry:E,scaleX:A.scale,scaleY:_.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){const i=Math.max(Tp.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const a=i-e,o=n-s,l=new Path2D;l.rect(e,s,a,o),$.axialAlignedBoundingBox([e,s,i,n],Ot(t.ctx),t.current.minMax),t.ctx.clip(l),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){var a;switch(e){case Dy.COLORED:s="#000000";break;case Dy.UNCOLORED:break;default:throw new Q0(`Unsupported paint type: ${e}`)}const{ctx:i,current:n}=t;n.patternFill=n.patternStroke=!1,i.fillStyle=i.strokeStyle=((a=n.transferMapsFallback)==null?void 0:a.applyToColor(s))??s,n.fillColor=n.strokeColor=s}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,n){const a=i!==Ue.SHADING?$.transform(s,this.patternBaseMatrix):s,o=this.createPatternCanvas(e,n);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const c=t.createPattern(o.canvas,"repeat");return e.canvasFactory.destroy(o.canvasEntry),c.setTransform(l),c}};O(Tp,"MAX_PATTERN_SIZE",3e3);let su=Tp;const tE=16,eE=100,sE=15,Fy=10,Ss=16,zs=new Float32Array(2);function Ly(u,t){if(u._removeMirroring)throw new Error("Context is already forwarding operations.");const e=new Map;for(const s of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const i=u[s];typeof i!="function"||typeof t[s]!="function"||(e.set(s,i),u[s]=function(...n){return t[s](...n),i.apply(this,n)})}u._removeMirroring=()=>{for(const[s,i]of e)u[s]=i;delete u._removeMirroring}}function pf(u,t,e,s,i,n,a,o,l,c){const[h,d,f,g,m,v]=Ot(u);if(d===0&&f===0){const _=a*h+m,E=Math.round(_),S=o*g+v,x=Math.round(S),T=(a+l)*h+m,C=Math.abs(Math.round(T)-E)||1,I=(o+c)*g+v,k=Math.abs(Math.round(I)-x)||1;return u.setTransform(Math.sign(h),0,0,Math.sign(g),E,x),u.drawImage(t,e,s,i,n,0,0,C,k),u.setTransform(h,d,f,g,m,v),[C,k]}if(h===0&&g===0){const _=o*f+m,E=Math.round(_),S=a*d+v,x=Math.round(S),T=(o+c)*f+m,C=Math.abs(Math.round(T)-E)||1,I=(a+l)*d+v,k=Math.abs(Math.round(I)-x)||1;return u.setTransform(0,Math.sign(d),Math.sign(f),0,E,x),u.drawImage(t,e,s,i,n,0,0,k,C),u.setTransform(h,d,f,g,m,v),[k,C]}u.drawImage(t,e,s,i,n,a,o,l,c);const w=Math.hypot(h,d),A=Math.hypot(f,g);return[w*l,A*c]}class Ny{constructor(t,e){O(this,"alphaIsShape",!1);O(this,"fontSize",0);O(this,"fontSizeScale",1);O(this,"textMatrix",null);O(this,"textMatrixScale",1);O(this,"fontMatrix",kg);O(this,"leading",0);O(this,"x",0);O(this,"y",0);O(this,"lineX",0);O(this,"lineY",0);O(this,"charSpacing",0);O(this,"wordSpacing",0);O(this,"textHScale",1);O(this,"textRenderingMode",ye.FILL);O(this,"textRise",0);O(this,"fillColor","#000000");O(this,"strokeColor","#000000");O(this,"tilingPatternDims",null);O(this,"patternFill",!1);O(this,"patternStroke",!1);O(this,"fillAlpha",1);O(this,"strokeAlpha",1);O(this,"lineWidth",1);O(this,"activeSMask",null);O(this,"transferMaps","none");O(this,"transferMapsFallback",null);O(this,"minMax",Ha.slice());this.clipBox=new Float32Array([0,0,t,e])}clone(){var e;const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=(e=this.tilingPatternDims)==null?void 0:e.slice(),t}getPathBoundingBox(t=Ue.FILL,e=null){const s=this.minMax.slice();if(t===Ue.STROKE){e||vt("Stroke bounding box must include transform."),$.singularValueDecompose2dScale(e,zs);const i=zs[0]*this.lineWidth/2,n=zs[1]*this.lineWidth/2;s[0]-=i,s[1]-=n,s[2]+=i,s[3]+=n}return s}updateClipFromPath(){const t=$.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(Ha,0)}getClippedPathBoundingBox(t=Ue.FILL,e=null){return $.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function By(u,t){const{width:e,height:s,kind:i}=t,n=s%Ss,a=(s-n)/Ss,o=n===0?a:a+1,l=u.createImageData(e,Ss);let c=0;const h=t.data,d=l.data;let f;if(i===wf.GRAYSCALE_1BPP)for(f=0;f<o;f++)({srcPos:c}=Ew({src:h,srcPos:c,dest:d,width:e,height:f<a?Ss:n})),u.putImageData(l,0,f*Ss);else if(i===wf.RGBA_32BPP){let g=0,m=e*Ss*4;for(f=0;f<a;f++)d.set(h.subarray(c,c+m)),c+=m,u.putImageData(l,0,g),g+=Ss;f<o&&(m=e*n*4,d.set(h.subarray(c,c+m)),u.putImageData(l,0,g))}else if(i===wf.RGB_24BPP)for(f=0;f<o;f++)({srcPos:c}=$S({src:h,srcPos:c,dest:new Uint32Array(d.buffer),width:e,height:f<a?Ss:n})),u.putImageData(l,0,f*Ss);else throw new Error(`bad image kind: ${i}`)}function Uy(u,t){if(t.bitmap){u.drawImage(t.bitmap,0,0);return}const{width:e,height:s}=t,i=s%Ss,n=(s-i)/Ss,a=i===0?n:n+1,o=u.createImageData(e,Ss);let l=0;const c=t.data,h=o.data;for(let d=0;d<a;d++)({srcPos:l}=Ew({src:c,srcPos:l,dest:h,width:e,height:d<n?Ss:i,nonBlackColor:0})),u.putImageData(o,0,d*Ss)}function ka(u,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)u[s]!==void 0&&(t[s]=u[s]);u.setLineDash!==void 0&&(t.setLineDash(u.getLineDash()),t.lineDashOffset=u.lineDashOffset)}function gf(u){u.strokeStyle=u.fillStyle="#000000",u.fillRule="nonzero",u.globalAlpha=1,u.lineWidth=1,u.lineCap="butt",u.lineJoin="miter",u.miterLimit=10,u.globalCompositeOperation="source-over",u.font="10px sans-serif",u.setLineDash!==void 0&&(u.setLineDash([]),u.lineDashOffset=0);const{filter:t}=u;t!=="none"&&t!==""&&(u.filter="none")}var _c;const ay=class ay{constructor(t){y(this,_c);const[e,s=e,i=e]=t,{identityMap:n}=ay;p(this,_c,[e||n,s||n,i||n])}static get identityMap(){return V(this,"identityMap",Uint8Array.from({length:256},(t,e)=>e))}applyToColor(t){if(typeof t!="string"||!t.startsWith("#"))return t;const[e,s,i]=xh(t),[n,a,o]=r(this,_c);return $.makeHexColor(n[e],a[s],o[i])}applyToImageData({data:t}){const[e,s,i]=r(this,_c);for(let n=0,a=t.length;n<a;n+=4)t[n]=e[t[n]],t[n+1]=s[t[n+1]],t[n+2]=i[t[n+2]]}applyToCanvas(t){const{width:e,height:s}=t.canvas,i=t.getImageData(0,0,e,s);this.applyToImageData(i),t.putImageData(i,0,0)}};_c=new WeakMap;let vm=ay;function Hy(u,t){if(t)return!0;$.singularValueDecompose2dScale(u,zs);const e=Math.fround(fi.pixelRatio*Ca.PDF_TO_CSS_UNITS);return zs[0]<=e&&zs[1]<=e}const iE=["butt","round","square"],rE=["miter","round","bevel"],nE={},jy={};var Cp,ks,Zn,_o,So,Eo,xo,To,Co,Po,rr,q,ym,bm,wm,Am,_m,ps,Ge,Sm,Vh,Tw,Of;const Na=class Na{constructor(t,e,s,i,n,{optionalContentConfig:a,markedContentStack:o=null},l,c,h,d){y(this,q);y(this,ks,0);y(this,Zn,0);y(this,_o,null);y(this,So,null);y(this,Eo,null);y(this,xo,null);y(this,To,1);y(this,Co);y(this,Po,null);y(this,rr,[]);this.ctx=t,this.current=new Ny(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null,this.imagesTracker=d??null}getObject(t,e,s=null){var i;return typeof e=="string"?((i=this.dependencyTracker)==null||i.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,a),this.ctx.fillStyle=o,s){const l=this.transparentCanvasEntry=this.canvasFactory.create(n,a);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=l,this.ctx.save(),this.ctx.transform(...Ot(this.compositeCtx))}this.ctx.save(),gf(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Ot(this.ctx)}executeOperatorList(t,e,s,i,n){var A;const a=t.argsArray,o=t.fnArray;let l=e||0;const c=a.length;if(c===l)return l;const h=c-l>Fy&&typeof s=="function",d=h?Date.now()+sE:0;let f=0;const g=this.commonObjs,m=this.objs;let v,w;for(;;){if(i!==void 0){if(l===i.nextBreakPoint)return i.breakIt(l,s),l;if(i.shouldSkip(l)){if(++l===c)return l;continue}}if(!n||n(l,t))if(v=o[l],w=a[l]??null,v!==zi.dependency)w===null?this[v](l):this[v](l,...w);else for(const _ of w){(A=this.dependencyTracker)==null||A.recordNamedData(_,l);const E=_.startsWith("g_")?g:m;if(!E.has(_))return E.get(_,s),l}if(l++,l===c)return l;if(h&&++f>Fy){if(Date.now()>d)return s(),l;f=0}}}endDrawing(){b(this,q,ym).call(this);for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(const t of r(this,rr))b(this,q,Of).call(this,t);r(this,rr).length=0,p(this,_o,null),p(this,So,null),p(this,Eo,null),p(this,xo,null),p(this,To,1),p(this,Po,null),p(this,Zn,0),p(this,ks,0),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),b(this,q,bm).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight,n=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=[];let l=n,c=a,h=s,d=i;for(;l>2&&h>1||c>2&&d>1;){let A=h,_=d;l>2&&h>1&&(A=Math.ceil(h/2),l/=h/A),c>2&&d>1&&(_=Math.ceil(d/2),c/=d/_),o.push({newWidth:A,newHeight:_}),h=A,d=_}if(o.length===0)return{img:t,paintWidth:s,paintHeight:i,tmpCanvas:null};if(o.length===1){const{newWidth:A,newHeight:_}=o[0],E=this.canvasFactory.create(A,_);return E.context.drawImage(t,0,0,s,i,0,0,A,_),{img:E.canvas,paintWidth:A,paintHeight:_,tmpCanvas:E}}let f=this.canvasFactory.create(1,1),g=this.canvasFactory.create(1,1),m=s,v=i,w=t;for(const{newWidth:A,newHeight:_}of o)this.canvasFactory.reset(g,A,_),g.context.drawImage(w,0,0,m,v,0,0,A,_),[f,g]=[g,f],w=f.canvas,m=A,v=_;return this.canvasFactory.destroy(g),{img:f.canvas,paintWidth:m,paintHeight:v,tmpCanvas:f}}_createMaskCanvas(t,e){var R,N;const s=this.ctx,{width:i,height:n}=e,a=this.current.patternFill,o=a?this.current.fillColor:s.fillStyle,l=Ot(s);let c,h,d,f;if((e.bitmap||e.data)&&e.count>1){const F=e.bitmap||e.data.buffer;h=JSON.stringify(a?l:[l.slice(0,4),o]),c=this._cachedBitmapsMap.getOrInsertComputed(F,zv);const j=c.get(h);if(j&&!a){const U=Math.round(Math.min(l[0],l[2])+l[4]),D=Math.round(Math.min(l[1],l[3])+l[5]);return(R=this.dependencyTracker)==null||R.recordDependencies(t,Ks.transformAndFill),{canvas:j,offsetX:U,offsetY:D}}d=j}d||(f=this.canvasFactory.create(i,n),Uy(f.context,e));let g=$.transform(l,[1/i,0,0,-1/n,0,0]);g=$.transform(g,[1,0,0,1,0,-n]);const m=Ha.slice();$.axialAlignedBoundingBox([0,0,i,n],g,m);const[v,w,A,_]=m,E=Math.round(A-v)||1,S=Math.round(_-w)||1,x=this.canvasFactory.create(E,S),T=x.context,C=v,I=w;T.translate(-C,-I),T.transform(...g);let k=null;if(!d){const F=this._scaleImage(f.canvas,Ui(T));d=F.img,k=F.tmpCanvas,d!==f.canvas&&(this.canvasFactory.destroy(f),f=null),c&&a&&(c.set(h,d),k=null,f=null)}T.imageSmoothingEnabled=Hy(Ot(T),e.interpolate),pf(T,d,0,0,d.width,d.height,0,0,i,n),k&&this.canvasFactory.destroy(k),f&&this.canvasFactory.destroy(f),T.globalCompositeOperation="source-in";const M=$.transform(Ui(T),[1,0,0,1,-C,-I]);return T.fillStyle=a?o.getPattern(s,this,M,Ue.FILL,t):o,T.fillRect(0,0,i,n),c&&!a&&c.set(h,x.canvas),(N=this.dependencyTracker)==null||N.recordDependencies(t,Ks.transformAndFill),{canvas:x.canvas,canvasEntry:c&&!a?null:x,offsetX:Math.round(C),offsetY:Math.round(I)}}setLineWidth(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineCap",t),this.ctx.lineCap=iE[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=rE[e]}setMiterLimit(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){var n;(n=this.dependencyTracker)==null||n.recordSimpleData("dash",t);const i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var s,i,n,a,o;for(const[l,c]of e)switch(l){case"LW":this.setLineWidth(t,c);break;case"LC":this.setLineCap(t,c);break;case"LJ":this.setLineJoin(t,c);break;case"ML":this.setMiterLimit(t,c);break;case"D":this.setDash(t,c[0],c[1]);break;case"RI":this.setRenderingIntent(t,c);break;case"FL":this.setFlatness(t,c);break;case"Font":this.setFont(t,c[0],c[1]);break;case"CA":(s=this.dependencyTracker)==null||s.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=c;break;case"ca":(i=this.dependencyTracker)==null||i.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=c;break;case"BM":(n=this.dependencyTracker)==null||n.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=c;break;case"SMask":(a=this.dependencyTracker)==null||a.recordSimpleData("SMask",t),this.current.activeSMask=c?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":{(o=this.dependencyTracker)==null||o.recordSimpleData("filter",t);let h=this.filterFactory.addFilter(c);this.ctx.filter=h;let d=null;c&&(h==="none"||!Et.isCanvasFilterSupported||this.ctx.filter==="none"||this.ctx.filter==="")&&(this.ctx.filter=h="none",d=new vm(c)),this.current.transferMaps=h,(d||this.current.transferMapsFallback)&&(this.current.transferMapsFallback=d,this.current.patternFill||(this.ctx.fillStyle=b(this,q,Vh).call(this,this.current.fillColor)),this.current.patternStroke||(this.ctx.strokeStyle=b(this,q,Vh).call(this,this.current.strokeColor)));break}}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t))}checkSMaskState(t){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){const{canvas:e,subtype:s,backdrop:i,transferMap:n}=t,a=s==="Luminosity"||s==="Alpha"&&n;if(!a&&!(s==="Luminosity"&&i)){this.smaskPreparedFor=t;return}let o;if(s==="Luminosity"&&i){const[_,E,S]=xh(i),x=Math.round(.3*_+.59*E+.11*S);o=(n==null?void 0:n[x])??x}else o=(n==null?void 0:n[0])??0;const l=4,{width:c,height:h}=this.ctx.canvas,d=e.width*e.height,f=c*h<l*d,g=a?{url:s==="Alpha"?this.filterFactory.addAlphaFilter(n):this.filterFactory.addLuminosityFilter(n),subtype:s,transferMap:n}:null,m=s==="Luminosity"?i:null;let v,w,A;f?(v=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,c,h,m,g),w=0,A=0):(v=this._bakeSMaskCanvas(e,0,0,e.width,e.height,m,g),w=t.offsetX,A=t.offsetY),this.smaskPreparedEntry=v,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=w,this.smaskPreparedOffsetY=A,this.smaskPreparedOOBAlpha=!f&&o!==0?o:null}_bakeSMaskCanvas(t,e,s,i,n,a,o){!a&&!o&&vt("_bakeSMaskCanvas with neither backdrop nor filter");const l=this.canvasFactory.create(i,n),c=l.context;if(c.drawImage(t,e,s),a&&(c.globalCompositeOperation="destination-atop",c.fillStyle=a,c.fillRect(0,0,i,n)),!o)return l;const h=this.canvasFactory.create(i,n),d=h.context;d.filter=o.url;const f=Et.isCanvasFilterSupported&&d.filter!=="none"&&d.filter!=="";if(d.drawImage(l.canvas,0,0),Et.isCanvasFilterSupported&&(d.filter="none"),!f){const g=d.getImageData(0,0,i,n),{data:m}=g,{transferMap:v}=o;if(o.subtype==="Luminosity")for(let w=0,A=m.length;w<A;w+=4){const _=.3*m[w]+.59*m[w+1]+.11*m[w+2]+.5|0;m[w]=m[w+1]=m[w+2]=0,m[w+3]=(v==null?void 0:v[_])??_}else for(let w=3,A=m.length;w<A;w+=4)m[w]=v[m[w]];d.putImageData(g,0,0)}return this.canvasFactory.destroy(l),h}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:e,height:s}=this.ctx.canvas,i=this.canvasFactory.create(e,s);this.smaskScratchCanvas=i,this.suspendedCtx=this.ctx;const n=this.ctx=i.context;n.setTransform(this.suspendedCtx.getTransform()),ka(this.suspendedCtx,n),Ly(n,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),ka(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx,i=r(this,Zn)>0&&s===this.ctx;this.composeSMask(i?null:s,e,this.ctx,t),!i&&(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,s,i){const n=i[0],a=i[1],o=i[2]-n,l=i[3]-a;if(o===0||l===0)return;const c=this.smaskPreparedEntry;if(c){let h=n,d=a,f=o,g=l;const m=this.smaskPreparedOOBAlpha,v=m!==null;if(v){h=Math.max(n,e.offsetX),d=Math.max(a,e.offsetY);const w=Math.min(n+o,e.offsetX+e.canvas.width),A=Math.min(a+l,e.offsetY+e.canvas.height);f=w-h,g=A-d}if(f>0&&g>0){const w=h-this.smaskPreparedOffsetX,A=d-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const _=new Path2D;_.rect(h,d,f,g),s.clip(_),s.globalCompositeOperation="destination-in",s.drawImage(c.canvas,w,A,f,g,h,d,f,g),s.restore()}v&&m<255&&this._applySMaskOOBAlpha(s,n,a,o,l,h,d,h+f,d+g,m)}else this.genericComposeSMask(e,s,o,l,n,a);t&&(t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,n,a,o,l,n,a,o,l),t.restore())}_applySMaskOOBAlpha(t,e,s,i,n,a,o,l,c,h){const d=a<l&&o<c;if(d&&a===e&&o===s&&l===e+i&&c===s+n)return;const f=new Path2D;f.rect(e,s,i,n),d&&f.rect(a,o,l-a,c-o),t.save(),t.globalAlpha=h/255,t.setTransform(1,0,0,1,0,0),t.clip(f,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,s,i,n),t.restore()}genericComposeSMask(t,e,s,i,n,a){const{context:o,offsetX:l,offsetY:c}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const h=new Path2D;h.rect(n,a,s,i),e.clip(h),e.globalCompositeOperation="destination-in",e.drawImage(o.canvas,n-l,a-c,s,i,n,a,s,i),e.restore()}save(t){var s;this.inSMaskMode&&ka(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(s=this.dependencyTracker)==null||s.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(ka(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1}transform(t,e,s,i,n,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,n,a,o),this._cachedScaleForStroking[0]=-1}constructPath(t,e,s,i){let[n]=s;if(!i){n||(n=s[0]=new Path2D),e!==zi.stroke&&e!==zi.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,n);return}if(this.dependencyTracker!==null){const o=e===zi.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-o,i[2]+o,i[1]-o,i[3]+o).recordDependencies(t,["transform"])}n instanceof Path2D||(n=s[0]=Ib(n)),$.axialAlignedBoundingBox(i,Ot(this.ctx),this.current.minMax);const a=this.current.tilingPatternDims;if(a&&e!==zi.stroke&&e!==zi.closeStroke&&this.current.fillColor instanceof su){const o=$.intersect(this.current.clipBox,this.current.minMax);o?this.current.fillColor.updatePatternDims(o,a):this.current.tilingPatternDims=null}this[e](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){var o;const i=s&&b(this,q,ps).call(this,this.current.strokeAlpha),n=this.ctx,a=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof a=="object"&&(a!=null&&a.getPattern)){const l=a.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=a.getPattern(n,this,Ui(n),Ue.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,Ks.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(Ue.STROKE,Ot(this.ctx))),n.globalAlpha=this.current.fillAlpha,b(this,q,Ge).call(this,i)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var h,d,f;const i=s&&b(this,q,ps).call(this,this.current.fillAlpha),n=this.ctx,a=this.current.fillColor,o=this.current.patternFill;let l=!1;const c=this.current.getClippedPathBoundingBox();if((h=this.dependencyTracker)==null||h.recordDependencies(t,Ks.fill),o){const g=this.current.tilingPatternDims,m=g&&a.canSkipPatternCanvas(g);if(m){a.drawPattern(this,e,this.pendingEOFill,m,t),this.pendingEOFill=!1,s&&this.consumePath(t,e,c),this.current.tilingPatternDims=null,b(this,q,Ge).call(this,i);return}const v=a.isModifyingCurrentTransform()?n.getTransform():null;if((d=this.dependencyTracker)==null||d.save(t),n.save(),n.fillStyle=a.getPattern(n,this,Ui(n),Ue.FILL,t),v){const w=new Path2D;w.addPath(e,n.getTransform().invertSelf().multiplySelf(v)),e=w}l=!0}this.contentVisible&&c!==null&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),l&&(n.restore(),(f=this.dependencyTracker)==null||f.restore(t)),s&&this.consumePath(t,e,c),b(this,q,Ge).call(this,i)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){const s=b(this,q,ps).call(this,Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),b(this,q,Ge).call(this,s)}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;const s=b(this,q,ps).call(this,this.current.fillAlpha);this.ctx.fill(e),(i=this.dependencyTracker)==null||i.recordDependencies(t,Ks.rawFillPath).recordOperation(t),b(this,q,Ge).call(this,s)}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=jy}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;e!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(e!==void 0){const i=new Path2D,n=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:c,path:h}of e)h&&i.addPath(h,new DOMMatrix(a).preMultiplySelf(n).translate(o,l).scale(c,-c));s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){var d,f;(d=this.dependencyTracker)==null||d.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const i=this.commonObjs.get(e),n=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(n.fontMatrix=i.fontMatrix||kg,(n.fontMatrix[0]===0||n.fontMatrix[3]===0)&&st("Invalid font matrix for font "+e),s<0?(s=-s,n.fontDirection=-1):n.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;const a=i.loadedName||"sans-serif",o=((f=i.systemFontInfo)==null?void 0:f.css)||`"${a}", ${i.fallbackName}`;let l="normal";i.black?l="900":i.bold&&(l="bold");const c=i.italic?"italic":"normal",h=jt(s,tE,eE);this.current.fontSizeScale=s/h,this.ctx.font=`${c} ${l} ${h}px ${o}`}setTextRenderingMode(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}paintChar(t,e,s,i,n,a){var A,_,E,S;const o=this.ctx,l=this.current,c=l.font,h=l.textRenderingMode,d=l.fontSize/l.fontSizeScale,f=h&ye.FILL_STROKE_MASK,g=!!(h&ye.ADD_TO_PATH_FLAG),m=l.patternFill&&!c.missingFile,v=l.patternStroke&&!c.missingFile;let w;if((c.disableFontFace||g||m||v)&&!c.missingFile&&(w=c.getPathGenerator(this.commonObjs,e)),w&&(c.disableFontFace||m||v)){o.save(),o.translate(s,i),o.scale(d,-d),(A=this.dependencyTracker)==null||A.recordCharacterBBox(t,o,c);let x;if(f===ye.FILL||f===ye.FILL_STROKE)if(n){x=o.getTransform(),o.setTransform(...n);const T=b(this,q,Sm).call(this,w,x,n);o.fill(T)}else o.fill(w);if(f===ye.STROKE||f===ye.FILL_STROKE)if(a){x||(x=o.getTransform()),o.setTransform(...a);const{a:T,b:C,c:I,d:k}=x,M=$.inverseTransform(a),R=$.transform([T,C,I,k,0,0],M);$.singularValueDecompose2dScale(R,zs),o.lineWidth*=Math.max(zs[0],zs[1])/d,o.stroke(b(this,q,Sm).call(this,w,x,a))}else o.lineWidth/=d,o.stroke(w);o.restore()}else(f===ye.FILL||f===ye.FILL_STROKE)&&(o.fillText(e,s,i),(_=this.dependencyTracker)==null||_.recordCharacterBBox(t,o,c,d,s,i,()=>o.measureText(e))),(f===ye.STROKE||f===ye.FILL_STROKE)&&(this.dependencyTracker&&((E=this.dependencyTracker)==null||E.recordCharacterBBox(t,o,c,d,s,i,()=>o.measureText(e)).recordDependencies(t,Ks.stroke)),o.strokeText(e,s,i));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Ot(o),x:s,y:i,fontSize:d,path:w}),(S=this.dependencyTracker)==null||S.recordCharacterBBox(t,o,c,d,s,i))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let i=!1;for(let n=3;n<s.length;n+=4)if(s[n]>0&&s[n]<255){i=!0;break}return V(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var R,N,F,j;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Ks.showText).resetBBox(t),this.current.textRenderingMode&ye.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){const U=b(this,q,ps).call(this,s.fillAlpha);this.showType3Text(t,e),(R=this.dependencyTracker)==null||R.recordShowTextOperation(t),b(this,q,Ge).call(this,U);return}const n=s.fontSize;if(n===0){(N=this.dependencyTracker)==null||N.recordOperation(t);return}const a=b(this,q,ps).call(this,s.fillAlpha),o=this.ctx,l=s.fontSizeScale,c=s.charSpacing,h=s.wordSpacing,d=s.fontDirection,f=s.textHScale*d,g=e.length,m=i.vertical,v=m?1:-1,w=n*s.fontMatrix[0],A=s.textRenderingMode===ye.FILL&&!i.disableFontFace&&!s.patternFill;o.save(),s.textMatrix&&o.transform(...s.textMatrix),o.translate(s.x,s.y+s.textRise),d>0?o.scale(f,-1):o.scale(f,1);let _,E;const S=s.textRenderingMode&ye.FILL_STROKE_MASK,x=S===ye.FILL||S===ye.FILL_STROKE,T=S===ye.STROKE||S===ye.FILL_STROKE;let C=s.lineWidth;const I=s.textMatrixScale;if(I===0||C===0?T&&(C=this.getSinglePixelWidth()):C/=I,l!==1&&(o.scale(l,l),C/=l),o.lineWidth=C,x&&s.patternFill){o.save();const U=s.fillColor.getPattern(o,this,Ui(o),Ue.FILL,t);_=Ot(o),o.restore(),o.fillStyle=U}if(T&&s.patternStroke){o.save();const U=s.strokeColor.getPattern(o,this,Ui(o),Ue.STROKE,t);E=Ot(o),o.restore(),o.strokeStyle=U}if(i.isInvalidPDFjsFont){const U=[];let D=0;for(const X of e)U.push(X.unicode),D+=X.width;const H=U.join("");if(o.fillText(H,0,0),this.dependencyTracker!==null){const X=o.measureText(H);this.dependencyTracker.recordBBox(t,this.ctx,-X.actualBoundingBoxLeft,X.actualBoundingBoxRight,-X.actualBoundingBoxAscent,X.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=D*w*f,o.restore(),this.compose(),b(this,q,Ge).call(this,a);return}let k=0,M;for(M=0;M<g;++M){const U=e[M];if(typeof U=="number"){k+=v*U*n/1e3;continue}let D=!1;const H=(U.isSpace?h:0)+c,X=U.fontChar,nt=U.accent;let gt,mt,ht=U.width;if(m){const G=U.vmetric,L=-G[1]*w,B=G[2]*w;ht=-G[0],gt=L/l,mt=(k+B)/l}else gt=k/l,mt=0;let at;if(i.remeasure&&ht>0){at=o.measureText(X);const G=at.width*1e3/n*l;if(ht<G&&this.isFontSubpixelAAEnabled){const L=ht/G;D=!0,o.save(),o.scale(L,1),gt/=L}else ht!==G&&(gt+=(ht-G)/2e3*n/l)}if(this.contentVisible&&(U.isInFont||i.missingFile)){if(A&&!nt)o.fillText(X,gt,mt),(F=this.dependencyTracker)==null||F.recordCharacterBBox(t,o,at?{bbox:null}:i,n/l,gt,mt,()=>at??o.measureText(X));else if(this.paintChar(t,X,gt,mt,_,E),nt){const G=gt+n*nt.offset.x/l,L=mt-n*nt.offset.y/l;this.paintChar(t,nt.fontChar,G,L,_,E)}}const Ee=m?ht*w-H*d:ht*w+H*d;k+=Ee,D&&o.restore()}m?s.y-=k:s.x+=k*f,o.restore(),this.compose(),(j=this.dependencyTracker)==null||j.recordShowTextOperation(t),b(this,q,Ge).call(this,a)}showType3Text(t,e){const s=this.ctx,i=this.current,n=i.font,a=i.fontSize,o=i.fontDirection,l=n.vertical?1:-1,c=i.charSpacing,h=i.wordSpacing,d=i.textHScale*o,f=i.fontMatrix||kg,g=e.length,m=i.textRenderingMode===ye.INVISIBLE;let v,w,A,_;if(m||a===0)return;this._cachedScaleForStroking[0]=-1,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(d,o);const E=this.dependencyTracker;for(this.dependencyTracker=E?new lu(E,t):null,v=0;v<g;++v){if(w=e[v],typeof w=="number"){_=l*w*a/1e3,this.ctx.translate(_,0),i.x+=_*d;continue}const S=(w.isSpace?h:0)+c,x=n.charProcOperatorList.get(w.operatorListId);x?this.contentVisible&&(this.save(),x.fnArray[0]===zi.setCharWidth&&(i.fillAlpha=i.strokeAlpha=1,s.globalAlpha=1),s.scale(a,a),s.transform(...f),this.executeOperatorList(x),this.restore()):st(`Type3 character "${w.operatorListId}" is not available.`);const T=[w.width,0];$.applyTransform(T,f),A=T[0]*a+S,s.translate(A,0),i.x+=A*d}s.restore(),E&&(this.dependencyTracker=E)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,n,a,o){var c;const l=new Path2D;l.rect(i,n,a-i,o-n),this.ctx.clip(l),(c=this.dependencyTracker)==null||c.recordBBox(t,this.ctx,i,a,n,o).recordClipBox(t,this.ctx,i,a,n,o),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const i=this.baseTransform||Ot(this.ctx),n={createCanvasGraphics:(a,o)=>new Na(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new lu(this.dependencyTracker,o,!0):null)};s=new su(e,this.ctx,n,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("fillColor",t);const s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof su?[0,0,0,0]:null}setStrokeRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.current.strokeColor=e,this.ctx.strokeStyle=b(this,q,Vh).call(this,e),this.current.patternStroke=!1}setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.current.fillColor=e,this.ctx.fillStyle=b(this,q,Vh).call(this,e),this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,s=null){const i=this.cachedPatterns.getOrInsertComputed(e,()=>ZS(this.getObject(t,e)));return s&&(i.matrix=s),i}shadingFill(t,e){var o;if(!this.contentVisible)return;const s=b(this,q,ps).call(this,this.current.fillAlpha),i=this.ctx;this.save(t);const n=this._getPattern(t,e);i.fillStyle=n.getPattern(i,this,Ui(i),Ue.SHADING,t);const a=Ui(i);if(a){const{width:l,height:c}=i.canvas,h=Ha.slice();$.axialAlignedBoundingBox([0,0,l,c],a,h);const[d,f,g,m]=h;this.ctx.fillRect(d,f,g-d,m-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Ks.transform).recordDependencies(t,Ks.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),b(this,q,Ge).call(this,s)}beginInlineImage(){vt("Should not call beginInlineImage")}beginImageData(){vt("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var i;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Ot(this.ctx),s)){$.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[n,a,o,l]=s,c=new Path2D;c.rect(n,a,o-n,l-a),this.ctx.clip(c),(i=this.dependencyTracker)==null||i.recordClipBox(t,this.ctx,n,o,a,l),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var S;if(!this.contentVisible)return;this.save(t);const{inSMaskMode:s}=this;s&&(this.endSMaskMode(),this.current.activeSMask=null);const i=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&r(this,ks)===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let x=new Path2D;const[T,C,I,k]=e.bbox;if(x.rect(T,C,I-T,k-C),e.matrix){const M=new Path2D;M.addPath(x,new DOMMatrix(e.matrix)),x=M}i.clip(x)}this.groupStack.push(null),r(this,rr).push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&r(this,ks)===0&&lg("TODO: Fully support non-isolated non-knockout groups.");const n=Ot(i);e.matrix&&i.transform(...e.matrix);const a=[0,0,i.canvas.width,i.canvas.height];let o;e.bbox?(o=Ha.slice(),$.axialAlignedBoundingBox(e.bbox,Ot(i),o),o=$.intersect(o,a)||[0,0,0,0]):o=a;const l=Math.floor(o[0]),c=Math.floor(o[1]),h=Math.max(Math.ceil(o[2])-l,1),d=Math.max(Math.ceil(o[3])-c,1);this.current.startNewPathAndClipBox([0,0,h,d]);const f=this.canvasFactory.create(h,d);e.smask&&this.smaskGroupCanvases.push(f);const g=f.context,m=e.knockout&&!e.isolated?i:null,v=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&r(this,ks)>0,w=e.knockout?this.canvasFactory.create(h,d):null,A=r(this,ks);e.knockout?Ft(this,ks)._++:p(this,ks,0),g.translate(-l,-c),g.transform(...n);const _=!e.isolated&&!e.smask&&e.needsIsolation,E=_&&!s&&A===0&&!e.knockout&&!e.isGray&&e.hasSoftMask&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&this.current.transferMaps==="none"&&!this.current.transferMapsFallback;if(_&&(s||E)&&(g.save(),g.setTransform(1,0,0,1,0,0),g.drawImage(i.canvas,-l,-c),g.restore()),e.bbox){let x=new Path2D;const[T,C,I,k]=e.bbox;if(x.rect(T,C,I-T,k-C),e.matrix){const M=new Path2D;M.addPath(x,new DOMMatrix(e.matrix)),x=M}g.clip(x)}e.smask&&this.smaskStack.push({canvas:f.canvas,context:g,offsetX:l,offsetY:c,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),(!e.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(l,c),i.save()),ka(i,g),this.ctx=g,(S=this.dependencyTracker)==null||S.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),r(this,rr).push({backdropCtx:m,savedKnockoutLevel:A,offsetX:l,offsetY:c,hasInnerBackdrop:v,replaceBackdrop:E,knockoutMaskEntry:w,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){var a,o;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,i=this.groupStack.pop(),n=r(this,rr).pop();if(n&&p(this,ks,n.savedKnockoutLevel),i===null){this.restore(t);return}if(e.isGray&&b(this,q,Tw).call(this,s),this.ctx=i,this.ctx.imageSmoothingEnabled=!1,(a=this.dependencyTracker)==null||a.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),b(this,q,Of).call(this,n);else{this.ctx.restore();const l=Ot(this.ctx);this.restore(t),(o=this.current.transferMapsFallback)==null||o.applyToCanvas(s),this.ctx.save(),this.ctx.setTransform(...l);const c=Ha.slice();$.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],l,c);const h=r(this,rr).at(-1);if(r(this,ks)>0)if(n.hasInnerBackdrop){const{width:d,height:f}=s.canvas,g=this.canvasFactory.create(d,f),m=g.context;m.drawImage(i.canvas,n.offsetX,n.offsetY,d,f,0,0,d,f),m.globalCompositeOperation="source-over",m.drawImage(s.canvas,0,0);const v=b(this,q,wm).call(this,s.canvas);m.globalCompositeOperation="destination-in",m.drawImage(v.canvas,0,0);const w=this.ctx.globalCompositeOperation,A=this.ctx.globalAlpha,_=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...l),this.ctx.globalAlpha=1,Et.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(v.canvas,0,0),this.ctx.globalCompositeOperation=w,this.ctx.globalAlpha=A,Et.isCanvasFilterSupported&&(this.ctx.filter=_??"none"),this.ctx.drawImage(g.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(v),this.canvasFactory.destroy(g)}else{const d=(h==null?void 0:h.backdropCtx)??null;b(this,q,_m).call(this,this.ctx,s.canvas,{backdropCanvas:(d==null?void 0:d.canvas)??null,destTransform:l,backdropOffset:d?[h.offsetX+n.offsetX,h.offsetY+n.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(n.replaceBackdrop){const d=new Path2D;d.rect(0,0,s.canvas.width,s.canvas.height),this.ctx.clip(d),this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(s.canvas,0,0)}this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),b(this,q,Of).call(this,n),this.compose(c)}}beginAnnotation(t,e,s,i,n,a,o){if(b(this,q,ym).call(this),gf(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const l=s[2]-s[0],c=s[3]-s[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],$.singularValueDecompose2dScale(Ot(this.ctx),zs);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:g,context:m}=this.annotationCanvas;if(o){const v=this.annotationCanvasMap.getOrInsertComputed(e,Eh);g.setAttribute("data-canvas-name",o);const w=v.findIndex(A=>A.getAttribute("data-canvas-name")===o);w===-1?v.push(g):v[w]=g}else this.annotationCanvasMap.set(e,g);this.annotationCanvas.savedCtx=this.ctx,this.ctx=m,this.ctx.save(),this.ctx.setTransform(zs[0],0,0,-zs[1],0,c*zs[1]),gf(this.ctx)}else{gf(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],l,c),this.ctx.clip(h)}}this.current=new Ny(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...n),this.baseTransform=Ot(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),b(this,q,bm).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){var l;if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const i=b(this,q,ps).call(this,this.current.fillAlpha),n=this.ctx,a=this._createMaskCanvas(t,e),o=a.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(o,a.offsetX,a.offsetY),(l=this.dependencyTracker)==null||l.resetBBox(t).recordBBox(t,this.ctx,a.offsetX,a.offsetX+o.width,a.offsetY,a.offsetY+o.height).recordOperation(t),n.restore(),a.canvasEntry&&this.canvasFactory.destroy(a.canvasEntry),this.compose(),b(this,q,Ge).call(this,i)}paintImageMaskXObjectRepeat(t,e,s,i=0,n=0,a,o){var f,g,m;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=b(this,q,ps).call(this,this.current.fillAlpha),c=this.ctx;c.save();const h=Ot(c);c.transform(s,i,n,a,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 v=0,w=o.length;v<w;v+=2){const A=$.transform(h,[s,i,n,a,o[v],o[v+1]]);c.drawImage(d.canvas,A[4],A[5]),(g=this.dependencyTracker)==null||g.recordBBox(t,this.ctx,A[4],A[4]+d.canvas.width,A[5],A[5]+d.canvas.height)}c.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),(m=this.dependencyTracker)==null||m.recordOperation(t),b(this,q,Ge).call(this,l)}paintImageMaskXObjectGroup(t,e){var o,l,c;if(!this.contentVisible)return;const s=b(this,q,ps).call(this,this.current.fillAlpha),i=this.ctx,n=this.current.patternFill,a=n?this.current.fillColor:i.fillStyle;(o=this.dependencyTracker)==null||o.resetBBox(t).recordDependencies(t,Ks.transformAndFill);for(const h of e){const{data:d,width:f,height:g,transform:m}=h,v=this.canvasFactory.create(f,g),w=v.context;w.save();const A=this.getObject(t,d,h);Uy(w,A),w.globalCompositeOperation="source-in",w.fillStyle=n?a.getPattern(w,this,Ui(i),Ue.FILL,t):a,w.fillRect(0,0,f,g),w.restore(),i.save(),i.transform(...m),i.scale(1,-1),pf(i,v.canvas,0,0,f,g,0,-1,1,1),this.canvasFactory.destroy(v),(l=this.dependencyTracker)==null||l.recordBBox(t,i,0,f,0,g),i.restore()}this.compose(),(c=this.dependencyTracker)==null||c.recordOperation(t),b(this,q,Ge).call(this,s)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){st("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,n){if(!this.contentVisible)return;const a=this.getObject(t,e);if(!a){st("Dependent image isn't ready yet");return}const o=a.width,l=a.height,c=[];for(let h=0,d=n.length;h<d;h+=2)c.push({transform:[s,0,0,i,n[h],n[h+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(t,a,c)}applyTransferMapsToCanvas(t){var e;return this.current.transferMaps!=="none"?(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"):(e=this.current.transferMapsFallback)==null||e.applyToCanvas(t),t.canvas}applyTransferMapsToBitmap(t){const{transferMaps:e,transferMapsFallback:s}=this.current;if(e==="none"&&!s)return{img:t.bitmap,canvasEntry:null};const{bitmap:i,width:n,height:a}=t,o=this.canvasFactory.create(n,a),l=o.context;return l.filter=e,l.drawImage(i,0,0),l.filter="none",s==null||s.applyToCanvas(l),{img:o.canvas,canvasEntry:o}}paintInlineImageXObject(t,e){var d;if(!this.contentVisible)return;const s=e.width,i=e.height,n=b(this,q,ps).call(this,this.current.fillAlpha),a=this.ctx;this.save(t);const{filter:o}=a;o!=="none"&&o!==""&&(a.filter="none"),a.scale(1/s,-1/i);let l,c=null;if(e.bitmap){const f=this.applyTransferMapsToBitmap(e);l=f.img,c=f.canvasEntry}else{const f=this.canvasFactory.create(s,i);By(f.context,e),l=this.applyTransferMapsToCanvas(f.context),c=f}const h=this._scaleImage(l,Ui(a));a.imageSmoothingEnabled=Hy(Ot(a),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,a,0,s,-i,0).recordDependencies(t,Ks.imageXObject).recordOperation(t),(d=this.imagesTracker)==null||d.record(a,s,i,this.dependencyTracker.clipBox)),pf(a,h.img,0,0,h.paintWidth,h.paintHeight,0,-i,s,i),h.tmpCanvas&&this.canvasFactory.destroy(h.tmpCanvas),c&&this.canvasFactory.destroy(c),this.compose(),this.restore(t),b(this,q,Ge).call(this,n)}paintInlineImageXObjectGroup(t,e,s){var l,c,h;if(!this.contentVisible)return;const i=b(this,q,ps).call(this,this.current.fillAlpha),n=this.ctx;let a,o=null;if(e.bitmap&&!this.current.transferMapsFallback)a=e.bitmap;else if(e.bitmap)({img:a,canvasEntry:o}=this.applyTransferMapsToBitmap(e));else{const d=e.width,f=e.height,g=this.canvasFactory.create(d,f);By(g.context,e),a=this.applyTransferMapsToCanvas(g.context),o=g}(l=this.dependencyTracker)==null||l.resetBBox(t);for(const d of s)n.save(),n.transform(...d.transform),n.scale(1,-1),pf(n,a,d.x,d.y,d.w,d.h,0,-1,1,1),(c=this.dependencyTracker)==null||c.recordBBox(t,n,0,1,-1,0),n.restore();o&&this.canvasFactory.destroy(o),(h=this.dependencyTracker)==null||h.recordOperation(t),this.compose(),b(this,q,Ge).call(this,i)}paintSolidColorImageMask(t){var s;if(!this.contentVisible)return;const e=b(this,q,ps).call(this,this.current.fillAlpha);(s=this.dependencyTracker)==null||s.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ks.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),b(this,q,Ge).call(this,e)}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){var i;(i=this.dependencyTracker)==null||i.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){var a,o;const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const n=this.ctx;this.pendingClip?(i||(this.pendingClip===jy?n.clip(e,"evenodd"):n.clip(e)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(o=this.dependencyTracker)==null||o.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){const t=Ot(this.ctx);if(t[1]===0&&t[2]===0)return 1/Math.min(Math.abs(t[0]),Math.abs(t[3]));const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);return Math.max(s,i)/e}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let a,o;if(s===0&&i===0){const l=Math.abs(e),c=Math.abs(n);if(l===c)if(t===0)a=o=1/l;else{const h=l*t;a=o=h<1?1/h:1}else if(t===0)a=1/l,o=1/c;else{const h=l*t,d=c*t;a=h<1?1/h:1,o=d<1?1/d:1}}else{const l=Math.abs(e*n-s*i),c=Math.hypot(e,s),h=Math.hypot(i,n);if(t===0)a=h/l,o=c/l;else{const d=t*l;a=h>d?h/d:1,o=c>d?c/d:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[n,a]=this.getScaleForStroking();if(n===a){s.lineWidth=(i||1)*n,s.stroke(t);return}const o=r(Na,Cp)??p(Na,Cp,new DOMMatrix),l=s.getLineDash();e&&s.save(),s.scale(n,a),o.a=1/n,o.d=1/a;const c=new Path2D;if(c.addPath(t,o),l.length>0){const h=Math.max(n,a);s.setLineDash(l.map(d=>d/h)),s.lineDashOffset/=h}s.lineWidth=i||1,s.stroke(c),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Cp=new WeakMap,ks=new WeakMap,Zn=new WeakMap,_o=new WeakMap,So=new WeakMap,Eo=new WeakMap,xo=new WeakMap,To=new WeakMap,Co=new WeakMap,Po=new WeakMap,rr=new WeakMap,q=new WeakSet,ym=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.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)},bm=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}}},wm=function(t,e=null,s=1){const{width:i,height:n}=t,a=e??this.canvasFactory.create(i,n),o=a.context;s=Math.round(s*255)/255;const l=s<1;l&&r(this,Co)===void 0&&p(this,Co,Et.isCanvasFilterSupported?new Map:"none");let c="none";if(l&&r(this,Co)instanceof Map&&(c=r(this,Co).getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s))),!l||c!=="none")return e&&(o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,i,n),o.restore()),o.filter=c,o.drawImage(t,0,0),o.filter="none",a;const h=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,i,n),d=o.createImageData(i,n),f=h.data,g=d.data,m=s>0?1/s:1e6;for(let v=3,w=f.length;v<w;v+=4)g[v]=Math.min(Math.round(f[v]*m),255);return o.putImageData(d,0,0),a},Am=function(t,e,s,i){let n=(t==null?void 0:t[e])??null;if(n&&(n.canvas.width!==s||n.canvas.height!==i)&&(this.canvasFactory.destroy(n),n=null),!n)return n=this.canvasFactory.create(s,i),t&&(t[e]=n),n;const a=n.context;return a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,s,i),a.restore(),n},_m=function(t,e,s={}){const{backdropCanvas:i=null,destTransform:n=[1,0,0,1,0,0],backdropOffset:a=[0,0],reuseMaskEntry:o=null,poolMeta:l=null,sourceAlpha:c=1,sourceFilter:h="none",knockoutAlpha:d=1}=s,{width:f,height:g}=e,m=b(this,q,wm).call(this,e,o,d),v=t.globalCompositeOperation;if(t.save(),t.setTransform(...n),t.globalAlpha=1,Et.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(m.canvas,0,0),i){const[w,A]=a,_=b(this,q,Am).call(this,l,"knockoutBackdropEntry",f,g),E=_.context;E.drawImage(i,w,A,f,g,0,0,f,g),E.globalCompositeOperation="destination-in",E.drawImage(m.canvas,0,0),E.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(_.canvas,0,0),l||this.canvasFactory.destroy(_)}t.globalCompositeOperation=v,t.globalAlpha=c,Et.isCanvasFilterSupported&&(t.filter=h??"none"),t.drawImage(e,0,0),t.restore(),o||this.canvasFactory.destroy(m)},ps=function(t=1){if(r(this,ks)===0||r(this,Zn)>0||!this.contentVisible)return!1;Ft(this,Zn)._++,p(this,To,t);const e=r(this,rr).at(-1),{canvas:s}=this.ctx,i=b(this,q,Am).call(this,e,"knockoutTempEntry",s.width,s.height);p(this,_o,i);const n=i.context;return n.save(),n.setTransform(this.ctx.getTransform()),ka(this.ctx,n),p(this,xo,n.globalCompositeOperation),n.globalCompositeOperation="source-over",Ly(n,this.ctx),p(this,Po,e),p(this,So,this.ctx),p(this,Eo,this.suspendedCtx),this.ctx=n,this.inSMaskMode&&(this.suspendedCtx=n),!0},Ge=function(t){var l;if(!t)return;const e=r(this,_o),s=r(this,So),i=r(this,Eo),n=e.context;p(this,_o,null),p(this,So,null),p(this,Eo,null),this.inSMaskMode&&this.suspendedCtx===n&&this.ctx!==n&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=i),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=r(this,xo),p(this,xo,null),ka(this.ctx,s),this.ctx=s;const a=r(this,Po);p(this,Po,null);const o=r(this,To);p(this,To,1);try{b(this,q,_m).call(this,i??s,e.canvas,{backdropCanvas:((l=a==null?void 0:a.backdropCtx)==null?void 0:l.canvas)??null,backdropOffset:a!=null&&a.backdropCtx?[a.offsetX,a.offsetY]:[0,0],reuseMaskEntry:(a==null?void 0:a.knockoutMaskEntry)??null,poolMeta:a,knockoutAlpha:o})}finally{n.restore(),Ft(this,Zn)._--,a||this.canvasFactory.destroy(e)}},Sm=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i},Vh=function(t){var e;return((e=this.current.transferMapsFallback)==null?void 0:e.applyToColor(t))??t},Tw=function(t){const{canvas:e}=t,{width:s,height:i}=e;if(Et.isCanvasFilterSupported){t.save(),t.setTransform(1,0,0,1,0,0),t.filter="grayscale(1)",t.globalAlpha=1,t.globalCompositeOperation="copy",t.drawImage(e,0,0),t.restore();return}const n=t.getImageData(0,0,s,i),{data:a}=n;for(let o=0,l=a.length;o<l;o+=4){const c=a[o]*.2126+a[o+1]*.7152+a[o+2]*.0722+.5|0;a[o]=a[o+1]=a[o+2]=c}t.putImageData(n,0,0)},Of=function(t){t&&(t.knockoutMaskEntry&&(this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null),t.knockoutTempEntry&&(this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null),t.knockoutBackdropEntry&&(this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null))},y(Na,Cp,null);let Hl=Na;for(const u in zi)Hl.prototype[u]!==void 0&&(Hl.prototype[zi[u]]=Hl.prototype[u]);var Xu,Yu;class dg{constructor(t,e,s){y(this,Xu,null);y(this,Yu,null);O(this,"_fullReader",null);O(this,"_rangeReaders",new Set);O(this,"_source",null);this._source=t,p(this,Xu,e),p(this,Yu,s)}get _progressiveDataLength(){var t;return((t=this._fullReader)==null?void 0:t._loaded)??0}getFullReader(){return ne(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new(r(this,Xu))(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new(r(this,Yu))(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){var e;(e=this._fullReader)==null||e.cancel(t);for(const s of new Set(this._rangeReaders))s.cancel(t)}}Xu=new WeakMap,Yu=new WeakMap;class fg{constructor(t){O(this,"onProgress",null);O(this,"_contentLength",0);O(this,"_filename",null);O(this,"_headersCapability",Promise.withResolvers());O(this,"_isRangeSupported",!1);O(this,"_isStreamingSupported",!1);O(this,"_loaded",0);O(this,"_stream",null);this._stream=t}_callOnProgress(){var t;(t=this.onProgress)==null||t.call(this,{loaded:this._loaded,total:this._contentLength})}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(){vt("Abstract method `read` called")}cancel(t){vt("Abstract method `cancel` called")}}class pg{constructor(t,e,s){O(this,"_stream",null);this._stream=t}async read(){vt("Abstract method `read` called")}cancel(t){vt("Abstract method `cancel` called")}}function aE(u){let t=!0,e=s("filename\\*","i").exec(u);if(e){e=e[1];let h=o(e);return h=unescape(h),h=l(h),h=c(h),n(h)}if(e=a(u),e){const h=c(e);return n(h)}if(e=s("filename","i").exec(u),e){e=e[1];let h=o(e);return h=c(h),n(h)}function s(h,d){return new RegExp("(?:^|;)\\s*"+h+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(h,d){if(h){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const f=new TextDecoder(h,{fatal:!0}),g=cg(d);d=f.decode(g),t=!1}catch{}}return d}function n(h){return t&&/[\x80-\xff]/.test(h)&&(h=i("utf-8",h),t&&(h=i("iso-8859-1",h))),h}function a(h){const d=[];let f;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=g.exec(h))!==null;){let[,v,w,A]=f;if(v=parseInt(v,10),v in d){if(v===0)break;continue}d[v]=[w,A]}const m=[];for(let v=0;v<d.length&&v in d;++v){let[w,A]=d[v];A=o(A),w&&(A=unescape(A),v===0&&(A=l(A))),m.push(A)}return m.join("")}function o(h){if(h.startsWith('"')){const d=h.slice(1).split('\\"');for(let f=0;f<d.length;++f){const g=d[f].indexOf('"');g!==-1&&(d[f]=d[f].slice(0,g),d.length=f+1),d[f]=d[f].replaceAll(/\\(.)/g,"$1")}h=d.join('"')}return h}function l(h){const d=h.indexOf("'");if(d===-1)return h;const f=h.slice(0,d),m=h.slice(d+1).replace(/^[^']*'/,"");return i(f,m)}function c(h){return!h.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(h)?h:h.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,f,g,m){if(g==="q"||g==="Q")return m=m.replaceAll("_"," ").replaceAll(/=([0-9a-f]{2})/gi,(v,w)=>String.fromCharCode(parseInt(w,16))),i(f,m);try{m=atob(m)}catch{}return i(f,m)})}return""}function Cw(u,t){const e=new Headers;if(!u||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function oE(u){let t=u.length;for(;t>0&&u[t-1]!==" "&&/\s/.test(u[t-1]);)t--;return u.slice(0,t)}function gg(u){var t;return((t=URL.parse(u))==null?void 0:t.origin)??null}function Pw({responseHeaders:u,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={contentLength:0,isRangeSupported:!1},n=parseInt(u.get("Content-Length"),10);return!Number.isInteger(n)||(i.contentLength=n,n<=2*e)||s||!t||u.get("Accept-Ranges")!=="bytes"||(u.get("Content-Encoding")||"identity")==="identity"&&(i.isRangeSupported=!0),i}function Iw(u){const t=u.get("Content-Disposition");if(t){let e=aE(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Yv(e))return e}return null}function mg(u,t){return new ap(`Unexpected server response (${u}) while retrieving PDF "${t.href}".`,u,u===404||u===0&&t.protocol==="file:")}function kw(u,t){if(u!==t)throw new Error(`Expected range response-origin "${u}" to match "${t}".`)}function Mw(u,t,e,s){return fetch(u,{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function Ow(u,t){if(u!==200&&u!==206)throw mg(u,t)}function vg(u){if(u instanceof Uint8Array)return u.buffer;if(u instanceof ArrayBuffer)return u;throw new Error(`getArrayBuffer - unexpected data: ${u}`)}class lE extends dg{constructor(e){super(e,cE,hE);O(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;ne(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Cw(!0,s)}}class cE extends fg{constructor(e){super(e);O(this,"_abortController",new AbortController);O(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:n,url:a,withCredentials:o}=e._source;this._isStreamingSupported=!i;const l=new Headers(e.headers);Mw(a,l,o,this._abortController).then(c=>{e._responseOrigin=gg(c.url),Ow(c.status,a),this._reader=c.body.getReader();const h=c.headers,{contentLength:d,isRangeSupported:f}=Pw({responseHeaders:h,isHttp:!0,rangeChunkSize:n,disableRange:s});this._contentLength=d,this._isRangeSupported=f,this._filename=Iw(h),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ta("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:vg(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}class hE extends pg{constructor(e,s,i){super(e,s,i);O(this,"_abortController",new AbortController);O(this,"_readCapability",Promise.withResolvers());O(this,"_reader",null);const{url:n,withCredentials:a}=e._source,o=new Headers(e.headers);o.append("Range",`bytes=${s}-${i-1}`),Mw(n,o,a,this._abortController).then(l=>{const c=gg(l.url);kw(c,e._responseOrigin),Ow(l.status,n),this._reader=l.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:vg(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e),this._abortController.abort()}}function $y(u){return u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength?u.buffer:new Uint8Array(u).buffer}function yg(){for(const u of this._requests)u.resolve({value:void 0,done:!0});this._requests.length=0}var Pp,Rw;class uE extends dg{constructor(e){super(e,dE,fE);y(this,Pp);O(this,"_progressiveDone",!1);O(this,"_queuedChunks",[]);const{pdfDataRangeTransport:s}=e,{initialData:i,progressiveDone:n}=s;if((i==null?void 0:i.length)>0){const o=$y(i);this._queuedChunks.push(o)}this._progressiveDone=n;const a=o=>{var l;switch(o.type){case"range":case"progressiveRead":b(this,Pp,Rw).call(this,o.begin,o.chunk);break;case"progressiveDone":(l=this._fullReader)==null||l.progressiveDone(),this._progressiveDone=!0;break}};s.transportReady(a)}getFullReader(){const e=super.getFullReader();return this._queuedChunks=null,e}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(e,s)),i}cancelAllRequests(e){super.cancelAllRequests(e),this._source.pdfDataRangeTransport.abort()}}Pp=new WeakSet,Rw=function(e,s){const i=$y(s);if(e===void 0)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const n=this._rangeReaders.keys().find(a=>a._begin===e);ne(n,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),n._enqueue(i)}};var Ku;class dE extends fg{constructor(e){super(e);y(this,Ku,yg.bind(this));O(this,"_done",!1);O(this,"_queuedChunks",null);O(this,"_requests",[]);const{pdfDataRangeTransport:s,disableRange:i,disableStream:n}=e._source,{length:a,contentDispositionFilename:o}=s;this._queuedChunks=e._queuedChunks||[];for(const c of this._queuedChunks)this._loaded+=c.byteLength;this._done=e._progressiveDone,this._contentLength=a,this._isStreamingSupported=!n,this._isRangeSupported=!i,Yv(o)&&(this._filename=o),this._headersCapability.resolve();const l=this._loaded;Promise.resolve().then(()=>{l>0&&this._loaded===l&&this._callOnProgress()})}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,r(this,Ku).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&r(this,Ku).call(this)}}Ku=new WeakMap;var qu;class fE extends pg{constructor(e,s,i){super(e,s,i);y(this,qu,yg.bind(this));O(this,"onDone",null);O(this,"_begin",-1);O(this,"_done",!1);O(this,"_queuedChunk",null);O(this,"_requests",[]);this._begin=s}_enqueue(e){var s;this._done||(this._requests.length===0?this._queuedChunk=e:(this._requests.shift().resolve({value:e,done:!1}),r(this,qu).call(this)),this._done=!0,(s=this.onDone)==null||s.call(this))}async read(){if(this._queuedChunk){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,r(this,qu).call(this),(s=this.onDone)==null||s.call(this)}}qu=new WeakMap;const Pg=200,Gy=206;function pE(u){return typeof u!="string"?u:cg(u).buffer}var nr,Ah,Dw,Fw;class gE extends dg{constructor(e){super(e,mE,vE);y(this,Ah);y(this,nr,new WeakMap);O(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=e;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=Cw(this.isHttp,s)}_request(e){const s=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};r(this,nr).set(s,i),s.open("GET",this.url),s.withCredentials=this._source.withCredentials;for(const[n,a]of this.headers)s.setRequestHeader(n,a);return this.isHttp&&"begin"in e&&"end"in e?(s.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.validateStatus=n=>n===Gy||n===Pg):i.validateStatus=n=>n===Pg,s.responseType="arraybuffer",ne(e.onError,"Expected `onError` callback to be provided."),s.onerror=()=>e.onError(s.status),s.onreadystatechange=b(this,Ah,Fw).bind(this,s),s.onprogress=b(this,Ah,Dw).bind(this,s),s.send(null),s}_abortRequest(e){r(this,nr).has(e)&&(r(this,nr).delete(e),e.abort())}getRangeReader(e,s){const i=super.getRangeReader(e,s);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}nr=new WeakMap,Ah=new WeakSet,Dw=function(e,s){var n;const i=r(this,nr).get(e);(n=i==null?void 0:i.onProgress)==null||n.call(i,s)},Fw=function(e,s){const i=r(this,nr).get(e);if(!i||(e.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),e.readyState!==4)||!r(this,nr).has(e))return;if(r(this,nr).delete(e),e.status===0&&this.isHttp){i.onError(e.status);return}const n=e.status||Pg;if(!i.validateStatus(n)){i.onError(e.status);return}const a=pE(e.response);if(n===Gy){const o=e.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(o)?i.onDone(a):(st('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone(a):i.onError(e.status)};var Ju,wr,Lw,Nw,Bw,Uw;class mE extends fg{constructor(e){super(e);y(this,wr);y(this,Ju,yg.bind(this));O(this,"_cachedChunks",[]);O(this,"_done",!1);O(this,"_requests",[]);O(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:b(this,wr,Lw).bind(this),onDone:b(this,wr,Nw).bind(this),onError:b(this,wr,Bw).bind(this),onProgress:b(this,wr,Uw).bind(this)})}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 e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e),r(this,Ju).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}Ju=new WeakMap,wr=new WeakSet,Lw=function(){const e=this._stream,{disableRange:s,rangeChunkSize:i}=e._source,n=this._fullRequestXhr;e._responseOrigin=gg(n.responseURL);const a=n.getAllResponseHeaders(),o=new Headers(a?oE(a.trimStart()).split(/[\r\n]+/).map(h=>{const[d,...f]=h.split(": ");return[d,f.join(": ")]}):[]),{contentLength:l,isRangeSupported:c}=Pw({responseHeaders:o,isHttp:e.isHttp,rangeChunkSize:i,disableRange:s});this._contentLength=l,this._isRangeSupported=c,this._filename=Iw(o),this._isRangeSupported&&e._abortRequest(n),this._headersCapability.resolve()},Nw=function(e){this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._cachedChunks.push(e),this._done=!0,this._cachedChunks.length===0&&r(this,Ju).call(this)},Bw=function(e){this._storedError=mg(e,this._stream.url),this._headersCapability.reject(this._storedError);for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0},Uw=function(e){var s;(s=this.onProgress)==null||s.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})};var Qu,mn,Hw,jw,Em;class vE extends pg{constructor(e,s,i){super(e,s,i);y(this,mn);y(this,Qu,yg.bind(this));O(this,"onClosed",null);O(this,"_done",!1);O(this,"_queuedChunk",null);O(this,"_requests",[]);O(this,"_storedError",null);this._requestXhr=e._request({begin:s,end:i,onHeadersReceived:b(this,mn,Hw).bind(this),onDone:b(this,mn,jw).bind(this),onError:b(this,mn,Em).bind(this),onProgress:null})}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){var s;this._done=!0,r(this,Qu).call(this),this._stream._abortRequest(this._requestXhr),(s=this.onClosed)==null||s.call(this)}}Qu=new WeakMap,mn=new WeakSet,Hw=function(){var s;const e=gg((s=this._requestXhr)==null?void 0:s.responseURL);try{kw(e,this._stream._responseOrigin)}catch(i){this._storedError=i,b(this,mn,Em).call(this,0)}},jw=function(e){var s;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,r(this,Qu).call(this),(s=this.onClosed)==null||s.call(this)},Em=function(e){this._storedError??(this._storedError=mg(e,this._stream.url));for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._queuedChunk=null};function $w(u,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),i=e.createReadStream(u,t);return s.toWeb(i)}class yE extends dg{constructor(t){super(t,bE,wE);const{url:e}=t;ne(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class bE extends fg{constructor(e){super(e);O(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:n,url:a}=e._source;this._isStreamingSupported=!i,process.getBuiltinModule("fs/promises").lstat(a).then(l=>{const c=$w(a);this._reader=c.getReader();const{size:h}=l;this._contentLength=h,this._isRangeSupported=!s&&h>2*n,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Ta("Streaming is disabled.")),this._headersCapability.resolve()}).catch(l=>{l.code==="ENOENT"&&(l=mg(0,a)),this._headersCapability.reject(l)})}async read(){await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,this._callOnProgress(),{value:vg(e),done:!1})}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}class wE extends pg{constructor(e,s,i){super(e,s,i);O(this,"_readCapability",Promise.withResolvers());O(this,"_reader",null);const{url:n}=e._source;try{const a=$w(n,{start:s,end:i-1});this._reader=a.getReader(),this._readCapability.resolve()}catch(a){this._readCapability.reject(a)}}async read(){await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:{value:vg(e),done:!1}}cancel(e){var s;(s=this._reader)==null||s.cancel(e)}}function AE(u){return tu(u)?lE:Gs?yE:gE}var Zu,td;class un{static get workerPort(){return r(this,Zu)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,Zu,t)}static get workerSrc(){return r(this,td)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,td,t)}}Zu=new WeakMap,td=new WeakMap,y(un,Zu,null),y(un,td,"");var Sc,ed;class _E{constructor({parsedData:t,rawData:e}){y(this,Sc);y(this,ed);p(this,Sc,t),p(this,ed,e)}getRaw(){return r(this,ed)}get(t){return r(this,Sc).get(t)??null}[Symbol.iterator](){return r(this,Sc).entries()}}Sc=new WeakMap,ed=new WeakMap;const Ra=Symbol("INTERNAL");var sd,id,Ec,Io;class SE{constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){y(this,sd,!1);y(this,id,!1);y(this,Ec,!1);y(this,Io,!0);p(this,sd,!!(t&$s.DISPLAY)),p(this,id,!!(t&$s.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(r(this,Ec))return r(this,Io);if(!r(this,Io))return!1;const{print:t,view:e}=this.usage;return r(this,sd)?(e==null?void 0:e.viewState)!=="OFF":r(this,id)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==Ra&&vt("Internal method `_setVisible` called."),p(this,Ec,s),p(this,Io,e)}get serializable(){return{userSet:r(this,Ec),visible:r(this,Io)}}}sd=new WeakMap,id=new WeakMap,Ec=new WeakMap,Io=new WeakMap;var ta,wt,xc,Tc,rd,nd,Tm;const oy=class oy{constructor(t,e=$s.DISPLAY,s=null){y(this,nd);y(this,ta,null);y(this,wt,new Map);y(this,xc,null);y(this,Tc,null);y(this,rd);O(this,"creator",null);O(this,"name",null);if(p(this,rd,t),this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,p(this,Tc,t.order);for(const i of t.groups)r(this,wt).set(i.id,new SE(e,i));if(s){s.size!==r(this,wt).size&&vt("Incorrect serialized groupState.");for(const[i,n]of s)r(this,wt).get(i)._setVisible(Ra,n.visible,n.userSet)}else{if(t.baseState==="OFF")for(const i of r(this,wt).values())i._setVisible(Ra,!1);for(const i of t.on)r(this,wt).get(i)._setVisible(Ra,!0);for(const i of t.off)r(this,wt).get(i)._setVisible(Ra,!1)}p(this,xc,this.getHash())}}isVisible(t){if(r(this,wt).size===0)return!0;if(!t)return lg("Optional content group not defined."),!0;if(t.type==="OCG")return r(this,wt).has(t.id)?r(this,wt).get(t.id).visible:(st(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,nd,Tm).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!r(this,wt).has(e))return st(`Optional content group not found: ${e}`),!0;if(r(this,wt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!r(this,wt).has(e))return st(`Optional content group not found: ${e}`),!0;if(!r(this,wt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!r(this,wt).has(e))return st(`Optional content group not found: ${e}`),!0;if(!r(this,wt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!r(this,wt).has(e))return st(`Optional content group not found: ${e}`),!0;if(r(this,wt).get(e).visible)return!1}return!0}return st(`Unknown optional content policy ${t.policy}.`),!0}return st(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var n;const i=r(this,wt).get(t);if(!i){st(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&((n=r(this,wt).get(o))==null||n._setVisible(Ra,!1,!0));i._setVisible(Ra,!!e,!0),p(this,ta,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const n=r(this,wt).get(i);if(n)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!n.visible,e);break}}p(this,ta,null)}get hasInitialVisibility(){return r(this,xc)===null||this.getHash()===r(this,xc)}getOrder(){return r(this,wt).size?r(this,Tc)?r(this,Tc).slice():[...r(this,wt).keys()]:null}getGroup(t){return r(this,wt).get(t)||null}getHash(){if(r(this,ta)!==null)return r(this,ta);const t=new om;for(const[e,s]of r(this,wt))t.update(`${e}:${s.visible}`);return p(this,ta,t.hexdigest())}[Symbol.iterator](){return r(this,wt).entries()}get serializable(){const t=new Map;for(const[e,s]of r(this,wt))t.set(e,s.serializable);return{data:r(this,rd),renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new oy(t,e,s)}};ta=new WeakMap,wt=new WeakMap,xc=new WeakMap,Tc=new WeakMap,rd=new WeakMap,nd=new WeakSet,Tm=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const n=t[i];let a;if(Array.isArray(n))a=b(this,nd,Tm).call(this,n);else if(r(this,wt).has(n))a=r(this,wt).get(n).visible;else return st(`Optional content group not found: ${n}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};let xm=oy;var Qt,ai,be,ko,ar,$e,Wh,Rf,Cm,Pm;class EE{constructor(){y(this,$e);y(this,Qt,null);y(this,ai,null);y(this,be,0);y(this,ko,null);y(this,ar,null)}get pagesNumber(){return r(this,be)}set pagesNumber(t){r(this,be)!==t&&(p(this,be,t),p(this,Qt,null),p(this,ai,null))}movePages(t,e,s){b(this,$e,Wh).call(this);const i=r(this,Qt),n=e.length,a=new Uint32Array(n);let o=0;for(let f=0;f<n;f++){const g=e[f]-1;a[f]=i[g],g<s&&o++}const l=r(this,be),c=l-n,h=new Int32Array(l),d=jt(s-o,0,c);for(let f=0,g=0;f<l;f++)t.has(f+1)||(i[g]=i[f],h[g++]=f+1);i.copyWithin(d+n,d,c),i.set(a,d),h.copyWithin(d+n,d,c),h.set(e,d),p(this,ai,h),i.every((f,g)=>f===g+1)&&p(this,Qt,null)}deletePages(t){b(this,$e,Wh).call(this);const e=r(this,Qt),s=b(this,$e,Rf).call(this);p(this,ar,{pageNumberToId:e.slice(),pagesNumber:r(this,be),prevPageNumbers:r(this,ai).slice()});const i=r(this,be)-t.length;p(this,be,i);const n=p(this,Qt,new Uint32Array(i));p(this,ai,new Int32Array(i));let a=0,o=0;for(const l of t){const c=l-1;c!==a&&(n.set(e.subarray(a,c),o),o+=c-a),a=c+1}a<e.length&&n.set(e.subarray(a),o),b(this,$e,Cm).call(this,s,new Set(t))}cancelDelete(){r(this,ar)&&(p(this,Qt,r(this,ar).pageNumberToId),p(this,be,r(this,ar).pagesNumber),p(this,ai,r(this,ar).prevPageNumbers),p(this,ar,null))}cleanSavedData(){p(this,ar,null)}copyPages(t){b(this,$e,Wh).call(this),p(this,ko,{pageNumbers:t,pageIds:t.map(e=>r(this,Qt)[e-1])})}cancelCopy(){p(this,ko,null)}pastePages(t){b(this,$e,Wh).call(this);const e=r(this,Qt),s=b(this,$e,Rf).call(this),{pageNumbers:i,pageIds:n}=r(this,ko),a=r(this,be)+i.length;p(this,be,a);const o=p(this,Qt,new Uint32Array(a));p(this,ai,new Int32Array(a)),o.set(e.subarray(0,t),0),o.set(n,t),o.set(e.subarray(t),t+i.length),b(this,$e,Cm).call(this,s,null,t,i),p(this,ko,null)}hasBeenAltered(){return r(this,Qt)!==null}getPageMappingForSaving(t=null,e=b(this,$e,Pm).call(this)){t??(t=b(this,$e,Rf).call(this));let s=0;for(const n of t.values())s=Math.max(s,n.length);const i=new Array(s);for(let n=0;n<s;n++)i[n]={document:null,pageIndices:[],includePages:[]};for(const[n,a]of t)for(let o=0,l=a.length;o<l;o++)i[o].includePages.push([n-1,a[o]-1]);for(const{includePages:n,pageIndices:a}of i){n.sort((o,l)=>o[0]-l[0]);for(let o=0,l=n.length;o<l;o++)a.push(n[o][1]),n[o]=n[o][0]}return{pageInfos:i,copyLevels:e}}extractPages(t){t=Array.from(t).sort((s,i)=>s-i);const e=new Map;for(let s=0,i=t.length;s<i;s++){const n=this.getPageId(t[s]);e.getOrInsertComputed(n,Eh).push(s+1)}return this.getPageMappingForSaving(e,b(this,$e,Pm).call(this,t))}getPrevPageNumber(t){var e;return((e=r(this,ai))==null?void 0:e[t-1])??0}getPageNumber(t){if(!r(this,Qt))return t;const e=r(this,Qt);for(let s=0,i=r(this,be);s<i;s++)if(e[s]===t)return s+1;return 0}getPageId(t){var e;return((e=r(this,Qt))==null?void 0:e[t-1])??t}getMapping(){var t;return(t=r(this,Qt))==null?void 0:t.subarray(0,this.pagesNumber)}}Qt=new WeakMap,ai=new WeakMap,be=new WeakMap,ko=new WeakMap,ar=new WeakMap,$e=new WeakSet,Wh=function(){if(r(this,Qt))return;const t=r(this,be),e=p(this,Qt,new Uint32Array(t));for(let s=0;s<t;s++)e[s]=s+1;p(this,ai,new Int32Array(e))},Rf=function(){const t=new Map,e=r(this,Qt);for(let s=0,i=r(this,be);s<i;s++){const n=e[s],a=t.get(n);a?a.push(s+1):t.set(n,[s+1])}return t},Cm=function(t,e=null,s=-1,i=null){const n=r(this,ai),a=r(this,Qt),o=s+((i==null?void 0:i.length)??0),l=new Map;for(let c=0,h=r(this,be);c<h;c++){if(c>=s&&c<o){n[c]=-i[c-s];continue}const d=a[c],f=t.get(d);let g=l.get(d)||0;if(e&&f)for(;g<f.length&&e.has(f[g]);)g++;n[c]=f==null?void 0:f[g],l.set(d,g+1)}},Pm=function(t=null){if(!r(this,Qt))return null;const e=new Int32Array(r(this,be)).fill(-1),s=new Map;if(t)for(const i of t){const n=this.getPageId(i),a=s.get(n)??0;s.set(n,a+1),e[i-1]=a}else for(let i=0,n=r(this,be);i<n;i++){const a=r(this,Qt)[i],o=s.get(a)??0;s.set(a,o+1),e[i]=o}return e};const Dl=Symbol("INITIAL_DATA"),zy=()=>({...Promise.withResolvers(),data:Dl});var oi;class Gw{constructor(){y(this,oi,new Map)}get(t,e=null){if(e){const i=r(this,oi).getOrInsertComputed(t,zy);return i.promise.then(()=>e(i.data)),null}const s=r(this,oi).get(t);if(!s||s.data===Dl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=r(this,oi).get(t);return!!e&&e.data!==Dl}delete(t){const e=r(this,oi).get(t);return!e||e.data===Dl?!1:(r(this,oi).delete(t),!0)}resolve(t,e=null){const s=r(this,oi).getOrInsertComputed(t,zy);if(s.data!==Dl)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}clear(){var t;for(const{data:e}of r(this,oi).values())(t=e==null?void 0:e.bitmap)==null||t.close();r(this,oi).clear()}*[Symbol.iterator](){for(const[t,{data:e}]of r(this,oi))e!==Dl&&(yield[t,e])}}oi=new WeakMap;const xE=1e5,TE=30;var Ky,ea,es,ad,od,Cc,Mo,zr,ld,cd,Pc,Oo,hd,Ic,Ro,kc,ud,Mc,Do,dd,fd,Oc,Fo,pd,Rc,Dc,vn,zw,Vw,Im,os,Df,Ww,km,Xw,Yw;const Pe=class Pe{constructor({textContentSource:t,images:e,container:s,viewport:i}){y(this,vn);y(this,ea,Promise.withResolvers());y(this,es,null);y(this,ad,!1);y(this,od,!!((Ky=globalThis.FontInspector)!=null&&Ky.enabled));y(this,Cc,null);y(this,Mo,null);y(this,zr,null);y(this,ld,0);y(this,cd,0);y(this,Pc,fi.pixelRatio);y(this,Oo,null);y(this,hd,null);y(this,Ic,0);y(this,Ro,0);y(this,kc,Object.create(null));y(this,ud,[]);y(this,Mc,null);y(this,Do,[]);y(this,dd,new WeakMap);y(this,fd,null);var c;if(t instanceof ReadableStream)p(this,Mc,t);else if(typeof t=="object")p(this,Mc,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,es,p(this,hd,s)),p(this,Cc,e),p(this,Ro,i.scale*r(this,Pc)),p(this,Ic,i.rotation),p(this,zr,{div:null,properties:null,ctx:null});const{pageWidth:n,pageHeight:a,pageX:o,pageY:l}=i.rawDims;p(this,fd,[1,0,0,-1,-o,l+a]),p(this,cd,n),p(this,ld,a),b(c=Pe,os,Xw).call(c),s.style.setProperty("--min-font-size",r(Pe,Rc)),vl(s,i),r(this,ea).promise.finally(()=>{r(Pe,Dc).delete(this),p(this,zr,null),p(this,kc,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Et.platform;return V(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){r(this,Cc)&&r(this,es).append(r(this,Cc).render());const t=()=>{r(this,Oo).read().then(({value:e,done:s})=>{if(s){r(this,ea).resolve();return}r(this,Mo)??p(this,Mo,e.lang),Object.assign(r(this,kc),e.styles),b(this,vn,zw).call(this,e.items),t()},r(this,ea).reject)};return p(this,Oo,r(this,Mc).getReader()),r(Pe,Dc).add(this),t(),r(this,ea).promise}update({viewport:t,onBefore:e=null}){var n;const s=t.scale*fi.pixelRatio,i=t.rotation;if(i!==r(this,Ic)&&(e==null||e(),p(this,Ic,i),vl(r(this,hd),{rotation:i})),s!==r(this,Ro)){e==null||e(),p(this,Ro,s),p(this,Pc,fi.pixelRatio);const a={div:null,properties:null,ctx:b(n=Pe,os,Df).call(n,r(this,Mo))};for(const o of r(this,Do))a.properties=r(this,dd).get(o),a.div=o,b(this,vn,Im).call(this,a)}}cancel(){var e;const t=new Ta("TextLayer task cancelled.");(e=r(this,Oo))==null||e.cancel(t).catch(()=>{}),p(this,Oo,null),r(this,ea).reject(t)}get textDivs(){return r(this,Do)}get textContentItemsStr(){return r(this,ud)}static cleanup(){if(!(r(this,Dc).size>0)){r(this,Oc).clear();for(const{canvas:t}of r(this,Fo).values())t.remove();r(this,Fo).clear()}}};ea=new WeakMap,es=new WeakMap,ad=new WeakMap,od=new WeakMap,Cc=new WeakMap,Mo=new WeakMap,zr=new WeakMap,ld=new WeakMap,cd=new WeakMap,Pc=new WeakMap,Oo=new WeakMap,hd=new WeakMap,Ic=new WeakMap,Ro=new WeakMap,kc=new WeakMap,ud=new WeakMap,Mc=new WeakMap,Do=new WeakMap,dd=new WeakMap,fd=new WeakMap,Oc=new WeakMap,Fo=new WeakMap,pd=new WeakMap,Rc=new WeakMap,Dc=new WeakMap,vn=new WeakSet,zw=function(t){var i,n;if(r(this,ad))return;(n=r(this,zr)).ctx??(n.ctx=b(i=Pe,os,Df).call(i,r(this,Mo)));const e=r(this,Do),s=r(this,ud);for(const a of t){if(e.length>xE){st("Ignoring additional textDivs for performance reasons."),p(this,ad,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=r(this,es);p(this,es,document.createElement("span")),r(this,es).classList.add("markedContent"),a.id&&r(this,es).setAttribute("id",a.id),a.tag==="Artifact"&&(r(this,es).ariaHidden=!0),o.append(r(this,es))}else a.type==="endMarkedContent"&&p(this,es,r(this,es).parentNode);continue}s.push(a.str),b(this,vn,Vw).call(this,a)}},Vw=function(t){var v;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};r(this,Do).push(e);const i=$.transform(r(this,fd),t.transform);let n=Math.atan2(i[1],i[0]);const a=r(this,kc)[t.fontName];a.vertical&&(n+=Math.PI/2);let o=r(this,od)&&a.fontSubstitution||a.fontFamily;o=Pe.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),c=l*b(v=Pe,os,Yw).call(v,o,a,r(this,Mo));let h,d;n===0?(h=i[4],d=i[5]-c):(h=i[4]+c*Math.sin(n),d=i[5]-c*Math.cos(n));const f=e.style;f.left=`${(100*h/r(this,cd)).toFixed(2)}%`,f.top=`${(100*d/r(this,ld)).toFixed(2)}%`;const g=Math.round(l*100)/100;f.setProperty("--font-height",`${g}px`),f.fontFamily=o,s.fontSize=g,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,r(this,od)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let m=!1;if(t.str.length>1)m=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const w=Math.abs(t.transform[0]),A=Math.abs(t.transform[3]);w!==A&&Math.max(w,A)/Math.min(w,A)>1.5&&(m=!0)}if(m&&(s.canvasWidth=a.vertical?t.height:t.width),r(this,dd).set(e,s),r(this,zr).div=e,r(this,zr).properties=s,b(this,vn,Im).call(this,r(this,zr)),s.hasText&&r(this,es).append(e),s.hasEOL){const w=document.createElement("br");w.setAttribute("role","presentation"),r(this,es).append(w)}},Im=function(t){var l,c;const{div:e,properties:s,ctx:i}=t,{style:n}=e,{canvasWidth:a,fontSize:o}=s;if(a!==0&&o!==0&&s.hasText){const{fontFamily:h}=n,d=r(this,Pc),f=b(l=Pe,os,Ww).call(l,o*r(this,Ro)/d)*d;b(c=Pe,os,km).call(c,i,f,h);const{width:g}=i.measureText(e.textContent);g>0&&n.setProperty("--scale-x",a*f/(g*o))}s.angle!==0&&n.setProperty("--rotate",`${s.angle}deg`)},os=new WeakSet,Df=function(t=null){let e=r(this,Fo).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),r(this,Fo).set(t,e),r(this,pd).set(e,{size:0,family:""})}return e},Ww=function(t){t=Math.fround(t);const e=Math.fround(t*((1<<17)+1));return Math.fround(e-Math.fround(e-t))},km=function(t,e,s){const i=r(this,pd).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},Xw=function(){if(r(this,Rc)!==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,Rc,t.getBoundingClientRect().height),t.remove()},Yw=function(t,e,s){const i=r(this,Oc).get(t);if(i)return i;const n=b(this,os,Df).call(this,s);b(this,os,km).call(this,n,TE,t);const a=n.measureText(""),o=a.fontBoundingBoxAscent,l=Math.abs(a.fontBoundingBoxDescent);let c=.8;return o?c=o/(o+l):(Et.platform.isFirefox&&st("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?c=e.ascent:e.descent&&(c=1+e.descent)),r(this,Oc).set(t,c),c},y(Pe,os),y(Pe,Oc,new Map),y(Pe,Fo,new Map),y(Pe,pd,new WeakMap),y(Pe,Rc,null),y(Pe,Dc,new Set);let cu=Pe;const CE=100;function PE(u={}){const t=new Mm,{docId:e}=t,s=u.url?MS(u.url):null,i=u.data?OS(u.data):null,n=u.httpHeaders||null,a=u.withCredentials===!0,o=u.password??null,l=u.range instanceof Kw?u.range:null,c=Number.isInteger(u.rangeChunkSize)&&u.rangeChunkSize>0?u.rangeChunkSize:2**16;let h=u.worker instanceof hu?u.worker:null;const d=u.verbosity,f=typeof u.docBaseUrl=="string"&&!hg(u.docBaseUrl)?u.docBaseUrl:null,g=df(u.cMapUrl),m=u.cMapPacked!==!1,v=df(u.iccUrl),w=df(u.standardFontDataUrl),A=df(u.wasmUrl),_=u.stopAtErrors!==!0,E=Number.isInteger(u.maxImageSize)&&u.maxImageSize>-1?u.maxImageSize:-1,S=typeof u.isOffscreenCanvasSupported=="boolean"?u.isOffscreenCanvasSupported:!Gs,x=typeof u.isImageDecoderSupported=="boolean"?u.isImageDecoderSupported:!Gs,T=Number.isInteger(u.canvasMaxAreaInBytes)?u.canvasMaxAreaInBytes:-1,C=typeof u.disableFontFace=="boolean"?u.disableFontFace:Gs,I=u.fontExtraProperties===!0,k=u.enableXfa===!0,M=u.ownerDocument||globalThis.document,R=u.disableRange===!0,N=u.disableStream===!0,F=u.disableAutoFetch===!0,j=u.pdfBug===!0,U=u.CanvasFactory||(Gs?HS:LS),D=u.FilterFactory||(Gs?US:NS),H=u.BinaryDataFactory||(Gs?jS:Ry),X=u.enableHWA===!0,gt=u.enableWebGPU===!0?VS():Promise.resolve(!1),mt=u.useWasm!==!1,ht=u.pagesMapper||new EE,at=typeof u.useSystemFonts=="boolean"?u.useSystemFonts:!Gs&&!C,Ee=typeof u.useWorkerFetch=="boolean"?u.useWorkerFetch:!!(H===Ry&&g&&m&&w&&A&&tu(g,document.baseURI)&&tu(w,document.baseURI)&&tu(A,document.baseURI)),G=null;K0(d);const L={canvasFactory:new U({ownerDocument:M,enableHWA:X}),filterFactory:new D({docId:e,ownerDocument:M}),binaryDataFactory:Ee?null:new H({cMapUrl:g,standardFontDataUrl:w,wasmUrl:A})};h||(h=hu.create({verbosity:d,port:un.workerPort}),t._worker=h);const B={docId:e,apiVersion:"6.4.299",data:i,password:o,disableAutoFetch:F,rangeChunkSize:c,docBaseUrl:f,enableXfa:k,evaluatorOptions:{maxImageSize:E,disableFontFace:C,ignoreErrors:_,isOffscreenCanvasSupported:S,isImageDecoderSupported:x,canvasMaxAreaInBytes:T,fontExtraProperties:I,useSystemFonts:at,useWasm:mt,useWorkerFetch:Ee,cMapUrl:g,cMapPacked:m,iccUrl:v,standardFontDataUrl:w,wasmUrl:A,hasGPU:!1}},it={ownerDocument:M,pdfBug:j,styleElement:G,enableHWA:X,loadingParams:{disableAutoFetch:F,enableXfa:k}};return Promise.all([h.promise,gt]).then(function([,bt]){if(h.destroyed)throw new Error("Worker was destroyed");B.evaluatorOptions.hasGPU=bt;const tt=h.messageHandler.sendWithPromise("GetDocRequest",B,i?[i.buffer]:null);let ut;if(!i)if(l)ut=new uE({pdfDataRangeTransport:l,disableRange:R,disableStream:N});else if(s){const xt=AE(s);ut=new xt({url:s,httpHeaders:n,withCredentials:a,rangeChunkSize:c,disableRange:R,disableStream:N})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return tt.then(xt=>{if(h.destroyed)throw new Error("Worker was destroyed");const xe=new Hh(e,xt,h.port),ve=new kE(xe,t,ut,it,L,ht);if(t._transport=ve,t.destroyed)throw new Error("Loading aborted");xe.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}var Ip;const kp=class kp{constructor(){O(this,"_capability",Promise.withResolvers());O(this,"_setupCapability",Promise.withResolvers());O(this,"_transport",null);O(this,"_worker",null);O(this,"docId",`d${Ft(kp,Ip)._++}`);O(this,"destroyed",!1);O(this,"onPassword",null);O(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;this.destroyed=!0,this._capability.promise.catch(()=>{});try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await((e=this._transport)==null?void 0:e.destroy())}catch(n){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,n}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null}async getData(){return this._transport.getData()}};Ip=new WeakMap,y(kp,Ip,0);let Mm=kp;var Fc,Lo;class Kw{constructor(t,e,s=!1,i=null){y(this,Fc,Promise.withResolvers());y(this,Lo,null);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){r(this,Lo).call(this,{type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){r(this,Fc).promise.then(()=>{r(this,Lo).call(this,{type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){r(this,Fc).promise.then(()=>{r(this,Lo).call(this,{type:"progressiveDone"})})}transportReady(t){p(this,Lo,t),r(this,Fc).resolve()}requestDataRange(t,e){vt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Fc=new WeakMap,Lo=new WeakMap;class IE{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return V(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAttachmentContent(t){return this._transport.getAttachmentContent(t)}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(t){return this._transport.saveDocument(t)}extractPages(t,e=null){return this._transport.extractPages(t,e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}getSignatures(){return this._transport.getSignatures()}getSignatureData(t){return this._transport.getSignatureData(t)}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Vr,No,Mp,Bo,Xh;const ru=class ru{constructor(t,e,s,i,n=!1){y(this,Bo);y(this,Vr,!1);y(this,No,null);this._pageIndex=t,this._id=Ft(ru,Mp)._++,this._pageInfo=e,this._transport=s,this._stats=n?new by:null,this._pdfBug=n,this.commonObjs=s.commonObjs,this.objs=new Gw,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,p(this,No,i),this.imageCoordinates=null}clone(t){const e=new ru(t,this._pageInfo,this._transport,r(this,No),this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new of({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return V(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:n=An.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:c=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:f=!1,recordImages:g=!1,recordOperations:m=!1,operationsFilter:v=null}){var F,j,U;(F=this._stats)==null||F.time("Overall");const w=this._transport.getRenderingIntent(i,n,d,f),{renderingIntent:A,cacheKey:_}=w;p(this,Vr,!1),l||(l=this._transport.getOptionalContentConfig(A));const E=this._intentStates.getOrInsertComputed(_,Fg);E.streamReaderCancelTimeout&&(clearTimeout(E.streamReaderCancelTimeout),E.streamReaderCancelTimeout=null);const S=!!(A&$s.PRINT);E.displayReadyCapability||(E.displayReadyCapability=Promise.withResolvers(),E.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(j=this._stats)==null||j.time("Page Request"),this._pumpOperatorList(w));const x=!!(this._pdfBug&&((U=globalThis.StepperManager)!=null&&U.enabled)),T=!!e&&!this.recordedBBoxes&&(m||x),C=!!e&&!this.imageCoordinates&&g,I=D=>{var H,X,nt,gt;if(E.renderTasks.delete(R),T){const mt=(H=R.gfx)==null?void 0:H.dependencyTracker.take();mt&&((X=R.stepper)==null||X.setOperatorBBoxes(mt,R.gfx.dependencyTracker.takeDebugMetadata()),m&&(this.recordedBBoxes=mt))}C&&!D&&(this.imageCoordinates=(nt=R.gfx)==null?void 0:nt.imagesTracker.take()),S&&p(this,Vr,!0),b(this,Bo,Xh).call(this),D?(R.capability.reject(D),this._abortOperatorList({intentState:E,reason:D instanceof Error?D:new Error(D)})):R.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(gt=globalThis.Stats)!=null&&gt.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let k=null,M=null;(T||C)&&(M=new wS(e,E.operatorList.length)),T&&(k=new AS(M,x));const R=new Rm({callback:I,params:{canvas:e,canvasContext:t,dependencyTracker:k??M,imagesTracker:C?new hm(e):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:E.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!S,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:v});(E.renderTasks||(E.renderTasks=new Set)).add(R);const N=R.task;return Promise.all([E.displayReadyCapability.promise,l]).then(([D,H])=>{var X;if(this.destroyed){I();return}if((X=this._stats)==null||X.time("Rendering"),!(H.renderingIntent&A))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");R.initializeGraphics({transparency:D,optionalContentConfig:H}),R.operatorListChanged()}).catch(I),N}getOperatorList({intent:t="display",annotationMode:e=An.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var c;function n(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,i,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,Fg);let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=n,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(c=this._stats)==null||c.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:r(this,No).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size:i=>i.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>au.textContent(i));const e=this.streamTextContent(t),s={items:[],styles:Object.create(null),lang:null};for await(const i of e)s.lang??(s.lang=i.lang),Object.assign(s.styles,i.styles),s.items.push(...i.items);return s}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),p(this,Vr,!1),Promise.all(t)}cleanup(t=!1){p(this,Vr,!0);const e=b(this,Bo,Xh).call(this);return t&&e&&this._stats&&(this._stats=new by),e}_startRenderPage(t,e){var i,n;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(n=s.displayReadyCapability)==null||n.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&b(this,Bo,Xh).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:n,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:r(this,No).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,pageProxyId:this._id,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:i},void 0,a).getReader(),c=this._intentStates.get(e);c.streamReader=l;const h=()=>{l.read().then(({value:d,done:f})=>{if(f){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,c),h())},d=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const f of c.renderTasks)f.operatorListChanged();b(this,Bo,Xh).call(this)}if(c.displayReadyCapability)c.displayReadyCapability.reject(d);else if(c.opListReadCapability)c.opListReadCapability.reject(d);else throw d}})};h()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Xv){let i=CE;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new Ta(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}};Vr=new WeakMap,No=new WeakMap,Mp=new WeakMap,Bo=new WeakSet,Xh=function(){if(!r(this,Vr)||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,Vr,!1),!0},y(ru,Mp,0);let Om=ru;var sa,Ci,Wr,Uo,Op,Ho,jo,Es,Ff,qw,Jw,Lf,Lc,Nf;const te=class te{constructor({name:t=null,port:e=null,verbosity:s=q0()}={}){y(this,Es);y(this,sa,Promise.withResolvers());y(this,Ci,null);y(this,Wr,null);y(this,Uo,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(r(te,jo).has(e))throw new Error("Cannot use more than one PDFWorker per port.");r(te,jo).set(e,this),b(this,Es,qw).call(this,e)}else b(this,Es,Jw).call(this)}get promise(){return r(this,sa).promise}get port(){return r(this,Wr)}get messageHandler(){return r(this,Ci)}destroy(){var t,e;this.destroyed=!0,(t=r(this,Uo))==null||t.terminate(),p(this,Uo,null),r(te,jo).delete(r(this,Wr)),p(this,Wr,null),(e=r(this,Ci))==null||e.destroy(),p(this,Ci,null)}static create(t){const e=r(this,jo).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 te(t)}static get workerSrc(){if(un.workerSrc)return un.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return V(this,"_setupFakeWorkerGlobal",(async()=>r(this,Lc,Nf)?r(this,Lc,Nf):(await import(this.workerSrc)).WorkerMessageHandler)())}};sa=new WeakMap,Ci=new WeakMap,Wr=new WeakMap,Uo=new WeakMap,Op=new WeakMap,Ho=new WeakMap,jo=new WeakMap,Es=new WeakSet,Ff=function(){r(this,sa).resolve(),r(this,Ci).send("configure",{verbosity:this.verbosity})},qw=function(t){p(this,Wr,t),p(this,Ci,new Hh("main","worker",t)),r(this,Ci).on("ready",()=>{}),b(this,Es,Ff).call(this)},Jw=function(){if(r(te,Ho)||r(te,Lc,Nf)){b(this,Es,Lf).call(this);return}let{workerSrc:t}=te;try{te._isSameOrigin(window.location,t)||(t=te._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Hh("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?r(this,sa).reject(new Error("Worker was destroyed")):b(this,Es,Lf).call(this)},n=new AbortController;e.addEventListener("error",()=>{r(this,Uo)||i()},{signal:n.signal}),s.on("ready",a=>{if(n.abort(),this.destroyed||!(a instanceof Uint8Array)){i();return}p(this,Ci,s),p(this,Wr,e),p(this,Uo,e),b(this,Es,Ff).call(this)})}catch{lg("The worker has been disabled."),b(this,Es,Lf).call(this)}},Lf=function(){r(te,Ho)||(st("Setting up fake worker."),p(te,Ho,!0)),te._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){r(this,sa).reject(new Error("Worker was destroyed"));return}const e=new FS;p(this,Wr,e);const s=`fake${Ft(te,Op)._++}`,i=new Hh(s+"_worker",s,e);t.setup(i,e),p(this,Ci,new Hh(s,s+"_worker",e)),b(this,Es,Ff).call(this)}).catch(t=>{r(this,sa).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Lc=new WeakSet,Nf=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},y(te,Lc),y(te,Op,0),y(te,Ho,!1),y(te,jo,new WeakMap),Gs&&(p(te,Ho,!0),un.workerSrc||(un.workerSrc="./pdf.worker.mjs")),te._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const i=new URL(e,s);return s.origin===i.origin},te._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let hu=te;var Ms,$o,Xr,Pi,Go,Nc,Yr,gd,di,Fl,Bf;class kE{constructor(t,e,s,i,n,a){y(this,di);O(this,"downloadInfoCapability",Promise.withResolvers());y(this,Ms,null);y(this,$o,new Map);y(this,Xr,null);y(this,Pi,new Map);y(this,Go,new Map);y(this,Nc,new Map);y(this,Yr,null);y(this,gd,null);this.messageHandler=t,this.loadingTask=e,p(this,Xr,s),this.commonObjs=new Gw,this.fontLoader=new SS({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.enableHWA=i.enableHWA,this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.binaryDataFactory=n.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){r(this,Pi).set(t._id,t),r(this,Go).set(t._pageIndex,Promise.resolve(t))}get annotationStorage(){return V(this,"annotationStorage",new Kv)}getRenderingIntent(t,e=An.ENABLE,s=null,i=!1,n=!1){let a=$s.DISPLAY,o=ou;switch(t){case"any":a=$s.ANY;break;case"display":break;case"print":a=$s.PRINT;break;default:st(`getRenderingIntent - invalid intent: ${t}`)}const l=a&$s.PRINT&&s instanceof hw?s:this.annotationStorage;switch(e){case An.DISABLE:a+=$s.ANNOTATIONS_DISABLE;break;case An.ENABLE:break;case An.ENABLE_FORMS:a+=$s.ANNOTATIONS_FORMS;break;case An.ENABLE_STORAGE:a+=$s.ANNOTATIONS_STORAGE,o=l.serializable;break;default:st(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=$s.IS_EDITING),n&&(a+=$s.OPLIST);const{ids:c,hash:h}=l.modifiedIds,d=[a,o.hash,h];return{renderingIntent:a,cacheKey:d.join("_"),annotationStorageSerializable:o,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=r(this,Yr))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of r(this,Pi).values())t.push(i._destroy());r(this,Pi).clear(),r(this,Go).clear(),r(this,Nc).clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,n;this.commonObjs.clear(),this.fontLoader.clear(),r(this,$o).clear(),this.filterFactory.destroy(),cu.cleanup(),(i=r(this,Xr))==null||i.cancelAllRequests(new Ta("Worker was terminated.")),(n=this.messageHandler)==null||n.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{ne(r(this,Xr),"GetReader - no `BasePDFStream` instance available."),p(this,Ms,r(this,Xr).getFullReader()),r(this,Ms).onProgress=n=>b(this,di,Bf).call(this,n),i.onPull=()=>{r(this,Ms).read().then(function({value:n,done:a}){if(a){i.close();return}ne(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{r(this,Ms).cancel(n),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{await r(this,Ms).headersReady;const{isStreamingSupported:i,isRangeSupported:n,contentLength:a}=r(this,Ms);return i&&n&&(r(this,Ms).onProgress=null),{isStreamingSupported:i,isRangeSupported:n,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{ne(r(this,Xr),"GetRangeReader - no `BasePDFStream` instance available.");const n=r(this,Xr).getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:a,done:o}){if(o){i.close();return}ne(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{n.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this.pagesMapper.pagesNumber=s.numPages,this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new IE(s,this))}),t.on("DocException",s=>{e._capability.reject(gs(s))}),t.on("PasswordRequest",s=>{p(this,Yr,Promise.withResolvers());try{if(!e.onPassword)throw gs(s);const i=n=>{n instanceof Error?r(this,Yr).reject(n):r(this,Yr).resolve({password:n})};e.onPassword(i,s.code)}catch(i){r(this,Yr).reject(i)}return r(this,Yr).promise}),t.on("DataLoaded",s=>{b(this,di,Bf).call(this,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;r(this,Pi).get(s.pageProxyId)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in n){const f=n.error;st(`Error during font loading: ${f}`),this.commonObjs.resolve(s,f);break}const o=new PS(n.buffer),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(f,g)=>globalThis.FontInspector.fontAdded(f,g):null,c=new ES(o,l,n.charProcOperatorList,n.extra);this.fontLoader.bind(c).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{c.fontExtraProperties||c.clearData(),this.commonObjs.resolve(s,c)});break;case"CopyLocalImage":const{imageRef:h}=n;ne(h,"The imageRef must be defined.");for(const f of r(this,Pi).values())for(const[,g]of f.objs){if((g==null?void 0:g.ref)!==h)continue;if(!g.dataLen)return null;const m=structuredClone(g);return this.commonObjs.resolve(s,m),g.dataLen}break;case"FontPath":this.commonObjs.resolve(s,new kS(n));break;case"Image":this.commonObjs.resolve(s,n);break;case"Pattern":const d=new IS(n);this.commonObjs.resolve(s,d.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,a])=>{var l;if(this.destroyed)return;const o=r(this,Pi).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(n){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{this.destroyed||b(this,di,Bf).call(this,s)}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(t=null){var i;this.annotationStorage.size<=0&&st("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:s}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,supportsPrintToPDF:r(this,gd)!==null,filename:((i=r(this,Ms))==null?void 0:i.filename)??null},s).finally(()=>{p(this,gd,null),this.annotationStorage.resetModified()})}extractPages(t,e=null){var a;const s={pageInfos:t};let i;const n=globalThis.ImageBitmap;if(typeof n=="function"){const o=Array.isArray(t)?t:[t];for(const l of o)(l==null?void 0:l.image)instanceof n&&(i||(i=[])).push(l.image)}if(this.annotationStorage.size>0){const o=this.annotationStorage.serializable;let{map:l}=o;(a=o.transfer)!=null&&a.length&&(i?i.push(...o.transfer):i=o.transfer);const c=this.pagesMapper.getMapping();if(c){const h=new Map;for(const[d,f]of l){if((f==null?void 0:f.pageIndex)!==void 0&&f.pageIndex>=0&&f.pageIndex<c.length){const g=(e==null?void 0:e[f.pageIndex])??0,m=c[f.pageIndex]-1;if(m!==f.pageIndex||g!==0){h.set(d,{...f,pageIndex:m,copyLevel:g});continue}}h.set(d,f)}l=h}s.annotationStorage=l}return this.messageHandler.sendWithPromise("ExtractPages",s,i).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.pagesMapper.getPageId(t)-1,i=r(this,Go).get(e);if(i)return i;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&r(this,Nc).set(a.refStr,s);const o=new Om(e,a,this,this.pagesMapper,this._params.pdfBug);return r(this,Pi).set(o._id,o),o});return r(this,Go).set(e,n),n}async getPageIndex(t){if(!fm(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw new Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return b(this,di,Fl).call(this,"GetFieldObjects")}getSignatures(){return b(this,di,Fl).call(this,"GetSignatures")}getSignatureData(t){return this.messageHandler.sendWithPromise("GetSignatureData",t)}hasJSActions(){return b(this,di,Fl).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)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return b(this,di,Fl).call(this,"GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return b(this,di,Fl).call(this,"GetOptionalContentConfig").then(e=>new xm(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return r(this,$o).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>{var s,i;return{info:e[0],metadata:e[1]?new _E(e[1]):null,contentDispositionFilename:((s=r(this,Ms))==null?void 0:s.filename)??null,contentLength:((i=r(this,Ms))==null?void 0:i.contentLength)??null,hasStructTree:e[2]}}))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of r(this,Pi).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),r(this,$o).clear(),this.filterFactory.destroy(!0),cu.cleanup()}}cachedPageNumber(t){if(!fm(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=r(this,Nc).get(e);if(s>=0){const i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}Ms=new WeakMap,$o=new WeakMap,Xr=new WeakMap,Pi=new WeakMap,Go=new WeakMap,Nc=new WeakMap,Yr=new WeakMap,gd=new WeakMap,di=new WeakSet,Fl=function(t,e=null){return r(this,$o).getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))},Bf=function({loaded:t,total:e}){var s,i;(i=(s=this.loadingTask).onProgress)==null||i.call(s,{loaded:t,total:e,percent:e?jt(Math.round(t/e*100),0,100):NaN})};class ME{constructor(t){O(this,"_internalRenderTask",null);O(this,"onContinue",null);O(this,"onError",null);this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&(e==null?void 0:e.size)>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}var ia,zo;const Ba=class Ba{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:f=null,enableHWA:g=!1,operationsFilter:m=null}){y(this,ia,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=d,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=h===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new ME(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._imagesTracker=e.imagesTracker,this._operationsFilter=m}get completed(){return this.capability.promise.catch(()=>{})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var c,h;if(this.cancelled)return;if(this._canvas){if(r(Ba,zo).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");r(Ba,zo).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:s,transform:i,background:n,dependencyTracker:a,imagesTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Hl(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a,o),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:n}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s,i,n;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),r(this,ia)&&(window.cancelAnimationFrame(r(this,ia)),p(this,ia,null)),r(Ba,zo).delete(this._canvas),t||(t=new Xv(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(n=(i=this.task).onError)==null||n.call(i,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,ia,window.requestAnimationFrame(()=>{p(this,ia,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(),r(Ba,zo).delete(this._canvas),this.callback())))}};ia=new WeakMap,zo=new WeakMap,y(Ba,zo,new WeakSet);let Rm=Ba;const OE="6.4.299",RE="d0991a0d5";P0();var Os,Vo,Bc,we,md,Uc,Kr,vd,ra,Ii,yd,kt,Dm,Fm,Lm,Da,Qw,bn;const vs=class vs{constructor({editor:t=null,uiManager:e=null}){y(this,kt);y(this,Os,null);y(this,Vo,null);y(this,Bc);y(this,we,null);y(this,md,!1);y(this,Uc,!1);y(this,Kr,null);y(this,vd);y(this,ra,null);y(this,Ii,null);var s,i;t?(p(this,Uc,!1),p(this,Kr,t)):p(this,Uc,!0),p(this,Ii,(t==null?void 0:t._uiManager)||e),p(this,vd,r(this,Ii)._eventBus),p(this,Bc,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((i=r(this,Ii))==null?void 0:i.highlightColors.values().next().value)||"#FFFF98"),r(vs,yd)||p(vs,yd,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return V(this,"_keyboardManager",new yl([[["Escape"],vs.prototype._hideDropdownFromKeyboard],[["Space"],vs.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],vs.prototype._moveToNext],[["ArrowUp","ArrowLeft"],vs.prototype._moveToPrevious],[["Home"],vs.prototype._moveToBeginning],[["End"],vs.prototype._moveToEnd]]))}renderButton(){const t=p(this,Os,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",r(this,Kr)&&(t.ariaControls=`${r(this,Kr).id}_colorpicker_dropdown`);const e=r(this,Ii)._signal;t.addEventListener("click",b(this,kt,Da).bind(this),{signal:e}),t.addEventListener("keydown",b(this,kt,Lm).bind(this),{signal:e});const s=p(this,Vo,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=r(this,Bc),t.append(s),t}renderMainDropdown(){const t=p(this,we,b(this,kt,Dm).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===r(this,Os)){b(this,kt,Da).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,kt,Fm).call(this,e,t)}_moveToNext(t){var e,s;if(!r(this,kt,bn)){b(this,kt,Da).call(this,t);return}if(t.target===r(this,Os)){(e=r(this,we).firstElementChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=r(this,we))==null?void 0:e.firstElementChild)||t.target===r(this,Os)){r(this,kt,bn)&&this._hideDropdownFromKeyboard();return}r(this,kt,bn)||b(this,kt,Da).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!r(this,kt,bn)){b(this,kt,Da).call(this,t);return}(e=r(this,we).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!r(this,kt,bn)){b(this,kt,Da).call(this,t);return}(e=r(this,we).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=r(this,we))==null||t.classList.add("hidden"),r(this,Os).ariaExpanded="false",(e=r(this,ra))==null||e.abort(),p(this,ra,null)}_hideDropdownFromKeyboard(){var t;if(!r(this,Uc)){if(!r(this,kt,bn)){(t=r(this,Kr))==null||t.unselect();return}this.hideDropdown(),r(this,Os).focus({preventScroll:!0,focusVisible:r(this,md)})}}update(t){if(r(this,Vo)&&(r(this,Vo).style.backgroundColor=t),!r(this,we))return;const e=r(this,Ii).highlightColors.values();for(const s of r(this,we).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=r(this,Os))==null||t.remove(),p(this,Os,null),p(this,Vo,null),(e=r(this,we))==null||e.remove(),p(this,we,null)}};Os=new WeakMap,Vo=new WeakMap,Bc=new WeakMap,we=new WeakMap,md=new WeakMap,Uc=new WeakMap,Kr=new WeakMap,vd=new WeakMap,ra=new WeakMap,Ii=new WeakMap,yd=new WeakMap,kt=new WeakSet,Dm=function(){const t=document.createElement("div"),e=r(this,Ii)._signal;t.addEventListener("contextmenu",Li,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),r(this,Kr)&&(t.id=`${r(this,Kr).id}_colorpicker_dropdown`);for(const[s,i]of r(this,Ii).highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",r(vs,yd)[s]);const a=document.createElement("span");n.append(a),a.className="swatch",a.style.backgroundColor=i,n.ariaSelected=i===r(this,Bc),n.addEventListener("click",b(this,kt,Fm).bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",b(this,kt,Lm).bind(this),{signal:e}),t},Fm=function(t,e){e.stopPropagation(),r(this,vd).dispatch("switchannotationeditorparams",{source:this,type:dt.HIGHLIGHT_COLOR,value:t}),this.update(t)},Lm=function(t){vs._keyboardManager.exec(this,t)},Da=function(t){if(r(this,kt,bn)){this.hideDropdown();return}if(p(this,md,t.detail===0),r(this,ra)||(p(this,ra,new AbortController),window.addEventListener("pointerdown",b(this,kt,Qw).bind(this),{signal:r(this,Ii).combinedSignal(r(this,ra))})),r(this,Os).ariaExpanded="true",r(this,we)){r(this,we).classList.remove("hidden");return}const e=p(this,we,b(this,kt,Dm).call(this));r(this,Os).append(e)},Qw=function(t){var e;(e=r(this,we))!=null&&e.contains(t.target)||this.hideDropdown()},bn=function(){return r(this,we)&&!r(this,we).classList.contains("hidden")},y(vs,yd,null);let cp=vs;var Rs,Hc,Wo,qr,bd;const Ua=class Ua{constructor(t){y(this,Rs,null);y(this,Hc,!1);y(this,Wo,null);y(this,qr,null);p(this,Wo,t),p(this,qr,t._uiManager),r(Ua,bd)||p(Ua,bd,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(r(this,Rs))return r(this,Rs);const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:n,opacity:a}=r(this,Wo),o=p(this,Hc,Et.isAlphaColorInputSupported&&i!==void 0),l=p(this,Rs,document.createElement("input"));if(l.type="color",o){l.setAttribute("alpha","");const c=$.hexNums[Math.round((a??1)*255)];l.value=(n||"#000000")+c}else l.value=n||"#000000";return l.className="basicColorPicker",l.tabIndex=0,l.setAttribute("data-l10n-id",r(Ua,bd)[t]),l.addEventListener("input",()=>{if(o){const c=xh(l.value);if(!c)return;const[h,d,f,g]=c,m=$.makeHexColor(h,d,f);s!==void 0?r(this,qr).updateParams(s,{color:m,opacity:g}):(r(this,qr).updateParams(e,m),r(this,qr).updateParams(i,g))}else r(this,qr).updateParams(e,l.value)},{signal:r(this,qr)._signal}),l}update(t){if(r(this,Rs))if(r(this,Hc)){const e=$.hexNums[Math.round(r(this,Wo).opacity*255)];r(this,Rs).value=t+e}else r(this,Rs).value=t}updateOpacity(t){if(!r(this,Rs)||!r(this,Hc))return;const e=$.hexNums[Math.round(t*255)];r(this,Rs).value=r(this,Wo).color+e}destroy(){var t;(t=r(this,Rs))==null||t.remove(),p(this,Rs,null)}hideDropdown(){}};Rs=new WeakMap,Hc=new WeakMap,Wo=new WeakMap,qr=new WeakMap,bd=new WeakMap,y(Ua,bd,null);let hp=Ua;y0();function Vy(u){return Math.floor(jt(u,0,1)*255).toString(16).padStart(2,"0")}function Mh(u){return jt(u,0,1)*255}class Wy{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Mh(t),[t,t,t]}static G_HTML([t]){const e=Vy(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(Mh)}static RGB_HTML(t){return`#${t.map(Vy).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Mh(1-Math.min(1,t+i)),Mh(1-Math.min(1,s+i)),Mh(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,n=1-e,a=1-s,o=Math.min(i,n,a);return["CMYK",i,n,a,o]}}class DE{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){vt("Abstract method `_createSVG` called.")}}class up extends DE{_createSVG(t){return document.createElementNS(ns,t)}}const FE=9,wl=new WeakSet,LE=new Date().getTimezoneOffset()*60*1e3;class Ig{static create(t){switch(t.data.annotationType){case Kt.LINK:return new Jv(t);case Kt.TEXT:return new BE(t);case Kt.WIDGET:switch(t.data.fieldType){case"Tx":return new UE(t);case"Btn":return t.data.radioButton?new $E(t):t.data.checkBox?new jE(t):new GE(t);case"Ch":return new zE(t);case"Sig":return new HE(t)}return new Pl(t);case Kt.POPUP:return new Bm(t);case Kt.FREETEXT:return new nA(t);case Kt.LINE:return new WE(t);case Kt.SQUARE:return new XE(t);case Kt.CIRCLE:return new YE(t);case Kt.POLYLINE:return new aA(t);case Kt.CARET:return new qE(t);case Kt.INK:return new Qv(t);case Kt.POLYGON:return new KE(t);case Kt.HIGHLIGHT:return new oA(t);case Kt.UNDERLINE:return new JE(t);case Kt.SQUIGGLY:return new QE(t);case Kt.STRIKEOUT:return new ZE(t);case Kt.STAMP:return new lA(t);case Kt.FILEATTACHMENT:return new tx(t);case Kt.RICHMEDIA:case Kt.SCREEN:case Kt.SOUND:return new cA(t);default:return new Wt(t)}}}var Xo,jc,li,wd,Nm;const ly=class ly{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){y(this,wd);y(this,Xo,null);y(this,jc,!1);y(this,li,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(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return ly._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var s;const{data:t}=this,e=(s=this.annotationStorage)==null?void 0:s.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var o;const t=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:i}=this.data;let n=-1/0,a=-1/0;if((e==null?void 0:e.length)>=8){for(let l=0;l<e.length;l+=8)e[l+1]>a?(a=e[l+1],n=e[l+2]):e[l+1]===a&&(n=Math.max(n,e[l+2]));return[n,a]}if((s==null?void 0:s.length)>=1){for(const l of s)for(let c=0,h=l.length;c<h;c+=2)l[c+1]>a?(a=l[c+1],n=l[c]):l[c+1]===a&&(n=Math.max(n,l[c]));if(n!==1/0)return[n,a]}return i?[i[2],i[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-n)/s,t[1]=100*(t[1]-a)/i,t}get commentText(){var e,s,i;const{data:t}=this;return((s=(e=this.annotationStorage.getRawValue(`${yh}${t.id}`))==null?void 0:e.popup)==null?void 0:s.contents)||((i=t.contentsObj)==null?void 0:i.str)||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${yh}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;(e=((t=r(this,li))==null?void 0:t.popup)||this.popup)==null||e.remove(),p(this,li,this.popup=null)}updateEdited(t){var n;if(!this.container)return;t.rect&&(r(this,Xo)||p(this,Xo,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&b(this,wd,Nm).call(this,e);let i=((n=r(this,li))==null?void 0:n.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=r(this,li).popup),i&&(i.updateEdited(t),s!=null&&s.deleted&&(i.remove(),p(this,li,null),this.popup=null))}resetEdited(){var t;r(this,Xo)&&(b(this,wd,Nm).call(this,r(this,Xo).rect),(t=r(this,li))==null||t.popup.resetEdited(),p(this,Xo,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),!(this instanceof Pl)&&!(this instanceof Jv)&&!(this instanceof cA)&&(n.tabIndex=0);const{style:a}=n;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Bm){const{rotation:v}=e;return!e.hasOwnCanvas&&v!==0&&this.setRotation(v,n),n}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const v=e.borderStyle.horizontalCornerRadius,w=e.borderStyle.verticalCornerRadius;if(v>0||w>0){const _=`calc(${v}px * var(--total-scale-factor)) / calc(${w}px * var(--total-scale-factor))`;a.borderRadius=_}switch(e.borderStyle.style){case Ol.SOLID:a.borderStyle="solid";break;case Ol.DASHED:a.borderStyle="dashed";break;case Ol.BEVELED:st("Unimplemented border style: beveled");break;case Ol.INSET:st("Unimplemented border style: inset");break;case Ol.UNDERLINE:a.borderBottomStyle="solid";break}const A=e.borderColor||null;A?(p(this,jc,!0),a.borderColor=$.makeHexColor(...A)):a.borderWidth=0}const c=$.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:h,pageHeight:d,pageX:f,pageY:g}=i.rawDims;a.left=`${100*(c[0]-f)/h}%`,a.top=`${100*(c[1]-g)/d}%`;const{rotation:m}=e;return e.hasOwnCanvas||m===0?(a.width=`${100*o/h}%`,a.height=`${100*l/d}%`):this.setRotation(m,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:n,height:a}=this;t%180!==0&&([n,a]=[a,n]),e.style.width=`${100*n/s}%`,e.style.height=`${100*a/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],a=n[0],o=n.slice(1);i.target.style[s]=Wy[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Wy[`${a}_rgb`](o)})};return V(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const n=t[i]||s[i];n==null||n(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,n]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:n},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(Math.fround);if(t.length===8){const[v,w,A,_]=t.subarray(2,6);if(i===v&&n===w&&e===A&&s===_)return}const{style:a}=this.container;let o;if(r(this,jc)){const{borderColor:v,borderWidth:w}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",`<svg xmlns="${ns}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${v}" stroke-width="${w}">`],this.container.classList.add("hasBorder")}const l=i-e,c=n-s,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";const f=h.createElement("defs");d.append(f);const g=h.createElement("clipPath"),m=`clippath_${this.data.id}`;g.setAttribute("id",m),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let v=2,w=t.length;v<w;v+=8){const A=t[v],_=t[v+1],E=t[v+2],S=t[v+3],x=h.createElement("rect"),T=(E-e)/l,C=(n-_)/c,I=(A-E)/l,k=(_-S)/c;x.setAttribute("x",T),x.setAttribute("y",C),x.setAttribute("width",I),x.setAttribute("height",k),g.append(x),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${T}" y="${C}" width="${I}" height="${k}"/>`)}r(this,jc)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(d),this.container.style.clipPath=`url(#${m})`}_createPopup(t=null){const{data:e}=this;let s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate),p(this,li,new Bm({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(r(this,li)||this.popup||this.data.popupRef)}get extraPopupElement(){return r(this,li)}render(){vt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects.get(t)||[];for(const{page:n,id:a,exportValues:o}of i){if(n===-1||a===e)continue;const l=typeof o=="string"?o:null,c=document.querySelector(`[data-element-id="${a}"]`);if(c&&!wl.has(c)){st(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,a=i.getAttribute("data-element-id");a===e||!wl.has(i)||s.push({id:a,exportValue:n,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;t.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":$.makeHexColor(...e)}};Xo=new WeakMap,jc=new WeakMap,li=new WeakMap,wd=new WeakSet,Nm=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t),e.left=`${100*(t[0]-o)/n}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*(t[2]-t[0])/n}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(i)};let Wt=ly;class NE extends Wt{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()}}var Vs,Fa,Zw,tA;class Jv extends Wt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});y(this,Vs);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let n=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),n=!0):e.action?(this._bindNamedAction(i,e.action,e.overlaidText),n=!0):e.attachment?(b(this,Vs,Zw).call(this,i,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest),n=!0):e.setOCGState?(b(this,Vs,tA).call(this,i,e.setOCGState,e.overlaidText),n=!0):e.dest?(this._bindLink(i,e.dest,e.overlaidText),n=!0):(e.actions&&(e.actions.has("Action")||e.actions.has("Mouse Up")||e.actions.has("Mouse Down"))&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),n=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&(this.contentElement=i,this.container.append(i)),this.container}_bindLink(e,s,i=""){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&b(this,Vs,Fa).call(this),i&&(e.title=i)}_bindNamedAction(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),i&&(e.title=i),b(this,Vs,Fa).call(this)}_bindJSAction(e,{actions:s,id:i,overlaidText:n}){e.href=this.linkService.getAnchorUrl("");const a=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const o of s.keys()){const l=a.get(o);l&&(e[l]=()=>{var c;return(c=this.linkService.eventBus)==null||c.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:o}}),!1})}n&&(e.title=n),e.onclick||(e.onclick=()=>!1),b(this,Vs,Fa).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),b(this,Vs,Fa).call(this),!this._fieldObjects){st('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var d;i==null||i();const{fields:n,refs:a,include:o}=s,l=[];if(n.length!==0||a.length!==0){const f=new Set(a);for(const m of n){const v=this._fieldObjects.get(m)||[];for(const{id:w}of v)f.add(w)}const g=new Map;for(const m of this._fieldObjects.values())for(const{id:v,kidIds:w}of m)w&&g.set(v,w);for(const m of f)for(const v of g.get(m)||[])f.add(v);for(const m of this._fieldObjects.values())for(const v of m)f.has(v.id)===o&&l.push(v)}else for(const f of this._fieldObjects.values())l.push(...f);const c=this.annotationStorage,h=[];for(const f of l){const{id:g}=f;switch(h.push(g),f.type){case"text":{const v=f.defaultValue||"";c.setValue(g,{value:v});break}case"checkbox":case"radiobutton":{const v=f.defaultValue===f.exportValues;c.setValue(g,{value:v});break}case"combobox":case"listbox":{const v=f.defaultValue||"";c.setValue(g,{value:v});break}default:continue}const m=document.querySelector(`[data-element-id="${g}"]`);if(m){if(!wl.has(m)){st(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;m.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((d=this.linkService.eventBus)==null||d.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}})),!1}}}Vs=new WeakSet,Fa=function(){this.container.setAttribute("data-internal-link","")},Zw=function(e,s,i,n="",a=null){e.href=this.linkService.getAnchorUrl(""),i.description?e.title=i.description:n&&(e.title=n);const o=async()=>{var c;const l=await this.linkService.getAttachmentContent(s);l&&((c=this.downloadManager)==null||c.openOrDownloadData(l,i.filename,a))};e.onclick=()=>(o(),!1),b(this,Vs,Fa).call(this)},tA=function(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(e.title=i),b(this,Vs,Fa).call(this)};class BE extends Wt{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 Pl extends Wt{render(){return this.container}_getKeyModifier(t){return Et.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}n&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a)}}))})}_setEventListeners(t,e,s,i){const{actions:n}=this.data;for(const[a,o]of s)(o==="Action"||n!=null&&n.has(o))&&((o==="Focus"||o==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,a,o,i),o==="Focus"&&!(n!=null&&n.has("Blur"))?this._setEventListener(t,e,"blur","Blur",null):o==="Blur"&&!(n!=null&&n.has("Focus"))&&this._setEventListener(t,e,"focus","Focus",null))}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||FE,n=t.style;let a;const o=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o),h=Math.round(c/(1.35*i))||1,d=c/h;a=Math.min(i,l(d/1.35))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(c/1.35))}n.fontSize=`calc(${a}px * var(--total-scale-factor))`,n.color=$.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class UE extends Pl{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const n=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),n.setValue(a.id,{[i]:s})}render(){var i,n;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let c=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
48
+ `))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const h={userValue:o,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",c??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(this.container.classList.add("hasOwnCanvas"),t.has(e)&&this.container.classList.add("sandboxModified")),wl.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:d,datetimeType:f,timeStep:g}=this.data,m=!!f&&this.enableScripting;d&&(s.title=d),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",w=>{t.setValue(e,{value:w.target.value}),this.setPropertyOnSiblings(s,"value",w.target.value,"value"),h.formattedValue=null}),s.addEventListener("resetform",w=>{const A=this.data.defaultFieldValue??"";s.value=h.userValue=A,h.formattedValue=null});let v=w=>{const{formattedValue:A}=h;A!=null&&(w.target.value=A),w.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",A=>{var E;if(h.focused)return;const{target:_}=A;if(m&&(_.type=f,g&&(_.step=g)),h.userValue){const S=h.userValue;if(m)if(f==="time"){const x=new Date(S),T=[x.getHours(),x.getMinutes(),x.getSeconds()];_.value=T.map(C=>C.toString().padStart(2,"0")).join(":")}else _.value=new Date(S-LE).toISOString().split(f==="date"?"T":".",1)[0];else _.value=S}h.lastCommittedValue=_.value,h.commitKey=1,(E=this.data.actions)!=null&&E.has("Focus")||(h.focused=!0)}),s.addEventListener("updatefromsandbox",A=>{this.container.classList.add("sandboxModified");const _={value(E){h.userValue=E.detail.value??"",m||t.setValue(e,{value:h.userValue.toString()}),E.target.value=h.userValue},formattedValue(E){const{formattedValue:S}=E.detail;h.formattedValue=S,S!=null&&E.target!==document.activeElement&&(E.target.value=S);const x={formattedValue:S};m&&(x.value=S),t.setValue(e,x)},selRange(E){E.target.setSelectionRange(...E.detail.selRange)},charLimit:E=>{var C;const{charLimit:S}=E.detail,{target:x}=E;if(S===0){x.removeAttribute("maxLength");return}x.setAttribute("maxLength",S);let T=h.userValue;!T||T.length<=S||(T=T.slice(0,S),x.value=h.userValue=T,t.setValue(e,{value:T}),(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:T,willCommit:!0,commitKey:1,selStart:x.selectionStart,selEnd:x.selectionEnd}}))}};this._dispatchEventFromSandbox(_,A)}),s.addEventListener("keydown",A=>{var S;h.commitKey=1;let _=-1;if(A.key==="Escape"?_=0:A.key==="Enter"&&!this.data.multiLine?_=2:A.key==="Tab"&&(h.commitKey=3),_===-1)return;const{value:E}=A.target;h.lastCommittedValue!==E&&(h.lastCommittedValue=E,h.userValue=E,(S=this.linkService.eventBus)==null||S.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,commitKey:_,selStart:A.target.selectionStart,selEnd:A.target.selectionEnd}}))});const w=v;v=null,s.addEventListener("blur",A=>{var S,x;if(!h.focused||!A.relatedTarget)return;(S=this.data.actions)!=null&&S.has("Blur")||(h.focused=!1);const{target:_}=A;let{value:E}=_;if(m){if(E&&f==="time"){const T=E.split(":").map(C=>parseInt(C,10));E=new Date(2e3,0,1,T[0],T[1],T[2]||0).valueOf(),_.step=""}else E.includes("T")||(E=`${E}T00:00`),E=new Date(E).valueOf();_.type="text"}h.userValue=E,h.lastCommittedValue!==E&&((x=this.linkService.eventBus)==null||x.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,commitKey:h.commitKey,selStart:A.target.selectionStart,selEnd:A.target.selectionEnd}})),w(A)}),(n=this.data.actions)!=null&&n.has("Keystroke")&&s.addEventListener("beforeinput",A=>{var k;h.lastCommittedValue=null;const{data:_,target:E}=A,{value:S,selectionStart:x,selectionEnd:T}=E;let C=x,I=T;switch(A.inputType){case"deleteWordBackward":{const M=/\w/;for(;C>0&&!M.test(S[C-1]);)C--;for(;C>0&&M.test(S[C-1]);)C--;break}case"deleteWordForward":{const M=S.substring(x).match(/^\W*\w*/);M&&(I+=M[0].length);break}case"deleteContentBackward":x===T&&(C-=1);break;case"deleteContentForward":x===T&&(I+=1);break}A.preventDefault(),(k=this.linkService.eventBus)==null||k.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:S,change:_||"",willCommit:!1,selStart:C,selEnd:I}})}),this._setEventListeners(s,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],A=>A.target.value)}if(v&&s.addEventListener("blur",v),this.data.comb){const A=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${A}px * var(--total-scale-factor))`);const _=this.data.textAlignment;if(_===1||_===2){const E=()=>{const S=l-s.value.length;s.style.setProperty("--comb-offset",`${_===1?S>>1:S}`)};E();for(const S of["input","blur","resetform","updatefromsandbox"])s.addEventListener(S,E)}}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class HE extends Pl{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class jE extends Pl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return wl.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=0,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s)){const h=l&&c.exportValue===e.exportValue;c.domElement&&(c.domElement.checked=h),t.setValue(c.id,{value:h})}t.setValue(s,{value:l})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class $E extends Pl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const n=document.createElement("input");if(wl.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=0,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s))t.setValue(c.id,{value:!1});t.setValue(s,{value:l})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;n.addEventListener("updatefromsandbox",o=>{const l={value:c=>{const h=a===c.detail.value;for(const d of this._getElementsByName(c.target.name)){const f=h&&d.id===s;d.domElement&&(d.domElement.checked=f),t.setValue(d.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class GE extends Jv{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class zE extends Pl{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");wl.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",d=>{const f=this.data.defaultFieldValue;for(const g of i.options)g.selected=g.value===f});const a=(d,f)=>{const g=f.replaceAll(" "," ");d.textContent=g,g!==f&&d.setAttribute("display-value",f)};for(const d of this.data.options){const f=document.createElement("option");a(f,d.displayValue),f.value=d.exportValue,s.value.includes(d.exportValue)&&(f.setAttribute("selected",!0),n=!1),i.append(f)}let o=null;if(n){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),o=()=>{d.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const l=d=>{const f=d?"value":"textContent",{options:g,multiple:m}=i;return m?Array.prototype.filter.call(g,v=>v.selected).map(v=>v[f]):g.selectedIndex===-1?null:g[g.selectedIndex][f]};let c=l(!1);const h=d=>{const f=d.target.options;return Array.prototype.map.call(f,g=>({displayValue:g.getAttribute("display-value")||g.textContent,exportValue:g.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const f={value(g){o==null||o();const m=g.detail.value,v=new Set(Array.isArray(m)?m:[m]);for(const w of i.options)w.selected=v.has(w.value);t.setValue(e,{value:l(!0)}),c=l(!1)},multipleSelection(g){i.multiple=!0},remove(g){const m=i.options,v=g.detail.remove;m[v].selected=!1,i.remove(v),m.length>0&&Array.prototype.findIndex.call(m,A=>A.selected)===-1&&(m[0].selected=!0),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},clear(g){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),c=l(!1)},insert(g){const{index:m,displayValue:v,exportValue:w}=g.detail.insert,A=i.children[m],_=document.createElement("option");a(_,v),_.value=w,A?A.before(_):i.append(_),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},items(g){const{items:m}=g.detail;for(;i.length!==0;)i.remove(0);for(const v of m){const{displayValue:w,exportValue:A}=v,_=document.createElement("option");a(_,w),_.value=A,i.append(_)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:l(!0),items:h(g)}),c=l(!1)},indices(g){const m=new Set(g.detail.indices);for(const v of g.target.options)v.selected=m.has(v.index);t.setValue(e,{value:l(!0)}),c=l(!1)},editable(g){g.target.disabled=!g.detail.editable}};this._dispatchEventFromSandbox(f,d)}),i.addEventListener("input",d=>{var m;const f=l(!0),g=l(!1);t.setValue(e,{value:f}),d.preventDefault(),(m=this.linkService.eventBus)==null||m.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:c,change:g,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):i.addEventListener("input",function(d){t.setValue(e,{value:l(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}var Ad,Um;class Bm extends Wt{constructor(e){const{data:s,elements:i,parent:n}=e,a=!!n._commentManager;super(e,{isRenderable:!a&&Wt._hasPopupData(s)});y(this,Ad);if(this.elements=i,a&&Wt._hasPopupData(s)){const o=this.popup=b(this,Ad,Um).call(this);for(const l of i)l.popup=o}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";const s=this.popup=b(this,Ad,Um).call(this),i=[];for(const n of this.elements)n.popup=s,n.container.ariaHasPopup="dialog",i.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(n=>`${Nl}${n}`).join(",")),this.container}}Ad=new WeakSet,Um=function(){return new VE({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})};var Ds,na,Rp,Dp,$c,Gc,ie,or,aa,Yo,zc,Vc,lr,Fs,Jr,Qr,re,Zr,oa,_d,tn,Wc,Ko,la,Oe,ca,lt,Uf,Hm,jm,$m,Hf,Gm,eA,sA,iA,rA,jf,$f,zm;class VE{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:a,richText:o,parent:l,rect:c,parentRect:h,open:d,commentManager:f=null}){y(this,lt);y(this,Ds,null);y(this,na,b(this,lt,iA).bind(this));y(this,Rp,b(this,lt,zm).bind(this));y(this,Dp,b(this,lt,$f).bind(this));y(this,$c,b(this,lt,jf).bind(this));y(this,Gc,null);y(this,ie,null);y(this,or,null);y(this,aa,null);y(this,Yo,null);y(this,zc,null);y(this,Vc,null);y(this,lr,!1);y(this,Fs,null);y(this,Jr,null);y(this,Qr,null);y(this,re,null);y(this,Zr,null);y(this,oa,null);y(this,_d,null);y(this,tn,null);y(this,Wc,null);y(this,Ko,null);y(this,la,!1);y(this,Oe,null);y(this,ca,null);p(this,ie,t),p(this,Wc,i),p(this,or,a),p(this,tn,o),p(this,zc,l),p(this,Gc,e),p(this,_d,c),p(this,Vc,h),p(this,Yo,s),p(this,Ds,f),p(this,Oe,s[0]),p(this,aa,op.toDateObject(n)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup()),f||(b(this,lt,Uf).call(this),r(this,ie).hidden=!0,d&&b(this,lt,jf).call(this))}renderCommentButton(){if(r(this,re)){r(this,re).parentNode||r(this,Oe).container.after(r(this,re));return}if(r(this,Zr)||b(this,lt,Hm).call(this),!r(this,Zr))return;const{signal:t}=p(this,Jr,new AbortController),e=r(this,Oe).hasOwnCommentButton,s=()=>{r(this,Ds).toggleCommentPopup(this,!0,void 0,!e)},i=()=>{r(this,Ds).toggleCommentPopup(this,!1,!0,!e)},n=()=>{r(this,Ds).toggleCommentPopup(this,!1,!1)};if(e){p(this,re,r(this,Oe).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",r(this,na),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",n,{signal:t}),a.classList.add("popupTriggerArea")}else{const a=p(this,re,document.createElement("button"));a.className="annotationCommentButton";const o=r(this,Oe).container;a.style.zIndex=parseInt(o.style.zIndex,10)+1,a.tabIndex=0,a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.setAttribute("data-l10n-id","pdfjs-show-comment-button"),b(this,lt,$m).call(this),b(this,lt,jm).call(this),a.addEventListener("keydown",r(this,na),{signal:t}),a.addEventListener("click",s,{signal:t}),a.addEventListener("pointerenter",i,{signal:t}),a.addEventListener("pointerleave",n,{signal:t}),o.after(a)}}get commentButtonColor(){const{color:t,opacity:e}=r(this,Oe).commentData;return t?r(this,zc)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=r(this,re))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:i,modificationDate:n}=r(this,Oe).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:n}}get elementBeforePopup(){return r(this,re)}get comment(){return r(this,ca)||p(this,ca,r(this,Oe).commentText),r(this,ca)}set comment(t){t!==this.comment&&(r(this,Oe).commentText=p(this,ca,t))}focus(){var t;(t=r(this,Oe).container)==null||t.focus()}get parentBoundingClientRect(){return r(this,Oe).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){r(this,re)&&(r(this,re).classList.toggle("selected",t),r(this,re).ariaExpanded=e)}setSelectedCommentButton(t){r(this,re).classList.toggle("selected",t)}get commentPopupPosition(){if(r(this,oa))return r(this,oa);const{x:t,y:e,height:s}=r(this,re).getBoundingClientRect(),{x:i,y:n,width:a,height:o}=r(this,Oe).layer.getBoundingClientRect();return[(t-i)/a,(e+s-n)/o]}set commentPopupPosition(t){p(this,oa,t)}hasDefaultPopupPosition(){return r(this,oa)===null}get commentButtonPosition(){return r(this,Zr)}get commentButtonWidth(){return r(this,re).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=r(this,oa)||this.commentButtonPosition.map(c=>c/100),i=this.parentBoundingClientRect,{x:n,y:a,width:o,height:l}=i;r(this,Ds).showDialog(null,this,n+e*o,a+s*l,{...t,parentDimensions:i})}render(){var s,i;if(r(this,Fs))return;const t=p(this,Fs,document.createElement("div"));if(t.className="popup",r(this,Gc)){const n=t.style.outlineColor=$.makeHexColor(...r(this,Gc));t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`}const e=document.createElement("span");if(e.className="header",(s=r(this,Wc))!=null&&s.str){const n=document.createElement("span");n.className="title",e.append(n),{dir:n.dir,str:n.textContent}=r(this,Wc)}if(t.append(e),r(this,aa)){const n=document.createElement("time");n.className="popupDate",n.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),n.setAttribute("data-l10n-args",JSON.stringify({dateObj:r(this,aa).valueOf()})),n.dateTime=r(this,aa).toISOString(),e.append(n)}Pb({html:r(this,lt,Hf)||r(this,or).str,dir:(i=r(this,or))==null?void 0:i.dir,className:"popupContent"},t),r(this,ie).append(t)}updateEdited({rect:t,popup:e,deleted:s}){var i;if(r(this,Ds)){s?(this.remove(),p(this,ca,null)):e&&(e.deleted?this.remove():(b(this,lt,$m).call(this),p(this,ca,e.text))),t&&(p(this,Zr,null),b(this,lt,Hm).call(this),b(this,lt,jm).call(this));return}if(s||e!=null&&e.deleted){this.remove();return}b(this,lt,Uf).call(this),r(this,Ko)||p(this,Ko,{contentsObj:r(this,or),richText:r(this,tn)}),t&&p(this,Qr,null),e&&e.text&&(p(this,tn,b(this,lt,sA).call(this,e.text)),p(this,aa,op.toDateObject(e.date)),p(this,or,null)),(i=r(this,Fs))==null||i.remove(),p(this,Fs,null)}resetEdited(){var t;r(this,Ko)&&({contentsObj:Ft(this,or)._,richText:Ft(this,tn)._}=r(this,Ko),p(this,Ko,null),(t=r(this,Fs))==null||t.remove(),p(this,Fs,null),p(this,Qr,null))}remove(){var t,e,s;if((t=r(this,Jr))==null||t.abort(),p(this,Jr,null),(e=r(this,Fs))==null||e.remove(),p(this,Fs,null),p(this,la,!1),p(this,lr,!1),(s=r(this,re))==null||s.remove(),p(this,re,null),this.trigger)for(const i of this.trigger)i.classList.remove("popupTriggerArea")}forceHide(){p(this,la,this.isVisible),r(this,la)&&(r(this,ie).hidden=!0)}maybeShow(){r(this,Ds)||(b(this,lt,Uf).call(this),r(this,la)&&(r(this,Fs)||b(this,lt,$f).call(this),p(this,la,!1),r(this,ie).hidden=!1))}get isVisible(){return!r(this,Ds)&&r(this,ie).hidden===!1}}Ds=new WeakMap,na=new WeakMap,Rp=new WeakMap,Dp=new WeakMap,$c=new WeakMap,Gc=new WeakMap,ie=new WeakMap,or=new WeakMap,aa=new WeakMap,Yo=new WeakMap,zc=new WeakMap,Vc=new WeakMap,lr=new WeakMap,Fs=new WeakMap,Jr=new WeakMap,Qr=new WeakMap,re=new WeakMap,Zr=new WeakMap,oa=new WeakMap,_d=new WeakMap,tn=new WeakMap,Wc=new WeakMap,Ko=new WeakMap,la=new WeakMap,Oe=new WeakMap,ca=new WeakMap,lt=new WeakSet,Uf=function(){var e;if(r(this,Jr))return;p(this,Jr,new AbortController);const{signal:t}=r(this,Jr);for(const s of this.trigger)s.addEventListener("click",r(this,$c),{signal:t}),s.addEventListener("pointerenter",r(this,Dp),{signal:t}),s.addEventListener("pointerleave",r(this,Rp),{signal:t}),s.classList.add("popupTriggerArea");for(const s of r(this,Yo))(e=s.container)==null||e.addEventListener("keydown",r(this,na),{signal:t})},Hm=function(){const t=r(this,Yo).find(e=>e.hasCommentButton);t&&p(this,Zr,t._normalizePoint(t.commentButtonPosition))},jm=function(){if(r(this,Oe).extraPopupElement&&!r(this,Oe).editor)return;r(this,re)||this.renderCommentButton();const[t,e]=r(this,Zr),{style:s}=r(this,re);s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`},$m=function(){r(this,Oe).extraPopupElement||(r(this,re)||this.renderCommentButton(),r(this,re).style.backgroundColor=this.commentButtonColor||"")},Hf=function(){const t=r(this,tn),e=r(this,or);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&r(this,tn).html||null},Gm=function(){var t,e,s;return((s=(e=(t=r(this,lt,Hf))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},eA=function(){var t,e,s;return((s=(e=(t=r(this,lt,Hf))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},sA=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:r(this,lt,eA),fontSize:r(this,lt,Gm)?`calc(${r(this,lt,Gm)}px * var(--total-scale-factor))`:""}};for(const n of t.split(`
49
+ `))e.push({name:"span",value:n,attributes:i});return s},iA=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&r(this,lr))&&b(this,lt,jf).call(this)},rA=function(){if(r(this,Qr)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=r(this,zc);let a=!!r(this,Vc),o=a?r(this,Vc):r(this,_d);for(const m of r(this,Yo))if(!o||$.intersect(m.data.rect,o)!==null){o=m.data.rect,a=!0;break}const l=$.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),h=a?o[2]-o[0]+5:0,d=l[0]+h,f=l[1];p(this,Qr,[100*(d-i)/e,100*(f-n)/s]);const{style:g}=r(this,ie);g.left=`${r(this,Qr)[0]}%`,g.top=`${r(this,Qr)[1]}%`},jf=function(){if(r(this,Ds)){r(this,Ds).toggleCommentPopup(this,!1);return}p(this,lr,!r(this,lr)),r(this,lr)?(b(this,lt,$f).call(this),r(this,ie).addEventListener("click",r(this,$c)),r(this,ie).addEventListener("keydown",r(this,na))):(b(this,lt,zm).call(this),r(this,ie).removeEventListener("click",r(this,$c)),r(this,ie).removeEventListener("keydown",r(this,na)))},$f=function(){r(this,Fs)||this.render(),this.isVisible?r(this,lr)&&r(this,ie).classList.add("focused"):(b(this,lt,rA).call(this),r(this,ie).hidden=!1,r(this,ie).style.zIndex=parseInt(r(this,ie).style.zIndex,10)+1e3)},zm=function(){r(this,ie).classList.remove("focused"),!(r(this,lr)||!this.isVisible)&&(r(this,ie).hidden=!0,r(this,ie).style.zIndex=parseInt(r(this,ie).style.zIndex,10)-1e3)};class nA extends Wt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=rt.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 s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}var Sd;class WE extends Wt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,Sd,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:s,height:i}=this,n=this.svgFactory.create(s,i,!0),a=p(this,Sd,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return r(this,Sd)}addHighlightArea(){this.container.classList.add("highlightArea")}}Sd=new WeakMap;var Ed;class XE extends Wt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,Ed,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:s,height:i}=this,n=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,Ed,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",i-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),n.append(o),this.container.append(n),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return r(this,Ed)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ed=new WeakMap;var xd;class YE extends Wt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,xd,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:s,height:i}=this,n=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,xd,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",i/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",i/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),n.append(o),this.container.append(n),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return r(this,xd)}addHighlightArea(){this.container.classList.add("highlightArea")}}xd=new WeakMap;var Td;class aA extends Wt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,Td,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:n},width:a,height:o}=this;if(!s)return this.container;const l=this.svgFactory.create(a,o,!0);let c=[];for(let d=0,f=s.length;d<f;d+=2){const g=s[d]-e[0],m=e[3]-s[d+1];c.push(`${g},${m}`)}c=c.join(" ");const h=p(this,Td,this.svgFactory.createElement(this.svgElementName));return h.setAttribute("points",c),h.setAttribute("stroke-width",i.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),l.append(h),this.container.append(l),!n&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return r(this,Td)}addHighlightArea(){this.container.classList.add("highlightArea")}}Td=new WeakMap;class KE extends aA{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class qE extends Wt{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}}var Cd,qo,Pd,Vm;class Qv extends Wt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,Pd);y(this,Cd,null);y(this,qo,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?rt.HIGHLIGHT:rt.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:i,borderStyle:n,popupRef:a}}=this,{transform:o,width:l,height:c}=b(this,Pd,Vm).call(this,s,e),h=this.svgFactory.create(l,c,!0),d=p(this,Cd,this.svgFactory.createElement("svg:g"));h.append(d),d.setAttribute("stroke-width",n.width||1),d.setAttribute("stroke-linecap","round"),d.setAttribute("stroke-linejoin","round"),d.setAttribute("stroke-miterlimit",10),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),d.setAttribute("transform",o);for(const f of i){const g=this.svgFactory.createElement(this.svgElementName);r(this,qo).push(g),g.setAttribute("points",f.join(",")),d.append(g)}return!a&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(h),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:i,rect:n}=e,a=r(this,Cd);if(s>=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=r(this,qo).length;o<l;o++)r(this,qo)[o].setAttribute("points",i[o].join(","));if(n){const{transform:o,width:l,height:c}=b(this,Pd,Vm).call(this,this.data.rotation,n);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${c}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return r(this,qo)}addHighlightArea(){this.container.classList.add("highlightArea")}}Cd=new WeakMap,qo=new WeakMap,Pd=new WeakSet,Vm=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class oA extends Wt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=rt.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 s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class JE extends Wt{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 s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class QE extends Wt{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 s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class ZE extends Wt{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 s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class lA extends Wt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=rt.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}}var Id,kd,Wm;class tx extends Wt{constructor(e){var n;super(e,{isRenderable:!0});y(this,kd);y(this,Id,null);const{fileId:s,file:i}=this.data;this.filename=i.filename,this.content=i.content,this.fileId=s,(n=this.linkService.eventBus)==null||n.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",b(this,kd,Wm).bind(this)),p(this,Id,i);const{isMac:n}=Et.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(n?a.metaKey:a.ctrlKey)&&b(this,kd,Wm).call(this)}),!s.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return r(this,Id)}addHighlightArea(){this.container.classList.add("highlightArea")}}Id=new WeakMap,kd=new WeakSet,Wm=async function(){var a;const{fileId:e,filename:s,content:i}=this,n=await this.linkService.getAttachmentContent(e)||i;n&&((a=this.downloadManager)==null||a.openOrDownloadData(n,s))};var Xc,Jo,en,Al,hA,Xm;class cA extends Wt{constructor(e){super(e,{isRenderable:!!e.data.richMedia});y(this,Al);y(this,Xc,new AbortController);y(this,Jo,null);y(this,en,null)}render(){this.container.classList.add("mediaAnnotation");const{filename:e}=this.data.richMedia,s=document.createElement("button");return s.className="mediaPlayButton",s.type="button",s.title=s.ariaLabel=e,s.addEventListener("click",()=>b(this,Al,hA).call(this,s),{signal:r(this,Xc).signal}),this.container.append(s),this.container}destroy(){r(this,Xc).abort(),r(this,en)&&(r(this,en).pause(),r(this,en).removeAttribute("src"),r(this,en).load(),p(this,en,null)),b(this,Al,Xm).call(this)}}Xc=new WeakMap,Jo=new WeakMap,en=new WeakMap,Al=new WeakSet,hA=async function(e){const{fileId:s,filename:i,contentType:n}=this.data.richMedia;e.disabled=!0;let a;try{a=await this.linkService.getAttachmentContent(s)}catch{return}finally{e.disabled=!1}if(!a||!e.isConnected)return;const{signal:o}=r(this,Xc),l=new Blob([a],{type:n});if(!/^(?:video|audio)\//.test(l.type))return;const c=URL.createObjectURL(l);p(this,Jo,c);const h=l.type.startsWith("audio/"),d=document.createElement(h?"audio":"video");if(p(this,en,d),d.className="mediaContent",this._setBackgroundColor(d),d.src=c,d.title=i,d.controls=!0,d.autoplay=!0,d.tabIndex=0,h){let f=!1,g=!1;const m=()=>{d.controls=f||g};this.container.addEventListener("pointerenter",()=>{f=!0,m()},{signal:o}),this.container.addEventListener("pointerleave",()=>{f=!1,m()},{signal:o}),this.container.addEventListener("focusin",()=>{g=!0,m()},{signal:o}),this.container.addEventListener("focusout",()=>{g=!1,m()},{signal:o})}d.addEventListener("emptied",()=>b(this,Al,Xm).call(this,c),{once:!0,signal:o}),e.replaceWith(d),d.play().catch(()=>{})},Xm=function(e=r(this,Jo)){e&&e===r(this,Jo)&&(URL.revokeObjectURL(e),p(this,Jo,null))};var ha,Qo,Yc,sn,Kc,Zo,Ye,Md,br,Gf,zf;const cy=class cy{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:a,structTreeLayer:o,commentManager:l,linkService:c,annotationStorage:h}){y(this,br);y(this,ha,null);y(this,Qo,null);y(this,Yc,null);y(this,sn,new Map);y(this,Kc,null);y(this,Zo,null);y(this,Ye,[]);y(this,Md,!1);O(this,"zIndex",0);this.div=t,p(this,ha,e),p(this,Qo,s),p(this,Kc,o||null),p(this,Zo,c||null),p(this,Yc,h||new Kv),this.page=n,this.viewport=a,this._annotationEditorUIManager=i,this._commentManager=l||null}hasEditableAnnotations(){return r(this,sn).size>0}async render(t){var l;const{annotations:e,optionalContentConfig:s}=t,i=this.div;vl(i,this.viewport);const n=new Map,a=[],o={data:null,layer:i,linkService:r(this,Zo),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new up,annotationStorage:r(this,Yc),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===Kt.POPUP;if(h){const g=n.get(c.id);if(!g)continue;if(!this._commentManager){a.push(c);continue}o.elements=g}else if(c.rect[2]===c.rect[0]||c.rect[3]===c.rect[1])continue;o.data=c;const d=Ig.create(o);if(!d.isRenderable)continue;h||(r(this,Ye).push(d),c.popupRef&&n.getOrInsertComputed(c.popupRef,Eh).push(d));const f=d.render();c.hidden&&(f.style.visibility="hidden"),d.updateOC(s),d._isEditable&&(r(this,sn).set(d.data.id,d),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(d))}await b(this,br,Gf).call(this);for(const c of a){const h=o.elements=n.get(c.id);o.data=c;const d=Ig.create(o);if(!d.isRenderable)continue;const f=d.render();d.contentElement.id=`${Nl}${c.id}`,c.hidden&&(f.style.visibility="hidden"),h.at(-1).container.after(f)}b(this,br,zf).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:r(this,Zo),svgFactory:new up,parent:this};for(const s of t){s.borderStyle||(s.borderStyle=cy._defaultBorderStyle),e.data=s;const i=Ig.create(e);i.isRenderable&&(i.render(),i.contentElement.id=`${Nl}${s.id}`,r(this,Ye).push(i))}await b(this,br,Gf).call(this)}update({viewport:t,optionalContentConfig:e}){const s=this.div;this.viewport=t,vl(s,{rotation:t.rotation});for(const i of r(this,Ye))i.updateOC(e);b(this,br,zf).call(this),s.hidden=!1}destroy(){var t,e;for(const s of r(this,Ye))(t=s.destroy)==null||t.call(s),(e=r(this,ha))==null||e.removePointerInTextLayer(s.contentElement);r(this,Ye).length=0,r(this,sn).clear(),this.div.replaceChildren()}refreshCanvases(){b(this,br,zf).call(this)}getEditableAnnotations(){return r(this,sn).values()}getEditableAnnotation(t){return r(this,sn).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:i}=t,n=new NE({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:r(this,Zo),annotationStorage:r(this,Yc)});return n.render(),n.contentElement.id=`${Nl}${s}`,n.createOrUpdatePopup(),r(this,Ye).push(n),n}removeAnnotation(t){var i;const e=r(this,Ye).findIndex(n=>n.data.id===t);if(e<0)return;const[s]=r(this,Ye).splice(e,1);(i=r(this,ha))==null||i.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);b(this,br,Gf).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return V(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Ol.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};ha=new WeakMap,Qo=new WeakMap,Yc=new WeakMap,sn=new WeakMap,Kc=new WeakMap,Zo=new WeakMap,Ye=new WeakMap,Md=new WeakMap,br=new WeakSet,Gf=async function(){var s,i,n,a;if(r(this,Ye).length===0)return;this.div.replaceChildren();const t=[];if(!r(this,Md)){p(this,Md,!0);for(const{contentElement:o,data:{hidden:l,id:c,oc:h}}of r(this,Ye)){const d=o.id=`${Nl}${c}`,f=o.localName==="a"&&!l&&!h;t.push((s=r(this,Kc))==null?void 0:s.getAriaAttributes(d,{enableLinkOwnership:f}).then(g=>{if(g)for(const[m,v]of g)o.setAttribute(m,v)}))}}r(this,Ye).sort(({data:{rect:[o,l,c,h]}},{data:{rect:[d,f,g,m]}})=>{if(o===c&&l===h)return 1;if(d===g&&f===m)return-1;const v=h,w=l,A=(l+h)/2,_=m,E=f,S=(f+m)/2;if(A>=_&&S<=w)return-1;if(S>=v&&A<=E)return 1;const x=(o+c)/2,T=(d+g)/2;return x-T});const e=document.createDocumentFragment();for(const o of r(this,Ye))e.append(o.container),this._commentManager?(n=((i=o.extraPopupElement)==null?void 0:i.popup)||o.popup)==null||n.renderCommentButton():o.extraPopupElement&&e.append(o.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),r(this,ha)){const o=await((a=r(this,Kc))==null?void 0:a.getAnnotationIds());for(const{contentElement:l}of r(this,Ye))o!=null&&o.has(l.id)||r(this,ha).addPointerInTextLayer(l,!1)}},zf=function(){var e;if(!r(this,Qo))return;const t=this.div;for(const[s,i]of r(this,Qo)){const n=t.querySelector(`[data-annotation-id="${s}"]`);if(!n)continue;if(Array.isArray(i))for(const h of i)h.className="annotationContent",h.ariaHidden=!0;else i.className="annotationContent",i.ariaHidden=!0;const a=[];for(const h of n.children)h.nodeName==="CANVAS"&&a.push(h);for(const h of a)h.remove();const o=Array.isArray(i)?i[0]:i,{firstChild:l}=n;if(l?l.classList.contains("annotationContent")?l.after(o):l.before(o):n.append(o),Array.isArray(i)){let h=o;for(let d=1,f=i.length;d<f;d++)h.after(i[d]),h=i[d]}r(this,Qo).delete(s);const c=r(this,sn).get(s);c&&(c._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(s,n.id,i),c._hasNoCanvas=!1):c.canvas=i)}};let Ym=cy;const mf=/\r\n?|\n/g;var Ls,Od,tl,Ns,me,uA,dA,fA,Vf,pn,Wf,Xf,pA,qm,gA;const Ut=class Ut extends Mt{constructor(e){super({...e,name:"freeTextEditor"});y(this,me);y(this,Ls,"");y(this,Od,`${this.id}-editor`);y(this,tl,null);y(this,Ns);O(this,"_colorPicker",null);this.color=e.color||Ut._defaultColor||Mt._defaultLineColor,p(this,Ns,e.fontSize||Ut._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert(Mt._l10nAlert.freetext),this.canAddComment=!1}static get _keyboardManager(){const e=Ut.prototype,s=a=>a.isEmpty(),i=bl.TRANSLATE_SMALL,n=bl.TRANSLATE_BIG;return V(this,"_keyboardManager",new yl([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],e.commitOrRemove],[["Escape"],e.commitOrRemove],[["ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:s}],[["ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[n,0],checker:s}],[["ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:s}],[["ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,n],checker:s}]]))}static initialize(e,s){Mt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case dt.FREETEXT_SIZE:Ut._defaultFontSize=s;break;case dt.FREETEXT_COLOR:Ut._defaultColor=s;break}}updateParams(e,s){switch(e){case dt.FREETEXT_SIZE:b(this,me,uA).call(this,s);break;case dt.FREETEXT_COLOR:b(this,me,dA).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[dt.FREETEXT_SIZE,Ut._defaultFontSize],[dt.FREETEXT_COLOR,Ut._defaultColor||Mt._defaultLineColor]]}get propertiesToUpdate(){return[[dt.FREETEXT_SIZE,r(this,Ns)],[dt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new hp(this)),[["colorPicker",this._colorPicker]]}get colorType(){return dt.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-Ut._internalPadding*e,-(Ut._internalPadding+r(this,Ns))*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,tl,new AbortController);const e=this._uiManager.combinedSignal(r(this,tl));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",r(this,Od)),this._isDraggable=!0,(e=r(this,tl))==null||e.abort(),p(this,tl,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=r(this,Ls),s=p(this,Ls,b(this,me,fA).call(this).trimEnd());if(e===s)return;const i=n=>{if(p(this,Ls,n),!n){this.remove();return}b(this,me,Xf).call(this),this._uiManager.rebuild(this),b(this,me,Vf).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),b(this,me,Vf).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){Ut._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,s;(this._isCopy||this.annotationElementId)&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",r(this,Od)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${r(this,Ns)}px * var(--total-scale-factor))`,i.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[n,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[h,d]=this.pageDimensions,[f,g]=this.pageTranslation;let m,v;switch(this.rotation){case 0:m=e+(o[0]-f)/h,v=s+this.height-(o[1]-g)/d;break;case 90:m=e+(o[0]-f)/h,v=s-(o[1]-g)/d,[l,c]=[c,-l];break;case 180:m=e-this.width+(o[0]-f)/h,v=s-(o[1]-g)/d,[l,c]=[-l,-c];break;case 270:m=e+(o[0]-f-this.height*d)/h,v=s+(o[1]-g-this.width*h)/d,[l,c]=[-c,l];break}this.setAt(m*n,v*a,l,c)}else this._moveAfterPaste(e,s);b(this,me,Xf).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var m,v,w;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const n=b(m=Ut,pn,qm).call(m,s.getData("text")||"").replaceAll(mf,`
50
+ `);if(!n)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!n.includes(`
51
+ `)){o.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:c}=o,h=[],d=[];if(l.nodeType===Node.TEXT_NODE){const A=l.parentElement;if(d.push(l.nodeValue.slice(c).replaceAll(mf,"")),A!==this.editorDiv){let _=h;for(const E of this.editorDiv.childNodes){if(E===A){_=d;continue}_.push(b(v=Ut,pn,Wf).call(v,E))}}h.push(l.nodeValue.slice(0,c).replaceAll(mf,""))}else if(l===this.editorDiv){let A=h,_=0;for(const E of this.editorDiv.childNodes)_++===c&&(A=d),A.push(b(w=Ut,pn,Wf).call(w,E))}p(this,Ls,`${h.join(`
52
+ `)}${n}${d.join(`
53
+ `)}`),b(this,me,Xf).call(this);const f=new Range;let g=Math.sumPrecise(h.map(A=>A.length));for(const{firstChild:A}of this.editorDiv.childNodes)if(A.nodeType===Node.TEXT_NODE){const _=A.nodeValue.length;if(g<=_){f.setStart(A,g),f.setEnd(A,g);break}g-=_}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=Ut._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,i){var o;let n=null;if(e instanceof nA){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:h,rotation:d,id:f,popupRef:g,richText:m,contentsObj:v,creationDate:w,modificationDate:A},textContent:_,textPosition:E,parent:{page:{pageNumber:S}}}=e;if(!(_!=null&&_.length))return null;n=e={annotationType:rt.FREETEXT,color:Array.from(c),fontSize:l,value:_.join(`
54
+ `),position:E,pageIndex:S-1,rect:h.slice(0),rotation:d,annotationElementId:f,id:f,deleted:!1,popupRef:g,comment:(v==null?void 0:v.str)||null,richText:m,creationDate:w,modificationDate:A}}const a=await super.deserialize(e,s,i);return p(a,Ns,e.fontSize),a.color=$.makeHexColor(...e.color),p(a,Ls,b(o=Ut,pn,qm).call(o,e.value)),a._initialData=n,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Mt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(e),{color:s,fontSize:r(this,Ns),value:b(this,me,pA).call(this)});return this.addComment(i),e?(i.isCopy=!0,i):this.annotationElementId&&!b(this,me,gA).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(!s)return null;const{style:i}=s;i.fontSize=`calc(${r(this,Ns)}px * var(--total-scale-factor))`,i.color=this.color,s.replaceChildren();for(const n of r(this,Ls).split(`
55
+ `)){const a=document.createElement("div");a.append(n?document.createTextNode(n):document.createElement("br")),s.append(a)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:r(this,Ls)}}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};Ls=new WeakMap,Od=new WeakMap,tl=new WeakMap,Ns=new WeakMap,me=new WeakSet,uA=function(e){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--total-scale-factor))`,this.translate(0,-(n-r(this,Ns))*this.parentScale),p(this,Ns,n),b(this,me,Vf).call(this)},i=r(this,Ns);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},dA=function(e){const s=n=>{this.color=n,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},fA=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const n of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&n.nodeName==="BR"||(e.push(b(i=Ut,pn,Wf).call(i,n)),s=n);return e.join(`
56
+ `)},Vf=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:n,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",n.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},pn=new WeakSet,Wf=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(mf,"")},Xf=function(){if(this.editorDiv.replaceChildren(),!!r(this,Ls))for(const e of r(this,Ls).split(`
57
+ `)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},pA=function(){return r(this,Ls).replaceAll(" "," ")},qm=function(e){return e.replaceAll(" "," ")},gA=function(e){const{value:s,fontSize:i,color:n,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==n[l])||e.pageIndex!==a},y(Ut,pn),O(Ut,"_freeTextDefaultContent",""),O(Ut,"_internalPadding",0),O(Ut,"_defaultColor",null),O(Ut,"_defaultFontSize",10),O(Ut,"_type","freetext"),O(Ut,"_editorType",rt.FREETEXT);let Km=Ut;var el;class Zv{constructor(){y(this,el,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){r(this,el)[t]=e}toSVGProperties(){const t=r(this,el);return p(this,el,Object.create(null)),{root:t}}reset(){p(this,el,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){vt("Not implemented")}}el=new WeakMap;var qc,Jc,fe,sl,il,Qc,Z,Jm,Qm,Zm,tv,Yh,ev,sv,iv,Kh,mA,Yf,qh,Ll;const ot=class ot extends Mt{constructor(e){super(e);y(this,Z);y(this,qc,null);y(this,Jc);O(this,"_clipPathId",null);O(this,"_colorPicker",null);O(this,"_drawId",null);O(this,"_drawOutlines",null);O(this,"_focusDrawId",null);p(this,Jc,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var e,s;(s=(e=this._colorPicker)==null?void 0:e.updateOpacity)==null||s.call(e,this.opacity)}_addOutlines(e){e.drawOutlines&&(b(this,Z,Jm).call(this,e),b(this,Z,Kh).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[n,a]of Object.entries(s))i.has(n)?Object.assign(e[n],a):e[n]=a;return e}static getDefaultDrawingOptions(e){vt("Not implemented")}static get typesMap(){vt("Not implemented")}static get isDrawer(){return!0}static get _hasClipPath(){return!1}static get _hasDrawClass(){return!0}static get supportMultipleDrawings(){return!1}get _drawRotation(){return this.rotation}get _opacityName(){return this.constructor.typesMap.get(this.opacityType)}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(r(ot,fe).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,n]of this.typesMap)e.push([i,s[n]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,n]of this.constructor.typesMap)e.push([i,s[n]]);return e}_updateProperty(e,s,i){const n=this._drawingOptions,a=n[s],o=l=>{var h;n.updateProperty(s,l);const c=this._drawOutlines.updateProperty(s,l);c&&b(this,Z,qh).call(this,c),(h=this.parent)==null||h.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,s,i=this.colorAndOpacityType){const n=this.constructor.typesMap.get(this.colorType),a=this._opacityName,o=this._drawingOptions,l=o[n],c=o[a],h=(d,f)=>{var g;o.updateProperty(n,d),o.updateProperty(a,f),this._drawOutlines.updateProperty(n,d),this._drawOutlines.updateProperty(a,f),(g=this.parent)==null||g.drawLayer.updateProperties(this._drawId,o.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:h.bind(this,e,s),undo:h.bind(this,l,c),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,ot._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(b(this,Z,Yf).call(this)),{bbox:b(this,Z,Ll).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,ot._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(b(this,Z,Yf).call(this)),{bbox:b(this,Z,Ll).call(this)})),b(this,Z,tv).call(this)}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,Z,Ll).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,ot._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(b(this,Z,Yf).call(this),this.parentDimensions),{bbox:b(this,Z,Ll).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}})}get _mustBeDisabledOnCommit(){return!0}commit(){super.commit(),this._mustBeDisabledOnCommit&&(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,r(this,Jc)&&(p(this,Jc,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this._uiManager.removeShouldRescale(this),b(this,Z,iv).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,Z,Kh).call(this),b(this,Z,qh).call(this,this._drawOutlines.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,Z,iv).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,Z,Kh).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),b(this,Z,ev).call(this),s&&this.select()}rotate(e=this.parentRotation){if(!this.parent||this._drawId===null)return;const s=(e-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,ot._mergeSVGProperties({bbox:b(this,Z,Ll).call(this,e)},this._drawOutlines.updateRotation(s))),b(this,Z,tv).call(this,s)}show(e=this._isVisible){super.show(e),b(this,Z,ev).call(this)}select(){super.select(),b(this,Z,Yh).call(this,{hovered:!1,selected:!0})}unselect(){super.unselect(),b(this,Z,Yh).call(this,{selected:!1})}pointerover(){this.isSelected||b(this,Z,Yh).call(this,{hovered:!0})}pointerleave(){this.isSelected||b(this,Z,Yh).call(this,{hovered:!1})}onScaleChanging(){if(!this.parent)return;const e=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);e&&b(this,Z,qh).call(this,e)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();this.constructor._hasDrawClass&&i.classList.add("draw");const n=p(this,qc,document.createElement("div"));return i.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",this._clipPathId&&(n.style.clipPath=this._clipPathId),Fb(this,n,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e){vt("Not implemented")}static _getDrawingTarget(e,{target:s}){return s}static _getPointerCoords({offsetX:e,offsetY:s,clientX:i,clientY:n},a=null){if(!a)return[e,s];let o=i-a.clientX,l=n-a.clientY;switch(this._currentParent.viewport.rotation){case 90:[o,l]=[l,-o];break;case 180:[o,l]=[-o,-l];break;case 270:[o,l]=[-l,o];break}return[a.offsetX+o,a.offsetY+l]}static _addDrawingListeners(e,s){}static _endDrawingSession(e=!1){return this._currentParent.endDrawingSession(e)}static startDrawing(e,s,i,n){var S;const{pointerId:a,pointerType:o}=n;if(ze.isInitializedAndDifferentPointerType(o))return;const l=this._getDrawingTarget(e,n),[c,h]=this._getPointerCoords(n),{viewport:{rotation:d}}=e,{x:f,y:g,width:m,height:v}=l.getBoundingClientRect(),w=p(ot,sl,new AbortController),A=e.combinedSignal(w);if(ze.setPointer(o,a),window.addEventListener("pointerup",x=>{ze.isSamePointerIdOrRemove(x.pointerId)&&this._endDraw(x)},{signal:A}),window.addEventListener("pointercancel",x=>{ze.isSamePointerIdOrRemove(x.pointerId)&&this._endDrawingSession()},{signal:A}),window.addEventListener("pointerdown",x=>{ze.isSamePointerType(x.pointerType)&&(ze.initializeAndAddPointerId(x.pointerId),r(ot,fe).isCancellable()&&(r(ot,fe).removeLastElement(),r(ot,fe).isEmpty()?this._endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:A}),window.addEventListener("contextmenu",Li,{signal:A}),l.addEventListener("pointermove",this._drawMove.bind(this),{signal:A}),l.addEventListener("touchmove",x=>{ze.isSameTimeStamp(x.timeStamp)&&Ae(x)},{signal:A}),this._addDrawingListeners(l,A),e.toggleDrawing(),(S=s._editorUndoBar)==null||S.hide(),r(ot,fe)){e.drawLayer.updateProperties(this._currentDrawId,r(ot,fe).startNew(c,h,m,v,d));return}s.updateUIForDefaultProperties(this),p(ot,fe,this.createDrawerInstance({x:c,y:h,box:[f,g,m,v],rotation:d,parent:e,isLTR:i})),p(ot,il,this.getDefaultDrawingOptions()),this._currentParent=e;const{id:_,clipPathId:E}=e.drawLayer.draw(this._mergeSVGProperties(r(ot,il).toSVGProperties(),r(ot,fe).defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=_,p(ot,Qc,this._hasClipPath?E:null)}static _drawMove(e){var n;if(ze.isSameTimeStamp(e.timeStamp),!r(ot,fe)||!ze.isSamePointerId(e.pointerId))return;if(ze.isUsingMultiplePointers()){this._endDraw(e);return}let s;const i=(n=e.getCoalescedEvents)==null?void 0:n.call(e);if(i!=null&&i.length){const a=[];for(const o of i)a.push(...this._getPointerCoords(o,e));s=r(ot,fe).addPoints(a)}else s=r(ot,fe).add(...this._getPointerCoords(e));this._currentParent.drawLayer.updateProperties(this._currentDrawId,s),ze.setTimeStamp(e.timeStamp),Ae(e)}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,p(ot,fe,null),p(ot,il,null),p(ot,Qc,null),ze.clearTimeStamp()),r(ot,sl)&&(r(ot,sl).abort(),p(ot,sl,null),ze.clearPointerIds())}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),s.drawLayer.updateProperties(this._currentDrawId,(e==null?void 0:e.target)===s.div?r(ot,fe).end(...this._getPointerCoords(e)):r(ot,fe).end()),this.supportMultipleDrawings){const i=r(ot,fe),n=this._currentDrawId,a=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(n,i.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(n,i.removeLastElement())},mustExec:!1,type:dt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(dt.DRAW_STEP),!r(ot,fe).isEmpty()){const{pageDimensions:[i,n],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:r(ot,Qc),drawOutlines:r(ot,fe).getOutlines(i*a,n*a,a,this._INNER_MARGIN),drawingOptions:r(ot,il),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,n,a,o,l){vt("Not implemented")}static async deserialize(e,s,i){var d,f;const{rawDims:{pageWidth:n,pageHeight:a,pageX:o,pageY:l}}=s.viewport,c=this.deserializeDraw(o,l,n,a,this._INNER_MARGIN,e,i),h=await super.deserialize(e,s,i);return h.createDrawingOptions(e),b(d=h,Z,Jm).call(d,{drawOutlines:c}),b(f=h,Z,Kh).call(f),h.onScaleChanging(),h.rotate(),h}serializeDraw(e){const[s,i]=this.pageTranslation,[n,a]=this.pageDimensions;return this._drawOutlines.serialize([s,i,n,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};qc=new WeakMap,Jc=new WeakMap,fe=new WeakMap,sl=new WeakMap,il=new WeakMap,Qc=new WeakMap,Z=new WeakSet,Jm=function({drawOutlines:e,drawId:s,drawingOptions:i,clipPathId:n}){this._drawOutlines=e,this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(Mt._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this._clipPathId=n??null,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties),b(this,Z,Zm).call(this,this.parent)):this._drawId=b(this,Z,Qm).call(this,e,this.parent),b(this,Z,qh).call(this,e.box)},Qm=function(e,s){const{id:i,clipPathId:n}=s.drawLayer.draw(ot._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,this.constructor._hasClipPath);return this.constructor._hasClipPath&&(this._clipPathId=n),b(this,Z,Zm).call(this,s),i},Zm=function(e){const s=this._drawOutlines.getFocusSVGProperties(r(this,Z,sv));s&&(this._focusDrawId=e.drawLayer.drawOutline(s,this._drawOutlines.focusMustRemoveSelfIntersections))},tv=function(e=r(this,Z,sv)){var s;this._focusDrawId!==null&&((s=this.parent)==null||s.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(e)))},Yh=function(e){var s;this._focusDrawId!==null&&((s=this.parent)==null||s.drawLayer.updateProperties(this._focusDrawId,{rootClass:e}))},ev=function(){const{parent:e,_drawId:s,_focusDrawId:i,_isVisible:n}=this;if(!e||s===null)return;const a={hidden:!n};e.drawLayer.updateProperties(s,{rootClass:a}),i!==null&&e.drawLayer.updateProperties(i,{rootClass:a})},sv=function(){return(this.parentRotation-this._drawRotation+360)%360},iv=function(){if(this._drawId===null||!this.parent)return;const{drawLayer:e}=this.parent;e.remove(this._drawId),this._drawId=null,this._focusDrawId!==null&&(e.remove(this._focusDrawId),this._focusDrawId=null),this._drawingOptions.reset()},Kh=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){const{drawLayer:s}=this.parent;s.updateParent(this._drawId,e.drawLayer),this._focusDrawId!==null&&s.updateParent(this._focusDrawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,Z,Qm).call(this,this._drawOutlines,e),this._clipPathId&&r(this,qc)&&(r(this,qc).style.clipPath=this._clipPathId)}},mA=function([e,s,i,n]){const{parentDimensions:[a,o],_drawRotation:l}=this;switch(l){case 90:return[s,1-e,i*(o/a),n*(a/o)];case 180:return[1-e,1-s,i,n];case 270:return[1-s,e,i*(o/a),n*(a/o)];default:return[e,s,i,n]}},Yf=function(){const{x:e,y:s,width:i,height:n,parentDimensions:[a,o],_drawRotation:l}=this;switch(l){case 90:return[1-s,e,i*(a/o),n*(o/a)];case 180:return[1-e,1-s,i,n];case 270:return[s,1-e,i*(a/o),n*(o/a)];default:return[e,s,i,n]}},qh=function(e){[this.x,this.y,this.width,this.height]=b(this,Z,mA).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},Ll=function(e=this.parentRotation){const{x:s,y:i,width:n,height:a,_drawRotation:o,parentDimensions:[l,c]}=this;switch((o*4+e)/90){case 1:return[1-i-a,s,a,n];case 2:return[1-s-n,1-i-a,n,a];case 3:return[i,1-s-n,a,n];case 4:return[s,i-n*(l/c),a*(c/l),n*(l/c)];case 5:return[1-i,s,n*(l/c),a*(c/l)];case 6:return[1-s-a*(c/l),1-i,a*(c/l),n*(l/c)];case 7:return[i-n*(l/c),1-s-a*(c/l),n*(l/c),a*(c/l)];case 8:return[s-n,i-a,n,a];case 9:return[1-i,s-n,a,n];case 10:return[1-s,1-i,n,a];case 11:return[i-a,1-s,a,n];case 12:return[s-a*(c/l),i,a*(c/l),n*(l/c)];case 13:return[1-i-n*(l/c),s-a*(c/l),n*(l/c),a*(c/l)];case 14:return[1-s,1-i-n*(l/c),a*(c/l),n*(l/c)];case 15:return[i,1-s,n*(l/c),a*(c/l)];default:return[s,i,n,a]}},O(ot,"_currentDrawId",-1),O(ot,"_currentParent",null),y(ot,fe,null),y(ot,sl,null),y(ot,il,null),y(ot,Qc,null),O(ot,"_INNER_MARGIN",3);let uu=ot;class Y{constructor(){O(this,"focusOutline",null)}toSVGPath(){vt("Abstract method `toSVGPath` must be implemented.")}get box(){vt("Abstract getter `box` must be implemented.")}serialize(t,e){vt("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){vt("Abstract getter `defaultSVGProperties` must be implemented.")}get defaultProperties(){return this.defaultSVGProperties}getFocusSVGProperties(t){return null}get focusMustRemoveSelfIntersections(){return!1}updateProperty(t,e){return null}updateParentDimensions(t,e){return null}serializeQuadPoints(t,e){return null}updateRotation(t){return{}}getPathResizingSVGProperties(t){return{}}getPathResizedSVGProperties(t){return{}}getPathTranslatedSVGProperties(t,e){return{}}static _rotateBox([t,e,s,i],n){switch(n){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}static _rescale(t,e,s,i,n,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*i,a[o+1]=s+t[o+1]*n;return a}static _rescaleAndSwap(t,e,s,i,n,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o+1]*i,a[o+1]=s+t[o]*n;return a}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let n=0,a=t.length;n<a;n+=2)i[n]=e+t[n],i[n+1]=s+t[n+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,n){switch(n){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static createBezierPoints(t,e,s,i,n,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+a)/6,(s+n)/2,(i+a)/2]}}O(Y,"PRECISION",1e-4);var Bs,ci,Zc,th,ki,ct,rl,nl,Rd,Dd,eh,sh,cr,Fd,Fp,Lp,_e,Jh,vA,yA,bA,wA,AA,_A;const Cr=class Cr{constructor(t,e,s,i,n,a,o=0){y(this,_e);y(this,Bs);y(this,ci,[]);y(this,Zc);y(this,th);y(this,ki,[]);y(this,ct,new Float32Array(18));y(this,rl);y(this,nl);y(this,Rd);y(this,Dd);y(this,eh);y(this,sh);y(this,cr,[]);p(this,Bs,s),p(this,sh,n*i),p(this,th,a),r(this,ct).set([NaN,NaN,NaN,NaN,t,e],6),p(this,Zc,o),p(this,Dd,r(Cr,Fd)*i),p(this,Rd,r(Cr,Lp)*i),p(this,eh,i),r(this,cr).push(t,e)}isEmpty(){return isNaN(r(this,ct)[8])}isCancellable(){return r(this,cr).length<=10}removeLastElement(){return r(this,ct).fill(NaN),r(this,ki).length=r(this,ci).length=r(this,cr).length=0,{path:{d:""}}}add(t,e){var k;p(this,rl,t),p(this,nl,e);const[s,i,n,a]=r(this,Bs);let[o,l,c,h]=r(this,ct).subarray(8,12);const d=t-c,f=e-h,g=Math.hypot(d,f);if(g<r(this,Rd))return!1;const m=g-r(this,Dd),v=m/g,w=v*d,A=v*f;let _=o,E=l;o=c,l=h,c+=w,h+=A,(k=r(this,cr))==null||k.push(t,e);const S=-A/m,x=w/m,T=S*r(this,sh),C=x*r(this,sh);return r(this,ct).set(r(this,ct).subarray(2,8),0),r(this,ct).set([c+T,h+C],4),r(this,ct).set(r(this,ct).subarray(14,18),12),r(this,ct).set([c-T,h-C],16),isNaN(r(this,ct)[6])?(r(this,ki).length===0&&(r(this,ct).set([o+T,l+C],2),r(this,ki).push(NaN,NaN,NaN,NaN,(o+T-s)/n,(l+C-i)/a),r(this,ct).set([o-T,l-C],14),r(this,ci).push(NaN,NaN,NaN,NaN,(o-T-s)/n,(l-C-i)/a)),r(this,ct).set([_,E,o,l,c,h],6),!this.isEmpty()):(r(this,ct).set([_,E,o,l,c,h],6),Math.abs(Math.atan2(E-l,_-o)-Math.atan2(A,w))<Math.PI/2?([o,l,c,h]=r(this,ct).subarray(2,6),r(this,ki).push(NaN,NaN,NaN,NaN,((o+c)/2-s)/n,((l+h)/2-i)/a),[o,l,_,E]=r(this,ct).subarray(14,18),r(this,ci).push(NaN,NaN,NaN,NaN,((_+o)/2-s)/n,((E+l)/2-i)/a),!0):([_,E,o,l,c,h]=r(this,ct).subarray(0,6),r(this,ki).push(((_+5*o)/6-s)/n,((E+5*l)/6-i)/a,((5*o+c)/6-s)/n,((5*l+h)/6-i)/a,((o+c)/2-s)/n,((l+h)/2-i)/a),[c,h,o,l,_,E]=r(this,ct).subarray(12,18),r(this,ci).push(((_+5*o)/6-s)/n,((E+5*l)/6-i)/a,((5*o+c)/6-s)/n,((5*l+h)/6-i)/a,((o+c)/2-s)/n,((l+h)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=r(this,ki),e=r(this,ci);if(isNaN(r(this,ct)[6])&&!this.isEmpty())return b(this,_e,vA).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);b(this,_e,bA).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return b(this,_e,yA).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,a){return new SA(t,e,s,i,n,a)}getOutlines(){var d;const t=r(this,ki),e=r(this,ci),s=r(this,ct),[i,n,a,o]=r(this,Bs),l=new Float32Array((((d=r(this,cr))==null?void 0:d.length)??0)+2);for(let f=0,g=l.length-2;f<g;f+=2)l[f]=(r(this,cr)[f]-i)/a,l[f+1]=(r(this,cr)[f+1]-n)/o;if(l[l.length-2]=(r(this,rl)-i)/a,l[l.length-1]=(r(this,nl)-n)/o,isNaN(s[6])&&!this.isEmpty())return b(this,_e,wA).call(this,l);const c=new Float32Array(r(this,ki).length+24+r(this,ci).length);let h=t.length;for(let f=0;f<h;f+=2){if(isNaN(t[f])){c[f]=c[f+1]=NaN;continue}c[f]=t[f],c[f+1]=t[f+1]}h=b(this,_e,_A).call(this,c,h);for(let f=e.length-6;f>=6;f-=6)for(let g=0;g<6;g+=2){if(isNaN(e[f+g])){c[h]=c[h+1]=NaN,h+=2;continue}c[h]=e[f+g],c[h+1]=e[f+g+1],h+=2}return b(this,_e,AA).call(this,c,h),this.newFreeDrawOutline(c,l,r(this,Bs),r(this,eh),r(this,Zc),r(this,th))}};Bs=new WeakMap,ci=new WeakMap,Zc=new WeakMap,th=new WeakMap,ki=new WeakMap,ct=new WeakMap,rl=new WeakMap,nl=new WeakMap,Rd=new WeakMap,Dd=new WeakMap,eh=new WeakMap,sh=new WeakMap,cr=new WeakMap,Fd=new WeakMap,Fp=new WeakMap,Lp=new WeakMap,_e=new WeakSet,Jh=function(){const t=r(this,ct).subarray(4,6),e=r(this,ct).subarray(16,18),[s,i,n,a]=r(this,Bs);return[(r(this,rl)+(t[0]-e[0])/2-s)/n,(r(this,nl)+(t[1]-e[1])/2-i)/a,(r(this,rl)+(e[0]-t[0])/2-s)/n,(r(this,nl)+(e[1]-t[1])/2-i)/a]},vA=function(){const[t,e,s,i]=r(this,Bs),[n,a,o,l]=b(this,_e,Jh).call(this);return`M${(r(this,ct)[2]-t)/s} ${(r(this,ct)[3]-e)/i} L${(r(this,ct)[4]-t)/s} ${(r(this,ct)[5]-e)/i} L${n} ${a} L${o} ${l} L${(r(this,ct)[16]-t)/s} ${(r(this,ct)[17]-e)/i} L${(r(this,ct)[14]-t)/s} ${(r(this,ct)[15]-e)/i} Z`},yA=function(t){const e=r(this,ci);t.push(`L${e[4]} ${e[5]} Z`)},bA=function(t){const[e,s,i,n]=r(this,Bs),a=r(this,ct).subarray(4,6),o=r(this,ct).subarray(16,18),[l,c,h,d]=b(this,_e,Jh).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/n} L${l} ${c} L${h} ${d} L${(o[0]-e)/i} ${(o[1]-s)/n}`)},wA=function(t){const e=r(this,ct),[s,i,n,a]=r(this,Bs),[o,l,c,h]=b(this,_e,Jh).call(this),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/a],0),this.newFreeDrawOutline(d,t,r(this,Bs),r(this,eh),r(this,Zc),r(this,th))},AA=function(t,e){const s=r(this,ci);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},_A=function(t,e){const s=r(this,ct).subarray(4,6),i=r(this,ct).subarray(16,18),[n,a,o,l]=r(this,Bs),[c,h,d,f]=b(this,_e,Jh).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,d,f,NaN,NaN,NaN,NaN,(i[0]-n)/o,(i[1]-a)/l],e),e+=24},y(Cr,Fd,8),y(Cr,Fp,2),y(Cr,Lp,r(Cr,Fd)+r(Cr,Fp));let dp=Cr;var ih,hr,rn,Ld,Mi,Nd,Zt,Np,EA;class SA extends Y{constructor(e,s,i,n,a,o){super();y(this,Np);y(this,ih);y(this,hr,new Float32Array(4));y(this,rn);y(this,Ld);y(this,Mi);y(this,Nd);y(this,Zt);p(this,Zt,e),p(this,Mi,s),p(this,ih,i),p(this,Nd,n),p(this,rn,a),p(this,Ld,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,Np,EA).call(this,o);const[l,c,h,d]=r(this,hr);for(let f=0,g=e.length;f<g;f+=2)e[f]=(e[f]-l)/h,e[f+1]=(e[f+1]-c)/d;for(let f=0,g=s.length;f<g;f+=2)s[f]=(s[f]-l)/h,s[f+1]=(s[f+1]-c)/d}toSVGPath(){const e=[`M${r(this,Zt)[4]} ${r(this,Zt)[5]}`];for(let s=6,i=r(this,Zt).length;s<i;s+=6){if(isNaN(r(this,Zt)[s])){e.push(`L${r(this,Zt)[s+4]} ${r(this,Zt)[s+5]}`);continue}e.push(`C${r(this,Zt)[s]} ${r(this,Zt)[s+1]} ${r(this,Zt)[s+2]} ${r(this,Zt)[s+3]} ${r(this,Zt)[s+4]} ${r(this,Zt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,n],a){const o=i-e,l=n-s;let c,h;switch(a){case 0:c=Y._rescale(r(this,Zt),e,n,o,-l),h=Y._rescale(r(this,Mi),e,n,o,-l);break;case 90:c=Y._rescaleAndSwap(r(this,Zt),e,s,o,l),h=Y._rescaleAndSwap(r(this,Mi),e,s,o,l);break;case 180:c=Y._rescale(r(this,Zt),i,s,-o,l),h=Y._rescale(r(this,Mi),i,s,-o,l);break;case 270:c=Y._rescaleAndSwap(r(this,Zt),i,n,-o,-l),h=Y._rescaleAndSwap(r(this,Mi),i,n,-o,-l);break}return{outline:Array.from(c),points:[Array.from(h)]}}get box(){return r(this,hr)}newOutliner(e,s,i,n,a,o,l=0){return new dp(e,s,i,n,a,o,l)}updateThickness(e){const s=this.getNewOutline(e);return p(this,Zt,r(s,Zt)),p(this,Mi,r(s,Mi)),r(this,hr).set(r(s,hr)),this.firstPoint=s.firstPoint,this.lastPoint=s.lastPoint,r(this,hr)}getNewOutline(e,s){const[i,n,a,o]=r(this,hr),[l,c,h,d]=r(this,ih),f=a*h,g=o*d,m=i*h+l,v=n*d+c,w=r(this,Mi),A=this.newOutliner(w[0]*f+m,w[1]*g+v,r(this,ih),r(this,Nd),e,r(this,Ld),s??r(this,rn));for(let _=2,E=w.length;_<E;_+=2)A.add(w[_]*f+m,w[_+1]*g+v);return A.getOutlines()}}ih=new WeakMap,hr=new WeakMap,rn=new WeakMap,Ld=new WeakMap,Mi=new WeakMap,Nd=new WeakMap,Zt=new WeakMap,Np=new WeakSet,EA=function(e){const s=r(this,Zt);let i=s[4],n=s[5];const a=[i,n,i,n];let o=i,l=n,c=i,h=n;const d=e?Math.max:Math.min,f=new Float32Array(4);for(let m=6,v=s.length;m<v;m+=6){const w=s[m+4],A=s[m+5];isNaN(s[m])?($.pointBoundingBox(w,A,a),l>A?(o=w,l=A):l===A&&(o=d(o,w)),h<A?(c=w,h=A):h===A&&(c=d(c,w))):(f.set(yr,0),$.bezierBoundingBox(i,n,...s.slice(m,m+6),f),$.rectBoundingBox(...f,a),l>f[1]?(o=f[0],l=f[1]):l===f[1]&&(o=d(o,f[0])),h<f[3]?(c=f[2],h=f[3]):h===f[3]&&(c=d(c,f[2]))),i=w,n=A}const g=r(this,hr);g[0]=a[0]-r(this,rn),g[1]=a[1]-r(this,rn),g[2]=a[2]-a[0]+2*r(this,rn),g[3]=a[3]-a[1]+2*r(this,rn),this.firstPoint=[o,l],this.lastPoint=[c,h]};function xA(u){return{bbox:u.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:u.isFree},path:{d:u.toSVGPath()}}}function TA(u,t){const{focusOutline:e}=u;return{bbox:Y._rotateBox(e.box,t),root:{"data-main-rotation":t},rootClass:{highlightOutline:!0,free:u.isFree},path:{d:e.toSVGPath()}}}var Bd,Ud,Hd,ua,Oi,ls,CA,Kf,PA,IA,nv;class rv{constructor(t,e=0,s=0,i=!0){y(this,ls);y(this,Bd);y(this,Ud);y(this,Hd);y(this,ua,[]);y(this,Oi,[]);const n=yr.slice(),a=10**-4;for(const{x:v,y:w,width:A,height:_}of t){const E=Math.floor((v-e)/a)*a,S=Math.ceil((v+A+e)/a)*a,x=Math.floor((w-e)/a)*a,T=Math.ceil((w+_+e)/a)*a,C=[E,x,T,!0],I=[S,x,T,!1];r(this,ua).push(C,I),$.rectBoundingBox(E,x,S,T,n)}const o=n[2]-n[0]+2*s,l=n[3]-n[1]+2*s,c=n[0]-s,h=n[1]-s;let d=i?-1/0:1/0,f=1/0;const g=r(this,ua).at(i?-1:-2),m=[g[0],g[2]];for(const v of r(this,ua)){const[w,A,_,E]=v;!E&&i?A<f?(f=A,d=w):A===f&&(d=Math.max(d,w)):E&&!i&&(A<f?(f=A,d=w):A===f&&(d=Math.min(d,w))),v[0]=(w-c)/o,v[1]=(A-h)/l,v[2]=(_-h)/l}p(this,Bd,new Float32Array([c,h,o,l])),p(this,Ud,[d,f]),p(this,Hd,m)}getOutlines(){r(this,ua).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of r(this,ua))e[3]?(t.push(...b(this,ls,nv).call(this,e)),b(this,ls,PA).call(this,e)):(b(this,ls,IA).call(this,e),t.push(...b(this,ls,nv).call(this,e)));return b(this,ls,CA).call(this,t)}}Bd=new WeakMap,Ud=new WeakMap,Hd=new WeakMap,ua=new WeakMap,Oi=new WeakMap,ls=new WeakSet,CA=function(t){const e=[],s=new Set;for(const n of t){const[a,o,l]=n;e.push([a,o,n],[a,l,n])}e.sort((n,a)=>n[1]-a[1]||n[0]-a[0]);for(let n=0,a=e.length;n<a;n+=2){const o=e[n][2],l=e[n+1][2];o.push(l),l.push(o),s.add(o),s.add(l)}const i=[];for(;s.size>0;){const n=s.values().next().value;let[a,o,l,c,h]=n;s.delete(n);let d=a,f=o;const g=[a,l];for(i.push(g);;){let m;if(s.has(c))m=c;else if(s.has(h))m=h;else break;s.delete(m),[a,o,l,c,h]=m,d!==a&&(g.push(d,f,a,f===o?o:l),d=a),f=f===o?l:o}g.push(d,f)}return new av(i,r(this,Bd),r(this,Ud),r(this,Hd))},Kf=function(t){const e=r(this,Oi);let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,a=e[n][0];if(a===t)return n;a<t?s=n+1:i=n-1}return i+1},PA=function([,t,e]){const s=b(this,ls,Kf).call(this,t);r(this,Oi).splice(s,0,[t,e])},IA=function([,t,e]){const s=b(this,ls,Kf).call(this,t);for(let i=s;i<r(this,Oi).length;i++){const[n,a]=r(this,Oi)[i];if(n!==t)break;if(n===t&&a===e){r(this,Oi).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[n,a]=r(this,Oi)[i];if(n!==t)break;if(n===t&&a===e){r(this,Oi).splice(i,1);return}}},nv=function(t){const[e,s,i]=t,n=[[e,s,i]],a=b(this,ls,Kf).call(this,i);for(let o=0;o<a;o++){const[l,c]=r(this,Oi)[o];for(let h=0,d=n.length;h<d;h++){const[,f,g]=n[h];if(!(c<=f||g<=l)){if(f>=l){if(g>c)n[h][1]=c;else{if(d===1)return[];n.splice(h,1),h--,d--}continue}n[h][2]=l,g>c&&n.push([e,c,g])}}}return n};var jd,$d,rh;class av extends Y{constructor(e,s,i,n){super();y(this,jd);y(this,$d,null);y(this,rh);p(this,rh,e),p(this,jd,s),this.firstPoint=i,this.lastPoint=n}static build(e,s){const i=new rv(e,.001).getOutlines();return p(i,$d,e),i.focusOutline=new rv(e,.0025,.001,s).getOutlines(),i}get isFree(){return!1}get defaultSVGProperties(){return xA(this)}getFocusSVGProperties(e){return TA(this,e)}updateRotation(e){return{root:{"data-main-rotation":e}}}serializeQuadPoints([e,s],[i,n]){const a=r(this,$d),o=new Float32Array(a.length*8);let l=0;for(const{x:c,y:h,width:d,height:f}of a){const g=c*i+e,m=(1-h)*n+s;o[l]=o[l+4]=g,o[l+1]=o[l+3]=m,o[l+2]=o[l+6]=g+d*i,o[l+5]=o[l+7]=m-f*n,l+=8}return o}toSVGPath(){const e=[];for(const s of r(this,rh)){let[i,n]=s;e.push(`M${i} ${n}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),n=l):l===n&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,n],a){const o=[],l=i-e,c=n-s;for(const h of r(this,rh)){const d=new Array(h.length);for(let f=0;f<h.length;f+=2)d[f]=e+h[f]*l,d[f+1]=n-h[f+1]*c;o.push(d)}return o}get box(){return r(this,jd)}}jd=new WeakMap,$d=new WeakMap,rh=new WeakMap;class ty extends dp{newFreeDrawOutline(t,e,s,i,n,a){return new ov(t,e,s,i,n,a)}}var Us,Gd;class ex{constructor(t,e,s,i,n,a,o){y(this,Us);y(this,Gd);p(this,Us,new ty(t,e,s,i,n,a,o)),p(this,Gd,n)}add(t,e){return r(this,Us).add(t,e)?{path:{d:r(this,Us).toSVGPath()}}:null}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)e=r(this,Us).add(t[s],t[s+1])||e;return e?{path:{d:r(this,Us).toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return r(this,Us).isEmpty()}isCancellable(){return r(this,Us).isCancellable()}removeLastElement(){return r(this,Us).removeLastElement()}updateProperty(t,e){return null}getOutlines(){const t=r(this,Us).getOutlines();return t.buildFocusOutline(2*r(this,Gd)),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:r(this,Us).toSVGPath()}}}}Us=new WeakMap,Gd=new WeakMap;var Bp;const Up=class Up extends SA{newOutliner(t,e,s,i,n,a,o=0){return new ty(t,e,s,i,n,a,o)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+r(Up,Bp),.0025)}get defaultSVGProperties(){return xA(this)}getFocusSVGProperties(t){return TA(this,t)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(t){return{root:{"data-main-rotation":t}}}updateProperty(t,e){if(t!=="thickness")return null;const s=this.updateThickness(e/2);return this.buildFocusOutline(e),s}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}};Bp=new WeakMap,y(Up,Bp,1.5);let ov=Up;class ey extends Zv{constructor(t=null){super(),super.updateProperties(t)}updateSVGProperty(t,e){t!=="thickness"&&super.updateSVGProperty(t,e)}clone(){const t=new ey;return t.updateAll(this),t}}var nh,zd,Vd,Wd,Xd,ah,Ws,lv,kA,qf,MA;const ts=class ts extends uu{constructor(e){var s;super({...e,name:"highlightEditor"});y(this,Ws);y(this,nh,null);y(this,zd,0);y(this,Vd,null);y(this,Wd,0);y(this,Xd,"");y(this,ah,"");p(this,nh,e.anchorNode||null),p(this,zd,e.anchorOffset||0),p(this,Vd,e.focusNode||null),p(this,Wd,e.focusOffset||0),p(this,Xd,e.methodOfCreation||((s=this._drawOutlines)!=null&&s.isFree?"main_toolbar":"")),p(this,ah,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static get _keyboardManager(){const e=ts.prototype;return V(this,"_keyboardManager",new yl([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}static initialize(e,s){var i;Mt.initialize(e,s),this._defaultDrawingOptions||(this._defaultDrawingOptions=new ey({fill:((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066","fill-opacity":ts._DEFAULT_OPACITY,thickness:ts._DEFAULT_THICKNESS}))}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get typesMap(){return V(this,"typesMap",new Map([[dt.HIGHLIGHT_COLOR,"fill"],[dt.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(e){const{boxes:s,drawOutlines:i}=e;!s&&!i||(this._drawingOptions||(this._drawingOptions=e.drawingOptions||ts.getDefaultDrawingOptions()),s&&(e={...e,drawOutlines:av.build(s,this._uiManager.direction==="ltr")}),super._addOutlines(e))}get colorType(){return dt.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){var e;return(e=this._drawOutlines)!=null&&e.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){var e;return!((e=this._drawOutlines)!=null&&e.isFree)}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:r(this,Xd)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}translateInPage(e,s){}get toolbarPosition(){return b(this,Ws,lv).call(this,this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return b(this,Ws,lv).call(this,this._drawOutlines.firstPoint)}updateParams(e,s){switch(e){case dt.HIGHLIGHT_COLOR:this._updateColorAndOpacity(s,ts._DEFAULT_OPACITY,e),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(s)},!0);break;case dt.HIGHLIGHT_THICKNESS:super.updateParams(e,s),this._reportTelemetry({action:"thickness_changed",thickness:s},!0);break}}get propertiesToUpdate(){const e=super.propertiesToUpdate;return e.push([dt.HIGHLIGHT_FREE,this._drawOutlines.isFree]),e}get toolbarButtons(){return this._uiManager.highlightColors?(this._colorPicker=new cp({editor:this}),[["colorPicker",this._colorPicker]]):super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(e,s){return super.getRect(e,s,this._drawRotation)}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this._reportTelemetry({action:"deleted"}),super.remove()}render(){if(this.div)return this.div;const e=super.render();return r(this,ah)&&(e.setAttribute("aria-label",r(this,ah)),e.setAttribute("role","mark")),this._drawOutlines.isFree?e.classList.add("free"):e.addEventListener("keydown",b(this,Ws,kA).bind(this),{signal:this._uiManager._signal}),this.enableEditing(),e}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,Ws,qf).call(this,!0);break;case 1:case 3:b(this,Ws,qf).call(this,!1);break}}unselect(){super.unselect(),this._drawOutlines.isFree||b(this,Ws,qf).call(this,!1)}static createDrawerInstance({x:e,y:s,box:i,parent:n,isLTR:a}){return new ex(e,s,i,n.scale,this._defaultDrawingOptions.thickness/2,a,.001)}static _getDrawingTarget(e,{target:s}){return s.closest(".textLayer")}static _getPointerCoords({x:e,y:s}){return[e,s]}static _addDrawingListeners(e,s){e.classList.add("free"),s.addEventListener("abort",()=>e.classList.remove("free"),{once:!0}),window.addEventListener("blur",()=>this._endDraw(null),{signal:s}),window.addEventListener("pointerdown",Ae,{capture:!0,passive:!1,signal:s})}static _endDrawingSession(e=!1){return this.endDrawing(e)}createDrawingOptions({color:e,opacity:s,thickness:i}){const{_defaultDrawingOptions:n,_DEFAULT_OPACITY:a}=ts;this._drawingOptions=ts.getDefaultDrawingOptions({fill:$.makeHexColor(...e),"fill-opacity":s||a,thickness:i||n.thickness})}static deserializeDraw(e,s,i,n,a,o,l){const{quadPoints:c}=o;if(c){const m=[];for(let v=0,w=c.length;v<w;v+=8)m.push({x:(c[v]-e)/i,y:1-(c[v+1]-s)/n,width:(c[v+2]-c[v])/i,height:(c[v+1]-c[v+5])/n});return av.build(m,l.direction==="ltr")}const h=o.thickness||this._defaultDrawingOptions.thickness,d=(o.inkLists||o.outlines.points)[0],f=new ty(d[0]-e,n-(d[1]-s),[0,0,i,n],1,h/2,!0,.001);for(let m=0,v=d.length;m<v;m+=2)f.add(d[m]-e,n-(d[m+1]-s));const g=f.getOutlines();return g.buildFocusOutline(h),g}static async deserialize(e,s,i){let n=null;if(e instanceof oA){const{data:{quadPoints:o,rect:l,rotation:c,id:h,color:d,opacity:f,popupRef:g,richText:m,contentsObj:v,creationDate:w,modificationDate:A},parent:{page:{pageNumber:_}}}=e;n=e={annotationType:rt.HIGHLIGHT,color:Array.from(d),opacity:f,quadPoints:o,pageIndex:_-1,rect:l.slice(0),rotation:c,annotationElementId:h,id:h,deleted:!1,popupRef:g,richText:m,comment:(v==null?void 0:v.str)||null,creationDate:w,modificationDate:A}}else if(e instanceof Qv){const{data:{inkLists:o,rect:l,rotation:c,id:h,color:d,borderStyle:{rawWidth:f},popupRef:g,richText:m,contentsObj:v,creationDate:w,modificationDate:A},parent:{page:{pageNumber:_}}}=e;n=e={annotationType:rt.HIGHLIGHT,color:Array.from(d),thickness:f,inkLists:o,pageIndex:_-1,rect:l.slice(0),rotation:c,annotationElementId:h,id:h,deleted:!1,popupRef:g,richText:m,comment:(v==null?void 0:v.str)||null,creationDate:w,modificationDate:A}}const a=await super.deserialize(e,s,i);return a._initialData=n,e.comment&&a.setCommentData(e),a}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=super.serialize(e);return Object.assign(s,{color:Mt._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),opacity:this.opacity,thickness:this._drawingOptions.thickness,quadPoints:this._drawOutlines.serializeQuadPoints(this.pageTranslation,this.pageDimensions),outlines:this._drawOutlines.serialize(s.rect,this._drawRotation)}),this.addComment(s),this.annotationElementId&&!b(this,Ws,MA).call(this,s)?null:(s.id=this.annotationElementId,s)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}};nh=new WeakMap,zd=new WeakMap,Vd=new WeakMap,Wd=new WeakMap,Xd=new WeakMap,ah=new WeakMap,Ws=new WeakSet,lv=function([e,s]){const[i,n,a,o]=this._drawOutlines.box;return[(e-i)/a,(s-n)/o]},kA=function(e){ts._keyboardManager.exec(this,e)},qf=function(e){if(!r(this,nh))return;const s=window.getSelection();e?s.setPosition(r(this,nh),r(this,zd)):s.setPosition(r(this,Vd),r(this,Wd))},MA=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,n)=>i!==s[n])},O(ts,"_DEFAULT_OPACITY",1),O(ts,"_DEFAULT_THICKNESS",12),O(ts,"_defaultDrawingOptions",null),O(ts,"_type","highlight"),O(ts,"_editorType",rt.HIGHLIGHT);let fp=ts;var ur,da,pe,Ne,al,oh,Be,ge,hi,ol,ll,cl,Xs,Jf,Qf,cv;class sx{constructor(t,e,s,i,n,a){y(this,Xs);y(this,ur,new Float64Array(6));y(this,da,new Float64Array(2));y(this,pe);y(this,Ne);y(this,al);y(this,oh);y(this,Be);y(this,ge,"");y(this,hi,0);y(this,ol,new cf);y(this,ll);y(this,cl);p(this,ll,s),p(this,cl,i),p(this,al,n),p(this,oh,a),[t,e]=b(this,Xs,Jf).call(this,t,e);const o=p(this,pe,[NaN,NaN,NaN,NaN,t,e]);p(this,Be,[t,e]),p(this,Ne,[{line:o,points:r(this,Be)}]),r(this,ur).set(o,0),r(this,da).set([t,e],0)}updateProperty(t,e){t==="stroke-width"&&p(this,oh,e)}isEmpty(){var t;return!((t=r(this,Ne))!=null&&t.length)}isCancellable(){return r(this,Be).length<=10}add(t,e){return b(this,Xs,Qf).call(this,t,e)&&this.toSVGPath(),{path:{d:b(this,Xs,cv).call(this)}}}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)b(this,Xs,Qf).call(this,t[s],t[s+1])&&(e=!0,r(this,Be).length<=6&&(this.toSVGPath(),e=!1));return e&&this.toSVGPath(),{path:{d:b(this,Xs,cv).call(this)}}}end(t,e){return t!==void 0&&b(this,Xs,Qf).call(this,t,e)?{path:{d:this.toSVGPath()}}:r(this,Be).length===2?{path:{d:this.toSVGPath()}}:{path:{d:r(this,ge)}}}startNew(t,e,s,i,n){p(this,ll,s),p(this,cl,i),p(this,al,n),[t,e]=b(this,Xs,Jf).call(this,t,e);const a=p(this,pe,[NaN,NaN,NaN,NaN,t,e]);p(this,Be,[t,e]),r(this,da).set([t,e],0);const o=r(this,Ne).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),r(this,Ne).push({line:a,points:r(this,Be)}),r(this,ur).set(a,0),p(this,hi,0),this.toSVGPath(),null}getLastElement(){return r(this,Ne).at(-1)}setLastElement(t){return r(this,Ne)?(r(this,Ne).push(t),p(this,pe,t.line),p(this,Be,t.points),p(this,hi,0),{path:{d:this.toSVGPath()}}):r(this,ol).setLastElement(t)}removeLastElement(){if(!r(this,Ne))return r(this,ol).removeLastElement();r(this,Ne).pop(),p(this,ge,"");for(let t=0,e=r(this,Ne).length;t<e;t++){const{line:s,points:i}=r(this,Ne)[t];p(this,pe,s),p(this,Be,i),p(this,hi,0),this.toSVGPath()}return{path:{d:r(this,ge)}}}toSVGPath(){const t=Y.svgRound(r(this,pe)[4]),e=Y.svgRound(r(this,pe)[5]);if(r(this,Be).length===2)return p(this,ge,`${r(this,ge)} M ${t} ${e} Z`),r(this,ge);if(r(this,Be).length<=6){const i=r(this,ge).lastIndexOf("M");p(this,ge,`${r(this,ge).slice(0,i)} M ${t} ${e}`),p(this,hi,6)}if(r(this,Be).length===4){const i=Y.svgRound(r(this,pe)[10]),n=Y.svgRound(r(this,pe)[11]);return p(this,ge,`${r(this,ge)} L ${i} ${n}`),p(this,hi,12),r(this,ge)}const s=[];r(this,hi)===0&&(s.push(`M ${t} ${e}`),p(this,hi,6));for(let i=r(this,hi),n=r(this,pe).length;i<n;i+=6){const[a,o,l,c,h,d]=r(this,pe).slice(i,i+6).map(Y.svgRound);s.push(`C${a} ${o} ${l} ${c} ${h} ${d}`)}return p(this,ge,r(this,ge)+s.join(" ")),p(this,hi,r(this,pe).length),r(this,ge)}getOutlines(t,e,s,i){const n=r(this,Ne).at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),r(this,ol).build(r(this,Ne),t,e,s,r(this,al),r(this,oh),i),p(this,ur,null),p(this,pe,null),p(this,Ne,null),p(this,ge,null),r(this,ol)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}ur=new WeakMap,da=new WeakMap,pe=new WeakMap,Ne=new WeakMap,al=new WeakMap,oh=new WeakMap,Be=new WeakMap,ge=new WeakMap,hi=new WeakMap,ol=new WeakMap,ll=new WeakMap,cl=new WeakMap,Xs=new WeakSet,Jf=function(t,e){return Y._normalizePoint(t,e,r(this,ll),r(this,cl),r(this,al))},Qf=function(t,e){[t,e]=b(this,Xs,Jf).call(this,t,e),r(this,da).set([t,e],0);const[s,i,n,a]=r(this,ur).subarray(2,6),o=t-n,l=e-a;return Math.hypot(r(this,ll)*o,r(this,cl)*l)<=2?!1:(r(this,Be).push(t,e),isNaN(s)?(r(this,ur).set([n,a,t,e],2),r(this,pe).push(NaN,NaN,NaN,NaN,t,e),!0):(isNaN(r(this,ur)[0])&&r(this,pe).splice(6,6),r(this,ur).set([s,i,n,a,t,e],0),r(this,pe).push(...Y.createBezierPoints(s,i,n,a,t,e)),!0))},cv=function(){const t=Y.svgRound(r(this,da)[0]),e=Y.svgRound(r(this,da)[1]);if(r(this,Be).length===2){const s=Y.svgRound(r(this,pe)[4]),i=Y.svgRound(r(this,pe)[5]);return`${r(this,ge)} M ${s} ${i} L ${t} ${e}`}return`${r(this,ge)} L ${t} ${e}`};var ss,Yd,Kd,Hs,dr,fr,lh,ch,hl,He,xr,OA,RA,DA;class cf extends Y{constructor(){super(...arguments);y(this,He);y(this,ss);y(this,Yd,0);y(this,Kd);y(this,Hs);y(this,dr);y(this,fr);y(this,lh);y(this,ch);y(this,hl)}build(e,s,i,n,a,o,l){p(this,dr,s),p(this,fr,i),p(this,lh,n),p(this,ch,a),p(this,hl,o),p(this,Kd,l??0),p(this,Hs,e),b(this,He,RA).call(this)}get thickness(){return r(this,hl)}setLastElement(e){return r(this,Hs).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return r(this,Hs).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of r(this,Hs)){if(e.push(`M${Y.svgRound(s[4])} ${Y.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${Y.svgRound(s[10])} ${Y.svgRound(s[11])}`);continue}for(let i=6,n=s.length;i<n;i+=6){const[a,o,l,c,h,d]=s.subarray(i,i+6).map(Y.svgRound);e.push(`C${a} ${o} ${l} ${c} ${h} ${d}`)}}return e.join("")}serialize([e,s,i,n],a){const o=[],l=[],[c,h,d,f]=b(this,He,OA).call(this);let g,m,v,w,A,_,E,S,x;switch(r(this,ch)){case 0:x=Y._rescale,g=e,m=s+n,v=i,w=-n,A=e+c*i,_=s+(1-h-f)*n,E=e+(c+d)*i,S=s+(1-h)*n;break;case 90:x=Y._rescaleAndSwap,g=e,m=s,v=i,w=n,A=e+h*i,_=s+c*n,E=e+(h+f)*i,S=s+(c+d)*n;break;case 180:x=Y._rescale,g=e+i,m=s,v=-i,w=n,A=e+(1-c-d)*i,_=s+h*n,E=e+(1-c)*i,S=s+(h+f)*n;break;case 270:x=Y._rescaleAndSwap,g=e+i,m=s+n,v=-i,w=-n,A=e+(1-h-f)*i,_=s+(1-c-d)*n,E=e+(1-h)*i,S=s+(1-c)*n;break}for(const{line:T,points:C}of r(this,Hs))o.push(x(T,g,m,v,w,a?new Array(T.length):null)),l.push(x(C,g,m,v,w,a?new Array(C.length):null));return{lines:o,points:l,rect:[A,_,E,S]}}static deserialize(e,s,i,n,a,{paths:{lines:o,points:l},rotation:c,thickness:h}){const d=[];let f,g,m,v,w;switch(c){case 0:w=Y._rescale,f=-e/i,g=s/n+1,m=1/i,v=-1/n;break;case 90:w=Y._rescaleAndSwap,f=-s/n,g=-e/i,m=1/n,v=1/i;break;case 180:w=Y._rescale,f=e/i+1,g=-s/n,m=-1/i,v=1/n;break;case 270:w=Y._rescaleAndSwap,f=s/n+1,g=e/i+1,m=-1/n,v=-1/i;break}if(!o){o=[];for(const _ of l){const E=_.length;if(E===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,_[0],_[1]]));continue}if(E===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,_[0],_[1],NaN,NaN,NaN,NaN,_[2],_[3]]));continue}const S=new Float32Array(3*(E-2));o.push(S);let[x,T,C,I]=_.subarray(0,4);S.set([NaN,NaN,NaN,NaN,x,T],0);for(let k=4;k<E;k+=2){const M=_[k],R=_[k+1];S.set(Y.createBezierPoints(x,T,C,I,M,R),(k-2)*3),[x,T,C,I]=[C,I,M,R]}}}for(let _=0,E=o.length;_<E;_++)d.push({line:w(o[_].map(S=>S??NaN),f,g,m,v),points:w(l[_].map(S=>S??NaN),f,g,m,v)});const A=new this.prototype.constructor;return A.build(d,i,n,1,c,h,a),A}get box(){return r(this,ss)}updateProperty(e,s){return e==="stroke-width"?b(this,He,DA).call(this,s):null}updateParentDimensions([e,s],i){const[n,a]=b(this,He,xr).call(this);p(this,dr,e),p(this,fr,s),p(this,lh,i);const[o,l]=b(this,He,xr).call(this),c=o-n,h=l-a,d=r(this,ss);return d[0]-=c,d[1]-=h,d[2]+=2*c,d[3]+=2*h,d}updateRotation(e){return p(this,Yd,e),{path:{transform:this.rotationTransform}}}get viewBox(){return r(this,ss).map(Y.svgRound).join(" ")}get defaultProperties(){const[e,s]=r(this,ss);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Y.svgRound(e)} ${Y.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=r(this,ss);let i=0,n=0,a=0,o=0,l=0,c=0;switch(r(this,Yd)){case 90:n=s/e,a=-e/s,l=e;break;case 180:i=-1,o=-1,l=e,c=s;break;case 270:n=-s/e,a=e/s,c=s;break;default:return""}return`matrix(${i} ${n} ${a} ${o} ${Y.svgRound(l)} ${Y.svgRound(c)})`}getPathResizingSVGProperties([e,s,i,n]){const[a,o]=b(this,He,xr).call(this),[l,c,h,d]=r(this,ss);if(Math.abs(h-a)<=Y.PRECISION||Math.abs(d-o)<=Y.PRECISION){const w=e+i/2-(l+h/2),A=s+n/2-(c+d/2);return{path:{"transform-origin":`${Y.svgRound(e)} ${Y.svgRound(s)}`,transform:`${this.rotationTransform} translate(${w} ${A})`}}}const f=(i-2*a)/(h-2*a),g=(n-2*o)/(d-2*o),m=h/i,v=d/n;return{path:{"transform-origin":`${Y.svgRound(l)} ${Y.svgRound(c)}`,transform:`${this.rotationTransform} scale(${m} ${v}) translate(${Y.svgRound(a)} ${Y.svgRound(o)}) scale(${f} ${g}) translate(${Y.svgRound(-a)} ${Y.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,n]){const[a,o]=b(this,He,xr).call(this),l=r(this,ss),[c,h,d,f]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=n,Math.abs(d-a)<=Y.PRECISION||Math.abs(f-o)<=Y.PRECISION){const A=e+i/2-(c+d/2),_=s+n/2-(h+f/2);for(const{line:E,points:S}of r(this,Hs))Y._translate(E,A,_,E),Y._translate(S,A,_,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Y.svgRound(e)} ${Y.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(i-2*a)/(d-2*a),m=(n-2*o)/(f-2*o),v=-g*(c+a)+e+a,w=-m*(h+o)+s+o;if(g!==1||m!==1||v!==0||w!==0)for(const{line:A,points:_}of r(this,Hs))Y._rescale(A,v,w,g,m,A),Y._rescale(_,v,w,g,m,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Y.svgRound(e)} ${Y.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[n,a]=i,o=r(this,ss),l=e-o[0],c=s-o[1];if(r(this,dr)===n&&r(this,fr)===a)for(const{line:h,points:d}of r(this,Hs))Y._translate(h,l,c,h),Y._translate(d,l,c,d);else{const h=r(this,dr)/n,d=r(this,fr)/a;p(this,dr,n),p(this,fr,a);for(const{line:f,points:g}of r(this,Hs))Y._rescale(f,l,c,h,d,f),Y._rescale(g,l,c,h,d,g);o[2]*=h,o[3]*=d}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Y.svgRound(e)} ${Y.svgRound(s)}`}}}get defaultSVGProperties(){const e=r(this,ss);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Y.svgRound(e[0])} ${Y.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}ss=new WeakMap,Yd=new WeakMap,Kd=new WeakMap,Hs=new WeakMap,dr=new WeakMap,fr=new WeakMap,lh=new WeakMap,ch=new WeakMap,hl=new WeakMap,He=new WeakSet,xr=function(e=r(this,hl)){const s=r(this,Kd)+e/2*r(this,lh);return r(this,ch)%180===0?[s/r(this,dr),s/r(this,fr)]:[s/r(this,fr),s/r(this,dr)]},OA=function(){const[e,s,i,n]=r(this,ss),[a,o]=b(this,He,xr).call(this,0);return[e+a,s+o,i-2*a,n-2*o]},RA=function(){const e=p(this,ss,Ha.slice());for(const{line:n}of r(this,Hs)){if(n.length<=12){for(let l=4,c=n.length;l<c;l+=6)$.pointBoundingBox(n[l],n[l+1],e);continue}let a=n[4],o=n[5];for(let l=6,c=n.length;l<c;l+=6){const[h,d,f,g,m,v]=n.subarray(l,l+6);$.bezierBoundingBox(a,o,h,d,f,g,m,v,e),a=m,o=v}}const[s,i]=b(this,He,xr).call(this);e[0]=jt(e[0]-s,0,1),e[1]=jt(e[1]-i,0,1),e[2]=jt(e[2]+s,0,1),e[3]=jt(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},DA=function(e){const[s,i]=b(this,He,xr).call(this);p(this,hl,e);const[n,a]=b(this,He,xr).call(this),[o,l]=[n-s,a-i],c=r(this,ss);return c[0]-=o,c[1]-=l,c[2]+=2*o,c[3]+=2*l,c};class bg extends Zv{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:Mt._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 bg(this._viewParameters);return t.updateAll(this),t}}var Hp,FA;const Ul=class Ul extends uu{constructor(e){super({...e,name:"inkEditor"});y(this,Hp);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){Mt.initialize(e,s),this._defaultDrawingOptions=new bg(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return V(this,"typesMap",new Map([[dt.INK_THICKNESS,"stroke-width"],[dt.INK_COLOR,"stroke"],[dt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:e,y:s,box:[,,i,n],rotation:a}){return new sx(e,s,i,n,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,n,a,o){return cf.deserialize(e,s,i,n,a,o)}static async deserialize(e,s,i){let n=null;if(e instanceof Qv){const{data:{inkLists:o,rect:l,rotation:c,id:h,color:d,opacity:f,borderStyle:{rawWidth:g},popupRef:m,richText:v,contentsObj:w,creationDate:A,modificationDate:_},parent:{page:{pageNumber:E}}}=e;n=e={annotationType:rt.INK,color:Array.from(d),thickness:g,opacity:f,paths:{points:o},boxes:null,pageIndex:E-1,rect:l.slice(0),rotation:c,annotationElementId:h,id:h,deleted:!1,popupRef:m,richText:v,comment:(w==null?void 0:w.str)||null,creationDate:A,modificationDate:_}}const a=await super.deserialize(e,s,i);return a._initialData=n,e.comment&&a.setCommentData(e),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new hp(this)),[["colorPicker",this._colorPicker]]}get colorType(){return dt.INK_COLOR}get colorAndOpacityType(){return dt.INK_COLOR_AND_OPACITY}get opacityType(){return dt.INK_OPACITY}updateParams(e,s){if(e===dt.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(e,s)}static updateDefaultParams(e,s){if(e===dt.INK_COLOR_AND_OPACITY){super.updateDefaultParams(dt.INK_COLOR,s.color),super.updateDefaultParams(dt.INK_OPACITY,s.opacity);return}super.updateDefaultParams(e,s)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=Ul.getDefaultDrawingOptions({stroke:$.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{stroke:n,"stroke-opacity":a,"stroke-width":o}}=this,l=Object.assign(super.serialize(e),{color:Mt._colorManager.convert(n),opacity:a,thickness:o,paths:{lines:s,points:i}});return this.addComment(l),e?(l.isCopy=!0,l):this.annotationElementId&&!b(this,Hp,FA).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:s,rect:i}=this.serializeDraw(!1);return e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s,popup:this.comment}),null}};Hp=new WeakSet,FA=function(e){const{color:s,thickness:i,opacity:n,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==i||e.opacity!==n||e.pageIndex!==a},O(Ul,"_type","ink"),O(Ul,"_editorType",rt.INK),O(Ul,"_defaultDrawingOptions",null);let hv=Ul;class uv extends cf{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}B0();const vf=8,Oh=3;var ul,_t,dv,Ri,LA,NA,fv,Zf,BA,UA,HA,pv,gv,jA;class dn{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},n,a,o,l){let c=new OffscreenCanvas(1,1),h=c.getContext("2d",{alpha:!1});const d=200,f=h.font=`${s} ${i} ${d}px ${e}`,{actualBoundingBoxLeft:g,actualBoundingBoxRight:m,actualBoundingBoxAscent:v,actualBoundingBoxDescent:w,fontBoundingBoxAscent:A,fontBoundingBoxDescent:_,width:E}=h.measureText(t),S=1.5,x=Math.ceil(Math.max(Math.abs(g)+Math.abs(m)||0,E)*S),T=Math.ceil(Math.max(Math.abs(v)+Math.abs(w)||d,Math.abs(A)+Math.abs(_)||d)*S);c=new OffscreenCanvas(x,T),h=c.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=f,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,x,T),h.fillStyle="black",h.fillText(t,x*(S-1)/2,T*(3-S)/2);const C=b(this,_t,pv).call(this,h.getImageData(0,0,x,T).data),I=b(this,_t,HA).call(this,C),k=b(this,_t,gv).call(this,I),M=b(this,_t,fv).call(this,C,x,T,k);return this.processDrawnLines({lines:{curves:M,width:x,height:T},pageWidth:n,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,n){const[a,o,l]=b(this,_t,jA).call(this,t),[c,h]=b(this,_t,UA).call(this,a,o,l,Math.hypot(o,l)*r(this,ul).sigmaSFactor,r(this,ul).sigmaR,r(this,ul).kernelSize),d=b(this,_t,gv).call(this,h),f=b(this,_t,fv).call(this,c,o,l,d);return this.processDrawnLines({lines:{curves:f,width:o,height:l},pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:a,areContours:o}){i%180!==0&&([e,s]=[s,e]);const{curves:l,width:c,height:h}=t,d=t.thickness??0,f=[],g=Math.min(e/c,s/h),m=g/e,v=g/s,w=[];for(const{points:_}of l){const E=a?b(this,_t,BA).call(this,_):_;if(!E)continue;w.push(E);const S=E.length,x=new Float32Array(S),T=new Float32Array(3*(S===2?2:S-2));if(f.push({line:T,points:x}),S===2){x[0]=E[0]*m,x[1]=E[1]*v,T.set([NaN,NaN,NaN,NaN,x[0],x[1]],0);continue}let[C,I,k,M]=E;C*=m,I*=v,k*=m,M*=v,x.set([C,I,k,M],0),T.set([NaN,NaN,NaN,NaN,C,I],0);for(let R=4;R<S;R+=2){const N=x[R]=E[R]*m,F=x[R+1]=E[R+1]*v;T.set(Y.createBezierPoints(C,I,k,M,N,F),(R-2)*3),[C,I,k,M]=[k,M,N,F]}}if(f.length===0)return null;const A=o?new uv:new cf;return A.build(f,e,s,1,i,o?0:d,n),{outline:A,newCurves:w,areContours:o,thickness:d,width:c,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:n}){let a=1/0,o=-1/0,l=0;for(const _ of t){l+=_.length;for(let E=2,S=_.length;E<S;E++){const x=_[E]-_[E-2];a=Math.min(a,x),o=Math.max(o,x)}}let c;a>=-128&&o<=127?c=Int8Array:a>=-32768&&o<=32767?c=Int16Array:c=Int32Array;const h=t.length,d=vf+Oh*h,f=new Uint32Array(d);let g=0;f[g++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*c.BYTES_PER_ELEMENT,f[g++]=0,f[g++]=i,f[g++]=n,f[g++]=e?0:1,f[g++]=Math.max(0,Math.floor(s??0)),f[g++]=h,f[g++]=c.BYTES_PER_ELEMENT;for(const _ of t)f[g++]=_.length-2,f[g++]=_[0],f[g++]=_[1];const m=new CompressionStream("deflate-raw"),v=m.writable.getWriter();await v.ready,v.write(f);const w=c.prototype.constructor;for(const _ of t){const E=new w(_.length-2);for(let S=2,x=_.length;S<x;S++)E[S-2]=_[S]-_[S-2];v.write(E)}return v.close(),(await new Response(m.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),n=i.getWriter();await n.ready,n.write(e).then(async()=>{await n.ready,await n.close()}).catch(()=>{});let a=null,o=0;for await(const E of s)a||(a=new Uint8Array(new Uint32Array(E.buffer,0,4)[0])),a.set(E,o),o+=E.length;const l=new Uint32Array(a.buffer,0,a.length>>2),c=l[1];if(c!==0)throw new Error(`Invalid version: ${c}`);const h=l[2],d=l[3],f=l[4]===0,g=l[5],m=l[6],v=l[7],w=[],A=(vf+Oh*m)*Uint32Array.BYTES_PER_ELEMENT;let _;switch(v){case Int8Array.BYTES_PER_ELEMENT:_=new Int8Array(a.buffer,A);break;case Int16Array.BYTES_PER_ELEMENT:_=new Int16Array(a.buffer,A);break;case Int32Array.BYTES_PER_ELEMENT:_=new Int32Array(a.buffer,A);break}o=0;for(let E=0;E<m;E++){const S=l[Oh*E+vf],x=new Float32Array(S+2);w.push(x);for(let T=0;T<Oh-1;T++)x[T]=l[Oh*E+vf+T+1];for(let T=0;T<S;T++)x[T+2]=x[T]+_[o++]}return{areContours:f,thickness:g,outlines:w,width:h,height:d}}catch(e){return st(`decompressSignature: ${e}`),null}}}ul=new WeakMap,_t=new WeakSet,dv=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},Ri=new WeakMap,LA=function(t,e,s,i,n,a,o){const l=b(this,_t,dv).call(this,s,i,n,a);for(let c=0;c<8;c++){const h=(-c+l-o+16)%8,d=r(this,Ri)[2*h],f=r(this,Ri)[2*h+1];if(t[(s+d)*e+(i+f)]!==0)return h}return-1},NA=function(t,e,s,i,n,a,o){const l=b(this,_t,dv).call(this,s,i,n,a);for(let c=0;c<8;c++){const h=(c+l+o+16)%8,d=r(this,Ri)[2*h],f=r(this,Ri)[2*h+1];if(t[(s+d)*e+(i+f)]!==0)return h}return-1},fv=function(t,e,s,i){const n=t.length,a=new Int32Array(n);for(let h=0;h<n;h++)a[h]=t[h]<=i?1:0;for(let h=1;h<s-1;h++)a[h*e]=a[h*e+e-1]=0;for(let h=0;h<e;h++)a[h]=a[e*s-1-h]=0;let o=1,l;const c=[];for(let h=1;h<s-1;h++){l=1;for(let d=1;d<e-1;d++){const f=h*e+d,g=a[f];if(g===0)continue;let m=h,v=d;if(g===1&&a[f-1]===0)o+=1,v-=1;else if(g>=1&&a[f+1]===0)o+=1,v+=1,g>1&&(l=g);else{g!==1&&(l=Math.abs(g));continue}const w=[d,h],A=v===d+1,_={isHole:A,points:w,id:o,parent:0};c.push(_);let E;for(const R of c)if(R.id===l){E=R;break}E?E.isHole?_.parent=A?E.parent:l:_.parent=A?l:E.parent:_.parent=A?l:0;const S=b(this,_t,LA).call(this,a,e,h,d,m,v,0);if(S===-1){a[f]=-o,a[f]!==1&&(l=Math.abs(a[f]));continue}let x=r(this,Ri)[2*S],T=r(this,Ri)[2*S+1];const C=h+x,I=d+T;m=C,v=I;let k=h,M=d;for(;;){const R=b(this,_t,NA).call(this,a,e,k,M,m,v,1);x=r(this,Ri)[2*R],T=r(this,Ri)[2*R+1];const N=k+x,F=M+T;w.push(F,N);const j=k*e+M;if(a[j+1]===0?a[j]=-o:a[j]===1&&(a[j]=o),N===h&&F===d&&k===C&&M===I){a[f]!==1&&(l=Math.abs(a[f]));break}else m=k,v=M,k=N,M=F}}}return c},Zf=function(t,e,s,i){if(s-e<=4){for(let C=e;C<s-2;C+=2)i.push(t[C],t[C+1]);return}const n=t[e],a=t[e+1],o=t[s-4]-n,l=t[s-3]-a,c=Math.hypot(o,l),h=o/c,d=l/c,f=h*a-d*n,g=l/o,m=1/c,v=Math.atan(g),w=Math.cos(v),A=Math.sin(v),_=m*(Math.abs(w)+Math.abs(A)),E=m*(1-_+_**2),S=Math.max(Math.atan(Math.abs(A+w)*E),Math.atan(Math.abs(A-w)*E));let x=0,T=e;for(let C=e+2;C<s-2;C+=2){const I=Math.abs(f-h*t[C+1]+d*t[C]);I>x&&(T=C,x=I)}x>(c*S)**2?(b(this,_t,Zf).call(this,t,e,T+2,i),b(this,_t,Zf).call(this,t,T,s,i)):i.push(n,a)},BA=function(t){const e=[],s=t.length;return b(this,_t,Zf).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},UA=function(t,e,s,i,n,a){const o=new Float32Array(a**2),l=-2*i**2,c=a>>1;for(let v=0;v<a;v++){const w=(v-c)**2;for(let A=0;A<a;A++)o[v*a+A]=Math.exp((w+(A-c)**2)/l)}const h=new Float32Array(256),d=-2*n**2;for(let v=0;v<256;v++)h[v]=Math.exp(v**2/d);const f=t.length,g=new Uint8Array(f),m=new Uint32Array(256);for(let v=0;v<s;v++)for(let w=0;w<e;w++){const A=v*e+w,_=t[A];let E=0,S=0;for(let T=0;T<a;T++){const C=v+T-c;if(!(C<0||C>=s))for(let I=0;I<a;I++){const k=w+I-c;if(k<0||k>=e)continue;const M=t[C*e+k],R=o[T*a+I]*h[Math.abs(M-_)];E+=M*R,S+=R}}const x=g[A]=Math.round(E/S);m[x]++}return[g,m]},HA=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},pv=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,n=1/0;for(let o=0,l=s.length;o<l;o++){const c=s[o]=t[o<<2];i=Math.max(i,c),n=Math.min(n,c)}const a=255/(i-n);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-n)*a;return s},gv=function(t){let e,s=-1/0,i=-1/0;const n=t.findIndex(l=>l!==0);let a=n,o=n;for(e=n;e<256;e++){const l=t[e];l>s&&(e-a>i&&(i=e-a,o=e-1),s=l,a=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e},jA=function(t){const e=t,{width:s,height:i}=t,{maxDim:n}=r(this,ul);let a=s,o=i;if(s>n||i>n){let f=s,g=i,m=Math.log2(Math.max(s,i)/n);const v=Math.floor(m);m=m===v?v-1:v;for(let A=0;A<m;A++){a=Math.ceil(f/2),o=Math.ceil(g/2);const _=new OffscreenCanvas(a,o);_.getContext("2d").drawImage(t,0,0,f,g,0,0,a,o),f=a,g=o,t!==e&&t.close(),t=_.transferToImageBitmap()}const w=Math.min(n/a,n/o);a=Math.round(a*w),o=Math.round(o*w)}const c=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});c.fillStyle="white",c.fillRect(0,0,a,o),c.filter="grayscale(1)",c.drawImage(t,0,0,t.width,t.height,0,0,a,o);const h=c.getImageData(0,0,a,o).data;return[b(this,_t,pv).call(this,h),a,o]},y(dn,_t),y(dn,ul,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),y(dn,Ri,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class sy extends Zv{constructor(){super(),super.updateProperties({fill:Mt._defaultLineColor,"stroke-width":0})}clone(){const t=new sy;return t.updateAll(this),t}}class iy extends bg{constructor(t){super(t),super.updateProperties({stroke:Mt._defaultLineColor,"stroke-width":1})}clone(){const t=new iy(this._viewParameters);return t.updateAll(this),t}}var fa,pr,pa,dl;const Ts=class Ts extends uu{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});y(this,fa,!1);y(this,pr,null);y(this,pa,null);y(this,dl,null);this._willKeepAspectRatio=!0,p(this,pa,e.signatureData||null),p(this,pr,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){Mt.initialize(e,s),this._defaultDrawingOptions=new sy,this._defaultDrawnSignatureOptions=new iy(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return V(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!r(this,pr)}}static computeTelemetryFinalData(e){const s=e.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(r(this,pa)){const{lines:n,mustSmooth:a,areContours:o,description:l,uuid:c,heightInPage:h}=r(this,pa),{rawDims:{pageWidth:d,pageHeight:f},rotation:g}=this.parent.viewport,m=dn.processDrawnLines({lines:n,pageWidth:d,pageHeight:f,rotation:g,innerMargin:Ts._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(m,h,l,c)}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:r(this,pr)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){p(this,dl,e),this.addEditToolbar()}getUuid(){return r(this,dl)}get description(){return r(this,pr)}set description(e){p(this,pr,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:i,width:n,height:a}=r(this,pa),o=Math.max(n,a),l=dn.processDrawnLines({lines:{curves:e.map(c=>({points:c})),thickness:i,width:n,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,i,n){const{x:a,y:o}=this,{outline:l}=p(this,pa,e);p(this,fa,l instanceof uv),this.description=i;let c;r(this,fa)?c=Ts.getDefaultDrawingOptions():(c=Ts._defaultDrawnSignatureOptions.clone(),c.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:c});const[,h]=this.pageDimensions;let d=s/h;d=d>=1?.5:d,this.width*=d/this.height,this.width>=1&&(d*=.9/this.width,this.width=.9),this.height=d,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(n),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return dn.process(e,s,i,n,Ts._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:n},rotation:a}=this.parent.viewport;return dn.extractContoursFromText(e,s,i,n,a,Ts._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return dn.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:n,innerMargin:Ts._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=Ts.getDefaultDrawingOptions():(this._drawingOptions=Ts._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:i}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":n}}=this,a=Object.assign(super.serialize(e),{isSignature:!0,areContours:r(this,fa),color:[0,0,0],thickness:r(this,fa)?0:n});return this.addComment(a),e?(a.paths={lines:s,points:i},a.uuid=r(this,dl),a.isCopy=!0):a.lines=s,r(this,pr)&&(a.accessibilityData={type:"Figure",alt:r(this,pr)}),a}static deserializeDraw(e,s,i,n,a,o){return o.areContours?uv.deserialize(e,s,i,n,a,o):cf.deserialize(e,s,i,n,a,o)}static async deserialize(e,s,i){var a;const n=await super.deserialize(e,s,i);return p(n,fa,e.areContours),n.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",p(n,dl,e.uuid),n}};fa=new WeakMap,pr=new WeakMap,pa=new WeakMap,dl=new WeakMap,O(Ts,"_type","signature"),O(Ts,"_editorType",rt.SIGNATURE),O(Ts,"_defaultDrawingOptions",null);let mv=Ts;var zt,Re,ga,nn,ma,hh,an,fl,gr,js,uh,yt,Qh,Zh,tp,ep,sp,yv,ip,$A;class vv extends Mt{constructor(e){super({...e,name:"stampEditor"});y(this,yt);y(this,zt,null);y(this,Re,null);y(this,ga,null);y(this,nn,null);y(this,ma,null);y(this,hh,"");y(this,an,null);y(this,fl,!1);y(this,gr,null);y(this,js,!1);y(this,uh,!1);p(this,nn,e.bitmapUrl),p(this,ma,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){Mt.initialize(e,s)}static isHandlingMimeForPasting(e){return Ng.has(e)}static paste(e,s){s.pasteEditor({mode:rt.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:n,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:n,width:a,height:o,channels:n.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const c=l.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var e;r(this,Re)&&(p(this,zt,null),this._uiManager.imageManager.deleteId(r(this,Re)),(e=r(this,an))==null||e.remove(),p(this,an,null),r(this,gr)&&(clearTimeout(r(this,gr)),p(this,gr,null))),super.remove()}rebuild(){if(!this.parent){r(this,Re)&&b(this,yt,tp).call(this);return}super.rebuild(),this.div!==null&&(r(this,Re)&&r(this,an)===null&&b(this,yt,tp).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(r(this,ga)||r(this,zt)||r(this,nn)||r(this,ma)||r(this,Re)||r(this,fl))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;return this._isCopy&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),r(this,fl)||(r(this,zt)?b(this,yt,ep).call(this):b(this,yt,tp).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:i,bitmap:n}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(p(this,Re,i),n&&p(this,zt,n),p(this,fl,!1),b(this,yt,ep).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;r(this,gr)!==null&&clearTimeout(r(this,gr)),p(this,gr,setTimeout(()=>{p(this,gr,null),b(this,yt,yv).call(this)},200))}copyCanvas(e,s,i=!1){e||(e=224);const{width:n,height:a}=r(this,zt),o=new fi;let l=r(this,zt),c=n,h=a,d=null;if(s){if(n>s||a>s){const C=Math.min(s/n,s/a);c=Math.floor(n*C),h=Math.floor(a*C)}d=document.createElement("canvas");const g=d.width=Math.ceil(c*o.sx),m=d.height=Math.ceil(h*o.sy);r(this,js)||(l=b(this,yt,sp).call(this,g,m));const v=d.getContext("2d");v.filter=this._uiManager.hcmFilter;let w="white",A="#cfcfd8";this._uiManager.hcmFilter!=="none"?A="black":cS.isDarkMode&&(w="#8f8f9d",A="#42414d");const _=15,E=_*o.sx,S=_*o.sy,x=new OffscreenCanvas(E*2,S*2),T=x.getContext("2d");T.fillStyle=w,T.fillRect(0,0,E*2,S*2),T.fillStyle=A,T.fillRect(0,0,E,S),T.fillRect(E,S,E,S),v.fillStyle=v.createPattern(x,"repeat"),v.fillRect(0,0,g,m),v.drawImage(l,0,0,l.width,l.height,0,0,g,m)}let f=null;if(i){let g,m;if(o.symmetric&&l.width<e&&l.height<e)g=l.width,m=l.height;else if(l=r(this,zt),n>e||a>e){const A=Math.min(e/n,e/a);g=Math.floor(n*A),m=Math.floor(a*A),r(this,js)||(l=b(this,yt,sp).call(this,g,m))}const w=new OffscreenCanvas(g,m).getContext("2d",{willReadFrequently:!0});w.drawImage(l,0,0,l.width,l.height,0,0,g,m),f={width:g,height:m,data:w.getImageData(0,0,g,m).data}}return{canvas:d,width:c,height:h,imageData:f}}static async deserialize(e,s,i){var w;let n=null,a=!1;if(e instanceof lA){const{data:{rect:A,rotation:_,id:E,structParent:S,popupRef:x,richText:T,contentsObj:C,creationDate:I,modificationDate:k},container:M,parent:{page:{pageNumber:R}},canvas:N}=e;let F,j;N?(delete e.canvas,{id:F,bitmap:j}=i.imageManager.getFromCanvas(M.id,N),N.remove()):(a=!0,e._hasNoCanvas=!0);const U=((w=await s._structTree.getAriaAttributes(`${Nl}${E}`))==null?void 0:w.get("aria-label"))||"";n=e={annotationType:rt.STAMP,bitmapId:F,bitmap:j,pageIndex:R-1,rect:A.slice(0),rotation:_,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:U},isSvg:!1,structParent:S,popupRef:x,richText:T,comment:(C==null?void 0:C.str)||null,creationDate:I,modificationDate:k}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:c,bitmapUrl:h,bitmapId:d,isSvg:f,accessibilityData:g}=e;a?(i.addMissingCanvas(e.id,o),p(o,fl,!0)):d&&i.imageManager.isValidId(d)?(p(o,Re,d),c&&p(o,zt,c)):p(o,nn,h),p(o,js,f);const[m,v]=o.pageDimensions;return o.width=(l[2]-l[0])/m,o.height=(l[3]-l[1])/v,g&&(o.altTextData=g),o._initialData=n,e.comment&&o.setCommentData(e),p(o,uh,!!n),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(e),{bitmapId:r(this,Re),isSvg:r(this,js)});if(this.addComment(i),e)return i.bitmapUrl=b(this,yt,ip).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:n,altText:a}=this.serializeAltText(!1);if(!n&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=b(this,yt,$A).call(this,i);return l.isSame?null:(l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(s===null)return i;s.stamps||(s.stamps=new Map);const o=r(this,js)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(r(this,Re)))s.stamps.set(r(this,Re),{area:o,serialized:i}),i.bitmap=b(this,yt,ip).call(this,!1);else if(r(this,js)){const l=s.stamps.get(r(this,Re));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,yt,ip).call(this,!1))}return i}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}zt=new WeakMap,Re=new WeakMap,ga=new WeakMap,nn=new WeakMap,ma=new WeakMap,hh=new WeakMap,an=new WeakMap,fl=new WeakMap,gr=new WeakMap,js=new WeakMap,uh=new WeakMap,yt=new WeakSet,Qh=function(e,s=!1){if(!e){this.remove();return}p(this,zt,e.bitmap),s||(p(this,Re,e.id),p(this,js,e.isSvg)),e.file&&p(this,hh,e.file.name),b(this,yt,ep).call(this)},Zh=function(){if(p(this,ga,null),this._uiManager.enableWaiting(!1),!!r(this,an)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,zt)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,zt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},tp=function(){if(r(this,Re)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(r(this,Re)).then(i=>b(this,yt,Qh).call(this,i,!0)).finally(()=>b(this,yt,Zh).call(this));return}if(r(this,nn)){const i=r(this,nn);p(this,nn,null),this._uiManager.enableWaiting(!0),p(this,ga,this._uiManager.imageManager.getFromUrl(i).then(n=>b(this,yt,Qh).call(this,n)).finally(()=>b(this,yt,Zh).call(this)));return}if(r(this,ma)){const i=r(this,ma);p(this,ma,null),this._uiManager.enableWaiting(!0),p(this,ga,this._uiManager.imageManager.getFromFile(i).then(n=>b(this,yt,Qh).call(this,n)).finally(()=>b(this,yt,Zh).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Ng.keys().join(",");const s=this._uiManager._signal;p(this,ga,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),b(this,yt,Qh).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,yt,Zh).call(this))),e.click()},ep=function(){var c;const{div:e}=this;let{width:s,height:i}=r(this,zt);const[n,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*n,i=this.height*a;else if(s>o*n||i>o*a){const h=Math.min(o*n/s,o*a/i);s*=h,i*=h}this._uiManager.enableWaiting(!1);const l=p(this,an,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/n,this.height=i/a,this.setDims(),(c=this._initialOptions)!=null&&c.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),b(this,yt,yv).call(this),r(this,uh)||(this.parent.addUndoableEditor(this),p(this,uh,!0)),this._reportTelemetry({action:"inserted_image"}),r(this,hh)&&this.div.setAttribute("aria-description",r(this,hh)),this.annotationElementId||this._uiManager.a11yAlert(Mt._l10nAlert.stamp)},sp=function(e,s){const{width:i,height:n}=r(this,zt);let a=i,o=n,l=r(this,zt);for(;a>2*e||o>2*s;){const c=a,h=o;a>2*e&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const d=new OffscreenCanvas(a,o);d.getContext("2d").drawImage(l,0,0,c,h,0,0,a,o),l=d.transferToImageBitmap()}return l},yv=function(){const[e,s]=this.parentDimensions,{width:i,height:n}=this,a=new fi,o=Math.ceil(i*e*a.sx),l=Math.ceil(n*s*a.sy),c=r(this,an);if(!c||c.width===o&&c.height===l)return;c.width=o,c.height=l;const h=r(this,js)?r(this,zt):b(this,yt,sp).call(this,o,l),d=c.getContext("2d");d.filter=this._uiManager.hcmFilter,d.drawImage(h,0,0,h.width,h.height,0,0,o,l)},ip=function(e){if(e){if(r(this,js)){const n=this._uiManager.imageManager.getSvgUrl(r(this,Re));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=r(this,zt),s.getContext("2d").drawImage(r(this,zt),0,0),s.toDataURL()}if(r(this,js)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*Ca.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Ca.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(n,a);return o.getContext("2d").drawImage(r(this,zt),0,0,r(this,zt).width,r(this,zt).height,0,0,n,a),o.transferToImageBitmap()}return structuredClone(r(this,zt))},$A=function(e){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,n=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&a,isSameAltText:a}},O(vv,"_type","stamp"),O(vv,"_editorType",rt.STAMP);var pl,dh,va,ya,on,As,ba,fh,ph,Di,ln,_s,cn,wa,gh,K,Aa,Rt,wv,GA,$i,Av,_v,rp;const bi=class bi{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:a,drawLayer:o,textLayer:l,viewport:c,l10n:h}){y(this,Rt);y(this,pl);y(this,dh,!1);y(this,va,null);y(this,ya,null);y(this,on,null);y(this,As,new Map);y(this,ba,!1);y(this,fh,!1);y(this,ph,!1);y(this,Di,null);y(this,ln,null);y(this,_s,null);y(this,cn,null);y(this,wa,null);y(this,gh,-1);y(this,K);const d=[...r(bi,Aa).values()];if(!bi._initialized){bi._initialized=!0;for(const f of d)f.initialize(h,t)}t.registerEditorTypes(d),p(this,K,t),this.pageIndex=e,this.div=s,p(this,pl,n),p(this,va,a),this.viewport=c,p(this,_s,l),this.drawLayer=o,this._structTree=i,r(this,K).addLayer(this)}get isEmpty(){return r(this,As).size===0}get isInvisible(){return this.isEmpty&&r(this,K).getMode()===rt.NONE}updateToolbar(t){r(this,K).updateToolbar(t)}updateMode(t=r(this,K).getMode()){switch(b(this,Rt,rp).call(this),t){case rt.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case rt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case rt.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===rt.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of r(bi,Aa).values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=r(this,_s))==null?void 0:e.div)}setEditingState(t){r(this,K).setEditingState(t)}addCommands(t){r(this,K).addCommands(t)}cleanUndoStack(t){r(this,K).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=r(this,va))==null||e.togglePointerEvents(t)}async enable(){var s;p(this,ph,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=r(this,wa))==null||s.abort(),p(this,wa,null);const t=new Set;for(const i of r(this,Rt,wv))i.enableEditing(),i.show(!0),i.annotationElementId&&(r(this,K).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const e=r(this,va);if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),r(this,K).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const n=await this.deserialize(i);n&&(this.addOrRebuild(n),n.enableEditing())}p(this,ph,!1),r(this,K)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(p(this,fh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),r(this,_s)&&!r(this,wa)){p(this,wa,new AbortController);const n=r(this,K).combinedSignal(r(this,wa));r(this,_s).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:c,timeStamp:h}=a,d=r(this,gh);if(h-d>500){p(this,gh,h);return}p(this,gh,-1);const{classList:f}=this.div;f.toggle("getElements",!0);const g=document.elementsFromPoint(l,c);if(f.toggle("getElements",!1),!this.div.contains(g[0]))return;let m;const v=new RegExp(`^${yh}[0-9]+$`);for(const A of g)if(v.test(A.id)){m=A.id;break}if(!m)return;const w=r(this,As).get(m);(w==null?void 0:w.annotationElementId)===null&&(Ae(a),w.dblclick(a))},{signal:n,capture:!0})}const t=r(this,va),e=[];if(t){const n=new Map,a=new Map;for(const o of r(this,Rt,wv)){if(o.disableEditing(),!o.annotationElementId){e.push(o);continue}if(o.serialize()!==null){n.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()}for(const o of t.getEditableAnnotations()){const{id:l}=o.data;if(r(this,K).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let c=a.get(l);if(c){c.resetAnnotationElement(o),c.show(!1),o.show();continue}c=n.get(l),c&&(r(this,K).addChangedExistingAnnotation(c),c.renderAnnotationElement(o)&&c.show(!1)),o.show()}}b(this,Rt,rp).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of r(bi,Aa).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),p(this,fh,!1)}getEditableAnnotation(t){var e;return((e=r(this,va))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){r(this,K).getActive()!==t&&r(this,K).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=r(this,_s))!=null&&t.div&&!r(this,cn)){p(this,cn,new AbortController);const e=r(this,K).combinedSignal(r(this,cn));r(this,_s).div.addEventListener("pointerdown",b(this,Rt,GA).bind(this),{signal:e}),r(this,_s).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=r(this,_s))!=null&&t.div&&r(this,cn)&&(r(this,cn).abort(),p(this,cn,null),r(this,_s).div.classList.remove("highlighting"))}enableClick(){if(r(this,ya))return;p(this,ya,new AbortController);const t=r(this,K).combinedSignal(r(this,ya));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=r(this,ya))==null||t.abort(),p(this,ya,null)}attach(t){r(this,As).set(t.id,t);const{annotationElementId:e}=t;e&&r(this,K).isDeletedAnnotationElement(e)&&r(this,K).removeDeletedAnnotationElement(t)}detach(t){var e;r(this,As).delete(t.id),(e=r(this,pl))==null||e.removePointerInTextLayer(t.contentDiv),!r(this,fh)&&t.annotationElementId&&r(this,K).addDeletedAnnotationElement(t)}remove(t){this.detach(t),r(this,K).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(r(this,K).addDeletedAnnotationElement(t),Mt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),r(this,K).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!r(this,ph)),r(this,K).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!r(this,on)&&(t._focusEventsAllowed=!1,p(this,on,setTimeout(()=>{p(this,on,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:r(this,K)._signal}),e.focus())},0))),t._structTreeParentId=(s=r(this,pl))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of r(this,As).values())if(e.uid===t)return e;return null}combinedSignal(t){return r(this,K).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=r(this,Rt,$i))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await r(this,K).updateMode(t.mode);const{offsetX:s,offsetY:i}=b(this,Rt,_v).call(this),n=r(this,K).getId(),a=b(this,Rt,Av).call(this,{parent:this,id:n,x:s,y:i,uiManager:r(this,K),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=r(bi,Aa).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,r(this,K)))||null}createAndAddNewEditor(t,e,s={}){const i=r(this,K).getId(),n=b(this,Rt,Av).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:r(this,K),isCentered:e,...s});return n&&this.add(n),n}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(b(this,Rt,_v).call(this),!0,t)}setSelected(t){r(this,K).setSelected(t)}toggleSelected(t){r(this,K).toggleSelected(t)}unselect(t){r(this,K).unselect(t)}pointerup(t){var i;const{isMac:e}=Et.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!r(this,ba)||(p(this,ba,!1),(i=r(this,Rt,$i))!=null&&i.isDrawer&&r(this,Rt,$i).supportMultipleDrawings))return;if(!r(this,dh)){p(this,dh,!0);return}const s=r(this,K).getMode();if(s===rt.STAMP||s===rt.POPUP||s===rt.SIGNATURE){r(this,K).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(r(this,K).getMode()===rt.HIGHLIGHT&&this.enableTextSelection(),r(this,ba)){p(this,ba,!1);return}const{isMac:e}=Et.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(p(this,ba,!0),(i=r(this,Rt,$i))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=r(this,K).getActive();p(this,dh,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),r(this,Di)){r(this,Rt,$i).startDrawing(this,r(this,K),!1,t);return}r(this,K).setCurrentDrawingSession(this),p(this,Di,new AbortController);const e=r(this,K).combinedSignal(r(this,Di));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(p(this,ln,null),this.commitOrRemove())},{signal:e}),r(this,Rt,$i).startDrawing(this,r(this,K),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&p(this,ln,e);return}r(this,ln)&&setTimeout(()=>{var e;(e=r(this,ln))==null||e.focus(),p(this,ln,null)},0)}endDrawingSession(t=!1){return r(this,Di)?(r(this,K).setCurrentDrawingSession(null),r(this,Di).abort(),p(this,Di,null),p(this,ln,null),r(this,Rt,$i).endDrawing(t)):null}findNewParent(t,e,s){const i=r(this,K).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return r(this,Di)?(this.endDrawingSession(),!0):!1}onScaleChanging(){r(this,Di)&&r(this,Rt,$i).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=r(this,K).getActive())==null?void 0:t.parent)===this&&(r(this,K).commitOrRemove(),r(this,K).setActiveEditor(null)),r(this,on)&&(clearTimeout(r(this,on)),p(this,on,null));for(const s of r(this,As).values())(e=r(this,pl))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,r(this,As).clear(),r(this,K).removeLayer(this)}async render({viewport:t}){this.viewport=t,vl(this.div,t);for(const e of r(this,K).getEditors(this.pageIndex))this.add(e),e.rebuild();await r(this,K).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){r(this,K).commitOrRemove(),b(this,Rt,rp).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,vl(this.div,{rotation:s}),e!==s)for(const i of r(this,As).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return r(this,K).viewParameters.realScale}};pl=new WeakMap,dh=new WeakMap,va=new WeakMap,ya=new WeakMap,on=new WeakMap,As=new WeakMap,ba=new WeakMap,fh=new WeakMap,ph=new WeakMap,Di=new WeakMap,ln=new WeakMap,_s=new WeakMap,cn=new WeakMap,wa=new WeakMap,gh=new WeakMap,K=new WeakMap,Aa=new WeakMap,Rt=new WeakSet,wv=function(){return r(this,As).size!==0?r(this,As).values():r(this,K).getEditors(this.pageIndex)},GA=function(t){r(this,K).unselectAll();const{target:e}=t;if(e===r(this,_s).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&r(this,_s).div.contains(e)){const{isMac:s}=Et.platform;if(t.button!==0||t.ctrlKey&&s)return;r(this,K).showAllEditors("highlight",!0,!0),fp.startDrawing(this,r(this,K),r(this,K).direction==="ltr",t),t.preventDefault()}},$i=function(){return r(bi,Aa).get(r(this,K).getMode())},Av=function(t){const e=r(this,Rt,$i);return e?new e.prototype.constructor(t):null},_v=function(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,n=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),c=(n+o)/2-t,h=(a+l)/2-e,[d,f]=this.viewport.rotation%180===0?[c,h]:[h,c];return{offsetX:d,offsetY:f}},rp=function(){for(const t of r(this,As).values())t.isEmpty()&&t.remove()},O(bi,"_initialized",!1),y(bi,Aa,new Map([Km,hv,vv,fp,mv].map(t=>[t._editorType,t])));let bv=bi;S0();function ix(u,t){return u===t?0:u.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function yf(u){var t;return u?u.nodeType===Node.ELEMENT_NODE?u.closest(".textLayer"):((t=u.parentElement)==null?void 0:t.closest(".textLayer"))||null:null}function rx(u,t,e,s){if(u===e)return t<=s;const i=u.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function Xy(u,t,e){if(u.nodeType!==Node.ELEMENT_NODE||!u.classList.contains("textLayer")||t!==u.childNodes.length)return{container:u,offset:t};let s=u.lastChild;return(s==null?void 0:s.nodeType)===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}var is,rs,ui,qd,Jd,gl,ml,Qd,jp,_a,Sa,Ea,xa,hn,Ke,Ev,xv,zA,np,VA,Ar,Tv,WA,Cv;const J=class J{constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){y(this,Ar);y(this,is,null);y(this,rs,new Map);y(this,ui,null);y(this,qd,null);y(this,Jd,null);y(this,gl,null);y(this,ml,new Map);if(this.pageIndex=s,p(this,qd,t),p(this,Jd,e),i){const n=r(J,hn).get(i);if(n!=null&&n.selectionDiv&&(n.selectionDiv.remove(),r(J,Sa).delete(n.selectionDiv)),r(J,hn).set(i,{drawLayer:this}),r(J,xa).add(i),p(this,ui,i),p(this,gl,new MutationObserver(a=>{var o,l,c;if(!(!r(this,is)||!((o=r(this,ui))!=null&&o.isConnected)||!b(l=J,Ke,xv).call(l))){for(const{addedNodes:h}of a)for(const d of h)if(d.nodeType===Node.ELEMENT_NODE&&d.classList.contains("endOfContent")){b(c=J,Ke,np).call(c);return}}})),r(this,gl).observe(i,{childList:!0}),r(J,_a)===null){p(J,_a,new AbortController);const{signal:a}=r(J,_a);document.addEventListener("selectionchange",b(J,Ke,np).bind(J),{signal:a}),document.addEventListener("pointerdown",()=>{p(J,Ea,!0)},{signal:a}),document.addEventListener("pointerup",()=>{p(J,Ea,!1)},{signal:a}),window.addEventListener("blur",()=>{p(J,Ea,!1)},{signal:a})}}}setParent(t){var e,s,i;if(!r(this,is)){p(this,is,t),(e=r(this,ui))!=null&&e.isConnected&&b(s=J,Ke,xv).call(s)&&b(i=J,Ke,np).call(i);return}if(r(this,is)!==t){if(r(this,rs).size>0)for(const n of r(this,rs).values())n.remove(),t.append(n);p(this,is,t)}}static get _svgFactory(){return V(this,"_svgFactory",new up)}draw(t,e=!1,s=!1){const i=Ft(J,Qd)._++,n=b(this,Ar,Tv).call(this),a=J._svgFactory.createElement("defs");n.append(a);const o=J._svgFactory.createElement("path");a.append(o);const l=`path_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&r(this,ml).set(i,o);const c=s?b(this,Ar,WA).call(this,a,l):null,h=J._svgFactory.createElement("use");return n.append(h),h.setAttribute("href",`#${l}`),this.updateProperties(n,t),r(this,rs).set(i,n),{id:i,clipPathId:`url(#${c})`}}drawOutline(t,e){const s=Ft(J,Qd)._++,i=b(this,Ar,Tv).call(this),n=J._svgFactory.createElement("defs");i.append(n);const a=J._svgFactory.createElement("path");n.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const d=J._svgFactory.createElement("mask");n.append(d),l=`mask_${s}`,d.setAttribute("id",l),d.setAttribute("maskUnits","objectBoundingBox");const f=J._svgFactory.createElement("rect");d.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const g=J._svgFactory.createElement("use");d.append(g),g.setAttribute("href",`#${o}`),g.setAttribute("stroke","none"),g.setAttribute("fill","black"),g.setAttribute("fill-rule","nonzero"),g.classList.add("mask")}const c=J._svgFactory.createElement("use");i.append(c),c.setAttribute("href",`#${o}`),l&&c.setAttribute("mask",`url(#${l})`);const h=c.cloneNode();return i.append(h),c.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(i,t),r(this,rs).set(s,i),s}finalizeDraw(t,e){r(this,ml).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:i,rootClass:n,path:a}=e,o=typeof t=="number"?r(this,rs).get(t):t;if(o){if(s&&b(this,Ar,Cv).call(this,o,s),i&&b(l=J,Ke,VA).call(l,o,i),n){const{classList:c}=o;for(const[h,d]of Object.entries(n))c.toggle(h,d)}if(a){const h=o.firstElementChild.firstElementChild;b(this,Ar,Cv).call(this,h,a)}}}updateParent(t,e){if(e===this)return;const s=r(this,rs).get(t);s&&(r(e,is).append(s),r(this,rs).delete(t),r(e,rs).set(t,s))}remove(t){r(this,ml).delete(t),r(this,is)!==null&&(r(this,rs).get(t).remove(),r(this,rs).delete(t))}destroy(){var t,e,s;p(this,is,null);for(const i of r(this,rs).values())i.remove();if(r(this,rs).clear(),r(this,ml).clear(),(t=r(this,gl))==null||t.disconnect(),p(this,gl,null),r(this,ui)){const i=r(J,hn).get(r(this,ui));(i==null?void 0:i.drawLayer)===this&&(b(e=J,Ke,Ev).call(e,r(this,ui)),r(J,hn).delete(r(this,ui)),r(J,xa).delete(r(this,ui)),r(J,xa).size===0&&((s=r(J,_a))==null||s.abort(),p(J,_a,null),p(J,Ea,!1))),p(this,ui,null)}}};is=new WeakMap,rs=new WeakMap,ui=new WeakMap,qd=new WeakMap,Jd=new WeakMap,gl=new WeakMap,ml=new WeakMap,Qd=new WeakMap,jp=new WeakMap,_a=new WeakMap,Sa=new WeakMap,Ea=new WeakMap,xa=new WeakMap,hn=new WeakMap,Ke=new WeakSet,Ev=function(t){const e=r(this,hn).get(t);e!=null&&e.selectionDiv&&(e.selectionDiv.remove(),r(this,Sa).delete(e.selectionDiv),e.selectionDiv=null,e.path=null)},xv=function(){const t=document.getSelection();return!!t&&!t.isCollapsed},zA=function(){return r(this,xa).keys().filter(t=>t.isConnected).toArray().sort(ix)},np=function(){var a;const t=document.getSelection();if(!t||t.isCollapsed){for(const o of r(this,Sa))o.remove();r(this,Sa).clear();return}const e=new WeakMap,s=b(this,Ke,zA).call(this),i=[];for(let o=0,l=t.rangeCount;o<l;o++){const c=t.getRangeAt(o);if(c.collapsed)continue;let{startContainer:h,startOffset:d,endContainer:f,endOffset:g}=c,m=yf(h),v=yf(f);const w=m===null,A=v===null;if(r(this,Ea)&&w!==A)return;if(t.rangeCount===1){const{anchorNode:S,anchorOffset:x,focusNode:T,focusOffset:C}=t,I=yf(S),k=yf(T),M=rx(S,x,T,C);I&&k&&M!==null&&(M?(h=S,d=x,m=I,f=T,g=C,v=k):(h=T,d=C,m=k,f=S,g=x,v=I))}const _=s.filter(S=>c.intersectsNode(S));if(_.length===0)continue;let E=!1;if(m||(m=_[0],h=m,d=0,E=!0),v||(v=_.at(-1),f=v,g=v.childNodes.length,E=!0),f.nodeType===Node.ELEMENT_NODE){if(f.classList.contains("endOfContent")){const S=f.previousSibling;if(!S)continue;f=S,g=S.nodeType===Node.TEXT_NODE?S.textContent.length:S.childNodes.length}else if(f.classList.contains("textLayer")&&f.childNodes.length===g){const S=Xy(f,g,v);if(!S)continue;f=S.container,g=S.offset}}if(h.nodeType===Node.ELEMENT_NODE){const S=Xy(h,d,m);if(!S)continue;h=S.container,d=S.offset}if(m===v&&!E&&_.includes(m)){i.push([c,m]);continue}for(const S of _){const x=S.firstChild;if(!x)continue;const T=document.createRange();if(S===m?T.setStart(h,d):T.setStartBefore(x),S===v)T.setEnd(f,g);else{const C=S.lastChild;if(!C)continue;if(C.nodeType===Node.ELEMENT_NODE&&C.classList.contains("endOfContent")){const I=C.previousSibling;if(!I)continue;T.setEndAfter(I)}else T.setEndAfter(C)}T.collapsed||i.push([T,S])}}const n=new Set(i.map(o=>o[1]));for(const o of r(this,xa))n.has(o)||b(this,Ke,Ev).call(this,o);for(const[o,l]of i){const c=r(J,hn).get(l);if(!c)continue;let h=e.get(l);if(!h){const v=l.getBoundingClientRect();h=(w,A,_,E)=>({x:(w-v.x)/v.width,y:(A-v.y)/v.height,width:_/v.width,height:E/v.height}),e.set(l,h)}const d=[];for(let{x:v,y:w,width:A,height:_}of o.getClientRects())A===0||_===0||({x:v,y:w,width:A,height:_}=h(v,w,A,_),!(A===1&&_===1)&&d.push(`M${v} ${w} h${A} v${_} h-${A} Z`));if(d.length===0)continue;const f=c.drawLayer;let g=c.selectionDiv,m=c.path;if(!g){const v=`clip_selection_${Ft(J,jp)._++}`;g=document.createElement("div"),g.className="selection",g.style.clipPath=`url(#${v})`;const w=(a=r(f,qd))==null?void 0:a.createSelectionStyle(r(f,Jd));if(w)for(const[E,S]of Object.entries(w))g.style.setProperty(E,S);const A=J._svgFactory.create(1,1,!0);A.setAttribute("aria-hidden","true"),A.setAttribute("width","100%"),A.setAttribute("height","100%");const _=J._svgFactory.createElement("clipPath");_.setAttribute("id",v),_.setAttribute("clipPathUnits","objectBoundingBox"),m=J._svgFactory.createElement("path"),_.append(m),A.append(_),g.append(A),c.path=m,c.selectionDiv=g}r(f,is)&&g.parentNode!==r(f,is)&&(r(f,is).append(g),r(this,Sa).add(g)),m.setAttribute("d",d.join(" "))}},VA=function(t,[e,s,i,n]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*n}%`},Ar=new WeakSet,Tv=function(){const t=J._svgFactory.create(1,1,!0);return r(this,is).append(t),t.setAttribute("aria-hidden","true"),t},WA=function(t,e){const s=J._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=J._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},Cv=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},y(J,Ke),y(J,Qd,0),y(J,jp,0),y(J,_a,null),y(J,Sa,new Set),y(J,Ea,!1),y(J,xa,new Set),y(J,hn,new WeakMap);let Sv=J;function bf(u){return`${(u*100).toFixed(2)}%`}var mh,Zd,tf,vh,mr,vr,ef,$p,XA;const nu=class nu{constructor(t,e,s,i){y(this,$p);y(this,mh,[]);y(this,Zd,new Map);y(this,tf,null);y(this,vh,0);y(this,mr,0);y(this,vr,0);p(this,vh,t),p(this,mh,e),p(this,mr,s.rawDims.pageWidth),p(this,vr,s.rawDims.pageHeight),p(this,tf,i)}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<r(this,mh).length;e+=6){const s=b(this,$p,XA).call(this,r(this,mh).subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{var A;if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=r(this,Zd).get(s);if(!i)return;const n=(A=r(nu,ef))==null?void 0:A.deref();if(n===s)return;n&&(n.width=0,n.height=0),p(nu,ef,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:c,height:h}=i,d=r(this,tf).call(this),f=Math.ceil(o*d.width),g=Math.ceil(l*d.height),m=Math.floor((o+c/r(this,mr))*d.width),v=Math.floor((l+h/r(this,vr))*d.height);s.width=m-f,s.height=v-g;const w=s.getContext("2d");w.setTransform(...a),w.translate(-f,-g),w.drawImage(d,0,0)}),t}};mh=new WeakMap,Zd=new WeakMap,tf=new WeakMap,vh=new WeakMap,mr=new WeakMap,vr=new WeakMap,ef=new WeakMap,$p=new WeakSet,XA=function([t,e,s,i,n,a]){const o=Math.hypot((n-t)*r(this,mr),(a-e)*r(this,vr)),l=Math.hypot((s-t)*r(this,mr),(i-e)*r(this,vr));if(o<r(this,vh)||l<r(this,vh))return null;const c=[(n-t)*r(this,mr)/o,(a-e)*r(this,vr)/o,(s-t)*r(this,mr)/l,(i-e)*r(this,vr)/l,0,0],h=$.inverseTransform(c),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:bf(t),top:bf(e),width:bf(o/r(this,mr)),height:bf(l/r(this,vr)),transformOrigin:"0% 0%",transform:`matrix(${c.join(",")})`}),r(this,Zd).set(d,{inverseTransform:h,width:o,height:l,x1:t,y1:e}),d},y(nu,ef,null);let Pv=nu;globalThis._pdfjsTestingUtils={HighlightOutliner:rv};globalThis.pdfjsLib={AbortException:Ta,AnnotationEditorLayer:bv,AnnotationEditorParamsType:dt,AnnotationEditorType:rt,AnnotationEditorUIManager:bl,AnnotationLayer:Ym,AnnotationMode:An,AnnotationType:Kt,applyOpacity:uS,build:RE,ColorPicker:cp,createValidAbsoluteUrl:xb,CSSConstants:hS,DOMSVGFactory:up,DrawLayer:Sv,FeatureTest:Et,fetchData:Wv,findContrastColor:dS,getDocument:PE,getFilenameFromUrl:aS,getPdfFilenameFromUrl:oS,getRGB:lf,getRGBA:xh,getUuid:Cb,GlobalWorkerOptions:un,ImageKind:wf,InvalidPDFException:Rg,isDataScheme:hg,isPdfFile:Yv,isValidExplicitDest:DS,makeArr:Eh,makeMap:zv,makeObj:Fg,makeSet:iS,MathClamp:jt,noContextMenu:Li,normalizeUnicode:eS,OPS:zi,OutputScale:fi,PasswordException:Og,PasswordResponses:Y0,PDFDataRangeTransport:Kw,PDFDateString:op,PDFWorker:hu,PermissionFlag:X0,PixelsPerInch:Ca,RenderingCancelledException:Xv,renderRichText:Pb,ResponseException:ap,setLayerDimensions:vl,shadow:V,SignatureExtractor:dn,stopEvent:Ae,SupportedImageMimeTypes:Ng,TextLayer:cu,TextLayerImages:Pv,TouchManager:qb,updateUrlHash:Tb,Util:$,VerbosityLevel:ag,version:OE,XfaLayer:Vv};export{Ta as AbortException,bv as AnnotationEditorLayer,dt as AnnotationEditorParamsType,rt as AnnotationEditorType,bl as AnnotationEditorUIManager,Ym as AnnotationLayer,An as AnnotationMode,Kt as AnnotationType,hS as CSSConstants,cp as ColorPicker,up as DOMSVGFactory,Sv as DrawLayer,Et as FeatureTest,un as GlobalWorkerOptions,wf as ImageKind,Rg as InvalidPDFException,jt as MathClamp,zi as OPS,fi as OutputScale,Kw as PDFDataRangeTransport,op as PDFDateString,hu as PDFWorker,Og as PasswordException,Y0 as PasswordResponses,X0 as PermissionFlag,Ca as PixelsPerInch,Xv as RenderingCancelledException,ap as ResponseException,dn as SignatureExtractor,Ng as SupportedImageMimeTypes,cu as TextLayer,Pv as TextLayerImages,qb as TouchManager,$ as Util,ag as VerbosityLevel,Vv as XfaLayer,uS as applyOpacity,RE as build,xb as createValidAbsoluteUrl,Wv as fetchData,dS as findContrastColor,PE as getDocument,aS as getFilenameFromUrl,oS as getPdfFilenameFromUrl,lf as getRGB,xh as getRGBA,Cb as getUuid,hg as isDataScheme,Yv as isPdfFile,DS as isValidExplicitDest,Eh as makeArr,zv as makeMap,Fg as makeObj,iS as makeSet,Li as noContextMenu,eS as normalizeUnicode,Pb as renderRichText,vl as setLayerDimensions,V as shadow,Ae as stopEvent,Tb as updateUrlHash,OE as version};