@elizaos/plugin-pdf 2.0.0-alpha.13 → 2.0.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,28 @@
1
- import{logger as x,Service as y,ServiceType as h}from"@elizaos/core";import*as w from"pdfjs-dist/legacy/build/pdf.mjs";var{getDocument:m}=w;function P(e){return"str"in e}class f extends y{static serviceType=h.PDF;capabilityDescription="The agent is able to convert PDF files to text";static async start(e){return new f(e)}static async stop(e){let t=e.getService(h.PDF);if(t)await t.stop()}async stop(){}async convertPdfToText(e){try{let t=new Uint8Array(e),a=await m({data:t}).promise,i=a.numPages,n=[];for(let s=1;s<=i;s++){let o=(await(await a.getPage(s)).getTextContent()).items.filter(P).map((g)=>g.str).join(" ");n.push(o)}let r=n.join(`
2
- `);return this.cleanUpContent(r)}catch(t){throw x.error(`PdfService: Failed to convert PDF to text - error: ${t}, bufferSize: ${e.length}`),t}}async convertPdfToTextWithOptions(e,t={}){try{let a=new Uint8Array(e),i=await m({data:a}).promise,n=i.numPages,r=Math.max(1,t.startPage||1),s=Math.min(n,t.endPage||n),d=[];for(let o=r;o<=s;o++){let l=(await(await i.getPage(o)).getTextContent()).items.filter(P).map((p)=>p.str).join(t.preserveWhitespace?"":" ");d.push(l)}let c=d.join(`
3
- `);if(t.cleanContent!==!1)c=this.cleanUpContent(c);return{success:!0,text:c,pageCount:n}}catch(a){return{success:!1,error:a instanceof Error?a.message:String(a)}}}async getDocumentInfo(e){let t=new Uint8Array(e),a=await m({data:t}).promise,i=a.numPages,r=(await a.getMetadata()).info,s={title:r.Title,author:r.Author,subject:r.Subject,keywords:r.Keywords,creator:r.Creator,producer:r.Producer,creationDate:r.CreationDate?new Date(r.CreationDate):void 0,modificationDate:r.ModDate?new Date(r.ModDate):void 0},d=[],c=[];for(let o=1;o<=i;o++){let g=await a.getPage(o),u=g.getViewport({scale:1}),p=(await g.getTextContent()).items.filter(P).map((C)=>C.str).join(" ");d.push({pageNumber:o,width:u.width,height:u.height,text:this.cleanUpContent(p)}),c.push(p)}return{pageCount:i,metadata:s,text:this.cleanUpContent(c.join(`
4
- `)),pages:d}}cleanUpContent(e){try{return e.split("").filter((i)=>{let n=i.charCodeAt(0);return!(n===0||n>=1&&n<=8||n>=11&&n<=12||n>=14&&n<=31||n===127)}).join("").replace(/[^\S\r\n]+/g," ").replace(/[ \t]+(\r?\n)/g,"$1").trim()}catch(t){return x.error(`PdfService: Failed to clean up content - error: ${t}, contentLength: ${e.length}`),e}}}var T={name:"pdf",description:"Plugin for PDF reading and text extraction",services:[f],actions:[]},v=T;export{T as pdfPlugin,v as default,f as PdfService};
1
+ var e8=Object.defineProperty;var $K=($)=>$;function QK($,Q){this[$]=$K.bind(null,Q)}var KK=($,Q)=>{for(var K in Q)e8($,K,{get:Q[K],enumerable:!0,configurable:!0,set:QK.bind(Q,K)})};import{Service as xK,ServiceType as t8,logger as p6}from"@elizaos/core";var _0={};KK(_0,{getException:()=>d8,VerbosityLevel:()=>FQ,UnknownErrorException:()=>aQ,Table:()=>X0,Shape:()=>F$,ResponseException:()=>iQ,Rectangle:()=>g6,Point:()=>l,PasswordException:()=>rQ,PDFParse:()=>i8,LineStore:()=>h6,LineDirection:()=>m$,Line:()=>z$,InvalidPDFException:()=>oQ,FormatError:()=>nQ,AbortException:()=>tQ});var j7=($)=>{throw TypeError($)},V6=($,Q,K)=>Q.has($)||j7("Cannot "+K),V$=($,Q,K)=>(V6($,Q,"read from private field"),K?K.call($):Q.get($)),e$=($,Q,K)=>Q.has($)?j7("Cannot add the same private member more than once"):Q instanceof WeakSet?Q.add($):Q.set($,K),b$=($,Q,K,Z)=>(V6($,Q,"write to private field"),Z?Z.call($,K):Q.set($,K),K),$Q=($,Q,K)=>(V6($,Q,"access private method"),K),ZK=($,Q,K,Z)=>({set _(J){b$($,Q,J,K)},get _(){return V$($,Q,Z)}}),RQ,a$,_Q,EQ,N6,YQ,IQ,g$,Y0,B7,F7,cQ,gQ,O0,JK={34:($,Q,K)=>{var Z=K(4901);$.exports=function(J){return typeof J=="object"?J!==null:Z(J)}},81:($,Q,K)=>{var Z=K(9565),J=K(9306),_=K(8551),q=K(6823),G=K(851),U=TypeError;$.exports=function(V,N){var R=arguments.length<2?G(V):N;if(J(R))return _(Z(R,V));throw new U(q(V)+" is not iterable")}},116:($,Q,K)=>{var Z=K(6518),J=K(9565),_=K(2652),q=K(9306),G=K(8551),U=K(1767),V=K(9539),N=K(4549),R=N("find",TypeError);Z({target:"Iterator",proto:!0,real:!0,forced:R},{find:function(F){G(this);try{q(F)}catch(z){V(this,"throw",z)}if(R)return J(R,this,F);var B=U(this),A=0;return _(B,function(z,O){if(F(z,A++))return O(z)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})},283:($,Q,K)=>{var Z=K(9504),J=K(9039),_=K(4901),q=K(9297),G=K(3724),U=K(350).CONFIGURABLE,V=K(3706),N=K(1181),R=N.enforce,j=N.get,F=String,B=Object.defineProperty,A=Z("".slice),z=Z("".replace),O=Z([].join),S=G&&!J(function(){return B(function(){},"length",{value:8}).length!==8}),I=String(String).split("String"),C=$.exports=function(T,k,E){if(A(F(k),0,7)==="Symbol(")k="["+z(F(k),/^Symbol\(([^)]*)\).*$/,"$1")+"]";if(E&&E.getter)k="get "+k;if(E&&E.setter)k="set "+k;if(!q(T,"name")||U&&T.name!==k)if(G)B(T,"name",{value:k,configurable:!0});else T.name=k;if(S&&E&&q(E,"arity")&&T.length!==E.arity)B(T,"length",{value:E.arity});try{if(E&&q(E,"constructor")&&E.constructor){if(G)B(T,"prototype",{writable:!1})}else if(T.prototype)T.prototype=void 0}catch(W){}var M=R(T);if(!q(M,"source"))M.source=O(I,typeof k=="string"?k:"");return T};Function.prototype.toString=C(function(){return _(this)&&j(this).source||V(this)},"toString")},350:($,Q,K)=>{var Z=K(3724),J=K(9297),_=Function.prototype,q=Z&&Object.getOwnPropertyDescriptor,G=J(_,"name"),U=G&&function(){}.name==="something",V=G&&(!Z||Z&&q(_,"name").configurable);$.exports={EXISTS:G,PROPER:U,CONFIGURABLE:V}},397:($,Q,K)=>{var Z=K(7751);$.exports=Z("document","documentElement")},421:($)=>{$.exports={}},456:($,Q,K)=>{var Z=K(6518),J=K(4576),_=K(9504),q=K(4154),G=K(5169),U=_(1.1 .toString),V=J.Uint8Array,N=!V||!V.prototype.toHex||!function(){try{var R=new V([255,255,255,255,255,255,255,255]);return R.toHex()==="ffffffffffffffff"}catch(j){return!1}}();if(V)Z({target:"Uint8Array",proto:!0,forced:N},{toHex:function(){q(this),G(this.buffer);var j="";for(var F=0,B=this.length;F<B;F++){var A=U(this[F],16);j+=A.length===1?"0"+A:A}return j}})},507:($,Q,K)=>{var Z=K(9565);$.exports=function(J,_,q){var G=q?J:J.iterator,U=J.next,V,N;while(!(V=Z(U,G)).done)if(N=_(V.value),N!==void 0)return N}},531:($,Q,K)=>{var Z=K(6518),J=K(9565),_=K(9306),q=K(8551),G=K(1767),U=K(8646),V=K(9462),N=K(9539),R=K(6395),j=K(684),F=K(4549),B=!R&&!j("flatMap",function(){}),A=!R&&!B&&F("flatMap",TypeError),z=R||B||A,O=V(function(){var S=this.iterator,I=this.mapper,C,T;while(!0){if(T=this.inner)try{if(C=q(J(T.next,T.iterator)),!C.done)return C.value;this.inner=null}catch(k){N(S,"throw",k)}if(C=q(J(this.next,S)),this.done=!!C.done)return;try{this.inner=U(I(C.value,this.counter++),!1)}catch(k){N(S,"throw",k)}}});Z({target:"Iterator",proto:!0,real:!0,forced:z},{flatMap:function(I){q(this);try{_(I)}catch(C){N(this,"throw",C)}if(A)return J(A,this,I);return new O(G(this),{mapper:I,inner:null})}})},616:($,Q,K)=>{var Z=K(9039);$.exports=!Z(function(){var J=function(){}.bind();return typeof J!="function"||J.hasOwnProperty("prototype")})},655:($,Q,K)=>{var Z=K(6955),J=String;$.exports=function(_){if(Z(_)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return J(_)}},679:($,Q,K)=>{var Z=K(1625),J=TypeError;$.exports=function(_,q){if(Z(q,_))return _;throw new J("Incorrect invocation")}},684:($)=>{$.exports=function(Q,K){var Z=typeof Iterator=="function"&&Iterator.prototype[Q];if(Z)try{Z.call({next:null},K).next()}catch(J){return!0}}},741:($)=>{var{ceil:Q,floor:K}=Math;$.exports=Math.trunc||function(J){var _=+J;return(_>0?K:Q)(_)}},757:($,Q,K)=>{var Z=K(7751),J=K(4901),_=K(1625),q=K(7040),G=Object;$.exports=q?function(U){return typeof U=="symbol"}:function(U){var V=Z("Symbol");return J(V)&&_(V.prototype,G(U))}},851:($,Q,K)=>{var Z=K(6955),J=K(5966),_=K(4117),q=K(6269),G=K(8227),U=G("iterator");$.exports=function(V){if(!_(V))return J(V,U)||J(V,"@@iterator")||q[Z(V)]}},944:($)=>{var Q=TypeError;$.exports=function(K){var Z=K&&K.alphabet;if(Z===void 0||Z==="base64"||Z==="base64url")return Z||"base64";throw new Q("Incorrect `alphabet` option")}},1072:($,Q,K)=>{var Z=K(1828),J=K(8727);$.exports=Object.keys||function(q){return Z(q,J)}},1103:($)=>{$.exports=function(Q){try{return{error:!1,value:Q()}}catch(K){return{error:!0,value:K}}}},1108:($,Q,K)=>{var Z=K(6955);$.exports=function(J){var _=Z(J);return _==="BigInt64Array"||_==="BigUint64Array"}},1148:($,Q,K)=>{var Z=K(6518),J=K(9565),_=K(2652),q=K(9306),G=K(8551),U=K(1767),V=K(9539),N=K(4549),R=N("every",TypeError);Z({target:"Iterator",proto:!0,real:!0,forced:R},{every:function(F){G(this);try{q(F)}catch(z){V(this,"throw",z)}if(R)return J(R,this,F);var B=U(this),A=0;return!_(B,function(z,O){if(!F(z,A++))return O()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},1181:($,Q,K)=>{var Z=K(8622),J=K(4576),_=K(34),q=K(6699),G=K(9297),U=K(7629),V=K(6119),N=K(421),R="Object already initialized",j=J.TypeError,F=J.WeakMap,B,A,z,O=function(T){return z(T)?A(T):B(T,{})},S=function(T){return function(k){var E;if(!_(k)||(E=A(k)).type!==T)throw new j("Incompatible receiver, "+T+" required");return E}};if(Z||U.state){var I=U.state||(U.state=new F);I.get=I.get,I.has=I.has,I.set=I.set,B=function(T,k){if(I.has(T))throw new j(R);return k.facade=T,I.set(T,k),k},A=function(T){return I.get(T)||{}},z=function(T){return I.has(T)}}else{var C=V("state");N[C]=!0,B=function(T,k){if(G(T,C))throw new j(R);return k.facade=T,q(T,C,k),k},A=function(T){return G(T,C)?T[C]:{}},z=function(T){return G(T,C)}}$.exports={set:B,get:A,has:z,enforce:O,getterFor:S}},1291:($,Q,K)=>{var Z=K(741);$.exports=function(J){var _=+J;return _!==_||_===0?0:Z(_)}},1385:($,Q,K)=>{var Z=K(9539);$.exports=function(J,_,q){for(var G=J.length-1;G>=0;G--){if(J[G]===void 0)continue;try{q=Z(J[G].iterator,_,q)}catch(U){_="throw",q=U}}if(_==="throw")throw q;return q}},1548:($,Q,K)=>{var Z=K(4576),J=K(9039),_=K(9519),q=K(4215),G=Z.structuredClone;$.exports=!!G&&!J(function(){if(q==="DENO"&&_>92||q==="NODE"&&_>94||q==="BROWSER"&&_>97)return!1;var U=new ArrayBuffer(8),V=G(U,{transfer:[U]});return U.byteLength!==0||V.byteLength!==8})},1549:($,Q,K)=>{K(6632)},1625:($,Q,K)=>{var Z=K(9504);$.exports=Z({}.isPrototypeOf)},1689:($,Q,K)=>{var Z=K(6518),J=K(4576),_=K(8745),q=K(7680),G=K(6043),U=K(9306),V=K(1103),N=J.Promise,R=!1,j=!N||!N.try||V(function(){N.try(function(F){R=F===8},8)}).error||!R;Z({target:"Promise",stat:!0,forced:j},{try:function(F){var B=arguments.length>1?q(arguments,1):[],A=G.f(this),z=V(function(){return _(U(F),void 0,B)});return(z.error?A.reject:A.resolve)(z.value),A.promise}})},1698:($,Q,K)=>{var Z=K(6518),J=K(4204),_=K(9835),q=K(4916),G=!q("union")||!_("union");Z({target:"Set",proto:!0,real:!0,forced:G},{union:J})},1701:($,Q,K)=>{var Z=K(6518),J=K(9565),_=K(9306),q=K(8551),G=K(1767),U=K(9462),V=K(6319),N=K(9539),R=K(684),j=K(4549),F=K(6395),B=!F&&!R("map",function(){}),A=!F&&!B&&j("map",TypeError),z=F||B||A,O=U(function(){var S=this.iterator,I=q(J(this.next,S)),C=this.done=!!I.done;if(!C)return V(S,this.mapper,[I.value,this.counter++],!0)});Z({target:"Iterator",proto:!0,real:!0,forced:z},{map:function(I){q(this);try{_(I)}catch(C){N(this,"throw",C)}if(A)return J(A,this,I);return new O(G(this),{mapper:I})}})},1767:($)=>{$.exports=function(Q){return{iterator:Q,next:Q.next,done:!1}}},1828:($,Q,K)=>{var Z=K(9504),J=K(9297),_=K(5397),q=K(9617).indexOf,G=K(421),U=Z([].push);$.exports=function(V,N){var R=_(V),j=0,F=[],B;for(B in R)!J(G,B)&&J(R,B)&&U(F,B);while(N.length>j)if(J(R,B=N[j++]))~q(F,B)||U(F,B);return F}},2106:($,Q,K)=>{var Z=K(283),J=K(4913);$.exports=function(_,q,G){if(G.get)Z(G.get,q,{getter:!0});if(G.set)Z(G.set,q,{setter:!0});return J.f(_,q,G)}},2140:($,Q,K)=>{var Z=K(8227),J=Z("toStringTag"),_={};_[J]="z",$.exports=String(_)==="[object z]"},2195:($,Q,K)=>{var Z=K(9504),J=Z({}.toString),_=Z("".slice);$.exports=function(q){return _(J(q),8,-1)}},2211:($,Q,K)=>{var Z=K(9039);$.exports=!Z(function(){function J(){}return J.prototype.constructor=null,Object.getPrototypeOf(new J)!==J.prototype})},2303:($,Q,K)=>{var Z=K(4576),J=K(9504),_=Z.Uint8Array,q=Z.SyntaxError,G=Z.parseInt,U=Math.min,V=/[^\da-f]/i,N=J(V.exec),R=J("".slice);$.exports=function(j,F){var B=j.length;if(B%2!==0)throw new q("String should be an even number of characters");var A=F?U(F.length,B/2):B/2,z=F||new _(A),O=0,S=0;while(S<A){var I=R(j,O,O+=2);if(N(V,I))throw new q("String should only contain hex characters");z[S++]=G(I,16)}return{bytes:z,read:O}}},2360:($,Q,K)=>{var Z=K(8551),J=K(6801),_=K(8727),q=K(421),G=K(397),U=K(4055),V=K(6119),N=">",R="<",j="prototype",F="script",B=V("IE_PROTO"),A=function(){},z=function(T){return R+F+N+T+R+"/"+F+N},O=function(T){T.write(z("")),T.close();var k=T.parentWindow.Object;return T=null,k},S=function(){var T=U("iframe"),k="java"+F+":",E;return T.style.display="none",G.appendChild(T),T.src=String(k),E=T.contentWindow.document,E.open(),E.write(z("document.F=Object")),E.close(),E.F},I,C=function(){try{I=new ActiveXObject("htmlfile")}catch(k){}C=typeof document<"u"?document.domain&&I?O(I):S():O(I);var T=_.length;while(T--)delete C[j][_[T]];return C()};q[B]=!0,$.exports=Object.create||function(k,E){var M;if(k!==null)A[j]=Z(k),M=new A,A[j]=null,M[B]=k;else M=C();return E===void 0?M:J.f(M,E)}},2475:($,Q,K)=>{var Z=K(6518),J=K(8527),_=K(4916),q=!_("isSupersetOf",function(G){return!G});Z({target:"Set",proto:!0,real:!0,forced:q},{isSupersetOf:J})},2489:($,Q,K)=>{var Z=K(6518),J=K(9565),_=K(9306),q=K(8551),G=K(1767),U=K(9462),V=K(6319),N=K(6395),R=K(9539),j=K(684),F=K(4549),B=!N&&!j("filter",function(){}),A=!N&&!B&&F("filter",TypeError),z=N||B||A,O=U(function(){var S=this.iterator,I=this.predicate,C=this.next,T,k,E;while(!0){if(T=q(J(C,S)),k=this.done=!!T.done,k)return;if(E=T.value,V(S,I,[E,this.counter++],!0))return E}});Z({target:"Iterator",proto:!0,real:!0,forced:z},{filter:function(I){q(this);try{_(I)}catch(C){R(this,"throw",C)}if(A)return J(A,this,I);return new O(G(this),{predicate:I})}})},2529:($)=>{$.exports=function(Q,K){return{value:Q,done:K}}},2603:($,Q,K)=>{var Z=K(655);$.exports=function(J,_){return J===void 0?arguments.length<2?"":_:Z(J)}},2652:($,Q,K)=>{var Z=K(6080),J=K(9565),_=K(8551),q=K(6823),G=K(4209),U=K(6198),V=K(1625),N=K(81),R=K(851),j=K(9539),F=TypeError,B=function(z,O){this.stopped=z,this.result=O},A=B.prototype;$.exports=function(z,O,S){var I=S&&S.that,C=!!(S&&S.AS_ENTRIES),T=!!(S&&S.IS_RECORD),k=!!(S&&S.IS_ITERATOR),E=!!(S&&S.INTERRUPTED),M=Z(O,I),W,X,Y,y,D,b,H,P=function(u){if(W)j(W,"normal");return new B(!0,u)},v=function(u){if(C)return _(u),E?M(u[0],u[1],P):M(u[0],u[1]);return E?M(u,P):M(u)};if(T)W=z.iterator;else if(k)W=z;else{if(X=R(z),!X)throw new F(q(z)+" is not iterable");if(G(X)){for(Y=0,y=U(z);y>Y;Y++)if(D=v(z[Y]),D&&V(A,D))return D;return new B(!1)}W=N(z,X)}b=T?z.next:W.next;while(!(H=J(b,W)).done){try{D=v(H.value)}catch(u){j(W,"throw",u)}if(typeof D=="object"&&D&&V(A,D))return D}return new B(!1)}},2777:($,Q,K)=>{var Z=K(9565),J=K(34),_=K(757),q=K(5966),G=K(4270),U=K(8227),V=TypeError,N=U("toPrimitive");$.exports=function(R,j){if(!J(R)||_(R))return R;var F=q(R,N),B;if(F){if(j===void 0)j="default";if(B=Z(F,R,j),!J(B)||_(B))return B;throw new V("Can't convert object to primitive value")}if(j===void 0)j="number";return G(R,j)}},2787:($,Q,K)=>{var Z=K(9297),J=K(4901),_=K(8981),q=K(6119),G=K(2211),U=q("IE_PROTO"),V=Object,N=V.prototype;$.exports=G?V.getPrototypeOf:function(R){var j=_(R);if(Z(j,U))return j[U];var F=j.constructor;if(J(F)&&j instanceof F)return F.prototype;return j instanceof V?N:null}},2796:($,Q,K)=>{var Z=K(9039),J=K(4901),_=/#|\.prototype\./,q=function(R,j){var F=U[G(R)];return F===N?!0:F===V?!1:J(j)?Z(j):!!j},G=q.normalize=function(R){return String(R).replace(_,".").toLowerCase()},U=q.data={},V=q.NATIVE="N",N=q.POLYFILL="P";$.exports=q},2804:($)=>{var Q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",K=Q+"+/",Z=Q+"-_",J=function(_){var q={},G=0;for(;G<64;G++)q[_.charAt(G)]=G;return q};$.exports={i2c:K,c2i:J(K),i2cUrl:Z,c2iUrl:J(Z)}},2812:($)=>{var Q=TypeError;$.exports=function(K,Z){if(K<Z)throw new Q("Not enough arguments");return K}},2839:($,Q,K)=>{var Z=K(4576),J=Z.navigator,_=J&&J.userAgent;$.exports=_?String(_):""},2967:($,Q,K)=>{var Z=K(6706),J=K(34),_=K(7750),q=K(3506);$.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var G=!1,U={},V;try{V=Z(Object.prototype,"__proto__","set"),V(U,[]),G=U instanceof Array}catch(N){}return function(R,j){if(_(R),q(j),!J(R))return R;if(G)V(R,j);else R.__proto__=j;return R}}():void 0)},3068:($,Q,K)=>{var Z=K(6518),J=K(9504),_=K(2652),q=RangeError,G=TypeError,U=1/0,V=NaN,N=Math.abs,R=Math.pow,j=J([].push),F=R(2,1023),B=R(2,53)-1,A=Number.MAX_VALUE,z=R(2,971),O={},S={},I={},C={},T={},k=function(E,M){var W=E+M,X=M-(W-E);return{hi:W,lo:X}};Z({target:"Math",stat:!0},{sumPrecise:function(M){var W=[],X=0,Y=C;switch(_(M,function(f){if(++X>=B)throw new q("Maximum allowed index exceeded");if(typeof f!="number")throw new G("Value is not a number");if(Y!==O){if(f!==f)Y=O;else if(f===U)Y=Y===S?O:I;else if(f===-U)Y=Y===I?O:S;else if((f!==0||1/f===U)&&(Y===C||Y===T))Y=T,j(W,f)}}),Y){case O:return V;case S:return-U;case I:return U;case C:return-0}var y=[],D=0,b,H,P,v,u,a;for(var Q$=0;Q$<W.length;Q$++){b=W[Q$];var G$=0;for(var t=0;t<y.length;t++){if(H=y[t],N(b)<N(H))a=b,b=H,H=a;if(P=k(b,H),v=P.hi,u=P.lo,N(v)===U){var e=v===U?1:-1;if(D+=e,b=b-e*F-e*F,N(b)<N(H))a=b,b=H,H=a;P=k(b,H),v=P.hi,u=P.lo}if(u!==0)y[G$++]=u;b=v}if(y.length=G$,b!==0)j(y,b)}var q$=y.length-1;if(v=0,u=0,D!==0){var k$=q$>=0?y[q$]:0;if(q$--,N(D)>1||D>0&&k$>0||D<0&&k$<0)return D>0?U:-U;if(P=k(D*F,k$/2),v=P.hi,u=P.lo,u*=2,N(2*v)===U){if(v>0)return v===F&&u===-(z/2)&&q$>=0&&y[q$]<0?A:U;return v===-F&&u===z/2&&q$>=0&&y[q$]>0?-A:-U}if(u!==0)y[++q$]=u,u=0;v*=2}while(q$>=0)if(P=k(v,y[q$--]),v=P.hi,u=P.lo,u!==0)break;if(q$>=0&&(u<0&&y[q$]<0||u>0&&y[q$]>0)){if(H=u*2,b=v+H,H===b-v)v=b}return v}})},3167:($,Q,K)=>{var Z=K(4901),J=K(34),_=K(2967);$.exports=function(q,G,U){var V,N;if(_&&Z(V=G.constructor)&&V!==U&&J(N=V.prototype)&&N!==U.prototype)_(q,N);return q}},3238:($,Q,K)=>{var Z=K(4576),J=K(7811),_=K(7394),q=Z.DataView;$.exports=function(G){if(!J||_(G)!==0)return!1;try{return new q(G),!1}catch(U){return!0}}},3392:($,Q,K)=>{var Z=K(9504),J=0,_=Math.random(),q=Z(1.1 .toString);$.exports=function(G){return"Symbol("+(G===void 0?"":G)+")_"+q(++J+_,36)}},3440:($,Q,K)=>{var Z=K(7080),J=K(4402),_=K(9286),q=K(5170),G=K(3789),U=K(8469),V=K(507),N=J.has,R=J.remove;$.exports=function(F){var B=Z(this),A=G(F),z=_(B);if(q(B)<=A.size)U(B,function(O){if(A.includes(O))R(z,O)});else V(A.getIterator(),function(O){if(N(z,O))R(z,O)});return z}},3463:($)=>{var Q=TypeError;$.exports=function(K){if(typeof K=="string")return K;throw new Q("Argument is not a string")}},3506:($,Q,K)=>{var Z=K(3925),J=String,_=TypeError;$.exports=function(q){if(Z(q))return q;throw new _("Can't set "+J(q)+" as a prototype")}},3579:($,Q,K)=>{var Z=K(6518),J=K(9565),_=K(2652),q=K(9306),G=K(8551),U=K(1767),V=K(9539),N=K(4549),R=N("some",TypeError);Z({target:"Iterator",proto:!0,real:!0,forced:R},{some:function(F){G(this);try{q(F)}catch(z){V(this,"throw",z)}if(R)return J(R,this,F);var B=U(this),A=0;return _(B,function(z,O){if(F(z,A++))return O()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},3650:($,Q,K)=>{var Z=K(7080),J=K(4402),_=K(9286),q=K(3789),G=K(507),U=J.add,V=J.has,N=J.remove;$.exports=function(j){var F=Z(this),B=q(j).getIterator(),A=_(F);return G(B,function(z){if(V(F,z))N(A,z);else U(A,z)}),A}},3706:($,Q,K)=>{var Z=K(9504),J=K(4901),_=K(7629),q=Z(Function.toString);if(!J(_.inspectSource))_.inspectSource=function(G){return q(G)};$.exports=_.inspectSource},3717:($,Q)=>{Q.f=Object.getOwnPropertySymbols},3724:($,Q,K)=>{var Z=K(9039);$.exports=!Z(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})},3789:($,Q,K)=>{var Z=K(9306),J=K(8551),_=K(9565),q=K(1291),G=K(1767),U="Invalid size",V=RangeError,N=TypeError,R=Math.max,j=function(F,B){this.set=F,this.size=R(B,0),this.has=Z(F.has),this.keys=Z(F.keys)};j.prototype={getIterator:function(){return G(J(_(this.keys,this.set)))},includes:function(F){return _(this.has,this.set,F)}},$.exports=function(F){J(F);var B=+F.size;if(B!==B)throw new N(U);var A=q(B);if(A<0)throw new V(U);return new j(F,A)}},3838:($,Q,K)=>{var Z=K(7080),J=K(5170),_=K(8469),q=K(3789);$.exports=function(U){var V=Z(this),N=q(U);if(J(V)>N.size)return!1;return _(V,function(R){if(!N.includes(R))return!1},!0)!==!1}},3853:($,Q,K)=>{var Z=K(6518),J=K(4449),_=K(4916),q=!_("isDisjointFrom",function(G){return!G});Z({target:"Set",proto:!0,real:!0,forced:q},{isDisjointFrom:J})},3925:($,Q,K)=>{var Z=K(34);$.exports=function(J){return Z(J)||J===null}},3972:($,Q,K)=>{var Z=K(34),J=String,_=TypeError;$.exports=function(q){if(q===void 0||Z(q))return q;throw new _(J(q)+" is not an object or undefined")}},4055:($,Q,K)=>{var Z=K(4576),J=K(34),_=Z.document,q=J(_)&&J(_.createElement);$.exports=function(G){return q?_.createElement(G):{}}},4114:($,Q,K)=>{var Z=K(6518),J=K(8981),_=K(6198),q=K(4527),G=K(6837),U=K(9039),V=U(function(){return[].push.call({length:4294967296},1)!==4294967297}),N=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(j){return j instanceof TypeError}},R=V||!N();Z({target:"Array",proto:!0,arity:1,forced:R},{push:function(F){var B=J(this),A=_(B),z=arguments.length;G(A+z);for(var O=0;O<z;O++)B[A]=arguments[O],A++;return q(B,A),A}})},4117:($)=>{$.exports=function(Q){return Q===null||Q===void 0}},4149:($)=>{var Q=RangeError;$.exports=function(K){if(K===K)return K;throw new Q("NaN is not allowed")}},4154:($,Q,K)=>{var Z=K(6955),J=TypeError;$.exports=function(_){if(Z(_)==="Uint8Array")return _;throw new J("Argument is not an Uint8Array")}},4204:($,Q,K)=>{var Z=K(7080),J=K(4402).add,_=K(9286),q=K(3789),G=K(507);$.exports=function(V){var N=Z(this),R=q(V).getIterator(),j=_(N);return G(R,function(F){J(j,F)}),j}},4209:($,Q,K)=>{var Z=K(8227),J=K(6269),_=Z("iterator"),q=Array.prototype;$.exports=function(G){return G!==void 0&&(J.Array===G||q[_]===G)}},4215:($,Q,K)=>{var Z=K(4576),J=K(2839),_=K(2195),q=function(G){return J.slice(0,G.length)===G};$.exports=function(){if(q("Bun/"))return"BUN";if(q("Cloudflare-Workers"))return"CLOUDFLARE";if(q("Deno/"))return"DENO";if(q("Node.js/"))return"NODE";if(Z.Bun&&typeof Bun.version=="string")return"BUN";if(Z.Deno&&typeof Deno.version=="object")return"DENO";if(_(Z.process)==="process")return"NODE";if(Z.window&&Z.document)return"BROWSER";return"REST"}()},4226:($,Q,K)=>{var Z=K(6518),J=K(4576),_=K(3463),q=K(4154),G=K(5169),U=K(2303);if(J.Uint8Array)Z({target:"Uint8Array",proto:!0},{setFromHex:function(N){q(this),_(N),G(this.buffer);var R=U(N,this).read;return{read:R,written:R/2}}})},4235:($,Q,K)=>{K(3068)},4270:($,Q,K)=>{var Z=K(9565),J=K(4901),_=K(34),q=TypeError;$.exports=function(G,U){var V,N;if(U==="string"&&J(V=G.toString)&&!_(N=Z(V,G)))return N;if(J(V=G.valueOf)&&!_(N=Z(V,G)))return N;if(U!=="string"&&J(V=G.toString)&&!_(N=Z(V,G)))return N;throw new q("Can't convert object to primitive value")}},4376:($,Q,K)=>{var Z=K(2195);$.exports=Array.isArray||function(_){return Z(_)==="Array"}},4402:($,Q,K)=>{var Z=K(9504),J=Set.prototype;$.exports={Set,add:Z(J.add),has:Z(J.has),remove:Z(J.delete),proto:J}},4449:($,Q,K)=>{var Z=K(7080),J=K(4402).has,_=K(5170),q=K(3789),G=K(8469),U=K(507),V=K(9539);$.exports=function(R){var j=Z(this),F=q(R);if(_(j)<=F.size)return G(j,function(A){if(F.includes(A))return!1},!0)!==!1;var B=F.getIterator();return U(B,function(A){if(J(j,A))return V(B,"normal",!1)})!==!1}},4483:($,Q,K)=>{var Z=K(4576),J=K(9429),_=K(1548),q=Z.structuredClone,G=Z.ArrayBuffer,U=Z.MessageChannel,V=!1,N,R,j,F;if(_)V=function(B){q(B,{transfer:[B]})};else if(G)try{if(!U){if(N=J("worker_threads"),N)U=N.MessageChannel}if(U){if(R=new U,j=new G(2),F=function(B){R.port1.postMessage(null,[B])},j.byteLength===2){if(F(j),j.byteLength===0)V=F}}}catch(B){}$.exports=V},4495:($,Q,K)=>{var Z=K(9519),J=K(9039),_=K(4576),q=_.String;$.exports=!!Object.getOwnPropertySymbols&&!J(function(){var G=Symbol("symbol detection");return!q(G)||!(Object(G)instanceof Symbol)||!Symbol.sham&&Z&&Z<41})},4527:($,Q,K)=>{var Z=K(3724),J=K(4376),_=TypeError,q=Object.getOwnPropertyDescriptor,G=Z&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(U){return U instanceof TypeError}}();$.exports=G?function(U,V){if(J(U)&&!q(U,"length").writable)throw new _("Cannot set read only .length");return U.length=V}:function(U,V){return U.length=V}},4549:($,Q,K)=>{var Z=K(4576);$.exports=function(J,_){var q=Z.Iterator,G=q&&q.prototype,U=G&&G[J],V=!1;if(U)try{U.call({next:function(){return{done:!0}},return:function(){V=!0}},-1)}catch(N){if(!(N instanceof _))V=!1}if(!V)return U}},4576:function($){var Q=function(K){return K&&K.Math===Math&&K};$.exports=Q(typeof globalThis=="object"&&globalThis)||Q(typeof window=="object"&&window)||Q(typeof self=="object"&&self)||Q(typeof global=="object"&&global)||Q(typeof this=="object"&&this)||function(){return this}()||Function("return this")()},4603:($,Q,K)=>{var Z=K(6840),J=K(9504),_=K(655),q=K(2812),G=URLSearchParams,U=G.prototype,V=J(U.append),N=J(U.delete),R=J(U.forEach),j=J([].push),F=new G("a=1&a=2&b=3");if(F.delete("a",1),F.delete("b",void 0),F+""!=="a=2")Z(U,"delete",function(B){var A=arguments.length,z=A<2?void 0:arguments[1];if(A&&z===void 0)return N(this,B);var O=[];R(this,function(W,X){j(O,{key:X,value:W})}),q(A,1);var S=_(B),I=_(z),C=0,T=0,k=!1,E=O.length,M;while(C<E)if(M=O[C++],k||M.key===S)k=!0,N(this,M.key);else T++;while(T<E)if(M=O[T++],!(M.key===S&&M.value===I))V(this,M.key,M.value)},{enumerable:!0,unsafe:!0})},4628:($,Q,K)=>{var Z=K(6518),J=K(6043);Z({target:"Promise",stat:!0},{withResolvers:function(){var q=J.f(this);return{promise:q.promise,resolve:q.resolve,reject:q.reject}}})},4644:($,Q,K)=>{var Z=K(7811),J=K(3724),_=K(4576),q=K(4901),G=K(34),U=K(9297),V=K(6955),N=K(6823),R=K(6699),j=K(6840),F=K(2106),B=K(1625),A=K(2787),z=K(2967),O=K(8227),S=K(3392),I=K(1181),C=I.enforce,T=I.get,k=_.Int8Array,E=k&&k.prototype,M=_.Uint8ClampedArray,W=M&&M.prototype,X=k&&A(k),Y=E&&A(E),y=Object.prototype,D=_.TypeError,b=O("toStringTag"),H=S("TYPED_ARRAY_TAG"),P="TypedArrayConstructor",v=Z&&!!z&&V(_.opera)!=="Opera",u=!1,a,Q$,G$,t={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},e={BigInt64Array:8,BigUint64Array:8},q$=function(J$){if(!G(J$))return!1;var _$=V(J$);return _$==="DataView"||U(t,_$)||U(e,_$)},k$=function(h){var J$=A(h);if(!G(J$))return;var _$=T(J$);return _$&&U(_$,P)?_$[P]:k$(J$)},f=function(h){if(!G(h))return!1;var J$=V(h);return U(t,J$)||U(e,J$)},L=function(h){if(f(h))return h;throw new D("Target is not a typed array")},w=function(h){if(q(h)&&(!z||B(X,h)))return h;throw new D(N(h)+" is not a typed array constructor")},o=function(h,J$,_$,x$){if(!J)return;if(_$)for(var Y$ in t){var T$=_[Y$];if(T$&&U(T$.prototype,h))try{delete T$.prototype[h]}catch(zQ){try{T$.prototype[h]=J$}catch(m0){}}}if(!Y[h]||_$)j(Y,h,_$?J$:v&&E[h]||J$,x$)},K$=function(h,J$,_$){var x$,Y$;if(!J)return;if(z){if(_$){for(x$ in t)if(Y$=_[x$],Y$&&U(Y$,h))try{delete Y$[h]}catch(T$){}}if(!X[h]||_$)try{return j(X,h,_$?J$:v&&X[h]||J$)}catch(T$){}else return}for(x$ in t)if(Y$=_[x$],Y$&&(!Y$[h]||_$))j(Y$,h,J$)};for(a in t)if(Q$=_[a],G$=Q$&&Q$.prototype,G$)C(G$)[P]=Q$;else v=!1;for(a in e)if(Q$=_[a],G$=Q$&&Q$.prototype,G$)C(G$)[P]=Q$;if(!v||!q(X)||X===Function.prototype){if(X=function(){throw new D("Incorrect invocation")},v){for(a in t)if(_[a])z(_[a],X)}}if(!v||!Y||Y===y){if(Y=X.prototype,v){for(a in t)if(_[a])z(_[a].prototype,Y)}}if(v&&A(W)!==Y)z(W,Y);if(J&&!U(Y,b)){u=!0,F(Y,b,{configurable:!0,get:function(){return G(this)?this[H]:void 0}});for(a in t)if(_[a])R(_[a],H,a)}$.exports={NATIVE_ARRAY_BUFFER_VIEWS:v,TYPED_ARRAY_TAG:u&&H,aTypedArray:L,aTypedArrayConstructor:w,exportTypedArrayMethod:o,exportTypedArrayStaticMethod:K$,getTypedArrayConstructor:k$,isView:q$,isTypedArray:f,TypedArray:X,TypedArrayPrototype:Y}},4659:($,Q,K)=>{var Z=K(3724),J=K(4913),_=K(6980);$.exports=function(q,G,U){if(Z)J.f(q,G,_(0,U));else q[G]=U}},4901:($)=>{var Q=typeof document=="object"&&document.all;$.exports=typeof Q>"u"&&Q!==void 0?function(K){return typeof K=="function"||K===Q}:function(K){return typeof K=="function"}},4913:($,Q,K)=>{var Z=K(3724),J=K(5917),_=K(8686),q=K(8551),G=K(6969),U=TypeError,V=Object.defineProperty,N=Object.getOwnPropertyDescriptor,R="enumerable",j="configurable",F="writable";Q.f=Z?_?function(A,z,O){if(q(A),z=G(z),q(O),typeof A==="function"&&z==="prototype"&&"value"in O&&F in O&&!O[F]){var S=N(A,z);if(S&&S[F])A[z]=O.value,O={configurable:j in O?O[j]:S[j],enumerable:R in O?O[R]:S[R],writable:!1}}return V(A,z,O)}:V:function(A,z,O){if(q(A),z=G(z),q(O),J)try{return V(A,z,O)}catch(S){}if("get"in O||"set"in O)throw new U("Accessors not supported");if("value"in O)A[z]=O.value;return A}},4916:($,Q,K)=>{var Z=K(7751),J=function(q){return{size:q,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},_=function(q){return{size:q,has:function(){return!0},keys:function(){throw Error("e")}}};$.exports=function(q,G){var U=Z("Set");try{new U()[q](J(0));try{return new U()[q](J(-1)),!1}catch(N){if(!G)return!0;try{return new U()[q](_(-1/0)),!1}catch(R){var V=new U;return V.add(1),V.add(2),G(V[q](_(1/0)))}}}catch(N){return!1}}},4972:($,Q,K)=>{var Z=K(6518),J=K(9565),_=K(8551),q=K(1767),G=K(4149),U=K(9590),V=K(9462),N=K(9539),R=K(4549),j=K(6395),F=!j&&R("take",RangeError),B=V(function(){var A=this.iterator;if(!this.remaining--)return this.done=!0,N(A,"normal",void 0);var z=_(J(this.next,A)),O=this.done=!!z.done;if(!O)return z.value});Z({target:"Iterator",proto:!0,real:!0,forced:j||F},{take:function(z){_(this);var O;try{O=U(G(+z))}catch(S){N(this,"throw",S)}if(F)return J(F,this,O);return new B(q(this),{remaining:O})}})},4979:($,Q,K)=>{var Z=K(6518),J=K(4576),_=K(7751),q=K(6980),G=K(4913).f,U=K(9297),V=K(679),N=K(3167),R=K(2603),j=K(5002),F=K(8574),B=K(3724),A=K(6395),z="DOMException",O=_("Error"),S=_(z),I=function(){V(this,C);var P=arguments.length,v=R(P<1?void 0:arguments[0]),u=R(P<2?void 0:arguments[1],"Error"),a=new S(v,u),Q$=new O(v);return Q$.name=z,G(a,"stack",q(1,F(Q$.stack,1))),N(a,this,I),a},C=I.prototype=S.prototype,T="stack"in new O(z),k="stack"in new S(1,2),E=S&&B&&Object.getOwnPropertyDescriptor(J,z),M=!!E&&!(E.writable&&E.configurable),W=T&&!M&&!k;Z({global:!0,constructor:!0,forced:A||W},{DOMException:W?I:S});var X=_(z),Y=X.prototype;if(Y.constructor!==X){if(!A)G(Y,"constructor",q(1,X));for(var y in j)if(U(j,y)){var D=j[y],b=D.s;if(!U(X,b))G(X,b,q(6,D.c))}}},5002:($)=>{$.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}}},5024:($,Q,K)=>{var Z=K(6518),J=K(3650),_=K(9835),q=K(4916),G=!q("symmetricDifference")||!_("symmetricDifference");Z({target:"Set",proto:!0,real:!0,forced:G},{symmetricDifference:J})},5031:($,Q,K)=>{var Z=K(7751),J=K(9504),_=K(8480),q=K(3717),G=K(8551),U=J([].concat);$.exports=Z("Reflect","ownKeys")||function(N){var R=_.f(G(N)),j=q.f;return j?U(R,j(N)):R}},5169:($,Q,K)=>{var Z=K(3238),J=TypeError;$.exports=function(_){if(Z(_))throw new J("ArrayBuffer is detached");return _}},5170:($,Q,K)=>{var Z=K(6706),J=K(4402);$.exports=Z(J.proto,"size","get")||function(_){return _.size}},5213:($,Q,K)=>{var Z=K(6518),J=K(4576),_=K(5370),q=K(9143),G=J.Uint8Array,U=!G||!G.fromBase64||!function(){try{G.fromBase64("a");return}catch(V){}try{G.fromBase64("",null)}catch(V){return!0}}();if(G)Z({target:"Uint8Array",stat:!0,forced:U},{fromBase64:function(N){var R=q(N,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return _(G,R.bytes)}})},5370:($,Q,K)=>{var Z=K(6198);$.exports=function(J,_,q){var G=0,U=arguments.length>2?q:Z(_),V=new J(U);while(U>G)V[G]=_[G++];return V}},5397:($,Q,K)=>{var Z=K(7055),J=K(7750);$.exports=function(_){return Z(J(_))}},5610:($,Q,K)=>{var Z=K(1291),J=Math.max,_=Math.min;$.exports=function(q,G){var U=Z(q);return U<0?J(U+G,0):_(U,G)}},5623:($,Q,K)=>{K(456)},5636:($,Q,K)=>{var Z=K(4576),J=K(9504),_=K(6706),q=K(7696),G=K(5169),U=K(7394),V=K(4483),N=K(1548),R=Z.structuredClone,j=Z.ArrayBuffer,F=Z.DataView,B=Math.min,A=j.prototype,z=F.prototype,O=J(A.slice),S=_(A,"resizable","get"),I=_(A,"maxByteLength","get"),C=J(z.getInt8),T=J(z.setInt8);$.exports=(N||V)&&function(k,E,M){var W=U(k),X=E===void 0?W:q(E),Y=!S||!S(k),y;if(G(k),N){if(k=R(k,{transfer:[k]}),W===X&&(M||Y))return k}if(W>=X&&(!M||Y))y=O(k,0,X);else{var D=M&&!Y&&I?{maxByteLength:I(k)}:void 0;y=new j(X,D);var b=new F(k),H=new F(y),P=B(X,W);for(var v=0;v<P;v++)T(H,v,C(b,v))}if(!N)V(k);return y}},5745:($,Q,K)=>{var Z=K(7629);$.exports=function(J,_){return Z[J]||(Z[J]=_||{})}},5781:($,Q,K)=>{var Z=K(6518),J=K(7751),_=K(2812),q=K(655),G=K(7416),U=J("URL");Z({target:"URL",stat:!0,forced:!G},{parse:function(N){var R=_(arguments.length,1),j=q(N),F=R<2||arguments[1]===void 0?void 0:q(arguments[1]);try{return new U(j,F)}catch(B){return null}}})},5854:($,Q,K)=>{var Z=K(2777),J=TypeError;$.exports=function(_){var q=Z(_,"number");if(typeof q=="number")throw new J("Can't convert number to bigint");return BigInt(q)}},5876:($,Q,K)=>{var Z=K(6518),J=K(3838),_=K(4916),q=!_("isSubsetOf",function(G){return G});Z({target:"Set",proto:!0,real:!0,forced:q},{isSubsetOf:J})},5917:($,Q,K)=>{var Z=K(3724),J=K(9039),_=K(4055);$.exports=!Z&&!J(function(){return Object.defineProperty(_("div"),"a",{get:function(){return 7}}).a!==7})},5966:($,Q,K)=>{var Z=K(9306),J=K(4117);$.exports=function(_,q){var G=_[q];return J(G)?void 0:Z(G)}},6043:($,Q,K)=>{var Z=K(9306),J=TypeError,_=function(q){var G,U;this.promise=new q(function(V,N){if(G!==void 0||U!==void 0)throw new J("Bad Promise constructor");G=V,U=N}),this.resolve=Z(G),this.reject=Z(U)};$.exports.f=function(q){return new _(q)}},6080:($,Q,K)=>{var Z=K(7476),J=K(9306),_=K(616),q=Z(Z.bind);$.exports=function(G,U){return J(G),U===void 0?G:_?q(G,U):function(){return G.apply(U,arguments)}}},6119:($,Q,K)=>{var Z=K(5745),J=K(3392),_=Z("keys");$.exports=function(q){return _[q]||(_[q]=J(q))}},6193:($,Q,K)=>{var Z=K(4215);$.exports=Z==="NODE"},6198:($,Q,K)=>{var Z=K(8014);$.exports=function(J){return Z(J.length)}},6269:($)=>{$.exports={}},6279:($,Q,K)=>{var Z=K(6840);$.exports=function(J,_,q){for(var G in _)Z(J,G,_[G],q);return J}},6319:($,Q,K)=>{var Z=K(8551),J=K(9539);$.exports=function(_,q,G,U){try{return U?q(Z(G)[0],G[1]):q(G)}catch(V){J(_,"throw",V)}}},6395:($)=>{$.exports=!1},6518:($,Q,K)=>{var Z=K(4576),J=K(7347).f,_=K(6699),q=K(6840),G=K(9433),U=K(7740),V=K(2796);$.exports=function(N,R){var{target:j,global:F,stat:B}=N,A,z,O,S,I,C;if(F)z=Z;else if(B)z=Z[j]||G(j,{});else z=Z[j]&&Z[j].prototype;if(z)for(O in R){if(I=R[O],N.dontCallGetSet)C=J(z,O),S=C&&C.value;else S=z[O];if(A=V(F?O:j+(B?".":"#")+O,N.forced),!A&&S!==void 0){if(typeof I==typeof S)continue;U(I,S)}if(N.sham||S&&S.sham)_(I,"sham",!0);q(z,O,I,N)}}},6573:($,Q,K)=>{var Z=K(3724),J=K(2106),_=K(3238),q=ArrayBuffer.prototype;if(Z&&!("detached"in q))J(q,"detached",{configurable:!0,get:function(){return _(this)}})},6632:($,Q,K)=>{var Z=K(6518),J=K(4576),_=K(9143),q=K(4154),G=J.Uint8Array,U=!G||!G.prototype.setFromBase64||!function(){var V=new G([255,255,255,255,255]);try{V.setFromBase64("",null);return}catch(N){}try{V.setFromBase64("a");return}catch(N){}try{V.setFromBase64("MjYyZg===")}catch(N){return V[0]===50&&V[1]===54&&V[2]===50&&V[3]===255&&V[4]===255}}();if(G)Z({target:"Uint8Array",proto:!0,forced:U},{setFromBase64:function(N){q(this);var R=_(N,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:R.read,written:R.written}}})},6699:($,Q,K)=>{var Z=K(3724),J=K(4913),_=K(6980);$.exports=Z?function(q,G,U){return J.f(q,G,_(1,U))}:function(q,G,U){return q[G]=U,q}},6706:($,Q,K)=>{var Z=K(9504),J=K(9306);$.exports=function(_,q,G){try{return Z(J(Object.getOwnPropertyDescriptor(_,q)[G]))}catch(U){}}},6801:($,Q,K)=>{var Z=K(3724),J=K(8686),_=K(4913),q=K(8551),G=K(5397),U=K(1072);Q.f=Z&&!J?Object.defineProperties:function(N,R){q(N);var j=G(R),F=U(R),B=F.length,A=0,z;while(B>A)_.f(N,z=F[A++],j[z]);return N}},6823:($)=>{var Q=String;$.exports=function(K){try{return Q(K)}catch(Z){return"Object"}}},6837:($)=>{var Q=TypeError,K=9007199254740991;$.exports=function(Z){if(Z>K)throw Q("Maximum allowed index exceeded");return Z}},6840:($,Q,K)=>{var Z=K(4901),J=K(4913),_=K(283),q=K(9433);$.exports=function(G,U,V,N){if(!N)N={};var R=N.enumerable,j=N.name!==void 0?N.name:U;if(Z(V))_(V,j,N);if(N.global)if(R)G[U]=V;else q(U,V);else{try{if(!N.unsafe)delete G[U];else if(G[U])R=!0}catch(F){}if(R)G[U]=V;else J.f(G,U,{value:V,enumerable:!1,configurable:!N.nonConfigurable,writable:!N.nonWritable})}return G}},6955:($,Q,K)=>{var Z=K(2140),J=K(4901),_=K(2195),q=K(8227),G=q("toStringTag"),U=Object,V=_(function(){return arguments}())==="Arguments",N=function(R,j){try{return R[j]}catch(F){}};$.exports=Z?_:function(R){var j,F,B;return R===void 0?"Undefined":R===null?"Null":typeof(F=N(j=U(R),G))=="string"?F:V?_(j):(B=_(j))==="Object"&&J(j.callee)?"Arguments":B}},6969:($,Q,K)=>{var Z=K(2777),J=K(757);$.exports=function(_){var q=Z(_,"string");return J(q)?q:q+""}},6980:($)=>{$.exports=function(Q,K){return{enumerable:!(Q&1),configurable:!(Q&2),writable:!(Q&4),value:K}}},7040:($,Q,K)=>{var Z=K(4495);$.exports=Z&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},7055:($,Q,K)=>{var Z=K(9504),J=K(9039),_=K(2195),q=Object,G=Z("".split);$.exports=J(function(){return!q("z").propertyIsEnumerable(0)})?function(U){return _(U)==="String"?G(U,""):q(U)}:q},7080:($,Q,K)=>{var Z=K(4402).has;$.exports=function(J){return Z(J),J}},7347:($,Q,K)=>{var Z=K(3724),J=K(9565),_=K(8773),q=K(6980),G=K(5397),U=K(6969),V=K(9297),N=K(5917),R=Object.getOwnPropertyDescriptor;Q.f=Z?R:function(F,B){if(F=G(F),B=U(B),N)try{return R(F,B)}catch(A){}if(V(F,B))return q(!J(_.f,F,B),F[B])}},7394:($,Q,K)=>{var Z=K(4576),J=K(6706),_=K(2195),q=Z.ArrayBuffer,G=Z.TypeError;$.exports=q&&J(q.prototype,"byteLength","get")||function(U){if(_(U)!=="ArrayBuffer")throw new G("ArrayBuffer expected");return U.byteLength}},7416:($,Q,K)=>{var Z=K(9039),J=K(8227),_=K(3724),q=K(6395),G=J("iterator");$.exports=!Z(function(){var U=new URL("b?a=1&b=2&c=3","https://a"),V=U.searchParams,N=new URLSearchParams("a=1&a=2&b=3"),R="";return U.pathname="c%20d",V.forEach(function(j,F){V.delete("b"),R+=F+j}),N.delete("a",2),N.delete("b",void 0),q&&(!U.toJSON||!N.has("a",1)||N.has("a",2)||!N.has("a",void 0)||N.has("b"))||!V.size&&(q||!_)||!V.sort||U.href!=="https://a/c%20d?a=1&c=3"||V.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!V[G]||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"||R!=="a1c3"||new URL("https://x",void 0).host!=="x"})},7476:($,Q,K)=>{var Z=K(2195),J=K(9504);$.exports=function(_){if(Z(_)==="Function")return J(_)}},7566:($,Q,K)=>{var Z=K(6840),J=K(9504),_=K(655),q=K(2812),G=URLSearchParams,U=G.prototype,V=J(U.getAll),N=J(U.has),R=new G("a=1");if(R.has("a",2)||!R.has("a",void 0))Z(U,"has",function(F){var B=arguments.length,A=B<2?void 0:arguments[1];if(B&&A===void 0)return N(this,F);var z=V(this,F);q(B,1);var O=_(A),S=0;while(S<z.length)if(z[S++]===O)return!0;return!1},{enumerable:!0,unsafe:!0})},7588:($,Q,K)=>{var Z=K(6518),J=K(9565),_=K(2652),q=K(9306),G=K(8551),U=K(1767),V=K(9539),N=K(4549),R=N("forEach",TypeError);Z({target:"Iterator",proto:!0,real:!0,forced:R},{forEach:function(F){G(this);try{q(F)}catch(z){V(this,"throw",z)}if(R)return J(R,this,F);var B=U(this),A=0;_(B,function(z){F(z,A++)},{IS_RECORD:!0})}})},7629:($,Q,K)=>{var Z=K(6395),J=K(4576),_=K(9433),q="__core-js_shared__",G=$.exports=J[q]||_(q,{});(G.versions||(G.versions=[])).push({version:"3.45.1",mode:Z?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.45.1/LICENSE",source:"https://github.com/zloirock/core-js"})},7642:($,Q,K)=>{var Z=K(6518),J=K(3440),_=K(9039),q=K(4916),G=!q("difference",function(V){return V.size===0}),U=G||_(function(){var V={size:1,has:function(){return!0},keys:function(){var R=0;return{next:function(){var j=R++>1;if(N.has(1))N.clear();return{done:j,value:2}}}}},N=new Set([1,2,3,4]);return N.difference(V).size!==3});Z({target:"Set",proto:!0,real:!0,forced:U},{difference:J})},7657:($,Q,K)=>{var Z=K(9039),J=K(4901),_=K(34),q=K(2360),G=K(2787),U=K(6840),V=K(8227),N=K(6395),R=V("iterator"),j=!1,F,B,A;if([].keys){if(A=[].keys(),!("next"in A))j=!0;else if(B=G(G(A)),B!==Object.prototype)F=B}var z=!_(F)||Z(function(){var O={};return F[R].call(O)!==O});if(z)F={};else if(N)F=q(F);if(!J(F[R]))U(F,R,function(){return this});$.exports={IteratorPrototype:F,BUGGY_SAFARI_ITERATORS:j}},7680:($,Q,K)=>{var Z=K(9504);$.exports=Z([].slice)},7696:($,Q,K)=>{var Z=K(1291),J=K(8014),_=RangeError;$.exports=function(q){if(q===void 0)return 0;var G=Z(q),U=J(G);if(G!==U)throw new _("Wrong length or index");return U}},7740:($,Q,K)=>{var Z=K(9297),J=K(5031),_=K(7347),q=K(4913);$.exports=function(G,U,V){var N=J(U),R=q.f,j=_.f;for(var F=0;F<N.length;F++){var B=N[F];if(!Z(G,B)&&!(V&&Z(V,B)))R(G,B,j(U,B))}}},7750:($,Q,K)=>{var Z=K(4117),J=TypeError;$.exports=function(_){if(Z(_))throw new J("Can't call method on "+_);return _}},7751:($,Q,K)=>{var Z=K(4576),J=K(4901),_=function(q){return J(q)?q:void 0};$.exports=function(q,G){return arguments.length<2?_(Z[q]):Z[q]&&Z[q][G]}},7811:($)=>{$.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"},7936:($,Q,K)=>{var Z=K(6518),J=K(5636);if(J)Z({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return J(this,arguments.length?arguments[0]:void 0,!1)}})},8004:($,Q,K)=>{var Z=K(6518),J=K(9039),_=K(8750),q=K(4916),G=!q("intersection",function(U){return U.size===2&&U.has(1)&&U.has(2)})||J(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});Z({target:"Set",proto:!0,real:!0,forced:G},{intersection:_})},8014:($,Q,K)=>{var Z=K(1291),J=Math.min;$.exports=function(_){var q=Z(_);return q>0?J(q,9007199254740991):0}},8100:($,Q,K)=>{var Z=K(6518),J=K(5636);if(J)Z({target:"ArrayBuffer",proto:!0},{transfer:function(){return J(this,arguments.length?arguments[0]:void 0,!0)}})},8111:($,Q,K)=>{var Z=K(6518),J=K(4576),_=K(679),q=K(8551),G=K(4901),U=K(2787),V=K(2106),N=K(4659),R=K(9039),j=K(9297),F=K(8227),B=K(7657).IteratorPrototype,A=K(3724),z=K(6395),O="constructor",S="Iterator",I=F("toStringTag"),C=TypeError,T=J[S],k=z||!G(T)||T.prototype!==B||!R(function(){T({})}),E=function(){if(_(this,B),U(this)===B)throw new C("Abstract class Iterator not directly constructable")},M=function(W,X){if(A)V(B,W,{configurable:!0,get:function(){return X},set:function(Y){if(q(this),this===B)throw new C("You can't redefine this property");if(j(this,W))this[W]=Y;else N(this,W,Y)}});else B[W]=X};if(!j(B,I))M(I,S);if(k||!j(B,O)||B[O]===Object)M(O,E);E.prototype=B,Z({global:!0,constructor:!0,forced:k},{Iterator:E})},8227:($,Q,K)=>{var Z=K(4576),J=K(5745),_=K(9297),q=K(3392),G=K(4495),U=K(7040),V=Z.Symbol,N=J("wks"),R=U?V.for||V:V&&V.withoutSetter||q;$.exports=function(j){if(!_(N,j))N[j]=G&&_(V,j)?V[j]:R("Symbol."+j);return N[j]}},8235:($,Q,K)=>{var Z=K(9504),J=K(9297),_=SyntaxError,q=parseInt,G=String.fromCharCode,U=Z("".charAt),V=Z("".slice),N=Z(/./.exec),R={"\\\"":'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
2
+ `,"\\r":"\r","\\t":"\t"},j=/^[\da-f]{4}$/i,F=/^[\u0000-\u001F]$/;$.exports=function(B,A){var z=!0,O="";while(A<B.length){var S=U(B,A);if(S==="\\"){var I=V(B,A,A+2);if(J(R,I))O+=R[I],A+=2;else if(I==="\\u"){A+=2;var C=V(B,A,A+4);if(!N(j,C))throw new _("Bad Unicode escape at: "+A);O+=G(q(C,16)),A+=4}else throw new _('Unknown escape sequence: "'+I+'"')}else if(S==='"'){z=!1,A++;break}else{if(N(F,S))throw new _("Bad control character in string literal at: "+A);O+=S,A++}}if(z)throw new _("Unterminated string at: "+A);return{value:O,end:A}}},8237:($,Q,K)=>{var Z=K(6518),J=K(2652),_=K(9306),q=K(8551),G=K(1767),U=K(9539),V=K(4549),N=K(8745),R=K(9039),j=TypeError,F=R(function(){[].keys().reduce(function(){},void 0)}),B=!F&&V("reduce",j);Z({target:"Iterator",proto:!0,real:!0,forced:F||B},{reduce:function(z){q(this);try{_(z)}catch(T){U(this,"throw",T)}var O=arguments.length<2,S=O?void 0:arguments[1];if(B)return N(B,this,O?[z]:[z,S]);var I=G(this),C=0;if(J(I,function(T){if(O)O=!1,S=T;else S=z(S,T,C);C++},{IS_RECORD:!0}),O)throw new j("Reduce of empty iterator with no initial value");return S}})},8335:($,Q,K)=>{var Z=K(6518),J=K(3724),_=K(4576),q=K(7751),G=K(9504),U=K(9565),V=K(4901),N=K(34),R=K(4376),j=K(9297),F=K(655),B=K(6198),A=K(4659),z=K(9039),O=K(8235),S=K(4495),I=_.JSON,C=_.Number,T=_.SyntaxError,k=I&&I.parse,E=q("Object","keys"),M=Object.getOwnPropertyDescriptor,W=G("".charAt),X=G("".slice),Y=G(/./.exec),y=G([].push),D=/^\d$/,b=/^[1-9]$/,H=/^[\d-]$/,P=/^[\t\n\r ]$/,v=0,u=1,a=function(f,L){f=F(f);var w=new e(f,0),o=w.parse(),K$=o.value,h=w.skip(P,o.end);if(h<f.length)throw new T('Unexpected extra character: "'+W(f,h)+'" after the parsed data at: '+h);return V(L)?Q$({"":K$},"",L,o):K$},Q$=function(f,L,w,o){var K$=f[L],h=o&&K$===o.value,J$=h&&typeof o.source=="string"?{source:o.source}:{},_$,x$,Y$,T$,zQ;if(N(K$)){var m0=R(K$),G0=h?o.nodes:m0?[]:{};if(m0){_$=G0.length,Y$=B(K$);for(T$=0;T$<Y$;T$++)G$(K$,T$,Q$(K$,""+T$,w,T$<_$?G0[T$]:void 0))}else{x$=E(K$),Y$=B(x$);for(T$=0;T$<Y$;T$++)zQ=x$[T$],G$(K$,zQ,Q$(K$,zQ,w,j(G0,zQ)?G0[zQ]:void 0))}}return U(w,f,L,K$,J$)},G$=function(f,L,w){if(J){var o=M(f,L);if(o&&!o.configurable)return}if(w===void 0)delete f[L];else A(f,L,w)},t=function(f,L,w,o){this.value=f,this.end=L,this.source=w,this.nodes=o},e=function(f,L){this.source=f,this.index=L};e.prototype={fork:function(f){return new e(this.source,f)},parse:function(){var f=this.source,L=this.skip(P,this.index),w=this.fork(L),o=W(f,L);if(Y(H,o))return w.number();switch(o){case"{":return w.object();case"[":return w.array();case'"':return w.string();case"t":return w.keyword(!0);case"f":return w.keyword(!1);case"n":return w.keyword(null)}throw new T('Unexpected character: "'+o+'" at: '+L)},node:function(f,L,w,o,K$){return new t(L,o,f?null:X(this.source,w,o),K$)},object:function(){var f=this.source,L=this.index+1,w=!1,o={},K$={};while(L<f.length){if(L=this.until(['"',"}"],L),W(f,L)==="}"&&!w){L++;break}var h=this.fork(L).string(),J$=h.value;L=h.end,L=this.until([":"],L)+1,L=this.skip(P,L),h=this.fork(L).parse(),A(K$,J$,h),A(o,J$,h.value),L=this.until([",","}"],h.end);var _$=W(f,L);if(_$===",")w=!0,L++;else if(_$==="}"){L++;break}}return this.node(u,o,this.index,L,K$)},array:function(){var f=this.source,L=this.index+1,w=!1,o=[],K$=[];while(L<f.length){if(L=this.skip(P,L),W(f,L)==="]"&&!w){L++;break}var h=this.fork(L).parse();if(y(K$,h),y(o,h.value),L=this.until([",","]"],h.end),W(f,L)===",")w=!0,L++;else if(W(f,L)==="]"){L++;break}}return this.node(u,o,this.index,L,K$)},string:function(){var f=this.index,L=O(this.source,this.index+1);return this.node(v,L.value,f,L.end)},number:function(){var f=this.source,L=this.index,w=L;if(W(f,w)==="-")w++;if(W(f,w)==="0")w++;else if(Y(b,W(f,w)))w=this.skip(D,w+1);else throw new T("Failed to parse number at: "+w);if(W(f,w)===".")w=this.skip(D,w+1);if(W(f,w)==="e"||W(f,w)==="E"){if(w++,W(f,w)==="+"||W(f,w)==="-")w++;var o=w;if(w=this.skip(D,w),o===w)throw new T("Failed to parse number's exponent value at: "+w)}return this.node(v,C(X(f,L,w)),L,w)},keyword:function(f){var L=""+f,w=this.index,o=w+L.length;if(X(this.source,w,o)!==L)throw new T("Failed to parse value at: "+w);return this.node(v,f,w,o)},skip:function(f,L){var w=this.source;for(;L<w.length;L++)if(!Y(f,W(w,L)))break;return L},until:function(f,L){L=this.skip(P,L);var w=W(this.source,L);for(var o=0;o<f.length;o++)if(f[o]===w)return L;throw new T('Unexpected character: "'+w+'" at: '+L)}};var q$=z(function(){var f="9007199254740993",L;return k(f,function(w,o,K$){L=K$.source}),L!==f}),k$=S&&!z(function(){return 1/k("-0 \t")!==-1/0});Z({target:"JSON",stat:!0,forced:q$},{parse:function(L,w){return k$&&!V(w)?k(L):a(L,w)}})},8469:($,Q,K)=>{var Z=K(9504),J=K(507),_=K(4402),q=_.Set,G=_.proto,U=Z(G.forEach),V=Z(G.keys),N=V(new q).next;$.exports=function(R,j,F){return F?J({iterator:V(R),next:N},j):U(R,j)}},8480:($,Q,K)=>{var Z=K(1828),J=K(8727),_=J.concat("length","prototype");Q.f=Object.getOwnPropertyNames||function(G){return Z(G,_)}},8527:($,Q,K)=>{var Z=K(7080),J=K(4402).has,_=K(5170),q=K(3789),G=K(507),U=K(9539);$.exports=function(N){var R=Z(this),j=q(N);if(_(R)<j.size)return!1;var F=j.getIterator();return G(F,function(B){if(!J(R,B))return U(F,"normal",!1)})!==!1}},8551:($,Q,K)=>{var Z=K(34),J=String,_=TypeError;$.exports=function(q){if(Z(q))return q;throw new _(J(q)+" is not an object")}},8574:($,Q,K)=>{var Z=K(9504),J=Error,_=Z("".replace),q=function(V){return String(new J(V).stack)}("zxcasd"),G=/\n\s*at [^:]*:[^\n]*/,U=G.test(q);$.exports=function(V,N){if(U&&typeof V=="string"&&!J.prepareStackTrace)while(N--)V=_(V,G,"");return V}},8622:($,Q,K)=>{var Z=K(4576),J=K(4901),_=Z.WeakMap;$.exports=J(_)&&/native code/.test(String(_))},8646:($,Q,K)=>{var Z=K(9565),J=K(8551),_=K(1767),q=K(851);$.exports=function(G,U){if(!U||typeof G!=="string")J(G);var V=q(G);return _(J(V!==void 0?Z(V,G):G))}},8686:($,Q,K)=>{var Z=K(3724),J=K(9039);$.exports=Z&&J(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})},8721:($,Q,K)=>{var Z=K(3724),J=K(9504),_=K(2106),q=URLSearchParams.prototype,G=J(q.forEach);if(Z&&!("size"in q))_(q,"size",{get:function(){var V=0;return G(this,function(){V++}),V},configurable:!0,enumerable:!0})},8727:($)=>{$.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},8745:($,Q,K)=>{var Z=K(616),J=Function.prototype,_=J.apply,q=J.call;$.exports=typeof Reflect=="object"&&Reflect.apply||(Z?q.bind(_):function(){return q.apply(_,arguments)})},8750:($,Q,K)=>{var Z=K(7080),J=K(4402),_=K(5170),q=K(3789),G=K(8469),U=K(507),V=J.Set,N=J.add,R=J.has;$.exports=function(F){var B=Z(this),A=q(F),z=new V;if(_(B)>A.size)U(A.getIterator(),function(O){if(R(B,O))N(z,O)});else G(B,function(O){if(A.includes(O))N(z,O)});return z}},8773:($,Q)=>{var K={}.propertyIsEnumerable,Z=Object.getOwnPropertyDescriptor,J=Z&&!K.call({1:2},1);Q.f=J?function(q){var G=Z(this,q);return!!G&&G.enumerable}:K},8981:($,Q,K)=>{var Z=K(7750),J=Object;$.exports=function(_){return J(Z(_))}},9039:($)=>{$.exports=function(Q){try{return!!Q()}catch(K){return!0}}},9143:($,Q,K)=>{var Z=K(4576),J=K(9504),_=K(3972),q=K(3463),G=K(9297),U=K(2804),V=K(944),N=K(5169),R=U.c2i,j=U.c2iUrl,F=Z.SyntaxError,B=Z.TypeError,A=J("".charAt),z=function(I,C){var T=I.length;for(;C<T;C++){var k=A(I,C);if(k!==" "&&k!=="\t"&&k!==`
3
+ `&&k!=="\f"&&k!=="\r")break}return C},O=function(I,C,T){var k=I.length;if(k<4)I+=k===2?"AA":"A";var E=(C[A(I,0)]<<18)+(C[A(I,1)]<<12)+(C[A(I,2)]<<6)+C[A(I,3)],M=[E>>16&255,E>>8&255,E&255];if(k===2){if(T&&M[1]!==0)throw new F("Extra bits");return[M[0]]}if(k===3){if(T&&M[2]!==0)throw new F("Extra bits");return[M[0],M[1]]}return M},S=function(I,C,T){var k=C.length;for(var E=0;E<k;E++)I[T+E]=C[E];return T+k};$.exports=function(I,C,T,k){q(I),_(C);var E=V(C)==="base64"?R:j,M=C?C.lastChunkHandling:void 0;if(M===void 0)M="loose";if(M!=="loose"&&M!=="strict"&&M!=="stop-before-partial")throw new B("Incorrect `lastChunkHandling` option");if(T)N(T.buffer);var W=I.length,X=T||[],Y=0,y=0,D="",b=0;if(k)while(!0){if(b=z(I,b),b===W){if(D.length>0){if(M==="stop-before-partial")break;if(M==="loose"){if(D.length===1)throw new F("Malformed padding: exactly one additional character");Y=S(X,O(D,E,!1),Y)}else throw new F("Missing padding")}y=W;break}var H=A(I,b);if(++b,H==="="){if(D.length<2)throw new F("Padding is too early");if(b=z(I,b),D.length===2){if(b===W){if(M==="stop-before-partial")break;throw new F("Malformed padding: only one =")}if(A(I,b)==="=")++b,b=z(I,b)}if(b<W)throw new F("Unexpected character after padding");Y=S(X,O(D,E,M==="strict"),Y),y=W;break}if(!G(E,H))throw new F("Unexpected character");var P=k-Y;if(P===1&&D.length===2||P===2&&D.length===3)break;if(D+=H,D.length===4){if(Y=S(X,O(D,E,!1),Y),D="",y=b,Y===k)break}}return{bytes:X,read:y,written:Y}}},9286:($,Q,K)=>{var Z=K(4402),J=K(8469),_=Z.Set,q=Z.add;$.exports=function(G){var U=new _;return J(G,function(V){q(U,V)}),U}},9297:($,Q,K)=>{var Z=K(9504),J=K(8981),_=Z({}.hasOwnProperty);$.exports=Object.hasOwn||function(G,U){return _(J(G),U)}},9306:($,Q,K)=>{var Z=K(4901),J=K(6823),_=TypeError;$.exports=function(q){if(Z(q))return q;throw new _(J(q)+" is not a function")}},9314:($,Q,K)=>{var Z=K(6518),J=K(9565),_=K(8551),q=K(1767),G=K(4149),U=K(9590),V=K(9539),N=K(9462),R=K(684),j=K(4549),F=K(6395),B=!F&&!R("drop",0),A=!F&&!B&&j("drop",RangeError),z=F||B||A,O=N(function(){var S=this.iterator,I=this.next,C,T;while(this.remaining)if(this.remaining--,C=_(J(I,S)),T=this.done=!!C.done,T)return;if(C=_(J(I,S)),T=this.done=!!C.done,!T)return C.value});Z({target:"Iterator",proto:!0,real:!0,forced:z},{drop:function(I){_(this);var C;try{C=U(G(+I))}catch(T){V(this,"throw",T)}if(A)return J(A,this,C);return new O(q(this),{remaining:C})}})},9429:($,Q,K)=>{var Z=K(4576),J=K(6193);$.exports=function(_){if(J){try{return Z.process.getBuiltinModule(_)}catch(q){}try{return Function('return require("'+_+'")')()}catch(q){}}}},9432:($,Q,K)=>{K(5213)},9433:($,Q,K)=>{var Z=K(4576),J=Object.defineProperty;$.exports=function(_,q){try{J(Z,_,{value:q,configurable:!0,writable:!0})}catch(G){Z[_]=q}return q}},9462:($,Q,K)=>{var Z=K(9565),J=K(2360),_=K(6699),q=K(6279),G=K(8227),U=K(1181),V=K(5966),N=K(7657).IteratorPrototype,R=K(2529),j=K(9539),F=K(1385),B=G("toStringTag"),A="IteratorHelper",z="WrapForValidIterator",O="normal",S="throw",I=U.set,C=function(E){var M=U.getterFor(E?z:A);return q(J(N),{next:function(){var X=M(this);if(E)return X.nextHandler();if(X.done)return R(void 0,!0);try{var Y=X.nextHandler();return X.returnHandlerResult?Y:R(Y,X.done)}catch(y){throw X.done=!0,y}},return:function(){var W=M(this),X=W.iterator;if(W.done=!0,E){var Y=V(X,"return");return Y?Z(Y,X):R(void 0,!0)}if(W.inner)try{j(W.inner.iterator,O)}catch(y){return j(X,S,y)}if(W.openIters)try{F(W.openIters,O)}catch(y){return j(X,S,y)}if(X)j(X,O);return R(void 0,!0)}})},T=C(!0),k=C(!1);_(k,B,"Iterator Helper"),$.exports=function(E,M,W){var X=function(y,D){if(D)D.iterator=y.iterator,D.next=y.next;else D=y;D.type=M?z:A,D.returnHandlerResult=!!W,D.nextHandler=E,D.counter=0,D.done=!1,I(this,D)};return X.prototype=M?T:k,X}},9486:($,Q,K)=>{var Z=K(6518),J=K(4576),_=K(9504),q=K(3972),G=K(4154),U=K(5169),V=K(2804),N=K(944),R=V.i2c,j=V.i2cUrl,F=_("".charAt),B=J.Uint8Array,A=!B||!B.prototype.toBase64||!function(){try{var z=new B;z.toBase64(null)}catch(O){return!0}}();if(B)Z({target:"Uint8Array",proto:!0,forced:A},{toBase64:function(){var O=G(this),S=arguments.length?q(arguments[0]):void 0,I=N(S)==="base64"?R:j,C=!!S&&!!S.omitPadding;U(this.buffer);var T="",k=0,E=O.length,M,W=function(X){return F(I,M>>6*X&63)};for(;k+2<E;k+=3)M=(O[k]<<16)+(O[k+1]<<8)+O[k+2],T+=W(3)+W(2)+W(1)+W(0);if(k+2===E)M=(O[k]<<16)+(O[k+1]<<8),T+=W(3)+W(2)+W(1)+(C?"":"=");else if(k+1===E)M=O[k]<<16,T+=W(3)+W(2)+(C?"":"==");return T}})},9504:($,Q,K)=>{var Z=K(616),J=Function.prototype,_=J.call,q=Z&&J.bind.bind(_,_);$.exports=Z?q:function(G){return function(){return _.apply(G,arguments)}}},9519:($,Q,K)=>{var Z=K(4576),J=K(2839),_=Z.process,q=Z.Deno,G=_&&_.versions||q&&q.version,U=G&&G.v8,V,N;if(U)V=U.split("."),N=V[0]>0&&V[0]<4?1:+(V[0]+V[1]);if(!N&&J){if(V=J.match(/Edge\/(\d+)/),!V||V[1]>=74){if(V=J.match(/Chrome\/(\d+)/),V)N=+V[1]}}$.exports=N},9539:($,Q,K)=>{var Z=K(9565),J=K(8551),_=K(5966);$.exports=function(q,G,U){var V,N;J(q);try{if(V=_(q,"return"),!V){if(G==="throw")throw U;return U}V=Z(V,q)}catch(R){N=!0,V=R}if(G==="throw")throw U;if(N)throw V;return J(V),U}},9565:($,Q,K)=>{var Z=K(616),J=Function.prototype.call;$.exports=Z?J.bind(J):function(){return J.apply(J,arguments)}},9577:($,Q,K)=>{var Z=K(9928),J=K(4644),_=K(1108),q=K(1291),G=K(5854),U=J.aTypedArray,V=J.getTypedArrayConstructor,N=J.exportTypedArrayMethod,R=function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(F){return F===8}}(),j=R&&function(){try{new Int8Array(1).with(-0.5,1)}catch(F){return!0}}();N("with",function(F,B){var A=U(this),z=q(F),O=_(A)?G(B):+B;return Z(A,V(A),z,O)},!R||j)},9590:($,Q,K)=>{var Z=K(1291),J=RangeError;$.exports=function(_){var q=Z(_);if(q<0)throw new J("The argument can't be less than 0");return q}},9617:($,Q,K)=>{var Z=K(5397),J=K(5610),_=K(6198),q=function(G){return function(U,V,N){var R=Z(U),j=_(R);if(j===0)return!G&&-1;var F=J(N,j),B;if(G&&V!==V){while(j>F)if(B=R[F++],B!==B)return!0}else for(;j>F;F++)if((G||(F in R))&&R[F]===V)return G||F||0;return!G&&-1}};$.exports={includes:q(!0),indexOf:q(!1)}},9631:($,Q,K)=>{K(9486)},9797:($,Q,K)=>{K(4226)},9835:($)=>{$.exports=function(Q){try{var K=new Set,Z={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return K.clear(),K.add(4),function(){return{done:!0}}}})}},J=K[Q](Z);return J.size===1&&J.values().next().value===4}catch(_){return!1}}},9928:($,Q,K)=>{var Z=K(6198),J=K(1291),_=RangeError;$.exports=function(q,G,U,V){var N=Z(q),R=J(U),j=R<0?N+R:R;if(j>=N||j<0)throw new _("Incorrect index");var F=new G(N),B=0;for(;B<N;B++)F[B]=B===j?V:q[B];return F}}},l6={};function s($){var Q=l6[$];if(Q!==void 0)return Q.exports;var K=l6[$]={exports:{}};return JK[$].call(K.exports,K,K.exports,s),K.exports}(()=>{s.d=($,Q)=>{for(var K in Q)if(s.o(Q,K)&&!s.o($,K))Object.defineProperty($,K,{enumerable:!0,get:Q[K]})}})();(()=>{s.o=($,Q)=>Object.prototype.hasOwnProperty.call($,Q)})();s(4114);s(6573);s(8100);s(7936);s(8111);s(8237);s(1689);s(9577);s(4235);s(9432);s(1549);s(9797);s(9631);s(5623);s(4979);s(5781);var L$=typeof process==="object"&&process+""==="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),a0=[0.001,0,0,0.001,0,0],h0=1.35,v$={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},QQ={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},pQ="pdfjs_internal_editor_",d={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},n={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},A7={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},E$={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},h$={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},j$={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},SQ={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},FQ={ERRORS:0,WARNINGS:1,INFOS:5},P$={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},U0={moveTo:0,lineTo:1,curveTo:2,closePath:3},z7={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},L0=FQ.WARNINGS;function _K($){if(Number.isInteger($))L0=$}function qK(){return L0}function P0($){if(L0>=FQ.INFOS)console.info(`Info: ${$}`)}function p($){if(L0>=FQ.WARNINGS)console.warn(`Warning: ${$}`)}function Z$($){throw Error($)}function i($,Q){if(!$)Z$(Q)}function GK($){switch($?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function R6($,Q=null,K=null){if(!$)return null;if(K&&typeof $==="string"){if(K.addDefaultProtocol&&$.startsWith("www.")){if($.match(/\./g)?.length>=2)$=`http://${$}`}if(K.tryConvertEncoding)try{$=jK($)}catch{}}let Z=Q?URL.parse($,Q):URL.parse($);return GK(Z)?Z:null}function j6($,Q,K=!1){let Z=URL.parse($);if(Z)return Z.hash=Q,Z.href;if(K&&R6($,"http://example.com"))return $.split("#",1)[0]+`${Q?`#${Q}`:""}`;return""}function r($,Q,K,Z=!1){return Object.defineProperty($,Q,{value:K,enumerable:!Z,configurable:!0,writable:!1}),K}var AQ=function(){function Q(K,Z){this.message=K,this.name=Z}return Q.prototype=Error(),Q.constructor=Q,Q}(),s6=class extends AQ{constructor(Q,K){super(Q,"PasswordException");this.code=K}},g0=class extends AQ{constructor(Q,K){super(Q,"UnknownErrorException");this.details=K}},S0=class extends AQ{constructor(Q){super(Q,"InvalidPDFException")}},dQ=class extends AQ{constructor(Q,K,Z){super(Q,"ResponseException");this.status=K,this.missing=Z}},UK=class extends AQ{constructor(Q){super(Q,"FormatError")}},KQ=class extends AQ{constructor(Q){super(Q,"AbortException")}};function O7($){if(typeof $!=="object"||$?.length===void 0)Z$("Invalid argument for bytesToString");let Q=$.length,K=8192;if(Q<K)return String.fromCharCode.apply(null,$);let Z=[];for(let J=0;J<Q;J+=K){let _=Math.min(J+K,Q),q=$.subarray(J,_);Z.push(String.fromCharCode.apply(null,q))}return Z.join("")}function eQ($){if(typeof $!=="string")Z$("Invalid argument for stringToBytes");let Q=$.length,K=new Uint8Array(Q);for(let Z=0;Z<Q;++Z)K[Z]=$.charCodeAt(Z)&255;return K}function VK($){return String.fromCharCode($>>24&255,$>>16&255,$>>8&255,$&255)}function NK(){let $=new Uint8Array(4);return $[0]=1,new Uint32Array($.buffer,0,1)[0]===1}function RK(){try{return Function(""),!0}catch{return!1}}class S${static get isLittleEndian(){return r(this,"isLittleEndian",NK())}static get isEvalSupported(){return r(this,"isEvalSupported",RK())}static get isOffscreenCanvasSupported(){return r(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return r(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){let{platform:$,userAgent:Q}=navigator;return r(this,"platform",{isAndroid:Q.includes("Android"),isLinux:$.includes("Linux"),isMac:$.includes("Mac"),isWindows:$.includes("Win"),isFirefox:Q.includes("Firefox")})}static get isCSSRoundSupported(){return r(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}var p0=Array.from(Array(256).keys(),($)=>$.toString(16).padStart(2,"0"));class x{static makeHexColor($,Q,K){return`#${p0[$]}${p0[Q]}${p0[K]}`}static domMatrixToTransform($){return[$.a,$.b,$.c,$.d,$.e,$.f]}static scaleMinMax($,Q){let K;if($[0]){if($[0]<0)K=Q[0],Q[0]=Q[2],Q[2]=K;if(Q[0]*=$[0],Q[2]*=$[0],$[3]<0)K=Q[1],Q[1]=Q[3],Q[3]=K;Q[1]*=$[3],Q[3]*=$[3]}else{if(K=Q[0],Q[0]=Q[1],Q[1]=K,K=Q[2],Q[2]=Q[3],Q[3]=K,$[1]<0)K=Q[1],Q[1]=Q[3],Q[3]=K;if(Q[1]*=$[1],Q[3]*=$[1],$[2]<0)K=Q[0],Q[0]=Q[2],Q[2]=K;Q[0]*=$[2],Q[2]*=$[2]}Q[0]+=$[4],Q[1]+=$[5],Q[2]+=$[4],Q[3]+=$[5]}static transform($,Q){return[$[0]*Q[0]+$[2]*Q[1],$[1]*Q[0]+$[3]*Q[1],$[0]*Q[2]+$[2]*Q[3],$[1]*Q[2]+$[3]*Q[3],$[0]*Q[4]+$[2]*Q[5]+$[4],$[1]*Q[4]+$[3]*Q[5]+$[5]]}static multiplyByDOMMatrix($,Q){return[$[0]*Q.a+$[2]*Q.b,$[1]*Q.a+$[3]*Q.b,$[0]*Q.c+$[2]*Q.d,$[1]*Q.c+$[3]*Q.d,$[0]*Q.e+$[2]*Q.f+$[4],$[1]*Q.e+$[3]*Q.f+$[5]]}static applyTransform($,Q,K=0){let Z=$[K],J=$[K+1];$[K]=Z*Q[0]+J*Q[2]+Q[4],$[K+1]=Z*Q[1]+J*Q[3]+Q[5]}static applyTransformToBezier($,Q,K=0){let Z=Q[0],J=Q[1],_=Q[2],q=Q[3],G=Q[4],U=Q[5];for(let V=0;V<6;V+=2){let N=$[K+V],R=$[K+V+1];$[K+V]=N*Z+R*_+G,$[K+V+1]=N*J+R*q+U}}static applyInverseTransform($,Q){let K=$[0],Z=$[1],J=Q[0]*Q[3]-Q[1]*Q[2];$[0]=(K*Q[3]-Z*Q[2]+Q[2]*Q[5]-Q[4]*Q[3])/J,$[1]=(-K*Q[1]+Z*Q[0]+Q[4]*Q[1]-Q[5]*Q[0])/J}static axialAlignedBoundingBox($,Q,K){let Z=Q[0],J=Q[1],_=Q[2],q=Q[3],G=Q[4],U=Q[5],V=$[0],N=$[1],R=$[2],j=$[3],F=Z*V+G,B=F,A=Z*R+G,z=A,O=q*N+U,S=O,I=q*j+U,C=I;if(J!==0||_!==0){let T=J*V,k=J*R,E=_*N,M=_*j;F+=E,z+=E,A+=M,B+=M,O+=T,C+=T,I+=k,S+=k}K[0]=Math.min(K[0],F,A,B,z),K[1]=Math.min(K[1],O,I,S,C),K[2]=Math.max(K[2],F,A,B,z),K[3]=Math.max(K[3],O,I,S,C)}static inverseTransform($){let Q=$[0]*$[3]-$[1]*$[2];return[$[3]/Q,-$[1]/Q,-$[2]/Q,$[0]/Q,($[2]*$[5]-$[4]*$[3])/Q,($[4]*$[1]-$[5]*$[0])/Q]}static singularValueDecompose2dScale($,Q){let K=$[0],Z=$[1],J=$[2],_=$[3],q=K**2+Z**2,G=K*J+Z*_,U=J**2+_**2,V=(q+U)/2,N=Math.sqrt(V**2-(q*U-G**2));Q[0]=Math.sqrt(V+N||1),Q[1]=Math.sqrt(V-N||1)}static normalizeRect($){let Q=$.slice(0);if($[0]>$[2])Q[0]=$[2],Q[2]=$[0];if($[1]>$[3])Q[1]=$[3],Q[3]=$[1];return Q}static intersect($,Q){let K=Math.max(Math.min($[0],$[2]),Math.min(Q[0],Q[2])),Z=Math.min(Math.max($[0],$[2]),Math.max(Q[0],Q[2]));if(K>Z)return null;let J=Math.max(Math.min($[1],$[3]),Math.min(Q[1],Q[3])),_=Math.min(Math.max($[1],$[3]),Math.max(Q[1],Q[3]));if(J>_)return null;return[K,J,Z,_]}static pointBoundingBox($,Q,K){K[0]=Math.min(K[0],$),K[1]=Math.min(K[1],Q),K[2]=Math.max(K[2],$),K[3]=Math.max(K[3],Q)}static rectBoundingBox($,Q,K,Z,J){J[0]=Math.min(J[0],$,K),J[1]=Math.min(J[1],Q,Z),J[2]=Math.max(J[2],$,K),J[3]=Math.max(J[3],Q,Z)}static#$($,Q,K,Z,J,_,q,G,U,V){if(U<=0||U>=1)return;let N=1-U,R=U*U,j=R*U,F=N*(N*(N*$+3*U*Q)+3*R*K)+j*Z,B=N*(N*(N*J+3*U*_)+3*R*q)+j*G;V[0]=Math.min(V[0],F),V[1]=Math.min(V[1],B),V[2]=Math.max(V[2],F),V[3]=Math.max(V[3],B)}static#Q($,Q,K,Z,J,_,q,G,U,V,N,R){if(Math.abs(U)<0.000000000001){if(Math.abs(V)>=0.000000000001)this.#$($,Q,K,Z,J,_,q,G,-N/V,R);return}let j=V**2-4*N*U;if(j<0)return;let F=Math.sqrt(j),B=2*U;this.#$($,Q,K,Z,J,_,q,G,(-V+F)/B,R),this.#$($,Q,K,Z,J,_,q,G,(-V-F)/B,R)}static bezierBoundingBox($,Q,K,Z,J,_,q,G,U){U[0]=Math.min(U[0],$,q),U[1]=Math.min(U[1],Q,G),U[2]=Math.max(U[2],$,q),U[3]=Math.max(U[3],Q,G),this.#Q($,K,J,q,Q,Z,_,G,3*(-$+3*(K-J)+q),6*($-2*K+J),3*(K-$),U),this.#Q($,K,J,q,Q,Z,_,G,3*(-Q+3*(Z-_)+G),6*(Q-2*Z+_),3*(Z-Q),U)}}function jK($){return decodeURIComponent(escape($))}var d0=null,o6=null;function S7($){if(!d0)d0=/([\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,o6=new Map([["ſt","ſt"]]);return $.replaceAll(d0,(Q,K,Z)=>K?K.normalize("NFKC"):o6.get(Z))}function B6(){if(typeof crypto.randomUUID==="function")return crypto.randomUUID();let $=new Uint8Array(32);return crypto.getRandomValues($),O7($)}var F6="pdfjs_internal_id_";function BK($,Q,K){if(!Array.isArray(K)||K.length<2)return!1;let[Z,J,..._]=K;if(!$(Z)&&!Number.isInteger(Z))return!1;if(!Q(J))return!1;let q=_.length,G=!0;switch(J.name){case"XYZ":if(q<2||q>3)return!1;break;case"Fit":case"FitB":return q===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(q>1)return!1;break;case"FitR":if(q!==4)return!1;G=!1;break;default:return!1}for(let U of _){if(typeof U==="number"||G&&U===null)continue;return!1}return!0}function X$($,Q,K){return Math.min(Math.max($,Q),K)}function T7($){if(Uint8Array.prototype.toBase64)return $.toBase64();return btoa(O7($))}function FK($){if(Uint8Array.fromBase64)return Uint8Array.fromBase64($);return eQ(atob($))}if(typeof Math.sumPrecise!=="function")Math.sumPrecise=function($){return $.reduce((Q,K)=>Q+K,0)};if(typeof AbortSignal.any!=="function")AbortSignal.any=function($){let Q=new AbortController,{signal:K}=Q;for(let Z of $)if(Z.aborted)return Q.abort(Z.reason),K;for(let Z of $)Z.addEventListener("abort",()=>{Q.abort(Z.reason)},{signal:K});return K};s(1701);s(4603);s(7566);s(8721);class lQ{static textContent($){let Q=[],K={items:Q,styles:Object.create(null)};function Z(J){if(!J)return;let _=null,q=J.name;if(q==="#text")_=J.value;else if(!lQ.shouldBuildText(q))return;else if(J?.attributes?.textContent)_=J.attributes.textContent;else if(J.value)_=J.value;if(_!==null)Q.push({str:_});if(!J.children)return;for(let G of J.children)Z(G)}return Z($),K}static shouldBuildText($){return!($==="textarea"||$==="input"||$==="option"||$==="select")}}class H0{static setupStorage($,Q,K,Z,J){let _=Z.getValue(Q,{value:null});switch(K.name){case"textarea":if(_.value!==null)$.textContent=_.value;if(J==="print")break;$.addEventListener("input",(q)=>{Z.setValue(Q,{value:q.target.value})});break;case"input":if(K.attributes.type==="radio"||K.attributes.type==="checkbox"){if(_.value===K.attributes.xfaOn)$.setAttribute("checked",!0);else if(_.value===K.attributes.xfaOff)$.removeAttribute("checked");if(J==="print")break;$.addEventListener("change",(q)=>{Z.setValue(Q,{value:q.target.checked?q.target.getAttribute("xfaOn"):q.target.getAttribute("xfaOff")})})}else{if(_.value!==null)$.setAttribute("value",_.value);if(J==="print")break;$.addEventListener("input",(q)=>{Z.setValue(Q,{value:q.target.value})})}break;case"select":if(_.value!==null){$.setAttribute("value",_.value);for(let q of K.children)if(q.attributes.value===_.value)q.attributes.selected=!0;else if(q.attributes.hasOwnProperty("selected"))delete q.attributes.selected}$.addEventListener("input",(q)=>{let G=q.target.options,U=G.selectedIndex===-1?"":G[G.selectedIndex].value;Z.setValue(Q,{value:U})});break}}static setAttributes({html:$,element:Q,storage:K=null,intent:Z,linkService:J}){let{attributes:_}=Q,q=$ instanceof HTMLAnchorElement;if(_.type==="radio")_.name=`${_.name}-${Z}`;for(let[G,U]of Object.entries(_)){if(U===null||U===void 0)continue;switch(G){case"class":if(U.length)$.setAttribute(G,U.join(" "));break;case"dataId":break;case"id":$.setAttribute("data-element-id",U);break;case"style":Object.assign($.style,U);break;case"textContent":$.textContent=U;break;default:if(!q||G!=="href"&&G!=="newWindow")$.setAttribute(G,U)}}if(q)J.addLinkAttributes($,_.href,_.newWindow);if(K&&_.dataId)this.setupStorage($,_.dataId,Q,K)}static render($){let{annotationStorage:Q,linkService:K,xfaHtml:Z}=$,J=$.intent||"display",_=document.createElement(Z.name);if(Z.attributes)this.setAttributes({html:_,element:Z,intent:J,linkService:K});let q=J!=="richText",G=$.div;if(G.append(_),$.viewport){let N=`matrix(${$.viewport.transform.join(",")})`;G.style.transform=N}if(q)G.setAttribute("class","xfaLayer xfaFont");let U=[];if(Z.children.length===0){if(Z.value){let N=document.createTextNode(Z.value);if(_.append(N),q&&lQ.shouldBuildText(Z.name))U.push(N)}return{textDivs:U}}let V=[[Z,-1,_]];while(V.length>0){let[N,R,j]=V.at(-1);if(R+1===N.children.length){V.pop();continue}let F=N.children[++V.at(-1)[1]];if(F===null)continue;let{name:B}=F;if(B==="#text"){let z=document.createTextNode(F.value);U.push(z),j.append(z);continue}let A=F?.attributes?.xmlns?document.createElementNS(F.attributes.xmlns,B):document.createElement(B);if(j.append(A),F.attributes)this.setAttributes({html:A,element:F,storage:Q,intent:J,linkService:K});if(F.children?.length>0)V.push([F,-1,A]);else if(F.value){let z=document.createTextNode(F.value);if(q&&lQ.shouldBuildText(B))U.push(z);A.append(z)}}for(let N of G.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))N.setAttribute("readOnly",!0);return{textDivs:U}}static update($){let Q=`matrix(${$.viewport.transform.join(",")})`;$.div.style.transform=Q,$.div.hidden=!1}}var i$="http://www.w3.org/2000/svg";class qQ{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function HQ($,Q="text"){if(uQ($,document.baseURI)){let K=await fetch($);if(!K.ok)throw Error(K.statusText);switch(Q){case"arraybuffer":return K.arrayBuffer();case"blob":return K.blob();case"json":return K.json()}return K.text()}return new Promise((K,Z)=>{let J=new XMLHttpRequest;J.open("GET",$,!0),J.responseType=Q,J.onreadystatechange=()=>{if(J.readyState!==XMLHttpRequest.DONE)return;if(J.status===200||J.status===0){switch(Q){case"arraybuffer":case"blob":case"json":K(J.response);return}K(J.responseText);return}Z(Error(J.statusText))},J.send(null)})}class $0{constructor({viewBox:$,userUnit:Q,scale:K,rotation:Z,offsetX:J=0,offsetY:_=0,dontFlip:q=!1}){this.viewBox=$,this.userUnit=Q,this.scale=K,this.rotation=Z,this.offsetX=J,this.offsetY=_,K*=Q;let G=($[2]+$[0])/2,U=($[3]+$[1])/2,V,N,R,j;if(Z%=360,Z<0)Z+=360;switch(Z){case 180:V=-1,N=0,R=0,j=1;break;case 90:V=0,N=1,R=1,j=0;break;case 270:V=0,N=-1,R=-1,j=0;break;case 0:V=1,N=0,R=0,j=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(q)R=-R,j=-j;let F,B,A,z;if(V===0)F=Math.abs(U-$[1])*K+J,B=Math.abs(G-$[0])*K+_,A=($[3]-$[1])*K,z=($[2]-$[0])*K;else F=Math.abs(G-$[0])*K+J,B=Math.abs(U-$[1])*K+_,A=($[2]-$[0])*K,z=($[3]-$[1])*K;this.transform=[V*K,N*K,R*K,j*K,F-V*K*G-R*K*U,B-N*K*G-j*K*U],this.width=A,this.height=z}get rawDims(){let $=this.viewBox;return r(this,"rawDims",{pageWidth:$[2]-$[0],pageHeight:$[3]-$[1],pageX:$[0],pageY:$[1]})}clone({scale:$=this.scale,rotation:Q=this.rotation,offsetX:K=this.offsetX,offsetY:Z=this.offsetY,dontFlip:J=!1}={}){return new $0({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:$,rotation:Q,offsetX:K,offsetY:Z,dontFlip:J})}convertToViewportPoint($,Q){let K=[$,Q];return x.applyTransform(K,this.transform),K}convertToViewportRectangle($){let Q=[$[0],$[1]];x.applyTransform(Q,this.transform);let K=[$[2],$[3]];return x.applyTransform(K,this.transform),[Q[0],Q[1],K[0],K[1]]}convertToPdfPoint($,Q){let K=[$,Q];return x.applyInverseTransform(K,this.transform),K}}class Q0 extends AQ{constructor($,Q=0){super($,"RenderingCancelledException");this.extraDelay=Q}}function K0($){let Q=$.length,K=0;while(K<Q&&$[K].trim()==="")K++;return $.substring(K,K+5).toLowerCase()==="data:"}function D0($){return typeof $==="string"&&/\.pdf$/i.test($)}function I7($){return[$]=$.split(/[#?]/,1),$.substring($.lastIndexOf("/")+1)}function C7($,Q="document.pdf"){if(typeof $!=="string")return Q;if(K0($))return p('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),Q;let Z=((G)=>{try{return new URL(G)}catch{try{return new URL(decodeURIComponent(G))}catch{try{return new URL(G,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(G),"https://foo.bar")}catch{return null}}}}})($);if(!Z)return Q;let J=(G)=>{try{let U=decodeURIComponent(G);if(U.includes("/")){if(U=U.split("/").at(-1),U.test(/^\.pdf$/i))return U;return G}return U}catch{return G}},_=/\.pdf$/i,q=Z.pathname.split("/").at(-1);if(_.test(q))return J(q);if(Z.searchParams.size>0){let G=Array.from(Z.searchParams.values()).reverse();for(let V of G)if(_.test(V))return J(V);let U=Array.from(Z.searchParams.keys()).reverse();for(let V of U)if(_.test(V))return J(V)}if(Z.hash){let U=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(Z.hash);if(U)return J(U[0])}return Q}class i0{started=Object.create(null);times=[];time($){if($ in this.started)p(`Timer is already running for ${$}`);this.started[$]=Date.now()}timeEnd($){if(!($ in this.started))p(`Timer has not been started for ${$}`);this.times.push({name:$,start:this.started[$],end:Date.now()}),delete this.started[$]}toString(){let $=[],Q=0;for(let{name:K}of this.times)Q=Math.max(K.length,Q);for(let{name:K,start:Z,end:J}of this.times)$.push(`${K.padEnd(Q)} ${J-Z}ms
4
+ `);return $.join("")}}function uQ($,Q){let K=Q?URL.parse($,Q):URL.parse($);return K?.protocol==="http:"||K?.protocol==="https:"}function y$($){$.preventDefault()}function N$($){$.preventDefault(),$.stopPropagation()}function AK($){console.log("Deprecated API usage: "+$)}class jQ{static#$;static toDateObject($){if($ instanceof Date)return $;if(!$||typeof $!=="string")return null;this.#$||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let Q=this.#$.exec($);if(!Q)return null;let K=parseInt(Q[1],10),Z=parseInt(Q[2],10);Z=Z>=1&&Z<=12?Z-1:0;let J=parseInt(Q[3],10);J=J>=1&&J<=31?J:1;let _=parseInt(Q[4],10);_=_>=0&&_<=23?_:0;let q=parseInt(Q[5],10);q=q>=0&&q<=59?q:0;let G=parseInt(Q[6],10);G=G>=0&&G<=59?G:0;let U=Q[7]||"Z",V=parseInt(Q[8],10);V=V>=0&&V<=23?V:0;let N=parseInt(Q[9],10)||0;if(N=N>=0&&N<=59?N:0,U==="-")_+=V,q+=N;else if(U==="+")_-=V,q-=N;return new Date(Date.UTC(K,Z,J,_,q,G))}}function k7($,{scale:Q=1,rotation:K=0}){let{width:Z,height:J}=$.attributes.style,_=[0,0,parseInt(Z),parseInt(J)];return new $0({viewBox:_,userUnit:1,scale:Q,rotation:K})}function DQ($){if($.startsWith("#")){let Q=parseInt($.slice(1),16);return[(Q&16711680)>>16,(Q&65280)>>8,Q&255]}if($.startsWith("rgb("))return $.slice(4,-1).split(",").map((Q)=>parseInt(Q));if($.startsWith("rgba("))return $.slice(5,-1).split(",").map((Q)=>parseInt(Q)).slice(0,3);return p(`Not a valid color format: "${$}"`),[0,0,0]}function zK($){let Q=document.createElement("span");Q.style.visibility="hidden",Q.style.colorScheme="only light",document.body.append(Q);for(let K of $.keys()){Q.style.color=K;let Z=window.getComputedStyle(Q).color;$.set(K,DQ(Z))}Q.remove()}function U$($){let{a:Q,b:K,c:Z,d:J,e:_,f:q}=$.getTransform();return[Q,K,Z,J,_,q]}function l$($){let{a:Q,b:K,c:Z,d:J,e:_,f:q}=$.getTransform().invertSelf();return[Q,K,Z,J,_,q]}function GQ($,Q,K=!1,Z=!0){if(Q instanceof $0){let{pageWidth:J,pageHeight:_}=Q.rawDims,{style:q}=$,G=S$.isCSSRoundSupported,U=`var(--total-scale-factor) * ${J}px`,V=`var(--total-scale-factor) * ${_}px`,N=G?`round(down, ${U}, var(--scale-round-x))`:`calc(${U})`,R=G?`round(down, ${V}, var(--scale-round-y))`:`calc(${V})`;if(!K||Q.rotation%180===0)q.width=N,q.height=R;else q.width=R,q.height=N}if(Z)$.setAttribute("data-main-rotation",Q.rotation)}class d${constructor(){let{pixelRatio:$}=d$;this.sx=$,this.sy=$}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas($,Q,K,Z,J=-1){let _=1/0,q=1/0,G=1/0;if(K=d$.capPixels(K,J),K>0)_=Math.sqrt(K/($*Q));if(Z!==-1)q=Z/$,G=Z/Q;let U=Math.min(_,q,G);if(this.sx>U||this.sy>U)return this.sx=U,this.sy=U,!0;return!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels($,Q){if(Q>=0){let K=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+Q/100));return $>0?Math.min($,K):K}return $}}var T0=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class E7{static get isDarkMode(){return r(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class A6{static get commentForegroundColor(){let $=document.createElement("span");$.classList.add("comment","sidebar");let{style:Q}=$;Q.width=Q.height="0",Q.display="none",Q.color="var(--comment-fg-color)",document.body.append($);let{color:K}=window.getComputedStyle($);return $.remove(),r(this,"commentForegroundColor",DQ(K))}}function M7($,Q,K,Z){Z=Math.min(Math.max(Z??1,0),1);let J=255*(1-Z);return $=Math.round($*Z+J),Q=Math.round(Q*Z+J),K=Math.round(K*Z+J),[$,Q,K]}function r6($,Q){let K=$[0]/255,Z=$[1]/255,J=$[2]/255,_=Math.max(K,Z,J),q=Math.min(K,Z,J),G=(_+q)/2;if(_===q)Q[0]=Q[1]=0;else{let U=_-q;switch(Q[1]=G<0.5?U/(_+q):U/(2-_-q),_){case K:Q[0]=((Z-J)/U+(Z<J?6:0))*60;break;case Z:Q[0]=((J-K)/U+2)*60;break;case J:Q[0]=((K-Z)/U+4)*60;break}}Q[2]=G}function t0($,Q){let K=$[0],Z=$[1],J=$[2],_=(1-Math.abs(2*J-1))*Z,q=_*(1-Math.abs(K/60%2-1)),G=J-_/2;switch(Math.floor(K/60)){case 0:Q[0]=_+G,Q[1]=q+G,Q[2]=G;break;case 1:Q[0]=q+G,Q[1]=_+G,Q[2]=G;break;case 2:Q[0]=G,Q[1]=_+G,Q[2]=q+G;break;case 3:Q[0]=G,Q[1]=q+G,Q[2]=_+G;break;case 4:Q[0]=q+G,Q[1]=G,Q[2]=_+G;break;case 5:case 6:Q[0]=_+G,Q[1]=G,Q[2]=q+G;break}}function n6($){return $<=0.03928?$/12.92:(($+0.055)/1.055)**2.4}function a6($,Q,K){t0($,K),K.map(n6);let Z=0.2126*K[0]+0.7152*K[1]+0.0722*K[2];t0(Q,K),K.map(n6);let J=0.2126*K[0]+0.7152*K[1]+0.0722*K[2];return Z>J?(Z+0.05)/(J+0.05):(J+0.05)/(Z+0.05)}var i6=new Map;function W7($,Q){let K=$[0]+$[1]*256+$[2]*65536+Q[0]*16777216+Q[1]*4294967296+Q[2]*1099511627776,Z=i6.get(K);if(Z)return Z;let J=new Float32Array(9),_=J.subarray(0,3),q=J.subarray(3,6);r6($,q);let G=J.subarray(6,9);r6(Q,G);let U=G[2]<0.5,V=U?12:4.5;if(q[2]=U?Math.sqrt(q[2]):1-Math.sqrt(1-q[2]),a6(q,G,_)<V){let N,R;if(U)N=q[2],R=1;else N=0,R=q[2];let j=0.005;while(R-N>j){let F=q[2]=(N+R)/2;if(U===a6(q,G,_)<V)N=F;else R=F}q[2]=U?R:N}return t0(q,_),Z=x.makeHexColor(Math.round(_[0]*255),Math.round(_[1]*255),Math.round(_[2]*255)),i6.set(K,Z),Z}function z6({html:$,dir:Q,className:K},Z){let J=document.createDocumentFragment();if(typeof $==="string"){let _=document.createElement("p");_.dir=Q||"auto";let q=$.split(/(?:\r\n?|\n)/);for(let G=0,U=q.length;G<U;++G){let V=q[G];if(_.append(document.createTextNode(V)),G<U-1)_.append(document.createElement("br"))}J.append(_)}else H0.render({xfaHtml:$,div:J,intent:"richText"});J.firstChild.classList.add("richText",K),Z.append(J)}s(4972);s(4628);s(7642);s(8004);s(3853);s(5876);s(2475);s(5024);s(1698);s(9314);s(1148);s(3579);s(8335);class hQ{#$=null;#Q=null;#Z;#K=null;#q=null;#J=null;#_=null;#G=null;static#V=null;constructor($){this.#Z=$,hQ.#V||=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(){let $=this.#$=document.createElement("div");$.classList.add("editToolbar","hidden"),$.setAttribute("role","toolbar");let Q=this.#Z._uiManager._signal;if(Q instanceof AbortSignal&&!Q.aborted)$.addEventListener("contextmenu",y$,{signal:Q}),$.addEventListener("pointerdown",hQ.#U,{signal:Q});let K=this.#K=document.createElement("div");K.className="buttons",$.append(K);let Z=this.#Z.toolbarPosition;if(Z){let{style:J}=$,_=this.#Z._uiManager.direction==="ltr"?1-Z[0]:Z[0];J.insetInlineEnd=`${100*_}%`,J.top=`calc(${100*Z[1]}% + var(--editor-toolbar-vert-offset))`}return $}get div(){return this.#$}static#U($){$.stopPropagation()}#j($){this.#Z._focusEventsAllowed=!1,N$($)}#R($){this.#Z._focusEventsAllowed=!0,N$($)}#B($){let Q=this.#Z._uiManager._signal;if(!(Q instanceof AbortSignal)||Q.aborted)return!1;return $.addEventListener("focusin",this.#j.bind(this),{capture:!0,signal:Q}),$.addEventListener("focusout",this.#R.bind(this),{capture:!0,signal:Q}),$.addEventListener("contextmenu",y$,{signal:Q}),!0}hide(){this.#$.classList.add("hidden"),this.#Q?.hideDropdown()}show(){this.#$.classList.remove("hidden"),this.#q?.shown(),this.#J?.shown()}addDeleteButton(){let{editorType:$,_uiManager:Q}=this.#Z,K=document.createElement("button");if(K.classList.add("basic","deleteButton"),K.tabIndex=0,K.setAttribute("data-l10n-id",hQ.#V[$]),this.#B(K))K.addEventListener("click",(Z)=>{Q.delete()},{signal:Q._signal});this.#K.append(K)}get#z(){let $=document.createElement("div");return $.className="divider",$}async addAltText($){let Q=await $.render();this.#B(Q),this.#K.append(Q,this.#z),this.#q=$}addComment($,Q=null){if(this.#J)return;let K=$.renderForToolbar();if(!K)return;this.#B(K);let Z=this.#_=this.#z;if(!Q)this.#K.append(K,Z);else this.#K.insertBefore(K,Q),this.#K.insertBefore(Z,Q);this.#J=$,$.toolbar=this}addColorPicker($){if(this.#Q)return;this.#Q=$;let Q=$.renderButton();this.#B(Q),this.#K.append(Q,this.#z)}async addEditSignatureButton($){let Q=this.#G=await $.renderEditButton(this.#Z);this.#B(Q),this.#K.append(Q,this.#z)}removeButton($){switch($){case"comment":this.#J?.removeToolbarCommentButton(),this.#J=null,this.#_?.remove(),this.#_=null;break}}async addButton($,Q){switch($){case"colorPicker":this.addColorPicker(Q);break;case"altText":await this.addAltText(Q);break;case"editSignature":await this.addEditSignatureButton(Q);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(Q);break}}async addButtonBefore($,Q,K){let Z=this.#K.querySelector(K);if(!Z)return;if($==="comment")this.addComment(Q,Z)}updateEditSignatureButton($){if(this.#G)this.#G.title=$}remove(){this.#$.remove(),this.#Q?.destroy(),this.#Q=null}}class X7{#$=null;#Q=null;#Z;constructor($){this.#Z=$}#K(){let $=this.#Q=document.createElement("div");$.className="editToolbar",$.setAttribute("role","toolbar");let Q=this.#Z._signal;if(Q instanceof AbortSignal&&!Q.aborted)$.addEventListener("contextmenu",y$,{signal:Q});let K=this.#$=document.createElement("div");if(K.className="buttons",$.append(K),this.#Z.hasCommentManager())this.#J("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#Z.commentSelection("floating_button")});return this.#J("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#Z.highlightSelection("floating_button")}),$}#q($,Q){let K=0,Z=0;for(let J of $){let _=J.y+J.height;if(_<K)continue;let q=J.x+(Q?J.width:0);if(_>K){Z=q,K=_;continue}if(Q){if(q>Z)Z=q}else if(q<Z)Z=q}return[Q?1-Z:Z,K]}show($,Q,K){let[Z,J]=this.#q(Q,K),{style:_}=this.#Q||=this.#K();$.append(this.#Q),_.insetInlineEnd=`${100*Z}%`,_.top=`calc(${100*J}% + var(--editor-toolbar-vert-offset))`}hide(){this.#Q.remove()}#J($,Q,K,Z){let J=document.createElement("button");J.classList.add("basic",$),J.tabIndex=0,J.setAttribute("data-l10n-id",Q);let _=document.createElement("span");J.append(_),_.className="visuallyHidden",_.setAttribute("data-l10n-id",K);let q=this.#Z._signal;if(q instanceof AbortSignal&&!q.aborted)J.addEventListener("contextmenu",y$,{signal:q}),J.addEventListener("click",Z,{signal:q});this.#$.append(J)}}function Y7($,Q,K){for(let Z of K)Q.addEventListener(Z,$[Z].bind($))}class L7{#$=0;get id(){return`${pQ}${this.#$++}`}}class O6{#$=B6();#Q=0;#Z=null;static get _isSVGFittingCanvas(){let K=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),Z=new Image;Z.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';let J=Z.decode().then(()=>{return K.drawImage(Z,0,0,1,1,0,0,1,3),new Uint32Array(K.getImageData(0,0,1,1).data.buffer)[0]===0});return r(this,"_isSVGFittingCanvas",J)}async#K($,Q){this.#Z||=new Map;let K=this.#Z.get($);if(K===null)return null;if(K?.bitmap)return K.refCounter+=1,K;try{K||={bitmap:null,id:`image_${this.#$}_${this.#Q++}`,refCounter:0,isSvg:!1};let Z;if(typeof Q==="string")K.url=Q,Z=await HQ(Q,"blob");else if(Q instanceof File)Z=K.file=Q;else if(Q instanceof Blob)Z=Q;if(Z.type==="image/svg+xml"){let J=O6._isSVGFittingCanvas,_=new FileReader,q=new Image,G=new Promise((U,V)=>{q.onload=()=>{K.bitmap=q,K.isSvg=!0,U()},_.onload=async()=>{let N=K.svgUrl=_.result;q.src=await J?`${N}#svgView(preserveAspectRatio(none))`:N},q.onerror=_.onerror=V});_.readAsDataURL(Z),await G}else K.bitmap=await createImageBitmap(Z);K.refCounter=1}catch(Z){p(Z),K=null}if(this.#Z.set($,K),K)this.#Z.set(K.id,K);return K}async getFromFile($){let{lastModified:Q,name:K,size:Z,type:J}=$;return this.#K(`${Q}_${K}_${Z}_${J}`,$)}async getFromUrl($){return this.#K($,$)}async getFromBlob($,Q){let K=await Q;return this.#K($,K)}async getFromId($){this.#Z||=new Map;let Q=this.#Z.get($);if(!Q)return null;if(Q.bitmap)return Q.refCounter+=1,Q;if(Q.file)return this.getFromFile(Q.file);if(Q.blobPromise){let{blobPromise:K}=Q;return delete Q.blobPromise,this.getFromBlob(Q.id,K)}return this.getFromUrl(Q.url)}getFromCanvas($,Q){this.#Z||=new Map;let K=this.#Z.get($);if(K?.bitmap)return K.refCounter+=1,K;let Z=new OffscreenCanvas(Q.width,Q.height);return Z.getContext("2d").drawImage(Q,0,0),K={bitmap:Z.transferToImageBitmap(),id:`image_${this.#$}_${this.#Q++}`,refCounter:1,isSvg:!1},this.#Z.set($,K),this.#Z.set(K.id,K),K}getSvgUrl($){let Q=this.#Z.get($);if(!Q?.isSvg)return null;return Q.svgUrl}deleteId($){this.#Z||=new Map;let Q=this.#Z.get($);if(!Q)return;if(Q.refCounter-=1,Q.refCounter!==0)return;let{bitmap:K}=Q;if(!Q.url&&!Q.file){let Z=new OffscreenCanvas(K.width,K.height);Z.getContext("bitmaprenderer").transferFromImageBitmap(K),Q.blobPromise=Z.convertToBlob()}K.close?.(),Q.bitmap=null}isValidId($){return $.startsWith(`image_${this.#$}_`)}}class P7{#$=[];#Q=!1;#Z;#K=-1;constructor($=128){this.#Z=$}add({cmd:$,undo:Q,post:K,mustExec:Z,type:J=NaN,overwriteIfSameType:_=!1,keepUndo:q=!1}){if(Z)$();if(this.#Q)return;let G={cmd:$,undo:Q,post:K,type:J};if(this.#K===-1){if(this.#$.length>0)this.#$.length=0;this.#K=0,this.#$.push(G);return}if(_&&this.#$[this.#K].type===J){if(q)G.undo=this.#$[this.#K].undo;this.#$[this.#K]=G;return}let U=this.#K+1;if(U===this.#Z)this.#$.splice(0,1);else if(this.#K=U,U<this.#$.length)this.#$.splice(U);this.#$.push(G)}undo(){if(this.#K===-1)return;this.#Q=!0;let{undo:$,post:Q}=this.#$[this.#K];$(),Q?.(),this.#Q=!1,this.#K-=1}redo(){if(this.#K<this.#$.length-1){this.#K+=1,this.#Q=!0;let{cmd:$,post:Q}=this.#$[this.#K];$(),Q?.(),this.#Q=!1}}hasSomethingToUndo(){return this.#K!==-1}hasSomethingToRedo(){return this.#K<this.#$.length-1}cleanType($){if(this.#K===-1)return;for(let Q=this.#K;Q>=0;Q--)if(this.#$[Q].type!==$){this.#$.splice(Q+1,this.#K-Q),this.#K=Q;return}this.#$.length=0,this.#K=-1}destroy(){this.#$=null}}class vQ{constructor($){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:Q}=S$.platform;for(let[K,Z,J={}]of $)for(let _ of K){let q=_.startsWith("mac+");if(Q&&q)this.callbacks.set(_.slice(4),{callback:Z,options:J}),this.allKeys.add(_.split("+").at(-1));else if(!Q&&!q)this.callbacks.set(_,{callback:Z,options:J}),this.allKeys.add(_.split("+").at(-1))}}#$($){if($.altKey)this.buffer.push("alt");if($.ctrlKey)this.buffer.push("ctrl");if($.metaKey)this.buffer.push("meta");if($.shiftKey)this.buffer.push("shift");this.buffer.push($.key);let Q=this.buffer.join("+");return this.buffer.length=0,Q}exec($,Q){if(!this.allKeys.has(Q.key))return;let K=this.callbacks.get(this.#$(Q));if(!K)return;let{callback:Z,options:{bubbles:J=!1,args:_=[],checker:q=null}}=K;if(q&&!q($,Q))return;if(Z.bind($,..._,Q)(),!J)N$(Q)}}class S6{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let $=new Map([["CanvasText",null],["Canvas",null]]);return zK($),r(this,"_colors",$)}convert($){let Q=DQ($);if(!window.matchMedia("(forced-colors: active)").matches)return Q;for(let[K,Z]of this._colors)if(Z.every((J,_)=>J===Q[_]))return S6._colorsMapping.get(K);return Q}getHexCode($){let Q=this._colors.get($);if(!Q)return $;return x.makeHexColor(...Q)}}class ZQ{#$=new AbortController;#Q=null;#Z=null;#K=new Map;#q=new Map;#J=null;#_=null;#G=null;#V=new P7;#U=null;#j=null;#R=null;#B=0;#z=new Set;#F=null;#N=null;#A=new Set;_editorUndoBar=null;#O=!1;#T=!1;#S=!1;#W=null;#E=null;#I=null;#Y=null;#k=!1;#M=null;#H=new L7;#L=!1;#P=!1;#x=!1;#v=null;#w=null;#c=null;#b=null;#d=null;#X=d.NONE;#C=new Set;#f=null;#u=null;#h=null;#o=null;#s=null;#r={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#g=[0,0];#y=null;#l=null;#t=null;#e=null;#m=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let $=ZQ.prototype,Q=(_)=>_.#l.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&_.hasSomethingToControl(),K=(_,{target:q})=>{if(q instanceof HTMLInputElement){let{type:G}=q;return G!=="text"&&G!=="number"}return!0},Z=this.TRANSLATE_SMALL,J=this.TRANSLATE_BIG;return r(this,"_keyboardManager",new vQ([[["ctrl+a","mac+meta+a"],$.selectAll,{checker:K}],[["ctrl+z","mac+meta+z"],$.undo,{checker:K}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],$.redo,{checker:K}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],$.delete,{checker:K}],[["Enter","mac+Enter"],$.addNewEditorFromKeyboard,{checker:(_,{target:q})=>!(q instanceof HTMLButtonElement)&&_.#l.contains(q)&&!_.isEnterHandled}],[[" ","mac+ "],$.addNewEditorFromKeyboard,{checker:(_,{target:q})=>!(q instanceof HTMLButtonElement)&&_.#l.contains(document.activeElement)}],[["Escape","mac+Escape"],$.unselectAll],[["ArrowLeft","mac+ArrowLeft"],$.translateSelectedEditors,{args:[-Z,0],checker:Q}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],$.translateSelectedEditors,{args:[-J,0],checker:Q}],[["ArrowRight","mac+ArrowRight"],$.translateSelectedEditors,{args:[Z,0],checker:Q}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],$.translateSelectedEditors,{args:[J,0],checker:Q}],[["ArrowUp","mac+ArrowUp"],$.translateSelectedEditors,{args:[0,-Z],checker:Q}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],$.translateSelectedEditors,{args:[0,-J],checker:Q}],[["ArrowDown","mac+ArrowDown"],$.translateSelectedEditors,{args:[0,Z],checker:Q}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],$.translateSelectedEditors,{args:[0,J],checker:Q}]]))}constructor($,Q,K,Z,J,_,q,G,U,V,N,R,j,F,B,A){let z=this._signal=this.#$.signal;this.#l=$,this.#t=Q,this.#e=K,this.#J=Z,this.#U=J,this.#u=_,this.#s=G,this._eventBus=q,q._on("editingaction",this.onEditingAction.bind(this),{signal:z}),q._on("pagechanging",this.onPageChanging.bind(this),{signal:z}),q._on("scalechanging",this.onScaleChanging.bind(this),{signal:z}),q._on("rotationchanging",this.onRotationChanging.bind(this),{signal:z}),q._on("setpreference",this.onSetPreference.bind(this),{signal:z}),q._on("switchannotationeditorparams",(O)=>this.updateParams(O.type,O.value),{signal:z}),window.addEventListener("pointerdown",()=>{this.#P=!0},{capture:!0,signal:z}),window.addEventListener("pointerup",()=>{this.#P=!1},{capture:!0,signal:z}),this.#U$(),this.#j$(),this.#Q$(),this.#_=G.annotationStorage,this.#W=G.filterFactory,this.#h=U,this.#Y=V||null,this.#O=N,this.#T=R,this.#S=j,this.#d=F||null,this.viewParameters={realScale:qQ.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=B||null,this._supportsPinchToZoom=A!==!1,J?.setSidebarUiManager(this)}destroy(){this.#m?.resolve(),this.#m=null,this.#$?.abort(),this.#$=null,this._signal=null;for(let $ of this.#q.values())$.destroy();if(this.#q.clear(),this.#K.clear(),this.#A.clear(),this.#b?.clear(),this.#Q=null,this.#C.clear(),this.#V.destroy(),this.#J?.destroy(),this.#U?.destroy(),this.#u?.destroy(),this.#M?.hide(),this.#M=null,this.#c?.destroy(),this.#c=null,this.#Z=null,this.#E)clearTimeout(this.#E),this.#E=null;if(this.#y)clearTimeout(this.#y),this.#y=null;this._editorUndoBar?.destroy(),this.#s=null}combinedSignal($){return AbortSignal.any([this._signal,$.signal])}get mlManager(){return this.#d}get useNewAltTextFlow(){return this.#T}get useNewAltTextWhenAddingImage(){return this.#S}get hcmFilter(){return r(this,"hcmFilter",this.#h?this.#W.addHCMFilter(this.#h.foreground,this.#h.background):"none")}get direction(){return r(this,"direction",getComputedStyle(this.#l).direction)}get _highlightColors(){return r(this,"_highlightColors",this.#Y?new Map(this.#Y.split(",").map(($)=>{return $=$.split("=").map((Q)=>Q.trim()),$[1]=$[1].toUpperCase(),$})):null)}get highlightColors(){let{_highlightColors:$}=this;if(!$)return r(this,"highlightColors",null);let Q=new Map,K=!!this.#h;for(let[Z,J]of $){let _=Z.endsWith("_HCM");if(K&&_){Q.set(Z.replace("_HCM",""),J);continue}if(!K&&!_)Q.set(Z,J)}return r(this,"highlightColors",Q)}get highlightColorNames(){return r(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,($)=>$.reverse())):null)}getNonHCMColor($){if(!this._highlightColors)return $;let Q=this.highlightColorNames.get($);return this._highlightColors.get(Q)||$}getNonHCMColorName($){return this.highlightColorNames.get($)||$}setCurrentDrawingSession($){if($)this.unselectAll(),this.disableUserSelect(!0);else this.disableUserSelect(!1);this.#R=$}setMainHighlightColorPicker($){this.#c=$}editAltText($,Q=!1){this.#J?.editAltText(this,$,Q)}hasCommentManager(){return!!this.#U}editComment($,Q,K,Z){this.#U?.showDialog(this,$,Q,K,Z)}selectComment($,Q){this.#q.get($)?.getEditorByUID(Q)?.toggleComment(!0,!0)}updateComment($){this.#U?.updateComment($.getData())}updatePopupColor($){this.#U?.updatePopupColor($)}removeComment($){this.#U?.removeComments([$.uid])}toggleComment($,Q,K=void 0){this.#U?.toggleCommentPopup($,Q,K)}makeCommentColor($,Q){return $&&this.#U?.makeCommentColor($,Q)||null}getCommentDialogElement(){return this.#U?.dialogElement||null}async waitForEditorsRendered($){if(this.#q.has($-1))return;let{resolve:Q,promise:K}=Promise.withResolvers(),Z=(J)=>{if(J.pageNumber===$)this._eventBus._off("editorsrendered",Z),Q()};this._eventBus.on("editorsrendered",Z),await K}getSignature($){this.#u?.getSignature({uiManager:this,editor:$})}get signatureManager(){return this.#u}switchToMode($,Q){this._eventBus.on("annotationeditormodechanged",Q,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:$})}setPreference($,Q){this._eventBus.dispatch("setpreference",{source:this,name:$,value:Q})}onSetPreference({name:$,value:Q}){switch($){case"enableNewAltTextWhenAddingImage":this.#S=Q;break}}onPageChanging({pageNumber:$}){this.#B=$-1}focusMainContainer(){this.#l.focus()}findParent($,Q){for(let K of this.#q.values()){let{x:Z,y:J,width:_,height:q}=K.div.getBoundingClientRect();if($>=Z&&$<=Z+_&&Q>=J&&Q<=J+q)return K}return null}disableUserSelect($=!1){this.#t.classList.toggle("noUserSelect",$)}addShouldRescale($){this.#A.add($)}removeShouldRescale($){this.#A.delete($)}onScaleChanging({scale:$}){this.commitOrRemove(),this.viewParameters.realScale=$*qQ.PDF_TO_CSS_UNITS;for(let Q of this.#A)Q.onScaleChanging();this.#R?.onScaleChanging()}onRotationChanging({pagesRotation:$}){this.commitOrRemove(),this.viewParameters.rotation=$}#i({anchorNode:$}){return $.nodeType===Node.TEXT_NODE?$.parentElement:$}#$$($){let{currentLayer:Q}=this;if(Q.hasTextLayer($))return Q;for(let K of this.#q.values())if(K.hasTextLayer($))return K;return null}highlightSelection($="",Q=!1){let K=document.getSelection();if(!K||K.isCollapsed)return;let{anchorNode:Z,anchorOffset:J,focusNode:_,focusOffset:q}=K,G=K.toString(),V=this.#i(K).closest(".textLayer"),N=this.getSelectionBoxes(V);if(!N)return;K.empty();let R=this.#$$(V),j=this.#X===d.NONE,F=()=>{let B=R?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:$,boxes:N,anchorNode:Z,anchorOffset:J,focusNode:_,focusOffset:q,text:G});if(j)this.showAllEditors("highlight",!0,!0);if(Q)B?.editComment()};if(j){this.switchToMode(d.HIGHLIGHT,F);return}F()}commentSelection($=""){this.highlightSelection($,!0)}#q$(){let $=document.getSelection();if(!$||$.isCollapsed)return;let K=this.#i($).closest(".textLayer"),Z=this.getSelectionBoxes(K);if(!Z)return;this.#M||=new X7(this),this.#M.show(K,Z,this.direction==="ltr")}getAndRemoveDataFromAnnotationStorage($){if(!this.#_)return null;let Q=`${pQ}${$}`,K=this.#_.getRawValue(Q);if(K)this.#_.remove(Q);return K}addToAnnotationStorage($){if(!$.isEmpty()&&this.#_&&!this.#_.has($.id))this.#_.setValue($.id,$)}a11yAlert($,Q=null){let K=this.#e;if(!K)return;if(K.setAttribute("data-l10n-id",$),Q)K.setAttribute("data-l10n-args",JSON.stringify(Q));else K.removeAttribute("data-l10n-args")}#G$(){let $=document.getSelection();if(!$||$.isCollapsed){if(this.#f)this.#M?.hide(),this.#f=null,this.#D({hasSelectedText:!1});return}let{anchorNode:Q}=$;if(Q===this.#f)return;let Z=this.#i($).closest(".textLayer");if(!Z){if(this.#f)this.#M?.hide(),this.#f=null,this.#D({hasSelectedText:!1});return}if(this.#M?.hide(),this.#f=Q,this.#D({hasSelectedText:!0}),this.#X!==d.HIGHLIGHT&&this.#X!==d.NONE)return;if(this.#X===d.HIGHLIGHT)this.showAllEditors("highlight",!0,!0);if(this.#k=this.isShiftKeyDown,!this.isShiftKeyDown){let J=this.#X===d.HIGHLIGHT?this.#$$(Z):null;if(J?.toggleDrawing(),this.#P){let _=new AbortController,q=this.combinedSignal(_),G=(U)=>{if(U.type==="pointerup"&&U.button!==0)return;if(_.abort(),J?.toggleDrawing(!0),U.type==="pointerup")this.#n("main_toolbar")};window.addEventListener("pointerup",G,{signal:q}),window.addEventListener("blur",G,{signal:q})}else J?.toggleDrawing(!0),this.#n("main_toolbar")}}#n($=""){if(this.#X===d.HIGHLIGHT)this.highlightSelection($);else if(this.#O)this.#q$()}#U$(){document.addEventListener("selectionchange",this.#G$.bind(this),{signal:this._signal})}#V$(){if(this.#I)return;this.#I=new AbortController;let $=this.combinedSignal(this.#I);window.addEventListener("focus",this.focus.bind(this),{signal:$}),window.addEventListener("blur",this.blur.bind(this),{signal:$})}#N$(){this.#I?.abort(),this.#I=null}blur(){if(this.isShiftKeyDown=!1,this.#k)this.#k=!1,this.#n("main_toolbar");if(!this.hasSelection)return;let{activeElement:$}=document;for(let Q of this.#C)if(Q.div.contains($)){this.#w=[Q,$],Q._focusEventsAllowed=!1;break}}focus(){if(!this.#w)return;let[$,Q]=this.#w;this.#w=null,Q.addEventListener("focusin",()=>{$._focusEventsAllowed=!0},{once:!0,signal:this._signal}),Q.focus()}#Q$(){if(this.#v)return;this.#v=new AbortController;let $=this.combinedSignal(this.#v);window.addEventListener("keydown",this.keydown.bind(this),{signal:$}),window.addEventListener("keyup",this.keyup.bind(this),{signal:$})}#R$(){this.#v?.abort(),this.#v=null}#K$(){if(this.#j)return;this.#j=new AbortController;let $=this.combinedSignal(this.#j);document.addEventListener("copy",this.copy.bind(this),{signal:$}),document.addEventListener("cut",this.cut.bind(this),{signal:$}),document.addEventListener("paste",this.paste.bind(this),{signal:$})}#Z$(){this.#j?.abort(),this.#j=null}#j$(){let $=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:$}),document.addEventListener("drop",this.drop.bind(this),{signal:$})}addEditListeners(){this.#Q$(),this.#K$()}removeEditListeners(){this.#R$(),this.#Z$()}dragOver($){for(let{type:Q}of $.dataTransfer.items)for(let K of this.#N)if(K.isHandlingMimeForPasting(Q)){$.dataTransfer.dropEffect="copy",$.preventDefault();return}}drop($){for(let Q of $.dataTransfer.items)for(let K of this.#N)if(K.isHandlingMimeForPasting(Q.type)){K.paste(Q,this.currentLayer),$.preventDefault();return}}copy($){if($.preventDefault(),this.#Q?.commitOrRemove(),!this.hasSelection)return;let Q=[];for(let K of this.#C){let Z=K.serialize(!0);if(Z)Q.push(Z)}if(Q.length===0)return;$.clipboardData.setData("application/pdfjs",JSON.stringify(Q))}cut($){this.copy($),this.delete()}async paste($){$.preventDefault();let{clipboardData:Q}=$;for(let J of Q.items)for(let _ of this.#N)if(_.isHandlingMimeForPasting(J.type)){_.paste(J,this.currentLayer);return}let K=Q.getData("application/pdfjs");if(!K)return;try{K=JSON.parse(K)}catch(J){p(`paste: "${J.message}".`);return}if(!Array.isArray(K))return;this.unselectAll();let Z=this.currentLayer;try{let J=[];for(let G of K){let U=await Z.deserialize(G);if(!U)return;J.push(U)}let _=()=>{for(let G of J)this.#J$(G);this.#_$(J)},q=()=>{for(let G of J)G.remove()};this.addCommands({cmd:_,undo:q,mustExec:!0})}catch(J){p(`paste: "${J.message}".`)}}keydown($){if(!this.isShiftKeyDown&&$.key==="Shift")this.isShiftKeyDown=!0;if(this.#X!==d.NONE&&!this.isEditorHandlingKeyboard)ZQ._keyboardManager.exec(this,$)}keyup($){if(this.isShiftKeyDown&&$.key==="Shift"){if(this.isShiftKeyDown=!1,this.#k)this.#k=!1,this.#n("main_toolbar")}}onEditingAction({name:$}){switch($){case"undo":case"redo":case"delete":case"selectAll":this[$]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}#D($){if(Object.entries($).some(([K,Z])=>this.#r[K]!==Z)){if(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#r,$)}),this.#X===d.HIGHLIGHT&&$.hasSelectedEditor===!1)this.#p([[n.HIGHLIGHT_FREE,!0]])}}#p($){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:$})}setEditingState($){if($)this.#V$(),this.#K$(),this.#D({isEditing:this.#X!==d.NONE,isEmpty:this.#a(),hasSomethingToUndo:this.#V.hasSomethingToUndo(),hasSomethingToRedo:this.#V.hasSomethingToRedo(),hasSelectedEditor:!1});else this.#N$(),this.#Z$(),this.#D({isEditing:!1}),this.disableUserSelect(!1)}registerEditorTypes($){if(this.#N)return;this.#N=$;for(let Q of this.#N)this.#p(Q.defaultPropertiesToUpdate)}getId(){return this.#H.id}get currentLayer(){return this.#q.get(this.#B)}getLayer($){return this.#q.get($)}get currentPageIndex(){return this.#B}addLayer($){if(this.#q.set($.pageIndex,$),this.#L)$.enable();else $.disable()}removeLayer($){this.#q.delete($.pageIndex)}async updateMode($,Q=null,K=!1,Z=!1,J=!1){if(this.#X===$)return;if(this.#m){if(await this.#m.promise,!this.#m)return}if(this.#m=Promise.withResolvers(),this.#R?.commitOrRemove(),this.#X===d.POPUP)this.#U?.hideSidebar();if(this.#U?.destroyPopup(),this.#X=$,$===d.NONE){this.setEditingState(!1),this.#F$();for(let _ of this.#K.values())_.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#m.resolve();return}for(let _ of this.#K.values())_.addStandaloneCommentButton();if($===d.SIGNATURE)await this.#u?.loadSignatures();this.setEditingState(!0),await this.#B$(),this.unselectAll();for(let _ of this.#q.values())_.updateMode($);if($===d.POPUP){this.#Z||=await this.#s.getAnnotationsByType(new Set(this.#N.map((G)=>G._editorType)));let _=new Set,q=[];for(let G of this.#K.values()){let{annotationElementId:U,hasComment:V,deleted:N}=G;if(U)_.add(U);if(V&&!N)q.push(G.getData())}for(let G of this.#Z){let{id:U,popupRef:V,contentsObj:N}=G;if(V&&N?.str&&!_.has(U)&&!this.#z.has(U))q.push(G)}this.#U?.showSidebar(q)}if(!Q){if(K)this.addNewEditorFromKeyboard();this.#m.resolve();return}for(let _ of this.#K.values())if(_.uid===Q)if(this.setSelected(_),J)_.editComment();else if(Z)_.enterInEditMode();else _.focus();else _.unselect();this.#m.resolve()}addNewEditorFromKeyboard(){if(this.currentLayer.canCreateNewEmptyEditor())this.currentLayer.addNewEditor()}updateToolbar($){if($.mode===this.#X)return;this._eventBus.dispatch("switchannotationeditormode",{source:this,...$})}updateParams($,Q){if(!this.#N)return;switch($){case n.CREATE:this.currentLayer.addNewEditor(Q);return;case n.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#o||=new Map).set($,Q),this.showAllEditors("highlight",Q);break}if(this.hasSelection)for(let K of this.#C)K.updateParams($,Q);else for(let K of this.#N)K.updateDefaultParams($,Q)}showAllEditors($,Q,K=!1){for(let J of this.#K.values())if(J.editorType===$)J.show(Q);if((this.#o?.get(n.HIGHLIGHT_SHOW_ALL)??!0)!==Q)this.#p([[n.HIGHLIGHT_SHOW_ALL,Q]])}enableWaiting($=!1){if(this.#x===$)return;this.#x=$;for(let Q of this.#q.values()){if($)Q.disableClick();else Q.enableClick();Q.div.classList.toggle("waiting",$)}}async#B$(){if(!this.#L){this.#L=!0;let $=[];for(let Q of this.#q.values())$.push(Q.enable());await Promise.all($);for(let Q of this.#K.values())Q.enable()}}#F$(){if(this.unselectAll(),this.#L){this.#L=!1;for(let $ of this.#q.values())$.disable();for(let $ of this.#K.values())$.disable()}}*getEditors($){for(let Q of this.#K.values())if(Q.pageIndex===$)yield Q}getEditor($){return this.#K.get($)}addEditor($){this.#K.set($.id,$)}removeEditor($){if($.div.contains(document.activeElement)){if(this.#E)clearTimeout(this.#E);this.#E=setTimeout(()=>{this.focusMainContainer(),this.#E=null},0)}if(this.#K.delete($.id),$.annotationElementId)this.#b?.delete($.annotationElementId);if(this.unselect($),!$.annotationElementId||!this.#z.has($.annotationElementId))this.#_?.remove($.id)}addDeletedAnnotationElement($){this.#z.add($.annotationElementId),this.addChangedExistingAnnotation($),$.deleted=!0}isDeletedAnnotationElement($){return this.#z.has($)}removeDeletedAnnotationElement($){this.#z.delete($.annotationElementId),this.removeChangedExistingAnnotation($),$.deleted=!1}#J$($){let Q=this.#q.get($.pageIndex);if(Q)Q.addOrRebuild($);else this.addEditor($),this.addToAnnotationStorage($)}setActiveEditor($){if(this.#Q===$)return;if(this.#Q=$,$)this.#p($.propertiesToUpdate)}get#A$(){let $=null;for($ of this.#C);return $}updateUI($){if(this.#A$===$)this.#p($.propertiesToUpdate)}updateUIForDefaultProperties($){this.#p($.defaultPropertiesToUpdate)}toggleSelected($){if(this.#C.has($)){this.#C.delete($),$.unselect(),this.#D({hasSelectedEditor:this.hasSelection});return}this.#C.add($),$.select(),this.#p($.propertiesToUpdate),this.#D({hasSelectedEditor:!0})}setSelected($){this.updateToolbar({mode:$.mode,editId:$.id}),this.#R?.commitOrRemove();for(let Q of this.#C)if(Q!==$)Q.unselect();this.#C.clear(),this.#C.add($),$.select(),this.#p($.propertiesToUpdate),this.#D({hasSelectedEditor:!0})}isSelected($){return this.#C.has($)}get firstSelectedEditor(){return this.#C.values().next().value}unselect($){$.unselect(),this.#C.delete($),this.#D({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#C.size!==0}get isEnterHandled(){return this.#C.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#V.undo(),this.#D({hasSomethingToUndo:this.#V.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#a()}),this._editorUndoBar?.hide()}redo(){this.#V.redo(),this.#D({hasSomethingToUndo:!0,hasSomethingToRedo:this.#V.hasSomethingToRedo(),isEmpty:this.#a()})}addCommands($){this.#V.add($),this.#D({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#a()})}cleanUndoStack($){this.#V.cleanType($)}#a(){if(this.#K.size===0)return!0;if(this.#K.size===1)for(let $ of this.#K.values())return $.isEmpty();return!1}delete(){this.commitOrRemove();let $=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!$)return;let Q=$?[$]:[...this.#C],K=()=>{this._editorUndoBar?.show(Z,Q.length===1?Q[0].editorType:Q.length);for(let J of Q)J.remove()},Z=()=>{for(let J of Q)this.#J$(J)};this.addCommands({cmd:K,undo:Z,mustExec:!0})}commitOrRemove(){this.#Q?.commitOrRemove()}hasSomethingToControl(){return this.#Q||this.hasSelection}#_$($){for(let Q of this.#C)Q.unselect();this.#C.clear();for(let Q of $){if(Q.isEmpty())continue;this.#C.add(Q),Q.select()}this.#D({hasSelectedEditor:this.hasSelection})}selectAll(){for(let $ of this.#C)$.commit();this.#_$(this.#K.values())}unselectAll(){if(this.#Q){if(this.#Q.commitOrRemove(),this.#X!==d.NONE)return}if(this.#R?.commitOrRemove())return;if(!this.hasSelection)return;for(let $ of this.#C)$.unselect();this.#C.clear(),this.#D({hasSelectedEditor:!1})}translateSelectedEditors($,Q,K=!1){if(!K)this.commitOrRemove();if(!this.hasSelection)return;this.#g[0]+=$,this.#g[1]+=Q;let[Z,J]=this.#g,_=[...this.#C],q=1000;if(this.#y)clearTimeout(this.#y);this.#y=setTimeout(()=>{this.#y=null,this.#g[0]=this.#g[1]=0,this.addCommands({cmd:()=>{for(let G of _)if(this.#K.has(G.id))G.translateInPage(Z,J),G.translationDone()},undo:()=>{for(let G of _)if(this.#K.has(G.id))G.translateInPage(-Z,-J),G.translationDone()},mustExec:!1})},q);for(let G of _)G.translateInPage($,Q),G.translationDone()}setUpDragSession(){if(!this.hasSelection)return;this.disableUserSelect(!0),this.#F=new Map;for(let $ of this.#C)this.#F.set($,{savedX:$.x,savedY:$.y,savedPageIndex:$.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#F)return!1;this.disableUserSelect(!1);let $=this.#F;this.#F=null;let Q=!1;for(let[{x:Z,y:J,pageIndex:_},q]of $)q.newX=Z,q.newY=J,q.newPageIndex=_,Q||=Z!==q.savedX||J!==q.savedY||_!==q.savedPageIndex;if(!Q)return!1;let K=(Z,J,_,q)=>{if(this.#K.has(Z.id)){let G=this.#q.get(q);if(G)Z._setParentAndPosition(G,J,_);else Z.pageIndex=q,Z.x=J,Z.y=_}};return this.addCommands({cmd:()=>{for(let[Z,{newX:J,newY:_,newPageIndex:q}]of $)K(Z,J,_,q)},undo:()=>{for(let[Z,{savedX:J,savedY:_,savedPageIndex:q}]of $)K(Z,J,_,q)},mustExec:!0}),!0}dragSelectedEditors($,Q){if(!this.#F)return;for(let K of this.#F.keys())K.drag($,Q)}rebuild($){if($.parent===null){let Q=this.getLayer($.pageIndex);if(Q)Q.changeParent($),Q.addOrRebuild($);else this.addEditor($),this.addToAnnotationStorage($),$.rebuild()}else $.parent.addOrRebuild($)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#C.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive($){return this.#Q===$}getActive(){return this.#Q}getMode(){return this.#X}isEditingMode(){return this.#X!==d.NONE}get imageManager(){return r(this,"imageManager",new O6)}getSelectionBoxes($){if(!$)return null;let Q=document.getSelection();for(let U=0,V=Q.rangeCount;U<V;U++)if(!$.contains(Q.getRangeAt(U).commonAncestorContainer))return null;let{x:K,y:Z,width:J,height:_}=$.getBoundingClientRect(),q;switch($.getAttribute("data-main-rotation")){case"90":q=(U,V,N,R)=>({x:(V-Z)/_,y:1-(U+N-K)/J,width:R/_,height:N/J});break;case"180":q=(U,V,N,R)=>({x:1-(U+N-K)/J,y:1-(V+R-Z)/_,width:N/J,height:R/_});break;case"270":q=(U,V,N,R)=>({x:1-(V+R-Z)/_,y:(U-K)/J,width:R/_,height:N/J});break;default:q=(U,V,N,R)=>({x:(U-K)/J,y:(V-Z)/_,width:N/J,height:R/_});break}let G=[];for(let U=0,V=Q.rangeCount;U<V;U++){let N=Q.getRangeAt(U);if(N.collapsed)continue;for(let{x:R,y:j,width:F,height:B}of N.getClientRects()){if(F===0||B===0)continue;G.push(q(R,j,F,B))}}return G.length===0?null:G}addChangedExistingAnnotation({annotationElementId:$,id:Q}){(this.#G||=new Map).set($,Q)}removeChangedExistingAnnotation({annotationElementId:$}){this.#G?.delete($)}renderAnnotationElement($){let Q=this.#G?.get($.data.id);if(!Q)return;let K=this.#_.getRawValue(Q);if(!K)return;if(this.#X===d.NONE&&!K.hasBeenModified)return;K.renderAnnotationElement($)}setMissingCanvas($,Q,K){let Z=this.#b?.get($);if(!Z)return;Z.setCanvas(Q,K),this.#b.delete($)}addMissingCanvas($,Q){(this.#b||=new Map).set($,Q)}}class r${#$=null;#Q=!1;#Z=null;#K=null;#q=null;#J=null;#_=!1;#G=null;#V=null;#U=null;#j=null;#R=!1;static#B=null;static _l10n=null;constructor($){this.#V=$,this.#R=$._uiManager.useNewAltTextFlow,r$.#B||=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($){r$._l10n??=$}async render(){let $=this.#Z=document.createElement("button");$.className="altText",$.tabIndex="0";let Q=this.#K=document.createElement("span");if($.append(Q),this.#R)$.classList.add("new"),$.setAttribute("data-l10n-id",r$.#B.missing),Q.setAttribute("data-l10n-id",r$.#B["missing-label"]);else $.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),Q.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label");let K=this.#V._uiManager._signal;$.addEventListener("contextmenu",y$,{signal:K}),$.addEventListener("pointerdown",(J)=>J.stopPropagation(),{signal:K});let Z=(J)=>{if(J.preventDefault(),this.#V._uiManager.editAltText(this.#V),this.#R)this.#V._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#z}})};return $.addEventListener("click",Z,{capture:!0,signal:K}),$.addEventListener("keydown",(J)=>{if(J.target===$&&J.key==="Enter")this.#_=!0,Z(J)},{signal:K}),await this.#F(),$}get#z(){return this.#$&&"added"||this.#$===null&&this.guessedText&&"review"||"missing"}finish(){if(!this.#Z)return;this.#Z.focus({focusVisible:this.#_}),this.#_=!1}isEmpty(){if(this.#R)return this.#$===null;return!this.#$&&!this.#Q}hasData(){if(this.#R)return this.#$!==null||!!this.#U;return this.isEmpty()}get guessedText(){return this.#U}async setGuessedText($){if(this.#$!==null)return;this.#U=$,this.#j=await r$._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:$}),this.#F()}toggleAltTextBadge($=!1){if(!this.#R||this.#$){this.#G?.remove(),this.#G=null;return}if(!this.#G){let Q=this.#G=document.createElement("div");Q.className="noAltTextBadge",this.#V.div.append(Q)}this.#G.classList.toggle("hidden",!$)}serialize($){let Q=this.#$;if(!$&&this.#U===Q)Q=this.#j;return{altText:Q,decorative:this.#Q,guessedText:this.#U,textWithDisclaimer:this.#j}}get data(){return{altText:this.#$,decorative:this.#Q}}set data({altText:$,decorative:Q,guessedText:K,textWithDisclaimer:Z,cancel:J=!1}){if(K)this.#U=K,this.#j=Z;if(this.#$===$&&this.#Q===Q)return;if(!J)this.#$=$,this.#Q=Q;this.#F()}toggle($=!1){if(!this.#Z)return;if(!$&&this.#J)clearTimeout(this.#J),this.#J=null;this.#Z.disabled=!$}shown(){this.#V._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#z}})}destroy(){this.#Z?.remove(),this.#Z=null,this.#K=null,this.#q=null,this.#G?.remove(),this.#G=null}async#F(){let $=this.#Z;if(!$)return;if(this.#R){if($.classList.toggle("done",!!this.#$),$.setAttribute("data-l10n-id",r$.#B[this.#z]),this.#K?.setAttribute("data-l10n-id",r$.#B[`${this.#z}-label`]),!this.#$){this.#q?.remove();return}}else{if(!this.#$&&!this.#Q){$.classList.remove("done"),this.#q?.remove();return}$.classList.add("done"),$.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let Q=this.#q;if(!Q){this.#q=Q=document.createElement("span"),Q.className="tooltip",Q.setAttribute("role","tooltip"),Q.id=`alt-text-tooltip-${this.#V.id}`;let Z=100,J=this.#V._uiManager._signal;J.addEventListener("abort",()=>{clearTimeout(this.#J),this.#J=null},{once:!0}),$.addEventListener("mouseenter",()=>{this.#J=setTimeout(()=>{this.#J=null,this.#q.classList.add("show"),this.#V._reportTelemetry({action:"alt_text_tooltip"})},Z)},{signal:J}),$.addEventListener("mouseleave",()=>{if(this.#J)clearTimeout(this.#J),this.#J=null;this.#q?.classList.remove("show")},{signal:J})}if(this.#Q)Q.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip");else Q.removeAttribute("data-l10n-id"),Q.textContent=this.#$;if(!Q.parentNode)$.append(Q);this.#V.getElementForAltText()?.setAttribute("aria-describedby",Q.id)}}class mQ{#$=null;#Q=null;#Z=!1;#K=null;#q=null;#J=null;#_=null;#G=null;#V=!1;#U=null;constructor($){this.#K=$}renderForToolbar(){let $=this.#Q=document.createElement("button");return $.className="comment",this.#j($,!1)}renderForStandalone(){let $=this.#$=document.createElement("button");$.className="annotationCommentButton";let Q=this.#K.commentButtonPosition;if(Q){let{style:K}=$;K.insetInlineEnd=`calc(${100*(this.#K._uiManager.direction==="ltr"?1-Q[0]:Q[0])}% - var(--comment-button-dim))`,K.top=`calc(${100*Q[1]}% - var(--comment-button-dim))`;let Z=this.#K.commentButtonColor;if(Z)K.backgroundColor=Z}return this.#j($,!0)}focusButton(){setTimeout(()=>{(this.#$??this.#Q)?.focus()},0)}onUpdatedColor(){if(!this.#$)return;let $=this.#K.commentButtonColor;if($)this.#$.style.backgroundColor=$;this.#K._uiManager.updatePopupColor(this.#K)}get commentButtonWidth(){return(this.#$?.getBoundingClientRect().width??0)/this.#K.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#U)return this.#U;if(!this.#$)return null;let{x:$,y:Q,height:K}=this.#$.getBoundingClientRect(),{x:Z,y:J,width:_,height:q}=this.#K.parent.boundingClientRect;return[($-Z)/_,(Q+K-J)/q]}set commentPopupPositionInLayer($){this.#U=$}hasDefaultPopupPosition(){return this.#U===null}removeStandaloneCommentButton(){this.#$?.remove(),this.#$=null}removeToolbarCommentButton(){this.#Q?.remove(),this.#Q=null}setCommentButtonStates({selected:$,hasPopup:Q}){if(!this.#$)return;this.#$.classList.toggle("selected",$),this.#$.ariaExpanded=Q}#j($,Q){if(!this.#K._uiManager.hasCommentManager())return null;if($.tabIndex="0",$.ariaHasPopup="dialog",Q)$.ariaControls="commentPopup",$.setAttribute("data-l10n-id","pdfjs-show-comment-button");else $.ariaControlsElements=[this.#K._uiManager.getCommentDialogElement()],$.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button");let K=this.#K._uiManager._signal;if(!(K instanceof AbortSignal)||K.aborted)return $;if($.addEventListener("contextmenu",y$,{signal:K}),Q)$.addEventListener("focusin",(J)=>{this.#K._focusEventsAllowed=!1,N$(J)},{capture:!0,signal:K}),$.addEventListener("focusout",(J)=>{this.#K._focusEventsAllowed=!0,N$(J)},{capture:!0,signal:K});$.addEventListener("pointerdown",(J)=>J.stopPropagation(),{signal:K});let Z=(J)=>{if(J.preventDefault(),$===this.#Q)this.edit();else this.#K.toggleComment(!0)};return $.addEventListener("click",Z,{capture:!0,signal:K}),$.addEventListener("keydown",(J)=>{if(J.target===$&&J.key==="Enter")this.#Z=!0,Z(J)},{signal:K}),$.addEventListener("pointerenter",()=>{this.#K.toggleComment(!1,!0)},{signal:K}),$.addEventListener("pointerleave",()=>{this.#K.toggleComment(!1,!1)},{signal:K}),$}edit($){let Q=this.commentPopupPositionInLayer,K,Z;if(Q)[K,Z]=Q;else{[K,Z]=this.#K.commentButtonPosition;let{width:V,height:N,x:R,y:j}=this.#K;K=R+K*V,Z=j+Z*N}let J=this.#K.parent.boundingClientRect,{x:_,y:q,width:G,height:U}=J;this.#K._uiManager.editComment(this.#K,_+K*G,q+Z*U,{...$,parentDimensions:J})}finish(){if(!this.#Q)return;this.#Q.focus({focusVisible:this.#Z}),this.#Z=!1}isDeleted(){return this.#V||this.#_===""}isEmpty(){return this.#_===null}hasBeenEdited(){return this.isDeleted()||this.#_!==this.#q}serialize(){return this.data}get data(){return{text:this.#_,richText:this.#J,date:this.#G,deleted:this.isDeleted()}}set data($){if($!==this.#_)this.#J=null;if($===null){this.#_="",this.#V=!0;return}this.#_=$,this.#G=new Date,this.#V=!1}setInitialText($,Q=null){this.#q=$,this.data=$,this.#G=null,this.#J=Q}shown(){}destroy(){this.#Q?.remove(),this.#Q=null,this.#$?.remove(),this.#$=null,this.#_="",this.#J=null,this.#G=null,this.#K=null,this.#Z=!1,this.#V=!1}}class Z0{#$;#Q=!1;#Z=null;#K;#q;#J;#_;#G=null;#V;#U=null;#j;#R=null;constructor({container:$,isPinchingDisabled:Q=null,isPinchingStopped:K=null,onPinchStart:Z=null,onPinching:J=null,onPinchEnd:_=null,signal:q}){this.#$=$,this.#Z=K,this.#K=Q,this.#q=Z,this.#J=J,this.#_=_,this.#j=new AbortController,this.#V=AbortSignal.any([q,this.#j.signal]),$.addEventListener("touchstart",this.#B.bind(this),{passive:!1,signal:this.#V})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/d$.pixelRatio}#B($){if(this.#K?.())return;if($.touches.length===1){if(this.#G)return;let Z=this.#G=new AbortController,J=AbortSignal.any([this.#V,Z.signal]),_=this.#$,q={capture:!0,signal:J,passive:!1},G=(U)=>{if(U.pointerType==="touch")this.#G?.abort(),this.#G=null};_.addEventListener("pointerdown",(U)=>{if(U.pointerType==="touch")N$(U),G(U)},q),_.addEventListener("pointerup",G,q),_.addEventListener("pointercancel",G,q);return}if(!this.#R){this.#R=new AbortController;let Z=AbortSignal.any([this.#V,this.#R.signal]),J=this.#$,_={signal:Z,capture:!1,passive:!1};J.addEventListener("touchmove",this.#z.bind(this),_);let q=this.#F.bind(this);J.addEventListener("touchend",q,_),J.addEventListener("touchcancel",q,_),_.capture=!0,J.addEventListener("pointerdown",N$,_),J.addEventListener("pointermove",N$,_),J.addEventListener("pointercancel",N$,_),J.addEventListener("pointerup",N$,_),this.#q?.()}if(N$($),$.touches.length!==2||this.#Z?.()){this.#U=null;return}let[Q,K]=$.touches;if(Q.identifier>K.identifier)[Q,K]=[K,Q];this.#U={touch0X:Q.screenX,touch0Y:Q.screenY,touch1X:K.screenX,touch1Y:K.screenY}}#z($){if(!this.#U||$.touches.length!==2)return;N$($);let[Q,K]=$.touches;if(Q.identifier>K.identifier)[Q,K]=[K,Q];let{screenX:Z,screenY:J}=Q,{screenX:_,screenY:q}=K,G=this.#U,{touch0X:U,touch0Y:V,touch1X:N,touch1Y:R}=G,j=N-U,F=R-V,B=_-Z,A=q-J,z=Math.hypot(B,A)||1,O=Math.hypot(j,F)||1;if(!this.#Q&&Math.abs(O-z)<=Z0.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(G.touch0X=Z,G.touch0Y=J,G.touch1X=_,G.touch1Y=q,!this.#Q){this.#Q=!0;return}let S=[(Z+_)/2,(J+q)/2];this.#J?.(S,O,z)}#F($){if($.touches.length>=2)return;if(this.#R)this.#R.abort(),this.#R=null,this.#_?.();if(!this.#U)return;N$($),this.#U=null,this.#Q=!1}destroy(){this.#j?.abort(),this.#j=null,this.#G?.abort(),this.#G=null}}class m{#$=null;#Q=null;#Z=null;#K=null;#q=null;#J=!1;#_=null;#G="";#V=null;#U=null;#j=null;#R=null;#B=null;#z="";#F=!1;#N=null;#A=!1;#O=!1;#T=!1;#S=null;#W=0;#E=0;#I=null;#Y=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#k=!1;#M=m._zIndex++;static _borderLineWidth=-1;static _colorManager=new S6;static _zIndex=1;static _telemetryTimeout=1000;static get _resizerKeyboardManager(){let $=m.prototype._resizeWithKeyboard,Q=ZQ.TRANSLATE_SMALL,K=ZQ.TRANSLATE_BIG;return r(this,"_resizerKeyboardManager",new vQ([[["ArrowLeft","mac+ArrowLeft"],$,{args:[-Q,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],$,{args:[-K,0]}],[["ArrowRight","mac+ArrowRight"],$,{args:[Q,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],$,{args:[K,0]}],[["ArrowUp","mac+ArrowUp"],$,{args:[0,-Q]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],$,{args:[0,-K]}],[["ArrowDown","mac+ArrowDown"],$,{args:[0,Q]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],$,{args:[0,K]}],[["Escape","mac+Escape"],m.prototype._stopResizingWithKeyboard]]))}constructor($){this.parent=$.parent,this.id=$.id,this.width=this.height=null,this.pageIndex=$.parent.pageIndex,this.name=$.name,this.div=null,this._uiManager=$.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=$.isCentered,this._structTreeParentId=null,this.annotationElementId=$.annotationElementId||null,this.creationDate=$.creationDate||new Date,this.modificationDate=$.modificationDate||null;let{rotation:Q,rawDims:{pageWidth:K,pageHeight:Z,pageX:J,pageY:_}}=this.parent.viewport;this.rotation=Q,this.pageRotation=(360+Q-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[K,Z],this.pageTranslation=[J,_];let[q,G]=this.parentDimensions;this.x=$.x/q,this.y=$.y/G,this.isAttachedToDOM=!1,this.deleted=!1}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 r(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement($){let Q=new H7({id:$.parent.getNextId(),parent:$.parent,uiManager:$._uiManager});Q.annotationElementId=$.annotationElementId,Q.deleted=!0,Q._uiManager.addToAnnotationStorage(Q)}static initialize($,Q){if(m._l10n??=$,m._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"}),m._borderLineWidth!==-1)return;let K=getComputedStyle(document.documentElement);m._borderLineWidth=parseFloat(K.getPropertyValue("--outline-width"))||0}static updateDefaultParams($,Q){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting($){return!1}static paste($,Q){Z$("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#k}set _isDraggable($){this.#k=$,this.div?.classList.toggle("draggable",$)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[$,Q]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*Q/($*2),this.y+=this.width*$/(Q*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*Q/($*2),this.y-=this.width*$/(Q*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands($){this._uiManager.addCommands($)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#M}setParent($){if($!==null)this.pageIndex=$.pageIndex,this.pageDimensions=$.pageDimensions;else this.#y(),this.#R?.remove(),this.#R=null;this.parent=$}focusin($){if(!this._focusEventsAllowed)return;if(!this.#F)this.parent.setSelected(this);else this.#F=!1}focusout($){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;if($.relatedTarget?.closest(`#${this.id}`))return;if($.preventDefault(),!this.parent?.isMultipleSelection)this.commitOrRemove()}commitOrRemove(){if(this.isEmpty())this.remove();else this.commit()}commit(){if(!this.isInEditMode())return;this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt($,Q,K,Z){let[J,_]=this.parentDimensions;[K,Z]=this.screenToPageTranslation(K,Z),this.x=($+K)/J,this.y=(Q+Z)/_,this.fixAndSetPosition()}_moveAfterPaste($,Q){let[K,Z]=this.parentDimensions;this.setAt($*K,Q*Z,this.width*K,this.height*Z),this._onTranslated()}#H([$,Q],K,Z){[K,Z]=this.screenToPageTranslation(K,Z),this.x+=K/$,this.y+=Z/Q,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate($,Q){this.#H(this.parentDimensions,$,Q)}translateInPage($,Q){this.#N||=[this.x,this.y,this.width,this.height],this.#H(this.pageDimensions,$,Q),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag($,Q){this.#N||=[this.x,this.y,this.width,this.height];let{div:K,parentDimensions:[Z,J]}=this;if(this.x+=$/Z,this.y+=Q/J,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:N,y:R}=this.div.getBoundingClientRect();if(this.parent.findNewParent(this,N,R))this.x-=Math.floor(this.x),this.y-=Math.floor(this.y)}let{x:_,y:q}=this,[G,U]=this.getBaseTranslation();_+=G,q+=U;let{style:V}=K;V.left=`${(100*_).toFixed(2)}%`,V.top=`${(100*q).toFixed(2)}%`,this._onTranslating(_,q),K.scrollIntoView({block:"nearest"})}_onTranslating($,Q){}_onTranslated($,Q){}get _hasBeenMoved(){return!!this.#N&&(this.#N[0]!==this.x||this.#N[1]!==this.y)}get _hasBeenResized(){return!!this.#N&&(this.#N[2]!==this.width||this.#N[3]!==this.height)}getBaseTranslation(){let[$,Q]=this.parentDimensions,{_borderLineWidth:K}=m,Z=K/$,J=K/Q;switch(this.rotation){case 90:return[-Z,J];case 180:return[Z,J];case 270:return[Z,-J];default:return[-Z,-J]}}get _mustFixPosition(){return!0}fixAndSetPosition($=this.rotation){let{div:{style:Q},pageDimensions:[K,Z]}=this,{x:J,y:_,width:q,height:G}=this;if(q*=K,G*=Z,J*=K,_*=Z,this._mustFixPosition)switch($){case 0:J=X$(J,0,K-q),_=X$(_,0,Z-G);break;case 90:J=X$(J,0,K-G),_=X$(_,q,Z);break;case 180:J=X$(J,q,K),_=X$(_,G,Z);break;case 270:J=X$(J,G,K),_=X$(_,0,Z-q);break}this.x=J/=K,this.y=_/=Z;let[U,V]=this.getBaseTranslation();J+=U,_+=V,Q.left=`${(100*J).toFixed(2)}%`,Q.top=`${(100*_).toFixed(2)}%`,this.moveInDOM()}static#L($,Q,K){switch(K){case 90:return[Q,-$];case 180:return[-$,-Q];case 270:return[-Q,$];default:return[$,Q]}}screenToPageTranslation($,Q){return m.#L($,Q,this.parentRotation)}pageTranslationToScreen($,Q){return m.#L($,Q,360-this.parentRotation)}#P($){switch($){case 90:{let[Q,K]=this.pageDimensions;return[0,-Q/K,K/Q,0]}case 180:return[-1,0,0,-1];case 270:{let[Q,K]=this.pageDimensions;return[0,Q/K,-K/Q,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:$,pageDimensions:[Q,K]}=this;return[Q*$,K*$]}setDims(){let{div:{style:$},width:Q,height:K}=this;$.width=`${(100*Q).toFixed(2)}%`,$.height=`${(100*K).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#x(){if(this.#V)return;this.#V=document.createElement("div"),this.#V.classList.add("resizers");let $=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],Q=this._uiManager._signal;for(let K of $){let Z=document.createElement("div");this.#V.append(Z),Z.classList.add("resizer",K),Z.setAttribute("data-resizer-name",K),Z.addEventListener("pointerdown",this.#v.bind(this,K),{signal:Q}),Z.addEventListener("contextmenu",y$,{signal:Q}),Z.tabIndex=-1}this.div.prepend(this.#V)}#v($,Q){Q.preventDefault();let{isMac:K}=S$.platform;if(Q.button!==0||Q.ctrlKey&&K)return;this.#Z?.toggle(!1);let Z=this._isDraggable;this._isDraggable=!1,this.#U=[Q.screenX,Q.screenY];let J=new AbortController,_=this._uiManager.combinedSignal(J);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#b.bind(this,$),{passive:!0,capture:!0,signal:_}),window.addEventListener("touchmove",N$,{passive:!1,signal:_}),window.addEventListener("contextmenu",y$,{signal:_}),this.#j={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let q=this.parent.div.style.cursor,G=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(Q.target).cursor;let U=()=>{J.abort(),this.parent.togglePointerEvents(!0),this.#Z?.toggle(!0),this._isDraggable=Z,this.parent.div.style.cursor=q,this.div.style.cursor=G,this.#c()};window.addEventListener("pointerup",U,{signal:_}),window.addEventListener("blur",U,{signal:_})}#w($,Q,K,Z){this.width=K,this.height=Z,this.x=$,this.y=Q,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#c(){if(!this.#j)return;let{savedX:$,savedY:Q,savedWidth:K,savedHeight:Z}=this.#j;this.#j=null;let J=this.x,_=this.y,q=this.width,G=this.height;if(J===$&&_===Q&&q===K&&G===Z)return;this.addCommands({cmd:this.#w.bind(this,J,_,q,G),undo:this.#w.bind(this,$,Q,K,Z),mustExec:!0})}static _round($){return Math.round($*1e4)/1e4}#b($,Q){let[K,Z]=this.parentDimensions,J=this.x,_=this.y,q=this.width,G=this.height,U=m.MIN_SIZE/K,V=m.MIN_SIZE/Z,N=this.#P(this.rotation),R=(H,P)=>[N[0]*H+N[2]*P,N[1]*H+N[3]*P],j=this.#P(360-this.rotation),F=(H,P)=>[j[0]*H+j[2]*P,j[1]*H+j[3]*P],B,A,z=!1,O=!1;switch($){case"topLeft":z=!0,B=(H,P)=>[0,0],A=(H,P)=>[H,P];break;case"topMiddle":B=(H,P)=>[H/2,0],A=(H,P)=>[H/2,P];break;case"topRight":z=!0,B=(H,P)=>[H,0],A=(H,P)=>[0,P];break;case"middleRight":O=!0,B=(H,P)=>[H,P/2],A=(H,P)=>[0,P/2];break;case"bottomRight":z=!0,B=(H,P)=>[H,P],A=(H,P)=>[0,0];break;case"bottomMiddle":B=(H,P)=>[H/2,P],A=(H,P)=>[H/2,0];break;case"bottomLeft":z=!0,B=(H,P)=>[0,P],A=(H,P)=>[H,0];break;case"middleLeft":O=!0,B=(H,P)=>[0,P/2],A=(H,P)=>[H,P/2];break}let S=B(q,G),I=A(q,G),C=R(...I),T=m._round(J+C[0]),k=m._round(_+C[1]),E=1,M=1,W,X;if(!Q.fromKeyboard){let{screenX:H,screenY:P}=Q,[v,u]=this.#U;[W,X]=this.screenToPageTranslation(H-v,P-u),this.#U[0]=H,this.#U[1]=P}else({deltaX:W,deltaY:X}=Q);if([W,X]=F(W/K,X/Z),z){let H=Math.hypot(q,G);E=M=Math.max(Math.min(Math.hypot(I[0]-S[0]-W,I[1]-S[1]-X)/H,1/q,1/G),U/q,V/G)}else if(O)E=X$(Math.abs(I[0]-S[0]-W),U,1)/q;else M=X$(Math.abs(I[1]-S[1]-X),V,1)/G;let Y=m._round(q*E),y=m._round(G*M);C=R(...A(Y,y));let D=T-C[0],b=k-C[1];this.#N||=[this.x,this.y,this.width,this.height],this.width=Y,this.height=y,this.x=D,this.y=b,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#Z?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#O)return this._editToolbar;this._editToolbar=new hQ(this),this.div.append(this._editToolbar.render());let{toolbarButtons:$}=this;if($)for(let[Q,K]of $)await this._editToolbar.addButton(Q,K);if(!this.hasComment)this._editToolbar.addButton("comment",this.addCommentButton());return this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#Z?.destroy()}addContainer($){let Q=this._editToolbar?.div;if(Q)Q.before($);else this.div.append($)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){if(!this.#Z){if(r$.initialize(m._l10n),this.#Z=new r$(this),this.#$)this.#Z.data=this.#$,this.#$=null}return this.#Z}get altTextData(){return this.#Z?.data}set altTextData($){if(!this.#Z)return;this.#Z.data=$}get guessedAltText(){return this.#Z?.guessedText}async setGuessedAltText($){await this.#Z?.setGuessedText($)}serializeAltText($){return this.#Z?.serialize($)}hasAltText(){return!!this.#Z&&!this.#Z.isEmpty()}hasAltTextData(){return this.#Z?.hasData()??!1}focusCommentButton(){this.#K?.focusButton()}addCommentButton(){return this.#K||=new mQ(this)}addStandaloneCommentButton(){if(this.#q){if(this._uiManager.isEditingMode())this.#q.classList.remove("hidden");return}if(!this.hasComment)return;this.#q=this.#K.renderForStandalone(),this.div.append(this.#q)}removeStandaloneCommentButton(){this.#K.removeStandaloneCommentButton(),this.#q=null}hideStandaloneCommentButton(){this.#q?.classList.add("hidden")}get comment(){let{data:{richText:$,text:Q,date:K,deleted:Z}}=this.#K;return{text:Q,richText:$,date:K,deleted:Z,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment($){if(this.#K||=new mQ(this),this.#K.data=$,this.hasComment)this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this);else this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this)}setCommentData({comment:$,popupRef:Q,richText:K}){if(!Q)return;if(this.#K||=new mQ(this),this.#K.setInitialText($,K),!this.annotationElementId)return;let Z=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);if(Z)this.updateFromAnnotationLayer(Z)}get hasEditedComment(){return this.#K?.hasBeenEdited()}get hasDeletedComment(){return this.#K?.isDeleted()}get hasComment(){return!!this.#K&&!this.#K.isEmpty()&&!this.#K.isDeleted()}async editComment($){this.#K||=new mQ(this),this.#K.edit($)}toggleComment($,Q=void 0){if(this.hasComment)this._uiManager.toggleComment(this,$,Q)}setSelectedCommentButton($){this.#K.setSelectedButton($)}addComment($){if(this.hasEditedComment){let[,,,Z]=$.rect,[J]=this.pageDimensions,[_]=this.pageTranslation,q=_+J+1,G=Z-100,U=q+180;$.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[q,G,U,Z]}}}updateFromAnnotationLayer({popup:{contents:$,deleted:Q}}){this.#K.data=Q?null:$}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let $=this.div=document.createElement("div");if($.setAttribute("data-editor-rotation",(360-this.rotation)%360),$.className=this.name,$.setAttribute("id",this.id),$.tabIndex=this.#J?-1:0,$.setAttribute("role","application"),this.defaultL10nId)$.setAttribute("data-l10n-id",this.defaultL10nId);if(!this._isVisible)$.classList.add("hidden");this.setInForeground(),this.#h();let[Q,K]=this.parentDimensions;if(this.parentRotation%180!==0)$.style.maxWidth=`${(100*K/Q).toFixed(2)}%`,$.style.maxHeight=`${(100*Q/K).toFixed(2)}%`;let[Z,J]=this.getInitialTranslation();if(this.translate(Z,J),Y7(this,$,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom)this.#Y||=new Z0({container:$,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#d.bind(this),onPinching:this.#X.bind(this),onPinchEnd:this.#C.bind(this),signal:this._uiManager._signal});return this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),$}#d(){this.#j={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#Z?.toggle(!1),this.parent.togglePointerEvents(!1)}#X($,Q,K){let J=0.7*(K/Q)+1-0.7;if(J===1)return;let _=this.#P(this.rotation),q=(T,k)=>[_[0]*T+_[2]*k,_[1]*T+_[3]*k],[G,U]=this.parentDimensions,V=this.x,N=this.y,R=this.width,j=this.height,F=m.MIN_SIZE/G,B=m.MIN_SIZE/U;J=Math.max(Math.min(J,1/R,1/j),F/R,B/j);let A=m._round(R*J),z=m._round(j*J);if(A===R&&z===j)return;this.#N||=[V,N,R,j];let O=q(R/2,j/2),S=m._round(V+O[0]),I=m._round(N+O[1]),C=q(A/2,z/2);this.x=S-C[0],this.y=I-C[1],this.width=A,this.height=z,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#C(){this.#Z?.toggle(!0),this.parent.togglePointerEvents(!0),this.#c()}pointerdown($){let{isMac:Q}=S$.platform;if($.button!==0||$.ctrlKey&&Q){$.preventDefault();return}if(this.#F=!0,this._isDraggable){this.#u($);return}this.#f($)}#f($){let{isMac:Q}=S$.platform;if($.ctrlKey&&!Q||$.shiftKey||$.metaKey&&Q)this.parent.toggleSelected(this);else this.parent.setSelected(this)}#u($){let{isSelected:Q}=this;this._uiManager.setUpDragSession();let K=!1,Z=new AbortController,J=this._uiManager.combinedSignal(Z),_={capture:!0,passive:!1,signal:J},q=(U)=>{if(Z.abort(),this.#_=null,this.#F=!1,!this._uiManager.endDragSession())this.#f(U);if(K)this._onStopDragging()};if(Q)this.#W=$.clientX,this.#E=$.clientY,this.#_=$.pointerId,this.#G=$.pointerType,window.addEventListener("pointermove",(U)=>{if(!K)K=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging();let{clientX:V,clientY:N,pointerId:R}=U;if(R!==this.#_){N$(U);return}let[j,F]=this.screenToPageTranslation(V-this.#W,N-this.#E);this.#W=V,this.#E=N,this._uiManager.dragSelectedEditors(j,F)},_),window.addEventListener("touchmove",N$,_),window.addEventListener("pointerdown",(U)=>{if(U.pointerType===this.#G){if(this.#Y||U.isPrimary)q(U)}N$(U)},_);let G=(U)=>{if(!this.#_||this.#_===U.pointerId){q(U);return}N$(U)};window.addEventListener("pointerup",G,{signal:J}),window.addEventListener("blur",G,{signal:J})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){if(this.#S)clearTimeout(this.#S);this.#S=setTimeout(()=>{this.#S=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition($,Q,K){$.changeParent(this),this.x=Q,this.y=K,this.fixAndSetPosition(),this._onTranslated()}getRect($,Q,K=this.rotation){let Z=this.parentScale,[J,_]=this.pageDimensions,[q,G]=this.pageTranslation,U=$/Z,V=Q/Z,N=this.x*J,R=this.y*_,j=this.width*J,F=this.height*_;switch(K){case 0:return[N+U+q,_-R-V-F+G,N+U+j+q,_-R-V+G];case 90:return[N+V+q,_-R+U+G,N+V+F+q,_-R+U+j+G];case 180:return[N-U-j+q,_-R+V+G,N-U+q,_-R+V+F+G];case 270:return[N-V-F+q,_-R-U-j+G,N-V+q,_-R-U+G];default:throw Error("Invalid rotation")}}getRectInCurrentCoords($,Q){let[K,Z,J,_]=$,q=J-K,G=_-Z;switch(this.rotation){case 0:return[K,Q-_,q,G];case 90:return[K,Q-Z,G,q];case 180:return[J,Q-Z,q,G];case 270:return[J,Q-_,G,q];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&m._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#K?.onUpdatedColor()}getData(){let{comment:{text:$,color:Q,date:K,opacity:Z,deleted:J,richText:_},uid:q,pageIndex:G,creationDate:U,modificationDate:V}=this;return{id:q,pageIndex:G,rect:this.getPDFRect(),richText:_,contentsObj:{str:$},creationDate:U,modificationDate:K||V,popupRef:!J,color:Q,opacity:Z}}onceAdded($){}isEmpty(){return!1}enableEditMode(){if(this.isInEditMode())return!1;return this.parent.setEditingState(!1),this.#O=!0,!0}disableEditMode(){if(!this.isInEditMode())return!1;return this.parent.setEditingState(!0),this.#O=!1,!0}isInEditMode(){return this.#O}shouldGetKeyboardEvents(){return this.#T}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:$,left:Q,bottom:K,right:Z}=this.getClientDimensions(),{innerHeight:J,innerWidth:_}=window;return Q<_&&Z>0&&$<J&&K>0}#h(){if(this.#B||!this.div)return;this.#B=new AbortController;let $=this._uiManager.combinedSignal(this.#B);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:$}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:$})}rebuild(){this.#h()}rotate($){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize($=!1,Q=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize($,Q,K){let Z=new this.prototype.constructor({parent:Q,id:Q.getNextId(),uiManager:K,annotationElementId:$.annotationElementId,creationDate:$.creationDate,modificationDate:$.modificationDate});Z.rotation=$.rotation,Z.#$=$.accessibilityData,Z._isCopy=$.isCopy||!1;let[J,_]=Z.pageDimensions,[q,G,U,V]=Z.getRectInCurrentCoords($.rect,_);return Z.x=q/J,Z.y=G/_,Z.width=U/J,Z.height=V/_,Z}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#B?.abort(),this.#B=null,!this.isEmpty())this.commit();if(this.parent)this.parent.remove(this);else this._uiManager.removeEditor(this);if(this.#S)clearTimeout(this.#S),this.#S=null;if(this.#y(),this.removeEditToolbar(),this.#I){for(let $ of this.#I.values())clearTimeout($);this.#I=null}this.parent=null,this.#Y?.destroy(),this.#Y=null}get isResizable(){return!1}makeResizable(){if(this.isResizable)this.#x(),this.#V.classList.remove("hidden")}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[$,Q]}=this,[K,Z,J,_]=this.getPDFRect();return[m._round(K+(J-K)*$),m._round(Z+(_-Z)*(1-Q))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#K.commentPopupPositionInLayer}set commentPopupPosition($){this.#K.commentPopupPositionInLayer=$}hasDefaultPopupPosition(){return this.#K.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#K.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates($){this.#K.setCommentButtonStates($)}keydown($){if(!this.isResizable||$.target!==this.div||$.key!=="Enter")return;this._uiManager.setSelected(this),this.#j={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let Q=this.#V.children;if(!this.#Q){this.#Q=Array.from(Q);let _=this.#o.bind(this),q=this.#s.bind(this),G=this._uiManager._signal;for(let U of this.#Q){let V=U.getAttribute("data-resizer-name");U.setAttribute("role","spinbutton"),U.addEventListener("keydown",_,{signal:G}),U.addEventListener("blur",q,{signal:G}),U.addEventListener("focus",this.#r.bind(this,V),{signal:G}),U.setAttribute("data-l10n-id",m._l10nResizer[V])}}let K=this.#Q[0],Z=0;for(let _ of Q){if(_===K)break;Z++}let J=(360-this.rotation+this.parentRotation)%360/90*(this.#Q.length/4);if(J!==Z){if(J<Z)for(let q=0;q<Z-J;q++)this.#V.append(this.#V.firstChild);else if(J>Z)for(let q=0;q<J-Z;q++)this.#V.firstChild.before(this.#V.lastChild);let _=0;for(let q of Q){let U=this.#Q[_++].getAttribute("data-resizer-name");q.setAttribute("data-l10n-id",m._l10nResizer[U])}}this.#g(0),this.#T=!0,this.#V.firstChild.focus({focusVisible:!0}),$.preventDefault(),$.stopImmediatePropagation()}#o($){m._resizerKeyboardManager.exec(this,$)}#s($){if(this.#T&&$.relatedTarget?.parentNode!==this.#V)this.#y()}#r($){this.#z=this.#T?$:""}#g($){if(!this.#Q)return;for(let Q of this.#Q)Q.tabIndex=$}_resizeWithKeyboard($,Q){if(!this.#T)return;this.#b(this.#z,{deltaX:$,deltaY:Q,fromKeyboard:!0})}#y(){this.#T=!1,this.#g(-1),this.#c()}_stopResizingWithKeyboard(){this.#y(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{if(this.div?.classList.contains("selectedEditor"))this._editToolbar?.show()});return}this._editToolbar?.show(),this.#Z?.toggleAltTextBadge(!1)}focus(){if(this.div&&!this.div.contains(document.activeElement))setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){if(!this.isSelected)return;if(this.isSelected=!1,this.#V?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement))this._uiManager.currentLayer.div.focus({preventScroll:!0});if(this._editToolbar?.hide(),this.#Z?.toggleAltTextBadge(!0),this.hasComment)this._uiManager.toggleComment(this,!1,!1)}updateParams($,Q){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){if(!this.canChangeContent)return;this.enableEditMode(),this.div.focus()}dblclick($){if($.target.nodeName==="BUTTON")return;this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#A}set isEditing($){if(this.#A=$,!this.parent)return;if($)this.parent.setSelected(this),this.parent.setActiveEditor(this);else this.parent.setActiveEditor(null)}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry($,Q=!1){if(Q){this.#I||=new Map;let{action:K}=$,Z=this.#I.get(K);if(Z)clearTimeout(Z);Z=setTimeout(()=>{if(this._reportTelemetry($),this.#I.delete(K),this.#I.size===0)this.#I=null},m._telemetryTimeout),this.#I.set(K,Z);return}$.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:$}})}show($=this._isVisible){this.div.classList.toggle("hidden",!$),this._isVisible=$}enable(){if(this.div)this.div.tabIndex=0;this.#J=!1}disable(){if(this.div)this.div.tabIndex=-1;this.#J=!0}updateFakeAnnotationElement($){if(!this.#R&&!this.deleted){this.#R=$.addFakeAnnotation(this);return}if(this.deleted){this.#R.remove(),this.#R=null;return}if(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)this.#R.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement($){if(this.deleted)return $.hide(),null;let Q=$.container.querySelector(".annotationContent");if(!Q)Q=document.createElement("div"),Q.classList.add("annotationContent",this.editorType),$.container.prepend(Q);else if(Q.nodeName==="CANVAS"){let K=Q;Q=document.createElement("div"),Q.classList.add("annotationContent",this.editorType),K.before(Q)}return Q}resetAnnotationElement($){let{firstChild:Q}=$.container;if(Q?.nodeName==="DIV"&&Q.classList.contains("annotationContent"))Q.remove()}}class H7 extends m{constructor($){super($);this.annotationElementId=$.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}var t6=3285377520,c$=4294901760,s$=65535;class T6{constructor($){this.h1=$?$&4294967295:t6,this.h2=$?$&4294967295:t6}update($){let Q,K;if(typeof $==="string"){Q=new Uint8Array($.length*2),K=0;for(let B=0,A=$.length;B<A;B++){let z=$.charCodeAt(B);if(z<=255)Q[K++]=z;else Q[K++]=z>>>8,Q[K++]=z&255}}else if(ArrayBuffer.isView($))Q=$.slice(),K=Q.byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let Z=K>>2,J=K-Z*4,_=new Uint32Array(Q.buffer,0,Z),q=0,G=0,U=this.h1,V=this.h2,N=3432918353,R=461845907,j=N&s$,F=R&s$;for(let B=0;B<Z;B++)if(B&1)q=_[B],q=q*N&c$|q*j&s$,q=q<<15|q>>>17,q=q*R&c$|q*F&s$,U^=q,U=U<<13|U>>>19,U=U*5+3864292196;else G=_[B],G=G*N&c$|G*j&s$,G=G<<15|G>>>17,G=G*R&c$|G*F&s$,V^=G,V=V<<13|V>>>19,V=V*5+3864292196;switch(q=0,J){case 3:q^=Q[Z*4+2]<<16;case 2:q^=Q[Z*4+1]<<8;case 1:if(q^=Q[Z*4],q=q*N&c$|q*j&s$,q=q<<15|q>>>17,q=q*R&c$|q*F&s$,Z&1)U^=q;else V^=q}this.h1=U,this.h2=V}hexdigest(){let $=this.h1,Q=this.h2;return $^=Q>>>1,$=$*3981806797&c$|$*36045&s$,Q=Q*4283543511&c$|((Q<<16|$>>>16)*2950163797&c$)>>>16,$^=Q>>>1,$=$*444984403&c$|$*60499&s$,Q=Q*3301882366&c$|((Q<<16|$>>>16)*3120437893&c$)>>>16,$^=Q>>>1,($>>>0).toString(16).padStart(8,"0")+(Q>>>0).toString(16).padStart(8,"0")}}var e0=Object.freeze({map:null,hash:"",transfer:void 0});class v0{#$=!1;#Q=null;#Z=null;#K=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue($,Q){let K=this.#K.get($);if(K===void 0)return Q;return Object.assign(Q,K)}getRawValue($){return this.#K.get($)}remove($){let Q=this.#K.get($);if(Q===void 0)return;if(Q instanceof m)this.#Z.delete(Q.annotationElementId);if(this.#K.delete($),this.#K.size===0)this.resetModified();if(typeof this.onAnnotationEditor==="function"){for(let K of this.#K.values())if(K instanceof m)return;this.onAnnotationEditor(null)}}setValue($,Q){let K=this.#K.get($),Z=!1;if(K!==void 0){for(let[J,_]of Object.entries(Q))if(K[J]!==_)Z=!0,K[J]=_}else Z=!0,this.#K.set($,Q);if(Z)this.#q();if(Q instanceof m){if((this.#Z||=new Map).set(Q.annotationElementId,Q),typeof this.onAnnotationEditor==="function")this.onAnnotationEditor(Q.constructor._type)}}has($){return this.#K.has($)}get size(){return this.#K.size}#q(){if(!this.#$){if(this.#$=!0,typeof this.onSetModified==="function")this.onSetModified()}}resetModified(){if(this.#$){if(this.#$=!1,typeof this.onResetModified==="function")this.onResetModified()}}get print(){return new I6(this)}get serializable(){if(this.#K.size===0)return e0;let $=new Map,Q=new T6,K=[],Z=Object.create(null),J=!1;for(let[_,q]of this.#K){let G=q instanceof m?q.serialize(!1,Z):q;if(G)$.set(_,G),Q.update(`${_}:${JSON.stringify(G)}`),J||=!!G.bitmap}if(J){for(let _ of $.values())if(_.bitmap)K.push(_.bitmap)}return $.size>0?{map:$,hash:Q.hexdigest(),transfer:K}:e0}get editorStats(){let $=null,Q=new Map,K=0,Z=0;for(let J of this.#K.values()){if(!(J instanceof m)){if(J.popup)if(J.popup.deleted)Z+=1;else K+=1;continue}if(J.isCommentDeleted)Z+=1;else if(J.hasEditedComment)K+=1;let _=J.telemetryFinalData;if(!_)continue;let{type:q}=_;if(!Q.has(q))Q.set(q,Object.getPrototypeOf(J).constructor);$||=Object.create(null);let G=$[q]||=new Map;for(let[U,V]of Object.entries(_)){if(U==="type")continue;let N=G.get(U);if(!N)N=new Map,G.set(U,N);let R=N.get(V)??0;N.set(V,R+1)}}if(Z>0||K>0)$||=Object.create(null),$.comments={deleted:Z,edited:K};if(!$)return null;for(let[J,_]of Q)$[J]=_.computeTelemetryFinalData($[J]);return $}resetModifiedIds(){this.#Q=null}updateEditor($,Q){let K=this.#Z?.get($);if(K)return K.updateFromAnnotationLayer(Q),!0;return!1}getEditor($){return this.#Z?.get($)||null}get modifiedIds(){if(this.#Q)return this.#Q;let $=[];if(this.#Z)for(let Q of this.#Z.values()){if(!Q.serialize())continue;$.push(Q.annotationElementId)}return this.#Q={ids:new Set($),hash:$.join(",")}}[Symbol.iterator](){return this.#K.entries()}}class I6 extends v0{#$;constructor($){super();let{map:Q,hash:K,transfer:Z}=$.serializable,J=structuredClone(Q,Z?{transfer:Z}:null);this.#$={map:J,hash:K,transfer:Z}}get print(){Z$("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#$}get modifiedIds(){return r(this,"modifiedIds",{ids:new Set,hash:""})}}class D7{#$=new Set;constructor({ownerDocument:$=globalThis.document,styleElement:Q=null}){this._document=$,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace($){this.nativeFontFaces.add($),this._document.fonts.add($)}removeNativeFontFace($){this.nativeFontFaces.delete($),this._document.fonts.delete($)}insertRule($){if(!this.styleElement)this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement);let Q=this.styleElement.sheet;Q.insertRule($,Q.cssRules.length)}clear(){for(let $ of this.nativeFontFaces)this._document.fonts.delete($);if(this.nativeFontFaces.clear(),this.#$.clear(),this.styleElement)this.styleElement.remove(),this.styleElement=null}async loadSystemFont({systemFontInfo:$,disableFontFace:Q,_inspectFont:K}){if(!$||this.#$.has($.loadedName))return;if(i(!Q,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:Z,src:J,style:_}=$,q=new FontFace(Z,J,_);this.addNativeFontFace(q);try{await q.load(),this.#$.add(Z),K?.($)}catch{p(`Cannot load system font: ${$.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(q)}return}Z$("Not implemented: loadSystemFont without the Font Loading API.")}async bind($){if($.attached||$.missingFile&&!$.systemFontInfo)return;if($.attached=!0,$.systemFontInfo){await this.loadSystemFont($);return}if(this.isFontLoadingAPISupported){let K=$.createNativeFontFace();if(K){this.addNativeFontFace(K);try{await K.loaded}catch(Z){throw p(`Failed to load font '${K.family}': '${Z}'.`),$.disableFontFace=!0,Z}}return}let Q=$.createFontFaceRule();if(Q){if(this.insertRule(Q),this.isSyncFontLoadingSupported)return;await new Promise((K)=>{let Z=this._queueLoadingCallback(K);this._prepareFontLoadEvent($,Z)})}}get isFontLoadingAPISupported(){let $=!!this._document?.fonts;return r(this,"isFontLoadingAPISupported",$)}get isSyncFontLoadingSupported(){return r(this,"isSyncFontLoadingSupported",L$||S$.platform.isFirefox)}_queueLoadingCallback($){function Q(){i(!Z.done,"completeRequest() cannot be called twice."),Z.done=!0;while(K.length>0&&K[0].done){let J=K.shift();setTimeout(J.callback,0)}}let{loadingRequests:K}=this,Z={done:!1,complete:Q,callback:$};return K.push(Z),Z}get _loadTestFont(){let $=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return r(this,"_loadTestFont",$)}_prepareFontLoadEvent($,Q){function K(I,C){return I.charCodeAt(C)<<24|I.charCodeAt(C+1)<<16|I.charCodeAt(C+2)<<8|I.charCodeAt(C+3)&255}function Z(I,C,T,k){let E=I.substring(0,C),M=I.substring(C+T);return E+k+M}let J,_,q=this._document.createElement("canvas");q.width=1,q.height=1;let G=q.getContext("2d"),U=0;function V(I,C){if(++U>30){p("Load test font never loaded."),C();return}if(G.font="30px "+I,G.fillText(".",0,20),G.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(V.bind(null,I,C))}let N=`lt${Date.now()}${this.loadTestFontId++}`,R=this._loadTestFont;R=Z(R,976,N.length,N);let F=16,B=1482184792,A=K(R,F);for(J=0,_=N.length-3;J<_;J+=4)A=A-B+K(N,J)|0;if(J<N.length)A=A-B+K(N+"XXX",J)|0;R=Z(R,F,4,VK(A));let z=`url(data:font/opentype;base64,${btoa(R)});`,O=`@font-face {font-family:"${N}";src:${z}}`;this.insertRule(O);let S=this._document.createElement("div");S.style.visibility="hidden",S.style.width=S.style.height="10px",S.style.position="absolute",S.style.top=S.style.left="0px";for(let I of[$.loadedName,N]){let C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=I,S.append(C)}this._document.body.append(S),V(N,()=>{S.remove(),Q.complete()})}}class v7{#$;constructor($,Q=null,K,Z){if(this.compiledGlyphs=Object.create(null),this.#$=$,this._inspectFont=Q,K)Object.assign(this,K);if(Z)this.charProcOperatorList=Z}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let $;if(!this.cssFontInfo)$=new FontFace(this.loadedName,this.data,{});else{let Q={weight:this.cssFontInfo.fontWeight};if(this.cssFontInfo.italicAngle)Q.style=`oblique ${this.cssFontInfo.italicAngle}deg`;$=new FontFace(this.cssFontInfo.fontFamily,this.data,Q)}return this._inspectFont?.(this),$}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;let $=`url(data:${this.mimetype};base64,${T7(this.data)});`,Q;if(!this.cssFontInfo)Q=`@font-face {font-family:"${this.loadedName}";src:${$}}`;else{let K=`font-weight: ${this.cssFontInfo.fontWeight};`;if(this.cssFontInfo.italicAngle)K+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`;Q=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${K}src:${$}}`}return this._inspectFont?.(this,$),Q}getPathGenerator($,Q){if(this.compiledGlyphs[Q]!==void 0)return this.compiledGlyphs[Q];let K=this.loadedName+"_path_"+Q,Z;try{Z=$.get(K)}catch(_){p(`getPathGenerator - ignoring character: "${_}".`)}let J=new Path2D(Z||"");if(!this.fontExtraProperties)$.delete(K);return this.compiledGlyphs[Q]=J}get black(){return this.#$.black}get bold(){return this.#$.bold}get disableFontFace(){return this.#$.disableFontFace??!1}get fontExtraProperties(){return this.#$.fontExtraProperties??!1}get isInvalidPDFjsFont(){return this.#$.isInvalidPDFjsFont}get isType3Font(){return this.#$.isType3Font}get italic(){return this.#$.italic}get missingFile(){return this.#$.missingFile}get remeasure(){return this.#$.remeasure}get vertical(){return this.#$.vertical}get ascent(){return this.#$.ascent}get defaultWidth(){return this.#$.defaultWidth}get descent(){return this.#$.descent}get bbox(){return this.#$.bbox}get fontMatrix(){return this.#$.fontMatrix}get fallbackName(){return this.#$.fallbackName}get loadedName(){return this.#$.loadedName}get mimetype(){return this.#$.mimetype}get name(){return this.#$.name}get data(){return this.#$.data}clearData(){this.#$.clearData()}get cssFontInfo(){return this.#$.cssFontInfo}get systemFontInfo(){return this.#$.systemFontInfo}get defaultVMetrics(){return this.#$.defaultVMetrics}}function OK($){if($ instanceof URL)return $.href;if(typeof $==="string"){if(L$)return $;let Q=URL.parse($,window.location);if(Q)return Q.href}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function SK($){if(L$&&typeof Buffer<"u"&&$ instanceof Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if($ instanceof Uint8Array&&$.byteLength===$.buffer.byteLength)return $;if(typeof $==="string")return eQ($);if($ instanceof ArrayBuffer||ArrayBuffer.isView($)||typeof $==="object"&&!isNaN($?.length))return new Uint8Array($);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function V0($){if(typeof $!=="string")return null;if($.endsWith("/"))return $;throw Error(`Invalid factory url: "${$}" must include trailing slash.`)}var $6=($)=>typeof $==="object"&&Number.isInteger($?.num)&&$.num>=0&&Number.isInteger($?.gen)&&$.gen>=0,TK=($)=>typeof $==="object"&&typeof $?.name==="string",f7=BK.bind(null,$6,TK);class w7{#$=new Map;#Q=Promise.resolve();postMessage($,Q){let K={data:structuredClone($,Q?{transfer:Q}:null)};this.#Q.then(()=>{for(let[Z]of this.#$)Z.call(this,K)})}addEventListener($,Q,K=null){let Z=null;if(K?.signal instanceof AbortSignal){let{signal:J}=K;if(J.aborted){p("LoopbackPort - cannot use an `aborted` signal.");return}let _=()=>this.removeEventListener($,Q);Z=()=>J.removeEventListener("abort",_),J.addEventListener("abort",_)}this.#$.set(Q,Z)}removeEventListener($,Q){this.#$.get(Q)?.(),this.#$.delete(Q)}terminate(){for(let[,$]of this.#$)$?.();this.#$.clear()}}var N0={DATA:1,ERROR:2},A$={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function e6(){}function H$($){if($ instanceof KQ||$ instanceof S0||$ instanceof s6||$ instanceof dQ||$ instanceof g0)return $;if(!($ instanceof Error||typeof $==="object"&&$!==null))Z$('wrapReason: Expected "reason" to be a (possibly cloned) Error.');switch($.name){case"AbortException":return new KQ($.message);case"InvalidPDFException":return new S0($.message);case"PasswordException":return new s6($.message,$.code);case"ResponseException":return new dQ($.message,$.status,$.missing);case"UnknownErrorException":return new g0($.message,$.details)}return new g0($.message,$.toString())}class LQ{#$=new AbortController;constructor($,Q,K){this.sourceName=$,this.targetName=Q,this.comObj=K,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),K.addEventListener("message",this.#Q.bind(this),{signal:this.#$.signal})}#Q({data:$}){if($.targetName!==this.sourceName)return;if($.stream){this.#K($);return}if($.callback){let K=$.callbackId,Z=this.callbackCapabilities[K];if(!Z)throw Error(`Cannot resolve callback ${K}`);if(delete this.callbackCapabilities[K],$.callback===N0.DATA)Z.resolve($.data);else if($.callback===N0.ERROR)Z.reject(H$($.reason));else throw Error("Unexpected callback case");return}let Q=this.actionHandler[$.action];if(!Q)throw Error(`Unknown action from worker: ${$.action}`);if($.callbackId){let K=this.sourceName,Z=$.sourceName,J=this.comObj;Promise.try(Q,$.data).then(function(_){J.postMessage({sourceName:K,targetName:Z,callback:N0.DATA,callbackId:$.callbackId,data:_})},function(_){J.postMessage({sourceName:K,targetName:Z,callback:N0.ERROR,callbackId:$.callbackId,reason:H$(_)})});return}if($.streamId){this.#Z($);return}Q($.data)}on($,Q){let K=this.actionHandler;if(K[$])throw Error(`There is already an actionName called "${$}"`);K[$]=Q}send($,Q,K){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:$,data:Q},K)}sendWithPromise($,Q,K){let Z=this.callbackId++,J=Promise.withResolvers();this.callbackCapabilities[Z]=J;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:$,callbackId:Z,data:Q},K)}catch(_){J.reject(_)}return J.promise}sendWithStream($,Q,K,Z){let J=this.streamId++,_=this.sourceName,q=this.targetName,G=this.comObj;return new ReadableStream({start:(U)=>{let V=Promise.withResolvers();return this.streamControllers[J]={controller:U,startCall:V,pullCall:null,cancelCall:null,isClosed:!1},G.postMessage({sourceName:_,targetName:q,action:$,streamId:J,data:Q,desiredSize:U.desiredSize},Z),V.promise},pull:(U)=>{let V=Promise.withResolvers();return this.streamControllers[J].pullCall=V,G.postMessage({sourceName:_,targetName:q,stream:A$.PULL,streamId:J,desiredSize:U.desiredSize}),V.promise},cancel:(U)=>{i(U instanceof Error,"cancel must have a valid reason");let V=Promise.withResolvers();return this.streamControllers[J].cancelCall=V,this.streamControllers[J].isClosed=!0,G.postMessage({sourceName:_,targetName:q,stream:A$.CANCEL,streamId:J,reason:H$(U)}),V.promise}},K)}#Z($){let Q=$.streamId,K=this.sourceName,Z=$.sourceName,J=this.comObj,_=this,q=this.actionHandler[$.action],G={enqueue(U,V=1,N){if(this.isCancelled)return;let R=this.desiredSize;if(this.desiredSize-=V,R>0&&this.desiredSize<=0)this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise;J.postMessage({sourceName:K,targetName:Z,stream:A$.ENQUEUE,streamId:Q,chunk:U},N)},close(){if(this.isCancelled)return;this.isCancelled=!0,J.postMessage({sourceName:K,targetName:Z,stream:A$.CLOSE,streamId:Q}),delete _.streamSinks[Q]},error(U){if(i(U instanceof Error,"error must have a valid reason"),this.isCancelled)return;this.isCancelled=!0,J.postMessage({sourceName:K,targetName:Z,stream:A$.ERROR,streamId:Q,reason:H$(U)})},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:$.desiredSize,ready:null};G.sinkCapability.resolve(),G.ready=G.sinkCapability.promise,this.streamSinks[Q]=G,Promise.try(q,$.data,G).then(function(){J.postMessage({sourceName:K,targetName:Z,stream:A$.START_COMPLETE,streamId:Q,success:!0})},function(U){J.postMessage({sourceName:K,targetName:Z,stream:A$.START_COMPLETE,streamId:Q,reason:H$(U)})})}#K($){let Q=$.streamId,K=this.sourceName,Z=$.sourceName,J=this.comObj,_=this.streamControllers[Q],q=this.streamSinks[Q];switch($.stream){case A$.START_COMPLETE:if($.success)_.startCall.resolve();else _.startCall.reject(H$($.reason));break;case A$.PULL_COMPLETE:if($.success)_.pullCall.resolve();else _.pullCall.reject(H$($.reason));break;case A$.PULL:if(!q){J.postMessage({sourceName:K,targetName:Z,stream:A$.PULL_COMPLETE,streamId:Q,success:!0});break}if(q.desiredSize<=0&&$.desiredSize>0)q.sinkCapability.resolve();q.desiredSize=$.desiredSize,Promise.try(q.onPull||e6).then(function(){J.postMessage({sourceName:K,targetName:Z,stream:A$.PULL_COMPLETE,streamId:Q,success:!0})},function(U){J.postMessage({sourceName:K,targetName:Z,stream:A$.PULL_COMPLETE,streamId:Q,reason:H$(U)})});break;case A$.ENQUEUE:if(i(_,"enqueue should have stream controller"),_.isClosed)break;_.controller.enqueue($.chunk);break;case A$.CLOSE:if(i(_,"close should have stream controller"),_.isClosed)break;_.isClosed=!0,_.controller.close(),this.#q(_,Q);break;case A$.ERROR:i(_,"error should have stream controller"),_.controller.error(H$($.reason)),this.#q(_,Q);break;case A$.CANCEL_COMPLETE:if($.success)_.cancelCall.resolve();else _.cancelCall.reject(H$($.reason));this.#q(_,Q);break;case A$.CANCEL:if(!q)break;let G=H$($.reason);Promise.try(q.onCancel||e6,G).then(function(){J.postMessage({sourceName:K,targetName:Z,stream:A$.CANCEL_COMPLETE,streamId:Q,success:!0})},function(U){J.postMessage({sourceName:K,targetName:Z,stream:A$.CANCEL_COMPLETE,streamId:Q,reason:H$(U)})}),q.sinkCapability.reject(G),q.isCancelled=!0,delete this.streamSinks[Q];break;default:throw Error("Unexpected stream case")}}async#q($,Q){await Promise.allSettled([$.startCall?.promise,$.pullCall?.promise,$.cancelCall?.promise]),delete this.streamControllers[Q]}destroy(){this.#$?.abort(),this.#$=null}}class C6{#$=!1;constructor({enableHWA:$=!1}){this.#$=$}create($,Q){if($<=0||Q<=0)throw Error("Invalid canvas size");let K=this._createCanvas($,Q);return{canvas:K,context:K.getContext("2d",{willReadFrequently:!this.#$})}}reset($,Q,K){if(!$.canvas)throw Error("Canvas is not specified");if(Q<=0||K<=0)throw Error("Invalid canvas size");$.canvas.width=Q,$.canvas.height=K}destroy($){if(!$.canvas)throw Error("Canvas is not specified");$.canvas.width=0,$.canvas.height=0,$.canvas=null,$.context=null}_createCanvas($,Q){Z$("Abstract method `_createCanvas` called.")}}class b7 extends C6{constructor({ownerDocument:$=globalThis.document,enableHWA:Q=!1}){super({enableHWA:Q});this._document=$}_createCanvas($,Q){let K=this._document.createElement("canvas");return K.width=$,K.height=Q,K}}class k6{constructor({baseUrl:$=null,isCompressed:Q=!0}){this.baseUrl=$,this.isCompressed=Q}async fetch({name:$}){if(!this.baseUrl)throw Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!$)throw Error("CMap name must be specified.");let Q=this.baseUrl+$+(this.isCompressed?".bcmap":"");return this._fetch(Q).then((K)=>({cMapData:K,isCompressed:this.isCompressed})).catch((K)=>{throw Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${Q}`)})}async _fetch($){Z$("Abstract method `_fetch` called.")}}class Q6 extends k6{async _fetch($){let Q=await HQ($,this.isCompressed?"arraybuffer":"text");return Q instanceof ArrayBuffer?new Uint8Array(Q):eQ(Q)}}s(2489);class E6{addFilter($){return"none"}addHCMFilter($,Q){return"none"}addAlphaFilter($){return"none"}addLuminosityFilter($){return"none"}addHighlightHCMFilter($,Q,K,Z,J){return"none"}destroy($=!1){}}class y7 extends E6{#$;#Q;#Z;#K;#q;#J;#_=0;constructor({docId:$,ownerDocument:Q=globalThis.document}){super();this.#K=$,this.#q=Q}get#G(){return this.#Q||=new Map}get#V(){return this.#J||=new Map}get#U(){if(!this.#Z){let $=this.#q.createElement("div"),{style:Q}=$;Q.visibility="hidden",Q.contain="strict",Q.width=Q.height=0,Q.position="absolute",Q.top=Q.left=0,Q.zIndex=-1;let K=this.#q.createElementNS(i$,"svg");K.setAttribute("width",0),K.setAttribute("height",0),this.#Z=this.#q.createElementNS(i$,"defs"),$.append(K),K.append(this.#Z),this.#q.body.append($)}return this.#Z}#j($){if($.length===1){let G=$[0],U=Array(256);for(let N=0;N<256;N++)U[N]=G[N]/255;let V=U.join(",");return[V,V,V]}let[Q,K,Z]=$,J=Array(256),_=Array(256),q=Array(256);for(let G=0;G<256;G++)J[G]=Q[G]/255,_[G]=K[G]/255,q[G]=Z[G]/255;return[J.join(","),_.join(","),q.join(",")]}#R($){if(this.#$===void 0){this.#$="";let Q=this.#q.URL;if(Q!==this.#q.baseURI)if(K0(Q))p('#createUrl: ignore "data:"-URL for performance reasons.');else this.#$=j6(Q,"")}return`url(${this.#$}#${$})`}addFilter($){if(!$)return"none";let Q=this.#G.get($);if(Q)return Q;let[K,Z,J]=this.#j($),_=$.length===1?K:`${K}${Z}${J}`;if(Q=this.#G.get(_),Q)return this.#G.set($,Q),Q;let q=`g_${this.#K}_transfer_map_${this.#_++}`,G=this.#R(q);this.#G.set($,G),this.#G.set(_,G);let U=this.#F(q);return this.#A(K,Z,J,U),G}addHCMFilter($,Q){let K=`${$}-${Q}`,Z="base",J=this.#V.get("base");if(J?.key===K)return J.url;if(J)J.filter?.remove(),J.key=K,J.url="none",J.filter=null;else J={key:K,url:"none",filter:null},this.#V.set("base",J);if(!$||!Q)return J.url;let _=this.#T($);$=x.makeHexColor(..._);let q=this.#T(Q);if(Q=x.makeHexColor(...q),this.#U.style.color="",$==="#000000"&&Q==="#ffffff"||$===Q)return J.url;let G=Array(256);for(let j=0;j<=255;j++){let F=j/255;G[j]=F<=0.03928?F/12.92:((F+0.055)/1.055)**2.4}let U=G.join(","),V=`g_${this.#K}_hcm_filter`,N=J.filter=this.#F(V);this.#A(U,U,U,N),this.#z(N);let R=(j,F)=>{let B=_[j]/255,A=q[j]/255,z=Array(F+1);for(let O=0;O<=F;O++)z[O]=B+O/F*(A-B);return z.join(",")};return this.#A(R(0,5),R(1,5),R(2,5),N),J.url=this.#R(V),J.url}addAlphaFilter($){let Q=this.#G.get($);if(Q)return Q;let[K]=this.#j([$]),Z=`alpha_${K}`;if(Q=this.#G.get(Z),Q)return this.#G.set($,Q),Q;let J=`g_${this.#K}_alpha_map_${this.#_++}`,_=this.#R(J);this.#G.set($,_),this.#G.set(Z,_);let q=this.#F(J);return this.#O(K,q),_}addLuminosityFilter($){let Q=this.#G.get($||"luminosity");if(Q)return Q;let K,Z;if($)[K]=this.#j([$]),Z=`luminosity_${K}`;else Z="luminosity";if(Q=this.#G.get(Z),Q)return this.#G.set($,Q),Q;let J=`g_${this.#K}_luminosity_map_${this.#_++}`,_=this.#R(J);this.#G.set($,_),this.#G.set(Z,_);let q=this.#F(J);if(this.#B(q),$)this.#O(K,q);return _}addHighlightHCMFilter($,Q,K,Z,J){let _=`${Q}-${K}-${Z}-${J}`,q=this.#V.get($);if(q?.key===_)return q.url;if(q)q.filter?.remove(),q.key=_,q.url="none",q.filter=null;else q={key:_,url:"none",filter:null},this.#V.set($,q);if(!Q||!K)return q.url;let[G,U]=[Q,K].map(this.#T.bind(this)),V=Math.round(0.2126*G[0]+0.7152*G[1]+0.0722*G[2]),N=Math.round(0.2126*U[0]+0.7152*U[1]+0.0722*U[2]),[R,j]=[Z,J].map(this.#T.bind(this));if(N<V)[V,N,R,j]=[N,V,j,R];this.#U.style.color="";let F=(z,O,S)=>{let I=Array(256),C=(N-V)/S,T=z/255,k=(O-z)/(255*S),E=0;for(let M=0;M<=S;M++){let W=Math.round(V+M*C),X=T+M*k;for(let Y=E;Y<=W;Y++)I[Y]=X;E=W+1}for(let M=E;M<256;M++)I[M]=I[E-1];return I.join(",")},B=`g_${this.#K}_hcm_${$}_filter`,A=q.filter=this.#F(B);return this.#z(A),this.#A(F(R[0],j[0],5),F(R[1],j[1],5),F(R[2],j[2],5),A),q.url=this.#R(B),q.url}destroy($=!1){if($&&this.#J?.size)return;this.#Z?.parentNode.parentNode.remove(),this.#Z=null,this.#Q?.clear(),this.#Q=null,this.#J?.clear(),this.#J=null,this.#_=0}#B($){let Q=this.#q.createElementNS(i$,"feColorMatrix");Q.setAttribute("type","matrix"),Q.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"),$.append(Q)}#z($){let Q=this.#q.createElementNS(i$,"feColorMatrix");Q.setAttribute("type","matrix"),Q.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"),$.append(Q)}#F($){let Q=this.#q.createElementNS(i$,"filter");return Q.setAttribute("color-interpolation-filters","sRGB"),Q.setAttribute("id",$),this.#U.append(Q),Q}#N($,Q,K){let Z=this.#q.createElementNS(i$,Q);Z.setAttribute("type","discrete"),Z.setAttribute("tableValues",K),$.append(Z)}#A($,Q,K,Z){let J=this.#q.createElementNS(i$,"feComponentTransfer");Z.append(J),this.#N(J,"feFuncR",$),this.#N(J,"feFuncG",Q),this.#N(J,"feFuncB",K)}#O($,Q){let K=this.#q.createElementNS(i$,"feComponentTransfer");Q.append(K),this.#N(K,"feFuncA",$)}#T($){return this.#U.style.color=$,DQ(getComputedStyle(this.#U).getPropertyValue("color"))}}class M6{constructor({baseUrl:$=null}){this.baseUrl=$}async fetch({filename:$}){if(!this.baseUrl)throw Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!$)throw Error("Font filename must be specified.");let Q=`${this.baseUrl}${$}`;return this._fetch(Q).catch((K)=>{throw Error(`Unable to load font data at: ${Q}`)})}async _fetch($){Z$("Abstract method `_fetch` called.")}}class K6 extends M6{async _fetch($){let Q=await HQ($,"arraybuffer");return new Uint8Array(Q)}}class W6{constructor({baseUrl:$=null}){this.baseUrl=$}async fetch({filename:$}){if(!this.baseUrl)throw Error("Ensure that the `wasmUrl` API parameter is provided.");if(!$)throw Error("Wasm filename must be specified.");let Q=`${this.baseUrl}${$}`;return this._fetch(Q).catch((K)=>{throw Error(`Unable to load wasm data at: ${Q}`)})}async _fetch($){Z$("Abstract method `_fetch` called.")}}class Z6 extends W6{async _fetch($){let Q=await HQ($,"arraybuffer");return new Uint8Array(Q)}}if(L$){let $;try{let Q=process.getBuiltinModule("module").createRequire(import.meta.url);try{$=Q("@napi-rs/canvas")}catch(K){p(`Cannot load "@napi-rs/canvas" package: "${K}".`)}}catch(Q){p(`Cannot access the \`require\` function: "${Q}".`)}if(!globalThis.DOMMatrix)if($?.DOMMatrix)globalThis.DOMMatrix=$.DOMMatrix;else p("Cannot polyfill `DOMMatrix`, rendering may be broken.");if(!globalThis.ImageData)if($?.ImageData)globalThis.ImageData=$.ImageData;else p("Cannot polyfill `ImageData`, rendering may be broken.");if(!globalThis.Path2D)if($?.Path2D)globalThis.Path2D=$.Path2D;else p("Cannot polyfill `Path2D`, rendering may be broken.");if(!globalThis.navigator?.language)globalThis.navigator={language:"en-US",platform:"",userAgent:""}}async function X6($){let K=await process.getBuiltinModule("fs").promises.readFile($);return new Uint8Array(K)}class x7 extends E6{}class c7 extends C6{_createCanvas($,Q){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas($,Q)}}class u7 extends k6{async _fetch($){return X6($)}}class m7 extends M6{async _fetch($){return X6($)}}class h7 extends W6{async _fetch($){return X6($)}}s(7588);var OQ="__forcedDependency",{floor:$7,ceil:Q7}=Math;function R0($,Q,K,Z,J,_){$[Q*4+0]=Math.min($[Q*4+0],K),$[Q*4+1]=Math.min($[Q*4+1],Z),$[Q*4+2]=Math.max($[Q*4+2],J),$[Q*4+3]=Math.max($[Q*4+3],_)}var J6=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class g7{#$;#Q;constructor($,Q){this.#$=$,this.#Q=Q}get length(){return this.#$.length}isEmpty($){return this.#$[$]===J6}minX($){return this.#Q[$*4+0]/256}minY($){return this.#Q[$*4+1]/256}maxX($){return(this.#Q[$*4+2]+1)/256}maxY($){return(this.#Q[$*4+3]+1)/256}}var j0=($,Q)=>{if(!$)return;let K=$.get(Q);if(!K)K={dependencies:new Set,isRenderingOperation:!1},$.set(Q,K);return K};class p7{#$={__proto__:null};#Q={__proto__:null,transform:[],moveText:[],sameLineText:[],[OQ]:[]};#Z=new Map;#K=[];#q=[];#J=[[1,0,0,1,0,0]];#_=[-1/0,-1/0,1/0,1/0];#G=new Float64Array([1/0,1/0,-1/0,-1/0]);#V=-1;#U=new Set;#j=new Map;#R=new Map;#B;#z;#F;#N;#A;constructor($,Q,K=!1){if(this.#B=$.width,this.#z=$.height,this.#O(Q),K)this.#A=new Map}growOperationsCount($){if($>=this.#N.length)this.#O($,this.#N)}#O($,Q){let K=new ArrayBuffer($*4);if(this.#F=new Uint8ClampedArray(K),this.#N=new Uint32Array(K),Q&&Q.length>0)this.#N.set(Q),this.#N.fill(J6,Q.length);else this.#N.fill(J6)}save($){return this.#$={__proto__:this.#$},this.#Q={__proto__:this.#Q,transform:{__proto__:this.#Q.transform},moveText:{__proto__:this.#Q.moveText},sameLineText:{__proto__:this.#Q.sameLineText},[OQ]:{__proto__:this.#Q[OQ]}},this.#_={__proto__:this.#_},this.#K.push($),this}restore($){let Q=Object.getPrototypeOf(this.#$);if(Q===null)return this;this.#$=Q,this.#Q=Object.getPrototypeOf(this.#Q),this.#_=Object.getPrototypeOf(this.#_);let K=this.#K.pop();if(K!==void 0)j0(this.#A,$)?.dependencies.add(K),this.#N[$]=this.#N[K];return this}recordOpenMarker($){return this.#K.push($),this}getOpenMarker(){if(this.#K.length===0)return null;return this.#K.at(-1)}recordCloseMarker($){let Q=this.#K.pop();if(Q!==void 0)j0(this.#A,$)?.dependencies.add(Q),this.#N[$]=this.#N[Q];return this}beginMarkedContent($){return this.#q.push($),this}endMarkedContent($){let Q=this.#q.pop();if(Q!==void 0)j0(this.#A,$)?.dependencies.add(Q),this.#N[$]=this.#N[Q];return this}pushBaseTransform($){return this.#J.push(x.multiplyByDOMMatrix(this.#J.at(-1),$.getTransform())),this}popBaseTransform(){if(this.#J.length>1)this.#J.pop();return this}recordSimpleData($,Q){return this.#$[$]=Q,this}recordIncrementalData($,Q){return this.#Q[$].push(Q),this}resetIncrementalData($,Q){return this.#Q[$].length=0,this}recordNamedData($,Q){return this.#Z.set($,Q),this}recordSimpleDataFromNamed($,Q,K){this.#$[$]=this.#Z.get(Q)??K}recordFutureForcedDependency($,Q){return this.recordIncrementalData(OQ,Q),this}inheritSimpleDataAsFutureForcedDependencies($){for(let Q of $)if(Q in this.#$)this.recordFutureForcedDependency(Q,this.#$[Q]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let $ of this.#U)this.recordFutureForcedDependency(OQ,$);return this}resetBBox($){if(this.#V!==$)this.#V=$,this.#G[0]=1/0,this.#G[1]=1/0,this.#G[2]=-1/0,this.#G[3]=-1/0;return this}recordClipBox($,Q,K,Z,J,_){let q=x.multiplyByDOMMatrix(this.#J.at(-1),Q.getTransform()),G=[1/0,1/0,-1/0,-1/0];x.axialAlignedBoundingBox([K,J,Z,_],q,G);let U=x.intersect(this.#_,G);if(U)this.#_[0]=U[0],this.#_[1]=U[1],this.#_[2]=U[2],this.#_[3]=U[3];else this.#_[0]=this.#_[1]=1/0,this.#_[2]=this.#_[3]=-1/0;return this}recordBBox($,Q,K,Z,J,_){let q=this.#_;if(q[0]===1/0)return this;let G=x.multiplyByDOMMatrix(this.#J.at(-1),Q.getTransform());if(q[0]===-1/0)return x.axialAlignedBoundingBox([K,J,Z,_],G,this.#G),this;let U=[1/0,1/0,-1/0,-1/0];return x.axialAlignedBoundingBox([K,J,Z,_],G,U),this.#G[0]=Math.min(this.#G[0],Math.max(U[0],q[0])),this.#G[1]=Math.min(this.#G[1],Math.max(U[1],q[1])),this.#G[2]=Math.max(this.#G[2],Math.min(U[2],q[2])),this.#G[3]=Math.max(this.#G[3],Math.min(U[3],q[3])),this}recordCharacterBBox($,Q,K,Z=1,J=0,_=0,q){let G=K.bbox,U,V;if(G){if(U=G[2]!==G[0]&&G[3]!==G[1]&&this.#R.get(K),U!==!1){if(V=[0,0,0,0],x.axialAlignedBoundingBox(G,K.fontMatrix,V),Z!==1||J!==0||_!==0)x.scaleMinMax([Z,0,0,-Z,J,_],V);if(U)return this.recordBBox($,Q,V[0],V[2],V[1],V[3])}}if(!q)return this.recordFullPageBBox($);let N=q();if(G&&V&&U===void 0){if(U=V[0]<=J-N.actualBoundingBoxLeft&&V[2]>=J+N.actualBoundingBoxRight&&V[1]<=_-N.actualBoundingBoxAscent&&V[3]>=_+N.actualBoundingBoxDescent,this.#R.set(K,U),U)return this.recordBBox($,Q,V[0],V[2],V[1],V[3])}return this.recordBBox($,Q,J-N.actualBoundingBoxLeft,J+N.actualBoundingBoxRight,_-N.actualBoundingBoxAscent,_+N.actualBoundingBoxDescent)}recordFullPageBBox($){return this.#G[0]=Math.max(0,this.#_[0]),this.#G[1]=Math.max(0,this.#_[1]),this.#G[2]=Math.min(this.#B,this.#_[2]),this.#G[3]=Math.min(this.#z,this.#_[3]),this}getSimpleIndex($){return this.#$[$]}recordDependencies($,Q){let K=this.#U,Z=this.#$,J=this.#Q;for(let _ of Q)if(_ in this.#$)K.add(Z[_]);else if(_ in J)J[_].forEach(K.add,K);return this}recordNamedDependency($,Q){if(this.#Z.has(Q))this.#U.add(this.#Z.get(Q));return this}recordOperation($,Q=!1){if(this.recordDependencies($,[OQ]),this.#A){let K=j0(this.#A,$),{dependencies:Z}=K;this.#U.forEach(Z.add,Z),this.#K.forEach(Z.add,Z),this.#q.forEach(Z.add,Z),Z.delete($),K.isRenderingOperation=!0}if(this.#V===$){let K=$7(this.#G[0]*256/this.#B),Z=$7(this.#G[1]*256/this.#z),J=Q7(this.#G[2]*256/this.#B),_=Q7(this.#G[3]*256/this.#z);R0(this.#F,$,K,Z,J,_);for(let q of this.#U)if(q!==$)R0(this.#F,q,K,Z,J,_);for(let q of this.#K)if(q!==$)R0(this.#F,q,K,Z,J,_);for(let q of this.#q)if(q!==$)R0(this.#F,q,K,Z,J,_);if(!Q)this.#U.clear(),this.#V=-1}return this}recordShowTextOperation($,Q=!1){let K=Array.from(this.#U);this.recordOperation($,Q),this.recordIncrementalData("sameLineText",$);for(let Z of K)this.recordIncrementalData("sameLineText",Z);return this}bboxToClipBoxDropOperation($,Q=!1){if(this.#V===$){if(this.#V=-1,this.#_[0]=Math.max(this.#_[0],this.#G[0]),this.#_[1]=Math.max(this.#_[1],this.#G[1]),this.#_[2]=Math.min(this.#_[2],this.#G[2]),this.#_[3]=Math.min(this.#_[3],this.#G[3]),!Q)this.#U.clear()}return this}_takePendingDependencies(){let $=this.#U;return this.#U=new Set,$}_extractOperation($){let Q=this.#j.get($);return this.#j.delete($),Q}_pushPendingDependencies($){for(let Q of $)this.#U.add(Q)}take(){return this.#R.clear(),new g7(this.#N,this.#F)}takeDebugMetadata(){return this.#A}}class I0{#$;#Q;#Z;#K=0;#q=0;constructor($,Q,K){if($ instanceof I0&&$.#Z===!!K)return $;this.#$=$,this.#Q=Q,this.#Z=!!K}growOperationsCount(){throw Error("Unreachable")}save($){return this.#q++,this.#$.save(this.#Q),this}restore($){if(this.#q>0)this.#$.restore(this.#Q),this.#q--;return this}recordOpenMarker($){return this.#K++,this}getOpenMarker(){return this.#K>0?this.#Q:this.#$.getOpenMarker()}recordCloseMarker($){return this.#K--,this}beginMarkedContent($){return this}endMarkedContent($){return this}pushBaseTransform($){return this.#$.pushBaseTransform($),this}popBaseTransform(){return this.#$.popBaseTransform(),this}recordSimpleData($,Q){return this.#$.recordSimpleData($,this.#Q),this}recordIncrementalData($,Q){return this.#$.recordIncrementalData($,this.#Q),this}resetIncrementalData($,Q){return this.#$.resetIncrementalData($,this.#Q),this}recordNamedData($,Q){return this}recordSimpleDataFromNamed($,Q,K){return this.#$.recordSimpleDataFromNamed($,Q,this.#Q),this}recordFutureForcedDependency($,Q){return this.#$.recordFutureForcedDependency($,this.#Q),this}inheritSimpleDataAsFutureForcedDependencies($){return this.#$.inheritSimpleDataAsFutureForcedDependencies($),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#$.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox($){if(!this.#Z)this.#$.resetBBox(this.#Q);return this}recordClipBox($,Q,K,Z,J,_){if(!this.#Z)this.#$.recordClipBox(this.#Q,Q,K,Z,J,_);return this}recordBBox($,Q,K,Z,J,_){if(!this.#Z)this.#$.recordBBox(this.#Q,Q,K,Z,J,_);return this}recordCharacterBBox($,Q,K,Z,J,_,q){if(!this.#Z)this.#$.recordCharacterBBox(this.#Q,Q,K,Z,J,_,q);return this}recordFullPageBBox($){if(!this.#Z)this.#$.recordFullPageBBox(this.#Q);return this}getSimpleIndex($){return this.#$.getSimpleIndex($)}recordDependencies($,Q){return this.#$.recordDependencies(this.#Q,Q),this}recordNamedDependency($,Q){return this.#$.recordNamedDependency(this.#Q,Q),this}recordOperation($){return this.#$.recordOperation(this.#Q,!0),this}recordShowTextOperation($){return this.#$.recordShowTextOperation(this.#Q,!0),this}bboxToClipBoxDropOperation($){if(!this.#Z)this.#$.bboxToClipBoxDropOperation(this.#Q,!0);return this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}var u$={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]},M$={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function _6($,Q){if(!Q)return;let K=Q[2]-Q[0],Z=Q[3]-Q[1],J=new Path2D;J.rect(Q[0],Q[1],K,Z),$.clip(J)}class f0{isModifyingCurrentTransform(){return!1}getPattern(){Z$("Abstract method `getPattern` called.")}}class d7 extends f0{constructor($){super();this._type=$[1],this._bbox=$[2],this._colorStops=$[3],this._p0=$[4],this._p1=$[5],this._r0=$[6],this._r1=$[7],this.matrix=null}_createGradient($){let Q;if(this._type==="axial")Q=$.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]);else if(this._type==="radial")Q=$.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1);for(let K of this._colorStops)Q.addColorStop(K[0],K[1]);return Q}getPattern($,Q,K,Z){let J;if(Z===M$.STROKE||Z===M$.FILL){let _=Q.current.getClippedPathBoundingBox(Z,U$($))||[0,0,0,0],q=Math.ceil(_[2]-_[0])||1,G=Math.ceil(_[3]-_[1])||1,U=Q.cachedCanvases.getCanvas("pattern",q,G),V=U.context;if(V.clearRect(0,0,V.canvas.width,V.canvas.height),V.beginPath(),V.rect(0,0,V.canvas.width,V.canvas.height),V.translate(-_[0],-_[1]),K=x.transform(K,[1,0,0,1,_[0],_[1]]),V.transform(...Q.baseTransform),this.matrix)V.transform(...this.matrix);_6(V,this._bbox),V.fillStyle=this._createGradient(V),V.fill(),J=$.createPattern(U.canvas,"no-repeat");let N=new DOMMatrix(K);J.setTransform(N)}else _6($,this._bbox),J=this._createGradient($);return J}}function l0($,Q,K,Z,J,_,q,G){let{coords:U,colors:V}=Q,N=$.data,R=$.width*4,j;if(U[K+1]>U[Z+1])j=K,K=Z,Z=j,j=_,_=q,q=j;if(U[Z+1]>U[J+1])j=Z,Z=J,J=j,j=q,q=G,G=j;if(U[K+1]>U[Z+1])j=K,K=Z,Z=j,j=_,_=q,q=j;let F=(U[K]+Q.offsetX)*Q.scaleX,B=(U[K+1]+Q.offsetY)*Q.scaleY,A=(U[Z]+Q.offsetX)*Q.scaleX,z=(U[Z+1]+Q.offsetY)*Q.scaleY,O=(U[J]+Q.offsetX)*Q.scaleX,S=(U[J+1]+Q.offsetY)*Q.scaleY;if(B>=S)return;let I=V[_],C=V[_+1],T=V[_+2],k=V[q],E=V[q+1],M=V[q+2],W=V[G],X=V[G+1],Y=V[G+2],y=Math.round(B),D=Math.round(S),b,H,P,v,u,a,Q$,G$;for(let t=y;t<=D;t++){if(t<z){let L=t<B?0:(B-t)/(B-z);b=F-(F-A)*L,H=I-(I-k)*L,P=C-(C-E)*L,v=T-(T-M)*L}else{let L;if(t>S)L=1;else if(z===S)L=0;else L=(z-t)/(z-S);b=A-(A-O)*L,H=k-(k-W)*L,P=E-(E-X)*L,v=M-(M-Y)*L}let e;if(t<B)e=0;else if(t>S)e=1;else e=(B-t)/(B-S);u=F-(F-O)*e,a=I-(I-W)*e,Q$=C-(C-X)*e,G$=T-(T-Y)*e;let q$=Math.round(Math.min(b,u)),k$=Math.round(Math.max(b,u)),f=R*t+q$*4;for(let L=q$;L<=k$;L++){if(e=(b-L)/(b-u),e<0)e=0;else if(e>1)e=1;N[f++]=H-(H-a)*e|0,N[f++]=P-(P-Q$)*e|0,N[f++]=v-(v-G$)*e|0,N[f++]=255}}}function IK($,Q,K){let{coords:Z,colors:J}=Q,_,q;switch(Q.type){case"lattice":let G=Q.verticesPerRow,U=Math.floor(Z.length/G)-1,V=G-1;for(_=0;_<U;_++){let N=_*G;for(let R=0;R<V;R++,N++)l0($,K,Z[N],Z[N+1],Z[N+G],J[N],J[N+1],J[N+G]),l0($,K,Z[N+G+1],Z[N+1],Z[N+G],J[N+G+1],J[N+1],J[N+G])}break;case"triangles":for(_=0,q=Z.length;_<q;_+=3)l0($,K,Z[_],Z[_+1],Z[_+2],J[_],J[_+1],J[_+2]);break;default:throw Error("illegal figure")}}class l7 extends f0{constructor($){super();this._coords=$[2],this._colors=$[3],this._figures=$[4],this._bounds=$[5],this._bbox=$[6],this._background=$[7],this.matrix=null}_createMeshCanvas($,Q,K){let q=Math.floor(this._bounds[0]),G=Math.floor(this._bounds[1]),U=Math.ceil(this._bounds[2])-q,V=Math.ceil(this._bounds[3])-G,N=Math.min(Math.ceil(Math.abs(U*$[0]*1.1)),3000),R=Math.min(Math.ceil(Math.abs(V*$[1]*1.1)),3000),j=U/N,F=V/R,B={coords:this._coords,colors:this._colors,offsetX:-q,offsetY:-G,scaleX:1/j,scaleY:1/F},A=N+4,z=R+4,O=K.getCanvas("mesh",A,z),S=O.context,I=S.createImageData(N,R);if(Q){let T=I.data;for(let k=0,E=T.length;k<E;k+=4)T[k]=Q[0],T[k+1]=Q[1],T[k+2]=Q[2],T[k+3]=255}for(let T of this._figures)IK(I,T,B);return S.putImageData(I,2,2),{canvas:O.canvas,offsetX:q-2*j,offsetY:G-2*F,scaleX:j,scaleY:F}}isModifyingCurrentTransform(){return!0}getPattern($,Q,K,Z){_6($,this._bbox);let J=new Float32Array(2);if(Z===M$.SHADING)x.singularValueDecompose2dScale(U$($),J);else if(this.matrix){x.singularValueDecompose2dScale(this.matrix,J);let[q,G]=J;x.singularValueDecompose2dScale(Q.baseTransform,J),J[0]*=q,J[1]*=G}else x.singularValueDecompose2dScale(Q.baseTransform,J);let _=this._createMeshCanvas(J,Z===M$.SHADING?null:this._background,Q.cachedCanvases);if(Z!==M$.SHADING){if($.setTransform(...Q.baseTransform),this.matrix)$.transform(...this.matrix)}return $.translate(_.offsetX,_.offsetY),$.scale(_.scaleX,_.scaleY),$.createPattern(_.canvas,"no-repeat")}}class s7 extends f0{getPattern(){return"hotpink"}}function CK($){switch($[0]){case"RadialAxial":return new d7($);case"Mesh":return new l7($);case"Dummy":return new s7}throw Error(`Unknown IR type: ${$[0]}`)}var K7={COLORED:1,UNCOLORED:2};class Y6{static MAX_PATTERN_SIZE=3000;constructor($,Q,K,Z){this.color=$[1],this.operatorList=$[2],this.matrix=$[3],this.bbox=$[4],this.xstep=$[5],this.ystep=$[6],this.paintType=$[7],this.tilingType=$[8],this.ctx=Q,this.canvasGraphicsFactory=K,this.baseTransform=Z}createPatternCanvas($,Q){let{bbox:K,operatorList:Z,paintType:J,tilingType:_,color:q,canvasGraphicsFactory:G}=this,{xstep:U,ystep:V}=this;U=Math.abs(U),V=Math.abs(V),P0("TilingType: "+_);let N=K[0],R=K[1],j=K[2],F=K[3],B=j-N,A=F-R,z=new Float32Array(2);x.singularValueDecompose2dScale(this.matrix,z);let[O,S]=z;x.singularValueDecompose2dScale(this.baseTransform,z);let I=O*z[0],C=S*z[1],T=B,k=A,E=!1,M=!1,W=Math.ceil(U*I),X=Math.ceil(V*C),Y=Math.ceil(B*I),y=Math.ceil(A*C);if(W>=Y)T=U;else E=!0;if(X>=y)k=V;else M=!0;let D=this.getSizeAndScale(T,this.ctx.canvas.width,I),b=this.getSizeAndScale(k,this.ctx.canvas.height,C),H=$.cachedCanvases.getCanvas("pattern",D.size,b.size),P=H.context,v=G.createCanvasGraphics(P,Q);if(v.groupLevel=$.groupLevel,this.setFillAndStrokeStyleToContext(v,J,q),P.translate(-D.scale*N,-b.scale*R),v.transform(0,D.scale,0,0,b.scale,0,0),P.save(),v.dependencyTracker?.save(),this.clipBbox(v,N,R,j,F),v.baseTransform=U$(v.ctx),v.executeOperatorList(Z),v.endDrawing(),v.dependencyTracker?.restore(),P.restore(),E||M){let u=H.canvas;if(E)T=U;if(M)k=V;let a=this.getSizeAndScale(T,this.ctx.canvas.width,I),Q$=this.getSizeAndScale(k,this.ctx.canvas.height,C),G$=a.size,t=Q$.size,e=$.cachedCanvases.getCanvas("pattern-workaround",G$,t),q$=e.context,k$=E?Math.floor(B/U):0,f=M?Math.floor(A/V):0;for(let L=0;L<=k$;L++)for(let w=0;w<=f;w++)q$.drawImage(u,G$*L,t*w,G$,t,0,0,G$,t);return{canvas:e.canvas,scaleX:a.scale,scaleY:Q$.scale,offsetX:N,offsetY:R}}return{canvas:H.canvas,scaleX:D.scale,scaleY:b.scale,offsetX:N,offsetY:R}}getSizeAndScale($,Q,K){let Z=Math.max(Y6.MAX_PATTERN_SIZE,Q),J=Math.ceil($*K);if(J>=Z)J=Z;else K=J/$;return{scale:K,size:J}}clipBbox($,Q,K,Z,J){let _=Z-Q,q=J-K;$.ctx.rect(Q,K,_,q),x.axialAlignedBoundingBox([Q,K,Z,J],U$($.ctx),$.current.minMax),$.clip(),$.endPath()}setFillAndStrokeStyleToContext($,Q,K){let{ctx:Z,current:J}=$;switch(Q){case K7.COLORED:let{fillStyle:_,strokeStyle:q}=this.ctx;Z.fillStyle=J.fillColor=_,Z.strokeStyle=J.strokeColor=q;break;case K7.UNCOLORED:Z.fillStyle=Z.strokeStyle=K,J.fillColor=J.strokeColor=K;break;default:throw new UK(`Unsupported paint type: ${Q}`)}}isModifyingCurrentTransform(){return!1}getPattern($,Q,K,Z,J){let _=K;if(Z!==M$.SHADING){if(_=x.transform(_,Q.baseTransform),this.matrix)_=x.transform(_,this.matrix)}let q=this.createPatternCanvas(Q,J),G=new DOMMatrix(_);G=G.translate(q.offsetX,q.offsetY),G=G.scale(1/q.scaleX,1/q.scaleY);let U=$.createPattern(q.canvas,"repeat");return U.setTransform(G),U}}function kK({src:$,srcPos:Q=0,dest:K,width:Z,height:J,nonBlackColor:_=4294967295,inverseDecode:q=!1}){let G=S$.isLittleEndian?4278190080:255,[U,V]=q?[_,G]:[G,_],N=Z>>3,R=Z&7,j=$.length;K=new Uint32Array(K.buffer);let F=0;for(let B=0;B<J;B++){for(let z=Q+N;Q<z;Q++){let O=Q<j?$[Q]:255;K[F++]=O&128?V:U,K[F++]=O&64?V:U,K[F++]=O&32?V:U,K[F++]=O&16?V:U,K[F++]=O&8?V:U,K[F++]=O&4?V:U,K[F++]=O&2?V:U,K[F++]=O&1?V:U}if(R===0)continue;let A=Q<j?$[Q++]:255;for(let z=0;z<R;z++)K[F++]=A&1<<7-z?V:U}return{srcPos:Q,destPos:F}}var Z7=16,J7=100,EK=15,_7=10,D$=16,s0=new DOMMatrix,w$=new Float32Array(2),CQ=new Float32Array([1/0,1/0,-1/0,-1/0]);function MK($,Q){if($._removeMirroring)throw Error("Context is already forwarding operations.");$.__originalSave=$.save,$.__originalRestore=$.restore,$.__originalRotate=$.rotate,$.__originalScale=$.scale,$.__originalTranslate=$.translate,$.__originalTransform=$.transform,$.__originalSetTransform=$.setTransform,$.__originalResetTransform=$.resetTransform,$.__originalClip=$.clip,$.__originalMoveTo=$.moveTo,$.__originalLineTo=$.lineTo,$.__originalBezierCurveTo=$.bezierCurveTo,$.__originalRect=$.rect,$.__originalClosePath=$.closePath,$.__originalBeginPath=$.beginPath,$._removeMirroring=()=>{$.save=$.__originalSave,$.restore=$.__originalRestore,$.rotate=$.__originalRotate,$.scale=$.__originalScale,$.translate=$.__originalTranslate,$.transform=$.__originalTransform,$.setTransform=$.__originalSetTransform,$.resetTransform=$.__originalResetTransform,$.clip=$.__originalClip,$.moveTo=$.__originalMoveTo,$.lineTo=$.__originalLineTo,$.bezierCurveTo=$.__originalBezierCurveTo,$.rect=$.__originalRect,$.closePath=$.__originalClosePath,$.beginPath=$.__originalBeginPath,delete $._removeMirroring},$.save=function(){Q.save(),this.__originalSave()},$.restore=function(){Q.restore(),this.__originalRestore()},$.translate=function(K,Z){Q.translate(K,Z),this.__originalTranslate(K,Z)},$.scale=function(K,Z){Q.scale(K,Z),this.__originalScale(K,Z)},$.transform=function(K,Z,J,_,q,G){Q.transform(K,Z,J,_,q,G),this.__originalTransform(K,Z,J,_,q,G)},$.setTransform=function(K,Z,J,_,q,G){Q.setTransform(K,Z,J,_,q,G),this.__originalSetTransform(K,Z,J,_,q,G)},$.resetTransform=function(){Q.resetTransform(),this.__originalResetTransform()},$.rotate=function(K){Q.rotate(K),this.__originalRotate(K)},$.clip=function(K){Q.clip(K),this.__originalClip(K)},$.moveTo=function(K,Z){Q.moveTo(K,Z),this.__originalMoveTo(K,Z)},$.lineTo=function(K,Z){Q.lineTo(K,Z),this.__originalLineTo(K,Z)},$.bezierCurveTo=function(K,Z,J,_,q,G){Q.bezierCurveTo(K,Z,J,_,q,G),this.__originalBezierCurveTo(K,Z,J,_,q,G)},$.rect=function(K,Z,J,_){Q.rect(K,Z,J,_),this.__originalRect(K,Z,J,_)},$.closePath=function(){Q.closePath(),this.__originalClosePath()},$.beginPath=function(){Q.beginPath(),this.__originalBeginPath()}}class o7{constructor($){this.canvasFactory=$,this.cache=Object.create(null)}getCanvas($,Q,K){let Z;if(this.cache[$]!==void 0)Z=this.cache[$],this.canvasFactory.reset(Z,Q,K);else Z=this.canvasFactory.create(Q,K),this.cache[$]=Z;return Z}delete($){delete this.cache[$]}clear(){for(let $ in this.cache){let Q=this.cache[$];this.canvasFactory.destroy(Q),delete this.cache[$]}}}function B0($,Q,K,Z,J,_,q,G,U,V){let[N,R,j,F,B,A]=U$($);if(R===0&&j===0){let S=q*N+B,I=Math.round(S),C=G*F+A,T=Math.round(C),k=(q+U)*N+B,E=Math.abs(Math.round(k)-I)||1,M=(G+V)*F+A,W=Math.abs(Math.round(M)-T)||1;return $.setTransform(Math.sign(N),0,0,Math.sign(F),I,T),$.drawImage(Q,K,Z,J,_,0,0,E,W),$.setTransform(N,R,j,F,B,A),[E,W]}if(N===0&&F===0){let S=G*j+B,I=Math.round(S),C=q*R+A,T=Math.round(C),k=(G+V)*j+B,E=Math.abs(Math.round(k)-I)||1,M=(q+U)*R+A,W=Math.abs(Math.round(M)-T)||1;return $.setTransform(0,Math.sign(R),Math.sign(j),0,I,T),$.drawImage(Q,K,Z,J,_,0,0,W,E),$.setTransform(N,R,j,F,B,A),[W,E]}$.drawImage(Q,K,Z,J,_,q,G,U,V);let z=Math.hypot(N,R),O=Math.hypot(j,F);return[z*U,O*V]}class q6{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=a0;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=E$.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor($,Q,K){K?.(this),this.clipBox=new Float32Array([0,0,$,Q]),this.minMax=CQ.slice()}clone(){let $=Object.create(this);return $.clipBox=this.clipBox.slice(),$.minMax=this.minMax.slice(),$}getPathBoundingBox($=M$.FILL,Q=null){let K=this.minMax.slice();if($===M$.STROKE){if(!Q)Z$("Stroke bounding box must include transform.");x.singularValueDecompose2dScale(Q,w$);let Z=w$[0]*this.lineWidth/2,J=w$[1]*this.lineWidth/2;K[0]-=Z,K[1]-=J,K[2]+=Z,K[3]+=J}return K}updateClipFromPath(){let $=x.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox($||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox($){this.clipBox.set($,0),this.minMax.set(CQ,0)}getClippedPathBoundingBox($=M$.FILL,Q=null){return x.intersect(this.clipBox,this.getPathBoundingBox($,Q))}}function q7($,Q){if(Q instanceof ImageData){$.putImageData(Q,0,0);return}let{height:K,width:Z}=Q,J=K%D$,_=(K-J)/D$,q=J===0?_:_+1,G=$.createImageData(Z,D$),U=0,V,N=Q.data,R=G.data,j,F,B,A;if(Q.kind===h$.GRAYSCALE_1BPP){let z=N.byteLength,O=new Uint32Array(R.buffer,0,R.byteLength>>2),S=O.length,I=Z+7>>3,C=4294967295,T=S$.isLittleEndian?4278190080:255;for(j=0;j<q;j++){B=j<_?D$:J,V=0;for(F=0;F<B;F++){let k=z-U,E=0,M=k>I?Z:k*8-7,W=M&-8,X=0,Y=0;for(;E<W;E+=8)Y=N[U++],O[V++]=Y&128?4294967295:T,O[V++]=Y&64?4294967295:T,O[V++]=Y&32?4294967295:T,O[V++]=Y&16?4294967295:T,O[V++]=Y&8?4294967295:T,O[V++]=Y&4?4294967295:T,O[V++]=Y&2?4294967295:T,O[V++]=Y&1?4294967295:T;for(;E<M;E++){if(X===0)Y=N[U++],X=128;O[V++]=Y&X?4294967295:T,X>>=1}}while(V<S)O[V++]=0;$.putImageData(G,0,j*D$)}}else if(Q.kind===h$.RGBA_32BPP){F=0,A=Z*D$*4;for(j=0;j<_;j++)R.set(N.subarray(U,U+A)),U+=A,$.putImageData(G,0,F),F+=D$;if(j<q)A=Z*J*4,R.set(N.subarray(U,U+A)),$.putImageData(G,0,F)}else if(Q.kind===h$.RGB_24BPP){B=D$,A=Z*B;for(j=0;j<q;j++){if(j>=_)B=J,A=Z*B;V=0;for(F=A;F--;)R[V++]=N[U++],R[V++]=N[U++],R[V++]=N[U++],R[V++]=255;$.putImageData(G,0,j*D$)}}else throw Error(`bad image kind: ${Q.kind}`)}function G7($,Q){if(Q.bitmap){$.drawImage(Q.bitmap,0,0);return}let{height:K,width:Z}=Q,J=K%D$,_=(K-J)/D$,q=J===0?_:_+1,G=$.createImageData(Z,D$),U=0,V=Q.data,N=G.data;for(let R=0;R<q;R++){let j=R<_?D$:J;({srcPos:U}=kK({src:V,srcPos:U,dest:N,width:Z,height:j,nonBlackColor:0})),$.putImageData(G,0,R*D$)}}function wQ($,Q){let K=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let Z of K)if($[Z]!==void 0)Q[Z]=$[Z];if($.setLineDash!==void 0)Q.setLineDash($.getLineDash()),Q.lineDashOffset=$.lineDashOffset}function F0($){if($.strokeStyle=$.fillStyle="#000000",$.fillRule="nonzero",$.globalAlpha=1,$.lineWidth=1,$.lineCap="butt",$.lineJoin="miter",$.miterLimit=10,$.globalCompositeOperation="source-over",$.font="10px sans-serif",$.setLineDash!==void 0)$.setLineDash([]),$.lineDashOffset=0;let{filter:Q}=$;if(Q!=="none"&&Q!=="")$.filter="none"}function U7($,Q){if(Q)return!0;x.singularValueDecompose2dScale($,w$);let K=Math.fround(d$.pixelRatio*qQ.PDF_TO_CSS_UNITS);return w$[0]<=K&&w$[1]<=K}var WK=["butt","round","square"],XK=["miter","round","bevel"],YK={},V7={};class MQ{constructor($,Q,K,Z,J,{optionalContentConfig:_,markedContentStack:q=null},G,U,V){this.ctx=$,this.current=new q6(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=Q,this.objs=K,this.canvasFactory=Z,this.filterFactory=J,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=q||[],this.optionalContentConfig=_,this.cachedCanvases=new o7(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=G,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=U,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=V??null}getObject($,Q,K=null){if(typeof Q==="string")return this.dependencyTracker?.recordNamedDependency($,Q),Q.startsWith("g_")?this.commonObjs.get(Q):this.objs.get(Q);return K}beginDrawing({transform:$,viewport:Q,transparency:K=!1,background:Z=null}){let J=this.ctx.canvas.width,_=this.ctx.canvas.height,q=this.ctx.fillStyle;if(this.ctx.fillStyle=Z||"#ffffff",this.ctx.fillRect(0,0,J,_),this.ctx.fillStyle=q,K){let G=this.cachedCanvases.getCanvas("transparent",J,_);this.compositeCtx=this.ctx,this.transparentCanvas=G.canvas,this.ctx=G.context,this.ctx.save(),this.ctx.transform(...U$(this.compositeCtx))}if(this.ctx.save(),F0(this.ctx),$)this.ctx.transform(...$),this.outputScaleX=$[0],this.outputScaleY=$[0];this.ctx.transform(...Q.transform),this.viewportScale=Q.scale,this.baseTransform=U$(this.ctx)}executeOperatorList($,Q,K,Z,J){let{argsArray:_,fnArray:q}=$,G=Q||0,U=_.length;if(U===G)return G;let V=U-G>_7&&typeof K==="function",N=V?Date.now()+EK:0,R=0,j=this.commonObjs,F=this.objs,B,A;while(!0){if(Z!==void 0&&G===Z.nextBreakPoint)return Z.breakIt(G,K),G;if(!J||J(G))if(B=q[G],A=_[G]??null,B!==P$.dependency)if(A===null)this[B](G);else this[B](G,...A);else for(let z of A){this.dependencyTracker?.recordNamedData(z,G);let O=z.startsWith("g_")?j:F;if(!O.has(z))return O.get(z,K),G}if(G++,G===U)return G;if(V&&++R>_7){if(Date.now()>N)return K(),G;R=0}}}#$(){while(this.stateStack.length||this.inSMaskMode)this.restore();if(this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas)this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null}endDrawing(){this.#$(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let $ of this._cachedBitmapsMap.values()){for(let Q of $.values())if(typeof HTMLCanvasElement<"u"&&Q instanceof HTMLCanvasElement)Q.width=Q.height=0;$.clear()}this._cachedBitmapsMap.clear(),this.#Q()}#Q(){if(this.pageColors){let $=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if($!=="none"){let Q=this.ctx.filter;this.ctx.filter=$,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=Q}}}_scaleImage($,Q){let K=$.width??$.displayWidth,Z=$.height??$.displayHeight,J=Math.max(Math.hypot(Q[0],Q[1]),1),_=Math.max(Math.hypot(Q[2],Q[3]),1),q=K,G=Z,U="prescale1",V,N;while(J>2&&q>1||_>2&&G>1){let R=q,j=G;if(J>2&&q>1)R=q>=16384?Math.floor(q/2)-1||1:Math.ceil(q/2),J/=q/R;if(_>2&&G>1)j=G>=16384?Math.floor(G/2)-1||1:Math.ceil(G)/2,_/=G/j;V=this.cachedCanvases.getCanvas(U,R,j),N=V.context,N.clearRect(0,0,R,j),N.drawImage($,0,0,q,G,0,0,R,j),$=V.canvas,q=R,G=j,U=U==="prescale1"?"prescale2":"prescale1"}return{img:$,paintWidth:q,paintHeight:G}}_createMaskCanvas($,Q){let K=this.ctx,{width:Z,height:J}=Q,_=this.current.fillColor,q=this.current.patternFill,G=U$(K),U,V,N,R;if((Q.bitmap||Q.data)&&Q.count>1){let W=Q.bitmap||Q.data.buffer;if(V=JSON.stringify(q?G:[G.slice(0,4),_]),U=this._cachedBitmapsMap.get(W),!U)U=new Map,this._cachedBitmapsMap.set(W,U);let X=U.get(V);if(X&&!q){let Y=Math.round(Math.min(G[0],G[2])+G[4]),y=Math.round(Math.min(G[1],G[3])+G[5]);return this.dependencyTracker?.recordDependencies($,u$.transformAndFill),{canvas:X,offsetX:Y,offsetY:y}}N=X}if(!N)R=this.cachedCanvases.getCanvas("maskCanvas",Z,J),G7(R.context,Q);let j=x.transform(G,[1/Z,0,0,-1/J,0,0]);j=x.transform(j,[1,0,0,1,0,-J]);let F=CQ.slice();x.axialAlignedBoundingBox([0,0,Z,J],j,F);let[B,A,z,O]=F,S=Math.round(z-B)||1,I=Math.round(O-A)||1,C=this.cachedCanvases.getCanvas("fillCanvas",S,I),T=C.context,k=B,E=A;if(T.translate(-k,-E),T.transform(...j),!N){if(N=this._scaleImage(R.canvas,l$(T)),N=N.img,U&&q)U.set(V,N)}T.imageSmoothingEnabled=U7(U$(T),Q.interpolate),B0(T,N,0,0,N.width,N.height,0,0,Z,J),T.globalCompositeOperation="source-in";let M=x.transform(l$(T),[1,0,0,1,-k,-E]);if(T.fillStyle=q?_.getPattern(K,this,M,M$.FILL,$):_,T.fillRect(0,0,Z,J),U&&!q)this.cachedCanvases.delete("fillCanvas"),U.set(V,C.canvas);return this.dependencyTracker?.recordDependencies($,u$.transformAndFill),{canvas:C.canvas,offsetX:Math.round(k),offsetY:Math.round(E)}}setLineWidth($,Q){if(this.dependencyTracker?.recordSimpleData("lineWidth",$),Q!==this.current.lineWidth)this._cachedScaleForStroking[0]=-1;this.current.lineWidth=Q,this.ctx.lineWidth=Q}setLineCap($,Q){this.dependencyTracker?.recordSimpleData("lineCap",$),this.ctx.lineCap=WK[Q]}setLineJoin($,Q){this.dependencyTracker?.recordSimpleData("lineJoin",$),this.ctx.lineJoin=XK[Q]}setMiterLimit($,Q){this.dependencyTracker?.recordSimpleData("miterLimit",$),this.ctx.miterLimit=Q}setDash($,Q,K){this.dependencyTracker?.recordSimpleData("dash",$);let Z=this.ctx;if(Z.setLineDash!==void 0)Z.setLineDash(Q),Z.lineDashOffset=K}setRenderingIntent($,Q){}setFlatness($,Q){}setGState($,Q){for(let[K,Z]of Q)switch(K){case"LW":this.setLineWidth($,Z);break;case"LC":this.setLineCap($,Z);break;case"LJ":this.setLineJoin($,Z);break;case"ML":this.setMiterLimit($,Z);break;case"D":this.setDash($,Z[0],Z[1]);break;case"RI":this.setRenderingIntent($,Z);break;case"FL":this.setFlatness($,Z);break;case"Font":this.setFont($,Z[0],Z[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",$),this.current.strokeAlpha=Z;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",$),this.ctx.globalAlpha=this.current.fillAlpha=Z;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",$),this.ctx.globalCompositeOperation=Z;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",$),this.current.activeSMask=Z?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",$),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(Z);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let $=this.inSMaskMode;if(this.current.activeSMask&&!$)this.beginSMaskMode();else if(!this.current.activeSMask&&$)this.endSMaskMode()}beginSMaskMode($){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let Q=this.ctx.canvas.width,K=this.ctx.canvas.height,Z="smaskGroupAt"+this.groupLevel,J=this.cachedCanvases.getCanvas(Z,Q,K);this.suspendedCtx=this.ctx;let _=this.ctx=J.context;_.setTransform(this.suspendedCtx.getTransform()),wQ(this.suspendedCtx,_),MK(_,this.suspendedCtx),this.setGState($,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),wQ(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose($){if(!this.current.activeSMask)return;if(!$)$=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];else $[0]=Math.floor($[0]),$[1]=Math.floor($[1]),$[2]=Math.ceil($[2]),$[3]=Math.ceil($[3]);let Q=this.current.activeSMask,K=this.suspendedCtx;this.composeSMask(K,Q,this.ctx,$),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($,Q,K,Z){let J=Z[0],_=Z[1],q=Z[2]-J,G=Z[3]-_;if(q===0||G===0)return;this.genericComposeSMask(Q.context,K,q,G,Q.subtype,Q.backdrop,Q.transferMap,J,_,Q.offsetX,Q.offsetY),$.save(),$.globalAlpha=1,$.globalCompositeOperation="source-over",$.setTransform(1,0,0,1,0,0),$.drawImage(K.canvas,0,0),$.restore()}genericComposeSMask($,Q,K,Z,J,_,q,G,U,V,N){let R=$.canvas,j=G-V,F=U-N;if(_)if(j<0||F<0||j+K>R.width||F+Z>R.height){let A=this.cachedCanvases.getCanvas("maskExtension",K,Z),z=A.context;z.drawImage(R,-j,-F),z.globalCompositeOperation="destination-atop",z.fillStyle=_,z.fillRect(0,0,K,Z),z.globalCompositeOperation="source-over",R=A.canvas,j=F=0}else{$.save(),$.globalAlpha=1,$.setTransform(1,0,0,1,0,0);let A=new Path2D;A.rect(j,F,K,Z),$.clip(A),$.globalCompositeOperation="destination-atop",$.fillStyle=_,$.fillRect(j,F,K,Z),$.restore()}if(Q.save(),Q.globalAlpha=1,Q.setTransform(1,0,0,1,0,0),J==="Alpha"&&q)Q.filter=this.filterFactory.addAlphaFilter(q);else if(J==="Luminosity")Q.filter=this.filterFactory.addLuminosityFilter(q);let B=new Path2D;B.rect(G,U,K,Z),Q.clip(B),Q.globalCompositeOperation="destination-in",Q.drawImage(R,j,F,K,Z,G,U,K,Z),Q.restore()}save($){if(this.inSMaskMode)wQ(this.ctx,this.suspendedCtx);this.ctx.save();let Q=this.current;this.stateStack.push(Q),this.current=Q.clone(),this.dependencyTracker?.save($)}restore($){if(this.dependencyTracker?.restore($),this.stateStack.length===0){if(this.inSMaskMode)this.endSMaskMode();return}if(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode)wQ(this.suspendedCtx,this.ctx);this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform($,Q,K,Z,J,_,q){this.dependencyTracker?.recordIncrementalData("transform",$),this.ctx.transform(Q,K,Z,J,_,q),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath($,Q,K,Z){let[J]=K;if(!Z){J||=K[0]=new Path2D,this[Q]($,J);return}if(this.dependencyTracker!==null){let _=Q===P$.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox($).recordBBox($,this.ctx,Z[0]-_,Z[2]+_,Z[1]-_,Z[3]+_).recordDependencies($,["transform"])}if(!(J instanceof Path2D)){let _=K[0]=new Path2D;for(let q=0,G=J.length;q<G;)switch(J[q++]){case U0.moveTo:_.moveTo(J[q++],J[q++]);break;case U0.lineTo:_.lineTo(J[q++],J[q++]);break;case U0.curveTo:_.bezierCurveTo(J[q++],J[q++],J[q++],J[q++],J[q++],J[q++]);break;case U0.closePath:_.closePath();break;default:p(`Unrecognized drawing path operator: ${J[q-1]}`);break}J=_}x.axialAlignedBoundingBox(Z,U$(this.ctx),this.current.minMax),this[Q]($,J),this._pathStartIdx=$}closePath($){this.ctx.closePath()}stroke($,Q,K=!0){let Z=this.ctx,J=this.current.strokeColor;if(Z.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof J==="object"&&J?.getPattern){let _=J.isModifyingCurrentTransform()?Z.getTransform():null;if(Z.save(),Z.strokeStyle=J.getPattern(Z,this,l$(Z),M$.STROKE,$),_){let q=new Path2D;q.addPath(Q,Z.getTransform().invertSelf().multiplySelf(_)),Q=q}this.rescaleAndStroke(Q,!1),Z.restore()}else this.rescaleAndStroke(Q,!0);if(this.dependencyTracker?.recordDependencies($,u$.stroke),K)this.consumePath($,Q,this.current.getClippedPathBoundingBox(M$.STROKE,U$(this.ctx)));Z.globalAlpha=this.current.fillAlpha}closeStroke($,Q){this.stroke($,Q)}fill($,Q,K=!0){let Z=this.ctx,J=this.current.fillColor,_=this.current.patternFill,q=!1;if(_){let U=J.isModifyingCurrentTransform()?Z.getTransform():null;if(this.dependencyTracker?.save($),Z.save(),Z.fillStyle=J.getPattern(Z,this,l$(Z),M$.FILL,$),U){let V=new Path2D;V.addPath(Q,Z.getTransform().invertSelf().multiplySelf(U)),Q=V}q=!0}let G=this.current.getClippedPathBoundingBox();if(this.contentVisible&&G!==null)if(this.pendingEOFill)Z.fill(Q,"evenodd"),this.pendingEOFill=!1;else Z.fill(Q);if(this.dependencyTracker?.recordDependencies($,u$.fill),q)Z.restore(),this.dependencyTracker?.restore($);if(K)this.consumePath($,Q,G)}eoFill($,Q){this.pendingEOFill=!0,this.fill($,Q)}fillStroke($,Q){this.fill($,Q,!1),this.stroke($,Q,!1),this.consumePath($,Q)}eoFillStroke($,Q){this.pendingEOFill=!0,this.fillStroke($,Q)}closeFillStroke($,Q){this.fillStroke($,Q)}closeEOFillStroke($,Q){this.pendingEOFill=!0,this.fillStroke($,Q)}endPath($,Q){this.consumePath($,Q)}rawFillPath($,Q){this.ctx.fill(Q),this.dependencyTracker?.recordDependencies($,u$.rawFillPath).recordOperation($)}clip($){this.dependencyTracker?.recordFutureForcedDependency("clipMode",$),this.pendingClip=YK}eoClip($){this.dependencyTracker?.recordFutureForcedDependency("clipMode",$),this.pendingClip=V7}beginText($){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker($).resetIncrementalData("sameLineText").resetIncrementalData("moveText",$)}endText($){let Q=this.pendingTextPaths,K=this.ctx;if(this.dependencyTracker){let{dependencyTracker:Z}=this;if(Q!==void 0)Z.recordFutureForcedDependency("textClip",Z.getOpenMarker()).recordFutureForcedDependency("textClip",$);Z.recordCloseMarker($)}if(Q!==void 0){let Z=new Path2D,J=K.getTransform().invertSelf();for(let{transform:_,x:q,y:G,fontSize:U,path:V}of Q){if(!V)continue;Z.addPath(V,new DOMMatrix(_).preMultiplySelf(J).translate(q,G).scale(U,-U))}K.clip(Z)}delete this.pendingTextPaths}setCharSpacing($,Q){this.dependencyTracker?.recordSimpleData("charSpacing",$),this.current.charSpacing=Q}setWordSpacing($,Q){this.dependencyTracker?.recordSimpleData("wordSpacing",$),this.current.wordSpacing=Q}setHScale($,Q){this.dependencyTracker?.recordSimpleData("hScale",$),this.current.textHScale=Q/100}setLeading($,Q){this.dependencyTracker?.recordSimpleData("leading",$),this.current.leading=-Q}setFont($,Q,K){this.dependencyTracker?.recordSimpleData("font",$).recordSimpleDataFromNamed("fontObj",Q,$);let Z=this.commonObjs.get(Q),J=this.current;if(!Z)throw Error(`Can't find font for ${Q}`);if(J.fontMatrix=Z.fontMatrix||a0,J.fontMatrix[0]===0||J.fontMatrix[3]===0)p("Invalid font matrix for font "+Q);if(K<0)K=-K,J.fontDirection=-1;else J.fontDirection=1;if(this.current.font=Z,this.current.fontSize=K,Z.isType3Font)return;let _=Z.loadedName||"sans-serif",q=Z.systemFontInfo?.css||`"${_}", ${Z.fallbackName}`,G="normal";if(Z.black)G="900";else if(Z.bold)G="bold";let U=Z.italic?"italic":"normal",V=K;if(K<Z7)V=Z7;else if(K>J7)V=J7;this.current.fontSizeScale=K/V,this.ctx.font=`${U} ${G} ${V}px ${q}`}setTextRenderingMode($,Q){this.dependencyTracker?.recordSimpleData("textRenderingMode",$),this.current.textRenderingMode=Q}setTextRise($,Q){this.dependencyTracker?.recordSimpleData("textRise",$),this.current.textRise=Q}moveText($,Q,K){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",$),this.current.x=this.current.lineX+=Q,this.current.y=this.current.lineY+=K}setLeadingMoveText($,Q,K){this.setLeading($,-K),this.moveText($,Q,K)}setTextMatrix($,Q){this.dependencyTracker?.recordSimpleData("textMatrix",$);let{current:K}=this;K.textMatrix=Q,K.textMatrixScale=Math.hypot(Q[0],Q[1]),K.x=K.lineX=0,K.y=K.lineY=0}nextLine($){this.moveText($,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??$)}#Z($,Q,K){let Z=new Path2D;return Z.addPath($,new DOMMatrix(K).invertSelf().multiplySelf(Q)),Z}paintChar($,Q,K,Z,J,_){let q=this.ctx,G=this.current,U=G.font,V=G.textRenderingMode,N=G.fontSize/G.fontSizeScale,R=V&E$.FILL_STROKE_MASK,j=!!(V&E$.ADD_TO_PATH_FLAG),F=G.patternFill&&!U.missingFile,B=G.patternStroke&&!U.missingFile,A;if((U.disableFontFace||j||F||B)&&!U.missingFile)A=U.getPathGenerator(this.commonObjs,Q);if(A&&(U.disableFontFace||F||B)){q.save(),q.translate(K,Z),q.scale(N,-N),this.dependencyTracker?.recordCharacterBBox($,q,U);let z;if(R===E$.FILL||R===E$.FILL_STROKE)if(J){z=q.getTransform(),q.setTransform(...J);let O=this.#Z(A,z,J);q.fill(O)}else q.fill(A);if(R===E$.STROKE||R===E$.FILL_STROKE)if(_){z||=q.getTransform(),q.setTransform(..._);let{a:O,b:S,c:I,d:C}=z,T=x.inverseTransform(_),k=x.transform([O,S,I,C,0,0],T);x.singularValueDecompose2dScale(k,w$),q.lineWidth*=Math.max(w$[0],w$[1])/N,q.stroke(this.#Z(A,z,_))}else q.lineWidth/=N,q.stroke(A);q.restore()}else{if(R===E$.FILL||R===E$.FILL_STROKE)q.fillText(Q,K,Z),this.dependencyTracker?.recordCharacterBBox($,q,U,N,K,Z,()=>q.measureText(Q));if(R===E$.STROKE||R===E$.FILL_STROKE){if(this.dependencyTracker)this.dependencyTracker?.recordCharacterBBox($,q,U,N,K,Z,()=>q.measureText(Q)).recordDependencies($,u$.stroke);q.strokeText(Q,K,Z)}}if(j)(this.pendingTextPaths||=[]).push({transform:U$(q),x:K,y:Z,fontSize:N,path:A}),this.dependencyTracker?.recordCharacterBBox($,q,U,N,K,Z)}get isFontSubpixelAAEnabled(){let{context:$}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);$.scale(1.5,1),$.fillText("I",0,10);let Q=$.getImageData(0,0,10,10).data,K=!1;for(let Z=3;Z<Q.length;Z+=4)if(Q[Z]>0&&Q[Z]<255){K=!0;break}return r(this,"isFontSubpixelAAEnabled",K)}showText($,Q){if(this.dependencyTracker){if(this.dependencyTracker.recordDependencies($,u$.showText).resetBBox($),this.current.textRenderingMode&E$.ADD_TO_PATH_FLAG)this.dependencyTracker.recordFutureForcedDependency("textClip",$).inheritPendingDependenciesAsFutureForcedDependencies()}let K=this.current,Z=K.font;if(Z.isType3Font){this.showType3Text($,Q),this.dependencyTracker?.recordShowTextOperation($);return}let J=K.fontSize;if(J===0){this.dependencyTracker?.recordOperation($);return}let _=this.ctx,q=K.fontSizeScale,G=K.charSpacing,U=K.wordSpacing,V=K.fontDirection,N=K.textHScale*V,R=Q.length,j=Z.vertical,F=j?1:-1,B=Z.defaultVMetrics,A=J*K.fontMatrix[0],z=K.textRenderingMode===E$.FILL&&!Z.disableFontFace&&!K.patternFill;if(_.save(),K.textMatrix)_.transform(...K.textMatrix);if(_.translate(K.x,K.y+K.textRise),V>0)_.scale(N,-1);else _.scale(N,1);let O,S;if(K.patternFill){_.save();let E=K.fillColor.getPattern(_,this,l$(_),M$.FILL,$);O=U$(_),_.restore(),_.fillStyle=E}if(K.patternStroke){_.save();let E=K.strokeColor.getPattern(_,this,l$(_),M$.STROKE,$);S=U$(_),_.restore(),_.strokeStyle=E}let{lineWidth:I,textMatrixScale:C}=K;if(C===0||I===0){let E=K.textRenderingMode&E$.FILL_STROKE_MASK;if(E===E$.STROKE||E===E$.FILL_STROKE)I=this.getSinglePixelWidth()}else I/=C;if(q!==1)_.scale(q,q),I/=q;if(_.lineWidth=I,Z.isInvalidPDFjsFont){let E=[],M=0;for(let X of Q)E.push(X.unicode),M+=X.width;let W=E.join("");if(_.fillText(W,0,0),this.dependencyTracker!==null){let X=_.measureText(W);this.dependencyTracker.recordBBox($,this.ctx,-X.actualBoundingBoxLeft,X.actualBoundingBoxRight,-X.actualBoundingBoxAscent,X.actualBoundingBoxDescent).recordShowTextOperation($)}K.x+=M*A*N,_.restore(),this.compose();return}let T=0,k;for(k=0;k<R;++k){let E=Q[k];if(typeof E==="number"){T+=F*E*J/1000;continue}let M=!1,W=(E.isSpace?U:0)+G,X=E.fontChar,Y=E.accent,y,D,b=E.width;if(j){let v=E.vmetric||B,u=-(E.vmetric?v[1]:b*0.5)*A,a=v[2]*A;b=v?-v[0]:b,y=u/q,D=(T+a)/q}else y=T/q,D=0;let H;if(Z.remeasure&&b>0){H=_.measureText(X);let v=H.width*1000/J*q;if(b<v&&this.isFontSubpixelAAEnabled){let u=b/v;M=!0,_.save(),_.scale(u,1),y/=u}else if(b!==v)y+=(b-v)/2000*J/q}if(this.contentVisible&&(E.isInFont||Z.missingFile)){if(z&&!Y)_.fillText(X,y,D),this.dependencyTracker?.recordCharacterBBox($,_,H?{bbox:null}:Z,J/q,y,D,()=>H??_.measureText(X));else if(this.paintChar($,X,y,D,O,S),Y){let v=y+J*Y.offset.x/q,u=D-J*Y.offset.y/q;this.paintChar($,Y.fontChar,v,u,O,S)}}let P=j?b*A-W*V:b*A+W*V;if(T+=P,M)_.restore()}if(j)K.y-=T;else K.x+=T*N;_.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation($);return}showType3Text($,Q){let K=this.ctx,Z=this.current,J=Z.font,_=Z.fontSize,q=Z.fontDirection,G=J.vertical?1:-1,U=Z.charSpacing,V=Z.wordSpacing,N=Z.textHScale*q,R=Z.fontMatrix||a0,j=Q.length,F=Z.textRenderingMode===E$.INVISIBLE,B,A,z,O;if(F||_===0)return;if(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,K.save(),Z.textMatrix)K.transform(...Z.textMatrix);K.translate(Z.x,Z.y+Z.textRise),K.scale(N,q);let S=this.dependencyTracker;this.dependencyTracker=S?new I0(S,$):null;for(B=0;B<j;++B){if(A=Q[B],typeof A==="number"){O=G*A*_/1000,this.ctx.translate(O,0),Z.x+=O*N;continue}let I=(A.isSpace?V:0)+U,C=J.charProcOperatorList[A.operatorListId];if(!C)p(`Type3 character "${A.operatorListId}" is not available.`);else if(this.contentVisible)this.save(),K.scale(_,_),K.transform(...R),this.executeOperatorList(C),this.restore();let T=[A.width,0];x.applyTransform(T,R),z=T[0]*_+I,K.translate(z,0),Z.x+=z*N}if(K.restore(),S)this.dependencyTracker=S}setCharWidth($,Q,K){}setCharWidthAndBounds($,Q,K,Z,J,_,q){let G=new Path2D;G.rect(Z,J,_-Z,q-J),this.ctx.clip(G),this.dependencyTracker?.recordBBox($,this.ctx,Z,_,J,q).recordClipBox($,this.ctx,Z,_,J,q),this.endPath($)}getColorN_Pattern($,Q){let K;if(Q[0]==="TilingPattern"){let Z=this.baseTransform||U$(this.ctx),J={createCanvasGraphics:(_,q)=>new MQ(_,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new I0(this.dependencyTracker,q,!0):null)};K=new Y6(Q,this.ctx,J,Z)}else K=this._getPattern($,Q[1],Q[2]);return K}setStrokeColorN($,...Q){this.dependencyTracker?.recordSimpleData("strokeColor",$),this.current.strokeColor=this.getColorN_Pattern($,Q),this.current.patternStroke=!0}setFillColorN($,...Q){this.dependencyTracker?.recordSimpleData("fillColor",$),this.current.fillColor=this.getColorN_Pattern($,Q),this.current.patternFill=!0}setStrokeRGBColor($,Q){this.dependencyTracker?.recordSimpleData("strokeColor",$),this.ctx.strokeStyle=this.current.strokeColor=Q,this.current.patternStroke=!1}setStrokeTransparent($){this.dependencyTracker?.recordSimpleData("strokeColor",$),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor($,Q){this.dependencyTracker?.recordSimpleData("fillColor",$),this.ctx.fillStyle=this.current.fillColor=Q,this.current.patternFill=!1}setFillTransparent($){this.dependencyTracker?.recordSimpleData("fillColor",$),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern($,Q,K=null){let Z;if(this.cachedPatterns.has(Q))Z=this.cachedPatterns.get(Q);else Z=CK(this.getObject($,Q)),this.cachedPatterns.set(Q,Z);if(K)Z.matrix=K;return Z}shadingFill($,Q){if(!this.contentVisible)return;let K=this.ctx;this.save($);let Z=this._getPattern($,Q);K.fillStyle=Z.getPattern(K,this,l$(K),M$.SHADING,$);let J=l$(K);if(J){let{width:_,height:q}=K.canvas,G=CQ.slice();x.axialAlignedBoundingBox([0,0,_,q],J,G);let[U,V,N,R]=G;this.ctx.fillRect(U,V,N-U,R-V)}else this.ctx.fillRect(-10000000000,-10000000000,20000000000,20000000000);this.dependencyTracker?.resetBBox($).recordFullPageBBox($).recordDependencies($,u$.transform).recordDependencies($,u$.fill).recordOperation($),this.compose(this.current.getClippedPathBoundingBox()),this.restore($)}beginInlineImage(){Z$("Should not call beginInlineImage")}beginImageData(){Z$("Should not call beginImageData")}paintFormXObjectBegin($,Q,K){if(!this.contentVisible)return;if(this.save($),this.baseTransformStack.push(this.baseTransform),Q)this.transform($,...Q);if(this.baseTransform=U$(this.ctx),K){x.axialAlignedBoundingBox(K,this.baseTransform,this.current.minMax);let[Z,J,_,q]=K,G=new Path2D;G.rect(Z,J,_-Z,q-J),this.ctx.clip(G),this.dependencyTracker?.recordClipBox($,this.ctx,Z,_,J,q),this.endPath($)}}paintFormXObjectEnd($){if(!this.contentVisible)return;this.restore($),this.baseTransform=this.baseTransformStack.pop()}beginGroup($,Q){if(!this.contentVisible)return;if(this.save($),this.inSMaskMode)this.endSMaskMode(),this.current.activeSMask=null;let K=this.ctx;if(!Q.isolated)P0("TODO: Support non-isolated groups.");if(Q.knockout)p("Knockout groups not supported.");let Z=U$(K);if(Q.matrix)K.transform(...Q.matrix);if(!Q.bbox)throw Error("Bounding box is required.");let J=CQ.slice();x.axialAlignedBoundingBox(Q.bbox,U$(K),J);let _=[0,0,K.canvas.width,K.canvas.height];J=x.intersect(J,_)||[0,0,0,0];let q=Math.floor(J[0]),G=Math.floor(J[1]),U=Math.max(Math.ceil(J[2])-q,1),V=Math.max(Math.ceil(J[3])-G,1);this.current.startNewPathAndClipBox([0,0,U,V]);let N="groupAt"+this.groupLevel;if(Q.smask)N+="_smask_"+this.smaskCounter++%2;let R=this.cachedCanvases.getCanvas(N,U,V),j=R.context;j.translate(-q,-G),j.transform(...Z);let F=new Path2D,[B,A,z,O]=Q.bbox;if(F.rect(B,A,z-B,O-A),Q.matrix){let S=new Path2D;S.addPath(F,new DOMMatrix(Q.matrix)),F=S}if(j.clip(F),Q.smask)this.smaskStack.push({canvas:R.canvas,context:j,offsetX:q,offsetY:G,subtype:Q.smask.subtype,backdrop:Q.smask.backdrop,transferMap:Q.smask.transferMap||null,startTransformInverse:null});if(!Q.smask||this.dependencyTracker)K.setTransform(1,0,0,1,0,0),K.translate(q,G),K.save();wQ(K,j),this.ctx=j,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(K),this.setGState($,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(K),this.groupLevel++}endGroup($,Q){if(!this.contentVisible)return;this.groupLevel--;let K=this.ctx,Z=this.groupStack.pop();if(this.ctx=Z,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),Q.smask){if(this.tempSMask=this.smaskStack.pop(),this.restore($),this.dependencyTracker)this.ctx.restore()}else{this.ctx.restore();let J=U$(this.ctx);this.restore($),this.ctx.save(),this.ctx.setTransform(...J);let _=CQ.slice();x.axialAlignedBoundingBox([0,0,K.canvas.width,K.canvas.height],J,_),this.ctx.drawImage(K.canvas,0,0),this.ctx.restore(),this.compose(_)}}beginAnnotation($,Q,K,Z,J,_){if(this.#$(),F0(this.ctx),this.ctx.save(),this.save($),this.baseTransform)this.ctx.setTransform(...this.baseTransform);if(K){let q=K[2]-K[0],G=K[3]-K[1];if(_&&this.annotationCanvasMap){Z=Z.slice(),Z[4]-=K[0],Z[5]-=K[1],K=K.slice(),K[0]=K[1]=0,K[2]=q,K[3]=G,x.singularValueDecompose2dScale(U$(this.ctx),w$);let{viewportScale:U}=this,V=Math.ceil(q*this.outputScaleX*U),N=Math.ceil(G*this.outputScaleY*U);this.annotationCanvas=this.canvasFactory.create(V,N);let{canvas:R,context:j}=this.annotationCanvas;this.annotationCanvasMap.set(Q,R),this.annotationCanvas.savedCtx=this.ctx,this.ctx=j,this.ctx.save(),this.ctx.setTransform(w$[0],0,0,-w$[1],0,G*w$[1]),F0(this.ctx)}else{F0(this.ctx),this.endPath($);let U=new Path2D;U.rect(K[0],K[1],q,G),this.ctx.clip(U)}}this.current=new q6(this.ctx.canvas.width,this.ctx.canvas.height),this.transform($,...Z),this.transform($,...J)}endAnnotation($){if(this.annotationCanvas)this.ctx.restore(),this.#Q(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas}paintImageMaskXObject($,Q){if(!this.contentVisible)return;let K=Q.count;Q=this.getObject($,Q.data,Q),Q.count=K;let Z=this.ctx,J=this._createMaskCanvas($,Q),_=J.canvas;Z.save(),Z.setTransform(1,0,0,1,0,0),Z.drawImage(_,J.offsetX,J.offsetY),this.dependencyTracker?.resetBBox($).recordBBox($,this.ctx,J.offsetX,J.offsetX+_.width,J.offsetY,J.offsetY+_.height).recordOperation($),Z.restore(),this.compose()}paintImageMaskXObjectRepeat($,Q,K,Z=0,J=0,_,q){if(!this.contentVisible)return;Q=this.getObject($,Q.data,Q);let G=this.ctx;G.save();let U=U$(G);G.transform(K,Z,J,_,0,0);let V=this._createMaskCanvas($,Q);G.setTransform(1,0,0,1,V.offsetX-U[4],V.offsetY-U[5]),this.dependencyTracker?.resetBBox($);for(let N=0,R=q.length;N<R;N+=2){let j=x.transform(U,[K,Z,J,_,q[N],q[N+1]]);G.drawImage(V.canvas,j[4],j[5]),this.dependencyTracker?.recordBBox($,this.ctx,j[4],j[4]+V.canvas.width,j[5],j[5]+V.canvas.height)}G.restore(),this.compose(),this.dependencyTracker?.recordOperation($)}paintImageMaskXObjectGroup($,Q){if(!this.contentVisible)return;let K=this.ctx,Z=this.current.fillColor,J=this.current.patternFill;this.dependencyTracker?.resetBBox($).recordDependencies($,u$.transformAndFill);for(let _ of Q){let{data:q,width:G,height:U,transform:V}=_,N=this.cachedCanvases.getCanvas("maskCanvas",G,U),R=N.context;R.save();let j=this.getObject($,q,_);G7(R,j),R.globalCompositeOperation="source-in",R.fillStyle=J?Z.getPattern(R,this,l$(K),M$.FILL,$):Z,R.fillRect(0,0,G,U),R.restore(),K.save(),K.transform(...V),K.scale(1,-1),B0(K,N.canvas,0,0,G,U,0,-1,1,1),this.dependencyTracker?.recordBBox($,K,0,G,0,U),K.restore()}this.compose(),this.dependencyTracker?.recordOperation($)}paintImageXObject($,Q){if(!this.contentVisible)return;let K=this.getObject($,Q);if(!K){p("Dependent image isn't ready yet");return}this.paintInlineImageXObject($,K)}paintImageXObjectRepeat($,Q,K,Z,J){if(!this.contentVisible)return;let _=this.getObject($,Q);if(!_){p("Dependent image isn't ready yet");return}let{width:q,height:G}=_,U=[];for(let V=0,N=J.length;V<N;V+=2)U.push({transform:[K,0,0,Z,J[V],J[V+1]],x:0,y:0,w:q,h:G});this.paintInlineImageXObjectGroup($,_,U)}applyTransferMapsToCanvas($){if(this.current.transferMaps!=="none")$.filter=this.current.transferMaps,$.drawImage($.canvas,0,0),$.filter="none";return $.canvas}applyTransferMapsToBitmap($){if(this.current.transferMaps==="none")return $.bitmap;let{bitmap:Q,width:K,height:Z}=$,J=this.cachedCanvases.getCanvas("inlineImage",K,Z),_=J.context;return _.filter=this.current.transferMaps,_.drawImage(Q,0,0),_.filter="none",J.canvas}paintInlineImageXObject($,Q){if(!this.contentVisible)return;let{width:K,height:Z}=Q,J=this.ctx;this.save($);let{filter:_}=J;if(_!=="none"&&_!=="")J.filter="none";J.scale(1/K,-1/Z);let q;if(Q.bitmap)q=this.applyTransferMapsToBitmap(Q);else if(typeof HTMLElement==="function"&&Q instanceof HTMLElement||!Q.data)q=Q;else{let V=this.cachedCanvases.getCanvas("inlineImage",K,Z).context;q7(V,Q),q=this.applyTransferMapsToCanvas(V)}let G=this._scaleImage(q,l$(J));J.imageSmoothingEnabled=U7(U$(J),Q.interpolate),this.dependencyTracker?.resetBBox($).recordBBox($,J,0,K,-Z,0).recordDependencies($,u$.imageXObject).recordOperation($),B0(J,G.img,0,0,G.paintWidth,G.paintHeight,0,-Z,K,Z),this.compose(),this.restore($)}paintInlineImageXObjectGroup($,Q,K){if(!this.contentVisible)return;let Z=this.ctx,J;if(Q.bitmap)J=Q.bitmap;else{let{width:_,height:q}=Q,U=this.cachedCanvases.getCanvas("inlineImage",_,q).context;q7(U,Q),J=this.applyTransferMapsToCanvas(U)}this.dependencyTracker?.resetBBox($);for(let _ of K)Z.save(),Z.transform(..._.transform),Z.scale(1,-1),B0(Z,J,_.x,_.y,_.w,_.h,0,-1,1,1),this.dependencyTracker?.recordBBox($,Z,0,1,-1,0),Z.restore();this.dependencyTracker?.recordOperation($),this.compose()}paintSolidColorImageMask($){if(!this.contentVisible)return;this.dependencyTracker?.resetBBox($).recordBBox($,this.ctx,0,1,0,1).recordDependencies($,u$.fill).recordOperation($),this.ctx.fillRect(0,0,1,1),this.compose()}markPoint($,Q){}markPointProps($,Q,K){}beginMarkedContent($,Q){this.dependencyTracker?.beginMarkedContent($),this.markedContentStack.push({visible:!0})}beginMarkedContentProps($,Q,K){if(this.dependencyTracker?.beginMarkedContent($),Q==="OC")this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(K)});else this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent($){this.dependencyTracker?.endMarkedContent($),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat($){}endCompat($){}consumePath($,Q,K){let Z=this.current.isEmptyClip();if(this.pendingClip)this.current.updateClipFromPath();if(!this.pendingClip)this.compose(K);let J=this.ctx;if(this.pendingClip){if(!Z)if(this.pendingClip===V7)J.clip(Q,"evenodd");else J.clip(Q);this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation($).recordFutureForcedDependency("clipPath",$)}else this.dependencyTracker?.recordOperation($);this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let $=U$(this.ctx);if($[1]===0&&$[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs($[0]),Math.abs($[3]));else{let Q=Math.abs($[0]*$[3]-$[2]*$[1]),K=Math.hypot($[0],$[2]),Z=Math.hypot($[1],$[3]);this._cachedGetSinglePixelWidth=Math.max(K,Z)/Q}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){let{lineWidth:$}=this.current,{a:Q,b:K,c:Z,d:J}=this.ctx.getTransform(),_,q;if(K===0&&Z===0){let G=Math.abs(Q),U=Math.abs(J);if(G===U)if($===0)_=q=1/G;else{let V=G*$;_=q=V<1?1/V:1}else if($===0)_=1/G,q=1/U;else{let V=G*$,N=U*$;_=V<1?1/V:1,q=N<1?1/N:1}}else{let G=Math.abs(Q*J-K*Z),U=Math.hypot(Q,K),V=Math.hypot(Z,J);if($===0)_=V/G,q=U/G;else{let N=$*G;_=V>N?V/N:1,q=U>N?U/N:1}}this._cachedScaleForStroking[0]=_,this._cachedScaleForStroking[1]=q}return this._cachedScaleForStroking}rescaleAndStroke($,Q){let{ctx:K,current:{lineWidth:Z}}=this,[J,_]=this.getScaleForStroking();if(J===_){K.lineWidth=(Z||1)*J,K.stroke($);return}let q=K.getLineDash();if(Q)K.save();K.scale(J,_),s0.a=1/J,s0.d=1/_;let G=new Path2D;if(G.addPath($,s0),q.length>0){let U=Math.max(J,_);K.setLineDash(q.map((V)=>V/U)),K.lineDashOffset/=U}if(K.lineWidth=Z||1,K.stroke(G),Q)K.restore()}isContentVisible(){for(let $=this.markedContentStack.length-1;$>=0;$--)if(!this.markedContentStack[$].visible)return!1;return!0}}for(let $ in P$)if(MQ.prototype[$]!==void 0)MQ.prototype[P$[$]]=MQ.prototype[$];class WQ{#$;#Q;#Z;static strings=["fontFamily","fontWeight","italicAngle"];static write($){let Q=new TextEncoder,K={},Z=0;for(let U of WQ.strings){let V=Q.encode($[U]);K[U]=V,Z+=4+V.length}let J=new ArrayBuffer(Z),_=new Uint8Array(J),q=new DataView(J),G=0;for(let U of WQ.strings){let V=K[U],N=V.length;q.setUint32(G,N),_.set(V,G+4),G+=4+N}return i(G===J.byteLength,"CssFontInfo.write: Buffer overflow"),J}constructor($){this.#$=$,this.#Q=new DataView(this.#$),this.#Z=new TextDecoder}#K($){i($<WQ.strings.length,"Invalid string index");let Q=0;for(let Z=0;Z<$;Z++)Q+=this.#Q.getUint32(Q)+4;let K=this.#Q.getUint32(Q);return this.#Z.decode(new Uint8Array(this.#$,Q+4,K))}get fontFamily(){return this.#K(0)}get fontWeight(){return this.#K(1)}get italicAngle(){return this.#K(2)}}class XQ{#$;#Q;#Z;static strings=["css","loadedName","baseFontName","src"];static write($){let Q=new TextEncoder,K={},Z=0;for(let R of XQ.strings){let j=Q.encode($[R]);K[R]=j,Z+=4+j.length}Z+=4;let J,_,q=1+Z;if($.style)J=Q.encode($.style.style),_=Q.encode($.style.weight),q+=4+J.length+4+_.length;let G=new ArrayBuffer(q),U=new Uint8Array(G),V=new DataView(G),N=0;V.setUint8(N++,$.guessFallback?1:0),V.setUint32(N,0),N+=4,Z=0;for(let R of XQ.strings){let j=K[R],F=j.length;Z+=4+F,V.setUint32(N,F),U.set(j,N+4),N+=4+F}if(V.setUint32(N-Z-4,Z),$.style)V.setUint32(N,J.length),U.set(J,N+4),N+=4+J.length,V.setUint32(N,_.length),U.set(_,N+4),N+=4+_.length;return i(N<=G.byteLength,"SubstitionInfo.write: Buffer overflow"),G.transferToFixedLength(N)}constructor($){this.#$=$,this.#Q=new DataView(this.#$),this.#Z=new TextDecoder}get guessFallback(){return this.#Q.getUint8(0)!==0}#K($){i($<XQ.strings.length,"Invalid string index");let Q=5;for(let Z=0;Z<$;Z++)Q+=this.#Q.getUint32(Q)+4;let K=this.#Q.getUint32(Q);return this.#Z.decode(new Uint8Array(this.#$,Q+4,K))}get css(){return this.#K(0)}get loadedName(){return this.#K(1)}get baseFontName(){return this.#K(2)}get src(){return this.#K(3)}get style(){let $=1;$+=4+this.#Q.getUint32($);let Q=this.#Q.getUint32($),K=this.#Z.decode(new Uint8Array(this.#$,$+4,Q));$+=4+Q;let Z=this.#Q.getUint32($),J=this.#Z.decode(new Uint8Array(this.#$,$+4,Z));return{style:K,weight:J}}}class $${static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static#$=Math.ceil(this.bools.length*2/8);static#Q=this.#$+this.numbers.length*8;static#Z=this.#Q+1+8;static#K=this.#Z+1+48;static#q=this.#K+1+6;#J;#_;#G;constructor({data:$,extra:Q}){if(this.#J=$,this.#_=new TextDecoder,this.#G=new DataView(this.#J),Q)Object.assign(this,Q)}#V($){i($<$$.bools.length,"Invalid boolean index");let Q=Math.floor($/4),K=$*2%8,Z=this.#G.getUint8(Q)>>K&3;return Z===0?void 0:Z===2}get black(){return this.#V(0)}get bold(){return this.#V(1)}get disableFontFace(){return this.#V(2)}get fontExtraProperties(){return this.#V(3)}get isInvalidPDFjsFont(){return this.#V(4)}get isType3Font(){return this.#V(5)}get italic(){return this.#V(6)}get missingFile(){return this.#V(7)}get remeasure(){return this.#V(8)}get vertical(){return this.#V(9)}#U($){return i($<$$.numbers.length,"Invalid number index"),this.#G.getFloat64($$.#$+$*8)}get ascent(){return this.#U(0)}get defaultWidth(){return this.#U(1)}get descent(){return this.#U(2)}get bbox(){let $=$$.#Q;if(this.#G.getUint8($)===0)return;$+=1;let K=[];for(let Z=0;Z<4;Z++)K.push(this.#G.getInt16($,!0)),$+=2;return K}get fontMatrix(){let $=$$.#Z;if(this.#G.getUint8($)===0)return;$+=1;let K=[];for(let Z=0;Z<6;Z++)K.push(this.#G.getFloat64($,!0)),$+=8;return K}get defaultVMetrics(){let $=$$.#K;if(this.#G.getUint8($)===0)return;$+=1;let K=[];for(let Z=0;Z<3;Z++)K.push(this.#G.getInt16($,!0)),$+=2;return K}#j($){i($<$$.strings.length,"Invalid string index");let Q=$$.#q+4;for(let J=0;J<$;J++)Q+=this.#G.getUint32(Q)+4;let K=this.#G.getUint32(Q),Z=new Uint8Array(K);return Z.set(new Uint8Array(this.#J,Q+4,K)),this.#_.decode(Z)}get fallbackName(){return this.#j(0)}get loadedName(){return this.#j(1)}get mimetype(){return this.#j(2)}get name(){return this.#j(3)}get data(){let $=$$.#q,Q=this.#G.getUint32($);$+=4+Q;let K=this.#G.getUint32($);$+=4+K;let Z=this.#G.getUint32($);$+=4+Z;let J=this.#G.getUint32($);if(J===0)return;return new Uint8Array(this.#J,$+4,J)}clearData(){let $=$$.#q,Q=this.#G.getUint32($);$+=4+Q;let K=this.#G.getUint32($);$+=4+K;let Z=this.#G.getUint32($);$+=4+Z;let J=this.#G.getUint32($);new Uint8Array(this.#J,$+4,J).fill(0),this.#G.setUint32($,0)}get cssFontInfo(){let $=$$.#q,Q=this.#G.getUint32($);$+=4+Q;let K=this.#G.getUint32($);$+=4+K;let Z=this.#G.getUint32($);if(Z===0)return null;let J=new Uint8Array(Z);return J.set(new Uint8Array(this.#J,$+4,Z)),new WQ(J.buffer)}get systemFontInfo(){let $=$$.#q,Q=this.#G.getUint32($);$+=4+Q;let K=this.#G.getUint32($);if(K===0)return null;let Z=new Uint8Array(K);return Z.set(new Uint8Array(this.#J,$+4,K)),new XQ(Z.buffer)}static write($){let Q=$.systemFontInfo?XQ.write($.systemFontInfo):null,K=$.cssFontInfo?WQ.write($.cssFontInfo):null,Z=new TextEncoder,J={},_=0;for(let B of $$.strings)J[B]=Z.encode($[B]),_+=4+J[B].length;let q=$$.#q+4+_+4+(Q?Q.byteLength:0)+4+(K?K.byteLength:0)+4+($.data?$.data.length:0),G=new ArrayBuffer(q),U=new Uint8Array(G),V=new DataView(G),N=0,R=$$.bools.length,j=0,F=0;for(let B=0;B<R;B++){let A=$[$$.bools[B]];if(j|=(A===void 0?0:A?2:1)<<F,F+=2,F===8||B===R-1)V.setUint8(N++,j),j=0,F=0}i(N===$$.#$,"FontInfo.write: Boolean properties offset mismatch");for(let B of $$.numbers)V.setFloat64(N,$[B]),N+=8;if(i(N===$$.#Q,"FontInfo.write: Number properties offset mismatch"),$.bbox){V.setUint8(N++,4);for(let B of $.bbox)V.setInt16(N,B,!0),N+=2}else V.setUint8(N++,0),N+=8;if(i(N===$$.#Z,"FontInfo.write: BBox properties offset mismatch"),$.fontMatrix){V.setUint8(N++,6);for(let B of $.fontMatrix)V.setFloat64(N,B,!0),N+=8}else V.setUint8(N++,0),N+=48;if(i(N===$$.#K,"FontInfo.write: FontMatrix properties offset mismatch"),$.defaultVMetrics){V.setUint8(N++,1);for(let B of $.defaultVMetrics)V.setInt16(N,B,!0),N+=2}else V.setUint8(N++,0),N+=6;i(N===$$.#q,"FontInfo.write: DefaultVMetrics properties offset mismatch"),V.setUint32($$.#q,0),N+=4;for(let B of $$.strings){let A=J[B],z=A.length;V.setUint32(N,z),U.set(A,N+4),N+=4+z}if(V.setUint32($$.#q,N-$$.#q-4),!Q)V.setUint32(N,0),N+=4;else{let B=Q.byteLength;V.setUint32(N,B),i(N+4+B<=G.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),U.set(new Uint8Array(Q),N+4),N+=4+B}if(!K)V.setUint32(N,0),N+=4;else{let B=K.byteLength;V.setUint32(N,B),i(N+4+B<=G.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),U.set(new Uint8Array(K),N+4),N+=4+B}if($.data===void 0)V.setUint32(N,0),N+=4;else V.setUint32(N,$.data.length),U.set($.data,N+4),N+=4+$.data.length;return i(N<=G.byteLength,"FontInfo.write: Buffer overflow"),G.transferToFixedLength(N)}}class p${static#$=null;static#Q="";static get workerPort(){return this.#$}static set workerPort($){if(!(typeof Worker<"u"&&$ instanceof Worker)&&$!==null)throw Error("Invalid `workerPort` type.");this.#$=$}static get workerSrc(){return this.#Q}static set workerSrc($){if(typeof $!=="string")throw Error("Invalid `workerSrc` type.");this.#Q=$}}class r7{#$;#Q;constructor({parsedData:$,rawData:Q}){this.#$=$,this.#Q=Q}getRaw(){return this.#Q}get($){return this.#$.get($)??null}[Symbol.iterator](){return this.#$.entries()}}var TQ=Symbol("INTERNAL");class n7{#$=!1;#Q=!1;#Z=!1;#K=!0;constructor($,{name:Q,intent:K,usage:Z,rbGroups:J}){this.#$=!!($&v$.DISPLAY),this.#Q=!!($&v$.PRINT),this.name=Q,this.intent=K,this.usage=Z,this.rbGroups=J}get visible(){if(this.#Z)return this.#K;if(!this.#K)return!1;let{print:$,view:Q}=this.usage;if(this.#$)return Q?.viewState!=="OFF";else if(this.#Q)return $?.printState!=="OFF";return!0}_setVisible($,Q,K=!1){if($!==TQ)Z$("Internal method `_setVisible` called.");this.#Z=K,this.#K=Q}}class a7{#$=null;#Q=new Map;#Z=null;#K=null;constructor($,Q=v$.DISPLAY){if(this.renderingIntent=Q,this.name=null,this.creator=null,$===null)return;this.name=$.name,this.creator=$.creator,this.#K=$.order;for(let K of $.groups)this.#Q.set(K.id,new n7(Q,K));if($.baseState==="OFF")for(let K of this.#Q.values())K._setVisible(TQ,!1);for(let K of $.on)this.#Q.get(K)._setVisible(TQ,!0);for(let K of $.off)this.#Q.get(K)._setVisible(TQ,!1);this.#Z=this.getHash()}#q($){let Q=$.length;if(Q<2)return!0;let K=$[0];for(let Z=1;Z<Q;Z++){let J=$[Z],_;if(Array.isArray(J))_=this.#q(J);else if(this.#Q.has(J))_=this.#Q.get(J).visible;else return p(`Optional content group not found: ${J}`),!0;switch(K){case"And":if(!_)return!1;break;case"Or":if(_)return!0;break;case"Not":return!_;default:return!0}}return K==="And"}isVisible($){if(this.#Q.size===0)return!0;if(!$)return P0("Optional content group not defined."),!0;if($.type==="OCG"){if(!this.#Q.has($.id))return p(`Optional content group not found: ${$.id}`),!0;return this.#Q.get($.id).visible}else if($.type==="OCMD"){if($.expression)return this.#q($.expression);if(!$.policy||$.policy==="AnyOn"){for(let Q of $.ids){if(!this.#Q.has(Q))return p(`Optional content group not found: ${Q}`),!0;if(this.#Q.get(Q).visible)return!0}return!1}else if($.policy==="AllOn"){for(let Q of $.ids){if(!this.#Q.has(Q))return p(`Optional content group not found: ${Q}`),!0;if(!this.#Q.get(Q).visible)return!1}return!0}else if($.policy==="AnyOff"){for(let Q of $.ids){if(!this.#Q.has(Q))return p(`Optional content group not found: ${Q}`),!0;if(!this.#Q.get(Q).visible)return!0}return!1}else if($.policy==="AllOff"){for(let Q of $.ids){if(!this.#Q.has(Q))return p(`Optional content group not found: ${Q}`),!0;if(this.#Q.get(Q).visible)return!1}return!0}return p(`Unknown optional content policy ${$.policy}.`),!0}return p(`Unknown group type ${$.type}.`),!0}setVisibility($,Q=!0,K=!0){let Z=this.#Q.get($);if(!Z){p(`Optional content group not found: ${$}`);return}if(K&&Q&&Z.rbGroups.length){for(let J of Z.rbGroups)for(let _ of J)if(_!==$)this.#Q.get(_)?._setVisible(TQ,!1,!0)}Z._setVisible(TQ,!!Q,!0),this.#$=null}setOCGState({state:$,preserveRB:Q}){let K;for(let Z of $){switch(Z){case"ON":case"OFF":case"Toggle":K=Z;continue}let J=this.#Q.get(Z);if(!J)continue;switch(K){case"ON":this.setVisibility(Z,!0,Q);break;case"OFF":this.setVisibility(Z,!1,Q);break;case"Toggle":this.setVisibility(Z,!J.visible,Q);break}}this.#$=null}get hasInitialVisibility(){return this.#Z===null||this.getHash()===this.#Z}getOrder(){if(!this.#Q.size)return null;if(this.#K)return this.#K.slice();return[...this.#Q.keys()]}getGroup($){return this.#Q.get($)||null}getHash(){if(this.#$!==null)return this.#$;let $=new T6;for(let[Q,K]of this.#Q)$.update(`${Q}:${K.visible}`);return this.#$=$.hexdigest()}[Symbol.iterator](){return this.#Q.entries()}}class i7{constructor($,{disableRange:Q=!1,disableStream:K=!1}){i($,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:Z,initialData:J,progressiveDone:_,contentDispositionFilename:q}=$;if(this._queuedChunks=[],this._progressiveDone=_,this._contentDispositionFilename=q,J?.length>0){let G=J instanceof Uint8Array&&J.byteLength===J.buffer.byteLength?J.buffer:new Uint8Array(J).buffer;this._queuedChunks.push(G)}this._pdfDataRangeTransport=$,this._isStreamingSupported=!K,this._isRangeSupported=!Q,this._contentLength=Z,this._fullRequestReader=null,this._rangeReaders=[],$.addRangeListener((G,U)=>{this._onReceiveData({begin:G,chunk:U})}),$.addProgressListener((G,U)=>{this._onProgress({loaded:G,total:U})}),$.addProgressiveReadListener((G)=>{this._onReceiveData({chunk:G})}),$.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),$.transportReady()}_onReceiveData({begin:$,chunk:Q}){let K=Q instanceof Uint8Array&&Q.byteLength===Q.buffer.byteLength?Q.buffer:new Uint8Array(Q).buffer;if($===void 0)if(this._fullRequestReader)this._fullRequestReader._enqueue(K);else this._queuedChunks.push(K);else{let Z=this._rangeReaders.some(function(J){if(J._begin!==$)return!1;return J._enqueue(K),!0});i(Z,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress($){if($.total===void 0)this._rangeReaders[0]?.onProgress?.({loaded:$.loaded});else this._fullRequestReader?.onProgress?.({loaded:$.loaded,total:$.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader($){let Q=this._rangeReaders.indexOf($);if(Q>=0)this._rangeReaders.splice(Q,1)}getFullReader(){i(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let $=this._queuedChunks;return this._queuedChunks=null,new t7(this,$,this._progressiveDone,this._contentDispositionFilename)}getRangeReader($,Q){if(Q<=this._progressiveDataLength)return null;let K=new e7(this,$,Q);return this._pdfDataRangeTransport.requestDataRange($,Q),this._rangeReaders.push(K),K}cancelAllRequests($){this._fullRequestReader?.cancel($);for(let Q of this._rangeReaders.slice(0))Q.cancel($);this._pdfDataRangeTransport.abort()}}class t7{constructor($,Q,K=!1,Z=null){this._stream=$,this._done=K||!1,this._filename=D0(Z)?Z:null,this._queuedChunks=Q||[],this._loaded=0;for(let J of this._queuedChunks)this._loaded+=J.byteLength;this._requests=[],this._headersReady=Promise.resolve(),$._fullRequestReader=this,this.onProgress=null}_enqueue($){if(this._done)return;if(this._requests.length>0)this._requests.shift().resolve({value:$,done:!1});else this._queuedChunks.push($);this._loaded+=$.byteLength}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let $=Promise.withResolvers();return this._requests.push($),$.promise}cancel($){this._done=!0;for(let Q of this._requests)Q.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){if(this._done)return;this._done=!0}}class e7{constructor($,Q,K){this._stream=$,this._begin=Q,this._end=K,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue($){if(this._done)return;if(this._requests.length===0)this._queuedChunk=$;else{this._requests.shift().resolve({value:$,done:!1});for(let K of this._requests)K.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let Q=this._queuedChunk;return this._queuedChunk=null,{value:Q,done:!1}}if(this._done)return{value:void 0,done:!0};let $=Promise.withResolvers();return this._requests.push($),$.promise}cancel($){this._done=!0;for(let Q of this._requests)Q.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function LK($){let Q=!0,K=Z("filename\\*","i").exec($);if(K){K=K[1];let N=G(K);return N=unescape(N),N=U(N),N=V(N),_(N)}if(K=q($),K){let N=V(K);return _(N)}if(K=Z("filename","i").exec($),K){K=K[1];let N=G(K);return N=V(N),_(N)}function Z(N,R){return new RegExp("(?:^|;)\\s*"+N+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',R)}function J(N,R){if(N){if(!/^[\x00-\xFF]+$/.test(R))return R;try{let j=new TextDecoder(N,{fatal:!0}),F=eQ(R);R=j.decode(F),Q=!1}catch{}}return R}function _(N){if(Q&&/[\x80-\xff]/.test(N)){if(N=J("utf-8",N),Q)N=J("iso-8859-1",N)}return N}function q(N){let R=[],j,F=Z("filename\\*((?!0\\d)\\d+)(\\*?)","ig");while((j=F.exec(N))!==null){let[,A,z,O]=j;if(A=parseInt(A,10),A in R){if(A===0)break;continue}R[A]=[z,O]}let B=[];for(let A=0;A<R.length;++A){if(!(A in R))break;let[z,O]=R[A];if(O=G(O),z){if(O=unescape(O),A===0)O=U(O)}B.push(O)}return B.join("")}function G(N){if(N.startsWith('"')){let R=N.slice(1).split("\\\"");for(let j=0;j<R.length;++j){let F=R[j].indexOf('"');if(F!==-1)R[j]=R[j].slice(0,F),R.length=j+1;R[j]=R[j].replaceAll(/\\(.)/g,"$1")}N=R.join('"')}return N}function U(N){let R=N.indexOf("'");if(R===-1)return N;let j=N.slice(0,R),B=N.slice(R+1).replace(/^[^']*'/,"");return J(j,B)}function V(N){if(!N.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(N))return N;return N.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(R,j,F,B){if(F==="q"||F==="Q")return B=B.replaceAll("_"," "),B=B.replaceAll(/=([0-9a-fA-F]{2})/g,function(A,z){return String.fromCharCode(parseInt(z,16))}),J(j,B);try{B=atob(B)}catch{}return J(j,B)})}return""}function $8($,Q){let K=new Headers;if(!$||!Q||typeof Q!=="object")return K;for(let Z in Q){let J=Q[Z];if(J!==void 0)K.append(Z,J)}return K}function w0($){return URL.parse($)?.origin??null}function Q8({responseHeaders:$,isHttp:Q,rangeChunkSize:K,disableRange:Z}){let J={allowRangeRequests:!1,suggestedLength:void 0},_=parseInt($.get("Content-Length"),10);if(!Number.isInteger(_))return J;if(J.suggestedLength=_,_<=2*K)return J;if(Z||!Q)return J;if($.get("Accept-Ranges")!=="bytes")return J;if(($.get("Content-Encoding")||"identity")!=="identity")return J;return J.allowRangeRequests=!0,J}function K8($){let Q=$.get("Content-Disposition");if(Q){let K=LK(Q);if(K.includes("%"))try{K=decodeURIComponent(K)}catch{}if(D0(K))return K}return null}function J0($,Q){return new dQ(`Unexpected server response (${$}) while retrieving PDF "${Q}".`,$,$===404||$===0&&Q.startsWith("file:"))}function Z8($){return $===200||$===206}function J8($,Q,K){return{method:"GET",headers:$,signal:K.signal,mode:"cors",credentials:Q?"include":"same-origin",redirect:"follow"}}function _8($){if($ instanceof Uint8Array)return $.buffer;if($ instanceof ArrayBuffer)return $;return p(`getArrayBuffer - unexpected data format: ${$}`),new Uint8Array($).buffer}class q8{_responseOrigin=null;constructor($){this.source=$,this.isHttp=/^https?:/i.test($.url),this.headers=$8(this.isHttp,$.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return i(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new G8(this),this._fullRequestReader}getRangeReader($,Q){if(Q<=this._progressiveDataLength)return null;let K=new U8(this,$,Q);return this._rangeRequestReaders.push(K),K}cancelAllRequests($){this._fullRequestReader?.cancel($);for(let Q of this._rangeRequestReaders.slice(0))Q.cancel($)}}class G8{constructor($){this._stream=$,this._reader=null,this._loaded=0,this._filename=null;let Q=$.source;if(this._withCredentials=Q.withCredentials||!1,this._contentLength=Q.length,this._headersCapability=Promise.withResolvers(),this._disableRange=Q.disableRange||!1,this._rangeChunkSize=Q.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange)this._disableRange=!0;this._abortController=new AbortController,this._isStreamingSupported=!Q.disableStream,this._isRangeSupported=!Q.disableRange;let K=new Headers($.headers),Z=Q.url;fetch(Z,J8(K,this._withCredentials,this._abortController)).then((J)=>{if($._responseOrigin=w0(J.url),!Z8(J.status))throw J0(J.status,Z);this._reader=J.body.getReader(),this._headersCapability.resolve();let _=J.headers,{allowRangeRequests:q,suggestedLength:G}=Q8({responseHeaders:_,isHttp:$.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});if(this._isRangeSupported=q,this._contentLength=G||this._contentLength,this._filename=K8(_),!this._isStreamingSupported&&this._isRangeSupported)this.cancel(new KQ("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:$,done:Q}=await this._reader.read();if(Q)return{value:$,done:Q};return this._loaded+=$.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:_8($),done:!1}}cancel($){this._reader?.cancel($),this._abortController.abort()}}class U8{constructor($,Q,K){this._stream=$,this._reader=null,this._loaded=0;let Z=$.source;this._withCredentials=Z.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!Z.disableStream,this._abortController=new AbortController;let J=new Headers($.headers);J.append("Range",`bytes=${Q}-${K-1}`);let _=Z.url;fetch(_,J8(J,this._withCredentials,this._abortController)).then((q)=>{let G=w0(q.url);if(G!==$._responseOrigin)throw Error(`Expected range response-origin "${G}" to match "${$._responseOrigin}".`);if(!Z8(q.status))throw J0(q.status,_);this._readCapability.resolve(),this._reader=q.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:$,done:Q}=await this._reader.read();if(Q)return{value:$,done:Q};return this._loaded+=$.byteLength,this.onProgress?.({loaded:this._loaded}),{value:_8($),done:!1}}cancel($){this._reader?.cancel($),this._abortController.abort()}}var o0=200,r0=206;function PK($){let Q=$.response;if(typeof Q!=="string")return Q;return eQ(Q).buffer}class V8{_responseOrigin=null;constructor({url:$,httpHeaders:Q,withCredentials:K}){this.url=$,this.isHttp=/^https?:/i.test($),this.headers=$8(this.isHttp,Q),this.withCredentials=K||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request($){let Q=new XMLHttpRequest,K=this.currXhrId++,Z=this.pendingRequests[K]={xhr:Q};Q.open("GET",this.url),Q.withCredentials=this.withCredentials;for(let[J,_]of this.headers)Q.setRequestHeader(J,_);if(this.isHttp&&"begin"in $&&"end"in $)Q.setRequestHeader("Range",`bytes=${$.begin}-${$.end-1}`),Z.expectedStatus=r0;else Z.expectedStatus=o0;return Q.responseType="arraybuffer",i($.onError,"Expected `onError` callback to be provided."),Q.onerror=()=>{$.onError(Q.status)},Q.onreadystatechange=this.onStateChange.bind(this,K),Q.onprogress=this.onProgress.bind(this,K),Z.onHeadersReceived=$.onHeadersReceived,Z.onDone=$.onDone,Z.onError=$.onError,Z.onProgress=$.onProgress,Q.send(null),K}onProgress($,Q){let K=this.pendingRequests[$];if(!K)return;K.onProgress?.(Q)}onStateChange($,Q){let K=this.pendingRequests[$];if(!K)return;let Z=K.xhr;if(Z.readyState>=2&&K.onHeadersReceived)K.onHeadersReceived(),delete K.onHeadersReceived;if(Z.readyState!==4)return;if(!($ in this.pendingRequests))return;if(delete this.pendingRequests[$],Z.status===0&&this.isHttp){K.onError(Z.status);return}let J=Z.status||o0;if(!(J===o0&&K.expectedStatus===r0)&&J!==K.expectedStatus){K.onError(Z.status);return}let q=PK(Z);if(J===r0){let G=Z.getResponseHeader("Content-Range"),U=/bytes (\d+)-(\d+)\/(\d+)/.exec(G);if(U)K.onDone({begin:parseInt(U[1],10),chunk:q});else p('Missing or invalid "Content-Range" header.'),K.onError(0)}else if(q)K.onDone({begin:0,chunk:q});else K.onError(Z.status)}getRequestXhr($){return this.pendingRequests[$].xhr}isPendingRequest($){return $ in this.pendingRequests}abortRequest($){let Q=this.pendingRequests[$].xhr;delete this.pendingRequests[$],Q.abort()}}class N8{constructor($){this._source=$,this._manager=new V8($),this._rangeChunkSize=$.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed($){let Q=this._rangeRequestReaders.indexOf($);if(Q>=0)this._rangeRequestReaders.splice(Q,1)}getFullReader(){return i(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new R8(this._manager,this._source),this._fullRequestReader}getRangeReader($,Q){let K=new j8(this._manager,$,Q);return K.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(K),K}cancelAllRequests($){this._fullRequestReader?.cancel($);for(let Q of this._rangeRequestReaders.slice(0))Q.cancel($)}}class R8{constructor($,Q){if(this._manager=$,this._url=Q.url,this._fullRequestId=$.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=Q.disableRange||!1,this._contentLength=Q.length,this._rangeChunkSize=Q.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange)this._disableRange=!0;this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let $=this._fullRequestId,Q=this._manager.getRequestXhr($);this._manager._responseOrigin=w0(Q.responseURL);let K=Q.getAllResponseHeaders(),Z=new Headers(K?K.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((q)=>{let[G,...U]=q.split(": ");return[G,U.join(": ")]}):[]),{allowRangeRequests:J,suggestedLength:_}=Q8({responseHeaders:Z,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});if(J)this._isRangeSupported=!0;if(this._contentLength=_||this._contentLength,this._filename=K8(Z),this._isRangeSupported)this._manager.abortRequest($);this._headersCapability.resolve()}_onDone($){if($)if(this._requests.length>0)this._requests.shift().resolve({value:$.chunk,done:!1});else this._cachedChunks.push($.chunk);if(this._done=!0,this._cachedChunks.length>0)return;for(let Q of this._requests)Q.resolve({value:void 0,done:!0});this._requests.length=0}_onError($){this._storedError=J0($,this._url),this._headersCapability.reject(this._storedError);for(let Q of this._requests)Q.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress($){this.onProgress?.({loaded:$.loaded,total:$.lengthComputable?$.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let $=Promise.withResolvers();return this._requests.push($),$.promise}cancel($){this._done=!0,this._headersCapability.reject($);for(let Q of this._requests)Q.resolve({value:void 0,done:!0});if(this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId))this._manager.abortRequest(this._fullRequestId);this._fullRequestReader=null}}class j8{constructor($,Q,K){this._manager=$,this._url=$.url,this._requestId=$.request({begin:Q,end:K,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let $=w0(this._manager.getRequestXhr(this._requestId)?.responseURL);if($!==this._manager._responseOrigin)this._storedError=Error(`Expected range response-origin "${$}" to match "${this._manager._responseOrigin}".`),this._onError(0)}_close(){this.onClosed?.(this)}_onDone($){let Q=$.chunk;if(this._requests.length>0)this._requests.shift().resolve({value:Q,done:!1});else this._queuedChunk=Q;this._done=!0;for(let K of this._requests)K.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError($){this._storedError??=J0($,this._url);for(let Q of this._requests)Q.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress($){if(!this.isStreamingSupported)this.onProgress?.({loaded:$.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){let Q=this._queuedChunk;return this._queuedChunk=null,{value:Q,done:!1}}if(this._done)return{value:void 0,done:!0};let $=Promise.withResolvers();return this._requests.push($),$.promise}cancel($){this._done=!0;for(let Q of this._requests)Q.resolve({value:void 0,done:!0});if(this._requests.length=0,this._manager.isPendingRequest(this._requestId))this._manager.abortRequest(this._requestId);this._close()}}var HK=/^[a-z][a-z0-9\-+.]+:/i;function DK($){if(HK.test($))return new URL($);let Q=process.getBuiltinModule("url");return new URL(Q.pathToFileURL($))}class B8{constructor($){this.source=$,this.url=DK($.url),i(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return i(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new F8(this),this._fullRequestReader}getRangeReader($,Q){if(Q<=this._progressiveDataLength)return null;let K=new A8(this,$,Q);return this._rangeRequestReaders.push(K),K}cancelAllRequests($){this._fullRequestReader?.cancel($);for(let Q of this._rangeRequestReaders.slice(0))Q.cancel($)}}class F8{constructor($){this._url=$.url,this._done=!1,this._storedError=null,this.onProgress=null;let Q=$.source;if(this._contentLength=Q.length,this._loaded=0,this._filename=null,this._disableRange=Q.disableRange||!1,this._rangeChunkSize=Q.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange)this._disableRange=!0;this._isStreamingSupported=!Q.disableStream,this._isRangeSupported=!Q.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();let K=process.getBuiltinModule("fs");K.promises.lstat(this._url).then((Z)=>{this._contentLength=Z.size,this._setReadableStream(K.createReadStream(this._url)),this._headersCapability.resolve()},(Z)=>{if(Z.code==="ENOENT")Z=J0(0,this._url.href);this._storedError=Z,this._headersCapability.reject(Z)})}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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let $=this._readableStream.read();if($===null)return this._readCapability=Promise.withResolvers(),this.read();return this._loaded+=$.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array($).buffer,done:!1}}cancel($){if(!this._readableStream){this._error($);return}this._readableStream.destroy($)}_error($){this._storedError=$,this._readCapability.resolve()}_setReadableStream($){if(this._readableStream=$,$.on("readable",()=>{this._readCapability.resolve()}),$.on("end",()=>{$.destroy(),this._done=!0,this._readCapability.resolve()}),$.on("error",(Q)=>{this._error(Q)}),!this._isStreamingSupported&&this._isRangeSupported)this._error(new KQ("streaming is disabled"));if(this._storedError)this._readableStream.destroy(this._storedError)}}class A8{constructor($,Q,K){this._url=$.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let Z=$.source;this._isStreamingSupported=!Z.disableStream;let J=process.getBuiltinModule("fs");this._setReadableStream(J.createReadStream(this._url,{start:Q,end:K-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let $=this._readableStream.read();if($===null)return this._readCapability=Promise.withResolvers(),this.read();return this._loaded+=$.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array($).buffer,done:!1}}cancel($){if(!this._readableStream){this._error($);return}this._readableStream.destroy($)}_error($){this._storedError=$,this._readCapability.resolve()}_setReadableStream($){if(this._readableStream=$,$.on("readable",()=>{this._readCapability.resolve()}),$.on("end",()=>{$.destroy(),this._done=!0,this._readCapability.resolve()}),$.on("error",(Q)=>{this._error(Q)}),this._storedError)this._readableStream.destroy(this._storedError)}}var bQ=Symbol("INITIAL_DATA");class L6{#$=Object.create(null);#Q($){return this.#$[$]||={...Promise.withResolvers(),data:bQ}}get($,Q=null){if(Q){let Z=this.#Q($);return Z.promise.then(()=>Q(Z.data)),null}let K=this.#$[$];if(!K||K.data===bQ)throw Error(`Requesting object that isn't resolved yet ${$}.`);return K.data}has($){let Q=this.#$[$];return!!Q&&Q.data!==bQ}delete($){let Q=this.#$[$];if(!Q||Q.data===bQ)return!1;return delete this.#$[$],!0}resolve($,Q=null){let K=this.#Q($);K.data=Q,K.resolve()}clear(){for(let $ in this.#$){let{data:Q}=this.#$[$];Q?.bitmap?.close()}this.#$=Object.create(null)}*[Symbol.iterator](){for(let $ in this.#$){let{data:Q}=this.#$[$];if(Q===bQ)continue;yield[$,Q]}}}var vK=1e5,N7=30;class W${#$=Promise.withResolvers();#Q=null;#Z=!1;#K=!!globalThis.FontInspector?.enabled;#q=null;#J=null;#_=0;#G=0;#V=null;#U=null;#j=0;#R=0;#B=Object.create(null);#z=[];#F=null;#N=[];#A=new WeakMap;#O=null;static#T=new Map;static#S=new Map;static#W=new WeakMap;static#E=null;static#I=new Set;constructor({textContentSource:$,container:Q,viewport:K}){if($ instanceof ReadableStream)this.#F=$;else if(typeof $==="object")this.#F=new ReadableStream({start(G){G.enqueue($),G.close()}});else throw Error('No "textContentSource" parameter specified.');this.#Q=this.#U=Q,this.#R=K.scale*d$.pixelRatio,this.#j=K.rotation,this.#J={div:null,properties:null,ctx:null};let{pageWidth:Z,pageHeight:J,pageX:_,pageY:q}=K.rawDims;this.#O=[1,0,0,-1,-_,q+J],this.#G=Z,this.#_=J,W$.#P(),GQ(Q,K),this.#$.promise.finally(()=>{W$.#I.delete(this),this.#J=null,this.#B=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:$,isFirefox:Q}=S$.platform;return r(this,"fontFamilyMap",new Map([["sans-serif",`${$&&Q?"Calibri, ":""}sans-serif`],["monospace",`${$&&Q?"Lucida Console, ":""}monospace`]]))}render(){let $=()=>{this.#V.read().then(({value:Q,done:K})=>{if(K){this.#$.resolve();return}this.#q??=Q.lang,Object.assign(this.#B,Q.styles),this.#Y(Q.items),$()},this.#$.reject)};return this.#V=this.#F.getReader(),W$.#I.add(this),$(),this.#$.promise}update({viewport:$,onBefore:Q=null}){let K=$.scale*d$.pixelRatio,Z=$.rotation;if(Z!==this.#j)Q?.(),this.#j=Z,GQ(this.#U,{rotation:Z});if(K!==this.#R){Q?.(),this.#R=K;let J={div:null,properties:null,ctx:W$.#H(this.#q)};for(let _ of this.#N)J.properties=this.#A.get(_),J.div=_,this.#M(J)}}cancel(){let $=new KQ("TextLayer task cancelled.");this.#V?.cancel($).catch(()=>{}),this.#V=null,this.#$.reject($)}get textDivs(){return this.#N}get textContentItemsStr(){return this.#z}#Y($){if(this.#Z)return;this.#J.ctx??=W$.#H(this.#q);let Q=this.#N,K=this.#z;for(let Z of $){if(Q.length>vK){p("Ignoring additional textDivs for performance reasons."),this.#Z=!0;return}if(Z.str===void 0){if(Z.type==="beginMarkedContentProps"||Z.type==="beginMarkedContent"){let J=this.#Q;if(this.#Q=document.createElement("span"),this.#Q.classList.add("markedContent"),Z.id)this.#Q.setAttribute("id",`${Z.id}`);J.append(this.#Q)}else if(Z.type==="endMarkedContent")this.#Q=this.#Q.parentNode;continue}K.push(Z.str),this.#k(Z)}}#k($){let Q=document.createElement("span"),K={angle:0,canvasWidth:0,hasText:$.str!=="",hasEOL:$.hasEOL,fontSize:0};this.#N.push(Q);let Z=x.transform(this.#O,$.transform),J=Math.atan2(Z[1],Z[0]),_=this.#B[$.fontName];if(_.vertical)J+=Math.PI/2;let q=this.#K&&_.fontSubstitution||_.fontFamily;q=W$.fontFamilyMap.get(q)||q;let G=Math.hypot(Z[2],Z[3]),U=G*W$.#x(q,_,this.#q),V,N;if(J===0)V=Z[4],N=Z[5]-U;else V=Z[4]+U*Math.sin(J),N=Z[5]-U*Math.cos(J);let R="calc(var(--total-scale-factor) *",j=Q.style;if(this.#Q===this.#U)j.left=`${(100*V/this.#G).toFixed(2)}%`,j.top=`${(100*N/this.#_).toFixed(2)}%`;else j.left=`${R}${V.toFixed(2)}px)`,j.top=`${R}${N.toFixed(2)}px)`;if(j.fontSize=`${R}${(W$.#E*G).toFixed(2)}px)`,j.fontFamily=q,K.fontSize=G,Q.setAttribute("role","presentation"),Q.textContent=$.str,Q.dir=$.dir,this.#K)Q.dataset.fontName=_.fontSubstitutionLoadedName||$.fontName;if(J!==0)K.angle=J*(180/Math.PI);let F=!1;if($.str.length>1)F=!0;else if($.str!==" "&&$.transform[0]!==$.transform[3]){let B=Math.abs($.transform[0]),A=Math.abs($.transform[3]);if(B!==A&&Math.max(B,A)/Math.min(B,A)>1.5)F=!0}if(F)K.canvasWidth=_.vertical?$.height:$.width;if(this.#A.set(Q,K),this.#J.div=Q,this.#J.properties=K,this.#M(this.#J),K.hasText)this.#Q.append(Q);if(K.hasEOL){let B=document.createElement("br");B.setAttribute("role","presentation"),this.#Q.append(B)}}#M($){let{div:Q,properties:K,ctx:Z}=$,{style:J}=Q,_="";if(W$.#E>1)_=`scale(${1/W$.#E})`;if(K.canvasWidth!==0&&K.hasText){let{fontFamily:q}=J,{canvasWidth:G,fontSize:U}=K;W$.#L(Z,U*this.#R,q);let{width:V}=Z.measureText(Q.textContent);if(V>0)_=`scaleX(${G*this.#R/V}) ${_}`}if(K.angle!==0)_=`rotate(${K.angle}deg) ${_}`;if(_.length>0)J.transform=_}static cleanup(){if(this.#I.size>0)return;this.#T.clear();for(let{canvas:$}of this.#S.values())$.remove();this.#S.clear()}static#H($=null){let Q=this.#S.get($||="");if(!Q){let K=document.createElement("canvas");K.className="hiddenCanvasElement",K.lang=$,document.body.append(K),Q=K.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#S.set($,Q),this.#W.set(Q,{size:0,family:""})}return Q}static#L($,Q,K){let Z=this.#W.get($);if(Q===Z.size&&K===Z.family)return;$.font=`${Q}px ${K}`,Z.size=Q,Z.family=K}static#P(){if(this.#E!==null)return;let $=document.createElement("div");$.style.opacity=0,$.style.lineHeight=1,$.style.fontSize="1px",$.style.position="absolute",$.textContent="X",document.body.append($),this.#E=$.getBoundingClientRect().height,$.remove()}static#x($,Q,K){let Z=this.#T.get($);if(Z)return Z;let J=this.#H(K);J.canvas.width=J.canvas.height=N7,this.#L(J,N7,$);let _=J.measureText(""),q=_.fontBoundingBoxAscent,G=Math.abs(_.fontBoundingBoxDescent);J.canvas.width=J.canvas.height=0;let U=0.8;if(q)U=q/(q+G);else{if(S$.platform.isFirefox)p("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering.");if(Q.ascent)U=Q.ascent;else if(Q.descent)U=1+Q.descent}return this.#T.set($,U),U}}var fK=100;function P6($={}){if(typeof $==="string"||$ instanceof URL)$={url:$};else if($ instanceof ArrayBuffer||ArrayBuffer.isView($))$={data:$};let Q=new H6,{docId:K}=Q,Z=$.url?OK($.url):null,J=$.data?SK($.data):null,_=$.httpHeaders||null,q=$.withCredentials===!0,G=$.password??null,U=$.range instanceof b0?$.range:null,V=Number.isInteger($.rangeChunkSize)&&$.rangeChunkSize>0?$.rangeChunkSize:65536,N=$.worker instanceof C0?$.worker:null,R=$.verbosity,j=typeof $.docBaseUrl==="string"&&!K0($.docBaseUrl)?$.docBaseUrl:null,F=V0($.cMapUrl),B=$.cMapPacked!==!1,A=$.CMapReaderFactory||(L$?u7:Q6),z=V0($.iccUrl),O=V0($.standardFontDataUrl),S=$.StandardFontDataFactory||(L$?m7:K6),I=V0($.wasmUrl),C=$.WasmFactory||(L$?h7:Z6),T=$.stopAtErrors!==!0,k=Number.isInteger($.maxImageSize)&&$.maxImageSize>-1?$.maxImageSize:-1,E=$.isEvalSupported!==!1,M=typeof $.isOffscreenCanvasSupported==="boolean"?$.isOffscreenCanvasSupported:!L$,W=typeof $.isImageDecoderSupported==="boolean"?$.isImageDecoderSupported:!L$&&(S$.platform.isFirefox||!globalThis.chrome),X=Number.isInteger($.canvasMaxAreaInBytes)?$.canvasMaxAreaInBytes:-1,Y=typeof $.disableFontFace==="boolean"?$.disableFontFace:L$,y=$.fontExtraProperties===!0,D=$.enableXfa===!0,b=$.ownerDocument||globalThis.document,H=$.disableRange===!0,P=$.disableStream===!0,v=$.disableAutoFetch===!0,u=$.pdfBug===!0,a=$.CanvasFactory||(L$?c7:b7),Q$=$.FilterFactory||(L$?x7:y7),G$=$.enableHWA===!0,t=$.useWasm!==!1,e=U?U.length:$.length??NaN,q$=typeof $.useSystemFonts==="boolean"?$.useSystemFonts:!L$&&!Y,k$=typeof $.useWorkerFetch==="boolean"?$.useWorkerFetch:!!(A===Q6&&S===K6&&C===Z6&&F&&O&&I&&uQ(F,document.baseURI)&&uQ(O,document.baseURI)&&uQ(I,document.baseURI)),f=null;_K(R);let L={canvasFactory:new a({ownerDocument:b,enableHWA:G$}),filterFactory:new Q$({docId:K,ownerDocument:b}),cMapReaderFactory:k$?null:new A({baseUrl:F,isCompressed:B}),standardFontDataFactory:k$?null:new S({baseUrl:O}),wasmFactory:k$?null:new C({baseUrl:I})};if(!N)N=C0.create({verbosity:R,port:p$.workerPort}),Q._worker=N;let w={docId:K,apiVersion:"5.4.296",data:J,password:G,disableAutoFetch:v,rangeChunkSize:V,length:e,docBaseUrl:j,enableXfa:D,evaluatorOptions:{maxImageSize:k,disableFontFace:Y,ignoreErrors:T,isEvalSupported:E,isOffscreenCanvasSupported:M,isImageDecoderSupported:W,canvasMaxAreaInBytes:X,fontExtraProperties:y,useSystemFonts:q$,useWasm:t,useWorkerFetch:k$,cMapUrl:F,iccUrl:z,standardFontDataUrl:O,wasmUrl:I}},o={ownerDocument:b,pdfBug:u,styleElement:f,loadingParams:{disableAutoFetch:v,enableXfa:D}};return N.promise.then(function(){if(Q.destroyed)throw Error("Loading aborted");if(N.destroyed)throw Error("Worker was destroyed");let K$=N.messageHandler.sendWithPromise("GetDocRequest",w,J?[J.buffer]:null),h;if(U)h=new i7(U,{disableRange:H,disableStream:P});else if(!J){if(!Z)throw Error("getDocument - no `url` parameter provided.");h=new((uQ(Z))?q8:L$?B8:N8)({url:Z,length:e,httpHeaders:_,withCredentials:q,rangeChunkSize:V,disableRange:H,disableStream:P})}return K$.then((J$)=>{if(Q.destroyed)throw Error("Loading aborted");if(N.destroyed)throw Error("Worker was destroyed");let _$=new LQ(K,J$,N.port),x$=new S8(_$,Q,h,o,L,G$);Q._transport=x$,_$.send("Ready",null)})}).catch(Q._capability.reject),Q}class H6{static#$=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${H6.#$++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{if(this._worker?.port)this._worker._pendingDestroy=!0;await this._transport?.destroy()}catch($){if(this._worker?.port)delete this._worker._pendingDestroy;throw $}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class b0{#$=Promise.withResolvers();#Q=[];#Z=[];#K=[];#q=[];constructor($,Q,K=!1,Z=null){this.length=$,this.initialData=Q,this.progressiveDone=K,this.contentDispositionFilename=Z}addRangeListener($){this.#q.push($)}addProgressListener($){this.#K.push($)}addProgressiveReadListener($){this.#Z.push($)}addProgressiveDoneListener($){this.#Q.push($)}onDataRange($,Q){for(let K of this.#q)K($,Q)}onDataProgress($,Q){this.#$.promise.then(()=>{for(let K of this.#K)K($,Q)})}onDataProgressiveRead($){this.#$.promise.then(()=>{for(let Q of this.#Z)Q($)})}onDataProgressiveDone(){this.#$.promise.then(()=>{for(let $ of this.#Q)$()})}transportReady(){this.#$.resolve()}requestDataRange($,Q){Z$("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class z8{constructor($,Q){this._pdfInfo=$,this._transport=Q}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 r(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage($){return this._transport.getPage($)}getPageIndex($){return this._transport.getPageIndex($)}getDestinations(){return this._transport.getDestinations()}getDestination($){return this._transport.getDestination($)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType($,Q){return this._transport.getAnnotationsByType($,Q)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:$="display"}={}){let{renderingIntent:Q}=this._transport.getRenderingIntent($);return this._transport.getOptionalContentConfig(Q)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup($=!1){return this._transport.startCleanup($||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber($){return this._transport.cachedPageNumber($)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class O8{#$=!1;constructor($,Q,K,Z=!1){this._pageIndex=$,this._pageInfo=Q,this._transport=K,this._stats=Z?new i0:null,this._pdfBug=Z,this.commonObjs=K.commonObjs,this.objs=new L6,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:$,rotation:Q=this.rotate,offsetX:K=0,offsetY:Z=0,dontFlip:J=!1}={}){return new $0({viewBox:this.view,userUnit:this.userUnit,scale:$,rotation:Q,offsetX:K,offsetY:Z,dontFlip:J})}getAnnotations({intent:$="display"}={}){let{renderingIntent:Q}=this._transport.getRenderingIntent($);return this._transport.getAnnotations(this._pageIndex,Q)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return r(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:$,canvas:Q=$.canvas,viewport:K,intent:Z="display",annotationMode:J=QQ.ENABLE,transform:_=null,background:q=null,optionalContentConfigPromise:G=null,annotationCanvasMap:U=null,pageColors:V=null,printAnnotationStorage:N=null,isEditing:R=!1,recordOperations:j=!1,operationsFilter:F=null}){this._stats?.time("Overall");let B=this._transport.getRenderingIntent(Z,J,N,R),{renderingIntent:A,cacheKey:z}=B;this.#$=!1,G||=this._transport.getOptionalContentConfig(A);let O=this._intentStates.get(z);if(!O)O=Object.create(null),this._intentStates.set(z,O);if(O.streamReaderCancelTimeout)clearTimeout(O.streamReaderCancelTimeout),O.streamReaderCancelTimeout=null;let S=!!(A&v$.PRINT);if(!O.displayReadyCapability)O.displayReadyCapability=Promise.withResolvers(),O.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(B);let I=Boolean(this._pdfBug&&globalThis.StepperManager?.enabled),C=!this.recordedBBoxes&&(j||I),T=(M)=>{if(O.renderTasks.delete(k),C){let W=k.gfx?.dependencyTracker.take();if(W){if(k.stepper)k.stepper.setOperatorBBoxes(W,k.gfx.dependencyTracker.takeDebugMetadata());if(j)this.recordedBBoxes=W}}if(S)this.#$=!0;if(this.#Q(),M)k.capability.reject(M),this._abortOperatorList({intentState:O,reason:M instanceof Error?M:Error(M)});else k.capability.resolve();if(this._stats){if(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled)globalThis.Stats.add(this.pageNumber,this._stats)}},k=new kQ({callback:T,params:{canvas:Q,canvasContext:$,dependencyTracker:C?new p7(Q,O.operatorList.length,I):null,viewport:K,transform:_,background:q},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:U,operatorList:O.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!S,pdfBug:this._pdfBug,pageColors:V,enableHWA:this._transport.enableHWA,operationsFilter:F});(O.renderTasks||=new Set).add(k);let E=k.task;return Promise.all([O.displayReadyCapability.promise,G]).then(([M,W])=>{if(this.destroyed){T();return}if(this._stats?.time("Rendering"),!(W.renderingIntent&A))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");k.initializeGraphics({transparency:M,optionalContentConfig:W}),k.operatorListChanged()}).catch(T),E}getOperatorList({intent:$="display",annotationMode:Q=QQ.ENABLE,printAnnotationStorage:K=null,isEditing:Z=!1}={}){function J(){if(q.operatorList.lastChunk)q.opListReadCapability.resolve(q.operatorList),q.renderTasks.delete(G)}let _=this._transport.getRenderingIntent($,Q,K,Z,!0),q=this._intentStates.get(_.cacheKey);if(!q)q=Object.create(null),this._intentStates.set(_.cacheKey,q);let G;if(!q.opListReadCapability)G=Object.create(null),G.operatorListChanged=J,q.opListReadCapability=Promise.withResolvers(),(q.renderTasks||=new Set).add(G),q.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(_);return q.opListReadCapability.promise}streamTextContent({includeMarkedContent:$=!1,disableNormalization:Q=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:$===!0,disableNormalization:Q===!0},{highWaterMark:100,size(Z){return Z.items.length}})}getTextContent($={}){if(this._transport._htmlForXfa)return this.getXfa().then((K)=>lQ.textContent(K));let Q=this.streamTextContent($);return new Promise(function(K,Z){function J(){_.read().then(function({value:G,done:U}){if(U){K(q);return}q.lang??=G.lang,Object.assign(q.styles,G.styles),q.items.push(...G.items),J()},Z)}let _=Q.getReader(),q={items:[],styles:Object.create(null),lang:null};J()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let $=[];for(let Q of this._intentStates.values()){if(this._abortOperatorList({intentState:Q,reason:Error("Page was destroyed."),force:!0}),Q.opListReadCapability)continue;for(let K of Q.renderTasks)$.push(K.completed),K.cancel()}return this.objs.clear(),this.#$=!1,Promise.all($)}cleanup($=!1){this.#$=!0;let Q=this.#Q();if($&&Q)this._stats&&=new i0;return Q}#Q(){if(!this.#$||this.destroyed)return!1;for(let{renderTasks:$,operatorList:Q}of this._intentStates.values())if($.size>0||!Q.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#$=!1,!0}_startRenderPage($,Q){let K=this._intentStates.get(Q);if(!K)return;this._stats?.timeEnd("Page Request"),K.displayReadyCapability?.resolve($)}_renderPageChunk($,Q){for(let K=0,Z=$.length;K<Z;K++)Q.operatorList.fnArray.push($.fnArray[K]),Q.operatorList.argsArray.push($.argsArray[K]);Q.operatorList.lastChunk=$.lastChunk,Q.operatorList.separateAnnots=$.separateAnnots;for(let K of Q.renderTasks)K.operatorListChanged();if($.lastChunk)this.#Q()}_pumpOperatorList({renderingIntent:$,cacheKey:Q,annotationStorageSerializable:K,modifiedIds:Z}){let{map:J,transfer:_}=K,G=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:$,cacheKey:Q,annotationStorage:J,modifiedIds:Z},_).getReader(),U=this._intentStates.get(Q);U.streamReader=G;let V=()=>{G.read().then(({value:N,done:R})=>{if(R){U.streamReader=null;return}if(this._transport.destroyed)return;this._renderPageChunk(N,U),V()},(N)=>{if(U.streamReader=null,this._transport.destroyed)return;if(U.operatorList){U.operatorList.lastChunk=!0;for(let R of U.renderTasks)R.operatorListChanged();this.#Q()}if(U.displayReadyCapability)U.displayReadyCapability.reject(N);else if(U.opListReadCapability)U.opListReadCapability.reject(N);else throw N})};V()}_abortOperatorList({intentState:$,reason:Q,force:K=!1}){if(!$.streamReader)return;if($.streamReaderCancelTimeout)clearTimeout($.streamReaderCancelTimeout),$.streamReaderCancelTimeout=null;if(!K){if($.renderTasks.size>0)return;if(Q instanceof Q0){let Z=fK;if(Q.extraDelay>0&&Q.extraDelay<1000)Z+=Q.extraDelay;$.streamReaderCancelTimeout=setTimeout(()=>{$.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:$,reason:Q,force:!0})},Z);return}}if($.streamReader.cancel(new KQ(Q.message)).catch(()=>{}),$.streamReader=null,this._transport.destroyed)return;for(let[Z,J]of this._intentStates)if(J===$){this._intentStates.delete(Z);break}this.cleanup()}get stats(){return this._stats}}var O$=class ${constructor({name:Q=null,port:K=null,verbosity:Z=qK()}={}){if(e$(this,g$),e$(this,RQ,Promise.withResolvers()),e$(this,a$,null),e$(this,_Q,null),e$(this,EQ,null),this.name=Q,this.destroyed=!1,this.verbosity=Z,K){if(V$($,IQ).has(K))throw Error("Cannot use more than one PDFWorker per port.");V$($,IQ).set(K,this),$Q(this,g$,B7).call(this,K)}else $Q(this,g$,F7).call(this)}get promise(){return V$(this,RQ).promise}get port(){return V$(this,_Q)}get messageHandler(){return V$(this,a$)}destroy(){this.destroyed=!0,V$(this,EQ)?.terminate(),b$(this,EQ,null),V$($,IQ).delete(V$(this,_Q)),b$(this,_Q,null),V$(this,a$)?.destroy(),b$(this,a$,null)}static create(Q){let K=V$(this,IQ).get(Q?.port);if(K){if(K._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return K}return new $(Q)}static get workerSrc(){if(p$.workerSrc)return p$.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return r(this,"_setupFakeWorkerGlobal",(async()=>{if(V$(this,gQ,O0))return V$(this,gQ,O0);return(await import(this.workerSrc)).WorkerMessageHandler})())}};RQ=new WeakMap;a$=new WeakMap;_Q=new WeakMap;EQ=new WeakMap;N6=new WeakMap;YQ=new WeakMap;IQ=new WeakMap;g$=new WeakSet;Y0=function(){V$(this,RQ).resolve(),V$(this,a$).send("configure",{verbosity:this.verbosity})};B7=function($){b$(this,_Q,$),b$(this,a$,new LQ("main","worker",$)),V$(this,a$).on("ready",()=>{}),$Q(this,g$,Y0).call(this)};F7=function(){if(V$(O$,YQ)||V$(O$,gQ,O0)){$Q(this,g$,cQ).call(this);return}let{workerSrc:$}=O$;try{if(!O$._isSameOrigin(window.location,$))$=O$._createCDNWrapper(new URL($,window.location).href);let Q=new Worker($,{type:"module"}),K=new LQ("main","worker",Q),Z=()=>{if(J.abort(),K.destroy(),Q.terminate(),this.destroyed)V$(this,RQ).reject(Error("Worker was destroyed"));else $Q(this,g$,cQ).call(this)},J=new AbortController;Q.addEventListener("error",()=>{if(!V$(this,EQ))Z()},{signal:J.signal}),K.on("test",(q)=>{if(J.abort(),this.destroyed||!q){Z();return}b$(this,a$,K),b$(this,_Q,Q),b$(this,EQ,Q),$Q(this,g$,Y0).call(this)}),K.on("ready",(q)=>{if(J.abort(),this.destroyed){Z();return}try{_()}catch{$Q(this,g$,cQ).call(this)}});let _=()=>{let q=new Uint8Array;K.send("test",q,[q.buffer])};_();return}catch{P0("The worker has been disabled.")}$Q(this,g$,cQ).call(this)};cQ=function(){if(!V$(O$,YQ))p("Setting up fake worker."),b$(O$,YQ,!0);O$._setupFakeWorkerGlobal.then(($)=>{if(this.destroyed){V$(this,RQ).reject(Error("Worker was destroyed"));return}let Q=new w7;b$(this,_Q,Q);let K=`fake${ZK(O$,N6)._++}`,Z=new LQ(K+"_worker",K,Q);$.setup(Z,Q),b$(this,a$,new LQ(K,K+"_worker",Q)),$Q(this,g$,Y0).call(this)}).catch(($)=>{V$(this,RQ).reject(Error(`Setting up fake worker failed: "${$.message}".`))})};gQ=new WeakSet;O0=function(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}};e$(O$,gQ);e$(O$,N6,0);e$(O$,YQ,!1);e$(O$,IQ,new WeakMap);(()=>{if(L$)b$(O$,YQ,!0),p$.workerSrc||="./pdf.worker.mjs";O$._isSameOrigin=($,Q)=>{let K=URL.parse($);if(!K?.origin||K.origin==="null")return!1;let Z=new URL(Q,K);return K.origin===Z.origin},O$._createCDNWrapper=($)=>{let Q=`await import("${$}");`;return URL.createObjectURL(new Blob([Q],{type:"text/javascript"}))},O$.fromPort=($)=>{if(AK("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!$?.port)throw Error("PDFWorker.fromPort - invalid method signature.");return O$.create($)}})();var C0=O$;class S8{#$=new Map;#Q=new Map;#Z=new Map;#K=new Map;#q=null;constructor($,Q,K,Z,J,_){this.messageHandler=$,this.loadingTask=Q,this.commonObjs=new L6,this.fontLoader=new D7({ownerDocument:Z.ownerDocument,styleElement:Z.styleElement}),this.loadingParams=Z.loadingParams,this._params=Z,this.canvasFactory=J.canvasFactory,this.filterFactory=J.filterFactory,this.cMapReaderFactory=J.cMapReaderFactory,this.standardFontDataFactory=J.standardFontDataFactory,this.wasmFactory=J.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=K,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=_,this.setupMessageHandler()}#J($,Q=null){let K=this.#$.get($);if(K)return K;let Z=this.messageHandler.sendWithPromise($,Q);return this.#$.set($,Z),Z}get annotationStorage(){return r(this,"annotationStorage",new v0)}getRenderingIntent($,Q=QQ.ENABLE,K=null,Z=!1,J=!1){let _=v$.DISPLAY,q=e0;switch($){case"any":_=v$.ANY;break;case"display":break;case"print":_=v$.PRINT;break;default:p(`getRenderingIntent - invalid intent: ${$}`)}let G=_&v$.PRINT&&K instanceof I6?K:this.annotationStorage;switch(Q){case QQ.DISABLE:_+=v$.ANNOTATIONS_DISABLE;break;case QQ.ENABLE:break;case QQ.ENABLE_FORMS:_+=v$.ANNOTATIONS_FORMS;break;case QQ.ENABLE_STORAGE:_+=v$.ANNOTATIONS_STORAGE,q=G.serializable;break;default:p(`getRenderingIntent - invalid annotationMode: ${Q}`)}if(Z)_+=v$.IS_EDITING;if(J)_+=v$.OPLIST;let{ids:U,hash:V}=G.modifiedIds,N=[_,q.hash,V];return{renderingIntent:_,cacheKey:N.join("_"),annotationStorageSerializable:q,modifiedIds:U}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#q?.reject(Error("Worker was destroyed during onPassword callback"));let $=[];for(let K of this.#Q.values())$.push(K._destroy());if(this.#Q.clear(),this.#Z.clear(),this.#K.clear(),this.hasOwnProperty("annotationStorage"))this.annotationStorage.resetModified();let Q=this.messageHandler.sendWithPromise("Terminate",null);return $.push(Q),Promise.all($).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#$.clear(),this.filterFactory.destroy(),W$.cleanup(),this._networkStream?.cancelAllRequests(new KQ("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:$,loadingTask:Q}=this;$.on("GetReader",(K,Z)=>{i(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=(J)=>{this._lastProgress={loaded:J.loaded,total:J.total}},Z.onPull=()=>{this._fullReader.read().then(function({value:J,done:_}){if(_){Z.close();return}i(J instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),Z.enqueue(new Uint8Array(J),1,[J])}).catch((J)=>{Z.error(J)})},Z.onCancel=(J)=>{this._fullReader.cancel(J),Z.ready.catch((_)=>{if(this.destroyed)return;throw _})}}),$.on("ReaderHeadersReady",async(K)=>{await this._fullReader.headersReady;let{isStreamingSupported:Z,isRangeSupported:J,contentLength:_}=this._fullReader;if(!Z||!J){if(this._lastProgress)Q.onProgress?.(this._lastProgress);this._fullReader.onProgress=(q)=>{Q.onProgress?.({loaded:q.loaded,total:q.total})}}return{isStreamingSupported:Z,isRangeSupported:J,contentLength:_}}),$.on("GetRangeReader",(K,Z)=>{i(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let J=this._networkStream.getRangeReader(K.begin,K.end);if(!J){Z.close();return}Z.onPull=()=>{J.read().then(function({value:_,done:q}){if(q){Z.close();return}i(_ instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),Z.enqueue(new Uint8Array(_),1,[_])}).catch((_)=>{Z.error(_)})},Z.onCancel=(_)=>{J.cancel(_),Z.ready.catch((q)=>{if(this.destroyed)return;throw q})}}),$.on("GetDoc",({pdfInfo:K})=>{this._numPages=K.numPages,this._htmlForXfa=K.htmlForXfa,delete K.htmlForXfa,Q._capability.resolve(new z8(K,this))}),$.on("DocException",(K)=>{Q._capability.reject(H$(K))}),$.on("PasswordRequest",(K)=>{this.#q=Promise.withResolvers();try{if(!Q.onPassword)throw H$(K);let Z=(J)=>{if(J instanceof Error)this.#q.reject(J);else this.#q.resolve({password:J})};Q.onPassword(Z,K.code)}catch(Z){this.#q.reject(Z)}return this.#q.promise}),$.on("DataLoaded",(K)=>{Q.onProgress?.({loaded:K.length,total:K.length}),this.downloadInfoCapability.resolve(K)}),$.on("StartRenderPage",(K)=>{if(this.destroyed)return;this.#Q.get(K.pageIndex)._startRenderPage(K.transparency,K.cacheKey)}),$.on("commonobj",([K,Z,J])=>{if(this.destroyed)return null;if(this.commonObjs.has(K))return null;switch(Z){case"Font":if("error"in J){let V=J.error;p(`Error during font loading: ${V}`),this.commonObjs.resolve(K,V);break}let _=new $$(J),q=this._params.pdfBug&&globalThis.FontInspector?.enabled?(V,N)=>globalThis.FontInspector.fontAdded(V,N):null,G=new v7(_,q,J.extra,J.charProcOperatorList);this.fontLoader.bind(G).catch(()=>$.sendWithPromise("FontFallback",{id:K})).finally(()=>{if(!G.fontExtraProperties&&G.data)G.clearData();this.commonObjs.resolve(K,G)});break;case"CopyLocalImage":let{imageRef:U}=J;i(U,"The imageRef must be defined.");for(let V of this.#Q.values())for(let[,N]of V.objs){if(N?.ref!==U)continue;if(!N.dataLen)return null;return this.commonObjs.resolve(K,structuredClone(N)),N.dataLen}break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(K,J);break;default:throw Error(`Got unknown common object type ${Z}`)}return null}),$.on("obj",([K,Z,J,_])=>{if(this.destroyed)return;let q=this.#Q.get(Z);if(q.objs.has(K))return;if(q._intentStates.size===0){_?.bitmap?.close();return}switch(J){case"Image":case"Pattern":q.objs.resolve(K,_);break;default:throw Error(`Got unknown object type ${J}`)}}),$.on("DocProgress",(K)=>{if(this.destroyed)return;Q.onProgress?.({loaded:K.loaded,total:K.total})}),$.on("FetchBinaryData",async(K)=>{if(this.destroyed)throw Error("Worker was destroyed.");let Z=this[K.type];if(!Z)throw Error(`${K.type} not initialized, see the \`useWorkerFetch\` parameter.`);return Z.fetch(K)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){if(this.annotationStorage.size<=0)p("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:$,transfer:Q}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:$,filename:this._fullReader?.filename??null},Q).finally(()=>{this.annotationStorage.resetModified()})}getPage($){if(!Number.isInteger($)||$<=0||$>this._numPages)return Promise.reject(Error("Invalid page request."));let Q=$-1,K=this.#Z.get(Q);if(K)return K;let Z=this.messageHandler.sendWithPromise("GetPage",{pageIndex:Q}).then((J)=>{if(this.destroyed)throw Error("Transport destroyed");if(J.refStr)this.#K.set(J.refStr,$);let _=new O8(Q,J,this,this._params.pdfBug);return this.#Q.set(Q,_),_});return this.#Z.set(Q,Z),Z}getPageIndex($){if(!$6($))return Promise.reject(Error("Invalid pageIndex request."));return this.messageHandler.sendWithPromise("GetPageIndex",{num:$.num,gen:$.gen})}getAnnotations($,Q){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:$,intent:Q})}getFieldObjects(){return this.#J("GetFieldObjects")}hasJSActions(){return this.#J("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination($){if(typeof $!=="string")return Promise.reject(Error("Invalid destination request."));return this.messageHandler.sendWithPromise("GetDestination",{id:$})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType($,Q){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:$,pageIndexesToSkip:Q})}getDocJSActions(){return this.#J("GetDocJSActions")}getPageJSActions($){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:$})}getStructTree($){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:$})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig($){return this.#J("GetOptionalContentConfig").then((Q)=>new a7(Q,$))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let Q=this.#$.get("GetMetadata");if(Q)return Q;let K=this.messageHandler.sendWithPromise("GetMetadata",null).then((Z)=>({info:Z[0],metadata:Z[1]?new r7(Z[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#$.set("GetMetadata",K),K}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup($=!1){if(this.destroyed)return;await this.messageHandler.sendWithPromise("Cleanup",null);for(let Q of this.#Q.values())if(!Q.cleanup())throw Error(`startCleanup: Page ${Q.pageNumber} is currently rendering.`);if(this.commonObjs.clear(),!$)this.fontLoader.clear();this.#$.clear(),this.filterFactory.destroy(!0),W$.cleanup()}cachedPageNumber($){if(!$6($))return null;let Q=$.gen===0?`${$.num}R`:`${$.num}R${$.gen}`;return this.#K.get(Q)??null}}class T8{#$=null;onContinue=null;onError=null;constructor($){this.#$=$}get promise(){return this.#$.capability.promise}cancel($=0){this.#$.cancel(null,$)}get separateAnnots(){let{separateAnnots:$}=this.#$.operatorList;if(!$)return!1;let{annotationCanvasMap:Q}=this.#$;return $.form||$.canvas&&Q?.size>0}}class kQ{#$=null;static#Q=new WeakSet;constructor({callback:$,params:Q,objs:K,commonObjs:Z,annotationCanvasMap:J,operatorList:_,pageIndex:q,canvasFactory:G,filterFactory:U,useRequestAnimationFrame:V=!1,pdfBug:N=!1,pageColors:R=null,enableHWA:j=!1,operationsFilter:F=null}){this.callback=$,this.params=Q,this.objs=K,this.commonObjs=Z,this.annotationCanvasMap=J,this.operatorListIdx=null,this.operatorList=_,this._pageIndex=q,this.canvasFactory=G,this.filterFactory=U,this._pdfBug=N,this.pageColors=R,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=V===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new T8(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=Q.canvas,this._canvasContext=Q.canvas?null:Q.canvasContext,this._enableHWA=j,this._dependencyTracker=Q.dependencyTracker,this._operationsFilter=F}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:$=!1,optionalContentConfig:Q}){if(this.cancelled)return;if(this._canvas){if(kQ.#Q.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");kQ.#Q.add(this._canvas)}if(this._pdfBug&&globalThis.StepperManager?.enabled)this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint();let{viewport:K,transform:Z,background:J,dependencyTracker:_}=this.params,q=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new MQ(q,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:Q},this.annotationCanvasMap,this.pageColors,_),this.gfx.beginDrawing({transform:Z,viewport:K,transparency:$,background:J}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel($=null,Q=0){if(this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#$)window.cancelAnimationFrame(this.#$),this.#$=null;kQ.#Q.delete(this._canvas),$||=new Q0(`Rendering cancelled, page ${this._pageIndex+1}`,Q),this.callback($),this.task.onError?.($)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}if(this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),this.running)return;this._continue()}_continue(){if(this.running=!0,this.cancelled)return;if(this.task.onContinue)this.task.onContinue(this._scheduleNextBound);else this._scheduleNext()}_scheduleNext(){if(this._useRequestAnimationFrame)this.#$=window.requestAnimationFrame(()=>{this.#$=null,this._nextBound().catch(this._cancelBound)});else Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(this.cancelled)return;if(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length){if(this.running=!1,this.operatorList.lastChunk)this.gfx.endDrawing(),kQ.#Q.delete(this._canvas),this.callback()}}}var I8="5.4.296",C8="f56dc8601";class f${#$=null;#Q=null;#Z;#K=null;#q=!1;#J=!1;#_=null;#G;#V=null;#U=null;static#j=null;static get _keyboardManager(){return r(this,"_keyboardManager",new vQ([[["Escape","mac+Escape"],f$.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],f$.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],f$.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],f$.prototype._moveToPrevious],[["Home","mac+Home"],f$.prototype._moveToBeginning],[["End","mac+End"],f$.prototype._moveToEnd]]))}constructor({editor:$=null,uiManager:Q=null}){if($)this.#J=!1,this.#_=$;else this.#J=!0;this.#U=$?._uiManager||Q,this.#G=this.#U._eventBus,this.#Z=$?.color?.toUpperCase()||this.#U?.highlightColors.values().next().value||"#FFFF98",f$.#j||=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"})}renderButton(){let $=this.#$=document.createElement("button");if($.className="colorPicker",$.tabIndex="0",$.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),$.ariaHasPopup="true",this.#_)$.ariaControls=`${this.#_.id}_colorpicker_dropdown`;let Q=this.#U._signal;$.addEventListener("click",this.#F.bind(this),{signal:Q}),$.addEventListener("keydown",this.#z.bind(this),{signal:Q});let K=this.#Q=document.createElement("span");return K.className="swatch",K.ariaHidden="true",K.style.backgroundColor=this.#Z,$.append(K),$}renderMainDropdown(){let $=this.#K=this.#R();return $.ariaOrientation="horizontal",$.ariaLabelledBy="highlightColorPickerLabel",$}#R(){let $=document.createElement("div"),Q=this.#U._signal;if($.addEventListener("contextmenu",y$,{signal:Q}),$.className="dropdown",$.role="listbox",$.ariaMultiSelectable="false",$.ariaOrientation="vertical",$.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#_)$.id=`${this.#_.id}_colorpicker_dropdown`;for(let[K,Z]of this.#U.highlightColors){let J=document.createElement("button");J.tabIndex="0",J.role="option",J.setAttribute("data-color",Z),J.title=K,J.setAttribute("data-l10n-id",f$.#j[K]);let _=document.createElement("span");J.append(_),_.className="swatch",_.style.backgroundColor=Z,J.ariaSelected=Z===this.#Z,J.addEventListener("click",this.#B.bind(this,Z),{signal:Q}),$.append(J)}return $.addEventListener("keydown",this.#z.bind(this),{signal:Q}),$}#B($,Q){Q.stopPropagation(),this.#G.dispatch("switchannotationeditorparams",{source:this,type:n.HIGHLIGHT_COLOR,value:$}),this.updateColor($)}_colorSelectFromKeyboard($){if($.target===this.#$){this.#F($);return}let Q=$.target.getAttribute("data-color");if(!Q)return;this.#B(Q,$)}_moveToNext($){if(!this.#A){this.#F($);return}if($.target===this.#$){this.#K.firstChild?.focus();return}$.target.nextSibling?.focus()}_moveToPrevious($){if($.target===this.#K?.firstChild||$.target===this.#$){if(this.#A)this._hideDropdownFromKeyboard();return}if(!this.#A)this.#F($);$.target.previousSibling?.focus()}_moveToBeginning($){if(!this.#A){this.#F($);return}this.#K.firstChild?.focus()}_moveToEnd($){if(!this.#A){this.#F($);return}this.#K.lastChild?.focus()}#z($){f$._keyboardManager.exec(this,$)}#F($){if(this.#A){this.hideDropdown();return}if(this.#q=$.detail===0,!this.#V)this.#V=new AbortController,window.addEventListener("pointerdown",this.#N.bind(this),{signal:this.#U.combinedSignal(this.#V)});if(this.#$.ariaExpanded="true",this.#K){this.#K.classList.remove("hidden");return}let Q=this.#K=this.#R();this.#$.append(Q)}#N($){if(this.#K?.contains($.target))return;this.hideDropdown()}hideDropdown(){this.#K?.classList.add("hidden"),this.#$.ariaExpanded="false",this.#V?.abort(),this.#V=null}get#A(){return this.#K&&!this.#K.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(this.#J)return;if(!this.#A){this.#_?.unselect();return}this.hideDropdown(),this.#$.focus({preventScroll:!0,focusVisible:this.#q})}updateColor($){if(this.#Q)this.#Q.style.backgroundColor=$;if(!this.#K)return;let Q=this.#U.highlightColors.values();for(let K of this.#K.children)K.ariaSelected=Q.next().value===$.toUpperCase()}destroy(){this.#$?.remove(),this.#$=null,this.#Q=null,this.#K?.remove(),this.#K=null}}class sQ{#$=null;#Q=null;#Z=null;static#K=null;constructor($){this.#Q=$,this.#Z=$._uiManager,sQ.#K||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#$)return this.#$;let{editorType:$,colorType:Q,colorValue:K}=this.#Q,Z=this.#$=document.createElement("input");return Z.type="color",Z.value=K||"#000000",Z.className="basicColorPicker",Z.tabIndex=0,Z.setAttribute("data-l10n-id",sQ.#K[$]),Z.addEventListener("input",()=>{this.#Z.updateParams(Q,Z.value)},{signal:this.#Z._signal}),Z}update($){if(!this.#$)return;this.#$.value=$}destroy(){this.#$?.remove(),this.#$=null}hideDropdown(){}}s(116);s(531);function R7($){return Math.floor(Math.max(0,Math.min(1,$))*255).toString(16).padStart(2,"0")}function yQ($){return Math.max(0,Math.min(255,255*$))}class G6{static CMYK_G([$,Q,K,Z]){return["G",1-Math.min(1,0.3*$+0.59*K+0.11*Q+Z)]}static G_CMYK([$]){return["CMYK",0,0,0,1-$]}static G_RGB([$]){return["RGB",$,$,$]}static G_rgb([$]){return $=yQ($),[$,$,$]}static G_HTML([$]){let Q=R7($);return`#${Q}${Q}${Q}`}static RGB_G([$,Q,K]){return["G",0.3*$+0.59*Q+0.11*K]}static RGB_rgb($){return $.map(yQ)}static RGB_HTML($){return`#${$.map(R7).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([$,Q,K,Z]){return["RGB",1-Math.min(1,$+Z),1-Math.min(1,K+Z),1-Math.min(1,Q+Z)]}static CMYK_rgb([$,Q,K,Z]){return[yQ(1-Math.min(1,$+Z)),yQ(1-Math.min(1,K+Z)),yQ(1-Math.min(1,Q+Z))]}static CMYK_HTML($){let Q=this.CMYK_RGB($).slice(1);return this.RGB_HTML(Q)}static RGB_CMYK([$,Q,K]){let Z=1-$,J=1-Q,_=1-K,q=Math.min(Z,J,_);return["CMYK",Z,J,_,q]}}class k8{create($,Q,K=!1){if($<=0||Q<=0)throw Error("Invalid SVG dimensions");let Z=this._createSVG("svg:svg");if(Z.setAttribute("version","1.1"),!K)Z.setAttribute("width",`${$}px`),Z.setAttribute("height",`${Q}px`);return Z.setAttribute("preserveAspectRatio","none"),Z.setAttribute("viewBox",`0 0 ${$} ${Q}`),Z}createElement($){if(typeof $!=="string")throw Error("Invalid SVG element type");return this._createSVG($)}_createSVG($){Z$("Abstract method `_createSVG` called.")}}class PQ extends k8{_createSVG($){return document.createElementNS(i$,$)}}var wK=9,BQ=new WeakSet,bK=new Date().getTimezoneOffset()*60*1000;class U6{static create($){switch($.data.annotationType){case j$.LINK:return new y0($);case j$.TEXT:return new M8($);case j$.WIDGET:switch($.data.fieldType){case"Tx":return new W8($);case"Btn":if($.data.radioButton)return new D6($);else if($.data.checkBox)return new Y8($);return new L8($);case"Ch":return new P8($);case"Sig":return new X8($)}return new UQ($);case j$.POPUP:return new k0($);case j$.FREETEXT:return new v6($);case j$.LINE:return new D8($);case j$.SQUARE:return new v8($);case j$.CIRCLE:return new f8($);case j$.POLYLINE:return new f6($);case j$.CARET:return new b8($);case j$.INK:return new x0($);case j$.POLYGON:return new w8($);case j$.HIGHLIGHT:return new w6($);case j$.UNDERLINE:return new y8($);case j$.SQUIGGLY:return new x8($);case j$.STRIKEOUT:return new c8($);case j$.STAMP:return new b6($);case j$.FILEATTACHMENT:return new u8($);default:return new R$($)}}}class R${#$=null;#Q=!1;#Z=null;constructor($,{isRenderable:Q=!1,ignoreBorder:K=!1,createQuadrilaterals:Z=!1}={}){if(this.isRenderable=Q,this.data=$.data,this.layer=$.layer,this.linkService=$.linkService,this.downloadManager=$.downloadManager,this.imageResourcesPath=$.imageResourcesPath,this.renderForms=$.renderForms,this.svgFactory=$.svgFactory,this.annotationStorage=$.annotationStorage,this.enableComment=$.enableComment,this.enableScripting=$.enableScripting,this.hasJSActions=$.hasJSActions,this._fieldObjects=$.fieldObjects,this.parent=$.parent,Q)this.container=this._createContainer(K);if(Z)this._createQuadrilaterals()}static _hasPopupData({contentsObj:$,richText:Q}){return!!($?.str||Q?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return R$._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:$}=this,Q=this.annotationStorage?.getEditor($.id);if(Q)return Q.getData();return $}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){let $=this.annotationStorage?.getEditor(this.data.id);if($)return $.commentButtonPositionInPage;let{quadPoints:Q,inkLists:K,rect:Z}=this.data,J=-1/0,_=-1/0;if(Q?.length>=8){for(let q=0;q<Q.length;q+=8)if(Q[q+1]>_)_=Q[q+1],J=Q[q+2];else if(Q[q+1]===_)J=Math.max(J,Q[q+2]);return[J,_]}if(K?.length>=1){for(let q of K)for(let G=0,U=q.length;G<U;G+=2)if(q[G+1]>_)_=q[G+1],J=q[G];else if(q[G+1]===_)J=Math.max(J,q[G]);if(J!==1/0)return[J,_]}if(Z)return[Z[2],Z[3]];return null}_normalizePoint($){let{page:{view:Q},viewport:{rawDims:{pageWidth:K,pageHeight:Z,pageX:J,pageY:_}}}=this.parent;return $[1]=Q[3]-$[1]+Q[1],$[0]=100*($[0]-J)/K,$[1]=100*($[1]-_)/Z,$}get commentText(){let{data:$}=this;return this.annotationStorage.getRawValue(`${pQ}${$.id}`)?.popup?.contents||$.contentsObj?.str||""}set commentText($){let{data:Q}=this,K={deleted:!$,contents:$||""};if(!this.annotationStorage.updateEditor(Q.id,{popup:K}))this.annotationStorage.setValue(`${pQ}${Q.id}`,{id:Q.id,annotationType:Q.annotationType,pageIndex:this.parent.page._pageIndex,popup:K,popupRef:Q.popupRef,modificationDate:new Date});if(!$)this.removePopup()}removePopup(){(this.#Z?.popup||this.popup)?.remove(),this.#Z=this.popup=null}updateEdited($){if(!this.container)return;if($.rect)this.#$||={rect:this.data.rect.slice(0)};let{rect:Q,popup:K}=$;if(Q)this.#K(Q);let Z=this.#Z?.popup||this.popup;if(!Z&&K?.text)this._createPopup(K),Z=this.#Z.popup;if(!Z)return;if(Z.updateEdited($),K?.deleted)Z.remove(),this.#Z=null,this.popup=null}resetEdited(){if(!this.#$)return;this.#K(this.#$.rect),this.#Z?.popup.resetEdited(),this.#$=null}#K($){let{container:{style:Q},data:{rect:K,rotation:Z},parent:{viewport:{rawDims:{pageWidth:J,pageHeight:_,pageX:q,pageY:G}}}}=this;if(K?.splice(0,4,...$),Q.left=`${100*($[0]-q)/J}%`,Q.top=`${100*(_-$[3]+G)/_}%`,Z===0)Q.width=`${100*($[2]-$[0])/J}%`,Q.height=`${100*($[3]-$[1])/_}%`;else this.setRotation(Z)}_createContainer($){let{data:Q,parent:{page:K,viewport:Z}}=this,J=document.createElement("section");if(J.setAttribute("data-annotation-id",Q.id),!(this instanceof UQ)&&!(this instanceof y0))J.tabIndex=0;let{style:_}=J;if(_.zIndex=this.parent.zIndex,this.parent.zIndex+=2,Q.alternativeText)J.title=Q.alternativeText;if(Q.noRotate)J.classList.add("norotate");if(!Q.rect||this instanceof k0){let{rotation:B}=Q;if(!Q.hasOwnCanvas&&B!==0)this.setRotation(B,J);return J}let{width:q,height:G}=this;if(!$&&Q.borderStyle.width>0){_.borderWidth=`${Q.borderStyle.width}px`;let B=Q.borderStyle.horizontalCornerRadius,A=Q.borderStyle.verticalCornerRadius;if(B>0||A>0){let O=`calc(${B}px * var(--total-scale-factor)) / calc(${A}px * var(--total-scale-factor))`;_.borderRadius=O}else if(this instanceof D6){let O=`calc(${q}px * var(--total-scale-factor)) / calc(${G}px * var(--total-scale-factor))`;_.borderRadius=O}switch(Q.borderStyle.style){case SQ.SOLID:_.borderStyle="solid";break;case SQ.DASHED:_.borderStyle="dashed";break;case SQ.BEVELED:p("Unimplemented border style: beveled");break;case SQ.INSET:p("Unimplemented border style: inset");break;case SQ.UNDERLINE:_.borderBottomStyle="solid";break}let z=Q.borderColor||null;if(z)this.#Q=!0,_.borderColor=x.makeHexColor(z[0]|0,z[1]|0,z[2]|0);else _.borderWidth=0}let U=x.normalizeRect([Q.rect[0],K.view[3]-Q.rect[1]+K.view[1],Q.rect[2],K.view[3]-Q.rect[3]+K.view[1]]),{pageWidth:V,pageHeight:N,pageX:R,pageY:j}=Z.rawDims;_.left=`${100*(U[0]-R)/V}%`,_.top=`${100*(U[1]-j)/N}%`;let{rotation:F}=Q;if(Q.hasOwnCanvas||F===0)_.width=`${100*q/V}%`,_.height=`${100*G/N}%`;else this.setRotation(F,J);return J}setRotation($,Q=this.container){if(!this.data.rect)return;let{pageWidth:K,pageHeight:Z}=this.parent.viewport.rawDims,{width:J,height:_}=this;if($%180!==0)[J,_]=[_,J];Q.style.width=`${100*J/K}%`,Q.style.height=`${100*_/Z}%`,Q.setAttribute("data-main-rotation",(360-$)%360)}get _commonActions(){let $=(Q,K,Z)=>{let J=Z.detail[Q],_=J[0],q=J.slice(1);Z.target.style[K]=G6[`${_}_HTML`](q),this.annotationStorage.setValue(this.data.id,{[K]:G6[`${_}_rgb`](q)})};return r(this,"_commonActions",{display:(Q)=>{let{display:K}=Q.detail,Z=K%2===1;this.container.style.visibility=Z?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:Z,noPrint:K===1||K===2})},print:(Q)=>{this.annotationStorage.setValue(this.data.id,{noPrint:!Q.detail.print})},hidden:(Q)=>{let{hidden:K}=Q.detail;this.container.style.visibility=K?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:K,noView:K})},focus:(Q)=>{setTimeout(()=>Q.target.focus({preventScroll:!1}),0)},userName:(Q)=>{Q.target.title=Q.detail.userName},readonly:(Q)=>{Q.target.disabled=Q.detail.readonly},required:(Q)=>{this._setRequired(Q.target,Q.detail.required)},bgColor:(Q)=>{$("bgColor","backgroundColor",Q)},fillColor:(Q)=>{$("fillColor","backgroundColor",Q)},fgColor:(Q)=>{$("fgColor","color",Q)},textColor:(Q)=>{$("textColor","color",Q)},borderColor:(Q)=>{$("borderColor","borderColor",Q)},strokeColor:(Q)=>{$("strokeColor","borderColor",Q)},rotation:(Q)=>{let K=Q.detail.rotation;this.setRotation(K),this.annotationStorage.setValue(this.data.id,{rotation:K})}})}_dispatchEventFromSandbox($,Q){let K=this._commonActions;for(let Z of Object.keys(Q.detail))($[Z]||K[Z])?.(Q)}_setDefaultPropertiesFromJS($){if(!this.enableScripting)return;let Q=this.annotationStorage.getRawValue(this.data.id);if(!Q)return;let K=this._commonActions;for(let[Z,J]of Object.entries(Q)){let _=K[Z];if(_){let q={detail:{[Z]:J},target:$};_(q),delete Q[Z]}}}_createQuadrilaterals(){if(!this.container)return;let{quadPoints:$}=this.data;if(!$)return;let[Q,K,Z,J]=this.data.rect.map((B)=>Math.fround(B));if($.length===8){let[B,A,z,O]=$.subarray(2,6);if(Z===B&&J===A&&Q===z&&K===O)return}let{style:_}=this.container,q;if(this.#Q){let{borderColor:B,borderWidth:A}=_;_.borderWidth=0,q=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${B}" stroke-width="${A}">`],this.container.classList.add("hasBorder")}let G=Z-Q,U=J-K,{svgFactory:V}=this,N=V.createElement("svg");N.classList.add("quadrilateralsContainer"),N.setAttribute("width",0),N.setAttribute("height",0),N.role="none";let R=V.createElement("defs");N.append(R);let j=V.createElement("clipPath"),F=`clippath_${this.data.id}`;j.setAttribute("id",F),j.setAttribute("clipPathUnits","objectBoundingBox"),R.append(j);for(let B=2,A=$.length;B<A;B+=8){let z=$[B],O=$[B+1],S=$[B+2],I=$[B+3],C=V.createElement("rect"),T=(S-Q)/G,k=(J-O)/U,E=(z-S)/G,M=(O-I)/U;C.setAttribute("x",T),C.setAttribute("y",k),C.setAttribute("width",E),C.setAttribute("height",M),j.append(C),q?.push(`<rect vector-effect="non-scaling-stroke" x="${T}" y="${k}" width="${E}" height="${M}"/>`)}if(this.#Q)q.push("</g></svg>')"),_.backgroundImage=q.join("");this.container.append(N),this.container.style.clipPath=`url(#${F})`}_createPopup($=null){let{data:Q}=this,K,Z;if($)K={str:$.text},Z=$.date;else K=Q.contentsObj,Z=Q.modificationDate;let J=this.#Z=new k0({data:{color:Q.color,titleObj:Q.titleObj,modificationDate:Z,contentsObj:K,richText:Q.richText,parentRect:Q.rect,borderStyle:0,id:`popup_${Q.id}`,rotation:Q.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]});if(!this.parent._commentManager)this.parent.div.append(J.render())}get hasPopupElement(){return!!(this.#Z||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#Z}render(){Z$("Abstract method `AnnotationElement.render` called")}_getElementsByName($,Q=null){let K=[];if(this._fieldObjects){let Z=this._fieldObjects[$];if(Z)for(let{page:J,id:_,exportValues:q}of Z){if(J===-1)continue;if(_===Q)continue;let G=typeof q==="string"?q:null,U=document.querySelector(`[data-element-id="${_}"]`);if(U&&!BQ.has(U)){p(`_getElementsByName - element not allowed: ${_}`);continue}K.push({id:_,exportValue:G,domElement:U})}return K}for(let Z of document.getElementsByName($)){let{exportValue:J}=Z,_=Z.getAttribute("data-element-id");if(_===Q)continue;if(!BQ.has(Z))continue;K.push({id:_,exportValue:J,domElement:Z})}return K}show(){if(this.container)this.container.hidden=!1;this.popup?.maybeShow()}hide(){if(this.container)this.container.hidden=!0;this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let $=this.getElementsToTriggerPopup();if(Array.isArray($))for(let Q of $)Q.classList.add("highlightArea");else $.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:$,data:{id:Q}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:$,editId:Q,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class E8 extends R${constructor($){super($,{isRenderable:!0,ignoreBorder:!0});this.editor=$.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:$}=this;if(!$.hasComment)return;this._createPopup($.comment),this.extraPopupElement.popup.renderCommentButton()}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText($){if(this.editor.comment=$,!$)this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}class y0 extends R${constructor($,Q=null){super($,{isRenderable:!0,ignoreBorder:!!Q?.ignoreBorder,createQuadrilaterals:!0});this.isTooltipOnly=$.data.isTooltipOnly}render(){let{data:$,linkService:Q}=this,K=document.createElement("a");K.setAttribute("data-element-id",$.id);let Z=!1;if($.url)Q.addLinkAttributes(K,$.url,$.newWindow),Z=!0;else if($.action)this._bindNamedAction(K,$.action,$.overlaidText),Z=!0;else if($.attachment)this.#Q(K,$.attachment,$.overlaidText,$.attachmentDest),Z=!0;else if($.setOCGState)this.#Z(K,$.setOCGState,$.overlaidText),Z=!0;else if($.dest)this._bindLink(K,$.dest,$.overlaidText),Z=!0;else{if($.actions&&($.actions.Action||$.actions["Mouse Up"]||$.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions)this._bindJSAction(K,$),Z=!0;if($.resetForm)this._bindResetFormAction(K,$.resetForm),Z=!0;else if(this.isTooltipOnly&&!Z)this._bindLink(K,""),Z=!0}if(this.container.classList.add("linkAnnotation"),Z)this.container.append(K);return this.container}#$(){this.container.setAttribute("data-internal-link","")}_bindLink($,Q,K=""){if($.href=this.linkService.getDestinationHash(Q),$.onclick=()=>{if(Q)this.linkService.goToDestination(Q);return!1},Q||Q==="")this.#$();if(K)$.title=K}_bindNamedAction($,Q,K=""){if($.href=this.linkService.getAnchorUrl(""),$.onclick=()=>{return this.linkService.executeNamedAction(Q),!1},K)$.title=K;this.#$()}#Q($,Q,K="",Z=null){if($.href=this.linkService.getAnchorUrl(""),Q.description)$.title=Q.description;else if(K)$.title=K;$.onclick=()=>{return this.downloadManager?.openOrDownloadData(Q.content,Q.filename,Z),!1},this.#$()}#Z($,Q,K=""){if($.href=this.linkService.getAnchorUrl(""),$.onclick=()=>{return this.linkService.executeSetOCGState(Q),!1},K)$.title=K;this.#$()}_bindJSAction($,Q){$.href=this.linkService.getAnchorUrl("");let K=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let Z of Object.keys(Q.actions)){let J=K.get(Z);if(!J)continue;$[J]=()=>{return this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:Q.id,name:Z}}),!1}}if(Q.overlaidText)$.title=Q.overlaidText;if(!$.onclick)$.onclick=()=>!1;this.#$()}_bindResetFormAction($,Q){let K=$.onclick;if(!K)$.href=this.linkService.getAnchorUrl("");if(this.#$(),!this._fieldObjects){if(p('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),!K)$.onclick=()=>!1;return}$.onclick=()=>{K?.();let{fields:Z,refs:J,include:_}=Q,q=[];if(Z.length!==0||J.length!==0){let V=new Set(J);for(let N of Z){let R=this._fieldObjects[N]||[];for(let{id:j}of R)V.add(j)}for(let N of Object.values(this._fieldObjects))for(let R of N)if(V.has(R.id)===_)q.push(R)}else for(let V of Object.values(this._fieldObjects))q.push(...V);let G=this.annotationStorage,U=[];for(let V of q){let{id:N}=V;switch(U.push(N),V.type){case"text":{let j=V.defaultValue||"";G.setValue(N,{value:j});break}case"checkbox":case"radiobutton":{let j=V.defaultValue===V.exportValues;G.setValue(N,{value:j});break}case"combobox":case"listbox":{let j=V.defaultValue||"";G.setValue(N,{value:j});break}default:continue}let R=document.querySelector(`[data-element-id="${N}"]`);if(!R)continue;else if(!BQ.has(R)){p(`_bindResetFormAction - element not allowed: ${N}`);continue}R.dispatchEvent(new Event("resetform"))}if(this.enableScripting)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:U,name:"ResetForm"}});return!1}}}class M8 extends R${constructor($){super($,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let $=document.createElement("img");if($.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",$.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),$.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData)this._createPopup();return this.container.append($),this.container}}class UQ extends R${render(){return this.container}showElementAndHideCanvas($){if(this.data.hasOwnCanvas){if($.previousSibling?.nodeName==="CANVAS")$.previousSibling.hidden=!0;$.hidden=!1}}_getKeyModifier($){return S$.platform.isMac?$.metaKey:$.ctrlKey}_setEventListener($,Q,K,Z,J){if(K.includes("mouse"))$.addEventListener(K,(_)=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:Z,value:J(_),shift:_.shiftKey,modifier:this._getKeyModifier(_)}})});else $.addEventListener(K,(_)=>{if(K==="blur"){if(!Q.focused||!_.relatedTarget)return;Q.focused=!1}else if(K==="focus"){if(Q.focused)return;Q.focused=!0}if(!J)return;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:Z,value:J(_)}})})}_setEventListeners($,Q,K,Z){for(let[J,_]of K)if(_==="Action"||this.data.actions?.[_]){if(_==="Focus"||_==="Blur")Q||={focused:!1};if(this._setEventListener($,Q,J,_,Z),_==="Focus"&&!this.data.actions?.Blur)this._setEventListener($,Q,"blur","Blur",null);else if(_==="Blur"&&!this.data.actions?.Focus)this._setEventListener($,Q,"focus","Focus",null)}}_setBackgroundColor($){let Q=this.data.backgroundColor||null;$.style.backgroundColor=Q===null?"transparent":x.makeHexColor(Q[0],Q[1],Q[2])}_setTextStyle($){let Q=["left","center","right"],{fontColor:K}=this.data.defaultAppearanceData,Z=this.data.defaultAppearanceData.fontSize||wK,J=$.style,_,q=2,G=(U)=>Math.round(10*U)/10;if(this.data.multiLine){let U=Math.abs(this.data.rect[3]-this.data.rect[1]-2),V=Math.round(U/(h0*Z))||1,N=U/V;_=Math.min(Z,G(N/h0))}else{let U=Math.abs(this.data.rect[3]-this.data.rect[1]-2);_=Math.min(Z,G(U/h0))}if(J.fontSize=`calc(${_}px * var(--total-scale-factor))`,J.color=x.makeHexColor(K[0],K[1],K[2]),this.data.textAlignment!==null)J.textAlign=Q[this.data.textAlignment]}_setRequired($,Q){if(Q)$.setAttribute("required",!0);else $.removeAttribute("required");$.setAttribute("aria-required",Q)}}class W8 extends UQ{constructor($){let Q=$.renderForms||$.data.hasOwnCanvas||!$.data.hasAppearance&&!!$.data.fieldValue;super($,{isRenderable:Q})}setPropertyOnSiblings($,Q,K,Z){let J=this.annotationStorage;for(let _ of this._getElementsByName($.name,$.id)){if(_.domElement)_.domElement[Q]=K;J.setValue(_.id,{[Z]:K})}}render(){let $=this.annotationStorage,Q=this.data.id;this.container.classList.add("textWidgetAnnotation");let K=null;if(this.renderForms){let Z=$.getValue(Q,{value:this.data.fieldValue}),J=Z.value||"",_=$.getValue(Q,{charLimit:this.data.maxLen}).charLimit;if(_&&J.length>_)J=J.slice(0,_);let q=Z.formattedValue||this.data.textContent?.join(`
5
+ `)||null;if(q&&this.data.comb)q=q.replaceAll(/\s+/g,"");let G={userValue:J,formattedValue:q,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){if(K=document.createElement("textarea"),K.textContent=q??J,this.data.doNotScroll)K.style.overflowY="hidden"}else if(K=document.createElement("input"),K.type=this.data.password?"password":"text",K.setAttribute("value",q??J),this.data.doNotScroll)K.style.overflowX="hidden";if(this.data.hasOwnCanvas)K.hidden=!0;BQ.add(K),K.setAttribute("data-element-id",Q),K.disabled=this.data.readOnly,K.name=this.data.fieldName,K.tabIndex=0;let{datetimeFormat:U,datetimeType:V,timeStep:N}=this.data,R=!!V&&this.enableScripting;if(U)K.title=U;if(this._setRequired(K,this.data.required),_)K.maxLength=_;K.addEventListener("input",(F)=>{$.setValue(Q,{value:F.target.value}),this.setPropertyOnSiblings(K,"value",F.target.value,"value"),G.formattedValue=null}),K.addEventListener("resetform",(F)=>{let B=this.data.defaultFieldValue??"";K.value=G.userValue=B,G.formattedValue=null});let j=(F)=>{let{formattedValue:B}=G;if(B!==null&&B!==void 0)F.target.value=B;F.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){K.addEventListener("focus",(B)=>{if(G.focused)return;let{target:A}=B;if(R){if(A.type=V,N)A.step=N}if(G.userValue){let z=G.userValue;if(R)if(V==="time"){let O=new Date(z),S=[O.getHours(),O.getMinutes(),O.getSeconds()];A.value=S.map((I)=>I.toString().padStart(2,"0")).join(":")}else A.value=new Date(z-bK).toISOString().split(V==="date"?"T":".",1)[0];else A.value=z}if(G.lastCommittedValue=A.value,G.commitKey=1,!this.data.actions?.Focus)G.focused=!0}),K.addEventListener("updatefromsandbox",(B)=>{this.showElementAndHideCanvas(B.target);let A={value(z){if(G.userValue=z.detail.value??"",!R)$.setValue(Q,{value:G.userValue.toString()});z.target.value=G.userValue},formattedValue(z){let{formattedValue:O}=z.detail;if(G.formattedValue=O,O!==null&&O!==void 0&&z.target!==document.activeElement)z.target.value=O;let S={formattedValue:O};if(R)S.value=O;$.setValue(Q,S)},selRange(z){z.target.setSelectionRange(...z.detail.selRange)},charLimit:(z)=>{let{charLimit:O}=z.detail,{target:S}=z;if(O===0){S.removeAttribute("maxLength");return}S.setAttribute("maxLength",O);let I=G.userValue;if(!I||I.length<=O)return;I=I.slice(0,O),S.value=G.userValue=I,$.setValue(Q,{value:I}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:Q,name:"Keystroke",value:I,willCommit:!0,commitKey:1,selStart:S.selectionStart,selEnd:S.selectionEnd}})}};this._dispatchEventFromSandbox(A,B)}),K.addEventListener("keydown",(B)=>{G.commitKey=1;let A=-1;if(B.key==="Escape")A=0;else if(B.key==="Enter"&&!this.data.multiLine)A=2;else if(B.key==="Tab")G.commitKey=3;if(A===-1)return;let{value:z}=B.target;if(G.lastCommittedValue===z)return;G.lastCommittedValue=z,G.userValue=z,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:Q,name:"Keystroke",value:z,willCommit:!0,commitKey:A,selStart:B.target.selectionStart,selEnd:B.target.selectionEnd}})});let F=j;if(j=null,K.addEventListener("blur",(B)=>{if(!G.focused||!B.relatedTarget)return;if(!this.data.actions?.Blur)G.focused=!1;let{target:A}=B,{value:z}=A;if(R){if(z&&V==="time"){let O=z.split(":").map((S)=>parseInt(S,10));z=new Date(2000,0,1,O[0],O[1],O[2]||0).valueOf(),A.step=""}else{if(!z.includes("T"))z=`${z}T00:00`;z=new Date(z).valueOf()}A.type="text"}if(G.userValue=z,G.lastCommittedValue!==z)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:Q,name:"Keystroke",value:z,willCommit:!0,commitKey:G.commitKey,selStart:B.target.selectionStart,selEnd:B.target.selectionEnd}});F(B)}),this.data.actions?.Keystroke)K.addEventListener("beforeinput",(B)=>{G.lastCommittedValue=null;let{data:A,target:z}=B,{value:O,selectionStart:S,selectionEnd:I}=z,C=S,T=I;switch(B.inputType){case"deleteWordBackward":{let k=O.substring(0,S).match(/\w*[^\w]*$/);if(k)C-=k[0].length;break}case"deleteWordForward":{let k=O.substring(S).match(/^[^\w]*\w*/);if(k)T+=k[0].length;break}case"deleteContentBackward":if(S===I)C-=1;break;case"deleteContentForward":if(S===I)T+=1;break}B.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:Q,name:"Keystroke",value:O,change:A||"",willCommit:!1,selStart:C,selEnd:T}})});this._setEventListeners(K,G,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(B)=>B.target.value)}if(j)K.addEventListener("blur",j);if(this.data.comb){let B=(this.data.rect[2]-this.data.rect[0])/_;K.classList.add("comb"),K.style.letterSpacing=`calc(${B}px * var(--total-scale-factor) - 1ch)`}}else if(K=document.createElement("div"),K.textContent=this.data.fieldValue,K.style.verticalAlign="middle",K.style.display="table-cell",this.data.hasOwnCanvas)K.hidden=!0;return this._setTextStyle(K),this._setBackgroundColor(K),this._setDefaultPropertiesFromJS(K),this.container.append(K),this.container}}class X8 extends UQ{constructor($){super($,{isRenderable:!!$.data.hasOwnCanvas})}}class Y8 extends UQ{constructor($){super($,{isRenderable:$.renderForms})}render(){let $=this.annotationStorage,Q=this.data,K=Q.id,Z=$.getValue(K,{value:Q.exportValue===Q.fieldValue}).value;if(typeof Z==="string")Z=Z!=="Off",$.setValue(K,{value:Z});this.container.classList.add("buttonWidgetAnnotation","checkBox");let J=document.createElement("input");if(BQ.add(J),J.setAttribute("data-element-id",K),J.disabled=Q.readOnly,this._setRequired(J,this.data.required),J.type="checkbox",J.name=Q.fieldName,Z)J.setAttribute("checked",!0);if(J.setAttribute("exportValue",Q.exportValue),J.tabIndex=0,J.addEventListener("change",(_)=>{let{name:q,checked:G}=_.target;for(let U of this._getElementsByName(q,K)){let V=G&&U.exportValue===Q.exportValue;if(U.domElement)U.domElement.checked=V;$.setValue(U.id,{value:V})}$.setValue(K,{value:G})}),J.addEventListener("resetform",(_)=>{let q=Q.defaultFieldValue||"Off";_.target.checked=q===Q.exportValue}),this.enableScripting&&this.hasJSActions)J.addEventListener("updatefromsandbox",(_)=>{let q={value(G){G.target.checked=G.detail.value!=="Off",$.setValue(K,{value:G.target.checked})}};this._dispatchEventFromSandbox(q,_)}),this._setEventListeners(J,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(_)=>_.target.checked);return this._setBackgroundColor(J),this._setDefaultPropertiesFromJS(J),this.container.append(J),this.container}}class D6 extends UQ{constructor($){super($,{isRenderable:$.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let $=this.annotationStorage,Q=this.data,K=Q.id,Z=$.getValue(K,{value:Q.fieldValue===Q.buttonValue}).value;if(typeof Z==="string")Z=Z!==Q.buttonValue,$.setValue(K,{value:Z});if(Z)for(let _ of this._getElementsByName(Q.fieldName,K))$.setValue(_.id,{value:!1});let J=document.createElement("input");if(BQ.add(J),J.setAttribute("data-element-id",K),J.disabled=Q.readOnly,this._setRequired(J,this.data.required),J.type="radio",J.name=Q.fieldName,Z)J.setAttribute("checked",!0);if(J.tabIndex=0,J.addEventListener("change",(_)=>{let{name:q,checked:G}=_.target;for(let U of this._getElementsByName(q,K))$.setValue(U.id,{value:!1});$.setValue(K,{value:G})}),J.addEventListener("resetform",(_)=>{let q=Q.defaultFieldValue;_.target.checked=q!==null&&q!==void 0&&q===Q.buttonValue}),this.enableScripting&&this.hasJSActions){let _=Q.buttonValue;J.addEventListener("updatefromsandbox",(q)=>{let G={value:(U)=>{let V=_===U.detail.value;for(let N of this._getElementsByName(U.target.name)){let R=V&&N.id===K;if(N.domElement)N.domElement.checked=R;$.setValue(N.id,{value:R})}}};this._dispatchEventFromSandbox(G,q)}),this._setEventListeners(J,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(q)=>q.target.checked)}return this._setBackgroundColor(J),this._setDefaultPropertiesFromJS(J),this.container.append(J),this.container}}class L8 extends y0{constructor($){super($,{ignoreBorder:$.data.hasAppearance})}render(){let $=super.render();$.classList.add("buttonWidgetAnnotation","pushButton");let Q=$.lastChild;if(this.enableScripting&&this.hasJSActions&&Q)this._setDefaultPropertiesFromJS(Q),Q.addEventListener("updatefromsandbox",(K)=>{this._dispatchEventFromSandbox({},K)});return $}}class P8 extends UQ{constructor($){super($,{isRenderable:$.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let $=this.annotationStorage,Q=this.data.id,K=$.getValue(Q,{value:this.data.fieldValue}),Z=document.createElement("select");BQ.add(Z),Z.setAttribute("data-element-id",Q),Z.disabled=this.data.readOnly,this._setRequired(Z,this.data.required),Z.name=this.data.fieldName,Z.tabIndex=0;let J=this.data.combo&&this.data.options.length>0;if(!this.data.combo){if(Z.size=this.data.options.length,this.data.multiSelect)Z.multiple=!0}Z.addEventListener("resetform",(V)=>{let N=this.data.defaultFieldValue;for(let R of Z.options)R.selected=R.value===N});for(let V of this.data.options){let N=document.createElement("option");if(N.textContent=V.displayValue,N.value=V.exportValue,K.value.includes(V.exportValue))N.setAttribute("selected",!0),J=!1;Z.append(N)}let _=null;if(J){let V=document.createElement("option");V.value=" ",V.setAttribute("hidden",!0),V.setAttribute("selected",!0),Z.prepend(V),_=()=>{V.remove(),Z.removeEventListener("input",_),_=null},Z.addEventListener("input",_)}let q=(V)=>{let N=V?"value":"textContent",{options:R,multiple:j}=Z;if(!j)return R.selectedIndex===-1?null:R[R.selectedIndex][N];return Array.prototype.filter.call(R,(F)=>F.selected).map((F)=>F[N])},G=q(!1),U=(V)=>{let N=V.target.options;return Array.prototype.map.call(N,(R)=>({displayValue:R.textContent,exportValue:R.value}))};if(this.enableScripting&&this.hasJSActions)Z.addEventListener("updatefromsandbox",(V)=>{let N={value(R){_?.();let j=R.detail.value,F=new Set(Array.isArray(j)?j:[j]);for(let B of Z.options)B.selected=F.has(B.value);$.setValue(Q,{value:q(!0)}),G=q(!1)},multipleSelection(R){Z.multiple=!0},remove(R){let j=Z.options,F=R.detail.remove;if(j[F].selected=!1,Z.remove(F),j.length>0){if(Array.prototype.findIndex.call(j,(A)=>A.selected)===-1)j[0].selected=!0}$.setValue(Q,{value:q(!0),items:U(R)}),G=q(!1)},clear(R){while(Z.length!==0)Z.remove(0);$.setValue(Q,{value:null,items:[]}),G=q(!1)},insert(R){let{index:j,displayValue:F,exportValue:B}=R.detail.insert,A=Z.children[j],z=document.createElement("option");if(z.textContent=F,z.value=B,A)A.before(z);else Z.append(z);$.setValue(Q,{value:q(!0),items:U(R)}),G=q(!1)},items(R){let{items:j}=R.detail;while(Z.length!==0)Z.remove(0);for(let F of j){let{displayValue:B,exportValue:A}=F,z=document.createElement("option");z.textContent=B,z.value=A,Z.append(z)}if(Z.options.length>0)Z.options[0].selected=!0;$.setValue(Q,{value:q(!0),items:U(R)}),G=q(!1)},indices(R){let j=new Set(R.detail.indices);for(let F of R.target.options)F.selected=j.has(F.index);$.setValue(Q,{value:q(!0)}),G=q(!1)},editable(R){R.target.disabled=!R.detail.editable}};this._dispatchEventFromSandbox(N,V)}),Z.addEventListener("input",(V)=>{let N=q(!0),R=q(!1);$.setValue(Q,{value:N}),V.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:Q,name:"Keystroke",value:G,change:R,changeEx:N,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(Z,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(V)=>V.target.value);else Z.addEventListener("input",function(V){$.setValue(Q,{value:q(!0)})});if(this.data.combo)this._setTextStyle(Z);return this._setBackgroundColor(Z),this._setDefaultPropertiesFromJS(Z),this.container.append(Z),this.container}}class k0 extends R${constructor($){let{data:Q,elements:K,parent:Z}=$,J=!!Z._commentManager;super($,{isRenderable:!J&&R$._hasPopupData(Q)});if(this.elements=K,J&&R$._hasPopupData(Q)){let _=this.popup=this.#$();for(let q of K)q.popup=_}else this.popup=null}#$(){return new H8({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})}render(){let{container:$}=this;$.classList.add("popupAnnotation"),$.role="comment";let Q=this.popup=this.#$(),K=[];for(let Z of this.elements)Z.popup=Q,Z.container.ariaHasPopup="dialog",K.push(Z.data.id),Z.addHighlightArea();return this.container.setAttribute("aria-controls",K.map((Z)=>`${F6}${Z}`).join(",")),this.container}}class H8{#$=null;#Q=this.#d.bind(this);#Z=this.#u.bind(this);#K=this.#f.bind(this);#q=this.#C.bind(this);#J=null;#_=null;#G=null;#V=null;#U=null;#j=null;#R=null;#B=!1;#z=null;#F=null;#N=null;#A=null;#O=null;#T=null;#S=null;#W=null;#E=null;#I=null;#Y=!1;#k=null;#M=null;constructor({container:$,color:Q,elements:K,titleObj:Z,modificationDate:J,contentsObj:_,richText:q,parent:G,rect:U,parentRect:V,open:N,commentManager:R=null}){if(this.#_=$,this.#E=Z,this.#G=_,this.#W=q,this.#j=G,this.#J=Q,this.#S=U,this.#R=V,this.#U=K,this.#$=R,this.#k=K[0],this.#V=jQ.toDateObject(J),this.trigger=K.flatMap((j)=>j.getElementsToTriggerPopup()),R)this.renderCommentButton();else if(this.#H(),this.#_.hidden=!0,N)this.#C()}#H(){if(this.#F)return;this.#F=new AbortController;let{signal:$}=this.#F;for(let Q of this.trigger)Q.addEventListener("click",this.#q,{signal:$}),Q.addEventListener("pointerenter",this.#K,{signal:$}),Q.addEventListener("pointerleave",this.#Z,{signal:$}),Q.classList.add("popupTriggerArea");for(let Q of this.#U)Q.container?.addEventListener("keydown",this.#Q,{signal:$})}#L(){let $=this.#U.find((Q)=>Q.hasCommentButton);if(!$)return;this.#O=$._normalizePoint($.commentButtonPosition)}renderCommentButton(){if(this.#A)return;if(!this.#O)this.#L();if(!this.#O)return;let{signal:$}=this.#F=new AbortController,Q=!!this.#k.extraPopupElement,K=()=>{this.#$.toggleCommentPopup(this,!0,void 0,!Q)},Z=()=>{this.#$.toggleCommentPopup(this,!1,!0,!Q)},J=()=>{this.#$.toggleCommentPopup(this,!1,!1)};if(!Q){let _=this.#A=document.createElement("button");_.className="annotationCommentButton";let q=this.#k.container;_.style.zIndex=q.style.zIndex+1,_.tabIndex=0,_.ariaHasPopup="dialog",_.ariaControls="commentPopup",_.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#x(),this.#P(),_.addEventListener("keydown",this.#Q,{signal:$}),_.addEventListener("click",K,{signal:$}),_.addEventListener("pointerenter",Z,{signal:$}),_.addEventListener("pointerleave",J,{signal:$}),q.after(_)}else{this.#A=this.#k.container;for(let _ of this.trigger)_.ariaHasPopup="dialog",_.ariaControls="commentPopup",_.addEventListener("keydown",this.#Q,{signal:$}),_.addEventListener("click",K,{signal:$}),_.addEventListener("pointerenter",Z,{signal:$}),_.addEventListener("pointerleave",J,{signal:$}),_.classList.add("popupTriggerArea")}}#P(){if(this.#k.extraPopupElement&&!this.#k.editor)return;this.renderCommentButton();let[$,Q]=this.#O,{style:K}=this.#A;K.left=`calc(${$}%)`,K.top=`calc(${Q}% - var(--comment-button-dim))`}#x(){if(this.#k.extraPopupElement)return;this.renderCommentButton(),this.#A.style.backgroundColor=this.commentButtonColor||""}get commentButtonColor(){let{color:$,opacity:Q}=this.#k.commentData;if(!$)return null;return this.#j._commentManager.makeCommentColor($,Q)}focusCommentButton(){setTimeout(()=>{this.#A?.focus()},0)}getData(){let{richText:$,color:Q,opacity:K,creationDate:Z,modificationDate:J}=this.#k.commentData;return{contentsObj:{str:this.comment},richText:$,color:Q,opacity:K,creationDate:Z,modificationDate:J}}get elementBeforePopup(){return this.#A}get comment(){return this.#M||=this.#k.commentText,this.#M}set comment($){if($===this.comment)return;this.#k.commentText=this.#M=$}get parentBoundingClientRect(){return this.#k.layer.getBoundingClientRect()}setCommentButtonStates({selected:$,hasPopup:Q}){if(!this.#A)return;this.#A.classList.toggle("selected",$),this.#A.ariaExpanded=Q}setSelectedCommentButton($){this.#A.classList.toggle("selected",$)}get commentPopupPosition(){if(this.#T)return this.#T;let{x:$,y:Q,height:K}=this.#A.getBoundingClientRect(),{x:Z,y:J,width:_,height:q}=this.#k.layer.getBoundingClientRect();return[($-Z)/_,(Q+K-J)/q]}set commentPopupPosition($){this.#T=$}hasDefaultPopupPosition(){return this.#T===null}get commentButtonPosition(){return this.#O}get commentButtonWidth(){return this.#A.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment($){let[Q,K]=this.#T||this.commentButtonPosition.map((U)=>U/100),Z=this.parentBoundingClientRect,{x:J,y:_,width:q,height:G}=Z;this.#$.showDialog(null,this,J+Q*q,_+K*G,{...$,parentDimensions:Z})}render(){if(this.#z)return;let $=this.#z=document.createElement("div");if($.className="popup",this.#J){let K=$.style.outlineColor=x.makeHexColor(...this.#J);$.style.backgroundColor=`color-mix(in srgb, ${K} 30%, white)`}let Q=document.createElement("span");if(Q.className="header",this.#E?.str){let K=document.createElement("span");K.className="title",Q.append(K),{dir:K.dir,str:K.textContent}=this.#E}if($.append(Q),this.#V){let K=document.createElement("time");K.className="popupDate",K.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),K.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#V.valueOf()})),K.dateTime=this.#V.toISOString(),Q.append(K)}z6({html:this.#v||this.#G.str,dir:this.#G?.dir,className:"popupContent"},$),this.#_.append($)}get#v(){let $=this.#W,Q=this.#G;if($?.str&&(!Q?.str||Q.str===$.str))return this.#W.html||null;return null}get#w(){return this.#v?.attributes?.style?.fontSize||0}get#c(){return this.#v?.attributes?.style?.color||null}#b($){let Q=[],K={str:$,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:Q}]}},Z={style:{color:this.#c,fontSize:this.#w?`calc(${this.#w}px * var(--total-scale-factor))`:""}};for(let J of $.split(`
6
+ `))Q.push({name:"span",value:J,attributes:Z});return K}#d($){if($.altKey||$.shiftKey||$.ctrlKey||$.metaKey)return;if($.key==="Enter"||$.key==="Escape"&&this.#B)this.#C()}updateEdited({rect:$,popup:Q,deleted:K}){if(this.#$){if(K)this.remove(),this.#M=null;else if(Q)if(Q.deleted)this.remove();else this.#x(),this.#M=Q.text;if($)this.#O=null,this.#L(),this.#P();return}if(K||Q?.deleted){this.remove();return}if(this.#H(),this.#I||={contentsObj:this.#G,richText:this.#W},$)this.#N=null;if(Q&&Q.text)this.#W=this.#b(Q.text),this.#V=jQ.toDateObject(Q.date),this.#G=null;this.#z?.remove(),this.#z=null}resetEdited(){if(!this.#I)return;({contentsObj:this.#G,richText:this.#W}=this.#I),this.#I=null,this.#z?.remove(),this.#z=null,this.#N=null}remove(){if(this.#F?.abort(),this.#F=null,this.#z?.remove(),this.#z=null,this.#Y=!1,this.#B=!1,this.#A?.remove(),this.#A=null,this.trigger)for(let $ of this.trigger)$.classList.remove("popupTriggerArea")}#X(){if(this.#N!==null)return;let{page:{view:$},viewport:{rawDims:{pageWidth:Q,pageHeight:K,pageX:Z,pageY:J}}}=this.#j,_=!!this.#R,q=_?this.#R:this.#S;for(let F of this.#U)if(!q||x.intersect(F.data.rect,q)!==null){q=F.data.rect,_=!0;break}let G=x.normalizeRect([q[0],$[3]-q[1]+$[1],q[2],$[3]-q[3]+$[1]]),U=5,V=_?q[2]-q[0]+U:0,N=G[0]+V,R=G[1];this.#N=[100*(N-Z)/Q,100*(R-J)/K];let{style:j}=this.#_;j.left=`${this.#N[0]}%`,j.top=`${this.#N[1]}%`}#C(){if(this.#$){this.#$.toggleCommentPopup(this,!1);return}if(this.#B=!this.#B,this.#B)this.#f(),this.#_.addEventListener("click",this.#q),this.#_.addEventListener("keydown",this.#Q);else this.#u(),this.#_.removeEventListener("click",this.#q),this.#_.removeEventListener("keydown",this.#Q)}#f(){if(!this.#z)this.render();if(!this.isVisible)this.#X(),this.#_.hidden=!1,this.#_.style.zIndex=parseInt(this.#_.style.zIndex)+1000;else if(this.#B)this.#_.classList.add("focused")}#u(){if(this.#_.classList.remove("focused"),this.#B||!this.isVisible)return;this.#_.hidden=!0,this.#_.style.zIndex=parseInt(this.#_.style.zIndex)-1000}forceHide(){if(this.#Y=this.isVisible,!this.#Y)return;this.#_.hidden=!0}maybeShow(){if(this.#$)return;if(this.#H(),!this.#Y)return;if(!this.#z)this.#f();this.#Y=!1,this.#_.hidden=!1}get isVisible(){if(this.#$)return!1;return this.#_.hidden===!1}}class v6 extends R${constructor($){super($,{isRenderable:!0,ignoreBorder:!0});this.textContent=$.data.textContent,this.textPosition=$.data.textPosition,this.annotationEditorType=d.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let $=document.createElement("div");$.classList.add("annotationTextContent"),$.setAttribute("role","comment");for(let Q of this.textContent){let K=document.createElement("span");K.textContent=Q,$.append(K)}this.container.append($)}if(!this.data.popupRef&&this.hasPopupData)this._createPopup();return this._editOnDoubleClick(),this.container}}class D8 extends R${#$=null;constructor($){super($,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:$,width:Q,height:K}=this,Z=this.svgFactory.create(Q,K,!0),J=this.#$=this.svgFactory.createElement("svg:line");if(J.setAttribute("x1",$.rect[2]-$.lineCoordinates[0]),J.setAttribute("y1",$.rect[3]-$.lineCoordinates[1]),J.setAttribute("x2",$.rect[2]-$.lineCoordinates[2]),J.setAttribute("y2",$.rect[3]-$.lineCoordinates[3]),J.setAttribute("stroke-width",$.borderStyle.width||1),J.setAttribute("stroke","transparent"),J.setAttribute("fill","transparent"),Z.append(J),this.container.append(Z),!$.popupRef&&this.hasPopupData)this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#$}addHighlightArea(){this.container.classList.add("highlightArea")}}class v8 extends R${#$=null;constructor($){super($,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:$,width:Q,height:K}=this,Z=this.svgFactory.create(Q,K,!0),J=$.borderStyle.width,_=this.#$=this.svgFactory.createElement("svg:rect");if(_.setAttribute("x",J/2),_.setAttribute("y",J/2),_.setAttribute("width",Q-J),_.setAttribute("height",K-J),_.setAttribute("stroke-width",J||1),_.setAttribute("stroke","transparent"),_.setAttribute("fill","transparent"),Z.append(_),this.container.append(Z),!$.popupRef&&this.hasPopupData)this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#$}addHighlightArea(){this.container.classList.add("highlightArea")}}class f8 extends R${#$=null;constructor($){super($,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:$,width:Q,height:K}=this,Z=this.svgFactory.create(Q,K,!0),J=$.borderStyle.width,_=this.#$=this.svgFactory.createElement("svg:ellipse");if(_.setAttribute("cx",Q/2),_.setAttribute("cy",K/2),_.setAttribute("rx",Q/2-J/2),_.setAttribute("ry",K/2-J/2),_.setAttribute("stroke-width",J||1),_.setAttribute("stroke","transparent"),_.setAttribute("fill","transparent"),Z.append(_),this.container.append(Z),!$.popupRef&&this.hasPopupData)this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#$}addHighlightArea(){this.container.classList.add("highlightArea")}}class f6 extends R${#$=null;constructor($){super($,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:$,vertices:Q,borderStyle:K,popupRef:Z},width:J,height:_}=this;if(!Q)return this.container;let q=this.svgFactory.create(J,_,!0),G=[];for(let V=0,N=Q.length;V<N;V+=2){let R=Q[V]-$[0],j=$[3]-Q[V+1];G.push(`${R},${j}`)}G=G.join(" ");let U=this.#$=this.svgFactory.createElement(this.svgElementName);if(U.setAttribute("points",G),U.setAttribute("stroke-width",K.width||1),U.setAttribute("stroke","transparent"),U.setAttribute("fill","transparent"),q.append(U),this.container.append(q),!Z&&this.hasPopupData)this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#$}addHighlightArea(){this.container.classList.add("highlightArea")}}class w8 extends f6{constructor($){super($);this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class b8 extends R${constructor($){super($,{isRenderable:!0,ignoreBorder:!0})}render(){if(this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData)this._createPopup();return this.container}}class x0 extends R${#$=null;#Q=[];constructor($){super($,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?d.HIGHLIGHT:d.INK}#Z($,Q){switch($){case 90:return{transform:`rotate(90) translate(${-Q[0]},${Q[1]}) scale(1,-1)`,width:Q[3]-Q[1],height:Q[2]-Q[0]};case 180:return{transform:`rotate(180) translate(${-Q[2]},${Q[1]}) scale(1,-1)`,width:Q[2]-Q[0],height:Q[3]-Q[1]};case 270:return{transform:`rotate(270) translate(${-Q[2]},${Q[3]}) scale(1,-1)`,width:Q[3]-Q[1],height:Q[2]-Q[0]};default:return{transform:`translate(${-Q[0]},${Q[3]}) scale(1,-1)`,width:Q[2]-Q[0],height:Q[3]-Q[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:$,rotation:Q,inkLists:K,borderStyle:Z,popupRef:J}}=this,{transform:_,width:q,height:G}=this.#Z(Q,$),U=this.svgFactory.create(q,G,!0),V=this.#$=this.svgFactory.createElement("svg:g");U.append(V),V.setAttribute("stroke-width",Z.width||1),V.setAttribute("stroke-linecap","round"),V.setAttribute("stroke-linejoin","round"),V.setAttribute("stroke-miterlimit",10),V.setAttribute("stroke","transparent"),V.setAttribute("fill","transparent"),V.setAttribute("transform",_);for(let N=0,R=K.length;N<R;N++){let j=this.svgFactory.createElement(this.svgElementName);this.#Q.push(j),j.setAttribute("points",K[N].join(",")),V.append(j)}if(!J&&this.hasPopupData)this._createPopup();return this.container.append(U),this._editOnDoubleClick(),this.container}updateEdited($){super.updateEdited($);let{thickness:Q,points:K,rect:Z}=$,J=this.#$;if(Q>=0)J.setAttribute("stroke-width",Q||1);if(K)for(let _=0,q=this.#Q.length;_<q;_++)this.#Q[_].setAttribute("points",K[_].join(","));if(Z){let{transform:_,width:q,height:G}=this.#Z(this.data.rotation,Z);J.parentElement.setAttribute("viewBox",`0 0 ${q} ${G}`),J.setAttribute("transform",_)}}getElementsToTriggerPopup(){return this.#Q}addHighlightArea(){this.container.classList.add("highlightArea")}}class w6 extends R${constructor($){super($,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0});this.annotationEditorType=d.HIGHLIGHT}render(){let{data:{overlaidText:$,popupRef:Q}}=this;if(!Q&&this.hasPopupData)this._createPopup();if(this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),$){let K=document.createElement("mark");K.classList.add("overlaidText"),K.textContent=$,this.container.append(K)}return this.container}}class y8 extends R${constructor($){super($,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:$,popupRef:Q}}=this;if(!Q&&this.hasPopupData)this._createPopup();if(this.container.classList.add("underlineAnnotation"),$){let K=document.createElement("u");K.classList.add("overlaidText"),K.textContent=$,this.container.append(K)}return this.container}}class x8 extends R${constructor($){super($,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:$,popupRef:Q}}=this;if(!Q&&this.hasPopupData)this._createPopup();if(this.container.classList.add("squigglyAnnotation"),$){let K=document.createElement("u");K.classList.add("overlaidText"),K.textContent=$,this.container.append(K)}return this.container}}class c8 extends R${constructor($){super($,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:$,popupRef:Q}}=this;if(!Q&&this.hasPopupData)this._createPopup();if(this.container.classList.add("strikeoutAnnotation"),$){let K=document.createElement("s");K.classList.add("overlaidText"),K.textContent=$,this.container.append(K)}return this.container}}class b6 extends R${constructor($){super($,{isRenderable:!0,ignoreBorder:!0});this.annotationEditorType=d.STAMP}render(){if(this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData)this._createPopup();return this._editOnDoubleClick(),this.container}}class u8 extends R${#$=null;constructor($){super($,{isRenderable:!0});let{file:Q}=this.data;this.filename=Q.filename,this.content=Q.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...Q})}render(){this.container.classList.add("fileAttachmentAnnotation");let{container:$,data:Q}=this,K;if(Q.hasAppearance||Q.fillAlpha===0)K=document.createElement("div");else if(K=document.createElement("img"),K.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(Q.name)?"paperclip":"pushpin"}.svg`,Q.fillAlpha&&Q.fillAlpha<1)K.style=`filter: opacity(${Math.round(Q.fillAlpha*100)}%);`;K.addEventListener("dblclick",this.#Q.bind(this)),this.#$=K;let{isMac:Z}=S$.platform;if($.addEventListener("keydown",(J)=>{if(J.key==="Enter"&&(Z?J.metaKey:J.ctrlKey))this.#Q()}),!Q.popupRef&&this.hasPopupData)this._createPopup();else K.classList.add("popupTriggerArea");return $.append(K),$}getElementsToTriggerPopup(){return this.#$}addHighlightArea(){this.container.classList.add("highlightArea")}#Q(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class c0{#$=null;#Q=null;#Z=null;#K=new Map;#q=null;#J=null;constructor({div:$,accessibilityManager:Q,annotationCanvasMap:K,annotationEditorUIManager:Z,page:J,viewport:_,structTreeLayer:q,commentManager:G,linkService:U,annotationStorage:V}){this.div=$,this.#$=Q,this.#Q=K,this.#q=q||null,this.#J=U||null,this.#Z=V||new v0,this.page=J,this.viewport=_,this.zIndex=0,this._annotationEditorUIManager=Z,this._commentManager=G||null}hasEditableAnnotations(){return this.#K.size>0}async#_($,Q,K){let Z=$.firstChild||$,J=Z.id=`${F6}${Q}`,_=await this.#q?.getAriaAttributes(J);if(_)for(let[q,G]of _)Z.setAttribute(q,G);if(K)K.at(-1).container.after($);else this.div.append($),this.#$?.moveElementInDOM(this.div,$,Z,!1)}async render($){let{annotations:Q}=$,K=this.div;GQ(K,this.viewport);let Z=new Map,J={data:null,layer:K,linkService:this.#J,downloadManager:$.downloadManager,imageResourcesPath:$.imageResourcesPath||"",renderForms:$.renderForms!==!1,svgFactory:new PQ,annotationStorage:this.#Z,enableComment:$.enableComment===!0,enableScripting:$.enableScripting===!0,hasJSActions:$.hasJSActions,fieldObjects:$.fieldObjects,parent:this,elements:null};for(let _ of Q){if(_.noHTML)continue;let q=_.annotationType===j$.POPUP;if(!q){if(_.rect[2]===_.rect[0]||_.rect[3]===_.rect[1])continue}else{let V=Z.get(_.id);if(!V)continue;J.elements=V}J.data=_;let G=U6.create(J);if(!G.isRenderable)continue;if(!q&&_.popupRef){let V=Z.get(_.popupRef);if(!V)Z.set(_.popupRef,[G]);else V.push(G)}let U=G.render();if(_.hidden)U.style.visibility="hidden";if(await this.#_(U,_.id,J.elements),G.extraPopupElement?.popup?.renderCommentButton(),G._isEditable)this.#K.set(G.data.id,G),this._annotationEditorUIManager?.renderAnnotationElement(G)}this.#G()}async addLinkAnnotations($){let Q={data:null,layer:this.div,linkService:this.#J,svgFactory:new PQ,parent:this};for(let K of $){K.borderStyle||=c0._defaultBorderStyle,Q.data=K;let Z=U6.create(Q);if(!Z.isRenderable)continue;let J=Z.render();await this.#_(J,K.id,null)}}update({viewport:$}){let Q=this.div;this.viewport=$,GQ(Q,{rotation:$.rotation}),this.#G(),Q.hidden=!1}#G(){if(!this.#Q)return;let $=this.div;for(let[Q,K]of this.#Q){let Z=$.querySelector(`[data-annotation-id="${Q}"]`);if(!Z)continue;K.className="annotationContent";let{firstChild:J}=Z;if(!J)Z.append(K);else if(J.nodeName==="CANVAS")J.replaceWith(K);else if(!J.classList.contains("annotationContent"))J.before(K);else J.after(K);let _=this.#K.get(Q);if(!_)continue;if(_._hasNoCanvas)this._annotationEditorUIManager?.setMissingCanvas(Q,Z.id,K),_._hasNoCanvas=!1;else _.canvas=K}this.#Q.clear()}getEditableAnnotations(){return Array.from(this.#K.values())}getEditableAnnotation($){return this.#K.get($)}addFakeAnnotation($){let{div:Q}=this,{id:K,rotation:Z}=$,J=new E8({data:{id:K,rect:$.getPDFRect(),rotation:Z},editor:$,layer:Q,parent:this,enableComment:!!this._commentManager,linkService:this.#J,annotationStorage:this.#Z}),_=J.render();return Q.append(_),this.#$?.moveElementInDOM(Q,_,_,!1),J.createOrUpdatePopup(),J}static get _defaultBorderStyle(){return r(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:SQ.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}var A0=/\r\n?|\n/g;class I$ extends m{#$="";#Q=`${this.id}-editor`;#Z=null;#K;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let $=I$.prototype,Q=(J)=>J.isEmpty(),K=ZQ.TRANSLATE_SMALL,Z=ZQ.TRANSLATE_BIG;return r(this,"_keyboardManager",new vQ([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],$.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],$.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],$._translateEmpty,{args:[-K,0],checker:Q}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],$._translateEmpty,{args:[-Z,0],checker:Q}],[["ArrowRight","mac+ArrowRight"],$._translateEmpty,{args:[K,0],checker:Q}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],$._translateEmpty,{args:[Z,0],checker:Q}],[["ArrowUp","mac+ArrowUp"],$._translateEmpty,{args:[0,-K],checker:Q}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],$._translateEmpty,{args:[0,-Z],checker:Q}],[["ArrowDown","mac+ArrowDown"],$._translateEmpty,{args:[0,K],checker:Q}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],$._translateEmpty,{args:[0,Z],checker:Q}]]))}static _type="freetext";static _editorType=d.FREETEXT;constructor($){super({...$,name:"freeTextEditor"});if(this.color=$.color||I$._defaultColor||m._defaultLineColor,this.#K=$.fontSize||I$._defaultFontSize,!this.annotationElementId)this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static initialize($,Q){m.initialize($,Q);let K=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(K.getPropertyValue("--freetext-padding"))}static updateDefaultParams($,Q){switch($){case n.FREETEXT_SIZE:I$._defaultFontSize=Q;break;case n.FREETEXT_COLOR:I$._defaultColor=Q;break}}updateParams($,Q){switch($){case n.FREETEXT_SIZE:this.#q(Q);break;case n.FREETEXT_COLOR:this.#J(Q);break}}static get defaultPropertiesToUpdate(){return[[n.FREETEXT_SIZE,I$._defaultFontSize],[n.FREETEXT_COLOR,I$._defaultColor||m._defaultLineColor]]}get propertiesToUpdate(){return[[n.FREETEXT_SIZE,this.#K],[n.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new sQ(this),[["colorPicker",this._colorPicker]]}get colorType(){return n.FREETEXT_COLOR}#q($){let Q=(Z)=>{this.editorDiv.style.fontSize=`calc(${Z}px * var(--total-scale-factor))`,this.translate(0,-(Z-this.#K)*this.parentScale),this.#K=Z,this.#G()},K=this.#K;this.addCommands({cmd:Q.bind(this,$),undo:Q.bind(this,K),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#J($){let Q=(Z)=>{this.color=Z,this.onUpdatedColor()},K=this.color;this.addCommands({cmd:Q.bind(this,$),undo:Q.bind(this,K),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty($,Q){this._uiManager.translateSelectedEditors($,Q,!0)}getInitialTranslation(){let $=this.parentScale;return[-I$._internalPadding*$,-(I$._internalPadding+this.#K)*$]}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(!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"),this.#Z=new AbortController;let $=this._uiManager.combinedSignal(this.#Z);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:$}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:$}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:$}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:$}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:$}),!0}disableEditMode(){if(!super.disableEditMode())return!1;return this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Q),this._isDraggable=!0,this.#Z?.abort(),this.#Z=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0}focusin($){if(!this._focusEventsAllowed)return;if(super.focusin($),$.target!==this.editorDiv)this.editorDiv.focus()}onceAdded($){if(this.width)return;if(this.enableEditMode(),$)this.editorDiv.focus();if(this._initialOptions?.isCentered)this.center();this._initialOptions=null}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){if(this.isEditing=!1,this.parent)this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing");super.remove()}#_(){let $=[];this.editorDiv.normalize();let Q=null;for(let K of this.editorDiv.childNodes){if(Q?.nodeType===Node.TEXT_NODE&&K.nodeName==="BR")continue;$.push(I$.#V(K)),Q=K}return $.join(`
7
+ `)}#G(){let[$,Q]=this.parentDimensions,K;if(this.isAttachedToDOM)K=this.div.getBoundingClientRect();else{let{currentLayer:Z,div:J}=this,_=J.style.display,q=J.classList.contains("hidden");J.classList.remove("hidden"),J.style.display="hidden",Z.div.append(this.div),K=J.getBoundingClientRect(),J.remove(),J.style.display=_,J.classList.toggle("hidden",q)}if(this.rotation%180===this.parentRotation%180)this.width=K.width/$,this.height=K.height/Q;else this.width=K.height/$,this.height=K.width/Q;this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let $=this.#$,Q=this.#$=this.#_().trimEnd();if($===Q)return;let K=(Z)=>{if(this.#$=Z,!Z){this.remove();return}this.#U(),this._uiManager.rebuild(this),this.#G()};this.addCommands({cmd:()=>{K(Q)},undo:()=>{K($)},mustExec:!1}),this.#G()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown($){if($.target===this.div&&$.key==="Enter")this.enterInEditMode(),$.preventDefault()}editorDivKeydown($){I$._keyboardManager.exec(this,$)}editorDivFocus($){this.isEditing=!0}editorDivBlur($){this.isEditing=!1}editorDivInput($){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 $,Q;if(this._isCopy||this.annotationElementId)$=this.x,Q=this.y;super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Q),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:K}=this.editorDiv;if(K.fontSize=`calc(${this.#K}px * var(--total-scale-factor))`,K.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){let[Z,J]=this.parentDimensions;if(this.annotationElementId){let{position:_}=this._initialData,[q,G]=this.getInitialTranslation();[q,G]=this.pageTranslationToScreen(q,G);let[U,V]=this.pageDimensions,[N,R]=this.pageTranslation,j,F;switch(this.rotation){case 0:j=$+(_[0]-N)/U,F=Q+this.height-(_[1]-R)/V;break;case 90:j=$+(_[0]-N)/U,F=Q-(_[1]-R)/V,[q,G]=[G,-q];break;case 180:j=$-this.width+(_[0]-N)/U,F=Q-(_[1]-R)/V,[q,G]=[-q,-G];break;case 270:j=$+(_[0]-N-this.height*V)/U,F=Q+(_[1]-R-this.width*U)/V,[q,G]=[-G,q];break}this.setAt(j*Z,F*J,q,G)}else this._moveAfterPaste($,Q);this.#U(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#V($){return($.nodeType===Node.TEXT_NODE?$.nodeValue:$.innerText).replaceAll(A0,"")}editorDivPaste($){let Q=$.clipboardData||window.clipboardData,{types:K}=Q;if(K.length===1&&K[0]==="text/plain")return;$.preventDefault();let Z=I$.#R(Q.getData("text")||"").replaceAll(A0,`
8
+ `);if(!Z)return;let J=window.getSelection();if(!J.rangeCount)return;this.editorDiv.normalize(),J.deleteFromDocument();let _=J.getRangeAt(0);if(!Z.includes(`
9
+ `)){_.insertNode(document.createTextNode(Z)),this.editorDiv.normalize(),J.collapseToStart();return}let{startContainer:q,startOffset:G}=_,U=[],V=[];if(q.nodeType===Node.TEXT_NODE){let j=q.parentElement;if(V.push(q.nodeValue.slice(G).replaceAll(A0,"")),j!==this.editorDiv){let F=U;for(let B of this.editorDiv.childNodes){if(B===j){F=V;continue}F.push(I$.#V(B))}}U.push(q.nodeValue.slice(0,G).replaceAll(A0,""))}else if(q===this.editorDiv){let j=U,F=0;for(let B of this.editorDiv.childNodes){if(F++===G)j=V;j.push(I$.#V(B))}}this.#$=`${U.join(`
10
+ `)}${Z}${V.join(`
11
+ `)}`,this.#U();let N=new Range,R=Math.sumPrecise(U.map((j)=>j.length));for(let{firstChild:j}of this.editorDiv.childNodes)if(j.nodeType===Node.TEXT_NODE){let F=j.nodeValue.length;if(R<=F){N.setStart(j,R),N.setEnd(j,R);break}R-=F}J.removeAllRanges(),J.addRange(N)}#U(){if(this.editorDiv.replaceChildren(),!this.#$)return;for(let $ of this.#$.split(`
12
+ `)){let Q=document.createElement("div");Q.append($?document.createTextNode($):document.createElement("br")),this.editorDiv.append(Q)}}#j(){return this.#$.replaceAll(" "," ")}static#R($){return $.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){let $=I$._internalPadding*this.parentScale;return this.getRect($,$)}static async deserialize($,Q,K){let Z=null;if($ instanceof v6){let{data:{defaultAppearanceData:{fontSize:_,fontColor:q},rect:G,rotation:U,id:V,popupRef:N,richText:R,contentsObj:j,creationDate:F,modificationDate:B},textContent:A,textPosition:z,parent:{page:{pageNumber:O}}}=$;if(!A||A.length===0)return null;Z=$={annotationType:d.FREETEXT,color:Array.from(q),fontSize:_,value:A.join(`
13
+ `),position:z,pageIndex:O-1,rect:G.slice(0),rotation:U,annotationElementId:V,id:V,deleted:!1,popupRef:N,comment:j?.str||null,richText:R,creationDate:F,modificationDate:B}}let J=await super.deserialize($,Q,K);if(J.#K=$.fontSize,J.color=x.makeHexColor(...$.color),J.#$=I$.#R($.value),J._initialData=Z,$.comment)J.setCommentData($);return J}serialize($=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let Q=m._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),K=Object.assign(super.serialize($),{color:Q,fontSize:this.#K,value:this.#j()});if(this.addComment(K),$)return K.isCopy=!0,K;if(this.annotationElementId&&!this.#B(K))return null;return K.id=this.annotationElementId,K}#B($){let{value:Q,fontSize:K,color:Z,pageIndex:J}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||$.value!==Q||$.fontSize!==K||$.color.some((_,q)=>_!==Z[q])||$.pageIndex!==J}renderAnnotationElement($){let Q=super.renderAnnotationElement($);if(!Q)return null;let{style:K}=Q;K.fontSize=`calc(${this.#K}px * var(--total-scale-factor))`,K.color=this.color,Q.replaceChildren();for(let Z of this.#$.split(`
14
+ `)){let J=document.createElement("div");J.append(Z?document.createTextNode(Z):document.createElement("br")),Q.append(J)}return $.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#$}}),Q}resetAnnotationElement($){super.resetAnnotationElement($),$.resetEdited()}}class c{static PRECISION=0.0001;toSVGPath(){Z$("Abstract method `toSVGPath` must be implemented.")}get box(){Z$("Abstract getter `box` must be implemented.")}serialize($,Q){Z$("Abstract method `serialize` must be implemented.")}static _rescale($,Q,K,Z,J,_){_||=new Float32Array($.length);for(let q=0,G=$.length;q<G;q+=2)_[q]=Q+$[q]*Z,_[q+1]=K+$[q+1]*J;return _}static _rescaleAndSwap($,Q,K,Z,J,_){_||=new Float32Array($.length);for(let q=0,G=$.length;q<G;q+=2)_[q]=Q+$[q+1]*Z,_[q+1]=K+$[q]*J;return _}static _translate($,Q,K,Z){Z||=new Float32Array($.length);for(let J=0,_=$.length;J<_;J+=2)Z[J]=Q+$[J],Z[J+1]=K+$[J+1];return Z}static svgRound($){return Math.round($*1e4)}static _normalizePoint($,Q,K,Z,J){switch(J){case 90:return[1-Q/K,$/Z];case 180:return[1-$/K,1-Q/Z];case 270:return[Q/K,1-$/Z];default:return[$/K,Q/Z]}}static _normalizePagePoint($,Q,K){switch(K){case 90:return[1-Q,$];case 180:return[1-$,1-Q];case 270:return[Q,1-$];default:return[$,Q]}}static createBezierPoints($,Q,K,Z,J,_){return[($+5*K)/6,(Q+5*Z)/6,(5*K+J)/6,(5*Z+_)/6,(K+J)/2,(Z+_)/2]}}class NQ{#$;#Q=[];#Z;#K;#q=[];#J=new Float32Array(18);#_;#G;#V;#U;#j;#R;#B=[];static#z=8;static#F=2;static#N=NQ.#z+NQ.#F;constructor({x:$,y:Q},K,Z,J,_,q=0){this.#$=K,this.#R=J*Z,this.#K=_,this.#J.set([NaN,NaN,NaN,NaN,$,Q],6),this.#Z=q,this.#U=NQ.#z*Z,this.#V=NQ.#N*Z,this.#j=Z,this.#B.push($,Q)}isEmpty(){return isNaN(this.#J[8])}#A(){let $=this.#J.subarray(4,6),Q=this.#J.subarray(16,18),[K,Z,J,_]=this.#$;return[(this.#_+($[0]-Q[0])/2-K)/J,(this.#G+($[1]-Q[1])/2-Z)/_,(this.#_+(Q[0]-$[0])/2-K)/J,(this.#G+(Q[1]-$[1])/2-Z)/_]}add({x:$,y:Q}){this.#_=$,this.#G=Q;let[K,Z,J,_]=this.#$,[q,G,U,V]=this.#J.subarray(8,12),N=$-U,R=Q-V,j=Math.hypot(N,R);if(j<this.#V)return!1;let F=j-this.#U,B=F/j,A=B*N,z=B*R,O=q,S=G;q=U,G=V,U+=A,V+=z,this.#B?.push($,Q);let I=-z/F,C=A/F,T=I*this.#R,k=C*this.#R;if(this.#J.set(this.#J.subarray(2,8),0),this.#J.set([U+T,V+k],4),this.#J.set(this.#J.subarray(14,18),12),this.#J.set([U-T,V-k],16),isNaN(this.#J[6])){if(this.#q.length===0)this.#J.set([q+T,G+k],2),this.#q.push(NaN,NaN,NaN,NaN,(q+T-K)/J,(G+k-Z)/_),this.#J.set([q-T,G-k],14),this.#Q.push(NaN,NaN,NaN,NaN,(q-T-K)/J,(G-k-Z)/_);return this.#J.set([O,S,q,G,U,V],6),!this.isEmpty()}if(this.#J.set([O,S,q,G,U,V],6),Math.abs(Math.atan2(S-G,O-q)-Math.atan2(z,A))<Math.PI/2)return[q,G,U,V]=this.#J.subarray(2,6),this.#q.push(NaN,NaN,NaN,NaN,((q+U)/2-K)/J,((G+V)/2-Z)/_),[q,G,O,S]=this.#J.subarray(14,18),this.#Q.push(NaN,NaN,NaN,NaN,((O+q)/2-K)/J,((S+G)/2-Z)/_),!0;return[O,S,q,G,U,V]=this.#J.subarray(0,6),this.#q.push(((O+5*q)/6-K)/J,((S+5*G)/6-Z)/_,((5*q+U)/6-K)/J,((5*G+V)/6-Z)/_,((q+U)/2-K)/J,((G+V)/2-Z)/_),[U,V,q,G,O,S]=this.#J.subarray(12,18),this.#Q.push(((O+5*q)/6-K)/J,((S+5*G)/6-Z)/_,((5*q+U)/6-K)/J,((5*G+V)/6-Z)/_,((q+U)/2-K)/J,((G+V)/2-Z)/_),!0}toSVGPath(){if(this.isEmpty())return"";let $=this.#q,Q=this.#Q;if(isNaN(this.#J[6])&&!this.isEmpty())return this.#O();let K=[];K.push(`M${$[4]} ${$[5]}`);for(let Z=6;Z<$.length;Z+=6)if(isNaN($[Z]))K.push(`L${$[Z+4]} ${$[Z+5]}`);else K.push(`C${$[Z]} ${$[Z+1]} ${$[Z+2]} ${$[Z+3]} ${$[Z+4]} ${$[Z+5]}`);this.#S(K);for(let Z=Q.length-6;Z>=6;Z-=6)if(isNaN(Q[Z]))K.push(`L${Q[Z+4]} ${Q[Z+5]}`);else K.push(`C${Q[Z]} ${Q[Z+1]} ${Q[Z+2]} ${Q[Z+3]} ${Q[Z+4]} ${Q[Z+5]}`);return this.#T(K),K.join(" ")}#O(){let[$,Q,K,Z]=this.#$,[J,_,q,G]=this.#A();return`M${(this.#J[2]-$)/K} ${(this.#J[3]-Q)/Z} L${(this.#J[4]-$)/K} ${(this.#J[5]-Q)/Z} L${J} ${_} L${q} ${G} L${(this.#J[16]-$)/K} ${(this.#J[17]-Q)/Z} L${(this.#J[14]-$)/K} ${(this.#J[15]-Q)/Z} Z`}#T($){let Q=this.#Q;$.push(`L${Q[4]} ${Q[5]} Z`)}#S($){let[Q,K,Z,J]=this.#$,_=this.#J.subarray(4,6),q=this.#J.subarray(16,18),[G,U,V,N]=this.#A();$.push(`L${(_[0]-Q)/Z} ${(_[1]-K)/J} L${G} ${U} L${V} ${N} L${(q[0]-Q)/Z} ${(q[1]-K)/J}`)}newFreeDrawOutline($,Q,K,Z,J,_){return new y6($,Q,K,Z,J,_)}getOutlines(){let $=this.#q,Q=this.#Q,K=this.#J,[Z,J,_,q]=this.#$,G=new Float32Array((this.#B?.length??0)+2);for(let N=0,R=G.length-2;N<R;N+=2)G[N]=(this.#B[N]-Z)/_,G[N+1]=(this.#B[N+1]-J)/q;if(G[G.length-2]=(this.#_-Z)/_,G[G.length-1]=(this.#G-J)/q,isNaN(K[6])&&!this.isEmpty())return this.#W(G);let U=new Float32Array(this.#q.length+24+this.#Q.length),V=$.length;for(let N=0;N<V;N+=2){if(isNaN($[N])){U[N]=U[N+1]=NaN;continue}U[N]=$[N],U[N+1]=$[N+1]}V=this.#I(U,V);for(let N=Q.length-6;N>=6;N-=6)for(let R=0;R<6;R+=2){if(isNaN(Q[N+R])){U[V]=U[V+1]=NaN,V+=2;continue}U[V]=Q[N+R],U[V+1]=Q[N+R+1],V+=2}return this.#E(U,V),this.newFreeDrawOutline(U,G,this.#$,this.#j,this.#Z,this.#K)}#W($){let Q=this.#J,[K,Z,J,_]=this.#$,[q,G,U,V]=this.#A(),N=new Float32Array(36);return N.set([NaN,NaN,NaN,NaN,(Q[2]-K)/J,(Q[3]-Z)/_,NaN,NaN,NaN,NaN,(Q[4]-K)/J,(Q[5]-Z)/_,NaN,NaN,NaN,NaN,q,G,NaN,NaN,NaN,NaN,U,V,NaN,NaN,NaN,NaN,(Q[16]-K)/J,(Q[17]-Z)/_,NaN,NaN,NaN,NaN,(Q[14]-K)/J,(Q[15]-Z)/_],0),this.newFreeDrawOutline(N,$,this.#$,this.#j,this.#Z,this.#K)}#E($,Q){let K=this.#Q;return $.set([NaN,NaN,NaN,NaN,K[4],K[5]],Q),Q+=6}#I($,Q){let K=this.#J.subarray(4,6),Z=this.#J.subarray(16,18),[J,_,q,G]=this.#$,[U,V,N,R]=this.#A();return $.set([NaN,NaN,NaN,NaN,(K[0]-J)/q,(K[1]-_)/G,NaN,NaN,NaN,NaN,U,V,NaN,NaN,NaN,NaN,N,R,NaN,NaN,NaN,NaN,(Z[0]-J)/q,(Z[1]-_)/G],Q),Q+=24}}class y6 extends c{#$;#Q=new Float32Array(4);#Z;#K;#q;#J;#_;constructor($,Q,K,Z,J,_){super();this.#_=$,this.#q=Q,this.#$=K,this.#J=Z,this.#Z=J,this.#K=_,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#G(_);let[q,G,U,V]=this.#Q;for(let N=0,R=$.length;N<R;N+=2)$[N]=($[N]-q)/U,$[N+1]=($[N+1]-G)/V;for(let N=0,R=Q.length;N<R;N+=2)Q[N]=(Q[N]-q)/U,Q[N+1]=(Q[N+1]-G)/V}toSVGPath(){let $=[`M${this.#_[4]} ${this.#_[5]}`];for(let Q=6,K=this.#_.length;Q<K;Q+=6){if(isNaN(this.#_[Q])){$.push(`L${this.#_[Q+4]} ${this.#_[Q+5]}`);continue}$.push(`C${this.#_[Q]} ${this.#_[Q+1]} ${this.#_[Q+2]} ${this.#_[Q+3]} ${this.#_[Q+4]} ${this.#_[Q+5]}`)}return $.push("Z"),$.join(" ")}serialize([$,Q,K,Z],J){let _=K-$,q=Z-Q,G,U;switch(J){case 0:G=c._rescale(this.#_,$,Z,_,-q),U=c._rescale(this.#q,$,Z,_,-q);break;case 90:G=c._rescaleAndSwap(this.#_,$,Q,_,q),U=c._rescaleAndSwap(this.#q,$,Q,_,q);break;case 180:G=c._rescale(this.#_,K,Q,-_,q),U=c._rescale(this.#q,K,Q,-_,q);break;case 270:G=c._rescaleAndSwap(this.#_,K,Z,-_,-q),U=c._rescaleAndSwap(this.#q,K,Z,-_,-q);break}return{outline:Array.from(G),points:[Array.from(U)]}}#G($){let Q=this.#_,K=Q[4],Z=Q[5],J=[K,Z,K,Z],_=K,q=Z,G=K,U=Z,V=$?Math.max:Math.min,N=new Float32Array(4);for(let j=6,F=Q.length;j<F;j+=6){let B=Q[j+4],A=Q[j+5];if(isNaN(Q[j])){if(x.pointBoundingBox(B,A,J),q>A)_=B,q=A;else if(q===A)_=V(_,B);if(U<A)G=B,U=A;else if(U===A)G=V(G,B)}else{if(N[0]=N[1]=1/0,N[2]=N[3]=-1/0,x.bezierBoundingBox(K,Z,...Q.slice(j,j+6),N),x.rectBoundingBox(N[0],N[1],N[2],N[3],J),q>N[1])_=N[0],q=N[1];else if(q===N[1])_=V(_,N[0]);if(U<N[3])G=N[2],U=N[3];else if(U===N[3])G=V(G,N[2])}K=B,Z=A}let R=this.#Q;R[0]=J[0]-this.#Z,R[1]=J[1]-this.#Z,R[2]=J[2]-J[0]+2*this.#Z,R[3]=J[3]-J[1]+2*this.#Z,this.firstPoint=[_,q],this.lastPoint=[G,U]}get box(){return this.#Q}newOutliner($,Q,K,Z,J,_=0){return new NQ($,Q,K,Z,J,_)}getNewOutline($,Q){let[K,Z,J,_]=this.#Q,[q,G,U,V]=this.#$,N=J*U,R=_*V,j=K*U+q,F=Z*V+G,B=this.newOutliner({x:this.#q[0]*N+j,y:this.#q[1]*R+F},this.#$,this.#J,$,this.#K,Q??this.#Z);for(let A=2;A<this.#q.length;A+=2)B.add({x:this.#q[A]*N+j,y:this.#q[A+1]*R+F});return B.getOutlines()}}class E0{#$;#Q;#Z;#K=[];#q=[];constructor($,Q=0,K=0,Z=!0){let J=[1/0,1/0,-1/0,-1/0],_=0.0001;for(let{x:B,y:A,width:z,height:O}of $){let S=Math.floor((B-Q)/0.0001)*0.0001,I=Math.ceil((B+z+Q)/0.0001)*0.0001,C=Math.floor((A-Q)/0.0001)*0.0001,T=Math.ceil((A+O+Q)/0.0001)*0.0001,k=[S,C,T,!0],E=[I,C,T,!1];this.#K.push(k,E),x.rectBoundingBox(S,C,I,T,J)}let q=J[2]-J[0]+2*K,G=J[3]-J[1]+2*K,U=J[0]-K,V=J[1]-K,N=Z?-1/0:1/0,R=1/0,j=this.#K.at(Z?-1:-2),F=[j[0],j[2]];for(let B of this.#K){let[A,z,O,S]=B;if(!S&&Z){if(z<R)R=z,N=A;else if(z===R)N=Math.max(N,A)}else if(S&&!Z){if(z<R)R=z,N=A;else if(z===R)N=Math.min(N,A)}B[0]=(A-U)/q,B[1]=(z-V)/G,B[2]=(O-V)/G}this.#$=new Float32Array([U,V,q,G]),this.#Q=[N,R],this.#Z=F}getOutlines(){this.#K.sort((Q,K)=>Q[0]-K[0]||Q[1]-K[1]||Q[2]-K[2]);let $=[];for(let Q of this.#K)if(Q[3])$.push(...this.#U(Q)),this.#G(Q);else this.#V(Q),$.push(...this.#U(Q));return this.#J($)}#J($){let Q=[],K=new Set;for(let _ of $){let[q,G,U]=_;Q.push([q,G,_],[q,U,_])}Q.sort((_,q)=>_[1]-q[1]||_[0]-q[0]);for(let _=0,q=Q.length;_<q;_+=2){let G=Q[_][2],U=Q[_+1][2];G.push(U),U.push(G),K.add(G),K.add(U)}let Z=[],J;while(K.size>0){let _=K.values().next().value,[q,G,U,V,N]=_;K.delete(_);let R=q,j=G;J=[q,U],Z.push(J);while(!0){let F;if(K.has(V))F=V;else if(K.has(N))F=N;else break;if(K.delete(F),[q,G,U,V,N]=F,R!==q)J.push(R,j,q,j===G?G:U),R=q;j=j===G?U:G}J.push(R,j)}return new m8(Z,this.#$,this.#Q,this.#Z)}#_($){let Q=this.#q,K=0,Z=Q.length-1;while(K<=Z){let J=K+Z>>1,_=Q[J][0];if(_===$)return J;if(_<$)K=J+1;else Z=J-1}return Z+1}#G([,$,Q]){let K=this.#_($);this.#q.splice(K,0,[$,Q])}#V([,$,Q]){let K=this.#_($);for(let Z=K;Z<this.#q.length;Z++){let[J,_]=this.#q[Z];if(J!==$)break;if(J===$&&_===Q){this.#q.splice(Z,1);return}}for(let Z=K-1;Z>=0;Z--){let[J,_]=this.#q[Z];if(J!==$)break;if(J===$&&_===Q){this.#q.splice(Z,1);return}}}#U($){let[Q,K,Z]=$,J=[[Q,K,Z]],_=this.#_(Z);for(let q=0;q<_;q++){let[G,U]=this.#q[q];for(let V=0,N=J.length;V<N;V++){let[,R,j]=J[V];if(U<=R||j<=G)continue;if(R>=G){if(j>U)J[V][1]=U;else{if(N===1)return[];J.splice(V,1),V--,N--}continue}if(J[V][2]=G,j>U)J.push([Q,U,j])}}return J}}class m8 extends c{#$;#Q;constructor($,Q,K,Z){super();this.#Q=$,this.#$=Q,this.firstPoint=K,this.lastPoint=Z}toSVGPath(){let $=[];for(let Q of this.#Q){let[K,Z]=Q;$.push(`M${K} ${Z}`);for(let J=2;J<Q.length;J+=2){let _=Q[J],q=Q[J+1];if(_===K)$.push(`V${q}`),Z=q;else if(q===Z)$.push(`H${_}`),K=_}$.push("Z")}return $.join(" ")}serialize([$,Q,K,Z],J){let _=[],q=K-$,G=Z-Q;for(let U of this.#Q){let V=Array(U.length);for(let N=0;N<U.length;N+=2)V[N]=$+U[N]*q,V[N+1]=Z-U[N+1]*G;_.push(V)}return _}get box(){return this.#$}get classNamesForOutlining(){return["highlightOutline"]}}class M0 extends NQ{newFreeDrawOutline($,Q,K,Z,J,_){return new h8($,Q,K,Z,J,_)}}class h8 extends y6{newOutliner($,Q,K,Z,J,_=0){return new M0($,Q,K,Z,J,_)}}class B$ extends m{#$=null;#Q=0;#Z;#K=null;#q=null;#J=null;#_=null;#G=0;#V=null;#U=null;#j=null;#R=!1;#B=null;#z=null;#F=null;#N="";#A;#O="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=d.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let $=B$.prototype;return r(this,"_keyboardManager",new vQ([[["ArrowLeft","mac+ArrowLeft"],$._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],$._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],$._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],$._moveCaret,{args:[3]}]]))}constructor($){super({...$,name:"highlightEditor"});if(this.color=$.color||B$._defaultColor,this.#A=$.thickness||B$._defaultThickness,this.opacity=$.opacity||B$._defaultOpacity,this.#Z=$.boxes||null,this.#O=$.methodOfCreation||"",this.#N=$.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",$.highlightId>-1)this.#R=!0,this.#S($),this.#k();else if(this.#Z)this.#$=$.anchorNode,this.#Q=$.anchorOffset,this.#_=$.focusNode,this.#G=$.focusOffset,this.#T(),this.#k(),this.rotate(this.rotation);if(!this.annotationElementId)this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#R?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#A,methodOfCreation:this.#O}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData($){return{numberOfColors:$.get("color").size}}#T(){let $=new E0(this.#Z,0.001);this.#U=$.getOutlines(),[this.x,this.y,this.width,this.height]=this.#U.box;let Q=new E0(this.#Z,0.0025,0.001,this._uiManager.direction==="ltr");this.#J=Q.getOutlines();let{firstPoint:K}=this.#U;this.#B=[(K[0]-this.x)/this.width,(K[1]-this.y)/this.height];let{lastPoint:Z}=this.#J;this.#z=[(Z[0]-this.x)/this.width,(Z[1]-this.y)/this.height]}#S({highlightOutlines:$,highlightId:Q,clipPathId:K}){this.#U=$;let Z=1.5;if(this.#J=$.getNewOutline(this.#A/2+Z,0.0025),Q>=0)this.#j=Q,this.#K=K,this.parent.drawLayer.finalizeDraw(Q,{bbox:$.box,path:{d:$.toSVGPath()}}),this.#F=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#J.box,path:{d:this.#J.toSVGPath()}},!0);else if(this.parent){let N=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#j,{bbox:B$.#M(this.#U.box,(N-this.rotation+360)%360),path:{d:$.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#F,{bbox:B$.#M(this.#J.box,N),path:{d:this.#J.toSVGPath()}})}let[J,_,q,G]=$.box;switch(this.rotation){case 0:this.x=J,this.y=_,this.width=q,this.height=G;break;case 90:{let[N,R]=this.parentDimensions;this.x=_,this.y=1-J,this.width=q*R/N,this.height=G*N/R;break}case 180:this.x=1-J,this.y=1-_,this.width=q,this.height=G;break;case 270:{let[N,R]=this.parentDimensions;this.x=1-_,this.y=J,this.width=q*R/N,this.height=G*N/R;break}}let{firstPoint:U}=$;this.#B=[(U[0]-J)/q,(U[1]-_)/G];let{lastPoint:V}=this.#J;this.#z=[(V[0]-J)/q,(V[1]-_)/G]}static initialize($,Q){m.initialize($,Q),B$._defaultColor||=Q.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams($,Q){switch($){case n.HIGHLIGHT_COLOR:B$._defaultColor=Q;break;case n.HIGHLIGHT_THICKNESS:B$._defaultThickness=Q;break}}translateInPage($,Q){}get toolbarPosition(){return this.#z}get commentButtonPosition(){return this.#B}updateParams($,Q){switch($){case n.HIGHLIGHT_COLOR:this.#W(Q);break;case n.HIGHLIGHT_THICKNESS:this.#E(Q);break}}static get defaultPropertiesToUpdate(){return[[n.HIGHLIGHT_COLOR,B$._defaultColor],[n.HIGHLIGHT_THICKNESS,B$._defaultThickness]]}get propertiesToUpdate(){return[[n.HIGHLIGHT_COLOR,this.color||B$._defaultColor],[n.HIGHLIGHT_THICKNESS,this.#A||B$._defaultThickness],[n.HIGHLIGHT_FREE,this.#R]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#j,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#q?.updateColor(this.color),super.onUpdatedColor()}#W($){let Q=(J,_)=>{this.color=J,this.opacity=_,this.onUpdatedColor()},K=this.color,Z=this.opacity;this.addCommands({cmd:Q.bind(this,$,B$._defaultOpacity),undo:Q.bind(this,K,Z),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName($)},!0)}#E($){let Q=this.#A,K=(Z)=>{this.#A=Z,this.#I(Z)};this.addCommands({cmd:K.bind(this,$),undo:K.bind(this,Q),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:n.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:$},!0)}get toolbarButtons(){if(this._uiManager.highlightColors)return[["colorPicker",this.#q=new f$({editor:this})]];return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#P())}getBaseTranslation(){return[0,0]}getRect($,Q){return super.getRect($,Q,this.#P())}onceAdded($){if(!this.annotationElementId)this.parent.addUndoableEditor(this);if($)this.div.focus()}remove(){this.#Y(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(this.#k(),!this.isAttachedToDOM)this.parent.add(this)}setParent($){let Q=!1;if(this.parent&&!$)this.#Y();else if($)this.#k($),Q=!this.parent&&this.div?.classList.contains("selectedEditor");if(super.setParent($),this.show(this._isVisible),Q)this.select()}#I($){if(!this.#R)return;this.#S({highlightOutlines:this.#U.getNewOutline($/2)}),this.fixAndSetPosition(),this.setDims(this.width,this.height)}#Y(){if(this.#j===null||!this.parent)return;this.parent.drawLayer.remove(this.#j),this.#j=null,this.parent.drawLayer.remove(this.#F),this.#F=null}#k($=this.parent){if(this.#j!==null)return;if({id:this.#j,clipPathId:this.#K}=$.drawLayer.draw({bbox:this.#U.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#R},path:{d:this.#U.toSVGPath()}},!1,!0),this.#F=$.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#R},bbox:this.#J.box,path:{d:this.#J.toSVGPath()}},this.#R),this.#V)this.#V.style.clipPath=this.#K}static#M([$,Q,K,Z],J){switch(J){case 90:return[1-Q-Z,$,Z,K];case 180:return[1-$-K,1-Q-Z,K,Z];case 270:return[Q,1-$-K,Z,K]}return[$,Q,K,Z]}rotate($){let{drawLayer:Q}=this.parent,K;if(this.#R)$=($-this.rotation+360)%360,K=B$.#M(this.#U.box,$);else K=B$.#M([this.x,this.y,this.width,this.height],$);Q.updateProperties(this.#j,{bbox:K,root:{"data-main-rotation":$}}),Q.updateProperties(this.#F,{bbox:B$.#M(this.#J.box,$),root:{"data-main-rotation":$}})}render(){if(this.div)return this.div;let $=super.render();if(this.#N)$.setAttribute("aria-label",this.#N),$.setAttribute("role","mark");if(this.#R)$.classList.add("free");else this.div.addEventListener("keydown",this.#H.bind(this),{signal:this._uiManager._signal});let Q=this.#V=document.createElement("div");return $.append(Q),Q.setAttribute("aria-hidden","true"),Q.className="internal",Q.style.clipPath=this.#K,this.setDims(this.width,this.height),Y7(this,this.#V,["pointerover","pointerleave"]),this.enableEditing(),$}pointerover(){if(!this.isSelected)this.parent?.drawLayer.updateProperties(this.#F,{rootClass:{hovered:!0}})}pointerleave(){if(!this.isSelected)this.parent?.drawLayer.updateProperties(this.#F,{rootClass:{hovered:!1}})}#H($){B$._keyboardManager.exec(this,$)}_moveCaret($){switch(this.parent.unselect(this),$){case 0:case 2:this.#L(!0);break;case 1:case 3:this.#L(!1);break}}#L($){if(!this.#$)return;let Q=window.getSelection();if($)Q.setPosition(this.#$,this.#Q);else Q.setPosition(this.#_,this.#G)}select(){if(super.select(),!this.#F)return;this.parent?.drawLayer.updateProperties(this.#F,{rootClass:{hovered:!1,selected:!0}})}unselect(){if(super.unselect(),!this.#F)return;if(this.parent?.drawLayer.updateProperties(this.#F,{rootClass:{selected:!1}}),!this.#R)this.#L(!1)}get _mustFixPosition(){return!this.#R}show($=this._isVisible){if(super.show($),this.parent)this.parent.drawLayer.updateProperties(this.#j,{rootClass:{hidden:!$}}),this.parent.drawLayer.updateProperties(this.#F,{rootClass:{hidden:!$}})}#P(){return this.#R?this.rotation:0}#x(){if(this.#R)return null;let[$,Q]=this.pageDimensions,[K,Z]=this.pageTranslation,J=this.#Z,_=new Float32Array(J.length*8),q=0;for(let{x:G,y:U,width:V,height:N}of J){let R=G*$+K,j=(1-U)*Q+Z;_[q]=_[q+4]=R,_[q+1]=_[q+3]=j,_[q+2]=_[q+6]=R+V*$,_[q+5]=_[q+7]=j-N*Q,q+=8}return _}#v($){return this.#U.serialize($,this.#P())}static startHighlighting($,Q,{target:K,x:Z,y:J}){let{x:_,y:q,width:G,height:U}=K.getBoundingClientRect(),V=new AbortController,N=$.combinedSignal(V),R=(j)=>{V.abort(),this.#c($,j)};window.addEventListener("blur",R,{signal:N}),window.addEventListener("pointerup",R,{signal:N}),window.addEventListener("pointerdown",N$,{capture:!0,passive:!1,signal:N}),window.addEventListener("contextmenu",y$,{signal:N}),K.addEventListener("pointermove",this.#w.bind(this,$),{signal:N}),this._freeHighlight=new M0({x:Z,y:J},[_,q,G,U],$.scale,this._defaultThickness/2,Q,0.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=$.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#w($,Q){if(this._freeHighlight.add(Q))$.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#c($,Q){if(!this._freeHighlight.isEmpty())$.createAndAddNewEditor(Q,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"});else $.drawLayer.remove(this._freeHighlightId);this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize($,Q,K){let Z=null;if($ instanceof w6){let{data:{quadPoints:F,rect:B,rotation:A,id:z,color:O,opacity:S,popupRef:I,richText:C,contentsObj:T,creationDate:k,modificationDate:E},parent:{page:{pageNumber:M}}}=$;Z=$={annotationType:d.HIGHLIGHT,color:Array.from(O),opacity:S,quadPoints:F,boxes:null,pageIndex:M-1,rect:B.slice(0),rotation:A,annotationElementId:z,id:z,deleted:!1,popupRef:I,richText:C,comment:T?.str||null,creationDate:k,modificationDate:E}}else if($ instanceof x0){let{data:{inkLists:F,rect:B,rotation:A,id:z,color:O,borderStyle:{rawWidth:S},popupRef:I,richText:C,contentsObj:T,creationDate:k,modificationDate:E},parent:{page:{pageNumber:M}}}=$;Z=$={annotationType:d.HIGHLIGHT,color:Array.from(O),thickness:S,inkLists:F,boxes:null,pageIndex:M-1,rect:B.slice(0),rotation:A,annotationElementId:z,id:z,deleted:!1,popupRef:I,richText:C,comment:T?.str||null,creationDate:k,modificationDate:E}}let{color:J,quadPoints:_,inkLists:q,opacity:G}=$,U=await super.deserialize($,Q,K);if(U.color=x.makeHexColor(...J),U.opacity=G||1,q)U.#A=$.thickness;if(U._initialData=Z,$.comment)U.setCommentData($);let[V,N]=U.pageDimensions,[R,j]=U.pageTranslation;if(_){let F=U.#Z=[];for(let B=0;B<_.length;B+=8)F.push({x:(_[B]-R)/V,y:1-(_[B+1]-j)/N,width:(_[B+2]-_[B])/V,height:(_[B+1]-_[B+5])/N});U.#T(),U.#k(),U.rotate(U.rotation)}else if(q){U.#R=!0;let F=q[0],B={x:F[0]-R,y:N-(F[1]-j)},A=new M0(B,[0,0,V,N],1,U.#A/2,!0,0.001);for(let S=0,I=F.length;S<I;S+=2)B.x=F[S]-R,B.y=N-(F[S+1]-j),A.add(B);let{id:z,clipPathId:O}=Q.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:U.color,"fill-opacity":U._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:A.toSVGPath()}},!0,!0);U.#S({highlightOutlines:A.getOutlines(),highlightId:z,clipPathId:O}),U.#k(),U.rotate(U.parentRotation)}return U}serialize($=!1){if(this.isEmpty()||$)return null;if(this.deleted)return this.serializeDeleted();let Q=m._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),K=super.serialize($);if(Object.assign(K,{color:Q,opacity:this.opacity,thickness:this.#A,quadPoints:this.#x(),outlines:this.#v(K.rect)}),this.addComment(K),this.annotationElementId&&!this.#b(K))return null;return K.id=this.annotationElementId,K}#b($){let{color:Q}=this._initialData;return this.hasEditedComment||$.color.some((K,Z)=>K!==Q[Z])}renderAnnotationElement($){if(this.deleted)return $.hide(),null;return $.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}static canCreateNewEmptyEditor(){return!1}}class x6{#$=Object.create(null);updateProperty($,Q){this[$]=Q,this.updateSVGProperty($,Q)}updateProperties($){if(!$)return;for(let[Q,K]of Object.entries($))if(!Q.startsWith("_"))this.updateProperty(Q,K)}updateSVGProperty($,Q){this.#$[$]=Q}toSVGProperties(){let $=this.#$;return this.#$=Object.create(null),{root:$}}reset(){this.#$=Object.create(null)}updateAll($=this){this.updateProperties($)}clone(){Z$("Not implemented")}}class g extends m{#$=null;#Q;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#Z=null;static#K=null;static#q=null;static#J=NaN;static#_=null;static#G=null;static#V=NaN;static _INNER_MARGIN=3;constructor($){super($);this.#Q=$.mustBeCommitted||!1,this._addOutlines($)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}_addOutlines($){if($.drawOutlines)this.#U($),this.#B()}#U({drawOutlines:$,drawId:Q,drawingOptions:K}){if(this.#$=$,this._drawingOptions||=K,!this.annotationElementId)this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`);if(Q>=0)this._drawId=Q,this.parent.drawLayer.finalizeDraw(Q,$.defaultProperties);else this._drawId=this.#j($,this.parent);this.#N($.box)}#j($,Q){let{id:K}=Q.drawLayer.draw(g._mergeSVGProperties(this._drawingOptions.toSVGProperties(),$.defaultSVGProperties),!1,!1);return K}static _mergeSVGProperties($,Q){let K=new Set(Object.keys($));for(let[Z,J]of Object.entries(Q))if(K.has(Z))Object.assign($[Z],J);else $[Z]=J;return $}static getDefaultDrawingOptions($){Z$("Not implemented")}static get typesMap(){Z$("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams($,Q){let K=this.typesMap.get($);if(K)this._defaultDrawingOptions.updateProperty(K,Q);if(this._currentParent)g.#Z.updateProperty(K,Q),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}updateParams($,Q){let K=this.constructor.typesMap.get($);if(K)this._updateProperty($,K,Q)}static get defaultPropertiesToUpdate(){let $=[],Q=this._defaultDrawingOptions;for(let[K,Z]of this.typesMap)$.push([K,Q[Z]]);return $}get propertiesToUpdate(){let $=[],{_drawingOptions:Q}=this;for(let[K,Z]of this.constructor.typesMap)$.push([K,Q[Z]]);return $}_updateProperty($,Q,K){let Z=this._drawingOptions,J=Z[Q],_=(q)=>{Z.updateProperty(Q,q);let G=this.#$.updateProperty(Q,q);if(G)this.#N(G);if(this.parent?.drawLayer.updateProperties(this._drawId,Z.toSVGProperties()),$===this.colorType)this.onUpdatedColor()};this.addCommands({cmd:_.bind(this,K),undo:_.bind(this,J),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,g._mergeSVGProperties(this.#$.getPathResizingSVGProperties(this.#F()),{bbox:this.#A()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,g._mergeSVGProperties(this.#$.getPathResizedSVGProperties(this.#F()),{bbox:this.#A()}))}_onTranslating($,Q){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#A()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,g._mergeSVGProperties(this.#$.getPathTranslatedSVGProperties(this.#F(),this.parentDimensions),{bbox:this.#A()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded($){if(!this.annotationElementId)this.parent.addUndoableEditor(this);if(this._isDraggable=!0,this.#Q){if(this.#Q=!1,this.commit(),this.parent.setSelected(this),$&&this.isOnScreen)this.div.focus()}}remove(){this.#R(),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),this.div===null)return;if(this.#B(),this.#N(this.#$.box),!this.isAttachedToDOM)this.parent.add(this)}setParent($){let Q=!1;if(this.parent&&!$)this._uiManager.removeShouldRescale(this),this.#R();else if($)this._uiManager.addShouldRescale(this),this.#B($),Q=!this.parent&&this.div?.classList.contains("selectedEditor");if(super.setParent($),Q)this.select()}#R(){if(this._drawId===null||!this.parent)return;this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset()}#B($=this.parent){if(this._drawId!==null&&this.parent===$)return;if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,$.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#j(this.#$,$)}#z([$,Q,K,Z]){let{parentDimensions:[J,_],rotation:q}=this;switch(q){case 90:return[Q,1-$,K*(_/J),Z*(J/_)];case 180:return[1-$,1-Q,K,Z];case 270:return[1-Q,$,K*(_/J),Z*(J/_)];default:return[$,Q,K,Z]}}#F(){let{x:$,y:Q,width:K,height:Z,parentDimensions:[J,_],rotation:q}=this;switch(q){case 90:return[1-Q,$,K*(J/_),Z*(_/J)];case 180:return[1-$,1-Q,K,Z];case 270:return[Q,1-$,K*(J/_),Z*(_/J)];default:return[$,Q,K,Z]}}#N($){if([this.x,this.y,this.width,this.height]=this.#z($),this.div)this.fixAndSetPosition(),this.setDims();this._onResized()}#A(){let{x:$,y:Q,width:K,height:Z,rotation:J,parentRotation:_,parentDimensions:[q,G]}=this;switch((J*4+_)/90){case 1:return[1-Q-Z,$,Z,K];case 2:return[1-$-K,1-Q-Z,K,Z];case 3:return[Q,1-$-K,Z,K];case 4:return[$,Q-K*(q/G),Z*(G/q),K*(q/G)];case 5:return[1-Q,$,K*(q/G),Z*(G/q)];case 6:return[1-$-Z*(G/q),1-Q,Z*(G/q),K*(q/G)];case 7:return[Q-K*(q/G),1-$-Z*(G/q),K*(q/G),Z*(G/q)];case 8:return[$-K,Q-Z,K,Z];case 9:return[1-Q,$-K,Z,K];case 10:return[1-$,1-Q,K,Z];case 11:return[Q-Z,1-$,Z,K];case 12:return[$-Z*(G/q),Q,Z*(G/q),K*(q/G)];case 13:return[1-Q-K*(q/G),$-Z*(G/q),K*(q/G),Z*(G/q)];case 14:return[1-$,1-Q-K*(q/G),Z*(G/q),K*(q/G)];case 15:return[Q,1-$,K*(q/G),Z*(G/q)];default:return[$,Q,K,Z]}}rotate(){if(!this.parent)return;this.parent.drawLayer.updateProperties(this._drawId,g._mergeSVGProperties({bbox:this.#A()},this.#$.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){if(!this.parent)return;this.#N(this.#$.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let $,Q;if(this._isCopy)$=this.x,Q=this.y;let K=super.render();K.classList.add("draw");let Z=document.createElement("div");if(K.append(Z),Z.setAttribute("aria-hidden","true"),Z.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy)this._moveAfterPaste($,Q);return K}static createDrawerInstance($,Q,K,Z,J){Z$("Not implemented")}static startDrawing($,Q,K,Z){let{target:J,offsetX:_,offsetY:q,pointerId:G,pointerType:U}=Z;if(g.#_&&g.#_!==U)return;let{viewport:{rotation:V}}=$,{width:N,height:R}=J.getBoundingClientRect(),j=g.#K=new AbortController,F=$.combinedSignal(j);if(g.#J||=G,g.#_??=U,window.addEventListener("pointerup",(B)=>{if(g.#J===B.pointerId)this._endDraw(B);else g.#G?.delete(B.pointerId)},{signal:F}),window.addEventListener("pointercancel",(B)=>{if(g.#J===B.pointerId)this._currentParent.endDrawingSession();else g.#G?.delete(B.pointerId)},{signal:F}),window.addEventListener("pointerdown",(B)=>{if(g.#_!==B.pointerType)return;if((g.#G||=new Set).add(B.pointerId),g.#Z.isCancellable())if(g.#Z.removeLastElement(),g.#Z.isEmpty())this._currentParent.endDrawingSession(!0);else this._endDraw(null)},{capture:!0,passive:!1,signal:F}),window.addEventListener("contextmenu",y$,{signal:F}),J.addEventListener("pointermove",this._drawMove.bind(this),{signal:F}),J.addEventListener("touchmove",(B)=>{if(B.timeStamp===g.#V)N$(B)},{signal:F}),$.toggleDrawing(),Q._editorUndoBar?.hide(),g.#Z){$.drawLayer.updateProperties(this._currentDrawId,g.#Z.startNew(_,q,N,R,V));return}Q.updateUIForDefaultProperties(this),g.#Z=this.createDrawerInstance(_,q,N,R,V),g.#q=this.getDefaultDrawingOptions(),this._currentParent=$,{id:this._currentDrawId}=$.drawLayer.draw(this._mergeSVGProperties(g.#q.toSVGProperties(),g.#Z.defaultSVGProperties),!0,!1)}static _drawMove($){if(g.#V=-1,!g.#Z)return;let{offsetX:Q,offsetY:K,pointerId:Z}=$;if(g.#J!==Z)return;if(g.#G?.size>=1){this._endDraw($);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,g.#Z.add(Q,K)),g.#V=$.timeStamp,N$($)}static _cleanup($){if($)this._currentDrawId=-1,this._currentParent=null,g.#Z=null,g.#q=null,g.#_=null,g.#V=NaN;if(g.#K)g.#K.abort(),g.#K=null,g.#J=NaN,g.#G=null}static _endDraw($){let Q=this._currentParent;if(!Q)return;if(Q.toggleDrawing(!0),this._cleanup(!1),$?.target===Q.div)Q.drawLayer.updateProperties(this._currentDrawId,g.#Z.end($.offsetX,$.offsetY));if(this.supportMultipleDrawings){let K=g.#Z,Z=this._currentDrawId,J=K.getLastElement();Q.addCommands({cmd:()=>{Q.drawLayer.updateProperties(Z,K.setLastElement(J))},undo:()=>{Q.drawLayer.updateProperties(Z,K.removeLastElement())},mustExec:!1,type:n.DRAW_STEP});return}this.endDrawing(!1)}static endDrawing($){let Q=this._currentParent;if(!Q)return null;if(Q.toggleDrawing(!0),Q.cleanUndoStack(n.DRAW_STEP),!g.#Z.isEmpty()){let{pageDimensions:[K,Z],scale:J}=Q,_=Q.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:g.#Z.getOutlines(K*J,Z*J,J,this._INNER_MARGIN),drawingOptions:g.#q,mustBeCommitted:!$});return this._cleanup(!0),_}return Q.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions($){}static deserializeDraw($,Q,K,Z,J,_){Z$("Not implemented")}static async deserialize($,Q,K){let{rawDims:{pageWidth:Z,pageHeight:J,pageX:_,pageY:q}}=Q.viewport,G=this.deserializeDraw(_,q,Z,J,this._INNER_MARGIN,$),U=await super.deserialize($,Q,K);return U.createDrawingOptions($),U.#U({drawOutlines:G}),U.#B(),U.onScaleChanging(),U.rotate(),U}serializeDraw($){let[Q,K]=this.pageTranslation,[Z,J]=this.pageDimensions;return this.#$.serialize([Q,K,Z,J],$)}renderAnnotationElement($){return $.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class g8{#$=new Float64Array(6);#Q;#Z;#K;#q;#J;#_="";#G=0;#V=new fQ;#U;#j;constructor($,Q,K,Z,J,_){this.#U=K,this.#j=Z,this.#K=J,this.#q=_,[$,Q]=this.#R($,Q);let q=this.#Q=[NaN,NaN,NaN,NaN,$,Q];this.#J=[$,Q],this.#Z=[{line:q,points:this.#J}],this.#$.set(q,0)}updateProperty($,Q){if($==="stroke-width")this.#q=Q}#R($,Q){return c._normalizePoint($,Q,this.#U,this.#j,this.#K)}isEmpty(){return!this.#Z||this.#Z.length===0}isCancellable(){return this.#J.length<=10}add($,Q){[$,Q]=this.#R($,Q);let[K,Z,J,_]=this.#$.subarray(2,6),q=$-J,G=Q-_;if(Math.hypot(this.#U*q,this.#j*G)<=2)return null;if(this.#J.push($,Q),isNaN(K))return this.#$.set([J,_,$,Q],2),this.#Q.push(NaN,NaN,NaN,NaN,$,Q),{path:{d:this.toSVGPath()}};if(isNaN(this.#$[0]))this.#Q.splice(6,6);return this.#$.set([K,Z,J,_,$,Q],0),this.#Q.push(...c.createBezierPoints(K,Z,J,_,$,Q)),{path:{d:this.toSVGPath()}}}end($,Q){let K=this.add($,Q);if(K)return K;if(this.#J.length===2)return{path:{d:this.toSVGPath()}};return null}startNew($,Q,K,Z,J){this.#U=K,this.#j=Z,this.#K=J,[$,Q]=this.#R($,Q);let _=this.#Q=[NaN,NaN,NaN,NaN,$,Q];this.#J=[$,Q];let q=this.#Z.at(-1);if(q)q.line=new Float32Array(q.line),q.points=new Float32Array(q.points);return this.#Z.push({line:_,points:this.#J}),this.#$.set(_,0),this.#G=0,this.toSVGPath(),null}getLastElement(){return this.#Z.at(-1)}setLastElement($){if(!this.#Z)return this.#V.setLastElement($);return this.#Z.push($),this.#Q=$.line,this.#J=$.points,this.#G=0,{path:{d:this.toSVGPath()}}}removeLastElement(){if(!this.#Z)return this.#V.removeLastElement();this.#Z.pop(),this.#_="";for(let $=0,Q=this.#Z.length;$<Q;$++){let{line:K,points:Z}=this.#Z[$];this.#Q=K,this.#J=Z,this.#G=0,this.toSVGPath()}return{path:{d:this.#_}}}toSVGPath(){let $=c.svgRound(this.#Q[4]),Q=c.svgRound(this.#Q[5]);if(this.#J.length===2)return this.#_=`${this.#_} M ${$} ${Q} Z`,this.#_;if(this.#J.length<=6){let Z=this.#_.lastIndexOf("M");this.#_=`${this.#_.slice(0,Z)} M ${$} ${Q}`,this.#G=6}if(this.#J.length===4){let Z=c.svgRound(this.#Q[10]),J=c.svgRound(this.#Q[11]);return this.#_=`${this.#_} L ${Z} ${J}`,this.#G=12,this.#_}let K=[];if(this.#G===0)K.push(`M ${$} ${Q}`),this.#G=6;for(let Z=this.#G,J=this.#Q.length;Z<J;Z+=6){let[_,q,G,U,V,N]=this.#Q.slice(Z,Z+6).map(c.svgRound);K.push(`C${_} ${q} ${G} ${U} ${V} ${N}`)}return this.#_+=K.join(" "),this.#G=this.#Q.length,this.#_}getOutlines($,Q,K,Z){let J=this.#Z.at(-1);return J.line=new Float32Array(J.line),J.points=new Float32Array(J.points),this.#V.build(this.#Z,$,Q,K,this.#K,this.#q,Z),this.#$=null,this.#Q=null,this.#Z=null,this.#_=null,this.#V}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class fQ extends c{#$;#Q=0;#Z;#K;#q;#J;#_;#G;#V;build($,Q,K,Z,J,_,q){this.#q=Q,this.#J=K,this.#_=Z,this.#G=J,this.#V=_,this.#Z=q??0,this.#K=$,this.#R()}get thickness(){return this.#V}setLastElement($){return this.#K.push($),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#K.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let $=[];for(let{line:Q}of this.#K){if($.push(`M${c.svgRound(Q[4])} ${c.svgRound(Q[5])}`),Q.length===6){$.push("Z");continue}if(Q.length===12&&isNaN(Q[6])){$.push(`L${c.svgRound(Q[10])} ${c.svgRound(Q[11])}`);continue}for(let K=6,Z=Q.length;K<Z;K+=6){let[J,_,q,G,U,V]=Q.subarray(K,K+6).map(c.svgRound);$.push(`C${J} ${_} ${q} ${G} ${U} ${V}`)}}return $.join("")}serialize([$,Q,K,Z],J){let _=[],q=[],[G,U,V,N]=this.#j(),R,j,F,B,A,z,O,S,I;switch(this.#G){case 0:I=c._rescale,R=$,j=Q+Z,F=K,B=-Z,A=$+G*K,z=Q+(1-U-N)*Z,O=$+(G+V)*K,S=Q+(1-U)*Z;break;case 90:I=c._rescaleAndSwap,R=$,j=Q,F=K,B=Z,A=$+U*K,z=Q+G*Z,O=$+(U+N)*K,S=Q+(G+V)*Z;break;case 180:I=c._rescale,R=$+K,j=Q,F=-K,B=Z,A=$+(1-G-V)*K,z=Q+U*Z,O=$+(1-G)*K,S=Q+(U+N)*Z;break;case 270:I=c._rescaleAndSwap,R=$+K,j=Q+Z,F=-K,B=-Z,A=$+(1-U-N)*K,z=Q+(1-G-V)*Z,O=$+(1-U)*K,S=Q+(1-G)*Z;break}for(let{line:C,points:T}of this.#K)_.push(I(C,R,j,F,B,J?Array(C.length):null)),q.push(I(T,R,j,F,B,J?Array(T.length):null));return{lines:_,points:q,rect:[A,z,O,S]}}static deserialize($,Q,K,Z,J,{paths:{lines:_,points:q},rotation:G,thickness:U}){let V=[],N,R,j,F,B;switch(G){case 0:B=c._rescale,N=-$/K,R=Q/Z+1,j=1/K,F=-1/Z;break;case 90:B=c._rescaleAndSwap,N=-Q/Z,R=-$/K,j=1/Z,F=1/K;break;case 180:B=c._rescale,N=$/K+1,R=-Q/Z,j=-1/K,F=1/Z;break;case 270:B=c._rescaleAndSwap,N=Q/Z+1,R=$/K+1,j=-1/Z,F=-1/K;break}if(!_){_=[];for(let z of q){let O=z.length;if(O===2){_.push(new Float32Array([NaN,NaN,NaN,NaN,z[0],z[1]]));continue}if(O===4){_.push(new Float32Array([NaN,NaN,NaN,NaN,z[0],z[1],NaN,NaN,NaN,NaN,z[2],z[3]]));continue}let S=new Float32Array(3*(O-2));_.push(S);let[I,C,T,k]=z.subarray(0,4);S.set([NaN,NaN,NaN,NaN,I,C],0);for(let E=4;E<O;E+=2){let M=z[E],W=z[E+1];S.set(c.createBezierPoints(I,C,T,k,M,W),(E-2)*3),[I,C,T,k]=[T,k,M,W]}}}for(let z=0,O=_.length;z<O;z++)V.push({line:B(_[z].map((S)=>S??NaN),N,R,j,F),points:B(q[z].map((S)=>S??NaN),N,R,j,F)});let A=new this.prototype.constructor;return A.build(V,K,Z,1,G,U,J),A}#U($=this.#V){let Q=this.#Z+$/2*this.#_;return this.#G%180===0?[Q/this.#q,Q/this.#J]:[Q/this.#J,Q/this.#q]}#j(){let[$,Q,K,Z]=this.#$,[J,_]=this.#U(0);return[$+J,Q+_,K-2*J,Z-2*_]}#R(){let $=this.#$=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:Z}of this.#K){if(Z.length<=12){for(let q=4,G=Z.length;q<G;q+=6)x.pointBoundingBox(Z[q],Z[q+1],$);continue}let J=Z[4],_=Z[5];for(let q=6,G=Z.length;q<G;q+=6){let[U,V,N,R,j,F]=Z.subarray(q,q+6);x.bezierBoundingBox(J,_,U,V,N,R,j,F,$),J=j,_=F}}let[Q,K]=this.#U();$[0]=X$($[0]-Q,0,1),$[1]=X$($[1]-K,0,1),$[2]=X$($[2]+Q,0,1),$[3]=X$($[3]+K,0,1),$[2]-=$[0],$[3]-=$[1]}get box(){return this.#$}updateProperty($,Q){if($==="stroke-width")return this.#B(Q);return null}#B($){let[Q,K]=this.#U();this.#V=$;let[Z,J]=this.#U(),[_,q]=[Z-Q,J-K],G=this.#$;return G[0]-=_,G[1]-=q,G[2]+=2*_,G[3]+=2*q,G}updateParentDimensions([$,Q],K){let[Z,J]=this.#U();this.#q=$,this.#J=Q,this.#_=K;let[_,q]=this.#U(),G=_-Z,U=q-J,V=this.#$;return V[0]-=G,V[1]-=U,V[2]+=2*G,V[3]+=2*U,V}updateRotation($){return this.#Q=$,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#$.map(c.svgRound).join(" ")}get defaultProperties(){let[$,Q]=this.#$;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${c.svgRound($)} ${c.svgRound(Q)}`}}}get rotationTransform(){let[,,$,Q]=this.#$,K=0,Z=0,J=0,_=0,q=0,G=0;switch(this.#Q){case 90:Z=Q/$,J=-$/Q,q=$;break;case 180:K=-1,_=-1,q=$,G=Q;break;case 270:Z=-Q/$,J=$/Q,G=Q;break;default:return""}return`matrix(${K} ${Z} ${J} ${_} ${c.svgRound(q)} ${c.svgRound(G)})`}getPathResizingSVGProperties([$,Q,K,Z]){let[J,_]=this.#U(),[q,G,U,V]=this.#$;if(Math.abs(U-J)<=c.PRECISION||Math.abs(V-_)<=c.PRECISION){let B=$+K/2-(q+U/2),A=Q+Z/2-(G+V/2);return{path:{"transform-origin":`${c.svgRound($)} ${c.svgRound(Q)}`,transform:`${this.rotationTransform} translate(${B} ${A})`}}}let N=(K-2*J)/(U-2*J),R=(Z-2*_)/(V-2*_),j=U/K,F=V/Z;return{path:{"transform-origin":`${c.svgRound(q)} ${c.svgRound(G)}`,transform:`${this.rotationTransform} scale(${j} ${F}) translate(${c.svgRound(J)} ${c.svgRound(_)}) scale(${N} ${R}) translate(${c.svgRound(-J)} ${c.svgRound(-_)})`}}}getPathResizedSVGProperties([$,Q,K,Z]){let[J,_]=this.#U(),q=this.#$,[G,U,V,N]=q;if(q[0]=$,q[1]=Q,q[2]=K,q[3]=Z,Math.abs(V-J)<=c.PRECISION||Math.abs(N-_)<=c.PRECISION){let A=$+K/2-(G+V/2),z=Q+Z/2-(U+N/2);for(let{line:O,points:S}of this.#K)c._translate(O,A,z,O),c._translate(S,A,z,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${c.svgRound($)} ${c.svgRound(Q)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let R=(K-2*J)/(V-2*J),j=(Z-2*_)/(N-2*_),F=-R*(G+J)+$+J,B=-j*(U+_)+Q+_;if(R!==1||j!==1||F!==0||B!==0)for(let{line:A,points:z}of this.#K)c._rescale(A,F,B,R,j,A),c._rescale(z,F,B,R,j,z);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${c.svgRound($)} ${c.svgRound(Q)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([$,Q],K){let[Z,J]=K,_=this.#$,q=$-_[0],G=Q-_[1];if(this.#q===Z&&this.#J===J)for(let{line:U,points:V}of this.#K)c._translate(U,q,G,U),c._translate(V,q,G,V);else{let U=this.#q/Z,V=this.#J/J;this.#q=Z,this.#J=J;for(let{line:N,points:R}of this.#K)c._rescale(N,q,G,U,V,N),c._rescale(R,q,G,U,V,R);_[2]*=U,_[3]*=V}return _[0]=$,_[1]=Q,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${c.svgRound($)} ${c.svgRound(Q)}`}}}get defaultSVGProperties(){let $=this.#$;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${c.svgRound($[0])} ${c.svgRound($[1])}`,transform:this.rotationTransform||null},bbox:$}}}class u0 extends x6{constructor($){super();this._viewParameters=$,super.updateProperties({fill:"none",stroke:m._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty($,Q){if($==="stroke-width")Q??=this["stroke-width"],Q*=this._viewParameters.realScale;super.updateSVGProperty($,Q)}clone(){let $=new u0(this._viewParameters);return $.updateAll(this),$}}class c6 extends g{static _type="ink";static _editorType=d.INK;static _defaultDrawingOptions=null;constructor($){super({...$,name:"inkEditor"});this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize($,Q){m.initialize($,Q),this._defaultDrawingOptions=new u0(Q.viewParameters)}static getDefaultDrawingOptions($){let Q=this._defaultDrawingOptions.clone();return Q.updateProperties($),Q}static get supportMultipleDrawings(){return!0}static get typesMap(){return r(this,"typesMap",new Map([[n.INK_THICKNESS,"stroke-width"],[n.INK_COLOR,"stroke"],[n.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance($,Q,K,Z,J){return new g8($,Q,K,Z,J,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw($,Q,K,Z,J,_){return fQ.deserialize($,Q,K,Z,J,_)}static async deserialize($,Q,K){let Z=null;if($ instanceof x0){let{data:{inkLists:_,rect:q,rotation:G,id:U,color:V,opacity:N,borderStyle:{rawWidth:R},popupRef:j,richText:F,contentsObj:B,creationDate:A,modificationDate:z},parent:{page:{pageNumber:O}}}=$;Z=$={annotationType:d.INK,color:Array.from(V),thickness:R,opacity:N,paths:{points:_},boxes:null,pageIndex:O-1,rect:q.slice(0),rotation:G,annotationElementId:U,id:U,deleted:!1,popupRef:j,richText:F,comment:B?.str||null,creationDate:A,modificationDate:z}}let J=await super.deserialize($,Q,K);if(J._initialData=Z,$.comment)J.setCommentData($);return J}get toolbarButtons(){return this._colorPicker||=new sQ(this),[["colorPicker",this._colorPicker]]}get colorType(){return n.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:$,_drawingOptions:Q,parent:K}=this;Q.updateSVGProperty("stroke-width"),K.drawLayer.updateProperties($,Q.toSVGProperties())}static onScaleChangingWhenDrawing(){let $=this._currentParent;if(!$)return;super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),$.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}createDrawingOptions({color:$,thickness:Q,opacity:K}){this._drawingOptions=c6.getDefaultDrawingOptions({stroke:x.makeHexColor(...$),"stroke-width":Q,"stroke-opacity":K})}serialize($=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:Q,points:K}=this.serializeDraw($),{_drawingOptions:{stroke:Z,"stroke-opacity":J,"stroke-width":_}}=this,q=Object.assign(super.serialize($),{color:m._colorManager.convert(Z),opacity:J,thickness:_,paths:{lines:Q,points:K}});if(this.addComment(q),$)return q.isCopy=!0,q;if(this.annotationElementId&&!this.#$(q))return null;return q.id=this.annotationElementId,q}#$($){let{color:Q,thickness:K,opacity:Z,pageIndex:J}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||$.color.some((_,q)=>_!==Q[q])||$.thickness!==K||$.opacity!==Z||$.pageIndex!==J}renderAnnotationElement($){if(this.deleted)return $.hide(),null;let{points:Q,rect:K}=this.serializeDraw(!1);return $.updateEdited({rect:K,thickness:this._drawingOptions["stroke-width"],points:Q,popup:this.comment}),null}}class W0 extends fQ{toSVGPath(){let $=super.toSVGPath();if(!$.endsWith("Z"))$+="Z";return $}}var z0=8,xQ=3;class JQ{static#$={maxDim:512,sigmaSFactor:0.02,sigmaR:25,kernelSize:16};static#Q($,Q,K,Z){if(K-=$,Z-=Q,K===0)return Z>0?0:4;if(K===1)return Z+6;return 2-Z}static#Z=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#K($,Q,K,Z,J,_,q){let G=this.#Q(K,Z,J,_);for(let U=0;U<8;U++){let V=(-U+G-q+16)%8,N=this.#Z[2*V],R=this.#Z[2*V+1];if($[(K+N)*Q+(Z+R)]!==0)return V}return-1}static#q($,Q,K,Z,J,_,q){let G=this.#Q(K,Z,J,_);for(let U=0;U<8;U++){let V=(U+G+q+16)%8,N=this.#Z[2*V],R=this.#Z[2*V+1];if($[(K+N)*Q+(Z+R)]!==0)return V}return-1}static#J($,Q,K,Z){let J=$.length,_=new Int32Array(J);for(let V=0;V<J;V++)_[V]=$[V]<=Z?1:0;for(let V=1;V<K-1;V++)_[V*Q]=_[V*Q+Q-1]=0;for(let V=0;V<Q;V++)_[V]=_[Q*K-1-V]=0;let q=1,G,U=[];for(let V=1;V<K-1;V++){G=1;for(let N=1;N<Q-1;N++){let R=V*Q+N,j=_[R];if(j===0)continue;let F=V,B=N;if(j===1&&_[R-1]===0)q+=1,B-=1;else if(j>=1&&_[R+1]===0){if(q+=1,B+=1,j>1)G=j}else{if(j!==1)G=Math.abs(j);continue}let A=[N,V],z=B===N+1,O={isHole:z,points:A,id:q,parent:0};U.push(O);let S;for(let X of U)if(X.id===G){S=X;break}if(!S)O.parent=z?G:0;else if(S.isHole)O.parent=z?S.parent:G;else O.parent=z?G:S.parent;let I=this.#K(_,Q,V,N,F,B,0);if(I===-1){if(_[R]=-q,_[R]!==1)G=Math.abs(_[R]);continue}let C=this.#Z[2*I],T=this.#Z[2*I+1],k=V+C,E=N+T;F=k,B=E;let M=V,W=N;while(!0){let X=this.#q(_,Q,M,W,F,B,1);C=this.#Z[2*X],T=this.#Z[2*X+1];let Y=M+C,y=W+T;A.push(y,Y);let D=M*Q+W;if(_[D+1]===0)_[D]=-q;else if(_[D]===1)_[D]=q;if(Y===V&&y===N&&M===k&&W===E){if(_[R]!==1)G=Math.abs(_[R]);break}else F=M,B=W,M=Y,W=y}}}return U}static#_($,Q,K,Z){if(K-Q<=4){for(let k=Q;k<K-2;k+=2)Z.push($[k],$[k+1]);return}let J=$[Q],_=$[Q+1],q=$[K-4]-J,G=$[K-3]-_,U=Math.hypot(q,G),V=q/U,N=G/U,R=V*_-N*J,j=G/q,F=1/U,B=Math.atan(j),A=Math.cos(B),z=Math.sin(B),O=F*(Math.abs(A)+Math.abs(z)),S=F*(1-O+O**2),I=Math.max(Math.atan(Math.abs(z+A)*S),Math.atan(Math.abs(z-A)*S)),C=0,T=Q;for(let k=Q+2;k<K-2;k+=2){let E=Math.abs(R-V*$[k+1]+N*$[k]);if(E>C)T=k,C=E}if(C>(U*I)**2)this.#_($,Q,T+2,Z),this.#_($,T,K,Z);else Z.push(J,_)}static#G($){let Q=[],K=$.length;return this.#_($,0,K,Q),Q.push($[K-2],$[K-1]),Q.length<=4?null:Q}static#V($,Q,K,Z,J,_){let q=new Float32Array(_**2),G=-2*Z**2,U=_>>1;for(let B=0;B<_;B++){let A=(B-U)**2;for(let z=0;z<_;z++)q[B*_+z]=Math.exp((A+(z-U)**2)/G)}let V=new Float32Array(256),N=-2*J**2;for(let B=0;B<256;B++)V[B]=Math.exp(B**2/N);let R=$.length,j=new Uint8Array(R),F=new Uint32Array(256);for(let B=0;B<K;B++)for(let A=0;A<Q;A++){let z=B*Q+A,O=$[z],S=0,I=0;for(let T=0;T<_;T++){let k=B+T-U;if(k<0||k>=K)continue;for(let E=0;E<_;E++){let M=A+E-U;if(M<0||M>=Q)continue;let W=$[k*Q+M],X=q[T*_+E]*V[Math.abs(W-O)];S+=W*X,I+=X}}let C=j[z]=Math.round(S/I);F[C]++}return[j,F]}static#U($){let Q=new Uint32Array(256);for(let K of $)Q[K]++;return Q}static#j($){let Q=$.length,K=new Uint8ClampedArray(Q>>2),Z=-1/0,J=1/0;for(let q=0,G=K.length;q<G;q++){let U=K[q]=$[q<<2];Z=Math.max(Z,U),J=Math.min(J,U)}let _=255/(Z-J);for(let q=0,G=K.length;q<G;q++)K[q]=(K[q]-J)*_;return K}static#R($){let Q,K=-1/0,Z=-1/0,J=$.findIndex((G)=>G!==0),_=J,q=J;for(Q=J;Q<256;Q++){let G=$[Q];if(G>K){if(Q-_>Z)Z=Q-_,q=Q-1;K=G,_=Q}}for(Q=q-1;Q>=0;Q--)if($[Q]>$[Q+1])break;return Q}static#B($){let Q=$,{width:K,height:Z}=$,{maxDim:J}=this.#$,_=K,q=Z;if(K>J||Z>J){let R=K,j=Z,F=Math.log2(Math.max(K,Z)/J),B=Math.floor(F);F=F===B?B-1:B;for(let z=0;z<F;z++){_=Math.ceil(R/2),q=Math.ceil(j/2);let O=new OffscreenCanvas(_,q);if(O.getContext("2d").drawImage($,0,0,R,j,0,0,_,q),R=_,j=q,$!==Q)$.close();$=O.transferToImageBitmap()}let A=Math.min(J/_,J/q);_=Math.round(_*A),q=Math.round(q*A)}let U=new OffscreenCanvas(_,q).getContext("2d",{willReadFrequently:!0});U.fillStyle="white",U.fillRect(0,0,_,q),U.filter="grayscale(1)",U.drawImage($,0,0,$.width,$.height,0,0,_,q);let V=U.getImageData(0,0,_,q).data;return[this.#j(V),_,q]}static extractContoursFromText($,{fontFamily:Q,fontStyle:K,fontWeight:Z},J,_,q,G){let U=new OffscreenCanvas(1,1),V=U.getContext("2d",{alpha:!1}),N=200,R=V.font=`${K} ${Z} ${N}px ${Q}`,{actualBoundingBoxLeft:j,actualBoundingBoxRight:F,actualBoundingBoxAscent:B,actualBoundingBoxDescent:A,fontBoundingBoxAscent:z,fontBoundingBoxDescent:O,width:S}=V.measureText($),I=1.5,C=Math.ceil(Math.max(Math.abs(j)+Math.abs(F)||0,S)*I),T=Math.ceil(Math.max(Math.abs(B)+Math.abs(A)||N,Math.abs(z)+Math.abs(O)||N)*I);U=new OffscreenCanvas(C,T),V=U.getContext("2d",{alpha:!0,willReadFrequently:!0}),V.font=R,V.filter="grayscale(1)",V.fillStyle="white",V.fillRect(0,0,C,T),V.fillStyle="black",V.fillText($,C*(I-1)/2,T*(3-I)/2);let k=this.#j(V.getImageData(0,0,C,T).data),E=this.#U(k),M=this.#R(E),W=this.#J(k,C,T,M);return this.processDrawnLines({lines:{curves:W,width:C,height:T},pageWidth:J,pageHeight:_,rotation:q,innerMargin:G,mustSmooth:!0,areContours:!0})}static process($,Q,K,Z,J){let[_,q,G]=this.#B($),[U,V]=this.#V(_,q,G,Math.hypot(q,G)*this.#$.sigmaSFactor,this.#$.sigmaR,this.#$.kernelSize),N=this.#R(V),R=this.#J(U,q,G,N);return this.processDrawnLines({lines:{curves:R,width:q,height:G},pageWidth:Q,pageHeight:K,rotation:Z,innerMargin:J,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:$,pageWidth:Q,pageHeight:K,rotation:Z,innerMargin:J,mustSmooth:_,areContours:q}){if(Z%180!==0)[Q,K]=[K,Q];let{curves:G,width:U,height:V}=$,N=$.thickness??0,R=[],j=Math.min(Q/U,K/V),F=j/Q,B=j/K,A=[];for(let{points:O}of G){let S=_?this.#G(O):O;if(!S)continue;A.push(S);let I=S.length,C=new Float32Array(I),T=new Float32Array(3*(I===2?2:I-2));if(R.push({line:T,points:C}),I===2){C[0]=S[0]*F,C[1]=S[1]*B,T.set([NaN,NaN,NaN,NaN,C[0],C[1]],0);continue}let[k,E,M,W]=S;k*=F,E*=B,M*=F,W*=B,C.set([k,E,M,W],0),T.set([NaN,NaN,NaN,NaN,k,E],0);for(let X=4;X<I;X+=2){let Y=C[X]=S[X]*F,y=C[X+1]=S[X+1]*B;T.set(c.createBezierPoints(k,E,M,W,Y,y),(X-2)*3),[k,E,M,W]=[M,W,Y,y]}}if(R.length===0)return null;let z=q?new W0:new fQ;return z.build(R,Q,K,1,Z,q?0:N,J),{outline:z,newCurves:A,areContours:q,thickness:N,width:U,height:V}}static async compressSignature({outlines:$,areContours:Q,thickness:K,width:Z,height:J}){let _=1/0,q=-1/0,G=0;for(let S of $){G+=S.length;for(let I=2,C=S.length;I<C;I++){let T=S[I]-S[I-2];_=Math.min(_,T),q=Math.max(q,T)}}let U;if(_>=-128&&q<=127)U=Int8Array;else if(_>=-32768&&q<=32767)U=Int16Array;else U=Int32Array;let V=$.length,N=z0+xQ*V,R=new Uint32Array(N),j=0;R[j++]=N*Uint32Array.BYTES_PER_ELEMENT+(G-2*V)*U.BYTES_PER_ELEMENT,R[j++]=0,R[j++]=Z,R[j++]=J,R[j++]=Q?0:1,R[j++]=Math.max(0,Math.floor(K??0)),R[j++]=V,R[j++]=U.BYTES_PER_ELEMENT;for(let S of $)R[j++]=S.length-2,R[j++]=S[0],R[j++]=S[1];let F=new CompressionStream("deflate-raw"),B=F.writable.getWriter();await B.ready,B.write(R);let A=U.prototype.constructor;for(let S of $){let I=new A(S.length-2);for(let C=2,T=S.length;C<T;C++)I[C-2]=S[C]-S[C-2];B.write(I)}B.close();let z=await new Response(F.readable).arrayBuffer(),O=new Uint8Array(z);return T7(O)}static async decompressSignature($){try{let Q=FK($),{readable:K,writable:Z}=new DecompressionStream("deflate-raw"),J=Z.getWriter();await J.ready,J.write(Q).then(async()=>{await J.ready,await J.close()}).catch(()=>{});let _=null,q=0;for await(let S of K)_||=new Uint8Array(new Uint32Array(S.buffer,0,4)[0]),_.set(S,q),q+=S.length;let G=new Uint32Array(_.buffer,0,_.length>>2),U=G[1];if(U!==0)throw Error(`Invalid version: ${U}`);let V=G[2],N=G[3],R=G[4]===0,j=G[5],F=G[6],B=G[7],A=[],z=(z0+xQ*F)*Uint32Array.BYTES_PER_ELEMENT,O;switch(B){case Int8Array.BYTES_PER_ELEMENT:O=new Int8Array(_.buffer,z);break;case Int16Array.BYTES_PER_ELEMENT:O=new Int16Array(_.buffer,z);break;case Int32Array.BYTES_PER_ELEMENT:O=new Int32Array(_.buffer,z);break}q=0;for(let S=0;S<F;S++){let I=G[xQ*S+z0],C=new Float32Array(I+2);A.push(C);for(let T=0;T<xQ-1;T++)C[T]=G[xQ*S+z0+T+1];for(let T=0;T<I;T++)C[T+2]=C[T]+O[q++]}return{areContours:R,thickness:j,outlines:A,width:V,height:N}}catch(Q){return p(`decompressSignature: ${Q}`),null}}}class u6 extends x6{constructor(){super();super.updateProperties({fill:m._defaultLineColor,"stroke-width":0})}clone(){let $=new u6;return $.updateAll(this),$}}class m6 extends u0{constructor($){super($);super.updateProperties({stroke:m._defaultLineColor,"stroke-width":1})}clone(){let $=new m6(this._viewParameters);return $.updateAll(this),$}}class o$ extends g{#$=!1;#Q=null;#Z=null;#K=null;static _type="signature";static _editorType=d.SIGNATURE;static _defaultDrawingOptions=null;constructor($){super({...$,mustBeCommitted:!0,name:"signatureEditor"});this._willKeepAspectRatio=!0,this.#Z=$.signatureData||null,this.#Q=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize($,Q){m.initialize($,Q),this._defaultDrawingOptions=new u6,this._defaultDrawnSignatureOptions=new m6(Q.viewParameters)}static getDefaultDrawingOptions($){let Q=this._defaultDrawingOptions.clone();return Q.updateProperties($),Q}static get supportMultipleDrawings(){return!1}static get typesMap(){return r(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#Q}}static computeTelemetryFinalData($){let Q=$.get("hasDescription");return{hasAltText:Q.get(!0)??0,hasNoAltText:Q.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){if(this._drawId===null)return;super.onScaleChanging()}render(){if(this.div)return this.div;let $,Q,{_isCopy:K}=this;if(K)this._isCopy=!1,$=this.x,Q=this.y;if(super.render(),this._drawId===null)if(this.#Z){let{lines:Z,mustSmooth:J,areContours:_,description:q,uuid:G,heightInPage:U}=this.#Z,{rawDims:{pageWidth:V,pageHeight:N},rotation:R}=this.parent.viewport,j=JQ.processDrawnLines({lines:Z,pageWidth:V,pageHeight:N,rotation:R,innerMargin:o$._INNER_MARGIN,mustSmooth:J,areContours:_});this.addSignature(j,U,q,G)}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:this.#Q||""}));if(K)this._isCopy=!0,this._moveAfterPaste($,Q);return this.div}setUuid($){this.#K=$,this.addEditToolbar()}getUuid(){return this.#K}get description(){return this.#Q}set description($){if(this.#Q=$,!this.div)return;this.div.setAttribute("data-l10n-args",JSON.stringify({description:$})),super.addEditToolbar().then((Q)=>{Q?.updateEditSignatureButton($)})}getSignaturePreview(){let{newCurves:$,areContours:Q,thickness:K,width:Z,height:J}=this.#Z,_=Math.max(Z,J),q=JQ.processDrawnLines({lines:{curves:$.map((G)=>({points:G})),thickness:K,width:Z,height:J},pageWidth:_,pageHeight:_,rotation:0,innerMargin:0,mustSmooth:!1,areContours:Q});return{areContours:Q,outline:q.outline}}get toolbarButtons(){if(this._uiManager.signatureManager)return[["editSignature",this._uiManager.signatureManager]];return super.toolbarButtons}addSignature($,Q,K,Z){let{x:J,y:_}=this,{outline:q}=this.#Z=$;this.#$=q instanceof W0,this.description=K;let G;if(this.#$)G=o$.getDefaultDrawingOptions();else G=o$._defaultDrawnSignatureOptions.clone(),G.updateProperties({"stroke-width":q.thickness});this._addOutlines({drawOutlines:q,drawingOptions:G});let[,U]=this.pageDimensions,V=Q/U;if(V=V>=1?0.5:V,this.width*=V/this.height,this.width>=1)V*=0.9/this.width,this.width=0.9;this.height=V,this.setDims(),this.x=J,this.y=_,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(Z),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!Z,hasDescription:!!K}}),this.div.hidden=!1}getFromImage($){let{rawDims:{pageWidth:Q,pageHeight:K},rotation:Z}=this.parent.viewport;return JQ.process($,Q,K,Z,o$._INNER_MARGIN)}getFromText($,Q){let{rawDims:{pageWidth:K,pageHeight:Z},rotation:J}=this.parent.viewport;return JQ.extractContoursFromText($,Q,K,Z,J,o$._INNER_MARGIN)}getDrawnSignature($){let{rawDims:{pageWidth:Q,pageHeight:K},rotation:Z}=this.parent.viewport;return JQ.processDrawnLines({lines:$,pageWidth:Q,pageHeight:K,rotation:Z,innerMargin:o$._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:$,thickness:Q}){if($)this._drawingOptions=o$.getDefaultDrawingOptions();else this._drawingOptions=o$._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":Q})}serialize($=!1){if(this.isEmpty())return null;let{lines:Q,points:K}=this.serializeDraw($),{_drawingOptions:{"stroke-width":Z}}=this,J=Object.assign(super.serialize($),{isSignature:!0,areContours:this.#$,color:[0,0,0],thickness:this.#$?0:Z});if(this.addComment(J),$)J.paths={lines:Q,points:K},J.uuid=this.#K,J.isCopy=!0;else J.lines=Q;if(this.#Q)J.accessibilityData={type:"Figure",alt:this.#Q};return J}static deserializeDraw($,Q,K,Z,J,_){if(_.areContours)return W0.deserialize($,Q,K,Z,J,_);return fQ.deserialize($,Q,K,Z,J,_)}static async deserialize($,Q,K){let Z=await super.deserialize($,Q,K);return Z.#$=$.areContours,Z.description=$.accessibilityData?.alt||"",Z.#K=$.uuid,Z}}class p8 extends m{#$=null;#Q=null;#Z=null;#K=null;#q=null;#J="";#_=null;#G=!1;#V=null;#U=!1;#j=!1;static _type="stamp";static _editorType=d.STAMP;constructor($){super({...$,name:"stampEditor"});this.#K=$.bitmapUrl,this.#q=$.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize($,Q){m.initialize($,Q)}static isHandlingMimeForPasting($){return T0.includes($)}static paste($,Q){Q.pasteEditor({mode:d.STAMP},{bitmapFile:$.getAsFile()})}altTextFinish(){if(this._uiManager.useNewAltTextFlow)this.div.hidden=!1;super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData($){let Q=$.get("hasAltText");return{hasAltText:Q.get(!0)??0,hasNoAltText:Q.get(!1)??0}}#R($,Q=!1){if(!$){this.remove();return}if(this.#$=$.bitmap,!Q)this.#Q=$.id,this.#U=$.isSvg;if($.file)this.#J=$.file.name;this.#F()}#B(){if(this.#Z=null,this._uiManager.enableWaiting(!1),!this.#_)return;if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#$){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#$){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}async mlGuessAltText($=null,Q=!0){if(this.hasAltTextData())return null;let{mlManager:K}=this._uiManager;if(!K)throw Error("No ML.");if(!await K.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:Z,width:J,height:_}=$||this.copyCanvas(null,null,!0).imageData,q=await K.guess({name:"altText",request:{data:Z,width:J,height:_,channels:Z.length/(J*_)}});if(!q)throw Error("No response from the AI service.");if(q.error)throw Error("Error from the AI service.");if(q.cancel)return null;if(!q.output)throw Error("No valid response from the AI service.");let G=q.output;if(await this.setGuessedAltText(G),Q&&!this.hasAltTextData())this.altTextData={alt:G,decorative:!1};return G}#z(){if(this.#Q){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#Q).then((K)=>this.#R(K,!0)).finally(()=>this.#B());return}if(this.#K){let K=this.#K;this.#K=null,this._uiManager.enableWaiting(!0),this.#Z=this._uiManager.imageManager.getFromUrl(K).then((Z)=>this.#R(Z)).finally(()=>this.#B());return}if(this.#q){let K=this.#q;this.#q=null,this._uiManager.enableWaiting(!0),this.#Z=this._uiManager.imageManager.getFromFile(K).then((Z)=>this.#R(Z)).finally(()=>this.#B());return}let $=document.createElement("input");$.type="file",$.accept=T0.join(",");let Q=this._uiManager._signal;this.#Z=new Promise((K)=>{$.addEventListener("change",async()=>{if(!$.files||$.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);let Z=await this._uiManager.imageManager.getFromFile($.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#R(Z)}K()},{signal:Q}),$.addEventListener("cancel",()=>{this.remove(),K()},{signal:Q})}).finally(()=>this.#B()),$.click()}remove(){if(this.#Q){if(this.#$=null,this._uiManager.imageManager.deleteId(this.#Q),this.#_?.remove(),this.#_=null,this.#V)clearTimeout(this.#V),this.#V=null}super.remove()}rebuild(){if(!this.parent){if(this.#Q)this.#z();return}if(super.rebuild(),this.div===null)return;if(this.#Q&&this.#_===null)this.#z();if(!this.isAttachedToDOM)this.parent.add(this)}onceAdded($){if(this._isDraggable=!0,$)this.div.focus()}isEmpty(){return!(this.#Z||this.#$||this.#K||this.#q||this.#Q||this.#G)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let $,Q;if(this._isCopy)$=this.x,Q=this.y;if(super.render(),this.div.hidden=!0,this.createAltText(),!this.#G)if(this.#$)this.#F();else this.#z();if(this._isCopy)this._moveAfterPaste($,Q);return this._uiManager.addShouldRescale(this),this.div}setCanvas($,Q){let{id:K,bitmap:Z}=this._uiManager.imageManager.getFromCanvas($,Q);if(Q.remove(),K&&this._uiManager.imageManager.isValidId(K)){if(this.#Q=K,Z)this.#$=Z;this.#G=!1,this.#F()}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;if(this.#V!==null)clearTimeout(this.#V);let $=200;this.#V=setTimeout(()=>{this.#V=null,this.#A()},$)}#F(){let{div:$}=this,{width:Q,height:K}=this.#$,[Z,J]=this.pageDimensions,_=0.75;if(this.width)Q=this.width*Z,K=this.height*J;else if(Q>0.75*Z||K>0.75*J){let G=Math.min(0.75*Z/Q,0.75*J/K);Q*=G,K*=G}this._uiManager.enableWaiting(!1);let q=this.#_=document.createElement("canvas");if(q.setAttribute("role","img"),this.addContainer(q),this.width=Q/Z,this.height=K/J,this.setDims(),this._initialOptions?.isCentered)this.center();else this.fixAndSetPosition();if(this._initialOptions=null,!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)$.hidden=!1;if(this.#A(),!this.#j)this.parent.addUndoableEditor(this),this.#j=!0;if(this._reportTelemetry({action:"inserted_image"}),this.#J)this.div.setAttribute("aria-description",this.#J);if(!this.annotationElementId)this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas($,Q,K=!1){if(!$)$=224;let{width:Z,height:J}=this.#$,_=new d$,q=this.#$,G=Z,U=J,V=null;if(Q){if(Z>Q||J>Q){let T=Math.min(Q/Z,Q/J);G=Math.floor(Z*T),U=Math.floor(J*T)}V=document.createElement("canvas");let R=V.width=Math.ceil(G*_.sx),j=V.height=Math.ceil(U*_.sy);if(!this.#U)q=this.#N(R,j);let F=V.getContext("2d");F.filter=this._uiManager.hcmFilter;let B="white",A="#cfcfd8";if(this._uiManager.hcmFilter!=="none")A="black";else if(E7.isDarkMode)B="#8f8f9d",A="#42414d";let z=15,O=z*_.sx,S=z*_.sy,I=new OffscreenCanvas(O*2,S*2),C=I.getContext("2d");C.fillStyle=B,C.fillRect(0,0,O*2,S*2),C.fillStyle=A,C.fillRect(0,0,O,S),C.fillRect(O,S,O,S),F.fillStyle=F.createPattern(I,"repeat"),F.fillRect(0,0,R,j),F.drawImage(q,0,0,q.width,q.height,0,0,R,j)}let N=null;if(K){let R,j;if(_.symmetric&&q.width<$&&q.height<$)R=q.width,j=q.height;else if(q=this.#$,Z>$||J>$){let A=Math.min($/Z,$/J);if(R=Math.floor(Z*A),j=Math.floor(J*A),!this.#U)q=this.#N(R,j)}let B=new OffscreenCanvas(R,j).getContext("2d",{willReadFrequently:!0});B.drawImage(q,0,0,q.width,q.height,0,0,R,j),N={width:R,height:j,data:B.getImageData(0,0,R,j).data}}return{canvas:V,width:G,height:U,imageData:N}}#N($,Q){let{width:K,height:Z}=this.#$,J=K,_=Z,q=this.#$;while(J>2*$||_>2*Q){let G=J,U=_;if(J>2*$)J=J>=16384?Math.floor(J/2)-1:Math.ceil(J/2);if(_>2*Q)_=_>=16384?Math.floor(_/2)-1:Math.ceil(_/2);let V=new OffscreenCanvas(J,_);V.getContext("2d").drawImage(q,0,0,G,U,0,0,J,_),q=V.transferToImageBitmap()}return q}#A(){let[$,Q]=this.parentDimensions,{width:K,height:Z}=this,J=new d$,_=Math.ceil(K*$*J.sx),q=Math.ceil(Z*Q*J.sy),G=this.#_;if(!G||G.width===_&&G.height===q)return;G.width=_,G.height=q;let U=this.#U?this.#$:this.#N(_,q),V=G.getContext("2d");V.filter=this._uiManager.hcmFilter,V.drawImage(U,0,0,U.width,U.height,0,0,_,q)}#O($){if($){if(this.#U){let Z=this._uiManager.imageManager.getSvgUrl(this.#Q);if(Z)return Z}let Q=document.createElement("canvas");return{width:Q.width,height:Q.height}=this.#$,Q.getContext("2d").drawImage(this.#$,0,0),Q.toDataURL()}if(this.#U){let[Q,K]=this.pageDimensions,Z=Math.round(this.width*Q*qQ.PDF_TO_CSS_UNITS),J=Math.round(this.height*K*qQ.PDF_TO_CSS_UNITS),_=new OffscreenCanvas(Z,J);return _.getContext("2d").drawImage(this.#$,0,0,this.#$.width,this.#$.height,0,0,Z,J),_.transferToImageBitmap()}return structuredClone(this.#$)}static async deserialize($,Q,K){let Z=null,J=!1;if($ instanceof b6){let{data:{rect:B,rotation:A,id:z,structParent:O,popupRef:S,richText:I,contentsObj:C,creationDate:T,modificationDate:k},container:E,parent:{page:{pageNumber:M}},canvas:W}=$,X,Y;if(W)delete $.canvas,{id:X,bitmap:Y}=K.imageManager.getFromCanvas(E.id,W),W.remove();else J=!0,$._hasNoCanvas=!0;let y=(await Q._structTree.getAriaAttributes(`${F6}${z}`))?.get("aria-label")||"";Z=$={annotationType:d.STAMP,bitmapId:X,bitmap:Y,pageIndex:M-1,rect:B.slice(0),rotation:A,annotationElementId:z,id:z,deleted:!1,accessibilityData:{decorative:!1,altText:y},isSvg:!1,structParent:O,popupRef:S,richText:I,comment:C?.str||null,creationDate:T,modificationDate:k}}let _=await super.deserialize($,Q,K),{rect:q,bitmap:G,bitmapUrl:U,bitmapId:V,isSvg:N,accessibilityData:R}=$;if(J)K.addMissingCanvas($.id,_),_.#G=!0;else if(V&&K.imageManager.isValidId(V)){if(_.#Q=V,G)_.#$=G}else _.#K=U;_.#U=N;let[j,F]=_.pageDimensions;if(_.width=(q[2]-q[0])/j,_.height=(q[3]-q[1])/F,R)_.altTextData=R;if(_._initialData=Z,$.comment)_.setCommentData($);return _.#j=!!Z,_}serialize($=!1,Q=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let K=Object.assign(super.serialize($),{bitmapId:this.#Q,isSvg:this.#U});if(this.addComment(K),$)return K.bitmapUrl=this.#O(!0),K.accessibilityData=this.serializeAltText(!0),K.isCopy=!0,K;let{decorative:Z,altText:J}=this.serializeAltText(!1);if(!Z&&J)K.accessibilityData={type:"Figure",alt:J};if(this.annotationElementId){let q=this.#T(K);if(q.isSame)return null;if(q.isSameAltText)delete K.accessibilityData;else K.accessibilityData.structParent=this._initialData.structParent??-1;return K.id=this.annotationElementId,delete K.bitmapId,K}if(Q===null)return K;Q.stamps||=new Map;let _=this.#U?(K.rect[2]-K.rect[0])*(K.rect[3]-K.rect[1]):null;if(!Q.stamps.has(this.#Q))Q.stamps.set(this.#Q,{area:_,serialized:K}),K.bitmap=this.#O(!1);else if(this.#U){let q=Q.stamps.get(this.#Q);if(_>q.area)q.area=_,q.serialized.bitmap.close(),q.serialized.bitmap=this.#O(!1)}return K}#T($){let{pageIndex:Q,accessibilityData:{altText:K}}=this._initialData,Z=$.pageIndex===Q,J=($.accessibilityData?.alt||"")===K;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&Z&&J,isSameAltText:J}}renderAnnotationElement($){if(this.deleted)return $.hide(),null;return $.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class n${#$;#Q=!1;#Z=null;#K=null;#q=null;#J=new Map;#_=!1;#G=!1;#V=!1;#U=null;#j=null;#R=null;#B=null;#z=null;#F=-1;#N;static _initialized=!1;static#A=new Map([I$,c6,p8,B$,o$].map(($)=>[$._editorType,$]));constructor({uiManager:$,pageIndex:Q,div:K,structTreeLayer:Z,accessibilityManager:J,annotationLayer:_,drawLayer:q,textLayer:G,viewport:U,l10n:V}){let N=[...n$.#A.values()];if(!n$._initialized){n$._initialized=!0;for(let R of N)R.initialize(V,$)}$.registerEditorTypes(N),this.#N=$,this.pageIndex=Q,this.div=K,this.#$=J,this.#Z=_,this.viewport=U,this.#R=G,this.drawLayer=q,this._structTree=Z,this.#N.addLayer(this)}get isEmpty(){return this.#J.size===0}get isInvisible(){return this.isEmpty&&this.#N.getMode()===d.NONE}updateToolbar($){this.#N.updateToolbar($)}updateMode($=this.#N.getMode()){switch(this.#I(),$){case d.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case d.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case d.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:Q}=this.div;if(Q.toggle("nonEditing",!1),$===d.POPUP)Q.toggle("commentEditing",!0);else{Q.toggle("commentEditing",!1);for(let K of n$.#A.values())Q.toggle(`${K._type}Editing`,$===K._editorType)}this.div.hidden=!1}hasTextLayer($){return $===this.#R?.div}setEditingState($){this.#N.setEditingState($)}addCommands($){this.#N.addCommands($)}cleanUndoStack($){this.#N.cleanUndoStack($)}toggleDrawing($=!1){this.div.classList.toggle("drawing",!$)}togglePointerEvents($=!1){this.div.classList.toggle("disabled",!$)}toggleAnnotationLayerPointerEvents($=!1){this.#Z?.div.classList.toggle("disabled",!$)}get#O(){return this.#J.size!==0?this.#J.values():this.#N.getEditors(this.pageIndex)}async enable(){this.#V=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#z?.abort(),this.#z=null;let $=new Set;for(let K of this.#O)if(K.enableEditing(),K.show(!0),K.annotationElementId)this.#N.removeChangedExistingAnnotation(K),$.add(K.annotationElementId);let Q=this.#Z;if(Q)for(let K of Q.getEditableAnnotations()){if(K.hide(),this.#N.isDeletedAnnotationElement(K.data.id))continue;if($.has(K.data.id))continue;let Z=await this.deserialize(K);if(!Z)continue;this.addOrRebuild(Z),Z.enableEditing()}this.#V=!1,this.#N._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#G=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#R&&!this.#z){this.#z=new AbortController;let K=this.#N.combinedSignal(this.#z);this.#R.div.addEventListener("pointerdown",(Z)=>{let{clientX:_,clientY:q,timeStamp:G}=Z,U=this.#F;if(G-U>500){this.#F=G;return}this.#F=-1;let{classList:V}=this.div;V.toggle("getElements",!0);let N=document.elementsFromPoint(_,q);if(V.toggle("getElements",!1),!this.div.contains(N[0]))return;let R,j=new RegExp(`^${pQ}[0-9]+$`);for(let B of N)if(j.test(B.id)){R=B.id;break}if(!R)return;let F=this.#J.get(R);if(F?.annotationElementId===null)Z.stopPropagation(),Z.preventDefault(),F.dblclick(Z)},{signal:K,capture:!0})}let $=this.#Z;if($){let K=new Map,Z=new Map;for(let _ of this.#O){if(_.disableEditing(),!_.annotationElementId){_.updateFakeAnnotationElement($);continue}if(_.serialize()!==null){K.set(_.annotationElementId,_);continue}else Z.set(_.annotationElementId,_);this.getEditableAnnotation(_.annotationElementId)?.show(),_.remove()}let J=$.getEditableAnnotations();for(let _ of J){let{id:q}=_.data;if(this.#N.isDeletedAnnotationElement(q)){_.updateEdited({deleted:!0});continue}let G=Z.get(q);if(G){G.resetAnnotationElement(_),G.show(!1),_.show();continue}if(G=K.get(q),G){if(this.#N.addChangedExistingAnnotation(G),G.renderAnnotationElement(_))G.show(!1)}_.show()}}if(this.#I(),this.isEmpty)this.div.hidden=!0;let{classList:Q}=this.div;for(let K of n$.#A.values())Q.remove(`${K._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#G=!1}getEditableAnnotation($){return this.#Z?.getEditableAnnotation($)||null}setActiveEditor($){if(this.#N.getActive()===$)return;this.#N.setActiveEditor($)}enableTextSelection(){if(this.div.tabIndex=-1,this.#R?.div&&!this.#B){this.#B=new AbortController;let $=this.#N.combinedSignal(this.#B);this.#R.div.addEventListener("pointerdown",this.#T.bind(this),{signal:$}),this.#R.div.classList.add("highlighting")}}disableTextSelection(){if(this.div.tabIndex=0,this.#R?.div&&this.#B)this.#B.abort(),this.#B=null,this.#R.div.classList.remove("highlighting")}#T($){this.#N.unselectAll();let{target:Q}=$;if(Q===this.#R.div||(Q.getAttribute("role")==="img"||Q.classList.contains("endOfContent"))&&this.#R.div.contains(Q)){let{isMac:K}=S$.platform;if($.button!==0||$.ctrlKey&&K)return;this.#N.showAllEditors("highlight",!0,!0),this.#R.div.classList.add("free"),this.toggleDrawing(),B$.startHighlighting(this,this.#N.direction==="ltr",{target:this.#R.div,x:$.x,y:$.y}),this.#R.div.addEventListener("pointerup",()=>{this.#R.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#N._signal}),$.preventDefault()}}enableClick(){if(this.#K)return;this.#K=new AbortController;let $=this.#N.combinedSignal(this.#K);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:$});let Q=this.pointerup.bind(this);this.div.addEventListener("pointerup",Q,{signal:$}),this.div.addEventListener("pointercancel",Q,{signal:$})}disableClick(){this.#K?.abort(),this.#K=null}attach($){this.#J.set($.id,$);let{annotationElementId:Q}=$;if(Q&&this.#N.isDeletedAnnotationElement(Q))this.#N.removeDeletedAnnotationElement($)}detach($){if(this.#J.delete($.id),this.#$?.removePointerInTextLayer($.contentDiv),!this.#G&&$.annotationElementId)this.#N.addDeletedAnnotationElement($)}remove($){this.detach($),this.#N.removeEditor($),$.div.remove(),$.isAttachedToDOM=!1}changeParent($){if($.parent===this)return;if($.parent&&$.annotationElementId)this.#N.addDeletedAnnotationElement($.annotationElementId),m.deleteAnnotationElement($),$.annotationElementId=null;if(this.attach($),$.parent?.detach($),$.setParent(this),$.div&&$.isAttachedToDOM)$.div.remove(),this.div.append($.div)}add($){if($.parent===this&&$.isAttachedToDOM)return;if(this.changeParent($),this.#N.addEditor($),this.attach($),!$.isAttachedToDOM){let Q=$.render();this.div.append(Q),$.isAttachedToDOM=!0}$.fixAndSetPosition(),$.onceAdded(!this.#V),this.#N.addToAnnotationStorage($),$._reportTelemetry($.telemetryInitialData)}moveEditorInDOM($){if(!$.isAttachedToDOM)return;let{activeElement:Q}=document;if($.div.contains(Q)&&!this.#q)$._focusEventsAllowed=!1,this.#q=setTimeout(()=>{if(this.#q=null,!$.div.contains(document.activeElement))$.div.addEventListener("focusin",()=>{$._focusEventsAllowed=!0},{once:!0,signal:this.#N._signal}),Q.focus();else $._focusEventsAllowed=!0},0);$._structTreeParentId=this.#$?.moveElementInDOM(this.div,$.div,$.contentDiv,!0)}addOrRebuild($){if($.needsToBeRebuilt())$.parent||=this,$.rebuild(),$.show();else this.add($)}addUndoableEditor($){let Q=()=>$._uiManager.rebuild($),K=()=>{$.remove()};this.addCommands({cmd:Q,undo:K,mustExec:!1})}getEditorByUID($){for(let Q of this.#J.values())if(Q.uid===$)return Q;return null}getNextId(){return this.#N.getId()}get#S(){return n$.#A.get(this.#N.getMode())}combinedSignal($){return this.#N.combinedSignal($)}#W($){let Q=this.#S;return Q?new Q.prototype.constructor($):null}canCreateNewEmptyEditor(){return this.#S?.canCreateNewEmptyEditor()}async pasteEditor($,Q){this.updateToolbar($),await this.#N.updateMode($.mode);let{offsetX:K,offsetY:Z}=this.#E(),J=this.getNextId(),_=this.#W({parent:this,id:J,x:K,y:Z,uiManager:this.#N,isCentered:!0,...Q});if(_)this.add(_)}async deserialize($){return await n$.#A.get($.annotationType??$.annotationEditorType)?.deserialize($,this,this.#N)||null}createAndAddNewEditor($,Q,K={}){let Z=this.getNextId(),J=this.#W({parent:this,id:Z,x:$.offsetX,y:$.offsetY,uiManager:this.#N,isCentered:Q,...K});if(J)this.add(J);return J}get boundingClientRect(){return this.div.getBoundingClientRect()}#E(){let{x:$,y:Q,width:K,height:Z}=this.boundingClientRect,J=Math.max(0,$),_=Math.max(0,Q),q=Math.min(window.innerWidth,$+K),G=Math.min(window.innerHeight,Q+Z),U=(J+q)/2-$,V=(_+G)/2-Q,[N,R]=this.viewport.rotation%180===0?[U,V]:[V,U];return{offsetX:N,offsetY:R}}addNewEditor($={}){this.createAndAddNewEditor(this.#E(),!0,$)}setSelected($){this.#N.setSelected($)}toggleSelected($){this.#N.toggleSelected($)}unselect($){this.#N.unselect($)}pointerup($){let{isMac:Q}=S$.platform;if($.button!==0||$.ctrlKey&&Q)return;if($.target!==this.div)return;if(!this.#_)return;if(this.#_=!1,this.#S?.isDrawer&&this.#S.supportMultipleDrawings)return;if(!this.#Q){this.#Q=!0;return}let K=this.#N.getMode();if(K===d.STAMP||K===d.SIGNATURE){this.#N.unselectAll();return}this.createAndAddNewEditor($,!1)}pointerdown($){if(this.#N.getMode()===d.HIGHLIGHT)this.enableTextSelection();if(this.#_){this.#_=!1;return}let{isMac:Q}=S$.platform;if($.button!==0||$.ctrlKey&&Q)return;if($.target!==this.div)return;if(this.#_=!0,this.#S?.isDrawer){this.startDrawingSession($);return}let K=this.#N.getActive();this.#Q=!K||K.isEmpty()}startDrawingSession($){if(this.div.focus({preventScroll:!0}),this.#U){this.#S.startDrawing(this,this.#N,!1,$);return}this.#N.setCurrentDrawingSession(this),this.#U=new AbortController;let Q=this.#N.combinedSignal(this.#U);this.div.addEventListener("blur",({relatedTarget:K})=>{if(K&&!this.div.contains(K))this.#j=null,this.commitOrRemove()},{signal:Q}),this.#S.startDrawing(this,this.#N,!1,$)}pause($){if($){let{activeElement:Q}=document;if(this.div.contains(Q))this.#j=Q;return}if(this.#j)setTimeout(()=>{this.#j?.focus(),this.#j=null},0)}endDrawingSession($=!1){if(!this.#U)return null;return this.#N.setCurrentDrawingSession(null),this.#U.abort(),this.#U=null,this.#j=null,this.#S.endDrawing($)}findNewParent($,Q,K){let Z=this.#N.findParent(Q,K);if(Z===null||Z===this)return!1;return Z.changeParent($),!0}commitOrRemove(){if(this.#U)return this.endDrawingSession(),!0;return!1}onScaleChanging(){if(!this.#U)return;this.#S.onScaleChangingWhenDrawing(this)}destroy(){if(this.commitOrRemove(),this.#N.getActive()?.parent===this)this.#N.commitOrRemove(),this.#N.setActiveEditor(null);if(this.#q)clearTimeout(this.#q),this.#q=null;for(let $ of this.#J.values())this.#$?.removePointerInTextLayer($.contentDiv),$.setParent(null),$.isAttachedToDOM=!1,$.div.remove();this.div=null,this.#J.clear(),this.#N.removeLayer(this)}#I(){for(let $ of this.#J.values())if($.isEmpty())$.remove()}render({viewport:$}){this.viewport=$,GQ(this.div,$);for(let Q of this.#N.getEditors(this.pageIndex))this.add(Q),Q.rebuild();this.updateMode()}update({viewport:$}){this.#N.commitOrRemove(),this.#I();let Q=this.viewport.rotation,K=$.rotation;if(this.viewport=$,GQ(this.div,{rotation:K}),Q!==K)for(let Z of this.#J.values())Z.rotate(K)}get pageDimensions(){let{pageWidth:$,pageHeight:Q}=this.viewport.rawDims;return[$,Q]}get scale(){return this.#N.viewParameters.realScale}}class C${#$=null;#Q=new Map;#Z=new Map;static#K=0;constructor({pageIndex:$}){this.pageIndex=$}setParent($){if(!this.#$){this.#$=$;return}if(this.#$!==$){if(this.#Q.size>0)for(let Q of this.#Q.values())Q.remove(),$.append(Q);this.#$=$}}static get _svgFactory(){return r(this,"_svgFactory",new PQ)}static#q($,[Q,K,Z,J]){let{style:_}=$;_.top=`${100*K}%`,_.left=`${100*Q}%`,_.width=`${100*Z}%`,_.height=`${100*J}%`}#J(){let $=C$._svgFactory.create(1,1,!0);return this.#$.append($),$.setAttribute("aria-hidden",!0),$}#_($,Q){let K=C$._svgFactory.createElement("clipPath");$.append(K);let Z=`clip_${Q}`;K.setAttribute("id",Z),K.setAttribute("clipPathUnits","objectBoundingBox");let J=C$._svgFactory.createElement("use");return K.append(J),J.setAttribute("href",`#${Q}`),J.classList.add("clip"),Z}#G($,Q){for(let[K,Z]of Object.entries(Q))if(Z===null)$.removeAttribute(K);else $.setAttribute(K,Z)}draw($,Q=!1,K=!1){let Z=C$.#K++,J=this.#J(),_=C$._svgFactory.createElement("defs");J.append(_);let q=C$._svgFactory.createElement("path");_.append(q);let G=`path_p${this.pageIndex}_${Z}`;if(q.setAttribute("id",G),q.setAttribute("vector-effect","non-scaling-stroke"),Q)this.#Z.set(Z,q);let U=K?this.#_(_,G):null,V=C$._svgFactory.createElement("use");return J.append(V),V.setAttribute("href",`#${G}`),this.updateProperties(J,$),this.#Q.set(Z,J),{id:Z,clipPathId:`url(#${U})`}}drawOutline($,Q){let K=C$.#K++,Z=this.#J(),J=C$._svgFactory.createElement("defs");Z.append(J);let _=C$._svgFactory.createElement("path");J.append(_);let q=`path_p${this.pageIndex}_${K}`;_.setAttribute("id",q),_.setAttribute("vector-effect","non-scaling-stroke");let G;if(Q){let N=C$._svgFactory.createElement("mask");J.append(N),G=`mask_p${this.pageIndex}_${K}`,N.setAttribute("id",G),N.setAttribute("maskUnits","objectBoundingBox");let R=C$._svgFactory.createElement("rect");N.append(R),R.setAttribute("width","1"),R.setAttribute("height","1"),R.setAttribute("fill","white");let j=C$._svgFactory.createElement("use");N.append(j),j.setAttribute("href",`#${q}`),j.setAttribute("stroke","none"),j.setAttribute("fill","black"),j.setAttribute("fill-rule","nonzero"),j.classList.add("mask")}let U=C$._svgFactory.createElement("use");if(Z.append(U),U.setAttribute("href",`#${q}`),G)U.setAttribute("mask",`url(#${G})`);let V=U.cloneNode();return Z.append(V),U.classList.add("mainOutline"),V.classList.add("secondaryOutline"),this.updateProperties(Z,$),this.#Q.set(K,Z),K}finalizeDraw($,Q){this.#Z.delete($),this.updateProperties($,Q)}updateProperties($,Q){if(!Q)return;let{root:K,bbox:Z,rootClass:J,path:_}=Q,q=typeof $==="number"?this.#Q.get($):$;if(!q)return;if(K)this.#G(q,K);if(Z)C$.#q(q,Z);if(J){let{classList:G}=q;for(let[U,V]of Object.entries(J))G.toggle(U,V)}if(_){let U=q.firstChild.firstChild;this.#G(U,_)}}updateParent($,Q){if(Q===this)return;let K=this.#Q.get($);if(!K)return;Q.#$.append(K),this.#Q.delete($),Q.#Q.set($,K)}remove($){if(this.#Z.delete($),this.#$===null)return;this.#Q.get($).remove(),this.#Q.delete($)}destroy(){this.#$=null;for(let $ of this.#Q.values())$.remove();this.#Q.clear(),this.#Z.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:E0};globalThis.pdfjsLib={AbortException:KQ,AnnotationEditorLayer:n$,AnnotationEditorParamsType:n,AnnotationEditorType:d,AnnotationEditorUIManager:ZQ,AnnotationLayer:c0,AnnotationMode:QQ,AnnotationType:j$,applyOpacity:M7,build:C8,ColorPicker:f$,createValidAbsoluteUrl:R6,CSSConstants:A6,DOMSVGFactory:PQ,DrawLayer:C$,FeatureTest:S$,fetchData:HQ,findContrastColor:W7,getDocument:P6,getFilenameFromUrl:I7,getPdfFilenameFromUrl:C7,getRGB:DQ,getUuid:B6,getXfaPageViewport:k7,GlobalWorkerOptions:p$,ImageKind:h$,InvalidPDFException:S0,isDataScheme:K0,isPdfFile:D0,isValidExplicitDest:f7,MathClamp:X$,noContextMenu:y$,normalizeUnicode:S7,OPS:P$,OutputScale:d$,PasswordResponses:z7,PDFDataRangeTransport:b0,PDFDateString:jQ,PDFWorker:C0,PermissionFlag:A7,PixelsPerInch:qQ,RenderingCancelledException:Q0,renderRichText:z6,ResponseException:dQ,setLayerDimensions:GQ,shadow:r,SignatureExtractor:JQ,stopEvent:N$,SupportedImageMimeTypes:T0,TextLayer:W$,TouchManager:Z0,updateUrlHash:j6,Util:x,VerbosityLevel:FQ,version:I8,XfaLayer:H0};var yK=Object.freeze(Object.defineProperty({__proto__:null,AbortException:KQ,AnnotationEditorLayer:n$,AnnotationEditorParamsType:n,AnnotationEditorType:d,AnnotationEditorUIManager:ZQ,AnnotationLayer:c0,AnnotationMode:QQ,AnnotationType:j$,CSSConstants:A6,ColorPicker:f$,DOMSVGFactory:PQ,DrawLayer:C$,FeatureTest:S$,GlobalWorkerOptions:p$,ImageKind:h$,InvalidPDFException:S0,MathClamp:X$,OPS:P$,OutputScale:d$,PDFDataRangeTransport:b0,PDFDateString:jQ,PDFWorker:C0,PasswordResponses:z7,PermissionFlag:A7,PixelsPerInch:qQ,RenderingCancelledException:Q0,ResponseException:dQ,SignatureExtractor:JQ,SupportedImageMimeTypes:T0,TextLayer:W$,TouchManager:Z0,Util:x,VerbosityLevel:FQ,XfaLayer:H0,applyOpacity:M7,build:C8,createValidAbsoluteUrl:R6,fetchData:HQ,findContrastColor:W7,getDocument:P6,getFilenameFromUrl:I7,getPdfFilenameFromUrl:C7,getRGB:DQ,getUuid:B6,getXfaPageViewport:k7,isDataScheme:K0,isPdfFile:D0,isValidExplicitDest:f7,noContextMenu:y$,normalizeUnicode:S7,renderRichText:z6,setLayerDimensions:GQ,shadow:r,stopEvent:N$,updateUrlHash:j6,version:I8},Symbol.toStringTag,{value:"Module"}));class oQ extends Error{constructor($,Q){if(Q!==void 0)super($??"Invalid PDF",{cause:Q});else super($??"Invalid PDF");if(this.name="InvalidPDFException",Object.setPrototypeOf(this,oQ.prototype),typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,oQ)}}class rQ extends Error{constructor($,Q){if(Q!==void 0)super($??"Password required or incorrect",{cause:Q});else super($??"Password required or incorrect");if(this.name="PasswordException",Object.setPrototypeOf(this,rQ.prototype),typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,rQ)}}class nQ extends Error{constructor($,Q){if(Q!==void 0)super($??"PDF format error",{cause:Q});else super($??"PDF format error");if(this.name="FormatError",Object.setPrototypeOf(this,nQ.prototype),typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,nQ)}}class aQ extends Error{constructor($,Q,K){if(K!==void 0)super($??"Unknown error",{cause:K});else super($??"Unknown error");if(this.name="UnknownErrorException",Object.setPrototypeOf(this,aQ.prototype),typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,aQ);this.details=Q}}class iQ extends Error{constructor($,Q,K,Z){if(Z!==void 0)super($??"Response error",{cause:Z});else super($??"Response error");if(this.name="ResponseException",Object.setPrototypeOf(this,iQ.prototype),typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,iQ);this.status=Q,this.missing=K}}class tQ extends Error{constructor($,Q){if(Q!==void 0)super($??"Operation aborted",{cause:Q});else super($??"Operation aborted");if(this.name="AbortException",Object.setPrototypeOf(this,tQ.prototype),typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,tQ)}}function d8($){if($ instanceof Error)switch($.name){case"InvalidPDFException":return new oQ($.message,$);case"PasswordException":return new rQ($.message,$);case"FormatError":return new nQ($.message,$);case"UnknownErrorException":return new aQ($.message,$.details,$);case"ResponseException":return new iQ($.message,$.status,$.missing,$);case"AbortException":return new tQ($.message,$);default:return $}return Error(String($))}class F${static tolerance=2;static applyTransform($,Q){let K=$[0]*Q[0]+$[1]*Q[2]+Q[4],Z=$[0]*Q[1]+$[1]*Q[3]+Q[5];return[K,Z]}}class l extends F${x;y;constructor($,Q){super();this.x=$,this.y=Q}equal($){return $.x===this.x&&$.y===this.y}transform($){let Q=F$.applyTransform([this.x,this.y],$);return this.x=Q[0],this.y=Q[1],this}}var m$=(($)=>{return $[$.None=0]="None",$[$.Horizontal=1]="Horizontal",$[$.Vertical=2]="Vertical",$})(m$||{});class z$ extends F${from;to;direction=0;length=0;intersections=[];gaps=[];constructor($,Q){super();this.from=$,this.to=Q,this.init()}init(){let $=this.from,Q=this.to;if(Math.abs($.y-Q.y)<F$.tolerance){if(this.direction=1,Q.y=$.y,$.x>Q.x){let K=$;$=Q,Q=K}this.length=Q.x-$.x}else if(Math.abs($.x-Q.x)<F$.tolerance){if(this.direction=2,Q.x=$.x,$.y>Q.y){let K=$;$=Q,Q=K}this.length=Q.y-$.y}this.from=$,this.to=Q}_valid=void 0;get valid(){if(this._valid===void 0)this._valid=this.direction!==0&&this.length>F$.tolerance;return this._valid}get normalized(){if(this.direction===1)return new z$(new l(this.from.x-F$.tolerance,this.from.y),new l(this.to.x+F$.tolerance,this.from.y));else if(this.direction===2)return new z$(new l(this.from.x,this.from.y-F$.tolerance),new l(this.from.x,this.to.y+F$.tolerance));return this}addGap($){this.gaps.push($)}containsPoint($){if(this.direction===2)return this.from.x===$.x&&$.y>=this.from.y&&$.y<=this.to.y;else if(this.direction===1)return this.from.y===$.y&&$.x>=this.from.x&&$.x<=this.to.x;return!1}addIntersectionPoint($){for(let Q of this.intersections)if(Q.equal($))return;this.intersections.push($)}intersection($){let Q;if(!this.valid||!$.valid)return Q;let K=this.normalized,Z=$.normalized;if(this.direction===1&&$.direction===2){let J=Z.from.x,_=K.from.y;if(J>K.from.x&&J<K.to.x&&_>Z.from.y&&_<Z.to.y){let G=new l(J,_);this.addIntersectionPoint(G),$.addIntersectionPoint(G),Q=G}}else if(this.direction===2&&$.direction===1){let J=K.from.x,_=Z.from.y;if(J>Z.from.x&&J<Z.to.x&&_>K.from.y&&_<K.to.y){let G=new l(J,_);this.addIntersectionPoint(G),$.addIntersectionPoint(G),Q=G}}return Q}transform($){let Q=this.from.transform($),K=this.to.transform($),Z=Math.min(Q.x,K.x),J=Math.min(Q.y,K.y),_=Math.abs(Q.x-K.x),q=Math.abs(Q.y-K.y);return this.from=new l(Z,J),this.to=new l(Z+_,J+q),this.init(),this}}class l8{minXY;maxXY;rows;rowPivots;colPivots;constructor($,Q,K,Z){this.minXY=$,this.maxXY=Q,this.rows=[],this.rowPivots=K,this.colPivots=Z}findCell($,Q){if($>=this.minXY.x&&Q>=this.minXY.y&&$<=this.maxXY.x&&Q<=this.maxXY.y){for(let K of this.rows)for(let Z of K)if(Z.minXY.x<=$&&Z.minXY.y<=Q&&Z.maxXY.x>=$&&Z.maxXY.y>=Q)return Z}return}get cellCount(){return this.rows.reduce(($,Q)=>$+Q.length,0)}get rowCount(){return this.rows.length}check(){let $=(this.colPivots.length-1)*(this.rowPivots.length-1),Q=0;for(let K of this.rows)for(let Z of K){let J=(Z.colspan||1)*(Z.rowspan||1);Q+=J}if($!==Q)return!1;return!0}toArray(){let $=[];for(let Q of this.rows){let K=[];for(let Z of Q){let J=Z.text.join("");J=J.replace(/^[\s]+|[\s]+$/g,""),J=J.trim(),K.push(J)}$.push(K)}return $}}class X0{hLines=[];vLines=[];constructor($){if($.direction===m$.Horizontal)this.hLines.push($);else if($.direction===m$.Vertical)this.vLines.push($)}get isValid(){return this.hLines.length+this.vLines.length>4}get rowPivots(){let $=new Set;for(let Q of this.hLines)$.add(Q.from.y);return[...$].sort((Q,K)=>Q-K)}get colPivots(){let $=new Set;for(let Q of this.vLines)$.add(Q.from.x);return[...$].sort((Q,K)=>Q-K)}add($){if(this.intersection($)){if($.direction===m$.Horizontal)return this.hLines.push($),!0;else if($.direction===m$.Vertical)return this.vLines.push($),!0}return!1}intersection($){let Q=!1;if(!$.valid)return Q;if($.direction===m$.Horizontal){for(let K of this.vLines)if($.intersection(K))Q=!0}else if($.direction===m$.Vertical){for(let K of this.hLines)if($.intersection(K))Q=!0}return Q}getSameHorizontal($){let Q=[$],K=[];while(this.hLines.length>0){let Z=this.hLines.shift();if(!Z)continue;if(Z.from.y===$.from.y)Q.push(Z);else K.push(Z)}return this.hLines=K,Q}getSameVertical($){let Q=[$],K=[];while(this.vLines.length>0){let Z=this.vLines.shift();if(!Z)continue;if(Z.from.x===$.from.x)Q.push(Z);else K.push(Z)}return this.vLines=K,Q}mergeHorizontalLines($){$.sort((J,_)=>J.from.x-_.from.x);let Q=$[0].from.x,K=$[$.length-1].to.x,Z=new z$(new l(Q,$[0].from.y),new l(K,$[0].from.y));for(let J=1;J<$.length;J++){let _=$[J-1],q=$[J];if(Math.abs(_.to.x-q.from.x)>F$.tolerance){let G=new z$(new l(_.to.x,_.from.y),new l(q.from.x,q.from.y));Z.addGap(G)}}return Z}mergeVerticalLines($){$.sort((J,_)=>J.from.y-_.from.y);let Q=$[0].from.y,K=$[$.length-1].to.y,Z=new z$(new l($[0].from.x,Q),new l($[0].from.x,K));for(let J=1;J<$.length;J++){let _=$[J-1],q=$[J];if(Math.abs(_.to.y-q.from.y)>F$.tolerance){let G=new z$(new l(_.to.x,_.to.y),new l(_.to.x,q.from.y));Z.addGap(G)}}return Z}normalize(){this.hLines=this.hLines.filter((K)=>K.intersections.length>1),this.vLines=this.vLines.filter((K)=>K.intersections.length>1),this.hLines.sort((K,Z)=>K.from.y-Z.from.y),this.vLines.sort((K,Z)=>K.from.x-Z.from.x);let $=[];while(this.hLines.length>0){let K=this.hLines.shift();if(!K)continue;let Z=this.getSameHorizontal(K),J=this.mergeHorizontalLines(Z);$.push(J)}this.hLines=$;let Q=[];while(this.vLines.length>0){let K=this.vLines.shift();if(!K)continue;let Z=this.getSameVertical(K),J=this.mergeVerticalLines(Z);Q.push(J)}this.vLines=Q}verticalExists($,Q,K){if($.direction!==m$.Vertical)throw Error("Line is not vertical");if(Q>=K)throw Error("y1 must be less than y2");if($.from.y<=Q&&$.to.y>=K){for(let Z of $.gaps)if(Z.from.y<=Q&&Z.to.y>=K)return!1;return!0}return!1}horizontalExists($,Q,K){if($.direction!==m$.Horizontal)throw Error("Line is not horizontal");if(Q>=K)throw Error("x1 must be less than x2");if($.from.x<=Q&&$.to.x>=K){for(let Z of $.gaps)if(Z.from.x<=Q&&Z.to.x>=K)return!1;return!0}return!1}findBottomLineIndex($,Q){for(let K=$;K<this.hLines.length;K++){let Z=this.hLines[K];if(Z.from.x<=Q&&Z.to.x>=Q)return K}return-1}findVerticalLineIndexs($,Q){let K=[];for(let Z=0;Z<this.vLines.length;Z++){let J=this.vLines[Z];if(J.from.y<=Q&&J.to.y>=Q&&$.intersection(J))K.push(Z)}return K}getRow($,Q,K){let Z=[],J=this.hLines[$],_=this.findVerticalLineIndexs(J,K);for(let q=1;q<_.length;q++){let G=this.vLines[_[q-1]],U=this.vLines[_[q]],V=(G.from.x+U.from.x)/2,N=this.findBottomLineIndex(Q,V),R=this.hLines[N],j={minXY:new l(G.from.x,J.from.y),maxXY:new l(U.from.x,R.from.y),width:U.from.x-G.from.x,height:R.from.y-J.from.y,text:[]},F=_[q]-_[q-1],B=N-$;if(F>1)j.colspan=F;if(B>1)j.rowspan=B;Z.push(j)}return Z}toData(){let $=this.rowPivots,Q=this.colPivots,K=new l(Q[0],$[0]),Z=new l(Q[Q.length-1],$[$.length-1]),J=new l8(K,Z,$,Q);for(let _=1;_<this.hLines.length;_++){let q=this.hLines[_-1],G=this.hLines[_],U=(q.from.y+G.from.y)/2,V=this.getRow(_-1,_,U);J.rows.push(V)}return J}}class h6{hLines=[];vLines=[];add($){if($.valid){if($.direction===m$.Horizontal)this.hLines.push($);else if($.direction===m$.Vertical)this.vLines.push($)}}addRectangle($){for(let Q of $.getLines())this.add(Q)}getTableData(){let $=[],Q=this.getTables();for(let K of Q){let Z=K.toData();if(Z)$.push(Z)}return $}getTables(){let $=[];while(this.hLines.length!==0){let K=this.hLines.shift();if(!K)continue;if(this.tryFill($,K))continue;let J=new X0(K);this.fillTable(J),$.push(J)}while(this.vLines.length!==0){let K=this.vLines.shift();if(!K)continue;if(this.tryFill($,K))continue;let J=new X0(K);this.fillTable(J),$.push(J)}let Q=$.filter((K)=>K.isValid);for(let K of Q)K.normalize();return Q}normalize(){this.normalizeHorizontal(),this.normalizeVertical()}normalizeHorizontal(){this.hLines.sort((K,Z)=>K.from.y-Z.from.y);let $=[],Q=[];for(let K of this.hLines)if(Q.length===0)Q.push(K);else if(Math.abs(Q[0]?.from.y-K.from.y)<F$.tolerance)Q.push(K);else{let Z=this.margeHorizontalLines(Q);$.push(...Z),Q=[K]}if(Q.length>0){let K=this.margeHorizontalLines(Q);$.push(...K)}this.hLines=$}normalizeVertical(){this.vLines.sort((K,Z)=>K.from.x-Z.from.x);let $=[],Q=[];for(let K of this.vLines)if(Q.length===0)Q.push(K);else if(Math.abs(Q[0]?.from.x-K.from.x)<F$.tolerance)Q.push(K);else{let Z=this.margeVerticalLines(Q);$.push(...Z),Q=[K]}if(Q.length>0){let K=this.margeVerticalLines(Q);$.push(...K)}this.vLines=$}fillTable($){let Q=[],K=[];for(let Z of this.vLines)if(!$.add(Z))Q.push(Z);for(let Z of this.hLines)if(!$.add(Z))K.push(Z);this.hLines=K,this.vLines=Q}tryFill($,Q){for(let K of $)if(K.add(Q))return this.fillTable(K),!0;return!1}margeHorizontalLines($){let Q=[];$.sort((q,G)=>q.from.x-G.from.x);let K=$[0]?.from.y;if(K===void 0)return Q;let{MAX_SAFE_INTEGER:Z,MIN_SAFE_INTEGER:J}=Number;for(let q of $)if(q.from.x-J<F$.tolerance){if(q.from.x<Z)Z=q.from.x;if(q.to.x>J)J=q.to.x}else{if(J>Z)Q.push(new z$(new l(Z,K),new l(J,K)));Z=q.from.x,J=q.to.x}let _=Q[Q.length-1];if(_){if(_.from.x!==Z&&_.to.x!==J)Q.push(new z$(new l(Z,K),new l(J,K)))}else Q.push(new z$(new l(Z,K),new l(J,K)));return Q}margeVerticalLines($){let Q=[];$.sort((q,G)=>q.from.y-G.from.y);let K=$[0]?.from.x;if(K===void 0)return Q;let{MAX_SAFE_INTEGER:Z,MIN_SAFE_INTEGER:J}=Number;for(let q of $)if(q.from.y-J<F$.tolerance){if(q.from.y<Z)Z=q.from.y;if(q.to.y>J)J=q.to.y}else{if(J>Z)Q.push(new z$(new l(K,Z),new l(K,J)));Z=q.from.y,J=q.to.y}let _=Q[Q.length-1];if(_){if(_.from.y!==Z&&_.to.y!==J)Q.push(new z$(new l(K,Z),new l(K,J)))}else Q.push(new z$(new l(K,Z),new l(K,J)));return Q}}class g6 extends F${from;width;height;constructor($,Q,K){super();this.from=$,this.width=Q,this.height=K}get to(){return new l(this.from.x+this.width,this.from.y+this.height)}getLines(){let $=this.to;return[new z$(this.from,new l($.x,this.from.y)),new z$(this.from,new l(this.from.x,$.y)),new z$(new l($.x,this.from.y),$),new z$(new l(this.from.x,$.y),$)].filter((K)=>K.valid)}transform($){let Q=F$.applyTransform([this.from.x,this.from.y],$),K=F$.applyTransform([this.from.x+this.width,this.from.y+this.height],$),Z=Math.min(Q[0],K[0]),J=Math.min(Q[1],K[1]),_=Math.abs(Q[0]-K[0]),q=Math.abs(Q[1]-K[1]);return this.from=new l(Z,J),this.width=_,this.height=q,this}}class s8{pages=[];total=0;getPageImage($,Q){for(let K of this.pages)if(K.pageNumber===$){for(let Z of K.images)if(Z.name===Q)return Z}return null}constructor($){this.total=$}}var VQ=["xmp:createdate","xmp:modifydate","xmp:metadatadate","xap:createdate","xap:modifydate","xap:metadatadate"];class o8{total;info;metadata;fingerprints;permission;outline;pages=[];getDateNode(){let $={},Q=this.info?.CreationDate;if(Q)$.CreationDate=jQ.toDateObject(Q);let K=this.info?.ModDate;if(K)$.ModDate=jQ.toDateObject(K);if(!this.metadata)return $;for(let Z of VQ){let J=this.metadata?.get(Z),_=this.parseISODateString(J);switch(Z){case VQ[0]:$.XmpCreateDate=_;break;case VQ[1]:$.XmpModifyDate=_;break;case VQ[2]:$.XmpMetadataDate=_;break;case VQ[3]:$.XapCreateDate=_;break;case VQ[4]:$.XapModifyDate=_;break;case VQ[5]:$.XapMetadataDate=_;break}}return $}parseISODateString($){if(!$)return;let Q=Date.parse($);if(!Number.isNaN(Q))return new Date(Q);return}constructor($){this.total=$}}function n0($){return $.lineThreshold=$?.lineThreshold??4.6,$.cellThreshold=$?.cellThreshold??7,$.cellSeparator=$?.cellSeparator??"\t",$.lineEnforce=$?.lineEnforce??!0,$.pageJoiner=$?.pageJoiner??`
15
+ -- page_number of total_number --`,$.imageThreshold=$?.imageThreshold??80,$.imageDataUrl=$?.imageDataUrl??!0,$.imageBuffer=$?.imageBuffer??!0,$.scale=$?.scale??1,$}var t$=(($)=>{return $[$.undefined=0]="undefined",$[$.hline=1]="hline",$[$.vline=2]="vline",$[$.rectangle=3]="rectangle",$})(t$||{});class r8{pages=[];total=0;constructor($){this.total=$}}class n8{pages=[];mergedTables=[];total=0;constructor($){this.total=$}}class a8{pages=[];text="";total=0;getPageText($){for(let Q of this.pages)if(Q.num===$)return Q.text;return""}constructor($){this.total=$}}class i8{options;doc;progress={loaded:-1,total:0};constructor($){if($.verbosity===void 0)$.verbosity=FQ.ERRORS;if(typeof Buffer<"u"&&$.data instanceof Buffer)$.data=new Uint8Array($.data);this.options=$}async destroy(){if(this.doc)await this.doc.destroy(),this.doc=void 0}static get isNodeJS(){return typeof process==="object"&&`${process}`==="[object process]"&&!process.versions.nw&&!(process.versions.electron&&typeof process.type<"u"&&process.type!=="browser")}static setWorker($){if(typeof globalThis.pdfjs>"u")globalThis.pdfjs=yK;if(p$===null)return"";if($!==void 0)return p$.workerSrc=$,p$.workerSrc;return p$.workerSrc}async getInfo($={}){let Q=await this.load(),K=new o8(Q.numPages),{info:Z,metadata:J}=await Q.getMetadata();K.info=Z,K.metadata=J,K.fingerprints=Q.fingerprints,K.outline=await Q.getOutline(),K.permission=await Q.getPermissions();let _=await Q.getPageLabels();if($.parsePageInfo){for(let q=1;q<=K.total;q++)if(this.shouldParse(q,K.total,$)){let G=await Q.getPage(q),U=await this.getPageLinks(G);U.pageLabel=_?.[G.pageNumber],K.pages.push(U),G.cleanup()}}return K}async getPageLinks($){let Q=$.getViewport({scale:1}),K={pageNumber:$.pageNumber,links:[],width:Q.width,height:Q.height},Z=await $.getAnnotations({intent:"display"})||[];for(let J of Z){if(J.subtype!=="Link")continue;let _=J.url??J.unsafeUrl;if(!_)continue;let q=J.overlaidText||"";K.links.push({url:_,text:q})}return K}async getText($={}){let Q=await this.load(),K=new a8(Q.numPages);for(let Z=1;Z<=K.total;Z++)if(this.shouldParse(Z,K.total,$)){let J=await Q.getPage(Z),_=await this.getPageText(J,$,K.total);K.pages.push({text:_,num:Z}),J.cleanup()}for(let Z of K.pages)if($.pageJoiner){let J=$.pageJoiner.replace("page_number",`${Z.num}`);J=J.replace("total_number",`${K.total}`),K.text+=`${Z.text}
16
+ ${J}
5
17
 
6
- //# debugId=AE2239ACD8254B9464756E2164756E21
18
+ `}else K.text+=`${Z.text}
19
+
20
+ `;return K}async load(){try{if(this.doc===void 0){let $=P6(this.options);$.onProgress=(Q)=>{this.progress=Q},this.doc=await $.promise}return this.doc}catch($){throw d8($)}}shouldParse($,Q,K){if(K.partial=K?.partial??[],K.first=K?.first??0,K.last=K?.last??0,K.partial.length>0){if(K.partial.includes($))return!0;return!1}if(K.first>0&&K.last>0){if($>=K.first&&$<=K.last)return!0;return!1}if(K.first>0){if($<=K.first)return!0;return!1}if(K.last>0){if($>Q-K.last)return!0;return!1}return!0}async getPageText($,Q,K){let Z=$.getViewport({scale:1}),J=n0(Q),_=await $.getTextContent({includeMarkedContent:!!J.includeMarkedContent,disableNormalization:!!J.disableNormalization}),q=new Map;if(J.parseHyperlinks)q=await this.getHyperlinks($,Z);let G=[],U,V,N=0;for(let R of _.items){if(!("str"in R))continue;let j=R.transform??R.transform,[F,B]=Z.convertToViewportPoint(j[4],j[5]);if(J.parseHyperlinks){let z=(q.get(R.str)||[]).find((O)=>F>=O.rect.left&&F<=O.rect.right&&B>=O.rect.top&&B<=O.rect.bottom);if(z)R.str=`[${R.str}](${z.url})`}if(J.lineEnforce){if(V!==void 0&&Math.abs(V-B)>J.lineThreshold){let A=G.length?G[G.length-1]:void 0,z=R.str.startsWith(`
21
+ `)||R.str.trim()===""&&R.hasEOL;if(A?.endsWith(`
22
+ `)===!1&&!z){if(Math.abs(V-B)-1>N)G.push(`
23
+ `),N=0}}}if(J.cellSeparator){if(V!==void 0&&Math.abs(V-B)<J.lineThreshold){if(U!==void 0&&Math.abs(U-F)>J.cellThreshold)R.str=`${J.cellSeparator}${R.str}`}}if(G.push(R.str),U=F+R.width,V=B,N=Math.max(N,R.height),R.hasEOL)G.push(`
24
+ `);if(R.hasEOL||R.str.endsWith(`
25
+ `))N=0}if(J.itemJoiner)return G.join(J.itemJoiner);return G.join("")}async getHyperlinks($,Q){let K=new Map,Z=await $.getAnnotations({intent:"display"})||[];for(let J of Z){if(J.subtype!=="Link")continue;let _=J.url??J.unsafeUrl;if(!_)continue;let q=J.overlaidText;if(!q)continue;let G=Q.convertToViewportRectangle(J.rect),U=Math.min(G[0],G[2])-0.5,V=Math.min(G[1],G[3])-0.5,N=Math.max(G[0],G[2])+0.5,R=Math.max(G[1],G[3])+0.5,j={rect:{left:U,top:V,right:N,bottom:R},url:_,text:q,used:!1},F=K.get(q);if(F)F.push(j);else K.set(q,[j])}return K}async getImage($={}){let Q=await this.load(),K=new s8(Q.numPages);n0($);for(let Z=1;Z<=K.total;Z++)if(this.shouldParse(Z,K.total,$)){let J=await Q.getPage(Z),_=await J.getOperatorList(),q={pageNumber:Z,images:[]};K.pages.push(q);for(let G=0;G<_.fnArray.length;G++)if(_.fnArray[G]===P$.paintInlineImageXObject||_.fnArray[G]===P$.paintImageXObject){let U=_.argsArray[G][0],N=J.commonObjs.has(U)?this.resolveEmbeddedImage(J.commonObjs,U):this.resolveEmbeddedImage(J.objs,U),{width:R,height:j,kind:F,data:B}=await N;if($.imageThreshold){if($.imageThreshold>=R||$.imageThreshold>=j)continue}let z=Q.canvasFactory.create(R,j),O=z.context,S=null;if(F===h$.RGBA_32BPP)S=O.createImageData(R,j),S.data.set(B);else S=O.createImageData(R,j),this.convertToRGBA({src:B,dest:new Uint32Array(S.data.buffer),width:R,height:j,kind:F});O.putImageData(S,0,0);let I=new Uint8Array,C="";if(typeof z.canvas.toBuffer==="function"){let T;if($.imageBuffer)T=z.canvas.toBuffer("image/png"),I=new Uint8Array(T);if($.imageDataUrl)if(T)C=`data:image/png;base64,${T.toString("base64")}`;else T=z.canvas.toBuffer("image/png"),I=new Uint8Array(T),C=`data:image/png;base64,${T.toString("base64")}`}else{if($.imageBuffer){let T=z.context.getImageData(0,0,z.canvas.width,z.canvas.height);I=new Uint8Array(T.data)}if($.imageDataUrl)C=z.canvas.toDataURL("image/png")}q.images.push({data:I,dataUrl:C,name:U,height:j,width:R,kind:F})}}return K}convertToRGBA({src:$,dest:Q,width:K,height:Z,kind:J}){if(J===h$.RGB_24BPP)for(let _=0,q=0;_<$.length;_+=3,q++){let G=$[_],U=$[_+1],V=$[_+2];Q[q]=-16777216|V<<16|U<<8|G}else if(J===h$.GRAYSCALE_1BPP){let _=0;for(let q=0;q<$.length;q++){let G=$[q];for(let U=7;U>=0;U--){if(_>=K*Z)break;let N=(G>>U&1)===1?255:0;Q[_++]=-16777216|N<<16|N<<8|N}}}else if(J===void 0||J===null){let _=$.length/(K*Z);if(Math.abs(_-3)<0.1)for(let q=0,G=0;q<$.length;q+=3,G++){let U=$[q],V=$[q+1],N=$[q+2];Q[G]=-16777216|N<<16|V<<8|U}else if(Math.abs(_-4)<0.1)for(let q=0,G=0;q<$.length;q+=4,G++){let U=$[q],V=$[q+1],N=$[q+2],R=$[q+3];Q[G]=R<<24|N<<16|V<<8|U}else if(Math.abs(_-1)<0.1)for(let q=0;q<$.length;q++){let G=$[q];Q[q]=-16777216|G<<16|G<<8|G}else throw Error(`convertToRGBA: Cannot infer image format. kind: ${J}, bytesPerPixel: ${_}, width: ${K}, height: ${Z}, dataLength: ${$.length}`)}else throw Error(`convertToRGBA: Unsupported image kind: ${J}. Available kinds: GRAYSCALE_1BPP=${h$.GRAYSCALE_1BPP}, RGB_24BPP=${h$.RGB_24BPP}, RGBA_32BPP=${h$.RGBA_32BPP}`)}resolveEmbeddedImage($,Q){return new Promise((K,Z)=>{$.get(Q,(J)=>{if(J){let _;if(J.data instanceof Uint8Array)_=J.data;else if(J.data instanceof Uint8ClampedArray)_=new Uint8Array(J.data);else if(J.data?.buffer)_=new Uint8Array(J.data.buffer);else if(J.bitmap){let G=this.doc.canvasFactory.create(J.bitmap.width,J.bitmap.height);G.context.drawImage(J.bitmap,0,0);let U=G.context.getImageData(0,0,J.bitmap.width,J.bitmap.height);_=new Uint8Array(U.data.buffer)}else if(ArrayBuffer.isView(J.data))_=new Uint8Array(J.data.buffer,J.data.byteOffset,J.data.byteLength);if(!_){Z(Error(`Image object ${Q}: data field is empty or invalid. Available fields: ${Object.keys(J).join(", ")}`));return}if(_.length===0){Z(Error(`Image object ${Q}: data buffer is empty (length: 0)`));return}K({width:J.width,height:J.height,kind:J.kind,data:_})}else Z(Error(`Image object ${Q} not found`))})})}async getScreenshot($={}){let Q=n0($),K=await this.load(),Z=new r8(K.numPages);if(this.doc===void 0)throw Error("PDF document not loaded");for(let J=1;J<=Z.total;J++)if(this.shouldParse(J,Z.total,Q)){let _=await this.doc.getPage(J),q=_.getViewport({scale:Q.scale});if(Q.desiredWidth){q=_.getViewport({scale:1});let F=Q.desiredWidth/q.width;q=_.getViewport({scale:F})}let U=this.doc.canvasFactory.create(q.width,q.height),V={canvasContext:U.context,viewport:q,canvas:U.canvas};await _.render(V).promise;let R=new Uint8Array,j="";if(typeof U.canvas.toBuffer==="function"){let F;if(Q.imageBuffer)F=U.canvas.toBuffer("image/png"),R=new Uint8Array(F);if(Q.imageDataUrl)if(F)j=`data:image/png;base64,${F.toString("base64")}`;else F=U.canvas.toBuffer("image/png"),R=new Uint8Array(F),j=`data:image/png;base64,${F.toString("base64")}`}else{if(Q.imageBuffer){let F=U.context.getImageData(0,0,U.canvas.width,U.canvas.height);R=new Uint8Array(F.data)}if(Q.imageDataUrl)j=U.canvas.toDataURL("image/png")}Z.pages.push({data:R,dataUrl:j,pageNumber:J,width:q.width,height:q.height,scale:q.scale}),_.cleanup()}return Z}async getTable($={}){let Q=await this.load(),K=new n8(Q.numPages);if(this.doc===void 0)throw Error("PDF document not loaded");for(let Z=1;Z<=K.total;Z++)if(this.shouldParse(Z,K.total,$)){let J=await this.doc.getPage(Z),_=await this.getPageTables(J);_.normalize();let q=_.getTableData();await this.fillPageTables(J,q);let G={num:Z,tables:[]};for(let U of q)G.tables.push(U.toArray());K.pages.push(G),J.cleanup()}return K}getPathGeometry($){let Q=$[2]-$[0],K=$[3]-$[1];if($[0]===1/0)return t$.undefined;if(Q>5&&K>5)return t$.rectangle;else if(Q>5&&K===0)return t$.hline;else if(Q===0&&K>5)return t$.vline;return t$.undefined}async getPageTables($){let Q=new h6,K=$.getViewport({scale:1}),Z=[1,0,0,1,0,0],J=[],_=await $.getOperatorList();for(let q=0;q<_.fnArray.length;q++){let G=_.fnArray[q],U=_.argsArray[q],V=U?.[0]??0,N=U?.[2]??[1/0,1/0,-1/0,-1/0];if(G===P$.constructPath){if(V===P$.fill);if(V!==P$.stroke)continue;let R=this.getPathGeometry(N);if(R===t$.rectangle){let j=new g6(new l(N[0],N[1]),N[2]-N[0],N[3]-N[1]);j.transform(Z),j.transform(K.transform),Q.addRectangle(j)}else if(R===t$.hline||R===t$.vline){let j=new l(N[0],N[1]),F=new l(N[2],N[3]),B=new z$(j,F);B.transform(Z),B.transform(K.transform),Q.add(B)}}else if(G===P$.setLineWidth);else if(G===P$.save)J.push(Z);else if(G===P$.restore){let R=J.pop();if(R)Z=R}else if(G===P$.transform)Z=x.transform(Z,U)}return Q}async fillPageTables($,Q){let K=$.getViewport({scale:1}),Z=await $.getTextContent({includeMarkedContent:!1,disableNormalization:!1});for(let J of Z.items){if(!("str"in J))continue;let _=x.transform(x.transform(K.transform,J.transform),[1,0,0,-1,0,0]);for(let q of Q){let G=q.findCell(_[4],_[5]);if(G){if(G.text.push(J.str),J.hasEOL)G.text.push(`
26
+ `);break}}}}}var d6=void 0||_0;class q0 extends xK{static serviceType=t8.PDF;capabilityDescription="The agent is able to convert PDF files to text";static async start($){return new q0}static async stop($){let Q=$.getService(t8.PDF);if(Q)await Q.stop?.()}async stop(){}async convertPdfToText($){try{let Q=await d6($);return this.cleanUpContent(Q.text)}catch(Q){throw p6.error(`PdfService: Failed to convert PDF to text - error: ${Q}`),Q}}async convertPdfToTextWithOptions($,Q={}){try{let K={};if(Q.endPage)K.max=Q.endPage;let Z=await d6($,K),J=Z.text;if(Q.cleanContent!==!1)J=this.cleanUpContent(J);return{success:!0,text:J,pageCount:Z.numpages}}catch(K){return{success:!1,error:K instanceof Error?K.message:String(K)}}}async getDocumentInfo($){try{let Q=await d6($);return{pageCount:Q.numpages,metadata:{title:Q.info?.Title,author:Q.info?.Author,creator:Q.info?.Creator,producer:Q.info?.Producer},text:this.cleanUpContent(Q.text),pages:[]}}catch(Q){throw p6.error(`PdfService: Failed to get document info - error: ${Q}`),Q}}cleanUpContent($){try{return $.replace(/[^\S\r\n]+/g," ").replace(/[ \t]+(\r?\n)/g,"$1").trim()}catch(Q){return p6.error(`PdfService: Failed to clean up content - error: ${Q}`),$}}}var lK={name:"pdf",description:"Plugin for PDF reading and text extraction",services:[q0],actions:[]};export{lK as pdfPlugin,tK as default,q0 as PdfService};
27
+
28
+ //# debugId=2034F2E19E1609B364756E2164756E21