@agentlang/lstudio 0.5.5 → 0.5.7

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.
Files changed (68) hide show
  1. package/assets/AwsJson1_1Protocol-BPKAibNb.js +1 -0
  2. package/assets/AwsQueryProtocol-gcsdfhfo.js +1 -0
  3. package/assets/XmlShapeDeserializer-yfMUWnPw.js +1 -0
  4. package/assets/_commonjs-dynamic-modules-B90KZyeo-MqqgM5Sj.js +1 -0
  5. package/assets/_commonjs-dynamic-modules-D244begT.js +1 -0
  6. package/assets/aws-BDH7ihg3.js +1 -0
  7. package/assets/documentFetcher-DXduTBqD-jqdP0czN.js +67 -0
  8. package/assets/documentFetcher-Ds-FwFaK.js +8 -0
  9. package/assets/index-BTpRe6xv-w-5JgxLH.js +1 -0
  10. package/assets/index-BWkXARMt.js +1 -0
  11. package/assets/index-BhYX3qBc.js +1 -0
  12. package/assets/{index-BFv-M3PX.js → index-BvJIpPZM.js} +14 -14
  13. package/assets/{index-CnJg8gWa.js → index-Bxvbin5N.js} +1838 -10340
  14. package/assets/index-CDKpgEyj-tyrSWl01.js +8753 -0
  15. package/assets/index-CZHYN75I.css +1 -0
  16. package/assets/index-Cv6PsiG7.js +1 -0
  17. package/assets/{index-KGBiLwKE-Doz2tX9S.js → index-D9hvpHrT-D460pOJZ.js} +7 -7
  18. package/assets/index-DGSGqHDe.js +1 -0
  19. package/assets/index-DRgW1--O-Be3NpfgF.js +17 -0
  20. package/assets/index-Dk98TczE-BtSqF03o.js +1 -0
  21. package/assets/{index-DYmn2gQ6-CnjFa625.js → index-DuUQBJXO-gNsOEp1C.js} +1 -1
  22. package/assets/{index-BitrXVkV.js → index-DzXvkWz5.js} +1 -1
  23. package/assets/{index-Dv4fZm7h.js → index-QhSmQuQt.js} +9 -9
  24. package/assets/index-_duzuPdC.js +15 -0
  25. package/assets/{index-D4z_hbl0-Bi21Cj4J.js → index-ruSRuF6L-BjzIBLlQ.js} +9 -9
  26. package/assets/index.browser-DC-BI9vG.js +5 -0
  27. package/assets/index.browser-yI_W1hK0-C1Oinehc.js +1 -0
  28. package/assets/loadCognitoIdentity-C6X581JO.js +1 -0
  29. package/assets/loadSts-BLVzhgX4.js +1 -0
  30. package/assets/noAuth-Cp7LDRaC.js +1 -0
  31. package/assets/{normalizeProvider-CtDY37Q6.js → normalizeProvider-Cd9_AiS_.js} +1 -1
  32. package/assets/pdf-parse.es-Bg6uvNNe-3L3fe-Mc.js +26 -0
  33. package/assets/pdf-parse.es-CO6QlkPs.js +26 -0
  34. package/assets/replService-CPKXCVUs.js +1 -0
  35. package/assets/sdk-stream-mixin.browser-Dycc9CbH.js +2 -0
  36. package/assets/{winston-C8DIYdyC.js → winston-BWsrMlta.js} +27 -27
  37. package/assets/{winston-BqN1-LuO.js → winston-BvOMKj10.js} +1 -1
  38. package/assets/winston-CnOlwptw-BXt6VwZK.js +1 -0
  39. package/assets/{winston-1qzyIKCb-CuWVDLx4.js → winston-Dk1WXlDf--OwDrr6q.js} +27 -27
  40. package/index.html +6 -12
  41. package/package.json +1 -1
  42. package/assets/__vite-browser-external-BDMct_Gn-FmFgRqLi.js +0 -1
  43. package/assets/__vite-browser-external-DLjrMatA.js +0 -1
  44. package/assets/_commonjs-dynamic-modules-BpilXLfW-DfYEAvWy.js +0 -1
  45. package/assets/_commonjs-dynamic-modules-DkOKMH7F.js +0 -1
  46. package/assets/index-69shuAsh-DF18H7zf.js +0 -1
  47. package/assets/index-6Q7eJvK1.js +0 -1
  48. package/assets/index-BJBOx-Z---hbiLl7B.js +0 -5
  49. package/assets/index-BVavKB4C.js +0 -1
  50. package/assets/index-BXMy9UIl.js +0 -1
  51. package/assets/index-BaNNpqQb.css +0 -1
  52. package/assets/index-Bto-kj6R-C0A_3Pwb.js +0 -1
  53. package/assets/index-CLtYN2zU.js +0 -1
  54. package/assets/index-ChvoNxcO.js +0 -5
  55. package/assets/index-DSosZ5sh-Ceejs_jv.js +0 -1
  56. package/assets/index-DTNuphFO-Bf5Ad1xs.js +0 -17
  57. package/assets/index-DsIu-45t-Bejjlpz4.js +0 -6
  58. package/assets/index.browser-BHPvGrwi-6Mh8eUw-.js +0 -1
  59. package/assets/index.browser-q8hb7jya.js +0 -6
  60. package/assets/inherits_browser-nmOknR35-Bp0mvRSL.js +0 -1
  61. package/assets/loadCognitoIdentity-j03dZ-sH.js +0 -1
  62. package/assets/loadSts-CjD8RYaH.js +0 -1
  63. package/assets/replService-DI2pw8YC.js +0 -1
  64. package/assets/resolveDefaultsModeConfig-D8w9mPn_.js +0 -15
  65. package/assets/util-BzZpaz2f.js +0 -10
  66. package/assets/util-CNqBjtt6-GUXK7Yxz.js +0 -10
  67. package/assets/util-DZRIOW0Z-CproX86h.js +0 -1
  68. package/assets/winston-CtxF18qc-Bm9o0b6l.js +0 -1
@@ -0,0 +1,26 @@
1
+ import{I as bi}from"./_commonjs-dynamic-modules-B90KZyeo-MqqgM5Sj.js";import{p as yt}from"./index.browser-yI_W1hK0-C1Oinehc.js";import{Y as cs}from"./index-6mKfgpcs-DsgiI2lM.js";var Xi=l=>{throw TypeError(l)},Ys=(l,t,e)=>t.has(l)||Xi("Cannot "+e),at=(l,t,e)=>(Ys(l,t,"read from private field"),e?e.call(l):t.get(l)),Zt=(l,t,e)=>t.has(l)?Xi("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(l):t.set(l,e),Ft=(l,t,e,s)=>(Ys(l,t,"write to private field"),t.set(l,e),e),te=(l,t,e)=>(Ys(l,t,"access private method"),e),Ir=(l,t,e,s)=>({set _(i){Ft(l,t,i)},get _(){return at(l,t,s)}}),ce,Kt,ne,Ae,Ks,Se,be,jt,xs,Yi,Ki,Oe,Ue,ds,Lr={34:((l,t,e)=>{var s=e(4901);l.exports=function(i){return typeof i=="object"?i!==null:s(i)}}),81:((l,t,e)=>{var s=e(9565),i=e(9306),r=e(8551),n=e(6823),a=e(851),o=TypeError;l.exports=function(h,c){var d=arguments.length<2?a(h):c;if(i(d))return r(s(d,h));throw new o(n(h)+" is not iterable")}}),116:((l,t,e)=>{var s=e(6518),i=e(9565),r=e(2652),n=e(9306),a=e(8551),o=e(1767),h=e(9539),c=e(4549),d=c("find",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:d},{find:function(u){a(this);try{n(u)}catch(f){h(this,"throw",f)}if(d)return i(d,this,u);var p=o(this),g=0;return r(p,function(f,m){if(u(f,g++))return m(f)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})}),283:((l,t,e)=>{var s=e(9504),i=e(9039),r=e(4901),n=e(9297),a=e(3724),o=e(350).CONFIGURABLE,h=e(3706),c=e(1181),d=c.enforce,u=c.get,p=String,g=Object.defineProperty,f=s("".slice),m=s("".replace),v=s([].join),y=a&&!i(function(){return g(function(){},"length",{value:8}).length!==8}),b=String(String).split("String"),w=l.exports=function(A,x,_){f(p(x),0,7)==="Symbol("&&(x="["+m(p(x),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),_&&_.getter&&(x="get "+x),_&&_.setter&&(x="set "+x),(!n(A,"name")||o&&A.name!==x)&&(a?g(A,"name",{value:x,configurable:!0}):A.name=x),y&&_&&n(_,"arity")&&A.length!==_.arity&&g(A,"length",{value:_.arity});try{_&&n(_,"constructor")&&_.constructor?a&&g(A,"prototype",{writable:!1}):A.prototype&&(A.prototype=void 0)}catch{}var E=d(A);return n(E,"source")||(E.source=v(b,typeof x=="string"?x:"")),A};Function.prototype.toString=w(function(){return r(this)&&u(this).source||h(this)},"toString")}),350:((l,t,e)=>{var s=e(3724),i=e(9297),r=Function.prototype,n=s&&Object.getOwnPropertyDescriptor,a=i(r,"name"),o=a&&(function(){}).name==="something",h=a&&(!s||s&&n(r,"name").configurable);l.exports={EXISTS:a,PROPER:o,CONFIGURABLE:h}}),397:((l,t,e)=>{var s=e(7751);l.exports=s("document","documentElement")}),421:(l=>{l.exports={}}),456:((l,t,e)=>{var s=e(6518),i=e(4576),r=e(9504),n=e(4154),a=e(5169),o=r(1.1.toString),h=i.Uint8Array,c=!h||!h.prototype.toHex||!(function(){try{var d=new h([255,255,255,255,255,255,255,255]);return d.toHex()==="ffffffffffffffff"}catch{return!1}})();h&&s({target:"Uint8Array",proto:!0,forced:c},{toHex:function(){n(this),a(this.buffer);for(var d="",u=0,p=this.length;u<p;u++){var g=o(this[u],16);d+=g.length===1?"0"+g:g}return d}})}),507:((l,t,e)=>{var s=e(9565);l.exports=function(i,r,n){for(var a=n?i:i.iterator,o=i.next,h,c;!(h=s(o,a)).done;)if(c=r(h.value),c!==void 0)return c}}),531:((l,t,e)=>{var s=e(6518),i=e(9565),r=e(9306),n=e(8551),a=e(1767),o=e(8646),h=e(9462),c=e(9539),d=e(6395),u=e(684),p=e(4549),g=!d&&!u("flatMap",function(){}),f=!d&&!g&&p("flatMap",TypeError),m=d||g||f,v=h(function(){for(var y=this.iterator,b=this.mapper,w,A;;){if(A=this.inner)try{if(w=n(i(A.next,A.iterator)),!w.done)return w.value;this.inner=null}catch(x){c(y,"throw",x)}if(w=n(i(this.next,y)),this.done=!!w.done)return;try{this.inner=o(b(w.value,this.counter++),!1)}catch(x){c(y,"throw",x)}}});s({target:"Iterator",proto:!0,real:!0,forced:m},{flatMap:function(y){n(this);try{r(y)}catch(b){c(this,"throw",b)}return f?i(f,this,y):new v(a(this),{mapper:y,inner:null})}})}),616:((l,t,e)=>{var s=e(9039);l.exports=!s(function(){var i=(function(){}).bind();return typeof i!="function"||i.hasOwnProperty("prototype")})}),655:((l,t,e)=>{var s=e(6955),i=String;l.exports=function(r){if(s(r)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return i(r)}}),679:((l,t,e)=>{var s=e(1625),i=TypeError;l.exports=function(r,n){if(s(n,r))return r;throw new i("Incorrect invocation")}}),684:(l=>{l.exports=function(t,e){var s=typeof Iterator=="function"&&Iterator.prototype[t];if(s)try{s.call({next:null},e).next()}catch{return!0}}}),741:(l=>{var t=Math.ceil,e=Math.floor;l.exports=Math.trunc||function(s){var i=+s;return(i>0?e:t)(i)}}),757:((l,t,e)=>{var s=e(7751),i=e(4901),r=e(1625),n=e(7040),a=Object;l.exports=n?function(o){return typeof o=="symbol"}:function(o){var h=s("Symbol");return i(h)&&r(h.prototype,a(o))}}),851:((l,t,e)=>{var s=e(6955),i=e(5966),r=e(4117),n=e(6269),a=e(8227),o=a("iterator");l.exports=function(h){if(!r(h))return i(h,o)||i(h,"@@iterator")||n[s(h)]}}),944:(l=>{var t=TypeError;l.exports=function(e){var s=e&&e.alphabet;if(s===void 0||s==="base64"||s==="base64url")return s||"base64";throw new t("Incorrect `alphabet` option")}}),1072:((l,t,e)=>{var s=e(1828),i=e(8727);l.exports=Object.keys||function(r){return s(r,i)}}),1103:(l=>{l.exports=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}}}),1108:((l,t,e)=>{var s=e(6955);l.exports=function(i){var r=s(i);return r==="BigInt64Array"||r==="BigUint64Array"}}),1148:((l,t,e)=>{var s=e(6518),i=e(9565),r=e(2652),n=e(9306),a=e(8551),o=e(1767),h=e(9539),c=e(4549),d=c("every",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:d},{every:function(u){a(this);try{n(u)}catch(f){h(this,"throw",f)}if(d)return i(d,this,u);var p=o(this),g=0;return!r(p,function(f,m){if(!u(f,g++))return m()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),1181:((l,t,e)=>{var s=e(8622),i=e(4576),r=e(34),n=e(6699),a=e(9297),o=e(7629),h=e(6119),c=e(421),d="Object already initialized",u=i.TypeError,p=i.WeakMap,g,f,m,v=function(A){return m(A)?f(A):g(A,{})},y=function(A){return function(x){var _;if(!r(x)||(_=f(x)).type!==A)throw new u("Incompatible receiver, "+A+" required");return _}};if(s||o.state){var b=o.state||(o.state=new p);b.get=b.get,b.has=b.has,b.set=b.set,g=function(A,x){if(b.has(A))throw new u(d);return x.facade=A,b.set(A,x),x},f=function(A){return b.get(A)||{}},m=function(A){return b.has(A)}}else{var w=h("state");c[w]=!0,g=function(A,x){if(a(A,w))throw new u(d);return x.facade=A,n(A,w,x),x},f=function(A){return a(A,w)?A[w]:{}},m=function(A){return a(A,w)}}l.exports={set:g,get:f,has:m,enforce:v,getterFor:y}}),1291:((l,t,e)=>{var s=e(741);l.exports=function(i){var r=+i;return r!==r||r===0?0:s(r)}}),1385:((l,t,e)=>{var s=e(9539);l.exports=function(i,r,n){for(var a=i.length-1;a>=0;a--)if(i[a]!==void 0)try{n=s(i[a].iterator,r,n)}catch(o){r="throw",n=o}if(r==="throw")throw n;return n}}),1548:((l,t,e)=>{var s=e(4576),i=e(9039),r=e(9519),n=e(4215),a=s.structuredClone;l.exports=!!a&&!i(function(){if(n==="DENO"&&r>92||n==="NODE"&&r>94||n==="BROWSER"&&r>97)return!1;var o=new ArrayBuffer(8),h=a(o,{transfer:[o]});return o.byteLength!==0||h.byteLength!==8})}),1549:((l,t,e)=>{e(6632)}),1625:((l,t,e)=>{var s=e(9504);l.exports=s({}.isPrototypeOf)}),1689:((l,t,e)=>{var s=e(6518),i=e(4576),r=e(8745),n=e(7680),a=e(6043),o=e(9306),h=e(1103),c=i.Promise,d=!1,u=!c||!c.try||h(function(){c.try(function(p){d=p===8},8)}).error||!d;s({target:"Promise",stat:!0,forced:u},{try:function(p){var g=arguments.length>1?n(arguments,1):[],f=a.f(this),m=h(function(){return r(o(p),void 0,g)});return(m.error?f.reject:f.resolve)(m.value),f.promise}})}),1698:((l,t,e)=>{var s=e(6518),i=e(4204),r=e(9835),n=e(4916),a=!n("union")||!r("union");s({target:"Set",proto:!0,real:!0,forced:a},{union:i})}),1701:((l,t,e)=>{var s=e(6518),i=e(9565),r=e(9306),n=e(8551),a=e(1767),o=e(9462),h=e(6319),c=e(9539),d=e(684),u=e(4549),p=e(6395),g=!p&&!d("map",function(){}),f=!p&&!g&&u("map",TypeError),m=p||g||f,v=o(function(){var y=this.iterator,b=n(i(this.next,y)),w=this.done=!!b.done;if(!w)return h(y,this.mapper,[b.value,this.counter++],!0)});s({target:"Iterator",proto:!0,real:!0,forced:m},{map:function(y){n(this);try{r(y)}catch(b){c(this,"throw",b)}return f?i(f,this,y):new v(a(this),{mapper:y})}})}),1767:(l=>{l.exports=function(t){return{iterator:t,next:t.next,done:!1}}}),1828:((l,t,e)=>{var s=e(9504),i=e(9297),r=e(5397),n=e(9617).indexOf,a=e(421),o=s([].push);l.exports=function(h,c){var d=r(h),u=0,p=[],g;for(g in d)!i(a,g)&&i(d,g)&&o(p,g);for(;c.length>u;)i(d,g=c[u++])&&(~n(p,g)||o(p,g));return p}}),2106:((l,t,e)=>{var s=e(283),i=e(4913);l.exports=function(r,n,a){return a.get&&s(a.get,n,{getter:!0}),a.set&&s(a.set,n,{setter:!0}),i.f(r,n,a)}}),2140:((l,t,e)=>{var s=e(8227),i=s("toStringTag"),r={};r[i]="z",l.exports=String(r)==="[object z]"}),2195:((l,t,e)=>{var s=e(9504),i=s({}.toString),r=s("".slice);l.exports=function(n){return r(i(n),8,-1)}}),2211:((l,t,e)=>{var s=e(9039);l.exports=!s(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype})}),2303:((l,t,e)=>{var s=e(4576),i=e(9504),r=s.Uint8Array,n=s.SyntaxError,a=s.parseInt,o=Math.min,h=/[^\da-f]/i,c=i(h.exec),d=i("".slice);l.exports=function(u,p){var g=u.length;if(g%2!==0)throw new n("String should be an even number of characters");for(var f=p?o(p.length,g/2):g/2,m=p||new r(f),v=0,y=0;y<f;){var b=d(u,v,v+=2);if(c(h,b))throw new n("String should only contain hex characters");m[y++]=a(b,16)}return{bytes:m,read:v}}}),2360:((l,t,e)=>{var s=e(8551),i=e(6801),r=e(8727),n=e(421),a=e(397),o=e(4055),h=e(6119),c=">",d="<",u="prototype",p="script",g=h("IE_PROTO"),f=function(){},m=function(A){return d+p+c+A+d+"/"+p+c},v=function(A){A.write(m("")),A.close();var x=A.parentWindow.Object;return A=null,x},y=function(){var A=o("iframe"),x="java"+p+":",_;return A.style.display="none",a.appendChild(A),A.src=String(x),_=A.contentWindow.document,_.open(),_.write(m("document.F=Object")),_.close(),_.F},b,w=function(){try{b=new ActiveXObject("htmlfile")}catch{}w=typeof document<"u"?document.domain&&b?v(b):y():v(b);for(var A=r.length;A--;)delete w[u][r[A]];return w()};n[g]=!0,l.exports=Object.create||function(A,x){var _;return A!==null?(f[u]=s(A),_=new f,f[u]=null,_[g]=A):_=w(),x===void 0?_:i.f(_,x)}}),2475:((l,t,e)=>{var s=e(6518),i=e(8527),r=e(4916),n=!r("isSupersetOf",function(a){return!a});s({target:"Set",proto:!0,real:!0,forced:n},{isSupersetOf:i})}),2489:((l,t,e)=>{var s=e(6518),i=e(9565),r=e(9306),n=e(8551),a=e(1767),o=e(9462),h=e(6319),c=e(6395),d=e(9539),u=e(684),p=e(4549),g=!c&&!u("filter",function(){}),f=!c&&!g&&p("filter",TypeError),m=c||g||f,v=o(function(){for(var y=this.iterator,b=this.predicate,w=this.next,A,x,_;;){if(A=n(i(w,y)),x=this.done=!!A.done,x)return;if(_=A.value,h(y,b,[_,this.counter++],!0))return _}});s({target:"Iterator",proto:!0,real:!0,forced:m},{filter:function(y){n(this);try{r(y)}catch(b){d(this,"throw",b)}return f?i(f,this,y):new v(a(this),{predicate:y})}})}),2529:(l=>{l.exports=function(t,e){return{value:t,done:e}}}),2603:((l,t,e)=>{var s=e(655);l.exports=function(i,r){return i===void 0?arguments.length<2?"":r:s(i)}}),2652:((l,t,e)=>{var s=e(6080),i=e(9565),r=e(8551),n=e(6823),a=e(4209),o=e(6198),h=e(1625),c=e(81),d=e(851),u=e(9539),p=TypeError,g=function(m,v){this.stopped=m,this.result=v},f=g.prototype;l.exports=function(m,v,y){var b=y&&y.that,w=!!(y&&y.AS_ENTRIES),A=!!(y&&y.IS_RECORD),x=!!(y&&y.IS_ITERATOR),_=!!(y&&y.INTERRUPTED),E=s(v,b),S,C,T,R,D,L,U,P=function(B){return S&&u(S,"normal"),new g(!0,B)},M=function(B){return w?(r(B),_?E(B[0],B[1],P):E(B[0],B[1])):_?E(B,P):E(B)};if(A)S=m.iterator;else if(x)S=m;else{if(C=d(m),!C)throw new p(n(m)+" is not iterable");if(a(C)){for(T=0,R=o(m);R>T;T++)if(D=M(m[T]),D&&h(f,D))return D;return new g(!1)}S=c(m,C)}for(L=A?m.next:S.next;!(U=i(L,S)).done;){try{D=M(U.value)}catch(B){u(S,"throw",B)}if(typeof D=="object"&&D&&h(f,D))return D}return new g(!1)}}),2777:((l,t,e)=>{var s=e(9565),i=e(34),r=e(757),n=e(5966),a=e(4270),o=e(8227),h=TypeError,c=o("toPrimitive");l.exports=function(d,u){if(!i(d)||r(d))return d;var p=n(d,c),g;if(p){if(u===void 0&&(u="default"),g=s(p,d,u),!i(g)||r(g))return g;throw new h("Can't convert object to primitive value")}return u===void 0&&(u="number"),a(d,u)}}),2787:((l,t,e)=>{var s=e(9297),i=e(4901),r=e(8981),n=e(6119),a=e(2211),o=n("IE_PROTO"),h=Object,c=h.prototype;l.exports=a?h.getPrototypeOf:function(d){var u=r(d);if(s(u,o))return u[o];var p=u.constructor;return i(p)&&u instanceof p?p.prototype:u instanceof h?c:null}}),2796:((l,t,e)=>{var s=e(9039),i=e(4901),r=/#|\.prototype\./,n=function(d,u){var p=o[a(d)];return p===c?!0:p===h?!1:i(u)?s(u):!!u},a=n.normalize=function(d){return String(d).replace(r,".").toLowerCase()},o=n.data={},h=n.NATIVE="N",c=n.POLYFILL="P";l.exports=n}),2804:(l=>{var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=t+"+/",s=t+"-_",i=function(r){for(var n={},a=0;a<64;a++)n[r.charAt(a)]=a;return n};l.exports={i2c:e,c2i:i(e),i2cUrl:s,c2iUrl:i(s)}}),2812:(l=>{var t=TypeError;l.exports=function(e,s){if(e<s)throw new t("Not enough arguments");return e}}),2839:((l,t,e)=>{var s=e(4576),i=s.navigator,r=i&&i.userAgent;l.exports=r?String(r):""}),2967:((l,t,e)=>{var s=e(6706),i=e(34),r=e(7750),n=e(3506);l.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var a=!1,o={},h;try{h=s(Object.prototype,"__proto__","set"),h(o,[]),a=o instanceof Array}catch{}return function(c,d){return r(c),n(d),i(c)&&(a?h(c,d):c.__proto__=d),c}})():void 0)}),3068:((l,t,e)=>{var s=e(6518),i=e(9504),r=e(2652),n=RangeError,a=TypeError,o=1/0,h=NaN,c=Math.abs,d=Math.pow,u=i([].push),p=d(2,1023),g=d(2,53)-1,f=Number.MAX_VALUE,m=d(2,971),v={},y={},b={},w={},A={},x=function(_,E){var S=_+E,C=E-(S-_);return{hi:S,lo:C}};s({target:"Math",stat:!0},{sumPrecise:function(_){var E=[],S=0,C=w;switch(r(_,function(ct){if(++S>=g)throw new n("Maximum allowed index exceeded");if(typeof ct!="number")throw new a("Value is not a number");C!==v&&(ct!==ct?C=v:ct===o?C=C===y?v:b:ct===-o?C=C===b?v:y:(ct!==0||1/ct===o)&&(C===w||C===A)&&(C=A,u(E,ct)))}),C){case v:return h;case y:return-o;case b:return o;case w:return-0}for(var T=[],R=0,D,L,U,P,M,B,K=0;K<E.length;K++){D=E[K];for(var rt=0,ht=0;ht<T.length;ht++){if(L=T[ht],c(D)<c(L)&&(B=D,D=L,L=B),U=x(D,L),P=U.hi,M=U.lo,c(P)===o){var Z=P===o?1:-1;R+=Z,D=D-Z*p-Z*p,c(D)<c(L)&&(B=D,D=L,L=B),U=x(D,L),P=U.hi,M=U.lo}M!==0&&(T[rt++]=M),D=P}T.length=rt,D!==0&&u(T,D)}var G=T.length-1;if(P=0,M=0,R!==0){var Tt=G>=0?T[G]:0;if(G--,c(R)>1||R>0&&Tt>0||R<0&&Tt<0)return R>0?o:-o;if(U=x(R*p,Tt/2),P=U.hi,M=U.lo,M*=2,c(2*P)===o)return P>0?P===p&&M===-(m/2)&&G>=0&&T[G]<0?f:o:P===-p&&M===m/2&&G>=0&&T[G]>0?-f:-o;M!==0&&(T[++G]=M,M=0),P*=2}for(;G>=0&&(U=x(P,T[G--]),P=U.hi,M=U.lo,M===0););return G>=0&&(M<0&&T[G]<0||M>0&&T[G]>0)&&(L=M*2,D=P+L,L===D-P&&(P=D)),P}})}),3167:((l,t,e)=>{var s=e(4901),i=e(34),r=e(2967);l.exports=function(n,a,o){var h,c;return r&&s(h=a.constructor)&&h!==o&&i(c=h.prototype)&&c!==o.prototype&&r(n,c),n}}),3238:((l,t,e)=>{var s=e(4576),i=e(7811),r=e(7394),n=s.DataView;l.exports=function(a){if(!i||r(a)!==0)return!1;try{return new n(a),!1}catch{return!0}}}),3392:((l,t,e)=>{var s=e(9504),i=0,r=Math.random(),n=s(1.1.toString);l.exports=function(a){return"Symbol("+(a===void 0?"":a)+")_"+n(++i+r,36)}}),3440:((l,t,e)=>{var s=e(7080),i=e(4402),r=e(9286),n=e(5170),a=e(3789),o=e(8469),h=e(507),c=i.has,d=i.remove;l.exports=function(u){var p=s(this),g=a(u),f=r(p);return n(p)<=g.size?o(p,function(m){g.includes(m)&&d(f,m)}):h(g.getIterator(),function(m){c(f,m)&&d(f,m)}),f}}),3463:(l=>{var t=TypeError;l.exports=function(e){if(typeof e=="string")return e;throw new t("Argument is not a string")}}),3506:((l,t,e)=>{var s=e(3925),i=String,r=TypeError;l.exports=function(n){if(s(n))return n;throw new r("Can't set "+i(n)+" as a prototype")}}),3579:((l,t,e)=>{var s=e(6518),i=e(9565),r=e(2652),n=e(9306),a=e(8551),o=e(1767),h=e(9539),c=e(4549),d=c("some",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:d},{some:function(u){a(this);try{n(u)}catch(f){h(this,"throw",f)}if(d)return i(d,this,u);var p=o(this),g=0;return r(p,function(f,m){if(u(f,g++))return m()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),3650:((l,t,e)=>{var s=e(7080),i=e(4402),r=e(9286),n=e(3789),a=e(507),o=i.add,h=i.has,c=i.remove;l.exports=function(d){var u=s(this),p=n(d).getIterator(),g=r(u);return a(p,function(f){h(u,f)?c(g,f):o(g,f)}),g}}),3706:((l,t,e)=>{var s=e(9504),i=e(4901),r=e(7629),n=s(Function.toString);i(r.inspectSource)||(r.inspectSource=function(a){return n(a)}),l.exports=r.inspectSource}),3717:((l,t)=>{t.f=Object.getOwnPropertySymbols}),3724:((l,t,e)=>{var s=e(9039);l.exports=!s(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),3789:((l,t,e)=>{var s=e(9306),i=e(8551),r=e(9565),n=e(1291),a=e(1767),o="Invalid size",h=RangeError,c=TypeError,d=Math.max,u=function(p,g){this.set=p,this.size=d(g,0),this.has=s(p.has),this.keys=s(p.keys)};u.prototype={getIterator:function(){return a(i(r(this.keys,this.set)))},includes:function(p){return r(this.has,this.set,p)}},l.exports=function(p){i(p);var g=+p.size;if(g!==g)throw new c(o);var f=n(g);if(f<0)throw new h(o);return new u(p,f)}}),3838:((l,t,e)=>{var s=e(7080),i=e(5170),r=e(8469),n=e(3789);l.exports=function(a){var o=s(this),h=n(a);return i(o)>h.size?!1:r(o,function(c){if(!h.includes(c))return!1},!0)!==!1}}),3853:((l,t,e)=>{var s=e(6518),i=e(4449),r=e(4916),n=!r("isDisjointFrom",function(a){return!a});s({target:"Set",proto:!0,real:!0,forced:n},{isDisjointFrom:i})}),3925:((l,t,e)=>{var s=e(34);l.exports=function(i){return s(i)||i===null}}),3972:((l,t,e)=>{var s=e(34),i=String,r=TypeError;l.exports=function(n){if(n===void 0||s(n))return n;throw new r(i(n)+" is not an object or undefined")}}),4055:((l,t,e)=>{var s=e(4576),i=e(34),r=s.document,n=i(r)&&i(r.createElement);l.exports=function(a){return n?r.createElement(a):{}}}),4114:((l,t,e)=>{var s=e(6518),i=e(8981),r=e(6198),n=e(4527),a=e(6837),o=e(9039),h=o(function(){return[].push.call({length:4294967296},1)!==4294967297}),c=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(u){return u instanceof TypeError}},d=h||!c();s({target:"Array",proto:!0,arity:1,forced:d},{push:function(u){var p=i(this),g=r(p),f=arguments.length;a(g+f);for(var m=0;m<f;m++)p[g]=arguments[m],g++;return n(p,g),g}})}),4117:(l=>{l.exports=function(t){return t==null}}),4149:(l=>{var t=RangeError;l.exports=function(e){if(e===e)return e;throw new t("NaN is not allowed")}}),4154:((l,t,e)=>{var s=e(6955),i=TypeError;l.exports=function(r){if(s(r)==="Uint8Array")return r;throw new i("Argument is not an Uint8Array")}}),4204:((l,t,e)=>{var s=e(7080),i=e(4402).add,r=e(9286),n=e(3789),a=e(507);l.exports=function(o){var h=s(this),c=n(o).getIterator(),d=r(h);return a(c,function(u){i(d,u)}),d}}),4209:((l,t,e)=>{var s=e(8227),i=e(6269),r=s("iterator"),n=Array.prototype;l.exports=function(a){return a!==void 0&&(i.Array===a||n[r]===a)}}),4215:((l,t,e)=>{var s=e(4576),i=e(2839),r=e(2195),n=function(a){return i.slice(0,a.length)===a};l.exports=(function(){return n("Bun/")?"BUN":n("Cloudflare-Workers")?"CLOUDFLARE":n("Deno/")?"DENO":n("Node.js/")?"NODE":s.Bun&&typeof Bun.version=="string"?"BUN":s.Deno&&typeof Deno.version=="object"?"DENO":r(s.process)==="process"?"NODE":s.window&&s.document?"BROWSER":"REST"})()}),4226:((l,t,e)=>{var s=e(6518),i=e(4576),r=e(3463),n=e(4154),a=e(5169),o=e(2303);i.Uint8Array&&s({target:"Uint8Array",proto:!0},{setFromHex:function(h){n(this),r(h),a(this.buffer);var c=o(h,this).read;return{read:c,written:c/2}}})}),4235:((l,t,e)=>{e(3068)}),4270:((l,t,e)=>{var s=e(9565),i=e(4901),r=e(34),n=TypeError;l.exports=function(a,o){var h,c;if(o==="string"&&i(h=a.toString)&&!r(c=s(h,a))||i(h=a.valueOf)&&!r(c=s(h,a))||o!=="string"&&i(h=a.toString)&&!r(c=s(h,a)))return c;throw new n("Can't convert object to primitive value")}}),4376:((l,t,e)=>{var s=e(2195);l.exports=Array.isArray||function(i){return s(i)==="Array"}}),4402:((l,t,e)=>{var s=e(9504),i=Set.prototype;l.exports={Set,add:s(i.add),has:s(i.has),remove:s(i.delete),proto:i}}),4449:((l,t,e)=>{var s=e(7080),i=e(4402).has,r=e(5170),n=e(3789),a=e(8469),o=e(507),h=e(9539);l.exports=function(c){var d=s(this),u=n(c);if(r(d)<=u.size)return a(d,function(g){if(u.includes(g))return!1},!0)!==!1;var p=u.getIterator();return o(p,function(g){if(i(d,g))return h(p,"normal",!1)})!==!1}}),4483:((l,t,e)=>{var s=e(4576),i=e(9429),r=e(1548),n=s.structuredClone,a=s.ArrayBuffer,o=s.MessageChannel,h=!1,c,d,u,p;if(r)h=function(g){n(g,{transfer:[g]})};else if(a)try{o||(c=i("worker_threads"),c&&(o=c.MessageChannel)),o&&(d=new o,u=new a(2),p=function(g){d.port1.postMessage(null,[g])},u.byteLength===2&&(p(u),u.byteLength===0&&(h=p)))}catch{}l.exports=h}),4495:((l,t,e)=>{var s=e(9519),i=e(9039),r=e(4576),n=r.String;l.exports=!!Object.getOwnPropertySymbols&&!i(function(){var a=Symbol("symbol detection");return!n(a)||!(Object(a)instanceof Symbol)||!Symbol.sham&&s&&s<41})}),4527:((l,t,e)=>{var s=e(3724),i=e(4376),r=TypeError,n=Object.getOwnPropertyDescriptor,a=s&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(o){return o instanceof TypeError}})();l.exports=a?function(o,h){if(i(o)&&!n(o,"length").writable)throw new r("Cannot set read only .length");return o.length=h}:function(o,h){return o.length=h}}),4549:((l,t,e)=>{var s=e(4576);l.exports=function(i,r){var n=s.Iterator,a=n&&n.prototype,o=a&&a[i],h=!1;if(o)try{o.call({next:function(){return{done:!0}},return:function(){h=!0}},-1)}catch(c){c instanceof r||(h=!1)}if(!h)return o}}),4576:(function(l){var t=function(e){return e&&e.Math===Math&&e};l.exports=t(typeof globalThis=="object"&&globalThis)||t(typeof window=="object"&&window)||t(typeof self=="object"&&self)||t(typeof bi=="object"&&bi)||t(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()}),4603:((l,t,e)=>{var s=e(6840),i=e(9504),r=e(655),n=e(2812),a=URLSearchParams,o=a.prototype,h=i(o.append),c=i(o.delete),d=i(o.forEach),u=i([].push),p=new a("a=1&a=2&b=3");p.delete("a",1),p.delete("b",void 0),p+""!="a=2"&&s(o,"delete",function(g){var f=arguments.length,m=f<2?void 0:arguments[1];if(f&&m===void 0)return c(this,g);var v=[];d(this,function(S,C){u(v,{key:C,value:S})}),n(f,1);for(var y=r(g),b=r(m),w=0,A=0,x=!1,_=v.length,E;w<_;)E=v[w++],x||E.key===y?(x=!0,c(this,E.key)):A++;for(;A<_;)E=v[A++],E.key===y&&E.value===b||h(this,E.key,E.value)},{enumerable:!0,unsafe:!0})}),4628:((l,t,e)=>{var s=e(6518),i=e(6043);s({target:"Promise",stat:!0},{withResolvers:function(){var r=i.f(this);return{promise:r.promise,resolve:r.resolve,reject:r.reject}}})}),4644:((l,t,e)=>{var s=e(7811),i=e(3724),r=e(4576),n=e(4901),a=e(34),o=e(9297),h=e(6955),c=e(6823),d=e(6699),u=e(6840),p=e(2106),g=e(1625),f=e(2787),m=e(2967),v=e(8227),y=e(3392),b=e(1181),w=b.enforce,A=b.get,x=r.Int8Array,_=x&&x.prototype,E=r.Uint8ClampedArray,S=E&&E.prototype,C=x&&f(x),T=_&&f(_),R=Object.prototype,D=r.TypeError,L=v("toStringTag"),U=y("TYPED_ARRAY_TAG"),P="TypedArrayConstructor",M=s&&!!m&&h(r.opera)!=="Opera",B=!1,K,rt,ht,Z={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},G={BigInt64Array:8,BigUint64Array:8},Tt=function($){if(!a($))return!1;var st=h($);return st==="DataView"||o(Z,st)||o(G,st)},ct=function($){var st=f($);if(a(st)){var dt=A(st);return dt&&o(dt,P)?dt[P]:ct(st)}},O=function($){if(!a($))return!1;var st=h($);return o(Z,st)||o(G,st)},k=function($){if(O($))return $;throw new D("Target is not a typed array")},I=function($){if(n($)&&(!m||g(C,$)))return $;throw new D(c($)+" is not a typed array constructor")},V=function($,st,dt,Bt){if(i){if(dt)for(var kt in Z){var Et=r[kt];if(Et&&o(Et.prototype,$))try{delete Et.prototype[$]}catch{try{Et.prototype[$]=st}catch{}}}(!T[$]||dt)&&u(T,$,dt?st:M&&_[$]||st,Bt)}},et=function($,st,dt){var Bt,kt;if(i){if(m){if(dt){for(Bt in Z)if(kt=r[Bt],kt&&o(kt,$))try{delete kt[$]}catch{}}if(!C[$]||dt)try{return u(C,$,dt?st:M&&C[$]||st)}catch{}else return}for(Bt in Z)kt=r[Bt],kt&&(!kt[$]||dt)&&u(kt,$,st)}};for(K in Z)rt=r[K],ht=rt&&rt.prototype,ht?w(ht)[P]=rt:M=!1;for(K in G)rt=r[K],ht=rt&&rt.prototype,ht&&(w(ht)[P]=rt);if((!M||!n(C)||C===Function.prototype)&&(C=function(){throw new D("Incorrect invocation")},M))for(K in Z)r[K]&&m(r[K],C);if((!M||!T||T===R)&&(T=C.prototype,M))for(K in Z)r[K]&&m(r[K].prototype,T);if(M&&f(S)!==T&&m(S,T),i&&!o(T,L)){B=!0,p(T,L,{configurable:!0,get:function(){return a(this)?this[U]:void 0}});for(K in Z)r[K]&&d(r[K],U,K)}l.exports={NATIVE_ARRAY_BUFFER_VIEWS:M,TYPED_ARRAY_TAG:B&&U,aTypedArray:k,aTypedArrayConstructor:I,exportTypedArrayMethod:V,exportTypedArrayStaticMethod:et,getTypedArrayConstructor:ct,isView:Tt,isTypedArray:O,TypedArray:C,TypedArrayPrototype:T}}),4659:((l,t,e)=>{var s=e(3724),i=e(4913),r=e(6980);l.exports=function(n,a,o){s?i.f(n,a,r(0,o)):n[a]=o}}),4901:(l=>{var t=typeof document=="object"&&document.all;l.exports=typeof t>"u"&&t!==void 0?function(e){return typeof e=="function"||e===t}:function(e){return typeof e=="function"}}),4913:((l,t,e)=>{var s=e(3724),i=e(5917),r=e(8686),n=e(8551),a=e(6969),o=TypeError,h=Object.defineProperty,c=Object.getOwnPropertyDescriptor,d="enumerable",u="configurable",p="writable";t.f=s?r?function(g,f,m){if(n(g),f=a(f),n(m),typeof g=="function"&&f==="prototype"&&"value"in m&&p in m&&!m[p]){var v=c(g,f);v&&v[p]&&(g[f]=m.value,m={configurable:u in m?m[u]:v[u],enumerable:d in m?m[d]:v[d],writable:!1})}return h(g,f,m)}:h:function(g,f,m){if(n(g),f=a(f),n(m),i)try{return h(g,f,m)}catch{}if("get"in m||"set"in m)throw new o("Accessors not supported");return"value"in m&&(g[f]=m.value),g}}),4916:((l,t,e)=>{var s=e(7751),i=function(n){return{size:n,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},r=function(n){return{size:n,has:function(){return!0},keys:function(){throw new Error("e")}}};l.exports=function(n,a){var o=s("Set");try{new o()[n](i(0));try{return new o()[n](i(-1)),!1}catch{if(!a)return!0;try{return new o()[n](r(-1/0)),!1}catch{var h=new o;return h.add(1),h.add(2),a(h[n](r(1/0)))}}}catch{return!1}}}),4972:((l,t,e)=>{var s=e(6518),i=e(9565),r=e(8551),n=e(1767),a=e(4149),o=e(9590),h=e(9462),c=e(9539),d=e(4549),u=e(6395),p=!u&&d("take",RangeError),g=h(function(){var f=this.iterator;if(!this.remaining--)return this.done=!0,c(f,"normal",void 0);var m=r(i(this.next,f)),v=this.done=!!m.done;if(!v)return m.value});s({target:"Iterator",proto:!0,real:!0,forced:u||p},{take:function(f){r(this);var m;try{m=o(a(+f))}catch(v){c(this,"throw",v)}return p?i(p,this,m):new g(n(this),{remaining:m})}})}),4979:((l,t,e)=>{var s=e(6518),i=e(4576),r=e(7751),n=e(6980),a=e(4913).f,o=e(9297),h=e(679),c=e(3167),d=e(2603),u=e(5002),p=e(8574),g=e(3724),f=e(6395),m="DOMException",v=r("Error"),y=r(m),b=function(){h(this,w);var U=arguments.length,P=d(U<1?void 0:arguments[0]),M=d(U<2?void 0:arguments[1],"Error"),B=new y(P,M),K=new v(P);return K.name=m,a(B,"stack",n(1,p(K.stack,1))),c(B,this,b),B},w=b.prototype=y.prototype,A="stack"in new v(m),x="stack"in new y(1,2),_=y&&g&&Object.getOwnPropertyDescriptor(i,m),E=!!_&&!(_.writable&&_.configurable),S=A&&!E&&!x;s({global:!0,constructor:!0,forced:f||S},{DOMException:S?b:y});var C=r(m),T=C.prototype;if(T.constructor!==C){f||a(T,"constructor",n(1,C));for(var R in u)if(o(u,R)){var D=u[R],L=D.s;o(C,L)||a(C,L,n(6,D.c))}}}),5002:(l=>{l.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:((l,t,e)=>{var s=e(6518),i=e(3650),r=e(9835),n=e(4916),a=!n("symmetricDifference")||!r("symmetricDifference");s({target:"Set",proto:!0,real:!0,forced:a},{symmetricDifference:i})}),5031:((l,t,e)=>{var s=e(7751),i=e(9504),r=e(8480),n=e(3717),a=e(8551),o=i([].concat);l.exports=s("Reflect","ownKeys")||function(h){var c=r.f(a(h)),d=n.f;return d?o(c,d(h)):c}}),5169:((l,t,e)=>{var s=e(3238),i=TypeError;l.exports=function(r){if(s(r))throw new i("ArrayBuffer is detached");return r}}),5170:((l,t,e)=>{var s=e(6706),i=e(4402);l.exports=s(i.proto,"size","get")||function(r){return r.size}}),5213:((l,t,e)=>{var s=e(6518),i=e(4576),r=e(5370),n=e(9143),a=i.Uint8Array,o=!a||!a.fromBase64||!(function(){try{a.fromBase64("a");return}catch{}try{a.fromBase64("",null)}catch{return!0}})();a&&s({target:"Uint8Array",stat:!0,forced:o},{fromBase64:function(h){var c=n(h,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return r(a,c.bytes)}})}),5370:((l,t,e)=>{var s=e(6198);l.exports=function(i,r,n){for(var a=0,o=arguments.length>2?n:s(r),h=new i(o);o>a;)h[a]=r[a++];return h}}),5397:((l,t,e)=>{var s=e(7055),i=e(7750);l.exports=function(r){return s(i(r))}}),5610:((l,t,e)=>{var s=e(1291),i=Math.max,r=Math.min;l.exports=function(n,a){var o=s(n);return o<0?i(o+a,0):r(o,a)}}),5623:((l,t,e)=>{e(456)}),5636:((l,t,e)=>{var s=e(4576),i=e(9504),r=e(6706),n=e(7696),a=e(5169),o=e(7394),h=e(4483),c=e(1548),d=s.structuredClone,u=s.ArrayBuffer,p=s.DataView,g=Math.min,f=u.prototype,m=p.prototype,v=i(f.slice),y=r(f,"resizable","get"),b=r(f,"maxByteLength","get"),w=i(m.getInt8),A=i(m.setInt8);l.exports=(c||h)&&function(x,_,E){var S=o(x),C=_===void 0?S:n(_),T=!y||!y(x),R;if(a(x),c&&(x=d(x,{transfer:[x]}),S===C&&(E||T)))return x;if(S>=C&&(!E||T))R=v(x,0,C);else{var D=E&&!T&&b?{maxByteLength:b(x)}:void 0;R=new u(C,D);for(var L=new p(x),U=new p(R),P=g(C,S),M=0;M<P;M++)A(U,M,w(L,M))}return c||h(x),R}}),5745:((l,t,e)=>{var s=e(7629);l.exports=function(i,r){return s[i]||(s[i]=r||{})}}),5781:((l,t,e)=>{var s=e(6518),i=e(7751),r=e(2812),n=e(655),a=e(7416),o=i("URL");s({target:"URL",stat:!0,forced:!a},{parse:function(h){var c=r(arguments.length,1),d=n(h),u=c<2||arguments[1]===void 0?void 0:n(arguments[1]);try{return new o(d,u)}catch{return null}}})}),5854:((l,t,e)=>{var s=e(2777),i=TypeError;l.exports=function(r){var n=s(r,"number");if(typeof n=="number")throw new i("Can't convert number to bigint");return BigInt(n)}}),5876:((l,t,e)=>{var s=e(6518),i=e(3838),r=e(4916),n=!r("isSubsetOf",function(a){return a});s({target:"Set",proto:!0,real:!0,forced:n},{isSubsetOf:i})}),5917:((l,t,e)=>{var s=e(3724),i=e(9039),r=e(4055);l.exports=!s&&!i(function(){return Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a!==7})}),5966:((l,t,e)=>{var s=e(9306),i=e(4117);l.exports=function(r,n){var a=r[n];return i(a)?void 0:s(a)}}),6043:((l,t,e)=>{var s=e(9306),i=TypeError,r=function(n){var a,o;this.promise=new n(function(h,c){if(a!==void 0||o!==void 0)throw new i("Bad Promise constructor");a=h,o=c}),this.resolve=s(a),this.reject=s(o)};l.exports.f=function(n){return new r(n)}}),6080:((l,t,e)=>{var s=e(7476),i=e(9306),r=e(616),n=s(s.bind);l.exports=function(a,o){return i(a),o===void 0?a:r?n(a,o):function(){return a.apply(o,arguments)}}}),6119:((l,t,e)=>{var s=e(5745),i=e(3392),r=s("keys");l.exports=function(n){return r[n]||(r[n]=i(n))}}),6193:((l,t,e)=>{var s=e(4215);l.exports=s==="NODE"}),6198:((l,t,e)=>{var s=e(8014);l.exports=function(i){return s(i.length)}}),6269:(l=>{l.exports={}}),6279:((l,t,e)=>{var s=e(6840);l.exports=function(i,r,n){for(var a in r)s(i,a,r[a],n);return i}}),6319:((l,t,e)=>{var s=e(8551),i=e(9539);l.exports=function(r,n,a,o){try{return o?n(s(a)[0],a[1]):n(a)}catch(h){i(r,"throw",h)}}}),6395:(l=>{l.exports=!1}),6518:((l,t,e)=>{var s=e(4576),i=e(7347).f,r=e(6699),n=e(6840),a=e(9433),o=e(7740),h=e(2796);l.exports=function(c,d){var u=c.target,p=c.global,g=c.stat,f,m,v,y,b,w;if(p?m=s:g?m=s[u]||a(u,{}):m=s[u]&&s[u].prototype,m)for(v in d){if(b=d[v],c.dontCallGetSet?(w=i(m,v),y=w&&w.value):y=m[v],f=h(p?v:u+(g?".":"#")+v,c.forced),!f&&y!==void 0){if(typeof b==typeof y)continue;o(b,y)}(c.sham||y&&y.sham)&&r(b,"sham",!0),n(m,v,b,c)}}}),6573:((l,t,e)=>{var s=e(3724),i=e(2106),r=e(3238),n=ArrayBuffer.prototype;s&&!("detached"in n)&&i(n,"detached",{configurable:!0,get:function(){return r(this)}})}),6632:((l,t,e)=>{var s=e(6518),i=e(4576),r=e(9143),n=e(4154),a=i.Uint8Array,o=!a||!a.prototype.setFromBase64||!(function(){var h=new a([255,255,255,255,255]);try{h.setFromBase64("",null);return}catch{}try{h.setFromBase64("a");return}catch{}try{h.setFromBase64("MjYyZg===")}catch{return h[0]===50&&h[1]===54&&h[2]===50&&h[3]===255&&h[4]===255}})();a&&s({target:"Uint8Array",proto:!0,forced:o},{setFromBase64:function(h){n(this);var c=r(h,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:c.read,written:c.written}}})}),6699:((l,t,e)=>{var s=e(3724),i=e(4913),r=e(6980);l.exports=s?function(n,a,o){return i.f(n,a,r(1,o))}:function(n,a,o){return n[a]=o,n}}),6706:((l,t,e)=>{var s=e(9504),i=e(9306);l.exports=function(r,n,a){try{return s(i(Object.getOwnPropertyDescriptor(r,n)[a]))}catch{}}}),6801:((l,t,e)=>{var s=e(3724),i=e(8686),r=e(4913),n=e(8551),a=e(5397),o=e(1072);t.f=s&&!i?Object.defineProperties:function(h,c){n(h);for(var d=a(c),u=o(c),p=u.length,g=0,f;p>g;)r.f(h,f=u[g++],d[f]);return h}}),6823:(l=>{var t=String;l.exports=function(e){try{return t(e)}catch{return"Object"}}}),6837:(l=>{var t=TypeError,e=9007199254740991;l.exports=function(s){if(s>e)throw t("Maximum allowed index exceeded");return s}}),6840:((l,t,e)=>{var s=e(4901),i=e(4913),r=e(283),n=e(9433);l.exports=function(a,o,h,c){c||(c={});var d=c.enumerable,u=c.name!==void 0?c.name:o;if(s(h)&&r(h,u,c),c.global)d?a[o]=h:n(o,h);else{try{c.unsafe?a[o]&&(d=!0):delete a[o]}catch{}d?a[o]=h:i.f(a,o,{value:h,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return a}}),6955:((l,t,e)=>{var s=e(2140),i=e(4901),r=e(2195),n=e(8227),a=n("toStringTag"),o=Object,h=r((function(){return arguments})())==="Arguments",c=function(d,u){try{return d[u]}catch{}};l.exports=s?r:function(d){var u,p,g;return d===void 0?"Undefined":d===null?"Null":typeof(p=c(u=o(d),a))=="string"?p:h?r(u):(g=r(u))==="Object"&&i(u.callee)?"Arguments":g}}),6969:((l,t,e)=>{var s=e(2777),i=e(757);l.exports=function(r){var n=s(r,"string");return i(n)?n:n+""}}),6980:(l=>{l.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}}),7040:((l,t,e)=>{var s=e(4495);l.exports=s&&!Symbol.sham&&typeof Symbol.iterator=="symbol"}),7055:((l,t,e)=>{var s=e(9504),i=e(9039),r=e(2195),n=Object,a=s("".split);l.exports=i(function(){return!n("z").propertyIsEnumerable(0)})?function(o){return r(o)==="String"?a(o,""):n(o)}:n}),7080:((l,t,e)=>{var s=e(4402).has;l.exports=function(i){return s(i),i}}),7347:((l,t,e)=>{var s=e(3724),i=e(9565),r=e(8773),n=e(6980),a=e(5397),o=e(6969),h=e(9297),c=e(5917),d=Object.getOwnPropertyDescriptor;t.f=s?d:function(u,p){if(u=a(u),p=o(p),c)try{return d(u,p)}catch{}if(h(u,p))return n(!i(r.f,u,p),u[p])}}),7394:((l,t,e)=>{var s=e(4576),i=e(6706),r=e(2195),n=s.ArrayBuffer,a=s.TypeError;l.exports=n&&i(n.prototype,"byteLength","get")||function(o){if(r(o)!=="ArrayBuffer")throw new a("ArrayBuffer expected");return o.byteLength}}),7416:((l,t,e)=>{var s=e(9039),i=e(8227),r=e(3724),n=e(6395),a=i("iterator");l.exports=!s(function(){var o=new URL("b?a=1&b=2&c=3","https://a"),h=o.searchParams,c=new URLSearchParams("a=1&a=2&b=3"),d="";return o.pathname="c%20d",h.forEach(function(u,p){h.delete("b"),d+=p+u}),c.delete("a",2),c.delete("b",void 0),n&&(!o.toJSON||!c.has("a",1)||c.has("a",2)||!c.has("a",void 0)||c.has("b"))||!h.size&&(n||!r)||!h.sort||o.href!=="https://a/c%20d?a=1&c=3"||h.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!h[a]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||d!=="a1c3"||new URL("https://x",void 0).host!=="x"})}),7476:((l,t,e)=>{var s=e(2195),i=e(9504);l.exports=function(r){if(s(r)==="Function")return i(r)}}),7566:((l,t,e)=>{var s=e(6840),i=e(9504),r=e(655),n=e(2812),a=URLSearchParams,o=a.prototype,h=i(o.getAll),c=i(o.has),d=new a("a=1");(d.has("a",2)||!d.has("a",void 0))&&s(o,"has",function(u){var p=arguments.length,g=p<2?void 0:arguments[1];if(p&&g===void 0)return c(this,u);var f=h(this,u);n(p,1);for(var m=r(g),v=0;v<f.length;)if(f[v++]===m)return!0;return!1},{enumerable:!0,unsafe:!0})}),7588:((l,t,e)=>{var s=e(6518),i=e(9565),r=e(2652),n=e(9306),a=e(8551),o=e(1767),h=e(9539),c=e(4549),d=c("forEach",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:d},{forEach:function(u){a(this);try{n(u)}catch(f){h(this,"throw",f)}if(d)return i(d,this,u);var p=o(this),g=0;r(p,function(f){u(f,g++)},{IS_RECORD:!0})}})}),7629:((l,t,e)=>{var s=e(6395),i=e(4576),r=e(9433),n="__core-js_shared__",a=l.exports=i[n]||r(n,{});(a.versions||(a.versions=[])).push({version:"3.45.1",mode:s?"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:((l,t,e)=>{var s=e(6518),i=e(3440),r=e(9039),n=e(4916),a=!n("difference",function(h){return h.size===0}),o=a||r(function(){var h={size:1,has:function(){return!0},keys:function(){var d=0;return{next:function(){var u=d++>1;return c.has(1)&&c.clear(),{done:u,value:2}}}}},c=new Set([1,2,3,4]);return c.difference(h).size!==3});s({target:"Set",proto:!0,real:!0,forced:o},{difference:i})}),7657:((l,t,e)=>{var s=e(9039),i=e(4901),r=e(34),n=e(2360),a=e(2787),o=e(6840),h=e(8227),c=e(6395),d=h("iterator"),u=!1,p,g,f;[].keys&&(f=[].keys(),"next"in f?(g=a(a(f)),g!==Object.prototype&&(p=g)):u=!0);var m=!r(p)||s(function(){var v={};return p[d].call(v)!==v});m?p={}:c&&(p=n(p)),i(p[d])||o(p,d,function(){return this}),l.exports={IteratorPrototype:p,BUGGY_SAFARI_ITERATORS:u}}),7680:((l,t,e)=>{var s=e(9504);l.exports=s([].slice)}),7696:((l,t,e)=>{var s=e(1291),i=e(8014),r=RangeError;l.exports=function(n){if(n===void 0)return 0;var a=s(n),o=i(a);if(a!==o)throw new r("Wrong length or index");return o}}),7740:((l,t,e)=>{var s=e(9297),i=e(5031),r=e(7347),n=e(4913);l.exports=function(a,o,h){for(var c=i(o),d=n.f,u=r.f,p=0;p<c.length;p++){var g=c[p];!s(a,g)&&!(h&&s(h,g))&&d(a,g,u(o,g))}}}),7750:((l,t,e)=>{var s=e(4117),i=TypeError;l.exports=function(r){if(s(r))throw new i("Can't call method on "+r);return r}}),7751:((l,t,e)=>{var s=e(4576),i=e(4901),r=function(n){return i(n)?n:void 0};l.exports=function(n,a){return arguments.length<2?r(s[n]):s[n]&&s[n][a]}}),7811:(l=>{l.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"}),7936:((l,t,e)=>{var s=e(6518),i=e(5636);i&&s({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return i(this,arguments.length?arguments[0]:void 0,!1)}})}),8004:((l,t,e)=>{var s=e(6518),i=e(9039),r=e(8750),n=e(4916),a=!n("intersection",function(o){return o.size===2&&o.has(1)&&o.has(2)})||i(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});s({target:"Set",proto:!0,real:!0,forced:a},{intersection:r})}),8014:((l,t,e)=>{var s=e(1291),i=Math.min;l.exports=function(r){var n=s(r);return n>0?i(n,9007199254740991):0}}),8100:((l,t,e)=>{var s=e(6518),i=e(5636);i&&s({target:"ArrayBuffer",proto:!0},{transfer:function(){return i(this,arguments.length?arguments[0]:void 0,!0)}})}),8111:((l,t,e)=>{var s=e(6518),i=e(4576),r=e(679),n=e(8551),a=e(4901),o=e(2787),h=e(2106),c=e(4659),d=e(9039),u=e(9297),p=e(8227),g=e(7657).IteratorPrototype,f=e(3724),m=e(6395),v="constructor",y="Iterator",b=p("toStringTag"),w=TypeError,A=i[y],x=m||!a(A)||A.prototype!==g||!d(function(){A({})}),_=function(){if(r(this,g),o(this)===g)throw new w("Abstract class Iterator not directly constructable")},E=function(S,C){f?h(g,S,{configurable:!0,get:function(){return C},set:function(T){if(n(this),this===g)throw new w("You can't redefine this property");u(this,S)?this[S]=T:c(this,S,T)}}):g[S]=C};u(g,b)||E(b,y),(x||!u(g,v)||g[v]===Object)&&E(v,_),_.prototype=g,s({global:!0,constructor:!0,forced:x},{Iterator:_})}),8227:((l,t,e)=>{var s=e(4576),i=e(5745),r=e(9297),n=e(3392),a=e(4495),o=e(7040),h=s.Symbol,c=i("wks"),d=o?h.for||h:h&&h.withoutSetter||n;l.exports=function(u){return r(c,u)||(c[u]=a&&r(h,u)?h[u]:d("Symbol."+u)),c[u]}}),8235:((l,t,e)=>{var s=e(9504),i=e(9297),r=SyntaxError,n=parseInt,a=String.fromCharCode,o=s("".charAt),h=s("".slice),c=s(/./.exec),d={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
2
+ `,"\\r":"\r","\\t":" "},u=/^[\da-f]{4}$/i,p=/^[\u0000-\u001F]$/;l.exports=function(g,f){for(var m=!0,v="";f<g.length;){var y=o(g,f);if(y==="\\"){var b=h(g,f,f+2);if(i(d,b))v+=d[b],f+=2;else if(b==="\\u"){f+=2;var w=h(g,f,f+4);if(!c(u,w))throw new r("Bad Unicode escape at: "+f);v+=a(n(w,16)),f+=4}else throw new r('Unknown escape sequence: "'+b+'"')}else if(y==='"'){m=!1,f++;break}else{if(c(p,y))throw new r("Bad control character in string literal at: "+f);v+=y,f++}}if(m)throw new r("Unterminated string at: "+f);return{value:v,end:f}}}),8237:((l,t,e)=>{var s=e(6518),i=e(2652),r=e(9306),n=e(8551),a=e(1767),o=e(9539),h=e(4549),c=e(8745),d=e(9039),u=TypeError,p=d(function(){[].keys().reduce(function(){},void 0)}),g=!p&&h("reduce",u);s({target:"Iterator",proto:!0,real:!0,forced:p||g},{reduce:function(f){n(this);try{r(f)}catch(w){o(this,"throw",w)}var m=arguments.length<2,v=m?void 0:arguments[1];if(g)return c(g,this,m?[f]:[f,v]);var y=a(this),b=0;if(i(y,function(w){m?(m=!1,v=w):v=f(v,w,b),b++},{IS_RECORD:!0}),m)throw new u("Reduce of empty iterator with no initial value");return v}})}),8335:((l,t,e)=>{var s=e(6518),i=e(3724),r=e(4576),n=e(7751),a=e(9504),o=e(9565),h=e(4901),c=e(34),d=e(4376),u=e(9297),p=e(655),g=e(6198),f=e(4659),m=e(9039),v=e(8235),y=e(4495),b=r.JSON,w=r.Number,A=r.SyntaxError,x=b&&b.parse,_=n("Object","keys"),E=Object.getOwnPropertyDescriptor,S=a("".charAt),C=a("".slice),T=a(/./.exec),R=a([].push),D=/^\d$/,L=/^[1-9]$/,U=/^[\d-]$/,P=/^[\t\n\r ]$/,M=0,B=1,K=function(O,k){O=p(O);var I=new G(O,0),V=I.parse(),et=V.value,$=I.skip(P,V.end);if($<O.length)throw new A('Unexpected extra character: "'+S(O,$)+'" after the parsed data at: '+$);return h(k)?rt({"":et},"",k,V):et},rt=function(O,k,I,V){var et=O[k],$=V&&et===V.value,st=$&&typeof V.source=="string"?{source:V.source}:{},dt,Bt,kt,Et,Me;if(c(et)){var vi=d(et),Ze=$?V.nodes:vi?[]:{};if(vi)for(dt=Ze.length,kt=g(et),Et=0;Et<kt;Et++)ht(et,Et,rt(et,""+Et,I,Et<dt?Ze[Et]:void 0));else for(Bt=_(et),kt=g(Bt),Et=0;Et<kt;Et++)Me=Bt[Et],ht(et,Me,rt(et,Me,I,u(Ze,Me)?Ze[Me]:void 0))}return o(I,O,k,et,st)},ht=function(O,k,I){if(i){var V=E(O,k);if(V&&!V.configurable)return}I===void 0?delete O[k]:f(O,k,I)},Z=function(O,k,I,V){this.value=O,this.end=k,this.source=I,this.nodes=V},G=function(O,k){this.source=O,this.index=k};G.prototype={fork:function(O){return new G(this.source,O)},parse:function(){var O=this.source,k=this.skip(P,this.index),I=this.fork(k),V=S(O,k);if(T(U,V))return I.number();switch(V){case"{":return I.object();case"[":return I.array();case'"':return I.string();case"t":return I.keyword(!0);case"f":return I.keyword(!1);case"n":return I.keyword(null)}throw new A('Unexpected character: "'+V+'" at: '+k)},node:function(O,k,I,V,et){return new Z(k,V,O?null:C(this.source,I,V),et)},object:function(){for(var O=this.source,k=this.index+1,I=!1,V={},et={};k<O.length;){if(k=this.until(['"',"}"],k),S(O,k)==="}"&&!I){k++;break}var $=this.fork(k).string(),st=$.value;k=$.end,k=this.until([":"],k)+1,k=this.skip(P,k),$=this.fork(k).parse(),f(et,st,$),f(V,st,$.value),k=this.until([",","}"],$.end);var dt=S(O,k);if(dt===",")I=!0,k++;else if(dt==="}"){k++;break}}return this.node(B,V,this.index,k,et)},array:function(){for(var O=this.source,k=this.index+1,I=!1,V=[],et=[];k<O.length;){if(k=this.skip(P,k),S(O,k)==="]"&&!I){k++;break}var $=this.fork(k).parse();if(R(et,$),R(V,$.value),k=this.until([",","]"],$.end),S(O,k)===",")I=!0,k++;else if(S(O,k)==="]"){k++;break}}return this.node(B,V,this.index,k,et)},string:function(){var O=this.index,k=v(this.source,this.index+1);return this.node(M,k.value,O,k.end)},number:function(){var O=this.source,k=this.index,I=k;if(S(O,I)==="-"&&I++,S(O,I)==="0")I++;else if(T(L,S(O,I)))I=this.skip(D,I+1);else throw new A("Failed to parse number at: "+I);if(S(O,I)==="."&&(I=this.skip(D,I+1)),S(O,I)==="e"||S(O,I)==="E"){I++,(S(O,I)==="+"||S(O,I)==="-")&&I++;var V=I;if(I=this.skip(D,I),V===I)throw new A("Failed to parse number's exponent value at: "+I)}return this.node(M,w(C(O,k,I)),k,I)},keyword:function(O){var k=""+O,I=this.index,V=I+k.length;if(C(this.source,I,V)!==k)throw new A("Failed to parse value at: "+I);return this.node(M,O,I,V)},skip:function(O,k){for(var I=this.source;k<I.length&&T(O,S(I,k));k++);return k},until:function(O,k){k=this.skip(P,k);for(var I=S(this.source,k),V=0;V<O.length;V++)if(O[V]===I)return k;throw new A('Unexpected character: "'+I+'" at: '+k)}};var Tt=m(function(){var O="9007199254740993",k;return x(O,function(I,V,et){k=et.source}),k!==O}),ct=y&&!m(function(){return 1/x("-0 ")!==-1/0});s({target:"JSON",stat:!0,forced:Tt},{parse:function(O,k){return ct&&!h(k)?x(O):K(O,k)}})}),8469:((l,t,e)=>{var s=e(9504),i=e(507),r=e(4402),n=r.Set,a=r.proto,o=s(a.forEach),h=s(a.keys),c=h(new n).next;l.exports=function(d,u,p){return p?i({iterator:h(d),next:c},u):o(d,u)}}),8480:((l,t,e)=>{var s=e(1828),i=e(8727),r=i.concat("length","prototype");t.f=Object.getOwnPropertyNames||function(n){return s(n,r)}}),8527:((l,t,e)=>{var s=e(7080),i=e(4402).has,r=e(5170),n=e(3789),a=e(507),o=e(9539);l.exports=function(h){var c=s(this),d=n(h);if(r(c)<d.size)return!1;var u=d.getIterator();return a(u,function(p){if(!i(c,p))return o(u,"normal",!1)})!==!1}}),8551:((l,t,e)=>{var s=e(34),i=String,r=TypeError;l.exports=function(n){if(s(n))return n;throw new r(i(n)+" is not an object")}}),8574:((l,t,e)=>{var s=e(9504),i=Error,r=s("".replace),n=(function(h){return String(new i(h).stack)})("zxcasd"),a=/\n\s*at [^:]*:[^\n]*/,o=a.test(n);l.exports=function(h,c){if(o&&typeof h=="string"&&!i.prepareStackTrace)for(;c--;)h=r(h,a,"");return h}}),8622:((l,t,e)=>{var s=e(4576),i=e(4901),r=s.WeakMap;l.exports=i(r)&&/native code/.test(String(r))}),8646:((l,t,e)=>{var s=e(9565),i=e(8551),r=e(1767),n=e(851);l.exports=function(a,o){(!o||typeof a!="string")&&i(a);var h=n(a);return r(i(h!==void 0?s(h,a):a))}}),8686:((l,t,e)=>{var s=e(3724),i=e(9039);l.exports=s&&i(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})}),8721:((l,t,e)=>{var s=e(3724),i=e(9504),r=e(2106),n=URLSearchParams.prototype,a=i(n.forEach);s&&!("size"in n)&&r(n,"size",{get:function(){var o=0;return a(this,function(){o++}),o},configurable:!0,enumerable:!0})}),8727:(l=>{l.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]}),8745:((l,t,e)=>{var s=e(616),i=Function.prototype,r=i.apply,n=i.call;l.exports=typeof Reflect=="object"&&Reflect.apply||(s?n.bind(r):function(){return n.apply(r,arguments)})}),8750:((l,t,e)=>{var s=e(7080),i=e(4402),r=e(5170),n=e(3789),a=e(8469),o=e(507),h=i.Set,c=i.add,d=i.has;l.exports=function(u){var p=s(this),g=n(u),f=new h;return r(p)>g.size?o(g.getIterator(),function(m){d(p,m)&&c(f,m)}):a(p,function(m){g.includes(m)&&c(f,m)}),f}}),8773:((l,t)=>{var e={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,i=s&&!e.call({1:2},1);t.f=i?function(r){var n=s(this,r);return!!n&&n.enumerable}:e}),8981:((l,t,e)=>{var s=e(7750),i=Object;l.exports=function(r){return i(s(r))}}),9039:(l=>{l.exports=function(t){try{return!!t()}catch{return!0}}}),9143:((l,t,e)=>{var s=e(4576),i=e(9504),r=e(3972),n=e(3463),a=e(9297),o=e(2804),h=e(944),c=e(5169),d=o.c2i,u=o.c2iUrl,p=s.SyntaxError,g=s.TypeError,f=i("".charAt),m=function(b,w){for(var A=b.length;w<A;w++){var x=f(b,w);if(x!==" "&&x!==" "&&x!==`
3
+ `&&x!=="\f"&&x!=="\r")break}return w},v=function(b,w,A){var x=b.length;x<4&&(b+=x===2?"AA":"A");var _=(w[f(b,0)]<<18)+(w[f(b,1)]<<12)+(w[f(b,2)]<<6)+w[f(b,3)],E=[_>>16&255,_>>8&255,_&255];if(x===2){if(A&&E[1]!==0)throw new p("Extra bits");return[E[0]]}if(x===3){if(A&&E[2]!==0)throw new p("Extra bits");return[E[0],E[1]]}return E},y=function(b,w,A){for(var x=w.length,_=0;_<x;_++)b[A+_]=w[_];return A+x};l.exports=function(b,w,A,x){n(b),r(w);var _=h(w)==="base64"?d:u,E=w?w.lastChunkHandling:void 0;if(E===void 0&&(E="loose"),E!=="loose"&&E!=="strict"&&E!=="stop-before-partial")throw new g("Incorrect `lastChunkHandling` option");A&&c(A.buffer);var S=b.length,C=A||[],T=0,R=0,D="",L=0;if(x)for(;;){if(L=m(b,L),L===S){if(D.length>0){if(E==="stop-before-partial")break;if(E==="loose"){if(D.length===1)throw new p("Malformed padding: exactly one additional character");T=y(C,v(D,_,!1),T)}else throw new p("Missing padding")}R=S;break}var U=f(b,L);if(++L,U==="="){if(D.length<2)throw new p("Padding is too early");if(L=m(b,L),D.length===2){if(L===S){if(E==="stop-before-partial")break;throw new p("Malformed padding: only one =")}f(b,L)==="="&&(++L,L=m(b,L))}if(L<S)throw new p("Unexpected character after padding");T=y(C,v(D,_,E==="strict"),T),R=S;break}if(!a(_,U))throw new p("Unexpected character");var P=x-T;if(P===1&&D.length===2||P===2&&D.length===3||(D+=U,D.length===4&&(T=y(C,v(D,_,!1),T),D="",R=L,T===x)))break}return{bytes:C,read:R,written:T}}}),9286:((l,t,e)=>{var s=e(4402),i=e(8469),r=s.Set,n=s.add;l.exports=function(a){var o=new r;return i(a,function(h){n(o,h)}),o}}),9297:((l,t,e)=>{var s=e(9504),i=e(8981),r=s({}.hasOwnProperty);l.exports=Object.hasOwn||function(n,a){return r(i(n),a)}}),9306:((l,t,e)=>{var s=e(4901),i=e(6823),r=TypeError;l.exports=function(n){if(s(n))return n;throw new r(i(n)+" is not a function")}}),9314:((l,t,e)=>{var s=e(6518),i=e(9565),r=e(8551),n=e(1767),a=e(4149),o=e(9590),h=e(9539),c=e(9462),d=e(684),u=e(4549),p=e(6395),g=!p&&!d("drop",0),f=!p&&!g&&u("drop",RangeError),m=p||g||f,v=c(function(){for(var y=this.iterator,b=this.next,w,A;this.remaining;)if(this.remaining--,w=r(i(b,y)),A=this.done=!!w.done,A)return;if(w=r(i(b,y)),A=this.done=!!w.done,!A)return w.value});s({target:"Iterator",proto:!0,real:!0,forced:m},{drop:function(y){r(this);var b;try{b=o(a(+y))}catch(w){h(this,"throw",w)}return f?i(f,this,b):new v(n(this),{remaining:b})}})}),9429:((l,t,e)=>{var s=e(4576),i=e(6193);l.exports=function(r){if(i){try{return s.process.getBuiltinModule(r)}catch{}try{return Function('return require("'+r+'")')()}catch{}}}}),9432:((l,t,e)=>{e(5213)}),9433:((l,t,e)=>{var s=e(4576),i=Object.defineProperty;l.exports=function(r,n){try{i(s,r,{value:n,configurable:!0,writable:!0})}catch{s[r]=n}return n}}),9462:((l,t,e)=>{var s=e(9565),i=e(2360),r=e(6699),n=e(6279),a=e(8227),o=e(1181),h=e(5966),c=e(7657).IteratorPrototype,d=e(2529),u=e(9539),p=e(1385),g=a("toStringTag"),f="IteratorHelper",m="WrapForValidIterator",v="normal",y="throw",b=o.set,w=function(_){var E=o.getterFor(_?m:f);return n(i(c),{next:function(){var S=E(this);if(_)return S.nextHandler();if(S.done)return d(void 0,!0);try{var C=S.nextHandler();return S.returnHandlerResult?C:d(C,S.done)}catch(T){throw S.done=!0,T}},return:function(){var S=E(this),C=S.iterator;if(S.done=!0,_){var T=h(C,"return");return T?s(T,C):d(void 0,!0)}if(S.inner)try{u(S.inner.iterator,v)}catch(R){return u(C,y,R)}if(S.openIters)try{p(S.openIters,v)}catch(R){return u(C,y,R)}return C&&u(C,v),d(void 0,!0)}})},A=w(!0),x=w(!1);r(x,g,"Iterator Helper"),l.exports=function(_,E,S){var C=function(T,R){R?(R.iterator=T.iterator,R.next=T.next):R=T,R.type=E?m:f,R.returnHandlerResult=!!S,R.nextHandler=_,R.counter=0,R.done=!1,b(this,R)};return C.prototype=E?A:x,C}}),9486:((l,t,e)=>{var s=e(6518),i=e(4576),r=e(9504),n=e(3972),a=e(4154),o=e(5169),h=e(2804),c=e(944),d=h.i2c,u=h.i2cUrl,p=r("".charAt),g=i.Uint8Array,f=!g||!g.prototype.toBase64||!(function(){try{var m=new g;m.toBase64(null)}catch{return!0}})();g&&s({target:"Uint8Array",proto:!0,forced:f},{toBase64:function(){var m=a(this),v=arguments.length?n(arguments[0]):void 0,y=c(v)==="base64"?d:u,b=!!v&&!!v.omitPadding;o(this.buffer);for(var w="",A=0,x=m.length,_,E=function(S){return p(y,_>>6*S&63)};A+2<x;A+=3)_=(m[A]<<16)+(m[A+1]<<8)+m[A+2],w+=E(3)+E(2)+E(1)+E(0);return A+2===x?(_=(m[A]<<16)+(m[A+1]<<8),w+=E(3)+E(2)+E(1)+(b?"":"=")):A+1===x&&(_=m[A]<<16,w+=E(3)+E(2)+(b?"":"==")),w}})}),9504:((l,t,e)=>{var s=e(616),i=Function.prototype,r=i.call,n=s&&i.bind.bind(r,r);l.exports=s?n:function(a){return function(){return r.apply(a,arguments)}}}),9519:((l,t,e)=>{var s=e(4576),i=e(2839),r=s.process,n=s.Deno,a=r&&r.versions||n&&n.version,o=a&&a.v8,h,c;o&&(h=o.split("."),c=h[0]>0&&h[0]<4?1:+(h[0]+h[1])),!c&&i&&(h=i.match(/Edge\/(\d+)/),(!h||h[1]>=74)&&(h=i.match(/Chrome\/(\d+)/),h&&(c=+h[1]))),l.exports=c}),9539:((l,t,e)=>{var s=e(9565),i=e(8551),r=e(5966);l.exports=function(n,a,o){var h,c;i(n);try{if(h=r(n,"return"),!h){if(a==="throw")throw o;return o}h=s(h,n)}catch(d){c=!0,h=d}if(a==="throw")throw o;if(c)throw h;return i(h),o}}),9565:((l,t,e)=>{var s=e(616),i=Function.prototype.call;l.exports=s?i.bind(i):function(){return i.apply(i,arguments)}}),9577:((l,t,e)=>{var s=e(9928),i=e(4644),r=e(1108),n=e(1291),a=e(5854),o=i.aTypedArray,h=i.getTypedArrayConstructor,c=i.exportTypedArrayMethod,d=(function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(p){return p===8}})(),u=d&&(function(){try{new Int8Array(1).with(-.5,1)}catch{return!0}})();c("with",function(p,g){var f=o(this),m=n(p),v=r(f)?a(g):+g;return s(f,h(f),m,v)},!d||u)}),9590:((l,t,e)=>{var s=e(1291),i=RangeError;l.exports=function(r){var n=s(r);if(n<0)throw new i("The argument can't be less than 0");return n}}),9617:((l,t,e)=>{var s=e(5397),i=e(5610),r=e(6198),n=function(a){return function(o,h,c){var d=s(o),u=r(d);if(u===0)return!a&&-1;var p=i(c,u),g;if(a&&h!==h){for(;u>p;)if(g=d[p++],g!==g)return!0}else for(;u>p;p++)if((a||p in d)&&d[p]===h)return a||p||0;return!a&&-1}};l.exports={includes:n(!0),indexOf:n(!1)}}),9631:((l,t,e)=>{e(9486)}),9797:((l,t,e)=>{e(4226)}),9835:(l=>{l.exports=function(t){try{var e=new Set,s={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return e.clear(),e.add(4),function(){return{done:!0}}}})}},i=e[t](s);return i.size===1&&i.values().next().value===4}catch{return!1}}}),9928:((l,t,e)=>{var s=e(6198),i=e(1291),r=RangeError;l.exports=function(n,a,o,h){var c=s(n),d=i(o),u=d<0?c+d:d;if(u>=c||u<0)throw new r("Incorrect index");for(var p=new a(c),g=0;g<c;g++)p[g]=g===u?h:n[g];return p}})},yi={};function q(l){var t=yi[l];if(t!==void 0)return t.exports;var e=yi[l]={exports:{}};return Lr[l].call(e.exports,e,e.exports,q),e.exports}q.d=(l,t)=>{for(var e in t)q.o(t,e)&&!q.o(l,e)&&Object.defineProperty(l,e,{enumerable:!0,get:t[e]})};q.o=(l,t)=>Object.prototype.hasOwnProperty.call(l,t);q(4114);q(6573);q(8100);q(7936);q(8111);q(8237);q(1689);q(9577);q(4235);q(9432);q(1549);q(9797);q(9631);q(5623);q(4979);q(5781);const Pt=typeof yt=="object"&&yt+""=="[object process]"&&!yt.versions.nw&&!(yt.versions.electron&&yt.type&&yt.type!=="browser"),Us=[.001,0,0,.001,0,0],Ms=1.35,It={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ee={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},He="pdfjs_internal_editor_",W={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},Q={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},Qi={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},xt={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},zt={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ut={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},me={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Te={ERRORS:0,WARNINGS:1,INFOS:5},Mt={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},ts={moveTo:0,lineTo:1,curveTo:2,closePath:3},Ji={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let _s=Te.WARNINGS;function Or(l){Number.isInteger(l)&&(_s=l)}function Fr(){return _s}function Es(l){_s>=Te.INFOS&&console.info(`Info: ${l}`)}function j(l){_s>=Te.WARNINGS&&console.warn(`Warning: ${l}`)}function it(l){throw new Error(l)}function J(l,t){l||it(t)}function Nr(l){switch(l?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Qs(l,t=null,e=null){if(!l)return null;if(e&&typeof l=="string"&&(e.addDefaultProtocol&&l.startsWith("www.")&&l.match(/\./g)?.length>=2&&(l=`http://${l}`),e.tryConvertEncoding))try{l=zr(l)}catch{}const s=t?URL.parse(l,t):URL.parse(l);return Nr(s)?s:null}function Js(l,t,e=!1){const s=URL.parse(l);return s?(s.hash=t,s.href):e&&Qs(l,"http://example.com")?l.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Y(l,t,e,s=!1){return Object.defineProperty(l,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const pe=(function(){function l(t,e){this.message=t,this.name=e}return l.prototype=new Error,l.constructor=l,l})();let wi=class extends pe{constructor(l,t){super(l,"PasswordException"),this.code=t}},Ds=class extends pe{constructor(l,t){super(l,"UnknownErrorException"),this.details=t}},us=class extends pe{constructor(l){super(l,"InvalidPDFException")}},$e=class extends pe{constructor(l,t,e){super(l,"ResponseException"),this.status=t,this.missing=e}},Br=class extends pe{constructor(l){super(l,"FormatError")}},ie=class extends pe{constructor(l){super(l,"AbortException")}};function Zi(l){(typeof l!="object"||l?.length===void 0)&&it("Invalid argument for bytesToString");const t=l.length,e=8192;if(t<e)return String.fromCharCode.apply(null,l);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),n=l.subarray(i,r);s.push(String.fromCharCode.apply(null,n))}return s.join("")}function We(l){typeof l!="string"&&it("Invalid argument for stringToBytes");const t=l.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=l.charCodeAt(s)&255;return e}function Ur(l){return String.fromCharCode(l>>24&255,l>>16&255,l>>8&255,l&255)}function Hr(){const l=new Uint8Array(4);return l[0]=1,new Uint32Array(l.buffer,0,1)[0]===1}function $r(){try{return new Function(""),!0}catch{return!1}}class At{static get isLittleEndian(){return Y(this,"isLittleEndian",Hr())}static get isEvalSupported(){return Y(this,"isEvalSupported",$r())}static get isOffscreenCanvasSupported(){return Y(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return Y(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return Y(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return Y(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Rs=Array.from(Array(256).keys(),l=>l.toString(16).padStart(2,"0"));class F{static makeHexColor(t,e,s){return`#${Rs[t]}${Rs[e]}${Rs[s]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,s=0){const i=t[s],r=t[s+1];t[s]=i*e[0]+r*e[2]+e[4],t[s+1]=i*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],r=e[1],n=e[2],a=e[3],o=e[4],h=e[5];for(let c=0;c<6;c+=2){const d=t[s+c],u=t[s+c+1];t[s+c]=d*i+u*n+o,t[s+c+1]=d*r+u*a+h}}static applyInverseTransform(t,e){const s=t[0],i=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const i=e[0],r=e[1],n=e[2],a=e[3],o=e[4],h=e[5],c=t[0],d=t[1],u=t[2],p=t[3];let g=i*c+o,f=g,m=i*u+o,v=m,y=a*d+h,b=y,w=a*p+h,A=w;if(r!==0||n!==0){const x=r*c,_=r*u,E=n*d,S=n*p;g+=E,v+=E,m+=S,f+=S,y+=x,A+=x,w+=_,b+=_}s[0]=Math.min(s[0],g,m,f,v),s[1]=Math.min(s[1],y,w,b,A),s[2]=Math.max(s[2],g,m,f,v),s[3]=Math.max(s[3],y,w,b,A)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const s=t[0],i=t[1],r=t[2],n=t[3],a=s**2+i**2,o=s*r+i*n,h=r**2+n**2,c=(a+h)/2,d=Math.sqrt(c**2-(a*h-o**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),n=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>n?null:[s,r,i,n]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,i),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,i)}static#t(t,e,s,i,r,n,a,o,h,c){if(h<=0||h>=1)return;const d=1-h,u=h*h,p=u*h,g=d*(d*(d*t+3*h*e)+3*u*s)+p*i,f=d*(d*(d*r+3*h*n)+3*u*a)+p*o;c[0]=Math.min(c[0],g),c[1]=Math.min(c[1],f),c[2]=Math.max(c[2],g),c[3]=Math.max(c[3],f)}static#e(t,e,s,i,r,n,a,o,h,c,d,u){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,s,i,r,n,a,o,-d/c,u);return}const p=c**2-4*d*h;if(p<0)return;const g=Math.sqrt(p),f=2*h;this.#t(t,e,s,i,r,n,a,o,(-c+g)/f,u),this.#t(t,e,s,i,r,n,a,o,(-c-g)/f,u)}static bezierBoundingBox(t,e,s,i,r,n,a,o,h){h[0]=Math.min(h[0],t,a),h[1]=Math.min(h[1],e,o),h[2]=Math.max(h[2],t,a),h[3]=Math.max(h[3],e,o),this.#e(t,s,r,a,e,i,n,o,3*(-t+3*(s-r)+a),6*(t-2*s+r),3*(s-t),h),this.#e(t,s,r,a,e,i,n,o,3*(-e+3*(i-n)+o),6*(e-2*i+n),3*(i-e),h)}}function zr(l){return decodeURIComponent(escape(l))}let Is=null,Ai=null;function tr(l){return Is||(Is=/([\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,Ai=new Map([["ſt","ſt"]])),l.replaceAll(Is,(t,e,s)=>e?e.normalize("NFKC"):Ai.get(s))}function Zs(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const l=new Uint8Array(32);return crypto.getRandomValues(l),Zi(l)}const ti="pdfjs_internal_id_";function jr(l,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!l(s)&&!Number.isInteger(s)||!t(i))return!1;const n=r.length;let a=!0;switch(i.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return n===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(n!==4)return!1;a=!1;break;default:return!1}for(const o of r)if(!(typeof o=="number"||a&&o===null))return!1;return!0}function Ct(l,t,e){return Math.min(Math.max(l,t),e)}function er(l){return Uint8Array.prototype.toBase64?l.toBase64():btoa(Zi(l))}function Gr(l){return Uint8Array.fromBase64?Uint8Array.fromBase64(l):We(atob(l))}typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(l){return l.reduce((t,e)=>t+e,0)});typeof AbortSignal.any!="function"&&(AbortSignal.any=function(l){const t=new AbortController,{signal:e}=t;for(const s of l)if(s.aborted)return t.abort(s.reason),e;for(const s of l)s.addEventListener("abort",()=>{t.abort(s.reason)},{signal:e});return e});q(1701);q(4603);q(7566);q(8721);class ze{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(r){if(!r)return;let n=null;const a=r.name;if(a==="#text")n=r.value;else if(ze.shouldBuildText(a))r?.attributes?.textContent?n=r.attributes.textContent:r.value&&(n=r.value);else return;if(n!==null&&e.push({str:n}),!!r.children)for(const o of r.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class ei{static setupStorage(t,e,s,i,r){const n=i.getValue(e,{value:null});switch(s.name){case"textarea":if(n.value!==null&&(t.textContent=n.value),r==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(n.value===s.attributes.xfaOn?t.setAttribute("checked",!0):n.value===s.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(n.value!==null&&t.setAttribute("value",n.value),r==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(n.value!==null){t.setAttribute("value",n.value);for(const a of s.children)a.attributes.value===n.value?a.attributes.selected=!0:a.attributes.hasOwnProperty("selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,h=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){const{attributes:n}=e,a=t instanceof HTMLAnchorElement;n.type==="radio"&&(n.name=`${n.name}-${i}`);for(const[o,h]of Object.entries(n))if(h!=null)switch(o){case"class":h.length&&t.setAttribute(o,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,h)}a&&r.addLinkAttributes(t,n.href,n.newWindow),s&&n.dataId&&this.setupStorage(t,n.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",n=document.createElement(i.name);i.attributes&&this.setAttributes({html:n,element:i,intent:r,linkService:s});const a=r!=="richText",o=t.div;if(o.append(n),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const d=document.createTextNode(i.value);n.append(d),a&&ze.shouldBuildText(i.name)&&h.push(d)}return{textDivs:h}}const c=[[i,-1,n]];for(;c.length>0;){const[d,u,p]=c.at(-1);if(u+1===d.children.length){c.pop();continue}const g=d.children[++c.at(-1)[1]];if(g===null)continue;const{name:f}=g;if(f==="#text"){const v=document.createTextNode(g.value);h.push(v),p.append(v);continue}const m=g?.attributes?.xmlns?document.createElementNS(g.attributes.xmlns,f):document.createElement(f);if(p.append(m),g.attributes&&this.setAttributes({html:m,element:g,storage:e,intent:r,linkService:s}),g.children?.length>0)c.push([g,-1,m]);else if(g.value){const v=document.createTextNode(g.value);a&&ze.shouldBuildText(f)&&h.push(v),m.append(v)}}for(const d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Qt="http://www.w3.org/2000/svg";class de{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function ke(l,t="text"){if(Fe(l,document.baseURI)){const e=await fetch(l);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",l,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class qe{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=n,s*=e;const o=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let c,d,u,p;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,d=0,u=0,p=1;break;case 90:c=0,d=1,u=1,p=0;break;case 270:c=0,d=-1,u=-1,p=0;break;case 0:c=1,d=0,u=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,p=-p);let g,f,m,v;c===0?(g=Math.abs(h-t[1])*s+r,f=Math.abs(o-t[0])*s+n,m=(t[3]-t[1])*s,v=(t[2]-t[0])*s):(g=Math.abs(o-t[0])*s+r,f=Math.abs(h-t[1])*s+n,m=(t[2]-t[0])*s,v=(t[3]-t[1])*s),this.transform=[c*s,d*s,u*s,p*s,g-c*s*o-u*s*h,f-d*s*o-p*s*h],this.width=m,this.height=v}get rawDims(){const t=this.viewBox;return Y(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new qe({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(t,e){const s=[t,e];return F.applyTransform(s,this.transform),s}convertToViewportRectangle(t){const e=[t[0],t[1]];F.applyTransform(e,this.transform);const s=[t[2],t[3]];return F.applyTransform(s,this.transform),[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){const s=[t,e];return F.applyInverseTransform(s,this.transform),s}}class Ss extends pe{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Xe(l){const t=l.length;let e=0;for(;e<t&&l[e].trim()==="";)e++;return l.substring(e,e+5).toLowerCase()==="data:"}function Cs(l){return typeof l=="string"&&/\.pdf$/i.test(l)}function sr(l){return[l]=l.split(/[#?]/,1),l.substring(l.lastIndexOf("/")+1)}function ir(l,t="document.pdf"){if(typeof l!="string")return t;if(Xe(l))return j('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const e=(n=>{try{return new URL(n)}catch{try{return new URL(decodeURIComponent(n))}catch{try{return new URL(n,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(n),"https://foo.bar")}catch{return null}}}}})(l);if(!e)return t;const s=n=>{try{let a=decodeURIComponent(n);return a.includes("/")?(a=a.split("/").at(-1),a.test(/^\.pdf$/i)?a:n):a}catch{return n}},i=/\.pdf$/i,r=e.pathname.split("/").at(-1);if(i.test(r))return s(r);if(e.searchParams.size>0){const n=Array.from(e.searchParams.values()).reverse();for(const o of n)if(i.test(o))return s(o);const a=Array.from(e.searchParams.keys()).reverse();for(const o of a)if(i.test(o))return s(o)}if(e.hash){const n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(e.hash);if(n)return s(n[0])}return t}class xi{started=Object.create(null);times=[];time(t){t in this.started&&j(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||j(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:r}of this.times)t.push(`${s.padEnd(e)} ${r-i}ms
4
+ `);return t.join("")}}function Fe(l,t){const e=t?URL.parse(l,t):URL.parse(l);return e?.protocol==="http:"||e?.protocol==="https:"}function Nt(l){l.preventDefault()}function ot(l){l.preventDefault(),l.stopPropagation()}function Vr(l){console.log("Deprecated API usage: "+l)}class Ce{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#t.exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let n=parseInt(e[4],10);n=n>=0&&n<=23?n:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,h==="-"?(n+=c,a+=d):h==="+"&&(n-=c,a-=d),new Date(Date.UTC(s,i,r,n,a,o))}}function rr(l,{scale:t=1,rotation:e=0}){const{width:s,height:i}=l.attributes.style,r=[0,0,parseInt(s),parseInt(i)];return new qe({viewBox:r,userUnit:1,scale:t,rotation:e})}function Pe(l){if(l.startsWith("#")){const t=parseInt(l.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return l.startsWith("rgb(")?l.slice(4,-1).split(",").map(t=>parseInt(t)):l.startsWith("rgba(")?l.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(j(`Not a valid color format: "${l}"`),[0,0,0])}function Wr(l){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of l.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;l.set(e,Pe(s))}t.remove()}function nt(l){const{a:t,b:e,c:s,d:i,e:r,f:n}=l.getTransform();return[t,e,s,i,r,n]}function Vt(l){const{a:t,b:e,c:s,d:i,e:r,f:n}=l.getTransform().invertSelf();return[t,e,s,i,r,n]}function ae(l,t,e=!1,s=!0){if(t instanceof qe){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:n}=l,a=At.isCSSRoundSupported,o=`var(--total-scale-factor) * ${i}px`,h=`var(--total-scale-factor) * ${r}px`,c=a?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,d=a?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;!e||t.rotation%180===0?(n.width=c,n.height=d):(n.width=d,n.height=c)}s&&l.setAttribute("data-main-rotation",t.rotation)}class Gt{constructor(){const{pixelRatio:t}=Gt;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,r=-1){let n=1/0,a=1/0,o=1/0;s=Gt.capPixels(s,r),s>0&&(n=Math.sqrt(s/(t*e))),i!==-1&&(a=i/t,o=i/e);const h=Math.min(n,a,o);return this.sx>h||this.sy>h?(this.sx=h,this.sy=h,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const ps=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class qr{static get isDarkMode(){return Y(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class nr{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:s}=window.getComputedStyle(t);return t.remove(),Y(this,"commentForegroundColor",Pe(s))}}function ar(l,t,e,s){s=Math.min(Math.max(s??1,0),1);const i=255*(1-s);return l=Math.round(l*s+i),t=Math.round(t*s+i),e=Math.round(e*s+i),[l,t,e]}function _i(l,t){const e=l[0]/255,s=l[1]/255,i=l[2]/255,r=Math.max(e,s,i),n=Math.min(e,s,i),a=(r+n)/2;if(r===n)t[0]=t[1]=0;else{const o=r-n;switch(t[1]=a<.5?o/(r+n):o/(2-r-n),r){case e:t[0]=((s-i)/o+(s<i?6:0))*60;break;case s:t[0]=((i-e)/o+2)*60;break;case i:t[0]=((e-s)/o+4)*60;break}}t[2]=a}function Hs(l,t){const e=l[0],s=l[1],i=l[2],r=(1-Math.abs(2*i-1))*s,n=r*(1-Math.abs(e/60%2-1)),a=i-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+a,t[1]=n+a,t[2]=a;break;case 1:t[0]=n+a,t[1]=r+a,t[2]=a;break;case 2:t[0]=a,t[1]=r+a,t[2]=n+a;break;case 3:t[0]=a,t[1]=n+a,t[2]=r+a;break;case 4:t[0]=n+a,t[1]=a,t[2]=r+a;break;case 5:case 6:t[0]=r+a,t[1]=a,t[2]=n+a;break}}function Ei(l){return l<=.03928?l/12.92:((l+.055)/1.055)**2.4}function Si(l,t,e){Hs(l,e),e.map(Ei);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];Hs(t,e),e.map(Ei);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const Ci=new Map;function or(l,t){const e=l[0]+l[1]*256+l[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=Ci.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),n=i.subarray(3,6);_i(l,n);const a=i.subarray(6,9);_i(t,a);const o=a[2]<.5,h=o?12:4.5;if(n[2]=o?Math.sqrt(n[2]):1-Math.sqrt(1-n[2]),Si(n,a,r)<h){let c,d;o?(c=n[2],d=1):(c=0,d=n[2]);const u=.005;for(;d-c>u;){const p=n[2]=(c+d)/2;o===Si(n,a,r)<h?c=p:d=p}n[2]=o?d:c}return Hs(n,r),s=F.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),Ci.set(e,s),s}function si({html:l,dir:t,className:e},s){const i=document.createDocumentFragment();if(typeof l=="string"){const r=document.createElement("p");r.dir=t||"auto";const n=l.split(/(?:\r\n?|\n)/);for(let a=0,o=n.length;a<o;++a){const h=n[a];r.append(document.createTextNode(h)),a<o-1&&r.append(document.createElement("br"))}i.append(r)}else ei.render({xfaHtml:l,div:i,intent:"richText"});i.firstChild.classList.add("richText",e),s.append(i)}q(4972);q(4628);q(7642);q(8004);q(3853);q(5876);q(2475);q(5024);q(1698);q(9314);q(1148);q(3579);q(8335);class Be{#t=null;#e=null;#i;#s=null;#a=null;#r=null;#n=null;#o=null;static#h=null;constructor(t){this.#i=t,Be.#h||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){const t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#i._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",Nt,{signal:e}),t.addEventListener("pointerdown",Be.#l,{signal:e}));const s=this.#s=document.createElement("div");s.className="buttons",t.append(s);const i=this.#i.toolbarPosition;if(i){const{style:r}=t,n=this.#i._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*n}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#l(t){t.stopPropagation()}#u(t){this.#i._focusEventsAllowed=!1,ot(t)}#d(t){this.#i._focusEventsAllowed=!0,ot(t)}#p(t){const e=this.#i._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Nt,{signal:e}),!0)}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#a?.shown(),this.#r?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#i,s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",Be.#h[t]),this.#p(s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),this.#s.append(s)}get#m(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#s.append(e,this.#m),this.#a=t}addComment(t,e=null){if(this.#r)return;const s=t.renderForToolbar();if(!s)return;this.#p(s);const i=this.#n=this.#m;e?(this.#s.insertBefore(s,e),this.#s.insertBefore(i,e)):this.#s.append(s,i),this.#r=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;const e=t.renderButton();this.#p(e),this.#s.append(e,this.#m)}async addEditSignatureButton(t){const e=this.#o=await t.renderEditButton(this.#i);this.#p(e),this.#s.append(e,this.#m)}removeButton(t){switch(t){case"comment":this.#r?.removeToolbarCommentButton(),this.#r=null,this.#n?.remove(),this.#n=null;break}}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e);break}}async addButtonBefore(t,e,s){const i=this.#s.querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){this.#o&&(this.#o.title=t)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class Xr{#t=null;#e=null;#i;constructor(t){this.#i=t}#s(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#i._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Nt,{signal:e});const s=this.#t=document.createElement("div");return s.className="buttons",t.append(s),this.#i.hasCommentManager()&&this.#r("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#i.commentSelection("floating_button")}),this.#r("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#i.highlightSelection("floating_button")}),t}#a(t,e){let s=0,i=0;for(const r of t){const n=r.y+r.height;if(n<s)continue;const a=r.x+(e?r.width:0);if(n>s){i=a,s=n;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,r]=this.#a(e,s),{style:n}=this.#e||=this.#s();t.append(this.#e),n.insetInlineEnd=`${100*i}%`,n.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#r(t,e,s,i){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const n=document.createElement("span");r.append(n),n.className="visuallyHidden",n.setAttribute("data-l10n-id",s);const a=this.#i._signal;a instanceof AbortSignal&&!a.aborted&&(r.addEventListener("contextmenu",Nt,{signal:a}),r.addEventListener("click",i,{signal:a})),this.#t.append(r)}}function lr(l,t,e){for(const s of e)t.addEventListener(s,l[s].bind(l))}class Yr{#t=0;get id(){return`${He}${this.#t++}`}}class ii{#t=Zs();#e=0;#i=null;static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',e=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),s=new Image;s.src=t;const i=s.decode().then(()=>(e.drawImage(s,0,0,1,1,0,0,1,3),new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0]===0));return Y(this,"_isSVGFittingCanvas",i)}async#s(t,e){this.#i||=new Map;let s=this.#i.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e=="string"?(s.url=e,i=await ke(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=ii._isSVGFittingCanvas,n=new FileReader,a=new Image,o=new Promise((h,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,h()},n.onload=async()=>{const d=s.svgUrl=n.result;a.src=await r?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=n.onerror=c});n.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){j(i),s=null}return this.#i.set(t,s),s&&this.#i.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return this.#s(`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return this.#s(t,t)}async getFromBlob(t,e){const s=await e;return this.#s(t,s)}async getFromId(t){this.#i||=new Map;const e=this.#i.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#i||=new Map;let s=this.#i.get(t);if(s?.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#i.set(t,s),this.#i.set(s.id,s),s}getSvgUrl(t){const e=this.#i.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#i||=new Map;const e=this.#i.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class Kr{#t=[];#e=!1;#i;#s=-1;constructor(t=128){this.#i=t}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:n=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:r};if(this.#s===-1){this.#t.length>0&&(this.#t.length=0),this.#s=0,this.#t.push(o);return}if(n&&this.#t[this.#s].type===r){a&&(o.undo=this.#t[this.#s].undo),this.#t[this.#s]=o;return}const h=this.#s+1;h===this.#i?this.#t.splice(0,1):(this.#s=h,h<this.#t.length&&this.#t.splice(h)),this.#t.push(o)}undo(){if(this.#s===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1,this.#s-=1}redo(){if(this.#s<this.#t.length-1){this.#s+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#s];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#s!==-1}hasSomethingToRedo(){return this.#s<this.#t.length-1}cleanType(t){if(this.#s!==-1){for(let e=this.#s;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#s-e),this.#s=e;return}this.#t.length=0,this.#s=-1}}destroy(){this.#t=null}}class Ye{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=At.platform;for(const[s,i,r={}]of t)for(const n of s){const a=n.startsWith("mac+");e&&a?(this.callbacks.set(n.slice(4),{callback:i,options:r}),this.allKeys.add(n.split("+").at(-1))):!e&&!a&&(this.callbacks.set(n,{callback:i,options:r}),this.allKeys.add(n.split("+").at(-1)))}}#t(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(this.#t(e));if(!s)return;const{callback:i,options:{bubbles:r=!1,args:n=[],checker:a=null}}=s;a&&!a(t,e)||(i.bind(t,...n,e)(),r||ot(e))}}class ri{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return Wr(t),Y(this,"_colors",t)}convert(t){const e=Pe(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((r,n)=>r===e[n]))return ri._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?F.makeHexColor(...e):t}}class re{#t=new AbortController;#e=null;#i=null;#s=new Map;#a=new Map;#r=null;#n=null;#o=null;#h=new Kr;#l=null;#u=null;#d=null;#p=0;#m=new Set;#f=null;#c=null;#g=new Set;_editorUndoBar=null;#v=!1;#y=!1;#b=!1;#S=null;#_=null;#w=null;#T=null;#x=!1;#E=null;#M=new Yr;#k=!1;#P=!1;#N=!1;#R=null;#L=null;#B=null;#O=null;#G=null;#C=W.NONE;#A=new Set;#I=null;#U=null;#$=null;#q=null;#W=null;#X={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#z=[0,0];#F=null;#V=null;#J=null;#Z=null;#H=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=re.prototype,e=n=>n.#V.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&n.hasSomethingToControl(),s=(n,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return Y(this,"_keyboardManager",new Ye([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(n,{target:a})=>!(a instanceof HTMLButtonElement)&&n.#V.contains(a)&&!n.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(n,{target:a})=>!(a instanceof HTMLButtonElement)&&n.#V.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}constructor(t,e,s,i,r,n,a,o,h,c,d,u,p,g,f,m){const v=this._signal=this.#t.signal;this.#V=t,this.#J=e,this.#Z=s,this.#r=i,this.#l=r,this.#U=n,this.#W=o,this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:v}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:v}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:v}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:v}),a._on("setpreference",this.onSetPreference.bind(this),{signal:v}),a._on("switchannotationeditorparams",y=>this.updateParams(y.type,y.value),{signal:v}),window.addEventListener("pointerdown",()=>{this.#P=!0},{capture:!0,signal:v}),window.addEventListener("pointerup",()=>{this.#P=!1},{capture:!0,signal:v}),this.#lt(),this.#ut(),this.#et(),this.#n=o.annotationStorage,this.#S=o.filterFactory,this.#$=h,this.#T=c||null,this.#v=d,this.#y=u,this.#b=p,this.#G=g||null,this.viewParameters={realScale:de.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=f||null,this._supportsPinchToZoom=m!==!1,r?.setSidebarUiManager(this)}destroy(){this.#H?.resolve(),this.#H=null,this.#t?.abort(),this.#t=null,this._signal=null;for(const t of this.#a.values())t.destroy();this.#a.clear(),this.#s.clear(),this.#g.clear(),this.#O?.clear(),this.#e=null,this.#A.clear(),this.#h.destroy(),this.#r?.destroy(),this.#l?.destroy(),this.#U?.destroy(),this.#E?.hide(),this.#E=null,this.#B?.destroy(),this.#B=null,this.#i=null,this.#_&&(clearTimeout(this.#_),this.#_=null),this.#F&&(clearTimeout(this.#F),this.#F=null),this._editorUndoBar?.destroy(),this.#W=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#G}get useNewAltTextFlow(){return this.#y}get useNewAltTextWhenAddingImage(){return this.#b}get hcmFilter(){return Y(this,"hcmFilter",this.#$?this.#S.addHCMFilter(this.#$.foreground,this.#$.background):"none")}get direction(){return Y(this,"direction",getComputedStyle(this.#V).direction)}get _highlightColors(){return Y(this,"_highlightColors",this.#T?new Map(this.#T.split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return Y(this,"highlightColors",null);const e=new Map,s=!!this.#$;for(const[i,r]of t){const n=i.endsWith("_HCM");if(s&&n){e.set(i.replace("_HCM",""),r);continue}!s&&!n&&e.set(i,r)}return Y(this,"highlightColors",e)}get highlightColorNames(){return Y(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#d=t}setMainHighlightColorPicker(t){this.#B=t}editAltText(t,e=!1){this.#r?.editAltText(this,t,e)}hasCommentManager(){return!!this.#l}editComment(t,e,s,i){this.#l?.showDialog(this,t,e,s,i)}selectComment(t,e){this.#a.get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){this.#l?.updateComment(t.getData())}updatePopupColor(t){this.#l?.updatePopupColor(t)}removeComment(t){this.#l?.removeComments([t.uid])}toggleComment(t,e,s=void 0){this.#l?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&this.#l?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#l?.dialogElement||null}async waitForEditorsRendered(t){if(this.#a.has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=r=>{r.pageNumber===t&&(this._eventBus._off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i),await s}getSignature(t){this.#U?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#U}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":this.#b=e;break}}onPageChanging({pageNumber:t}){this.#p=t-1}focusMainContainer(){this.#V.focus()}findParent(t,e){for(const s of this.#a.values()){const{x:i,y:r,width:n,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+n&&e>=r&&e<=r+a)return s}return null}disableUserSelect(t=!1){this.#J.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#g.add(t)}removeShouldRescale(t){this.#g.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*de.PDF_TO_CSS_UNITS;for(const e of this.#g)e.onScaleChanging();this.#d?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#Q({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#tt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of this.#a.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:n,focusOffset:a}=s,o=s.toString(),h=this.#Q(s).closest(".textLayer"),c=this.getSelectionBoxes(h);if(!c)return;s.empty();const d=this.#tt(h),u=this.#C===W.NONE,p=()=>{const g=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:i,anchorOffset:r,focusNode:n,focusOffset:a,text:o});u&&this.showAllEditors("highlight",!0,!0),e&&g?.editComment()};if(u){this.switchToMode(W.HIGHLIGHT,p);return}p()}commentSelection(t=""){this.highlightSelection(t,!0)}#at(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#Q(t).closest(".textLayer"),s=this.getSelectionBoxes(e);s&&(this.#E||=new Xr(this),this.#E.show(e,s,this.direction==="ltr"))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#n)return null;const e=`${He}${t}`,s=this.#n.getRawValue(e);return s&&this.#n.remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&this.#n&&!this.#n.has(t.id)&&this.#n.setValue(t.id,t)}a11yAlert(t,e=null){const s=this.#Z;s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}#ot(){const t=document.getSelection();if(!t||t.isCollapsed){this.#I&&(this.#E?.hide(),this.#I=null,this.#D({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#I)return;const s=this.#Q(t).closest(".textLayer");if(!s){this.#I&&(this.#E?.hide(),this.#I=null,this.#D({hasSelectedText:!1}));return}if(this.#E?.hide(),this.#I=e,this.#D({hasSelectedText:!0}),!(this.#C!==W.HIGHLIGHT&&this.#C!==W.NONE)&&(this.#C===W.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#x=this.isShiftKeyDown,!this.isShiftKeyDown)){const i=this.#C===W.HIGHLIGHT?this.#tt(s):null;if(i?.toggleDrawing(),this.#P){const r=new AbortController,n=this.combinedSignal(r),a=o=>{o.type==="pointerup"&&o.button!==0||(r.abort(),i?.toggleDrawing(!0),o.type==="pointerup"&&this.#Y("main_toolbar"))};window.addEventListener("pointerup",a,{signal:n}),window.addEventListener("blur",a,{signal:n})}else i?.toggleDrawing(!0),this.#Y("main_toolbar")}}#Y(t=""){this.#C===W.HIGHLIGHT?this.highlightSelection(t):this.#v&&this.#at()}#lt(){document.addEventListener("selectionchange",this.#ot.bind(this),{signal:this._signal})}#ht(){if(this.#w)return;this.#w=new AbortController;const t=this.combinedSignal(this.#w);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ct(){this.#w?.abort(),this.#w=null}blur(){if(this.isShiftKeyDown=!1,this.#x&&(this.#x=!1,this.#Y("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#A)if(e.div.contains(t)){this.#L=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#L)return;const[t,e]=this.#L;this.#L=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#et(){if(this.#R)return;this.#R=new AbortController;const t=this.combinedSignal(this.#R);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#dt(){this.#R?.abort(),this.#R=null}#st(){if(this.#u)return;this.#u=new AbortController;const t=this.combinedSignal(this.#u);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#it(){this.#u?.abort(),this.#u=null}#ut(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#et(),this.#st()}removeEditListeners(){this.#dt(),this.#it()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#c)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#c)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#A){const i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const n of this.#c)if(n.isHandlingMimeForPasting(r.type)){n.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){j(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const o of s){const h=await i.deserialize(o);if(!h)return;r.push(h)}const n=()=>{for(const o of r)this.#rt(o);this.#nt(r)},a=()=>{for(const o of r)o.remove()};this.addCommands({cmd:n,undo:a,mustExec:!0})}catch(r){j(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#C!==W.NONE&&!this.isEditorHandlingKeyboard&&re._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#x&&(this.#x=!1,this.#Y("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}#D(t){Object.entries(t).some(([e,s])=>this.#X[e]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#X,t)}),this.#C===W.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#j([[Q.HIGHLIGHT_FREE,!0]]))}#j(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#ht(),this.#st(),this.#D({isEditing:this.#C!==W.NONE,isEmpty:this.#K(),hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:this.#h.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ct(),this.#it(),this.#D({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#c){this.#c=t;for(const e of this.#c)this.#j(e.defaultPropertiesToUpdate)}}getId(){return this.#M.id}get currentLayer(){return this.#a.get(this.#p)}getLayer(t){return this.#a.get(t)}get currentPageIndex(){return this.#p}addLayer(t){this.#a.set(t.pageIndex,t),this.#k?t.enable():t.disable()}removeLayer(t){this.#a.delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1){if(this.#C!==t&&!(this.#H&&(await this.#H.promise,!this.#H))){if(this.#H=Promise.withResolvers(),this.#d?.commitOrRemove(),this.#C===W.POPUP&&this.#l?.hideSidebar(),this.#l?.destroyPopup(),this.#C=t,t===W.NONE){this.setEditingState(!1),this.#ft();for(const n of this.#s.values())n.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#H.resolve();return}for(const n of this.#s.values())n.addStandaloneCommentButton();t===W.SIGNATURE&&await this.#U?.loadSignatures(),this.setEditingState(!0),await this.#pt(),this.unselectAll();for(const n of this.#a.values())n.updateMode(t);if(t===W.POPUP){this.#i||=await this.#W.getAnnotationsByType(new Set(this.#c.map(o=>o._editorType)));const n=new Set,a=[];for(const o of this.#s.values()){const{annotationElementId:h,hasComment:c,deleted:d}=o;h&&n.add(h),c&&!d&&a.push(o.getData())}for(const o of this.#i){const{id:h,popupRef:c,contentsObj:d}=o;c&&d?.str&&!n.has(h)&&!this.#m.has(h)&&a.push(o)}this.#l?.showSidebar(a)}if(!e){s&&this.addNewEditorFromKeyboard(),this.#H.resolve();return}for(const n of this.#s.values())n.uid===e?(this.setSelected(n),r?n.editComment():i?n.enterInEditMode():n.focus()):n.unselect();this.#H.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#C&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#c){switch(t){case Q.CREATE:this.currentLayer.addNewEditor(e);return;case Q.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#q||=new Map).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of this.#A)s.updateParams(t,e);else for(const s of this.#c)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const i of this.#s.values())i.editorType===t&&i.show(e);(this.#q?.get(Q.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#j([[Q.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#N!==t){this.#N=t;for(const e of this.#a.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#pt(){if(!this.#k){this.#k=!0;const t=[];for(const e of this.#a.values())t.push(e.enable());await Promise.all(t);for(const e of this.#s.values())e.enable()}}#ft(){if(this.unselectAll(),this.#k){this.#k=!1;for(const t of this.#a.values())t.disable();for(const t of this.#s.values())t.disable()}}*getEditors(t){for(const e of this.#s.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#s.get(t)}addEditor(t){this.#s.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#_&&clearTimeout(this.#_),this.#_=setTimeout(()=>{this.focusMainContainer(),this.#_=null},0)),this.#s.delete(t.id),t.annotationElementId&&this.#O?.delete(t.annotationElementId),this.unselect(t),(!t.annotationElementId||!this.#m.has(t.annotationElementId))&&this.#n?.remove(t.id)}addDeletedAnnotationElement(t){this.#m.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#m.has(t)}removeDeletedAnnotationElement(t){this.#m.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#rt(t){const e=this.#a.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#j(t.propertiesToUpdate))}get#gt(){let t=null;for(t of this.#A);return t}updateUI(t){this.#gt===t&&this.#j(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#j(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#A.has(t)){this.#A.delete(t),t.unselect(),this.#D({hasSelectedEditor:this.hasSelection});return}this.#A.add(t),t.select(),this.#j(t.propertiesToUpdate),this.#D({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.id}),this.#d?.commitOrRemove();for(const e of this.#A)e!==t&&e.unselect();this.#A.clear(),this.#A.add(t),t.select(),this.#j(t.propertiesToUpdate),this.#D({hasSelectedEditor:!0})}isSelected(t){return this.#A.has(t)}get firstSelectedEditor(){return this.#A.values().next().value}unselect(t){t.unselect(),this.#A.delete(t),this.#D({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#A.size!==0}get isEnterHandled(){return this.#A.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#h.undo(),this.#D({hasSomethingToUndo:this.#h.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#K()}),this._editorUndoBar?.hide()}redo(){this.#h.redo(),this.#D({hasSomethingToUndo:!0,hasSomethingToRedo:this.#h.hasSomethingToRedo(),isEmpty:this.#K()})}addCommands(t){this.#h.add(t),this.#D({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#K()})}cleanUndoStack(t){this.#h.cleanType(t)}#K(){if(this.#s.size===0)return!0;if(this.#s.size===1)for(const t of this.#s.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#A],s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(const r of e)r.remove()},i=()=>{for(const r of e)this.#rt(r)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#nt(t){for(const e of this.#A)e.unselect();this.#A.clear();for(const e of t)e.isEmpty()||(this.#A.add(e),e.select());this.#D({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#A)t.commit();this.#nt(this.#s.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#C!==W.NONE))&&!this.#d?.commitOrRemove()&&this.hasSelection){for(const t of this.#A)t.unselect();this.#A.clear(),this.#D({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#z[0]+=t,this.#z[1]+=e;const[i,r]=this.#z,n=[...this.#A],a=1e3;this.#F&&clearTimeout(this.#F),this.#F=setTimeout(()=>{this.#F=null,this.#z[0]=this.#z[1]=0,this.addCommands({cmd:()=>{for(const o of n)this.#s.has(o.id)&&(o.translateInPage(i,r),o.translationDone())},undo:()=>{for(const o of n)this.#s.has(o.id)&&(o.translateInPage(-i,-r),o.translationDone())},mustExec:!1})},a);for(const o of n)o.translateInPage(t,e),o.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#f=new Map;for(const t of this.#A)this.#f.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#f)return!1;this.disableUserSelect(!1);const t=this.#f;this.#f=null;let e=!1;for(const[{x:i,y:r,pageIndex:n},a]of t)a.newX=i,a.newY=r,a.newPageIndex=n,e||=i!==a.savedX||r!==a.savedY||n!==a.savedPageIndex;if(!e)return!1;const s=(i,r,n,a)=>{if(this.#s.has(i.id)){const o=this.#a.get(a);o?i._setParentAndPosition(o,r,n):(i.pageIndex=a,i.x=r,i.y=n)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:n,newPageIndex:a}]of t)s(i,r,n,a)},undo:()=>{for(const[i,{savedX:r,savedY:n,savedPageIndex:a}]of t)s(i,r,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#f)for(const s of this.#f.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#A.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#C}isEditingMode(){return this.#C!==W.NONE}get imageManager(){return Y(this,"imageManager",new ii)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:i,width:r,height:n}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(h,c,d,u)=>({x:(c-i)/n,y:1-(h+d-s)/r,width:u/n,height:d/r});break;case"180":a=(h,c,d,u)=>({x:1-(h+d-s)/r,y:1-(c+u-i)/n,width:d/r,height:u/n});break;case"270":a=(h,c,d,u)=>({x:1-(c+u-i)/n,y:(h-s)/r,width:u/n,height:d/r});break;default:a=(h,c,d,u)=>({x:(h-s)/r,y:(c-i)/n,width:d/r,height:u/n});break}const o=[];for(let h=0,c=e.rangeCount;h<c;h++){const d=e.getRangeAt(h);if(!d.collapsed)for(const{x:u,y:p,width:g,height:f}of d.getClientRects())g===0||f===0||o.push(a(u,p,g,f))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#o||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#o?.delete(t)}renderAnnotationElement(t){const e=this.#o?.get(t.data.id);if(!e)return;const s=this.#n.getRawValue(e);s&&(this.#C===W.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){const i=this.#O?.get(t);i&&(i.setCanvas(e,s),this.#O.delete(t))}addMissingCanvas(t,e){(this.#O||=new Map).set(t,e)}}class Xt{#t=null;#e=!1;#i=null;#s=null;#a=null;#r=null;#n=!1;#o=null;#h=null;#l=null;#u=null;#d=!1;static#p=null;static _l10n=null;constructor(t){this.#h=t,this.#d=t._uiManager.useNewAltTextFlow,Xt.#p||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){Xt._l10n??=t}async render(){const t=this.#i=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#s=document.createElement("span");t.append(e),this.#d?(t.classList.add("new"),t.setAttribute("data-l10n-id",Xt.#p.missing),e.setAttribute("data-l10n-id",Xt.#p["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=this.#h._uiManager._signal;t.addEventListener("contextmenu",Nt,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),this.#h._uiManager.editAltText(this.#h),this.#d&&this.#h._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#m}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(this.#n=!0,i(r))},{signal:s}),await this.#f(),t}get#m(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#i&&(this.#i.focus({focusVisible:this.#n}),this.#n=!1)}isEmpty(){return this.#d?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#d?this.#t!==null||!!this.#l:this.isEmpty()}get guessedText(){return this.#l}async setGuessedText(t){this.#t===null&&(this.#l=t,this.#u=await Xt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#f())}toggleAltTextBadge(t=!1){if(!this.#d||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){const e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#h.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#l===e&&(e=this.#u),{altText:e,decorative:this.#e,guessedText:this.#l,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(this.#l=s,this.#u=i),!(this.#t===t&&this.#e===e)&&(r||(this.#t=t,this.#e=e),this.#f())}toggle(t=!1){this.#i&&(!t&&this.#r&&(clearTimeout(this.#r),this.#r=null),this.#i.disabled=!t)}shown(){this.#h._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#m}})}destroy(){this.#i?.remove(),this.#i=null,this.#s=null,this.#a=null,this.#o?.remove(),this.#o=null}async#f(){const t=this.#i;if(!t)return;if(this.#d){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",Xt.#p[this.#m]),this.#s?.setAttribute("data-l10n-id",Xt.#p[`${this.#m}-label`]),!this.#t){this.#a?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#a?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#a;if(!e){this.#a=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#h.id}`;const s=100,i=this.#h._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#r),this.#r=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#r=setTimeout(()=>{this.#r=null,this.#a.classList.add("show"),this.#h._reportTelemetry({action:"alt_text_tooltip"})},s)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#r&&(clearTimeout(this.#r),this.#r=null),this.#a?.classList.remove("show")},{signal:i})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#h.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class es{#t=null;#e=null;#i=!1;#s=null;#a=null;#r=null;#n=null;#o=null;#h=!1;#l=null;constructor(t){this.#s=t}renderForToolbar(){const t=this.#e=document.createElement("button");return t.className="comment",this.#u(t,!1)}renderForStandalone(){const t=this.#t=document.createElement("button");t.className="annotationCommentButton";const e=this.#s.commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#s._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=this.#s.commentButtonColor;i&&(s.backgroundColor=i)}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;const t=this.#s.commentButtonColor;t&&(this.#t.style.backgroundColor=t),this.#s._uiManager.updatePopupColor(this.#s)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#s.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#l)return this.#l;if(!this.#t)return null;const{x:t,y:e,height:s}=this.#t.getBoundingClientRect(),{x:i,y:r,width:n,height:a}=this.#s.parent.boundingClientRect;return[(t-i)/n,(e+s-r)/a]}set commentPopupPositionInLayer(t){this.#l=t}hasDefaultPopupPosition(){return this.#l===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t&&(this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e)}#u(t,e){if(!this.#s._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#s._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));const s=this.#s._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",Nt,{signal:s}),e&&(t.addEventListener("focusin",r=>{this.#s._focusEventsAllowed=!1,ot(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{this.#s._focusEventsAllowed=!0,ot(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===this.#e?this.edit():this.#s.toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(this.#i=!0,i(r))},{signal:s}),t.addEventListener("pointerenter",()=>{this.#s.toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{this.#s.toggleComment(!1,!1)},{signal:s}),t}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=this.#s.commentButtonPosition;const{width:c,height:d,x:u,y:p}=this.#s;s=u+s*c,i=p+i*d}const r=this.#s.parent.boundingClientRect,{x:n,y:a,width:o,height:h}=r;this.#s._uiManager.editComment(this.#s,n+s*o,a+i*h,{...t,parentDimensions:r})}finish(){this.#e&&(this.#e.focus({focusVisible:this.#i}),this.#i=!1)}isDeleted(){return this.#h||this.#n===""}isEmpty(){return this.#n===null}hasBeenEdited(){return this.isDeleted()||this.#n!==this.#a}serialize(){return this.data}get data(){return{text:this.#n,richText:this.#r,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#n&&(this.#r=null),t===null){this.#n="",this.#h=!0;return}this.#n=t,this.#o=new Date,this.#h=!1}setInitialText(t,e=null){this.#a=t,this.data=t,this.#o=null,this.#r=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#n="",this.#r=null,this.#o=null,this.#s=null,this.#i=!1,this.#h=!1}}class Ke{#t;#e=!1;#i=null;#s;#a;#r;#n;#o=null;#h;#l=null;#u;#d=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:n=null,signal:a}){this.#t=t,this.#i=s,this.#s=e,this.#a=i,this.#r=r,this.#n=n,this.#u=new AbortController,this.#h=AbortSignal.any([a,this.#u.signal]),t.addEventListener("touchstart",this.#p.bind(this),{passive:!1,signal:this.#h})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Gt.pixelRatio}#p(t){if(this.#s?.())return;if(t.touches.length===1){if(this.#o)return;const i=this.#o=new AbortController,r=AbortSignal.any([this.#h,i.signal]),n=this.#t,a={capture:!0,signal:r,passive:!1},o=h=>{h.pointerType==="touch"&&(this.#o?.abort(),this.#o=null)};n.addEventListener("pointerdown",h=>{h.pointerType==="touch"&&(ot(h),o(h))},a),n.addEventListener("pointerup",o,a),n.addEventListener("pointercancel",o,a);return}if(!this.#d){this.#d=new AbortController;const i=AbortSignal.any([this.#h,this.#d.signal]),r=this.#t,n={signal:i,capture:!1,passive:!1};r.addEventListener("touchmove",this.#m.bind(this),n);const a=this.#f.bind(this);r.addEventListener("touchend",a,n),r.addEventListener("touchcancel",a,n),n.capture=!0,r.addEventListener("pointerdown",ot,n),r.addEventListener("pointermove",ot,n),r.addEventListener("pointercancel",ot,n),r.addEventListener("pointerup",ot,n),this.#a?.()}if(ot(t),t.touches.length!==2||this.#i?.()){this.#l=null;return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),this.#l={touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY}}#m(t){if(!this.#l||t.touches.length!==2)return;ot(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:r}=e,{screenX:n,screenY:a}=s,o=this.#l,{touch0X:h,touch0Y:c,touch1X:d,touch1Y:u}=o,p=d-h,g=u-c,f=n-i,m=a-r,v=Math.hypot(f,m)||1,y=Math.hypot(p,g)||1;if(!this.#e&&Math.abs(y-v)<=Ke.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=i,o.touch0Y=r,o.touch1X=n,o.touch1Y=a,!this.#e){this.#e=!0;return}const b=[(i+n)/2,(r+a)/2];this.#r?.(b,y,v)}#f(t){t.touches.length>=2||(this.#d&&(this.#d.abort(),this.#d=null,this.#n?.()),this.#l&&(ot(t),this.#l=null,this.#e=!1))}destroy(){this.#u?.abort(),this.#u=null,this.#o?.abort(),this.#o=null}}class H{#t=null;#e=null;#i=null;#s=null;#a=null;#r=!1;#n=null;#o="";#h=null;#l=null;#u=null;#d=null;#p=null;#m="";#f=!1;#c=null;#g=!1;#v=!1;#y=!1;#b=null;#S=0;#_=0;#w=null;#T=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;#x=!1;#E=H._zIndex++;static _borderLineWidth=-1;static _colorManager=new ri;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=H.prototype._resizeWithKeyboard,e=re.TRANSLATE_SMALL,s=re.TRANSLATE_BIG;return Y(this,"_resizerKeyboardManager",new Ye([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],H.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:n}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,n];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,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 Y(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Qr({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(H._l10n??=t,H._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"}),H._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);H._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){it("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#x}set _isDraggable(t){this.#x=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#E}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#F(),this.#d?.remove(),this.#d=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#f?this.#f=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[r,n]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/n,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}#M([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#M(this.parentDimensions,t,e)}translateInPage(t,e){this.#c||=[this.x,this.y,this.width,this.height],this.#M(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#c||=[this.x,this.y,this.width,this.height];const{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this;const[o,h]=this.getBaseTranslation();n+=o,a+=h;const{style:c}=s;c.left=`${(100*n).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(n,a),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#c&&(this.#c[0]!==this.x||this.#c[1]!==this.y)}get _hasBeenResized(){return!!this.#c&&(this.#c[2]!==this.width||this.#c[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=H,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:r,y:n,width:a,height:o}=this;if(a*=s,o*=i,r*=s,n*=i,this._mustFixPosition)switch(t){case 0:r=Ct(r,0,s-a),n=Ct(n,0,i-o);break;case 90:r=Ct(r,0,s-o),n=Ct(n,a,i);break;case 180:r=Ct(r,a,s),n=Ct(n,o,i);break;case 270:r=Ct(r,o,s),n=Ct(n,0,i-a);break}this.x=r/=s,this.y=n/=i;const[h,c]=this.getBaseTranslation();r+=h,n+=c,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#k(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return H.#k(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return H.#k(t,e,360-this.parentRotation)}#P(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#N(){if(this.#h)return;this.#h=document.createElement("div"),this.#h.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");this.#h.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#R.bind(this,s),{signal:e}),i.addEventListener("contextmenu",Nt,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#h)}#R(t,e){e.preventDefault();const{isMac:s}=At.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#i?.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,this.#l=[e.screenX,e.screenY];const r=new AbortController,n=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#O.bind(this,t),{passive:!0,capture:!0,signal:n}),window.addEventListener("touchmove",ot,{passive:!1,signal:n}),window.addEventListener("contextmenu",Nt,{signal:n}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{r.abort(),this.parent.togglePointerEvents(!0),this.#i?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#B()};window.addEventListener("pointerup",h,{signal:n}),window.addEventListener("blur",h,{signal:n})}#L(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#B(){if(!this.#u)return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;const r=this.x,n=this.y,a=this.width,o=this.height;r===t&&n===e&&a===s&&o===i||this.addCommands({cmd:this.#L.bind(this,r,n,a,o),undo:this.#L.bind(this,t,e,s,i),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#O(t,e){const[s,i]=this.parentDimensions,r=this.x,n=this.y,a=this.width,o=this.height,h=H.MIN_SIZE/s,c=H.MIN_SIZE/i,d=this.#P(this.rotation),u=(P,M)=>[d[0]*P+d[2]*M,d[1]*P+d[3]*M],p=this.#P(360-this.rotation),g=(P,M)=>[p[0]*P+p[2]*M,p[1]*P+p[3]*M];let f,m,v=!1,y=!1;switch(t){case"topLeft":v=!0,f=(P,M)=>[0,0],m=(P,M)=>[P,M];break;case"topMiddle":f=(P,M)=>[P/2,0],m=(P,M)=>[P/2,M];break;case"topRight":v=!0,f=(P,M)=>[P,0],m=(P,M)=>[0,M];break;case"middleRight":y=!0,f=(P,M)=>[P,M/2],m=(P,M)=>[0,M/2];break;case"bottomRight":v=!0,f=(P,M)=>[P,M],m=(P,M)=>[0,0];break;case"bottomMiddle":f=(P,M)=>[P/2,M],m=(P,M)=>[P/2,0];break;case"bottomLeft":v=!0,f=(P,M)=>[0,M],m=(P,M)=>[P,0];break;case"middleLeft":y=!0,f=(P,M)=>[0,M/2],m=(P,M)=>[P,M/2];break}const b=f(a,o),w=m(a,o);let A=u(...w);const x=H._round(r+A[0]),_=H._round(n+A[1]);let E=1,S=1,C,T;if(e.fromKeyboard)({deltaX:C,deltaY:T}=e);else{const{screenX:P,screenY:M}=e,[B,K]=this.#l;[C,T]=this.screenToPageTranslation(P-B,M-K),this.#l[0]=P,this.#l[1]=M}if([C,T]=g(C/s,T/i),v){const P=Math.hypot(a,o);E=S=Math.max(Math.min(Math.hypot(w[0]-b[0]-C,w[1]-b[1]-T)/P,1/a,1/o),h/a,c/o)}else y?E=Ct(Math.abs(w[0]-b[0]-C),h,1)/a:S=Ct(Math.abs(w[1]-b[1]-T),c,1)/o;const R=H._round(a*E),D=H._round(o*S);A=u(...m(R,D));const L=x-A[0],U=_-A[1];this.#c||=[this.x,this.y,this.width,this.height],this.width=R,this.height=D,this.x=L,this.y=U,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#i?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#v)return this._editToolbar;this._editToolbar=new Be(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#i?.destroy()}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#i||(Xt.initialize(H._l10n),this.#i=new Xt(this),this.#t&&(this.#i.data=this.#t,this.#t=null)),this.#i}get altTextData(){return this.#i?.data}set altTextData(t){this.#i&&(this.#i.data=t)}get guessedAltText(){return this.#i?.guessedText}async setGuessedAltText(t){await this.#i?.setGuessedText(t)}serializeAltText(t){return this.#i?.serialize(t)}hasAltText(){return!!this.#i&&!this.#i.isEmpty()}hasAltTextData(){return this.#i?.hasData()??!1}focusCommentButton(){this.#s?.focusButton()}addCommentButton(){return this.#s||=new es(this)}addStandaloneCommentButton(){if(this.#a){this._uiManager.isEditingMode()&&this.#a.classList.remove("hidden");return}this.hasComment&&(this.#a=this.#s.renderForStandalone(),this.div.append(this.#a))}removeStandaloneCommentButton(){this.#s.removeStandaloneCommentButton(),this.#a=null}hideStandaloneCommentButton(){this.#a?.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:s,deleted:i}}=this.#s;return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#s||=new es(this),this.#s.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:s}){if(!e||(this.#s||=new es(this),this.#s.setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#s?.hasBeenEdited()}get hasDeletedComment(){return this.#s?.isDeleted()}get hasComment(){return!!this.#s&&!this.#s.isEmpty()&&!this.#s.isDeleted()}async editComment(t){this.#s||=new es(this),this.#s.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#s.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,e]=t.rect,[s]=this.pageDimensions,[i]=this.pageTranslation,r=i+s+1,n=e-100,a=r+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[r,n,a,e]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#s.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#r?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#$();const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,r]=this.getInitialTranslation();return this.translate(i,r),lr(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#T||=new Ke({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#G.bind(this),onPinching:this.#C.bind(this),onPinchEnd:this.#A.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#G(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#i?.toggle(!1),this.parent.togglePointerEvents(!1)}#C(t,e,s){let i=.7*(s/e)+1-.7;if(i===1)return;const r=this.#P(this.rotation),n=(A,x)=>[r[0]*A+r[2]*x,r[1]*A+r[3]*x],[a,o]=this.parentDimensions,h=this.x,c=this.y,d=this.width,u=this.height,p=H.MIN_SIZE/a,g=H.MIN_SIZE/o;i=Math.max(Math.min(i,1/d,1/u),p/d,g/u);const f=H._round(d*i),m=H._round(u*i);if(f===d&&m===u)return;this.#c||=[h,c,d,u];const v=n(d/2,u/2),y=H._round(h+v[0]),b=H._round(c+v[1]),w=n(f/2,m/2);this.x=y-w[0],this.y=b-w[1],this.width=f,this.height=m,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#A(){this.#i?.toggle(!0),this.parent.togglePointerEvents(!0),this.#B()}pointerdown(t){const{isMac:e}=At.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#f=!0,this._isDraggable){this.#U(t);return}this.#I(t)}#I(t){const{isMac:e}=At.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#U(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),n={capture:!0,passive:!1,signal:r},a=h=>{i.abort(),this.#n=null,this.#f=!1,this._uiManager.endDragSession()||this.#I(h),s&&this._onStopDragging()};e&&(this.#S=t.clientX,this.#_=t.clientY,this.#n=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:d,pointerId:u}=h;if(u!==this.#n){ot(h);return}const[p,g]=this.screenToPageTranslation(c-this.#S,d-this.#_);this.#S=c,this.#_=d,this._uiManager.dragSelectedEditors(p,g)},n),window.addEventListener("touchmove",ot,n),window.addEventListener("pointerdown",h=>{h.pointerType===this.#o&&(this.#T||h.isPrimary)&&a(h),ot(h)},n));const o=h=>{if(!this.#n||this.#n===h.pointerId){a(h);return}ot(h)};window.addEventListener("pointerup",o,{signal:r}),window.addEventListener("blur",o,{signal:r})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[r,n]=this.pageDimensions,[a,o]=this.pageTranslation,h=t/i,c=e/i,d=this.x*r,u=this.y*n,p=this.width*r,g=this.height*n;switch(s){case 0:return[d+h+a,n-u-c-g+o,d+h+p+a,n-u-c+o];case 90:return[d+c+a,n-u+h+o,d+c+g+a,n-u+h+p+o];case 180:return[d-h-p+a,n-u+c+o,d-h+a,n-u+c+g+o];case 270:return[d-c-g+a,n-u-h-p+o,d-c+a,n-u-h+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,r,n]=t,a=r-s,o=n-i;switch(this.rotation){case 0:return[s,e-n,a,o];case 90:return[s,e-i,o,a];case 180:return[r,e-i,a,o];case 270:return[r,e-n,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&H._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#s?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:r,richText:n},uid:a,pageIndex:o,creationDate:h,modificationDate:c}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:n,contentsObj:{str:t},creationDate:h,modificationDate:s||c,popupRef:!r,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#v=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#v=!1,!0):!1}isInEditMode(){return this.#v}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:n}=window;return e<n&&i>0&&t<r&&s>0}#$(){if(this.#p||!this.div)return;this.#p=new AbortController;const t=this._uiManager.combinedSignal(this.#p);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#$()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,i.#t=t.accessibilityData,i._isCopy=t.isCopy||!1;const[r,n]=i.pageDimensions,[a,o,h,c]=i.getRectInCurrentCoords(t.rect,n);return i.x=a/r,i.y=o/n,i.width=h/r,i.height=c/n,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#p?.abort(),this.#p=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#F(),this.removeEditToolbar(),this.#w){for(const t of this.#w.values())clearTimeout(t);this.#w=null}this.parent=null,this.#T?.destroy(),this.#T=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#N(),this.#h.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,i,r,n]=this.getPDFRect();return[H._round(s+(r-s)*t),H._round(i+(n-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#s.commentPopupPositionInLayer}set commentPopupPosition(t){this.#s.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#s.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#s.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#s.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#h.children;if(!this.#e){this.#e=Array.from(e);const n=this.#q.bind(this),a=this.#W.bind(this),o=this._uiManager._signal;for(const h of this.#e){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",n,{signal:o}),h.addEventListener("blur",a,{signal:o}),h.addEventListener("focus",this.#X.bind(this,c),{signal:o}),h.setAttribute("data-l10n-id",H._l10nResizer[c])}}const s=this.#e[0];let i=0;for(const n of e){if(n===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(r!==i){if(r<i)for(let a=0;a<i-r;a++)this.#h.append(this.#h.firstChild);else if(r>i)for(let a=0;a<r-i;a++)this.#h.firstChild.before(this.#h.lastChild);let n=0;for(const a of e){const o=this.#e[n++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",H._l10nResizer[o])}}this.#z(0),this.#y=!0,this.#h.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#q(t){H._resizerKeyboardManager.exec(this,t)}#W(t){this.#y&&t.relatedTarget?.parentNode!==this.#h&&this.#F()}#X(t){this.#m=this.#y?t:""}#z(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#y&&this.#O(this.#m,{deltaX:t,deltaY:e,fromKeyboard:!0})}#F(){this.#y=!1,this.#z(-1),this.#B()}_stopResizingWithKeyboard(){this.#F(),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(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()});return}this._editToolbar?.show(),this.#i?.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#h?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#i?.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#g}set isEditing(t){this.#g=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#w||=new Map;const{action:s}=t;let i=this.#w.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#w.delete(s),this.#w.size===0&&(this.#w=null)},H._telemetryTimeout),this.#w.set(s,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#r=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#r=!0}updateFakeAnnotationElement(t){if(!this.#d&&!this.deleted){this.#d=t.addFakeAnnotation(this);return}if(this.deleted){this.#d.remove(),this.#d=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#d.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class Qr extends H{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ti=3285377520,Ut=4294901760,Wt=65535;class hr{constructor(t){this.h1=t?t&4294967295:Ti,this.h2=t?t&4294967295:Ti}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let f=0,m=t.length;f<m;f++){const v=t.charCodeAt(f);v<=255?e[s++]=v:(e[s++]=v>>>8,e[s++]=v&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,n=new Uint32Array(e.buffer,0,i);let a=0,o=0,h=this.h1,c=this.h2;const d=3432918353,u=461845907,p=d&Wt,g=u&Wt;for(let f=0;f<i;f++)f&1?(a=n[f],a=a*d&Ut|a*p&Wt,a=a<<15|a>>>17,a=a*u&Ut|a*g&Wt,h^=a,h=h<<13|h>>>19,h=h*5+3864292196):(o=n[f],o=o*d&Ut|o*p&Wt,o=o<<15|o>>>17,o=o*u&Ut|o*g&Wt,c^=o,c=c<<13|c>>>19,c=c*5+3864292196);switch(a=0,r){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*d&Ut|a*p&Wt,a=a<<15|a>>>17,a=a*u&Ut|a*g&Wt,i&1?h^=a:c^=a}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Ut|t*36045&Wt,e=e*4283543511&Ut|((e<<16|t>>>16)*2950163797&Ut)>>>16,t^=e>>>1,t=t*444984403&Ut|t*60499&Wt,e=e*3301882366&Ut|((e<<16|t>>>16)*3120437893&Ut)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const $s=Object.freeze({map:null,hash:"",transfer:void 0});class ni{#t=!1;#e=null;#i=null;#s=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=this.#s.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#s.get(t)}remove(t){const e=this.#s.get(t);if(e!==void 0&&(e instanceof H&&this.#i.delete(e.annotationElementId),this.#s.delete(t),this.#s.size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(const s of this.#s.values())if(s instanceof H)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=this.#s.get(t);let i=!1;if(s!==void 0)for(const[r,n]of Object.entries(e))s[r]!==n&&(i=!0,s[r]=n);else i=!0,this.#s.set(t,e);i&&this.#a(),e instanceof H&&((this.#i||=new Map).set(e.annotationElementId,e),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type))}has(t){return this.#s.has(t)}get size(){return this.#s.size}#a(){this.#t||(this.#t=!0,typeof this.onSetModified=="function"&&this.onSetModified())}resetModified(){this.#t&&(this.#t=!1,typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new cr(this)}get serializable(){if(this.#s.size===0)return $s;const t=new Map,e=new hr,s=[],i=Object.create(null);let r=!1;for(const[n,a]of this.#s){const o=a instanceof H?a.serialize(!1,i):a;o&&(t.set(n,o),e.update(`${n}:${JSON.stringify(o)}`),r||=!!o.bitmap)}if(r)for(const n of t.values())n.bitmap&&s.push(n.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:$s}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of this.#s.values()){if(!(r instanceof H)){r.popup&&(r.popup.deleted?i+=1:s+=1);continue}r.isCommentDeleted?i+=1:r.hasEditedComment&&(s+=1);const n=r.telemetryFinalData;if(!n)continue;const{type:a}=n;e.has(a)||e.set(a,Object.getPrototypeOf(r).constructor),t||=Object.create(null);const o=t[a]||=new Map;for(const[h,c]of Object.entries(n)){if(h==="type")continue;let d=o.get(h);d||(d=new Map,o.set(h,d));const u=d.get(c)??0;d.set(c,u+1)}}if((i>0||s>0)&&(t||=Object.create(null),t.comments={deleted:i,edited:s}),!t)return null;for(const[r,n]of e)t[r]=n.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){const s=this.#i?.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){return this.#i?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;const t=[];if(this.#i)for(const e of this.#i.values())e.serialize()&&t.push(e.annotationElementId);return this.#e={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#s.entries()}}class cr extends ni{#t;constructor(t){super();const{map:e,hash:s,transfer:i}=t.serializable,r=structuredClone(e,i?{transfer:i}:null);this.#t={map:r,hash:s,transfer:i}}get print(){it("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return Y(this,"modifiedIds",{ids:new Set,hash:""})}}class Jr{#t=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#t.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||this.#t.has(t.loadedName))){if(J(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:n}=t,a=new FontFace(i,r,n);this.addNativeFontFace(a);try{await a.load(),this.#t.add(i),s?.(t)}catch{j(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}it("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw j(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return Y(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return Y(this,"isSyncFontLoadingSupported",Pt||At.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(J(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return Y(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(b,w){return b.charCodeAt(w)<<24|b.charCodeAt(w+1)<<16|b.charCodeAt(w+2)<<8|b.charCodeAt(w+3)&255}function i(b,w,A,x){const _=b.substring(0,w),E=b.substring(w+A);return _+x+E}let r,n;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let h=0;function c(b,w){if(++h>30){j("Load test font never loaded."),w();return}if(o.font="30px "+b,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0){w();return}setTimeout(c.bind(null,b,w))}const d=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=i(u,976,d.length,d);const p=16,g=1482184792;let f=s(u,p);for(r=0,n=d.length-3;r<n;r+=4)f=f-g+s(d,r)|0;r<d.length&&(f=f-g+s(d+"XXX",r)|0),u=i(u,p,4,Ur(f));const m=`url(data:font/opentype;base64,${btoa(u)});`,v=`@font-face {font-family:"${d}";src:${m}}`;this.insertRule(v);const y=this._document.createElement("div");y.style.visibility="hidden",y.style.width=y.style.height="10px",y.style.position="absolute",y.style.top=y.style.left="0px";for(const b of[t.loadedName,d]){const w=this._document.createElement("span");w.textContent="Hi",w.style.fontFamily=b,y.append(w)}this._document.body.append(y),c(d,()=>{y.remove(),e.complete()})}}class Zr{#t;constructor(t,e=null,s,i){this.compiledGlyphs=Object.create(null),this.#t=t,this._inspectFont=e,s&&Object.assign(this,s),i&&(this.charProcOperatorList=i)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${er(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${t}}`}return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(n){j(`getPathGenerator - ignoring character: "${n}".`)}const r=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return this.#t.black}get bold(){return this.#t.bold}get disableFontFace(){return this.#t.disableFontFace??!1}get fontExtraProperties(){return this.#t.fontExtraProperties??!1}get isInvalidPDFjsFont(){return this.#t.isInvalidPDFjsFont}get isType3Font(){return this.#t.isType3Font}get italic(){return this.#t.italic}get missingFile(){return this.#t.missingFile}get remeasure(){return this.#t.remeasure}get vertical(){return this.#t.vertical}get ascent(){return this.#t.ascent}get defaultWidth(){return this.#t.defaultWidth}get descent(){return this.#t.descent}get bbox(){return this.#t.bbox}get fontMatrix(){return this.#t.fontMatrix}get fallbackName(){return this.#t.fallbackName}get loadedName(){return this.#t.loadedName}get mimetype(){return this.#t.mimetype}get name(){return this.#t.name}get data(){return this.#t.data}clearData(){this.#t.clearData()}get cssFontInfo(){return this.#t.cssFontInfo}get systemFontInfo(){return this.#t.systemFontInfo}get defaultVMetrics(){return this.#t.defaultVMetrics}}function tn(l){if(l instanceof URL)return l.href;if(typeof l=="string"){if(Pt)return l;const t=URL.parse(l,window.location);if(t)return t.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function en(l){if(Pt&&typeof cs<"u"&&l instanceof cs)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(l instanceof Uint8Array&&l.byteLength===l.buffer.byteLength)return l;if(typeof l=="string")return We(l);if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)||typeof l=="object"&&!isNaN(l?.length))return new Uint8Array(l);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function ss(l){if(typeof l!="string")return null;if(l.endsWith("/"))return l;throw new Error(`Invalid factory url: "${l}" must include trailing slash.`)}const zs=l=>typeof l=="object"&&Number.isInteger(l?.num)&&l.num>=0&&Number.isInteger(l?.gen)&&l.gen>=0,sn=l=>typeof l=="object"&&typeof l?.name=="string",dr=jr.bind(null,zs,sn);class rn{#t=new Map;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const[i]of this.#t)i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){const{signal:r}=s;if(r.aborted){j("LoopbackPort - cannot use an `aborted` signal.");return}const n=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",n),r.addEventListener("abort",n)}this.#t.set(e,i)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(const[,t]of this.#t)t?.();this.#t.clear()}}const is={DATA:1,ERROR:2},ft={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function ki(){}function Dt(l){if(l instanceof ie||l instanceof us||l instanceof wi||l instanceof $e||l instanceof Ds)return l;switch(l instanceof Error||typeof l=="object"&&l!==null||it('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),l.name){case"AbortException":return new ie(l.message);case"InvalidPDFException":return new us(l.message);case"PasswordException":return new wi(l.message,l.code);case"ResponseException":return new $e(l.message,l.status,l.missing);case"UnknownErrorException":return new Ds(l.message,l.details)}return new Ds(l.message,l.toString())}class je{#t=new AbortController;constructor(t,e,s){this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",this.#e.bind(this),{signal:this.#t.signal})}#e({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){this.#s(t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===is.DATA)i.resolve(t.data);else if(t.callback===is.ERROR)i.reject(Dt(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(n){r.postMessage({sourceName:s,targetName:i,callback:is.DATA,callbackId:t.callbackId,data:n})},function(n){r.postMessage({sourceName:s,targetName:i,callback:is.ERROR,callbackId:t.callbackId,reason:Dt(n)})});return}if(t.streamId){this.#i(t);return}e(t.data)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(n){r.reject(n)}return r.promise}sendWithStream(t,e,s,i){const r=this.streamId++,n=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[r]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:n,targetName:a,action:t,streamId:r,data:e,desiredSize:h.desiredSize},i),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[r].pullCall=c,o.postMessage({sourceName:n,targetName:a,stream:ft.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{J(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[r].cancelCall=c,this.streamControllers[r].isClosed=!0,o.postMessage({sourceName:n,targetName:a,stream:ft.CANCEL,streamId:r,reason:Dt(h)}),c.promise}},s)}#i(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,n=this,a=this.actionHandler[t.action],o={enqueue(h,c=1,d){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:ft.ENQUEUE,streamId:e,chunk:h},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:ft.CLOSE,streamId:e}),delete n.streamSinks[e])},error(h){J(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:ft.ERROR,streamId:e,reason:Dt(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ft.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:ft.START_COMPLETE,streamId:e,reason:Dt(h)})})}#s(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,n=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case ft.START_COMPLETE:t.success?n.startCall.resolve():n.startCall.reject(Dt(t.reason));break;case ft.PULL_COMPLETE:t.success?n.pullCall.resolve():n.pullCall.reject(Dt(t.reason));break;case ft.PULL:if(!a){r.postMessage({sourceName:s,targetName:i,stream:ft.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||ki).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ft.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:ft.PULL_COMPLETE,streamId:e,reason:Dt(h)})});break;case ft.ENQUEUE:if(J(n,"enqueue should have stream controller"),n.isClosed)break;n.controller.enqueue(t.chunk);break;case ft.CLOSE:if(J(n,"close should have stream controller"),n.isClosed)break;n.isClosed=!0,n.controller.close(),this.#a(n,e);break;case ft.ERROR:J(n,"error should have stream controller"),n.controller.error(Dt(t.reason)),this.#a(n,e);break;case ft.CANCEL_COMPLETE:t.success?n.cancelCall.resolve():n.cancelCall.reject(Dt(t.reason)),this.#a(n,e);break;case ft.CANCEL:if(!a)break;const o=Dt(t.reason);Promise.try(a.onCancel||ki,o).then(function(){r.postMessage({sourceName:s,targetName:i,stream:ft.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:ft.CANCEL_COMPLETE,streamId:e,reason:Dt(h)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#a(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#t?.abort(),this.#t=null}}class ur{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){it("Abstract method `_createCanvas` called.")}}class nn extends ur{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class pr{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){it("Abstract method `_fetch` called.")}}class Pi extends pr{async _fetch(t){const e=await ke(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):We(e)}}q(2489);class fr{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}destroy(t=!1){}}class an extends fr{#t;#e;#i;#s;#a;#r;#n=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#s=t,this.#a=e}get#o(){return this.#e||=new Map}get#h(){return this.#r||=new Map}get#l(){if(!this.#i){const t=this.#a.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const s=this.#a.createElementNS(Qt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#i=this.#a.createElementNS(Qt,"defs"),t.append(s),s.append(this.#i),this.#a.body.append(t)}return this.#i}#u(t){if(t.length===1){const o=t[0],h=new Array(256);for(let d=0;d<256;d++)h[d]=o[d]/255;const c=h.join(",");return[c,c,c]}const[e,s,i]=t,r=new Array(256),n=new Array(256),a=new Array(256);for(let o=0;o<256;o++)r[o]=e[o]/255,n[o]=s[o]/255,a[o]=i[o]/255;return[r.join(","),n.join(","),a.join(",")]}#d(t){if(this.#t===void 0){this.#t="";const e=this.#a.URL;e!==this.#a.baseURI&&(Xe(e)?j('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=Js(e,""))}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;const[s,i,r]=this.#u(t),n=t.length===1?s:`${s}${i}${r}`;if(e=this.#o.get(n),e)return this.#o.set(t,e),e;const a=`g_${this.#s}_transfer_map_${this.#n++}`,o=this.#d(a);this.#o.set(t,o),this.#o.set(n,o);const h=this.#f(a);return this.#g(s,i,r,h),o}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let r=this.#h.get(i);if(r?.key===s||(r?(r.filter?.remove(),r.key=s,r.url="none",r.filter=null):(r={key:s,url:"none",filter:null},this.#h.set(i,r)),!t||!e))return r.url;const n=this.#y(t);t=F.makeHexColor(...n);const a=this.#y(e);if(e=F.makeHexColor(...a),this.#l.style.color="",t==="#000000"&&e==="#ffffff"||t===e)return r.url;const o=new Array(256);for(let p=0;p<=255;p++){const g=p/255;o[p]=g<=.03928?g/12.92:((g+.055)/1.055)**2.4}const h=o.join(","),c=`g_${this.#s}_hcm_filter`,d=r.filter=this.#f(c);this.#g(h,h,h,d),this.#m(d);const u=(p,g)=>{const f=n[p]/255,m=a[p]/255,v=new Array(g+1);for(let y=0;y<=g;y++)v[y]=f+y/g*(m-f);return v.join(",")};return this.#g(u(0,5),u(1,5),u(2,5),d),r.url=this.#d(c),r.url}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;const[s]=this.#u([t]),i=`alpha_${s}`;if(e=this.#o.get(i),e)return this.#o.set(t,e),e;const r=`g_${this.#s}_alpha_map_${this.#n++}`,n=this.#d(r);this.#o.set(t,n),this.#o.set(i,n);const a=this.#f(r);return this.#v(s,a),n}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#u([t]),i=`luminosity_${s}`):i="luminosity",e=this.#o.get(i),e)return this.#o.set(t,e),e;const r=`g_${this.#s}_luminosity_map_${this.#n++}`,n=this.#d(r);this.#o.set(t,n),this.#o.set(i,n);const a=this.#f(r);return this.#p(a),t&&this.#v(s,a),n}addHighlightHCMFilter(t,e,s,i,r){const n=`${e}-${s}-${i}-${r}`;let a=this.#h.get(t);if(a?.key===n||(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},this.#h.set(t,a)),!e||!s))return a.url;const[o,h]=[e,s].map(this.#y.bind(this));let c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[u,p]=[i,r].map(this.#y.bind(this));d<c&&([c,d,u,p]=[d,c,p,u]),this.#l.style.color="";const g=(v,y,b)=>{const w=new Array(256),A=(d-c)/b,x=v/255,_=(y-v)/(255*b);let E=0;for(let S=0;S<=b;S++){const C=Math.round(c+S*A),T=x+S*_;for(let R=E;R<=C;R++)w[R]=T;E=C+1}for(let S=E;S<256;S++)w[S]=w[E-1];return w.join(",")},f=`g_${this.#s}_hcm_${t}_filter`,m=a.filter=this.#f(f);return this.#m(m),this.#g(g(u[0],p[0],5),g(u[1],p[1],5),g(u[2],p[2],5),m),a.url=this.#d(f),a.url}destroy(t=!1){t&&this.#r?.size||(this.#i?.parentNode.parentNode.remove(),this.#i=null,this.#e?.clear(),this.#e=null,this.#r?.clear(),this.#r=null,this.#n=0)}#p(t){const e=this.#a.createElementNS(Qt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#m(t){const e=this.#a.createElementNS(Qt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)}#f(t){const e=this.#a.createElementNS(Qt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#l.append(e),e}#c(t,e,s){const i=this.#a.createElementNS(Qt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#g(t,e,s,i){const r=this.#a.createElementNS(Qt,"feComponentTransfer");i.append(r),this.#c(r,"feFuncR",t),this.#c(r,"feFuncG",e),this.#c(r,"feFuncB",s)}#v(t,e){const s=this.#a.createElementNS(Qt,"feComponentTransfer");e.append(s),this.#c(s,"feFuncA",t)}#y(t){return this.#l.style.color=t,Pe(getComputedStyle(this.#l).getPropertyValue("color"))}}class gr{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){it("Abstract method `_fetch` called.")}}class Mi extends gr{async _fetch(t){const e=await ke(t,"arraybuffer");return new Uint8Array(e)}}class mr{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(s=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){it("Abstract method `_fetch` called.")}}class Di extends mr{async _fetch(t){const e=await ke(t,"arraybuffer");return new Uint8Array(e)}}if(Pt){let l;try{const t=yt.getBuiltinModule("module").createRequire(import.meta.url);try{l=t("@napi-rs/canvas")}catch(e){j(`Cannot load "@napi-rs/canvas" package: "${e}".`)}}catch(t){j(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(l?.DOMMatrix?globalThis.DOMMatrix=l.DOMMatrix:j("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(l?.ImageData?globalThis.ImageData=l.ImageData:j("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(l?.Path2D?globalThis.Path2D=l.Path2D:j("Cannot polyfill `Path2D`, rendering may be broken.")),globalThis.navigator?.language||(globalThis.navigator={language:"en-US",platform:"",userAgent:""})}async function ai(l){const t=await yt.getBuiltinModule("fs").promises.readFile(l);return new Uint8Array(t)}class on extends fr{}class ln extends ur{_createCanvas(t,e){return yt.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class hn extends pr{async _fetch(t){return ai(t)}}class cn extends gr{async _fetch(t){return ai(t)}}class dn extends mr{async _fetch(t){return ai(t)}}q(7588);const ge="__forcedDependency",{floor:Ri,ceil:Ii}=Math;function rs(l,t,e,s,i,r){l[t*4+0]=Math.min(l[t*4+0],e),l[t*4+1]=Math.min(l[t*4+1],s),l[t*4+2]=Math.max(l[t*4+2],i),l[t*4+3]=Math.max(l[t*4+3],r)}const js=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class un{#t;#e;constructor(t,e){this.#t=t,this.#e=e}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===js}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}}const ns=(l,t)=>{if(!l)return;let e=l.get(t);return e||(e={dependencies:new Set,isRenderingOperation:!1},l.set(t,e)),e};class pn{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[ge]:[]};#i=new Map;#s=[];#a=[];#r=[[1,0,0,1,0,0]];#n=[-1/0,-1/0,1/0,1/0];#o=new Float64Array([1/0,1/0,-1/0,-1/0]);#h=-1;#l=new Set;#u=new Map;#d=new Map;#p;#m;#f;#c;#g;constructor(t,e,s=!1){this.#p=t.width,this.#m=t.height,this.#v(e),s&&(this.#g=new Map)}growOperationsCount(t){t>=this.#c.length&&this.#v(t,this.#c)}#v(t,e){const s=new ArrayBuffer(t*4);this.#f=new Uint8ClampedArray(s),this.#c=new Uint32Array(s),e&&e.length>0?(this.#c.set(e),this.#c.fill(js,e.length)):this.#c.fill(js)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[ge]:{__proto__:this.#e[ge]}},this.#n={__proto__:this.#n},this.#s.push(t),this}restore(t){const e=Object.getPrototypeOf(this.#t);if(e===null)return this;this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this.#n=Object.getPrototypeOf(this.#n);const s=this.#s.pop();return s!==void 0&&(ns(this.#g,t)?.dependencies.add(s),this.#c[t]=this.#c[s]),this}recordOpenMarker(t){return this.#s.push(t),this}getOpenMarker(){return this.#s.length===0?null:this.#s.at(-1)}recordCloseMarker(t){const e=this.#s.pop();return e!==void 0&&(ns(this.#g,t)?.dependencies.add(e),this.#c[t]=this.#c[e]),this}beginMarkedContent(t){return this.#a.push(t),this}endMarkedContent(t){const e=this.#a.pop();return e!==void 0&&(ns(this.#g,t)?.dependencies.add(e),this.#c[t]=this.#c[e]),this}pushBaseTransform(t){return this.#r.push(F.multiplyByDOMMatrix(this.#r.at(-1),t.getTransform())),this}popBaseTransform(){return this.#r.length>1&&this.#r.pop(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#i.set(t,e),this}recordSimpleDataFromNamed(t,e,s){this.#t[t]=this.#i.get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(ge,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#t&&this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#l)this.recordFutureForcedDependency(ge,t);return this}resetBBox(t){return this.#h!==t&&(this.#h=t,this.#o[0]=1/0,this.#o[1]=1/0,this.#o[2]=-1/0,this.#o[3]=-1/0),this}recordClipBox(t,e,s,i,r,n){const a=F.multiplyByDOMMatrix(this.#r.at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];F.axialAlignedBoundingBox([s,r,i,n],a,o);const h=F.intersect(this.#n,o);return h?(this.#n[0]=h[0],this.#n[1]=h[1],this.#n[2]=h[2],this.#n[3]=h[3]):(this.#n[0]=this.#n[1]=1/0,this.#n[2]=this.#n[3]=-1/0),this}recordBBox(t,e,s,i,r,n){const a=this.#n;if(a[0]===1/0)return this;const o=F.multiplyByDOMMatrix(this.#r.at(-1),e.getTransform());if(a[0]===-1/0)return F.axialAlignedBoundingBox([s,r,i,n],o,this.#o),this;const h=[1/0,1/0,-1/0,-1/0];return F.axialAlignedBoundingBox([s,r,i,n],o,h),this.#o[0]=Math.min(this.#o[0],Math.max(h[0],a[0])),this.#o[1]=Math.min(this.#o[1],Math.max(h[1],a[1])),this.#o[2]=Math.max(this.#o[2],Math.min(h[2],a[2])),this.#o[3]=Math.max(this.#o[3],Math.min(h[3],a[3])),this}recordCharacterBBox(t,e,s,i=1,r=0,n=0,a){const o=s.bbox;let h,c;if(o&&(h=o[2]!==o[0]&&o[3]!==o[1]&&this.#d.get(s),h!==!1&&(c=[0,0,0,0],F.axialAlignedBoundingBox(o,s.fontMatrix,c),(i!==1||r!==0||n!==0)&&F.scaleMinMax([i,0,0,-i,r,n],c),h)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!a)return this.recordFullPageBBox(t);const d=a();return o&&c&&h===void 0&&(h=c[0]<=r-d.actualBoundingBoxLeft&&c[2]>=r+d.actualBoundingBoxRight&&c[1]<=n-d.actualBoundingBoxAscent&&c[3]>=n+d.actualBoundingBoxDescent,this.#d.set(s,h),h)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,n-d.actualBoundingBoxAscent,n+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o[0]=Math.max(0,this.#n[0]),this.#o[1]=Math.max(0,this.#n[1]),this.#o[2]=Math.min(this.#p,this.#n[2]),this.#o[3]=Math.min(this.#m,this.#n[3]),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){const s=this.#l,i=this.#t,r=this.#e;for(const n of e)n in this.#t?s.add(i[n]):n in r&&r[n].forEach(s.add,s);return this}recordNamedDependency(t,e){return this.#i.has(e)&&this.#l.add(this.#i.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[ge]),this.#g){const s=ns(this.#g,t),{dependencies:i}=s;this.#l.forEach(i.add,i),this.#s.forEach(i.add,i),this.#a.forEach(i.add,i),i.delete(t),s.isRenderingOperation=!0}if(this.#h===t){const s=Ri(this.#o[0]*256/this.#p),i=Ri(this.#o[1]*256/this.#m),r=Ii(this.#o[2]*256/this.#p),n=Ii(this.#o[3]*256/this.#m);rs(this.#f,t,s,i,r,n);for(const a of this.#l)a!==t&&rs(this.#f,a,s,i,r,n);for(const a of this.#s)a!==t&&rs(this.#f,a,s,i,r,n);for(const a of this.#a)a!==t&&rs(this.#f,a,s,i,r,n);e||(this.#l.clear(),this.#h=-1)}return this}recordShowTextOperation(t,e=!1){const s=Array.from(this.#l);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){return this.#h===t&&(this.#h=-1,this.#n[0]=Math.max(this.#n[0],this.#o[0]),this.#n[1]=Math.max(this.#n[1],this.#o[1]),this.#n[2]=Math.min(this.#n[2],this.#o[2]),this.#n[3]=Math.min(this.#n[3],this.#o[3]),e||this.#l.clear()),this}_takePendingDependencies(){const t=this.#l;return this.#l=new Set,t}_extractOperation(t){const e=this.#u.get(t);return this.#u.delete(t),e}_pushPendingDependencies(t){for(const e of t)this.#l.add(e)}take(){return this.#d.clear(),new un(this.#c,this.#f)}takeDebugMetadata(){return this.#g}}class fs{#t;#e;#i;#s=0;#a=0;constructor(t,e,s){if(t instanceof fs&&t.#i===!!s)return t;this.#t=t,this.#e=e,this.#i=!!s}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#a++,this.#t.save(this.#e),this}restore(t){return this.#a>0&&(this.#t.restore(this.#e),this.#a--),this}recordOpenMarker(t){return this.#s++,this}getOpenMarker(){return this.#s>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#s--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#i||this.#t.resetBBox(this.#e),this}recordClipBox(t,e,s,i,r,n){return this.#i||this.#t.recordClipBox(this.#e,e,s,i,r,n),this}recordBBox(t,e,s,i,r,n){return this.#i||this.#t.recordBBox(this.#e,e,s,i,r,n),this}recordCharacterBBox(t,e,s,i,r,n,a){return this.#i||this.#t.recordCharacterBBox(this.#e,e,s,i,r,n,a),this}recordFullPageBBox(t){return this.#i||this.#t.recordFullPageBBox(this.#e),this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){return this.#i||this.#t.bboxToClipBoxDropOperation(this.#e,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const Ht={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"]},_t={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Gs(l,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),l.clip(i)}class oi{isModifyingCurrentTransform(){return!1}getPattern(){it("Abstract method `getPattern` called.")}}class fn extends oi{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let r;if(i===_t.STROKE||i===_t.FILL){const n=e.current.getClippedPathBoundingBox(i,nt(t))||[0,0,0,0],a=Math.ceil(n[2]-n[0])||1,o=Math.ceil(n[3]-n[1])||1,h=e.cachedCanvases.getCanvas("pattern",a,o),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-n[0],-n[1]),s=F.transform(s,[1,0,0,1,n[0],n[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),Gs(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),r=t.createPattern(h.canvas,"no-repeat");const d=new DOMMatrix(s);r.setTransform(d)}else Gs(t,this._bbox),r=this._createGradient(t);return r}}function Ls(l,t,e,s,i,r,n,a){const o=t.coords,h=t.colors,c=l.data,d=l.width*4;let u;o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=r,r=n,n=u),o[s+1]>o[i+1]&&(u=s,s=i,i=u,u=n,n=a,a=u),o[e+1]>o[s+1]&&(u=e,e=s,s=u,u=r,r=n,n=u);const p=(o[e]+t.offsetX)*t.scaleX,g=(o[e+1]+t.offsetY)*t.scaleY,f=(o[s]+t.offsetX)*t.scaleX,m=(o[s+1]+t.offsetY)*t.scaleY,v=(o[i]+t.offsetX)*t.scaleX,y=(o[i+1]+t.offsetY)*t.scaleY;if(g>=y)return;const b=h[r],w=h[r+1],A=h[r+2],x=h[n],_=h[n+1],E=h[n+2],S=h[a],C=h[a+1],T=h[a+2],R=Math.round(g),D=Math.round(y);let L,U,P,M,B,K,rt,ht;for(let Z=R;Z<=D;Z++){if(Z<m){const k=Z<g?0:(g-Z)/(g-m);L=p-(p-f)*k,U=b-(b-x)*k,P=w-(w-_)*k,M=A-(A-E)*k}else{let k;Z>y?k=1:m===y?k=0:k=(m-Z)/(m-y),L=f-(f-v)*k,U=x-(x-S)*k,P=_-(_-C)*k,M=E-(E-T)*k}let G;Z<g?G=0:Z>y?G=1:G=(g-Z)/(g-y),B=p-(p-v)*G,K=b-(b-S)*G,rt=w-(w-C)*G,ht=A-(A-T)*G;const Tt=Math.round(Math.min(L,B)),ct=Math.round(Math.max(L,B));let O=d*Z+Tt*4;for(let k=Tt;k<=ct;k++)G=(L-k)/(L-B),G<0?G=0:G>1&&(G=1),c[O++]=U-(U-K)*G|0,c[O++]=P-(P-rt)*G|0,c[O++]=M-(M-ht)*G|0,c[O++]=255}}function gn(l,t,e){const s=t.coords,i=t.colors;let r,n;switch(t.type){case"lattice":const a=t.verticesPerRow,o=Math.floor(s.length/a)-1,h=a-1;for(r=0;r<o;r++){let c=r*a;for(let d=0;d<h;d++,c++)Ls(l,e,s[c],s[c+1],s[c+a],i[c],i[c+1],i[c+a]),Ls(l,e,s[c+a+1],s[c+1],s[c+a],i[c+a+1],i[c+1],i[c+a])}break;case"triangles":for(r=0,n=s.length;r<n;r+=3)Ls(l,e,s[r],s[r+1],s[r+2],i[r],i[r+1],i[r+2]);break;default:throw new Error("illegal figure")}}class mn extends oi{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,s){const i=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),n=Math.ceil(this._bounds[2])-i,a=Math.ceil(this._bounds[3])-r,o=Math.min(Math.ceil(Math.abs(n*t[0]*1.1)),3e3),h=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),c=n/o,d=a/h,u={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-r,scaleX:1/c,scaleY:1/d},p=o+4,g=h+4,f=s.getCanvas("mesh",p,g),m=f.context,v=m.createImageData(o,h);if(e){const y=v.data;for(let b=0,w=y.length;b<w;b+=4)y[b]=e[0],y[b+1]=e[1],y[b+2]=e[2],y[b+3]=255}for(const y of this._figures)gn(v,y,u);return m.putImageData(v,2,2),{canvas:f.canvas,offsetX:i-2*c,offsetY:r-2*d,scaleX:c,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){Gs(t,this._bbox);const r=new Float32Array(2);if(i===_t.SHADING)F.singularValueDecompose2dScale(nt(t),r);else if(this.matrix){F.singularValueDecompose2dScale(this.matrix,r);const[a,o]=r;F.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=a,r[1]*=o}else F.singularValueDecompose2dScale(e.baseTransform,r);const n=this._createMeshCanvas(r,i===_t.SHADING?null:this._background,e.cachedCanvases);return i!==_t.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(n.offsetX,n.offsetY),t.scale(n.scaleX,n.scaleY),t.createPattern(n.canvas,"no-repeat")}}class vn extends oi{getPattern(){return"hotpink"}}function bn(l){switch(l[0]){case"RadialAxial":return new fn(l);case"Mesh":return new mn(l);case"Dummy":return new vn}throw new Error(`Unknown IR type: ${l[0]}`)}const Li={COLORED:1,UNCOLORED:2};class li{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i}createPatternCanvas(t,e){const{bbox:s,operatorList:i,paintType:r,tilingType:n,color:a,canvasGraphicsFactory:o}=this;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),Es("TilingType: "+n);const d=s[0],u=s[1],p=s[2],g=s[3],f=p-d,m=g-u,v=new Float32Array(2);F.singularValueDecompose2dScale(this.matrix,v);const[y,b]=v;F.singularValueDecompose2dScale(this.baseTransform,v);const w=y*v[0],A=b*v[1];let x=f,_=m,E=!1,S=!1;const C=Math.ceil(h*w),T=Math.ceil(c*A),R=Math.ceil(f*w),D=Math.ceil(m*A);C>=R?x=h:E=!0,T>=D?_=c:S=!0;const L=this.getSizeAndScale(x,this.ctx.canvas.width,w),U=this.getSizeAndScale(_,this.ctx.canvas.height,A),P=t.cachedCanvases.getCanvas("pattern",L.size,U.size),M=P.context,B=o.createCanvasGraphics(M,e);if(B.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(B,r,a),M.translate(-L.scale*d,-U.scale*u),B.transform(0,L.scale,0,0,U.scale,0,0),M.save(),B.dependencyTracker?.save(),this.clipBbox(B,d,u,p,g),B.baseTransform=nt(B.ctx),B.executeOperatorList(i),B.endDrawing(),B.dependencyTracker?.restore(),M.restore(),E||S){const K=P.canvas;E&&(x=h),S&&(_=c);const rt=this.getSizeAndScale(x,this.ctx.canvas.width,w),ht=this.getSizeAndScale(_,this.ctx.canvas.height,A),Z=rt.size,G=ht.size,Tt=t.cachedCanvases.getCanvas("pattern-workaround",Z,G),ct=Tt.context,O=E?Math.floor(f/h):0,k=S?Math.floor(m/c):0;for(let I=0;I<=O;I++)for(let V=0;V<=k;V++)ct.drawImage(K,Z*I,G*V,Z,G,0,0,Z,G);return{canvas:Tt.canvas,scaleX:rt.scale,scaleY:ht.scale,offsetX:d,offsetY:u}}return{canvas:P.canvas,scaleX:L.scale,scaleY:U.scale,offsetX:d,offsetY:u}}getSizeAndScale(t,e,s){const i=Math.max(li.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=i?r=i:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,i,r){const n=i-e,a=r-s;t.ctx.rect(e,s,n,a),F.axialAlignedBoundingBox([e,s,i,r],nt(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,r=t.current;switch(e){case Li.COLORED:const{fillStyle:n,strokeStyle:a}=this.ctx;i.fillStyle=r.fillColor=n,i.strokeStyle=r.strokeColor=a;break;case Li.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new Br(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){let n=s;i!==_t.SHADING&&(n=F.transform(n,e.baseTransform),this.matrix&&(n=F.transform(n,this.matrix)));const a=this.createPatternCanvas(e,r);let o=new DOMMatrix(n);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const h=t.createPattern(a.canvas,"repeat");return h.setTransform(o),h}}function yn({src:l,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:n=!1}){const a=At.isLittleEndian?4278190080:255,[o,h]=n?[r,a]:[a,r],c=s>>3,d=s&7,u=l.length;e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<i;g++){for(const m=t+c;t<m;t++){const v=t<u?l[t]:255;e[p++]=v&128?h:o,e[p++]=v&64?h:o,e[p++]=v&32?h:o,e[p++]=v&16?h:o,e[p++]=v&8?h:o,e[p++]=v&4?h:o,e[p++]=v&2?h:o,e[p++]=v&1?h:o}if(d===0)continue;const f=t<u?l[t++]:255;for(let m=0;m<d;m++)e[p++]=f&1<<7-m?h:o}return{srcPos:t,destPos:p}}const Oi=16,Fi=100,wn=15,Ni=10,Rt=16,Os=new DOMMatrix,Ot=new Float32Array(2),ye=new Float32Array([1/0,1/0,-1/0,-1/0]);function An(l,t){if(l._removeMirroring)throw new Error("Context is already forwarding operations.");l.__originalSave=l.save,l.__originalRestore=l.restore,l.__originalRotate=l.rotate,l.__originalScale=l.scale,l.__originalTranslate=l.translate,l.__originalTransform=l.transform,l.__originalSetTransform=l.setTransform,l.__originalResetTransform=l.resetTransform,l.__originalClip=l.clip,l.__originalMoveTo=l.moveTo,l.__originalLineTo=l.lineTo,l.__originalBezierCurveTo=l.bezierCurveTo,l.__originalRect=l.rect,l.__originalClosePath=l.closePath,l.__originalBeginPath=l.beginPath,l._removeMirroring=()=>{l.save=l.__originalSave,l.restore=l.__originalRestore,l.rotate=l.__originalRotate,l.scale=l.__originalScale,l.translate=l.__originalTranslate,l.transform=l.__originalTransform,l.setTransform=l.__originalSetTransform,l.resetTransform=l.__originalResetTransform,l.clip=l.__originalClip,l.moveTo=l.__originalMoveTo,l.lineTo=l.__originalLineTo,l.bezierCurveTo=l.__originalBezierCurveTo,l.rect=l.__originalRect,l.closePath=l.__originalClosePath,l.beginPath=l.__originalBeginPath,delete l._removeMirroring},l.save=function(){t.save(),this.__originalSave()},l.restore=function(){t.restore(),this.__originalRestore()},l.translate=function(e,s){t.translate(e,s),this.__originalTranslate(e,s)},l.scale=function(e,s){t.scale(e,s),this.__originalScale(e,s)},l.transform=function(e,s,i,r,n,a){t.transform(e,s,i,r,n,a),this.__originalTransform(e,s,i,r,n,a)},l.setTransform=function(e,s,i,r,n,a){t.setTransform(e,s,i,r,n,a),this.__originalSetTransform(e,s,i,r,n,a)},l.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},l.rotate=function(e){t.rotate(e),this.__originalRotate(e)},l.clip=function(e){t.clip(e),this.__originalClip(e)},l.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},l.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},l.bezierCurveTo=function(e,s,i,r,n,a){t.bezierCurveTo(e,s,i,r,n,a),this.__originalBezierCurveTo(e,s,i,r,n,a)},l.rect=function(e,s,i,r){t.rect(e,s,i,r),this.__originalRect(e,s,i,r)},l.closePath=function(){t.closePath(),this.__originalClosePath()},l.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class xn{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function as(l,t,e,s,i,r,n,a,o,h){const[c,d,u,p,g,f]=nt(l);if(d===0&&u===0){const y=n*c+g,b=Math.round(y),w=a*p+f,A=Math.round(w),x=(n+o)*c+g,_=Math.abs(Math.round(x)-b)||1,E=(a+h)*p+f,S=Math.abs(Math.round(E)-A)||1;return l.setTransform(Math.sign(c),0,0,Math.sign(p),b,A),l.drawImage(t,e,s,i,r,0,0,_,S),l.setTransform(c,d,u,p,g,f),[_,S]}if(c===0&&p===0){const y=a*u+g,b=Math.round(y),w=n*d+f,A=Math.round(w),x=(a+h)*u+g,_=Math.abs(Math.round(x)-b)||1,E=(n+o)*d+f,S=Math.abs(Math.round(E)-A)||1;return l.setTransform(0,Math.sign(d),Math.sign(u),0,b,A),l.drawImage(t,e,s,i,r,0,0,S,_),l.setTransform(c,d,u,p,g,f),[S,_]}l.drawImage(t,e,s,i,r,n,a,o,h);const m=Math.hypot(c,d),v=Math.hypot(u,p);return[m*o,v*h]}class Bi{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Us;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=xt.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e,s){s?.(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=ye.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=_t.FILL,e=null){const s=this.minMax.slice();if(t===_t.STROKE){e||it("Stroke bounding box must include transform."),F.singularValueDecompose2dScale(e,Ot);const i=Ot[0]*this.lineWidth/2,r=Ot[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,s[3]+=r}return s}updateClipFromPath(){const t=F.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(ye,0)}getClippedPathBoundingBox(t=_t.FILL,e=null){return F.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Ui(l,t){if(t instanceof ImageData){l.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%Rt,r=(e-i)/Rt,n=i===0?r:r+1,a=l.createImageData(s,Rt);let o=0,h;const c=t.data,d=a.data;let u,p,g,f;if(t.kind===zt.GRAYSCALE_1BPP){const m=c.byteLength,v=new Uint32Array(d.buffer,0,d.byteLength>>2),y=v.length,b=s+7>>3,w=4294967295,A=At.isLittleEndian?4278190080:255;for(u=0;u<n;u++){for(g=u<r?Rt:i,h=0,p=0;p<g;p++){const x=m-o;let _=0;const E=x>b?s:x*8-7,S=E&-8;let C=0,T=0;for(;_<S;_+=8)T=c[o++],v[h++]=T&128?w:A,v[h++]=T&64?w:A,v[h++]=T&32?w:A,v[h++]=T&16?w:A,v[h++]=T&8?w:A,v[h++]=T&4?w:A,v[h++]=T&2?w:A,v[h++]=T&1?w:A;for(;_<E;_++)C===0&&(T=c[o++],C=128),v[h++]=T&C?w:A,C>>=1}for(;h<y;)v[h++]=0;l.putImageData(a,0,u*Rt)}}else if(t.kind===zt.RGBA_32BPP){for(p=0,f=s*Rt*4,u=0;u<r;u++)d.set(c.subarray(o,o+f)),o+=f,l.putImageData(a,0,p),p+=Rt;u<n&&(f=s*i*4,d.set(c.subarray(o,o+f)),l.putImageData(a,0,p))}else if(t.kind===zt.RGB_24BPP)for(g=Rt,f=s*g,u=0;u<n;u++){for(u>=r&&(g=i,f=s*g),h=0,p=f;p--;)d[h++]=c[o++],d[h++]=c[o++],d[h++]=c[o++],d[h++]=255;l.putImageData(a,0,u*Rt)}else throw new Error(`bad image kind: ${t.kind}`)}function Hi(l,t){if(t.bitmap){l.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%Rt,r=(e-i)/Rt,n=i===0?r:r+1,a=l.createImageData(s,Rt);let o=0;const h=t.data,c=a.data;for(let d=0;d<n;d++){const u=d<r?Rt:i;({srcPos:o}=yn({src:h,srcPos:o,dest:c,width:s,height:u,nonBlackColor:0})),l.putImageData(a,0,d*Rt)}}function De(l,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)l[s]!==void 0&&(t[s]=l[s]);l.setLineDash!==void 0&&(t.setLineDash(l.getLineDash()),t.lineDashOffset=l.lineDashOffset)}function os(l){l.strokeStyle=l.fillStyle="#000000",l.fillRule="nonzero",l.globalAlpha=1,l.lineWidth=1,l.lineCap="butt",l.lineJoin="miter",l.miterLimit=10,l.globalCompositeOperation="source-over",l.font="10px sans-serif",l.setLineDash!==void 0&&(l.setLineDash([]),l.lineDashOffset=0);const{filter:t}=l;t!=="none"&&t!==""&&(l.filter="none")}function $i(l,t){if(t)return!0;F.singularValueDecompose2dScale(l,Ot);const e=Math.fround(Gt.pixelRatio*de.PDF_TO_CSS_UNITS);return Ot[0]<=e&&Ot[1]<=e}const _n=["butt","round","square"],En=["miter","round","bevel"],Sn={},zi={};class xe{constructor(t,e,s,i,r,{optionalContentConfig:n,markedContentStack:a=null},o,h,c){this.ctx=t,this.current=new Bi(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=n,this.cachedCanvases=new xn(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=c??null}getObject(t,e,s=null){return typeof e=="string"?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const r=this.ctx.canvas.width,n=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,n),this.ctx.fillStyle=a,s){const o=this.cachedCanvases.getCanvas("transparent",r,n);this.compositeCtx=this.ctx,this.transparentCanvas=o.canvas,this.ctx=o.context,this.ctx.save(),this.ctx.transform(...nt(this.compositeCtx))}this.ctx.save(),os(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=nt(this.ctx)}executeOperatorList(t,e,s,i,r){const n=t.argsArray,a=t.fnArray;let o=e||0;const h=n.length;if(h===o)return o;const c=h-o>Ni&&typeof s=="function",d=c?Date.now()+wn:0;let u=0;const p=this.commonObjs,g=this.objs;let f,m;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(!r||r(o))if(f=a[o],m=n[o]??null,f!==Mt.dependency)m===null?this[f](o):this[f](o,...m);else for(const v of m){this.dependencyTracker?.recordNamedData(v,o);const y=v.startsWith("g_")?p:g;if(!y.has(v))return y.get(v,s),o}if(o++,o===h)return o;if(c&&++u>Ni){if(Date.now()>d)return s(),o;u=0}}}#t(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#t(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#e()}#e(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let r=Math.max(Math.hypot(e[0],e[1]),1),n=Math.max(Math.hypot(e[2],e[3]),1),a=s,o=i,h="prescale1",c,d;for(;r>2&&a>1||n>2&&o>1;){let u=a,p=o;r>2&&a>1&&(u=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),r/=a/u),n>2&&o>1&&(p=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,n/=o/p),c=this.cachedCanvases.getCanvas(h,u,p),d=c.context,d.clearRect(0,0,u,p),d.drawImage(t,0,0,a,o,0,0,u,p),t=c.canvas,a=u,o=p,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:o}}_createMaskCanvas(t,e){const s=this.ctx,{width:i,height:r}=e,n=this.current.fillColor,a=this.current.patternFill,o=nt(s);let h,c,d,u;if((e.bitmap||e.data)&&e.count>1){const C=e.bitmap||e.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),n]),h=this._cachedBitmapsMap.get(C),h||(h=new Map,this._cachedBitmapsMap.set(C,h));const T=h.get(c);if(T&&!a){const R=Math.round(Math.min(o[0],o[2])+o[4]),D=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,Ht.transformAndFill),{canvas:T,offsetX:R,offsetY:D}}d=T}d||(u=this.cachedCanvases.getCanvas("maskCanvas",i,r),Hi(u.context,e));let p=F.transform(o,[1/i,0,0,-1/r,0,0]);p=F.transform(p,[1,0,0,1,0,-r]);const g=ye.slice();F.axialAlignedBoundingBox([0,0,i,r],p,g);const[f,m,v,y]=g,b=Math.round(v-f)||1,w=Math.round(y-m)||1,A=this.cachedCanvases.getCanvas("fillCanvas",b,w),x=A.context,_=f,E=m;x.translate(-_,-E),x.transform(...p),d||(d=this._scaleImage(u.canvas,Vt(x)),d=d.img,h&&a&&h.set(c,d)),x.imageSmoothingEnabled=$i(nt(x),e.interpolate),as(x,d,0,0,d.width,d.height,0,0,i,r),x.globalCompositeOperation="source-in";const S=F.transform(Vt(x),[1,0,0,1,-_,-E]);return x.fillStyle=a?n.getPattern(s,this,S,_t.FILL,t):n,x.fillRect(0,0,i,r),h&&!a&&(this.cachedCanvases.delete("fillCanvas"),h.set(c,A.canvas)),this.dependencyTracker?.recordDependencies(t,Ht.transformAndFill),{canvas:A.canvas,offsetX:Math.round(_),offsetY:Math.round(E)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=_n[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=En[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){this.dependencyTracker?.recordSimpleData("dash",t);const i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(const[s,i]of e)switch(s){case"LW":this.setLineWidth(t,i);break;case"LC":this.setLineCap(t,i);break;case"LJ":this.setLineJoin(t,i);break;case"ML":this.setMiterLimit(t,i);break;case"D":this.setDash(t,i[0],i[1]);break;case"RI":this.setRenderingIntent(t,i);break;case"FL":this.setFlatness(t,i);break;case"Font":this.setFont(t,i[0],i[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=i;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=i;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=i;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,s=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(i,e,s);this.suspendedCtx=this.ctx;const n=this.ctx=r.context;n.setTransform(this.suspendedCtx.getTransform()),De(this.suspendedCtx,n),An(n,this.suspendedCtx),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),De(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx;this.composeSMask(s,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,s,i){const r=i[0],n=i[1],a=i[2]-r,o=i[3]-n;a===0||o===0||(this.genericComposeSMask(e.context,s,a,o,e.subtype,e.backdrop,e.transferMap,r,n,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,r,n,a,o,h,c,d){let u=t.canvas,p=o-c,g=h-d;if(n)if(p<0||g<0||p+s>u.width||g+i>u.height){const m=this.cachedCanvases.getCanvas("maskExtension",s,i),v=m.context;v.drawImage(u,-p,-g),v.globalCompositeOperation="destination-atop",v.fillStyle=n,v.fillRect(0,0,s,i),v.globalCompositeOperation="source-over",u=m.canvas,p=g=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const m=new Path2D;m.rect(p,g,s,i),t.clip(m),t.globalCompositeOperation="destination-atop",t.fillStyle=n,t.fillRect(p,g,s,i),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),r==="Alpha"&&a?e.filter=this.filterFactory.addAlphaFilter(a):r==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(a));const f=new Path2D;f.rect(o,h,s,i),e.clip(f),e.globalCompositeOperation="destination-in",e.drawImage(u,p,g,s,i,o,h,s,i),e.restore()}save(t){this.inSMaskMode&&De(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&De(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,r,n,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,r,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[r]=s;if(!i){r||=s[0]=new Path2D,this[e](t,r);return}if(this.dependencyTracker!==null){const n=e===Mt.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-n,i[2]+n,i[1]-n,i[3]+n).recordDependencies(t,["transform"])}if(!(r instanceof Path2D)){const n=s[0]=new Path2D;for(let a=0,o=r.length;a<o;)switch(r[a++]){case ts.moveTo:n.moveTo(r[a++],r[a++]);break;case ts.lineTo:n.lineTo(r[a++],r[a++]);break;case ts.curveTo:n.bezierCurveTo(r[a++],r[a++],r[a++],r[a++],r[a++],r[a++]);break;case ts.closePath:n.closePath();break;default:j(`Unrecognized drawing path operator: ${r[a-1]}`);break}r=n}F.axialAlignedBoundingBox(i,nt(this.ctx),this.current.minMax),this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){const i=this.ctx,r=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&r?.getPattern){const n=r.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=r.getPattern(i,this,Vt(i),_t.STROKE,t),n){const a=new Path2D;a.addPath(e,i.getTransform().invertSelf().multiplySelf(n)),e=a}this.rescaleAndStroke(e,!1),i.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,Ht.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(_t.STROKE,nt(this.ctx))),i.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){const i=this.ctx,r=this.current.fillColor,n=this.current.patternFill;let a=!1;if(n){const h=r.isModifyingCurrentTransform()?i.getTransform():null;if(this.dependencyTracker?.save(t),i.save(),i.fillStyle=r.getPattern(i,this,Vt(i),_t.FILL,t),h){const c=new Path2D;c.addPath(e,i.getTransform().invertSelf().multiplySelf(h)),e=c}a=!0}const o=this.current.getClippedPathBoundingBox();this.contentVisible&&o!==null&&(this.pendingEOFill?(i.fill(e,"evenodd"),this.pendingEOFill=!1):i.fill(e)),this.dependencyTracker?.recordDependencies(t,Ht.fill),a&&(i.restore(),this.dependencyTracker?.restore(t)),s&&this.consumePath(t,e,o)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,Ht.rawFillPath).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Sn}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=zi}beginText(t){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(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;e!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(e!==void 0){const i=new Path2D,r=s.getTransform().invertSelf();for(const{transform:n,x:a,y:o,fontSize:h,path:c}of e)c&&i.addPath(c,new DOMMatrix(n).preMultiplySelf(r).translate(a,o).scale(h,-h));s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||Us,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&j("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;const n=i.loadedName||"sans-serif",a=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let o="normal";i.black?o="900":i.bold&&(o="bold");const h=i.italic?"italic":"normal";let c=s;s<Oi?c=Oi:s>Fi&&(c=Fi),this.current.fontSizeScale=s/c,this.ctx.font=`${h} ${o} ${c}px ${a}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){this.dependencyTracker?.recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#i(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i}paintChar(t,e,s,i,r,n){const a=this.ctx,o=this.current,h=o.font,c=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,u=c&xt.FILL_STROKE_MASK,p=!!(c&xt.ADD_TO_PATH_FLAG),g=o.patternFill&&!h.missingFile,f=o.patternStroke&&!h.missingFile;let m;if((h.disableFontFace||p||g||f)&&!h.missingFile&&(m=h.getPathGenerator(this.commonObjs,e)),m&&(h.disableFontFace||g||f)){a.save(),a.translate(s,i),a.scale(d,-d),this.dependencyTracker?.recordCharacterBBox(t,a,h);let v;if(u===xt.FILL||u===xt.FILL_STROKE)if(r){v=a.getTransform(),a.setTransform(...r);const y=this.#i(m,v,r);a.fill(y)}else a.fill(m);if(u===xt.STROKE||u===xt.FILL_STROKE)if(n){v||=a.getTransform(),a.setTransform(...n);const{a:y,b,c:w,d:A}=v,x=F.inverseTransform(n),_=F.transform([y,b,w,A,0,0],x);F.singularValueDecompose2dScale(_,Ot),a.lineWidth*=Math.max(Ot[0],Ot[1])/d,a.stroke(this.#i(m,v,n))}else a.lineWidth/=d,a.stroke(m);a.restore()}else(u===xt.FILL||u===xt.FILL_STROKE)&&(a.fillText(e,s,i),this.dependencyTracker?.recordCharacterBBox(t,a,h,d,s,i,()=>a.measureText(e))),(u===xt.STROKE||u===xt.FILL_STROKE)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,a,h,d,s,i,()=>a.measureText(e)).recordDependencies(t,Ht.stroke),a.strokeText(e,s,i));p&&((this.pendingTextPaths||=[]).push({transform:nt(a),x:s,y:i,fontSize:d,path:m}),this.dependencyTracker?.recordCharacterBBox(t,a,h,d,s,i))}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return Y(this,"isFontSubpixelAAEnabled",s)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Ht.showText).resetBBox(t),this.current.textRenderingMode&xt.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t);return}const r=s.fontSize;if(r===0){this.dependencyTracker?.recordOperation(t);return}const n=this.ctx,a=s.fontSizeScale,o=s.charSpacing,h=s.wordSpacing,c=s.fontDirection,d=s.textHScale*c,u=e.length,p=i.vertical,g=p?1:-1,f=i.defaultVMetrics,m=r*s.fontMatrix[0],v=s.textRenderingMode===xt.FILL&&!i.disableFontFace&&!s.patternFill;n.save(),s.textMatrix&&n.transform(...s.textMatrix),n.translate(s.x,s.y+s.textRise),c>0?n.scale(d,-1):n.scale(d,1);let y,b;if(s.patternFill){n.save();const E=s.fillColor.getPattern(n,this,Vt(n),_t.FILL,t);y=nt(n),n.restore(),n.fillStyle=E}if(s.patternStroke){n.save();const E=s.strokeColor.getPattern(n,this,Vt(n),_t.STROKE,t);b=nt(n),n.restore(),n.strokeStyle=E}let w=s.lineWidth;const A=s.textMatrixScale;if(A===0||w===0){const E=s.textRenderingMode&xt.FILL_STROKE_MASK;(E===xt.STROKE||E===xt.FILL_STROKE)&&(w=this.getSinglePixelWidth())}else w/=A;if(a!==1&&(n.scale(a,a),w/=a),n.lineWidth=w,i.isInvalidPDFjsFont){const E=[];let S=0;for(const T of e)E.push(T.unicode),S+=T.width;const C=E.join("");if(n.fillText(C,0,0),this.dependencyTracker!==null){const T=n.measureText(C);this.dependencyTracker.recordBBox(t,this.ctx,-T.actualBoundingBoxLeft,T.actualBoundingBoxRight,-T.actualBoundingBoxAscent,T.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=S*m*d,n.restore(),this.compose();return}let x=0,_;for(_=0;_<u;++_){const E=e[_];if(typeof E=="number"){x+=g*E*r/1e3;continue}let S=!1;const C=(E.isSpace?h:0)+o,T=E.fontChar,R=E.accent;let D,L,U=E.width;if(p){const B=E.vmetric||f,K=-(E.vmetric?B[1]:U*.5)*m,rt=B[2]*m;U=B?-B[0]:U,D=K/a,L=(x+rt)/a}else D=x/a,L=0;let P;if(i.remeasure&&U>0){P=n.measureText(T);const B=P.width*1e3/r*a;if(U<B&&this.isFontSubpixelAAEnabled){const K=U/B;S=!0,n.save(),n.scale(K,1),D/=K}else U!==B&&(D+=(U-B)/2e3*r/a)}if(this.contentVisible&&(E.isInFont||i.missingFile)){if(v&&!R)n.fillText(T,D,L),this.dependencyTracker?.recordCharacterBBox(t,n,P?{bbox:null}:i,r/a,D,L,()=>P??n.measureText(T));else if(this.paintChar(t,T,D,L,y,b),R){const B=D+r*R.offset.x/a,K=L-r*R.offset.y/a;this.paintChar(t,R.fontChar,B,K,y,b)}}const M=p?U*m-C*c:U*m+C*c;x+=M,S&&n.restore()}p?s.y-=x:s.x+=x*d,n.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,e){const s=this.ctx,i=this.current,r=i.font,n=i.fontSize,a=i.fontDirection,o=r.vertical?1:-1,h=i.charSpacing,c=i.wordSpacing,d=i.textHScale*a,u=i.fontMatrix||Us,p=e.length,g=i.textRenderingMode===xt.INVISIBLE;let f,m,v,y;if(g||n===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(d,a);const b=this.dependencyTracker;for(this.dependencyTracker=b?new fs(b,t):null,f=0;f<p;++f){if(m=e[f],typeof m=="number"){y=o*m*n/1e3,this.ctx.translate(y,0),i.x+=y*d;continue}const w=(m.isSpace?c:0)+h,A=r.charProcOperatorList[m.operatorListId];A?this.contentVisible&&(this.save(),s.scale(n,n),s.transform(...u),this.executeOperatorList(A),this.restore()):j(`Type3 character "${m.operatorListId}" is not available.`);const x=[m.width,0];F.applyTransform(x,u),v=x[0]*n+w,s.translate(v,0),i.x+=v*d}s.restore(),b&&(this.dependencyTracker=b)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,r,n,a){const o=new Path2D;o.rect(i,r,n-i,a-r),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,i,n,r,a).recordClipBox(t,this.ctx,i,n,r,a),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const i=this.baseTransform||nt(this.ctx),r={createCanvasGraphics:(n,a)=>new xe(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new fs(this.dependencyTracker,a,!0):null)};s=new li(e,this.ctx,r,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,s=null){let i;return this.cachedPatterns.has(e)?i=this.cachedPatterns.get(e):(i=bn(this.getObject(t,e)),this.cachedPatterns.set(e,i)),s&&(i.matrix=s),i}shadingFill(t,e){if(!this.contentVisible)return;const s=this.ctx;this.save(t);const i=this._getPattern(t,e);s.fillStyle=i.getPattern(s,this,Vt(s),_t.SHADING,t);const r=Vt(s);if(r){const{width:n,height:a}=s.canvas,o=ye.slice();F.axialAlignedBoundingBox([0,0,n,a],r,o);const[h,c,d,u]=o;this.ctx.fillRect(h,c,d-h,u-c)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Ht.transform).recordDependencies(t,Ht.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){it("Should not call beginInlineImage")}beginImageData(){it("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=nt(this.ctx),s)){F.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[i,r,n,a]=s,o=new Path2D;o.rect(i,r,n-i,a-r),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(t,this.ctx,i,n,r,a),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;e.isolated||Es("TODO: Support non-isolated groups."),e.knockout&&j("Knockout groups not supported.");const i=nt(s);if(e.matrix&&s.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=ye.slice();F.axialAlignedBoundingBox(e.bbox,nt(s),r);const n=[0,0,s.canvas.width,s.canvas.height];r=F.intersect(r,n)||[0,0,0,0];const a=Math.floor(r[0]),o=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-a,1),c=Math.max(Math.ceil(r[3])-o,1);this.current.startNewPathAndClipBox([0,0,h,c]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(d,h,c),p=u.context;p.translate(-a,-o),p.transform(...i);let g=new Path2D;const[f,m,v,y]=e.bbox;if(g.rect(f,m,v-f,y-m),e.matrix){const b=new Path2D;b.addPath(g,new DOMMatrix(e.matrix)),g=b}p.clip(g),e.smask&&this.smaskStack.push({canvas:u.canvas,context:p,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(s.setTransform(1,0,0,1,0,0),s.translate(a,o),s.save()),De(s,p),this.ctx=p,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(s),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const r=nt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...r);const n=ye.slice();F.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],r,n),this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,r,n){if(this.#t(),os(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const a=s[2]-s[0],o=s[3]-s[1];if(n&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=a,s[3]=o,F.singularValueDecompose2dScale(nt(this.ctx),Ot);const{viewportScale:h}=this,c=Math.ceil(a*this.outputScaleX*h),d=Math.ceil(o*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,d);const{canvas:u,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(e,u),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(Ot[0],0,0,-Ot[1],0,o*Ot[1]),os(this.ctx)}else{os(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],a,o),this.ctx.clip(h)}}this.current=new Bi(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...i),this.transform(t,...r)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#e(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const i=this.ctx,r=this._createMaskCanvas(t,e),n=r.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(n,r.offsetX,r.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+n.width,r.offsetY,r.offsetY+n.height).recordOperation(t),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,n,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const o=this.ctx;o.save();const h=nt(o);o.transform(s,i,r,n,0,0);const c=this._createMaskCanvas(t,e);o.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]),this.dependencyTracker?.resetBBox(t);for(let d=0,u=a.length;d<u;d+=2){const p=F.transform(h,[s,i,r,n,a[d],a[d+1]]);o.drawImage(c.canvas,p[4],p[5]),this.dependencyTracker?.recordBBox(t,this.ctx,p[4],p[4]+c.canvas.width,p[5],p[5]+c.canvas.height)}o.restore(),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx,i=this.current.fillColor,r=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Ht.transformAndFill);for(const n of e){const{data:a,width:o,height:h,transform:c}=n,d=this.cachedCanvases.getCanvas("maskCanvas",o,h),u=d.context;u.save();const p=this.getObject(t,a,n);Hi(u,p),u.globalCompositeOperation="source-in",u.fillStyle=r?i.getPattern(u,this,Vt(s),_t.FILL,t):i,u.fillRect(0,0,o,h),u.restore(),s.save(),s.transform(...c),s.scale(1,-1),as(s,d.canvas,0,0,o,h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,s,0,o,0,h),s.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){j("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,r){if(!this.contentVisible)return;const n=this.getObject(t,e);if(!n){j("Dependent image isn't ready yet");return}const a=n.width,o=n.height,h=[];for(let c=0,d=r.length;c<d;c+=2)h.push({transform:[s,0,0,i,r[c],r[c+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,n,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,r=this.cachedCanvases.getCanvas("inlineImage",s,i),n=r.context;return n.filter=this.current.transferMaps,n.drawImage(e,0,0),n.filter="none",r.canvas}paintInlineImageXObject(t,e){if(!this.contentVisible)return;const s=e.width,i=e.height,r=this.ctx;this.save(t);const{filter:n}=r;n!=="none"&&n!==""&&(r.filter="none"),r.scale(1/s,-1/i);let a;if(e.bitmap)a=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)a=e;else{const h=this.cachedCanvases.getCanvas("inlineImage",s,i).context;Ui(h,e),a=this.applyTransferMapsToCanvas(h)}const o=this._scaleImage(a,Vt(r));r.imageSmoothingEnabled=$i(nt(r),e.interpolate),this.dependencyTracker?.resetBBox(t).recordBBox(t,r,0,s,-i,0).recordDependencies(t,Ht.imageXObject).recordOperation(t),as(r,o.img,0,0,o.paintWidth,o.paintHeight,0,-i,s,i),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,s){if(!this.contentVisible)return;const i=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const n=e.width,a=e.height,o=this.cachedCanvases.getCanvas("inlineImage",n,a).context;Ui(o,e),r=this.applyTransferMapsToCanvas(o)}this.dependencyTracker?.resetBBox(t);for(const n of s)i.save(),i.transform(...n.transform),i.scale(1,-1),as(i,r,n.x,n.y,n.w,n.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,i,0,1,-1,0),i.restore();this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ht.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){this.dependencyTracker?.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(i||(this.pendingClip===zi?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=nt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:r}=this.ctx.getTransform();let n,a;if(s===0&&i===0){const o=Math.abs(e),h=Math.abs(r);if(o===h)if(t===0)n=a=1/o;else{const c=o*t;n=a=c<1?1/c:1}else if(t===0)n=1/o,a=1/h;else{const c=o*t,d=h*t;n=c<1?1/c:1,a=d<1?1/d:1}}else{const o=Math.abs(e*r-s*i),h=Math.hypot(e,s),c=Math.hypot(i,r);if(t===0)n=c/o,a=h/o;else{const d=t*o;n=c>d?c/d:1,a=h>d?h/d:1}}this._cachedScaleForStroking[0]=n,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[r,n]=this.getScaleForStroking();if(r===n){s.lineWidth=(i||1)*r,s.stroke(t);return}const a=s.getLineDash();e&&s.save(),s.scale(r,n),Os.a=1/r,Os.d=1/n;const o=new Path2D;if(o.addPath(t,Os),a.length>0){const h=Math.max(r,n);s.setLineDash(a.map(c=>c/h)),s.lineDashOffset/=h}s.lineWidth=i||1,s.stroke(o),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const l in Mt)xe.prototype[l]!==void 0&&(xe.prototype[Mt[l]]=xe.prototype[l]);class _e{#t;#e;#i;static strings=["fontFamily","fontWeight","italicAngle"];static write(t){const e=new TextEncoder,s={};let i=0;for(const h of _e.strings){const c=e.encode(t[h]);s[h]=c,i+=4+c.length}const r=new ArrayBuffer(i),n=new Uint8Array(r),a=new DataView(r);let o=0;for(const h of _e.strings){const c=s[h],d=c.length;a.setUint32(o,d),n.set(c,o+4),o+=4+d}return J(o===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}constructor(t){this.#t=t,this.#e=new DataView(this.#t),this.#i=new TextDecoder}#s(t){J(t<_e.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#e.getUint32(e)+4;const s=this.#e.getUint32(e);return this.#i.decode(new Uint8Array(this.#t,e+4,s))}get fontFamily(){return this.#s(0)}get fontWeight(){return this.#s(1)}get italicAngle(){return this.#s(2)}}class Ee{#t;#e;#i;static strings=["css","loadedName","baseFontName","src"];static write(t){const e=new TextEncoder,s={};let i=0;for(const u of Ee.strings){const p=e.encode(t[u]);s[u]=p,i+=4+p.length}i+=4;let r,n,a=1+i;t.style&&(r=e.encode(t.style.style),n=e.encode(t.style.weight),a+=4+r.length+4+n.length);const o=new ArrayBuffer(a),h=new Uint8Array(o),c=new DataView(o);let d=0;c.setUint8(d++,t.guessFallback?1:0),c.setUint32(d,0),d+=4,i=0;for(const u of Ee.strings){const p=s[u],g=p.length;i+=4+g,c.setUint32(d,g),h.set(p,d+4),d+=4+g}return c.setUint32(d-i-4,i),t.style&&(c.setUint32(d,r.length),h.set(r,d+4),d+=4+r.length,c.setUint32(d,n.length),h.set(n,d+4),d+=4+n.length),J(d<=o.byteLength,"SubstitionInfo.write: Buffer overflow"),o.transferToFixedLength(d)}constructor(t){this.#t=t,this.#e=new DataView(this.#t),this.#i=new TextDecoder}get guessFallback(){return this.#e.getUint8(0)!==0}#s(t){J(t<Ee.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#e.getUint32(e)+4;const s=this.#e.getUint32(e);return this.#i.decode(new Uint8Array(this.#t,e+4,s))}get css(){return this.#s(0)}get loadedName(){return this.#s(1)}get baseFontName(){return this.#s(2)}get src(){return this.#s(3)}get style(){let t=1;t+=4+this.#e.getUint32(t);const e=this.#e.getUint32(t),s=this.#i.decode(new Uint8Array(this.#t,t+4,e));t+=4+e;const i=this.#e.getUint32(t),r=this.#i.decode(new Uint8Array(this.#t,t+4,i));return{style:s,weight:r}}}class tt{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static#t=Math.ceil(this.bools.length*2/8);static#e=this.#t+this.numbers.length*8;static#i=this.#e+1+8;static#s=this.#i+1+48;static#a=this.#s+1+6;#r;#n;#o;constructor({data:t,extra:e}){this.#r=t,this.#n=new TextDecoder,this.#o=new DataView(this.#r),e&&Object.assign(this,e)}#h(t){J(t<tt.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=this.#o.getUint8(e)>>s&3;return i===0?void 0:i===2}get black(){return this.#h(0)}get bold(){return this.#h(1)}get disableFontFace(){return this.#h(2)}get fontExtraProperties(){return this.#h(3)}get isInvalidPDFjsFont(){return this.#h(4)}get isType3Font(){return this.#h(5)}get italic(){return this.#h(6)}get missingFile(){return this.#h(7)}get remeasure(){return this.#h(8)}get vertical(){return this.#h(9)}#l(t){return J(t<tt.numbers.length,"Invalid number index"),this.#o.getFloat64(tt.#t+t*8)}get ascent(){return this.#l(0)}get defaultWidth(){return this.#l(1)}get descent(){return this.#l(2)}get bbox(){let t=tt.#e;if(this.#o.getUint8(t)===0)return;t+=1;const e=[];for(let s=0;s<4;s++)e.push(this.#o.getInt16(t,!0)),t+=2;return e}get fontMatrix(){let t=tt.#i;if(this.#o.getUint8(t)===0)return;t+=1;const e=[];for(let s=0;s<6;s++)e.push(this.#o.getFloat64(t,!0)),t+=8;return e}get defaultVMetrics(){let t=tt.#s;if(this.#o.getUint8(t)===0)return;t+=1;const e=[];for(let s=0;s<3;s++)e.push(this.#o.getInt16(t,!0)),t+=2;return e}#u(t){J(t<tt.strings.length,"Invalid string index");let e=tt.#a+4;for(let r=0;r<t;r++)e+=this.#o.getUint32(e)+4;const s=this.#o.getUint32(e),i=new Uint8Array(s);return i.set(new Uint8Array(this.#r,e+4,s)),this.#n.decode(i)}get fallbackName(){return this.#u(0)}get loadedName(){return this.#u(1)}get mimetype(){return this.#u(2)}get name(){return this.#u(3)}get data(){let t=tt.#a;const e=this.#o.getUint32(t);t+=4+e;const s=this.#o.getUint32(t);t+=4+s;const i=this.#o.getUint32(t);t+=4+i;const r=this.#o.getUint32(t);if(r!==0)return new Uint8Array(this.#r,t+4,r)}clearData(){let t=tt.#a;const e=this.#o.getUint32(t);t+=4+e;const s=this.#o.getUint32(t);t+=4+s;const i=this.#o.getUint32(t);t+=4+i;const r=this.#o.getUint32(t);new Uint8Array(this.#r,t+4,r).fill(0),this.#o.setUint32(t,0)}get cssFontInfo(){let t=tt.#a;const e=this.#o.getUint32(t);t+=4+e;const s=this.#o.getUint32(t);t+=4+s;const i=this.#o.getUint32(t);if(i===0)return null;const r=new Uint8Array(i);return r.set(new Uint8Array(this.#r,t+4,i)),new _e(r.buffer)}get systemFontInfo(){let t=tt.#a;const e=this.#o.getUint32(t);t+=4+e;const s=this.#o.getUint32(t);if(s===0)return null;const i=new Uint8Array(s);return i.set(new Uint8Array(this.#r,t+4,s)),new Ee(i.buffer)}static write(t){const e=t.systemFontInfo?Ee.write(t.systemFontInfo):null,s=t.cssFontInfo?_e.write(t.cssFontInfo):null,i=new TextEncoder,r={};let n=0;for(const f of tt.strings)r[f]=i.encode(t[f]),n+=4+r[f].length;const a=tt.#a+4+n+4+(e?e.byteLength:0)+4+(s?s.byteLength:0)+4+(t.data?t.data.length:0),o=new ArrayBuffer(a),h=new Uint8Array(o),c=new DataView(o);let d=0;const u=tt.bools.length;let p=0,g=0;for(let f=0;f<u;f++){const m=t[tt.bools[f]];p|=(m===void 0?0:m?2:1)<<g,g+=2,(g===8||f===u-1)&&(c.setUint8(d++,p),p=0,g=0)}J(d===tt.#t,"FontInfo.write: Boolean properties offset mismatch");for(const f of tt.numbers)c.setFloat64(d,t[f]),d+=8;if(J(d===tt.#e,"FontInfo.write: Number properties offset mismatch"),t.bbox){c.setUint8(d++,4);for(const f of t.bbox)c.setInt16(d,f,!0),d+=2}else c.setUint8(d++,0),d+=8;if(J(d===tt.#i,"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix){c.setUint8(d++,6);for(const f of t.fontMatrix)c.setFloat64(d,f,!0),d+=8}else c.setUint8(d++,0),d+=48;if(J(d===tt.#s,"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics){c.setUint8(d++,1);for(const f of t.defaultVMetrics)c.setInt16(d,f,!0),d+=2}else c.setUint8(d++,0),d+=6;J(d===tt.#a,"FontInfo.write: DefaultVMetrics properties offset mismatch"),c.setUint32(tt.#a,0),d+=4;for(const f of tt.strings){const m=r[f],v=m.length;c.setUint32(d,v),h.set(m,d+4),d+=4+v}if(c.setUint32(tt.#a,d-tt.#a-4),!e)c.setUint32(d,0),d+=4;else{const f=e.byteLength;c.setUint32(d,f),J(d+4+f<=o.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),h.set(new Uint8Array(e),d+4),d+=4+f}if(!s)c.setUint32(d,0),d+=4;else{const f=s.byteLength;c.setUint32(d,f),J(d+4+f<=o.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),h.set(new Uint8Array(s),d+4),d+=4+f}return t.data===void 0?(c.setUint32(d,0),d+=4):(c.setUint32(d,t.data.length),h.set(t.data,d+4),d+=4+t.data.length),J(d<=o.byteLength,"FontInfo.write: Buffer overflow"),o.transferToFixedLength(d)}}class se{static#t=null;static#e="";static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#e}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#e=t}}class Cn{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}[Symbol.iterator](){return this.#t.entries()}}const ve=Symbol("INTERNAL");class Tn{#t=!1;#e=!1;#i=!1;#s=!0;constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){this.#t=!!(t&It.DISPLAY),this.#e=!!(t&It.PRINT),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(this.#i)return this.#s;if(!this.#s)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==ve&&it("Internal method `_setVisible` called."),this.#i=s,this.#s=e}}class kn{#t=null;#e=new Map;#i=null;#s=null;constructor(t,e=It.DISPLAY){if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,this.#s=t.order;for(const s of t.groups)this.#e.set(s.id,new Tn(e,s));if(t.baseState==="OFF")for(const s of this.#e.values())s._setVisible(ve,!1);for(const s of t.on)this.#e.get(s)._setVisible(ve,!0);for(const s of t.off)this.#e.get(s)._setVisible(ve,!1);this.#i=this.getHash()}}#a(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const r=t[i];let n;if(Array.isArray(r))n=this.#a(r);else if(this.#e.has(r))n=this.#e.get(r).visible;else return j(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Es("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(j(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#a(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return j(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return j(`Unknown optional content policy ${t.policy}.`),!0}return j(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){const i=this.#e.get(t);if(!i){j(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const r of i.rbGroups)for(const n of r)n!==t&&this.#e.get(n)?._setVisible(ve,!1,!0);i._setVisible(ve,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=this.#e.get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#i===null||this.getHash()===this.#i}getOrder(){return this.#e.size?this.#s?this.#s.slice():[...this.#e.keys()]:null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new hr;for(const[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}[Symbol.iterator](){return this.#e.entries()}}class Pn{constructor(t,{disableRange:e=!1,disableStream:s=!1}){J(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:r,progressiveDone:n,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=n,this._contentDispositionFilename=a,r?.length>0){const o=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(o)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((o,h)=>{this._onReceiveData({begin:o,chunk:h})}),t.addProgressListener((o,h)=>{this._onProgress({loaded:o,total:h})}),t.addProgressiveReadListener(o=>{this._onReceiveData({chunk:o})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(r){return r._begin!==t?!1:(r._enqueue(s),!0)});J(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){t.total===void 0?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){J(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Mn(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Dn(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Mn{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=Cs(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Dn{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Rn(l){let t=!0,e=s("filename\\*","i").exec(l);if(e){e=e[1];let c=a(e);return c=unescape(c),c=o(c),c=h(c),r(c)}if(e=n(l),e){const c=h(e);return r(c)}if(e=s("filename","i").exec(l),e){e=e[1];let c=a(e);return c=h(c),r(c)}function s(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const u=new TextDecoder(c,{fatal:!0}),p=We(d);d=u.decode(p),t=!1}catch{}}return d}function r(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("iso-8859-1",c))),c}function n(c){const d=[];let u;const p=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=p.exec(c))!==null;){let[,f,m,v]=u;if(f=parseInt(f,10),f in d){if(f===0)break;continue}d[f]=[m,v]}const g=[];for(let f=0;f<d.length&&f in d;++f){let[m,v]=d[f];v=a(v),m&&(v=unescape(v),f===0&&(v=o(v))),g.push(v)}return g.join("")}function a(c){if(c.startsWith('"')){const d=c.slice(1).split('\\"');for(let u=0;u<d.length;++u){const p=d[u].indexOf('"');p!==-1&&(d[u]=d[u].slice(0,p),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function o(c){const d=c.indexOf("'");if(d===-1)return c;const u=c.slice(0,d),p=c.slice(d+1).replace(/^[^']*'/,"");return i(u,p)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(d,u,p,g){if(p==="q"||p==="Q")return g=g.replaceAll("_"," "),g=g.replaceAll(/=([0-9a-fA-F]{2})/g,function(f,m){return String.fromCharCode(parseInt(m,16))}),i(u,g);try{g=atob(g)}catch{}return i(u,g)})}return""}function vr(l,t){const e=new Headers;if(!l||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function Ts(l){return URL.parse(l)?.origin??null}function br({responseHeaders:l,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(l.get("Content-Length"),10);return!Number.isInteger(r)||(i.suggestedLength=r,r<=2*e)||s||!t||l.get("Accept-Ranges")!=="bytes"||(l.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function yr(l){const t=l.get("Content-Disposition");if(t){let e=Rn(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Cs(e))return e}return null}function Qe(l,t){return new $e(`Unexpected server response (${l}) while retrieving PDF "${t}".`,l,l===404||l===0&&t.startsWith("file:"))}function wr(l){return l===200||l===206}function Ar(l,t,e){return{method:"GET",headers:l,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function xr(l){return l instanceof Uint8Array?l.buffer:l instanceof ArrayBuffer?l:(j(`getArrayBuffer - unexpected data format: ${l}`),new Uint8Array(l).buffer)}class In{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=vr(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return J(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Ln(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new On(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Ln{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const s=new Headers(t.headers),i=e.url;fetch(i,Ar(s,this._withCredentials,this._abortController)).then(r=>{if(t._responseOrigin=Ts(r.url),!wr(r.status))throw Qe(r.status,i);this._reader=r.body.getReader(),this._headersCapability.resolve();const n=r.headers,{allowRangeRequests:a,suggestedLength:o}=br({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=yr(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ie("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;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:xr(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class On{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const r=new Headers(t.headers);r.append("Range",`bytes=${e}-${s-1}`);const n=i.url;fetch(n,Ar(r,this._withCredentials,this._abortController)).then(a=>{const o=Ts(a.url);if(o!==t._responseOrigin)throw new Error(`Expected range response-origin "${o}" to match "${t._responseOrigin}".`);if(!wr(a.status))throw Qe(a.status,n);this._readCapability.resolve(),this._reader=a.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:xr(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}const Fs=200,Ns=206;function Fn(l){const t=l.response;return typeof t!="string"?t:We(t).buffer}class Nn{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=vr(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[r,n]of this.headers)e.setRequestHeader(r,n);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=Ns):i.expectedStatus=Fs,e.responseType="arraybuffer",J(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError(i.status);return}const r=i.status||Fs;if(!(r===Fs&&s.expectedStatus===Ns)&&r!==s.expectedStatus){s.onError(i.status);return}const n=Fn(i);if(r===Ns){const a=i.getResponseHeader("Content-Range"),o=/bytes (\d+)-(\d+)\/(\d+)/.exec(a);o?s.onDone({begin:parseInt(o[1],10),chunk:n}):(j('Missing or invalid "Content-Range" header.'),s.onError(0))}else n?s.onDone({begin:0,chunk:n}):s.onError(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Bn{constructor(t){this._source=t,this._manager=new Nn(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return J(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Un(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Hn(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Un{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=Ts(e.responseURL);const s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(a=>{const[o,...h]=a.split(": ");return[o,h.join(": ")]}):[]),{allowRangeRequests:r,suggestedLength:n}=br({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=yr(i),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Qe(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Hn{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=Ts(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=Qe(t,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const $n=/^[a-z][a-z0-9\-+.]+:/i;function zn(l){if($n.test(l))return new URL(l);const t=yt.getBuiltinModule("url");return new URL(t.pathToFileURL(l))}class jn{constructor(t){this.source=t,this.url=zn(t.url),J(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return J(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Gn(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Vn(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Gn{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const s=yt.getBuiltinModule("fs");s.promises.lstat(this._url).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=Qe(0,this._url.href)),this._storedError=i,this._headersCapability.reject(i)})}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;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new ie("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Vn{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const i=t.source;this._isStreamingSupported=!i.disableStream;const r=yt.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:e,end:s-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;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Re=Symbol("INITIAL_DATA");class _r{#t=Object.create(null);#e(t){return this.#t[t]||={...Promise.withResolvers(),data:Re}}get(t,e=null){if(e){const i=this.#e(t);return i.promise.then(()=>e(i.data)),null}const s=this.#t[t];if(!s||s.data===Re)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=this.#t[t];return!!e&&e.data!==Re}delete(t){const e=this.#t[t];return!e||e.data===Re?!1:(delete this.#t[t],!0)}resolve(t,e=null){const s=this.#e(t);s.data=e,s.resolve()}clear(){for(const t in this.#t){const{data:e}=this.#t[t];e?.bitmap?.close()}this.#t=Object.create(null)}*[Symbol.iterator](){for(const t in this.#t){const{data:e}=this.#t[t];e!==Re&&(yield[t,e])}}}const Wn=1e5,ji=30;class St{#t=Promise.withResolvers();#e=null;#i=!1;#s=!!globalThis.FontInspector?.enabled;#a=null;#r=null;#n=0;#o=0;#h=null;#l=null;#u=0;#d=0;#p=Object.create(null);#m=[];#f=null;#c=[];#g=new WeakMap;#v=null;static#y=new Map;static#b=new Map;static#S=new WeakMap;static#_=null;static#w=new Set;constructor({textContentSource:t,container:e,viewport:s}){if(t instanceof ReadableStream)this.#f=t;else if(typeof t=="object")this.#f=new ReadableStream({start(o){o.enqueue(t),o.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#l=e,this.#d=s.scale*Gt.pixelRatio,this.#u=s.rotation,this.#r={div:null,properties:null,ctx:null};const{pageWidth:i,pageHeight:r,pageX:n,pageY:a}=s.rawDims;this.#v=[1,0,0,-1,-n,a+r],this.#o=i,this.#n=r,St.#P(),ae(e,s),this.#t.promise.finally(()=>{St.#w.delete(this),this.#r=null,this.#p=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=At.platform;return Y(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{this.#h.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#a??=e.lang,Object.assign(this.#p,e.styles),this.#T(e.items),t()},this.#t.reject)};return this.#h=this.#f.getReader(),St.#w.add(this),t(),this.#t.promise}update({viewport:t,onBefore:e=null}){const s=t.scale*Gt.pixelRatio,i=t.rotation;if(i!==this.#u&&(e?.(),this.#u=i,ae(this.#l,{rotation:i})),s!==this.#d){e?.(),this.#d=s;const r={div:null,properties:null,ctx:St.#M(this.#a)};for(const n of this.#c)r.properties=this.#g.get(n),r.div=n,this.#E(r)}}cancel(){const t=new ie("TextLayer task cancelled.");this.#h?.cancel(t).catch(()=>{}),this.#h=null,this.#t.reject(t)}get textDivs(){return this.#c}get textContentItemsStr(){return this.#m}#T(t){if(this.#i)return;this.#r.ctx??=St.#M(this.#a);const e=this.#c,s=this.#m;for(const i of t){if(e.length>Wn){j("Ignoring additional textDivs for performance reasons."),this.#i=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){const r=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id&&this.#e.setAttribute("id",`${i.id}`),r.append(this.#e)}else i.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(i.str),this.#x(i)}}#x(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#c.push(e);const i=F.transform(this.#v,t.transform);let r=Math.atan2(i[1],i[0]);const n=this.#p[t.fontName];n.vertical&&(r+=Math.PI/2);let a=this.#s&&n.fontSubstitution||n.fontFamily;a=St.fontFamilyMap.get(a)||a;const o=Math.hypot(i[2],i[3]),h=o*St.#N(a,n,this.#a);let c,d;r===0?(c=i[4],d=i[5]-h):(c=i[4]+h*Math.sin(r),d=i[5]-h*Math.cos(r));const u="calc(var(--total-scale-factor) *",p=e.style;this.#e===this.#l?(p.left=`${(100*c/this.#o).toFixed(2)}%`,p.top=`${(100*d/this.#n).toFixed(2)}%`):(p.left=`${u}${c.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(St.#_*o).toFixed(2)}px)`,p.fontFamily=a,s.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#s&&(e.dataset.fontName=n.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const f=Math.abs(t.transform[0]),m=Math.abs(t.transform[3]);f!==m&&Math.max(f,m)/Math.min(f,m)>1.5&&(g=!0)}if(g&&(s.canvasWidth=n.vertical?t.height:t.width),this.#g.set(e,s),this.#r.div=e,this.#r.properties=s,this.#E(this.#r),s.hasText&&this.#e.append(e),s.hasEOL){const f=document.createElement("br");f.setAttribute("role","presentation"),this.#e.append(f)}}#E(t){const{div:e,properties:s,ctx:i}=t,{style:r}=e;let n="";if(St.#_>1&&(n=`scale(${1/St.#_})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:a}=r,{canvasWidth:o,fontSize:h}=s;St.#k(i,h*this.#d,a);const{width:c}=i.measureText(e.textContent);c>0&&(n=`scaleX(${o*this.#d/c}) ${n}`)}s.angle!==0&&(n=`rotate(${s.angle}deg) ${n}`),n.length>0&&(r.transform=n)}static cleanup(){if(!(this.#w.size>0)){this.#y.clear();for(const{canvas:t}of this.#b.values())t.remove();this.#b.clear()}}static#M(t=null){let e=this.#b.get(t||="");if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#b.set(t,e),this.#S.set(e,{size:0,family:""})}return e}static#k(t,e,s){const i=this.#S.get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)}static#P(){if(this.#_!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#_=t.getBoundingClientRect().height,t.remove()}static#N(t,e,s){const i=this.#y.get(t);if(i)return i;const r=this.#M(s);r.canvas.width=r.canvas.height=ji,this.#k(r,ji,t);const n=r.measureText(""),a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let h=.8;return a?h=a/(a+o):(At.platform.isFirefox&&j("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.descent)),this.#y.set(t,h),h}}const qn=100;function hi(l={}){typeof l=="string"||l instanceof URL?l={url:l}:(l instanceof ArrayBuffer||ArrayBuffer.isView(l))&&(l={data:l});const t=new ci,{docId:e}=t,s=l.url?tn(l.url):null,i=l.data?en(l.data):null,r=l.httpHeaders||null,n=l.withCredentials===!0,a=l.password??null,o=l.range instanceof di?l.range:null,h=Number.isInteger(l.rangeChunkSize)&&l.rangeChunkSize>0?l.rangeChunkSize:2**16;let c=l.worker instanceof gs?l.worker:null;const d=l.verbosity,u=typeof l.docBaseUrl=="string"&&!Xe(l.docBaseUrl)?l.docBaseUrl:null,p=ss(l.cMapUrl),g=l.cMapPacked!==!1,f=l.CMapReaderFactory||(Pt?hn:Pi),m=ss(l.iccUrl),v=ss(l.standardFontDataUrl),y=l.StandardFontDataFactory||(Pt?cn:Mi),b=ss(l.wasmUrl),w=l.WasmFactory||(Pt?dn:Di),A=l.stopAtErrors!==!0,x=Number.isInteger(l.maxImageSize)&&l.maxImageSize>-1?l.maxImageSize:-1,_=l.isEvalSupported!==!1,E=typeof l.isOffscreenCanvasSupported=="boolean"?l.isOffscreenCanvasSupported:!Pt,S=typeof l.isImageDecoderSupported=="boolean"?l.isImageDecoderSupported:!Pt&&(At.platform.isFirefox||!globalThis.chrome),C=Number.isInteger(l.canvasMaxAreaInBytes)?l.canvasMaxAreaInBytes:-1,T=typeof l.disableFontFace=="boolean"?l.disableFontFace:Pt,R=l.fontExtraProperties===!0,D=l.enableXfa===!0,L=l.ownerDocument||globalThis.document,U=l.disableRange===!0,P=l.disableStream===!0,M=l.disableAutoFetch===!0,B=l.pdfBug===!0,K=l.CanvasFactory||(Pt?ln:nn),rt=l.FilterFactory||(Pt?on:an),ht=l.enableHWA===!0,Z=l.useWasm!==!1,G=o?o.length:l.length??NaN,Tt=typeof l.useSystemFonts=="boolean"?l.useSystemFonts:!Pt&&!T,ct=typeof l.useWorkerFetch=="boolean"?l.useWorkerFetch:!!(f===Pi&&y===Mi&&w===Di&&p&&v&&b&&Fe(p,document.baseURI)&&Fe(v,document.baseURI)&&Fe(b,document.baseURI)),O=null;Or(d);const k={canvasFactory:new K({ownerDocument:L,enableHWA:ht}),filterFactory:new rt({docId:e,ownerDocument:L}),cMapReaderFactory:ct?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:ct?null:new y({baseUrl:v}),wasmFactory:ct?null:new w({baseUrl:b})};c||(c=gs.create({verbosity:d,port:se.workerPort}),t._worker=c);const I={docId:e,apiVersion:"5.4.296",data:i,password:a,disableAutoFetch:M,rangeChunkSize:h,length:G,docBaseUrl:u,enableXfa:D,evaluatorOptions:{maxImageSize:x,disableFontFace:T,ignoreErrors:A,isEvalSupported:_,isOffscreenCanvasSupported:E,isImageDecoderSupported:S,canvasMaxAreaInBytes:C,fontExtraProperties:R,useSystemFonts:Tt,useWasm:Z,useWorkerFetch:ct,cMapUrl:p,iccUrl:m,standardFontDataUrl:v,wasmUrl:b}},V={ownerDocument:L,pdfBug:B,styleElement:O,loadingParams:{disableAutoFetch:M,enableXfa:D}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const et=c.messageHandler.sendWithPromise("GetDocRequest",I,i?[i.buffer]:null);let $;if(o)$=new Pn(o,{disableRange:U,disableStream:P});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");const st=Fe(s)?In:Pt?jn:Bn;$=new st({url:s,length:G,httpHeaders:r,withCredentials:n,rangeChunkSize:h,disableRange:U,disableStream:P})}return et.then(st=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const dt=new je(e,st,c.port),Bt=new Kn(dt,t,$,V,k,ht);t._transport=Bt,dt.send("Ready",null)})}).catch(t._capability.reject),t}class ci{static#t=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${ci.#t++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class di{#t=Promise.withResolvers();#e=[];#i=[];#s=[];#a=[];constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}addRangeListener(t){this.#a.push(t)}addProgressListener(t){this.#s.push(t)}addProgressiveReadListener(t){this.#i.push(t)}addProgressiveDoneListener(t){this.#e.push(t)}onDataRange(t,e){for(const s of this.#a)s(t,e)}onDataProgress(t,e){this.#t.promise.then(()=>{for(const s of this.#s)s(t,e)})}onDataProgressiveRead(t){this.#t.promise.then(()=>{for(const e of this.#i)e(t)})}onDataProgressiveDone(){this.#t.promise.then(()=>{for(const t of this.#e)t()})}transportReady(){this.#t.resolve()}requestDataRange(t,e){it("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Xn{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Y(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Yn{#t=!1;constructor(t,e,s,i=!1){this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new xi:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new _r,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new qe({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Y(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:r=ee.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:u=!1,recordOperations:p=!1,operationsFilter:g=null}){this._stats?.time("Overall");const f=this._transport.getRenderingIntent(i,r,d,u),{renderingIntent:m,cacheKey:v}=f;this.#t=!1,o||=this._transport.getOptionalContentConfig(m);let y=this._intentStates.get(v);y||(y=Object.create(null),this._intentStates.set(v,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const b=!!(m&It.PRINT);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(f));const w=!!(this._pdfBug&&globalThis.StepperManager?.enabled),A=!this.recordedBBoxes&&(p||w),x=S=>{if(y.renderTasks.delete(_),A){const C=_.gfx?.dependencyTracker.take();C&&(_.stepper&&_.stepper.setOperatorBBoxes(C,_.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=C))}b&&(this.#t=!0),this.#e(),S?(_.capability.reject(S),this._abortOperatorList({intentState:y,reason:S instanceof Error?S:new Error(S)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},_=new we({callback:x,params:{canvas:e,canvasContext:t,dependencyTracker:A?new pn(e,y.operatorList.length,w):null,viewport:s,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!b,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:g});(y.renderTasks||=new Set).add(_);const E=_.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([S,C])=>{if(this.destroyed){x();return}if(this._stats?.time("Rendering"),!(C.renderingIntent&m))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:S,optionalContentConfig:C}),_.operatorListChanged()}).catch(x),E}getOperatorList({intent:t="display",annotationMode:e=ee.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){function r(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o))}const n=this._transport.getRenderingIntent(t,e,s,i,!0);let a=this._intentStates.get(n.cacheKey);a||(a=Object.create(null),this._intentStates.set(n.cacheKey,a));let o;return a.opListReadCapability||(o=Object.create(null),o.operatorListChanged=r,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(s){return s.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>ze.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function r(){n.read().then(function({value:o,done:h}){if(h){s(a);return}a.lang??=o.lang,Object.assign(a.styles,o.styles),a.items.push(...o.items),r()},i)}const n=e.getReader(),a={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this.#t=!1,Promise.all(t)}cleanup(t=!1){this.#t=!0;const e=this.#e();return t&&e&&(this._stats&&=new xi),e}#e(){if(!this.#t||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#t=!1,!0}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#e()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:r,transfer:n}=s,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:i},n).getReader(),o=this._intentStates.get(e);o.streamReader=a;const h=()=>{a.read().then(({value:c,done:d})=>{if(d){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(c,o),h())},c=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const d of o.renderTasks)d.operatorListChanged();this.#e()}if(o.displayReadyCapability)o.displayReadyCapability.reject(c);else if(o.opListReadCapability)o.opListReadCapability.reject(c);else throw c}})};h()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof Ss){let i=qn;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new ie(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}const mt=class Ne{constructor({name:t=null,port:e=null,verbosity:s=Fr()}={}){if(Zt(this,jt),Zt(this,ce,Promise.withResolvers()),Zt(this,Kt,null),Zt(this,ne,null),Zt(this,Ae,null),this.name=t,this.destroyed=!1,this.verbosity=s,e){if(at(Ne,be).has(e))throw new Error("Cannot use more than one PDFWorker per port.");at(Ne,be).set(e,this),te(this,jt,Yi).call(this,e)}else te(this,jt,Ki).call(this)}get promise(){return at(this,ce).promise}get port(){return at(this,ne)}get messageHandler(){return at(this,Kt)}destroy(){this.destroyed=!0,at(this,Ae)?.terminate(),Ft(this,Ae,null),at(Ne,be).delete(at(this,ne)),Ft(this,ne,null),at(this,Kt)?.destroy(),Ft(this,Kt,null)}static create(t){const e=at(this,be).get(t?.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Ne(t)}static get workerSrc(){if(se.workerSrc)return se.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return Y(this,"_setupFakeWorkerGlobal",(async()=>at(this,Ue,ds)?at(this,Ue,ds):(await import(this.workerSrc)).WorkerMessageHandler)())}};ce=new WeakMap;Kt=new WeakMap;ne=new WeakMap;Ae=new WeakMap;Ks=new WeakMap;Se=new WeakMap;be=new WeakMap;jt=new WeakSet;xs=function(){at(this,ce).resolve(),at(this,Kt).send("configure",{verbosity:this.verbosity})};Yi=function(l){Ft(this,ne,l),Ft(this,Kt,new je("main","worker",l)),at(this,Kt).on("ready",()=>{}),te(this,jt,xs).call(this)};Ki=function(){if(at(mt,Se)||at(mt,Ue,ds)){te(this,jt,Oe).call(this);return}let{workerSrc:l}=mt;try{mt._isSameOrigin(window.location,l)||(l=mt._createCDNWrapper(new URL(l,window.location).href));const t=new Worker(l,{type:"module"}),e=new je("main","worker",t),s=()=>{i.abort(),e.destroy(),t.terminate(),this.destroyed?at(this,ce).reject(new Error("Worker was destroyed")):te(this,jt,Oe).call(this)},i=new AbortController;t.addEventListener("error",()=>{at(this,Ae)||s()},{signal:i.signal}),e.on("test",n=>{if(i.abort(),this.destroyed||!n){s();return}Ft(this,Kt,e),Ft(this,ne,t),Ft(this,Ae,t),te(this,jt,xs).call(this)}),e.on("ready",n=>{if(i.abort(),this.destroyed){s();return}try{r()}catch{te(this,jt,Oe).call(this)}});const r=()=>{const n=new Uint8Array;e.send("test",n,[n.buffer])};r();return}catch{Es("The worker has been disabled.")}te(this,jt,Oe).call(this)};Oe=function(){at(mt,Se)||(j("Setting up fake worker."),Ft(mt,Se,!0)),mt._setupFakeWorkerGlobal.then(l=>{if(this.destroyed){at(this,ce).reject(new Error("Worker was destroyed"));return}const t=new rn;Ft(this,ne,t);const e=`fake${Ir(mt,Ks)._++}`,s=new je(e+"_worker",e,t);l.setup(s,t),Ft(this,Kt,new je(e,e+"_worker",t)),te(this,jt,xs).call(this)}).catch(l=>{at(this,ce).reject(new Error(`Setting up fake worker failed: "${l.message}".`))})};Ue=new WeakSet;ds=function(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}};Zt(mt,Ue);Zt(mt,Ks,0);Zt(mt,Se,!1);Zt(mt,be,new WeakMap);Pt&&(Ft(mt,Se,!0),se.workerSrc||="./pdf.worker.mjs"),mt._isSameOrigin=(l,t)=>{const e=URL.parse(l);if(!e?.origin||e.origin==="null")return!1;const s=new URL(t,e);return e.origin===s.origin},mt._createCDNWrapper=l=>{const t=`await import("${l}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))},mt.fromPort=l=>{if(Vr("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!l?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return mt.create(l)};let gs=mt;class Kn{#t=new Map;#e=new Map;#i=new Map;#s=new Map;#a=null;constructor(t,e,s,i,r,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new _r,this.fontLoader=new Jr({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.wasmFactory=r.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=n,this.setupMessageHandler()}#r(t,e=null){const s=this.#t.get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return this.#t.set(t,i),i}get annotationStorage(){return Y(this,"annotationStorage",new ni)}getRenderingIntent(t,e=ee.ENABLE,s=null,i=!1,r=!1){let n=It.DISPLAY,a=$s;switch(t){case"any":n=It.ANY;break;case"display":break;case"print":n=It.PRINT;break;default:j(`getRenderingIntent - invalid intent: ${t}`)}const o=n&It.PRINT&&s instanceof cr?s:this.annotationStorage;switch(e){case ee.DISABLE:n+=It.ANNOTATIONS_DISABLE;break;case ee.ENABLE:break;case ee.ENABLE_FORMS:n+=It.ANNOTATIONS_FORMS;break;case ee.ENABLE_STORAGE:n+=It.ANNOTATIONS_STORAGE,a=o.serializable;break;default:j(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(n+=It.IS_EDITING),r&&(n+=It.OPLIST);const{ids:h,hash:c}=o.modifiedIds,d=[n,a.hash,c];return{renderingIntent:n,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:h}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#a?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of this.#e.values())t.push(s._destroy());this.#e.clear(),this.#i.clear(),this.#s.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(),St.cleanup(),this._networkStream?.cancelAllRequests(new ie("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{J(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},i.onPull=()=>{this._fullReader.read().then(function({value:r,done:n}){if(n){i.close();return}J(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{this._fullReader.cancel(r),i.ready.catch(n=>{if(!this.destroyed)throw n})}}),t.on("ReaderHeadersReady",async s=>{await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:n}=this._fullReader;return(!i||!r)&&(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=a=>{e.onProgress?.({loaded:a.loaded,total:a.total})}),{isStreamingSupported:i,isRangeSupported:r,contentLength:n}}),t.on("GetRangeReader",(s,i)=>{J(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:n,done:a}){if(a){i.close();return}J(n instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{r.cancel(n),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new Xn(s,this))}),t.on("DocException",s=>{e._capability.reject(Dt(s))}),t.on("PasswordRequest",s=>{this.#a=Promise.withResolvers();try{if(!e.onPassword)throw Dt(s);const i=r=>{r instanceof Error?this.#a.reject(r):this.#a.resolve({password:r})};e.onPassword(i,s.code)}catch(i){this.#a.reject(i)}return this.#a.promise}),t.on("DataLoaded",s=>{e.onProgress?.({loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{this.destroyed||this.#e.get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,r])=>{if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in r){const c=r.error;j(`Error during font loading: ${c}`),this.commonObjs.resolve(s,c);break}const n=new tt(r),a=this._params.pdfBug&&globalThis.FontInspector?.enabled?(c,d)=>globalThis.FontInspector.fontAdded(c,d):null,o=new Zr(n,a,r.extra,r.charProcOperatorList);this.fontLoader.bind(o).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!o.fontExtraProperties&&o.data&&o.clearData(),this.commonObjs.resolve(s,o)});break;case"CopyLocalImage":const{imageRef:h}=r;J(h,"The imageRef must be defined.");for(const c of this.#e.values())for(const[,d]of c.objs)if(d?.ref===h)return d.dataLen?(this.commonObjs.resolve(s,structuredClone(d)),d.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,r);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,r,n])=>{if(this.destroyed)return;const a=this.#e.get(i);if(!a.objs.has(s)){if(a._intentStates.size===0){n?.bitmap?.close();return}switch(r){case"Image":case"Pattern":a.objs.resolve(s,n);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{this.destroyed||e.onProgress?.({loaded:s.loaded,total:s.total})}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");const i=this[s.type];if(!i)throw new Error(`${s.type} not initialized, see the \`useWorkerFetch\` parameter.`);return i.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&j("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.#i.get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&this.#s.set(r.refStr,t);const n=new Yn(e,r,this,this._params.pdfBug);return this.#e.set(e,n),n});return this.#i.set(e,i),i}getPageIndex(t){return zs(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#r("GetFieldObjects")}hasJSActions(){return this.#r("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#r("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#r("GetOptionalContentConfig").then(e=>new kn(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#t.get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>({info:i[0],metadata:i[1]?new Cn(i[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#t.set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#e.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#t.clear(),this.filterFactory.destroy(!0),St.cleanup()}}cachedPageNumber(t){if(!zs(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return this.#s.get(e)??null}}class Qn{#t=null;onContinue=null;onError=null;constructor(t){this.#t=t}get promise(){return this.#t.capability.promise}cancel(t=0){this.#t.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#t.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#t;return t.form||t.canvas&&e?.size>0}}class we{#t=null;static#e=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:n,pageIndex:a,canvasFactory:o,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null,enableHWA:p=!1,operationsFilter:g=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=n,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=h,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Qn(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=p,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=g}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(we.#e.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");we.#e.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:i,background:r,dependencyTracker:n}=this.params,a=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new xe(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,n),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#t&&(window.cancelAnimationFrame(this.#t),this.#t=null),we.#e.delete(this._canvas),t||=new Ss(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#t=window.requestAnimationFrame(()=>{this.#t=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),we.#e.delete(this._canvas),this.callback())))}}const Er="5.4.296",Sr="f56dc8601";class Lt{#t=null;#e=null;#i;#s=null;#a=!1;#r=!1;#n=null;#o;#h=null;#l=null;static#u=null;static get _keyboardManager(){return Y(this,"_keyboardManager",new Ye([[["Escape","mac+Escape"],Lt.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Lt.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Lt.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Lt.prototype._moveToPrevious],[["Home","mac+Home"],Lt.prototype._moveToBeginning],[["End","mac+End"],Lt.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#r=!1,this.#n=t):this.#r=!0,this.#l=t?._uiManager||e,this.#o=this.#l._eventBus,this.#i=t?.color?.toUpperCase()||this.#l?.highlightColors.values().next().value||"#FFFF98",Lt.#u||=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(){const t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#n&&(t.ariaControls=`${this.#n.id}_colorpicker_dropdown`);const e=this.#l._signal;t.addEventListener("click",this.#f.bind(this),{signal:e}),t.addEventListener("keydown",this.#m.bind(this),{signal:e});const s=this.#e=document.createElement("span");return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=this.#i,t.append(s),t}renderMainDropdown(){const t=this.#s=this.#d();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#d(){const t=document.createElement("div"),e=this.#l._signal;t.addEventListener("contextmenu",Nt,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#n&&(t.id=`${this.#n.id}_colorpicker_dropdown`);for(const[s,i]of this.#l.highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",Lt.#u[s]);const n=document.createElement("span");r.append(n),n.className="swatch",n.style.backgroundColor=i,r.ariaSelected=i===this.#i,r.addEventListener("click",this.#p.bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",this.#m.bind(this),{signal:e}),t}#p(t,e){e.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:Q.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#f(t);return}const e=t.target.getAttribute("data-color");e&&this.#p(e,t)}_moveToNext(t){if(!this.#g){this.#f(t);return}if(t.target===this.#t){this.#s.firstChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#s?.firstChild||t.target===this.#t){this.#g&&this._hideDropdownFromKeyboard();return}this.#g||this.#f(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#g){this.#f(t);return}this.#s.firstChild?.focus()}_moveToEnd(t){if(!this.#g){this.#f(t);return}this.#s.lastChild?.focus()}#m(t){Lt._keyboardManager.exec(this,t)}#f(t){if(this.#g){this.hideDropdown();return}if(this.#a=t.detail===0,this.#h||(this.#h=new AbortController,window.addEventListener("pointerdown",this.#c.bind(this),{signal:this.#l.combinedSignal(this.#h)})),this.#t.ariaExpanded="true",this.#s){this.#s.classList.remove("hidden");return}const e=this.#s=this.#d();this.#t.append(e)}#c(t){this.#s?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#s?.classList.add("hidden"),this.#t.ariaExpanded="false",this.#h?.abort(),this.#h=null}get#g(){return this.#s&&!this.#s.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#r){if(!this.#g){this.#n?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#a})}}updateColor(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#s)return;const e=this.#l.highlightColors.values();for(const s of this.#s.children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#s?.remove(),this.#s=null}}class Ge{#t=null;#e=null;#i=null;static#s=null;constructor(t){this.#e=t,this.#i=t._uiManager,Ge.#s||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#t)return this.#t;const{editorType:t,colorType:e,colorValue:s}=this.#e,i=this.#t=document.createElement("input");return i.type="color",i.value=s||"#000000",i.className="basicColorPicker",i.tabIndex=0,i.setAttribute("data-l10n-id",Ge.#s[t]),i.addEventListener("input",()=>{this.#i.updateParams(e,i.value)},{signal:this.#i._signal}),i}update(t){this.#t&&(this.#t.value=t)}destroy(){this.#t?.remove(),this.#t=null}hideDropdown(){}}q(116);q(531);function Gi(l){return Math.floor(Math.max(0,Math.min(1,l))*255).toString(16).padStart(2,"0")}function Ie(l){return Math.max(0,Math.min(255,255*l))}class Vi{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Ie(t),[t,t,t]}static G_HTML([t]){const e=Gi(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(Ie)}static RGB_HTML(t){return`#${t.map(Gi).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[Ie(1-Math.min(1,t+i)),Ie(1-Math.min(1,s+i)),Ie(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,r=1-e,n=1-s,a=Math.min(i,r,n);return["CMYK",i,r,n,a]}}class Jn{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){it("Abstract method `_createSVG` called.")}}class Ve extends Jn{_createSVG(t){return document.createElementNS(Qt,t)}}const Zn=9,ue=new WeakSet,ta=new Date().getTimezoneOffset()*60*1e3;class Wi{static create(t){switch(t.data.annotationType){case ut.LINK:return new ui(t);case ut.TEXT:return new sa(t);case ut.WIDGET:switch(t.data.fieldType){case"Tx":return new ia(t);case"Btn":return t.data.radioButton?new Cr(t):t.data.checkBox?new na(t):new aa(t);case"Ch":return new oa(t);case"Sig":return new ra(t)}return new fe(t);case ut.POPUP:return new Vs(t);case ut.FREETEXT:return new Tr(t);case ut.LINE:return new ha(t);case ut.SQUARE:return new ca(t);case ut.CIRCLE:return new da(t);case ut.POLYLINE:return new kr(t);case ut.CARET:return new pa(t);case ut.INK:return new pi(t);case ut.POLYGON:return new ua(t);case ut.HIGHLIGHT:return new Pr(t);case ut.UNDERLINE:return new fa(t);case ut.SQUIGGLY:return new ga(t);case ut.STRIKEOUT:return new ma(t);case ut.STAMP:return new Mr(t);case ut.FILEATTACHMENT:return new va(t);default:return new lt(t)}}}class lt{#t=null;#e=!1;#i=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return lt._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:i}=this.data;let r=-1/0,n=-1/0;if(e?.length>=8){for(let a=0;a<e.length;a+=8)e[a+1]>n?(n=e[a+1],r=e[a+2]):e[a+1]===n&&(r=Math.max(r,e[a+2]));return[r,n]}if(s?.length>=1){for(const a of s)for(let o=0,h=a.length;o<h;o+=2)a[o+1]>n?(n=a[o+1],r=a[o]):a[o+1]===n&&(r=Math.max(r,a[o]));if(r!==1/0)return[r,n]}return i?[i[2],i[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:n}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-n)/i,t}get commentText(){const{data:t}=this;return this.annotationStorage.getRawValue(`${He}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${He}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#i?.popup||this.popup)?.remove(),this.#i=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#t||={rect:this.data.rect.slice(0)});const{rect:e,popup:s}=t;e&&this.#s(e);let i=this.#i?.popup||this.popup;!i&&s?.text&&(this._createPopup(s),i=this.#i.popup),i&&(i.updateEdited(t),s?.deleted&&(i.remove(),this.#i=null,this.popup=null))}resetEdited(){this.#t&&(this.#s(this.#t.rect),this.#i?.popup.resetEdited(),this.#t=null)}#s(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:n,pageX:a,pageY:o}}}}=this;s?.splice(0,4,...t),e.left=`${100*(t[0]-a)/r}%`,e.top=`${100*(n-t[3]+o)/n}%`,i===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/n}%`):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof fe)&&!(this instanceof ui)&&(r.tabIndex=0);const{style:n}=r;if(n.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof Vs){const{rotation:f}=e;return!e.hasOwnCanvas&&f!==0&&this.setRotation(f,r),r}const{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){n.borderWidth=`${e.borderStyle.width}px`;const f=e.borderStyle.horizontalCornerRadius,m=e.borderStyle.verticalCornerRadius;if(f>0||m>0){const y=`calc(${f}px * var(--total-scale-factor)) / calc(${m}px * var(--total-scale-factor))`;n.borderRadius=y}else if(this instanceof Cr){const y=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;n.borderRadius=y}switch(e.borderStyle.style){case me.SOLID:n.borderStyle="solid";break;case me.DASHED:n.borderStyle="dashed";break;case me.BEVELED:j("Unimplemented border style: beveled");break;case me.INSET:j("Unimplemented border style: inset");break;case me.UNDERLINE:n.borderBottomStyle="solid";break}const v=e.borderColor||null;v?(this.#e=!0,n.borderColor=F.makeHexColor(v[0]|0,v[1]|0,v[2]|0)):n.borderWidth=0}const h=F.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:p}=i.rawDims;n.left=`${100*(h[0]-u)/c}%`,n.top=`${100*(h[1]-p)/d}%`;const{rotation:g}=e;return e.hasOwnCanvas||g===0?(n.width=`${100*a/c}%`,n.height=`${100*o/d}%`):this.setRotation(g,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:r,height:n}=this;t%180!==0&&([r,n]=[n,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*n/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const r=i.detail[e],n=r[0],a=r.slice(1);i.target.style[s]=Vi[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:Vi[`${n}_rgb`](a)})};return Y(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,r]of Object.entries(e)){const n=s[i];if(n){const a={detail:{[i]:r},target:t};n(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,r]=this.data.rect.map(f=>Math.fround(f));if(t.length===8){const[f,m,v,y]=t.subarray(2,6);if(i===f&&r===m&&e===v&&s===y)return}const{style:n}=this.container;let a;if(this.#e){const{borderColor:f,borderWidth:m}=n;n.borderWidth=0,a=["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="${f}" stroke-width="${m}">`],this.container.classList.add("hasBorder")}const o=i-e,h=r-s,{svgFactory:c}=this,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";const u=c.createElement("defs");d.append(u);const p=c.createElement("clipPath"),g=`clippath_${this.data.id}`;p.setAttribute("id",g),p.setAttribute("clipPathUnits","objectBoundingBox"),u.append(p);for(let f=2,m=t.length;f<m;f+=8){const v=t[f],y=t[f+1],b=t[f+2],w=t[f+3],A=c.createElement("rect"),x=(b-e)/o,_=(r-y)/h,E=(v-b)/o,S=(y-w)/h;A.setAttribute("x",x),A.setAttribute("y",_),A.setAttribute("width",E),A.setAttribute("height",S),p.append(A),a?.push(`<rect vector-effect="non-scaling-stroke" x="${x}" y="${_}" width="${E}" height="${S}"/>`)}this.#e&&(a.push("</g></svg>')"),n.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${g})`}_createPopup(t=null){const{data:e}=this;let s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate);const r=this.#i=new Vs({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]});this.parent._commentManager||this.parent.div.append(r.render())}get hasPopupElement(){return!!(this.#i||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#i}render(){it("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:r,id:n,exportValues:a}of i){if(r===-1||n===e)continue;const o=typeof a=="string"?a:null,h=document.querySelector(`[data-element-id="${n}"]`);if(h&&!ue.has(h)){j(`_getElementsByName - element not allowed: ${n}`);continue}s.push({id:n,exportValue:o,domElement:h})}return s}for(const i of document.getElementsByName(t)){const{exportValue:r}=i,n=i.getAttribute("data-element-id");n!==e&&ue.has(i)&&s.push({id:n,exportValue:r,domElement:i})}return s}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class ea extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&(this._createPopup(t.comment),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(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}class ui extends lt{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action,t.overlaidText),i=!0):t.attachment?(this.#e(s,t.attachment,t.overlaidText,t.attachmentDest),i=!0):t.setOCGState?(this.#i(s,t.setOCGState,t.overlaidText),i=!0):t.dest?(this._bindLink(s,t.dest,t.overlaidText),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(s),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,s=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t(),s&&(t.title=s)}_bindNamedAction(t,e,s=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),s&&(t.title=s),this.#t()}#e(t,e,s="",i=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:s&&(t.title=s),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#t()}#i(t,e,s=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),s&&(t.title=s),this.#t()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const r=s.get(i);r&&(t[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#t()}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){j('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();const{fields:i,refs:r,include:n}=e,a=[];if(i.length!==0||r.length!==0){const c=new Set(r);for(const d of i){const u=this._fieldObjects[d]||[];for(const{id:p}of u)c.add(p)}for(const d of Object.values(this._fieldObjects))for(const u of d)c.has(u.id)===n&&a.push(u)}else for(const c of Object.values(this._fieldObjects))a.push(...c);const o=this.annotationStorage,h=[];for(const c of a){const{id:d}=c;switch(h.push(d),c.type){case"text":{const p=c.defaultValue||"";o.setValue(d,{value:p});break}case"checkbox":case"radiobutton":{const p=c.defaultValue===c.exportValues;o.setValue(d,{value:p});break}case"combobox":case"listbox":{const p=c.defaultValue||"";o.setValue(d,{value:p});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!ue.has(u)){j(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}}class sa extends lt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class fe extends lt{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return At.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,r){s.includes("mouse")?t.addEventListener(s,n=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(n),shift:n.shiftKey,modifier:this._getKeyModifier(n)}})}):t.addEventListener(s,n=>{if(s==="blur"){if(!e.focused||!n.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(n)}})})}_setEventListeners(t,e,s,i){for(const[r,n]of s)(n==="Action"||this.data.actions?.[n])&&((n==="Focus"||n==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,r,n,i),n==="Focus"&&!this.data.actions?.Blur?this._setEventListener(t,e,"blur","Blur",null):n==="Blur"&&!this.data.actions?.Focus&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":F.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||Zn,r=t.style;let n;const a=2,o=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-a),c=Math.round(h/(Ms*i))||1,d=h/c;n=Math.min(i,o(d/Ms))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-a);n=Math.min(i,o(h/Ms))}r.fontSize=`calc(${n}px * var(--total-scale-factor))`,r.color=F.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class ia extends fe{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const r=this.annotationStorage;for(const n of this._getElementsByName(t.name,t.id))n.domElement&&(n.domElement[e]=s),r.setValue(n.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let r=i.value||"";const n=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;n&&r.length>n&&(r=r.slice(0,n));let a=i.formattedValue||this.data.textContent?.join(`
5
+ `)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:r,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=a??r,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",a??r),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),ue.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:h,datetimeType:c,timeStep:d}=this.data,u=!!c&&this.enableScripting;h&&(s.title=h),this._setRequired(s,this.data.required),n&&(s.maxLength=n),s.addEventListener("input",g=>{t.setValue(e,{value:g.target.value}),this.setPropertyOnSiblings(s,"value",g.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",g=>{const f=this.data.defaultFieldValue??"";s.value=o.userValue=f,o.formattedValue=null});let p=g=>{const{formattedValue:f}=o;f!=null&&(g.target.value=f),g.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",f=>{if(o.focused)return;const{target:m}=f;if(u&&(m.type=c,d&&(m.step=d)),o.userValue){const v=o.userValue;if(u)if(c==="time"){const y=new Date(v),b=[y.getHours(),y.getMinutes(),y.getSeconds()];m.value=b.map(w=>w.toString().padStart(2,"0")).join(":")}else m.value=new Date(v-ta).toISOString().split(c==="date"?"T":".",1)[0];else m.value=v}o.lastCommittedValue=m.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),s.addEventListener("updatefromsandbox",f=>{this.showElementAndHideCanvas(f.target);const m={value(v){o.userValue=v.detail.value??"",u||t.setValue(e,{value:o.userValue.toString()}),v.target.value=o.userValue},formattedValue(v){const{formattedValue:y}=v.detail;o.formattedValue=y,y!=null&&v.target!==document.activeElement&&(v.target.value=y);const b={formattedValue:y};u&&(b.value=y),t.setValue(e,b)},selRange(v){v.target.setSelectionRange(...v.detail.selRange)},charLimit:v=>{const{charLimit:y}=v.detail,{target:b}=v;if(y===0){b.removeAttribute("maxLength");return}b.setAttribute("maxLength",y);let w=o.userValue;!w||w.length<=y||(w=w.slice(0,y),b.value=o.userValue=w,t.setValue(e,{value:w}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,willCommit:!0,commitKey:1,selStart:b.selectionStart,selEnd:b.selectionEnd}}))}};this._dispatchEventFromSandbox(m,f)}),s.addEventListener("keydown",f=>{o.commitKey=1;let m=-1;if(f.key==="Escape"?m=0:f.key==="Enter"&&!this.data.multiLine?m=2:f.key==="Tab"&&(o.commitKey=3),m===-1)return;const{value:v}=f.target;o.lastCommittedValue!==v&&(o.lastCommittedValue=v,o.userValue=v,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:m,selStart:f.target.selectionStart,selEnd:f.target.selectionEnd}}))});const g=p;p=null,s.addEventListener("blur",f=>{if(!o.focused||!f.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{target:m}=f;let{value:v}=m;if(u){if(v&&c==="time"){const y=v.split(":").map(b=>parseInt(b,10));v=new Date(2e3,0,1,y[0],y[1],y[2]||0).valueOf(),m.step=""}else v.includes("T")||(v=`${v}T00:00`),v=new Date(v).valueOf();m.type="text"}o.userValue=v,o.lastCommittedValue!==v&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:o.commitKey,selStart:f.target.selectionStart,selEnd:f.target.selectionEnd}}),g(f)}),this.data.actions?.Keystroke&&s.addEventListener("beforeinput",f=>{o.lastCommittedValue=null;const{data:m,target:v}=f,{value:y,selectionStart:b,selectionEnd:w}=v;let A=b,x=w;switch(f.inputType){case"deleteWordBackward":{const _=y.substring(0,b).match(/\w*[^\w]*$/);_&&(A-=_[0].length);break}case"deleteWordForward":{const _=y.substring(b).match(/^[^\w]*\w*/);_&&(x+=_[0].length);break}case"deleteContentBackward":b===w&&(A-=1);break;case"deleteContentForward":b===w&&(x+=1);break}f.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:y,change:m||"",willCommit:!1,selStart:A,selEnd:x}})}),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],f=>f.target.value)}if(p&&s.addEventListener("blur",p),this.data.comb){const g=(this.data.rect[2]-this.data.rect[0])/n;s.classList.add("comb"),s.style.letterSpacing=`calc(${g}px * var(--total-scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class ra extends fe{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class na extends fe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return ue.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",n=>{const{name:a,checked:o}=n.target;for(const h of this._getElementsByName(a,s)){const c=o&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(s,{value:o})}),r.addEventListener("resetform",n=>{const a=e.defaultFieldValue||"Off";n.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",n=>{const a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,n)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],n=>n.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class Cr extends fe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const n of this._getElementsByName(e.fieldName,s))t.setValue(n.id,{value:!1});const r=document.createElement("input");if(ue.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",n=>{const{name:a,checked:o}=n.target;for(const h of this._getElementsByName(a,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:o})}),r.addEventListener("resetform",n=>{const a=e.defaultFieldValue;n.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const n=e.buttonValue;r.addEventListener("updatefromsandbox",a=>{const o={value:h=>{const c=n===h.detail.value;for(const d of this._getElementsByName(h.target.name)){const u=c&&d.id===s;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class aa extends ui{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class oa extends fe{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");ue.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",c=>{const d=this.data.defaultFieldValue;for(const u of i.options)u.selected=u.value===d});for(const c of this.data.options){const d=document.createElement("option");d.textContent=c.displayValue,d.value=c.exportValue,s.value.includes(c.exportValue)&&(d.setAttribute("selected",!0),r=!1),i.append(d)}let n=null;if(r){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),n=()=>{c.remove(),i.removeEventListener("input",n),n=null},i.addEventListener("input",n)}const a=c=>{const d=c?"value":"textContent",{options:u,multiple:p}=i;return p?Array.prototype.filter.call(u,g=>g.selected).map(g=>g[d]):u.selectedIndex===-1?null:u[u.selectedIndex][d]};let o=a(!1);const h=c=>{const d=c.target.options;return Array.prototype.map.call(d,u=>({displayValue:u.textContent,exportValue:u.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{const d={value(u){n?.();const p=u.detail.value,g=new Set(Array.isArray(p)?p:[p]);for(const f of i.options)f.selected=g.has(f.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(u){i.multiple=!0},remove(u){const p=i.options,g=u.detail.remove;p[g].selected=!1,i.remove(g),p.length>0&&Array.prototype.findIndex.call(p,f=>f.selected)===-1&&(p[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},clear(u){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(u){const{index:p,displayValue:g,exportValue:f}=u.detail.insert,m=i.children[p],v=document.createElement("option");v.textContent=g,v.value=f,m?m.before(v):i.append(v),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},items(u){const{items:p}=u.detail;for(;i.length!==0;)i.remove(0);for(const g of p){const{displayValue:f,exportValue:m}=g,v=document.createElement("option");v.textContent=f,v.value=m,i.append(v)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:a(!0),items:h(u)}),o=a(!1)},indices(u){const p=new Set(u.detail.indices);for(const g of u.target.options)g.selected=p.has(g.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(d,c)}),i.addEventListener("input",c=>{const d=a(!0),u=a(!1);t.setValue(e,{value:d}),c.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:u,changeEx:d,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],c=>c.target.value)):i.addEventListener("input",function(c){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Vs extends lt{constructor(t){const{data:e,elements:s,parent:i}=t,r=!!i._commentManager;if(super(t,{isRenderable:!r&&lt._hasPopupData(e)}),this.elements=s,r&&lt._hasPopupData(e)){const n=this.popup=this.#t();for(const a of s)a.popup=n}else this.popup=null}#t(){return new la({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(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=this.#t(),s=[];for(const i of this.elements)i.popup=e,i.container.ariaHasPopup="dialog",s.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",s.map(i=>`${ti}${i}`).join(",")),this.container}}class la{#t=null;#e=this.#G.bind(this);#i=this.#U.bind(this);#s=this.#I.bind(this);#a=this.#A.bind(this);#r=null;#n=null;#o=null;#h=null;#l=null;#u=null;#d=null;#p=!1;#m=null;#f=null;#c=null;#g=null;#v=null;#y=null;#b=null;#S=null;#_=null;#w=null;#T=!1;#x=null;#E=null;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:n,richText:a,parent:o,rect:h,parentRect:c,open:d,commentManager:u=null}){this.#n=t,this.#_=i,this.#o=n,this.#S=a,this.#u=o,this.#r=e,this.#b=h,this.#d=c,this.#l=s,this.#t=u,this.#x=s[0],this.#h=Ce.toDateObject(r),this.trigger=s.flatMap(p=>p.getElementsToTriggerPopup()),u?this.renderCommentButton():(this.#M(),this.#n.hidden=!0,d&&this.#A())}#M(){if(this.#f)return;this.#f=new AbortController;const{signal:t}=this.#f;for(const e of this.trigger)e.addEventListener("click",this.#a,{signal:t}),e.addEventListener("pointerenter",this.#s,{signal:t}),e.addEventListener("pointerleave",this.#i,{signal:t}),e.classList.add("popupTriggerArea");for(const e of this.#l)e.container?.addEventListener("keydown",this.#e,{signal:t})}#k(){const t=this.#l.find(e=>e.hasCommentButton);t&&(this.#v=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#g||(this.#v||this.#k(),!this.#v))return;const{signal:t}=this.#f=new AbortController,e=!!this.#x.extraPopupElement,s=()=>{this.#t.toggleCommentPopup(this,!0,void 0,!e)},i=()=>{this.#t.toggleCommentPopup(this,!1,!0,!e)},r=()=>{this.#t.toggleCommentPopup(this,!1,!1)};if(e){this.#g=this.#x.container;for(const n of this.trigger)n.ariaHasPopup="dialog",n.ariaControls="commentPopup",n.addEventListener("keydown",this.#e,{signal:t}),n.addEventListener("click",s,{signal:t}),n.addEventListener("pointerenter",i,{signal:t}),n.addEventListener("pointerleave",r,{signal:t}),n.classList.add("popupTriggerArea")}else{const n=this.#g=document.createElement("button");n.className="annotationCommentButton";const a=this.#x.container;n.style.zIndex=a.style.zIndex+1,n.tabIndex=0,n.ariaHasPopup="dialog",n.ariaControls="commentPopup",n.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#N(),this.#P(),n.addEventListener("keydown",this.#e,{signal:t}),n.addEventListener("click",s,{signal:t}),n.addEventListener("pointerenter",i,{signal:t}),n.addEventListener("pointerleave",r,{signal:t}),a.after(n)}}#P(){if(this.#x.extraPopupElement&&!this.#x.editor)return;this.renderCommentButton();const[t,e]=this.#v,{style:s}=this.#g;s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`}#N(){this.#x.extraPopupElement||(this.renderCommentButton(),this.#g.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){const{color:t,opacity:e}=this.#x.commentData;return t?this.#u._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#g?.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}=this.#x.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}}get elementBeforePopup(){return this.#g}get comment(){return this.#E||=this.#x.commentText,this.#E}set comment(t){t!==this.comment&&(this.#x.commentText=this.#E=t)}get parentBoundingClientRect(){return this.#x.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#g&&(this.#g.classList.toggle("selected",t),this.#g.ariaExpanded=e)}setSelectedCommentButton(t){this.#g.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#y)return this.#y;const{x:t,y:e,height:s}=this.#g.getBoundingClientRect(),{x:i,y:r,width:n,height:a}=this.#x.layer.getBoundingClientRect();return[(t-i)/n,(e+s-r)/a]}set commentPopupPosition(t){this.#y=t}hasDefaultPopupPosition(){return this.#y===null}get commentButtonPosition(){return this.#v}get commentButtonWidth(){return this.#g.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=this.#y||this.commentButtonPosition.map(h=>h/100),i=this.parentBoundingClientRect,{x:r,y:n,width:a,height:o}=i;this.#t.showDialog(null,this,r+e*a,n+s*o,{...t,parentDimensions:i})}render(){if(this.#m)return;const t=this.#m=document.createElement("div");if(t.className="popup",this.#r){const s=t.style.outlineColor=F.makeHexColor(...this.#r);t.style.backgroundColor=`color-mix(in srgb, ${s} 30%, white)`}const e=document.createElement("span");if(e.className="header",this.#_?.str){const s=document.createElement("span");s.className="title",e.append(s),{dir:s.dir,str:s.textContent}=this.#_}if(t.append(e),this.#h){const s=document.createElement("time");s.className="popupDate",s.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),s.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#h.valueOf()})),s.dateTime=this.#h.toISOString(),e.append(s)}si({html:this.#R||this.#o.str,dir:this.#o?.dir,className:"popupContent"},t),this.#n.append(t)}get#R(){const t=this.#S,e=this.#o;return t?.str&&(!e?.str||e.str===t.str)&&this.#S.html||null}get#L(){return this.#R?.attributes?.style?.fontSize||0}get#B(){return this.#R?.attributes?.style?.color||null}#O(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#B,fontSize:this.#L?`calc(${this.#L}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
6
+ `))e.push({name:"span",value:r,attributes:i});return s}#G(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#p)&&this.#A()}updateEdited({rect:t,popup:e,deleted:s}){if(this.#t){s?(this.remove(),this.#E=null):e&&(e.deleted?this.remove():(this.#N(),this.#E=e.text)),t&&(this.#v=null,this.#k(),this.#P());return}if(s||e?.deleted){this.remove();return}this.#M(),this.#w||={contentsObj:this.#o,richText:this.#S},t&&(this.#c=null),e&&e.text&&(this.#S=this.#O(e.text),this.#h=Ce.toDateObject(e.date),this.#o=null),this.#m?.remove(),this.#m=null}resetEdited(){this.#w&&({contentsObj:this.#o,richText:this.#S}=this.#w,this.#w=null,this.#m?.remove(),this.#m=null,this.#c=null)}remove(){if(this.#f?.abort(),this.#f=null,this.#m?.remove(),this.#m=null,this.#T=!1,this.#p=!1,this.#g?.remove(),this.#g=null,this.trigger)for(const t of this.trigger)t.classList.remove("popupTriggerArea")}#C(){if(this.#c!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=this.#u;let n=!!this.#d,a=n?this.#d:this.#b;for(const p of this.#l)if(!a||F.intersect(p.data.rect,a)!==null){a=p.data.rect,n=!0;break}const o=F.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),h=n?a[2]-a[0]+5:0,c=o[0]+h,d=o[1];this.#c=[100*(c-i)/e,100*(d-r)/s];const{style:u}=this.#n;u.left=`${this.#c[0]}%`,u.top=`${this.#c[1]}%`}#A(){if(this.#t){this.#t.toggleCommentPopup(this,!1);return}this.#p=!this.#p,this.#p?(this.#I(),this.#n.addEventListener("click",this.#a),this.#n.addEventListener("keydown",this.#e)):(this.#U(),this.#n.removeEventListener("click",this.#a),this.#n.removeEventListener("keydown",this.#e))}#I(){this.#m||this.render(),this.isVisible?this.#p&&this.#n.classList.add("focused"):(this.#C(),this.#n.hidden=!1,this.#n.style.zIndex=parseInt(this.#n.style.zIndex)+1e3)}#U(){this.#n.classList.remove("focused"),!(this.#p||!this.isVisible)&&(this.#n.hidden=!0,this.#n.style.zIndex=parseInt(this.#n.style.zIndex)-1e3)}forceHide(){this.#T=this.isVisible,this.#T&&(this.#n.hidden=!0)}maybeShow(){this.#t||(this.#M(),this.#T&&(this.#m||this.#I(),this.#T=!1,this.#n.hidden=!1))}get isVisible(){return this.#t?!1:this.#n.hidden===!1}}class Tr extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=W.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class ha extends lt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),r=this.#t=this.svgFactory.createElement("svg:line");return r.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),r.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),r.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),r.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),r.setAttribute("stroke-width",t.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class ca extends lt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),r=t.borderStyle.width,n=this.#t=this.svgFactory.createElement("svg:rect");return n.setAttribute("x",r/2),n.setAttribute("y",r/2),n.setAttribute("width",e-r),n.setAttribute("height",s-r),n.setAttribute("stroke-width",r||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class da extends lt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),r=t.borderStyle.width,n=this.#t=this.svgFactory.createElement("svg:ellipse");return n.setAttribute("cx",e/2),n.setAttribute("cy",s/2),n.setAttribute("rx",e/2-r/2),n.setAttribute("ry",s/2-r/2),n.setAttribute("stroke-width",r||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class kr extends lt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:s,popupRef:i},width:r,height:n}=this;if(!e)return this.container;const a=this.svgFactory.create(r,n,!0);let o=[];for(let c=0,d=e.length;c<d;c+=2){const u=e[c]-t[0],p=t[3]-e[c+1];o.push(`${u},${p}`)}o=o.join(" ");const h=this.#t=this.svgFactory.createElement(this.svgElementName);return h.setAttribute("points",o),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),a.append(h),this.container.append(a),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class ua extends kr{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class pa extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class pi extends lt{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?W.HIGHLIGHT:W.INK}#i(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:r}}=this,{transform:n,width:a,height:o}=this.#i(e,t),h=this.svgFactory.create(a,o,!0),c=this.#t=this.svgFactory.createElement("svg:g");h.append(c),c.setAttribute("stroke-width",i.width||1),c.setAttribute("stroke-linecap","round"),c.setAttribute("stroke-linejoin","round"),c.setAttribute("stroke-miterlimit",10),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),c.setAttribute("transform",n);for(let d=0,u=s.length;d<u;d++){const p=this.svgFactory.createElement(this.svgElementName);this.#e.push(p),p.setAttribute("points",s[d].join(",")),c.append(p)}return!r&&this.hasPopupData&&this._createPopup(),this.container.append(h),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:s,rect:i}=t,r=this.#t;if(e>=0&&r.setAttribute("stroke-width",e||1),s)for(let n=0,a=this.#e.length;n<a;n++)this.#e[n].setAttribute("points",s[n].join(","));if(i){const{transform:n,width:a,height:o}=this.#i(this.data.rotation,i);r.parentElement.setAttribute("viewBox",`0 0 ${a} ${o}`),r.setAttribute("transform",n)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class Pr extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=W.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class fa extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class ga extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class ma extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){const s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Mr extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=W.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class va extends lt{#t=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let s;e.hasAppearance||e.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;const{isMac:i}=At.platform;return t.addEventListener("keydown",r=>{r.key==="Enter"&&(i?r.metaKey:r.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}#e(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class ks{#t=null;#e=null;#i=null;#s=new Map;#a=null;#r=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:n,structTreeLayer:a,commentManager:o,linkService:h,annotationStorage:c}){this.div=t,this.#t=e,this.#e=s,this.#a=a||null,this.#r=h||null,this.#i=c||new ni,this.page=r,this.viewport=n,this.zIndex=0,this._annotationEditorUIManager=i,this._commentManager=o||null}hasEditableAnnotations(){return this.#s.size>0}async#n(t,e,s){const i=t.firstChild||t,r=i.id=`${ti}${e}`,n=await this.#a?.getAriaAttributes(r);if(n)for(const[a,o]of n)i.setAttribute(a,o);s?s.at(-1).container.after(t):(this.div.append(t),this.#t?.moveElementInDOM(this.div,t,i,!1))}async render(t){const{annotations:e}=t,s=this.div;ae(s,this.viewport);const i=new Map,r={data:null,layer:s,linkService:this.#r,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Ve,annotationStorage:this.#i,enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const n of e){if(n.noHTML)continue;const a=n.annotationType===ut.POPUP;if(a){const c=i.get(n.id);if(!c)continue;r.elements=c}else if(n.rect[2]===n.rect[0]||n.rect[3]===n.rect[1])continue;r.data=n;const o=Wi.create(r);if(!o.isRenderable)continue;if(!a&&n.popupRef){const c=i.get(n.popupRef);c?c.push(o):i.set(n.popupRef,[o])}const h=o.render();n.hidden&&(h.style.visibility="hidden"),await this.#n(h,n.id,r.elements),o.extraPopupElement?.popup?.renderCommentButton(),o._isEditable&&(this.#s.set(o.data.id,o),this._annotationEditorUIManager?.renderAnnotationElement(o))}this.#o()}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:this.#r,svgFactory:new Ve,parent:this};for(const s of t){s.borderStyle||=ks._defaultBorderStyle,e.data=s;const i=Wi.create(e);if(!i.isRenderable)continue;const r=i.render();await this.#n(r,s.id,null)}}update({viewport:t}){const e=this.div;this.viewport=t,ae(e,{rotation:t.rotation}),this.#o(),e.hidden=!1}#o(){if(!this.#e)return;const t=this.div;for(const[e,s]of this.#e){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:r}=i;r?r.nodeName==="CANVAS"?r.replaceWith(s):r.classList.contains("annotationContent")?r.after(s):r.before(s):i.append(s);const n=this.#s.get(e);n&&(n._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,i.id,s),n._hasNoCanvas=!1):n.canvas=s)}this.#e.clear()}getEditableAnnotations(){return Array.from(this.#s.values())}getEditableAnnotation(t){return this.#s.get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:i}=t,r=new ea({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#r,annotationStorage:this.#i}),n=r.render();return e.append(n),this.#t?.moveElementInDOM(e,n,n,!1),r.createOrUpdatePopup(),r}static get _defaultBorderStyle(){return Y(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:me.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const ls=/\r\n?|\n/g;class vt extends H{#t="";#e=`${this.id}-editor`;#i=null;#s;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=vt.prototype,e=r=>r.isEmpty(),s=re.TRANSLATE_SMALL,i=re.TRANSLATE_BIG;return Y(this,"_keyboardManager",new Ye([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=W.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||vt._defaultColor||H._defaultLineColor,this.#s=t.fontSize||vt._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static initialize(t,e){H.initialize(t,e);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case Q.FREETEXT_SIZE:vt._defaultFontSize=e;break;case Q.FREETEXT_COLOR:vt._defaultColor=e;break}}updateParams(t,e){switch(t){case Q.FREETEXT_SIZE:this.#a(e);break;case Q.FREETEXT_COLOR:this.#r(e);break}}static get defaultPropertiesToUpdate(){return[[Q.FREETEXT_SIZE,vt._defaultFontSize],[Q.FREETEXT_COLOR,vt._defaultColor||H._defaultLineColor]]}get propertiesToUpdate(){return[[Q.FREETEXT_SIZE,this.#s],[Q.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new Ge(this),[["colorPicker",this._colorPicker]]}get colorType(){return Q.FREETEXT_COLOR}#a(t){const e=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--total-scale-factor))`,this.translate(0,-(i-this.#s)*this.parentScale),this.#s=i,this.#o()},s=this.#s;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Q.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#r(t){const e=i=>{this.color=i,this.onUpdatedColor()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Q.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-vt._internalPadding*t,-(vt._internalPadding+this.#s)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#i=new AbortController;const t=this._uiManager.combinedSignal(this.#i);return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#e),this._isDraggable=!0,this.#i?.abort(),this.#i=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#n(){const t=[];this.editorDiv.normalize();let e=null;for(const s of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR"||(t.push(vt.#h(s)),e=s);return t.join(`
7
+ `)}#o(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:i,div:r}=this,n=r.style.display,a=r.classList.contains("hidden");r.classList.remove("hidden"),r.style.display="hidden",i.div.append(this.div),s=r.getBoundingClientRect(),r.remove(),r.style.display=n,r.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#t,e=this.#t=this.#n().trimEnd();if(t===e)return;const s=i=>{if(this.#t=i,!i){this.remove();return}this.#l(),this._uiManager.rebuild(this),this.#o()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#o()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){vt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#e),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#s}px * var(--total-scale-factor))`,s.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,r]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);const[h,c]=this.pageDimensions,[d,u]=this.pageTranslation;let p,g;switch(this.rotation){case 0:p=t+(n[0]-d)/h,g=e+this.height-(n[1]-u)/c;break;case 90:p=t+(n[0]-d)/h,g=e-(n[1]-u)/c,[a,o]=[o,-a];break;case 180:p=t-this.width+(n[0]-d)/h,g=e-(n[1]-u)/c,[a,o]=[-a,-o];break;case 270:p=t+(n[0]-d-this.height*c)/h,g=e+(n[1]-u-this.width*h)/c,[a,o]=[-o,a];break}this.setAt(p*i,g*r,a,o)}else this._moveAfterPaste(t,e);this.#l(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#h(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(ls,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();const i=vt.#d(e.getData("text")||"").replaceAll(ls,`
8
+ `);if(!i)return;const r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();const n=r.getRangeAt(0);if(!i.includes(`
9
+ `)){n.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),r.collapseToStart();return}const{startContainer:a,startOffset:o}=n,h=[],c=[];if(a.nodeType===Node.TEXT_NODE){const p=a.parentElement;if(c.push(a.nodeValue.slice(o).replaceAll(ls,"")),p!==this.editorDiv){let g=h;for(const f of this.editorDiv.childNodes){if(f===p){g=c;continue}g.push(vt.#h(f))}}h.push(a.nodeValue.slice(0,o).replaceAll(ls,""))}else if(a===this.editorDiv){let p=h,g=0;for(const f of this.editorDiv.childNodes)g++===o&&(p=c),p.push(vt.#h(f))}this.#t=`${h.join(`
10
+ `)}${i}${c.join(`
11
+ `)}`,this.#l();const d=new Range;let u=Math.sumPrecise(h.map(p=>p.length));for(const{firstChild:p}of this.editorDiv.childNodes)if(p.nodeType===Node.TEXT_NODE){const g=p.nodeValue.length;if(u<=g){d.setStart(p,u),d.setEnd(p,u);break}u-=g}r.removeAllRanges(),r.addRange(d)}#l(){if(this.editorDiv.replaceChildren(),!!this.#t)for(const t of this.#t.split(`
12
+ `)){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#u(){return this.#t.replaceAll(" "," ")}static#d(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=vt._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,s){let i=null;if(t instanceof Tr){const{data:{defaultAppearanceData:{fontSize:n,fontColor:a},rect:o,rotation:h,id:c,popupRef:d,richText:u,contentsObj:p,creationDate:g,modificationDate:f},textContent:m,textPosition:v,parent:{page:{pageNumber:y}}}=t;if(!m||m.length===0)return null;i=t={annotationType:W.FREETEXT,color:Array.from(a),fontSize:n,value:m.join(`
13
+ `),position:v,pageIndex:y-1,rect:o.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:d,comment:p?.str||null,richText:u,creationDate:g,modificationDate:f}}const r=await super.deserialize(t,e,s);return r.#s=t.fontSize,r.color=F.makeHexColor(...t.color),r.#t=vt.#d(t.value),r._initialData=i,t.comment&&r.setCommentData(t),r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=H._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(t),{color:e,fontSize:this.#s,value:this.#u()});return this.addComment(s),t?(s.isCopy=!0,s):this.annotationElementId&&!this.#p(s)?null:(s.id=this.annotationElementId,s)}#p(t){const{value:e,fontSize:s,color:i,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((n,a)=>n!==i[a])||t.pageIndex!==r}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:s}=e;s.fontSize=`calc(${this.#s}px * var(--total-scale-factor))`,s.color=this.color,e.replaceChildren();for(const i of this.#t.split(`
14
+ `)){const r=document.createElement("div");r.append(i?document.createTextNode(i):document.createElement("br")),e.append(r)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#t}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class N{static PRECISION=1e-4;toSVGPath(){it("Abstract method `toSVGPath` must be implemented.")}get box(){it("Abstract getter `box` must be implemented.")}serialize(t,e){it("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a]*i,n[a+1]=s+t[a+1]*r;return n}static _rescaleAndSwap(t,e,s,i,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a+1]*i,n[a+1]=s+t[a]*r;return n}static _translate(t,e,s,i){i||=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r){switch(r){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,s,i,r,n){return[(t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+n)/6,(s+r)/2,(i+n)/2]}}class he{#t;#e=[];#i;#s;#a=[];#r=new Float32Array(18);#n;#o;#h;#l;#u;#d;#p=[];static#m=8;static#f=2;static#c=he.#m+he.#f;constructor({x:t,y:e},s,i,r,n,a=0){this.#t=s,this.#d=r*i,this.#s=n,this.#r.set([NaN,NaN,NaN,NaN,t,e],6),this.#i=a,this.#l=he.#m*i,this.#h=he.#c*i,this.#u=i,this.#p.push(t,e)}isEmpty(){return isNaN(this.#r[8])}#g(){const t=this.#r.subarray(4,6),e=this.#r.subarray(16,18),[s,i,r,n]=this.#t;return[(this.#n+(t[0]-e[0])/2-s)/r,(this.#o+(t[1]-e[1])/2-i)/n,(this.#n+(e[0]-t[0])/2-s)/r,(this.#o+(e[1]-t[1])/2-i)/n]}add({x:t,y:e}){this.#n=t,this.#o=e;const[s,i,r,n]=this.#t;let[a,o,h,c]=this.#r.subarray(8,12);const d=t-h,u=e-c,p=Math.hypot(d,u);if(p<this.#h)return!1;const g=p-this.#l,f=g/p,m=f*d,v=f*u;let y=a,b=o;a=h,o=c,h+=m,c+=v,this.#p?.push(t,e);const w=-v/g,A=m/g,x=w*this.#d,_=A*this.#d;return this.#r.set(this.#r.subarray(2,8),0),this.#r.set([h+x,c+_],4),this.#r.set(this.#r.subarray(14,18),12),this.#r.set([h-x,c-_],16),isNaN(this.#r[6])?(this.#a.length===0&&(this.#r.set([a+x,o+_],2),this.#a.push(NaN,NaN,NaN,NaN,(a+x-s)/r,(o+_-i)/n),this.#r.set([a-x,o-_],14),this.#e.push(NaN,NaN,NaN,NaN,(a-x-s)/r,(o-_-i)/n)),this.#r.set([y,b,a,o,h,c],6),!this.isEmpty()):(this.#r.set([y,b,a,o,h,c],6),Math.abs(Math.atan2(b-o,y-a)-Math.atan2(v,m))<Math.PI/2?([a,o,h,c]=this.#r.subarray(2,6),this.#a.push(NaN,NaN,NaN,NaN,((a+h)/2-s)/r,((o+c)/2-i)/n),[a,o,y,b]=this.#r.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((y+a)/2-s)/r,((b+o)/2-i)/n),!0):([y,b,a,o,h,c]=this.#r.subarray(0,6),this.#a.push(((y+5*a)/6-s)/r,((b+5*o)/6-i)/n,((5*a+h)/6-s)/r,((5*o+c)/6-i)/n,((a+h)/2-s)/r,((o+c)/2-i)/n),[h,c,a,o,y,b]=this.#r.subarray(12,18),this.#e.push(((y+5*a)/6-s)/r,((b+5*o)/6-i)/n,((5*a+h)/6-s)/r,((5*o+c)/6-i)/n,((a+h)/2-s)/r,((o+c)/2-i)/n),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#a,e=this.#e;if(isNaN(this.#r[6])&&!this.isEmpty())return this.#v();const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#b(s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return this.#y(s),s.join(" ")}#v(){const[t,e,s,i]=this.#t,[r,n,a,o]=this.#g();return`M${(this.#r[2]-t)/s} ${(this.#r[3]-e)/i} L${(this.#r[4]-t)/s} ${(this.#r[5]-e)/i} L${r} ${n} L${a} ${o} L${(this.#r[16]-t)/s} ${(this.#r[17]-e)/i} L${(this.#r[14]-t)/s} ${(this.#r[15]-e)/i} Z`}#y(t){const e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#b(t){const[e,s,i,r]=this.#t,n=this.#r.subarray(4,6),a=this.#r.subarray(16,18),[o,h,c,d]=this.#g();t.push(`L${(n[0]-e)/i} ${(n[1]-s)/r} L${o} ${h} L${c} ${d} L${(a[0]-e)/i} ${(a[1]-s)/r}`)}newFreeDrawOutline(t,e,s,i,r,n){return new Dr(t,e,s,i,r,n)}getOutlines(){const t=this.#a,e=this.#e,s=this.#r,[i,r,n,a]=this.#t,o=new Float32Array((this.#p?.length??0)+2);for(let d=0,u=o.length-2;d<u;d+=2)o[d]=(this.#p[d]-i)/n,o[d+1]=(this.#p[d+1]-r)/a;if(o[o.length-2]=(this.#n-i)/n,o[o.length-1]=(this.#o-r)/a,isNaN(s[6])&&!this.isEmpty())return this.#S(o);const h=new Float32Array(this.#a.length+24+this.#e.length);let c=t.length;for(let d=0;d<c;d+=2){if(isNaN(t[d])){h[d]=h[d+1]=NaN;continue}h[d]=t[d],h[d+1]=t[d+1]}c=this.#w(h,c);for(let d=e.length-6;d>=6;d-=6)for(let u=0;u<6;u+=2){if(isNaN(e[d+u])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[d+u],h[c+1]=e[d+u+1],c+=2}return this.#_(h,c),this.newFreeDrawOutline(h,o,this.#t,this.#u,this.#i,this.#s)}#S(t){const e=this.#r,[s,i,r,n]=this.#t,[a,o,h,c]=this.#g(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/n,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/n,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/n,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/n],0),this.newFreeDrawOutline(d,t,this.#t,this.#u,this.#i,this.#s)}#_(t,e){const s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#w(t,e){const s=this.#r.subarray(4,6),i=this.#r.subarray(16,18),[r,n,a,o]=this.#t,[h,c,d,u]=this.#g();return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/a,(s[1]-n)/o,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(i[0]-r)/a,(i[1]-n)/o],e),e+=24}}class Dr extends N{#t;#e=new Float32Array(4);#i;#s;#a;#r;#n;constructor(t,e,s,i,r,n){super(),this.#n=t,this.#a=e,this.#t=s,this.#r=i,this.#i=r,this.#s=n,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(n);const[a,o,h,c]=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/h,t[d+1]=(t[d+1]-o)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/h,e[d+1]=(e[d+1]-o)/c}toSVGPath(){const t=[`M${this.#n[4]} ${this.#n[5]}`];for(let e=6,s=this.#n.length;e<s;e+=6){if(isNaN(this.#n[e])){t.push(`L${this.#n[e+4]} ${this.#n[e+5]}`);continue}t.push(`C${this.#n[e]} ${this.#n[e+1]} ${this.#n[e+2]} ${this.#n[e+3]} ${this.#n[e+4]} ${this.#n[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],r){const n=s-t,a=i-e;let o,h;switch(r){case 0:o=N._rescale(this.#n,t,i,n,-a),h=N._rescale(this.#a,t,i,n,-a);break;case 90:o=N._rescaleAndSwap(this.#n,t,e,n,a),h=N._rescaleAndSwap(this.#a,t,e,n,a);break;case 180:o=N._rescale(this.#n,s,e,-n,a),h=N._rescale(this.#a,s,e,-n,a);break;case 270:o=N._rescaleAndSwap(this.#n,s,i,-n,-a),h=N._rescaleAndSwap(this.#a,s,i,-n,-a);break}return{outline:Array.from(o),points:[Array.from(h)]}}#o(t){const e=this.#n;let s=e[4],i=e[5];const r=[s,i,s,i];let n=s,a=i,o=s,h=i;const c=t?Math.max:Math.min,d=new Float32Array(4);for(let p=6,g=e.length;p<g;p+=6){const f=e[p+4],m=e[p+5];isNaN(e[p])?(F.pointBoundingBox(f,m,r),a>m?(n=f,a=m):a===m&&(n=c(n,f)),h<m?(o=f,h=m):h===m&&(o=c(o,f))):(d[0]=d[1]=1/0,d[2]=d[3]=-1/0,F.bezierBoundingBox(s,i,...e.slice(p,p+6),d),F.rectBoundingBox(d[0],d[1],d[2],d[3],r),a>d[1]?(n=d[0],a=d[1]):a===d[1]&&(n=c(n,d[0])),h<d[3]?(o=d[2],h=d[3]):h===d[3]&&(o=c(o,d[2]))),s=f,i=m}const u=this.#e;u[0]=r[0]-this.#i,u[1]=r[1]-this.#i,u[2]=r[2]-r[0]+2*this.#i,u[3]=r[3]-r[1]+2*this.#i,this.firstPoint=[n,a],this.lastPoint=[o,h]}get box(){return this.#e}newOutliner(t,e,s,i,r,n=0){return new he(t,e,s,i,r,n)}getNewOutline(t,e){const[s,i,r,n]=this.#e,[a,o,h,c]=this.#t,d=r*h,u=n*c,p=s*h+a,g=i*c+o,f=this.newOutliner({x:this.#a[0]*d+p,y:this.#a[1]*u+g},this.#t,this.#r,t,this.#s,e??this.#i);for(let m=2;m<this.#a.length;m+=2)f.add({x:this.#a[m]*d+p,y:this.#a[m+1]*u+g});return f.getOutlines()}}class Ws{#t;#e;#i;#s=[];#a=[];constructor(t,e=0,s=0,i=!0){const r=[1/0,1/0,-1/0,-1/0],n=10**-4;for(const{x:f,y:m,width:v,height:y}of t){const b=Math.floor((f-e)/n)*n,w=Math.ceil((f+v+e)/n)*n,A=Math.floor((m-e)/n)*n,x=Math.ceil((m+y+e)/n)*n,_=[b,A,x,!0],E=[w,A,x,!1];this.#s.push(_,E),F.rectBoundingBox(b,A,w,x,r)}const a=r[2]-r[0]+2*s,o=r[3]-r[1]+2*s,h=r[0]-s,c=r[1]-s;let d=i?-1/0:1/0,u=1/0;const p=this.#s.at(i?-1:-2),g=[p[0],p[2]];for(const f of this.#s){const[m,v,y,b]=f;!b&&i?v<u?(u=v,d=m):v===u&&(d=Math.max(d,m)):b&&!i&&(v<u?(u=v,d=m):v===u&&(d=Math.min(d,m))),f[0]=(m-h)/a,f[1]=(v-c)/o,f[2]=(y-c)/o}this.#t=new Float32Array([h,c,a,o]),this.#e=[d,u],this.#i=g}getOutlines(){this.#s.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of this.#s)e[3]?(t.push(...this.#l(e)),this.#o(e)):(this.#h(e),t.push(...this.#l(e)));return this.#r(t)}#r(t){const e=[],s=new Set;for(const n of t){const[a,o,h]=n;e.push([a,o,n],[a,h,n])}e.sort((n,a)=>n[1]-a[1]||n[0]-a[0]);for(let n=0,a=e.length;n<a;n+=2){const o=e[n][2],h=e[n+1][2];o.push(h),h.push(o),s.add(o),s.add(h)}const i=[];let r;for(;s.size>0;){const n=s.values().next().value;let[a,o,h,c,d]=n;s.delete(n);let u=a,p=o;for(r=[a,h],i.push(r);;){let g;if(s.has(c))g=c;else if(s.has(d))g=d;else break;s.delete(g),[a,o,h,c,d]=g,u!==a&&(r.push(u,p,a,p===o?o:h),u=a),p=p===o?h:o}r.push(u,p)}return new ba(i,this.#t,this.#e,this.#i)}#n(t){const e=this.#a;let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,n=e[r][0];if(n===t)return r;n<t?s=r+1:i=r-1}return i+1}#o([,t,e]){const s=this.#n(t);this.#a.splice(s,0,[t,e])}#h([,t,e]){const s=this.#n(t);for(let i=s;i<this.#a.length;i++){const[r,n]=this.#a[i];if(r!==t)break;if(r===t&&n===e){this.#a.splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,n]=this.#a[i];if(r!==t)break;if(r===t&&n===e){this.#a.splice(i,1);return}}}#l(t){const[e,s,i]=t,r=[[e,s,i]],n=this.#n(i);for(let a=0;a<n;a++){const[o,h]=this.#a[a];for(let c=0,d=r.length;c<d;c++){const[,u,p]=r[c];if(!(h<=u||p<=o)){if(u>=o){if(p>h)r[c][1]=h;else{if(d===1)return[];r.splice(c,1),c--,d--}continue}r[c][2]=o,p>h&&r.push([e,h,p])}}}return r}}class ba extends N{#t;#e;constructor(t,e,s,i){super(),this.#e=t,this.#t=e,this.firstPoint=s,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#e){let[s,i]=e;t.push(`M${s} ${i}`);for(let r=2;r<e.length;r+=2){const n=e[r],a=e[r+1];n===s?(t.push(`V${a}`),i=a):a===i&&(t.push(`H${n}`),s=n)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],r){const n=[],a=s-t,o=i-e;for(const h of this.#e){const c=new Array(h.length);for(let d=0;d<h.length;d+=2)c[d]=t+h[d]*a,c[d+1]=i-h[d+1]*o;n.push(c)}return n}get box(){return this.#t}get classNamesForOutlining(){return["highlightOutline"]}}class qs extends he{newFreeDrawOutline(t,e,s,i,r,n){return new ya(t,e,s,i,r,n)}}class ya extends Dr{newOutliner(t,e,s,i,r,n=0){return new qs(t,e,s,i,r,n)}}class pt extends H{#t=null;#e=0;#i;#s=null;#a=null;#r=null;#n=null;#o=0;#h=null;#l=null;#u=null;#d=!1;#p=null;#m=null;#f=null;#c="";#g;#v="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=W.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=pt.prototype;return Y(this,"_keyboardManager",new Ye([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||pt._defaultColor,this.#g=t.thickness||pt._defaultThickness,this.opacity=t.opacity||pt._defaultOpacity,this.#i=t.boxes||null,this.#v=t.methodOfCreation||"",this.#c=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#d=!0,this.#b(t),this.#x()):this.#i&&(this.#t=t.anchorNode,this.#e=t.anchorOffset,this.#n=t.focusNode,this.#o=t.focusOffset,this.#y(),this.#x(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#d?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#g,methodOfCreation:this.#v}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#y(){const t=new Ws(this.#i,.001);this.#l=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#l.box;const e=new Ws(this.#i,.0025,.001,this._uiManager.direction==="ltr");this.#r=e.getOutlines();const{firstPoint:s}=this.#l;this.#p=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height];const{lastPoint:i}=this.#r;this.#m=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#b({highlightOutlines:t,highlightId:e,clipPathId:s}){this.#l=t;const i=1.5;if(this.#r=t.getNewOutline(this.#g/2+i,.0025),e>=0)this.#u=e,this.#s=s,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#f=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#r.box,path:{d:this.#r.toSVGPath()}},!0);else if(this.parent){const d=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#u,{bbox:pt.#E(this.#l.box,(d-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#f,{bbox:pt.#E(this.#r.box,d),path:{d:this.#r.toSVGPath()}})}const[r,n,a,o]=t.box;switch(this.rotation){case 0:this.x=r,this.y=n,this.width=a,this.height=o;break;case 90:{const[d,u]=this.parentDimensions;this.x=n,this.y=1-r,this.width=a*u/d,this.height=o*d/u;break}case 180:this.x=1-r,this.y=1-n,this.width=a,this.height=o;break;case 270:{const[d,u]=this.parentDimensions;this.x=1-n,this.y=r,this.width=a*u/d,this.height=o*d/u;break}}const{firstPoint:h}=t;this.#p=[(h[0]-r)/a,(h[1]-n)/o];const{lastPoint:c}=this.#r;this.#m=[(c[0]-r)/a,(c[1]-n)/o]}static initialize(t,e){H.initialize(t,e),pt._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case Q.HIGHLIGHT_COLOR:pt._defaultColor=e;break;case Q.HIGHLIGHT_THICKNESS:pt._defaultThickness=e;break}}translateInPage(t,e){}get toolbarPosition(){return this.#m}get commentButtonPosition(){return this.#p}updateParams(t,e){switch(t){case Q.HIGHLIGHT_COLOR:this.#S(e);break;case Q.HIGHLIGHT_THICKNESS:this.#_(e);break}}static get defaultPropertiesToUpdate(){return[[Q.HIGHLIGHT_COLOR,pt._defaultColor],[Q.HIGHLIGHT_THICKNESS,pt._defaultThickness]]}get propertiesToUpdate(){return[[Q.HIGHLIGHT_COLOR,this.color||pt._defaultColor],[Q.HIGHLIGHT_THICKNESS,this.#g||pt._defaultThickness],[Q.HIGHLIGHT_FREE,this.#d]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#u,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#a?.updateColor(this.color),super.onUpdatedColor()}#S(t){const e=(r,n)=>{this.color=r,this.opacity=n,this.onUpdatedColor()},s=this.color,i=this.opacity;this.addCommands({cmd:e.bind(this,t,pt._defaultOpacity),undo:e.bind(this,s,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Q.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#_(t){const e=this.#g,s=i=>{this.#g=i,this.#w(i)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Q.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#a=new Lt({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#P())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#P())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#T(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#x(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#T():t&&(this.#x(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#w(t){this.#d&&(this.#b({highlightOutlines:this.#l.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims(this.width,this.height))}#T(){this.#u===null||!this.parent||(this.parent.drawLayer.remove(this.#u),this.#u=null,this.parent.drawLayer.remove(this.#f),this.#f=null)}#x(t=this.parent){this.#u===null&&({id:this.#u,clipPathId:this.#s}=t.drawLayer.draw({bbox:this.#l.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#d},path:{d:this.#l.toSVGPath()}},!1,!0),this.#f=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#d},bbox:this.#r.box,path:{d:this.#r.toSVGPath()}},this.#d),this.#h&&(this.#h.style.clipPath=this.#s))}static#E([t,e,s,i],r){switch(r){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}rotate(t){const{drawLayer:e}=this.parent;let s;this.#d?(t=(t-this.rotation+360)%360,s=pt.#E(this.#l.box,t)):s=pt.#E([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#u,{bbox:s,root:{"data-main-rotation":t}}),e.updateProperties(this.#f,{bbox:pt.#E(this.#r.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#c&&(t.setAttribute("aria-label",this.#c),t.setAttribute("role","mark")),this.#d?t.classList.add("free"):this.div.addEventListener("keydown",this.#M.bind(this),{signal:this._uiManager._signal});const e=this.#h=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#s,this.setDims(this.width,this.height),lr(this,this.#h,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#f,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#f,{rootClass:{hovered:!1}})}#M(t){pt._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#k(!0);break;case 1:case 3:this.#k(!1);break}}#k(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#n,this.#o)}select(){super.select(),this.#f&&this.parent?.drawLayer.updateProperties(this.#f,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#f&&(this.parent?.drawLayer.updateProperties(this.#f,{rootClass:{selected:!1}}),this.#d||this.#k(!1))}get _mustFixPosition(){return!this.#d}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#u,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#f,{rootClass:{hidden:!t}}))}#P(){return this.#d?this.rotation:0}#N(){if(this.#d)return null;const[t,e]=this.pageDimensions,[s,i]=this.pageTranslation,r=this.#i,n=new Float32Array(r.length*8);let a=0;for(const{x:o,y:h,width:c,height:d}of r){const u=o*t+s,p=(1-h)*e+i;n[a]=n[a+4]=u,n[a+1]=n[a+3]=p,n[a+2]=n[a+6]=u+c*t,n[a+5]=n[a+7]=p-d*e,a+=8}return n}#R(t){return this.#l.serialize(t,this.#P())}static startHighlighting(t,e,{target:s,x:i,y:r}){const{x:n,y:a,width:o,height:h}=s.getBoundingClientRect(),c=new AbortController,d=t.combinedSignal(c),u=p=>{c.abort(),this.#B(t,p)};window.addEventListener("blur",u,{signal:d}),window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("pointerdown",ot,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",Nt,{signal:d}),s.addEventListener("pointermove",this.#L.bind(this,t),{signal:d}),this._freeHighlight=new qs({x:i,y:r},[n,a,o,h],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static#L(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#B(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,s){let i=null;if(t instanceof Pr){const{data:{quadPoints:g,rect:f,rotation:m,id:v,color:y,opacity:b,popupRef:w,richText:A,contentsObj:x,creationDate:_,modificationDate:E},parent:{page:{pageNumber:S}}}=t;i=t={annotationType:W.HIGHLIGHT,color:Array.from(y),opacity:b,quadPoints:g,boxes:null,pageIndex:S-1,rect:f.slice(0),rotation:m,annotationElementId:v,id:v,deleted:!1,popupRef:w,richText:A,comment:x?.str||null,creationDate:_,modificationDate:E}}else if(t instanceof pi){const{data:{inkLists:g,rect:f,rotation:m,id:v,color:y,borderStyle:{rawWidth:b},popupRef:w,richText:A,contentsObj:x,creationDate:_,modificationDate:E},parent:{page:{pageNumber:S}}}=t;i=t={annotationType:W.HIGHLIGHT,color:Array.from(y),thickness:b,inkLists:g,boxes:null,pageIndex:S-1,rect:f.slice(0),rotation:m,annotationElementId:v,id:v,deleted:!1,popupRef:w,richText:A,comment:x?.str||null,creationDate:_,modificationDate:E}}const{color:r,quadPoints:n,inkLists:a,opacity:o}=t,h=await super.deserialize(t,e,s);h.color=F.makeHexColor(...r),h.opacity=o||1,a&&(h.#g=t.thickness),h._initialData=i,t.comment&&h.setCommentData(t);const[c,d]=h.pageDimensions,[u,p]=h.pageTranslation;if(n){const g=h.#i=[];for(let f=0;f<n.length;f+=8)g.push({x:(n[f]-u)/c,y:1-(n[f+1]-p)/d,width:(n[f+2]-n[f])/c,height:(n[f+1]-n[f+5])/d});h.#y(),h.#x(),h.rotate(h.rotation)}else if(a){h.#d=!0;const g=a[0],f={x:g[0]-u,y:d-(g[1]-p)},m=new qs(f,[0,0,c,d],1,h.#g/2,!0,.001);for(let b=0,w=g.length;b<w;b+=2)f.x=g[b]-u,f.y=d-(g[b+1]-p),m.add(f);const{id:v,clipPathId:y}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:m.toSVGPath()}},!0,!0);h.#b({highlightOutlines:m.getOutlines(),highlightId:v,clipPathId:y}),h.#x(),h.rotate(h.parentRotation)}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=H._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),s=super.serialize(t);return Object.assign(s,{color:e,opacity:this.opacity,thickness:this.#g,quadPoints:this.#N(),outlines:this.#R(s.rect)}),this.addComment(s),this.annotationElementId&&!this.#O(s)?null:(s.id=this.annotationElementId,s)}#O(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((s,i)=>s!==e[i])}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}}class Rr{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){const t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){it("Not implemented")}}class z extends H{#t=null;#e;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#i=null;static#s=null;static#a=null;static#r=NaN;static#n=null;static#o=null;static#h=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}_addOutlines(t){t.drawOutlines&&(this.#l(t),this.#p())}#l({drawOutlines:t,drawId:e,drawingOptions:s}){this.#t=t,this._drawingOptions||=s,this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#u(t,this.parent),this.#c(t.box)}#u(t,e){const{id:s}=e.drawLayer.draw(z._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return s}static _mergeSVGProperties(t,e){const s=new Set(Object.keys(t));for(const[i,r]of Object.entries(e))s.has(i)?Object.assign(t[i],r):t[i]=r;return t}static getDefaultDrawingOptions(t){it("Not implemented")}static get typesMap(){it("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,e),this._currentParent&&(z.#i.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){const i=this._drawingOptions,r=i[e],n=a=>{i.updateProperty(e,a);const o=this.#t.updateProperty(e,a);o&&this.#c(o),this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),t===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:n.bind(this,s),undo:n.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,z._mergeSVGProperties(this.#t.getPathResizingSVGProperties(this.#f()),{bbox:this.#g()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,z._mergeSVGProperties(this.#t.getPathResizedSVGProperties(this.#f()),{bbox:this.#g()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#g()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,z._mergeSVGProperties(this.#t.getPathTranslatedSVGProperties(this.#f(),this.parentDimensions),{bbox:this.#g()}))}_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(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#d(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#p(),this.#c(this.#t.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#d()):t&&(this._uiManager.addShouldRescale(this),this.#p(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#d(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#p(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#u(this.#t,t)}}#m([t,e,s,i]){const{parentDimensions:[r,n],rotation:a}=this;switch(a){case 90:return[e,1-t,s*(n/r),i*(r/n)];case 180:return[1-t,1-e,s,i];case 270:return[1-e,t,s*(n/r),i*(r/n)];default:return[t,e,s,i]}}#f(){const{x:t,y:e,width:s,height:i,parentDimensions:[r,n],rotation:a}=this;switch(a){case 90:return[1-e,t,s*(r/n),i*(n/r)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(r/n),i*(n/r)];default:return[t,e,s,i]}}#c(t){[this.x,this.y,this.width,this.height]=this.#m(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#g(){const{x:t,y:e,width:s,height:i,rotation:r,parentRotation:n,parentDimensions:[a,o]}=this;switch((r*4+n)/90){case 1:return[1-e-i,t,i,s];case 2:return[1-t-s,1-e-i,s,i];case 3:return[e,1-t-s,i,s];case 4:return[t,e-s*(a/o),i*(o/a),s*(a/o)];case 5:return[1-e,t,s*(a/o),i*(o/a)];case 6:return[1-t-i*(o/a),1-e,i*(o/a),s*(a/o)];case 7:return[e-s*(a/o),1-t-i*(o/a),s*(a/o),i*(o/a)];case 8:return[t-s,e-i,s,i];case 9:return[1-e,t-s,i,s];case 10:return[1-t,1-e,s,i];case 11:return[e-i,1-t,i,s];case 12:return[t-i*(o/a),e,i*(o/a),s*(a/o)];case 13:return[1-e-s*(a/o),t-i*(o/a),s*(a/o),i*(o/a)];case 14:return[1-t,1-e-s*(a/o),i*(o/a),s*(a/o)];case 15:return[e,1-t,s*(a/o),i*(o/a)];default:return[t,e,s,i]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,z._mergeSVGProperties({bbox:this.#g()},this.#t.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#c(this.#t.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const s=super.render();s.classList.add("draw");const i=document.createElement("div");return s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),s}static createDrawerInstance(t,e,s,i,r){it("Not implemented")}static startDrawing(t,e,s,i){const{target:r,offsetX:n,offsetY:a,pointerId:o,pointerType:h}=i;if(z.#n&&z.#n!==h)return;const{viewport:{rotation:c}}=t,{width:d,height:u}=r.getBoundingClientRect(),p=z.#s=new AbortController,g=t.combinedSignal(p);if(z.#r||=o,z.#n??=h,window.addEventListener("pointerup",f=>{z.#r===f.pointerId?this._endDraw(f):z.#o?.delete(f.pointerId)},{signal:g}),window.addEventListener("pointercancel",f=>{z.#r===f.pointerId?this._currentParent.endDrawingSession():z.#o?.delete(f.pointerId)},{signal:g}),window.addEventListener("pointerdown",f=>{z.#n===f.pointerType&&((z.#o||=new Set).add(f.pointerId),z.#i.isCancellable()&&(z.#i.removeLastElement(),z.#i.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",Nt,{signal:g}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),r.addEventListener("touchmove",f=>{f.timeStamp===z.#h&&ot(f)},{signal:g}),t.toggleDrawing(),e._editorUndoBar?.hide(),z.#i){t.drawLayer.updateProperties(this._currentDrawId,z.#i.startNew(n,a,d,u,c));return}e.updateUIForDefaultProperties(this),z.#i=this.createDrawerInstance(n,a,d,u,c),z.#a=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(z.#a.toSVGProperties(),z.#i.defaultSVGProperties),!0,!1)}static _drawMove(t){if(z.#h=-1,!z.#i)return;const{offsetX:e,offsetY:s,pointerId:i}=t;if(z.#r===i){if(z.#o?.size>=1){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,z.#i.add(e,s)),z.#h=t.timeStamp,ot(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,z.#i=null,z.#a=null,z.#n=null,z.#h=NaN),z.#s&&(z.#s.abort(),z.#s=null,z.#r=NaN,z.#o=null)}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,z.#i.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const s=z.#i,i=this._currentDrawId,r=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,s.setLastElement(r))},undo:()=>{e.drawLayer.updateProperties(i,s.removeLastElement())},mustExec:!1,type:Q.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(Q.DRAW_STEP),!z.#i.isEmpty()){const{pageDimensions:[s,i],scale:r}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:z.#i.getOutlines(s*r,i*r,r,this._INNER_MARGIN),drawingOptions:z.#a,mustBeCommitted:!t});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,r,n){it("Not implemented")}static async deserialize(t,e,s){const{rawDims:{pageWidth:i,pageHeight:r,pageX:n,pageY:a}}=e.viewport,o=this.deserializeDraw(n,a,i,r,this._INNER_MARGIN,t),h=await super.deserialize(t,e,s);return h.createDrawingOptions(t),h.#l({drawOutlines:o}),h.#p(),h.onScaleChanging(),h.rotate(),h}serializeDraw(t){const[e,s]=this.pageTranslation,[i,r]=this.pageDimensions;return this.#t.serialize([e,s,i,r],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class wa{#t=new Float64Array(6);#e;#i;#s;#a;#r;#n="";#o=0;#h=new Je;#l;#u;constructor(t,e,s,i,r,n){this.#l=s,this.#u=i,this.#s=r,this.#a=n,[t,e]=this.#d(t,e);const a=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e],this.#i=[{line:a,points:this.#r}],this.#t.set(a,0)}updateProperty(t,e){t==="stroke-width"&&(this.#a=e)}#d(t,e){return N._normalizePoint(t,e,this.#l,this.#u,this.#s)}isEmpty(){return!this.#i||this.#i.length===0}isCancellable(){return this.#r.length<=10}add(t,e){[t,e]=this.#d(t,e);const[s,i,r,n]=this.#t.subarray(2,6),a=t-r,o=e-n;return Math.hypot(this.#l*a,this.#u*o)<=2?null:(this.#r.push(t,e),isNaN(s)?(this.#t.set([r,n,t,e],2),this.#e.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#t[0])&&this.#e.splice(6,6),this.#t.set([s,i,r,n,t,e],0),this.#e.push(...N.createBezierPoints(s,i,r,n,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){return this.add(t,e)||(this.#r.length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,r){this.#l=s,this.#u=i,this.#s=r,[t,e]=this.#d(t,e);const n=this.#e=[NaN,NaN,NaN,NaN,t,e];this.#r=[t,e];const a=this.#i.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#i.push({line:n,points:this.#r}),this.#t.set(n,0),this.#o=0,this.toSVGPath(),null}getLastElement(){return this.#i.at(-1)}setLastElement(t){return this.#i?(this.#i.push(t),this.#e=t.line,this.#r=t.points,this.#o=0,{path:{d:this.toSVGPath()}}):this.#h.setLastElement(t)}removeLastElement(){if(!this.#i)return this.#h.removeLastElement();this.#i.pop(),this.#n="";for(let t=0,e=this.#i.length;t<e;t++){const{line:s,points:i}=this.#i[t];this.#e=s,this.#r=i,this.#o=0,this.toSVGPath()}return{path:{d:this.#n}}}toSVGPath(){const t=N.svgRound(this.#e[4]),e=N.svgRound(this.#e[5]);if(this.#r.length===2)return this.#n=`${this.#n} M ${t} ${e} Z`,this.#n;if(this.#r.length<=6){const i=this.#n.lastIndexOf("M");this.#n=`${this.#n.slice(0,i)} M ${t} ${e}`,this.#o=6}if(this.#r.length===4){const i=N.svgRound(this.#e[10]),r=N.svgRound(this.#e[11]);return this.#n=`${this.#n} L ${i} ${r}`,this.#o=12,this.#n}const s=[];this.#o===0&&(s.push(`M ${t} ${e}`),this.#o=6);for(let i=this.#o,r=this.#e.length;i<r;i+=6){const[n,a,o,h,c,d]=this.#e.slice(i,i+6).map(N.svgRound);s.push(`C${n} ${a} ${o} ${h} ${c} ${d}`)}return this.#n+=s.join(" "),this.#o=this.#e.length,this.#n}getOutlines(t,e,s,i){const r=this.#i.at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),this.#h.build(this.#i,t,e,s,this.#s,this.#a,i),this.#t=null,this.#e=null,this.#i=null,this.#n=null,this.#h}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Je extends N{#t;#e=0;#i;#s;#a;#r;#n;#o;#h;build(t,e,s,i,r,n,a){this.#a=e,this.#r=s,this.#n=i,this.#o=r,this.#h=n,this.#i=a??0,this.#s=t,this.#d()}get thickness(){return this.#h}setLastElement(t){return this.#s.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#s.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#s){if(t.push(`M${N.svgRound(e[4])} ${N.svgRound(e[5])}`),e.length===6){t.push("Z");continue}if(e.length===12&&isNaN(e[6])){t.push(`L${N.svgRound(e[10])} ${N.svgRound(e[11])}`);continue}for(let s=6,i=e.length;s<i;s+=6){const[r,n,a,o,h,c]=e.subarray(s,s+6).map(N.svgRound);t.push(`C${r} ${n} ${a} ${o} ${h} ${c}`)}}return t.join("")}serialize([t,e,s,i],r){const n=[],a=[],[o,h,c,d]=this.#u();let u,p,g,f,m,v,y,b,w;switch(this.#o){case 0:w=N._rescale,u=t,p=e+i,g=s,f=-i,m=t+o*s,v=e+(1-h-d)*i,y=t+(o+c)*s,b=e+(1-h)*i;break;case 90:w=N._rescaleAndSwap,u=t,p=e,g=s,f=i,m=t+h*s,v=e+o*i,y=t+(h+d)*s,b=e+(o+c)*i;break;case 180:w=N._rescale,u=t+s,p=e,g=-s,f=i,m=t+(1-o-c)*s,v=e+h*i,y=t+(1-o)*s,b=e+(h+d)*i;break;case 270:w=N._rescaleAndSwap,u=t+s,p=e+i,g=-s,f=-i,m=t+(1-h-d)*s,v=e+(1-o-c)*i,y=t+(1-h)*s,b=e+(1-o)*i;break}for(const{line:A,points:x}of this.#s)n.push(w(A,u,p,g,f,r?new Array(A.length):null)),a.push(w(x,u,p,g,f,r?new Array(x.length):null));return{lines:n,points:a,rect:[m,v,y,b]}}static deserialize(t,e,s,i,r,{paths:{lines:n,points:a},rotation:o,thickness:h}){const c=[];let d,u,p,g,f;switch(o){case 0:f=N._rescale,d=-t/s,u=e/i+1,p=1/s,g=-1/i;break;case 90:f=N._rescaleAndSwap,d=-e/i,u=-t/s,p=1/i,g=1/s;break;case 180:f=N._rescale,d=t/s+1,u=-e/i,p=-1/s,g=1/i;break;case 270:f=N._rescaleAndSwap,d=e/i+1,u=t/s+1,p=-1/i,g=-1/s;break}if(!n){n=[];for(const v of a){const y=v.length;if(y===2){n.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]));continue}if(y===4){n.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));continue}const b=new Float32Array(3*(y-2));n.push(b);let[w,A,x,_]=v.subarray(0,4);b.set([NaN,NaN,NaN,NaN,w,A],0);for(let E=4;E<y;E+=2){const S=v[E],C=v[E+1];b.set(N.createBezierPoints(w,A,x,_,S,C),(E-2)*3),[w,A,x,_]=[x,_,S,C]}}}for(let v=0,y=n.length;v<y;v++)c.push({line:f(n[v].map(b=>b??NaN),d,u,p,g),points:f(a[v].map(b=>b??NaN),d,u,p,g)});const m=new this.prototype.constructor;return m.build(c,s,i,1,o,h,r),m}#l(t=this.#h){const e=this.#i+t/2*this.#n;return this.#o%180===0?[e/this.#a,e/this.#r]:[e/this.#r,e/this.#a]}#u(){const[t,e,s,i]=this.#t,[r,n]=this.#l(0);return[t+r,e+n,s-2*r,i-2*n]}#d(){const t=this.#t=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:i}of this.#s){if(i.length<=12){for(let a=4,o=i.length;a<o;a+=6)F.pointBoundingBox(i[a],i[a+1],t);continue}let r=i[4],n=i[5];for(let a=6,o=i.length;a<o;a+=6){const[h,c,d,u,p,g]=i.subarray(a,a+6);F.bezierBoundingBox(r,n,h,c,d,u,p,g,t),r=p,n=g}}const[e,s]=this.#l();t[0]=Ct(t[0]-e,0,1),t[1]=Ct(t[1]-s,0,1),t[2]=Ct(t[2]+e,0,1),t[3]=Ct(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#p(e):null}#p(t){const[e,s]=this.#l();this.#h=t;const[i,r]=this.#l(),[n,a]=[i-e,r-s],o=this.#t;return o[0]-=n,o[1]-=a,o[2]+=2*n,o[3]+=2*a,o}updateParentDimensions([t,e],s){const[i,r]=this.#l();this.#a=t,this.#r=e,this.#n=s;const[n,a]=this.#l(),o=n-i,h=a-r,c=this.#t;return c[0]-=o,c[1]-=h,c[2]+=2*o,c[3]+=2*h,c}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(N.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${N.svgRound(t)} ${N.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#t;let s=0,i=0,r=0,n=0,a=0,o=0;switch(this.#e){case 90:i=e/t,r=-t/e,a=t;break;case 180:s=-1,n=-1,a=t,o=e;break;case 270:i=-e/t,r=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${r} ${n} ${N.svgRound(a)} ${N.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,i]){const[r,n]=this.#l(),[a,o,h,c]=this.#t;if(Math.abs(h-r)<=N.PRECISION||Math.abs(c-n)<=N.PRECISION){const f=t+s/2-(a+h/2),m=e+i/2-(o+c/2);return{path:{"transform-origin":`${N.svgRound(t)} ${N.svgRound(e)}`,transform:`${this.rotationTransform} translate(${f} ${m})`}}}const d=(s-2*r)/(h-2*r),u=(i-2*n)/(c-2*n),p=h/s,g=c/i;return{path:{"transform-origin":`${N.svgRound(a)} ${N.svgRound(o)}`,transform:`${this.rotationTransform} scale(${p} ${g}) translate(${N.svgRound(r)} ${N.svgRound(n)}) scale(${d} ${u}) translate(${N.svgRound(-r)} ${N.svgRound(-n)})`}}}getPathResizedSVGProperties([t,e,s,i]){const[r,n]=this.#l(),a=this.#t,[o,h,c,d]=a;if(a[0]=t,a[1]=e,a[2]=s,a[3]=i,Math.abs(c-r)<=N.PRECISION||Math.abs(d-n)<=N.PRECISION){const m=t+s/2-(o+c/2),v=e+i/2-(h+d/2);for(const{line:y,points:b}of this.#s)N._translate(y,m,v,y),N._translate(b,m,v,b);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${N.svgRound(t)} ${N.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(s-2*r)/(c-2*r),p=(i-2*n)/(d-2*n),g=-u*(o+r)+t+r,f=-p*(h+n)+e+n;if(u!==1||p!==1||g!==0||f!==0)for(const{line:m,points:v}of this.#s)N._rescale(m,g,f,u,p,m),N._rescale(v,g,f,u,p,v);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${N.svgRound(t)} ${N.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){const[i,r]=s,n=this.#t,a=t-n[0],o=e-n[1];if(this.#a===i&&this.#r===r)for(const{line:h,points:c}of this.#s)N._translate(h,a,o,h),N._translate(c,a,o,c);else{const h=this.#a/i,c=this.#r/r;this.#a=i,this.#r=r;for(const{line:d,points:u}of this.#s)N._rescale(d,a,o,h,c,d),N._rescale(u,a,o,h,c,u);n[2]*=h,n[3]*=c}return n[0]=t,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${N.svgRound(t)} ${N.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${N.svgRound(t[0])} ${N.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Ps extends Rr{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:H._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Ps(this._viewParameters);return t.updateAll(this),t}}class fi extends z{static _type="ink";static _editorType=W.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions=new Ps(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Y(this,"typesMap",new Map([[Q.INK_THICKNESS,"stroke-width"],[Q.INK_COLOR,"stroke"],[Q.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,i,r){return new wa(t,e,s,i,r,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,i,r,n){return Je.deserialize(t,e,s,i,r,n)}static async deserialize(t,e,s){let i=null;if(t instanceof pi){const{data:{inkLists:n,rect:a,rotation:o,id:h,color:c,opacity:d,borderStyle:{rawWidth:u},popupRef:p,richText:g,contentsObj:f,creationDate:m,modificationDate:v},parent:{page:{pageNumber:y}}}=t;i=t={annotationType:W.INK,color:Array.from(c),thickness:u,opacity:d,paths:{points:n},boxes:null,pageIndex:y-1,rect:a.slice(0),rotation:o,annotationElementId:h,id:h,deleted:!1,popupRef:p,richText:g,comment:f?.str||null,creationDate:m,modificationDate:v}}const r=await super.deserialize(t,e,s);return r._initialData=i,t.comment&&r.setCommentData(t),r}get toolbarButtons(){return this._colorPicker||=new Ge(this),[["colorPicker",this._colorPicker]]}get colorType(){return Q.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:s}){this._drawingOptions=fi.getDefaultDrawingOptions({stroke:F.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":r,"stroke-width":n}}=this,a=Object.assign(super.serialize(t),{color:H._colorManager.convert(i),opacity:r,thickness:n,paths:{lines:e,points:s}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!this.#t(a)?null:(a.id=this.annotationElementId,a)}#t(t){const{color:e,thickness:s,opacity:i,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((n,a)=>n!==e[a])||t.thickness!==s||t.opacity!==i||t.pageIndex!==r}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class Xs extends Je{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const hs=8,Le=3;class le{static#t={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#e(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i}static#i=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#s(t,e,s,i,r,n,a){const o=this.#e(s,i,r,n);for(let h=0;h<8;h++){const c=(-h+o-a+16)%8,d=this.#i[2*c],u=this.#i[2*c+1];if(t[(s+d)*e+(i+u)]!==0)return c}return-1}static#a(t,e,s,i,r,n,a){const o=this.#e(s,i,r,n);for(let h=0;h<8;h++){const c=(h+o+a+16)%8,d=this.#i[2*c],u=this.#i[2*c+1];if(t[(s+d)*e+(i+u)]!==0)return c}return-1}static#r(t,e,s,i){const r=t.length,n=new Int32Array(r);for(let c=0;c<r;c++)n[c]=t[c]<=i?1:0;for(let c=1;c<s-1;c++)n[c*e]=n[c*e+e-1]=0;for(let c=0;c<e;c++)n[c]=n[e*s-1-c]=0;let a=1,o;const h=[];for(let c=1;c<s-1;c++){o=1;for(let d=1;d<e-1;d++){const u=c*e+d,p=n[u];if(p===0)continue;let g=c,f=d;if(p===1&&n[u-1]===0)a+=1,f-=1;else if(p>=1&&n[u+1]===0)a+=1,f+=1,p>1&&(o=p);else{p!==1&&(o=Math.abs(p));continue}const m=[d,c],v=f===d+1,y={isHole:v,points:m,id:a,parent:0};h.push(y);let b;for(const T of h)if(T.id===o){b=T;break}b?b.isHole?y.parent=v?b.parent:o:y.parent=v?o:b.parent:y.parent=v?o:0;const w=this.#s(n,e,c,d,g,f,0);if(w===-1){n[u]=-a,n[u]!==1&&(o=Math.abs(n[u]));continue}let A=this.#i[2*w],x=this.#i[2*w+1];const _=c+A,E=d+x;g=_,f=E;let S=c,C=d;for(;;){const T=this.#a(n,e,S,C,g,f,1);A=this.#i[2*T],x=this.#i[2*T+1];const R=S+A,D=C+x;m.push(D,R);const L=S*e+C;if(n[L+1]===0?n[L]=-a:n[L]===1&&(n[L]=a),R===c&&D===d&&S===_&&C===E){n[u]!==1&&(o=Math.abs(n[u]));break}else g=S,f=C,S=R,C=D}}}return h}static#n(t,e,s,i){if(s-e<=4){for(let _=e;_<s-2;_+=2)i.push(t[_],t[_+1]);return}const r=t[e],n=t[e+1],a=t[s-4]-r,o=t[s-3]-n,h=Math.hypot(a,o),c=a/h,d=o/h,u=c*n-d*r,p=o/a,g=1/h,f=Math.atan(p),m=Math.cos(f),v=Math.sin(f),y=g*(Math.abs(m)+Math.abs(v)),b=g*(1-y+y**2),w=Math.max(Math.atan(Math.abs(v+m)*b),Math.atan(Math.abs(v-m)*b));let A=0,x=e;for(let _=e+2;_<s-2;_+=2){const E=Math.abs(u-c*t[_+1]+d*t[_]);E>A&&(x=_,A=E)}A>(h*w)**2?(this.#n(t,e,x+2,i),this.#n(t,x,s,i)):i.push(r,n)}static#o(t){const e=[],s=t.length;return this.#n(t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e}static#h(t,e,s,i,r,n){const a=new Float32Array(n**2),o=-2*i**2,h=n>>1;for(let f=0;f<n;f++){const m=(f-h)**2;for(let v=0;v<n;v++)a[f*n+v]=Math.exp((m+(v-h)**2)/o)}const c=new Float32Array(256),d=-2*r**2;for(let f=0;f<256;f++)c[f]=Math.exp(f**2/d);const u=t.length,p=new Uint8Array(u),g=new Uint32Array(256);for(let f=0;f<s;f++)for(let m=0;m<e;m++){const v=f*e+m,y=t[v];let b=0,w=0;for(let x=0;x<n;x++){const _=f+x-h;if(!(_<0||_>=s))for(let E=0;E<n;E++){const S=m+E-h;if(S<0||S>=e)continue;const C=t[_*e+S],T=a[x*n+E]*c[Math.abs(C-y)];b+=C*T,w+=T}}const A=p[v]=Math.round(b/w);g[A]++}return[p,g]}static#l(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e}static#u(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,r=1/0;for(let a=0,o=s.length;a<o;a++){const h=s[a]=t[a<<2];i=Math.max(i,h),r=Math.min(r,h)}const n=255/(i-r);for(let a=0,o=s.length;a<o;a++)s[a]=(s[a]-r)*n;return s}static#d(t){let e,s=-1/0,i=-1/0;const r=t.findIndex(o=>o!==0);let n=r,a=r;for(e=r;e<256;e++){const o=t[e];o>s&&(e-n>i&&(i=e-n,a=e-1),s=o,n=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#p(t){const e=t,{width:s,height:i}=t,{maxDim:r}=this.#t;let n=s,a=i;if(s>r||i>r){let c=s,d=i,u=Math.log2(Math.max(s,i)/r);const p=Math.floor(u);u=u===p?p-1:p;for(let f=0;f<u;f++){n=Math.ceil(c/2),a=Math.ceil(d/2);const m=new OffscreenCanvas(n,a);m.getContext("2d").drawImage(t,0,0,c,d,0,0,n,a),c=n,d=a,t!==e&&t.close(),t=m.transferToImageBitmap()}const g=Math.min(r/n,r/a);n=Math.round(n*g),a=Math.round(a*g)}const o=new OffscreenCanvas(n,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,n,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,n,a);const h=o.getImageData(0,0,n,a).data;return[this.#u(h),n,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,n,a,o){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1});const d=200,u=c.font=`${s} ${i} ${d}px ${e}`,{actualBoundingBoxLeft:p,actualBoundingBoxRight:g,actualBoundingBoxAscent:f,actualBoundingBoxDescent:m,fontBoundingBoxAscent:v,fontBoundingBoxDescent:y,width:b}=c.measureText(t),w=1.5,A=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||0,b)*w),x=Math.ceil(Math.max(Math.abs(f)+Math.abs(m)||d,Math.abs(v)+Math.abs(y)||d)*w);h=new OffscreenCanvas(A,x),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=u,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,A,x),c.fillStyle="black",c.fillText(t,A*(w-1)/2,x*(3-w)/2);const _=this.#u(c.getImageData(0,0,A,x).data),E=this.#l(_),S=this.#d(E),C=this.#r(_,A,x,S);return this.processDrawnLines({lines:{curves:C,width:A,height:x},pageWidth:r,pageHeight:n,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){const[n,a,o]=this.#p(t),[h,c]=this.#h(n,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),d=this.#d(c),u=this.#r(h,a,o,d);return this.processDrawnLines({lines:{curves:u,width:a,height:o},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:n,areContours:a}){i%180!==0&&([e,s]=[s,e]);const{curves:o,width:h,height:c}=t,d=t.thickness??0,u=[],p=Math.min(e/h,s/c),g=p/e,f=p/s,m=[];for(const{points:y}of o){const b=n?this.#o(y):y;if(!b)continue;m.push(b);const w=b.length,A=new Float32Array(w),x=new Float32Array(3*(w===2?2:w-2));if(u.push({line:x,points:A}),w===2){A[0]=b[0]*g,A[1]=b[1]*f,x.set([NaN,NaN,NaN,NaN,A[0],A[1]],0);continue}let[_,E,S,C]=b;_*=g,E*=f,S*=g,C*=f,A.set([_,E,S,C],0),x.set([NaN,NaN,NaN,NaN,_,E],0);for(let T=4;T<w;T+=2){const R=A[T]=b[T]*g,D=A[T+1]=b[T+1]*f;x.set(N.createBezierPoints(_,E,S,C,R,D),(T-2)*3),[_,E,S,C]=[S,C,R,D]}}if(u.length===0)return null;const v=a?new Xs:new Je;return v.build(u,e,s,1,i,a?0:d,r),{outline:v,newCurves:m,areContours:a,thickness:d,width:h,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:r}){let n=1/0,a=-1/0,o=0;for(const b of t){o+=b.length;for(let w=2,A=b.length;w<A;w++){const x=b[w]-b[w-2];n=Math.min(n,x),a=Math.max(a,x)}}let h;n>=-128&&a<=127?h=Int8Array:n>=-32768&&a<=32767?h=Int16Array:h=Int32Array;const c=t.length,d=hs+Le*c,u=new Uint32Array(d);let p=0;u[p++]=d*Uint32Array.BYTES_PER_ELEMENT+(o-2*c)*h.BYTES_PER_ELEMENT,u[p++]=0,u[p++]=i,u[p++]=r,u[p++]=e?0:1,u[p++]=Math.max(0,Math.floor(s??0)),u[p++]=c,u[p++]=h.BYTES_PER_ELEMENT;for(const b of t)u[p++]=b.length-2,u[p++]=b[0],u[p++]=b[1];const g=new CompressionStream("deflate-raw"),f=g.writable.getWriter();await f.ready,f.write(u);const m=h.prototype.constructor;for(const b of t){const w=new m(b.length-2);for(let A=2,x=b.length;A<x;A++)w[A-2]=b[A]-b[A-2];f.write(w)}f.close();const v=await new Response(g.readable).arrayBuffer(),y=new Uint8Array(v);return er(y)}static async decompressSignature(t){try{const e=Gr(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),r=i.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let n=null,a=0;for await(const b of s)n||=new Uint8Array(new Uint32Array(b.buffer,0,4)[0]),n.set(b,a),a+=b.length;const o=new Uint32Array(n.buffer,0,n.length>>2),h=o[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const c=o[2],d=o[3],u=o[4]===0,p=o[5],g=o[6],f=o[7],m=[],v=(hs+Le*g)*Uint32Array.BYTES_PER_ELEMENT;let y;switch(f){case Int8Array.BYTES_PER_ELEMENT:y=new Int8Array(n.buffer,v);break;case Int16Array.BYTES_PER_ELEMENT:y=new Int16Array(n.buffer,v);break;case Int32Array.BYTES_PER_ELEMENT:y=new Int32Array(n.buffer,v);break}a=0;for(let b=0;b<g;b++){const w=o[Le*b+hs],A=new Float32Array(w+2);m.push(A);for(let x=0;x<Le-1;x++)A[x]=o[Le*b+hs+x+1];for(let x=0;x<w;x++)A[x+2]=A[x]+y[a++]}return{areContours:u,thickness:p,outlines:m,width:c,height:d}}catch(e){return j(`decompressSignature: ${e}`),null}}}class gi extends Rr{constructor(){super(),super.updateProperties({fill:H._defaultLineColor,"stroke-width":0})}clone(){const t=new gi;return t.updateAll(this),t}}class mi extends Ps{constructor(t){super(t),super.updateProperties({stroke:H._defaultLineColor,"stroke-width":1})}clone(){const t=new mi(this._viewParameters);return t.updateAll(this),t}}class qt extends z{#t=!1;#e=null;#i=null;#s=null;static _type="signature";static _editorType=W.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#i=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions=new gi,this._defaultDrawnSignatureOptions=new mi(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return Y(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#e}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:s}=this;if(s&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),this._drawId===null)if(this.#i){const{lines:i,mustSmooth:r,areContours:n,description:a,uuid:o,heightInPage:h}=this.#i,{rawDims:{pageWidth:c,pageHeight:d},rotation:u}=this.parent.viewport,p=le.processDrawnLines({lines:i,pageWidth:c,pageHeight:d,rotation:u,innerMargin:qt._INNER_MARGIN,mustSmooth:r,areContours:n});this.addSignature(p,h,a,o)}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.#e||""}));return s&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#s=t,this.addEditToolbar()}getUuid(){return this.#s}get description(){return this.#e}set description(t){this.#e=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:s,width:i,height:r}=this.#i,n=Math.max(i,r),a=le.processDrawnLines({lines:{curves:t.map(o=>({points:o})),thickness:s,width:i,height:r},pageWidth:n,pageHeight:n,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,s,i){const{x:r,y:n}=this,{outline:a}=this.#i=t;this.#t=a instanceof Xs,this.description=s;let o;this.#t?o=qt.getDefaultDrawingOptions():(o=qt._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[,h]=this.pageDimensions;let c=e/h;c=c>=1?.5:c,this.width*=c/this.height,this.width>=1&&(c*=.9/this.width,this.width=.9),this.height=c,this.setDims(),this.x=r,this.y=n,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!s}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return le.process(t,e,s,i,qt._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return le.extractContoursFromText(t,e,s,i,r,qt._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return le.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:qt._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=qt.getDefaultDrawingOptions():(this._drawingOptions=qt._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,r=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:i});return this.addComment(r),t?(r.paths={lines:e,points:s},r.uuid=this.#s,r.isCopy=!0):r.lines=e,this.#e&&(r.accessibilityData={type:"Figure",alt:this.#e}),r}static deserializeDraw(t,e,s,i,r,n){return n.areContours?Xs.deserialize(t,e,s,i,r,n):Je.deserialize(t,e,s,i,r,n)}static async deserialize(t,e,s){const i=await super.deserialize(t,e,s);return i.#t=t.areContours,i.description=t.accessibilityData?.alt||"",i.#s=t.uuid,i}}class Aa extends H{#t=null;#e=null;#i=null;#s=null;#a=null;#r="";#n=null;#o=!1;#h=null;#l=!1;#u=!1;static _type="stamp";static _editorType=W.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#s=t.bitmapUrl,this.#a=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){H.initialize(t,e)}static isHandlingMimeForPasting(t){return ps.includes(t)}static paste(t,e){e.pasteEditor({mode:W.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#d(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#l=t.isSvg),t.file&&(this.#r=t.file.name),this.#f()}#p(){if(this.#i=null,this._uiManager.enableWaiting(!1),!!this.#n){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){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(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:r,height:n}=t||this.copyCanvas(null,null,!0).imageData,a=await s.guess({name:"altText",request:{data:i,width:r,height:n,channels:i.length/(r*n)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#m(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#d(s,!0)).finally(()=>this.#p());return}if(this.#s){const s=this.#s;this.#s=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromUrl(s).then(i=>this.#d(i)).finally(()=>this.#p());return}if(this.#a){const s=this.#a;this.#a=null,this._uiManager.enableWaiting(!0),this.#i=this._uiManager.imageManager.getFromFile(s).then(i=>this.#d(i)).finally(()=>this.#p());return}const t=document.createElement("input");t.type="file",t.accept=ps.join(",");const e=this._uiManager._signal;this.#i=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#d(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#p()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#n?.remove(),this.#n=null,this.#h&&(clearTimeout(this.#h),this.#h=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#m();return}super.rebuild(),this.div!==null&&(this.#e&&this.#n===null&&this.#m(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#i||this.#t||this.#s||this.#a||this.#e||this.#o)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#o||(this.#t?this.#f():this.#m()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),s&&this._uiManager.imageManager.isValidId(s)&&(this.#e=s,i&&(this.#t=i),this.#o=!1,this.#f())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#h!==null&&clearTimeout(this.#h);const t=200;this.#h=setTimeout(()=>{this.#h=null,this.#g()},t)}#f(){const{div:t}=this;let{width:e,height:s}=this.#t;const[i,r]=this.pageDimensions,n=.75;if(this.width)e=this.width*i,s=this.height*r;else if(e>n*i||s>n*r){const o=Math.min(n*i/e,n*r/s);e*=o,s*=o}this._uiManager.enableWaiting(!1);const a=this.#n=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/i,this.height=s/r,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#g(),this.#u||(this.parent.addUndoableEditor(this),this.#u=!0),this._reportTelemetry({action:"inserted_image"}),this.#r&&this.div.setAttribute("aria-description",this.#r),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,s=!1){t||(t=224);const{width:i,height:r}=this.#t,n=new Gt;let a=this.#t,o=i,h=r,c=null;if(e){if(i>e||r>e){const x=Math.min(e/i,e/r);o=Math.floor(i*x),h=Math.floor(r*x)}c=document.createElement("canvas");const u=c.width=Math.ceil(o*n.sx),p=c.height=Math.ceil(h*n.sy);this.#l||(a=this.#c(u,p));const g=c.getContext("2d");g.filter=this._uiManager.hcmFilter;let f="white",m="#cfcfd8";this._uiManager.hcmFilter!=="none"?m="black":qr.isDarkMode&&(f="#8f8f9d",m="#42414d");const v=15,y=v*n.sx,b=v*n.sy,w=new OffscreenCanvas(y*2,b*2),A=w.getContext("2d");A.fillStyle=f,A.fillRect(0,0,y*2,b*2),A.fillStyle=m,A.fillRect(0,0,y,b),A.fillRect(y,b,y,b),g.fillStyle=g.createPattern(w,"repeat"),g.fillRect(0,0,u,p),g.drawImage(a,0,0,a.width,a.height,0,0,u,p)}let d=null;if(s){let u,p;if(n.symmetric&&a.width<t&&a.height<t)u=a.width,p=a.height;else if(a=this.#t,i>t||r>t){const f=Math.min(t/i,t/r);u=Math.floor(i*f),p=Math.floor(r*f),this.#l||(a=this.#c(u,p))}const g=new OffscreenCanvas(u,p).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,u,p),d={width:u,height:p,data:g.getImageData(0,0,u,p).data}}return{canvas:c,width:o,height:h,imageData:d}}#c(t,e){const{width:s,height:i}=this.#t;let r=s,n=i,a=this.#t;for(;r>2*t||n>2*e;){const o=r,h=n;r>2*t&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),n>2*e&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2));const c=new OffscreenCanvas(r,n);c.getContext("2d").drawImage(a,0,0,o,h,0,0,r,n),a=c.transferToImageBitmap()}return a}#g(){const[t,e]=this.parentDimensions,{width:s,height:i}=this,r=new Gt,n=Math.ceil(s*t*r.sx),a=Math.ceil(i*e*r.sy),o=this.#n;if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;const h=this.#l?this.#t:this.#c(n,a),c=o.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(h,0,0,h.width,h.height,0,0,n,a)}#v(t){if(t){if(this.#l){const s=this._uiManager.imageManager.getSvgUrl(this.#e);if(s)return s}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#l){const[e,s]=this.pageDimensions,i=Math.round(this.width*e*de.PDF_TO_CSS_UNITS),r=Math.round(this.height*s*de.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,r);return n.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,r),n.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let i=null,r=!1;if(t instanceof Mr){const{data:{rect:f,rotation:m,id:v,structParent:y,popupRef:b,richText:w,contentsObj:A,creationDate:x,modificationDate:_},container:E,parent:{page:{pageNumber:S}},canvas:C}=t;let T,R;C?(delete t.canvas,{id:T,bitmap:R}=s.imageManager.getFromCanvas(E.id,C),C.remove()):(r=!0,t._hasNoCanvas=!0);const D=(await e._structTree.getAriaAttributes(`${ti}${v}`))?.get("aria-label")||"";i=t={annotationType:W.STAMP,bitmapId:T,bitmap:R,pageIndex:S-1,rect:f.slice(0),rotation:m,annotationElementId:v,id:v,deleted:!1,accessibilityData:{decorative:!1,altText:D},isSvg:!1,structParent:y,popupRef:b,richText:w,comment:A?.str||null,creationDate:x,modificationDate:_}}const n=await super.deserialize(t,e,s),{rect:a,bitmap:o,bitmapUrl:h,bitmapId:c,isSvg:d,accessibilityData:u}=t;r?(s.addMissingCanvas(t.id,n),n.#o=!0):c&&s.imageManager.isValidId(c)?(n.#e=c,o&&(n.#t=o)):n.#s=h,n.#l=d;const[p,g]=n.pageDimensions;return n.width=(a[2]-a[0])/p,n.height=(a[3]-a[1])/g,u&&(n.altTextData=u),n._initialData=i,t.comment&&n.setCommentData(t),n.#u=!!i,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#l});if(this.addComment(s),t)return s.bitmapUrl=this.#v(!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;const{decorative:i,altText:r}=this.serializeAltText(!1);if(!i&&r&&(s.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const a=this.#y(s);return a.isSame?null:(a.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1,s.id=this.annotationElementId,delete s.bitmapId,s)}if(e===null)return s;e.stamps||=new Map;const n=this.#l?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:n,serialized:s}),s.bitmap=this.#v(!1);else if(this.#l){const a=e.stamps.get(this.#e);n>a.area&&(a.area=n,a.serialized.bitmap.close(),a.serialized.bitmap=this.#v(!1))}return s}#y(t){const{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,i=t.pageIndex===e,r=(t.accessibilityData?.alt||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&r,isSameAltText:r}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class Yt{#t;#e=!1;#i=null;#s=null;#a=null;#r=new Map;#n=!1;#o=!1;#h=!1;#l=null;#u=null;#d=null;#p=null;#m=null;#f=-1;#c;static _initialized=!1;static#g=new Map([vt,fi,Aa,pt,qt].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:n,drawLayer:a,textLayer:o,viewport:h,l10n:c}){const d=[...Yt.#g.values()];if(!Yt._initialized){Yt._initialized=!0;for(const u of d)u.initialize(c,t)}t.registerEditorTypes(d),this.#c=t,this.pageIndex=e,this.div=s,this.#t=r,this.#i=n,this.viewport=h,this.#d=o,this.drawLayer=a,this._structTree=i,this.#c.addLayer(this)}get isEmpty(){return this.#r.size===0}get isInvisible(){return this.isEmpty&&this.#c.getMode()===W.NONE}updateToolbar(t){this.#c.updateToolbar(t)}updateMode(t=this.#c.getMode()){switch(this.#w(),t){case W.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case W.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case W.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===W.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of Yt.#g.values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#d?.div}setEditingState(t){this.#c.setEditingState(t)}addCommands(t){this.#c.addCommands(t)}cleanUndoStack(t){this.#c.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#i?.div.classList.toggle("disabled",!t)}get#v(){return this.#r.size!==0?this.#r.values():this.#c.getEditors(this.pageIndex)}async enable(){this.#h=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#m?.abort(),this.#m=null;const t=new Set;for(const s of this.#v)s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#c.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));const e=this.#i;if(e)for(const s of e.getEditableAnnotations()){if(s.hide(),this.#c.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}this.#h=!1,this.#c._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#d&&!this.#m){this.#m=new AbortController;const s=this.#c.combinedSignal(this.#m);this.#d.div.addEventListener("pointerdown",i=>{const{clientX:r,clientY:n,timeStamp:a}=i,o=this.#f;if(a-o>500){this.#f=a;return}this.#f=-1;const{classList:h}=this.div;h.toggle("getElements",!0);const c=document.elementsFromPoint(r,n);if(h.toggle("getElements",!1),!this.div.contains(c[0]))return;let d;const u=new RegExp(`^${He}[0-9]+$`);for(const g of c)if(u.test(g.id)){d=g.id;break}if(!d)return;const p=this.#r.get(d);p?.annotationElementId===null&&(i.stopPropagation(),i.preventDefault(),p.dblclick(i))},{signal:s,capture:!0})}const t=this.#i;if(t){const s=new Map,i=new Map;for(const n of this.#v){if(n.disableEditing(),!n.annotationElementId){n.updateFakeAnnotationElement(t);continue}if(n.serialize()!==null){s.set(n.annotationElementId,n);continue}else i.set(n.annotationElementId,n);this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()}const r=t.getEditableAnnotations();for(const n of r){const{id:a}=n.data;if(this.#c.isDeletedAnnotationElement(a)){n.updateEdited({deleted:!0});continue}let o=i.get(a);if(o){o.resetAnnotationElement(n),o.show(!1),n.show();continue}o=s.get(a),o&&(this.#c.addChangedExistingAnnotation(o),o.renderAnnotationElement(n)&&o.show(!1)),n.show()}}this.#w(),this.isEmpty&&(this.div.hidden=!0);const{classList:e}=this.div;for(const s of Yt.#g.values())e.remove(`${s._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#o=!1}getEditableAnnotation(t){return this.#i?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#c.getActive()!==t&&this.#c.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#d?.div&&!this.#p){this.#p=new AbortController;const t=this.#c.combinedSignal(this.#p);this.#d.div.addEventListener("pointerdown",this.#y.bind(this),{signal:t}),this.#d.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#d?.div&&this.#p&&(this.#p.abort(),this.#p=null,this.#d.div.classList.remove("highlighting"))}#y(t){this.#c.unselectAll();const{target:e}=t;if(e===this.#d.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&this.#d.div.contains(e)){const{isMac:s}=At.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#c.showAllEditors("highlight",!0,!0),this.#d.div.classList.add("free"),this.toggleDrawing(),pt.startHighlighting(this,this.#c.direction==="ltr",{target:this.#d.div,x:t.x,y:t.y}),this.#d.div.addEventListener("pointerup",()=>{this.#d.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#c._signal}),t.preventDefault()}}enableClick(){if(this.#s)return;this.#s=new AbortController;const t=this.#c.combinedSignal(this.#s);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#s?.abort(),this.#s=null}attach(t){this.#r.set(t.id,t);const{annotationElementId:e}=t;e&&this.#c.isDeletedAnnotationElement(e)&&this.#c.removeDeletedAnnotationElement(t)}detach(t){this.#r.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId&&this.#c.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#c.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#c.addDeletedAnnotationElement(t.annotationElementId),H.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),this.#c.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#h),this.#c.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#a&&(t._focusEventsAllowed=!1,this.#a=setTimeout(()=>{this.#a=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#c._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of this.#r.values())if(e.uid===t)return e;return null}getNextId(){return this.#c.getId()}get#b(){return Yt.#g.get(this.#c.getMode())}combinedSignal(t){return this.#c.combinedSignal(t)}#S(t){const e=this.#b;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#b?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#c.updateMode(t.mode);const{offsetX:s,offsetY:i}=this.#_(),r=this.getNextId(),n=this.#S({parent:this,id:r,x:s,y:i,uiManager:this.#c,isCentered:!0,...e});n&&this.add(n)}async deserialize(t){return await Yt.#g.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#c)||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),r=this.#S({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#c,isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}#_(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,r=Math.max(0,t),n=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+i),h=(r+a)/2-t,c=(n+o)/2-e,[d,u]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:d,offsetY:u}}addNewEditor(t={}){this.createAndAddNewEditor(this.#_(),!0,t)}setSelected(t){this.#c.setSelected(t)}toggleSelected(t){this.#c.toggleSelected(t)}unselect(t){this.#c.unselect(t)}pointerup(t){const{isMac:e}=At.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!this.#n||(this.#n=!1,this.#b?.isDrawer&&this.#b.supportMultipleDrawings))return;if(!this.#e){this.#e=!0;return}const s=this.#c.getMode();if(s===W.STAMP||s===W.SIGNATURE){this.#c.unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#c.getMode()===W.HIGHLIGHT&&this.enableTextSelection(),this.#n){this.#n=!1;return}const{isMac:e}=At.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#n=!0,this.#b?.isDrawer){this.startDrawingSession(t);return}const s=this.#c.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#l){this.#b.startDrawing(this,this.#c,!1,t);return}this.#c.setCurrentDrawingSession(this),this.#l=new AbortController;const e=this.#c.combinedSignal(this.#l);this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(this.#u=null,this.commitOrRemove())},{signal:e}),this.#b.startDrawing(this,this.#c,!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){return this.#l?(this.#c.setCurrentDrawingSession(null),this.#l.abort(),this.#l=null,this.#u=null,this.#b.endDrawing(t)):null}findNewParent(t,e,s){const i=this.#c.findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return this.#l?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#l&&this.#b.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#c.getActive()?.parent===this&&(this.#c.commitOrRemove(),this.#c.setActiveEditor(null)),this.#a&&(clearTimeout(this.#a),this.#a=null);for(const t of this.#r.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#r.clear(),this.#c.removeLayer(this)}#w(){for(const t of this.#r.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,ae(this.div,t);for(const e of this.#c.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#c.commitOrRemove(),this.#w();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,ae(this.div,{rotation:s}),e!==s)for(const i of this.#r.values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#c.viewParameters.realScale}}class bt{#t=null;#e=new Map;#i=new Map;static#s=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#t){this.#t=t;return}if(this.#t!==t){if(this.#e.size>0)for(const e of this.#e.values())e.remove(),t.append(e);this.#t=t}}static get _svgFactory(){return Y(this,"_svgFactory",new Ve)}static#a(t,[e,s,i,r]){const{style:n}=t;n.top=`${100*s}%`,n.left=`${100*e}%`,n.width=`${100*i}%`,n.height=`${100*r}%`}#r(){const t=bt._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden",!0),t}#n(t,e){const s=bt._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=bt._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i}#o(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)}draw(t,e=!1,s=!1){const i=bt.#s++,r=this.#r(),n=bt._svgFactory.createElement("defs");r.append(n);const a=bt._svgFactory.createElement("path");n.append(a);const o=`path_p${this.pageIndex}_${i}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#i.set(i,a);const h=s?this.#n(n,o):null,c=bt._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${o}`),this.updateProperties(r,t),this.#e.set(i,r),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=bt.#s++,i=this.#r(),r=bt._svgFactory.createElement("defs");i.append(r);const n=bt._svgFactory.createElement("path");r.append(n);const a=`path_p${this.pageIndex}_${s}`;n.setAttribute("id",a),n.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){const d=bt._svgFactory.createElement("mask");r.append(d),o=`mask_p${this.pageIndex}_${s}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=bt._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const p=bt._svgFactory.createElement("use");d.append(p),p.setAttribute("href",`#${a}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const h=bt._svgFactory.createElement("use");i.append(h),h.setAttribute("href",`#${a}`),o&&h.setAttribute("mask",`url(#${o})`);const c=h.cloneNode();return i.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),this.#e.set(s,i),s}finalizeDraw(t,e){this.#i.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:s,bbox:i,rootClass:r,path:n}=e,a=typeof t=="number"?this.#e.get(t):t;if(a){if(s&&this.#o(a,s),i&&bt.#a(a,i),r){const{classList:o}=a;for(const[h,c]of Object.entries(r))o.toggle(h,c)}if(n){const o=a.firstChild.firstChild;this.#o(o,n)}}}updateParent(t,e){if(e===this)return;const s=this.#e.get(t);s&&(e.#t.append(s),this.#e.delete(t),e.#e.set(t,s))}remove(t){this.#i.delete(t),this.#t!==null&&(this.#e.get(t).remove(),this.#e.delete(t))}destroy(){this.#t=null;for(const t of this.#e.values())t.remove();this.#e.clear(),this.#i.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:Ws};globalThis.pdfjsLib={AbortException:ie,AnnotationEditorLayer:Yt,AnnotationEditorParamsType:Q,AnnotationEditorType:W,AnnotationEditorUIManager:re,AnnotationLayer:ks,AnnotationMode:ee,AnnotationType:ut,applyOpacity:ar,build:Sr,ColorPicker:Lt,createValidAbsoluteUrl:Qs,CSSConstants:nr,DOMSVGFactory:Ve,DrawLayer:bt,FeatureTest:At,fetchData:ke,findContrastColor:or,getDocument:hi,getFilenameFromUrl:sr,getPdfFilenameFromUrl:ir,getRGB:Pe,getUuid:Zs,getXfaPageViewport:rr,GlobalWorkerOptions:se,ImageKind:zt,InvalidPDFException:us,isDataScheme:Xe,isPdfFile:Cs,isValidExplicitDest:dr,MathClamp:Ct,noContextMenu:Nt,normalizeUnicode:tr,OPS:Mt,OutputScale:Gt,PasswordResponses:Ji,PDFDataRangeTransport:di,PDFDateString:Ce,PDFWorker:gs,PermissionFlag:Qi,PixelsPerInch:de,RenderingCancelledException:Ss,renderRichText:si,ResponseException:$e,setLayerDimensions:ae,shadow:Y,SignatureExtractor:le,stopEvent:ot,SupportedImageMimeTypes:ps,TextLayer:St,TouchManager:Ke,updateUrlHash:Js,Util:F,VerbosityLevel:Te,version:Er,XfaLayer:ei};const xa=Object.freeze(Object.defineProperty({__proto__:null,AbortException:ie,AnnotationEditorLayer:Yt,AnnotationEditorParamsType:Q,AnnotationEditorType:W,AnnotationEditorUIManager:re,AnnotationLayer:ks,AnnotationMode:ee,AnnotationType:ut,CSSConstants:nr,ColorPicker:Lt,DOMSVGFactory:Ve,DrawLayer:bt,FeatureTest:At,GlobalWorkerOptions:se,ImageKind:zt,InvalidPDFException:us,MathClamp:Ct,OPS:Mt,OutputScale:Gt,PDFDataRangeTransport:di,PDFDateString:Ce,PDFWorker:gs,PasswordResponses:Ji,PermissionFlag:Qi,PixelsPerInch:de,RenderingCancelledException:Ss,ResponseException:$e,SignatureExtractor:le,SupportedImageMimeTypes:ps,TextLayer:St,TouchManager:Ke,Util:F,VerbosityLevel:Te,XfaLayer:ei,applyOpacity:ar,build:Sr,createValidAbsoluteUrl:Qs,fetchData:ke,findContrastColor:or,getDocument:hi,getFilenameFromUrl:sr,getPdfFilenameFromUrl:ir,getRGB:Pe,getUuid:Zs,getXfaPageViewport:rr,isDataScheme:Xe,isPdfFile:Cs,isValidExplicitDest:dr,noContextMenu:Nt,normalizeUnicode:tr,renderRichText:si,setLayerDimensions:ae,shadow:Y,stopEvent:ot,updateUrlHash:Js,version:Er},Symbol.toStringTag,{value:"Module"}));class ms extends Error{constructor(t,e){e!==void 0?super(t??"Invalid PDF",{cause:e}):super(t??"Invalid PDF"),this.name="InvalidPDFException",Object.setPrototypeOf(this,ms.prototype),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ms)}}class vs extends Error{constructor(t,e){e!==void 0?super(t??"Password required or incorrect",{cause:e}):super(t??"Password required or incorrect"),this.name="PasswordException",Object.setPrototypeOf(this,vs.prototype),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,vs)}}class bs extends Error{constructor(t,e){e!==void 0?super(t??"PDF format error",{cause:e}):super(t??"PDF format error"),this.name="FormatError",Object.setPrototypeOf(this,bs.prototype),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,bs)}}class ys extends Error{constructor(t,e,s){s!==void 0?super(t??"Unknown error",{cause:s}):super(t??"Unknown error"),this.name="UnknownErrorException",Object.setPrototypeOf(this,ys.prototype),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ys),this.details=e}}class ws extends Error{constructor(t,e,s,i){i!==void 0?super(t??"Response error",{cause:i}):super(t??"Response error"),this.name="ResponseException",Object.setPrototypeOf(this,ws.prototype),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ws),this.status=e,this.missing=s}}class As extends Error{constructor(t,e){e!==void 0?super(t??"Operation aborted",{cause:e}):super(t??"Operation aborted"),this.name="AbortException",Object.setPrototypeOf(this,As.prototype),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,As)}}function _a(l){if(l instanceof Error)switch(l.name){case"InvalidPDFException":return new ms(l.message,l);case"PasswordException":return new vs(l.message,l);case"FormatError":return new bs(l.message,l);case"UnknownErrorException":return new ys(l.message,l.details,l);case"ResponseException":return new ws(l.message,l.status,l.missing,l);case"AbortException":return new As(l.message,l);default:return l}return new Error(String(l))}class gt{static tolerance=2;static applyTransform(t,e){const s=t[0]*e[0]+t[1]*e[2]+e[4],i=t[0]*e[1]+t[1]*e[3]+e[5];return[s,i]}}class X extends gt{x;y;constructor(t,e){super(),this.x=t,this.y=e}equal(t){return t.x===this.x&&t.y===this.y}transform(t){const e=gt.applyTransform([this.x,this.y],t);return this.x=e[0],this.y=e[1],this}}var $t=(l=>(l[l.None=0]="None",l[l.Horizontal=1]="Horizontal",l[l.Vertical=2]="Vertical",l))($t||{});class wt extends gt{from;to;direction=0;length=0;intersections=[];gaps=[];constructor(t,e){super(),this.from=t,this.to=e,this.init()}init(){let t=this.from,e=this.to;if(Math.abs(t.y-e.y)<gt.tolerance){if(this.direction=1,e.y=t.y,t.x>e.x){const s=t;t=e,e=s}this.length=e.x-t.x}else if(Math.abs(t.x-e.x)<gt.tolerance){if(this.direction=2,e.x=t.x,t.y>e.y){const s=t;t=e,e=s}this.length=e.y-t.y}this.from=t,this.to=e}_valid=void 0;get valid(){return this._valid===void 0&&(this._valid=this.direction!==0&&this.length>gt.tolerance),this._valid}get normalized(){return this.direction===1?new wt(new X(this.from.x-gt.tolerance,this.from.y),new X(this.to.x+gt.tolerance,this.from.y)):this.direction===2?new wt(new X(this.from.x,this.from.y-gt.tolerance),new X(this.from.x,this.to.y+gt.tolerance)):this}addGap(t){this.gaps.push(t)}containsPoint(t){return this.direction===2?this.from.x===t.x&&t.y>=this.from.y&&t.y<=this.to.y:this.direction===1?this.from.y===t.y&&t.x>=this.from.x&&t.x<=this.to.x:!1}addIntersectionPoint(t){for(const e of this.intersections)if(e.equal(t))return;this.intersections.push(t)}intersection(t){let e;if(!this.valid||!t.valid)return e;const s=this.normalized,i=t.normalized;if(this.direction===1&&t.direction===2){const r=i.from.x,n=s.from.y;if(r>s.from.x&&r<s.to.x&&n>i.from.y&&n<i.to.y){const a=new X(r,n);this.addIntersectionPoint(a),t.addIntersectionPoint(a),e=a}}else if(this.direction===2&&t.direction===1){const r=s.from.x,n=i.from.y;if(r>i.from.x&&r<i.to.x&&n>s.from.y&&n<s.to.y){const a=new X(r,n);this.addIntersectionPoint(a),t.addIntersectionPoint(a),e=a}}return e}transform(t){const e=this.from.transform(t),s=this.to.transform(t),i=Math.min(e.x,s.x),r=Math.min(e.y,s.y),n=Math.abs(e.x-s.x),a=Math.abs(e.y-s.y);return this.from=new X(i,r),this.to=new X(i+n,r+a),this.init(),this}}class Ea{minXY;maxXY;rows;rowPivots;colPivots;constructor(t,e,s,i){this.minXY=t,this.maxXY=e,this.rows=[],this.rowPivots=s,this.colPivots=i}findCell(t,e){if(t>=this.minXY.x&&e>=this.minXY.y&&t<=this.maxXY.x&&e<=this.maxXY.y){for(const s of this.rows)for(const i of s)if(i.minXY.x<=t&&i.minXY.y<=e&&i.maxXY.x>=t&&i.maxXY.y>=e)return i}}get cellCount(){return this.rows.reduce((t,e)=>t+e.length,0)}get rowCount(){return this.rows.length}check(){const t=(this.colPivots.length-1)*(this.rowPivots.length-1);let e=0;for(const s of this.rows)for(const i of s){const r=(i.colspan||1)*(i.rowspan||1);e+=r}return t===e}toArray(){const t=[];for(const e of this.rows){const s=[];for(const i of e){let r=i.text.join("");r=r.replace(/^[\s]+|[\s]+$/g,""),r=r.trim(),s.push(r)}t.push(s)}return t}}class qi{hLines=[];vLines=[];constructor(t){t.direction===$t.Horizontal?this.hLines.push(t):t.direction===$t.Vertical&&this.vLines.push(t)}get isValid(){return this.hLines.length+this.vLines.length>4}get rowPivots(){const t=new Set;for(const e of this.hLines)t.add(e.from.y);return[...t].sort((e,s)=>e-s)}get colPivots(){const t=new Set;for(const e of this.vLines)t.add(e.from.x);return[...t].sort((e,s)=>e-s)}add(t){if(this.intersection(t)){if(t.direction===$t.Horizontal)return this.hLines.push(t),!0;if(t.direction===$t.Vertical)return this.vLines.push(t),!0}return!1}intersection(t){let e=!1;if(!t.valid)return e;if(t.direction===$t.Horizontal)for(const s of this.vLines)t.intersection(s)&&(e=!0);else if(t.direction===$t.Vertical)for(const s of this.hLines)t.intersection(s)&&(e=!0);return e}getSameHorizontal(t){const e=[t],s=[];for(;this.hLines.length>0;){const i=this.hLines.shift();i&&(i.from.y===t.from.y?e.push(i):s.push(i))}return this.hLines=s,e}getSameVertical(t){const e=[t],s=[];for(;this.vLines.length>0;){const i=this.vLines.shift();i&&(i.from.x===t.from.x?e.push(i):s.push(i))}return this.vLines=s,e}mergeHorizontalLines(t){t.sort((r,n)=>r.from.x-n.from.x);const e=t[0].from.x,s=t[t.length-1].to.x,i=new wt(new X(e,t[0].from.y),new X(s,t[0].from.y));for(let r=1;r<t.length;r++){const n=t[r-1],a=t[r];if(Math.abs(n.to.x-a.from.x)>gt.tolerance){const o=new wt(new X(n.to.x,n.from.y),new X(a.from.x,a.from.y));i.addGap(o)}}return i}mergeVerticalLines(t){t.sort((r,n)=>r.from.y-n.from.y);const e=t[0].from.y,s=t[t.length-1].to.y,i=new wt(new X(t[0].from.x,e),new X(t[0].from.x,s));for(let r=1;r<t.length;r++){const n=t[r-1],a=t[r];if(Math.abs(n.to.y-a.from.y)>gt.tolerance){const o=new wt(new X(n.to.x,n.to.y),new X(n.to.x,a.from.y));i.addGap(o)}}return i}normalize(){this.hLines=this.hLines.filter(s=>s.intersections.length>1),this.vLines=this.vLines.filter(s=>s.intersections.length>1),this.hLines.sort((s,i)=>s.from.y-i.from.y),this.vLines.sort((s,i)=>s.from.x-i.from.x);const t=[];for(;this.hLines.length>0;){const s=this.hLines.shift();if(!s)continue;const i=this.getSameHorizontal(s),r=this.mergeHorizontalLines(i);t.push(r)}this.hLines=t;const e=[];for(;this.vLines.length>0;){const s=this.vLines.shift();if(!s)continue;const i=this.getSameVertical(s),r=this.mergeVerticalLines(i);e.push(r)}this.vLines=e}verticalExists(t,e,s){if(t.direction!==$t.Vertical)throw new Error("Line is not vertical");if(e>=s)throw new Error("y1 must be less than y2");if(t.from.y<=e&&t.to.y>=s){for(const i of t.gaps)if(i.from.y<=e&&i.to.y>=s)return!1;return!0}return!1}horizontalExists(t,e,s){if(t.direction!==$t.Horizontal)throw new Error("Line is not horizontal");if(e>=s)throw new Error("x1 must be less than x2");if(t.from.x<=e&&t.to.x>=s){for(const i of t.gaps)if(i.from.x<=e&&i.to.x>=s)return!1;return!0}return!1}findBottomLineIndex(t,e){for(let s=t;s<this.hLines.length;s++){const i=this.hLines[s];if(i.from.x<=e&&i.to.x>=e)return s}return-1}findVerticalLineIndexs(t,e){const s=[];for(let i=0;i<this.vLines.length;i++){const r=this.vLines[i];r.from.y<=e&&r.to.y>=e&&t.intersection(r)&&s.push(i)}return s}getRow(t,e,s){const i=[],r=this.hLines[t],n=this.findVerticalLineIndexs(r,s);for(let a=1;a<n.length;a++){const o=this.vLines[n[a-1]],h=this.vLines[n[a]],c=(o.from.x+h.from.x)/2,d=this.findBottomLineIndex(e,c),u=this.hLines[d],p={minXY:new X(o.from.x,r.from.y),maxXY:new X(h.from.x,u.from.y),width:h.from.x-o.from.x,height:u.from.y-r.from.y,text:[]},g=n[a]-n[a-1],f=d-t;g>1&&(p.colspan=g),f>1&&(p.rowspan=f),i.push(p)}return i}toData(){const t=this.rowPivots,e=this.colPivots,s=new X(e[0],t[0]),i=new X(e[e.length-1],t[t.length-1]),r=new Ea(s,i,t,e);for(let n=1;n<this.hLines.length;n++){const a=this.hLines[n-1],o=this.hLines[n],h=(a.from.y+o.from.y)/2,c=this.getRow(n-1,n,h);r.rows.push(c)}return r}}class Sa{hLines=[];vLines=[];add(t){t.valid&&(t.direction===$t.Horizontal?this.hLines.push(t):t.direction===$t.Vertical&&this.vLines.push(t))}addRectangle(t){for(const e of t.getLines())this.add(e)}getTableData(){const t=[],e=this.getTables();for(const s of e){const i=s.toData();i&&t.push(i)}return t}getTables(){const t=[];for(;this.hLines.length!==0;){const s=this.hLines.shift();if(!s||this.tryFill(t,s))continue;const i=new qi(s);this.fillTable(i),t.push(i)}for(;this.vLines.length!==0;){const s=this.vLines.shift();if(!s||this.tryFill(t,s))continue;const i=new qi(s);this.fillTable(i),t.push(i)}const e=t.filter(s=>s.isValid);for(const s of e)s.normalize();return e}normalize(){this.normalizeHorizontal(),this.normalizeVertical()}normalizeHorizontal(){this.hLines.sort((s,i)=>s.from.y-i.from.y);const t=[];let e=[];for(const s of this.hLines)if(e.length===0)e.push(s);else if(Math.abs(e[0]?.from.y-s.from.y)<gt.tolerance)e.push(s);else{const i=this.margeHorizontalLines(e);t.push(...i),e=[s]}if(e.length>0){const s=this.margeHorizontalLines(e);t.push(...s)}this.hLines=t}normalizeVertical(){this.vLines.sort((s,i)=>s.from.x-i.from.x);const t=[];let e=[];for(const s of this.vLines)if(e.length===0)e.push(s);else if(Math.abs(e[0]?.from.x-s.from.x)<gt.tolerance)e.push(s);else{const i=this.margeVerticalLines(e);t.push(...i),e=[s]}if(e.length>0){const s=this.margeVerticalLines(e);t.push(...s)}this.vLines=t}fillTable(t){const e=[],s=[];for(const i of this.vLines)t.add(i)||e.push(i);for(const i of this.hLines)t.add(i)||s.push(i);this.hLines=s,this.vLines=e}tryFill(t,e){for(const s of t)if(s.add(e))return this.fillTable(s),!0;return!1}margeHorizontalLines(t){const e=[];t.sort((a,o)=>a.from.x-o.from.x);const s=t[0]?.from.y;if(s===void 0)return e;let i=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(const a of t)a.from.x-r<gt.tolerance?(a.from.x<i&&(i=a.from.x),a.to.x>r&&(r=a.to.x)):(r>i&&e.push(new wt(new X(i,s),new X(r,s))),i=a.from.x,r=a.to.x);const n=e[e.length-1];return n?n.from.x!==i&&n.to.x!==r&&e.push(new wt(new X(i,s),new X(r,s))):e.push(new wt(new X(i,s),new X(r,s))),e}margeVerticalLines(t){const e=[];t.sort((a,o)=>a.from.y-o.from.y);const s=t[0]?.from.x;if(s===void 0)return e;let i=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(const a of t)a.from.y-r<gt.tolerance?(a.from.y<i&&(i=a.from.y),a.to.y>r&&(r=a.to.y)):(r>i&&e.push(new wt(new X(s,i),new X(s,r))),i=a.from.y,r=a.to.y);const n=e[e.length-1];return n?n.from.y!==i&&n.to.y!==r&&e.push(new wt(new X(s,i),new X(s,r))):e.push(new wt(new X(s,i),new X(s,r))),e}}class Ca extends gt{from;width;height;constructor(t,e,s){super(),this.from=t,this.width=e,this.height=s}get to(){return new X(this.from.x+this.width,this.from.y+this.height)}getLines(){const t=this.to;return[new wt(this.from,new X(t.x,this.from.y)),new wt(this.from,new X(this.from.x,t.y)),new wt(new X(t.x,this.from.y),t),new wt(new X(this.from.x,t.y),t)].filter(e=>e.valid)}transform(t){const e=gt.applyTransform([this.from.x,this.from.y],t),s=gt.applyTransform([this.from.x+this.width,this.from.y+this.height],t),i=Math.min(e[0],s[0]),r=Math.min(e[1],s[1]),n=Math.abs(e[0]-s[0]),a=Math.abs(e[1]-s[1]);return this.from=new X(i,r),this.width=n,this.height=a,this}}class Ta{pages=[];total=0;getPageImage(t,e){for(const s of this.pages)if(s.pageNumber===t){for(const i of s.images)if(i.name===e)return i}return null}constructor(t){this.total=t}}const oe=["xmp:createdate","xmp:modifydate","xmp:metadatadate","xap:createdate","xap:modifydate","xap:metadatadate"];class ka{total;info;metadata;fingerprints;permission;outline;pages=[];getDateNode(){const t={},e=this.info?.CreationDate;e&&(t.CreationDate=Ce.toDateObject(e));const s=this.info?.ModDate;if(s&&(t.ModDate=Ce.toDateObject(s)),!this.metadata)return t;for(const i of oe){const r=this.metadata?.get(i),n=this.parseISODateString(r);switch(i){case oe[0]:t.XmpCreateDate=n;break;case oe[1]:t.XmpModifyDate=n;break;case oe[2]:t.XmpMetadataDate=n;break;case oe[3]:t.XapCreateDate=n;break;case oe[4]:t.XapModifyDate=n;break;case oe[5]:t.XapMetadataDate=n;break}}return t}parseISODateString(t){if(!t)return;const e=Date.parse(t);if(!Number.isNaN(e))return new Date(e)}constructor(t){this.total=t}}function Bs(l){return l.lineThreshold=l?.lineThreshold??4.6,l.cellThreshold=l?.cellThreshold??7,l.cellSeparator=l?.cellSeparator??" ",l.lineEnforce=l?.lineEnforce??!0,l.pageJoiner=l?.pageJoiner??`
15
+ -- page_number of total_number --`,l.imageThreshold=l?.imageThreshold??80,l.imageDataUrl=l?.imageDataUrl??!0,l.imageBuffer=l?.imageBuffer??!0,l.scale=l?.scale??1,l}var Jt=(l=>(l[l.undefined=0]="undefined",l[l.hline=1]="hline",l[l.vline=2]="vline",l[l.rectangle=3]="rectangle",l))(Jt||{});class Pa{pages=[];total=0;constructor(t){this.total=t}}class Ma{pages=[];mergedTables=[];total=0;constructor(t){this.total=t}}class Da{pages=[];text="";total=0;getPageText(t){for(const e of this.pages)if(e.num===t)return e.text;return""}constructor(t){this.total=t}}class Oa{options;doc;progress={loaded:-1,total:0};constructor(t){t.verbosity===void 0&&(t.verbosity=Te.ERRORS),typeof cs<"u"&&t.data instanceof cs&&(t.data=new Uint8Array(t.data)),this.options=t}async destroy(){this.doc&&(await this.doc.destroy(),this.doc=void 0)}static get isNodeJS(){return typeof yt=="object"&&`${yt}`=="[object process]"&&!yt.versions.nw&&!(yt.versions.electron&&typeof yt.type<"u"&&yt.type!=="browser")}static setWorker(t){return typeof globalThis.pdfjs>"u"&&(globalThis.pdfjs=xa),se===null?"":(t!==void 0&&(se.workerSrc=t),se.workerSrc)}async getInfo(t={}){const e=await this.load(),s=new ka(e.numPages),{info:i,metadata:r}=await e.getMetadata();s.info=i,s.metadata=r,s.fingerprints=e.fingerprints,s.outline=await e.getOutline(),s.permission=await e.getPermissions();const n=await e.getPageLabels();if(t.parsePageInfo){for(let a=1;a<=s.total;a++)if(this.shouldParse(a,s.total,t)){const o=await e.getPage(a),h=await this.getPageLinks(o);h.pageLabel=n?.[o.pageNumber],s.pages.push(h),o.cleanup()}}return s}async getPageLinks(t){const e=t.getViewport({scale:1}),s={pageNumber:t.pageNumber,links:[],width:e.width,height:e.height},i=await t.getAnnotations({intent:"display"})||[];for(const r of i){if(r.subtype!=="Link")continue;const n=r.url??r.unsafeUrl;if(!n)continue;const a=r.overlaidText||"";s.links.push({url:n,text:a})}return s}async getText(t={}){const e=await this.load(),s=new Da(e.numPages);for(let i=1;i<=s.total;i++)if(this.shouldParse(i,s.total,t)){const r=await e.getPage(i),n=await this.getPageText(r,t,s.total);s.pages.push({text:n,num:i}),r.cleanup()}for(const i of s.pages)if(t.pageJoiner){let r=t.pageJoiner.replace("page_number",`${i.num}`);r=r.replace("total_number",`${s.total}`),s.text+=`${i.text}
16
+ ${r}
17
+
18
+ `}else s.text+=`${i.text}
19
+
20
+ `;return s}async load(){try{if(this.doc===void 0){const t=hi(this.options);t.onProgress=e=>{this.progress=e},this.doc=await t.promise}return this.doc}catch(t){throw _a(t)}}shouldParse(t,e,s){return s.partial=s?.partial??[],s.first=s?.first??0,s.last=s?.last??0,s.partial.length>0?!!s.partial.includes(t):s.first>0&&s.last>0?t>=s.first&&t<=s.last:s.first>0?t<=s.first:s.last>0?t>e-s.last:!0}async getPageText(t,e,s){const i=t.getViewport({scale:1}),r=Bs(e),n=await t.getTextContent({includeMarkedContent:!!r.includeMarkedContent,disableNormalization:!!r.disableNormalization});let a=new Map;r.parseHyperlinks&&(a=await this.getHyperlinks(t,i));const o=[];let h,c,d=0;for(const u of n.items){if(!("str"in u))continue;const p=u.transform??u.transform,[g,f]=i.convertToViewportPoint(p[4],p[5]);if(r.parseHyperlinks){const m=(a.get(u.str)||[]).find(v=>g>=v.rect.left&&g<=v.rect.right&&f>=v.rect.top&&f<=v.rect.bottom);m&&(u.str=`[${u.str}](${m.url})`)}if(r.lineEnforce&&c!==void 0&&Math.abs(c-f)>r.lineThreshold){const m=o.length?o[o.length-1]:void 0,v=u.str.startsWith(`
21
+ `)||u.str.trim()===""&&u.hasEOL;m?.endsWith(`
22
+ `)===!1&&!v&&Math.abs(c-f)-1>d&&(o.push(`
23
+ `),d=0)}r.cellSeparator&&c!==void 0&&Math.abs(c-f)<r.lineThreshold&&h!==void 0&&Math.abs(h-g)>r.cellThreshold&&(u.str=`${r.cellSeparator}${u.str}`),o.push(u.str),h=g+u.width,c=f,d=Math.max(d,u.height),u.hasEOL&&o.push(`
24
+ `),(u.hasEOL||u.str.endsWith(`
25
+ `))&&(d=0)}return r.itemJoiner?o.join(r.itemJoiner):o.join("")}async getHyperlinks(t,e){const s=new Map,i=await t.getAnnotations({intent:"display"})||[];for(const r of i){if(r.subtype!=="Link")continue;const n=r.url??r.unsafeUrl;if(!n)continue;const a=r.overlaidText;if(!a)continue;const o=e.convertToViewportRectangle(r.rect),h=Math.min(o[0],o[2])-.5,c=Math.min(o[1],o[3])-.5,d=Math.max(o[0],o[2])+.5,u=Math.max(o[1],o[3])+.5,p={rect:{left:h,top:c,right:d,bottom:u},url:n,text:a,used:!1},g=s.get(a);g?g.push(p):s.set(a,[p])}return s}async getImage(t={}){const e=await this.load(),s=new Ta(e.numPages);Bs(t);for(let i=1;i<=s.total;i++)if(this.shouldParse(i,s.total,t)){const r=await e.getPage(i),n=await r.getOperatorList(),a={pageNumber:i,images:[]};s.pages.push(a);for(let o=0;o<n.fnArray.length;o++)if(n.fnArray[o]===Mt.paintInlineImageXObject||n.fnArray[o]===Mt.paintImageXObject){const h=n.argsArray[o][0],c=r.commonObjs.has(h)?this.resolveEmbeddedImage(r.commonObjs,h):this.resolveEmbeddedImage(r.objs,h),{width:d,height:u,kind:p,data:g}=await c;if(t.imageThreshold&&(t.imageThreshold>=d||t.imageThreshold>=u))continue;const f=e.canvasFactory.create(d,u),m=f.context;let v=null;p===zt.RGBA_32BPP?(v=m.createImageData(d,u),v.data.set(g)):(v=m.createImageData(d,u),this.convertToRGBA({src:g,dest:new Uint32Array(v.data.buffer),width:d,height:u,kind:p})),m.putImageData(v,0,0);let y=new Uint8Array,b="";if(typeof f.canvas.toBuffer=="function"){let w;t.imageBuffer&&(w=f.canvas.toBuffer("image/png"),y=new Uint8Array(w)),t.imageDataUrl&&(w?b=`data:image/png;base64,${w.toString("base64")}`:(w=f.canvas.toBuffer("image/png"),y=new Uint8Array(w),b=`data:image/png;base64,${w.toString("base64")}`))}else{if(t.imageBuffer){const w=f.context.getImageData(0,0,f.canvas.width,f.canvas.height);y=new Uint8Array(w.data)}t.imageDataUrl&&(b=f.canvas.toDataURL("image/png"))}a.images.push({data:y,dataUrl:b,name:h,height:u,width:d,kind:p})}}return s}convertToRGBA({src:t,dest:e,width:s,height:i,kind:r}){if(r===zt.RGB_24BPP)for(let n=0,a=0;n<t.length;n+=3,a++){const o=t[n],h=t[n+1],c=t[n+2];e[a]=255<<24|c<<16|h<<8|o}else if(r===zt.GRAYSCALE_1BPP){let n=0;for(let a=0;a<t.length;a++){const o=t[a];for(let h=7;h>=0&&!(n>=s*i);h--){const c=(o>>h&1)===1?255:0;e[n++]=255<<24|c<<16|c<<8|c}}}else if(r==null){const n=t.length/(s*i);if(Math.abs(n-3)<.1)for(let a=0,o=0;a<t.length;a+=3,o++){const h=t[a],c=t[a+1],d=t[a+2];e[o]=255<<24|d<<16|c<<8|h}else if(Math.abs(n-4)<.1)for(let a=0,o=0;a<t.length;a+=4,o++){const h=t[a],c=t[a+1],d=t[a+2],u=t[a+3];e[o]=u<<24|d<<16|c<<8|h}else if(Math.abs(n-1)<.1)for(let a=0;a<t.length;a++){const o=t[a];e[a]=255<<24|o<<16|o<<8|o}else throw new Error(`convertToRGBA: Cannot infer image format. kind: ${r}, bytesPerPixel: ${n}, width: ${s}, height: ${i}, dataLength: ${t.length}`)}else throw new Error(`convertToRGBA: Unsupported image kind: ${r}. Available kinds: GRAYSCALE_1BPP=${zt.GRAYSCALE_1BPP}, RGB_24BPP=${zt.RGB_24BPP}, RGBA_32BPP=${zt.RGBA_32BPP}`)}resolveEmbeddedImage(t,e){return new Promise((s,i)=>{t.get(e,r=>{if(r){let n;if(r.data instanceof Uint8Array)n=r.data;else if(r.data instanceof Uint8ClampedArray)n=new Uint8Array(r.data);else if(r.data?.buffer)n=new Uint8Array(r.data.buffer);else if(r.bitmap){const a=this.doc.canvasFactory.create(r.bitmap.width,r.bitmap.height);a.context.drawImage(r.bitmap,0,0);const o=a.context.getImageData(0,0,r.bitmap.width,r.bitmap.height);n=new Uint8Array(o.data.buffer)}else ArrayBuffer.isView(r.data)&&(n=new Uint8Array(r.data.buffer,r.data.byteOffset,r.data.byteLength));if(!n){i(new Error(`Image object ${e}: data field is empty or invalid. Available fields: ${Object.keys(r).join(", ")}`));return}if(n.length===0){i(new Error(`Image object ${e}: data buffer is empty (length: 0)`));return}s({width:r.width,height:r.height,kind:r.kind,data:n})}else i(new Error(`Image object ${e} not found`))})})}async getScreenshot(t={}){const e=Bs(t),s=await this.load(),i=new Pa(s.numPages);if(this.doc===void 0)throw new Error("PDF document not loaded");for(let r=1;r<=i.total;r++)if(this.shouldParse(r,i.total,e)){const n=await this.doc.getPage(r);let a=n.getViewport({scale:e.scale});if(e.desiredWidth){a=n.getViewport({scale:1});const u=e.desiredWidth/a.width;a=n.getViewport({scale:u})}const o=this.doc.canvasFactory.create(a.width,a.height),h={canvasContext:o.context,viewport:a,canvas:o.canvas};await n.render(h).promise;let c=new Uint8Array,d="";if(typeof o.canvas.toBuffer=="function"){let u;e.imageBuffer&&(u=o.canvas.toBuffer("image/png"),c=new Uint8Array(u)),e.imageDataUrl&&(u?d=`data:image/png;base64,${u.toString("base64")}`:(u=o.canvas.toBuffer("image/png"),c=new Uint8Array(u),d=`data:image/png;base64,${u.toString("base64")}`))}else{if(e.imageBuffer){const u=o.context.getImageData(0,0,o.canvas.width,o.canvas.height);c=new Uint8Array(u.data)}e.imageDataUrl&&(d=o.canvas.toDataURL("image/png"))}i.pages.push({data:c,dataUrl:d,pageNumber:r,width:a.width,height:a.height,scale:a.scale}),n.cleanup()}return i}async getTable(t={}){const e=await this.load(),s=new Ma(e.numPages);if(this.doc===void 0)throw new Error("PDF document not loaded");for(let i=1;i<=s.total;i++)if(this.shouldParse(i,s.total,t)){const r=await this.doc.getPage(i),n=await this.getPageTables(r);n.normalize();const a=n.getTableData();await this.fillPageTables(r,a);const o={num:i,tables:[]};for(const h of a)o.tables.push(h.toArray());s.pages.push(o),r.cleanup()}return s}getPathGeometry(t){const e=t[2]-t[0],s=t[3]-t[1];return t[0]===1/0?Jt.undefined:e>5&&s>5?Jt.rectangle:e>5&&s===0?Jt.hline:e===0&&s>5?Jt.vline:Jt.undefined}async getPageTables(t){const e=new Sa,s=t.getViewport({scale:1});let i=[1,0,0,1,0,0];const r=[],n=await t.getOperatorList();for(let a=0;a<n.fnArray.length;a++){const o=n.fnArray[a],h=n.argsArray[a],c=h?.[0]??0,d=h?.[2]??[1/0,1/0,-1/0,-1/0];if(o===Mt.constructPath){if(Mt.fill,c!==Mt.stroke)continue;const u=this.getPathGeometry(d);if(u===Jt.rectangle){const p=new Ca(new X(d[0],d[1]),d[2]-d[0],d[3]-d[1]);p.transform(i),p.transform(s.transform),e.addRectangle(p)}else if(u===Jt.hline||u===Jt.vline){const p=new X(d[0],d[1]),g=new X(d[2],d[3]),f=new wt(p,g);f.transform(i),f.transform(s.transform),e.add(f)}}else if(o!==Mt.setLineWidth)if(o===Mt.save)r.push(i);else if(o===Mt.restore){const u=r.pop();u&&(i=u)}else o===Mt.transform&&(i=F.transform(i,h))}return e}async fillPageTables(t,e){const s=t.getViewport({scale:1}),i=await t.getTextContent({includeMarkedContent:!1,disableNormalization:!1});for(const r of i.items){if(!("str"in r))continue;const n=F.transform(F.transform(s.transform,r.transform),[1,0,0,-1,0,0]);for(const a of e){const o=a.findCell(n[4],n[5]);if(o){o.text.push(r.str),r.hasEOL&&o.text.push(`
26
+ `);break}}}}}export{As as AbortException,bs as FormatError,ms as InvalidPDFException,wt as Line,$t as LineDirection,Sa as LineStore,Oa as PDFParse,vs as PasswordException,X as Point,Ca as Rectangle,ws as ResponseException,gt as Shape,qi as Table,ys as UnknownErrorException,Te as VerbosityLevel,_a as getException};