@getflip/swirl-components 0.459.0 → 0.459.1

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.
@@ -19,4 +19,4 @@ import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as s,Host as
19
19
  *
20
20
  * @licend The above is the entire license notice for the
21
21
  * JavaScript code in this page
22
- */var p={34:(t,e,i)=>{var s=i(4901);t.exports=function(t){return"object"==typeof t?null!==t:s(t)}},81:(t,e,i)=>{var s=i(9565),n=i(9306),r=i(8551),o=i(6823),h=i(851),a=TypeError;t.exports=function(t,e){var i=arguments.length<2?h(t):e;if(n(i))return r(s(i,t));throw new a(o(t)+" is not iterable")}},283:(t,e,i)=>{var s=i(9504),n=i(9039),r=i(4901),o=i(9297),h=i(3724),a=i(350).CONFIGURABLE,c=i(3706),l=i(1181),u=l.enforce,d=l.get,f=String,p=Object.defineProperty,g=s("".slice),m=s("".replace),w=s([].join),A=h&&!n((function(){return 8!==p((function(){}),"length",{value:8}).length})),b=String(String).split("String"),v=t.exports=function(t,e,i){"Symbol("===g(f(e),0,7)&&(e="["+m(f(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),i&&i.getter&&(e="get "+e),i&&i.setter&&(e="set "+e),(!o(t,"name")||a&&t.name!==e)&&(h?p(t,"name",{value:e,configurable:!0}):t.name=e),A&&i&&o(i,"arity")&&t.length!==i.arity&&p(t,"length",{value:i.arity});try{i&&o(i,"constructor")&&i.constructor?h&&p(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var s=u(t);return o(s,"source")||(s.source=w(b,"string"==typeof e?e:"")),t};Function.prototype.toString=v((function(){return r(this)&&d(this).source||c(this)}),"toString")},350:(t,e,i)=>{var s=i(3724),n=i(9297),r=Function.prototype,o=s&&Object.getOwnPropertyDescriptor,h=n(r,"name"),a=h&&"something"===function(){}.name,c=h&&(!s||s&&o(r,"name").configurable);t.exports={EXISTS:h,PROPER:a,CONFIGURABLE:c}},397:(t,e,i)=>{var s=i(7751);t.exports=s("document","documentElement")},421:t=>{t.exports={}},507:(t,e,i)=>{var s=i(9565);t.exports=function(t,e,i){for(var n,r,o=i?t:t.iterator,h=t.next;!(n=s(h,o)).done;)if(void 0!==(r=e(n.value)))return r}},531:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(9306),o=i(8551),h=i(1767),a=i(8646),c=i(9462),l=i(9539),u=i(6395),d=i(4549),f=!u&&d("flatMap",TypeError),p=c((function(){for(var t,e,i=this.iterator,s=this.mapper;;){if(e=this.inner)try{if(!(t=o(n(e.next,e.iterator))).done)return t.value;this.inner=null}catch(t){l(i,"throw",t)}if(t=o(n(this.next,i)),this.done=!!t.done)return;try{this.inner=a(s(t.value,this.counter++),!1)}catch(t){l(i,"throw",t)}}}));s({target:"Iterator",proto:!0,real:!0,forced:u||f},{flatMap:function(t){o(this);try{r(t)}catch(t){l(this,"throw",t)}return f?n(f,this,t):new p(h(this),{mapper:t,inner:null})}})},616:(t,e,i)=>{var s=i(9039);t.exports=!s((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},655:(t,e,i)=>{var s=i(6955),n=String;t.exports=function(t){if("Symbol"===s(t))throw new TypeError("Cannot convert a Symbol value to a string");return n(t)}},679:(t,e,i)=>{var s=i(1625),n=TypeError;t.exports=function(t,e){if(s(e,t))return t;throw new n("Incorrect invocation")}},741:t=>{var e=Math.ceil,i=Math.floor;t.exports=Math.trunc||function(t){var s=+t;return(s>0?i:e)(s)}},757:(t,e,i)=>{var s=i(7751),n=i(4901),r=i(1625),o=i(7040),h=Object;t.exports=o?function(t){return"symbol"==typeof t}:function(t){var e=s("Symbol");return n(e)&&r(e.prototype,h(t))}},851:(t,e,i)=>{var s=i(6955),n=i(5966),r=i(4117),o=i(6269),h=i(8227)("iterator");t.exports=function(t){if(!r(t))return n(t,h)||n(t,"@@iterator")||o[s(t)]}},944:t=>{var e=TypeError;t.exports=function(t){var i=t&&t.alphabet;if(void 0===i||"base64"===i||"base64url"===i)return i||"base64";throw new e("Incorrect `alphabet` option")}},1072:(t,e,i)=>{var s=i(1828),n=i(8727);t.exports=Object.keys||function(t){return s(t,n)}},1103:t=>{t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},1148:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(2652),o=i(9306),h=i(8551),a=i(1767),c=i(9539),l=i(4549)("every",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:l},{every:function(t){h(this);try{o(t)}catch(t){c(this,"throw",t)}if(l)return n(l,this,t);var e=a(this),i=0;return!r(e,(function(e,s){if(!t(e,i++))return s()}),{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},1181:(t,e,i)=>{var s,n,r,o=i(8622),h=i(4576),a=i(34),c=i(6699),l=i(9297),u=i(7629),d=i(6119),f=i(421),p="Object already initialized",g=h.TypeError;if(o||u.state){var m=u.state||(u.state=new(0,h.WeakMap));m.get=m.get,m.has=m.has,m.set=m.set,s=function(t,e){if(m.has(t))throw new g(p);return e.facade=t,m.set(t,e),e},n=function(t){return m.get(t)||{}},r=function(t){return m.has(t)}}else{var w=d("state");f[w]=!0,s=function(t,e){if(l(t,w))throw new g(p);return e.facade=t,c(t,w,e),e},n=function(t){return l(t,w)?t[w]:{}},r=function(t){return l(t,w)}}t.exports={set:s,get:n,has:r,enforce:function(t){return r(t)?n(t):s(t,{})},getterFor:function(t){return function(e){var i;if(!a(e)||(i=n(e)).type!==t)throw new g("Incompatible receiver, "+t+" required");return i}}}},1291:(t,e,i)=>{var s=i(741);t.exports=function(t){var e=+t;return e!=e||0===e?0:s(e)}},1548:(t,e,i)=>{var s=i(4576),n=i(9039),r=i(9519),o=i(4215),h=s.structuredClone;t.exports=!!h&&!n((function(){if("DENO"===o&&r>92||"NODE"===o&&r>94||"BROWSER"===o&&r>97)return!1;var t=new ArrayBuffer(8),e=h(t,{transfer:[t]});return 0!==t.byteLength||8!==e.byteLength}))},1549:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(9143),o=i(4154),h=n.Uint8Array,a=!h||!h.prototype.setFromBase64||!function(){var t=new h([255,255,255,255,255]);try{t.setFromBase64("MjYyZg===")}catch(e){return 50===t[0]&&54===t[1]&&50===t[2]&&255===t[3]&&255===t[4]}}();h&&s({target:"Uint8Array",proto:!0,forced:a},{setFromBase64:function(t){o(this);var e=r(t,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:e.read,written:e.written}}})},1625:(t,e,i)=>{var s=i(9504);t.exports=s({}.isPrototypeOf)},1689:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(8745),o=i(7680),h=i(6043),a=i(9306),c=i(1103),l=n.Promise,u=!1;s({target:"Promise",stat:!0,forced:!l||!l.try||c((function(){l.try((function(t){u=8===t}),8)})).error||!u},{try:function(t){var e=arguments.length>1?o(arguments,1):[],i=h.f(this),s=c((function(){return r(a(t),void 0,e)}));return(s.error?i.reject:i.resolve)(s.value),i.promise}})},1698:(t,e,i)=>{var s=i(6518),n=i(4204);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("union")},{union:n})},1701:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(9306),o=i(8551),h=i(1767),a=i(9462),c=i(6319),l=i(9539),u=i(4549),d=i(6395),f=!d&&u("map",TypeError),p=a((function(){var t=this.iterator,e=o(n(this.next,t));if(!(this.done=!!e.done))return c(t,this.mapper,[e.value,this.counter++],!0)}));s({target:"Iterator",proto:!0,real:!0,forced:d||f},{map:function(t){o(this);try{r(t)}catch(t){l(this,"throw",t)}return f?n(f,this,t):new p(h(this),{mapper:t})}})},1767:t=>{t.exports=function(t){return{iterator:t,next:t.next,done:!1}}},1828:(t,e,i)=>{var s=i(9504),n=i(9297),r=i(5397),o=i(9617).indexOf,h=i(421),a=s([].push);t.exports=function(t,e){var i,s=r(t),c=0,l=[];for(i in s)!n(h,i)&&n(s,i)&&a(l,i);for(;e.length>c;)n(s,i=e[c++])&&(~o(l,i)||a(l,i));return l}},2106:(t,e,i)=>{var s=i(283),n=i(4913);t.exports=function(t,e,i){return i.get&&s(i.get,e,{getter:!0}),i.set&&s(i.set,e,{setter:!0}),n.f(t,e,i)}},2140:(t,e,i)=>{var s={};s[i(8227)("toStringTag")]="z",t.exports="[object z]"===String(s)},2195:(t,e,i)=>{var s=i(9504),n=s({}.toString),r=s("".slice);t.exports=function(t){return r(n(t),8,-1)}},2211:(t,e,i)=>{var s=i(9039);t.exports=!s((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}))},2303:(t,e,i)=>{var s=i(4576),n=i(9504),r=s.Uint8Array,o=s.SyntaxError,h=s.parseInt,a=Math.min,c=/[^\da-f]/i,l=n(c.exec),u=n("".slice);t.exports=function(t,e){var i=t.length;if(i%2!=0)throw new o("String should be an even number of characters");for(var s=e?a(e.length,i/2):i/2,n=e||new r(s),d=0,f=0;f<s;){var p=u(t,d,d+=2);if(l(c,p))throw new o("String should only contain hex characters");n[f++]=h(p,16)}return{bytes:n,read:d}}},2360:(t,e,i)=>{var s,n=i(8551),r=i(6801),o=i(8727),h=i(421),a=i(397),c=i(4055),l=i(6119),u="prototype",d="script",f=l("IE_PROTO"),p=function(){},g=function(t){return"<"+d+">"+t+"</"+d+">"},m=function(t){t.write(g("")),t.close();var e=t.parentWindow.Object;return t=null,e},w=function(){try{s=new ActiveXObject("htmlfile")}catch(t){}var t,e,i;w="undefined"!=typeof document?document.domain&&s?m(s):(e=c("iframe"),i="java"+d+":",e.style.display="none",a.appendChild(e),e.src=String(i),(t=e.contentWindow.document).open(),t.write(g("document.F=Object")),t.close(),t.F):m(s);for(var n=o.length;n--;)delete w[u][o[n]];return w()};h[f]=!0,t.exports=Object.create||function(t,e){var i;return null!==t?(p[u]=n(t),i=new p,p[u]=null,i[f]=t):i=w(),void 0===e?i:r.f(i,e)}},2475:(t,e,i)=>{var s=i(6518),n=i(8527);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSupersetOf",(function(t){return!t}))},{isSupersetOf:n})},2489:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(9306),o=i(8551),h=i(1767),a=i(9462),c=i(6319),l=i(6395),u=i(9539),d=i(4549),f=!l&&d("filter",TypeError),p=a((function(){for(var t,e,i=this.iterator,s=this.predicate,r=this.next;;){if(t=o(n(r,i)),this.done=!!t.done)return;if(c(i,s,[e=t.value,this.counter++],!0))return e}}));s({target:"Iterator",proto:!0,real:!0,forced:l||f},{filter:function(t){o(this);try{r(t)}catch(t){u(this,"throw",t)}return f?n(f,this,t):new p(h(this),{predicate:t})}})},2529:t=>{t.exports=function(t,e){return{value:t,done:e}}},2603:(t,e,i)=>{var s=i(655);t.exports=function(t,e){return void 0===t?arguments.length<2?"":e:s(t)}},2652:(t,e,i)=>{var s=i(6080),n=i(9565),r=i(8551),o=i(6823),h=i(4209),a=i(6198),c=i(1625),l=i(81),u=i(851),d=i(9539),f=TypeError,p=function(t,e){this.stopped=t,this.result=e},g=p.prototype;t.exports=function(t,e,i){var m,w,A,b,v,y,x,M=!(!i||!i.AS_ENTRIES),E=!(!i||!i.IS_RECORD),S=!(!i||!i.IS_ITERATOR),k=!(!i||!i.INTERRUPTED),C=s(e,i&&i.that),T=function(t){return m&&d(m,"normal",t),new p(!0,t)},P=function(t){return M?(r(t),k?C(t[0],t[1],T):C(t[0],t[1])):k?C(t,T):C(t)};if(E)m=t.iterator;else if(S)m=t;else{if(!(w=u(t)))throw new f(o(t)+" is not iterable");if(h(w)){for(A=0,b=a(t);b>A;A++)if((v=P(t[A]))&&c(g,v))return v;return new p(!1)}m=l(t,w)}for(y=E?t.next:m.next;!(x=n(y,m)).done;){try{v=P(x.value)}catch(t){d(m,"throw",t)}if("object"==typeof v&&v&&c(g,v))return v}return new p(!1)}},2777:(t,e,i)=>{var s=i(9565),n=i(34),r=i(757),o=i(5966),h=i(4270),a=i(8227),c=TypeError,l=a("toPrimitive");t.exports=function(t,e){if(!n(t)||r(t))return t;var i,a=o(t,l);if(a){if(void 0===e&&(e="default"),i=s(a,t,e),!n(i)||r(i))return i;throw new c("Can't convert object to primitive value")}return void 0===e&&(e="number"),h(t,e)}},2787:(t,e,i)=>{var s=i(9297),n=i(4901),r=i(8981),o=i(6119),h=i(2211),a=o("IE_PROTO"),c=Object,l=c.prototype;t.exports=h?c.getPrototypeOf:function(t){var e=r(t);if(s(e,a))return e[a];var i=e.constructor;return n(i)&&e instanceof i?i.prototype:e instanceof c?l:null}},2796:(t,e,i)=>{var s=i(9039),n=i(4901),r=/#|\.prototype\./,o=function(t,e){var i=a[h(t)];return i===l||i!==c&&(n(e)?s(e):!!e)},h=o.normalize=function(t){return String(t).replace(r,".").toLowerCase()},a=o.data={},c=o.NATIVE="N",l=o.POLYFILL="P";t.exports=o},2804:t=>{var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=e+"+/",s=e+"-_",n=function(t){for(var e={},i=0;i<64;i++)e[t.charAt(i)]=i;return e};t.exports={i2c:i,c2i:n(i),i2cUrl:s,c2iUrl:n(s)}},2812:t=>{var e=TypeError;t.exports=function(t,i){if(t<i)throw new e("Not enough arguments");return t}},2839:(t,e,i)=>{var s=i(4576).navigator,n=s&&s.userAgent;t.exports=n?String(n):""},2967:(t,e,i)=>{var s=i(6706),n=i(34),r=i(7750),o=i(3506);t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,i={};try{(t=s(Object.prototype,"__proto__","set"))(i,[]),e=i instanceof Array}catch(t){}return function(i,s){return r(i),o(s),n(i)?(e?t(i,s):i.__proto__=s,i):i}}():void 0)},3167:(t,e,i)=>{var s=i(4901),n=i(34),r=i(2967);t.exports=function(t,e,i){var o,h;return r&&s(o=e.constructor)&&o!==i&&n(h=o.prototype)&&h!==i.prototype&&r(t,h),t}},3238:(t,e,i)=>{var s=i(4576),n=i(7811),r=i(7394),o=s.DataView;t.exports=function(t){if(!n||0!==r(t))return!1;try{return new o(t),!1}catch(t){return!0}}},3392:(t,e,i)=>{var s=i(9504),n=0,r=Math.random(),o=s(1..toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+o(++n+r,36)}},3440:(t,e,i)=>{var s=i(7080),n=i(4402),r=i(9286),o=i(5170),h=i(3789),a=i(8469),c=i(507),l=n.has,u=n.remove;t.exports=function(t){var e=s(this),i=h(t),n=r(e);return o(e)<=i.size?a(e,(function(t){i.includes(t)&&u(n,t)})):c(i.getIterator(),(function(t){l(e,t)&&u(n,t)})),n}},3463:t=>{var e=TypeError;t.exports=function(t){if("string"==typeof t)return t;throw new e("Argument is not a string")}},3506:(t,e,i)=>{var s=i(3925),n=String,r=TypeError;t.exports=function(t){if(s(t))return t;throw new r("Can't set "+n(t)+" as a prototype")}},3579:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(2652),o=i(9306),h=i(8551),a=i(1767),c=i(9539),l=i(4549)("some",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:l},{some:function(t){h(this);try{o(t)}catch(t){c(this,"throw",t)}if(l)return n(l,this,t);var e=a(this),i=0;return r(e,(function(e,s){if(t(e,i++))return s()}),{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},3650:(t,e,i)=>{var s=i(7080),n=i(4402),r=i(9286),o=i(3789),h=i(507),a=n.add,c=n.has,l=n.remove;t.exports=function(t){var e=s(this),i=o(t).getIterator(),n=r(e);return h(i,(function(t){c(e,t)?l(n,t):a(n,t)})),n}},3706:(t,e,i)=>{var s=i(9504),n=i(4901),r=i(7629),o=s(Function.toString);n(r.inspectSource)||(r.inspectSource=function(t){return o(t)}),t.exports=r.inspectSource},3717:(t,e)=>{e.f=Object.getOwnPropertySymbols},3724:(t,e,i)=>{var s=i(9039);t.exports=!s((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))},3789:(t,e,i)=>{var s=i(9306),n=i(8551),r=i(9565),o=i(1291),h=i(1767),a="Invalid size",c=RangeError,l=TypeError,u=Math.max,d=function(t,e){this.set=t,this.size=u(e,0),this.has=s(t.has),this.keys=s(t.keys)};d.prototype={getIterator:function(){return h(n(r(this.keys,this.set)))},includes:function(t){return r(this.has,this.set,t)}},t.exports=function(t){n(t);var e=+t.size;if(e!=e)throw new l(a);var i=o(e);if(i<0)throw new c(a);return new d(t,i)}},3838:(t,e,i)=>{var s=i(7080),n=i(5170),r=i(8469),o=i(3789);t.exports=function(t){var e=s(this),i=o(t);return!(n(e)>i.size)&&!1!==r(e,(function(t){if(!i.includes(t))return!1}),!0)}},3853:(t,e,i)=>{var s=i(6518),n=i(4449);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isDisjointFrom",(function(t){return!t}))},{isDisjointFrom:n})},3925:(t,e,i)=>{var s=i(34);t.exports=function(t){return s(t)||null===t}},3972:(t,e,i)=>{var s=i(34),n=String,r=TypeError;t.exports=function(t){if(void 0===t||s(t))return t;throw new r(n(t)+" is not an object or undefined")}},4055:(t,e,i)=>{var s=i(4576),n=i(34),r=s.document,o=n(r)&&n(r.createElement);t.exports=function(t){return o?r.createElement(t):{}}},4114:(t,e,i)=>{var s=i(6518),n=i(8981),r=i(6198),o=i(4527),h=i(6837);s({target:"Array",proto:!0,arity:1,forced:i(9039)((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(t){return t instanceof TypeError}}()},{push:function(t){var e=n(this),i=r(e),s=arguments.length;h(i+s);for(var a=0;a<s;a++)e[i]=arguments[a],i++;return o(e,i),i}})},4117:t=>{t.exports=function(t){return null==t}},4149:t=>{var e=RangeError;t.exports=function(t){if(t==t)return t;throw new e("NaN is not allowed")}},4154:(t,e,i)=>{var s=i(6955),n=TypeError;t.exports=function(t){if("Uint8Array"===s(t))return t;throw new n("Argument is not an Uint8Array")}},4204:(t,e,i)=>{var s=i(7080),n=i(4402).add,r=i(9286),o=i(3789),h=i(507);t.exports=function(t){var e=s(this),i=o(t).getIterator(),a=r(e);return h(i,(function(t){n(a,t)})),a}},4209:(t,e,i)=>{var s=i(8227),n=i(6269),r=s("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(n.Array===t||o[r]===t)}},4215:(t,e,i)=>{var s=i(4576),n=i(2839),r=i(2195),o=function(t){return n.slice(0,t.length)===t};t.exports=o("Bun/")?"BUN":o("Cloudflare-Workers")?"CLOUDFLARE":o("Deno/")?"DENO":o("Node.js/")?"NODE":s.Bun&&"string"==typeof Bun.version?"BUN":s.Deno&&"object"==typeof Deno.version?"DENO":"process"===r(s.process)?"NODE":s.window&&s.document?"BROWSER":"REST"},4270:(t,e,i)=>{var s=i(9565),n=i(4901),r=i(34),o=TypeError;t.exports=function(t,e){var i,h;if("string"===e&&n(i=t.toString)&&!r(h=s(i,t)))return h;if(n(i=t.valueOf)&&!r(h=s(i,t)))return h;if("string"!==e&&n(i=t.toString)&&!r(h=s(i,t)))return h;throw new o("Can't convert object to primitive value")}},4376:(t,e,i)=>{var s=i(2195);t.exports=Array.isArray||function(t){return"Array"===s(t)}},4402:(t,e,i)=>{var s=i(9504),n=Set.prototype;t.exports={Set,add:s(n.add),has:s(n.has),remove:s(n.delete),proto:n}},4449:(t,e,i)=>{var s=i(7080),n=i(4402).has,r=i(5170),o=i(3789),h=i(8469),a=i(507),c=i(9539);t.exports=function(t){var e=s(this),i=o(t);if(r(e)<=i.size)return!1!==h(e,(function(t){if(i.includes(t))return!1}),!0);var l=i.getIterator();return!1!==a(l,(function(t){if(n(e,t))return c(l,"normal",!1)}))}},4483:(t,e,i)=>{var s,n,r,o,h=i(4576),a=i(9429),c=i(1548),l=h.structuredClone,u=h.ArrayBuffer,d=h.MessageChannel,f=!1;if(c)f=function(t){l(t,{transfer:[t]})};else if(u)try{d||(s=a("worker_threads"))&&(d=s.MessageChannel),d&&(n=new d,r=new u(2),o=function(t){n.port1.postMessage(null,[t])},2===r.byteLength&&(o(r),0===r.byteLength&&(f=o)))}catch(t){}t.exports=f},4495:(t,e,i)=>{var s=i(9519),n=i(9039),r=i(4576).String;t.exports=!!Object.getOwnPropertySymbols&&!n((function(){var t=Symbol("symbol detection");return!r(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&s&&s<41}))},4527:(t,e,i)=>{var s=i(3724),n=i(4376),r=TypeError,o=Object.getOwnPropertyDescriptor,h=s&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}();t.exports=h?function(t,e){if(n(t)&&!o(t,"length").writable)throw new r("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e}},4549:(t,e,i)=>{var s=i(4576);t.exports=function(t,e){var i=s.Iterator,n=i&&i.prototype,r=n&&n[t],o=!1;if(r)try{r.call({next:function(){return{done:!0}},return:function(){o=!0}},-1)}catch(t){t instanceof e||(o=!1)}if(!o)return r}},4576:function(t){var e=function(t){return t&&t.Math===Math&&t};t.exports=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof global&&global)||e("object"==typeof this&&this)||function(){return this}()||Function("return this")()},4603:(t,e,i)=>{var s=i(6840),n=i(9504),r=i(655),o=i(2812),h=URLSearchParams,a=h.prototype,c=n(a.append),l=n(a.delete),u=n(a.forEach),d=n([].push),f=new h("a=1&a=2&b=3");f.delete("a",1),f.delete("b",void 0),f+""!="a=2"&&s(a,"delete",(function(t){var e=arguments.length,i=e<2?void 0:arguments[1];if(e&&void 0===i)return l(this,t);var s=[];u(this,(function(t,e){d(s,{key:e,value:t})})),o(e,1);for(var n,h=r(t),a=r(i),f=0,p=0,g=!1,m=s.length;f<m;)n=s[f++],g||n.key===h?(g=!0,l(this,n.key)):p++;for(;p<m;)(n=s[p++]).key===h&&n.value===a||c(this,n.key,n.value)}),{enumerable:!0,unsafe:!0})},4628:(t,e,i)=>{var s=i(6518),n=i(6043);s({target:"Promise",stat:!0},{withResolvers:function(){var t=n.f(this);return{promise:t.promise,resolve:t.resolve,reject:t.reject}}})},4659:(t,e,i)=>{var s=i(3724),n=i(4913),r=i(6980);t.exports=function(t,e,i){s?n.f(t,e,r(0,i)):t[e]=i}},4901:t=>{var e="object"==typeof document&&document.all;t.exports=void 0===e&&void 0!==e?function(t){return"function"==typeof t||t===e}:function(t){return"function"==typeof t}},4913:(t,e,i)=>{var s=i(3724),n=i(5917),r=i(8686),o=i(8551),h=i(6969),a=TypeError,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u="enumerable",d="configurable",f="writable";e.f=s?r?function(t,e,i){if(o(t),e=h(e),o(i),"function"==typeof t&&"prototype"===e&&"value"in i&&f in i&&!i[f]){var s=l(t,e);s&&s[f]&&(t[e]=i.value,i={configurable:d in i?i[d]:s[d],enumerable:u in i?i[u]:s[u],writable:!1})}return c(t,e,i)}:c:function(t,e,i){if(o(t),e=h(e),o(i),n)try{return c(t,e,i)}catch(t){}if("get"in i||"set"in i)throw new a("Accessors not supported");return"value"in i&&(t[e]=i.value),t}},4916:(t,e,i)=>{var s=i(7751),n=function(t){return{size:t,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},r=function(t){return{size:t,has:function(){return!0},keys:function(){throw new Error("e")}}};t.exports=function(t,e){var i=s("Set");try{(new i)[t](n(0));try{return(new i)[t](n(-1)),!1}catch(s){if(!e)return!0;try{return(new i)[t](r(-1/0)),!1}catch(s){var o=new i;return o.add(1),o.add(2),e(o[t](r(1/0)))}}}catch(t){return!1}}},4979:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(7751),o=i(6980),h=i(4913).f,a=i(9297),c=i(679),l=i(3167),u=i(2603),d=i(5002),f=i(8574),p=i(3724),g=i(6395),m="DOMException",w=r("Error"),A=r(m),b=function(){c(this,v);var t=arguments.length,e=u(t<1?void 0:arguments[0]),i=u(t<2?void 0:arguments[1],"Error"),s=new A(e,i),n=new w(e);return n.name=m,h(s,"stack",o(1,f(n.stack,1))),l(s,this,b),s},v=b.prototype=A.prototype,y="stack"in new w(m),x="stack"in new A(1,2),M=A&&p&&Object.getOwnPropertyDescriptor(n,m),E=y&&!!(!M||M.writable&&M.configurable)&&!x;s({global:!0,constructor:!0,forced:g||E},{DOMException:E?b:A});var S=r(m),k=S.prototype;if(k.constructor!==S)for(var C in g||h(k,"constructor",o(1,S)),d)if(a(d,C)){var T=d[C],P=T.s;a(S,P)||h(S,P,o(6,T.c))}},5002:t=>{t.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:(t,e,i)=>{var s=i(6518),n=i(3650);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("symmetricDifference")},{symmetricDifference:n})},5031:(t,e,i)=>{var s=i(7751),n=i(9504),r=i(8480),o=i(3717),h=i(8551),a=n([].concat);t.exports=s("Reflect","ownKeys")||function(t){var e=r.f(h(t)),i=o.f;return i?a(e,i(t)):e}},5169:(t,e,i)=>{var s=i(3238),n=TypeError;t.exports=function(t){if(s(t))throw new n("ArrayBuffer is detached");return t}},5170:(t,e,i)=>{var s=i(6706),n=i(4402);t.exports=s(n.proto,"size","get")||function(t){return t.size}},5370:(t,e,i)=>{var s=i(6198);t.exports=function(t,e,i){for(var n=0,r=arguments.length>2?i:s(e),o=new t(r);r>n;)o[n]=e[n++];return o}},5397:(t,e,i)=>{var s=i(7055),n=i(7750);t.exports=function(t){return s(n(t))}},5610:(t,e,i)=>{var s=i(1291),n=Math.max,r=Math.min;t.exports=function(t,e){var i=s(t);return i<0?n(i+e,0):r(i,e)}},5623:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(9504),o=i(4154),h=i(5169),a=r(1..toString);n.Uint8Array&&s({target:"Uint8Array",proto:!0},{toHex:function(){o(this),h(this.buffer);for(var t="",e=0,i=this.length;e<i;e++){var s=a(this[e],16);t+=1===s.length?"0"+s:s}return t}})},5636:(t,e,i)=>{var s=i(4576),n=i(9504),r=i(6706),o=i(7696),h=i(5169),a=i(7394),c=i(4483),l=i(1548),u=s.structuredClone,d=s.ArrayBuffer,f=s.DataView,p=Math.min,g=d.prototype,m=f.prototype,w=n(g.slice),A=r(g,"resizable","get"),b=r(g,"maxByteLength","get"),v=n(m.getInt8),y=n(m.setInt8);t.exports=(l||c)&&function(t,e,i){var s,n=a(t),r=void 0===e?n:o(e),g=!A||!A(t);if(h(t),l&&(t=u(t,{transfer:[t]}),n===r&&(i||g)))return t;if(n>=r&&(!i||g))s=w(t,0,r);else{var m=i&&!g&&b?{maxByteLength:b(t)}:void 0;s=new d(r,m);for(var x=new f(t),M=new f(s),E=p(r,n),S=0;S<E;S++)y(M,S,v(x,S))}return l||c(t),s}},5745:(t,e,i)=>{var s=i(7629);t.exports=function(t,e){return s[t]||(s[t]=e||{})}},5781:(t,e,i)=>{var s=i(6518),n=i(7751),r=i(2812),o=i(655),h=i(7416),a=n("URL");s({target:"URL",stat:!0,forced:!h},{parse:function(t){var e=r(arguments.length,1),i=o(t),s=e<2||void 0===arguments[1]?void 0:o(arguments[1]);try{return new a(i,s)}catch(t){return null}}})},5876:(t,e,i)=>{var s=i(6518),n=i(3838);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSubsetOf",(function(t){return t}))},{isSubsetOf:n})},5917:(t,e,i)=>{var s=i(3724),n=i(9039),r=i(4055);t.exports=!s&&!n((function(){return 7!==Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))},5966:(t,e,i)=>{var s=i(9306),n=i(4117);t.exports=function(t,e){var i=t[e];return n(i)?void 0:s(i)}},6043:(t,e,i)=>{var s=i(9306),n=TypeError,r=function(t){var e,i;this.promise=new t((function(t,s){if(void 0!==e||void 0!==i)throw new n("Bad Promise constructor");e=t,i=s})),this.resolve=s(e),this.reject=s(i)};t.exports.f=function(t){return new r(t)}},6080:(t,e,i)=>{var s=i(7476),n=i(9306),r=i(616),o=s(s.bind);t.exports=function(t,e){return n(t),void 0===e?t:r?o(t,e):function(){return t.apply(e,arguments)}}},6119:(t,e,i)=>{var s=i(5745),n=i(3392),r=s("keys");t.exports=function(t){return r[t]||(r[t]=n(t))}},6193:(t,e,i)=>{var s=i(4215);t.exports="NODE"===s},6198:(t,e,i)=>{var s=i(8014);t.exports=function(t){return s(t.length)}},6269:t=>{t.exports={}},6279:(t,e,i)=>{var s=i(6840);t.exports=function(t,e,i){for(var n in e)s(t,n,e[n],i);return t}},6319:(t,e,i)=>{var s=i(8551),n=i(9539);t.exports=function(t,e,i,r){try{return r?e(s(i)[0],i[1]):e(i)}catch(e){n(t,"throw",e)}}},6395:t=>{t.exports=!1},6518:(t,e,i)=>{var s=i(4576),n=i(7347).f,r=i(6699),o=i(6840),h=i(9433),a=i(7740),c=i(2796);t.exports=function(t,e){var i,l,u,d,f,p=t.target,g=t.global,m=t.stat;if(i=g?s:m?s[p]||h(p,{}):s[p]&&s[p].prototype)for(l in e){if(d=e[l],u=t.dontCallGetSet?(f=n(i,l))&&f.value:i[l],!c(g?l:p+(m?".":"#")+l,t.forced)&&void 0!==u){if(typeof d==typeof u)continue;a(d,u)}(t.sham||u&&u.sham)&&r(d,"sham",!0),o(i,l,d,t)}}},6573:(t,e,i)=>{var s=i(3724),n=i(2106),r=i(3238),o=ArrayBuffer.prototype;s&&!("detached"in o)&&n(o,"detached",{configurable:!0,get:function(){return r(this)}})},6699:(t,e,i)=>{var s=i(3724),n=i(4913),r=i(6980);t.exports=s?function(t,e,i){return n.f(t,e,r(1,i))}:function(t,e,i){return t[e]=i,t}},6706:(t,e,i)=>{var s=i(9504),n=i(9306);t.exports=function(t,e,i){try{return s(n(Object.getOwnPropertyDescriptor(t,e)[i]))}catch(t){}}},6801:(t,e,i)=>{var s=i(3724),n=i(8686),r=i(4913),o=i(8551),h=i(5397),a=i(1072);e.f=s&&!n?Object.defineProperties:function(t,e){o(t);for(var i,s=h(e),n=a(e),c=n.length,l=0;c>l;)r.f(t,i=n[l++],s[i]);return t}},6823:t=>{var e=String;t.exports=function(t){try{return e(t)}catch(t){return"Object"}}},6837:t=>{var e=TypeError;t.exports=function(t){if(t>9007199254740991)throw e("Maximum allowed index exceeded");return t}},6840:(t,e,i)=>{var s=i(4901),n=i(4913),r=i(283),o=i(9433);t.exports=function(t,e,i,h){h||(h={});var a=h.enumerable,c=void 0!==h.name?h.name:e;if(s(i)&&r(i,c,h),h.global)a?t[e]=i:o(e,i);else{try{h.unsafe?t[e]&&(a=!0):delete t[e]}catch(t){}a?t[e]=i:n.f(t,e,{value:i,enumerable:!1,configurable:!h.nonConfigurable,writable:!h.nonWritable})}return t}},6955:(t,e,i)=>{var s=i(2140),n=i(4901),r=i(2195),o=i(8227)("toStringTag"),h=Object,a="Arguments"===r(function(){return arguments}());t.exports=s?r:function(t){var e,i,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=h(t),o))?i:a?r(e):"Object"===(s=r(e))&&n(e.callee)?"Arguments":s}},6969:(t,e,i)=>{var s=i(2777),n=i(757);t.exports=function(t){var e=s(t,"string");return n(e)?e:e+""}},6980:t=>{t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},7040:(t,e,i)=>{var s=i(4495);t.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},7055:(t,e,i)=>{var s=i(9504),n=i(9039),r=i(2195),o=Object,h=s("".split);t.exports=n((function(){return!o("z").propertyIsEnumerable(0)}))?function(t){return"String"===r(t)?h(t,""):o(t)}:o},7080:(t,e,i)=>{var s=i(4402).has;t.exports=function(t){return s(t),t}},7347:(t,e,i)=>{var s=i(3724),n=i(9565),r=i(8773),o=i(6980),h=i(5397),a=i(6969),c=i(9297),l=i(5917),u=Object.getOwnPropertyDescriptor;e.f=s?u:function(t,e){if(t=h(t),e=a(e),l)try{return u(t,e)}catch(t){}if(c(t,e))return o(!n(r.f,t,e),t[e])}},7394:(t,e,i)=>{var s=i(4576),n=i(6706),r=i(2195),o=s.ArrayBuffer,h=s.TypeError;t.exports=o&&n(o.prototype,"byteLength","get")||function(t){if("ArrayBuffer"!==r(t))throw new h("ArrayBuffer expected");return t.byteLength}},7416:(t,e,i)=>{var s=i(9039),n=i(8227),r=i(3724),o=i(6395),h=n("iterator");t.exports=!s((function(){var t=new URL("b?a=1&b=2&c=3","https://a"),e=t.searchParams,i=new URLSearchParams("a=1&a=2&b=3"),s="";return t.pathname="c%20d",e.forEach((function(t,i){e.delete("b"),s+=i+t})),i.delete("a",2),i.delete("b",void 0),o&&(!t.toJSON||!i.has("a",1)||i.has("a",2)||!i.has("a",void 0)||i.has("b"))||!e.size&&(o||!r)||!e.sort||"https://a/c%20d?a=1&c=3"!==t.href||"3"!==e.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!e[h]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==s||"x"!==new URL("https://x",void 0).host}))},7476:(t,e,i)=>{var s=i(2195),n=i(9504);t.exports=function(t){if("Function"===s(t))return n(t)}},7566:(t,e,i)=>{var s=i(6840),n=i(9504),r=i(655),o=i(2812),h=URLSearchParams,a=h.prototype,c=n(a.getAll),l=n(a.has),u=new h("a=1");!u.has("a",2)&&u.has("a",void 0)||s(a,"has",(function(t){var e=arguments.length,i=e<2?void 0:arguments[1];if(e&&void 0===i)return l(this,t);var s=c(this,t);o(e,1);for(var n=r(i),h=0;h<s.length;)if(s[h++]===n)return!0;return!1}),{enumerable:!0,unsafe:!0})},7629:(t,e,i)=>{var s=i(6395),n=i(4576),r=i(9433),o="__core-js_shared__",h=t.exports=n[o]||r(o,{});(h.versions||(h.versions=[])).push({version:"3.42.0",mode:s?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.42.0/LICENSE",source:"https://github.com/zloirock/core-js"})},7642:(t,e,i)=>{var s=i(6518),n=i(3440);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("difference",(function(t){return 0===t.size}))},{difference:n})},7657:(t,e,i)=>{var s,n,r,o=i(9039),h=i(4901),a=i(34),c=i(2360),l=i(2787),u=i(6840),d=i(8227),f=i(6395),p=d("iterator"),g=!1;[].keys&&("next"in(r=[].keys())?(n=l(l(r)))!==Object.prototype&&(s=n):g=!0),!a(s)||o((function(){var t={};return s[p].call(t)!==t}))?s={}:f&&(s=c(s)),h(s[p])||u(s,p,(function(){return this})),t.exports={IteratorPrototype:s,BUGGY_SAFARI_ITERATORS:g}},7680:(t,e,i)=>{var s=i(9504);t.exports=s([].slice)},7696:(t,e,i)=>{var s=i(1291),n=i(8014),r=RangeError;t.exports=function(t){if(void 0===t)return 0;var e=s(t),i=n(e);if(e!==i)throw new r("Wrong length or index");return i}},7740:(t,e,i)=>{var s=i(9297),n=i(5031),r=i(7347),o=i(4913);t.exports=function(t,e,i){for(var h=n(e),a=o.f,c=r.f,l=0;l<h.length;l++){var u=h[l];s(t,u)||i&&s(i,u)||a(t,u,c(e,u))}}},7750:(t,e,i)=>{var s=i(4117),n=TypeError;t.exports=function(t){if(s(t))throw new n("Can't call method on "+t);return t}},7751:(t,e,i)=>{var s=i(4576),n=i(4901);t.exports=function(t,e){return arguments.length<2?n(i=s[t])?i:void 0:s[t]&&s[t][e];var i}},7811:t=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},7936:(t,e,i)=>{var s=i(6518),n=i(5636);n&&s({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return n(this,arguments.length?arguments[0]:void 0,!1)}})},8004:(t,e,i)=>{var s=i(6518),n=i(9039),r=i(8750);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("intersection",(function(t){return 2===t.size&&t.has(1)&&t.has(2)}))||n((function(){return"3,2"!==String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))}))},{intersection:r})},8014:(t,e,i)=>{var s=i(1291),n=Math.min;t.exports=function(t){var e=s(t);return e>0?n(e,9007199254740991):0}},8100:(t,e,i)=>{var s=i(6518),n=i(5636);n&&s({target:"ArrayBuffer",proto:!0},{transfer:function(){return n(this,arguments.length?arguments[0]:void 0,!0)}})},8111:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(679),o=i(8551),h=i(4901),a=i(2787),c=i(2106),l=i(4659),u=i(9039),d=i(9297),f=i(8227),p=i(7657).IteratorPrototype,g=i(3724),m=i(6395),w="constructor",A="Iterator",b=f("toStringTag"),v=TypeError,y=n[A],x=m||!h(y)||y.prototype!==p||!u((function(){y({})})),M=function(){if(r(this,p),a(this)===p)throw new v("Abstract class Iterator not directly constructable")},E=function(t,e){g?c(p,t,{configurable:!0,get:function(){return e},set:function(e){if(o(this),this===p)throw new v("You can't redefine this property");d(this,t)?this[t]=e:l(this,t,e)}}):p[t]=e};d(p,b)||E(b,A),!x&&d(p,w)&&p[w]!==Object||E(w,M),M.prototype=p,s({global:!0,constructor:!0,forced:x},{Iterator:M})},8227:(t,e,i)=>{var s=i(4576),n=i(5745),r=i(9297),o=i(3392),h=i(4495),a=i(7040),c=s.Symbol,l=n("wks"),u=a?c.for||c:c&&c.withoutSetter||o;t.exports=function(t){return r(l,t)||(l[t]=h&&r(c,t)?c[t]:u("Symbol."+t)),l[t]}},8235:(t,e,i)=>{var s=i(9504),n=i(9297),r=SyntaxError,o=parseInt,h=String.fromCharCode,a=s("".charAt),c=s("".slice),l=s(/./.exec),u={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t"},d=/^[\da-f]{4}$/i,f=/^[\u0000-\u001F]$/;t.exports=function(t,e){for(var i=!0,s="";e<t.length;){var p=a(t,e);if("\\"===p){var g=c(t,e,e+2);if(n(u,g))s+=u[g],e+=2;else{if("\\u"!==g)throw new r('Unknown escape sequence: "'+g+'"');var m=c(t,e+=2,e+4);if(!l(d,m))throw new r("Bad Unicode escape at: "+e);s+=h(o(m,16)),e+=4}}else{if('"'===p){i=!1,e++;break}if(l(f,p))throw new r("Bad control character in string literal at: "+e);s+=p,e++}}if(i)throw new r("Unterminated string at: "+e);return{value:s,end:e}}},8237:(t,e,i)=>{var s=i(6518),n=i(2652),r=i(9306),o=i(8551),h=i(1767),a=i(9539),c=i(4549),l=i(8745),u=i(9039),d=TypeError,f=u((function(){[].keys().reduce((function(){}),void 0)})),p=!f&&c("reduce",d);s({target:"Iterator",proto:!0,real:!0,forced:f||p},{reduce:function(t){o(this);try{r(t)}catch(t){a(this,"throw",t)}var e=arguments.length<2,i=e?void 0:arguments[1];if(p)return l(p,this,e?[t]:[t,i]);var s=h(this),c=0;if(n(s,(function(s){e?(e=!1,i=s):i=t(i,s,c),c++}),{IS_RECORD:!0}),e)throw new d("Reduce of empty iterator with no initial value");return i}})},8335:(t,e,i)=>{var s=i(6518),n=i(3724),r=i(4576),o=i(7751),h=i(9504),a=i(9565),c=i(4901),l=i(34),u=i(4376),d=i(9297),f=i(655),p=i(6198),g=i(4659),m=i(9039),w=i(8235),A=i(4495),b=r.JSON,v=r.Number,y=r.SyntaxError,x=b&&b.parse,M=o("Object","keys"),E=Object.getOwnPropertyDescriptor,S=h("".charAt),k=h("".slice),C=h(/./.exec),T=h([].push),P=/^\d$/,_=/^[1-9]$/,R=/^[\d-]$/,N=/^[\t\n\r ]$/,I=function(t,e,i,s){var n,r,o,h,c,f=t[e],g=s&&f===s.value,m=g&&"string"==typeof s.source?{source:s.source}:{};if(l(f)){var w=u(f),A=g?s.nodes:w?[]:{};if(w)for(n=A.length,o=p(f),h=0;h<o;h++)D(f,h,I(f,""+h,i,h<n?A[h]:void 0));else for(r=M(f),o=p(r),h=0;h<o;h++)D(f,c=r[h],I(f,c,i,d(A,c)?A[c]:void 0))}return a(i,t,e,f,m)},D=function(t,e,i){if(n){var s=E(t,e);if(s&&!s.configurable)return}void 0===i?delete t[e]:g(t,e,i)},F=function(t,e,i,s){this.value=t,this.end=e,this.source=i,this.nodes=s},O=function(t,e){this.source=t,this.index=e};O.prototype={fork:function(t){return new O(this.source,t)},parse:function(){var t=this.source,e=this.skip(N,this.index),i=this.fork(e),s=S(t,e);if(C(R,s))return i.number();switch(s){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 y('Unexpected character: "'+s+'" at: '+e)},node:function(t,e,i,s,n){return new F(e,s,t?null:k(this.source,i,s),n)},object:function(){for(var t=this.source,e=this.index+1,i=!1,s={},n={};e<t.length;){if(e=this.until(['"',"}"],e),"}"===S(t,e)&&!i){e++;break}var r=this.fork(e).string(),o=r.value;e=this.until([":"],e=r.end)+1,e=this.skip(N,e),r=this.fork(e).parse(),g(n,o,r),g(s,o,r.value),e=this.until([",","}"],r.end);var h=S(t,e);if(","===h)i=!0,e++;else if("}"===h){e++;break}}return this.node(1,s,this.index,e,n)},array:function(){for(var t=this.source,e=this.index+1,i=!1,s=[],n=[];e<t.length;){if(e=this.skip(N,e),"]"===S(t,e)&&!i){e++;break}var r=this.fork(e).parse();if(T(n,r),T(s,r.value),e=this.until([",","]"],r.end),","===S(t,e))i=!0,e++;else if("]"===S(t,e)){e++;break}}return this.node(1,s,this.index,e,n)},string:function(){var t=this.index,e=w(this.source,this.index+1);return this.node(0,e.value,t,e.end)},number:function(){var t=this.source,e=this.index,i=e;if("-"===S(t,i)&&i++,"0"===S(t,i))i++;else{if(!C(_,S(t,i)))throw new y("Failed to parse number at: "+i);i=this.skip(P,i+1)}if(!("."===S(t,i)&&(i=this.skip(P,i+1)),"e"!==S(t,i)&&"E"!==S(t,i)||(i++,"+"!==S(t,i)&&"-"!==S(t,i)||i++,i!==(i=this.skip(P,i)))))throw new y("Failed to parse number's exponent value at: "+i);return this.node(0,v(k(t,e,i)),e,i)},keyword:function(t){var e=""+t,i=this.index,s=i+e.length;if(k(this.source,i,s)!==e)throw new y("Failed to parse value at: "+i);return this.node(0,t,i,s)},skip:function(t,e){for(var i=this.source;e<i.length&&C(t,S(i,e));e++);return e},until:function(t,e){e=this.skip(N,e);for(var i=S(this.source,e),s=0;s<t.length;s++)if(t[s]===i)return e;throw new y('Unexpected character: "'+i+'" at: '+e)}};var $=m((function(){var t,e="9007199254740993";return x(e,(function(e,i,s){t=s.source})),t!==e})),L=A&&!m((function(){return 1/x("-0 \t")!=-1/0}));s({target:"JSON",stat:!0,forced:$},{parse:function(t,e){return L&&!c(e)?x(t):function(t,e){t=f(t);var i=new O(t,0),s=i.parse(),n=s.value,r=i.skip(N,s.end);if(r<t.length)throw new y('Unexpected extra character: "'+S(t,r)+'" after the parsed data at: '+r);return c(e)?I({"":n},"",e,s):n}(t,e)}})},8469:(t,e,i)=>{var s=i(9504),n=i(507),r=i(4402),o=r.Set,h=r.proto,a=s(h.forEach),c=s(h.keys),l=c(new o).next;t.exports=function(t,e,i){return i?n({iterator:c(t),next:l},e):a(t,e)}},8480:(t,e,i)=>{var s=i(1828),n=i(8727).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return s(t,n)}},8527:(t,e,i)=>{var s=i(7080),n=i(4402).has,r=i(5170),o=i(3789),h=i(507),a=i(9539);t.exports=function(t){var e=s(this),i=o(t);if(r(e)<i.size)return!1;var c=i.getIterator();return!1!==h(c,(function(t){if(!n(e,t))return a(c,"normal",!1)}))}},8551:(t,e,i)=>{var s=i(34),n=String,r=TypeError;t.exports=function(t){if(s(t))return t;throw new r(n(t)+" is not an object")}},8574:(t,e,i)=>{var s=i(9504),n=Error,r=s("".replace),o=String(new n("zxcasd").stack),h=/\n\s*at [^:]*:[^\n]*/,a=h.test(o);t.exports=function(t,e){if(a&&"string"==typeof t&&!n.prepareStackTrace)for(;e--;)t=r(t,h,"");return t}},8622:(t,e,i)=>{var s=i(4576),n=i(4901),r=s.WeakMap;t.exports=n(r)&&/native code/.test(String(r))},8646:(t,e,i)=>{var s=i(9565),n=i(8551),r=i(1767),o=i(851);t.exports=function(t,e){e&&"string"==typeof t||n(t);var i=o(t);return r(n(void 0!==i?s(i,t):t))}},8686:(t,e,i)=>{var s=i(3724),n=i(9039);t.exports=s&&n((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},8721:(t,e,i)=>{var s=i(3724),n=i(9504),r=i(2106),o=URLSearchParams.prototype,h=n(o.forEach);s&&!("size"in o)&&r(o,"size",{get:function(){var t=0;return h(this,(function(){t++})),t},configurable:!0,enumerable:!0})},8727:t=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},8745:(t,e,i)=>{var s=i(616),n=Function.prototype,r=n.apply,o=n.call;t.exports="object"==typeof Reflect&&Reflect.apply||(s?o.bind(r):function(){return o.apply(r,arguments)})},8750:(t,e,i)=>{var s=i(7080),n=i(4402),r=i(5170),o=i(3789),h=i(8469),a=i(507),c=n.Set,l=n.add,u=n.has;t.exports=function(t){var e=s(this),i=o(t),n=new c;return r(e)>i.size?a(i.getIterator(),(function(t){u(e,t)&&l(n,t)})):h(e,(function(t){i.includes(t)&&l(n,t)})),n}},8773:(t,e)=>{var i={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,n=s&&!i.call({1:2},1);e.f=n?function(t){var e=s(this,t);return!!e&&e.enumerable}:i},8981:(t,e,i)=>{var s=i(7750),n=Object;t.exports=function(t){return n(s(t))}},9039:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},9143:(t,e,i)=>{var s=i(4576),n=i(9504),r=i(3972),o=i(3463),h=i(9297),a=i(2804),c=i(944),l=i(5169),u=a.c2i,d=a.c2iUrl,f=s.SyntaxError,p=s.TypeError,g=n("".charAt),m=function(t,e){for(var i=t.length;e<i;e++){var s=g(t,e);if(" "!==s&&"\t"!==s&&"\n"!==s&&"\f"!==s&&"\r"!==s)break}return e},w=function(t,e,i){var s=t.length;s<4&&(t+=2===s?"AA":"A");var n=(e[g(t,0)]<<18)+(e[g(t,1)]<<12)+(e[g(t,2)]<<6)+e[g(t,3)],r=[n>>16&255,n>>8&255,255&n];if(2===s){if(i&&0!==r[1])throw new f("Extra bits");return[r[0]]}if(3===s){if(i&&0!==r[2])throw new f("Extra bits");return[r[0],r[1]]}return r},A=function(t,e,i){for(var s=e.length,n=0;n<s;n++)t[i+n]=e[n];return i+s};t.exports=function(t,e,i,s){o(t),r(e);var n="base64"===c(e)?u:d,a=e?e.lastChunkHandling:void 0;if(void 0===a&&(a="loose"),"loose"!==a&&"strict"!==a&&"stop-before-partial"!==a)throw new p("Incorrect `lastChunkHandling` option");i&&l(i.buffer);var b=i||[],v=0,y=0,x="",M=0;if(s)for(;;){if((M=m(t,M))===t.length){if(x.length>0){if("stop-before-partial"===a)break;if("loose"!==a)throw new f("Missing padding");if(1===x.length)throw new f("Malformed padding: exactly one additional character");v=A(b,w(x,n,!1),v)}y=t.length;break}var E=g(t,M);if(++M,"="===E){if(x.length<2)throw new f("Padding is too early");if(M=m(t,M),2===x.length){if(M===t.length){if("stop-before-partial"===a)break;throw new f("Malformed padding: only one =")}"="===g(t,M)&&(++M,M=m(t,M))}if(M<t.length)throw new f("Unexpected character after padding");v=A(b,w(x,n,"strict"===a),v),y=t.length;break}if(!h(n,E))throw new f("Unexpected character");var S=s-v;if(1===S&&2===x.length||2===S&&3===x.length)break;if(4===(x+=E).length&&(v=A(b,w(x,n,!1),v),x="",y=M,v===s))break}return{bytes:b,read:y,written:v}}},9286:(t,e,i)=>{var s=i(4402),n=i(8469),r=s.Set,o=s.add;t.exports=function(t){var e=new r;return n(t,(function(t){o(e,t)})),e}},9297:(t,e,i)=>{var s=i(9504),n=i(8981),r=s({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return r(n(t),e)}},9306:(t,e,i)=>{var s=i(4901),n=i(6823),r=TypeError;t.exports=function(t){if(s(t))return t;throw new r(n(t)+" is not a function")}},9314:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(8551),o=i(1767),h=i(4149),a=i(9590),c=i(9539),l=i(9462),u=i(4549),d=i(6395),f=!d&&u("drop",RangeError),p=l((function(){for(var t,e=this.iterator,i=this.next;this.remaining;)if(this.remaining--,t=r(n(i,e)),this.done=!!t.done)return;if(t=r(n(i,e)),!(this.done=!!t.done))return t.value}));s({target:"Iterator",proto:!0,real:!0,forced:d||f},{drop:function(t){var e;r(this);try{e=a(h(+t))}catch(t){c(this,"throw",t)}return f?n(f,this,e):new p(o(this),{remaining:e})}})},9429:(t,e,i)=>{var s=i(4576),n=i(6193);t.exports=function(t){if(n){try{return s.process.getBuiltinModule(t)}catch(t){}try{return Function('return require("'+t+'")')()}catch(t){}}}},9432:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(5370),o=i(9143),h=n.Uint8Array;h&&s({target:"Uint8Array",stat:!0},{fromBase64:function(t){var e=o(t,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return r(h,e.bytes)}})},9433:(t,e,i)=>{var s=i(4576),n=Object.defineProperty;t.exports=function(t,e){try{n(s,t,{value:e,configurable:!0,writable:!0})}catch(i){s[t]=e}return e}},9462:(t,e,i)=>{var s=i(9565),n=i(2360),r=i(6699),o=i(6279),h=i(8227),a=i(1181),c=i(5966),l=i(7657).IteratorPrototype,u=i(2529),d=i(9539),f=h("toStringTag"),p="IteratorHelper",g="WrapForValidIterator",m=a.set,w=function(t){var e=a.getterFor(t?g:p);return o(n(l),{next:function(){var i=e(this);if(t)return i.nextHandler();if(i.done)return u(void 0,!0);try{var s=i.nextHandler();return i.returnHandlerResult?s:u(s,i.done)}catch(t){throw i.done=!0,t}},return:function(){var i=e(this),n=i.iterator;if(i.done=!0,t){var r=c(n,"return");return r?s(r,n):u(void 0,!0)}if(i.inner)try{d(i.inner.iterator,"normal")}catch(t){return d(n,"throw",t)}return n&&d(n,"normal"),u(void 0,!0)}})},A=w(!0),b=w(!1);r(b,f,"Iterator Helper"),t.exports=function(t,e,i){var s=function(s,n){n?(n.iterator=s.iterator,n.next=s.next):n=s,n.type=e?g:p,n.returnHandlerResult=!!i,n.nextHandler=t,n.counter=0,n.done=!1,m(this,n)};return s.prototype=e?A:b,s}},9504:(t,e,i)=>{var s=i(616),n=Function.prototype,r=n.call,o=s&&n.bind.bind(r,r);t.exports=s?o:function(t){return function(){return r.apply(t,arguments)}}},9519:(t,e,i)=>{var s,n,r=i(4576),o=i(2839),h=r.process,a=r.Deno,c=h&&h.versions||a&&a.version,l=c&&c.v8;l&&(n=(s=l.split("."))[0]>0&&s[0]<4?1:+(s[0]+s[1])),!n&&o&&(!(s=o.match(/Edge\/(\d+)/))||s[1]>=74)&&(s=o.match(/Chrome\/(\d+)/))&&(n=+s[1]),t.exports=n},9539:(t,e,i)=>{var s=i(9565),n=i(8551),r=i(5966);t.exports=function(t,e,i){var o,h;n(t);try{if(!(o=r(t,"return"))){if("throw"===e)throw i;return i}o=s(o,t)}catch(t){h=!0,o=t}if("throw"===e)throw i;if(h)throw o;return n(o),i}},9565:(t,e,i)=>{var s=i(616),n=Function.prototype.call;t.exports=s?n.bind(n):function(){return n.apply(n,arguments)}},9590:(t,e,i)=>{var s=i(1291),n=RangeError;t.exports=function(t){var e=s(t);if(e<0)throw new n("The argument can't be less than 0");return e}},9617:(t,e,i)=>{var s=i(5397),n=i(5610),r=i(6198),o=function(t){return function(e,i,o){var h=s(e),a=r(h);if(0===a)return!t&&-1;var c,l=n(o,a);if(t&&i!=i){for(;a>l;)if((c=h[l++])!=c)return!0}else for(;a>l;l++)if((t||l in h)&&h[l]===i)return t||l||0;return!t&&-1}};t.exports={includes:o(!0),indexOf:o(!1)}},9631:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(9504),o=i(3972),h=i(4154),a=i(5169),c=i(2804),l=i(944),u=c.i2c,d=c.i2cUrl,f=r("".charAt);n.Uint8Array&&s({target:"Uint8Array",proto:!0},{toBase64:function(){var t=h(this),e=arguments.length?o(arguments[0]):void 0,i="base64"===l(e)?u:d,s=!!e&&!!e.omitPadding;a(this.buffer);for(var n,r="",c=0,p=t.length,g=function(t){return f(i,n>>6*t&63)};c+2<p;c+=3)n=(t[c]<<16)+(t[c+1]<<8)+t[c+2],r+=g(3)+g(2)+g(1)+g(0);return c+2===p?(n=(t[c]<<16)+(t[c+1]<<8),r+=g(3)+g(2)+g(1)+(s?"":"=")):c+1===p&&(n=t[c]<<16,r+=g(3)+g(2)+(s?"":"==")),r}})},9797:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(3463),o=i(4154),h=i(5169),a=i(2303);n.Uint8Array&&s({target:"Uint8Array",proto:!0},{setFromHex:function(t){o(this),r(t),h(this.buffer);var e=a(t,this).read;return{read:e,written:e/2}}})}},g={};function m(t){var e=g[t];if(void 0!==e)return e.exports;var i=g[t]={exports:{}};return p[t].call(i.exports,i,i.exports,m),i.exports}m(4114),m(6573),m(8100),m(7936),m(8111),m(8237),m(1689),m(9432),m(1549),m(9797),m(9631),m(5623),m(4979),m(5781);const w=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),A=[.001,0,0,.001,0,0],b=1.35,v={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},y={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101},x={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_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},M={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},E={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},S={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},k={ERRORS:0,WARNINGS:1,INFOS:5},C={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},T={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let P=k.WARNINGS;function _(t){Number.isInteger(t)&&(P=t)}function R(){return P}function N(t){P>=k.INFOS&&console.log(`Info: ${t}`)}function I(t){P>=k.WARNINGS&&console.log(`Warning: ${t}`)}function D(t){throw new Error(t)}function F(t,e){t||D(e)}function O(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s)?s:null}function $(t,e,i=!1){const s=URL.parse(t);return s?(s.hash=e,s.href):i&&O(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function L(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const B=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class U extends B{constructor(t,e){super(t,"PasswordException"),this.code=e}}class j extends B{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class z extends B{constructor(t){super(t,"InvalidPDFException")}}class H extends B{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class G extends B{constructor(t){super(t,"FormatError")}}class W extends B{constructor(t){super(t,"AbortException")}}function V(t){"object"==typeof t&&void 0!==t?.length||D("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const r=Math.min(n+i,e),o=t.subarray(n,r);s.push(String.fromCharCode.apply(null,o))}return s.join("")}function X(t){"string"!=typeof t&&D("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class Y{static get isLittleEndian(){return L(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return L(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return L(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return L(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){const{platform:t,userAgent:e}=navigator;return L(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 L(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const q=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class Q{static makeHexColor(t,e,i){return`#${q[t]}${q[e]}${q[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e,i=0){const s=t[i],n=t[i+1];t[i]=s*e[0]+n*e[2]+e[4],t[i+1]=s*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const s=e[0],n=e[1],r=e[2],o=e[3],h=e[4],a=e[5];for(let e=0;e<6;e+=2){const c=t[i+e],l=t[i+e+1];t[i+e]=c*s+l*r+h,t[i+e+1]=c*n+l*o+a}}static applyInverseTransform(t,e){const i=t[0],s=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,i){const s=e[0],n=e[1],r=e[2],o=e[3],h=e[4],a=e[5],c=t[0],l=t[1],u=t[2],d=t[3];let f=s*c+h,p=f,g=s*u+h,m=g,w=o*l+a,A=w,b=o*d+a,v=b;if(0!==n||0!==r){const t=n*c,e=n*u,i=r*l,s=r*d;f+=i,m+=i,g+=s,p+=s,w+=t,v+=t,b+=e,A+=e}i[0]=Math.min(i[0],f,g,p,m),i[1]=Math.min(i[1],w,b,A,v),i[2]=Math.max(i[2],f,g,p,m),i[3]=Math.max(i[3],w,b,A,v)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const i=t[0],s=t[1],n=t[2],r=t[3],o=i**2+s**2,h=n**2+r**2,a=(o+h)/2,c=Math.sqrt(a**2-(o*h-(i*n+s*r)**2));e[0]=Math.sqrt(a+c||1),e[1]=Math.sqrt(a-c||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,n){n[0]=Math.min(n[0],t,i),n[1]=Math.min(n[1],e,s),n[2]=Math.max(n[2],t,i),n[3]=Math.max(n[3],e,s)}static#t(t,e,i,s,n,r,o,h,a,c){if(a<=0||a>=1)return;const l=1-a,u=a*a,d=u*a,f=l*(l*(l*t+3*a*e)+3*u*i)+d*s,p=l*(l*(l*n+3*a*r)+3*u*o)+d*h;c[0]=Math.min(c[0],f),c[1]=Math.min(c[1],p),c[2]=Math.max(c[2],f),c[3]=Math.max(c[3],p)}static#e(t,e,i,s,n,r,o,h,a,c,l,u){if(Math.abs(a)<1e-12)return void(Math.abs(c)>=1e-12&&this.#t(t,e,i,s,n,r,o,h,-l/c,u));const d=c**2-4*l*a;if(d<0)return;const f=Math.sqrt(d),p=2*a;this.#t(t,e,i,s,n,r,o,h,(-c+f)/p,u),this.#t(t,e,i,s,n,r,o,h,(-c-f)/p,u)}static bezierBoundingBox(t,e,i,s,n,r,o,h,a){a[0]=Math.min(a[0],t,o),a[1]=Math.min(a[1],e,h),a[2]=Math.max(a[2],t,o),a[3]=Math.max(a[3],e,h),this.#e(t,i,n,o,e,s,r,h,3*(3*(i-n)-t+o),6*(t-2*i+n),3*(i-t),a),this.#e(t,i,n,o,e,s,r,h,3*(3*(s-r)-e+h),6*(e-2*s+r),3*(s-e),a)}}let K=null,J=null;function Z(t){return K||(K=/([\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,J=new Map([["ſt","ſt"]])),t.replaceAll(K,((t,e,i)=>e?e.normalize("NFKC"):J.get(i)))}function tt(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),V(t)}const et="pdfjs_internal_id_";function it(t,e,i){return Math.min(Math.max(t,e),i)}function st(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(V(t))}"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce(((t,e)=>t+e),0)}),"function"!=typeof AbortSignal.any&&(AbortSignal.any=function(t){const e=new AbortController,{signal:i}=e;for(const s of t)if(s.aborted)return e.abort(s.reason),i;for(const s of t)s.addEventListener("abort",(()=>{e.abort(s.reason)}),{signal:i});return i}),m(1701),m(4628),m(7642),m(8004),m(3853),m(5876),m(2475),m(5024),m(1698),m(4603),m(7566),m(8721),m(9314),m(1148),m(3579),m(8335);const nt="http://www.w3.org/2000/svg";class rt{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function ot(t,e="text"){if(pt(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class ht{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const h=(t[2]+t[0])/2,a=(t[3]+t[1])/2;let c,l,u,d,f,p,g,m;switch((s%=360)<0&&(s+=360),s){case 180:c=-1,l=0,u=0,d=1;break;case 90:c=0,l=1,u=1,d=0;break;case 270:c=0,l=-1,u=-1,d=0;break;case 0:c=1,l=0,u=0,d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(u=-u,d=-d),0===c?(f=Math.abs(a-t[1])*i+n,p=Math.abs(h-t[0])*i+r,g=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(f=Math.abs(h-t[0])*i+n,p=Math.abs(a-t[1])*i+r,g=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[c*i,l*i,u*i,d*i,f-c*i*h-u*i*a,p-l*i*h-d*i*a],this.width=g,this.height=m}get rawDims(){const t=this.viewBox;return L(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new ht({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){const i=[t,e];return Q.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];Q.applyTransform(e,this.transform);const i=[t[2],t[3]];return Q.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return Q.applyInverseTransform(i,this.transform),i}}class at extends B{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function ct(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function lt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function ut(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function dt(t,e="document.pdf"){if("string"!=typeof t)return e;if(ct(t))return I('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e}class ft{started=Object.create(null);times=[];time(t){t in this.started&&I(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||I(`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:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function pt(t,e){const i=e?URL.parse(t,e):URL.parse(t);return"http:"===i?.protocol||"https:"===i?.protocol}function gt(t){t.preventDefault()}function mt(t){t.preventDefault(),t.stopPropagation()}class wt{static#i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let h=parseInt(e[6],10);h=h>=0&&h<=59?h:0;const a=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let l=parseInt(e[9],10)||0;return l=l>=0&&l<=59?l:0,"-"===a?(r+=c,o+=l):"+"===a&&(r-=c,o-=l),new Date(Date.UTC(i,s,n,r,o,h))}}function At(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new ht({viewBox:r,userUnit:1,scale:e,rotation:i})}function bt(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(I(`Not a valid color format: "${t}"`),[0,0,0])}function vt(t){const{a:e,b:i,c:s,d:n,e:r,f:o}=t.getTransform();return[e,i,s,n,r,o]}function yt(t){const{a:e,b:i,c:s,d:n,e:r,f:o}=t.getTransform().invertSelf();return[e,i,s,n,r,o]}function xt(t,e,i=!1,s=!0){if(e instanceof ht){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,o=Y.isCSSRoundSupported,h=`var(--total-scale-factor) * ${s}px`,a=`var(--total-scale-factor) * ${n}px`,c=o?`round(down, ${h}, var(--scale-round-x))`:`calc(${h})`,l=o?`round(down, ${a}, var(--scale-round-y))`:`calc(${a})`;i&&e.rotation%180!=0?(r.width=l,r.height=c):(r.width=c,r.height=l)}s&&t.setAttribute("data-main-rotation",e.rotation)}class Mt{constructor(){const{pixelRatio:t}=Mt;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,n=-1){let r=1/0,o=1/0,h=1/0;(i=Mt.capPixels(i,n))>0&&(r=Math.sqrt(i/(t*e))),-1!==s&&(o=s/t,h=s/e);const a=Math.min(r,o,h);return(this.sx>a||this.sy>a)&&(this.sx=a,this.sy=a,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}const Et=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class St{#s=null;#n=null;#r;#o=null;#h=null;#a=null;static#c=null;constructor(t){this.#r=t,St.#c||=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.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#r._uiManager._signal;t.addEventListener("contextmenu",gt,{signal:e}),t.addEventListener("pointerdown",St.#l,{signal:e});const i=this.#o=document.createElement("div");i.className="buttons",t.append(i);const s=this.#r.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#u(),t}get div(){return this.#s}static#l(t){t.stopPropagation()}#d(t){this.#r._focusEventsAllowed=!1,mt(t)}#f(t){this.#r._focusEventsAllowed=!0,mt(t)}#p(t){const e=this.#r._uiManager._signal;t.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#f.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",gt,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#h?.shown()}#u(){const{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",St.#c[t]),this.#p(i),i.addEventListener("click",(()=>{e.delete()}),{signal:e._signal}),this.#o.append(i)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#o.prepend(e,this.#g),this.#h=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#p(e),this.#o.prepend(e,this.#g)}async addEditSignatureButton(t){const e=this.#a=await t.renderEditButton(this.#r);this.#p(e),this.#o.prepend(e,this.#g)}updateEditSignatureButton(t){this.#a&&(this.#a.title=t)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class kt{#o=null;#s=null;#m;constructor(t){this.#m=t}#w(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",gt,{signal:this.#m._signal});const e=this.#o=document.createElement("div");return e.className="buttons",t.append(e),this.#A(),t}#b(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const r=n.x+(e?n.width:0);t>i?(s=r,i=t):e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#b(e,i),{style:r}=this.#s||=this.#w();t.append(this.#s),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#A(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#m._signal;t.addEventListener("contextmenu",gt,{signal:i}),t.addEventListener("click",(()=>{this.#m.highlightSelection("floating_button")}),{signal:i}),this.#o.append(t)}}function Ct(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class Tt{#v=0;get id(){return"pdfjs_internal_editor_"+this.#v++}}class Pt{#y=tt();#v=0;#x=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',L(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#M(t,e){this.#x||=new Map;let i=this.#x.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#y}_${this.#v++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await ot(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Pt._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise(((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r}));s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){I(t),i=null}return this.#x.set(t,i),i&&this.#x.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#M(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#M(t,t)}async getFromBlob(t,e){const i=await e;return this.#M(t,i)}async getFromId(t){this.#x||=new Map;const e=this.#x.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#x||=new Map;let i=this.#x.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#y}_${this.#v++}`,refCounter:1,isSvg:!1},this.#x.set(t,i),this.#x.set(i.id,i),i}getSvgUrl(t){const e=this.#x.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#x||=new Map;const e=this.#x.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#y}_`)}}class _t{#E=[];#S=!1;#k;#C=-1;constructor(t=128){this.#k=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:o=!1}){if(s&&t(),this.#S)return;const h={cmd:t,undo:e,post:i,type:n};if(-1===this.#C)return this.#E.length>0&&(this.#E.length=0),this.#C=0,void this.#E.push(h);if(r&&this.#E[this.#C].type===n)return o&&(h.undo=this.#E[this.#C].undo),void(this.#E[this.#C]=h);const a=this.#C+1;a===this.#k?this.#E.splice(0,1):(this.#C=a,a<this.#E.length&&this.#E.splice(a)),this.#E.push(h)}undo(){if(-1===this.#C)return;this.#S=!0;const{undo:t,post:e}=this.#E[this.#C];t(),e?.(),this.#S=!1,this.#C-=1}redo(){if(this.#C<this.#E.length-1){this.#C+=1,this.#S=!0;const{cmd:t,post:e}=this.#E[this.#C];t(),e?.(),this.#S=!1}}hasSomethingToUndo(){return-1!==this.#C}hasSomethingToRedo(){return this.#C<this.#E.length-1}cleanType(t){if(-1!==this.#C){for(let e=this.#C;e>=0;e--)if(this.#E[e].type!==t)return this.#E.splice(e+1,this.#C-e),void(this.#C=e);this.#E.length=0,this.#C=-1}}destroy(){this.#E=null}}class Rt{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Y.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.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 i=this.callbacks.get(this.#T(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:o=null}}=i;o&&!o(t,e)||(s.bind(t,...r,e)(),n||mt(e))}}class Nt{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,bt(s))}e.remove()}(t),L(this,"_colors",t)}convert(t){const e=bt(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,i]of this._colors)if(i.every(((t,i)=>t===e[i])))return Nt._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?Q.makeHexColor(...e):t}}class It{#P=new AbortController;#_=null;#R=new Map;#N=new Map;#I=null;#D=null;#F=null;#O=new _t;#$=null;#L=null;#B=0;#U=new Set;#j=null;#z=null;#H=new Set;_editorUndoBar=null;#G=!1;#W=!1;#V=!1;#X=null;#Y=null;#q=null;#Q=null;#K=!1;#J=null;#Z=new Tt;#tt=!1;#et=!1;#it=null;#st=null;#nt=null;#rt=null;#ot=null;#ht=y.NONE;#at=new Set;#ct=null;#lt=null;#ut=null;#dt=null;#ft={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#pt=[0,0];#gt=null;#mt=null;#wt=null;#At=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=It.prototype,e=t=>t.#mt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return L(this,"_keyboardManager",new Rt([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#mt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#mt.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,i,s,n,r,o,h,a,c,l,u,d,f){const p=this._signal=this.#P.signal;this.#mt=t,this.#wt=e,this.#I=i,this.#lt=s,this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:p}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),n._on("setpreference",this.onSetPreference.bind(this),{signal:p}),n._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),this.#bt(),this.#vt(),this.#yt(),this.#D=r.annotationStorage,this.#X=r.filterFactory,this.#ut=o,this.#Q=h||null,this.#G=a,this.#W=c,this.#V=l,this.#ot=u||null,this.viewParameters={realScale:rt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=d||null,this._supportsPinchToZoom=!1!==f}destroy(){this.#At?.resolve(),this.#At=null,this.#P?.abort(),this.#P=null,this._signal=null;for(const t of this.#N.values())t.destroy();this.#N.clear(),this.#R.clear(),this.#H.clear(),this.#rt?.clear(),this.#_=null,this.#at.clear(),this.#O.destroy(),this.#I?.destroy(),this.#lt?.destroy(),this.#J?.hide(),this.#J=null,this.#nt?.destroy(),this.#nt=null,this.#Y&&(clearTimeout(this.#Y),this.#Y=null),this.#gt&&(clearTimeout(this.#gt),this.#gt=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#ot}get useNewAltTextFlow(){return this.#W}get useNewAltTextWhenAddingImage(){return this.#V}get hcmFilter(){return L(this,"hcmFilter",this.#ut?this.#X.addHCMFilter(this.#ut.foreground,this.#ut.background):"none")}get direction(){return L(this,"direction",getComputedStyle(this.#mt).direction)}get highlightColors(){return L(this,"highlightColors",this.#Q?new Map(this.#Q.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return L(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#L=t}setMainHighlightColorPicker(t){this.#nt=t}editAltText(t,e=!1){this.#I?.editAltText(this,t,e)}getSignature(t){this.#lt?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#lt}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}){"enableNewAltTextWhenAddingImage"===t&&(this.#V=e)}onPageChanging({pageNumber:t}){this.#B=t-1}focusMainContainer(){this.#mt.focus()}findParent(t,e){for(const i of this.#N.values()){const{x:s,y:n,width:r,height:o}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+o)return i}return null}disableUserSelect(t=!1){this.#wt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#H.add(t)}removeShouldRescale(t){this.#H.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*rt.PDF_TO_CSS_UNITS;for(const t of this.#H)t.onScaleChanging();this.#L?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#xt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#Mt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#N.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}=e,o=e.toString(),h=this.#xt(e).closest(".textLayer"),a=this.getSelectionBoxes(h);if(!a)return;e.empty();const c=this.#Mt(h),l=this.#ht===y.NONE,u=()=>{c?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:a,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r,text:o}),l&&this.showAllEditors("highlight",!0,!0)};l?this.switchToMode(y.HIGHLIGHT,u):u()}#Et(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#xt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#J||=new kt(this),this.#J.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#D||this.#D.has(t.id)||this.#D.setValue(t.id,t)}#St(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ct&&(this.#J?.hide(),this.#ct=null,this.#kt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ct)return;const i=this.#xt(t).closest(".textLayer");if(i){if(this.#J?.hide(),this.#ct=e,this.#kt({hasSelectedText:!0}),(this.#ht===y.HIGHLIGHT||this.#ht===y.NONE)&&(this.#ht===y.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#K=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#ht===y.HIGHLIGHT?this.#Mt(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#Ct("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ct&&(this.#J?.hide(),this.#ct=null,this.#kt({hasSelectedText:!1}))}#Ct(t=""){this.#ht===y.HIGHLIGHT?this.highlightSelection(t):this.#G&&this.#Et()}#bt(){document.addEventListener("selectionchange",this.#St.bind(this),{signal:this._signal})}#Tt(){if(this.#q)return;this.#q=new AbortController;const t=this.combinedSignal(this.#q);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Pt(){this.#q?.abort(),this.#q=null}blur(){if(this.isShiftKeyDown=!1,this.#K&&(this.#K=!1,this.#Ct("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#at)if(e.div.contains(t)){this.#st=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#st)return;const[t,e]=this.#st;this.#st=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#yt(){if(this.#it)return;this.#it=new AbortController;const t=this.combinedSignal(this.#it);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#_t(){this.#it?.abort(),this.#it=null}#Rt(){if(this.#$)return;this.#$=new AbortController;const t=this.combinedSignal(this.#$);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})}#Nt(){this.#$?.abort(),this.#$=null}#vt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#yt(),this.#Rt()}removeEditListeners(){this.#_t(),this.#Nt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#z)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#z)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#_?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#at){const i=t.serialize(!0);i&&e.push(i)}0!==e.length&&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 t of e.items)for(const e of this.#z)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void I(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=await s.deserialize(e);if(!i)return;t.push(i)}this.addCommands({cmd:()=>{for(const e of t)this.#It(e);this.#Dt(t)},undo:()=>{for(const e of t)e.remove()},mustExec:!0})}catch(t){I(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#ht===y.NONE||this.isEditorHandlingKeyboard||It._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#K&&(this.#K=!1,this.#Ct("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#kt(t){Object.entries(t).some((([t,e])=>this.#ft[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#ft,t)}),this.#ht===y.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Ft([[x.HIGHLIGHT_FREE,!0]]))}#Ft(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Tt(),this.#Rt(),this.#kt({isEditing:this.#ht!==y.NONE,isEmpty:this.#Ot(),hasSomethingToUndo:this.#O.hasSomethingToUndo(),hasSomethingToRedo:this.#O.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Pt(),this.#Nt(),this.#kt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#z){this.#z=t;for(const t of this.#z)this.#Ft(t.defaultPropertiesToUpdate)}}getId(){return this.#Z.id}get currentLayer(){return this.#N.get(this.#B)}getLayer(t){return this.#N.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#N.set(t.pageIndex,t),this.#tt?t.enable():t.disable()}removeLayer(t){this.#N.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#ht!==t&&(!this.#At||(await this.#At.promise,this.#At))){if(this.#At=Promise.withResolvers(),this.#L?.commitOrRemove(),this.#ht=t,t===y.NONE)return this.setEditingState(!1),this.#$t(),this._editorUndoBar?.hide(),void this.#At.resolve();t===y.SIGNATURE&&await(this.#lt?.loadSignatures()),this.setEditingState(!0),await this.#Lt(),this.unselectAll();for(const e of this.#N.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#At.resolve();for(const t of this.#R.values())t.annotationElementId===e||t.id===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#At.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#ht&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#z){switch(t){case x.CREATE:return void this.currentLayer.addNewEditor(e);case x.HIGHLIGHT_DEFAULT_COLOR:this.#nt?.updateColor(e);break;case x.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#dt||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#at)i.updateParams(t,e);for(const i of this.#z)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#R.values())i.editorType===t&&i.show(e);(this.#dt?.get(x.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Ft([[x.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#et!==t){this.#et=t;for(const e of this.#N.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Lt(){if(!this.#tt){this.#tt=!0;const t=[];for(const e of this.#N.values())t.push(e.enable());await Promise.all(t);for(const t of this.#R.values())t.enable()}}#$t(){if(this.unselectAll(),this.#tt){this.#tt=!1;for(const t of this.#N.values())t.disable();for(const t of this.#R.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#R.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#R.get(t)}addEditor(t){this.#R.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#Y&&clearTimeout(this.#Y),this.#Y=setTimeout((()=>{this.focusMainContainer(),this.#Y=null}),0)),this.#R.delete(t.id),t.annotationElementId&&this.#rt?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#U.has(t.annotationElementId)||this.#D?.remove(t.id)}addDeletedAnnotationElement(t){this.#U.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#U.has(t)}removeDeletedAnnotationElement(t){this.#U.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#It(t){const e=this.#N.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#_!==t&&(this.#_=t,t&&this.#Ft(t.propertiesToUpdate))}get#Bt(){let t=null;for(t of this.#at);return t}updateUI(t){this.#Bt===t&&this.#Ft(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Ft(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#at.has(t))return this.#at.delete(t),t.unselect(),void this.#kt({hasSelectedEditor:this.hasSelection});this.#at.add(t),t.select(),this.#Ft(t.propertiesToUpdate),this.#kt({hasSelectedEditor:!0})}setSelected(t){this.#L?.commitOrRemove();for(const e of this.#at)e!==t&&e.unselect();this.#at.clear(),this.#at.add(t),t.select(),this.#Ft(t.propertiesToUpdate),this.#kt({hasSelectedEditor:!0})}isSelected(t){return this.#at.has(t)}get firstSelectedEditor(){return this.#at.values().next().value}unselect(t){t.unselect(),this.#at.delete(t),this.#kt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#at.size}get isEnterHandled(){return 1===this.#at.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#O.undo(),this.#kt({hasSomethingToUndo:this.#O.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Ot()}),this._editorUndoBar?.hide()}redo(){this.#O.redo(),this.#kt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#O.hasSomethingToRedo(),isEmpty:this.#Ot()})}addCommands(t){this.#O.add(t),this.#kt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Ot()})}cleanUndoStack(t){this.#O.cleanType(t)}#Ot(){if(0===this.#R.size)return!0;if(1===this.#R.size)for(const t of this.#R.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.#at],i=()=>{for(const t of e)this.#It(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#_?.commitOrRemove()}hasSomethingToControl(){return this.#_||this.hasSelection}#Dt(t){for(const t of this.#at)t.unselect();this.#at.clear();for(const e of t)e.isEmpty()||(this.#at.add(e),e.select());this.#kt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#at)t.commit();this.#Dt(this.#R.values())}unselectAll(){if((!this.#_||(this.#_.commitOrRemove(),this.#ht===y.NONE))&&!this.#L?.commitOrRemove()&&this.hasSelection){for(const t of this.#at)t.unselect();this.#at.clear(),this.#kt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#pt[0]+=t,this.#pt[1]+=e;const[s,n]=this.#pt,r=[...this.#at];this.#gt&&clearTimeout(this.#gt),this.#gt=setTimeout((()=>{this.#gt=null,this.#pt[0]=this.#pt[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#R.has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(const t of r)this.#R.has(t.id)&&(t.translateInPage(-s,-n),t.translationDone())},mustExec:!1})}),1e3);for(const i of r)i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#j=new Map;for(const t of this.#at)this.#j.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#j)return!1;this.disableUserSelect(!1);const t=this.#j;this.#j=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},r]of t)r.newX=i,r.newY=s,r.newPageIndex=n,e||=i!==r.savedX||s!==r.savedY||n!==r.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#R.has(t.id)){const n=this.#N.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:r}]of t)i(e,s,n,r)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#j)for(const i of this.#j.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#at.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#_===t}getActive(){return this.#_}getMode(){return this.#ht}get imageManager(){return L(this,"imageManager",new Pt)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(t,e,o,h)=>({x:(e-s)/r,y:1-(t+o-i)/n,width:h/r,height:o/n});break;case"180":o=(t,e,o,h)=>({x:1-(t+o-i)/n,y:1-(e+h-s)/r,width:o/n,height:h/r});break;case"270":o=(t,e,o,h)=>({x:1-(e+h-s)/r,y:(t-i)/n,width:h/r,height:o/n});break;default:o=(t,e,o,h)=>({x:(t-i)/n,y:(e-s)/r,width:o/n,height:h/r})}const h=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:n}of i.getClientRects())0!==s&&0!==n&&h.push(o(t,e,s,n))}return 0===h.length?null:h}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#F||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#F?.delete(t)}renderAnnotationElement(t){const e=this.#F?.get(t.data.id);if(!e)return;const i=this.#D.getRawValue(e);i&&(this.#ht!==y.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){const s=this.#rt?.get(t);s&&(s.setCanvas(e,i),this.#rt.delete(t))}addMissingCanvas(t,e){(this.#rt||=new Map).set(t,e)}}class Dt{#h=null;#Ut=!1;#jt=null;#zt=null;#Ht=null;#Gt=null;#Wt=!1;#Vt=null;#r=null;#Xt=null;#Yt=null;#qt=!1;static#Qt=null;static _l10n=null;constructor(t){this.#r=t,this.#qt=t._uiManager.useNewAltTextFlow,Dt.#Qt||=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){Dt._l10n??=t}async render(){const t=this.#jt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#zt=document.createElement("span");t.append(e),this.#qt?(t.classList.add("new"),t.setAttribute("data-l10n-id",Dt.#Qt.missing),e.setAttribute("data-l10n-id",Dt.#Qt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#r._uiManager._signal;t.addEventListener("contextmenu",gt,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#qt&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Kt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#Wt=!0,s(e))}),{signal:i}),await this.#Jt(),t}get#Kt(){return(this.#h?"added":null===this.#h&&this.guessedText&&"review")||"missing"}finish(){this.#jt&&(this.#jt.focus({focusVisible:this.#Wt}),this.#Wt=!1)}isEmpty(){return this.#qt?null===this.#h:!this.#h&&!this.#Ut}hasData(){return this.#qt?null!==this.#h||!!this.#Xt:this.isEmpty()}get guessedText(){return this.#Xt}async setGuessedText(t){null===this.#h&&(this.#Xt=t,this.#Yt=await Dt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Jt())}toggleAltTextBadge(t=!1){if(!this.#qt||this.#h)return this.#Vt?.remove(),void(this.#Vt=null);if(!this.#Vt){const t=this.#Vt=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#Vt.classList.toggle("hidden",!t)}serialize(t){let e=this.#h;return t||this.#Xt!==e||(e=this.#Yt),{altText:e,decorative:this.#Ut,guessedText:this.#Xt,textWithDisclaimer:this.#Yt}}get data(){return{altText:this.#h,decorative:this.#Ut}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#Xt=i,this.#Yt=s),this.#h===t&&this.#Ut===e||(n||(this.#h=t,this.#Ut=e),this.#Jt())}toggle(t=!1){this.#jt&&(!t&&this.#Gt&&(clearTimeout(this.#Gt),this.#Gt=null),this.#jt.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Kt}})}destroy(){this.#jt?.remove(),this.#jt=null,this.#zt=null,this.#Ht=null,this.#Vt?.remove(),this.#Vt=null}async#Jt(){const t=this.#jt;if(!t)return;if(this.#qt){if(t.classList.toggle("done",!!this.#h),t.setAttribute("data-l10n-id",Dt.#Qt[this.#Kt]),this.#zt?.setAttribute("data-l10n-id",Dt.#Qt[`${this.#Kt}-label`]),!this.#h)return void this.#Ht?.remove()}else{if(!this.#h&&!this.#Ut)return t.classList.remove("done"),void this.#Ht?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Ht;if(!e){this.#Ht=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;const i=100,s=this.#r._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#Gt),this.#Gt=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Gt=setTimeout((()=>{this.#Gt=null,this.#Ht.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Gt&&(clearTimeout(this.#Gt),this.#Gt=null),this.#Ht?.classList.remove("show")}),{signal:s})}this.#Ut?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#h),e.parentNode||t.append(e);const i=this.#r.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class Ft{#mt;#Zt=!1;#te=null;#ee;#ie;#se;#ne;#re=null;#oe;#he=null;#ae;#ce=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:o}){this.#mt=t,this.#te=i,this.#ee=e,this.#ie=s,this.#se=n,this.#ne=r,this.#ae=new AbortController,this.#oe=AbortSignal.any([o,this.#ae.signal]),t.addEventListener("touchstart",this.#le.bind(this),{passive:!1,signal:this.#oe})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Mt.pixelRatio}#le(t){if(this.#ee?.())return;if(1===t.touches.length){if(this.#re)return;const t=this.#re=new AbortController,e=AbortSignal.any([this.#oe,t.signal]),i=this.#mt,s={capture:!0,signal:e,passive:!1},n=t=>{"touch"===t.pointerType&&(this.#re?.abort(),this.#re=null)};return i.addEventListener("pointerdown",(t=>{"touch"===t.pointerType&&(mt(t),n(t))}),s),i.addEventListener("pointerup",n,s),void i.addEventListener("pointercancel",n,s)}if(!this.#ce){this.#ce=new AbortController;const t=AbortSignal.any([this.#oe,this.#ce.signal]),e=this.#mt,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#ue.bind(this),i);const s=this.#de.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",mt,i),e.addEventListener("pointermove",mt,i),e.addEventListener("pointercancel",mt,i),e.addEventListener("pointerup",mt,i),this.#ie?.()}if(mt(t),2!==t.touches.length||this.#te?.())return void(this.#he=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#he={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#ue(t){if(!this.#he||2!==t.touches.length)return;mt(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);const{screenX:s,screenY:n}=e,{screenX:r,screenY:o}=i,h=this.#he,{touch0X:a,touch0Y:c,touch1X:l,touch1Y:u}=h,d=l-a,f=u-c,p=Math.hypot(r-s,o-n)||1,g=Math.hypot(d,f)||1;if(!this.#Zt&&Math.abs(g-p)<=Ft.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(h.touch0X=s,h.touch0Y=n,h.touch1X=r,h.touch1Y=o,!this.#Zt)return void(this.#Zt=!0);const m=[(s+r)/2,(n+o)/2];this.#se?.(m,g,p)}#de(t){t.touches.length>=2||(this.#ce&&(this.#ce.abort(),this.#ce=null,this.#ne?.()),this.#he&&(mt(t),this.#he=null,this.#Zt=!1))}destroy(){this.#ae?.abort(),this.#ae=null,this.#re?.abort(),this.#re=null}}class Ot{#fe=null;#pe=null;#h=null;#ge=!1;#me=null;#we="";#Ae=!1;#be=null;#ve=null;#ye=null;#xe=null;#Me="";#Ee=!1;#Se=null;#ke=!1;#Ce=!1;#Te=!1;#Pe=null;#_e=0;#Re=0;#Ne=null;#Ie=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;#De=!1;#Fe=Ot._zIndex++;static _borderLineWidth=-1;static _colorManager=new Nt;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=Ot.prototype._resizeWithKeyboard,e=It.TRANSLATE_SMALL,i=It.TRANSLATE_BIG;return L(this,"_resizerKeyboardManager",new Rt([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],Ot.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;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[o,h]=this.parentDimensions;this.x=t.x/o,this.y=t.y/h,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return L(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new $t({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(Ot._l10n??=t,Ot._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==Ot._borderLineWidth)return;const i=getComputedStyle(document.documentElement);Ot._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){D("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#De}set _isDraggable(t){this.#De=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Fe}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#Oe(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#Ee?this.#Ee=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#$e([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#$e(this.parentDimensions,t,e)}translateInPage(t,e){this.#Se||=[this.x,this.y,this.width,this.height],this.#$e(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#Se||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:o}=this;const[h,a]=this.getBaseTranslation();r+=h,o+=a;const{style:c}=i;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(r,o),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#Se&&(this.#Se[0]!==this.x||this.#Se[1]!==this.y)}get _hasBeenResized(){return!!this.#Se&&(this.#Se[2]!==this.width||this.#Se[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=Ot,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:o,height:h}=this;if(o*=i,h*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=it(n,0,i-o),r=it(r,0,s-h);break;case 90:n=it(n,0,i-h),r=it(r,o,s);break;case 180:n=it(n,o,i),r=it(r,h,s);break;case 270:n=it(n,h,i),r=it(r,0,s-o)}this.x=n/=i,this.y=r/=s;const[a,c]=this.getBaseTranslation();n+=a,r+=c,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#Le(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return Ot.#Le(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Ot.#Le(t,e,360-this.parentRotation)}#Be(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#Ae||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#Ae&&e.endsWith("%");if(s&&n)return;const[r,o]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#Ae||n||(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Ue(){if(this.#be)return;this.#be=document.createElement("div"),this.#be.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#be.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#je.bind(this,i),{signal:e}),t.addEventListener("contextmenu",gt,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#be)}#je(t,e){e.preventDefault();const{isMac:i}=Y.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#h?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#ve=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#ze.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",mt,{passive:!1,signal:r}),window.addEventListener("contextmenu",gt,{signal:r}),this.#ye={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const o=this.parent.div.style.cursor,h=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const a=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#h?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=o,this.div.style.cursor=h,this.#He()};window.addEventListener("pointerup",a,{signal:r}),window.addEventListener("blur",a,{signal:r})}#Ge(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,r]=this.parentDimensions;this.setDims(n*i,r*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#He(){if(!this.#ye)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#ye;this.#ye=null;const n=this.x,r=this.y,o=this.width,h=this.height;n===t&&r===e&&o===i&&h===s||this.addCommands({cmd:this.#Ge.bind(this,n,r,o,h),undo:this.#Ge.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#ze(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,o=this.width,h=this.height,a=Ot.MIN_SIZE/i,c=Ot.MIN_SIZE/s,l=this.#Be(this.rotation),u=(t,e)=>[l[0]*t+l[2]*e,l[1]*t+l[3]*e],d=this.#Be(360-this.rotation);let f,p,g=!1,m=!1;switch(t){case"topLeft":g=!0,f=()=>[0,0],p=(t,e)=>[t,e];break;case"topMiddle":f=t=>[t/2,0],p=(t,e)=>[t/2,e];break;case"topRight":g=!0,f=t=>[t,0],p=(t,e)=>[0,e];break;case"middleRight":m=!0,f=(t,e)=>[t,e/2],p=(t,e)=>[0,e/2];break;case"bottomRight":g=!0,f=(t,e)=>[t,e],p=()=>[0,0];break;case"bottomMiddle":f=(t,e)=>[t/2,e],p=t=>[t/2,0];break;case"bottomLeft":g=!0,f=(t,e)=>[0,e],p=t=>[t,0];break;case"middleLeft":m=!0,f=(t,e)=>[0,e/2],p=(t,e)=>[t,e/2]}const w=f(o,h),A=p(o,h);let b=u(...A);const v=Ot._round(n+b[0]),y=Ot._round(r+b[1]);let x,M,E=1,S=1;if(e.fromKeyboard)({deltaX:x,deltaY:M}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#ve;[x,M]=this.screenToPageTranslation(t-s,i-n),this.#ve[0]=t,this.#ve[1]=i}var k,C;if([x,M]=[d[0]*(k=x/i)+d[2]*(C=M/s),d[1]*k+d[3]*C],g){const t=Math.hypot(o,h);E=S=Math.max(Math.min(Math.hypot(A[0]-w[0]-x,A[1]-w[1]-M)/t,1/o,1/h),a/o,c/h)}else m?E=it(Math.abs(A[0]-w[0]-x),a,1)/o:S=it(Math.abs(A[1]-w[1]-M),c,1)/h;const T=Ot._round(o*E),P=Ot._round(h*S);b=u(...p(T,P));const _=v-b[0],R=y-b[1];this.#Se||=[this.x,this.y,this.width,this.height],this.width=T,this.height=P,this.x=_,this.y=R,this.setDims(i*T,s*P),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#h?.finish()}async addEditToolbar(){return this._editToolbar||this.#Ce||(this._editToolbar=new St(this),this.div.append(this._editToolbar.render()),this.#h&&await this._editToolbar.addAltText(this.#h)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#h?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#h||(Dt.initialize(Ot._l10n),this.#h=new Dt(this),this.#fe&&(this.#h.data=this.#fe,this.#fe=null),await this.addEditToolbar())}get altTextData(){return this.#h?.data}set altTextData(t){this.#h&&(this.#h.data=t)}get guessedAltText(){return this.#h?.guessedText}async setGuessedAltText(t){await(this.#h?.setGuessedText(t))}serializeAltText(t){return this.#h?.serialize(t)}hasAltText(){return!!this.#h&&!this.#h.isEmpty()}hasAltTextData(){return this.#h?.hasData()??!1}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.#ge?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#We();const[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[s,n]=this.getInitialTranslation();return this.translate(s,n),Ct(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Ie||=new Ft({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#Ve.bind(this),onPinching:this.#Xe.bind(this),onPinchEnd:this.#Ye.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),t}#Ve(){this.#ye={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#h?.toggle(!1),this.parent.togglePointerEvents(!1)}#Xe(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#Be(this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[o,h]=this.parentDimensions,a=this.x,c=this.y,l=this.width,u=this.height,d=Ot.MIN_SIZE/o,f=Ot.MIN_SIZE/h;s=Math.max(Math.min(s,1/l,1/u),d/l,f/u);const p=Ot._round(l*s),g=Ot._round(u*s);if(p===l&&g===u)return;this.#Se||=[a,c,l,u];const m=r(l/2,u/2),w=Ot._round(a+m[0]),A=Ot._round(c+m[1]),b=r(p/2,g/2);this.x=w-b[0],this.y=A-b[1],this.width=p,this.height=g,this.setDims(o*p,h*g),this.fixAndSetPosition(),this._onResizing()}#Ye(){this.#h?.toggle(!0),this.parent.togglePointerEvents(!0),this.#He()}pointerdown(t){const{isMac:e}=Y.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#Ee=!0,this._isDraggable?this.#qe(t):this.#Qe(t))}#Qe(t){const{isMac:e}=Y.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#qe(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},o=t=>{s.abort(),this.#me=null,this.#Ee=!1,this._uiManager.endDragSession()||this.#Qe(t),i&&this._onStopDragging()};e&&(this.#_e=t.clientX,this.#Re=t.clientY,this.#me=t.pointerId,this.#we=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#me)return void mt(t);const[r,o]=this.screenToPageTranslation(e-this.#_e,s-this.#Re);this.#_e=e,this.#Re=s,this._uiManager.dragSelectedEditors(r,o)}),r),window.addEventListener("touchmove",mt,r),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#we&&(this.#Ie||t.isPrimary)&&o(t),mt(t)}),r));const h=t=>{this.#me&&this.#me!==t.pointerId?mt(t):o(t)};window.addEventListener("pointerup",h,{signal:n}),window.addEventListener("blur",h,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Pe&&clearTimeout(this.#Pe),this.#Pe=setTimeout((()=>{this.#Pe=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[o,h]=this.pageTranslation,a=t/s,c=e/s,l=this.x*n,u=this.y*r,d=this.width*n,f=this.height*r;switch(i){case 0:return[l+a+o,r-u-c-f+h,l+a+d+o,r-u-c+h];case 90:return[l+c+o,r-u+a+h,l+c+f+o,r-u+a+d+h];case 180:return[l-a-d+o,r-u+c+h,l-a+o,r-u+c+f+h];case 270:return[l-c-f+o,r-u-a-d+h,l-c+o,r-u-a+h];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,o=n-i,h=r-s;switch(this.rotation){case 0:return[i,e-r,o,h];case 90:return[i,e-s,h,o];case 180:return[n,e-s,o,h];case 270:return[n,e-r,h,o];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#Ce=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#Ce=!1,!0)}isInEditMode(){return this.#Ce}shouldGetKeyboardEvents(){return this.#Te}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#We(){if(this.#xe||!this.div)return;this.#xe=new AbortController;const t=this._uiManager.combinedSignal(this.#xe);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#We()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){D("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#fe=t.accessibilityData,s._isCopy=t.isCopy||!1;const[n,r]=s.pageDimensions,[o,h,a,c]=s.getRectInCurrentCoords(t.rect,r);return s.x=o/n,s.y=h/r,s.width=a/n,s.height=c/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#xe?.abort(),this.#xe=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Pe&&(clearTimeout(this.#Pe),this.#Pe=null),this.#Oe(),this.removeEditToolbar(),this.#Ne){for(const t of this.#Ne.values())clearTimeout(t);this.#Ne=null}this.parent=null,this.#Ie?.destroy(),this.#Ie=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#Ue(),this.#be.classList.remove("hidden"))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#ye={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#be.children;if(!this.#pe){this.#pe=Array.from(e);const t=this.#Ke.bind(this),i=this.#Je.bind(this),s=this._uiManager._signal;for(const e of this.#pe){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Ze.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",Ot._l10nResizer[n])}}const i=this.#pe[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#pe.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#be.append(this.#be.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#be.firstChild.before(this.#be.lastChild);let t=0;for(const i of e){const e=this.#pe[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",Ot._l10nResizer[e])}}this.#ti(0),this.#Te=!0,this.#be.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#Ke(t){Ot._resizerKeyboardManager.exec(this,t)}#Je(t){this.#Te&&t.relatedTarget?.parentNode!==this.#be&&this.#Oe()}#Ze(t){this.#Me=this.#Te?t:""}#ti(t){if(this.#pe)for(const e of this.#pe)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Te&&this.#ze(this.#Me,{deltaX:t,deltaY:e,fromKeyboard:!0})}#Oe(){this.#Te=!1,this.#ti(-1),this.#He()}_stopResizingWithKeyboard(){this.#Oe(),this.div.focus()}select(){this.isSelected&&this._editToolbar||(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#h?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})))}unselect(){this.isSelected&&(this.isSelected=!1,this.#be?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#h?.toggleAltTextBadge(!0))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#ke}set isEditing(t){this.#ke=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#Ae=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}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.#Ne||=new Map;const{action:e}=t;let i=this.#Ne.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#Ne.delete(e),0===this.#Ne.size&&(this.#Ne=null)}),Ot._telemetryTimeout),void this.#Ne.set(e,i)}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.#ge=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ge=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class $t extends Ot{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Lt=3285377520,Bt=4294901760,Ut=65535;class jt{constructor(t){this.h1=t?4294967295&t:Lt,this.h2=t?4294967295&t:Lt}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s);let o=0,h=0,a=this.h1,c=this.h2;const l=3432918353,u=461845907,d=11601,f=13715;for(let t=0;t<s;t++)1&t?(o=r[t],o=o*l&Bt|o*d&Ut,o=o<<15|o>>>17,o=o*u&Bt|o*f&Ut,a^=o,a=a<<13|a>>>19,a=5*a+3864292196):(h=r[t],h=h*l&Bt|h*d&Ut,h=h<<15|h>>>17,h=h*u&Bt|h*f&Ut,c^=h,c=c<<13|c>>>19,c=5*c+3864292196);switch(o=0,n){case 3:o^=e[4*s+2]<<16;case 2:o^=e[4*s+1]<<8;case 1:o^=e[4*s],o=o*l&Bt|o*d&Ut,o=o<<15|o>>>17,o=o*u&Bt|o*f&Ut,1&s?a^=o:c^=o}this.h1=a,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&Bt|36045*t&Ut,e=4283543511*e&Bt|(2950163797*(e<<16|t>>>16)&Bt)>>>16,t^=e>>>1,t=444984403*t&Bt|60499*t&Ut,e=3301882366*e&Bt|(3120437893*(e<<16|t>>>16)&Bt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const zt=Object.freeze({map:null,hash:"",transfer:void 0});class Ht{#ei=!1;#ii=null;#si=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#si.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#si.get(t)}remove(t){if(this.#si.delete(t),0===this.#si.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#si.values())if(t instanceof Ot)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#si.get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#si.set(t,e);s&&this.#ni(),e instanceof Ot&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#si.has(t)}get size(){return this.#si.size}#ni(){this.#ei||(this.#ei=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#ei&&(this.#ei=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Gt(this)}get serializable(){if(0===this.#si.size)return zt;const t=new Map,e=new jt,i=[],s=Object.create(null);let n=!1;for(const[i,r]of this.#si){const o=r instanceof Ot?r.serialize(!1,s):r;o&&(t.set(i,o),e.update(`${i}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:zt}get editorStats(){let t=null;const e=new Map;for(const i of this.#si.values()){if(!(i instanceof Ot))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=r.get(t);i||(i=new Map,r.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#ii=null}get modifiedIds(){if(this.#ii)return this.#ii;const t=[];for(const e of this.#si.values())e instanceof Ot&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#ii={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#si.entries()}}class Gt extends Ht{#ri;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ri={map:n,hash:i,transfer:s}}get print(){D("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ri}get modifiedIds(){return L(this,"modifiedIds",{ids:new Set,hash:""})}}class Wt{#oi=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.#oi.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!this.#oi.has(t.loadedName))if(F(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:s,style:n}=t,r=new FontFace(e,s,n);this.addNativeFontFace(r);try{await r.load(),this.#oi.add(e),i?.(t)}catch{I(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else D("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw I(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){return L(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return L(this,"isSyncFontLoadingSupported",w||Y.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(F(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return L(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,r;const o=this._document.createElement("canvas");o.width=1,o.height=1;const h=o.getContext("2d");let a=0;const c=`lt${Date.now()}${this.loadTestFontId++}`;let l=this._loadTestFont;l=s(l,976,c.length,c);const u=1482184792;let d=i(l,16);for(n=0,r=c.length-3;n<r;n+=4)d=d-u+i(c,n)|0;var f;n<c.length&&(d=d-u+i(c+"XXX",n)|0),l=s(l,16,4,(f=d,String.fromCharCode(f>>24&255,f>>16&255,f>>8&255,255&f)));const p=`url(data:font/opentype;base64,${btoa(l)});`;this.insertRule(`@font-face {font-family:"${c}";src:${p}}`);const g=this._document.createElement("div");g.style.visibility="hidden",g.style.width=g.style.height="10px",g.style.position="absolute",g.style.top=g.style.left="0px";for(const e of[t.loadedName,c]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,g.append(t)}this._document.body.append(g),function t(e,i){if(++a>30)return I("Load test font never loaded."),void i();h.font="30px "+e,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(c,(()=>{g.remove(),e.complete()}))}}class Vt{constructor(t,e=null){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this._inspectFont=e}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){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)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${st(this.data)});`;let e;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(t){I(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}function Xt(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const Yt=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,qt=function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;const[s,n,...r]=i;if(!t(s)&&!Number.isInteger(s))return!1;if(!e(n))return!1;const o=r.length;let h=!0;switch(n.name){case"XYZ":if(o<2||o>3)return!1;break;case"Fit":case"FitB":return 0===o;case"FitH":case"FitBH":case"FitV":case"FitBV":if(o>1)return!1;break;case"FitR":if(4!==o)return!1;h=!1;break;default:return!1}for(const t of r)if(!("number"==typeof t||h&&null===t))return!1;return!0}.bind(null,Yt,(t=>"object"==typeof t&&"string"==typeof t?.name));class Qt{#hi=new Map;#ai=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#ai.then((()=>{for(const[t]of this.#hi)t.call(this,i)}))}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void I("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#hi.set(e,s)}removeEventListener(t,e){const i=this.#hi.get(e);i?.(),this.#hi.delete(e)}terminate(){for(const[,t]of this.#hi)t?.();this.#hi.clear()}}function Kt(){}function Jt(t){if(t instanceof W||t instanceof z||t instanceof U||t instanceof H||t instanceof j)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||D('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new W(t.message);case"InvalidPDFException":return new z(t.message);case"PasswordException":return new U(t.message,t.code);case"ResponseException":return new H(t.message,t.status,t.missing);case"UnknownErrorException":return new j(t.message,t.details)}return new j(t.message,t.toString())}class Zt{#ci=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",this.#li.bind(this),{signal:this.#ci.signal})}#li({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ui(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else{if(2!==t.callback)throw new Error("Unexpected callback case");i.reject(Jt(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then((function(e){n.postMessage({sourceName:i,targetName:s,callback:1,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:2,callbackId:t.callbackId,reason:Jt(e)})}))}else t.streamId?this.#di(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,o=this.targetName,h=this.comObj;return new ReadableStream({start:i=>{const a=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:a,pullCall:null,cancelCall:null,isClosed:!1},h.postMessage({sourceName:r,targetName:o,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),a.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,h.postMessage({sourceName:r,targetName:o,stream:6,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{F(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,h.postMessage({sourceName:r,targetName:o,stream:1,streamId:n,reason:Jt(t)}),e.promise}},i)}#di(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,o=this.actionHandler[t.action],h={enqueue(t,r=1,o){if(this.isCancelled)return;const h=this.desiredSize;this.desiredSize-=r,h>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:4,streamId:e,chunk:t},o)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:3,streamId:e}),delete r.streamSinks[e])},error(t){F(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:5,streamId:e,reason:Jt(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};h.sinkCapability.resolve(),h.ready=h.sinkCapability.promise,this.streamSinks[e]=h,Promise.try(o,t.data,h).then((function(){n.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,reason:Jt(t)})}))}#ui(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case 8:t.success?r.startCall.resolve():r.startCall.reject(Jt(t.reason));break;case 7:t.success?r.pullCall.resolve():r.pullCall.reject(Jt(t.reason));break;case 6:if(!o){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||Kt).then((function(){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,reason:Jt(t)})}));break;case 4:if(F(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case 3:if(F(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#fi(r,e);break;case 5:F(r,"error should have stream controller"),r.controller.error(Jt(t.reason)),this.#fi(r,e);break;case 2:t.success?r.cancelCall.resolve():r.cancelCall.reject(Jt(t.reason)),this.#fi(r,e);break;case 1:if(!o)break;const h=Jt(t.reason);Promise.try(o.onCancel||Kt,h).then((function(){n.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,reason:Jt(t)})})),o.sinkCapability.reject(h),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#fi(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#ci?.abort(),this.#ci=null}}class te{#pi=!1;constructor({enableHWA:t=!1}){this.#pi=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#pi})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){D("Abstract method `_createCanvas` called.")}}class ee extends te{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class ie{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then((t=>({cMapData:t,isCompressed:this.isCompressed}))).catch((()=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}async _fetch(t){D("Abstract method `_fetch` called.")}}class se extends ie{async _fetch(t){const e=await ot(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):X(e)}}m(2489);class ne{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class re extends ne{#gi;#mi;#wi;#Ai;#bi;#vi;#v=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#Ai=t,this.#bi=e}get#x(){return this.#mi||=new Map}get#yi(){return this.#vi||=new Map}get#xi(){if(!this.#wi){const t=this.#bi.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 i=this.#bi.createElementNS(nt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#wi=this.#bi.createElementNS(nt,"defs"),t.append(i),i.append(this.#wi),this.#bi.body.append(t)}return this.#wi}#Mi(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),r=new Array(256),o=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,r[t]=i[t]/255,o[t]=s[t]/255;return[n.join(","),r.join(","),o.join(",")]}#Ei(t){if(void 0===this.#gi){this.#gi="";const t=this.#bi.URL;t!==this.#bi.baseURI&&(ct(t)?I('#createUrl: ignore "data:"-URL for performance reasons.'):this.#gi=$(t,""))}return`url(${this.#gi}#${t})`}addFilter(t){if(!t)return"none";let e=this.#x.get(t);if(e)return e;const[i,s,n]=this.#Mi(t),r=1===t.length?i:`${i}${s}${n}`;if(e=this.#x.get(r),e)return this.#x.set(t,e),e;const o=`g_${this.#Ai}_transfer_map_${this.#v++}`,h=this.#Ei(o);this.#x.set(t,h),this.#x.set(r,h);const a=this.#Si(o);return this.#ki(i,s,n,a),h}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#yi.get(s);if(n?.key===i)return n.url;if(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#yi.set(s,n)),!t||!e)return n.url;const r=this.#Ci(t);t=Q.makeHexColor(...r);const o=this.#Ci(e);if(e=Q.makeHexColor(...o),this.#xi.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const h=new Array(256);for(let t=0;t<=255;t++){const e=t/255;h[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const a=h.join(","),c=`g_${this.#Ai}_hcm_filter`,l=n.filter=this.#Si(c);this.#ki(a,a,a,l),this.#Ti(l);const u=(t,e)=>{const i=r[t]/255,s=o[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#ki(u(0,5),u(1,5),u(2,5),l),n.url=this.#Ei(c),n.url}addAlphaFilter(t){let e=this.#x.get(t);if(e)return e;const[i]=this.#Mi([t]),s=`alpha_${i}`;if(e=this.#x.get(s),e)return this.#x.set(t,e),e;const n=`g_${this.#Ai}_alpha_map_${this.#v++}`,r=this.#Ei(n);this.#x.set(t,r),this.#x.set(s,r);const o=this.#Si(n);return this.#Pi(i,o),r}addLuminosityFilter(t){let e,i,s=this.#x.get(t||"luminosity");if(s)return s;if(t?([e]=this.#Mi([t]),i=`luminosity_${e}`):i="luminosity",s=this.#x.get(i),s)return this.#x.set(t,s),s;const n=`g_${this.#Ai}_luminosity_map_${this.#v++}`,r=this.#Ei(n);this.#x.set(t,r),this.#x.set(i,r);const o=this.#Si(n);return this.#_i(o),t&&this.#Pi(e,o),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let o=this.#yi.get(t);if(o?.key===r)return o.url;if(o?(o.filter?.remove(),o.key=r,o.url="none",o.filter=null):(o={key:r,url:"none",filter:null},this.#yi.set(t,o)),!e||!i)return o.url;const[h,a]=[e,i].map(this.#Ci.bind(this));let c=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),l=Math.round(.2126*a[0]+.7152*a[1]+.0722*a[2]),[u,d]=[s,n].map(this.#Ci.bind(this));l<c&&([c,l,u,d]=[l,c,d,u]),this.#xi.style.color="";const f=(t,e,i)=>{const s=new Array(256),n=(l-c)/i,r=t/255,o=(e-t)/(255*i);let h=0;for(let t=0;t<=i;t++){const e=Math.round(c+t*n),i=r+t*o;for(let t=h;t<=e;t++)s[t]=i;h=e+1}for(let t=h;t<256;t++)s[t]=s[h-1];return s.join(",")},p=`g_${this.#Ai}_hcm_${t}_filter`,g=o.filter=this.#Si(p);return this.#Ti(g),this.#ki(f(u[0],d[0],5),f(u[1],d[1],5),f(u[2],d[2],5),g),o.url=this.#Ei(p),o.url}destroy(t=!1){t&&this.#vi?.size||(this.#wi?.parentNode.parentNode.remove(),this.#wi=null,this.#mi?.clear(),this.#mi=null,this.#vi?.clear(),this.#vi=null,this.#v=0)}#_i(t){const e=this.#bi.createElementNS(nt,"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)}#Ti(t){const e=this.#bi.createElementNS(nt,"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)}#Si(t){const e=this.#bi.createElementNS(nt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#xi.append(e),e}#Ri(t,e,i){const s=this.#bi.createElementNS(nt,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#ki(t,e,i,s){const n=this.#bi.createElementNS(nt,"feComponentTransfer");s.append(n),this.#Ri(n,"feFuncR",t),this.#Ri(n,"feFuncG",e),this.#Ri(n,"feFuncB",i)}#Pi(t,e){const i=this.#bi.createElementNS(nt,"feComponentTransfer");e.append(i),this.#Ri(i,"feFuncA",t)}#Ci(t){return this.#xi.style.color=t,bt(getComputedStyle(this.#xi).getPropertyValue("color"))}}class oe{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((()=>{throw new Error(`Unable to load font data at: ${e}`)}))}async _fetch(t){D("Abstract method `_fetch` called.")}}class he extends oe{async _fetch(t){const e=await ot(t,"arraybuffer");return new Uint8Array(e)}}class ae{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((()=>{throw new Error(`Unable to load wasm data at: ${e}`)}))}async _fetch(t){D("Abstract method `_fetch` called.")}}class ce extends ae{async _fetch(t){const e=await ot(t,"arraybuffer");return new Uint8Array(e)}}if(w){let t;try{const e=process.getBuiltinModule("module").createRequire(import.meta.url);try{t=e("@napi-rs/canvas")}catch(t){I(`Cannot load "@napi-rs/canvas" package: "${t}".`)}}catch(t){I(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(t?.DOMMatrix?globalThis.DOMMatrix=t.DOMMatrix:I("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(t?.ImageData?globalThis.ImageData=t.ImageData:I("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(t?.Path2D?globalThis.Path2D=t.Path2D:I("Cannot polyfill `Path2D`, rendering may be broken.")),globalThis.navigator?.language||(globalThis.navigator={language:"en-US",platform:"",userAgent:""})}async function le(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}class ue extends ne{}class de extends te{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class fe extends ie{async _fetch(t){return le(t)}}class pe extends oe{async _fetch(t){return le(t)}}class ge extends ae{async _fetch(t){return le(t)}}const me="Fill",we="Stroke",Ae="Shading";function be(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class ve{isModifyingCurrentTransform(){return!1}getPattern(){D("Abstract method `getPattern` called.")}}class ye extends ve{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,i,s){let n;if(s===we||s===me){const r=e.current.getClippedPathBoundingBox(s,vt(t))||[0,0,0,0],o=Math.ceil(r[2]-r[0])||1,h=Math.ceil(r[3]-r[1])||1,a=e.cachedCanvases.getCanvas("pattern",o,h),c=a.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(-r[0],-r[1]),i=Q.transform(i,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),be(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),n=t.createPattern(a.canvas,"no-repeat");const l=new DOMMatrix(i);n.setTransform(l)}else be(t,this._bbox),n=this._createGradient(t);return n}}function xe(t,e,i,s,n,r,o,h){const a=e.coords,c=e.colors,l=t.data,u=4*t.width;let d;a[i+1]>a[s+1]&&(d=i,i=s,s=d,d=r,r=o,o=d),a[s+1]>a[n+1]&&(d=s,s=n,n=d,d=o,o=h,h=d),a[i+1]>a[s+1]&&(d=i,i=s,s=d,d=r,r=o,o=d);const f=(a[i]+e.offsetX)*e.scaleX,p=(a[i+1]+e.offsetY)*e.scaleY,g=(a[s]+e.offsetX)*e.scaleX,m=(a[s+1]+e.offsetY)*e.scaleY,w=(a[n]+e.offsetX)*e.scaleX,A=(a[n+1]+e.offsetY)*e.scaleY;if(p>=A)return;const b=c[r],v=c[r+1],y=c[r+2],x=c[o],M=c[o+1],E=c[o+2],S=c[h],k=c[h+1],C=c[h+2],T=Math.round(p),P=Math.round(A);let _,R,N,I,D,F,O,$;for(let t=T;t<=P;t++){if(t<m){const e=t<p?0:(p-t)/(p-m);_=f-(f-g)*e,R=b-(b-x)*e,N=v-(v-M)*e,I=y-(y-E)*e}else{let e;e=t>A?1:m===A?0:(m-t)/(m-A),_=g-(g-w)*e,R=x-(x-S)*e,N=M-(M-k)*e,I=E-(E-C)*e}let e;e=t<p?0:t>A?1:(p-t)/(p-A),D=f-(f-w)*e,F=b-(b-S)*e,O=v-(v-k)*e,$=y-(y-C)*e;const i=Math.round(Math.min(_,D)),s=Math.round(Math.max(_,D));let n=u*t+4*i;for(let t=i;t<=s;t++)e=(_-t)/(_-D),e<0?e=0:e>1&&(e=1),l[n++]=R-(R-F)*e|0,l[n++]=N-(N-O)*e|0,l[n++]=I-(I-$)*e|0,l[n++]=255}}function Me(t,e,i){const s=e.coords,n=e.colors;let r,o;switch(e.type){case"lattice":const h=e.verticesPerRow,a=Math.floor(s.length/h)-1,c=h-1;for(r=0;r<a;r++){let e=r*h;for(let r=0;r<c;r++,e++)xe(t,i,s[e],s[e+1],s[e+h],n[e],n[e+1],n[e+h]),xe(t,i,s[e+h+1],s[e+1],s[e+h],n[e+h+1],n[e+1],n[e+h])}break;case"triangles":for(r=0,o=s.length;r<o;r+=3)xe(t,i,s[r],s[r+1],s[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class Ee extends ve{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,o=Math.ceil(this._bounds[3])-n,h=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),a=Math.min(Math.ceil(Math.abs(o*t[1]*1.1)),3e3),c=r/h,l=o/a,u={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/c,scaleY:1/l},d=i.getCanvas("mesh",h+4,a+4),f=d.context,p=f.createImageData(h,a);if(e){const t=p.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const t of this._figures)Me(p,t,u);return f.putImageData(p,2,2),{canvas:d.canvas,offsetX:s-2*c,offsetY:n-2*l,scaleX:c,scaleY:l}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){be(t,this._bbox);const n=new Float32Array(2);if(s===Ae)Q.singularValueDecompose2dScale(vt(t),n);else if(this.matrix){Q.singularValueDecompose2dScale(this.matrix,n);const[t,i]=n;Q.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=i}else Q.singularValueDecompose2dScale(e.baseTransform,n);const r=this._createMeshCanvas(n,s===Ae?null:this._background,e.cachedCanvases);return s!==Ae&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class Se extends ve{getPattern(){return"hotpink"}}class ke{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:r,canvasGraphicsFactory:o}=this;let{xstep:h,ystep:a}=this;h=Math.abs(h),a=Math.abs(a),N("TilingType: "+n);const c=e[0],l=e[1],u=e[2],d=e[3],f=u-c,p=d-l,g=new Float32Array(2);Q.singularValueDecompose2dScale(this.matrix,g);const[m,w]=g;Q.singularValueDecompose2dScale(this.baseTransform,g);const A=m*g[0],b=w*g[1];let v=f,y=p,x=!1,M=!1;const E=Math.ceil(h*A),S=Math.ceil(a*b);E>=Math.ceil(f*A)?v=h:x=!0,S>=Math.ceil(p*b)?y=a:M=!0;const k=this.getSizeAndScale(v,this.ctx.canvas.width,A),C=this.getSizeAndScale(y,this.ctx.canvas.height,b),T=t.cachedCanvases.getCanvas("pattern",k.size,C.size),P=T.context,_=o.createCanvasGraphics(P);if(_.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(_,s,r),P.translate(-k.scale*c,-C.scale*l),_.transform(k.scale,0,0,C.scale,0,0),P.save(),this.clipBbox(_,c,l,u,d),_.baseTransform=vt(_.ctx),_.executeOperatorList(i),_.endDrawing(),P.restore(),x||M){const e=T.canvas;x&&(v=h),M&&(y=a);const i=this.getSizeAndScale(v,this.ctx.canvas.width,A),s=this.getSizeAndScale(y,this.ctx.canvas.height,b),n=i.size,r=s.size,o=t.cachedCanvases.getCanvas("pattern-workaround",n,r),u=o.context,d=x?Math.floor(f/h):0,g=M?Math.floor(p/a):0;for(let t=0;t<=d;t++)for(let i=0;i<=g;i++)u.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:o.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:c,offsetY:l}}return{canvas:T.canvas,scaleX:k.scale,scaleY:C.scale,offsetX:c,offsetY:l}}getSizeAndScale(t,e,i){const s=Math.max(ke.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){t.ctx.rect(e,i,s-e,n-i),Q.axialAlignedBoundingBox([e,i,s,n],vt(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case 1:const{fillStyle:t,strokeStyle:r}=this.ctx;s.fillStyle=n.fillColor=t,s.strokeStyle=n.strokeColor=r;break;case 2:s.fillStyle=s.strokeStyle=i,n.fillColor=n.strokeColor=i;break;default:throw new G(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s){let n=i;s!==Ae&&(n=Q.transform(n,e.baseTransform),this.matrix&&(n=Q.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let o=new DOMMatrix(n);o=o.translate(r.offsetX,r.offsetY),o=o.scale(1/r.scaleX,1/r.scaleY);const h=t.createPattern(r.canvas,"repeat");return h.setTransform(o),h}}function Ce({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:o=!1}){const h=Y.isLittleEndian?4278190080:255,[a,c]=o?[r,h]:[h,r],l=s>>3,u=7&s,d=t.length;i=new Uint32Array(i.buffer);let f=0;for(let s=0;s<n;s++){for(const s=e+l;e<s;e++){const s=e<d?t[e]:255;i[f++]=128&s?c:a,i[f++]=64&s?c:a,i[f++]=32&s?c:a,i[f++]=16&s?c:a,i[f++]=8&s?c:a,i[f++]=4&s?c:a,i[f++]=2&s?c:a,i[f++]=1&s?c:a}if(0===u)continue;const s=e<d?t[e++]:255;for(let t=0;t<u;t++)i[f++]=s&1<<7-t?c:a}return{srcPos:e,destPos:f}}const Te=16,Pe=new DOMMatrix,_e=new Float32Array(2),Re=new Float32Array([1/0,1/0,-1/0,-1/0]);class Ne{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache)this.canvasFactory.destroy(this.cache[t]),delete this.cache[t]}}function Ie(t,e,i,s,n,r,o,h,a,c){const[l,u,d,f,p,g]=vt(t);if(0===u&&0===d){const m=Math.round(o*l+p),w=Math.round(h*f+g),A=Math.abs(Math.round((o+a)*l+p)-m)||1,b=Math.abs(Math.round((h+c)*f+g)-w)||1;return t.setTransform(Math.sign(l),0,0,Math.sign(f),m,w),t.drawImage(e,i,s,n,r,0,0,A,b),t.setTransform(l,u,d,f,p,g),[A,b]}if(0===l&&0===f){const m=Math.round(h*d+p),w=Math.round(o*u+g),A=Math.abs(Math.round((h+c)*d+p)-m)||1,b=Math.abs(Math.round((o+a)*u+g)-w)||1;return t.setTransform(0,Math.sign(u),Math.sign(d),0,m,w),t.drawImage(e,i,s,n,r,0,0,b,A),t.setTransform(l,u,d,f,p,g),[b,A]}return t.drawImage(e,i,s,n,r,o,h,a,c),[Math.hypot(l,u)*a,Math.hypot(d,f)*c]}class De{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=A;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e){this.clipBox=new Float32Array([0,0,t,e]),this.minMax=Re.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=me,e=null){const i=this.minMax.slice();if(t===we){e||D("Stroke bounding box must include transform."),Q.singularValueDecompose2dScale(e,_e);const t=_e[0]*this.lineWidth/2,s=_e[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){const t=Q.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(Re,0)}getClippedPathBoundingBox(t=me,e=null){return Q.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Fe(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%Te,r=(i-n)/Te,o=0===n?r:r+1,h=t.createImageData(s,Te);let a,c=0;const l=e.data,u=h.data;let d,f,p,g;if(e.kind===E.GRAYSCALE_1BPP){const e=l.byteLength,i=new Uint32Array(u.buffer,0,u.byteLength>>2),g=i.length,m=s+7>>3,w=4294967295,A=Y.isLittleEndian?4278190080:255;for(d=0;d<o;d++){for(p=d<r?Te:n,a=0,f=0;f<p;f++){const t=e-c;let n=0;const r=t>m?s:8*t-7,o=-8&r;let h=0,u=0;for(;n<o;n+=8)u=l[c++],i[a++]=128&u?w:A,i[a++]=64&u?w:A,i[a++]=32&u?w:A,i[a++]=16&u?w:A,i[a++]=8&u?w:A,i[a++]=4&u?w:A,i[a++]=2&u?w:A,i[a++]=1&u?w:A;for(;n<r;n++)0===h&&(u=l[c++],h=128),i[a++]=u&h?w:A,h>>=1}for(;a<g;)i[a++]=0;t.putImageData(h,0,d*Te)}}else if(e.kind===E.RGBA_32BPP){for(f=0,g=s*Te*4,d=0;d<r;d++)u.set(l.subarray(c,c+g)),c+=g,t.putImageData(h,0,f),f+=Te;d<o&&(g=s*n*4,u.set(l.subarray(c,c+g)),t.putImageData(h,0,f))}else{if(e.kind!==E.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(p=Te,g=s*p,d=0;d<o;d++){for(d>=r&&(p=n,g=s*p),a=0,f=g;f--;)u[a++]=l[c++],u[a++]=l[c++],u[a++]=l[c++],u[a++]=255;t.putImageData(h,0,d*Te)}}}function Oe(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%Te,r=(i-n)/Te,o=0===n?r:r+1,h=t.createImageData(s,Te);let a=0;const c=e.data,l=h.data;for(let e=0;e<o;e++){const i=e<r?Te:n;({srcPos:a}=Ce({src:c,srcPos:a,dest:l,width:s,height:i,nonBlackColor:0})),t.putImageData(h,0,e*Te)}}function $e(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function Le(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function Be(t,e){if(e)return!0;Q.singularValueDecompose2dScale(t,_e);const i=Math.fround(Mt.pixelRatio*rt.PDF_TO_CSS_UNITS);return _e[0]<=i&&_e[1]<=i}const Ue=["butt","round","square"],je=["miter","round","bevel"],ze={},He={};class Ge{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:o=null},h,a){this.ctx=t,this.current=new De(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=r,this.cachedCanvases=new Ne(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=h,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=a,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=o,i){const t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...vt(this.compositeCtx))}this.ctx.save(),Le(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=vt(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,r=t.fnArray;let o=e||0;const h=n.length;if(h===o)return o;const a=h-o>10&&"function"==typeof i,c=a?Date.now()+15:0;let l=0;const u=this.commonObjs,d=this.objs;let f;for(;;){if(void 0!==s&&o===s.nextBreakPoint)return s.breakIt(o,i),o;if(f=r[o],f!==C.dependency)this[f].apply(this,n[o]);else for(const t of n[o]){const e=t.startsWith("g_")?u:d;if(!e.has(t))return e.get(t,i),o}if(o++,o===h)return o;if(a&&++l>10){if(Date.now()>c)return i(),o;l=0}}}#Ni(){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.#Ni(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#Ii()}#Ii(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,r,o=Math.max(Math.hypot(e[0],e[1]),1),h=Math.max(Math.hypot(e[2],e[3]),1),a=i,c=s,l="prescale1";for(;o>2&&a>1||h>2&&c>1;){let e=a,i=c;o>2&&a>1&&(e=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),o/=a/e),h>2&&c>1&&(i=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,h/=c/i),n=this.cachedCanvases.getCanvas(l,e,i),r=n.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,a,c,0,0,e,i),t=n.canvas,a=e,c=i,l="prescale1"===l?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:c}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,r=this.current.patternFill,o=vt(e);let h,a,c,l;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;a=JSON.stringify(r?o:[o.slice(0,4),n]),h=this._cachedBitmapsMap.get(e),h||(h=new Map,this._cachedBitmapsMap.set(e,h));const i=h.get(a);if(i&&!r)return{canvas:i,offsetX:Math.round(Math.min(o[0],o[2])+o[4]),offsetY:Math.round(Math.min(o[1],o[3])+o[5])};c=i}c||(l=this.cachedCanvases.getCanvas("maskCanvas",i,s),Oe(l.context,t));let u=Q.transform(o,[1/i,0,0,-1/s,0,0]);u=Q.transform(u,[1,0,0,1,0,-s]);const d=Re.slice();Q.axialAlignedBoundingBox([0,0,i,s],u,d);const[f,p,g,m]=d,w=Math.round(g-f)||1,A=Math.round(m-p)||1,b=this.cachedCanvases.getCanvas("fillCanvas",w,A),v=b.context,y=f,x=p;v.translate(-y,-x),v.transform(...u),c||(c=this._scaleImage(l.canvas,yt(v)),c=c.img,h&&r&&h.set(a,c)),v.imageSmoothingEnabled=Be(vt(v),t.interpolate),Ie(v,c,0,0,c.width,c.height,0,0,i,s),v.globalCompositeOperation="source-in";const M=Q.transform(yt(v),[1,0,0,1,-y,-x]);return v.fillStyle=r?n.getPattern(e,this,M,me):n,v.fillRect(0,0,i,s),h&&!r&&(this.cachedCanvases.delete("fillCanvas"),h.set(a,b.canvas)),{canvas:b.canvas,offsetX:Math.round(y),offsetY:Math.round(x)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Ue[t]}setLineJoin(t){this.ctx.lineJoin=je[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.ctx.globalAlpha=this.current.fillAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.cachedCanvases.getCanvas("smaskGroupAt"+this.groupLevel,this.ctx.canvas.width,this.ctx.canvas.height);this.suspendedCtx=this.ctx;const e=this.ctx=t.context;e.setTransform(this.suspendedCtx.getTransform()),$e(this.suspendedCtx,e),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,r,o){e.transform(t,i,s,n,r,o),this.__originalTransform(t,i,s,n,r,o)},t.setTransform=function(t,i,s,n,r,o){e.setTransform(t,i,s,n,r,o),this.__originalSetTransform(t,i,s,n,r,o)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,r,o){e.bezierCurveTo(t,i,s,n,r,o),this.__originalBezierCurveTo(t,i,s,n,r,o)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(e,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),$e(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){this.current.activeSMask&&(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],this.composeSMask(this.suspendedCtx,this.current.activeSMask,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,i,s){const n=s[0],r=s[1],o=s[2]-n,h=s[3]-r;0!==o&&0!==h&&(this.genericComposeSMask(e.context,i,o,h,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,o,h,a,c,l){let u=t.canvas,d=h-c,f=a-l;if(r)if(d<0||f<0||d+i>u.width||f+s>u.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),e=t.context;e.drawImage(u,-d,-f),e.globalCompositeOperation="destination-atop",e.fillStyle=r,e.fillRect(0,0,i,s),e.globalCompositeOperation="source-over",u=t.canvas,d=f=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(d,f,i,s),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=r,t.fillRect(d,f,i,s),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&o?e.filter=this.filterFactory.addAlphaFilter(o):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(o));const p=new Path2D;p.rect(h,a,i,s),e.clip(p),e.globalCompositeOperation="destination-in",e.drawImage(u,d,f,i,s,h,a,i,s),e.restore()}save(){this.inSMaskMode&&$e(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&$e(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,s,n,r){this.ctx.transform(t,e,i,s,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){let[s]=e;if(!i)return s||=e[0]=new Path2D,void this[t](s);if(!(s instanceof Path2D)){const t=e[0]=new Path2D;for(let e=0,i=s.length;e<i;)switch(s[e++]){case 0:t.moveTo(s[e++],s[e++]);break;case 1:t.lineTo(s[e++],s[e++]);break;case 2:t.bezierCurveTo(s[e++],s[e++],s[e++],s[e++],s[e++],s[e++]);break;case 3:t.closePath();break;default:I(`Unrecognized drawing path operator: ${s[e-1]}`)}s=t}Q.axialAlignedBoundingBox(i,vt(this.ctx),this.current.minMax),this[t](s)}closePath(){this.ctx.closePath()}stroke(t,e=!0){const i=this.ctx,s=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof s&&s?.getPattern){const e=s.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=s.getPattern(i,this,yt(i),we),e){const s=new Path2D;s.addPath(t,i.getTransform().invertSelf().multiplySelf(e)),t=s}this.rescaleAndStroke(t,!1),i.restore()}else this.rescaleAndStroke(t,!0);e&&this.consumePath(t,this.current.getClippedPathBoundingBox(we,vt(this.ctx))),i.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t,e=!0){const i=this.ctx,s=this.current.fillColor;let n=!1;if(this.current.patternFill){const e=s.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.fillStyle=s.getPattern(i,this,yt(i),me),e){const s=new Path2D;s.addPath(t,i.getTransform().invertSelf().multiplySelf(e)),t=s}n=!0}const r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(i.fill(t,"evenodd"),this.pendingEOFill=!1):i.fill(t)),n&&i.restore(),e&&this.consumePath(t,r)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}rawFillPath(t){this.ctx.fill(t)}clip(){this.pendingClip=ze}eoClip(){this.pendingClip=He}beginText(){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return;const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:r,fontSize:o,path:h}of t)i.addPath(h,new DOMMatrix(e).preMultiplySelf(s).translate(n,r).scale(o,-o));e.clip(i),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||A,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||I("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let o="normal";i.black?o="900":i.bold&&(o="bold");const h=i.italic?"italic":"normal";let a=e;e<16?a=16:e>100&&(a=100),this.current.fontSizeScale=e/a,this.ctx.font=`${h} ${o} ${a}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t){const{current:e}=this;e.textMatrix=t,e.textMatrixScale=Math.hypot(t[0],t[1]),e.x=e.lineX=0,e.y=e.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#Di(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n){const r=this.ctx,o=this.current,h=o.font,a=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,l=3&a,u=!!(4&a),d=o.patternFill&&!h.missingFile,f=o.patternStroke&&!h.missingFile;let p;if((h.disableFontFace||u||d||f)&&(p=h.getPathGenerator(this.commonObjs,t)),h.disableFontFace||d||f){let t;if(r.save(),r.translate(e,i),r.scale(c,-c),0!==l&&2!==l||(s?(t=r.getTransform(),r.setTransform(...s),r.fill(this.#Di(p,t,s))):r.fill(p)),1===l||2===l)if(n){t||=r.getTransform(),r.setTransform(...n);const{a:e,b:i,c:s,d:o}=t,h=Q.inverseTransform(n),a=Q.transform([e,i,s,o,0,0],h);Q.singularValueDecompose2dScale(a,_e),r.lineWidth*=Math.max(_e[0],_e[1])/c,r.stroke(this.#Di(p,t,n))}else r.lineWidth/=c,r.stroke(p);r.restore()}else 0!==l&&2!==l||r.fillText(t,e,i),1!==l&&2!==l||r.strokeText(t,e,i);u&&(this.pendingTextPaths||=[]).push({transform:vt(r),x:e,y:i,fontSize:c,path:p})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return L(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(0===s)return;const n=this.ctx,r=e.fontSizeScale,o=e.charSpacing,h=e.wordSpacing,a=e.fontDirection,c=e.textHScale*a,l=t.length,u=i.vertical,d=u?1:-1,f=i.defaultVMetrics,p=s*e.fontMatrix[0],g=0===e.textRenderingMode&&!i.disableFontFace&&!e.patternFill;let m,w;if(n.save(),e.textMatrix&&n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),n.scale(c,a>0?-1:1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,yt(n),me);m=vt(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,yt(n),we);w=vt(n),n.restore(),n.strokeStyle=t}let A=e.lineWidth;const b=e.textMatrixScale;if(0===b||0===A){const t=3&e.textRenderingMode;1!==t&&2!==t||(A=this.getSinglePixelWidth())}else A/=b;if(1!==r&&(n.scale(r,r),A/=r),n.lineWidth=A,i.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t)i.push(e.unicode),s+=e.width;return n.fillText(i.join(""),0,0),e.x+=s*p*c,n.restore(),void this.compose()}let v,y=0;for(v=0;v<l;++v){const e=t[v];if("number"==typeof e){y+=d*e*s/1e3;continue}let c=!1;const l=(e.isSpace?h:0)+o,A=e.fontChar,b=e.accent;let x,M,E=e.width;if(u){const t=e.vmetric||f,i=-(e.vmetric?t[1]:.5*E)*p;E=t?-t[0]:E,x=i/r,M=(y+t[2]*p)/r}else x=y/r,M=0;if(i.remeasure&&E>0){const t=1e3*n.measureText(A).width/s*r;if(E<t&&this.isFontSubpixelAAEnabled){const e=E/t;c=!0,n.save(),n.scale(e,1),x/=e}else E!==t&&(x+=(E-t)/2e3*s/r)}this.contentVisible&&(e.isInFont||i.missingFile)&&(g&&!b?n.fillText(A,x,M):(this.paintChar(A,x,M,m,w),b&&this.paintChar(b.fontChar,x+s*b.offset.x/r,M-s*b.offset.y/r,m,w))),y+=u?E*p-l*a:E*p+l*a,c&&n.restore()}u?e.y-=y:e.x+=y*c,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,r=i.fontDirection,o=s.vertical?1:-1,h=i.charSpacing,a=i.wordSpacing,c=i.textHScale*r,l=i.fontMatrix||A,u=t.length;let d,f,p,g;if(3!==i.textRenderingMode&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),i.textMatrix&&e.transform(...i.textMatrix),e.translate(i.x,i.y+i.textRise),e.scale(c,r),d=0;d<u;++d){if(f=t[d],"number"==typeof f){g=o*f*n/1e3,this.ctx.translate(g,0),i.x+=g*c;continue}const r=(f.isSpace?a:0)+h,u=s.charProcOperatorList[f.operatorListId];u?this.contentVisible&&(this.save(),e.scale(n,n),e.transform(...l),this.executeOperatorList(u),this.restore()):I(`Type3 character "${f.operatorListId}" is not available.`);const m=[f.width,0];Q.applyTransform(m,l),p=m[0]*n+r,e.translate(p,0),i.x+=p*c}e.restore()}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,r){const o=new Path2D;o.rect(i,s,n-i,r-s),this.ctx.clip(o),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=this.baseTransform||vt(this.ctx);e=new ke(t,this.ctx,{createCanvasGraphics:t=>new Ge(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t){this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t){this.ctx.fillStyle=this.current.fillColor=t,this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new ye(t);case"Mesh":return new Ee(t);case"Dummy":return new Se}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,yt(e),Ae);const s=yt(e);if(s){const{width:t,height:i}=e.canvas,n=Re.slice();Q.axialAlignedBoundingBox([0,0,t,i],s,n);const[r,o,h,a]=n;this.ctx.fillRect(r,o,h-r,a-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){D("Should not call beginInlineImage")}beginImageData(){D("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=vt(this.ctx),e)){Q.axialAlignedBoundingBox(e,this.baseTransform,this.current.minMax);const[t,i,s,n]=e,r=new Path2D;r.rect(t,i,s-t,n-i),this.ctx.clip(r),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||N("TODO: Support non-isolated groups."),t.knockout&&I("Knockout groups not supported.");const i=vt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=Re.slice();Q.axialAlignedBoundingBox(t.bbox,vt(e),s),s=Q.intersect(s,[0,0,e.canvas.width,e.canvas.height])||[0,0,0,0];const n=Math.floor(s[0]),r=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-n,1),h=Math.max(Math.ceil(s[3])-r,1);this.current.startNewPathAndClipBox([0,0,o,h]);let a="groupAt"+this.groupLevel;t.smask&&(a+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(a,o,h),l=c.context;l.translate(-n,-r),l.transform(...i);let u=new Path2D;const[d,f,p,g]=t.bbox;if(u.rect(d,f,p-d,g-f),t.matrix){const e=new Path2D;e.addPath(u,new DOMMatrix(t.matrix)),u=e}l.clip(u),t.smask?this.smaskStack.push({canvas:c.canvas,context:l,offsetX:n,offsetY:r,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(n,r),e.save()),$e(e,l),this.ctx=l,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=vt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=Re.slice();Q.axialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t,i),this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#Ni(),Le(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],r=e[3]-e[1];if(n&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=r,Q.singularValueDecompose2dScale(vt(this.ctx),_e);const{viewportScale:n}=this,o=Math.ceil(s*this.outputScaleX*n),h=Math.ceil(r*this.outputScaleY*n);this.annotationCanvas=this.canvasFactory.create(o,h);const{canvas:a,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(t,a),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,this.ctx.save(),this.ctx.setTransform(_e[0],0,0,-_e[1],0,r*_e[1]),Le(this.ctx)}else{Le(this.ctx),this.endPath();const t=new Path2D;t.rect(e[0],e[1],s,r),this.ctx.clip(t)}}this.current=new De(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#Ii(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this._createMaskCanvas(t),n=s.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(n,s.offsetX,s.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const o=this.ctx;o.save();const h=vt(o);o.transform(e,i,s,n,0,0);const a=this._createMaskCanvas(t);o.setTransform(1,0,0,1,a.offsetX-h[4],a.offsetY-h[5]);for(let t=0,c=r.length;t<c;t+=2){const c=Q.transform(h,[e,i,s,n,r[t],r[t+1]]);o.drawImage(a.canvas,c[4],c[5])}o.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:t,width:r,height:o,transform:h}=n,a=this.cachedCanvases.getCanvas("maskCanvas",r,o),c=a.context;c.save(),Oe(c,this.getObject(t,n)),c.globalCompositeOperation="source-in",c.fillStyle=s?i.getPattern(c,this,yt(e),me):i,c.fillRect(0,0,r,o),c.restore(),e.save(),e.transform(...h),e.scale(1,-1),Ie(e,a.canvas,0,0,r,o,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):I("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void I("Dependent image isn't ready yet");const r=n.width,o=n.height,h=[];for(let t=0,n=s.length;t<n;t+=2)h.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:r,h:o});this.paintInlineImageXObjectGroup(n,h)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;this.save();const{filter:n}=s;let r;if("none"!==n&&""!==n&&(s.filter="none"),s.scale(1/e,-1/i),t.bitmap)r=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)r=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;Fe(s,t),r=this.applyTransferMapsToCanvas(s)}const o=this._scaleImage(r,yt(s));s.imageSmoothingEnabled=Be(vt(s),t.interpolate),Ie(s,o.img,0,0,o.paintWidth,o.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const e=this.cachedCanvases.getCanvas("inlineImage",t.width,t.height).context;Fe(e,t),s=this.applyTransferMapsToCanvas(e)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),Ie(i,s,t.x,t.y,t.w,t.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){this.markedContentStack.push("OC"===t?{visible:this.optionalContentConfig.isVisible(e)}:{visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t,e){const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const s=this.ctx;this.pendingClip&&(i||(this.pendingClip===He?s.clip(t,"evenodd"):s.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=vt(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,o;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)r=o=1/i;else{const e=i*t;r=o=e<1?1/e:1}else if(0===t)r=1/i,o=1/s;else{const e=i*t,n=s*t;r=e<1?1/e:1,o=n<1?1/n:1}}else{const h=Math.abs(e*n-i*s),a=Math.hypot(e,i),c=Math.hypot(s,n);if(0===t)r=c/h,o=a/h;else{const e=t*h;r=c>e?c/e:1,o=a>e?a/e:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:s}}=this,[n,r]=this.getScaleForStroking();if(n===r)return i.lineWidth=(s||1)*n,void i.stroke(t);const o=i.getLineDash();e&&i.save(),i.scale(n,r),Pe.a=1/n,Pe.d=1/r;const h=new Path2D;if(h.addPath(t,Pe),o.length>0){const t=Math.max(n,r);i.setLineDash(o.map((e=>e/t))),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(h),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in C)void 0!==Ge.prototype[t]&&(Ge.prototype[C[t]]=Ge.prototype[t]);class We{static#Fi=null;static#Oi="";static get workerPort(){return this.#Fi}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#Fi=t}static get workerSrc(){return this.#Oi}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#Oi=t}}class Ve{#$i;#Li;constructor({parsedData:t,rawData:e}){this.#$i=t,this.#Li=e}getRaw(){return this.#Li}get(t){return this.#$i.get(t)??null}[Symbol.iterator](){return this.#$i.entries()}}const Xe=Symbol("INTERNAL");class Ye{#Bi=!1;#Ui=!1;#ji=!1;#zi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#Bi=!!(2&t),this.#Ui=!!(4&t),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#ji)return this.#zi;if(!this.#zi)return!1;const{print:t,view:e}=this.usage;return this.#Bi?"OFF"!==e?.viewState:!this.#Ui||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==Xe&&D("Internal method `_setVisible` called."),this.#ji=i,this.#zi=e}}class qe{#Hi=null;#Gi=new Map;#Wi=null;#Vi=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#Vi=t.order;for(const i of t.groups)this.#Gi.set(i.id,new Ye(e,i));if("OFF"===t.baseState)for(const t of this.#Gi.values())t._setVisible(Xe,!1);for(const e of t.on)this.#Gi.get(e)._setVisible(Xe,!0);for(const e of t.off)this.#Gi.get(e)._setVisible(Xe,!1);this.#Wi=this.getHash()}}#Xi(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#Xi(e);else{if(!this.#Gi.has(e))return I(`Optional content group not found: ${e}`),!0;n=this.#Gi.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#Gi.size)return!0;if(!t)return N("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Gi.has(t.id)?this.#Gi.get(t.id).visible:(I(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Xi(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Gi.has(e))return I(`Optional content group not found: ${e}`),!0;if(this.#Gi.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Gi.has(e))return I(`Optional content group not found: ${e}`),!0;if(!this.#Gi.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Gi.has(e))return I(`Optional content group not found: ${e}`),!0;if(!this.#Gi.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Gi.has(e))return I(`Optional content group not found: ${e}`),!0;if(this.#Gi.get(e).visible)return!1}return!0}return I(`Unknown optional content policy ${t.policy}.`),!0}return I(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#Gi.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#Gi.get(i)?._setVisible(Xe,!1,!0);s._setVisible(Xe,!!e,!0),this.#Hi=null}else I(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=this.#Gi.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#Hi=null}get hasInitialVisibility(){return null===this.#Wi||this.getHash()===this.#Wi}getOrder(){return this.#Gi.size?this.#Vi?this.#Vi.slice():[...this.#Gi.keys()]:null}getGroup(t){return this.#Gi.get(t)||null}getHash(){if(null!==this.#Hi)return this.#Hi;const t=new jt;for(const[e,i]of this.#Gi)t.update(`${e}:${i.visible}`);return this.#Hi=t.hexdigest()}[Symbol.iterator](){return this.#Gi.entries()}}class Qe{constructor(t,{disableRange:e=!1,disableStream:i=!1}){F(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=o,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i):F(this._rangeReaders.some((function(e){return e._begin===t&&(e._enqueue(i),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?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(){F(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Ke(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Je(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Ke{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=lt(s)?s:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Je{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ze(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const s=e[t];void 0!==s&&i.append(t,s)}return i}function ti(t){return URL.parse(t)?.origin??null}function ei({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);return Number.isInteger(r)?(n.suggestedLength=r,r<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n):n}function ii(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=o(i);return t=unescape(t),t=h(t),t=a(t),r(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=o(s),i&&(s=unescape(s),0===t&&(s=h(s))),r.push(s)}return r.join("")}(t),i)return r(a(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=o(i);return t=a(t),r(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=X(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function o(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function h(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function a(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{s=atob(s)}catch{}return n(e,s)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(lt(t))return t}return null}function si(t,e){return new H(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function ni(t){return 200===t||206===t}function ri(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function oi(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(I(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class hi{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Ze(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return F(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ai(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new ci(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class ai{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,ri(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=ti(e.url),!ni(e.status))throw si(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:r}=ei({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=ii(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new W("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:oi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ci{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,ri(n,this._withCredentials,this._abortController)).then((e=>{const i=ti(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!ni(e.status))throw si(e.status,r);this._readCapability.resolve(),this._reader=e.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:oi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class li{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Ze(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[t,i]of this.headers)e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",F(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError(s.status);const n=s.status||200;if((200!==n||206!==i.expectedStatus)&&n!==i.expectedStatus)return void i.onError(s.status);const r=function(t){const e=t.response;return"string"!=typeof e?e:X(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:r}):(I('Missing or invalid "Content-Range" header.'),i.onError(0))}else r?i.onDone({begin:0,chunk:r}):i.onError(s.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 ui{constructor(t){this._source=t,this._manager=new li(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 F(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new di(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new fi(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class di{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=ti(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{allowRangeRequests:n,suggestedLength:r}=ei({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=ii(s),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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=si(t,this._url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class fi{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=ti(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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=si(t,this._url);for(const t of this._requests)t.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(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const pi=/^[a-z][a-z0-9\-+.]+:/i;class gi{constructor(t){this.source=t,this.url=function(t){if(pi.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),F("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return F(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new mi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new wi(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class mi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=si(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){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 null===t?(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){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new W("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class wi{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!t.source.disableStream;const s=process.getBuiltinModule("fs");this._setReadableStream(s.createReadStream(this._url,{start:e,end:i-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 null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const Ai=Symbol("INITIAL_DATA");class bi{#Yi=Object.create(null);#qi(t){return this.#Yi[t]||={...Promise.withResolvers(),data:Ai}}get(t,e=null){if(e){const i=this.#qi(t);return i.promise.then((()=>e(i.data))),null}const i=this.#Yi[t];if(!i||i.data===Ai)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Yi[t];return!!e&&e.data!==Ai}delete(t){const e=this.#Yi[t];return!(!e||e.data===Ai||(delete this.#Yi[t],0))}resolve(t,e=null){const i=this.#qi(t);i.data=e,i.resolve()}clear(){for(const t in this.#Yi){const{data:e}=this.#Yi[t];e?.bitmap?.close()}this.#Yi=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Yi){const{data:e}=this.#Yi[t];e!==Ai&&(yield[t,e])}}}class vi{#Qi=Promise.withResolvers();#mt=null;#Ki=!1;#Ji=!!globalThis.FontInspector?.enabled;#Zi=null;#ts=null;#es=0;#is=0;#ss=null;#ns=null;#rs=0;#os=0;#hs=Object.create(null);#as=[];#cs=null;#ls=[];#us=new WeakMap;#ds=null;static#fs=new Map;static#ps=new Map;static#gs=new WeakMap;static#ms=null;static#ws=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#cs=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#cs=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#mt=this.#ns=e,this.#os=i.scale*Mt.pixelRatio,this.#rs=i.rotation,this.#ts={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:n,pageX:r,pageY:o}=i.rawDims;this.#ds=[1,0,0,-1,-r,o+n],this.#is=s,this.#es=n,vi.#As(),xt(e,i),this.#Qi.promise.finally((()=>{vi.#ws.delete(this),this.#ts=null,this.#hs=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Y.platform;return L(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{this.#ss.read().then((({value:e,done:i})=>{i?this.#Qi.resolve():(this.#Zi??=e.lang,Object.assign(this.#hs,e.styles),this.#bs(e.items),t())}),this.#Qi.reject)};return this.#ss=this.#cs.getReader(),vi.#ws.add(this),t(),this.#Qi.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*Mt.pixelRatio,s=t.rotation;if(s!==this.#rs&&(e?.(),this.#rs=s,xt(this.#ns,{rotation:s})),i!==this.#os){e?.(),this.#os=i;const t={div:null,properties:null,ctx:vi.#vs(this.#Zi)};for(const e of this.#ls)t.properties=this.#us.get(e),t.div=e,this.#ys(t)}}cancel(){const t=new W("TextLayer task cancelled.");this.#ss?.cancel(t).catch((()=>{})),this.#ss=null,this.#Qi.reject(t)}get textDivs(){return this.#ls}get textContentItemsStr(){return this.#as}#bs(t){if(this.#Ki)return;this.#ts.ctx??=vi.#vs(this.#Zi);const e=this.#ls,i=this.#as;for(const s of t){if(e.length>1e5)return I("Ignoring additional textDivs for performance reasons."),void(this.#Ki=!0);if(void 0!==s.str)i.push(s.str),this.#xs(s);else if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){const t=this.#mt;this.#mt=document.createElement("span"),this.#mt.classList.add("markedContent"),null!==s.id&&this.#mt.setAttribute("id",`${s.id}`),t.append(this.#mt)}else"endMarkedContent"===s.type&&(this.#mt=this.#mt.parentNode)}}#xs(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#ls.push(e);const s=Q.transform(this.#ds,t.transform);let n=Math.atan2(s[1],s[0]);const r=this.#hs[t.fontName];r.vertical&&(n+=Math.PI/2);let o=this.#Ji&&r.fontSubstitution||r.fontFamily;o=vi.fontFamilyMap.get(o)||o;const h=Math.hypot(s[2],s[3]),a=h*vi.#Ms(o,r,this.#Zi);let c,l;0===n?(c=s[4],l=s[5]-a):(c=s[4]+a*Math.sin(n),l=s[5]-a*Math.cos(n));const u="calc(var(--total-scale-factor) *",d=e.style;this.#mt===this.#ns?(d.left=`${(100*c/this.#is).toFixed(2)}%`,d.top=`${(100*l/this.#es).toFixed(2)}%`):(d.left=`${u}${c.toFixed(2)}px)`,d.top=`${u}${l.toFixed(2)}px)`),d.fontSize=`${u}${(vi.#ms*h).toFixed(2)}px)`,d.fontFamily=o,i.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#Ji&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),0!==n&&(i.angle=n*(180/Math.PI));let f=!1;if(t.str.length>1)f=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(f=!0)}if(f&&(i.canvasWidth=r.vertical?t.height:t.width),this.#us.set(e,i),this.#ts.div=e,this.#ts.properties=i,this.#ys(this.#ts),i.hasText&&this.#mt.append(e),i.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#mt.append(t)}}#ys(t){const{div:e,properties:i,ctx:s}=t,{style:n}=e;let r="";if(vi.#ms>1&&(r=`scale(${1/vi.#ms})`),0!==i.canvasWidth&&i.hasText){const{fontFamily:t}=n,{canvasWidth:o,fontSize:h}=i;vi.#Es(s,h*this.#os,t);const{width:a}=s.measureText(e.textContent);a>0&&(r=`scaleX(${o*this.#os/a}) ${r}`)}0!==i.angle&&(r=`rotate(${i.angle}deg) ${r}`),r.length>0&&(n.transform=r)}static cleanup(){if(!(this.#ws.size>0)){this.#fs.clear();for(const{canvas:t}of this.#ps.values())t.remove();this.#ps.clear()}}static#vs(t=null){let e=this.#ps.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#ps.set(t,e),this.#gs.set(e,{size:0,family:""})}return e}static#Es(t,e,i){const s=this.#gs.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#As(){if(null!==this.#ms)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.#ms=t.getBoundingClientRect().height,t.remove()}static#Ms(t,e,i){const s=this.#fs.get(t);if(s)return s;const n=this.#vs(i);n.canvas.width=n.canvas.height=30,this.#Es(n,30,t);const r=n.measureText(""),o=r.fontBoundingBoxAscent,h=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let a=.8;return o?a=o/(o+h):(Y.platform.isFirefox&&I("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?a=e.ascent:e.descent&&(a=1+e.descent)),this.#fs.set(t,a),a}}class yi{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let s=null;const n=i.name;if("#text"===n)s=i.value;else{if(!yi.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}function xi(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Mi,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(w)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(w&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return X(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,o=!0===t.withCredentials,h=t.password??null,a=t.range instanceof Ei?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let l=t.worker instanceof Ci?t.worker:null;const u=t.verbosity,d="string"!=typeof t.docBaseUrl||ct(t.docBaseUrl)?null:t.docBaseUrl,f=Xt(t.cMapUrl),p=!1!==t.cMapPacked,g=t.CMapReaderFactory||(w?fe:se),m=Xt(t.iccUrl),A=Xt(t.standardFontDataUrl),b=t.StandardFontDataFactory||(w?pe:he),v=Xt(t.wasmUrl),y=t.WasmFactory||(w?ge:ce),x=!0!==t.stopAtErrors,M=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,E=!1!==t.isEvalSupported,S="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!w,k="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!w&&(Y.platform.isFirefox||!globalThis.chrome),C=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,T="boolean"==typeof t.disableFontFace?t.disableFontFace:w,P=!0===t.fontExtraProperties,R=!0===t.enableXfa,N=t.ownerDocument||globalThis.document,I=!0===t.disableRange,D=!0===t.disableStream,F=!0===t.disableAutoFetch,O=!0===t.pdfBug,$=t.CanvasFactory||(w?de:ee),L=t.FilterFactory||(w?ue:re),B=!0===t.enableHWA,U=!1!==t.useWasm,j=a?a.length:t.length??NaN,z="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!w&&!T,H="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(g===se&&b===he&&y===ce&&f&&A&&v&&pt(f,document.baseURI)&&pt(A,document.baseURI)&&pt(v,document.baseURI));_(u);const G={canvasFactory:new $({ownerDocument:N,enableHWA:B}),filterFactory:new L({docId:i,ownerDocument:N}),cMapReaderFactory:H?null:new g({baseUrl:f,isCompressed:p}),standardFontDataFactory:H?null:new b({baseUrl:A}),wasmFactory:H?null:new y({baseUrl:v})};l||(l=Ci.create({verbosity:u,port:We.workerPort}),e._worker=l);const W={docId:i,apiVersion:"5.3.31",data:n,password:h,disableAutoFetch:F,rangeChunkSize:c,length:j,docBaseUrl:d,enableXfa:R,evaluatorOptions:{maxImageSize:M,disableFontFace:T,ignoreErrors:x,isEvalSupported:E,isOffscreenCanvasSupported:S,isImageDecoderSupported:k,canvasMaxAreaInBytes:C,fontExtraProperties:P,useSystemFonts:z,useWasm:U,useWorkerFetch:H,cMapUrl:f,iccUrl:m,standardFontDataUrl:A,wasmUrl:v}},V={ownerDocument:N,pdfBug:O,styleElement:null,loadingParams:{disableAutoFetch:F,enableXfa:R}};return l.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(l.destroyed)throw new Error("Worker was destroyed");const t=l.messageHandler.sendWithPromise("GetDocRequest",W,n?[n.buffer]:null);let h;if(a)h=new Qe(a,{disableRange:I,disableStream:D});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");const t=pt(s)?hi:w?gi:ui;h=new t({url:s,length:j,httpHeaders:r,withCredentials:o,rangeChunkSize:c,disableRange:I,disableStream:D})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(l.destroyed)throw new Error("Worker was destroyed");const s=new Zt(i,t,l.port),n=new Ti(s,e,h,V,G);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}class Mi{static#Ai=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+Mi.#Ai++;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 Ei{#Qi=Promise.withResolvers();#Ss=[];#ks=[];#Cs=[];#Ts=[];constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}addRangeListener(t){this.#Ts.push(t)}addProgressListener(t){this.#Cs.push(t)}addProgressiveReadListener(t){this.#ks.push(t)}addProgressiveDoneListener(t){this.#Ss.push(t)}onDataRange(t,e){for(const i of this.#Ts)i(t,e)}onDataProgress(t,e){this.#Qi.promise.then((()=>{for(const i of this.#Cs)i(t,e)}))}onDataProgressiveRead(t){this.#Qi.promise.then((()=>{for(const e of this.#ks)e(t)}))}onDataProgressiveDone(){this.#Qi.promise.then((()=>{for(const t of this.#Ss)t()}))}transportReady(){this.#Qi.resolve()}requestDataRange(t,e){D("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Si{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 L(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class ki{#Ps=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new ft:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new bi,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new ht({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return L(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=v.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:o=null,annotationCanvasMap:h=null,pageColors:a=null,printAnnotationStorage:c=null,isEditing:l=!1}){this._stats?.time("Overall");const u=this._transport.getRenderingIntent(i,s,c,l),{renderingIntent:d,cacheKey:f}=u;this.#Ps=!1,o||=this._transport.getOptionalContentConfig(d);let p=this._intentStates.get(f);p||(p=Object.create(null),this._intentStates.set(f,p)),p.streamReaderCancelTimeout&&(clearTimeout(p.streamReaderCancelTimeout),p.streamReaderCancelTimeout=null);const g=!!(4&d);p.displayReadyCapability||(p.displayReadyCapability=Promise.withResolvers(),p.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u));const m=t=>{p.renderTasks.delete(w),g&&(this.#Ps=!0),this.#_s(),t?(w.capability.reject(t),this._abortOperatorList({intentState:p,reason:t instanceof Error?t:new Error(t)})):w.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},w=new _i({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:p.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!g,pdfBug:this._pdfBug,pageColors:a});(p.renderTasks||=new Set).add(w);const A=w.task;return Promise.all([p.displayReadyCapability.promise,o]).then((([t,e])=>{if(this.destroyed)m();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&d))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");w.initializeGraphics({transparency:t,optionalContentConfig:e}),w.operatorListChanged()}})).catch(m),A}getOperatorList({intent:t="display",annotationMode:e=v.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let r,o=this._intentStates.get(n.cacheKey);return o||(o=Object.create(null),this._intentStates.set(n.cacheKey,o)),o.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(r))},o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||=new Set).add(r),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>yi.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then((function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#Ps=!1,Promise.all(t)}cleanup(t=!1){this.#Ps=!0;const e=this.#_s();return t&&e&&(this._stats&&=new ft),e}#_s(){if(!this.#Ps||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.#Ps=!1,!0}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#_s()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),h=this._intentStates.get(e);h.streamReader=o;const a=()=>{o.read().then((({value:t,done:e})=>{e?h.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,h),a())}),(t=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const t of h.renderTasks)t.operatorListChanged();this.#_s()}if(h.displayReadyCapability)h.displayReadyCapability.reject(t);else{if(!h.opListReadCapability)throw t;h.opListReadCapability.reject(t)}}}))};a()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof at){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})}),i))}}if(t.streamReader.cancel(new W(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class Ci{#Qi=Promise.withResolvers();#Rs=null;#Fi=null;#Ns=null;static#Is=0;static#Ds=!1;static#Fs=new WeakMap;static{w&&(this.#Ds=!0,We.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>URL.createObjectURL(new Blob([`await import("${t}");`],{type:"text/javascript"})),this.fromPort=t=>{if(console.log("Deprecated API usage: `PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:i=R()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(Ci.#Fs.has(e))throw new Error("Cannot use more than one PDFWorker per port.");Ci.#Fs.set(e,this),this.#Os(e)}else this.#$s()}get promise(){return this.#Qi.promise}#Ls(){this.#Qi.resolve(),this.#Rs.send("configure",{verbosity:this.verbosity})}get port(){return this.#Fi}get messageHandler(){return this.#Rs}#Os(t){this.#Fi=t,this.#Rs=new Zt("main","worker",t),this.#Rs.on("ready",(()=>{})),this.#Ls()}#$s(){if(Ci.#Ds||Ci.#Bs)return void this.#Us();let{workerSrc:t}=Ci;try{Ci._isSameOrigin(window.location,t)||(t=Ci._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new Zt("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this.#Qi.reject(new Error("Worker was destroyed")):this.#Us()},n=new AbortController;e.addEventListener("error",(()=>{this.#Ns||s()}),{signal:n.signal}),i.on("test",(t=>{n.abort(),!this.destroyed&&t?(this.#Rs=i,this.#Fi=e,this.#Ns=e,this.#Ls()):s()})),i.on("ready",(()=>{if(n.abort(),this.destroyed)s();else try{r()}catch{this.#Us()}}));const r=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};return void r()}catch{N("The worker has been disabled.")}this.#Us()}#Us(){Ci.#Ds||(I("Setting up fake worker."),Ci.#Ds=!0),Ci._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this.#Qi.reject(new Error("Worker was destroyed"));const e=new Qt;this.#Fi=e;const i="fake"+Ci.#Is++,s=new Zt(i+"_worker",i,e);t.setup(s,e),this.#Rs=new Zt(i,i+"_worker",e),this.#Ls()})).catch((t=>{this.#Qi.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this.#Ns?.terminate(),this.#Ns=null,Ci.#Fs.delete(this.#Fi),this.#Fi=null,this.#Rs?.destroy(),this.#Rs=null}static create(t){const e=this.#Fs.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 Ci(t)}static get workerSrc(){if(We.workerSrc)return We.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Bs(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return L(this,"_setupFakeWorkerGlobal",(async()=>this.#Bs?this.#Bs:(await import(this.workerSrc)).WorkerMessageHandler)())}}class Ti{#js=new Map;#zs=new Map;#Hs=new Map;#Gs=new Map;#Ws=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new bi,this.fontLoader=new Wt({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Vs(t,e=null){const i=this.#js.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#js.set(t,s),s}get annotationStorage(){return L(this,"annotationStorage",new Ht)}getRenderingIntent(t,e=v.ENABLE,i=null,s=!1,n=!1){let r=2,o=zt;switch(t){case"any":r=1;break;case"display":break;case"print":r=4;break;default:I(`getRenderingIntent - invalid intent: ${t}`)}const h=4&r&&i instanceof Gt?i:this.annotationStorage;switch(e){case v.DISABLE:r+=64;break;case v.ENABLE:break;case v.ENABLE_FORMS:r+=16;break;case v.ENABLE_STORAGE:r+=32,o=h.serializable;break;default:I(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=128),n&&(r+=256);const{ids:a,hash:c}=h.modifiedIds;return{renderingIntent:r,cacheKey:[r,o.hash,c].join("_"),annotationStorageSerializable:o,modifiedIds:a}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Ws?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#zs.values())t.push(e._destroy());this.#zs.clear(),this.#Hs.clear(),this.#Gs.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.#js.clear(),this.filterFactory.destroy(),vi.cleanup(),this._networkStream?.cancelAllRequests(new W("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",((t,e)=>{F(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function({value:t,done:i}){i?e.close():(F(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async()=>{await this._fullReader.headersReady;const{isStreamingSupported:t,isRangeSupported:i,contentLength:s}=this._fullReader;return t&&i||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:t,isRangeSupported:i,contentLength:s}})),t.on("GetRangeReader",((t,e)=>{F(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then((function({value:t,done:i}){i?e.close():(F(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{i.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Si(t,this))})),t.on("DocException",(t=>{e._capability.reject(Jt(t))})),t.on("PasswordRequest",(t=>{this.#Ws=Promise.withResolvers();try{if(!e.onPassword)throw Jt(t);e.onPassword((t=>{t instanceof Error?this.#Ws.reject(t):this.#Ws.resolve({password:t})}),t.code)}catch(t){this.#Ws.reject(t)}return this.#Ws.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{this.destroyed||this.#zs.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){const t=s.error;I(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const n=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,r=new Vt(s,n);this.fontLoader.bind(r).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!r.fontExtraProperties&&r.data&&(r.data=null),this.commonObjs.resolve(e,r)}));break;case"CopyLocalImage":const{imageRef:o}=s;F(o,"The imageRef must be defined.");for(const t of this.#zs.values())for(const[,i]of t.objs)if(i?.ref===o)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null})),t.on("obj",(([t,e,i,s])=>{if(this.destroyed)return;const n=this.#zs.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":case"Pattern":n.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBinaryData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&I("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,i=this.#Hs.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#Gs.set(i.refStr,t);const s=new ki(e,i,this,this._params.pdfBug);return this.#zs.set(e,s),s}));return this.#Hs.set(e,s),s}getPageIndex(t){return Yt(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.#Vs("GetFieldObjects")}hasJSActions(){return this.#Vs("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Vs("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.#Vs("GetOptionalContentConfig").then((e=>new qe(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#js.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new Ve(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#js.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#zs.values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#js.clear(),this.filterFactory.destroy(!0),vi.cleanup()}}cachedPageNumber(t){return Yt(t)?this.#Gs.get(0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`)??null:null}}class Pi{#Xs=null;onContinue=null;onError=null;constructor(t){this.#Xs=t}get promise(){return this.#Xs.capability.promise}cancel(t=0){this.#Xs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#Xs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#Xs;return t.form||t.canvas&&e?.size>0}}class _i{#Ys=null;static#qs=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:o,canvasFactory:h,filterFactory:a,useRequestAnimationFrame:c=!1,pdfBug:l=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=o,this.canvasFactory=h,this.filterFactory=a,this._pdfBug=l,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===c&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Pi(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.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(_i.#qs.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.");_i.#qs.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{canvasContext:i,viewport:s,transform:n,background:r}=this.params;this.gfx=new Ge(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,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.#Ys&&(window.cancelAnimationFrame(this.#Ys),this.#Ys=null),_i.#qs.delete(this._canvas),t||=new at(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Ys=window.requestAnimationFrame((()=>{this.#Ys=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),_i.#qs.delete(this._canvas),this.callback())))}}const Ri="5.3.31",Ni="47ad820d9";function Ii(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Di(t){return Math.max(0,Math.min(255,255*t))}m(531);class Fi{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}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=Di(t),t,t]}static G_HTML([t]){const e=Ii(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Di)}static RGB_HTML(t){return`#${t.map(Ii).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[Di(1-Math.min(1,t+s)),Di(1-Math.min(1,i+s)),Di(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i;return["CMYK",s,n,r,Math.min(s,n,r)]}}class Oi{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){D("Abstract method `_createSVG` called.")}}class $i extends Oi{_createSVG(t){return document.createElementNS(nt,t)}}class Li{static setupStorage(t,e,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{s.setValue(e,{value:t.target.getAttribute(t.target.checked?"xfaOn":"xfaOff")})}))}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of i.children)t.attributes.value===r.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const i=t.target.options;s.setValue(e,{value:-1===i.selectedIndex?"":i[i.selectedIndex].value})}))}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,o=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${s}`);for(const[e,i]of Object.entries(r))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!o||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}o&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});const o="richText"!==n,h=t.div;if(h.append(r),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=e}o&&h.setAttribute("class","xfaLayer xfaFont");const a=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);r.append(t),o&&yi.shouldBuildText(s.name)&&a.push(t)}return{textDivs:a}}const c=[[s,-1,r]];for(;c.length>0;){const[t,s,r]=c.at(-1);if(s+1===t.children.length){c.pop();continue}const h=t.children[++c.at(-1)[1]];if(null===h)continue;const{name:l}=h;if("#text"===l){const t=document.createTextNode(h.value);a.push(t),r.append(t);continue}const u=h?.attributes?.xmlns?document.createElementNS(h.attributes.xmlns,l):document.createElement(l);if(r.append(u),h.attributes&&this.setAttributes({html:u,element:h,storage:e,intent:n,linkService:i}),h.children?.length>0)c.push([h,-1,u]);else if(h.value){const t=document.createTextNode(h.value);o&&yi.shouldBuildText(l)&&a.push(t),u.append(t)}}for(const t of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:a}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Bi=1e3,Ui=new WeakSet;class ji{static create(t){switch(t.data.annotationType){case S.LINK:return new Hi(t);case S.TEXT:return new Gi(t);case S.WIDGET:switch(t.data.fieldType){case"Tx":return new Vi(t);case"Btn":return t.data.radioButton?new qi(t):t.data.checkBox?new Yi(t):new Qi(t);case"Ch":return new Ki(t);case"Sig":return new Xi(t)}return new Wi(t);case S.POPUP:return new Ji(t);case S.FREETEXT:return new ts(t);case S.LINE:return new es(t);case S.SQUARE:return new is(t);case S.CIRCLE:return new ss(t);case S.POLYLINE:return new ns(t);case S.CARET:return new os(t);case S.INK:return new hs(t);case S.POLYGON:return new rs(t);case S.HIGHLIGHT:return new as(t);case S.UNDERLINE:return new cs(t);case S.SQUIGGLY:return new ls(t);case S.STRIKEOUT:return new us(t);case S.STAMP:return new ds(t);case S.FILEATTACHMENT:return new fs(t);default:return new zi(t)}}}class zi{#Qs=null;#Ks=!1;#Js=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!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.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return zi._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#Qs||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#Zs(e),this.#Js?.popup.updateEdited(t)}resetEdited(){this.#Qs&&(this.#Zs(this.#Qs.rect),this.#Js?.popup.resetEdited(),this.#Qs=null)}#Zs(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:o,pageY:h}}}}=this;i?.splice(0,4,...t),e.left=100*(t[0]-o)/n+"%",e.top=100*(r-t[3]+h)/r+"%",0===s?(e.width=100*(t[2]-t[0])/n+"%",e.height=100*(t[3]-t[1])/r+"%"):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Wi||(n.tabIndex=Bi);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Ji){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:o,height:h}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;switch(t>0||i>0?r.borderRadius=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`:this instanceof qi&&(r.borderRadius=`calc(${o}px * var(--total-scale-factor)) / calc(${h}px * var(--total-scale-factor))`),e.borderStyle.style){case 1:r.borderStyle="solid";break;case 2:r.borderStyle="dashed";break;case 3:I("Unimplemented border style: beveled");break;case 4:I("Unimplemented border style: inset");break;case 5:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Ks=!0,r.borderColor=Q.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}const a=Q.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:c,pageHeight:l,pageX:u,pageY:d}=s.rawDims;r.left=100*(a[0]-u)/c+"%",r.top=100*(a[1]-d)/l+"%";const{rotation:f}=e;return e.hasOwnCanvas||0===f?(r.width=100*o/c+"%",r.height=100*h/l+"%"):this.setRotation(f,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims;let{width:n,height:r}=this;t%180!=0&&([n,r]=[r,n]),e.style.width=100*n/i+"%",e.style.height=100*r/s+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=Fi[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:Fi[`${n}_rgb`](r)})};return L(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];r&&(r({detail:{[s]:n},target:t}),delete e[s])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[r,o,h,a]=t.subarray(2,6);if(s===r&&n===o&&e===h&&i===a)return}const{style:r}=this.container;let o;if(this.#Ks){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const h=s-e,a=n-i,{svgFactory:c}=this,l=c.createElement("svg");l.classList.add("quadrilateralsContainer"),l.setAttribute("width",0),l.setAttribute("height",0);const u=c.createElement("defs");l.append(u);const d=c.createElement("clipPath"),f=`clippath_${this.data.id}`;d.setAttribute("id",f),d.setAttribute("clipPathUnits","objectBoundingBox"),u.append(d);for(let i=2,s=t.length;i<s;i+=8){const s=t[i],r=t[i+1],l=t[i+2],u=t[i+3],f=c.createElement("rect"),p=(l-e)/h,g=(n-r)/a,m=(s-l)/h,w=(r-u)/a;f.setAttribute("x",p),f.setAttribute("y",g),f.setAttribute("width",m),f.setAttribute("height",w),d.append(f),o?.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${g}" width="${m}" height="${w}"/>`)}this.#Ks&&(o.push("</g></svg>')"),r.backgroundImage=o.join("")),this.container.append(l),this.container.style.clipPath=`url(#${f})`}_createPopup(){const{data:t}=this,e=this.#Js=new Ji({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){D("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:r}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof r?r:null,o=document.querySelector(`[data-element-id="${n}"]`);!o||Ui.has(o)?i.push({id:n,exportValue:s,domElement:o}):I(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&Ui.has(s)&&i.push({id:n,exportValue:t,domElement:s})}return i}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})}))}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class Hi extends zi{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,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#tn(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#en(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#in(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#in()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#in()}#tn(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#in()}#en(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#in()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#in()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#in(),!this._fieldObjects)return I('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:s,include:n}=e,r=[];if(0!==t.length||0!==s.length){const e=new Set(s);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===n&&r.push(i)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const o=this.annotationStorage,h=[];for(const t of r){const{id:e}=t;switch(h.push(e),t.type){case"text":case"combobox":case"listbox":o.setValue(e,{value:t.defaultValue||""});break;case"checkbox":case"radiobutton":o.setValue(e,{value:t.defaultValue===t.exportValues});break;default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(Ui.has(i)?i.dispatchEvent(new Event("resetform")):I(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}}class Gi extends zi{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 Wi extends zi{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Y.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(i,(t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,e,i,s){for(const[n,r]of i)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(e||={focused:!1}),this._setEventListener(t,e,n,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":Q.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const{fontColor:e}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,s=t.style;let n;const r=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=Math.round(t/(b*i))||1;n=Math.min(i,r(t/e/b))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);n=Math.min(i,r(t/b))}s.fontSize=`calc(${n}px * var(--total-scale-factor))`,s.color=Q.makeHexColor(e[0],e[1],e[2]),null!==this.data.textAlignment&&(s.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Vi extends Wi{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let o=s.formattedValue||this.data.textContent?.join("\n")||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,""));const h={userValue:n,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=o??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",o??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),Ui.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Bi,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",(s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),h.formattedValue=null})),i.addEventListener("resetform",(()=>{i.value=h.userValue=this.data.defaultFieldValue??"",h.formattedValue=null}));let a=t=>{const{formattedValue:e}=h;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(t=>{if(h.focused)return;const{target:e}=t;h.userValue&&(e.value=h.userValue),h.lastCommittedValue=e.value,h.commitKey=1,this.data.actions?.Focus||(h.focused=!0)})),i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target),this._dispatchEventFromSandbox({value(i){h.userValue=i.detail.value??"",t.setValue(e,{value:h.userValue.toString()}),i.target.value=h.userValue},formattedValue(i){const{formattedValue:s}=i.detail;h.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let r=h.userValue;!r||r.length<=s||(r=r.slice(0,s),n.value=h.userValue=r,t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}},i)})),i.addEventListener("keydown",(t=>{h.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(h.commitKey=3):i=2,-1===i)return;const{value:s}=t.target;h.lastCommittedValue!==s&&(h.lastCommittedValue=s,h.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const s=a;a=null,i.addEventListener("blur",(t=>{if(!h.focused||!t.relatedTarget)return;this.data.actions?.Blur||(h.focused=!1);const{value:i}=t.target;h.userValue=i,h.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:h.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)})),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{h.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:r,selectionEnd:o}=s;let a=r,c=o;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,r).match(/\w*[^\w]*$/);t&&(a-=t[0].length);break}case"deleteWordForward":{const t=n.substring(r).match(/^[^\w]*\w*/);t&&(c+=t[0].length);break}case"deleteContentBackward":r===o&&(a-=1);break;case"deleteContentForward":r===o&&(c+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:a,selEnd:c}})})),this._setEventListeners(i,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(a&&i.addEventListener("blur",a),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Xi extends Wi{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Yi extends Wi{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Ui.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=Bi,n.addEventListener("change",(s=>{const{name:n,checked:r}=s.target;for(const s of this._getElementsByName(n,i)){const i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})})),n.addEventListener("resetform",(t=>{t.target.checked=(e.defaultFieldValue||"Off")===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class qi extends Wi{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});const n=document.createElement("input");if(Ui.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=Bi,n.addEventListener("change",(e=>{const{name:s,checked:n}=e.target;for(const e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue})),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Qi extends Hi{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Ki extends Wi{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Ui.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=Bi;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",(()=>{const t=this.data.defaultFieldValue;for(const e of s.options)e.selected=e.value===t}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let r=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}const o=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let h=o(!1);const a=t=>Array.prototype.map.call(t.target.options,(t=>({displayValue:t.textContent,exportValue:t.value})));return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{this._dispatchEventFromSandbox({value(i){r?.();const n=i.detail.value,a=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=a.has(t.value);t.setValue(e,{value:o(!0)}),h=o(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,r=i.detail.remove;n[r].selected=!1,s.remove(r),n.length>0&&-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0),t.setValue(e,{value:o(!0),items:a(i)}),h=o(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),h=o(!1)},insert(i){const{index:n,displayValue:r,exportValue:c}=i.detail.insert,l=s.children[n],u=document.createElement("option");u.textContent=r,u.value=c,l?l.before(u):s.append(u),t.setValue(e,{value:o(!0),items:a(i)}),h=o(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:o(!0),items:a(i)}),h=o(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:o(!0)}),h=o(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)})),s.addEventListener("input",(i=>{const s=o(!0),n=o(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:h,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):s.addEventListener("input",(function(){t.setValue(e,{value:o(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Ji extends zi{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:zi._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Zi({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,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}),e=[];for(const i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${et}${t}`)).join(",")),this.container}}class Zi{#sn=this.#nn.bind(this);#rn=this.#on.bind(this);#hn=this.#an.bind(this);#cn=this.#ln.bind(this);#un=null;#mt=null;#dn=null;#fn=null;#pn=null;#gn=null;#mn=null;#wn=!1;#An=null;#C=null;#bn=null;#vn=null;#yn=null;#Qs=null;#xn=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:o,parent:h,rect:a,parentRect:c,open:l}){this.#mt=t,this.#yn=s,this.#dn=r,this.#vn=o,this.#gn=h,this.#un=e,this.#bn=a,this.#mn=c,this.#pn=i,this.#fn=wt.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#cn),t.addEventListener("mouseenter",this.#hn),t.addEventListener("mouseleave",this.#rn),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#sn);this.#mt.hidden=!0,l&&this.#ln()}render(){if(this.#An)return;const t=this.#An=document.createElement("div");if(t.className="popup",this.#un){const e=t.style.outlineColor=Q.makeHexColor(...this.#un);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#yn),t.append(e),this.#fn){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#fn.valueOf()})),e.append(t)}const s=this.#Mn;if(s)Li.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#dn);t.append(e)}this.#mt.append(t)}get#Mn(){const t=this.#vn,e=this.#dn;return!t?.str||e?.str&&e.str!==t.str?null:this.#vn.html||null}get#En(){return this.#Mn?.attributes?.style?.fontSize||0}get#Sn(){return this.#Mn?.attributes?.style?.color||null}#kn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#Sn,fontSize:this.#En?`calc(${this.#En}px * var(--total-scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t)i.append(document.createTextNode(s[t])),t<e-1&&i.append(document.createElement("br"));return i}#nn(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#wn)&&this.#ln()}updateEdited({rect:t,popupContent:e}){this.#Qs||={contentsObj:this.#dn,richText:this.#vn},t&&(this.#C=null),e&&(this.#vn=this.#kn(e),this.#dn=null),this.#An?.remove(),this.#An=null}resetEdited(){this.#Qs&&(({contentsObj:this.#dn,richText:this.#vn}=this.#Qs),this.#Qs=null,this.#An?.remove(),this.#An=null,this.#C=null)}#Cn(){if(null!==this.#C)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#gn;let r=!!this.#mn,o=r?this.#mn:this.#bn;for(const t of this.#pn)if(!o||null!==Q.intersect(t.data.rect,o)){o=t.data.rect,r=!0;break}const h=Q.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]);this.#C=[100*(h[0]+(r?o[2]-o[0]+5:0)-s)/e,100*(h[1]-n)/i];const{style:a}=this.#mt;a.left=`${this.#C[0]}%`,a.top=`${this.#C[1]}%`}#ln(){this.#wn=!this.#wn,this.#wn?(this.#an(),this.#mt.addEventListener("click",this.#cn),this.#mt.addEventListener("keydown",this.#sn)):(this.#on(),this.#mt.removeEventListener("click",this.#cn),this.#mt.removeEventListener("keydown",this.#sn))}#an(){this.#An||this.render(),this.isVisible?this.#wn&&this.#mt.classList.add("focused"):(this.#Cn(),this.#mt.hidden=!1,this.#mt.style.zIndex=parseInt(this.#mt.style.zIndex)+1e3)}#on(){this.#mt.classList.remove("focused"),!this.#wn&&this.isVisible&&(this.#mt.hidden=!0,this.#mt.style.zIndex=parseInt(this.#mt.style.zIndex)-1e3)}forceHide(){this.#xn=this.isVisible,this.#xn&&(this.#mt.hidden=!0)}maybeShow(){this.#xn&&(this.#An||this.#an(),this.#xn=!1,this.#mt.hidden=!1)}get isVisible(){return!1===this.#mt.hidden}}class ts extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=y.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 i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class es extends zi{#Tn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=this.#Tn=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Tn}addHighlightArea(){this.container.classList.add("highlightArea")}}class is extends zi{#Pn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#Pn=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Pn}addHighlightArea(){this.container.classList.add("highlightArea")}}class ss extends zi{#_n=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#_n=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#_n}addHighlightArea(){this.container.classList.add("highlightArea")}}class ns extends zi{#Rn=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:i,popupRef:s},width:n,height:r}=this;if(!e)return this.container;const o=this.svgFactory.create(n,r,!0);let h=[];for(let i=0,s=e.length;i<s;i+=2)h.push(`${e[i]-t[0]},${t[3]-e[i+1]}`);h=h.join(" ");const a=this.#Rn=this.svgFactory.createElement(this.svgElementName);return a.setAttribute("points",h),a.setAttribute("stroke-width",i.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),o.append(a),this.container.append(o),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Rn}addHighlightArea(){this.container.classList.add("highlightArea")}}class rs extends ns{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class os extends zi{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 hs extends zi{#Nn=null;#In=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?y.HIGHLIGHT:y.INK}#Dn(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:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:o,height:h}=this.#Dn(e,t),a=this.svgFactory.create(o,h,!0),c=this.#Nn=this.svgFactory.createElement("svg:g");a.append(c),c.setAttribute("stroke-width",s.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",r);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#In.push(e),e.setAttribute("points",i[t].join(",")),c.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(a),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#Nn;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#In.length;t<e;t++)this.#In[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#Dn(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#In}addHighlightArea(){this.container.classList.add("highlightArea")}}class as extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=y.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class cs extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class ls extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class us extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class ds extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=y.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 fs extends zi{#Fn=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 i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#On.bind(this)),this.#Fn=i;const{isMac:s}=Y.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#On()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#Fn}addHighlightArea(){this.container.classList.add("highlightArea")}#On(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class ps{#$n=null;#Ln=null;#Bn=new Map;#Un=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:o}){this.div=t,this.#$n=e,this.#Ln=i,this.#Un=o||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#Bn.size>0}async#jn(t,e){const i=t.firstChild||t,s=i.id=`${et}${e}`,n=await(this.#Un?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#$n?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;xt(i,this.viewport);const s=new Map,n={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new $i,annotationStorage:t.annotationStorage||new Ht,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===S.POPUP;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;n.data=t;const i=ji.create(n);if(!i.isRenderable)continue;if(!e&&t.popupRef){const e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}const r=i.render();t.hidden&&(r.style.visibility="hidden"),await this.#jn(r,t.id),i._isEditable&&(this.#Bn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#zn()}async addLinkAnnotations(t,e){const i={data:null,layer:this.div,linkService:e,svgFactory:new $i,parent:this};for(const e of t){e.borderStyle||=ps._defaultBorderStyle,i.data=e;const t=ji.create(i);if(!t.isRenderable)continue;const s=t.render();await this.#jn(s,e.id)}}update({viewport:t}){const e=this.div;this.viewport=t,xt(e,{rotation:t.rotation}),this.#zn(),e.hidden=!1}#zn(){if(!this.#Ln)return;const t=this.div;for(const[e,i]of this.#Ln){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i);const r=this.#Bn.get(e);r&&(r._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),r._hasNoCanvas=!1):r.canvas=i)}this.#Ln.clear()}getEditableAnnotations(){return Array.from(this.#Bn.values())}getEditableAnnotation(t){return this.#Bn.get(t)}static get _defaultBorderStyle(){return L(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:1,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const gs=/\r\n?|\n/g;class ms extends Ot{#un;#Hn="";#Gn=`${this.id}-editor`;#Wn=null;#En;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=ms.prototype,e=t=>t.isEmpty(),i=It.TRANSLATE_SMALL,s=It.TRANSLATE_BIG;return L(this,"_keyboardManager",new Rt([[["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:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=y.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#un=t.color||ms._defaultColor||Ot._defaultLineColor,this.#En=t.fontSize||ms._defaultFontSize}static initialize(t,e){Ot.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case x.FREETEXT_SIZE:ms._defaultFontSize=e;break;case x.FREETEXT_COLOR:ms._defaultColor=e}}updateParams(t,e){switch(t){case x.FREETEXT_SIZE:this.#Vn(e);break;case x.FREETEXT_COLOR:this.#Xn(e)}}static get defaultPropertiesToUpdate(){return[[x.FREETEXT_SIZE,ms._defaultFontSize],[x.FREETEXT_COLOR,ms._defaultColor||Ot._defaultLineColor]]}get propertiesToUpdate(){return[[x.FREETEXT_SIZE,this.#En],[x.FREETEXT_COLOR,this.#un]]}#Vn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#En)*this.parentScale),this.#En=t,this.#Yn()},i=this.#En;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:x.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#Xn(t){const e=t=>{this.#un=this.editorDiv.style.color=t},i=this.#un;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:x.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-ms._internalPadding*t,-(ms._internalPadding+this.#En)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Wn=new AbortController;const t=this._uiManager.combinedSignal(this.#Wn);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.#Gn),this._isDraggable=!0,this.#Wn?.abort(),this.#Wn=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){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()}#qn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(ms.#Qn(i)),e=i);return t.join("\n")}#Yn(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#Hn,e=this.#Hn=this.#qn().trimEnd();if(t===e)return;const i=t=>{this.#Hn=t,t?(this.#Kn(),this._uiManager.rebuild(this),this.#Yn()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#Yn()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){ms._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.#Gn),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#En}px * var(--total-scale-factor))`,i.color=this.#un,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,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[r,o]=this.getInitialTranslation();[r,o]=this.pageTranslationToScreen(r,o);const[h,a]=this.pageDimensions,[c,l]=this.pageTranslation;let u,d;switch(this.rotation){case 0:u=t+(n[0]-c)/h,d=e+this.height-(n[1]-l)/a;break;case 90:u=t+(n[0]-c)/h,d=e-(n[1]-l)/a,[r,o]=[o,-r];break;case 180:u=t-this.width+(n[0]-c)/h,d=e-(n[1]-l)/a,[r,o]=[-r,-o];break;case 270:u=t+(n[0]-c-this.height*a)/h,d=e+(n[1]-l-this.width*h)/a,[r,o]=[-o,r]}this.setAt(u*i,d*s,r,o)}else this._moveAfterPaste(t,e);this.#Kn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Qn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(gs,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=ms.#Jn(e.getData("text")||"").replaceAll(gs,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!s.includes("\n"))return r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:o,startOffset:h}=r,a=[],c=[];if(o.nodeType===Node.TEXT_NODE){const t=o.parentElement;if(c.push(o.nodeValue.slice(h).replaceAll(gs,"")),t!==this.editorDiv){let e=a;for(const i of this.editorDiv.childNodes)i!==t?e.push(ms.#Qn(i)):e=c}a.push(o.nodeValue.slice(0,h).replaceAll(gs,""))}else if(o===this.editorDiv){let t=a,e=0;for(const i of this.editorDiv.childNodes)e++===h&&(t=c),t.push(ms.#Qn(i))}this.#Hn=`${a.join("\n")}${s}${c.join("\n")}`,this.#Kn();const l=new Range;let u=Math.sumPrecise(a.map((t=>t.length)));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(u<=e){l.setStart(t,u),l.setEnd(t,u);break}u-=e}n.removeAllRanges(),n.addRange(l)}#Kn(){if(this.editorDiv.replaceChildren(),this.#Hn)for(const t of this.#Hn.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#Zn(){return this.#Hn.replaceAll(" "," ")}static#Jn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof ts){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:r,id:o,popupRef:h},textContent:a,textPosition:c,parent:{page:{pageNumber:l}}}=t;if(!a||0===a.length)return null;s=t={annotationType:y.FREETEXT,color:Array.from(i),fontSize:e,value:a.join("\n"),position:c,pageIndex:l-1,rect:n.slice(0),rotation:r,id:o,deleted:!1,popupRef:h}}const n=await super.deserialize(t,e,i);return n.#En=t.fontSize,n.#un=Q.makeHexColor(...t.color),n.#Hn=ms.#Jn(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=ms._internalPadding*this.parentScale,i=this.getRect(e,e),s=Ot._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#un),n={annotationType:y.FREETEXT,color:s,fontSize:this.#En,value:this.#Zn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(n.isCopy=!0,n):this.annotationElementId&&!this.#tr(n)?null:(n.id=this.annotationElementId,n)}#tr(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#En}px * var(--total-scale-factor))`,i.color=this.#un,e.replaceChildren();for(const t of this.#Hn.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=ms._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#Hn}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class ws{static PRECISION=1e-4;toSVGPath(){D("Abstract method `toSVGPath` must be implemented.")}get box(){D("Abstract getter `box` must be implemented.")}serialize(t,e){D("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let o=0,h=t.length;o<h;o+=2)r[o]=e+t[o]*s,r[o+1]=i+t[o+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let o=0,h=t.length;o<h;o+=2)r[o]=e+t[o+1]*s,r[o+1]=i+t[o]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class As{#er;#ir=[];#sr;#nr;#rr=[];#or=new Float32Array(18);#hr;#ar;#cr;#lr;#ur;#dr;#fr=[];static#pr=8;static#gr=2;static#mr=As.#pr+As.#gr;constructor({x:t,y:e},i,s,n,r,o=0){this.#er=i,this.#dr=n*s,this.#nr=r,this.#or.set([NaN,NaN,NaN,NaN,t,e],6),this.#sr=o,this.#lr=As.#pr*s,this.#cr=As.#mr*s,this.#ur=s,this.#fr.push(t,e)}isEmpty(){return isNaN(this.#or[8])}#wr(){const t=this.#or.subarray(4,6),e=this.#or.subarray(16,18),[i,s,n,r]=this.#er;return[(this.#hr+(t[0]-e[0])/2-i)/n,(this.#ar+(t[1]-e[1])/2-s)/r,(this.#hr+(e[0]-t[0])/2-i)/n,(this.#ar+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#hr=t,this.#ar=e;const[i,s,n,r]=this.#er;let[o,h,a,c]=this.#or.subarray(8,12);const l=t-a,u=e-c,d=Math.hypot(l,u);if(d<this.#cr)return!1;const f=d-this.#lr,p=f/d,g=p*l,m=p*u;let w=o,A=h;o=a,h=c,a+=g,c+=m,this.#fr?.push(t,e);const b=-m/f*this.#dr,v=g/f*this.#dr;return this.#or.set(this.#or.subarray(2,8),0),this.#or.set([a+b,c+v],4),this.#or.set(this.#or.subarray(14,18),12),this.#or.set([a-b,c-v],16),isNaN(this.#or[6])?(0===this.#rr.length&&(this.#or.set([o+b,h+v],2),this.#rr.push(NaN,NaN,NaN,NaN,(o+b-i)/n,(h+v-s)/r),this.#or.set([o-b,h-v],14),this.#ir.push(NaN,NaN,NaN,NaN,(o-b-i)/n,(h-v-s)/r)),this.#or.set([w,A,o,h,a,c],6),!this.isEmpty()):(this.#or.set([w,A,o,h,a,c],6),Math.abs(Math.atan2(A-h,w-o)-Math.atan2(m,g))<Math.PI/2?([o,h,a,c]=this.#or.subarray(2,6),this.#rr.push(NaN,NaN,NaN,NaN,((o+a)/2-i)/n,((h+c)/2-s)/r),[o,h,w,A]=this.#or.subarray(14,18),this.#ir.push(NaN,NaN,NaN,NaN,((w+o)/2-i)/n,((A+h)/2-s)/r),!0):([w,A,o,h,a,c]=this.#or.subarray(0,6),this.#rr.push(((w+5*o)/6-i)/n,((A+5*h)/6-s)/r,((5*o+a)/6-i)/n,((5*h+c)/6-s)/r,((o+a)/2-i)/n,((h+c)/2-s)/r),[a,c,o,h,w,A]=this.#or.subarray(12,18),this.#ir.push(((w+5*o)/6-i)/n,((A+5*h)/6-s)/r,((5*o+a)/6-i)/n,((5*h+c)/6-s)/r,((o+a)/2-i)/n,((h+c)/2-s)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#rr,e=this.#ir;if(isNaN(this.#or[6])&&!this.isEmpty())return this.#Ar();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#br(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#vr(i),i.join(" ")}#Ar(){const[t,e,i,s]=this.#er,[n,r,o,h]=this.#wr();return`M${(this.#or[2]-t)/i} ${(this.#or[3]-e)/s} L${(this.#or[4]-t)/i} ${(this.#or[5]-e)/s} L${n} ${r} L${o} ${h} L${(this.#or[16]-t)/i} ${(this.#or[17]-e)/s} L${(this.#or[14]-t)/i} ${(this.#or[15]-e)/s} Z`}#vr(t){const e=this.#ir;t.push(`L${e[4]} ${e[5]} Z`)}#br(t){const[e,i,s,n]=this.#er,r=this.#or.subarray(4,6),o=this.#or.subarray(16,18),[h,a,c,l]=this.#wr();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${h} ${a} L${c} ${l} L${(o[0]-e)/s} ${(o[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new bs(t,e,i,s,n,r)}getOutlines(){const t=this.#rr,e=this.#ir,i=this.#or,[s,n,r,o]=this.#er,h=new Float32Array((this.#fr?.length??0)+2);for(let t=0,e=h.length-2;t<e;t+=2)h[t]=(this.#fr[t]-s)/r,h[t+1]=(this.#fr[t+1]-n)/o;if(h[h.length-2]=(this.#hr-s)/r,h[h.length-1]=(this.#ar-n)/o,isNaN(i[6])&&!this.isEmpty())return this.#yr(h);const a=new Float32Array(this.#rr.length+24+this.#ir.length);let c=t.length;for(let e=0;e<c;e+=2)isNaN(t[e])?a[e]=a[e+1]=NaN:(a[e]=t[e],a[e+1]=t[e+1]);c=this.#xr(a,c);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(a[c]=a[c+1]=NaN,c+=2):(a[c]=e[t+i],a[c+1]=e[t+i+1],c+=2);return this.#Mr(a,c),this.newFreeDrawOutline(a,h,this.#er,this.#ur,this.#sr,this.#nr)}#yr(t){const e=this.#or,[i,s,n,r]=this.#er,[o,h,a,c]=this.#wr(),l=new Float32Array(36);return l.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,o,h,NaN,NaN,NaN,NaN,a,c,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(l,t,this.#er,this.#ur,this.#sr,this.#nr)}#Mr(t,e){const i=this.#ir;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#xr(t,e){const i=this.#or.subarray(4,6),s=this.#or.subarray(16,18),[n,r,o,h]=this.#er,[a,c,l,u]=this.#wr();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/o,(i[1]-r)/h,NaN,NaN,NaN,NaN,a,c,NaN,NaN,NaN,NaN,l,u,NaN,NaN,NaN,NaN,(s[0]-n)/o,(s[1]-r)/h],e),e+24}}class bs extends ws{#er;#Er=new Float32Array(4);#sr;#nr;#fr;#ur;#Sr;constructor(t,e,i,s,n,r){super(),this.#Sr=t,this.#fr=e,this.#er=i,this.#ur=s,this.#sr=n,this.#nr=r,this.lastPoint=[NaN,NaN],this.#kr(r);const[o,h,a,c]=this.#Er;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-o)/a,t[e+1]=(t[e+1]-h)/c;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-o)/a,e[t+1]=(e[t+1]-h)/c}toSVGPath(){const t=[`M${this.#Sr[4]} ${this.#Sr[5]}`];for(let e=6,i=this.#Sr.length;e<i;e+=6)isNaN(this.#Sr[e])?t.push(`L${this.#Sr[e+4]} ${this.#Sr[e+5]}`):t.push(`C${this.#Sr[e]} ${this.#Sr[e+1]} ${this.#Sr[e+2]} ${this.#Sr[e+3]} ${this.#Sr[e+4]} ${this.#Sr[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,o=s-e;let h,a;switch(n){case 0:h=ws._rescale(this.#Sr,t,s,r,-o),a=ws._rescale(this.#fr,t,s,r,-o);break;case 90:h=ws._rescaleAndSwap(this.#Sr,t,e,r,o),a=ws._rescaleAndSwap(this.#fr,t,e,r,o);break;case 180:h=ws._rescale(this.#Sr,i,e,-r,o),a=ws._rescale(this.#fr,i,e,-r,o);break;case 270:h=ws._rescaleAndSwap(this.#Sr,i,s,-r,-o),a=ws._rescaleAndSwap(this.#fr,i,s,-r,-o)}return{outline:Array.from(h),points:[Array.from(a)]}}#kr(t){const e=this.#Sr;let i=e[4],s=e[5];const n=[i,s,i,s];let r=i,o=s;const h=t?Math.max:Math.min;for(let t=6,a=e.length;t<a;t+=6){const a=e[t+4],c=e[t+5];if(isNaN(e[t]))Q.pointBoundingBox(a,c,n),o<c?(r=a,o=c):o===c&&(r=h(r,a));else{const a=[1/0,1/0,-1/0,-1/0];Q.bezierBoundingBox(i,s,...e.slice(t,t+6),a),Q.rectBoundingBox(...a,n),o<a[3]?(r=a[2],o=a[3]):o===a[3]&&(r=h(r,a[2]))}i=a,s=c}const a=this.#Er;a[0]=n[0]-this.#sr,a[1]=n[1]-this.#sr,a[2]=n[2]-n[0]+2*this.#sr,a[3]=n[3]-n[1]+2*this.#sr,this.lastPoint=[r,o]}get box(){return this.#Er}newOutliner(t,e,i,s,n,r=0){return new As(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=this.#Er,[o,h,a,c]=this.#er,l=n*a,u=r*c,d=i*a+o,f=s*c+h,p=this.newOutliner({x:this.#fr[0]*l+d,y:this.#fr[1]*u+f},this.#er,this.#ur,t,this.#nr,e??this.#sr);for(let t=2;t<this.#fr.length;t+=2)p.add({x:this.#fr[t]*l+d,y:this.#fr[t+1]*u+f});return p.getOutlines()}}class vs{#er;#Cr;#Tr=[];#Pr=[];constructor(t,e=0,i=0,s=!0){const n=[1/0,1/0,-1/0,-1/0],r=10**-4;for(const{x:i,y:s,width:o,height:h}of t){const t=Math.floor((i-e)/r)*r,a=Math.ceil((i+o+e)/r)*r,c=Math.floor((s-e)/r)*r,l=Math.ceil((s+h+e)/r)*r;this.#Tr.push([t,c,l,!0],[a,c,l,!1]),Q.rectBoundingBox(t,c,a,l,n)}const o=n[2]-n[0]+2*i,h=n[3]-n[1]+2*i,a=n[0]-i,c=n[1]-i,l=this.#Tr.at(s?-1:-2),u=[l[0],l[2]];for(const t of this.#Tr){const[e,i,s]=t;t[0]=(e-a)/o,t[1]=(i-c)/h,t[2]=(s-c)/h}this.#er=new Float32Array([a,c,o,h]),this.#Cr=u}getOutlines(){this.#Tr.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#Tr)e[3]?(t.push(...this.#_r(e)),this.#Rr(e)):(this.#Nr(e),t.push(...this.#_r(e)));return this.#Ir(t)}#Ir(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,s=e.length;t<s;t+=2){const s=e[t][2],n=e[t+1][2];s.push(n),n.push(s),i.add(s),i.add(n)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,r,o,h,a]=t;i.delete(t);let c=e,l=r;for(n=[e,o],s.push(n);;){let t;if(i.has(h))t=h;else{if(!i.has(a))break;t=a}i.delete(t),[e,r,o,h,a]=t,c!==e&&(n.push(c,l,e,l===r?r:o),c=e),l=l===r?o:r}n.push(c,l)}return new ys(s,this.#er,this.#Cr)}#Dr(t){const e=this.#Pr;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#Rr([,t,e]){const i=this.#Dr(t);this.#Pr.splice(i,0,[t,e])}#Nr([,t,e]){const i=this.#Dr(t);for(let s=i;s<this.#Pr.length;s++){const[i,n]=this.#Pr[s];if(i!==t)break;if(i===t&&n===e)return void this.#Pr.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#Pr[s];if(i!==t)break;if(i===t&&n===e)return void this.#Pr.splice(s,1)}}#_r(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#Dr(s);for(let t=0;t<r;t++){const[i,s]=this.#Pr[t];for(let t=0,r=n.length;t<r;t++){const[,o,h]=n[t];if(!(s<=o||h<=i))if(o>=i)if(h>s)n[t][1]=s;else{if(1===r)return[];n.splice(t,1),t--,r--}else n[t][2]=i,h>s&&n.push([e,s,h])}}return n}}class ys extends ws{#er;#Fr;constructor(t,e,i){super(),this.#Fr=t,this.#er=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Fr){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],o=e[n+1];r===i?(t.push(`V${o}`),s=o):o===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],o=i-t,h=s-e;for(const e of this.#Fr){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*o,i[n+1]=s-e[n+1]*h;r.push(i)}return r}get box(){return this.#er}get classNamesForOutlining(){return["highlightOutline"]}}class xs extends As{newFreeDrawOutline(t,e,i,s,n,r){return new Ms(t,e,i,s,n,r)}}class Ms extends bs{newOutliner(t,e,i,s,n,r=0){return new xs(t,e,i,s,n,r)}}class Es{#Or=null;#$r=null;#Lr;#Br=null;#Ur=!1;#jr=!1;#r=null;#zr;#Hr=null;#m=null;#Gr;static#Wr=null;static get _keyboardManager(){return L(this,"_keyboardManager",new Rt([[["Escape","mac+Escape"],Es.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Es.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Es.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Es.prototype._moveToPrevious],[["Home","mac+Home"],Es.prototype._moveToBeginning],[["End","mac+End"],Es.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#jr=!1,this.#Gr=x.HIGHLIGHT_COLOR,this.#r=t):(this.#jr=!0,this.#Gr=x.HIGHLIGHT_DEFAULT_COLOR),this.#m=t?._uiManager||e,this.#zr=this.#m._eventBus,this.#Lr=t?.color||this.#m?.highlightColors.values().next().value||"#FFFF98",Es.#Wr||=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.#Or=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#m._signal;t.addEventListener("click",this.#Vr.bind(this),{signal:e}),t.addEventListener("keydown",this.#nn.bind(this),{signal:e});const i=this.#$r=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Lr,t.append(i),t}renderMainDropdown(){const t=this.#Br=this.#Xr();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Xr(){const t=document.createElement("div"),e=this.#m._signal;t.addEventListener("contextmenu",gt,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[i,s]of this.#m.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",Es.#Wr[i]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.setAttribute("aria-selected",s===this.#Lr),n.addEventListener("click",this.#Yr.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#nn.bind(this),{signal:e}),t}#Yr(t,e){e.stopPropagation(),this.#zr.dispatch("switchannotationeditorparams",{source:this,type:this.#Gr,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Or)return void this.#Vr(t);const e=t.target.getAttribute("data-color");e&&this.#Yr(e,t)}_moveToNext(t){this.#qr?t.target!==this.#Or?t.target.nextSibling?.focus():this.#Br.firstChild?.focus():this.#Vr(t)}_moveToPrevious(t){t.target!==this.#Br?.firstChild&&t.target!==this.#Or?(this.#qr||this.#Vr(t),t.target.previousSibling?.focus()):this.#qr&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#qr?this.#Br.firstChild?.focus():this.#Vr(t)}_moveToEnd(t){this.#qr?this.#Br.lastChild?.focus():this.#Vr(t)}#nn(t){Es._keyboardManager.exec(this,t)}#Vr(t){if(this.#qr)return void this.hideDropdown();if(this.#Ur=0===t.detail,this.#Hr||(this.#Hr=new AbortController,window.addEventListener("pointerdown",this.#l.bind(this),{signal:this.#m.combinedSignal(this.#Hr)})),this.#Br)return void this.#Br.classList.remove("hidden");const e=this.#Br=this.#Xr();this.#Or.append(e)}#l(t){this.#Br?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Br?.classList.add("hidden"),this.#Hr?.abort(),this.#Hr=null}get#qr(){return this.#Br&&!this.#Br.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#jr||(this.#qr?(this.hideDropdown(),this.#Or.focus({preventScroll:!0,focusVisible:this.#Ur})):this.#r?.unselect())}updateColor(t){if(this.#$r&&(this.#$r.style.backgroundColor=t),!this.#Br)return;const e=this.#m.highlightColors.values();for(const i of this.#Br.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Or?.remove(),this.#Or=null,this.#$r=null,this.#Br?.remove(),this.#Br=null}}class Ss extends Ot{#Qr=null;#Kr=0;#Jr;#Zr=null;#n=null;#to=null;#eo=null;#io=0;#so=null;#no=null;#v=null;#ro=!1;#Cr=null;#oo;#ho=null;#ao="";#dr;#co="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=y.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Ss.prototype;return L(this,"_keyboardManager",new Rt([[["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||Ss._defaultColor,this.#dr=t.thickness||Ss._defaultThickness,this.#oo=t.opacity||Ss._defaultOpacity,this.#Jr=t.boxes||null,this.#co=t.methodOfCreation||"",this.#ao=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#ro=!0,this.#lo(t),this.#uo()):this.#Jr&&(this.#Qr=t.anchorNode,this.#Kr=t.anchorOffset,this.#eo=t.focusNode,this.#io=t.focusOffset,this.#do(),this.#uo(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#ro?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#dr,methodOfCreation:this.#co}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#do(){const t=new vs(this.#Jr,.001);this.#no=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#no.box;const e=new vs(this.#Jr,.0025,.001,"ltr"===this._uiManager.direction);this.#to=e.getOutlines();const{lastPoint:i}=this.#to;this.#Cr=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#lo({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#no=t,this.#to=t.getNewOutline(this.#dr/2+1.5,.0025),e>=0)this.#v=e,this.#Zr=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#ho=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#to.box,path:{d:this.#to.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#v,{bbox:Ss.#fo(this.#no.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#ho,{bbox:Ss.#fo(this.#to.box,e),path:{d:this.#to.toSVGPath()}})}const[s,n,r,o]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=r,this.height=o;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=r*e/t,this.height=o*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=r,this.height=o;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=r*e/t,this.height=o*t/e;break}}const{lastPoint:h}=this.#to;this.#Cr=[(h[0]-s)/r,(h[1]-n)/o]}static initialize(t,e){Ot.initialize(t,e),Ss._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case x.HIGHLIGHT_DEFAULT_COLOR:Ss._defaultColor=e;break;case x.HIGHLIGHT_THICKNESS:Ss._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#Cr}updateParams(t,e){switch(t){case x.HIGHLIGHT_COLOR:this.#Xn(e);break;case x.HIGHLIGHT_THICKNESS:this.#po(e)}}static get defaultPropertiesToUpdate(){return[[x.HIGHLIGHT_DEFAULT_COLOR,Ss._defaultColor],[x.HIGHLIGHT_THICKNESS,Ss._defaultThickness]]}get propertiesToUpdate(){return[[x.HIGHLIGHT_COLOR,this.color||Ss._defaultColor],[x.HIGHLIGHT_THICKNESS,this.#dr||Ss._defaultThickness],[x.HIGHLIGHT_FREE,this.#ro]]}#Xn(t){const e=(t,e)=>{this.color=t,this.#oo=e,this.parent?.drawLayer.updateProperties(this.#v,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#oo;this.addCommands({cmd:e.bind(this,t,Ss._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:x.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#po(t){const e=this.#dr,i=t=>{this.#dr=t,this.#go(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:x.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#n=new Es({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#mo())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#mo())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#wo(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#uo(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#wo():t&&(this.#uo(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#go(t){if(!this.#ro)return;this.#lo({highlightOutlines:this.#no.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#wo(){null!==this.#v&&this.parent&&(this.parent.drawLayer.remove(this.#v),this.#v=null,this.parent.drawLayer.remove(this.#ho),this.#ho=null)}#uo(t=this.parent){null===this.#v&&(({id:this.#v,clipPathId:this.#Zr}=t.drawLayer.draw({bbox:this.#no.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#oo},rootClass:{highlight:!0,free:this.#ro},path:{d:this.#no.toSVGPath()}},!1,!0)),this.#ho=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#ro},bbox:this.#to.box,path:{d:this.#to.toSVGPath()}},this.#ro),this.#so&&(this.#so.style.clipPath=this.#Zr))}static#fo([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){const{drawLayer:e}=this.parent;let i;i=this.#ro?Ss.#fo(this.#no.box,t=(t-this.rotation+360)%360):Ss.#fo([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#v,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#ho,{bbox:Ss.#fo(this.#to.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#ao&&(t.setAttribute("aria-label",this.#ao),t.setAttribute("role","mark")),this.#ro?t.classList.add("free"):this.div.addEventListener("keydown",this.#Ao.bind(this),{signal:this._uiManager._signal});const e=this.#so=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#Zr;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),Ct(this,this.#so,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ho,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ho,{rootClass:{hovered:!1}})}#Ao(t){Ss._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#bo(!0);break;case 1:case 3:this.#bo(!1)}}#bo(t){if(!this.#Qr)return;const e=window.getSelection();t?e.setPosition(this.#Qr,this.#Kr):e.setPosition(this.#eo,this.#io)}select(){super.select(),this.#ho&&this.parent?.drawLayer.updateProperties(this.#ho,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#ho&&(this.parent?.drawLayer.updateProperties(this.#ho,{rootClass:{selected:!1}}),this.#ro||this.#bo(!1))}get _mustFixPosition(){return!this.#ro}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#v,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#ho,{rootClass:{hidden:!t}}))}#mo(){return this.#ro?this.rotation:0}#vo(){if(this.#ro)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Jr,r=new Float32Array(8*n.length);let o=0;for(const{x:h,y:a,width:c,height:l}of n){const n=h*t+i,u=(1-a)*e+s;r[o]=r[o+4]=n,r[o+1]=r[o+3]=u,r[o+2]=r[o+6]=n+c*t,r[o+5]=r[o+7]=u-l*e,o+=8}return r}#yo(t){return this.#no.serialize(t,this.#mo())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:r,y:o,width:h,height:a}=i.getBoundingClientRect(),c=new AbortController,l=t.combinedSignal(c),u=e=>{c.abort(),this.#xo(t,e)};window.addEventListener("blur",u,{signal:l}),window.addEventListener("pointerup",u,{signal:l}),window.addEventListener("pointerdown",mt,{capture:!0,passive:!1,signal:l}),window.addEventListener("contextmenu",gt,{signal:l}),i.addEventListener("pointermove",this.#Mo.bind(this,t),{signal:l}),this._freeHighlight=new xs({x:s,y:n},[r,o,h,a],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#Mo(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#xo(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,i){let s=null;if(t instanceof as){const{data:{quadPoints:e,rect:i,rotation:n,id:r,color:o,opacity:h,popupRef:a},parent:{page:{pageNumber:c}}}=t;s=t={annotationType:y.HIGHLIGHT,color:Array.from(o),opacity:h,quadPoints:e,boxes:null,pageIndex:c-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:a}}else if(t instanceof hs){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:o,borderStyle:{rawWidth:h},popupRef:a},parent:{page:{pageNumber:c}}}=t;s=t={annotationType:y.HIGHLIGHT,color:Array.from(o),thickness:h,inkLists:e,boxes:null,pageIndex:c-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:a}}const{color:n,quadPoints:r,inkLists:o,opacity:h}=t,a=await super.deserialize(t,e,i);a.color=Q.makeHexColor(...n),a.#oo=h||1,o&&(a.#dr=t.thickness),a.annotationElementId=t.id||null,a._initialData=s;const[c,l]=a.pageDimensions,[u,d]=a.pageTranslation;if(r){const t=a.#Jr=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-u)/c,y:1-(r[e+1]-d)/l,width:(r[e+2]-r[e])/c,height:(r[e+1]-r[e+5])/l});a.#do(),a.#uo(),a.rotate(a.rotation)}else if(o){a.#ro=!0;const t=o[0],i={x:t[0]-u,y:l-(t[1]-d)},s=new xs(i,[0,0,c,l],1,a.#dr/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-u,i.y=l-(t[e+1]-d),s.add(i);const{id:n,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:a.color,"fill-opacity":a._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);a.#lo({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),a.#uo(),a.rotate(a.parentRotation)}return a}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=Ot._colorManager.convert(this.color),s={annotationType:y.HIGHLIGHT,color:i,opacity:this.#oo,thickness:this.#dr,quadPoints:this.#vo(),outlines:this.#yo(e),pageIndex:this.pageIndex,rect:e,rotation:this.#mo(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#tr(s)?null:(s.id=this.annotationElementId,s)}#tr(t){const{color:e}=this._initialData;return t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class ks{#Eo=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#Eo[t]=e}toSVGProperties(){const t=this.#Eo;return this.#Eo=Object.create(null),{root:t}}reset(){this.#Eo=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){D("Not implemented")}}class Cs extends Ot{#So=null;#ko;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#Co=null;static#To=null;static#Po=null;static#_o=NaN;static#Ro=null;static#No=null;static#Io=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#ko=t.mustBeCommitted||!1,this._addOutlines(t)}_addOutlines(t){t.drawOutlines&&(this.#Do(t),this.#uo())}#Do({drawOutlines:t,drawId:e,drawingOptions:i}){this.#So=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Fo(t,this.parent),this.#Oo(t.box)}#Fo(t,e){const{id:i}=e.drawLayer.draw(Cs._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){D("Not implemented")}static get typesMap(){D("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(Cs.#Co.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=t=>{s.updateProperty(e,t);const i=this.#So.updateProperty(e,t);i&&this.#Oo(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,Cs._mergeSVGProperties(this.#So.getPathResizingSVGProperties(this.#$o()),{bbox:this.#Lo()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Cs._mergeSVGProperties(this.#So.getPathResizedSVGProperties(this.#$o()),{bbox:this.#Lo()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Lo()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,Cs._mergeSVGProperties(this.#So.getPathTranslatedSVGProperties(this.#$o(),this.parentDimensions),{bbox:this.#Lo()}))}_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.#ko&&(this.#ko=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#wo(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#uo(),this.#Oo(this.#So.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#wo()):t&&(this._uiManager.addShouldRescale(this),this.#uo(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#wo(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#uo(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Fo(this.#So,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Bo([t,e,i,s]){const{parentDimensions:[n,r],rotation:o}=this;switch(o){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}}#$o(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:o}=this;switch(o){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}}#Oo(t){if([this.x,this.y,this.width,this.height]=this.#Bo(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Lo(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[o,h]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(o/h),s*(h/o),i*(o/h)];case 5:return[1-e,t,i*(o/h),s*(h/o)];case 6:return[1-t-s*(h/o),1-e,s*(h/o),i*(o/h)];case 7:return[e-i*(o/h),1-t-s*(h/o),i*(o/h),s*(h/o)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(h/o),e,s*(h/o),i*(o/h)];case 13:return[1-e-i*(o/h),t-s*(h/o),i*(o/h),s*(h/o)];case 14:return[1-t,1-e-i*(o/h),s*(h/o),i*(o/h)];case 15:return[e,1-t,i*(o/h),s*(h/o)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,Cs._mergeSVGProperties({bbox:this.#Lo()},this.#So.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Oo(this.#So.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 i=super.render();i.classList.add("draw");const s=document.createElement("div");i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,n){D("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:r,offsetY:o,pointerId:h,pointerType:a}=s;if(Cs.#Ro&&Cs.#Ro!==a)return;const{viewport:{rotation:c}}=t,{width:l,height:u}=n.getBoundingClientRect(),d=Cs.#To=new AbortController,f=t.combinedSignal(d);Cs.#_o||=h,Cs.#Ro??=a,window.addEventListener("pointerup",(t=>{Cs.#_o===t.pointerId?this._endDraw(t):Cs.#No?.delete(t.pointerId)}),{signal:f}),window.addEventListener("pointercancel",(t=>{Cs.#_o===t.pointerId?this._currentParent.endDrawingSession():Cs.#No?.delete(t.pointerId)}),{signal:f}),window.addEventListener("pointerdown",(t=>{Cs.#Ro===t.pointerType&&((Cs.#No||=new Set).add(t.pointerId),Cs.#Co.isCancellable()&&(Cs.#Co.removeLastElement(),Cs.#Co.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",gt,{signal:f}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:f}),n.addEventListener("touchmove",(t=>{t.timeStamp===Cs.#Io&&mt(t)}),{signal:f}),t.toggleDrawing(),e._editorUndoBar?.hide(),Cs.#Co?t.drawLayer.updateProperties(this._currentDrawId,Cs.#Co.startNew(r,o,l,u,c)):(e.updateUIForDefaultProperties(this),Cs.#Co=this.createDrawerInstance(r,o,l,u,c),Cs.#Po=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(Cs.#Po.toSVGProperties(),Cs.#Co.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(Cs.#Io=-1,!Cs.#Co)return;const{offsetX:e,offsetY:i,pointerId:s}=t;Cs.#_o===s&&(Cs.#No?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Cs.#Co.add(e,i)),Cs.#Io=t.timeStamp,mt(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,Cs.#Co=null,Cs.#Po=null,Cs.#Ro=null,Cs.#Io=NaN),Cs.#To&&(Cs.#To.abort(),Cs.#To=null,Cs.#_o=NaN,Cs.#No=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,Cs.#Co.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=Cs.#Co,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:x.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(x.DRAW_STEP),!Cs.#Co.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Cs.#Co.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:Cs.#Po,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){D("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:o}}=e.viewport,h=this.deserializeDraw(r,o,s,n,this._INNER_MARGIN,t),a=await super.deserialize(t,e,i);return a.createDrawingOptions(t),a.#Do({drawOutlines:h}),a.#uo(),a.onScaleChanging(),a.rotate(),a}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#So.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Ts{#or=new Float64Array(6);#Tn;#Uo;#rs;#dr;#fr;#jo="";#zo=0;#Fr=new Ps;#Ho;#Go;constructor(t,e,i,s,n,r){this.#Ho=i,this.#Go=s,this.#rs=n,this.#dr=r,[t,e]=this.#Wo(t,e);const o=this.#Tn=[NaN,NaN,NaN,NaN,t,e];this.#fr=[t,e],this.#Uo=[{line:o,points:this.#fr}],this.#or.set(o,0)}updateProperty(t,e){"stroke-width"===t&&(this.#dr=e)}#Wo(t,e){return ws._normalizePoint(t,e,this.#Ho,this.#Go,this.#rs)}isEmpty(){return!this.#Uo||0===this.#Uo.length}isCancellable(){return this.#fr.length<=10}add(t,e){[t,e]=this.#Wo(t,e);const[i,s,n,r]=this.#or.subarray(2,6);return Math.hypot(this.#Ho*(t-n),this.#Go*(e-r))<=2?null:(this.#fr.push(t,e),isNaN(i)?(this.#or.set([n,r,t,e],2),this.#Tn.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#or[0])&&this.#Tn.splice(6,6),this.#or.set([i,s,n,r,t,e],0),this.#Tn.push(...ws.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){return this.add(t,e)||(2===this.#fr.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#Ho=i,this.#Go=s,this.#rs=n,[t,e]=this.#Wo(t,e);const r=this.#Tn=[NaN,NaN,NaN,NaN,t,e];this.#fr=[t,e];const o=this.#Uo.at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),this.#Uo.push({line:r,points:this.#fr}),this.#or.set(r,0),this.#zo=0,this.toSVGPath(),null}getLastElement(){return this.#Uo.at(-1)}setLastElement(t){return this.#Uo?(this.#Uo.push(t),this.#Tn=t.line,this.#fr=t.points,this.#zo=0,{path:{d:this.toSVGPath()}}):this.#Fr.setLastElement(t)}removeLastElement(){if(!this.#Uo)return this.#Fr.removeLastElement();this.#Uo.pop(),this.#jo="";for(let t=0,e=this.#Uo.length;t<e;t++){const{line:e,points:i}=this.#Uo[t];this.#Tn=e,this.#fr=i,this.#zo=0,this.toSVGPath()}return{path:{d:this.#jo}}}toSVGPath(){const t=ws.svgRound(this.#Tn[4]),e=ws.svgRound(this.#Tn[5]);if(2===this.#fr.length)return this.#jo=`${this.#jo} M ${t} ${e} Z`,this.#jo;if(this.#fr.length<=6){const i=this.#jo.lastIndexOf("M");this.#jo=`${this.#jo.slice(0,i)} M ${t} ${e}`,this.#zo=6}if(4===this.#fr.length){const t=ws.svgRound(this.#Tn[10]),e=ws.svgRound(this.#Tn[11]);return this.#jo=`${this.#jo} L ${t} ${e}`,this.#zo=12,this.#jo}const i=[];0===this.#zo&&(i.push(`M ${t} ${e}`),this.#zo=6);for(let t=this.#zo,e=this.#Tn.length;t<e;t+=6){const[e,s,n,r,o,h]=this.#Tn.slice(t,t+6).map(ws.svgRound);i.push(`C${e} ${s} ${n} ${r} ${o} ${h}`)}return this.#jo+=i.join(" "),this.#zo=this.#Tn.length,this.#jo}getOutlines(t,e,i,s){const n=this.#Uo.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Fr.build(this.#Uo,t,e,i,this.#rs,this.#dr,s),this.#or=null,this.#Tn=null,this.#Uo=null,this.#jo=null,this.#Fr}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Ps extends ws{#Er;#Vo=0;#sr;#Uo;#Ho;#Go;#Xo;#rs;#dr;build(t,e,i,s,n,r,o){this.#Ho=e,this.#Go=i,this.#Xo=s,this.#rs=n,this.#dr=r,this.#sr=o??0,this.#Uo=t,this.#Yo()}get thickness(){return this.#dr}setLastElement(t){return this.#Uo.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Uo.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Uo)if(t.push(`M${ws.svgRound(e[4])} ${ws.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${ws.svgRound(e[10])} ${ws.svgRound(e[11])}`);else for(let i=6,s=e.length;i<s;i+=6){const[s,n,r,o,h,a]=e.subarray(i,i+6).map(ws.svgRound);t.push(`C${s} ${n} ${r} ${o} ${h} ${a}`)}else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const r=[],o=[],[h,a,c,l]=this.#qo();let u,d,f,p,g,m,w,A,b;switch(this.#rs){case 0:b=ws._rescale,u=t,d=e+s,f=i,p=-s,g=t+h*i,m=e+(1-a-l)*s,w=t+(h+c)*i,A=e+(1-a)*s;break;case 90:b=ws._rescaleAndSwap,u=t,d=e,f=i,p=s,g=t+a*i,m=e+h*s,w=t+(a+l)*i,A=e+(h+c)*s;break;case 180:b=ws._rescale,u=t+i,d=e,f=-i,p=s,g=t+(1-h-c)*i,m=e+a*s,w=t+(1-h)*i,A=e+(a+l)*s;break;case 270:b=ws._rescaleAndSwap,u=t+i,d=e+s,f=-i,p=-s,g=t+(1-a-l)*i,m=e+(1-h-c)*s,w=t+(1-a)*i,A=e+(1-h)*s}for(const{line:t,points:e}of this.#Uo)r.push(b(t,u,d,f,p,n?new Array(t.length):null)),o.push(b(e,u,d,f,p,n?new Array(e.length):null));return{lines:r,points:o,rect:[g,m,w,A]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:o},rotation:h,thickness:a}){const c=[];let l,u,d,f,p;switch(h){case 0:p=ws._rescale,l=-t/i,u=e/s+1,d=1/i,f=-1/s;break;case 90:p=ws._rescaleAndSwap,l=-e/s,u=-t/i,d=1/s,f=1/i;break;case 180:p=ws._rescale,l=t/i+1,u=-e/s,d=-1/i,f=1/s;break;case 270:p=ws._rescaleAndSwap,l=e/s+1,u=t/i+1,d=-1/s,f=-1/i}if(!r){r=[];for(const t of o){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));r.push(i);let[s,n,o,h]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){const e=t[r],a=t[r+1];i.set(ws.createBezierPoints(s,n,o,h,e,a),3*(r-2)),[s,n,o,h]=[o,h,e,a]}}}for(let t=0,e=r.length;t<e;t++)c.push({line:p(r[t].map((t=>t??NaN)),l,u,d,f),points:p(o[t].map((t=>t??NaN)),l,u,d,f)});const g=new this.prototype.constructor;return g.build(c,i,s,1,h,a,n),g}#Qo(t=this.#dr){const e=this.#sr+t/2*this.#Xo;return this.#rs%180==0?[e/this.#Ho,e/this.#Go]:[e/this.#Go,e/this.#Ho]}#qo(){const[t,e,i,s]=this.#Er,[n,r]=this.#Qo(0);return[t+n,e+r,i-2*n,s-2*r]}#Yo(){const t=this.#Er=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#Uo){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)Q.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let n=6,r=e.length;n<r;n+=6){const[r,o,h,a,c,l]=e.subarray(n,n+6);Q.bezierBoundingBox(i,s,r,o,h,a,c,l,t),i=c,s=l}}const[e,i]=this.#Qo();t[0]=it(t[0]-e,0,1),t[1]=it(t[1]-i,0,1),t[2]=it(t[2]+e,0,1),t[3]=it(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#Er}updateProperty(t,e){return"stroke-width"===t?this.#po(e):null}#po(t){const[e,i]=this.#Qo();this.#dr=t;const[s,n]=this.#Qo(),[r,o]=[s-e,n-i],h=this.#Er;return h[0]-=r,h[1]-=o,h[2]+=2*r,h[3]+=2*o,h}updateParentDimensions([t,e],i){const[s,n]=this.#Qo();this.#Ho=t,this.#Go=e,this.#Xo=i;const[r,o]=this.#Qo(),h=r-s,a=o-n,c=this.#Er;return c[0]-=h,c[1]-=a,c[2]+=2*h,c[3]+=2*a,c}updateRotation(t){return this.#Vo=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#Er.map(ws.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#Er;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ws.svgRound(t)} ${ws.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#Er;let i=0,s=0,n=0,r=0,o=0,h=0;switch(this.#Vo){case 90:s=e/t,n=-t/e,o=t;break;case 180:i=-1,r=-1,o=t,h=e;break;case 270:s=-e/t,n=t/e,h=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${ws.svgRound(o)} ${ws.svgRound(h)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#Qo(),[o,h,a,c]=this.#Er;if(Math.abs(a-n)<=ws.PRECISION||Math.abs(c-r)<=ws.PRECISION){const n=t+i/2-(o+a/2),r=e+s/2-(h+c/2);return{path:{"transform-origin":`${ws.svgRound(t)} ${ws.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const l=(i-2*n)/(a-2*n),u=(s-2*r)/(c-2*r),d=a/i,f=c/s;return{path:{"transform-origin":`${ws.svgRound(o)} ${ws.svgRound(h)}`,transform:`${this.rotationTransform} scale(${d} ${f}) translate(${ws.svgRound(n)} ${ws.svgRound(r)}) scale(${l} ${u}) translate(${ws.svgRound(-n)} ${ws.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#Qo(),o=this.#Er,[h,a,c,l]=o;if(o[0]=t,o[1]=e,o[2]=i,o[3]=s,Math.abs(c-n)<=ws.PRECISION||Math.abs(l-r)<=ws.PRECISION){const n=t+i/2-(h+c/2),r=e+s/2-(a+l/2);for(const{line:t,points:e}of this.#Uo)ws._translate(t,n,r,t),ws._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ws.svgRound(t)} ${ws.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(i-2*n)/(c-2*n),d=(s-2*r)/(l-2*r),f=-u*(h+n)+t+n,p=-d*(a+r)+e+r;if(1!==u||1!==d||0!==f||0!==p)for(const{line:t,points:e}of this.#Uo)ws._rescale(t,f,p,u,d,t),ws._rescale(e,f,p,u,d,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ws.svgRound(t)} ${ws.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#Er,o=t-r[0],h=e-r[1];if(this.#Ho===s&&this.#Go===n)for(const{line:t,points:e}of this.#Uo)ws._translate(t,o,h,t),ws._translate(e,o,h,e);else{const t=this.#Ho/s,e=this.#Go/n;this.#Ho=s,this.#Go=n;for(const{line:i,points:s}of this.#Uo)ws._rescale(i,o,h,t,e,i),ws._rescale(s,o,h,t,e,s);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${ws.svgRound(t)} ${ws.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#Er;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${ws.svgRound(t[0])} ${ws.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class _s extends ks{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:Ot._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new _s(this._viewParameters);return t.updateAll(this),t}}class Rs extends Cs{static _type="ink";static _editorType=y.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){Ot.initialize(t,e),this._defaultDrawingOptions=new _s(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return L(this,"typesMap",new Map([[x.INK_THICKNESS,"stroke-width"],[x.INK_COLOR,"stroke"],[x.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new Ts(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return Ps.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof hs){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:o,opacity:h,borderStyle:{rawWidth:a},popupRef:c},parent:{page:{pageNumber:l}}}=t;s=t={annotationType:y.INK,color:Array.from(o),thickness:a,opacity:h,paths:{points:e},boxes:null,pageIndex:l-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:c}}const n=await super.deserialize(t,e,i);return n.annotationElementId=t.id||null,n._initialData=s,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.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:i}){this._drawingOptions=Rs.getDefaultDrawingOptions({stroke:Q.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":o}}=this,h={annotationType:y.INK,color:Ot._colorManager.convert(n),opacity:r,thickness:o,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(h.isCopy=!0,h):this.annotationElementId&&!this.#tr(h)?null:(h.id=this.annotationElementId,h)}#tr(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class Ns extends Ps{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class Is{static#Ko={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#Jo(t,e,i,s){return s-=e,0==(i-=t)?s>0?0:4:1===i?s+6:2-s}static#Zo=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#th(t,e,i,s,n,r,o){const h=this.#Jo(i,s,n,r);for(let n=0;n<8;n++){const r=(-n+h-o+16)%8;if(0!==t[(i+this.#Zo[2*r])*e+(s+this.#Zo[2*r+1])])return r}return-1}static#eh(t,e,i,s,n,r,o){const h=this.#Jo(i,s,n,r);for(let n=0;n<8;n++){const r=(n+h+o+16)%8;if(0!==t[(i+this.#Zo[2*r])*e+(s+this.#Zo[2*r+1])])return r}return-1}static#ih(t,e,i,s){const n=t.length,r=new Int32Array(n);for(let e=0;e<n;e++)r[e]=t[e]<=s?1:0;for(let t=1;t<i-1;t++)r[t*e]=r[t*e+e-1]=0;for(let t=0;t<e;t++)r[t]=r[e*i-1-t]=0;let o,h=1;const a=[];for(let t=1;t<i-1;t++){o=1;for(let i=1;i<e-1;i++){const s=t*e+i,n=r[s];if(0===n)continue;let c=t,l=i;if(1===n&&0===r[s-1])h+=1,l-=1;else{if(!(n>=1&&0===r[s+1])){1!==n&&(o=Math.abs(n));continue}h+=1,l+=1,n>1&&(o=n)}const u=[i,t],d=l===i+1,f={isHole:d,points:u,id:h,parent:0};let p;a.push(f);for(const t of a)if(t.id===o){p=t;break}f.parent=p?p.isHole?d?p.parent:o:d?o:p.parent:d?o:0;const g=this.#th(r,e,t,i,c,l,0);if(-1===g){r[s]=-h,1!==r[s]&&(o=Math.abs(r[s]));continue}let m=this.#Zo[2*g],w=this.#Zo[2*g+1];const A=t+m,b=i+w;c=A,l=b;let v=t,y=i;for(;;){const n=this.#eh(r,e,v,y,c,l,1);m=this.#Zo[2*n],w=this.#Zo[2*n+1];const a=v+m,d=y+w;u.push(d,a);const f=v*e+y;if(0===r[f+1]?r[f]=-h:1===r[f]&&(r[f]=h),a===t&&d===i&&v===A&&y===b){1!==r[s]&&(o=Math.abs(r[s]));break}c=v,l=y,v=a,y=d}}}return a}static#sh(t,e,i,s){if(i-e<=4){for(let n=e;n<i-2;n+=2)s.push(t[n],t[n+1]);return}const n=t[e],r=t[e+1],o=t[i-4]-n,h=t[i-3]-r,a=Math.hypot(o,h),c=o/a,l=h/a,u=c*r-l*n,d=1/a,f=Math.atan(h/o),p=Math.cos(f),g=Math.sin(f),m=d*(Math.abs(p)+Math.abs(g)),w=d*(1-m+m**2),A=Math.max(Math.atan(Math.abs(g+p)*w),Math.atan(Math.abs(g-p)*w));let b=0,v=e;for(let s=e+2;s<i-2;s+=2){const e=Math.abs(u-c*t[s+1]+l*t[s]);e>b&&(v=s,b=e)}b>(a*A)**2?(this.#sh(t,e,v+2,s),this.#sh(t,v,i,s)):s.push(n,r)}static#nh(t){const e=[],i=t.length;return this.#sh(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#rh(t,e,i,s,n,r){const o=new Float32Array(r**2),h=-2*s**2,a=r>>1;for(let t=0;t<r;t++){const e=(t-a)**2;for(let i=0;i<r;i++)o[t*r+i]=Math.exp((e+(i-a)**2)/h)}const c=new Float32Array(256),l=-2*n**2;for(let t=0;t<256;t++)c[t]=Math.exp(t**2/l);const u=new Uint8Array(t.length),d=new Uint32Array(256);for(let s=0;s<i;s++)for(let n=0;n<e;n++){const h=s*e+n,l=t[h];let f=0,p=0;for(let h=0;h<r;h++){const u=s+h-a;if(!(u<0||u>=i))for(let i=0;i<r;i++){const s=n+i-a;if(s<0||s>=e)continue;const d=t[u*e+s],g=o[h*r+i]*c[Math.abs(d-l)];f+=d*g,p+=g}}d[u[h]=Math.round(f/p)]++}return[u,d]}static#oh(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#hh(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let s=-1/0,n=1/0;for(let e=0,r=i.length;e<r;e++){if(0===t[3+(e<<2)]){s=i[e]=255;continue}const r=i[e]=t[e<<2];r>s&&(s=r),r<n&&(n=r)}const r=255/(s-n);for(let t=0;t<e;t++)i[t]=(i[t]-n)*r;return i}static#ah(t){let e,i=-1/0,s=-1/0;const n=t.findIndex((t=>0!==t));let r=n,o=n;for(e=n;e<256;e++){const n=t[e];n>i&&(e-r>s&&(s=e-r,o=e-1),i=n,r=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#ch(t){const e=t,{width:i,height:s}=t,{maxDim:n}=this.#Ko;let r=i,o=s;if(i>n||s>n){let h=i,a=s,c=Math.log2(Math.max(i,s)/n);const l=Math.floor(c);c=c===l?l-1:l;for(let i=0;i<c;i++){r=Math.ceil(h/2),o=Math.ceil(a/2);const i=new OffscreenCanvas(r,o);i.getContext("2d").drawImage(t,0,0,h,a,0,0,r,o),h=r,a=o,t!==e&&t.close(),t=i.transferToImageBitmap()}const u=Math.min(n/r,n/o);r=Math.round(r*u),o=Math.round(o*u)}const h=new OffscreenCanvas(r,o).getContext("2d",{willReadFrequently:!0});h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,r,o);const a=h.getImageData(0,0,r,o).data;return[this.#hh(a),r,o]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},n,r,o,h){let a=new OffscreenCanvas(1,1),c=a.getContext("2d",{alpha:!1});const l=c.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:u,actualBoundingBoxRight:d,actualBoundingBoxAscent:f,actualBoundingBoxDescent:p,fontBoundingBoxAscent:g,fontBoundingBoxDescent:m,width:w}=c.measureText(t),A=Math.ceil(1.5*Math.max(Math.abs(u)+Math.abs(d)||0,w)),b=Math.ceil(1.5*Math.max(Math.abs(f)+Math.abs(p)||200,Math.abs(g)+Math.abs(m)||200));a=new OffscreenCanvas(A,b),c=a.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=l,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,A,b),c.fillStyle="black",c.fillText(t,.5*A/2,1.5*b/2);const v=this.#hh(c.getImageData(0,0,A,b).data),y=this.#oh(v),x=this.#ah(y),M=this.#ih(v,A,b,x);return this.processDrawnLines({lines:{curves:M,width:A,height:b},pageWidth:n,pageHeight:r,rotation:o,innerMargin:h,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){const[r,o,h]=this.#ch(t),[a,c]=this.#rh(r,o,h,Math.hypot(o,h)*this.#Ko.sigmaSFactor,this.#Ko.sigmaR,this.#Ko.kernelSize),l=this.#ah(c),u=this.#ih(a,o,h,l);return this.processDrawnLines({lines:{curves:u,width:o,height:h},pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:r,areContours:o}){s%180!=0&&([e,i]=[i,e]);const{curves:h,width:a,height:c}=t,l=t.thickness??0,u=[],d=Math.min(e/a,i/c),f=d/e,p=d/i,g=[];for(const{points:t}of h){const e=r?this.#nh(t):t;if(!e)continue;g.push(e);const i=e.length,s=new Float32Array(i),n=new Float32Array(3*(2===i?2:i-2));if(u.push({line:n,points:s}),2===i){s[0]=e[0]*f,s[1]=e[1]*p,n.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[o,h,a,c]=e;o*=f,h*=p,a*=f,c*=p,s.set([o,h,a,c],0),n.set([NaN,NaN,NaN,NaN,o,h],0);for(let t=4;t<i;t+=2){const i=s[t]=e[t]*f,r=s[t+1]=e[t+1]*p;n.set(ws.createBezierPoints(o,h,a,c,i,r),3*(t-2)),[o,h,a,c]=[a,c,i,r]}}if(0===u.length)return null;const m=o?new Ns:new Ps;return m.build(u,e,i,1,s,o?0:l,n),{outline:m,newCurves:g,areContours:o,thickness:l,width:a,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:n}){let r,o=1/0,h=-1/0,a=0;for(const e of t){a+=e.length;for(let t=2,i=e.length;t<i;t++){const i=e[t]-e[t-2];o=Math.min(o,i),h=Math.max(h,i)}}r=o>=-128&&h<=127?Int8Array:o>=-32768&&h<=32767?Int16Array:Int32Array;const c=t.length,l=8+3*c,u=new Uint32Array(l);let d=0;u[d++]=l*Uint32Array.BYTES_PER_ELEMENT+(a-2*c)*r.BYTES_PER_ELEMENT,u[d++]=0,u[d++]=s,u[d++]=n,u[d++]=e?0:1,u[d++]=Math.max(0,Math.floor(i??0)),u[d++]=c,u[d++]=r.BYTES_PER_ELEMENT;for(const e of t)u[d++]=e.length-2,u[d++]=e[0],u[d++]=e[1];const f=new CompressionStream("deflate-raw"),p=f.writable.getWriter();await p.ready,p.write(u);const g=r.prototype.constructor;for(const e of t){const t=new g(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];p.write(t)}p.close();const m=await new Response(f.readable).arrayBuffer();return st(new Uint8Array(m))}static async decompressSignature(t){try{const i=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):X(atob(e))),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),r=n.getWriter();await r.ready,r.write(i).then((async()=>{await r.ready,await r.close()})).catch((()=>{}));let o=null,h=0;for await(const t of s)o||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),o.set(t,h),h+=t.length;const a=new Uint32Array(o.buffer,0,o.length>>2),c=a[1];if(0!==c)throw new Error(`Invalid version: ${c}`);const l=a[2],u=a[3],d=0===a[4],f=a[5],p=a[6],g=[],m=(8+3*p)*Uint32Array.BYTES_PER_ELEMENT;let w;switch(a[7]){case Int8Array.BYTES_PER_ELEMENT:w=new Int8Array(o.buffer,m);break;case Int16Array.BYTES_PER_ELEMENT:w=new Int16Array(o.buffer,m);break;case Int32Array.BYTES_PER_ELEMENT:w=new Int32Array(o.buffer,m)}h=0;for(let t=0;t<p;t++){const e=a[3*t+8],i=new Float32Array(e+2);g.push(i);for(let e=0;e<2;e++)i[e]=a[3*t+8+e+1];for(let t=0;t<e;t++)i[t+2]=i[t]+w[h++]}return{areContours:d,thickness:f,outlines:g,width:l,height:u}}catch(t){return I(`decompressSignature: ${t}`),null}var e}}class Ds extends ks{constructor(){super(),super.updateProperties({fill:Ot._defaultLineColor,"stroke-width":0})}clone(){const t=new Ds;return t.updateAll(this),t}}class Fs extends _s{constructor(t){super(t),super.updateProperties({stroke:Ot._defaultLineColor,"stroke-width":1})}clone(){const t=new Fs(this._viewParameters);return t.updateAll(this),t}}class Os extends Cs{#lh=!1;#uh=null;#dh=null;#fh=null;static _type="signature";static _editorType=y.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#dh=t.signatureData||null,this.#uh=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){Ot.initialize(t,e),this._defaultDrawingOptions=new Ds,this._defaultDrawnSignatureOptions=new Fs(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return L(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#uh}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#dh){const{lines:t,mustSmooth:e,areContours:i,description:s,uuid:n,heightInPage:r}=this.#dh,{rawDims:{pageWidth:o,pageHeight:h},rotation:a}=this.parent.viewport,c=Is.processDrawnLines({lines:t,pageWidth:o,pageHeight:h,rotation:a,innerMargin:Os._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(c,r,s,n)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#fh=t,this.addEditToolbar()}getUuid(){return this.#fh}get description(){return this.#uh}set description(t){this.#uh=t,super.addEditToolbar().then((e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:s,height:n}=this.#dh,r=Math.max(s,n);return{areContours:e,outline:Is.processDrawnLines({lines:{curves:t.map((t=>({points:t}))),thickness:i,width:s,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.signatureManager&&null!==this.#uh&&(await t.addEditSignatureButton(this._uiManager.signatureManager,this.#fh,this.#uh),t.show()),t):null}addSignature(t,e,i,s){const{x:n,y:r}=this,{outline:o}=this.#dh=t;let h;this.#lh=o instanceof Ns,this.#uh=i,this.div.setAttribute("data-l10n-args",JSON.stringify({description:i})),this.#lh?h=Os.getDefaultDrawingOptions():(h=Os._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":o.thickness})),this._addOutlines({drawOutlines:o,drawingOptions:h});const[a,c]=this.parentDimensions,[,l]=this.pageDimensions;let u=e/l;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(a*this.width,c*this.height),this.x=n,this.y=r,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return Is.process(t,e,i,s,Os._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return Is.extractContoursFromText(t,e,i,s,n,Os._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return Is.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:Os._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=Os.getDefaultDrawingOptions():(this._drawingOptions=Os._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,r={annotationType:y.SIGNATURE,isSignature:!0,areContours:this.#lh,color:[0,0,0],thickness:this.#lh?0:n,pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(r.paths={lines:e,points:i},r.uuid=this.#fh,r.isCopy=!0):r.lines=e,this.#uh&&(r.accessibilityData={type:"Figure",alt:this.#uh}),r}static deserializeDraw(t,e,i,s,n,r){return r.areContours?Ns.deserialize(t,e,i,s,n,r):Ps.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){const s=await super.deserialize(t,e,i);return s.#lh=t.areContours,s.#uh=t.accessibilityData?.alt||"",s.#fh=t.uuid,s}}class $s extends Ot{#ph=null;#gh=null;#mh=null;#wh=null;#Ah=null;#bh="";#vh=null;#yh=!1;#xh=null;#Mh=!1;#Eh=!1;static _type="stamp";static _editorType=y.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#wh=t.bitmapUrl,this.#Ah=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){Ot.initialize(t,e)}static isHandlingMimeForPasting(t){return Et.includes(t)}static paste(t,e){e.pasteEditor({mode:y.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}}#Sh(t,e=!1){t?(this.#ph=t.bitmap,e||(this.#gh=t.id,this.#Mh=t.isSvg),t.file&&(this.#bh=t.file.name),this.#kh()):this.remove()}#Ch(){if(this.#mh=null,this._uiManager.enableWaiting(!1),this.#vh){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#ph)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#ph){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:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,o=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!o)throw new Error("No response from the AI service.");if(o.error)throw new Error("Error from the AI service.");if(o.cancel)return null;if(!o.output)throw new Error("No valid response from the AI service.");const h=o.output;return await this.setGuessedAltText(h),e&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}#Th(){if(this.#gh)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#gh).then((t=>this.#Sh(t,!0))).finally((()=>this.#Ch()));if(this.#wh){const t=this.#wh;return this.#wh=null,this._uiManager.enableWaiting(!0),void(this.#mh=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Sh(t))).finally((()=>this.#Ch())))}if(this.#Ah){const t=this.#Ah;return this.#Ah=null,this._uiManager.enableWaiting(!0),void(this.#mh=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Sh(t))).finally((()=>this.#Ch())))}const t=document.createElement("input");t.type="file",t.accept=Et.join(",");const e=this._uiManager._signal;this.#mh=new Promise((i=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Sh(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Ch())),t.click()}remove(){this.#gh&&(this.#ph=null,this._uiManager.imageManager.deleteId(this.#gh),this.#vh?.remove(),this.#vh=null,this.#xh&&(clearTimeout(this.#xh),this.#xh=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#gh&&null===this.#vh&&this.#Th(),this.isAttachedToDOM||this.parent.add(this))):this.#gh&&this.#Th()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#mh||this.#ph||this.#wh||this.#Ah||this.#gh||this.#yh)}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.addAltTextButton(),this.#yh||(this.#ph?this.#kh():this.#Th()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#gh=i,s&&(this.#ph=s),this.#yh=!1,this.#kh())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#xh&&clearTimeout(this.#xh),this.#xh=setTimeout((()=>{this.#xh=null,this.#Ph()}),200))}#kh(){const{div:t}=this;let{width:e,height:i}=this.#ph;const[s,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>r*s||i>r*n){const t=Math.min(r*s/e,r*n/i);e*=t,i*=t}const[o,h]=this.parentDimensions;this.setDims(e*o/s,i*h/n),this._uiManager.enableWaiting(!1);const a=this.#vh=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#Ph(),this.#Eh||(this.parent.addUndoableEditor(this),this.#Eh=!0),this._reportTelemetry({action:"inserted_image"}),this.#bh&&this.div.setAttribute("aria-description",this.#bh)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#ph,r=new Mt;let o=this.#ph,h=s,a=n,c=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);h=Math.floor(s*t),a=Math.floor(n*t)}c=document.createElement("canvas");const t=c.width=Math.ceil(h*r.sx),i=c.height=Math.ceil(a*r.sy);this.#Mh||(o=this.#_h(t,i));const l=c.getContext("2d");l.filter=this._uiManager.hcmFilter;let u="white",d="#cfcfd8";"none"!==this._uiManager.hcmFilter?d="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(u="#8f8f9d",d="#42414d");const f=15,p=f*r.sx,g=f*r.sy,m=new OffscreenCanvas(2*p,2*g),w=m.getContext("2d");w.fillStyle=u,w.fillRect(0,0,2*p,2*g),w.fillStyle=d,w.fillRect(0,0,p,g),w.fillRect(p,g,p,g),l.fillStyle=l.createPattern(m,"repeat"),l.fillRect(0,0,t,i),l.drawImage(o,0,0,o.width,o.height,0,0,t,i)}let l=null;if(i){let e,i;if(r.symmetric&&o.width<t&&o.height<t)e=o.width,i=o.height;else if(o=this.#ph,s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#Mh||(o=this.#_h(e,i))}const h=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});h.drawImage(o,0,0,o.width,o.height,0,0,e,i),l={width:e,height:i,data:h.getImageData(0,0,e,i).data}}return{canvas:c,width:h,height:a,imageData:l}}#_h(t,e){const{width:i,height:s}=this.#ph;let n=i,r=s,o=this.#ph;for(;n>2*t||r>2*e;){const i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const h=new OffscreenCanvas(n,r);h.getContext("2d").drawImage(o,0,0,i,s,0,0,n,r),o=h.transferToImageBitmap()}return o}#Ph(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Mt,r=Math.ceil(i*t*n.sx),o=Math.ceil(s*e*n.sy),h=this.#vh;if(!h||h.width===r&&h.height===o)return;h.width=r,h.height=o;const a=this.#Mh?this.#ph:this.#_h(r,o),c=h.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(a,0,0,a.width,a.height,0,0,r,o)}#Rh(t){if(t){if(this.#Mh){const t=this._uiManager.imageManager.getSvgUrl(this.#gh);if(t)return t}const t=document.createElement("canvas");return({width:t.width,height:t.height}=this.#ph),t.getContext("2d").drawImage(this.#ph,0,0),t.toDataURL()}if(this.#Mh){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*rt.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*rt.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#ph,0,0,this.#ph.width,this.#ph.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#ph)}static async deserialize(t,e,i){let s=null,n=!1;if(t instanceof ds){const{data:{rect:r,rotation:o,id:h,structParent:a,popupRef:c},container:l,parent:{page:{pageNumber:u}},canvas:d}=t;let f,p;d?(delete t.canvas,({id:f,bitmap:p}=i.imageManager.getFromCanvas(l.id,d)),d.remove()):(n=!0,t._hasNoCanvas=!0);const g=(await e._structTree.getAriaAttributes(`${et}${h}`))?.get("aria-label")||"";s=t={annotationType:y.STAMP,bitmapId:f,bitmap:p,pageIndex:u-1,rect:r.slice(0),rotation:o,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:g},isSvg:!1,structParent:a,popupRef:c}}const r=await super.deserialize(t,e,i),{rect:o,bitmap:h,bitmapUrl:a,bitmapId:c,isSvg:l,accessibilityData:u}=t;n?(i.addMissingCanvas(t.id,r),r.#yh=!0):c&&i.imageManager.isValidId(c)?(r.#gh=c,h&&(r.#ph=h)):r.#wh=a,r.#Mh=l;const[d,f]=r.pageDimensions;return r.width=(o[2]-o[0])/d,r.height=(o[3]-o[1])/f,r.annotationElementId=t.id||null,u&&(r.altTextData=u),r._initialData=s,r.#Eh=!!s,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:y.STAMP,bitmapId:this.#gh,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Mh,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#Rh(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#tr(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const r=this.#Mh?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#gh)){if(this.#Mh){const t=e.stamps.get(this.#gh);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#Rh(!1))}}else e.stamps.set(this.#gh,{area:r,serialized:i}),i.bitmap=this.#Rh(!1);return i}#tr(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}class Ls{#$n;#Nh=!1;#Ih=null;#Dh=null;#Fh=null;#Oh=new Map;#$h=!1;#Lh=!1;#Bh=!1;#Uh=null;#jh=null;#zh=null;#Hh=null;#m;static _initialized=!1;static#z=new Map([ms,Rs,$s,Ss,Os].map((t=>[t._editorType,t])));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:n,annotationLayer:r,drawLayer:o,textLayer:h,viewport:a,l10n:c}){const l=[...Ls.#z.values()];if(!Ls._initialized){Ls._initialized=!0;for(const e of l)e.initialize(c,t)}t.registerEditorTypes(l),this.#m=t,this.pageIndex=e,this.div=i,this.#$n=n,this.#Ih=r,this.viewport=a,this.#zh=h,this.drawLayer=o,this._structTree=s,this.#m.addLayer(this)}get isEmpty(){return 0===this.#Oh.size}get isInvisible(){return this.isEmpty&&this.#m.getMode()===y.NONE}updateToolbar(t){this.#m.updateToolbar(t)}updateMode(t=this.#m.getMode()){switch(this.#Gh(),t){case y.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case y.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case y.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;for(const i of Ls.#z.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#zh?.div}setEditingState(t){this.#m.setEditingState(t)}addCommands(t){this.#m.addCommands(t)}cleanUndoStack(t){this.#m.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#Ih?.div.classList.toggle("disabled",!t)}async enable(){this.#Bh=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#Oh.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#m.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#Ih)return void(this.#Bh=!1);const e=this.#Ih.getEditableAnnotations();for(const i of e){if(i.hide(),this.#m.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#Bh=!1}disable(){this.#Lh=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of this.#Oh.values())i.disableEditing(),i.annotationElementId&&(null===i.serialize()?(e.set(i.annotationElementId,i),this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()):t.set(i.annotationElementId,i));if(this.#Ih){const i=this.#Ih.getEditableAnnotations();for(const s of i){const{id:i}=s.data;if(this.#m.isDeletedAnnotationElement(i))continue;let n=e.get(i);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=t.get(i),n&&(this.#m.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#Gh(),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const t of Ls.#z.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#Lh=!1}getEditableAnnotation(t){return this.#Ih?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#m.getActive()!==t&&this.#m.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#zh?.div&&!this.#Hh){this.#Hh=new AbortController;const t=this.#m.combinedSignal(this.#Hh);this.#zh.div.addEventListener("pointerdown",this.#Wh.bind(this),{signal:t}),this.#zh.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#zh?.div&&this.#Hh&&(this.#Hh.abort(),this.#Hh=null,this.#zh.div.classList.remove("highlighting"))}#Wh(t){this.#m.unselectAll();const{target:e}=t;if(e===this.#zh.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#zh.div.contains(e)){const{isMac:e}=Y.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#m.showAllEditors("highlight",!0,!0),this.#zh.div.classList.add("free"),this.toggleDrawing(),Ss.startHighlighting(this,"ltr"===this.#m.direction,{target:this.#zh.div,x:t.x,y:t.y}),this.#zh.div.addEventListener("pointerup",(()=>{this.#zh.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#m._signal}),t.preventDefault()}}enableClick(){if(this.#Dh)return;this.#Dh=new AbortController;const t=this.#m.combinedSignal(this.#Dh);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.#Dh?.abort(),this.#Dh=null}attach(t){this.#Oh.set(t.id,t);const{annotationElementId:e}=t;e&&this.#m.isDeletedAnnotationElement(e)&&this.#m.removeDeletedAnnotationElement(t)}detach(t){this.#Oh.delete(t.id),this.#$n?.removePointerInTextLayer(t.contentDiv),!this.#Lh&&t.annotationElementId&&this.#m.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#m.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#m.addDeletedAnnotationElement(t.annotationElementId),Ot.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.#m.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#Bh),this.#m.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Fh&&(t._focusEventsAllowed=!1,this.#Fh=setTimeout((()=>{this.#Fh=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#m._signal}),e.focus())}),0)),t._structTreeParentId=this.#$n?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#m.getId()}get#Vh(){return Ls.#z.get(this.#m.getMode())}combinedSignal(t){return this.#m.combinedSignal(t)}#Xh(t){const e=this.#Vh;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#Vh?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#m.updateMode(t.mode);const{offsetX:i,offsetY:s}=this.#Yh(),n=this.getNextId(),r=this.#Xh({parent:this,id:n,x:i,y:s,uiManager:this.#m,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await(Ls.#z.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#m))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#Xh({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#m,isCentered:e,...i});return n&&this.add(n),n}#Yh(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),o=(n+Math.min(window.innerWidth,t+i))/2-t,h=(r+Math.min(window.innerHeight,e+s))/2-e,[a,c]=this.viewport.rotation%180==0?[o,h]:[h,o];return{offsetX:a,offsetY:c}}addNewEditor(t={}){this.createAndAddNewEditor(this.#Yh(),!0,t)}setSelected(t){this.#m.setSelected(t)}toggleSelected(t){this.#m.toggleSelected(t)}unselect(t){this.#m.unselect(t)}pointerup(t){const{isMac:e}=Y.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#$h)return;if(this.#$h=!1,this.#Vh?.isDrawer&&this.#Vh.supportMultipleDrawings)return;if(!this.#Nh)return void(this.#Nh=!0);const i=this.#m.getMode();i!==y.STAMP&&i!==y.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#m.unselectAll()}pointerdown(t){if(this.#m.getMode()===y.HIGHLIGHT&&this.enableTextSelection(),this.#$h)return void(this.#$h=!1);const{isMac:e}=Y.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#$h=!0,this.#Vh?.isDrawer)return void this.startDrawingSession(t);const i=this.#m.getActive();this.#Nh=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#Uh)return void this.#Vh.startDrawing(this,this.#m,!1,t);this.#m.setCurrentDrawingSession(this),this.#Uh=new AbortController;const e=this.#m.combinedSignal(this.#Uh);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#jh=null,this.commitOrRemove())}),{signal:e}),this.#Vh.startDrawing(this,this.#m,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#jh=t)}else this.#jh&&setTimeout((()=>{this.#jh?.focus(),this.#jh=null}),0)}endDrawingSession(t=!1){return this.#Uh?(this.#m.setCurrentDrawingSession(null),this.#Uh.abort(),this.#Uh=null,this.#jh=null,this.#Vh.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#m.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#Uh&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#Uh&&this.#Vh.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#m.getActive()?.parent===this&&(this.#m.commitOrRemove(),this.#m.setActiveEditor(null)),this.#Fh&&(clearTimeout(this.#Fh),this.#Fh=null);for(const t of this.#Oh.values())this.#$n?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#Oh.clear(),this.#m.removeLayer(this)}#Gh(){for(const t of this.#Oh.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,xt(this.div,t);for(const t of this.#m.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#m.commitOrRemove(),this.#Gh();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,xt(this.div,{rotation:i}),e!==i)for(const t of this.#Oh.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#m.viewParameters.realScale}}class Bs{#gn=null;#qh=new Map;#Qh=new Map;static#v=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#gn){if(this.#gn!==t){if(this.#qh.size>0)for(const e of this.#qh.values())e.remove(),t.append(e);this.#gn=t}}else this.#gn=t}static get _svgFactory(){return L(this,"_svgFactory",new $i)}static#Kh(t,[e,i,s,n]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*s+"%",r.height=100*n+"%"}#Jh(){const t=Bs._svgFactory.create(1,1,!0);return this.#gn.append(t),t.setAttribute("aria-hidden",!0),t}#Zh(t,e){const i=Bs._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=Bs._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}#ta(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){const s=Bs.#v++,n=this.#Jh(),r=Bs._svgFactory.createElement("defs");n.append(r);const o=Bs._svgFactory.createElement("path");r.append(o);const h=`path_p${this.pageIndex}_${s}`;o.setAttribute("id",h),o.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#Qh.set(s,o);const a=i?this.#Zh(r,h):null,c=Bs._svgFactory.createElement("use");return n.append(c),c.setAttribute("href",`#${h}`),this.updateProperties(n,t),this.#qh.set(s,n),{id:s,clipPathId:`url(#${a})`}}drawOutline(t,e){const i=Bs.#v++,s=this.#Jh(),n=Bs._svgFactory.createElement("defs");s.append(n);const r=Bs._svgFactory.createElement("path");n.append(r);const o=`path_p${this.pageIndex}_${i}`;let h;if(r.setAttribute("id",o),r.setAttribute("vector-effect","non-scaling-stroke"),e){const t=Bs._svgFactory.createElement("mask");n.append(t),h=`mask_p${this.pageIndex}_${i}`,t.setAttribute("id",h),t.setAttribute("maskUnits","objectBoundingBox");const e=Bs._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");const s=Bs._svgFactory.createElement("use");t.append(s),s.setAttribute("href",`#${o}`),s.setAttribute("stroke","none"),s.setAttribute("fill","black"),s.setAttribute("fill-rule","nonzero"),s.classList.add("mask")}const a=Bs._svgFactory.createElement("use");s.append(a),a.setAttribute("href",`#${o}`),h&&a.setAttribute("mask",`url(#${h})`);const c=a.cloneNode();return s.append(c),a.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(s,t),this.#qh.set(i,s),i}finalizeDraw(t,e){this.#Qh.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:i,bbox:s,rootClass:n,path:r}=e,o="number"==typeof t?this.#qh.get(t):t;if(o){if(i&&this.#ta(o,i),s&&Bs.#Kh(o,s),n){const{classList:t}=o;for(const[e,i]of Object.entries(n))t.toggle(e,i)}r&&this.#ta(o.firstChild.firstChild,r)}}updateParent(t,e){if(e===this)return;const i=this.#qh.get(t);i&&(e.#gn.append(i),this.#qh.delete(t),e.#qh.set(t,i))}remove(t){this.#Qh.delete(t),null!==this.#gn&&(this.#qh.get(t).remove(),this.#qh.delete(t))}destroy(){this.#gn=null;for(const t of this.#qh.values())t.remove();this.#qh.clear(),this.#Qh.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:vs},globalThis.pdfjsLib={AbortException:W,AnnotationEditorLayer:Ls,AnnotationEditorParamsType:x,AnnotationEditorType:y,AnnotationEditorUIManager:It,AnnotationLayer:ps,AnnotationMode:v,AnnotationType:S,build:Ni,ColorPicker:Es,createValidAbsoluteUrl:O,DOMSVGFactory:$i,DrawLayer:Bs,FeatureTest:Y,fetchData:ot,getDocument:xi,getFilenameFromUrl:ut,getPdfFilenameFromUrl:dt,getUuid:tt,getXfaPageViewport:At,GlobalWorkerOptions:We,ImageKind:E,InvalidPDFException:z,isDataScheme:ct,isPdfFile:lt,isValidExplicitDest:qt,MathClamp:it,noContextMenu:gt,normalizeUnicode:Z,OPS:C,OutputScale:Mt,PasswordResponses:T,PDFDataRangeTransport:Ei,PDFDateString:wt,PDFWorker:Ci,PermissionFlag:M,PixelsPerInch:rt,RenderingCancelledException:at,ResponseException:H,setLayerDimensions:xt,shadow:L,SignatureExtractor:Is,stopEvent:mt,SupportedImageMimeTypes:Et,TextLayer:vi,TouchManager:Ft,updateUrlHash:$,Util:Q,VerbosityLevel:k,version:Ri,XfaLayer:Li},window.pdf=Object.freeze({__proto__:null,AbortException:W,AnnotationEditorLayer:Ls,AnnotationEditorParamsType:x,AnnotationEditorType:y,AnnotationEditorUIManager:It,AnnotationLayer:ps,AnnotationMode:v,AnnotationType:S,ColorPicker:Es,DOMSVGFactory:$i,DrawLayer:Bs,FeatureTest:Y,GlobalWorkerOptions:We,ImageKind:E,InvalidPDFException:z,MathClamp:it,OPS:C,OutputScale:Mt,PDFDataRangeTransport:Ei,PDFDateString:wt,PDFWorker:Ci,PasswordResponses:T,PermissionFlag:M,PixelsPerInch:rt,RenderingCancelledException:at,ResponseException:H,SignatureExtractor:Is,SupportedImageMimeTypes:Et,TextLayer:vi,TouchManager:Ft,Util:Q,VerbosityLevel:k,XfaLayer:Li,build:Ni,createValidAbsoluteUrl:O,fetchData:ot,getDocument:xi,getFilenameFromUrl:ut,getPdfFilenameFromUrl:dt,getUuid:tt,getXfaPageViewport:At,isDataScheme:ct,isPdfFile:lt,isValidExplicitDest:qt,noContextMenu:gt,normalizeUnicode:Z,setLayerDimensions:xt,shadow:L,stopEvent:mt,updateUrlHash:$,version:Ri});const Us=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.activate=i(this,"activate",7),this.visiblePagesChange=i(this,"visiblePagesChange",7),this.errorMessage="File could not be loaded.",this.viewMode="single",this.workerSrc="/pdfjs/pdf.worker.min.mjs",this.zoom=1,this.currentPage=null,this.loading=!0,this.renderedPages=[],this.singlePageModePage=1,this.visiblePages=[],this.pages=[],this.renderingPageNumbers=[],this.recentScrollPosition={x:0,y:0},this.storeRecentScrollPosition=()=>{this.recentScrollPosition={x:Math.round(this.scrollContainer?.scrollLeft/this.scrollContainer?.scrollWidth*100)/100,y:Math.round(this.scrollContainer?.scrollTop/this.scrollContainer?.scrollHeight*100)/100}},this.onScroll=h((()=>{this.updateVisiblePages(),this.storeRecentScrollPosition()}),60)}componentWillLoad(){window.pdf.GlobalWorkerOptions.workerSrc=this.workerSrc}async componentDidLoad(){await this.getPages(),await this.updateVisiblePages(),this.activate.emit(this.el)}componentDidRender(){this.updateVisiblePages()}disconnectedCallback(){this.doc?.destroy()}async onWindowResize(){this.visiblePages=[],this.renderedPages=[],await this.updateVisiblePages()}async watchProps(){await this.getPages(),await this.updateVisiblePages()}async watchViewMode(){queueMicrotask((async()=>{this.visiblePages=[],this.renderedPages=[],await this.updateVisiblePages()}))}watchZoom(){queueMicrotask((async()=>{this.restoreScrollPosition(),this.visiblePages=[],this.renderedPages=[],await this.updateVisiblePages()}))}async getThumbnails(){return await Promise.all(this.pages.filter(Boolean).map((t=>{const e=t.getViewport({scale:1}),i=document.createElement("canvas");i.width=e.width,i.height=e.height;const s=Math.min(i.width/e.width,i.height/e.height);return t.render({canvasContext:i.getContext("2d"),viewport:t.getViewport({scale:s})}).promise.then((function(){return i}))})))}async print(){this.loading=!0,await this.updateVisiblePages(!0),await this.openPrintDialog(),this.loading=!1}async nextPage(){await this.setPage(this.singlePageModePage+1),await this.updateVisiblePages()}async previousPage(){await this.setPage(this.singlePageModePage-1),await this.updateVisiblePages()}async setPage(t){this.singlePageModePage=Math.min(Math.max(t,1),this.pages.length-1),await this.updateVisiblePages()}async getPages(){this.error=!1,this.loading=!0;try{Boolean(this.doc)&&this.doc.destroy(),this.doc=await xi({isEvalSupported:!1,url:this.file}).promise;const t=[];for(let e=1;e<=this.doc.numPages;e++)t.push(this.doc.getPage(e));this.pages=await Promise.all(t),this.loading=!1}catch(t){this.error=!0,this.loading=!1}}async renderVisiblePages(t){const e=Array.from(this.el.shadowRoot.querySelectorAll("canvas")),i=[];for(const s of e){const e=s.closest(".file-viewer-pdf__page"),n=this.pages.find((t=>t?.pageNumber===+e?.dataset.pageNumber));Boolean(n)&&!this.renderingPageNumbers.includes(n.pageNumber)&&(this.visiblePages.includes(n.pageNumber)||t?!this.renderedPages.includes(n.pageNumber)||t?(await this.renderPage(n,s,t),i.push(n.pageNumber)):i.push(n.pageNumber):this.destroyPage(n))}this.renderedPages=i}async renderPage(t,e,i){const s=e.closest(".file-viewer-pdf__page"),n=s?.querySelector(".file-viewer-pdf__text-container"),r=s?.querySelector(".file-viewer-pdf__annotation-container");this.renderingPageNumbers=[...this.renderingPageNumbers,t.pageNumber];const o=i?this.getPrintScale(t):this.getScale(t),h=Math.max(window.devicePixelRatio||2,2),a=[h,0,0,h,0,0],c=t.getViewport({scale:o}),l=e.getContext("2d");e.height=Math.floor(c.height*h),e.width=Math.floor(c.width*h);const u={canvasContext:l,transform:a,viewport:c};try{await t.render(u).promise,t.cleanup(),n.innerHTML="",r.innerHTML="",this.renderTextLayer(t,n).catch(),this.renderAnnotationLayer(t,r).catch(),this.renderingPageNumbers=this.renderingPageNumbers.filter((e=>e!==t.pageNumber))}catch(t){}}destroyPage(t){const e=this.el.shadowRoot.querySelector(`[data-page-number="${t.pageNumber}"]`),i=e.querySelector("canvas"),s=e.querySelector(".file-viewer-pdf__text-container"),n=e.querySelector(".file-viewer-pdf__annotation-container");i.width=1,i.height=1,i.getContext("2d").clearRect(0,0,i.width,i.height),s.innerHTML="",n.innerHTML=""}async updateVisiblePages(t){const e=Array.from(this.el.shadowRoot.querySelectorAll(".file-viewer-pdf__page"));let i=[],s=null;if(this.singlePageMode)i=[this.singlePageModePage],s=this.singlePageModePage;else if(t)i=e.map((t=>+t.dataset.pageNumber));else{const t=e.map((t=>({pageNumber:+t.dataset.pageNumber,visibleHeight:a(t,this.scrollContainer)}))).filter((({visibleHeight:t})=>t>0));i=t.map((t=>t.pageNumber)),t.length>0&&(s=t.reduce(((t,e)=>e.visibleHeight>t.visibleHeight?e:t),t[0]).pageNumber)}this.visiblePages.length===i.length&&this.visiblePages.every((t=>i.includes(t)))&&this.currentPage===s||(this.visiblePages=i,this.currentPage=s,await this.renderVisiblePages(t),this.visiblePagesChange.emit(this.visiblePages))}async renderTextLayer(t,e){return new vi({container:e,textContentSource:await t.getTextContent(),viewport:t.getViewport({scale:this.getScale(t)})}).render()}async renderAnnotationLayer(t,e){const i=t.getViewport({scale:this.getScale(t)}),s=await t.getAnnotations();if(!s||0===s.length)return;const n=new ps({div:e,page:t,viewport:i,accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,structTreeLayer:null});await n.render({annotations:s,div:e,page:t,viewport:i,linkService:{externalLinkEnabled:!0,pagesCount:this.doc?.numPages??0,page:0,rotation:0,isInPresentationMode:!1,getDestinationHash:()=>"#",getAnchorUrl:()=>"#",setHash:()=>{},executeNamedAction:()=>{},executeSetOCGState:()=>{},addLinkAttributes:(t,e)=>{t.href=e,t.rel="noopener noreferrer nofollow",t.target="_blank"},goToDestination:async t=>{const e="string"==typeof t?await this.doc.getDestination(t):t;if(!e)return;const i=await this.doc.getPageIndex(e[0]);this.scrollToPage(i+1)},goToPage:t=>{const e="string"==typeof t?parseInt(t,10):t;this.scrollToPage(e)}},renderForms:!1})}scrollToPage(t){if(this.singlePageMode)return void this.setPage(t);const e=this.el.shadowRoot.querySelector(`[data-page-number="${t}"]`);e?.scrollIntoView({behavior:"smooth"})}async openPrintDialog(){const t=Array.from(this.scrollContainer.querySelectorAll("canvas"));let e=`\n <!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8">\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>${this.file}</title>\n <style>\n *, *:before, *:after {\n margin: 0;\n padding: 0;\n outline: 0;\n }\n\n @page {\n size: a4 !important;\n margin: 0;\n padding: 0;\n }\n\n html, body {\n width: 210mm;\n height: 297mm;\n }\n\n img {\n display: block;\n max-width: 100%;\n max-height: 100%;\n page-break-after: always;\n }\n </style>\n </head>\n <body>\n `;for(const i of t)e+=`<img src="${i.toDataURL()}">`;e+="\n </body>\n </html>\n ";const i=document.createElement("iframe");this.el.append(i);const s=i.contentWindow;s.document.write(e),s.focus(),await new Promise((t=>setTimeout(t,100))),s.print(),i.remove()}getScale(t){const e=c()?0:32;return"auto"===this.zoom?(this.scrollContainer?.clientWidth-e)/t.view[2]:isNaN(this.zoom)?1:this.zoom}getPrintScale(t){return Math.min(Math.min(2480/t.view[2],3508/t.view[3]),2)}restoreScrollPosition(){this.scrollContainer.scrollTop=this.recentScrollPosition.y*this.scrollContainer?.scrollHeight,this.scrollContainer.scrollLeft=this.recentScrollPosition.x*this.scrollContainer?.scrollWidth}render(){const t=!this.error&&!this.loading&&this.visiblePages.length>0,e=this.loading,i=o("file-viewer-pdf",`file-viewer-pdf--view-mode-${this.viewMode}`);return s(n,{key:"c2cb9cff7ac4f4205a4dcfb3b59cf4377833d972",class:i,exportparts:"file-viewer-pdf__pagination"},this.error&&s("swirl-inline-error",{key:"66f9453e61c63ee695e34c5de5fef417bb31741b",class:"file-viewer-pdf__error",message:this.errorMessage}),s("div",{key:"7e1c09b1becfe70ede745e3953ff5495cb8ebd2b","aria-describedby":"pagination",class:"file-viewer-pdf__pages",onScroll:this.onScroll,ref:t=>this.scrollContainer=t},this.pages.map((t=>{const e=t.getViewport({scale:this.getScale(t)}),i=e.height,n=e.width,r=this.renderedPages.includes(t.pageNumber);return s("div",{"aria-label":t.pageNumber,class:"file-viewer-pdf__page","data-page-number":t.pageNumber,hidden:!(!this.singlePageMode||t.pageNumber===this.singlePageModePage)||void 0,id:`page-${t.pageNumber}`,key:t.pageNumber,role:"region",style:{width:`${n}px`,height:`${i}px`},tabIndex:0},!r&&s("swirl-spinner",{class:"file-viewer-pdf__page-spinner"}),s("canvas",{class:"file-viewer-pdf__canvas",style:{opacity:r?"1":"0"}}),s("div",{class:"file-viewer-pdf__text-container"}),s("div",{class:"file-viewer-pdf__annotation-container"}))}))),t&&s("span",{key:"99e4985be05610192738e613b3600a8df82744f9",class:"file-viewer-pdf__pagination",id:"pagination",part:"file-viewer-pdf__pagination"},s("span",{key:"947826c1a6d2e955d4dfbff9ced5e5f6cb0e40cd","aria-current":"page"},this.currentPage)," /"," ",this.doc.numPages),e&&s("div",{key:"417aa0f4011f78486cc8bb0bc214c0c14edf4497",class:"file-viewer-pdf__spinner"},s("swirl-spinner",{key:"6c1f8146da3b48420b8abf30673836acc992fa8d"})))}get el(){return this}static get watchers(){return{file:[{watchProps:0}],viewMode:[{watchViewMode:0}],zoom:[{watchZoom:0}]}}static get style(){return":host{position:relative;display:inline-flex;width:100%;height:100%;pointer-events:auto}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__pages{display:grid;grid-template-columns:repeat(2, 1fr);grid-row-gap:var(--s-space-8);grid-column-gap:var(--s-space-8);grid-auto-rows:auto}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__page{margin:0}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__page:nth-child(odd){justify-self:end}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__page:nth-child(even){justify-self:start}:host *{box-sizing:border-box}.file-viewer-pdf__pages{overflow:auto;width:100%;height:100%}@media (min-width: 768px){.file-viewer-pdf__pages{padding:var(--s-space-16)}}.file-viewer-pdf__page{position:relative;margin-right:auto;margin-left:auto;border-bottom:var(--s-border-width-default) solid var(--s-border-default);background-color:#fff}@media (min-width: 768px){.file-viewer-pdf__page{border:var(--s-border-width-default) solid var(--s-border-default)}.file-viewer-pdf__page:not(:last-of-type){margin-bottom:var(--s-space-8)}}.file-viewer-pdf__page-spinner{position:absolute;top:50%;left:50%;transform:translate3d(-50%, -50%, 0)}.file-viewer-pdf__canvas{display:flex;width:100%;height:100%;margin-right:auto;margin-left:auto}.file-viewer-pdf__text-container{position:absolute;overflow:hidden;line-height:1;text-align:initial;-webkit-user-select:none;-moz-user-select:none;user-select:none;inset:0;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;forced-color-adjust:none}.file-viewer-pdf__text-container>*{position:absolute;color:transparent;white-space:pre;cursor:text;transform-origin:0% 0%}.file-viewer-pdf__text-container>*.markedContent{top:0;height:0}.file-viewer-pdf__text-container>*.highlight{margin:-1px;padding:1px;border-radius:4px;background-color:rgba(180, 0, 170, 1)}.file-viewer-pdf__text-container>*.highlight.appended{position:initial}.file-viewer-pdf__text-container>*.highlight.begin{border-radius:4px 0 0 4px}.file-viewer-pdf__text-container>*.highlight.end{border-radius:0 4px 4px 0}.file-viewer-pdf__text-container>*.highlight.middle{border-radius:0}.file-viewer-pdf__text-container>*.highlight.selected{background-color:rgba(0, 100, 0, 1)}.file-viewer-pdf__text-container>*.endOfContent{position:absolute;z-index:-1;top:100%;right:0;bottom:0;left:0;display:block;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none}.file-viewer-pdf__text-container>*.endOfContent.active{top:0}.file-viewer-pdf__text-container>br::-moz-selection{background:transparent}.file-viewer-pdf__text-container>br::selection{background:transparent}@media (min-width: 768px){.file-viewer-pdf__text-container{-webkit-user-select:auto;-moz-user-select:auto;user-select:auto}}.file-viewer-pdf__annotation-container{position:absolute;overflow:hidden;inset:0;pointer-events:none}.file-viewer-pdf__annotation-container section{position:absolute;pointer-events:auto}.file-viewer-pdf__annotation-container section a{display:block;width:100%;height:100%}.file-viewer-pdf__spinner{position:absolute;display:flex;justify-content:center;align-items:center;background-color:rgba(0, 0, 0, 0.2);inset:0}.file-viewer-pdf__error{position:absolute;top:50%;left:50%;transform:translate3d(-50%, -50%, 0)}.file-viewer-pdf__pagination{position:absolute;bottom:var(--s-space-16);left:50%;padding:var(--s-space-4) var(--s-space-12);border-radius:var(--s-border-radius-base);color:var(--s-text-on-image);background-color:rgba(0, 0, 0, 0.6);font-weight:var(--s-font-weight-medium);line-height:var(--s-line-height-base);transform:translateX(-50%);pointer-events:none}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.file-viewer-pdf__pagination{font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}"}},[1,"swirl-file-viewer-pdf",{errorMessage:[1,"error-message"],file:[1],singlePageMode:[4,"single-page-mode"],viewMode:[1,"view-mode"],workerSrc:[1,"worker-src"],zoom:[8],currentPage:[32],doc:[32],error:[32],loading:[32],renderedPages:[32],singlePageModePage:[32],visiblePages:[32],getThumbnails:[64],print:[64],nextPage:[64],previousPage:[64],setPage:[64]},[[9,"resize","onWindowResize"]],{file:[{watchProps:0}],viewMode:[{watchViewMode:0}],zoom:[{watchZoom:0}]}]);function js(){"undefined"!=typeof customElements&&["swirl-file-viewer-pdf","swirl-icon-error","swirl-inline-error","swirl-spinner","swirl-visually-hidden"].forEach((t=>{switch(t){case"swirl-file-viewer-pdf":customElements.get(r(t))||customElements.define(r(t),Us);break;case"swirl-icon-error":customElements.get(r(t))||l();break;case"swirl-inline-error":customElements.get(r(t))||u();break;case"swirl-spinner":customElements.get(r(t))||d();break;case"swirl-visually-hidden":customElements.get(r(t))||f()}}))}export{Us as S,js as d}
22
+ */var p={34:(t,e,i)=>{var s=i(4901);t.exports=function(t){return"object"==typeof t?null!==t:s(t)}},81:(t,e,i)=>{var s=i(9565),n=i(9306),r=i(8551),o=i(6823),h=i(851),a=TypeError;t.exports=function(t,e){var i=arguments.length<2?h(t):e;if(n(i))return r(s(i,t));throw new a(o(t)+" is not iterable")}},283:(t,e,i)=>{var s=i(9504),n=i(9039),r=i(4901),o=i(9297),h=i(3724),a=i(350).CONFIGURABLE,c=i(3706),l=i(1181),u=l.enforce,d=l.get,f=String,p=Object.defineProperty,g=s("".slice),m=s("".replace),w=s([].join),A=h&&!n((function(){return 8!==p((function(){}),"length",{value:8}).length})),b=String(String).split("String"),v=t.exports=function(t,e,i){"Symbol("===g(f(e),0,7)&&(e="["+m(f(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),i&&i.getter&&(e="get "+e),i&&i.setter&&(e="set "+e),(!o(t,"name")||a&&t.name!==e)&&(h?p(t,"name",{value:e,configurable:!0}):t.name=e),A&&i&&o(i,"arity")&&t.length!==i.arity&&p(t,"length",{value:i.arity});try{i&&o(i,"constructor")&&i.constructor?h&&p(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var s=u(t);return o(s,"source")||(s.source=w(b,"string"==typeof e?e:"")),t};Function.prototype.toString=v((function(){return r(this)&&d(this).source||c(this)}),"toString")},350:(t,e,i)=>{var s=i(3724),n=i(9297),r=Function.prototype,o=s&&Object.getOwnPropertyDescriptor,h=n(r,"name"),a=h&&"something"===function(){}.name,c=h&&(!s||s&&o(r,"name").configurable);t.exports={EXISTS:h,PROPER:a,CONFIGURABLE:c}},397:(t,e,i)=>{var s=i(7751);t.exports=s("document","documentElement")},421:t=>{t.exports={}},507:(t,e,i)=>{var s=i(9565);t.exports=function(t,e,i){for(var n,r,o=i?t:t.iterator,h=t.next;!(n=s(h,o)).done;)if(void 0!==(r=e(n.value)))return r}},531:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(9306),o=i(8551),h=i(1767),a=i(8646),c=i(9462),l=i(9539),u=i(6395),d=i(4549),f=!u&&d("flatMap",TypeError),p=c((function(){for(var t,e,i=this.iterator,s=this.mapper;;){if(e=this.inner)try{if(!(t=o(n(e.next,e.iterator))).done)return t.value;this.inner=null}catch(t){l(i,"throw",t)}if(t=o(n(this.next,i)),this.done=!!t.done)return;try{this.inner=a(s(t.value,this.counter++),!1)}catch(t){l(i,"throw",t)}}}));s({target:"Iterator",proto:!0,real:!0,forced:u||f},{flatMap:function(t){o(this);try{r(t)}catch(t){l(this,"throw",t)}return f?n(f,this,t):new p(h(this),{mapper:t,inner:null})}})},616:(t,e,i)=>{var s=i(9039);t.exports=!s((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},655:(t,e,i)=>{var s=i(6955),n=String;t.exports=function(t){if("Symbol"===s(t))throw new TypeError("Cannot convert a Symbol value to a string");return n(t)}},679:(t,e,i)=>{var s=i(1625),n=TypeError;t.exports=function(t,e){if(s(e,t))return t;throw new n("Incorrect invocation")}},741:t=>{var e=Math.ceil,i=Math.floor;t.exports=Math.trunc||function(t){var s=+t;return(s>0?i:e)(s)}},757:(t,e,i)=>{var s=i(7751),n=i(4901),r=i(1625),o=i(7040),h=Object;t.exports=o?function(t){return"symbol"==typeof t}:function(t){var e=s("Symbol");return n(e)&&r(e.prototype,h(t))}},851:(t,e,i)=>{var s=i(6955),n=i(5966),r=i(4117),o=i(6269),h=i(8227)("iterator");t.exports=function(t){if(!r(t))return n(t,h)||n(t,"@@iterator")||o[s(t)]}},944:t=>{var e=TypeError;t.exports=function(t){var i=t&&t.alphabet;if(void 0===i||"base64"===i||"base64url"===i)return i||"base64";throw new e("Incorrect `alphabet` option")}},1072:(t,e,i)=>{var s=i(1828),n=i(8727);t.exports=Object.keys||function(t){return s(t,n)}},1103:t=>{t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},1148:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(2652),o=i(9306),h=i(8551),a=i(1767),c=i(9539),l=i(4549)("every",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:l},{every:function(t){h(this);try{o(t)}catch(t){c(this,"throw",t)}if(l)return n(l,this,t);var e=a(this),i=0;return!r(e,(function(e,s){if(!t(e,i++))return s()}),{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},1181:(t,e,i)=>{var s,n,r,o=i(8622),h=i(4576),a=i(34),c=i(6699),l=i(9297),u=i(7629),d=i(6119),f=i(421),p="Object already initialized",g=h.TypeError;if(o||u.state){var m=u.state||(u.state=new(0,h.WeakMap));m.get=m.get,m.has=m.has,m.set=m.set,s=function(t,e){if(m.has(t))throw new g(p);return e.facade=t,m.set(t,e),e},n=function(t){return m.get(t)||{}},r=function(t){return m.has(t)}}else{var w=d("state");f[w]=!0,s=function(t,e){if(l(t,w))throw new g(p);return e.facade=t,c(t,w,e),e},n=function(t){return l(t,w)?t[w]:{}},r=function(t){return l(t,w)}}t.exports={set:s,get:n,has:r,enforce:function(t){return r(t)?n(t):s(t,{})},getterFor:function(t){return function(e){var i;if(!a(e)||(i=n(e)).type!==t)throw new g("Incompatible receiver, "+t+" required");return i}}}},1291:(t,e,i)=>{var s=i(741);t.exports=function(t){var e=+t;return e!=e||0===e?0:s(e)}},1548:(t,e,i)=>{var s=i(4576),n=i(9039),r=i(9519),o=i(4215),h=s.structuredClone;t.exports=!!h&&!n((function(){if("DENO"===o&&r>92||"NODE"===o&&r>94||"BROWSER"===o&&r>97)return!1;var t=new ArrayBuffer(8),e=h(t,{transfer:[t]});return 0!==t.byteLength||8!==e.byteLength}))},1549:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(9143),o=i(4154),h=n.Uint8Array,a=!h||!h.prototype.setFromBase64||!function(){var t=new h([255,255,255,255,255]);try{t.setFromBase64("MjYyZg===")}catch(e){return 50===t[0]&&54===t[1]&&50===t[2]&&255===t[3]&&255===t[4]}}();h&&s({target:"Uint8Array",proto:!0,forced:a},{setFromBase64:function(t){o(this);var e=r(t,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:e.read,written:e.written}}})},1625:(t,e,i)=>{var s=i(9504);t.exports=s({}.isPrototypeOf)},1689:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(8745),o=i(7680),h=i(6043),a=i(9306),c=i(1103),l=n.Promise,u=!1;s({target:"Promise",stat:!0,forced:!l||!l.try||c((function(){l.try((function(t){u=8===t}),8)})).error||!u},{try:function(t){var e=arguments.length>1?o(arguments,1):[],i=h.f(this),s=c((function(){return r(a(t),void 0,e)}));return(s.error?i.reject:i.resolve)(s.value),i.promise}})},1698:(t,e,i)=>{var s=i(6518),n=i(4204);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("union")},{union:n})},1701:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(9306),o=i(8551),h=i(1767),a=i(9462),c=i(6319),l=i(9539),u=i(4549),d=i(6395),f=!d&&u("map",TypeError),p=a((function(){var t=this.iterator,e=o(n(this.next,t));if(!(this.done=!!e.done))return c(t,this.mapper,[e.value,this.counter++],!0)}));s({target:"Iterator",proto:!0,real:!0,forced:d||f},{map:function(t){o(this);try{r(t)}catch(t){l(this,"throw",t)}return f?n(f,this,t):new p(h(this),{mapper:t})}})},1767:t=>{t.exports=function(t){return{iterator:t,next:t.next,done:!1}}},1828:(t,e,i)=>{var s=i(9504),n=i(9297),r=i(5397),o=i(9617).indexOf,h=i(421),a=s([].push);t.exports=function(t,e){var i,s=r(t),c=0,l=[];for(i in s)!n(h,i)&&n(s,i)&&a(l,i);for(;e.length>c;)n(s,i=e[c++])&&(~o(l,i)||a(l,i));return l}},2106:(t,e,i)=>{var s=i(283),n=i(4913);t.exports=function(t,e,i){return i.get&&s(i.get,e,{getter:!0}),i.set&&s(i.set,e,{setter:!0}),n.f(t,e,i)}},2140:(t,e,i)=>{var s={};s[i(8227)("toStringTag")]="z",t.exports="[object z]"===String(s)},2195:(t,e,i)=>{var s=i(9504),n=s({}.toString),r=s("".slice);t.exports=function(t){return r(n(t),8,-1)}},2211:(t,e,i)=>{var s=i(9039);t.exports=!s((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}))},2303:(t,e,i)=>{var s=i(4576),n=i(9504),r=s.Uint8Array,o=s.SyntaxError,h=s.parseInt,a=Math.min,c=/[^\da-f]/i,l=n(c.exec),u=n("".slice);t.exports=function(t,e){var i=t.length;if(i%2!=0)throw new o("String should be an even number of characters");for(var s=e?a(e.length,i/2):i/2,n=e||new r(s),d=0,f=0;f<s;){var p=u(t,d,d+=2);if(l(c,p))throw new o("String should only contain hex characters");n[f++]=h(p,16)}return{bytes:n,read:d}}},2360:(t,e,i)=>{var s,n=i(8551),r=i(6801),o=i(8727),h=i(421),a=i(397),c=i(4055),l=i(6119),u="prototype",d="script",f=l("IE_PROTO"),p=function(){},g=function(t){return"<"+d+">"+t+"</"+d+">"},m=function(t){t.write(g("")),t.close();var e=t.parentWindow.Object;return t=null,e},w=function(){try{s=new ActiveXObject("htmlfile")}catch(t){}var t,e,i;w="undefined"!=typeof document?document.domain&&s?m(s):(e=c("iframe"),i="java"+d+":",e.style.display="none",a.appendChild(e),e.src=String(i),(t=e.contentWindow.document).open(),t.write(g("document.F=Object")),t.close(),t.F):m(s);for(var n=o.length;n--;)delete w[u][o[n]];return w()};h[f]=!0,t.exports=Object.create||function(t,e){var i;return null!==t?(p[u]=n(t),i=new p,p[u]=null,i[f]=t):i=w(),void 0===e?i:r.f(i,e)}},2475:(t,e,i)=>{var s=i(6518),n=i(8527);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSupersetOf",(function(t){return!t}))},{isSupersetOf:n})},2489:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(9306),o=i(8551),h=i(1767),a=i(9462),c=i(6319),l=i(6395),u=i(9539),d=i(4549),f=!l&&d("filter",TypeError),p=a((function(){for(var t,e,i=this.iterator,s=this.predicate,r=this.next;;){if(t=o(n(r,i)),this.done=!!t.done)return;if(c(i,s,[e=t.value,this.counter++],!0))return e}}));s({target:"Iterator",proto:!0,real:!0,forced:l||f},{filter:function(t){o(this);try{r(t)}catch(t){u(this,"throw",t)}return f?n(f,this,t):new p(h(this),{predicate:t})}})},2529:t=>{t.exports=function(t,e){return{value:t,done:e}}},2603:(t,e,i)=>{var s=i(655);t.exports=function(t,e){return void 0===t?arguments.length<2?"":e:s(t)}},2652:(t,e,i)=>{var s=i(6080),n=i(9565),r=i(8551),o=i(6823),h=i(4209),a=i(6198),c=i(1625),l=i(81),u=i(851),d=i(9539),f=TypeError,p=function(t,e){this.stopped=t,this.result=e},g=p.prototype;t.exports=function(t,e,i){var m,w,A,b,v,y,x,M=!(!i||!i.AS_ENTRIES),E=!(!i||!i.IS_RECORD),S=!(!i||!i.IS_ITERATOR),k=!(!i||!i.INTERRUPTED),C=s(e,i&&i.that),T=function(t){return m&&d(m,"normal",t),new p(!0,t)},P=function(t){return M?(r(t),k?C(t[0],t[1],T):C(t[0],t[1])):k?C(t,T):C(t)};if(E)m=t.iterator;else if(S)m=t;else{if(!(w=u(t)))throw new f(o(t)+" is not iterable");if(h(w)){for(A=0,b=a(t);b>A;A++)if((v=P(t[A]))&&c(g,v))return v;return new p(!1)}m=l(t,w)}for(y=E?t.next:m.next;!(x=n(y,m)).done;){try{v=P(x.value)}catch(t){d(m,"throw",t)}if("object"==typeof v&&v&&c(g,v))return v}return new p(!1)}},2777:(t,e,i)=>{var s=i(9565),n=i(34),r=i(757),o=i(5966),h=i(4270),a=i(8227),c=TypeError,l=a("toPrimitive");t.exports=function(t,e){if(!n(t)||r(t))return t;var i,a=o(t,l);if(a){if(void 0===e&&(e="default"),i=s(a,t,e),!n(i)||r(i))return i;throw new c("Can't convert object to primitive value")}return void 0===e&&(e="number"),h(t,e)}},2787:(t,e,i)=>{var s=i(9297),n=i(4901),r=i(8981),o=i(6119),h=i(2211),a=o("IE_PROTO"),c=Object,l=c.prototype;t.exports=h?c.getPrototypeOf:function(t){var e=r(t);if(s(e,a))return e[a];var i=e.constructor;return n(i)&&e instanceof i?i.prototype:e instanceof c?l:null}},2796:(t,e,i)=>{var s=i(9039),n=i(4901),r=/#|\.prototype\./,o=function(t,e){var i=a[h(t)];return i===l||i!==c&&(n(e)?s(e):!!e)},h=o.normalize=function(t){return String(t).replace(r,".").toLowerCase()},a=o.data={},c=o.NATIVE="N",l=o.POLYFILL="P";t.exports=o},2804:t=>{var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=e+"+/",s=e+"-_",n=function(t){for(var e={},i=0;i<64;i++)e[t.charAt(i)]=i;return e};t.exports={i2c:i,c2i:n(i),i2cUrl:s,c2iUrl:n(s)}},2812:t=>{var e=TypeError;t.exports=function(t,i){if(t<i)throw new e("Not enough arguments");return t}},2839:(t,e,i)=>{var s=i(4576).navigator,n=s&&s.userAgent;t.exports=n?String(n):""},2967:(t,e,i)=>{var s=i(6706),n=i(34),r=i(7750),o=i(3506);t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,i={};try{(t=s(Object.prototype,"__proto__","set"))(i,[]),e=i instanceof Array}catch(t){}return function(i,s){return r(i),o(s),n(i)?(e?t(i,s):i.__proto__=s,i):i}}():void 0)},3167:(t,e,i)=>{var s=i(4901),n=i(34),r=i(2967);t.exports=function(t,e,i){var o,h;return r&&s(o=e.constructor)&&o!==i&&n(h=o.prototype)&&h!==i.prototype&&r(t,h),t}},3238:(t,e,i)=>{var s=i(4576),n=i(7811),r=i(7394),o=s.DataView;t.exports=function(t){if(!n||0!==r(t))return!1;try{return new o(t),!1}catch(t){return!0}}},3392:(t,e,i)=>{var s=i(9504),n=0,r=Math.random(),o=s(1..toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+o(++n+r,36)}},3440:(t,e,i)=>{var s=i(7080),n=i(4402),r=i(9286),o=i(5170),h=i(3789),a=i(8469),c=i(507),l=n.has,u=n.remove;t.exports=function(t){var e=s(this),i=h(t),n=r(e);return o(e)<=i.size?a(e,(function(t){i.includes(t)&&u(n,t)})):c(i.getIterator(),(function(t){l(e,t)&&u(n,t)})),n}},3463:t=>{var e=TypeError;t.exports=function(t){if("string"==typeof t)return t;throw new e("Argument is not a string")}},3506:(t,e,i)=>{var s=i(3925),n=String,r=TypeError;t.exports=function(t){if(s(t))return t;throw new r("Can't set "+n(t)+" as a prototype")}},3579:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(2652),o=i(9306),h=i(8551),a=i(1767),c=i(9539),l=i(4549)("some",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:l},{some:function(t){h(this);try{o(t)}catch(t){c(this,"throw",t)}if(l)return n(l,this,t);var e=a(this),i=0;return r(e,(function(e,s){if(t(e,i++))return s()}),{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},3650:(t,e,i)=>{var s=i(7080),n=i(4402),r=i(9286),o=i(3789),h=i(507),a=n.add,c=n.has,l=n.remove;t.exports=function(t){var e=s(this),i=o(t).getIterator(),n=r(e);return h(i,(function(t){c(e,t)?l(n,t):a(n,t)})),n}},3706:(t,e,i)=>{var s=i(9504),n=i(4901),r=i(7629),o=s(Function.toString);n(r.inspectSource)||(r.inspectSource=function(t){return o(t)}),t.exports=r.inspectSource},3717:(t,e)=>{e.f=Object.getOwnPropertySymbols},3724:(t,e,i)=>{var s=i(9039);t.exports=!s((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))},3789:(t,e,i)=>{var s=i(9306),n=i(8551),r=i(9565),o=i(1291),h=i(1767),a="Invalid size",c=RangeError,l=TypeError,u=Math.max,d=function(t,e){this.set=t,this.size=u(e,0),this.has=s(t.has),this.keys=s(t.keys)};d.prototype={getIterator:function(){return h(n(r(this.keys,this.set)))},includes:function(t){return r(this.has,this.set,t)}},t.exports=function(t){n(t);var e=+t.size;if(e!=e)throw new l(a);var i=o(e);if(i<0)throw new c(a);return new d(t,i)}},3838:(t,e,i)=>{var s=i(7080),n=i(5170),r=i(8469),o=i(3789);t.exports=function(t){var e=s(this),i=o(t);return!(n(e)>i.size)&&!1!==r(e,(function(t){if(!i.includes(t))return!1}),!0)}},3853:(t,e,i)=>{var s=i(6518),n=i(4449);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isDisjointFrom",(function(t){return!t}))},{isDisjointFrom:n})},3925:(t,e,i)=>{var s=i(34);t.exports=function(t){return s(t)||null===t}},3972:(t,e,i)=>{var s=i(34),n=String,r=TypeError;t.exports=function(t){if(void 0===t||s(t))return t;throw new r(n(t)+" is not an object or undefined")}},4055:(t,e,i)=>{var s=i(4576),n=i(34),r=s.document,o=n(r)&&n(r.createElement);t.exports=function(t){return o?r.createElement(t):{}}},4114:(t,e,i)=>{var s=i(6518),n=i(8981),r=i(6198),o=i(4527),h=i(6837);s({target:"Array",proto:!0,arity:1,forced:i(9039)((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(t){return t instanceof TypeError}}()},{push:function(t){var e=n(this),i=r(e),s=arguments.length;h(i+s);for(var a=0;a<s;a++)e[i]=arguments[a],i++;return o(e,i),i}})},4117:t=>{t.exports=function(t){return null==t}},4149:t=>{var e=RangeError;t.exports=function(t){if(t==t)return t;throw new e("NaN is not allowed")}},4154:(t,e,i)=>{var s=i(6955),n=TypeError;t.exports=function(t){if("Uint8Array"===s(t))return t;throw new n("Argument is not an Uint8Array")}},4204:(t,e,i)=>{var s=i(7080),n=i(4402).add,r=i(9286),o=i(3789),h=i(507);t.exports=function(t){var e=s(this),i=o(t).getIterator(),a=r(e);return h(i,(function(t){n(a,t)})),a}},4209:(t,e,i)=>{var s=i(8227),n=i(6269),r=s("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(n.Array===t||o[r]===t)}},4215:(t,e,i)=>{var s=i(4576),n=i(2839),r=i(2195),o=function(t){return n.slice(0,t.length)===t};t.exports=o("Bun/")?"BUN":o("Cloudflare-Workers")?"CLOUDFLARE":o("Deno/")?"DENO":o("Node.js/")?"NODE":s.Bun&&"string"==typeof Bun.version?"BUN":s.Deno&&"object"==typeof Deno.version?"DENO":"process"===r(s.process)?"NODE":s.window&&s.document?"BROWSER":"REST"},4270:(t,e,i)=>{var s=i(9565),n=i(4901),r=i(34),o=TypeError;t.exports=function(t,e){var i,h;if("string"===e&&n(i=t.toString)&&!r(h=s(i,t)))return h;if(n(i=t.valueOf)&&!r(h=s(i,t)))return h;if("string"!==e&&n(i=t.toString)&&!r(h=s(i,t)))return h;throw new o("Can't convert object to primitive value")}},4376:(t,e,i)=>{var s=i(2195);t.exports=Array.isArray||function(t){return"Array"===s(t)}},4402:(t,e,i)=>{var s=i(9504),n=Set.prototype;t.exports={Set,add:s(n.add),has:s(n.has),remove:s(n.delete),proto:n}},4449:(t,e,i)=>{var s=i(7080),n=i(4402).has,r=i(5170),o=i(3789),h=i(8469),a=i(507),c=i(9539);t.exports=function(t){var e=s(this),i=o(t);if(r(e)<=i.size)return!1!==h(e,(function(t){if(i.includes(t))return!1}),!0);var l=i.getIterator();return!1!==a(l,(function(t){if(n(e,t))return c(l,"normal",!1)}))}},4483:(t,e,i)=>{var s,n,r,o,h=i(4576),a=i(9429),c=i(1548),l=h.structuredClone,u=h.ArrayBuffer,d=h.MessageChannel,f=!1;if(c)f=function(t){l(t,{transfer:[t]})};else if(u)try{d||(s=a("worker_threads"))&&(d=s.MessageChannel),d&&(n=new d,r=new u(2),o=function(t){n.port1.postMessage(null,[t])},2===r.byteLength&&(o(r),0===r.byteLength&&(f=o)))}catch(t){}t.exports=f},4495:(t,e,i)=>{var s=i(9519),n=i(9039),r=i(4576).String;t.exports=!!Object.getOwnPropertySymbols&&!n((function(){var t=Symbol("symbol detection");return!r(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&s&&s<41}))},4527:(t,e,i)=>{var s=i(3724),n=i(4376),r=TypeError,o=Object.getOwnPropertyDescriptor,h=s&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}();t.exports=h?function(t,e){if(n(t)&&!o(t,"length").writable)throw new r("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e}},4549:(t,e,i)=>{var s=i(4576);t.exports=function(t,e){var i=s.Iterator,n=i&&i.prototype,r=n&&n[t],o=!1;if(r)try{r.call({next:function(){return{done:!0}},return:function(){o=!0}},-1)}catch(t){t instanceof e||(o=!1)}if(!o)return r}},4576:function(t){var e=function(t){return t&&t.Math===Math&&t};t.exports=e("object"==typeof globalThis&&globalThis)||e("object"==typeof window&&window)||e("object"==typeof self&&self)||e("object"==typeof global&&global)||e("object"==typeof this&&this)||function(){return this}()||Function("return this")()},4603:(t,e,i)=>{var s=i(6840),n=i(9504),r=i(655),o=i(2812),h=URLSearchParams,a=h.prototype,c=n(a.append),l=n(a.delete),u=n(a.forEach),d=n([].push),f=new h("a=1&a=2&b=3");f.delete("a",1),f.delete("b",void 0),f+""!="a=2"&&s(a,"delete",(function(t){var e=arguments.length,i=e<2?void 0:arguments[1];if(e&&void 0===i)return l(this,t);var s=[];u(this,(function(t,e){d(s,{key:e,value:t})})),o(e,1);for(var n,h=r(t),a=r(i),f=0,p=0,g=!1,m=s.length;f<m;)n=s[f++],g||n.key===h?(g=!0,l(this,n.key)):p++;for(;p<m;)(n=s[p++]).key===h&&n.value===a||c(this,n.key,n.value)}),{enumerable:!0,unsafe:!0})},4628:(t,e,i)=>{var s=i(6518),n=i(6043);s({target:"Promise",stat:!0},{withResolvers:function(){var t=n.f(this);return{promise:t.promise,resolve:t.resolve,reject:t.reject}}})},4659:(t,e,i)=>{var s=i(3724),n=i(4913),r=i(6980);t.exports=function(t,e,i){s?n.f(t,e,r(0,i)):t[e]=i}},4901:t=>{var e="object"==typeof document&&document.all;t.exports=void 0===e&&void 0!==e?function(t){return"function"==typeof t||t===e}:function(t){return"function"==typeof t}},4913:(t,e,i)=>{var s=i(3724),n=i(5917),r=i(8686),o=i(8551),h=i(6969),a=TypeError,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u="enumerable",d="configurable",f="writable";e.f=s?r?function(t,e,i){if(o(t),e=h(e),o(i),"function"==typeof t&&"prototype"===e&&"value"in i&&f in i&&!i[f]){var s=l(t,e);s&&s[f]&&(t[e]=i.value,i={configurable:d in i?i[d]:s[d],enumerable:u in i?i[u]:s[u],writable:!1})}return c(t,e,i)}:c:function(t,e,i){if(o(t),e=h(e),o(i),n)try{return c(t,e,i)}catch(t){}if("get"in i||"set"in i)throw new a("Accessors not supported");return"value"in i&&(t[e]=i.value),t}},4916:(t,e,i)=>{var s=i(7751),n=function(t){return{size:t,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},r=function(t){return{size:t,has:function(){return!0},keys:function(){throw new Error("e")}}};t.exports=function(t,e){var i=s("Set");try{(new i)[t](n(0));try{return(new i)[t](n(-1)),!1}catch(s){if(!e)return!0;try{return(new i)[t](r(-1/0)),!1}catch(s){var o=new i;return o.add(1),o.add(2),e(o[t](r(1/0)))}}}catch(t){return!1}}},4979:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(7751),o=i(6980),h=i(4913).f,a=i(9297),c=i(679),l=i(3167),u=i(2603),d=i(5002),f=i(8574),p=i(3724),g=i(6395),m="DOMException",w=r("Error"),A=r(m),b=function(){c(this,v);var t=arguments.length,e=u(t<1?void 0:arguments[0]),i=u(t<2?void 0:arguments[1],"Error"),s=new A(e,i),n=new w(e);return n.name=m,h(s,"stack",o(1,f(n.stack,1))),l(s,this,b),s},v=b.prototype=A.prototype,y="stack"in new w(m),x="stack"in new A(1,2),M=A&&p&&Object.getOwnPropertyDescriptor(n,m),E=y&&!!(!M||M.writable&&M.configurable)&&!x;s({global:!0,constructor:!0,forced:g||E},{DOMException:E?b:A});var S=r(m),k=S.prototype;if(k.constructor!==S)for(var C in g||h(k,"constructor",o(1,S)),d)if(a(d,C)){var T=d[C],P=T.s;a(S,P)||h(S,P,o(6,T.c))}},5002:t=>{t.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:(t,e,i)=>{var s=i(6518),n=i(3650);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("symmetricDifference")},{symmetricDifference:n})},5031:(t,e,i)=>{var s=i(7751),n=i(9504),r=i(8480),o=i(3717),h=i(8551),a=n([].concat);t.exports=s("Reflect","ownKeys")||function(t){var e=r.f(h(t)),i=o.f;return i?a(e,i(t)):e}},5169:(t,e,i)=>{var s=i(3238),n=TypeError;t.exports=function(t){if(s(t))throw new n("ArrayBuffer is detached");return t}},5170:(t,e,i)=>{var s=i(6706),n=i(4402);t.exports=s(n.proto,"size","get")||function(t){return t.size}},5370:(t,e,i)=>{var s=i(6198);t.exports=function(t,e,i){for(var n=0,r=arguments.length>2?i:s(e),o=new t(r);r>n;)o[n]=e[n++];return o}},5397:(t,e,i)=>{var s=i(7055),n=i(7750);t.exports=function(t){return s(n(t))}},5610:(t,e,i)=>{var s=i(1291),n=Math.max,r=Math.min;t.exports=function(t,e){var i=s(t);return i<0?n(i+e,0):r(i,e)}},5623:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(9504),o=i(4154),h=i(5169),a=r(1..toString);n.Uint8Array&&s({target:"Uint8Array",proto:!0},{toHex:function(){o(this),h(this.buffer);for(var t="",e=0,i=this.length;e<i;e++){var s=a(this[e],16);t+=1===s.length?"0"+s:s}return t}})},5636:(t,e,i)=>{var s=i(4576),n=i(9504),r=i(6706),o=i(7696),h=i(5169),a=i(7394),c=i(4483),l=i(1548),u=s.structuredClone,d=s.ArrayBuffer,f=s.DataView,p=Math.min,g=d.prototype,m=f.prototype,w=n(g.slice),A=r(g,"resizable","get"),b=r(g,"maxByteLength","get"),v=n(m.getInt8),y=n(m.setInt8);t.exports=(l||c)&&function(t,e,i){var s,n=a(t),r=void 0===e?n:o(e),g=!A||!A(t);if(h(t),l&&(t=u(t,{transfer:[t]}),n===r&&(i||g)))return t;if(n>=r&&(!i||g))s=w(t,0,r);else{var m=i&&!g&&b?{maxByteLength:b(t)}:void 0;s=new d(r,m);for(var x=new f(t),M=new f(s),E=p(r,n),S=0;S<E;S++)y(M,S,v(x,S))}return l||c(t),s}},5745:(t,e,i)=>{var s=i(7629);t.exports=function(t,e){return s[t]||(s[t]=e||{})}},5781:(t,e,i)=>{var s=i(6518),n=i(7751),r=i(2812),o=i(655),h=i(7416),a=n("URL");s({target:"URL",stat:!0,forced:!h},{parse:function(t){var e=r(arguments.length,1),i=o(t),s=e<2||void 0===arguments[1]?void 0:o(arguments[1]);try{return new a(i,s)}catch(t){return null}}})},5876:(t,e,i)=>{var s=i(6518),n=i(3838);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSubsetOf",(function(t){return t}))},{isSubsetOf:n})},5917:(t,e,i)=>{var s=i(3724),n=i(9039),r=i(4055);t.exports=!s&&!n((function(){return 7!==Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))},5966:(t,e,i)=>{var s=i(9306),n=i(4117);t.exports=function(t,e){var i=t[e];return n(i)?void 0:s(i)}},6043:(t,e,i)=>{var s=i(9306),n=TypeError,r=function(t){var e,i;this.promise=new t((function(t,s){if(void 0!==e||void 0!==i)throw new n("Bad Promise constructor");e=t,i=s})),this.resolve=s(e),this.reject=s(i)};t.exports.f=function(t){return new r(t)}},6080:(t,e,i)=>{var s=i(7476),n=i(9306),r=i(616),o=s(s.bind);t.exports=function(t,e){return n(t),void 0===e?t:r?o(t,e):function(){return t.apply(e,arguments)}}},6119:(t,e,i)=>{var s=i(5745),n=i(3392),r=s("keys");t.exports=function(t){return r[t]||(r[t]=n(t))}},6193:(t,e,i)=>{var s=i(4215);t.exports="NODE"===s},6198:(t,e,i)=>{var s=i(8014);t.exports=function(t){return s(t.length)}},6269:t=>{t.exports={}},6279:(t,e,i)=>{var s=i(6840);t.exports=function(t,e,i){for(var n in e)s(t,n,e[n],i);return t}},6319:(t,e,i)=>{var s=i(8551),n=i(9539);t.exports=function(t,e,i,r){try{return r?e(s(i)[0],i[1]):e(i)}catch(e){n(t,"throw",e)}}},6395:t=>{t.exports=!1},6518:(t,e,i)=>{var s=i(4576),n=i(7347).f,r=i(6699),o=i(6840),h=i(9433),a=i(7740),c=i(2796);t.exports=function(t,e){var i,l,u,d,f,p=t.target,g=t.global,m=t.stat;if(i=g?s:m?s[p]||h(p,{}):s[p]&&s[p].prototype)for(l in e){if(d=e[l],u=t.dontCallGetSet?(f=n(i,l))&&f.value:i[l],!c(g?l:p+(m?".":"#")+l,t.forced)&&void 0!==u){if(typeof d==typeof u)continue;a(d,u)}(t.sham||u&&u.sham)&&r(d,"sham",!0),o(i,l,d,t)}}},6573:(t,e,i)=>{var s=i(3724),n=i(2106),r=i(3238),o=ArrayBuffer.prototype;s&&!("detached"in o)&&n(o,"detached",{configurable:!0,get:function(){return r(this)}})},6699:(t,e,i)=>{var s=i(3724),n=i(4913),r=i(6980);t.exports=s?function(t,e,i){return n.f(t,e,r(1,i))}:function(t,e,i){return t[e]=i,t}},6706:(t,e,i)=>{var s=i(9504),n=i(9306);t.exports=function(t,e,i){try{return s(n(Object.getOwnPropertyDescriptor(t,e)[i]))}catch(t){}}},6801:(t,e,i)=>{var s=i(3724),n=i(8686),r=i(4913),o=i(8551),h=i(5397),a=i(1072);e.f=s&&!n?Object.defineProperties:function(t,e){o(t);for(var i,s=h(e),n=a(e),c=n.length,l=0;c>l;)r.f(t,i=n[l++],s[i]);return t}},6823:t=>{var e=String;t.exports=function(t){try{return e(t)}catch(t){return"Object"}}},6837:t=>{var e=TypeError;t.exports=function(t){if(t>9007199254740991)throw e("Maximum allowed index exceeded");return t}},6840:(t,e,i)=>{var s=i(4901),n=i(4913),r=i(283),o=i(9433);t.exports=function(t,e,i,h){h||(h={});var a=h.enumerable,c=void 0!==h.name?h.name:e;if(s(i)&&r(i,c,h),h.global)a?t[e]=i:o(e,i);else{try{h.unsafe?t[e]&&(a=!0):delete t[e]}catch(t){}a?t[e]=i:n.f(t,e,{value:i,enumerable:!1,configurable:!h.nonConfigurable,writable:!h.nonWritable})}return t}},6955:(t,e,i)=>{var s=i(2140),n=i(4901),r=i(2195),o=i(8227)("toStringTag"),h=Object,a="Arguments"===r(function(){return arguments}());t.exports=s?r:function(t){var e,i,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=h(t),o))?i:a?r(e):"Object"===(s=r(e))&&n(e.callee)?"Arguments":s}},6969:(t,e,i)=>{var s=i(2777),n=i(757);t.exports=function(t){var e=s(t,"string");return n(e)?e:e+""}},6980:t=>{t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},7040:(t,e,i)=>{var s=i(4495);t.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},7055:(t,e,i)=>{var s=i(9504),n=i(9039),r=i(2195),o=Object,h=s("".split);t.exports=n((function(){return!o("z").propertyIsEnumerable(0)}))?function(t){return"String"===r(t)?h(t,""):o(t)}:o},7080:(t,e,i)=>{var s=i(4402).has;t.exports=function(t){return s(t),t}},7347:(t,e,i)=>{var s=i(3724),n=i(9565),r=i(8773),o=i(6980),h=i(5397),a=i(6969),c=i(9297),l=i(5917),u=Object.getOwnPropertyDescriptor;e.f=s?u:function(t,e){if(t=h(t),e=a(e),l)try{return u(t,e)}catch(t){}if(c(t,e))return o(!n(r.f,t,e),t[e])}},7394:(t,e,i)=>{var s=i(4576),n=i(6706),r=i(2195),o=s.ArrayBuffer,h=s.TypeError;t.exports=o&&n(o.prototype,"byteLength","get")||function(t){if("ArrayBuffer"!==r(t))throw new h("ArrayBuffer expected");return t.byteLength}},7416:(t,e,i)=>{var s=i(9039),n=i(8227),r=i(3724),o=i(6395),h=n("iterator");t.exports=!s((function(){var t=new URL("b?a=1&b=2&c=3","https://a"),e=t.searchParams,i=new URLSearchParams("a=1&a=2&b=3"),s="";return t.pathname="c%20d",e.forEach((function(t,i){e.delete("b"),s+=i+t})),i.delete("a",2),i.delete("b",void 0),o&&(!t.toJSON||!i.has("a",1)||i.has("a",2)||!i.has("a",void 0)||i.has("b"))||!e.size&&(o||!r)||!e.sort||"https://a/c%20d?a=1&c=3"!==t.href||"3"!==e.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!e[h]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==s||"x"!==new URL("https://x",void 0).host}))},7476:(t,e,i)=>{var s=i(2195),n=i(9504);t.exports=function(t){if("Function"===s(t))return n(t)}},7566:(t,e,i)=>{var s=i(6840),n=i(9504),r=i(655),o=i(2812),h=URLSearchParams,a=h.prototype,c=n(a.getAll),l=n(a.has),u=new h("a=1");!u.has("a",2)&&u.has("a",void 0)||s(a,"has",(function(t){var e=arguments.length,i=e<2?void 0:arguments[1];if(e&&void 0===i)return l(this,t);var s=c(this,t);o(e,1);for(var n=r(i),h=0;h<s.length;)if(s[h++]===n)return!0;return!1}),{enumerable:!0,unsafe:!0})},7629:(t,e,i)=>{var s=i(6395),n=i(4576),r=i(9433),o="__core-js_shared__",h=t.exports=n[o]||r(o,{});(h.versions||(h.versions=[])).push({version:"3.42.0",mode:s?"pure":"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.42.0/LICENSE",source:"https://github.com/zloirock/core-js"})},7642:(t,e,i)=>{var s=i(6518),n=i(3440);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("difference",(function(t){return 0===t.size}))},{difference:n})},7657:(t,e,i)=>{var s,n,r,o=i(9039),h=i(4901),a=i(34),c=i(2360),l=i(2787),u=i(6840),d=i(8227),f=i(6395),p=d("iterator"),g=!1;[].keys&&("next"in(r=[].keys())?(n=l(l(r)))!==Object.prototype&&(s=n):g=!0),!a(s)||o((function(){var t={};return s[p].call(t)!==t}))?s={}:f&&(s=c(s)),h(s[p])||u(s,p,(function(){return this})),t.exports={IteratorPrototype:s,BUGGY_SAFARI_ITERATORS:g}},7680:(t,e,i)=>{var s=i(9504);t.exports=s([].slice)},7696:(t,e,i)=>{var s=i(1291),n=i(8014),r=RangeError;t.exports=function(t){if(void 0===t)return 0;var e=s(t),i=n(e);if(e!==i)throw new r("Wrong length or index");return i}},7740:(t,e,i)=>{var s=i(9297),n=i(5031),r=i(7347),o=i(4913);t.exports=function(t,e,i){for(var h=n(e),a=o.f,c=r.f,l=0;l<h.length;l++){var u=h[l];s(t,u)||i&&s(i,u)||a(t,u,c(e,u))}}},7750:(t,e,i)=>{var s=i(4117),n=TypeError;t.exports=function(t){if(s(t))throw new n("Can't call method on "+t);return t}},7751:(t,e,i)=>{var s=i(4576),n=i(4901);t.exports=function(t,e){return arguments.length<2?n(i=s[t])?i:void 0:s[t]&&s[t][e];var i}},7811:t=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},7936:(t,e,i)=>{var s=i(6518),n=i(5636);n&&s({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return n(this,arguments.length?arguments[0]:void 0,!1)}})},8004:(t,e,i)=>{var s=i(6518),n=i(9039),r=i(8750);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("intersection",(function(t){return 2===t.size&&t.has(1)&&t.has(2)}))||n((function(){return"3,2"!==String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))}))},{intersection:r})},8014:(t,e,i)=>{var s=i(1291),n=Math.min;t.exports=function(t){var e=s(t);return e>0?n(e,9007199254740991):0}},8100:(t,e,i)=>{var s=i(6518),n=i(5636);n&&s({target:"ArrayBuffer",proto:!0},{transfer:function(){return n(this,arguments.length?arguments[0]:void 0,!0)}})},8111:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(679),o=i(8551),h=i(4901),a=i(2787),c=i(2106),l=i(4659),u=i(9039),d=i(9297),f=i(8227),p=i(7657).IteratorPrototype,g=i(3724),m=i(6395),w="constructor",A="Iterator",b=f("toStringTag"),v=TypeError,y=n[A],x=m||!h(y)||y.prototype!==p||!u((function(){y({})})),M=function(){if(r(this,p),a(this)===p)throw new v("Abstract class Iterator not directly constructable")},E=function(t,e){g?c(p,t,{configurable:!0,get:function(){return e},set:function(e){if(o(this),this===p)throw new v("You can't redefine this property");d(this,t)?this[t]=e:l(this,t,e)}}):p[t]=e};d(p,b)||E(b,A),!x&&d(p,w)&&p[w]!==Object||E(w,M),M.prototype=p,s({global:!0,constructor:!0,forced:x},{Iterator:M})},8227:(t,e,i)=>{var s=i(4576),n=i(5745),r=i(9297),o=i(3392),h=i(4495),a=i(7040),c=s.Symbol,l=n("wks"),u=a?c.for||c:c&&c.withoutSetter||o;t.exports=function(t){return r(l,t)||(l[t]=h&&r(c,t)?c[t]:u("Symbol."+t)),l[t]}},8235:(t,e,i)=>{var s=i(9504),n=i(9297),r=SyntaxError,o=parseInt,h=String.fromCharCode,a=s("".charAt),c=s("".slice),l=s(/./.exec),u={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t"},d=/^[\da-f]{4}$/i,f=/^[\u0000-\u001F]$/;t.exports=function(t,e){for(var i=!0,s="";e<t.length;){var p=a(t,e);if("\\"===p){var g=c(t,e,e+2);if(n(u,g))s+=u[g],e+=2;else{if("\\u"!==g)throw new r('Unknown escape sequence: "'+g+'"');var m=c(t,e+=2,e+4);if(!l(d,m))throw new r("Bad Unicode escape at: "+e);s+=h(o(m,16)),e+=4}}else{if('"'===p){i=!1,e++;break}if(l(f,p))throw new r("Bad control character in string literal at: "+e);s+=p,e++}}if(i)throw new r("Unterminated string at: "+e);return{value:s,end:e}}},8237:(t,e,i)=>{var s=i(6518),n=i(2652),r=i(9306),o=i(8551),h=i(1767),a=i(9539),c=i(4549),l=i(8745),u=i(9039),d=TypeError,f=u((function(){[].keys().reduce((function(){}),void 0)})),p=!f&&c("reduce",d);s({target:"Iterator",proto:!0,real:!0,forced:f||p},{reduce:function(t){o(this);try{r(t)}catch(t){a(this,"throw",t)}var e=arguments.length<2,i=e?void 0:arguments[1];if(p)return l(p,this,e?[t]:[t,i]);var s=h(this),c=0;if(n(s,(function(s){e?(e=!1,i=s):i=t(i,s,c),c++}),{IS_RECORD:!0}),e)throw new d("Reduce of empty iterator with no initial value");return i}})},8335:(t,e,i)=>{var s=i(6518),n=i(3724),r=i(4576),o=i(7751),h=i(9504),a=i(9565),c=i(4901),l=i(34),u=i(4376),d=i(9297),f=i(655),p=i(6198),g=i(4659),m=i(9039),w=i(8235),A=i(4495),b=r.JSON,v=r.Number,y=r.SyntaxError,x=b&&b.parse,M=o("Object","keys"),E=Object.getOwnPropertyDescriptor,S=h("".charAt),k=h("".slice),C=h(/./.exec),T=h([].push),P=/^\d$/,_=/^[1-9]$/,R=/^[\d-]$/,N=/^[\t\n\r ]$/,I=function(t,e,i,s){var n,r,o,h,c,f=t[e],g=s&&f===s.value,m=g&&"string"==typeof s.source?{source:s.source}:{};if(l(f)){var w=u(f),A=g?s.nodes:w?[]:{};if(w)for(n=A.length,o=p(f),h=0;h<o;h++)D(f,h,I(f,""+h,i,h<n?A[h]:void 0));else for(r=M(f),o=p(r),h=0;h<o;h++)D(f,c=r[h],I(f,c,i,d(A,c)?A[c]:void 0))}return a(i,t,e,f,m)},D=function(t,e,i){if(n){var s=E(t,e);if(s&&!s.configurable)return}void 0===i?delete t[e]:g(t,e,i)},F=function(t,e,i,s){this.value=t,this.end=e,this.source=i,this.nodes=s},O=function(t,e){this.source=t,this.index=e};O.prototype={fork:function(t){return new O(this.source,t)},parse:function(){var t=this.source,e=this.skip(N,this.index),i=this.fork(e),s=S(t,e);if(C(R,s))return i.number();switch(s){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 y('Unexpected character: "'+s+'" at: '+e)},node:function(t,e,i,s,n){return new F(e,s,t?null:k(this.source,i,s),n)},object:function(){for(var t=this.source,e=this.index+1,i=!1,s={},n={};e<t.length;){if(e=this.until(['"',"}"],e),"}"===S(t,e)&&!i){e++;break}var r=this.fork(e).string(),o=r.value;e=this.until([":"],e=r.end)+1,e=this.skip(N,e),r=this.fork(e).parse(),g(n,o,r),g(s,o,r.value),e=this.until([",","}"],r.end);var h=S(t,e);if(","===h)i=!0,e++;else if("}"===h){e++;break}}return this.node(1,s,this.index,e,n)},array:function(){for(var t=this.source,e=this.index+1,i=!1,s=[],n=[];e<t.length;){if(e=this.skip(N,e),"]"===S(t,e)&&!i){e++;break}var r=this.fork(e).parse();if(T(n,r),T(s,r.value),e=this.until([",","]"],r.end),","===S(t,e))i=!0,e++;else if("]"===S(t,e)){e++;break}}return this.node(1,s,this.index,e,n)},string:function(){var t=this.index,e=w(this.source,this.index+1);return this.node(0,e.value,t,e.end)},number:function(){var t=this.source,e=this.index,i=e;if("-"===S(t,i)&&i++,"0"===S(t,i))i++;else{if(!C(_,S(t,i)))throw new y("Failed to parse number at: "+i);i=this.skip(P,i+1)}if(!("."===S(t,i)&&(i=this.skip(P,i+1)),"e"!==S(t,i)&&"E"!==S(t,i)||(i++,"+"!==S(t,i)&&"-"!==S(t,i)||i++,i!==(i=this.skip(P,i)))))throw new y("Failed to parse number's exponent value at: "+i);return this.node(0,v(k(t,e,i)),e,i)},keyword:function(t){var e=""+t,i=this.index,s=i+e.length;if(k(this.source,i,s)!==e)throw new y("Failed to parse value at: "+i);return this.node(0,t,i,s)},skip:function(t,e){for(var i=this.source;e<i.length&&C(t,S(i,e));e++);return e},until:function(t,e){e=this.skip(N,e);for(var i=S(this.source,e),s=0;s<t.length;s++)if(t[s]===i)return e;throw new y('Unexpected character: "'+i+'" at: '+e)}};var $=m((function(){var t,e="9007199254740993";return x(e,(function(e,i,s){t=s.source})),t!==e})),L=A&&!m((function(){return 1/x("-0 \t")!=-1/0}));s({target:"JSON",stat:!0,forced:$},{parse:function(t,e){return L&&!c(e)?x(t):function(t,e){t=f(t);var i=new O(t,0),s=i.parse(),n=s.value,r=i.skip(N,s.end);if(r<t.length)throw new y('Unexpected extra character: "'+S(t,r)+'" after the parsed data at: '+r);return c(e)?I({"":n},"",e,s):n}(t,e)}})},8469:(t,e,i)=>{var s=i(9504),n=i(507),r=i(4402),o=r.Set,h=r.proto,a=s(h.forEach),c=s(h.keys),l=c(new o).next;t.exports=function(t,e,i){return i?n({iterator:c(t),next:l},e):a(t,e)}},8480:(t,e,i)=>{var s=i(1828),n=i(8727).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return s(t,n)}},8527:(t,e,i)=>{var s=i(7080),n=i(4402).has,r=i(5170),o=i(3789),h=i(507),a=i(9539);t.exports=function(t){var e=s(this),i=o(t);if(r(e)<i.size)return!1;var c=i.getIterator();return!1!==h(c,(function(t){if(!n(e,t))return a(c,"normal",!1)}))}},8551:(t,e,i)=>{var s=i(34),n=String,r=TypeError;t.exports=function(t){if(s(t))return t;throw new r(n(t)+" is not an object")}},8574:(t,e,i)=>{var s=i(9504),n=Error,r=s("".replace),o=String(new n("zxcasd").stack),h=/\n\s*at [^:]*:[^\n]*/,a=h.test(o);t.exports=function(t,e){if(a&&"string"==typeof t&&!n.prepareStackTrace)for(;e--;)t=r(t,h,"");return t}},8622:(t,e,i)=>{var s=i(4576),n=i(4901),r=s.WeakMap;t.exports=n(r)&&/native code/.test(String(r))},8646:(t,e,i)=>{var s=i(9565),n=i(8551),r=i(1767),o=i(851);t.exports=function(t,e){e&&"string"==typeof t||n(t);var i=o(t);return r(n(void 0!==i?s(i,t):t))}},8686:(t,e,i)=>{var s=i(3724),n=i(9039);t.exports=s&&n((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},8721:(t,e,i)=>{var s=i(3724),n=i(9504),r=i(2106),o=URLSearchParams.prototype,h=n(o.forEach);s&&!("size"in o)&&r(o,"size",{get:function(){var t=0;return h(this,(function(){t++})),t},configurable:!0,enumerable:!0})},8727:t=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},8745:(t,e,i)=>{var s=i(616),n=Function.prototype,r=n.apply,o=n.call;t.exports="object"==typeof Reflect&&Reflect.apply||(s?o.bind(r):function(){return o.apply(r,arguments)})},8750:(t,e,i)=>{var s=i(7080),n=i(4402),r=i(5170),o=i(3789),h=i(8469),a=i(507),c=n.Set,l=n.add,u=n.has;t.exports=function(t){var e=s(this),i=o(t),n=new c;return r(e)>i.size?a(i.getIterator(),(function(t){u(e,t)&&l(n,t)})):h(e,(function(t){i.includes(t)&&l(n,t)})),n}},8773:(t,e)=>{var i={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,n=s&&!i.call({1:2},1);e.f=n?function(t){var e=s(this,t);return!!e&&e.enumerable}:i},8981:(t,e,i)=>{var s=i(7750),n=Object;t.exports=function(t){return n(s(t))}},9039:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},9143:(t,e,i)=>{var s=i(4576),n=i(9504),r=i(3972),o=i(3463),h=i(9297),a=i(2804),c=i(944),l=i(5169),u=a.c2i,d=a.c2iUrl,f=s.SyntaxError,p=s.TypeError,g=n("".charAt),m=function(t,e){for(var i=t.length;e<i;e++){var s=g(t,e);if(" "!==s&&"\t"!==s&&"\n"!==s&&"\f"!==s&&"\r"!==s)break}return e},w=function(t,e,i){var s=t.length;s<4&&(t+=2===s?"AA":"A");var n=(e[g(t,0)]<<18)+(e[g(t,1)]<<12)+(e[g(t,2)]<<6)+e[g(t,3)],r=[n>>16&255,n>>8&255,255&n];if(2===s){if(i&&0!==r[1])throw new f("Extra bits");return[r[0]]}if(3===s){if(i&&0!==r[2])throw new f("Extra bits");return[r[0],r[1]]}return r},A=function(t,e,i){for(var s=e.length,n=0;n<s;n++)t[i+n]=e[n];return i+s};t.exports=function(t,e,i,s){o(t),r(e);var n="base64"===c(e)?u:d,a=e?e.lastChunkHandling:void 0;if(void 0===a&&(a="loose"),"loose"!==a&&"strict"!==a&&"stop-before-partial"!==a)throw new p("Incorrect `lastChunkHandling` option");i&&l(i.buffer);var b=i||[],v=0,y=0,x="",M=0;if(s)for(;;){if((M=m(t,M))===t.length){if(x.length>0){if("stop-before-partial"===a)break;if("loose"!==a)throw new f("Missing padding");if(1===x.length)throw new f("Malformed padding: exactly one additional character");v=A(b,w(x,n,!1),v)}y=t.length;break}var E=g(t,M);if(++M,"="===E){if(x.length<2)throw new f("Padding is too early");if(M=m(t,M),2===x.length){if(M===t.length){if("stop-before-partial"===a)break;throw new f("Malformed padding: only one =")}"="===g(t,M)&&(++M,M=m(t,M))}if(M<t.length)throw new f("Unexpected character after padding");v=A(b,w(x,n,"strict"===a),v),y=t.length;break}if(!h(n,E))throw new f("Unexpected character");var S=s-v;if(1===S&&2===x.length||2===S&&3===x.length)break;if(4===(x+=E).length&&(v=A(b,w(x,n,!1),v),x="",y=M,v===s))break}return{bytes:b,read:y,written:v}}},9286:(t,e,i)=>{var s=i(4402),n=i(8469),r=s.Set,o=s.add;t.exports=function(t){var e=new r;return n(t,(function(t){o(e,t)})),e}},9297:(t,e,i)=>{var s=i(9504),n=i(8981),r=s({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return r(n(t),e)}},9306:(t,e,i)=>{var s=i(4901),n=i(6823),r=TypeError;t.exports=function(t){if(s(t))return t;throw new r(n(t)+" is not a function")}},9314:(t,e,i)=>{var s=i(6518),n=i(9565),r=i(8551),o=i(1767),h=i(4149),a=i(9590),c=i(9539),l=i(9462),u=i(4549),d=i(6395),f=!d&&u("drop",RangeError),p=l((function(){for(var t,e=this.iterator,i=this.next;this.remaining;)if(this.remaining--,t=r(n(i,e)),this.done=!!t.done)return;if(t=r(n(i,e)),!(this.done=!!t.done))return t.value}));s({target:"Iterator",proto:!0,real:!0,forced:d||f},{drop:function(t){var e;r(this);try{e=a(h(+t))}catch(t){c(this,"throw",t)}return f?n(f,this,e):new p(o(this),{remaining:e})}})},9429:(t,e,i)=>{var s=i(4576),n=i(6193);t.exports=function(t){if(n){try{return s.process.getBuiltinModule(t)}catch(t){}try{return Function('return require("'+t+'")')()}catch(t){}}}},9432:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(5370),o=i(9143),h=n.Uint8Array;h&&s({target:"Uint8Array",stat:!0},{fromBase64:function(t){var e=o(t,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return r(h,e.bytes)}})},9433:(t,e,i)=>{var s=i(4576),n=Object.defineProperty;t.exports=function(t,e){try{n(s,t,{value:e,configurable:!0,writable:!0})}catch(i){s[t]=e}return e}},9462:(t,e,i)=>{var s=i(9565),n=i(2360),r=i(6699),o=i(6279),h=i(8227),a=i(1181),c=i(5966),l=i(7657).IteratorPrototype,u=i(2529),d=i(9539),f=h("toStringTag"),p="IteratorHelper",g="WrapForValidIterator",m=a.set,w=function(t){var e=a.getterFor(t?g:p);return o(n(l),{next:function(){var i=e(this);if(t)return i.nextHandler();if(i.done)return u(void 0,!0);try{var s=i.nextHandler();return i.returnHandlerResult?s:u(s,i.done)}catch(t){throw i.done=!0,t}},return:function(){var i=e(this),n=i.iterator;if(i.done=!0,t){var r=c(n,"return");return r?s(r,n):u(void 0,!0)}if(i.inner)try{d(i.inner.iterator,"normal")}catch(t){return d(n,"throw",t)}return n&&d(n,"normal"),u(void 0,!0)}})},A=w(!0),b=w(!1);r(b,f,"Iterator Helper"),t.exports=function(t,e,i){var s=function(s,n){n?(n.iterator=s.iterator,n.next=s.next):n=s,n.type=e?g:p,n.returnHandlerResult=!!i,n.nextHandler=t,n.counter=0,n.done=!1,m(this,n)};return s.prototype=e?A:b,s}},9504:(t,e,i)=>{var s=i(616),n=Function.prototype,r=n.call,o=s&&n.bind.bind(r,r);t.exports=s?o:function(t){return function(){return r.apply(t,arguments)}}},9519:(t,e,i)=>{var s,n,r=i(4576),o=i(2839),h=r.process,a=r.Deno,c=h&&h.versions||a&&a.version,l=c&&c.v8;l&&(n=(s=l.split("."))[0]>0&&s[0]<4?1:+(s[0]+s[1])),!n&&o&&(!(s=o.match(/Edge\/(\d+)/))||s[1]>=74)&&(s=o.match(/Chrome\/(\d+)/))&&(n=+s[1]),t.exports=n},9539:(t,e,i)=>{var s=i(9565),n=i(8551),r=i(5966);t.exports=function(t,e,i){var o,h;n(t);try{if(!(o=r(t,"return"))){if("throw"===e)throw i;return i}o=s(o,t)}catch(t){h=!0,o=t}if("throw"===e)throw i;if(h)throw o;return n(o),i}},9565:(t,e,i)=>{var s=i(616),n=Function.prototype.call;t.exports=s?n.bind(n):function(){return n.apply(n,arguments)}},9590:(t,e,i)=>{var s=i(1291),n=RangeError;t.exports=function(t){var e=s(t);if(e<0)throw new n("The argument can't be less than 0");return e}},9617:(t,e,i)=>{var s=i(5397),n=i(5610),r=i(6198),o=function(t){return function(e,i,o){var h=s(e),a=r(h);if(0===a)return!t&&-1;var c,l=n(o,a);if(t&&i!=i){for(;a>l;)if((c=h[l++])!=c)return!0}else for(;a>l;l++)if((t||l in h)&&h[l]===i)return t||l||0;return!t&&-1}};t.exports={includes:o(!0),indexOf:o(!1)}},9631:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(9504),o=i(3972),h=i(4154),a=i(5169),c=i(2804),l=i(944),u=c.i2c,d=c.i2cUrl,f=r("".charAt);n.Uint8Array&&s({target:"Uint8Array",proto:!0},{toBase64:function(){var t=h(this),e=arguments.length?o(arguments[0]):void 0,i="base64"===l(e)?u:d,s=!!e&&!!e.omitPadding;a(this.buffer);for(var n,r="",c=0,p=t.length,g=function(t){return f(i,n>>6*t&63)};c+2<p;c+=3)n=(t[c]<<16)+(t[c+1]<<8)+t[c+2],r+=g(3)+g(2)+g(1)+g(0);return c+2===p?(n=(t[c]<<16)+(t[c+1]<<8),r+=g(3)+g(2)+g(1)+(s?"":"=")):c+1===p&&(n=t[c]<<16,r+=g(3)+g(2)+(s?"":"==")),r}})},9797:(t,e,i)=>{var s=i(6518),n=i(4576),r=i(3463),o=i(4154),h=i(5169),a=i(2303);n.Uint8Array&&s({target:"Uint8Array",proto:!0},{setFromHex:function(t){o(this),r(t),h(this.buffer);var e=a(t,this).read;return{read:e,written:e/2}}})}},g={};function m(t){var e=g[t];if(void 0!==e)return e.exports;var i=g[t]={exports:{}};return p[t].call(i.exports,i,i.exports,m),i.exports}m(4114),m(6573),m(8100),m(7936),m(8111),m(8237),m(1689),m(9432),m(1549),m(9797),m(9631),m(5623),m(4979),m(5781);const w=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),A=[.001,0,0,.001,0,0],b=1.35,v={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},y={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101},x={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_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},M={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},E={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},S={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},k={ERRORS:0,WARNINGS:1,INFOS:5},C={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},T={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let P=k.WARNINGS;function _(t){Number.isInteger(t)&&(P=t)}function R(){return P}function N(t){P>=k.INFOS&&console.log(`Info: ${t}`)}function I(t){P>=k.WARNINGS&&console.log(`Warning: ${t}`)}function D(t){throw new Error(t)}function F(t,e){t||D(e)}function O(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s)?s:null}function $(t,e,i=!1){const s=URL.parse(t);return s?(s.hash=e,s.href):i&&O(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function L(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const B=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class U extends B{constructor(t,e){super(t,"PasswordException"),this.code=e}}class j extends B{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class z extends B{constructor(t){super(t,"InvalidPDFException")}}class H extends B{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class G extends B{constructor(t){super(t,"FormatError")}}class W extends B{constructor(t){super(t,"AbortException")}}function V(t){"object"==typeof t&&void 0!==t?.length||D("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const r=Math.min(n+i,e),o=t.subarray(n,r);s.push(String.fromCharCode.apply(null,o))}return s.join("")}function X(t){"string"!=typeof t&&D("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class Y{static get isLittleEndian(){return L(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return L(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return L(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return L(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){const{platform:t,userAgent:e}=navigator;return L(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 L(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const q=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class Q{static makeHexColor(t,e,i){return`#${q[t]}${q[e]}${q[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e,i=0){const s=t[i],n=t[i+1];t[i]=s*e[0]+n*e[2]+e[4],t[i+1]=s*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const s=e[0],n=e[1],r=e[2],o=e[3],h=e[4],a=e[5];for(let e=0;e<6;e+=2){const c=t[i+e],l=t[i+e+1];t[i+e]=c*s+l*r+h,t[i+e+1]=c*n+l*o+a}}static applyInverseTransform(t,e){const i=t[0],s=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,i){const s=e[0],n=e[1],r=e[2],o=e[3],h=e[4],a=e[5],c=t[0],l=t[1],u=t[2],d=t[3];let f=s*c+h,p=f,g=s*u+h,m=g,w=o*l+a,A=w,b=o*d+a,v=b;if(0!==n||0!==r){const t=n*c,e=n*u,i=r*l,s=r*d;f+=i,m+=i,g+=s,p+=s,w+=t,v+=t,b+=e,A+=e}i[0]=Math.min(i[0],f,g,p,m),i[1]=Math.min(i[1],w,b,A,v),i[2]=Math.max(i[2],f,g,p,m),i[3]=Math.max(i[3],w,b,A,v)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const i=t[0],s=t[1],n=t[2],r=t[3],o=i**2+s**2,h=n**2+r**2,a=(o+h)/2,c=Math.sqrt(a**2-(o*h-(i*n+s*r)**2));e[0]=Math.sqrt(a+c||1),e[1]=Math.sqrt(a-c||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,n){n[0]=Math.min(n[0],t,i),n[1]=Math.min(n[1],e,s),n[2]=Math.max(n[2],t,i),n[3]=Math.max(n[3],e,s)}static#t(t,e,i,s,n,r,o,h,a,c){if(a<=0||a>=1)return;const l=1-a,u=a*a,d=u*a,f=l*(l*(l*t+3*a*e)+3*u*i)+d*s,p=l*(l*(l*n+3*a*r)+3*u*o)+d*h;c[0]=Math.min(c[0],f),c[1]=Math.min(c[1],p),c[2]=Math.max(c[2],f),c[3]=Math.max(c[3],p)}static#e(t,e,i,s,n,r,o,h,a,c,l,u){if(Math.abs(a)<1e-12)return void(Math.abs(c)>=1e-12&&this.#t(t,e,i,s,n,r,o,h,-l/c,u));const d=c**2-4*l*a;if(d<0)return;const f=Math.sqrt(d),p=2*a;this.#t(t,e,i,s,n,r,o,h,(-c+f)/p,u),this.#t(t,e,i,s,n,r,o,h,(-c-f)/p,u)}static bezierBoundingBox(t,e,i,s,n,r,o,h,a){a[0]=Math.min(a[0],t,o),a[1]=Math.min(a[1],e,h),a[2]=Math.max(a[2],t,o),a[3]=Math.max(a[3],e,h),this.#e(t,i,n,o,e,s,r,h,3*(3*(i-n)-t+o),6*(t-2*i+n),3*(i-t),a),this.#e(t,i,n,o,e,s,r,h,3*(3*(s-r)-e+h),6*(e-2*s+r),3*(s-e),a)}}let K=null,J=null;function Z(t){return K||(K=/([\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,J=new Map([["ſt","ſt"]])),t.replaceAll(K,((t,e,i)=>e?e.normalize("NFKC"):J.get(i)))}function tt(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),V(t)}const et="pdfjs_internal_id_";function it(t,e,i){return Math.min(Math.max(t,e),i)}function st(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(V(t))}"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce(((t,e)=>t+e),0)}),"function"!=typeof AbortSignal.any&&(AbortSignal.any=function(t){const e=new AbortController,{signal:i}=e;for(const s of t)if(s.aborted)return e.abort(s.reason),i;for(const s of t)s.addEventListener("abort",(()=>{e.abort(s.reason)}),{signal:i});return i}),m(1701),m(4628),m(7642),m(8004),m(3853),m(5876),m(2475),m(5024),m(1698),m(4603),m(7566),m(8721),m(9314),m(1148),m(3579),m(8335);const nt="http://www.w3.org/2000/svg";class rt{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function ot(t,e="text"){if(pt(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class ht{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const h=(t[2]+t[0])/2,a=(t[3]+t[1])/2;let c,l,u,d,f,p,g,m;switch((s%=360)<0&&(s+=360),s){case 180:c=-1,l=0,u=0,d=1;break;case 90:c=0,l=1,u=1,d=0;break;case 270:c=0,l=-1,u=-1,d=0;break;case 0:c=1,l=0,u=0,d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(u=-u,d=-d),0===c?(f=Math.abs(a-t[1])*i+n,p=Math.abs(h-t[0])*i+r,g=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(f=Math.abs(h-t[0])*i+n,p=Math.abs(a-t[1])*i+r,g=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[c*i,l*i,u*i,d*i,f-c*i*h-u*i*a,p-l*i*h-d*i*a],this.width=g,this.height=m}get rawDims(){const t=this.viewBox;return L(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new ht({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){const i=[t,e];return Q.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];Q.applyTransform(e,this.transform);const i=[t[2],t[3]];return Q.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return Q.applyInverseTransform(i,this.transform),i}}class at extends B{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function ct(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function lt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function ut(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function dt(t,e="document.pdf"){if("string"!=typeof t)return e;if(ct(t))return I('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e}class ft{started=Object.create(null);times=[];time(t){t in this.started&&I(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||I(`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:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function pt(t,e){const i=e?URL.parse(t,e):URL.parse(t);return"http:"===i?.protocol||"https:"===i?.protocol}function gt(t){t.preventDefault()}function mt(t){t.preventDefault(),t.stopPropagation()}class wt{static#i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let h=parseInt(e[6],10);h=h>=0&&h<=59?h:0;const a=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let l=parseInt(e[9],10)||0;return l=l>=0&&l<=59?l:0,"-"===a?(r+=c,o+=l):"+"===a&&(r-=c,o-=l),new Date(Date.UTC(i,s,n,r,o,h))}}function At(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new ht({viewBox:r,userUnit:1,scale:e,rotation:i})}function bt(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(I(`Not a valid color format: "${t}"`),[0,0,0])}function vt(t){const{a:e,b:i,c:s,d:n,e:r,f:o}=t.getTransform();return[e,i,s,n,r,o]}function yt(t){const{a:e,b:i,c:s,d:n,e:r,f:o}=t.getTransform().invertSelf();return[e,i,s,n,r,o]}function xt(t,e,i=!1,s=!0){if(e instanceof ht){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,o=Y.isCSSRoundSupported,h=`var(--total-scale-factor) * ${s}px`,a=`var(--total-scale-factor) * ${n}px`,c=o?`round(down, ${h}, var(--scale-round-x))`:`calc(${h})`,l=o?`round(down, ${a}, var(--scale-round-y))`:`calc(${a})`;i&&e.rotation%180!=0?(r.width=l,r.height=c):(r.width=c,r.height=l)}s&&t.setAttribute("data-main-rotation",e.rotation)}class Mt{constructor(){const{pixelRatio:t}=Mt;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,n=-1){let r=1/0,o=1/0,h=1/0;(i=Mt.capPixels(i,n))>0&&(r=Math.sqrt(i/(t*e))),-1!==s&&(o=s/t,h=s/e);const a=Math.min(r,o,h);return(this.sx>a||this.sy>a)&&(this.sx=a,this.sy=a,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}const Et=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class St{#s=null;#n=null;#r;#o=null;#h=null;#a=null;static#c=null;constructor(t){this.#r=t,St.#c||=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.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#r._uiManager._signal;t.addEventListener("contextmenu",gt,{signal:e}),t.addEventListener("pointerdown",St.#l,{signal:e});const i=this.#o=document.createElement("div");i.className="buttons",t.append(i);const s=this.#r.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#u(),t}get div(){return this.#s}static#l(t){t.stopPropagation()}#d(t){this.#r._focusEventsAllowed=!1,mt(t)}#f(t){this.#r._focusEventsAllowed=!0,mt(t)}#p(t){const e=this.#r._uiManager._signal;t.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#f.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",gt,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#h?.shown()}#u(){const{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",St.#c[t]),this.#p(i),i.addEventListener("click",(()=>{e.delete()}),{signal:e._signal}),this.#o.append(i)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#o.prepend(e,this.#g),this.#h=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#p(e),this.#o.prepend(e,this.#g)}async addEditSignatureButton(t){const e=this.#a=await t.renderEditButton(this.#r);this.#p(e),this.#o.prepend(e,this.#g)}updateEditSignatureButton(t){this.#a&&(this.#a.title=t)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class kt{#o=null;#s=null;#m;constructor(t){this.#m=t}#w(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",gt,{signal:this.#m._signal});const e=this.#o=document.createElement("div");return e.className="buttons",t.append(e),this.#A(),t}#b(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const r=n.x+(e?n.width:0);t>i?(s=r,i=t):e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#b(e,i),{style:r}=this.#s||=this.#w();t.append(this.#s),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#A(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#m._signal;t.addEventListener("contextmenu",gt,{signal:i}),t.addEventListener("click",(()=>{this.#m.highlightSelection("floating_button")}),{signal:i}),this.#o.append(t)}}function Ct(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class Tt{#v=0;get id(){return"pdfjs_internal_editor_"+this.#v++}}class Pt{#y=tt();#v=0;#x=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;return e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',L(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#M(t,e){this.#x||=new Map;let i=this.#x.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#y}_${this.#v++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await ot(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Pt._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise(((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r}));s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){I(t),i=null}return this.#x.set(t,i),i&&this.#x.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#M(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#M(t,t)}async getFromBlob(t,e){const i=await e;return this.#M(t,i)}async getFromId(t){this.#x||=new Map;const e=this.#x.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#x||=new Map;let i=this.#x.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#y}_${this.#v++}`,refCounter:1,isSvg:!1},this.#x.set(t,i),this.#x.set(i.id,i),i}getSvgUrl(t){const e=this.#x.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#x||=new Map;const e=this.#x.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#y}_`)}}class _t{#E=[];#S=!1;#k;#C=-1;constructor(t=128){this.#k=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:o=!1}){if(s&&t(),this.#S)return;const h={cmd:t,undo:e,post:i,type:n};if(-1===this.#C)return this.#E.length>0&&(this.#E.length=0),this.#C=0,void this.#E.push(h);if(r&&this.#E[this.#C].type===n)return o&&(h.undo=this.#E[this.#C].undo),void(this.#E[this.#C]=h);const a=this.#C+1;a===this.#k?this.#E.splice(0,1):(this.#C=a,a<this.#E.length&&this.#E.splice(a)),this.#E.push(h)}undo(){if(-1===this.#C)return;this.#S=!0;const{undo:t,post:e}=this.#E[this.#C];t(),e?.(),this.#S=!1,this.#C-=1}redo(){if(this.#C<this.#E.length-1){this.#C+=1,this.#S=!0;const{cmd:t,post:e}=this.#E[this.#C];t(),e?.(),this.#S=!1}}hasSomethingToUndo(){return-1!==this.#C}hasSomethingToRedo(){return this.#C<this.#E.length-1}cleanType(t){if(-1!==this.#C){for(let e=this.#C;e>=0;e--)if(this.#E[e].type!==t)return this.#E.splice(e+1,this.#C-e),void(this.#C=e);this.#E.length=0,this.#C=-1}}destroy(){this.#E=null}}class Rt{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Y.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.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 i=this.callbacks.get(this.#T(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:o=null}}=i;o&&!o(t,e)||(s.bind(t,...r,e)(),n||mt(e))}}class Nt{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,bt(s))}e.remove()}(t),L(this,"_colors",t)}convert(t){const e=bt(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,i]of this._colors)if(i.every(((t,i)=>t===e[i])))return Nt._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?Q.makeHexColor(...e):t}}class It{#P=new AbortController;#_=null;#R=new Map;#N=new Map;#I=null;#D=null;#F=null;#O=new _t;#$=null;#L=null;#B=0;#U=new Set;#j=null;#z=null;#H=new Set;_editorUndoBar=null;#G=!1;#W=!1;#V=!1;#X=null;#Y=null;#q=null;#Q=null;#K=!1;#J=null;#Z=new Tt;#tt=!1;#et=!1;#it=null;#st=null;#nt=null;#rt=null;#ot=null;#ht=y.NONE;#at=new Set;#ct=null;#lt=null;#ut=null;#dt=null;#ft={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#pt=[0,0];#gt=null;#mt=null;#wt=null;#At=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=It.prototype,e=t=>t.#mt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return L(this,"_keyboardManager",new Rt([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#mt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#mt.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,i,s,n,r,o,h,a,c,l,u,d,f){const p=this._signal=this.#P.signal;this.#mt=t,this.#wt=e,this.#I=i,this.#lt=s,this._eventBus=n,n._on("editingaction",this.onEditingAction.bind(this),{signal:p}),n._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),n._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),n._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),n._on("setpreference",this.onSetPreference.bind(this),{signal:p}),n._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),this.#bt(),this.#vt(),this.#yt(),this.#D=r.annotationStorage,this.#X=r.filterFactory,this.#ut=o,this.#Q=h||null,this.#G=a,this.#W=c,this.#V=l,this.#ot=u||null,this.viewParameters={realScale:rt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=d||null,this._supportsPinchToZoom=!1!==f}destroy(){this.#At?.resolve(),this.#At=null,this.#P?.abort(),this.#P=null,this._signal=null;for(const t of this.#N.values())t.destroy();this.#N.clear(),this.#R.clear(),this.#H.clear(),this.#rt?.clear(),this.#_=null,this.#at.clear(),this.#O.destroy(),this.#I?.destroy(),this.#lt?.destroy(),this.#J?.hide(),this.#J=null,this.#nt?.destroy(),this.#nt=null,this.#Y&&(clearTimeout(this.#Y),this.#Y=null),this.#gt&&(clearTimeout(this.#gt),this.#gt=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#ot}get useNewAltTextFlow(){return this.#W}get useNewAltTextWhenAddingImage(){return this.#V}get hcmFilter(){return L(this,"hcmFilter",this.#ut?this.#X.addHCMFilter(this.#ut.foreground,this.#ut.background):"none")}get direction(){return L(this,"direction",getComputedStyle(this.#mt).direction)}get highlightColors(){return L(this,"highlightColors",this.#Q?new Map(this.#Q.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return L(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#L=t}setMainHighlightColorPicker(t){this.#nt=t}editAltText(t,e=!1){this.#I?.editAltText(this,t,e)}getSignature(t){this.#lt?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#lt}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}){"enableNewAltTextWhenAddingImage"===t&&(this.#V=e)}onPageChanging({pageNumber:t}){this.#B=t-1}focusMainContainer(){this.#mt.focus()}findParent(t,e){for(const i of this.#N.values()){const{x:s,y:n,width:r,height:o}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+o)return i}return null}disableUserSelect(t=!1){this.#wt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#H.add(t)}removeShouldRescale(t){this.#H.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*rt.PDF_TO_CSS_UNITS;for(const t of this.#H)t.onScaleChanging();this.#L?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#xt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#Mt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#N.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}=e,o=e.toString(),h=this.#xt(e).closest(".textLayer"),a=this.getSelectionBoxes(h);if(!a)return;e.empty();const c=this.#Mt(h),l=this.#ht===y.NONE,u=()=>{c?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:a,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r,text:o}),l&&this.showAllEditors("highlight",!0,!0)};l?this.switchToMode(y.HIGHLIGHT,u):u()}#Et(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#xt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#J||=new kt(this),this.#J.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#D||this.#D.has(t.id)||this.#D.setValue(t.id,t)}#St(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ct&&(this.#J?.hide(),this.#ct=null,this.#kt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ct)return;const i=this.#xt(t).closest(".textLayer");if(i){if(this.#J?.hide(),this.#ct=e,this.#kt({hasSelectedText:!0}),(this.#ht===y.HIGHLIGHT||this.#ht===y.NONE)&&(this.#ht===y.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#K=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#ht===y.HIGHLIGHT?this.#Mt(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#Ct("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ct&&(this.#J?.hide(),this.#ct=null,this.#kt({hasSelectedText:!1}))}#Ct(t=""){this.#ht===y.HIGHLIGHT?this.highlightSelection(t):this.#G&&this.#Et()}#bt(){document.addEventListener("selectionchange",this.#St.bind(this),{signal:this._signal})}#Tt(){if(this.#q)return;this.#q=new AbortController;const t=this.combinedSignal(this.#q);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Pt(){this.#q?.abort(),this.#q=null}blur(){if(this.isShiftKeyDown=!1,this.#K&&(this.#K=!1,this.#Ct("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#at)if(e.div.contains(t)){this.#st=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#st)return;const[t,e]=this.#st;this.#st=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#yt(){if(this.#it)return;this.#it=new AbortController;const t=this.combinedSignal(this.#it);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#_t(){this.#it?.abort(),this.#it=null}#Rt(){if(this.#$)return;this.#$=new AbortController;const t=this.combinedSignal(this.#$);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})}#Nt(){this.#$?.abort(),this.#$=null}#vt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#yt(),this.#Rt()}removeEditListeners(){this.#_t(),this.#Nt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#z)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#z)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#_?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#at){const i=t.serialize(!0);i&&e.push(i)}0!==e.length&&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 t of e.items)for(const e of this.#z)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void I(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=await s.deserialize(e);if(!i)return;t.push(i)}this.addCommands({cmd:()=>{for(const e of t)this.#It(e);this.#Dt(t)},undo:()=>{for(const e of t)e.remove()},mustExec:!0})}catch(t){I(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#ht===y.NONE||this.isEditorHandlingKeyboard||It._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#K&&(this.#K=!1,this.#Ct("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#kt(t){Object.entries(t).some((([t,e])=>this.#ft[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#ft,t)}),this.#ht===y.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Ft([[x.HIGHLIGHT_FREE,!0]]))}#Ft(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Tt(),this.#Rt(),this.#kt({isEditing:this.#ht!==y.NONE,isEmpty:this.#Ot(),hasSomethingToUndo:this.#O.hasSomethingToUndo(),hasSomethingToRedo:this.#O.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Pt(),this.#Nt(),this.#kt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#z){this.#z=t;for(const t of this.#z)this.#Ft(t.defaultPropertiesToUpdate)}}getId(){return this.#Z.id}get currentLayer(){return this.#N.get(this.#B)}getLayer(t){return this.#N.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#N.set(t.pageIndex,t),this.#tt?t.enable():t.disable()}removeLayer(t){this.#N.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#ht!==t&&(!this.#At||(await this.#At.promise,this.#At))){if(this.#At=Promise.withResolvers(),this.#L?.commitOrRemove(),this.#ht=t,t===y.NONE)return this.setEditingState(!1),this.#$t(),this._editorUndoBar?.hide(),void this.#At.resolve();t===y.SIGNATURE&&await(this.#lt?.loadSignatures()),this.setEditingState(!0),await this.#Lt(),this.unselectAll();for(const e of this.#N.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#At.resolve();for(const t of this.#R.values())t.annotationElementId===e||t.id===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#At.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#ht&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#z){switch(t){case x.CREATE:return void this.currentLayer.addNewEditor(e);case x.HIGHLIGHT_DEFAULT_COLOR:this.#nt?.updateColor(e);break;case x.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#dt||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#at)i.updateParams(t,e);for(const i of this.#z)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#R.values())i.editorType===t&&i.show(e);(this.#dt?.get(x.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Ft([[x.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#et!==t){this.#et=t;for(const e of this.#N.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Lt(){if(!this.#tt){this.#tt=!0;const t=[];for(const e of this.#N.values())t.push(e.enable());await Promise.all(t);for(const t of this.#R.values())t.enable()}}#$t(){if(this.unselectAll(),this.#tt){this.#tt=!1;for(const t of this.#N.values())t.disable();for(const t of this.#R.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#R.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#R.get(t)}addEditor(t){this.#R.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#Y&&clearTimeout(this.#Y),this.#Y=setTimeout((()=>{this.focusMainContainer(),this.#Y=null}),0)),this.#R.delete(t.id),t.annotationElementId&&this.#rt?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#U.has(t.annotationElementId)||this.#D?.remove(t.id)}addDeletedAnnotationElement(t){this.#U.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#U.has(t)}removeDeletedAnnotationElement(t){this.#U.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#It(t){const e=this.#N.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#_!==t&&(this.#_=t,t&&this.#Ft(t.propertiesToUpdate))}get#Bt(){let t=null;for(t of this.#at);return t}updateUI(t){this.#Bt===t&&this.#Ft(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Ft(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#at.has(t))return this.#at.delete(t),t.unselect(),void this.#kt({hasSelectedEditor:this.hasSelection});this.#at.add(t),t.select(),this.#Ft(t.propertiesToUpdate),this.#kt({hasSelectedEditor:!0})}setSelected(t){this.#L?.commitOrRemove();for(const e of this.#at)e!==t&&e.unselect();this.#at.clear(),this.#at.add(t),t.select(),this.#Ft(t.propertiesToUpdate),this.#kt({hasSelectedEditor:!0})}isSelected(t){return this.#at.has(t)}get firstSelectedEditor(){return this.#at.values().next().value}unselect(t){t.unselect(),this.#at.delete(t),this.#kt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#at.size}get isEnterHandled(){return 1===this.#at.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#O.undo(),this.#kt({hasSomethingToUndo:this.#O.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Ot()}),this._editorUndoBar?.hide()}redo(){this.#O.redo(),this.#kt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#O.hasSomethingToRedo(),isEmpty:this.#Ot()})}addCommands(t){this.#O.add(t),this.#kt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Ot()})}cleanUndoStack(t){this.#O.cleanType(t)}#Ot(){if(0===this.#R.size)return!0;if(1===this.#R.size)for(const t of this.#R.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.#at],i=()=>{for(const t of e)this.#It(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#_?.commitOrRemove()}hasSomethingToControl(){return this.#_||this.hasSelection}#Dt(t){for(const t of this.#at)t.unselect();this.#at.clear();for(const e of t)e.isEmpty()||(this.#at.add(e),e.select());this.#kt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#at)t.commit();this.#Dt(this.#R.values())}unselectAll(){if((!this.#_||(this.#_.commitOrRemove(),this.#ht===y.NONE))&&!this.#L?.commitOrRemove()&&this.hasSelection){for(const t of this.#at)t.unselect();this.#at.clear(),this.#kt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#pt[0]+=t,this.#pt[1]+=e;const[s,n]=this.#pt,r=[...this.#at];this.#gt&&clearTimeout(this.#gt),this.#gt=setTimeout((()=>{this.#gt=null,this.#pt[0]=this.#pt[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#R.has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(const t of r)this.#R.has(t.id)&&(t.translateInPage(-s,-n),t.translationDone())},mustExec:!1})}),1e3);for(const i of r)i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#j=new Map;for(const t of this.#at)this.#j.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#j)return!1;this.disableUserSelect(!1);const t=this.#j;this.#j=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},r]of t)r.newX=i,r.newY=s,r.newPageIndex=n,e||=i!==r.savedX||s!==r.savedY||n!==r.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#R.has(t.id)){const n=this.#N.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:r}]of t)i(e,s,n,r)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#j)for(const i of this.#j.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#at.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#_===t}getActive(){return this.#_}getMode(){return this.#ht}get imageManager(){return L(this,"imageManager",new Pt)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(t,e,o,h)=>({x:(e-s)/r,y:1-(t+o-i)/n,width:h/r,height:o/n});break;case"180":o=(t,e,o,h)=>({x:1-(t+o-i)/n,y:1-(e+h-s)/r,width:o/n,height:h/r});break;case"270":o=(t,e,o,h)=>({x:1-(e+h-s)/r,y:(t-i)/n,width:h/r,height:o/n});break;default:o=(t,e,o,h)=>({x:(t-i)/n,y:(e-s)/r,width:o/n,height:h/r})}const h=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:n}of i.getClientRects())0!==s&&0!==n&&h.push(o(t,e,s,n))}return 0===h.length?null:h}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#F||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#F?.delete(t)}renderAnnotationElement(t){const e=this.#F?.get(t.data.id);if(!e)return;const i=this.#D.getRawValue(e);i&&(this.#ht!==y.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){const s=this.#rt?.get(t);s&&(s.setCanvas(e,i),this.#rt.delete(t))}addMissingCanvas(t,e){(this.#rt||=new Map).set(t,e)}}class Dt{#h=null;#Ut=!1;#jt=null;#zt=null;#Ht=null;#Gt=null;#Wt=!1;#Vt=null;#r=null;#Xt=null;#Yt=null;#qt=!1;static#Qt=null;static _l10n=null;constructor(t){this.#r=t,this.#qt=t._uiManager.useNewAltTextFlow,Dt.#Qt||=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){Dt._l10n??=t}async render(){const t=this.#jt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#zt=document.createElement("span");t.append(e),this.#qt?(t.classList.add("new"),t.setAttribute("data-l10n-id",Dt.#Qt.missing),e.setAttribute("data-l10n-id",Dt.#Qt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#r._uiManager._signal;t.addEventListener("contextmenu",gt,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#qt&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Kt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#Wt=!0,s(e))}),{signal:i}),await this.#Jt(),t}get#Kt(){return(this.#h?"added":null===this.#h&&this.guessedText&&"review")||"missing"}finish(){this.#jt&&(this.#jt.focus({focusVisible:this.#Wt}),this.#Wt=!1)}isEmpty(){return this.#qt?null===this.#h:!this.#h&&!this.#Ut}hasData(){return this.#qt?null!==this.#h||!!this.#Xt:this.isEmpty()}get guessedText(){return this.#Xt}async setGuessedText(t){null===this.#h&&(this.#Xt=t,this.#Yt=await Dt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Jt())}toggleAltTextBadge(t=!1){if(!this.#qt||this.#h)return this.#Vt?.remove(),void(this.#Vt=null);if(!this.#Vt){const t=this.#Vt=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#Vt.classList.toggle("hidden",!t)}serialize(t){let e=this.#h;return t||this.#Xt!==e||(e=this.#Yt),{altText:e,decorative:this.#Ut,guessedText:this.#Xt,textWithDisclaimer:this.#Yt}}get data(){return{altText:this.#h,decorative:this.#Ut}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#Xt=i,this.#Yt=s),this.#h===t&&this.#Ut===e||(n||(this.#h=t,this.#Ut=e),this.#Jt())}toggle(t=!1){this.#jt&&(!t&&this.#Gt&&(clearTimeout(this.#Gt),this.#Gt=null),this.#jt.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Kt}})}destroy(){this.#jt?.remove(),this.#jt=null,this.#zt=null,this.#Ht=null,this.#Vt?.remove(),this.#Vt=null}async#Jt(){const t=this.#jt;if(!t)return;if(this.#qt){if(t.classList.toggle("done",!!this.#h),t.setAttribute("data-l10n-id",Dt.#Qt[this.#Kt]),this.#zt?.setAttribute("data-l10n-id",Dt.#Qt[`${this.#Kt}-label`]),!this.#h)return void this.#Ht?.remove()}else{if(!this.#h&&!this.#Ut)return t.classList.remove("done"),void this.#Ht?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Ht;if(!e){this.#Ht=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;const i=100,s=this.#r._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#Gt),this.#Gt=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Gt=setTimeout((()=>{this.#Gt=null,this.#Ht.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Gt&&(clearTimeout(this.#Gt),this.#Gt=null),this.#Ht?.classList.remove("show")}),{signal:s})}this.#Ut?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#h),e.parentNode||t.append(e);const i=this.#r.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class Ft{#mt;#Zt=!1;#te=null;#ee;#ie;#se;#ne;#re=null;#oe;#he=null;#ae;#ce=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:o}){this.#mt=t,this.#te=i,this.#ee=e,this.#ie=s,this.#se=n,this.#ne=r,this.#ae=new AbortController,this.#oe=AbortSignal.any([o,this.#ae.signal]),t.addEventListener("touchstart",this.#le.bind(this),{passive:!1,signal:this.#oe})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Mt.pixelRatio}#le(t){if(this.#ee?.())return;if(1===t.touches.length){if(this.#re)return;const t=this.#re=new AbortController,e=AbortSignal.any([this.#oe,t.signal]),i=this.#mt,s={capture:!0,signal:e,passive:!1},n=t=>{"touch"===t.pointerType&&(this.#re?.abort(),this.#re=null)};return i.addEventListener("pointerdown",(t=>{"touch"===t.pointerType&&(mt(t),n(t))}),s),i.addEventListener("pointerup",n,s),void i.addEventListener("pointercancel",n,s)}if(!this.#ce){this.#ce=new AbortController;const t=AbortSignal.any([this.#oe,this.#ce.signal]),e=this.#mt,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#ue.bind(this),i);const s=this.#de.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",mt,i),e.addEventListener("pointermove",mt,i),e.addEventListener("pointercancel",mt,i),e.addEventListener("pointerup",mt,i),this.#ie?.()}if(mt(t),2!==t.touches.length||this.#te?.())return void(this.#he=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#he={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#ue(t){if(!this.#he||2!==t.touches.length)return;mt(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);const{screenX:s,screenY:n}=e,{screenX:r,screenY:o}=i,h=this.#he,{touch0X:a,touch0Y:c,touch1X:l,touch1Y:u}=h,d=l-a,f=u-c,p=Math.hypot(r-s,o-n)||1,g=Math.hypot(d,f)||1;if(!this.#Zt&&Math.abs(g-p)<=Ft.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(h.touch0X=s,h.touch0Y=n,h.touch1X=r,h.touch1Y=o,!this.#Zt)return void(this.#Zt=!0);const m=[(s+r)/2,(n+o)/2];this.#se?.(m,g,p)}#de(t){t.touches.length>=2||(this.#ce&&(this.#ce.abort(),this.#ce=null,this.#ne?.()),this.#he&&(mt(t),this.#he=null,this.#Zt=!1))}destroy(){this.#ae?.abort(),this.#ae=null,this.#re?.abort(),this.#re=null}}class Ot{#fe=null;#pe=null;#h=null;#ge=!1;#me=null;#we="";#Ae=!1;#be=null;#ve=null;#ye=null;#xe=null;#Me="";#Ee=!1;#Se=null;#ke=!1;#Ce=!1;#Te=!1;#Pe=null;#_e=0;#Re=0;#Ne=null;#Ie=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;#De=!1;#Fe=Ot._zIndex++;static _borderLineWidth=-1;static _colorManager=new Nt;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=Ot.prototype._resizeWithKeyboard,e=It.TRANSLATE_SMALL,i=It.TRANSLATE_BIG;return L(this,"_resizerKeyboardManager",new Rt([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],Ot.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;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[o,h]=this.parentDimensions;this.x=t.x/o,this.y=t.y/h,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return L(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new $t({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(Ot._l10n??=t,Ot._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==Ot._borderLineWidth)return;const i=getComputedStyle(document.documentElement);Ot._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){D("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#De}set _isDraggable(t){this.#De=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Fe}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#Oe(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#Ee?this.#Ee=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#$e([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#$e(this.parentDimensions,t,e)}translateInPage(t,e){this.#Se||=[this.x,this.y,this.width,this.height],this.#$e(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#Se||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:o}=this;const[h,a]=this.getBaseTranslation();r+=h,o+=a;const{style:c}=i;c.left=`${(100*r).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(r,o),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#Se&&(this.#Se[0]!==this.x||this.#Se[1]!==this.y)}get _hasBeenResized(){return!!this.#Se&&(this.#Se[2]!==this.width||this.#Se[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=Ot,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:o,height:h}=this;if(o*=i,h*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=it(n,0,i-o),r=it(r,0,s-h);break;case 90:n=it(n,0,i-h),r=it(r,o,s);break;case 180:n=it(n,o,i),r=it(r,h,s);break;case 270:n=it(n,h,i),r=it(r,0,s-o)}this.x=n/=i,this.y=r/=s;const[a,c]=this.getBaseTranslation();n+=a,r+=c,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#Le(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return Ot.#Le(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Ot.#Le(t,e,360-this.parentRotation)}#Be(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#Ae||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#Ae&&e.endsWith("%");if(s&&n)return;const[r,o]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#Ae||n||(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Ue(){if(this.#be)return;this.#be=document.createElement("div"),this.#be.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#be.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#je.bind(this,i),{signal:e}),t.addEventListener("contextmenu",gt,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#be)}#je(t,e){e.preventDefault();const{isMac:i}=Y.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#h?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#ve=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#ze.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",mt,{passive:!1,signal:r}),window.addEventListener("contextmenu",gt,{signal:r}),this.#ye={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const o=this.parent.div.style.cursor,h=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const a=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#h?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=o,this.div.style.cursor=h,this.#He()};window.addEventListener("pointerup",a,{signal:r}),window.addEventListener("blur",a,{signal:r})}#Ge(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,r]=this.parentDimensions;this.setDims(n*i,r*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#He(){if(!this.#ye)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#ye;this.#ye=null;const n=this.x,r=this.y,o=this.width,h=this.height;n===t&&r===e&&o===i&&h===s||this.addCommands({cmd:this.#Ge.bind(this,n,r,o,h),undo:this.#Ge.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#ze(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,o=this.width,h=this.height,a=Ot.MIN_SIZE/i,c=Ot.MIN_SIZE/s,l=this.#Be(this.rotation),u=(t,e)=>[l[0]*t+l[2]*e,l[1]*t+l[3]*e],d=this.#Be(360-this.rotation);let f,p,g=!1,m=!1;switch(t){case"topLeft":g=!0,f=()=>[0,0],p=(t,e)=>[t,e];break;case"topMiddle":f=t=>[t/2,0],p=(t,e)=>[t/2,e];break;case"topRight":g=!0,f=t=>[t,0],p=(t,e)=>[0,e];break;case"middleRight":m=!0,f=(t,e)=>[t,e/2],p=(t,e)=>[0,e/2];break;case"bottomRight":g=!0,f=(t,e)=>[t,e],p=()=>[0,0];break;case"bottomMiddle":f=(t,e)=>[t/2,e],p=t=>[t/2,0];break;case"bottomLeft":g=!0,f=(t,e)=>[0,e],p=t=>[t,0];break;case"middleLeft":m=!0,f=(t,e)=>[0,e/2],p=(t,e)=>[t,e/2]}const w=f(o,h),A=p(o,h);let b=u(...A);const v=Ot._round(n+b[0]),y=Ot._round(r+b[1]);let x,M,E=1,S=1;if(e.fromKeyboard)({deltaX:x,deltaY:M}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#ve;[x,M]=this.screenToPageTranslation(t-s,i-n),this.#ve[0]=t,this.#ve[1]=i}var k,C;if([x,M]=[d[0]*(k=x/i)+d[2]*(C=M/s),d[1]*k+d[3]*C],g){const t=Math.hypot(o,h);E=S=Math.max(Math.min(Math.hypot(A[0]-w[0]-x,A[1]-w[1]-M)/t,1/o,1/h),a/o,c/h)}else m?E=it(Math.abs(A[0]-w[0]-x),a,1)/o:S=it(Math.abs(A[1]-w[1]-M),c,1)/h;const T=Ot._round(o*E),P=Ot._round(h*S);b=u(...p(T,P));const _=v-b[0],R=y-b[1];this.#Se||=[this.x,this.y,this.width,this.height],this.width=T,this.height=P,this.x=_,this.y=R,this.setDims(i*T,s*P),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#h?.finish()}async addEditToolbar(){return this._editToolbar||this.#Ce||(this._editToolbar=new St(this),this.div.append(this._editToolbar.render()),this.#h&&await this._editToolbar.addAltText(this.#h)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#h?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#h||(Dt.initialize(Ot._l10n),this.#h=new Dt(this),this.#fe&&(this.#h.data=this.#fe,this.#fe=null),await this.addEditToolbar())}get altTextData(){return this.#h?.data}set altTextData(t){this.#h&&(this.#h.data=t)}get guessedAltText(){return this.#h?.guessedText}async setGuessedAltText(t){await(this.#h?.setGuessedText(t))}serializeAltText(t){return this.#h?.serialize(t)}hasAltText(){return!!this.#h&&!this.#h.isEmpty()}hasAltTextData(){return this.#h?.hasData()??!1}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.#ge?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#We();const[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[s,n]=this.getInitialTranslation();return this.translate(s,n),Ct(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Ie||=new Ft({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#Ve.bind(this),onPinching:this.#Xe.bind(this),onPinchEnd:this.#Ye.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),t}#Ve(){this.#ye={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#h?.toggle(!1),this.parent.togglePointerEvents(!1)}#Xe(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#Be(this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[o,h]=this.parentDimensions,a=this.x,c=this.y,l=this.width,u=this.height,d=Ot.MIN_SIZE/o,f=Ot.MIN_SIZE/h;s=Math.max(Math.min(s,1/l,1/u),d/l,f/u);const p=Ot._round(l*s),g=Ot._round(u*s);if(p===l&&g===u)return;this.#Se||=[a,c,l,u];const m=r(l/2,u/2),w=Ot._round(a+m[0]),A=Ot._round(c+m[1]),b=r(p/2,g/2);this.x=w-b[0],this.y=A-b[1],this.width=p,this.height=g,this.setDims(o*p,h*g),this.fixAndSetPosition(),this._onResizing()}#Ye(){this.#h?.toggle(!0),this.parent.togglePointerEvents(!0),this.#He()}pointerdown(t){const{isMac:e}=Y.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#Ee=!0,this._isDraggable?this.#qe(t):this.#Qe(t))}#Qe(t){const{isMac:e}=Y.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#qe(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},o=t=>{s.abort(),this.#me=null,this.#Ee=!1,this._uiManager.endDragSession()||this.#Qe(t),i&&this._onStopDragging()};e&&(this.#_e=t.clientX,this.#Re=t.clientY,this.#me=t.pointerId,this.#we=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#me)return void mt(t);const[r,o]=this.screenToPageTranslation(e-this.#_e,s-this.#Re);this.#_e=e,this.#Re=s,this._uiManager.dragSelectedEditors(r,o)}),r),window.addEventListener("touchmove",mt,r),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#we&&(this.#Ie||t.isPrimary)&&o(t),mt(t)}),r));const h=t=>{this.#me&&this.#me!==t.pointerId?mt(t):o(t)};window.addEventListener("pointerup",h,{signal:n}),window.addEventListener("blur",h,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Pe&&clearTimeout(this.#Pe),this.#Pe=setTimeout((()=>{this.#Pe=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[o,h]=this.pageTranslation,a=t/s,c=e/s,l=this.x*n,u=this.y*r,d=this.width*n,f=this.height*r;switch(i){case 0:return[l+a+o,r-u-c-f+h,l+a+d+o,r-u-c+h];case 90:return[l+c+o,r-u+a+h,l+c+f+o,r-u+a+d+h];case 180:return[l-a-d+o,r-u+c+h,l-a+o,r-u+c+f+h];case 270:return[l-c-f+o,r-u-a-d+h,l-c+o,r-u-a+h];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,o=n-i,h=r-s;switch(this.rotation){case 0:return[i,e-r,o,h];case 90:return[i,e-s,h,o];case 180:return[n,e-s,o,h];case 270:return[n,e-r,h,o];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#Ce=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#Ce=!1,!0)}isInEditMode(){return this.#Ce}shouldGetKeyboardEvents(){return this.#Te}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#We(){if(this.#xe||!this.div)return;this.#xe=new AbortController;const t=this._uiManager.combinedSignal(this.#xe);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#We()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){D("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#fe=t.accessibilityData,s._isCopy=t.isCopy||!1;const[n,r]=s.pageDimensions,[o,h,a,c]=s.getRectInCurrentCoords(t.rect,r);return s.x=o/n,s.y=h/r,s.width=a/n,s.height=c/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#xe?.abort(),this.#xe=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Pe&&(clearTimeout(this.#Pe),this.#Pe=null),this.#Oe(),this.removeEditToolbar(),this.#Ne){for(const t of this.#Ne.values())clearTimeout(t);this.#Ne=null}this.parent=null,this.#Ie?.destroy(),this.#Ie=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#Ue(),this.#be.classList.remove("hidden"))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#ye={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#be.children;if(!this.#pe){this.#pe=Array.from(e);const t=this.#Ke.bind(this),i=this.#Je.bind(this),s=this._uiManager._signal;for(const e of this.#pe){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Ze.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",Ot._l10nResizer[n])}}const i=this.#pe[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#pe.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#be.append(this.#be.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#be.firstChild.before(this.#be.lastChild);let t=0;for(const i of e){const e=this.#pe[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",Ot._l10nResizer[e])}}this.#ti(0),this.#Te=!0,this.#be.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#Ke(t){Ot._resizerKeyboardManager.exec(this,t)}#Je(t){this.#Te&&t.relatedTarget?.parentNode!==this.#be&&this.#Oe()}#Ze(t){this.#Me=this.#Te?t:""}#ti(t){if(this.#pe)for(const e of this.#pe)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Te&&this.#ze(this.#Me,{deltaX:t,deltaY:e,fromKeyboard:!0})}#Oe(){this.#Te=!1,this.#ti(-1),this.#He()}_stopResizingWithKeyboard(){this.#Oe(),this.div.focus()}select(){this.isSelected&&this._editToolbar||(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#h?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})))}unselect(){this.isSelected&&(this.isSelected=!1,this.#be?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#h?.toggleAltTextBadge(!0))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#ke}set isEditing(t){this.#ke=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#Ae=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}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.#Ne||=new Map;const{action:e}=t;let i=this.#Ne.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#Ne.delete(e),0===this.#Ne.size&&(this.#Ne=null)}),Ot._telemetryTimeout),void this.#Ne.set(e,i)}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.#ge=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ge=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class $t extends Ot{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Lt=3285377520,Bt=4294901760,Ut=65535;class jt{constructor(t){this.h1=t?4294967295&t:Lt,this.h2=t?4294967295&t:Lt}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s);let o=0,h=0,a=this.h1,c=this.h2;const l=3432918353,u=461845907,d=11601,f=13715;for(let t=0;t<s;t++)1&t?(o=r[t],o=o*l&Bt|o*d&Ut,o=o<<15|o>>>17,o=o*u&Bt|o*f&Ut,a^=o,a=a<<13|a>>>19,a=5*a+3864292196):(h=r[t],h=h*l&Bt|h*d&Ut,h=h<<15|h>>>17,h=h*u&Bt|h*f&Ut,c^=h,c=c<<13|c>>>19,c=5*c+3864292196);switch(o=0,n){case 3:o^=e[4*s+2]<<16;case 2:o^=e[4*s+1]<<8;case 1:o^=e[4*s],o=o*l&Bt|o*d&Ut,o=o<<15|o>>>17,o=o*u&Bt|o*f&Ut,1&s?a^=o:c^=o}this.h1=a,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&Bt|36045*t&Ut,e=4283543511*e&Bt|(2950163797*(e<<16|t>>>16)&Bt)>>>16,t^=e>>>1,t=444984403*t&Bt|60499*t&Ut,e=3301882366*e&Bt|(3120437893*(e<<16|t>>>16)&Bt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const zt=Object.freeze({map:null,hash:"",transfer:void 0});class Ht{#ei=!1;#ii=null;#si=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#si.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#si.get(t)}remove(t){if(this.#si.delete(t),0===this.#si.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#si.values())if(t instanceof Ot)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#si.get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#si.set(t,e);s&&this.#ni(),e instanceof Ot&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#si.has(t)}get size(){return this.#si.size}#ni(){this.#ei||(this.#ei=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#ei&&(this.#ei=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Gt(this)}get serializable(){if(0===this.#si.size)return zt;const t=new Map,e=new jt,i=[],s=Object.create(null);let n=!1;for(const[i,r]of this.#si){const o=r instanceof Ot?r.serialize(!1,s):r;o&&(t.set(i,o),e.update(`${i}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:zt}get editorStats(){let t=null;const e=new Map;for(const i of this.#si.values()){if(!(i instanceof Ot))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=r.get(t);i||(i=new Map,r.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#ii=null}get modifiedIds(){if(this.#ii)return this.#ii;const t=[];for(const e of this.#si.values())e instanceof Ot&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#ii={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#si.entries()}}class Gt extends Ht{#ri;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ri={map:n,hash:i,transfer:s}}get print(){D("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ri}get modifiedIds(){return L(this,"modifiedIds",{ids:new Set,hash:""})}}class Wt{#oi=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.#oi.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!this.#oi.has(t.loadedName))if(F(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:s,style:n}=t,r=new FontFace(e,s,n);this.addNativeFontFace(r);try{await r.load(),this.#oi.add(e),i?.(t)}catch{I(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else D("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw I(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){return L(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return L(this,"isSyncFontLoadingSupported",w||Y.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(F(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return L(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,r;const o=this._document.createElement("canvas");o.width=1,o.height=1;const h=o.getContext("2d");let a=0;const c=`lt${Date.now()}${this.loadTestFontId++}`;let l=this._loadTestFont;l=s(l,976,c.length,c);const u=1482184792;let d=i(l,16);for(n=0,r=c.length-3;n<r;n+=4)d=d-u+i(c,n)|0;var f;n<c.length&&(d=d-u+i(c+"XXX",n)|0),l=s(l,16,4,(f=d,String.fromCharCode(f>>24&255,f>>16&255,f>>8&255,255&f)));const p=`url(data:font/opentype;base64,${btoa(l)});`;this.insertRule(`@font-face {font-family:"${c}";src:${p}}`);const g=this._document.createElement("div");g.style.visibility="hidden",g.style.width=g.style.height="10px",g.style.position="absolute",g.style.top=g.style.left="0px";for(const e of[t.loadedName,c]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,g.append(t)}this._document.body.append(g),function t(e,i){if(++a>30)return I("Load test font never loaded."),void i();h.font="30px "+e,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(c,(()=>{g.remove(),e.complete()}))}}class Vt{constructor(t,e=null){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this._inspectFont=e}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){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)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${st(this.data)});`;let e;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(t){I(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}function Xt(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const Yt=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,qt=function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;const[s,n,...r]=i;if(!t(s)&&!Number.isInteger(s))return!1;if(!e(n))return!1;const o=r.length;let h=!0;switch(n.name){case"XYZ":if(o<2||o>3)return!1;break;case"Fit":case"FitB":return 0===o;case"FitH":case"FitBH":case"FitV":case"FitBV":if(o>1)return!1;break;case"FitR":if(4!==o)return!1;h=!1;break;default:return!1}for(const t of r)if(!("number"==typeof t||h&&null===t))return!1;return!0}.bind(null,Yt,(t=>"object"==typeof t&&"string"==typeof t?.name));class Qt{#hi=new Map;#ai=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#ai.then((()=>{for(const[t]of this.#hi)t.call(this,i)}))}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void I("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#hi.set(e,s)}removeEventListener(t,e){const i=this.#hi.get(e);i?.(),this.#hi.delete(e)}terminate(){for(const[,t]of this.#hi)t?.();this.#hi.clear()}}function Kt(){}function Jt(t){if(t instanceof W||t instanceof z||t instanceof U||t instanceof H||t instanceof j)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||D('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new W(t.message);case"InvalidPDFException":return new z(t.message);case"PasswordException":return new U(t.message,t.code);case"ResponseException":return new H(t.message,t.status,t.missing);case"UnknownErrorException":return new j(t.message,t.details)}return new j(t.message,t.toString())}class Zt{#ci=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",this.#li.bind(this),{signal:this.#ci.signal})}#li({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ui(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else{if(2!==t.callback)throw new Error("Unexpected callback case");i.reject(Jt(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then((function(e){n.postMessage({sourceName:i,targetName:s,callback:1,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:2,callbackId:t.callbackId,reason:Jt(e)})}))}else t.streamId?this.#di(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,o=this.targetName,h=this.comObj;return new ReadableStream({start:i=>{const a=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:a,pullCall:null,cancelCall:null,isClosed:!1},h.postMessage({sourceName:r,targetName:o,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),a.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,h.postMessage({sourceName:r,targetName:o,stream:6,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{F(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,h.postMessage({sourceName:r,targetName:o,stream:1,streamId:n,reason:Jt(t)}),e.promise}},i)}#di(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,o=this.actionHandler[t.action],h={enqueue(t,r=1,o){if(this.isCancelled)return;const h=this.desiredSize;this.desiredSize-=r,h>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:4,streamId:e,chunk:t},o)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:3,streamId:e}),delete r.streamSinks[e])},error(t){F(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:5,streamId:e,reason:Jt(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};h.sinkCapability.resolve(),h.ready=h.sinkCapability.promise,this.streamSinks[e]=h,Promise.try(o,t.data,h).then((function(){n.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,reason:Jt(t)})}))}#ui(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case 8:t.success?r.startCall.resolve():r.startCall.reject(Jt(t.reason));break;case 7:t.success?r.pullCall.resolve():r.pullCall.reject(Jt(t.reason));break;case 6:if(!o){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||Kt).then((function(){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,reason:Jt(t)})}));break;case 4:if(F(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case 3:if(F(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#fi(r,e);break;case 5:F(r,"error should have stream controller"),r.controller.error(Jt(t.reason)),this.#fi(r,e);break;case 2:t.success?r.cancelCall.resolve():r.cancelCall.reject(Jt(t.reason)),this.#fi(r,e);break;case 1:if(!o)break;const h=Jt(t.reason);Promise.try(o.onCancel||Kt,h).then((function(){n.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,reason:Jt(t)})})),o.sinkCapability.reject(h),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#fi(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#ci?.abort(),this.#ci=null}}class te{#pi=!1;constructor({enableHWA:t=!1}){this.#pi=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#pi})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){D("Abstract method `_createCanvas` called.")}}class ee extends te{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class ie{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then((t=>({cMapData:t,isCompressed:this.isCompressed}))).catch((()=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}async _fetch(t){D("Abstract method `_fetch` called.")}}class se extends ie{async _fetch(t){const e=await ot(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):X(e)}}m(2489);class ne{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class re extends ne{#gi;#mi;#wi;#Ai;#bi;#vi;#v=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#Ai=t,this.#bi=e}get#x(){return this.#mi||=new Map}get#yi(){return this.#vi||=new Map}get#xi(){if(!this.#wi){const t=this.#bi.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 i=this.#bi.createElementNS(nt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#wi=this.#bi.createElementNS(nt,"defs"),t.append(i),i.append(this.#wi),this.#bi.body.append(t)}return this.#wi}#Mi(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),r=new Array(256),o=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,r[t]=i[t]/255,o[t]=s[t]/255;return[n.join(","),r.join(","),o.join(",")]}#Ei(t){if(void 0===this.#gi){this.#gi="";const t=this.#bi.URL;t!==this.#bi.baseURI&&(ct(t)?I('#createUrl: ignore "data:"-URL for performance reasons.'):this.#gi=$(t,""))}return`url(${this.#gi}#${t})`}addFilter(t){if(!t)return"none";let e=this.#x.get(t);if(e)return e;const[i,s,n]=this.#Mi(t),r=1===t.length?i:`${i}${s}${n}`;if(e=this.#x.get(r),e)return this.#x.set(t,e),e;const o=`g_${this.#Ai}_transfer_map_${this.#v++}`,h=this.#Ei(o);this.#x.set(t,h),this.#x.set(r,h);const a=this.#Si(o);return this.#ki(i,s,n,a),h}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#yi.get(s);if(n?.key===i)return n.url;if(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#yi.set(s,n)),!t||!e)return n.url;const r=this.#Ci(t);t=Q.makeHexColor(...r);const o=this.#Ci(e);if(e=Q.makeHexColor(...o),this.#xi.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const h=new Array(256);for(let t=0;t<=255;t++){const e=t/255;h[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const a=h.join(","),c=`g_${this.#Ai}_hcm_filter`,l=n.filter=this.#Si(c);this.#ki(a,a,a,l),this.#Ti(l);const u=(t,e)=>{const i=r[t]/255,s=o[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#ki(u(0,5),u(1,5),u(2,5),l),n.url=this.#Ei(c),n.url}addAlphaFilter(t){let e=this.#x.get(t);if(e)return e;const[i]=this.#Mi([t]),s=`alpha_${i}`;if(e=this.#x.get(s),e)return this.#x.set(t,e),e;const n=`g_${this.#Ai}_alpha_map_${this.#v++}`,r=this.#Ei(n);this.#x.set(t,r),this.#x.set(s,r);const o=this.#Si(n);return this.#Pi(i,o),r}addLuminosityFilter(t){let e,i,s=this.#x.get(t||"luminosity");if(s)return s;if(t?([e]=this.#Mi([t]),i=`luminosity_${e}`):i="luminosity",s=this.#x.get(i),s)return this.#x.set(t,s),s;const n=`g_${this.#Ai}_luminosity_map_${this.#v++}`,r=this.#Ei(n);this.#x.set(t,r),this.#x.set(i,r);const o=this.#Si(n);return this.#_i(o),t&&this.#Pi(e,o),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let o=this.#yi.get(t);if(o?.key===r)return o.url;if(o?(o.filter?.remove(),o.key=r,o.url="none",o.filter=null):(o={key:r,url:"none",filter:null},this.#yi.set(t,o)),!e||!i)return o.url;const[h,a]=[e,i].map(this.#Ci.bind(this));let c=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),l=Math.round(.2126*a[0]+.7152*a[1]+.0722*a[2]),[u,d]=[s,n].map(this.#Ci.bind(this));l<c&&([c,l,u,d]=[l,c,d,u]),this.#xi.style.color="";const f=(t,e,i)=>{const s=new Array(256),n=(l-c)/i,r=t/255,o=(e-t)/(255*i);let h=0;for(let t=0;t<=i;t++){const e=Math.round(c+t*n),i=r+t*o;for(let t=h;t<=e;t++)s[t]=i;h=e+1}for(let t=h;t<256;t++)s[t]=s[h-1];return s.join(",")},p=`g_${this.#Ai}_hcm_${t}_filter`,g=o.filter=this.#Si(p);return this.#Ti(g),this.#ki(f(u[0],d[0],5),f(u[1],d[1],5),f(u[2],d[2],5),g),o.url=this.#Ei(p),o.url}destroy(t=!1){t&&this.#vi?.size||(this.#wi?.parentNode.parentNode.remove(),this.#wi=null,this.#mi?.clear(),this.#mi=null,this.#vi?.clear(),this.#vi=null,this.#v=0)}#_i(t){const e=this.#bi.createElementNS(nt,"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)}#Ti(t){const e=this.#bi.createElementNS(nt,"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)}#Si(t){const e=this.#bi.createElementNS(nt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#xi.append(e),e}#Ri(t,e,i){const s=this.#bi.createElementNS(nt,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#ki(t,e,i,s){const n=this.#bi.createElementNS(nt,"feComponentTransfer");s.append(n),this.#Ri(n,"feFuncR",t),this.#Ri(n,"feFuncG",e),this.#Ri(n,"feFuncB",i)}#Pi(t,e){const i=this.#bi.createElementNS(nt,"feComponentTransfer");e.append(i),this.#Ri(i,"feFuncA",t)}#Ci(t){return this.#xi.style.color=t,bt(getComputedStyle(this.#xi).getPropertyValue("color"))}}class oe{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((()=>{throw new Error(`Unable to load font data at: ${e}`)}))}async _fetch(t){D("Abstract method `_fetch` called.")}}class he extends oe{async _fetch(t){const e=await ot(t,"arraybuffer");return new Uint8Array(e)}}class ae{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((()=>{throw new Error(`Unable to load wasm data at: ${e}`)}))}async _fetch(t){D("Abstract method `_fetch` called.")}}class ce extends ae{async _fetch(t){const e=await ot(t,"arraybuffer");return new Uint8Array(e)}}if(w){let t;try{const e=process.getBuiltinModule("module").createRequire(import.meta.url);try{t=e("@napi-rs/canvas")}catch(t){I(`Cannot load "@napi-rs/canvas" package: "${t}".`)}}catch(t){I(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(t?.DOMMatrix?globalThis.DOMMatrix=t.DOMMatrix:I("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(t?.ImageData?globalThis.ImageData=t.ImageData:I("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(t?.Path2D?globalThis.Path2D=t.Path2D:I("Cannot polyfill `Path2D`, rendering may be broken.")),globalThis.navigator?.language||(globalThis.navigator={language:"en-US",platform:"",userAgent:""})}async function le(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}class ue extends ne{}class de extends te{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class fe extends ie{async _fetch(t){return le(t)}}class pe extends oe{async _fetch(t){return le(t)}}class ge extends ae{async _fetch(t){return le(t)}}const me="Fill",we="Stroke",Ae="Shading";function be(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class ve{isModifyingCurrentTransform(){return!1}getPattern(){D("Abstract method `getPattern` called.")}}class ye extends ve{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,i,s){let n;if(s===we||s===me){const r=e.current.getClippedPathBoundingBox(s,vt(t))||[0,0,0,0],o=Math.ceil(r[2]-r[0])||1,h=Math.ceil(r[3]-r[1])||1,a=e.cachedCanvases.getCanvas("pattern",o,h),c=a.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(-r[0],-r[1]),i=Q.transform(i,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),be(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),n=t.createPattern(a.canvas,"no-repeat");const l=new DOMMatrix(i);n.setTransform(l)}else be(t,this._bbox),n=this._createGradient(t);return n}}function xe(t,e,i,s,n,r,o,h){const a=e.coords,c=e.colors,l=t.data,u=4*t.width;let d;a[i+1]>a[s+1]&&(d=i,i=s,s=d,d=r,r=o,o=d),a[s+1]>a[n+1]&&(d=s,s=n,n=d,d=o,o=h,h=d),a[i+1]>a[s+1]&&(d=i,i=s,s=d,d=r,r=o,o=d);const f=(a[i]+e.offsetX)*e.scaleX,p=(a[i+1]+e.offsetY)*e.scaleY,g=(a[s]+e.offsetX)*e.scaleX,m=(a[s+1]+e.offsetY)*e.scaleY,w=(a[n]+e.offsetX)*e.scaleX,A=(a[n+1]+e.offsetY)*e.scaleY;if(p>=A)return;const b=c[r],v=c[r+1],y=c[r+2],x=c[o],M=c[o+1],E=c[o+2],S=c[h],k=c[h+1],C=c[h+2],T=Math.round(p),P=Math.round(A);let _,R,N,I,D,F,O,$;for(let t=T;t<=P;t++){if(t<m){const e=t<p?0:(p-t)/(p-m);_=f-(f-g)*e,R=b-(b-x)*e,N=v-(v-M)*e,I=y-(y-E)*e}else{let e;e=t>A?1:m===A?0:(m-t)/(m-A),_=g-(g-w)*e,R=x-(x-S)*e,N=M-(M-k)*e,I=E-(E-C)*e}let e;e=t<p?0:t>A?1:(p-t)/(p-A),D=f-(f-w)*e,F=b-(b-S)*e,O=v-(v-k)*e,$=y-(y-C)*e;const i=Math.round(Math.min(_,D)),s=Math.round(Math.max(_,D));let n=u*t+4*i;for(let t=i;t<=s;t++)e=(_-t)/(_-D),e<0?e=0:e>1&&(e=1),l[n++]=R-(R-F)*e|0,l[n++]=N-(N-O)*e|0,l[n++]=I-(I-$)*e|0,l[n++]=255}}function Me(t,e,i){const s=e.coords,n=e.colors;let r,o;switch(e.type){case"lattice":const h=e.verticesPerRow,a=Math.floor(s.length/h)-1,c=h-1;for(r=0;r<a;r++){let e=r*h;for(let r=0;r<c;r++,e++)xe(t,i,s[e],s[e+1],s[e+h],n[e],n[e+1],n[e+h]),xe(t,i,s[e+h+1],s[e+1],s[e+h],n[e+h+1],n[e+1],n[e+h])}break;case"triangles":for(r=0,o=s.length;r<o;r+=3)xe(t,i,s[r],s[r+1],s[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class Ee extends ve{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,o=Math.ceil(this._bounds[3])-n,h=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),a=Math.min(Math.ceil(Math.abs(o*t[1]*1.1)),3e3),c=r/h,l=o/a,u={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/c,scaleY:1/l},d=i.getCanvas("mesh",h+4,a+4),f=d.context,p=f.createImageData(h,a);if(e){const t=p.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const t of this._figures)Me(p,t,u);return f.putImageData(p,2,2),{canvas:d.canvas,offsetX:s-2*c,offsetY:n-2*l,scaleX:c,scaleY:l}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){be(t,this._bbox);const n=new Float32Array(2);if(s===Ae)Q.singularValueDecompose2dScale(vt(t),n);else if(this.matrix){Q.singularValueDecompose2dScale(this.matrix,n);const[t,i]=n;Q.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=i}else Q.singularValueDecompose2dScale(e.baseTransform,n);const r=this._createMeshCanvas(n,s===Ae?null:this._background,e.cachedCanvases);return s!==Ae&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class Se extends ve{getPattern(){return"hotpink"}}class ke{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:r,canvasGraphicsFactory:o}=this;let{xstep:h,ystep:a}=this;h=Math.abs(h),a=Math.abs(a),N("TilingType: "+n);const c=e[0],l=e[1],u=e[2],d=e[3],f=u-c,p=d-l,g=new Float32Array(2);Q.singularValueDecompose2dScale(this.matrix,g);const[m,w]=g;Q.singularValueDecompose2dScale(this.baseTransform,g);const A=m*g[0],b=w*g[1];let v=f,y=p,x=!1,M=!1;const E=Math.ceil(h*A),S=Math.ceil(a*b);E>=Math.ceil(f*A)?v=h:x=!0,S>=Math.ceil(p*b)?y=a:M=!0;const k=this.getSizeAndScale(v,this.ctx.canvas.width,A),C=this.getSizeAndScale(y,this.ctx.canvas.height,b),T=t.cachedCanvases.getCanvas("pattern",k.size,C.size),P=T.context,_=o.createCanvasGraphics(P);if(_.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(_,s,r),P.translate(-k.scale*c,-C.scale*l),_.transform(k.scale,0,0,C.scale,0,0),P.save(),this.clipBbox(_,c,l,u,d),_.baseTransform=vt(_.ctx),_.executeOperatorList(i),_.endDrawing(),P.restore(),x||M){const e=T.canvas;x&&(v=h),M&&(y=a);const i=this.getSizeAndScale(v,this.ctx.canvas.width,A),s=this.getSizeAndScale(y,this.ctx.canvas.height,b),n=i.size,r=s.size,o=t.cachedCanvases.getCanvas("pattern-workaround",n,r),u=o.context,d=x?Math.floor(f/h):0,g=M?Math.floor(p/a):0;for(let t=0;t<=d;t++)for(let i=0;i<=g;i++)u.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:o.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:c,offsetY:l}}return{canvas:T.canvas,scaleX:k.scale,scaleY:C.scale,offsetX:c,offsetY:l}}getSizeAndScale(t,e,i){const s=Math.max(ke.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){t.ctx.rect(e,i,s-e,n-i),Q.axialAlignedBoundingBox([e,i,s,n],vt(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case 1:const{fillStyle:t,strokeStyle:r}=this.ctx;s.fillStyle=n.fillColor=t,s.strokeStyle=n.strokeColor=r;break;case 2:s.fillStyle=s.strokeStyle=i,n.fillColor=n.strokeColor=i;break;default:throw new G(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s){let n=i;s!==Ae&&(n=Q.transform(n,e.baseTransform),this.matrix&&(n=Q.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let o=new DOMMatrix(n);o=o.translate(r.offsetX,r.offsetY),o=o.scale(1/r.scaleX,1/r.scaleY);const h=t.createPattern(r.canvas,"repeat");return h.setTransform(o),h}}function Ce({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:o=!1}){const h=Y.isLittleEndian?4278190080:255,[a,c]=o?[r,h]:[h,r],l=s>>3,u=7&s,d=t.length;i=new Uint32Array(i.buffer);let f=0;for(let s=0;s<n;s++){for(const s=e+l;e<s;e++){const s=e<d?t[e]:255;i[f++]=128&s?c:a,i[f++]=64&s?c:a,i[f++]=32&s?c:a,i[f++]=16&s?c:a,i[f++]=8&s?c:a,i[f++]=4&s?c:a,i[f++]=2&s?c:a,i[f++]=1&s?c:a}if(0===u)continue;const s=e<d?t[e++]:255;for(let t=0;t<u;t++)i[f++]=s&1<<7-t?c:a}return{srcPos:e,destPos:f}}const Te=16,Pe=new DOMMatrix,_e=new Float32Array(2),Re=new Float32Array([1/0,1/0,-1/0,-1/0]);class Ne{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache)this.canvasFactory.destroy(this.cache[t]),delete this.cache[t]}}function Ie(t,e,i,s,n,r,o,h,a,c){const[l,u,d,f,p,g]=vt(t);if(0===u&&0===d){const m=Math.round(o*l+p),w=Math.round(h*f+g),A=Math.abs(Math.round((o+a)*l+p)-m)||1,b=Math.abs(Math.round((h+c)*f+g)-w)||1;return t.setTransform(Math.sign(l),0,0,Math.sign(f),m,w),t.drawImage(e,i,s,n,r,0,0,A,b),t.setTransform(l,u,d,f,p,g),[A,b]}if(0===l&&0===f){const m=Math.round(h*d+p),w=Math.round(o*u+g),A=Math.abs(Math.round((h+c)*d+p)-m)||1,b=Math.abs(Math.round((o+a)*u+g)-w)||1;return t.setTransform(0,Math.sign(u),Math.sign(d),0,m,w),t.drawImage(e,i,s,n,r,0,0,b,A),t.setTransform(l,u,d,f,p,g),[b,A]}return t.drawImage(e,i,s,n,r,o,h,a,c),[Math.hypot(l,u)*a,Math.hypot(d,f)*c]}class De{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=A;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e){this.clipBox=new Float32Array([0,0,t,e]),this.minMax=Re.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=me,e=null){const i=this.minMax.slice();if(t===we){e||D("Stroke bounding box must include transform."),Q.singularValueDecompose2dScale(e,_e);const t=_e[0]*this.lineWidth/2,s=_e[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){const t=Q.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(Re,0)}getClippedPathBoundingBox(t=me,e=null){return Q.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Fe(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%Te,r=(i-n)/Te,o=0===n?r:r+1,h=t.createImageData(s,Te);let a,c=0;const l=e.data,u=h.data;let d,f,p,g;if(e.kind===E.GRAYSCALE_1BPP){const e=l.byteLength,i=new Uint32Array(u.buffer,0,u.byteLength>>2),g=i.length,m=s+7>>3,w=4294967295,A=Y.isLittleEndian?4278190080:255;for(d=0;d<o;d++){for(p=d<r?Te:n,a=0,f=0;f<p;f++){const t=e-c;let n=0;const r=t>m?s:8*t-7,o=-8&r;let h=0,u=0;for(;n<o;n+=8)u=l[c++],i[a++]=128&u?w:A,i[a++]=64&u?w:A,i[a++]=32&u?w:A,i[a++]=16&u?w:A,i[a++]=8&u?w:A,i[a++]=4&u?w:A,i[a++]=2&u?w:A,i[a++]=1&u?w:A;for(;n<r;n++)0===h&&(u=l[c++],h=128),i[a++]=u&h?w:A,h>>=1}for(;a<g;)i[a++]=0;t.putImageData(h,0,d*Te)}}else if(e.kind===E.RGBA_32BPP){for(f=0,g=s*Te*4,d=0;d<r;d++)u.set(l.subarray(c,c+g)),c+=g,t.putImageData(h,0,f),f+=Te;d<o&&(g=s*n*4,u.set(l.subarray(c,c+g)),t.putImageData(h,0,f))}else{if(e.kind!==E.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(p=Te,g=s*p,d=0;d<o;d++){for(d>=r&&(p=n,g=s*p),a=0,f=g;f--;)u[a++]=l[c++],u[a++]=l[c++],u[a++]=l[c++],u[a++]=255;t.putImageData(h,0,d*Te)}}}function Oe(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%Te,r=(i-n)/Te,o=0===n?r:r+1,h=t.createImageData(s,Te);let a=0;const c=e.data,l=h.data;for(let e=0;e<o;e++){const i=e<r?Te:n;({srcPos:a}=Ce({src:c,srcPos:a,dest:l,width:s,height:i,nonBlackColor:0})),t.putImageData(h,0,e*Te)}}function $e(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function Le(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function Be(t,e){if(e)return!0;Q.singularValueDecompose2dScale(t,_e);const i=Math.fround(Mt.pixelRatio*rt.PDF_TO_CSS_UNITS);return _e[0]<=i&&_e[1]<=i}const Ue=["butt","round","square"],je=["miter","round","bevel"],ze={},He={};class Ge{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:o=null},h,a){this.ctx=t,this.current=new De(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=r,this.cachedCanvases=new Ne(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=h,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=a,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=o,i){const t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...vt(this.compositeCtx))}this.ctx.save(),Le(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=vt(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,r=t.fnArray;let o=e||0;const h=n.length;if(h===o)return o;const a=h-o>10&&"function"==typeof i,c=a?Date.now()+15:0;let l=0;const u=this.commonObjs,d=this.objs;let f;for(;;){if(void 0!==s&&o===s.nextBreakPoint)return s.breakIt(o,i),o;if(f=r[o],f!==C.dependency)this[f].apply(this,n[o]);else for(const t of n[o]){const e=t.startsWith("g_")?u:d;if(!e.has(t))return e.get(t,i),o}if(o++,o===h)return o;if(a&&++l>10){if(Date.now()>c)return i(),o;l=0}}}#Ni(){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.#Ni(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#Ii()}#Ii(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,r,o=Math.max(Math.hypot(e[0],e[1]),1),h=Math.max(Math.hypot(e[2],e[3]),1),a=i,c=s,l="prescale1";for(;o>2&&a>1||h>2&&c>1;){let e=a,i=c;o>2&&a>1&&(e=a>=16384?Math.floor(a/2)-1||1:Math.ceil(a/2),o/=a/e),h>2&&c>1&&(i=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,h/=c/i),n=this.cachedCanvases.getCanvas(l,e,i),r=n.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,a,c,0,0,e,i),t=n.canvas,a=e,c=i,l="prescale1"===l?"prescale2":"prescale1"}return{img:t,paintWidth:a,paintHeight:c}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,r=this.current.patternFill,o=vt(e);let h,a,c,l;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;a=JSON.stringify(r?o:[o.slice(0,4),n]),h=this._cachedBitmapsMap.get(e),h||(h=new Map,this._cachedBitmapsMap.set(e,h));const i=h.get(a);if(i&&!r)return{canvas:i,offsetX:Math.round(Math.min(o[0],o[2])+o[4]),offsetY:Math.round(Math.min(o[1],o[3])+o[5])};c=i}c||(l=this.cachedCanvases.getCanvas("maskCanvas",i,s),Oe(l.context,t));let u=Q.transform(o,[1/i,0,0,-1/s,0,0]);u=Q.transform(u,[1,0,0,1,0,-s]);const d=Re.slice();Q.axialAlignedBoundingBox([0,0,i,s],u,d);const[f,p,g,m]=d,w=Math.round(g-f)||1,A=Math.round(m-p)||1,b=this.cachedCanvases.getCanvas("fillCanvas",w,A),v=b.context,y=f,x=p;v.translate(-y,-x),v.transform(...u),c||(c=this._scaleImage(l.canvas,yt(v)),c=c.img,h&&r&&h.set(a,c)),v.imageSmoothingEnabled=Be(vt(v),t.interpolate),Ie(v,c,0,0,c.width,c.height,0,0,i,s),v.globalCompositeOperation="source-in";const M=Q.transform(yt(v),[1,0,0,1,-y,-x]);return v.fillStyle=r?n.getPattern(e,this,M,me):n,v.fillRect(0,0,i,s),h&&!r&&(this.cachedCanvases.delete("fillCanvas"),h.set(a,b.canvas)),{canvas:b.canvas,offsetX:Math.round(y),offsetY:Math.round(x)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Ue[t]}setLineJoin(t){this.ctx.lineJoin=je[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.ctx.globalAlpha=this.current.fillAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.cachedCanvases.getCanvas("smaskGroupAt"+this.groupLevel,this.ctx.canvas.width,this.ctx.canvas.height);this.suspendedCtx=this.ctx;const e=this.ctx=t.context;e.setTransform(this.suspendedCtx.getTransform()),$e(this.suspendedCtx,e),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,r,o){e.transform(t,i,s,n,r,o),this.__originalTransform(t,i,s,n,r,o)},t.setTransform=function(t,i,s,n,r,o){e.setTransform(t,i,s,n,r,o),this.__originalSetTransform(t,i,s,n,r,o)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,r,o){e.bezierCurveTo(t,i,s,n,r,o),this.__originalBezierCurveTo(t,i,s,n,r,o)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(e,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),$e(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){this.current.activeSMask&&(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],this.composeSMask(this.suspendedCtx,this.current.activeSMask,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,i,s){const n=s[0],r=s[1],o=s[2]-n,h=s[3]-r;0!==o&&0!==h&&(this.genericComposeSMask(e.context,i,o,h,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,o,h,a,c,l){let u=t.canvas,d=h-c,f=a-l;if(r)if(d<0||f<0||d+i>u.width||f+s>u.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),e=t.context;e.drawImage(u,-d,-f),e.globalCompositeOperation="destination-atop",e.fillStyle=r,e.fillRect(0,0,i,s),e.globalCompositeOperation="source-over",u=t.canvas,d=f=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(d,f,i,s),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=r,t.fillRect(d,f,i,s),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&o?e.filter=this.filterFactory.addAlphaFilter(o):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(o));const p=new Path2D;p.rect(h,a,i,s),e.clip(p),e.globalCompositeOperation="destination-in",e.drawImage(u,d,f,i,s,h,a,i,s),e.restore()}save(){this.inSMaskMode&&$e(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&$e(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,s,n,r){this.ctx.transform(t,e,i,s,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){let[s]=e;if(!i)return s||=e[0]=new Path2D,void this[t](s);if(!(s instanceof Path2D)){const t=e[0]=new Path2D;for(let e=0,i=s.length;e<i;)switch(s[e++]){case 0:t.moveTo(s[e++],s[e++]);break;case 1:t.lineTo(s[e++],s[e++]);break;case 2:t.bezierCurveTo(s[e++],s[e++],s[e++],s[e++],s[e++],s[e++]);break;case 3:t.closePath();break;default:I(`Unrecognized drawing path operator: ${s[e-1]}`)}s=t}Q.axialAlignedBoundingBox(i,vt(this.ctx),this.current.minMax),this[t](s)}closePath(){this.ctx.closePath()}stroke(t,e=!0){const i=this.ctx,s=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof s&&s?.getPattern){const e=s.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=s.getPattern(i,this,yt(i),we),e){const s=new Path2D;s.addPath(t,i.getTransform().invertSelf().multiplySelf(e)),t=s}this.rescaleAndStroke(t,!1),i.restore()}else this.rescaleAndStroke(t,!0);e&&this.consumePath(t,this.current.getClippedPathBoundingBox(we,vt(this.ctx))),i.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t,e=!0){const i=this.ctx,s=this.current.fillColor;let n=!1;if(this.current.patternFill){const e=s.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.fillStyle=s.getPattern(i,this,yt(i),me),e){const s=new Path2D;s.addPath(t,i.getTransform().invertSelf().multiplySelf(e)),t=s}n=!0}const r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(i.fill(t,"evenodd"),this.pendingEOFill=!1):i.fill(t)),n&&i.restore(),e&&this.consumePath(t,r)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}rawFillPath(t){this.ctx.fill(t)}clip(){this.pendingClip=ze}eoClip(){this.pendingClip=He}beginText(){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return;const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:r,fontSize:o,path:h}of t)i.addPath(h,new DOMMatrix(e).preMultiplySelf(s).translate(n,r).scale(o,-o));e.clip(i),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||A,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||I("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let o="normal";i.black?o="900":i.bold&&(o="bold");const h=i.italic?"italic":"normal";let a=e;e<16?a=16:e>100&&(a=100),this.current.fontSizeScale=e/a,this.ctx.font=`${h} ${o} ${a}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t){const{current:e}=this;e.textMatrix=t,e.textMatrixScale=Math.hypot(t[0],t[1]),e.x=e.lineX=0,e.y=e.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#Di(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n){const r=this.ctx,o=this.current,h=o.font,a=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,l=3&a,u=!!(4&a),d=o.patternFill&&!h.missingFile,f=o.patternStroke&&!h.missingFile;let p;if((h.disableFontFace||u||d||f)&&(p=h.getPathGenerator(this.commonObjs,t)),h.disableFontFace||d||f){let t;if(r.save(),r.translate(e,i),r.scale(c,-c),0!==l&&2!==l||(s?(t=r.getTransform(),r.setTransform(...s),r.fill(this.#Di(p,t,s))):r.fill(p)),1===l||2===l)if(n){t||=r.getTransform(),r.setTransform(...n);const{a:e,b:i,c:s,d:o}=t,h=Q.inverseTransform(n),a=Q.transform([e,i,s,o,0,0],h);Q.singularValueDecompose2dScale(a,_e),r.lineWidth*=Math.max(_e[0],_e[1])/c,r.stroke(this.#Di(p,t,n))}else r.lineWidth/=c,r.stroke(p);r.restore()}else 0!==l&&2!==l||r.fillText(t,e,i),1!==l&&2!==l||r.strokeText(t,e,i);u&&(this.pendingTextPaths||=[]).push({transform:vt(r),x:e,y:i,fontSize:c,path:p})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return L(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(0===s)return;const n=this.ctx,r=e.fontSizeScale,o=e.charSpacing,h=e.wordSpacing,a=e.fontDirection,c=e.textHScale*a,l=t.length,u=i.vertical,d=u?1:-1,f=i.defaultVMetrics,p=s*e.fontMatrix[0],g=0===e.textRenderingMode&&!i.disableFontFace&&!e.patternFill;let m,w;if(n.save(),e.textMatrix&&n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),n.scale(c,a>0?-1:1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,yt(n),me);m=vt(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,yt(n),we);w=vt(n),n.restore(),n.strokeStyle=t}let A=e.lineWidth;const b=e.textMatrixScale;if(0===b||0===A){const t=3&e.textRenderingMode;1!==t&&2!==t||(A=this.getSinglePixelWidth())}else A/=b;if(1!==r&&(n.scale(r,r),A/=r),n.lineWidth=A,i.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t)i.push(e.unicode),s+=e.width;return n.fillText(i.join(""),0,0),e.x+=s*p*c,n.restore(),void this.compose()}let v,y=0;for(v=0;v<l;++v){const e=t[v];if("number"==typeof e){y+=d*e*s/1e3;continue}let c=!1;const l=(e.isSpace?h:0)+o,A=e.fontChar,b=e.accent;let x,M,E=e.width;if(u){const t=e.vmetric||f,i=-(e.vmetric?t[1]:.5*E)*p;E=t?-t[0]:E,x=i/r,M=(y+t[2]*p)/r}else x=y/r,M=0;if(i.remeasure&&E>0){const t=1e3*n.measureText(A).width/s*r;if(E<t&&this.isFontSubpixelAAEnabled){const e=E/t;c=!0,n.save(),n.scale(e,1),x/=e}else E!==t&&(x+=(E-t)/2e3*s/r)}this.contentVisible&&(e.isInFont||i.missingFile)&&(g&&!b?n.fillText(A,x,M):(this.paintChar(A,x,M,m,w),b&&this.paintChar(b.fontChar,x+s*b.offset.x/r,M-s*b.offset.y/r,m,w))),y+=u?E*p-l*a:E*p+l*a,c&&n.restore()}u?e.y-=y:e.x+=y*c,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,r=i.fontDirection,o=s.vertical?1:-1,h=i.charSpacing,a=i.wordSpacing,c=i.textHScale*r,l=i.fontMatrix||A,u=t.length;let d,f,p,g;if(3!==i.textRenderingMode&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),i.textMatrix&&e.transform(...i.textMatrix),e.translate(i.x,i.y+i.textRise),e.scale(c,r),d=0;d<u;++d){if(f=t[d],"number"==typeof f){g=o*f*n/1e3,this.ctx.translate(g,0),i.x+=g*c;continue}const r=(f.isSpace?a:0)+h,u=s.charProcOperatorList[f.operatorListId];u?this.contentVisible&&(this.save(),e.scale(n,n),e.transform(...l),this.executeOperatorList(u),this.restore()):I(`Type3 character "${f.operatorListId}" is not available.`);const m=[f.width,0];Q.applyTransform(m,l),p=m[0]*n+r,e.translate(p,0),i.x+=p*c}e.restore()}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,r){const o=new Path2D;o.rect(i,s,n-i,r-s),this.ctx.clip(o),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=this.baseTransform||vt(this.ctx);e=new ke(t,this.ctx,{createCanvasGraphics:t=>new Ge(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t){this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t){this.ctx.fillStyle=this.current.fillColor=t,this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new ye(t);case"Mesh":return new Ee(t);case"Dummy":return new Se}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,yt(e),Ae);const s=yt(e);if(s){const{width:t,height:i}=e.canvas,n=Re.slice();Q.axialAlignedBoundingBox([0,0,t,i],s,n);const[r,o,h,a]=n;this.ctx.fillRect(r,o,h-r,a-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){D("Should not call beginInlineImage")}beginImageData(){D("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=vt(this.ctx),e)){Q.axialAlignedBoundingBox(e,this.baseTransform,this.current.minMax);const[t,i,s,n]=e,r=new Path2D;r.rect(t,i,s-t,n-i),this.ctx.clip(r),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||N("TODO: Support non-isolated groups."),t.knockout&&I("Knockout groups not supported.");const i=vt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=Re.slice();Q.axialAlignedBoundingBox(t.bbox,vt(e),s),s=Q.intersect(s,[0,0,e.canvas.width,e.canvas.height])||[0,0,0,0];const n=Math.floor(s[0]),r=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-n,1),h=Math.max(Math.ceil(s[3])-r,1);this.current.startNewPathAndClipBox([0,0,o,h]);let a="groupAt"+this.groupLevel;t.smask&&(a+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(a,o,h),l=c.context;l.translate(-n,-r),l.transform(...i);let u=new Path2D;const[d,f,p,g]=t.bbox;if(u.rect(d,f,p-d,g-f),t.matrix){const e=new Path2D;e.addPath(u,new DOMMatrix(t.matrix)),u=e}l.clip(u),t.smask?this.smaskStack.push({canvas:c.canvas,context:l,offsetX:n,offsetY:r,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(n,r),e.save()),$e(e,l),this.ctx=l,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=vt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=Re.slice();Q.axialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t,i),this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#Ni(),Le(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],r=e[3]-e[1];if(n&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=r,Q.singularValueDecompose2dScale(vt(this.ctx),_e);const{viewportScale:n}=this,o=Math.ceil(s*this.outputScaleX*n),h=Math.ceil(r*this.outputScaleY*n);this.annotationCanvas=this.canvasFactory.create(o,h);const{canvas:a,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(t,a),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,this.ctx.save(),this.ctx.setTransform(_e[0],0,0,-_e[1],0,r*_e[1]),Le(this.ctx)}else{Le(this.ctx),this.endPath();const t=new Path2D;t.rect(e[0],e[1],s,r),this.ctx.clip(t)}}this.current=new De(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#Ii(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this._createMaskCanvas(t),n=s.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(n,s.offsetX,s.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const o=this.ctx;o.save();const h=vt(o);o.transform(e,i,s,n,0,0);const a=this._createMaskCanvas(t);o.setTransform(1,0,0,1,a.offsetX-h[4],a.offsetY-h[5]);for(let t=0,c=r.length;t<c;t+=2){const c=Q.transform(h,[e,i,s,n,r[t],r[t+1]]);o.drawImage(a.canvas,c[4],c[5])}o.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:t,width:r,height:o,transform:h}=n,a=this.cachedCanvases.getCanvas("maskCanvas",r,o),c=a.context;c.save(),Oe(c,this.getObject(t,n)),c.globalCompositeOperation="source-in",c.fillStyle=s?i.getPattern(c,this,yt(e),me):i,c.fillRect(0,0,r,o),c.restore(),e.save(),e.transform(...h),e.scale(1,-1),Ie(e,a.canvas,0,0,r,o,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):I("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void I("Dependent image isn't ready yet");const r=n.width,o=n.height,h=[];for(let t=0,n=s.length;t<n;t+=2)h.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:r,h:o});this.paintInlineImageXObjectGroup(n,h)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;this.save();const{filter:n}=s;let r;if("none"!==n&&""!==n&&(s.filter="none"),s.scale(1/e,-1/i),t.bitmap)r=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)r=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;Fe(s,t),r=this.applyTransferMapsToCanvas(s)}const o=this._scaleImage(r,yt(s));s.imageSmoothingEnabled=Be(vt(s),t.interpolate),Ie(s,o.img,0,0,o.paintWidth,o.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const e=this.cachedCanvases.getCanvas("inlineImage",t.width,t.height).context;Fe(e,t),s=this.applyTransferMapsToCanvas(e)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),Ie(i,s,t.x,t.y,t.w,t.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){this.markedContentStack.push("OC"===t?{visible:this.optionalContentConfig.isVisible(e)}:{visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t,e){const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const s=this.ctx;this.pendingClip&&(i||(this.pendingClip===He?s.clip(t,"evenodd"):s.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=vt(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,o;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)r=o=1/i;else{const e=i*t;r=o=e<1?1/e:1}else if(0===t)r=1/i,o=1/s;else{const e=i*t,n=s*t;r=e<1?1/e:1,o=n<1?1/n:1}}else{const h=Math.abs(e*n-i*s),a=Math.hypot(e,i),c=Math.hypot(s,n);if(0===t)r=c/h,o=a/h;else{const e=t*h;r=c>e?c/e:1,o=a>e?a/e:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:s}}=this,[n,r]=this.getScaleForStroking();if(n===r)return i.lineWidth=(s||1)*n,void i.stroke(t);const o=i.getLineDash();e&&i.save(),i.scale(n,r),Pe.a=1/n,Pe.d=1/r;const h=new Path2D;if(h.addPath(t,Pe),o.length>0){const t=Math.max(n,r);i.setLineDash(o.map((e=>e/t))),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(h),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in C)void 0!==Ge.prototype[t]&&(Ge.prototype[C[t]]=Ge.prototype[t]);class We{static#Fi=null;static#Oi="";static get workerPort(){return this.#Fi}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#Fi=t}static get workerSrc(){return this.#Oi}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#Oi=t}}class Ve{#$i;#Li;constructor({parsedData:t,rawData:e}){this.#$i=t,this.#Li=e}getRaw(){return this.#Li}get(t){return this.#$i.get(t)??null}[Symbol.iterator](){return this.#$i.entries()}}const Xe=Symbol("INTERNAL");class Ye{#Bi=!1;#Ui=!1;#ji=!1;#zi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#Bi=!!(2&t),this.#Ui=!!(4&t),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#ji)return this.#zi;if(!this.#zi)return!1;const{print:t,view:e}=this.usage;return this.#Bi?"OFF"!==e?.viewState:!this.#Ui||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==Xe&&D("Internal method `_setVisible` called."),this.#ji=i,this.#zi=e}}class qe{#Hi=null;#Gi=new Map;#Wi=null;#Vi=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#Vi=t.order;for(const i of t.groups)this.#Gi.set(i.id,new Ye(e,i));if("OFF"===t.baseState)for(const t of this.#Gi.values())t._setVisible(Xe,!1);for(const e of t.on)this.#Gi.get(e)._setVisible(Xe,!0);for(const e of t.off)this.#Gi.get(e)._setVisible(Xe,!1);this.#Wi=this.getHash()}}#Xi(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#Xi(e);else{if(!this.#Gi.has(e))return I(`Optional content group not found: ${e}`),!0;n=this.#Gi.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#Gi.size)return!0;if(!t)return N("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Gi.has(t.id)?this.#Gi.get(t.id).visible:(I(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Xi(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Gi.has(e))return I(`Optional content group not found: ${e}`),!0;if(this.#Gi.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Gi.has(e))return I(`Optional content group not found: ${e}`),!0;if(!this.#Gi.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Gi.has(e))return I(`Optional content group not found: ${e}`),!0;if(!this.#Gi.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Gi.has(e))return I(`Optional content group not found: ${e}`),!0;if(this.#Gi.get(e).visible)return!1}return!0}return I(`Unknown optional content policy ${t.policy}.`),!0}return I(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#Gi.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#Gi.get(i)?._setVisible(Xe,!1,!0);s._setVisible(Xe,!!e,!0),this.#Hi=null}else I(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=this.#Gi.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#Hi=null}get hasInitialVisibility(){return null===this.#Wi||this.getHash()===this.#Wi}getOrder(){return this.#Gi.size?this.#Vi?this.#Vi.slice():[...this.#Gi.keys()]:null}getGroup(t){return this.#Gi.get(t)||null}getHash(){if(null!==this.#Hi)return this.#Hi;const t=new jt;for(const[e,i]of this.#Gi)t.update(`${e}:${i.visible}`);return this.#Hi=t.hexdigest()}[Symbol.iterator](){return this.#Gi.entries()}}class Qe{constructor(t,{disableRange:e=!1,disableStream:i=!1}){F(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=o,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i):F(this._rangeReaders.some((function(e){return e._begin===t&&(e._enqueue(i),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?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(){F(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Ke(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Je(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Ke{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=lt(s)?s:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Je{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ze(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const s=e[t];void 0!==s&&i.append(t,s)}return i}function ti(t){return URL.parse(t)?.origin??null}function ei({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);return Number.isInteger(r)?(n.suggestedLength=r,r<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n):n}function ii(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=o(i);return t=unescape(t),t=h(t),t=a(t),r(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=o(s),i&&(s=unescape(s),0===t&&(s=h(s))),r.push(s)}return r.join("")}(t),i)return r(a(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=o(i);return t=a(t),r(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=X(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function o(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function h(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function a(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{s=atob(s)}catch{}return n(e,s)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(lt(t))return t}return null}function si(t,e){return new H(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function ni(t){return 200===t||206===t}function ri(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function oi(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(I(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class hi{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Ze(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return F(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new ai(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new ci(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class ai{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,ri(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=ti(e.url),!ni(e.status))throw si(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:r}=ei({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=ii(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new W("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:oi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ci{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,ri(n,this._withCredentials,this._abortController)).then((e=>{const i=ti(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!ni(e.status))throw si(e.status,r);this._readCapability.resolve(),this._reader=e.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:oi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class li{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Ze(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[t,i]of this.headers)e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",F(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError(s.status);const n=s.status||200;if((200!==n||206!==i.expectedStatus)&&n!==i.expectedStatus)return void i.onError(s.status);const r=function(t){const e=t.response;return"string"!=typeof e?e:X(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:r}):(I('Missing or invalid "Content-Range" header.'),i.onError(0))}else r?i.onDone({begin:0,chunk:r}):i.onError(s.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 ui{constructor(t){this._source=t,this._manager=new li(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 F(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new di(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new fi(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class di{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=ti(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{allowRangeRequests:n,suggestedLength:r}=ei({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=ii(s),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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=si(t,this._url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class fi{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=ti(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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=si(t,this._url);for(const t of this._requests)t.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(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const pi=/^[a-z][a-z0-9\-+.]+:/i;class gi{constructor(t){this.source=t,this.url=function(t){if(pi.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),F("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return F(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new mi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new wi(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class mi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=si(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){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 null===t?(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){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new W("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class wi{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!t.source.disableStream;const s=process.getBuiltinModule("fs");this._setReadableStream(s.createReadStream(this._url,{start:e,end:i-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 null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const Ai=Symbol("INITIAL_DATA");class bi{#Yi=Object.create(null);#qi(t){return this.#Yi[t]||={...Promise.withResolvers(),data:Ai}}get(t,e=null){if(e){const i=this.#qi(t);return i.promise.then((()=>e(i.data))),null}const i=this.#Yi[t];if(!i||i.data===Ai)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Yi[t];return!!e&&e.data!==Ai}delete(t){const e=this.#Yi[t];return!(!e||e.data===Ai||(delete this.#Yi[t],0))}resolve(t,e=null){const i=this.#qi(t);i.data=e,i.resolve()}clear(){for(const t in this.#Yi){const{data:e}=this.#Yi[t];e?.bitmap?.close()}this.#Yi=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Yi){const{data:e}=this.#Yi[t];e!==Ai&&(yield[t,e])}}}class vi{#Qi=Promise.withResolvers();#mt=null;#Ki=!1;#Ji=!!globalThis.FontInspector?.enabled;#Zi=null;#ts=null;#es=0;#is=0;#ss=null;#ns=null;#rs=0;#os=0;#hs=Object.create(null);#as=[];#cs=null;#ls=[];#us=new WeakMap;#ds=null;static#fs=new Map;static#ps=new Map;static#gs=new WeakMap;static#ms=null;static#ws=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#cs=t;else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');this.#cs=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#mt=this.#ns=e,this.#os=i.scale*Mt.pixelRatio,this.#rs=i.rotation,this.#ts={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:n,pageX:r,pageY:o}=i.rawDims;this.#ds=[1,0,0,-1,-r,o+n],this.#is=s,this.#es=n,vi.#As(),xt(e,i),this.#Qi.promise.finally((()=>{vi.#ws.delete(this),this.#ts=null,this.#hs=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Y.platform;return L(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{this.#ss.read().then((({value:e,done:i})=>{i?this.#Qi.resolve():(this.#Zi??=e.lang,Object.assign(this.#hs,e.styles),this.#bs(e.items),t())}),this.#Qi.reject)};return this.#ss=this.#cs.getReader(),vi.#ws.add(this),t(),this.#Qi.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*Mt.pixelRatio,s=t.rotation;if(s!==this.#rs&&(e?.(),this.#rs=s,xt(this.#ns,{rotation:s})),i!==this.#os){e?.(),this.#os=i;const t={div:null,properties:null,ctx:vi.#vs(this.#Zi)};for(const e of this.#ls)t.properties=this.#us.get(e),t.div=e,this.#ys(t)}}cancel(){const t=new W("TextLayer task cancelled.");this.#ss?.cancel(t).catch((()=>{})),this.#ss=null,this.#Qi.reject(t)}get textDivs(){return this.#ls}get textContentItemsStr(){return this.#as}#bs(t){if(this.#Ki)return;this.#ts.ctx??=vi.#vs(this.#Zi);const e=this.#ls,i=this.#as;for(const s of t){if(e.length>1e5)return I("Ignoring additional textDivs for performance reasons."),void(this.#Ki=!0);if(void 0!==s.str)i.push(s.str),this.#xs(s);else if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){const t=this.#mt;this.#mt=document.createElement("span"),this.#mt.classList.add("markedContent"),null!==s.id&&this.#mt.setAttribute("id",`${s.id}`),t.append(this.#mt)}else"endMarkedContent"===s.type&&(this.#mt=this.#mt.parentNode)}}#xs(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#ls.push(e);const s=Q.transform(this.#ds,t.transform);let n=Math.atan2(s[1],s[0]);const r=this.#hs[t.fontName];r.vertical&&(n+=Math.PI/2);let o=this.#Ji&&r.fontSubstitution||r.fontFamily;o=vi.fontFamilyMap.get(o)||o;const h=Math.hypot(s[2],s[3]),a=h*vi.#Ms(o,r,this.#Zi);let c,l;0===n?(c=s[4],l=s[5]-a):(c=s[4]+a*Math.sin(n),l=s[5]-a*Math.cos(n));const u="calc(var(--total-scale-factor) *",d=e.style;this.#mt===this.#ns?(d.left=`${(100*c/this.#is).toFixed(2)}%`,d.top=`${(100*l/this.#es).toFixed(2)}%`):(d.left=`${u}${c.toFixed(2)}px)`,d.top=`${u}${l.toFixed(2)}px)`),d.fontSize=`${u}${(vi.#ms*h).toFixed(2)}px)`,d.fontFamily=o,i.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#Ji&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),0!==n&&(i.angle=n*(180/Math.PI));let f=!1;if(t.str.length>1)f=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(f=!0)}if(f&&(i.canvasWidth=r.vertical?t.height:t.width),this.#us.set(e,i),this.#ts.div=e,this.#ts.properties=i,this.#ys(this.#ts),i.hasText&&this.#mt.append(e),i.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#mt.append(t)}}#ys(t){const{div:e,properties:i,ctx:s}=t,{style:n}=e;let r="";if(vi.#ms>1&&(r=`scale(${1/vi.#ms})`),0!==i.canvasWidth&&i.hasText){const{fontFamily:t}=n,{canvasWidth:o,fontSize:h}=i;vi.#Es(s,h*this.#os,t);const{width:a}=s.measureText(e.textContent);a>0&&(r=`scaleX(${o*this.#os/a}) ${r}`)}0!==i.angle&&(r=`rotate(${i.angle}deg) ${r}`),r.length>0&&(n.transform=r)}static cleanup(){if(!(this.#ws.size>0)){this.#fs.clear();for(const{canvas:t}of this.#ps.values())t.remove();this.#ps.clear()}}static#vs(t=null){let e=this.#ps.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#ps.set(t,e),this.#gs.set(e,{size:0,family:""})}return e}static#Es(t,e,i){const s=this.#gs.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#As(){if(null!==this.#ms)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.#ms=t.getBoundingClientRect().height,t.remove()}static#Ms(t,e,i){const s=this.#fs.get(t);if(s)return s;const n=this.#vs(i);n.canvas.width=n.canvas.height=30,this.#Es(n,30,t);const r=n.measureText(""),o=r.fontBoundingBoxAscent,h=Math.abs(r.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let a=.8;return o?a=o/(o+h):(Y.platform.isFirefox&&I("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?a=e.ascent:e.descent&&(a=1+e.descent)),this.#fs.set(t,a),a}}class yi{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let s=null;const n=i.name;if("#text"===n)s=i.value;else{if(!yi.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}function xi(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Mi,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(w)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(w&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return X(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,o=!0===t.withCredentials,h=t.password??null,a=t.range instanceof Ei?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let l=t.worker instanceof Ci?t.worker:null;const u=t.verbosity,d="string"!=typeof t.docBaseUrl||ct(t.docBaseUrl)?null:t.docBaseUrl,f=Xt(t.cMapUrl),p=!1!==t.cMapPacked,g=t.CMapReaderFactory||(w?fe:se),m=Xt(t.iccUrl),A=Xt(t.standardFontDataUrl),b=t.StandardFontDataFactory||(w?pe:he),v=Xt(t.wasmUrl),y=t.WasmFactory||(w?ge:ce),x=!0!==t.stopAtErrors,M=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,E=!1!==t.isEvalSupported,S="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!w,k="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!w&&(Y.platform.isFirefox||!globalThis.chrome),C=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,T="boolean"==typeof t.disableFontFace?t.disableFontFace:w,P=!0===t.fontExtraProperties,R=!0===t.enableXfa,N=t.ownerDocument||globalThis.document,I=!0===t.disableRange,D=!0===t.disableStream,F=!0===t.disableAutoFetch,O=!0===t.pdfBug,$=t.CanvasFactory||(w?de:ee),L=t.FilterFactory||(w?ue:re),B=!0===t.enableHWA,U=!1!==t.useWasm,j=a?a.length:t.length??NaN,z="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!w&&!T,H="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(g===se&&b===he&&y===ce&&f&&A&&v&&pt(f,document.baseURI)&&pt(A,document.baseURI)&&pt(v,document.baseURI));_(u);const G={canvasFactory:new $({ownerDocument:N,enableHWA:B}),filterFactory:new L({docId:i,ownerDocument:N}),cMapReaderFactory:H?null:new g({baseUrl:f,isCompressed:p}),standardFontDataFactory:H?null:new b({baseUrl:A}),wasmFactory:H?null:new y({baseUrl:v})};l||(l=Ci.create({verbosity:u,port:We.workerPort}),e._worker=l);const W={docId:i,apiVersion:"5.3.31",data:n,password:h,disableAutoFetch:F,rangeChunkSize:c,length:j,docBaseUrl:d,enableXfa:R,evaluatorOptions:{maxImageSize:M,disableFontFace:T,ignoreErrors:x,isEvalSupported:E,isOffscreenCanvasSupported:S,isImageDecoderSupported:k,canvasMaxAreaInBytes:C,fontExtraProperties:P,useSystemFonts:z,useWasm:U,useWorkerFetch:H,cMapUrl:f,iccUrl:m,standardFontDataUrl:A,wasmUrl:v}},V={ownerDocument:N,pdfBug:O,styleElement:null,loadingParams:{disableAutoFetch:F,enableXfa:R}};return l.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(l.destroyed)throw new Error("Worker was destroyed");const t=l.messageHandler.sendWithPromise("GetDocRequest",W,n?[n.buffer]:null);let h;if(a)h=new Qe(a,{disableRange:I,disableStream:D});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");const t=pt(s)?hi:w?gi:ui;h=new t({url:s,length:j,httpHeaders:r,withCredentials:o,rangeChunkSize:c,disableRange:I,disableStream:D})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(l.destroyed)throw new Error("Worker was destroyed");const s=new Zt(i,t,l.port),n=new Ti(s,e,h,V,G);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}class Mi{static#Ai=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+Mi.#Ai++;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 Ei{#Qi=Promise.withResolvers();#Ss=[];#ks=[];#Cs=[];#Ts=[];constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}addRangeListener(t){this.#Ts.push(t)}addProgressListener(t){this.#Cs.push(t)}addProgressiveReadListener(t){this.#ks.push(t)}addProgressiveDoneListener(t){this.#Ss.push(t)}onDataRange(t,e){for(const i of this.#Ts)i(t,e)}onDataProgress(t,e){this.#Qi.promise.then((()=>{for(const i of this.#Cs)i(t,e)}))}onDataProgressiveRead(t){this.#Qi.promise.then((()=>{for(const e of this.#ks)e(t)}))}onDataProgressiveDone(){this.#Qi.promise.then((()=>{for(const t of this.#Ss)t()}))}transportReady(){this.#Qi.resolve()}requestDataRange(t,e){D("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Si{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 L(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class ki{#Ps=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new ft:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new bi,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new ht({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return L(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=v.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:o=null,annotationCanvasMap:h=null,pageColors:a=null,printAnnotationStorage:c=null,isEditing:l=!1}){this._stats?.time("Overall");const u=this._transport.getRenderingIntent(i,s,c,l),{renderingIntent:d,cacheKey:f}=u;this.#Ps=!1,o||=this._transport.getOptionalContentConfig(d);let p=this._intentStates.get(f);p||(p=Object.create(null),this._intentStates.set(f,p)),p.streamReaderCancelTimeout&&(clearTimeout(p.streamReaderCancelTimeout),p.streamReaderCancelTimeout=null);const g=!!(4&d);p.displayReadyCapability||(p.displayReadyCapability=Promise.withResolvers(),p.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u));const m=t=>{p.renderTasks.delete(w),g&&(this.#Ps=!0),this.#_s(),t?(w.capability.reject(t),this._abortOperatorList({intentState:p,reason:t instanceof Error?t:new Error(t)})):w.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},w=new _i({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:p.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!g,pdfBug:this._pdfBug,pageColors:a});(p.renderTasks||=new Set).add(w);const A=w.task;return Promise.all([p.displayReadyCapability.promise,o]).then((([t,e])=>{if(this.destroyed)m();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&d))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");w.initializeGraphics({transparency:t,optionalContentConfig:e}),w.operatorListChanged()}})).catch(m),A}getOperatorList({intent:t="display",annotationMode:e=v.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let r,o=this._intentStates.get(n.cacheKey);return o||(o=Object.create(null),this._intentStates.set(n.cacheKey,o)),o.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(r))},o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||=new Set).add(r),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>yi.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then((function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#Ps=!1,Promise.all(t)}cleanup(t=!1){this.#Ps=!0;const e=this.#_s();return t&&e&&(this._stats&&=new ft),e}#_s(){if(!this.#Ps||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.#Ps=!1,!0}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#_s()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),h=this._intentStates.get(e);h.streamReader=o;const a=()=>{o.read().then((({value:t,done:e})=>{e?h.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,h),a())}),(t=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const t of h.renderTasks)t.operatorListChanged();this.#_s()}if(h.displayReadyCapability)h.displayReadyCapability.reject(t);else{if(!h.opListReadCapability)throw t;h.opListReadCapability.reject(t)}}}))};a()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof at){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})}),i))}}if(t.streamReader.cancel(new W(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class Ci{#Qi=Promise.withResolvers();#Rs=null;#Fi=null;#Ns=null;static#Is=0;static#Ds=!1;static#Fs=new WeakMap;static{w&&(this.#Ds=!0,We.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>URL.createObjectURL(new Blob([`await import("${t}");`],{type:"text/javascript"})),this.fromPort=t=>{if(console.log("Deprecated API usage: `PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:i=R()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(Ci.#Fs.has(e))throw new Error("Cannot use more than one PDFWorker per port.");Ci.#Fs.set(e,this),this.#Os(e)}else this.#$s()}get promise(){return this.#Qi.promise}#Ls(){this.#Qi.resolve(),this.#Rs.send("configure",{verbosity:this.verbosity})}get port(){return this.#Fi}get messageHandler(){return this.#Rs}#Os(t){this.#Fi=t,this.#Rs=new Zt("main","worker",t),this.#Rs.on("ready",(()=>{})),this.#Ls()}#$s(){if(Ci.#Ds||Ci.#Bs)return void this.#Us();let{workerSrc:t}=Ci;try{Ci._isSameOrigin(window.location,t)||(t=Ci._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new Zt("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this.#Qi.reject(new Error("Worker was destroyed")):this.#Us()},n=new AbortController;e.addEventListener("error",(()=>{this.#Ns||s()}),{signal:n.signal}),i.on("test",(t=>{n.abort(),!this.destroyed&&t?(this.#Rs=i,this.#Fi=e,this.#Ns=e,this.#Ls()):s()})),i.on("ready",(()=>{if(n.abort(),this.destroyed)s();else try{r()}catch{this.#Us()}}));const r=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};return void r()}catch{N("The worker has been disabled.")}this.#Us()}#Us(){Ci.#Ds||(I("Setting up fake worker."),Ci.#Ds=!0),Ci._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this.#Qi.reject(new Error("Worker was destroyed"));const e=new Qt;this.#Fi=e;const i="fake"+Ci.#Is++,s=new Zt(i+"_worker",i,e);t.setup(s,e),this.#Rs=new Zt(i,i+"_worker",e),this.#Ls()})).catch((t=>{this.#Qi.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this.#Ns?.terminate(),this.#Ns=null,Ci.#Fs.delete(this.#Fi),this.#Fi=null,this.#Rs?.destroy(),this.#Rs=null}static create(t){const e=this.#Fs.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 Ci(t)}static get workerSrc(){if(We.workerSrc)return We.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Bs(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return L(this,"_setupFakeWorkerGlobal",(async()=>this.#Bs?this.#Bs:(await import(this.workerSrc)).WorkerMessageHandler)())}}class Ti{#js=new Map;#zs=new Map;#Hs=new Map;#Gs=new Map;#Ws=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new bi,this.fontLoader=new Wt({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Vs(t,e=null){const i=this.#js.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#js.set(t,s),s}get annotationStorage(){return L(this,"annotationStorage",new Ht)}getRenderingIntent(t,e=v.ENABLE,i=null,s=!1,n=!1){let r=2,o=zt;switch(t){case"any":r=1;break;case"display":break;case"print":r=4;break;default:I(`getRenderingIntent - invalid intent: ${t}`)}const h=4&r&&i instanceof Gt?i:this.annotationStorage;switch(e){case v.DISABLE:r+=64;break;case v.ENABLE:break;case v.ENABLE_FORMS:r+=16;break;case v.ENABLE_STORAGE:r+=32,o=h.serializable;break;default:I(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=128),n&&(r+=256);const{ids:a,hash:c}=h.modifiedIds;return{renderingIntent:r,cacheKey:[r,o.hash,c].join("_"),annotationStorageSerializable:o,modifiedIds:a}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Ws?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#zs.values())t.push(e._destroy());this.#zs.clear(),this.#Hs.clear(),this.#Gs.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.#js.clear(),this.filterFactory.destroy(),vi.cleanup(),this._networkStream?.cancelAllRequests(new W("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",((t,e)=>{F(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function({value:t,done:i}){i?e.close():(F(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async()=>{await this._fullReader.headersReady;const{isStreamingSupported:t,isRangeSupported:i,contentLength:s}=this._fullReader;return t&&i||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:t,isRangeSupported:i,contentLength:s}})),t.on("GetRangeReader",((t,e)=>{F(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then((function({value:t,done:i}){i?e.close():(F(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{i.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Si(t,this))})),t.on("DocException",(t=>{e._capability.reject(Jt(t))})),t.on("PasswordRequest",(t=>{this.#Ws=Promise.withResolvers();try{if(!e.onPassword)throw Jt(t);e.onPassword((t=>{t instanceof Error?this.#Ws.reject(t):this.#Ws.resolve({password:t})}),t.code)}catch(t){this.#Ws.reject(t)}return this.#Ws.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{this.destroyed||this.#zs.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){const t=s.error;I(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const n=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,r=new Vt(s,n);this.fontLoader.bind(r).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!r.fontExtraProperties&&r.data&&(r.data=null),this.commonObjs.resolve(e,r)}));break;case"CopyLocalImage":const{imageRef:o}=s;F(o,"The imageRef must be defined.");for(const t of this.#zs.values())for(const[,i]of t.objs)if(i?.ref===o)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null})),t.on("obj",(([t,e,i,s])=>{if(this.destroyed)return;const n=this.#zs.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":case"Pattern":n.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBinaryData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&I("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,i=this.#Hs.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#Gs.set(i.refStr,t);const s=new ki(e,i,this,this._params.pdfBug);return this.#zs.set(e,s),s}));return this.#Hs.set(e,s),s}getPageIndex(t){return Yt(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.#Vs("GetFieldObjects")}hasJSActions(){return this.#Vs("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Vs("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.#Vs("GetOptionalContentConfig").then((e=>new qe(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#js.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new Ve(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#js.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#zs.values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#js.clear(),this.filterFactory.destroy(!0),vi.cleanup()}}cachedPageNumber(t){return Yt(t)?this.#Gs.get(0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`)??null:null}}class Pi{#Xs=null;onContinue=null;onError=null;constructor(t){this.#Xs=t}get promise(){return this.#Xs.capability.promise}cancel(t=0){this.#Xs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#Xs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#Xs;return t.form||t.canvas&&e?.size>0}}class _i{#Ys=null;static#qs=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:o,canvasFactory:h,filterFactory:a,useRequestAnimationFrame:c=!1,pdfBug:l=!1,pageColors:u=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=o,this.canvasFactory=h,this.filterFactory=a,this._pdfBug=l,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===c&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Pi(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.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(_i.#qs.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.");_i.#qs.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{canvasContext:i,viewport:s,transform:n,background:r}=this.params;this.gfx=new Ge(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,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.#Ys&&(window.cancelAnimationFrame(this.#Ys),this.#Ys=null),_i.#qs.delete(this._canvas),t||=new at(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Ys=window.requestAnimationFrame((()=>{this.#Ys=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),_i.#qs.delete(this._canvas),this.callback())))}}const Ri="5.3.31",Ni="47ad820d9";function Ii(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Di(t){return Math.max(0,Math.min(255,255*t))}m(531);class Fi{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}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=Di(t),t,t]}static G_HTML([t]){const e=Ii(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Di)}static RGB_HTML(t){return`#${t.map(Ii).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[Di(1-Math.min(1,t+s)),Di(1-Math.min(1,i+s)),Di(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i;return["CMYK",s,n,r,Math.min(s,n,r)]}}class Oi{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){D("Abstract method `_createSVG` called.")}}class $i extends Oi{_createSVG(t){return document.createElementNS(nt,t)}}class Li{static setupStorage(t,e,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{s.setValue(e,{value:t.target.getAttribute(t.target.checked?"xfaOn":"xfaOff")})}))}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of i.children)t.attributes.value===r.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const i=t.target.options;s.setValue(e,{value:-1===i.selectedIndex?"":i[i.selectedIndex].value})}))}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,o=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${s}`);for(const[e,i]of Object.entries(r))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!o||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}o&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});const o="richText"!==n,h=t.div;if(h.append(r),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=e}o&&h.setAttribute("class","xfaLayer xfaFont");const a=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);r.append(t),o&&yi.shouldBuildText(s.name)&&a.push(t)}return{textDivs:a}}const c=[[s,-1,r]];for(;c.length>0;){const[t,s,r]=c.at(-1);if(s+1===t.children.length){c.pop();continue}const h=t.children[++c.at(-1)[1]];if(null===h)continue;const{name:l}=h;if("#text"===l){const t=document.createTextNode(h.value);a.push(t),r.append(t);continue}const u=h?.attributes?.xmlns?document.createElementNS(h.attributes.xmlns,l):document.createElement(l);if(r.append(u),h.attributes&&this.setAttributes({html:u,element:h,storage:e,intent:n,linkService:i}),h.children?.length>0)c.push([h,-1,u]);else if(h.value){const t=document.createTextNode(h.value);o&&yi.shouldBuildText(l)&&a.push(t),u.append(t)}}for(const t of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:a}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Bi=1e3,Ui=new WeakSet;class ji{static create(t){switch(t.data.annotationType){case S.LINK:return new Hi(t);case S.TEXT:return new Gi(t);case S.WIDGET:switch(t.data.fieldType){case"Tx":return new Vi(t);case"Btn":return t.data.radioButton?new qi(t):t.data.checkBox?new Yi(t):new Qi(t);case"Ch":return new Ki(t);case"Sig":return new Xi(t)}return new Wi(t);case S.POPUP:return new Ji(t);case S.FREETEXT:return new ts(t);case S.LINE:return new es(t);case S.SQUARE:return new is(t);case S.CIRCLE:return new ss(t);case S.POLYLINE:return new ns(t);case S.CARET:return new os(t);case S.INK:return new hs(t);case S.POLYGON:return new rs(t);case S.HIGHLIGHT:return new as(t);case S.UNDERLINE:return new cs(t);case S.SQUIGGLY:return new ls(t);case S.STRIKEOUT:return new us(t);case S.STAMP:return new ds(t);case S.FILEATTACHMENT:return new fs(t);default:return new zi(t)}}}class zi{#Qs=null;#Ks=!1;#Js=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!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.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return zi._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#Qs||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#Zs(e),this.#Js?.popup.updateEdited(t)}resetEdited(){this.#Qs&&(this.#Zs(this.#Qs.rect),this.#Js?.popup.resetEdited(),this.#Qs=null)}#Zs(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:o,pageY:h}}}}=this;i?.splice(0,4,...t),e.left=100*(t[0]-o)/n+"%",e.top=100*(r-t[3]+h)/r+"%",0===s?(e.width=100*(t[2]-t[0])/n+"%",e.height=100*(t[3]-t[1])/r+"%"):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Wi||(n.tabIndex=Bi);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Ji){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:o,height:h}=this;if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;switch(t>0||i>0?r.borderRadius=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`:this instanceof qi&&(r.borderRadius=`calc(${o}px * var(--total-scale-factor)) / calc(${h}px * var(--total-scale-factor))`),e.borderStyle.style){case 1:r.borderStyle="solid";break;case 2:r.borderStyle="dashed";break;case 3:I("Unimplemented border style: beveled");break;case 4:I("Unimplemented border style: inset");break;case 5:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Ks=!0,r.borderColor=Q.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}const a=Q.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:c,pageHeight:l,pageX:u,pageY:d}=s.rawDims;r.left=100*(a[0]-u)/c+"%",r.top=100*(a[1]-d)/l+"%";const{rotation:f}=e;return e.hasOwnCanvas||0===f?(r.width=100*o/c+"%",r.height=100*h/l+"%"):this.setRotation(f,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims;let{width:n,height:r}=this;t%180!=0&&([n,r]=[r,n]),e.style.width=100*n/i+"%",e.style.height=100*r/s+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=Fi[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:Fi[`${n}_rgb`](r)})};return L(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];r&&(r({detail:{[s]:n},target:t}),delete e[s])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[r,o,h,a]=t.subarray(2,6);if(s===r&&n===o&&e===h&&i===a)return}const{style:r}=this.container;let o;if(this.#Ks){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const h=s-e,a=n-i,{svgFactory:c}=this,l=c.createElement("svg");l.classList.add("quadrilateralsContainer"),l.setAttribute("width",0),l.setAttribute("height",0);const u=c.createElement("defs");l.append(u);const d=c.createElement("clipPath"),f=`clippath_${this.data.id}`;d.setAttribute("id",f),d.setAttribute("clipPathUnits","objectBoundingBox"),u.append(d);for(let i=2,s=t.length;i<s;i+=8){const s=t[i],r=t[i+1],l=t[i+2],u=t[i+3],f=c.createElement("rect"),p=(l-e)/h,g=(n-r)/a,m=(s-l)/h,w=(r-u)/a;f.setAttribute("x",p),f.setAttribute("y",g),f.setAttribute("width",m),f.setAttribute("height",w),d.append(f),o?.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${g}" width="${m}" height="${w}"/>`)}this.#Ks&&(o.push("</g></svg>')"),r.backgroundImage=o.join("")),this.container.append(l),this.container.style.clipPath=`url(#${f})`}_createPopup(){const{data:t}=this,e=this.#Js=new Ji({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){D("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:r}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof r?r:null,o=document.querySelector(`[data-element-id="${n}"]`);!o||Ui.has(o)?i.push({id:n,exportValue:s,domElement:o}):I(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&Ui.has(s)&&i.push({id:n,exportValue:t,domElement:s})}return i}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})}))}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class Hi extends zi{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,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#tn(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#en(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#in(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#in()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#in()}#tn(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#in()}#en(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#in()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#in()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#in(),!this._fieldObjects)return I('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:s,include:n}=e,r=[];if(0!==t.length||0!==s.length){const e=new Set(s);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===n&&r.push(i)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const o=this.annotationStorage,h=[];for(const t of r){const{id:e}=t;switch(h.push(e),t.type){case"text":case"combobox":case"listbox":o.setValue(e,{value:t.defaultValue||""});break;case"checkbox":case"radiobutton":o.setValue(e,{value:t.defaultValue===t.exportValues});break;default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(Ui.has(i)?i.dispatchEvent(new Event("resetform")):I(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}}class Gi extends zi{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 Wi extends zi{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Y.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(i,(t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,e,i,s){for(const[n,r]of i)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(e||={focused:!1}),this._setEventListener(t,e,n,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":Q.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const{fontColor:e}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,s=t.style;let n;const r=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=Math.round(t/(b*i))||1;n=Math.min(i,r(t/e/b))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);n=Math.min(i,r(t/b))}s.fontSize=`calc(${n}px * var(--total-scale-factor))`,s.color=Q.makeHexColor(e[0],e[1],e[2]),null!==this.data.textAlignment&&(s.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Vi extends Wi{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let o=s.formattedValue||this.data.textContent?.join("\n")||null;o&&this.data.comb&&(o=o.replaceAll(/\s+/g,""));const h={userValue:n,formattedValue:o,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=o??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",o??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),Ui.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Bi,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",(s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),h.formattedValue=null})),i.addEventListener("resetform",(()=>{i.value=h.userValue=this.data.defaultFieldValue??"",h.formattedValue=null}));let a=t=>{const{formattedValue:e}=h;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(t=>{if(h.focused)return;const{target:e}=t;h.userValue&&(e.value=h.userValue),h.lastCommittedValue=e.value,h.commitKey=1,this.data.actions?.Focus||(h.focused=!0)})),i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target),this._dispatchEventFromSandbox({value(i){h.userValue=i.detail.value??"",t.setValue(e,{value:h.userValue.toString()}),i.target.value=h.userValue},formattedValue(i){const{formattedValue:s}=i.detail;h.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let r=h.userValue;!r||r.length<=s||(r=r.slice(0,s),n.value=h.userValue=r,t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}},i)})),i.addEventListener("keydown",(t=>{h.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(h.commitKey=3):i=2,-1===i)return;const{value:s}=t.target;h.lastCommittedValue!==s&&(h.lastCommittedValue=s,h.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const s=a;a=null,i.addEventListener("blur",(t=>{if(!h.focused||!t.relatedTarget)return;this.data.actions?.Blur||(h.focused=!1);const{value:i}=t.target;h.userValue=i,h.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:h.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)})),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{h.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:r,selectionEnd:o}=s;let a=r,c=o;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,r).match(/\w*[^\w]*$/);t&&(a-=t[0].length);break}case"deleteWordForward":{const t=n.substring(r).match(/^[^\w]*\w*/);t&&(c+=t[0].length);break}case"deleteContentBackward":r===o&&(a-=1);break;case"deleteContentForward":r===o&&(c+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:a,selEnd:c}})})),this._setEventListeners(i,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(a&&i.addEventListener("blur",a),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Xi extends Wi{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Yi extends Wi{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Ui.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=Bi,n.addEventListener("change",(s=>{const{name:n,checked:r}=s.target;for(const s of this._getElementsByName(n,i)){const i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})})),n.addEventListener("resetform",(t=>{t.target.checked=(e.defaultFieldValue||"Off")===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class qi extends Wi{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});const n=document.createElement("input");if(Ui.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=Bi,n.addEventListener("change",(e=>{const{name:s,checked:n}=e.target;for(const e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue})),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Qi extends Hi{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Ki extends Wi{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Ui.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=Bi;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",(()=>{const t=this.data.defaultFieldValue;for(const e of s.options)e.selected=e.value===t}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let r=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}const o=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let h=o(!1);const a=t=>Array.prototype.map.call(t.target.options,(t=>({displayValue:t.textContent,exportValue:t.value})));return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{this._dispatchEventFromSandbox({value(i){r?.();const n=i.detail.value,a=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=a.has(t.value);t.setValue(e,{value:o(!0)}),h=o(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,r=i.detail.remove;n[r].selected=!1,s.remove(r),n.length>0&&-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0),t.setValue(e,{value:o(!0),items:a(i)}),h=o(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),h=o(!1)},insert(i){const{index:n,displayValue:r,exportValue:c}=i.detail.insert,l=s.children[n],u=document.createElement("option");u.textContent=r,u.value=c,l?l.before(u):s.append(u),t.setValue(e,{value:o(!0),items:a(i)}),h=o(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:o(!0),items:a(i)}),h=o(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:o(!0)}),h=o(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)})),s.addEventListener("input",(i=>{const s=o(!0),n=o(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:h,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):s.addEventListener("input",(function(){t.setValue(e,{value:o(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Ji extends zi{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:zi._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Zi({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,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}),e=[];for(const i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${et}${t}`)).join(",")),this.container}}class Zi{#sn=this.#nn.bind(this);#rn=this.#on.bind(this);#hn=this.#an.bind(this);#cn=this.#ln.bind(this);#un=null;#mt=null;#dn=null;#fn=null;#pn=null;#gn=null;#mn=null;#wn=!1;#An=null;#C=null;#bn=null;#vn=null;#yn=null;#Qs=null;#xn=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:o,parent:h,rect:a,parentRect:c,open:l}){this.#mt=t,this.#yn=s,this.#dn=r,this.#vn=o,this.#gn=h,this.#un=e,this.#bn=a,this.#mn=c,this.#pn=i,this.#fn=wt.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#cn),t.addEventListener("mouseenter",this.#hn),t.addEventListener("mouseleave",this.#rn),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#sn);this.#mt.hidden=!0,l&&this.#ln()}render(){if(this.#An)return;const t=this.#An=document.createElement("div");if(t.className="popup",this.#un){const e=t.style.outlineColor=Q.makeHexColor(...this.#un);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#yn),t.append(e),this.#fn){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#fn.valueOf()})),e.append(t)}const s=this.#Mn;if(s)Li.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#dn);t.append(e)}this.#mt.append(t)}get#Mn(){const t=this.#vn,e=this.#dn;return!t?.str||e?.str&&e.str!==t.str?null:this.#vn.html||null}get#En(){return this.#Mn?.attributes?.style?.fontSize||0}get#Sn(){return this.#Mn?.attributes?.style?.color||null}#kn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#Sn,fontSize:this.#En?`calc(${this.#En}px * var(--total-scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t)i.append(document.createTextNode(s[t])),t<e-1&&i.append(document.createElement("br"));return i}#nn(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#wn)&&this.#ln()}updateEdited({rect:t,popupContent:e}){this.#Qs||={contentsObj:this.#dn,richText:this.#vn},t&&(this.#C=null),e&&(this.#vn=this.#kn(e),this.#dn=null),this.#An?.remove(),this.#An=null}resetEdited(){this.#Qs&&(({contentsObj:this.#dn,richText:this.#vn}=this.#Qs),this.#Qs=null,this.#An?.remove(),this.#An=null,this.#C=null)}#Cn(){if(null!==this.#C)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#gn;let r=!!this.#mn,o=r?this.#mn:this.#bn;for(const t of this.#pn)if(!o||null!==Q.intersect(t.data.rect,o)){o=t.data.rect,r=!0;break}const h=Q.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]);this.#C=[100*(h[0]+(r?o[2]-o[0]+5:0)-s)/e,100*(h[1]-n)/i];const{style:a}=this.#mt;a.left=`${this.#C[0]}%`,a.top=`${this.#C[1]}%`}#ln(){this.#wn=!this.#wn,this.#wn?(this.#an(),this.#mt.addEventListener("click",this.#cn),this.#mt.addEventListener("keydown",this.#sn)):(this.#on(),this.#mt.removeEventListener("click",this.#cn),this.#mt.removeEventListener("keydown",this.#sn))}#an(){this.#An||this.render(),this.isVisible?this.#wn&&this.#mt.classList.add("focused"):(this.#Cn(),this.#mt.hidden=!1,this.#mt.style.zIndex=parseInt(this.#mt.style.zIndex)+1e3)}#on(){this.#mt.classList.remove("focused"),!this.#wn&&this.isVisible&&(this.#mt.hidden=!0,this.#mt.style.zIndex=parseInt(this.#mt.style.zIndex)-1e3)}forceHide(){this.#xn=this.isVisible,this.#xn&&(this.#mt.hidden=!0)}maybeShow(){this.#xn&&(this.#An||this.#an(),this.#xn=!1,this.#mt.hidden=!1)}get isVisible(){return!1===this.#mt.hidden}}class ts extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=y.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 i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class es extends zi{#Tn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=this.#Tn=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Tn}addHighlightArea(){this.container.classList.add("highlightArea")}}class is extends zi{#Pn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#Pn=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Pn}addHighlightArea(){this.container.classList.add("highlightArea")}}class ss extends zi{#_n=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#_n=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#_n}addHighlightArea(){this.container.classList.add("highlightArea")}}class ns extends zi{#Rn=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:i,popupRef:s},width:n,height:r}=this;if(!e)return this.container;const o=this.svgFactory.create(n,r,!0);let h=[];for(let i=0,s=e.length;i<s;i+=2)h.push(`${e[i]-t[0]},${t[3]-e[i+1]}`);h=h.join(" ");const a=this.#Rn=this.svgFactory.createElement(this.svgElementName);return a.setAttribute("points",h),a.setAttribute("stroke-width",i.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),o.append(a),this.container.append(o),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Rn}addHighlightArea(){this.container.classList.add("highlightArea")}}class rs extends ns{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class os extends zi{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 hs extends zi{#Nn=null;#In=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?y.HIGHLIGHT:y.INK}#Dn(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:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:o,height:h}=this.#Dn(e,t),a=this.svgFactory.create(o,h,!0),c=this.#Nn=this.svgFactory.createElement("svg:g");a.append(c),c.setAttribute("stroke-width",s.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",r);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#In.push(e),e.setAttribute("points",i[t].join(",")),c.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(a),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#Nn;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#In.length;t<e;t++)this.#In[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#Dn(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#In}addHighlightArea(){this.container.classList.add("highlightArea")}}class as extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=y.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class cs extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class ls extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class us extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class ds extends zi{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=y.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 fs extends zi{#Fn=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 i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#On.bind(this)),this.#Fn=i;const{isMac:s}=Y.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#On()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#Fn}addHighlightArea(){this.container.classList.add("highlightArea")}#On(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class ps{#$n=null;#Ln=null;#Bn=new Map;#Un=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:o}){this.div=t,this.#$n=e,this.#Ln=i,this.#Un=o||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#Bn.size>0}async#jn(t,e){const i=t.firstChild||t,s=i.id=`${et}${e}`,n=await(this.#Un?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#$n?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;xt(i,this.viewport);const s=new Map,n={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new $i,annotationStorage:t.annotationStorage||new Ht,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===S.POPUP;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;n.data=t;const i=ji.create(n);if(!i.isRenderable)continue;if(!e&&t.popupRef){const e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}const r=i.render();t.hidden&&(r.style.visibility="hidden"),await this.#jn(r,t.id),i._isEditable&&(this.#Bn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#zn()}async addLinkAnnotations(t,e){const i={data:null,layer:this.div,linkService:e,svgFactory:new $i,parent:this};for(const e of t){e.borderStyle||=ps._defaultBorderStyle,i.data=e;const t=ji.create(i);if(!t.isRenderable)continue;const s=t.render();await this.#jn(s,e.id)}}update({viewport:t}){const e=this.div;this.viewport=t,xt(e,{rotation:t.rotation}),this.#zn(),e.hidden=!1}#zn(){if(!this.#Ln)return;const t=this.div;for(const[e,i]of this.#Ln){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i);const r=this.#Bn.get(e);r&&(r._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),r._hasNoCanvas=!1):r.canvas=i)}this.#Ln.clear()}getEditableAnnotations(){return Array.from(this.#Bn.values())}getEditableAnnotation(t){return this.#Bn.get(t)}static get _defaultBorderStyle(){return L(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:1,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const gs=/\r\n?|\n/g;class ms extends Ot{#un;#Hn="";#Gn=`${this.id}-editor`;#Wn=null;#En;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=ms.prototype,e=t=>t.isEmpty(),i=It.TRANSLATE_SMALL,s=It.TRANSLATE_BIG;return L(this,"_keyboardManager",new Rt([[["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:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=y.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#un=t.color||ms._defaultColor||Ot._defaultLineColor,this.#En=t.fontSize||ms._defaultFontSize}static initialize(t,e){Ot.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case x.FREETEXT_SIZE:ms._defaultFontSize=e;break;case x.FREETEXT_COLOR:ms._defaultColor=e}}updateParams(t,e){switch(t){case x.FREETEXT_SIZE:this.#Vn(e);break;case x.FREETEXT_COLOR:this.#Xn(e)}}static get defaultPropertiesToUpdate(){return[[x.FREETEXT_SIZE,ms._defaultFontSize],[x.FREETEXT_COLOR,ms._defaultColor||Ot._defaultLineColor]]}get propertiesToUpdate(){return[[x.FREETEXT_SIZE,this.#En],[x.FREETEXT_COLOR,this.#un]]}#Vn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#En)*this.parentScale),this.#En=t,this.#Yn()},i=this.#En;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:x.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#Xn(t){const e=t=>{this.#un=this.editorDiv.style.color=t},i=this.#un;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:x.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-ms._internalPadding*t,-(ms._internalPadding+this.#En)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Wn=new AbortController;const t=this._uiManager.combinedSignal(this.#Wn);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.#Gn),this._isDraggable=!0,this.#Wn?.abort(),this.#Wn=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){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()}#qn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(ms.#Qn(i)),e=i);return t.join("\n")}#Yn(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#Hn,e=this.#Hn=this.#qn().trimEnd();if(t===e)return;const i=t=>{this.#Hn=t,t?(this.#Kn(),this._uiManager.rebuild(this),this.#Yn()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#Yn()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){ms._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.#Gn),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#En}px * var(--total-scale-factor))`,i.color=this.#un,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,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[r,o]=this.getInitialTranslation();[r,o]=this.pageTranslationToScreen(r,o);const[h,a]=this.pageDimensions,[c,l]=this.pageTranslation;let u,d;switch(this.rotation){case 0:u=t+(n[0]-c)/h,d=e+this.height-(n[1]-l)/a;break;case 90:u=t+(n[0]-c)/h,d=e-(n[1]-l)/a,[r,o]=[o,-r];break;case 180:u=t-this.width+(n[0]-c)/h,d=e-(n[1]-l)/a,[r,o]=[-r,-o];break;case 270:u=t+(n[0]-c-this.height*a)/h,d=e+(n[1]-l-this.width*h)/a,[r,o]=[-o,r]}this.setAt(u*i,d*s,r,o)}else this._moveAfterPaste(t,e);this.#Kn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Qn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(gs,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=ms.#Jn(e.getData("text")||"").replaceAll(gs,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!s.includes("\n"))return r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:o,startOffset:h}=r,a=[],c=[];if(o.nodeType===Node.TEXT_NODE){const t=o.parentElement;if(c.push(o.nodeValue.slice(h).replaceAll(gs,"")),t!==this.editorDiv){let e=a;for(const i of this.editorDiv.childNodes)i!==t?e.push(ms.#Qn(i)):e=c}a.push(o.nodeValue.slice(0,h).replaceAll(gs,""))}else if(o===this.editorDiv){let t=a,e=0;for(const i of this.editorDiv.childNodes)e++===h&&(t=c),t.push(ms.#Qn(i))}this.#Hn=`${a.join("\n")}${s}${c.join("\n")}`,this.#Kn();const l=new Range;let u=Math.sumPrecise(a.map((t=>t.length)));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(u<=e){l.setStart(t,u),l.setEnd(t,u);break}u-=e}n.removeAllRanges(),n.addRange(l)}#Kn(){if(this.editorDiv.replaceChildren(),this.#Hn)for(const t of this.#Hn.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#Zn(){return this.#Hn.replaceAll(" "," ")}static#Jn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof ts){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:r,id:o,popupRef:h},textContent:a,textPosition:c,parent:{page:{pageNumber:l}}}=t;if(!a||0===a.length)return null;s=t={annotationType:y.FREETEXT,color:Array.from(i),fontSize:e,value:a.join("\n"),position:c,pageIndex:l-1,rect:n.slice(0),rotation:r,id:o,deleted:!1,popupRef:h}}const n=await super.deserialize(t,e,i);return n.#En=t.fontSize,n.#un=Q.makeHexColor(...t.color),n.#Hn=ms.#Jn(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=ms._internalPadding*this.parentScale,i=this.getRect(e,e),s=Ot._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#un),n={annotationType:y.FREETEXT,color:s,fontSize:this.#En,value:this.#Zn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(n.isCopy=!0,n):this.annotationElementId&&!this.#tr(n)?null:(n.id=this.annotationElementId,n)}#tr(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#En}px * var(--total-scale-factor))`,i.color=this.#un,e.replaceChildren();for(const t of this.#Hn.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=ms._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#Hn}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class ws{static PRECISION=1e-4;toSVGPath(){D("Abstract method `toSVGPath` must be implemented.")}get box(){D("Abstract getter `box` must be implemented.")}serialize(t,e){D("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let o=0,h=t.length;o<h;o+=2)r[o]=e+t[o]*s,r[o+1]=i+t[o+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let o=0,h=t.length;o<h;o+=2)r[o]=e+t[o+1]*s,r[o+1]=i+t[o]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class As{#er;#ir=[];#sr;#nr;#rr=[];#or=new Float32Array(18);#hr;#ar;#cr;#lr;#ur;#dr;#fr=[];static#pr=8;static#gr=2;static#mr=As.#pr+As.#gr;constructor({x:t,y:e},i,s,n,r,o=0){this.#er=i,this.#dr=n*s,this.#nr=r,this.#or.set([NaN,NaN,NaN,NaN,t,e],6),this.#sr=o,this.#lr=As.#pr*s,this.#cr=As.#mr*s,this.#ur=s,this.#fr.push(t,e)}isEmpty(){return isNaN(this.#or[8])}#wr(){const t=this.#or.subarray(4,6),e=this.#or.subarray(16,18),[i,s,n,r]=this.#er;return[(this.#hr+(t[0]-e[0])/2-i)/n,(this.#ar+(t[1]-e[1])/2-s)/r,(this.#hr+(e[0]-t[0])/2-i)/n,(this.#ar+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#hr=t,this.#ar=e;const[i,s,n,r]=this.#er;let[o,h,a,c]=this.#or.subarray(8,12);const l=t-a,u=e-c,d=Math.hypot(l,u);if(d<this.#cr)return!1;const f=d-this.#lr,p=f/d,g=p*l,m=p*u;let w=o,A=h;o=a,h=c,a+=g,c+=m,this.#fr?.push(t,e);const b=-m/f*this.#dr,v=g/f*this.#dr;return this.#or.set(this.#or.subarray(2,8),0),this.#or.set([a+b,c+v],4),this.#or.set(this.#or.subarray(14,18),12),this.#or.set([a-b,c-v],16),isNaN(this.#or[6])?(0===this.#rr.length&&(this.#or.set([o+b,h+v],2),this.#rr.push(NaN,NaN,NaN,NaN,(o+b-i)/n,(h+v-s)/r),this.#or.set([o-b,h-v],14),this.#ir.push(NaN,NaN,NaN,NaN,(o-b-i)/n,(h-v-s)/r)),this.#or.set([w,A,o,h,a,c],6),!this.isEmpty()):(this.#or.set([w,A,o,h,a,c],6),Math.abs(Math.atan2(A-h,w-o)-Math.atan2(m,g))<Math.PI/2?([o,h,a,c]=this.#or.subarray(2,6),this.#rr.push(NaN,NaN,NaN,NaN,((o+a)/2-i)/n,((h+c)/2-s)/r),[o,h,w,A]=this.#or.subarray(14,18),this.#ir.push(NaN,NaN,NaN,NaN,((w+o)/2-i)/n,((A+h)/2-s)/r),!0):([w,A,o,h,a,c]=this.#or.subarray(0,6),this.#rr.push(((w+5*o)/6-i)/n,((A+5*h)/6-s)/r,((5*o+a)/6-i)/n,((5*h+c)/6-s)/r,((o+a)/2-i)/n,((h+c)/2-s)/r),[a,c,o,h,w,A]=this.#or.subarray(12,18),this.#ir.push(((w+5*o)/6-i)/n,((A+5*h)/6-s)/r,((5*o+a)/6-i)/n,((5*h+c)/6-s)/r,((o+a)/2-i)/n,((h+c)/2-s)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#rr,e=this.#ir;if(isNaN(this.#or[6])&&!this.isEmpty())return this.#Ar();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#br(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#vr(i),i.join(" ")}#Ar(){const[t,e,i,s]=this.#er,[n,r,o,h]=this.#wr();return`M${(this.#or[2]-t)/i} ${(this.#or[3]-e)/s} L${(this.#or[4]-t)/i} ${(this.#or[5]-e)/s} L${n} ${r} L${o} ${h} L${(this.#or[16]-t)/i} ${(this.#or[17]-e)/s} L${(this.#or[14]-t)/i} ${(this.#or[15]-e)/s} Z`}#vr(t){const e=this.#ir;t.push(`L${e[4]} ${e[5]} Z`)}#br(t){const[e,i,s,n]=this.#er,r=this.#or.subarray(4,6),o=this.#or.subarray(16,18),[h,a,c,l]=this.#wr();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${h} ${a} L${c} ${l} L${(o[0]-e)/s} ${(o[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new bs(t,e,i,s,n,r)}getOutlines(){const t=this.#rr,e=this.#ir,i=this.#or,[s,n,r,o]=this.#er,h=new Float32Array((this.#fr?.length??0)+2);for(let t=0,e=h.length-2;t<e;t+=2)h[t]=(this.#fr[t]-s)/r,h[t+1]=(this.#fr[t+1]-n)/o;if(h[h.length-2]=(this.#hr-s)/r,h[h.length-1]=(this.#ar-n)/o,isNaN(i[6])&&!this.isEmpty())return this.#yr(h);const a=new Float32Array(this.#rr.length+24+this.#ir.length);let c=t.length;for(let e=0;e<c;e+=2)isNaN(t[e])?a[e]=a[e+1]=NaN:(a[e]=t[e],a[e+1]=t[e+1]);c=this.#xr(a,c);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(a[c]=a[c+1]=NaN,c+=2):(a[c]=e[t+i],a[c+1]=e[t+i+1],c+=2);return this.#Mr(a,c),this.newFreeDrawOutline(a,h,this.#er,this.#ur,this.#sr,this.#nr)}#yr(t){const e=this.#or,[i,s,n,r]=this.#er,[o,h,a,c]=this.#wr(),l=new Float32Array(36);return l.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,o,h,NaN,NaN,NaN,NaN,a,c,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(l,t,this.#er,this.#ur,this.#sr,this.#nr)}#Mr(t,e){const i=this.#ir;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#xr(t,e){const i=this.#or.subarray(4,6),s=this.#or.subarray(16,18),[n,r,o,h]=this.#er,[a,c,l,u]=this.#wr();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/o,(i[1]-r)/h,NaN,NaN,NaN,NaN,a,c,NaN,NaN,NaN,NaN,l,u,NaN,NaN,NaN,NaN,(s[0]-n)/o,(s[1]-r)/h],e),e+24}}class bs extends ws{#er;#Er=new Float32Array(4);#sr;#nr;#fr;#ur;#Sr;constructor(t,e,i,s,n,r){super(),this.#Sr=t,this.#fr=e,this.#er=i,this.#ur=s,this.#sr=n,this.#nr=r,this.lastPoint=[NaN,NaN],this.#kr(r);const[o,h,a,c]=this.#Er;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-o)/a,t[e+1]=(t[e+1]-h)/c;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-o)/a,e[t+1]=(e[t+1]-h)/c}toSVGPath(){const t=[`M${this.#Sr[4]} ${this.#Sr[5]}`];for(let e=6,i=this.#Sr.length;e<i;e+=6)isNaN(this.#Sr[e])?t.push(`L${this.#Sr[e+4]} ${this.#Sr[e+5]}`):t.push(`C${this.#Sr[e]} ${this.#Sr[e+1]} ${this.#Sr[e+2]} ${this.#Sr[e+3]} ${this.#Sr[e+4]} ${this.#Sr[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,o=s-e;let h,a;switch(n){case 0:h=ws._rescale(this.#Sr,t,s,r,-o),a=ws._rescale(this.#fr,t,s,r,-o);break;case 90:h=ws._rescaleAndSwap(this.#Sr,t,e,r,o),a=ws._rescaleAndSwap(this.#fr,t,e,r,o);break;case 180:h=ws._rescale(this.#Sr,i,e,-r,o),a=ws._rescale(this.#fr,i,e,-r,o);break;case 270:h=ws._rescaleAndSwap(this.#Sr,i,s,-r,-o),a=ws._rescaleAndSwap(this.#fr,i,s,-r,-o)}return{outline:Array.from(h),points:[Array.from(a)]}}#kr(t){const e=this.#Sr;let i=e[4],s=e[5];const n=[i,s,i,s];let r=i,o=s;const h=t?Math.max:Math.min;for(let t=6,a=e.length;t<a;t+=6){const a=e[t+4],c=e[t+5];if(isNaN(e[t]))Q.pointBoundingBox(a,c,n),o<c?(r=a,o=c):o===c&&(r=h(r,a));else{const a=[1/0,1/0,-1/0,-1/0];Q.bezierBoundingBox(i,s,...e.slice(t,t+6),a),Q.rectBoundingBox(...a,n),o<a[3]?(r=a[2],o=a[3]):o===a[3]&&(r=h(r,a[2]))}i=a,s=c}const a=this.#Er;a[0]=n[0]-this.#sr,a[1]=n[1]-this.#sr,a[2]=n[2]-n[0]+2*this.#sr,a[3]=n[3]-n[1]+2*this.#sr,this.lastPoint=[r,o]}get box(){return this.#Er}newOutliner(t,e,i,s,n,r=0){return new As(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=this.#Er,[o,h,a,c]=this.#er,l=n*a,u=r*c,d=i*a+o,f=s*c+h,p=this.newOutliner({x:this.#fr[0]*l+d,y:this.#fr[1]*u+f},this.#er,this.#ur,t,this.#nr,e??this.#sr);for(let t=2;t<this.#fr.length;t+=2)p.add({x:this.#fr[t]*l+d,y:this.#fr[t+1]*u+f});return p.getOutlines()}}class vs{#er;#Cr;#Tr=[];#Pr=[];constructor(t,e=0,i=0,s=!0){const n=[1/0,1/0,-1/0,-1/0],r=10**-4;for(const{x:i,y:s,width:o,height:h}of t){const t=Math.floor((i-e)/r)*r,a=Math.ceil((i+o+e)/r)*r,c=Math.floor((s-e)/r)*r,l=Math.ceil((s+h+e)/r)*r;this.#Tr.push([t,c,l,!0],[a,c,l,!1]),Q.rectBoundingBox(t,c,a,l,n)}const o=n[2]-n[0]+2*i,h=n[3]-n[1]+2*i,a=n[0]-i,c=n[1]-i,l=this.#Tr.at(s?-1:-2),u=[l[0],l[2]];for(const t of this.#Tr){const[e,i,s]=t;t[0]=(e-a)/o,t[1]=(i-c)/h,t[2]=(s-c)/h}this.#er=new Float32Array([a,c,o,h]),this.#Cr=u}getOutlines(){this.#Tr.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#Tr)e[3]?(t.push(...this.#_r(e)),this.#Rr(e)):(this.#Nr(e),t.push(...this.#_r(e)));return this.#Ir(t)}#Ir(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,s=e.length;t<s;t+=2){const s=e[t][2],n=e[t+1][2];s.push(n),n.push(s),i.add(s),i.add(n)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,r,o,h,a]=t;i.delete(t);let c=e,l=r;for(n=[e,o],s.push(n);;){let t;if(i.has(h))t=h;else{if(!i.has(a))break;t=a}i.delete(t),[e,r,o,h,a]=t,c!==e&&(n.push(c,l,e,l===r?r:o),c=e),l=l===r?o:r}n.push(c,l)}return new ys(s,this.#er,this.#Cr)}#Dr(t){const e=this.#Pr;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#Rr([,t,e]){const i=this.#Dr(t);this.#Pr.splice(i,0,[t,e])}#Nr([,t,e]){const i=this.#Dr(t);for(let s=i;s<this.#Pr.length;s++){const[i,n]=this.#Pr[s];if(i!==t)break;if(i===t&&n===e)return void this.#Pr.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#Pr[s];if(i!==t)break;if(i===t&&n===e)return void this.#Pr.splice(s,1)}}#_r(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#Dr(s);for(let t=0;t<r;t++){const[i,s]=this.#Pr[t];for(let t=0,r=n.length;t<r;t++){const[,o,h]=n[t];if(!(s<=o||h<=i))if(o>=i)if(h>s)n[t][1]=s;else{if(1===r)return[];n.splice(t,1),t--,r--}else n[t][2]=i,h>s&&n.push([e,s,h])}}return n}}class ys extends ws{#er;#Fr;constructor(t,e,i){super(),this.#Fr=t,this.#er=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Fr){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],o=e[n+1];r===i?(t.push(`V${o}`),s=o):o===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],o=i-t,h=s-e;for(const e of this.#Fr){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*o,i[n+1]=s-e[n+1]*h;r.push(i)}return r}get box(){return this.#er}get classNamesForOutlining(){return["highlightOutline"]}}class xs extends As{newFreeDrawOutline(t,e,i,s,n,r){return new Ms(t,e,i,s,n,r)}}class Ms extends bs{newOutliner(t,e,i,s,n,r=0){return new xs(t,e,i,s,n,r)}}class Es{#Or=null;#$r=null;#Lr;#Br=null;#Ur=!1;#jr=!1;#r=null;#zr;#Hr=null;#m=null;#Gr;static#Wr=null;static get _keyboardManager(){return L(this,"_keyboardManager",new Rt([[["Escape","mac+Escape"],Es.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Es.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Es.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Es.prototype._moveToPrevious],[["Home","mac+Home"],Es.prototype._moveToBeginning],[["End","mac+End"],Es.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#jr=!1,this.#Gr=x.HIGHLIGHT_COLOR,this.#r=t):(this.#jr=!0,this.#Gr=x.HIGHLIGHT_DEFAULT_COLOR),this.#m=t?._uiManager||e,this.#zr=this.#m._eventBus,this.#Lr=t?.color||this.#m?.highlightColors.values().next().value||"#FFFF98",Es.#Wr||=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.#Or=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#m._signal;t.addEventListener("click",this.#Vr.bind(this),{signal:e}),t.addEventListener("keydown",this.#nn.bind(this),{signal:e});const i=this.#$r=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Lr,t.append(i),t}renderMainDropdown(){const t=this.#Br=this.#Xr();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Xr(){const t=document.createElement("div"),e=this.#m._signal;t.addEventListener("contextmenu",gt,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[i,s]of this.#m.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",Es.#Wr[i]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.setAttribute("aria-selected",s===this.#Lr),n.addEventListener("click",this.#Yr.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#nn.bind(this),{signal:e}),t}#Yr(t,e){e.stopPropagation(),this.#zr.dispatch("switchannotationeditorparams",{source:this,type:this.#Gr,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Or)return void this.#Vr(t);const e=t.target.getAttribute("data-color");e&&this.#Yr(e,t)}_moveToNext(t){this.#qr?t.target!==this.#Or?t.target.nextSibling?.focus():this.#Br.firstChild?.focus():this.#Vr(t)}_moveToPrevious(t){t.target!==this.#Br?.firstChild&&t.target!==this.#Or?(this.#qr||this.#Vr(t),t.target.previousSibling?.focus()):this.#qr&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#qr?this.#Br.firstChild?.focus():this.#Vr(t)}_moveToEnd(t){this.#qr?this.#Br.lastChild?.focus():this.#Vr(t)}#nn(t){Es._keyboardManager.exec(this,t)}#Vr(t){if(this.#qr)return void this.hideDropdown();if(this.#Ur=0===t.detail,this.#Hr||(this.#Hr=new AbortController,window.addEventListener("pointerdown",this.#l.bind(this),{signal:this.#m.combinedSignal(this.#Hr)})),this.#Br)return void this.#Br.classList.remove("hidden");const e=this.#Br=this.#Xr();this.#Or.append(e)}#l(t){this.#Br?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Br?.classList.add("hidden"),this.#Hr?.abort(),this.#Hr=null}get#qr(){return this.#Br&&!this.#Br.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#jr||(this.#qr?(this.hideDropdown(),this.#Or.focus({preventScroll:!0,focusVisible:this.#Ur})):this.#r?.unselect())}updateColor(t){if(this.#$r&&(this.#$r.style.backgroundColor=t),!this.#Br)return;const e=this.#m.highlightColors.values();for(const i of this.#Br.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Or?.remove(),this.#Or=null,this.#$r=null,this.#Br?.remove(),this.#Br=null}}class Ss extends Ot{#Qr=null;#Kr=0;#Jr;#Zr=null;#n=null;#to=null;#eo=null;#io=0;#so=null;#no=null;#v=null;#ro=!1;#Cr=null;#oo;#ho=null;#ao="";#dr;#co="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=y.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Ss.prototype;return L(this,"_keyboardManager",new Rt([[["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||Ss._defaultColor,this.#dr=t.thickness||Ss._defaultThickness,this.#oo=t.opacity||Ss._defaultOpacity,this.#Jr=t.boxes||null,this.#co=t.methodOfCreation||"",this.#ao=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#ro=!0,this.#lo(t),this.#uo()):this.#Jr&&(this.#Qr=t.anchorNode,this.#Kr=t.anchorOffset,this.#eo=t.focusNode,this.#io=t.focusOffset,this.#do(),this.#uo(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#ro?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#dr,methodOfCreation:this.#co}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#do(){const t=new vs(this.#Jr,.001);this.#no=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#no.box;const e=new vs(this.#Jr,.0025,.001,"ltr"===this._uiManager.direction);this.#to=e.getOutlines();const{lastPoint:i}=this.#to;this.#Cr=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#lo({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#no=t,this.#to=t.getNewOutline(this.#dr/2+1.5,.0025),e>=0)this.#v=e,this.#Zr=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#ho=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#to.box,path:{d:this.#to.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#v,{bbox:Ss.#fo(this.#no.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#ho,{bbox:Ss.#fo(this.#to.box,e),path:{d:this.#to.toSVGPath()}})}const[s,n,r,o]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=r,this.height=o;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=r*e/t,this.height=o*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=r,this.height=o;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=r*e/t,this.height=o*t/e;break}}const{lastPoint:h}=this.#to;this.#Cr=[(h[0]-s)/r,(h[1]-n)/o]}static initialize(t,e){Ot.initialize(t,e),Ss._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case x.HIGHLIGHT_DEFAULT_COLOR:Ss._defaultColor=e;break;case x.HIGHLIGHT_THICKNESS:Ss._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#Cr}updateParams(t,e){switch(t){case x.HIGHLIGHT_COLOR:this.#Xn(e);break;case x.HIGHLIGHT_THICKNESS:this.#po(e)}}static get defaultPropertiesToUpdate(){return[[x.HIGHLIGHT_DEFAULT_COLOR,Ss._defaultColor],[x.HIGHLIGHT_THICKNESS,Ss._defaultThickness]]}get propertiesToUpdate(){return[[x.HIGHLIGHT_COLOR,this.color||Ss._defaultColor],[x.HIGHLIGHT_THICKNESS,this.#dr||Ss._defaultThickness],[x.HIGHLIGHT_FREE,this.#ro]]}#Xn(t){const e=(t,e)=>{this.color=t,this.#oo=e,this.parent?.drawLayer.updateProperties(this.#v,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#oo;this.addCommands({cmd:e.bind(this,t,Ss._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:x.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#po(t){const e=this.#dr,i=t=>{this.#dr=t,this.#go(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:x.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#n=new Es({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#mo())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#mo())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#wo(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#uo(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#wo():t&&(this.#uo(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#go(t){if(!this.#ro)return;this.#lo({highlightOutlines:this.#no.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#wo(){null!==this.#v&&this.parent&&(this.parent.drawLayer.remove(this.#v),this.#v=null,this.parent.drawLayer.remove(this.#ho),this.#ho=null)}#uo(t=this.parent){null===this.#v&&(({id:this.#v,clipPathId:this.#Zr}=t.drawLayer.draw({bbox:this.#no.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#oo},rootClass:{highlight:!0,free:this.#ro},path:{d:this.#no.toSVGPath()}},!1,!0)),this.#ho=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#ro},bbox:this.#to.box,path:{d:this.#to.toSVGPath()}},this.#ro),this.#so&&(this.#so.style.clipPath=this.#Zr))}static#fo([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){const{drawLayer:e}=this.parent;let i;i=this.#ro?Ss.#fo(this.#no.box,t=(t-this.rotation+360)%360):Ss.#fo([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#v,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#ho,{bbox:Ss.#fo(this.#to.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#ao&&(t.setAttribute("aria-label",this.#ao),t.setAttribute("role","mark")),this.#ro?t.classList.add("free"):this.div.addEventListener("keydown",this.#Ao.bind(this),{signal:this._uiManager._signal});const e=this.#so=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#Zr;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),Ct(this,this.#so,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ho,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ho,{rootClass:{hovered:!1}})}#Ao(t){Ss._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#bo(!0);break;case 1:case 3:this.#bo(!1)}}#bo(t){if(!this.#Qr)return;const e=window.getSelection();t?e.setPosition(this.#Qr,this.#Kr):e.setPosition(this.#eo,this.#io)}select(){super.select(),this.#ho&&this.parent?.drawLayer.updateProperties(this.#ho,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#ho&&(this.parent?.drawLayer.updateProperties(this.#ho,{rootClass:{selected:!1}}),this.#ro||this.#bo(!1))}get _mustFixPosition(){return!this.#ro}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#v,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#ho,{rootClass:{hidden:!t}}))}#mo(){return this.#ro?this.rotation:0}#vo(){if(this.#ro)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Jr,r=new Float32Array(8*n.length);let o=0;for(const{x:h,y:a,width:c,height:l}of n){const n=h*t+i,u=(1-a)*e+s;r[o]=r[o+4]=n,r[o+1]=r[o+3]=u,r[o+2]=r[o+6]=n+c*t,r[o+5]=r[o+7]=u-l*e,o+=8}return r}#yo(t){return this.#no.serialize(t,this.#mo())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:r,y:o,width:h,height:a}=i.getBoundingClientRect(),c=new AbortController,l=t.combinedSignal(c),u=e=>{c.abort(),this.#xo(t,e)};window.addEventListener("blur",u,{signal:l}),window.addEventListener("pointerup",u,{signal:l}),window.addEventListener("pointerdown",mt,{capture:!0,passive:!1,signal:l}),window.addEventListener("contextmenu",gt,{signal:l}),i.addEventListener("pointermove",this.#Mo.bind(this,t),{signal:l}),this._freeHighlight=new xs({x:s,y:n},[r,o,h,a],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#Mo(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#xo(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,i){let s=null;if(t instanceof as){const{data:{quadPoints:e,rect:i,rotation:n,id:r,color:o,opacity:h,popupRef:a},parent:{page:{pageNumber:c}}}=t;s=t={annotationType:y.HIGHLIGHT,color:Array.from(o),opacity:h,quadPoints:e,boxes:null,pageIndex:c-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:a}}else if(t instanceof hs){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:o,borderStyle:{rawWidth:h},popupRef:a},parent:{page:{pageNumber:c}}}=t;s=t={annotationType:y.HIGHLIGHT,color:Array.from(o),thickness:h,inkLists:e,boxes:null,pageIndex:c-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:a}}const{color:n,quadPoints:r,inkLists:o,opacity:h}=t,a=await super.deserialize(t,e,i);a.color=Q.makeHexColor(...n),a.#oo=h||1,o&&(a.#dr=t.thickness),a.annotationElementId=t.id||null,a._initialData=s;const[c,l]=a.pageDimensions,[u,d]=a.pageTranslation;if(r){const t=a.#Jr=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-u)/c,y:1-(r[e+1]-d)/l,width:(r[e+2]-r[e])/c,height:(r[e+1]-r[e+5])/l});a.#do(),a.#uo(),a.rotate(a.rotation)}else if(o){a.#ro=!0;const t=o[0],i={x:t[0]-u,y:l-(t[1]-d)},s=new xs(i,[0,0,c,l],1,a.#dr/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-u,i.y=l-(t[e+1]-d),s.add(i);const{id:n,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:a.color,"fill-opacity":a._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);a.#lo({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),a.#uo(),a.rotate(a.parentRotation)}return a}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=Ot._colorManager.convert(this.color),s={annotationType:y.HIGHLIGHT,color:i,opacity:this.#oo,thickness:this.#dr,quadPoints:this.#vo(),outlines:this.#yo(e),pageIndex:this.pageIndex,rect:e,rotation:this.#mo(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#tr(s)?null:(s.id=this.annotationElementId,s)}#tr(t){const{color:e}=this._initialData;return t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class ks{#Eo=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#Eo[t]=e}toSVGProperties(){const t=this.#Eo;return this.#Eo=Object.create(null),{root:t}}reset(){this.#Eo=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){D("Not implemented")}}class Cs extends Ot{#So=null;#ko;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#Co=null;static#To=null;static#Po=null;static#_o=NaN;static#Ro=null;static#No=null;static#Io=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#ko=t.mustBeCommitted||!1,this._addOutlines(t)}_addOutlines(t){t.drawOutlines&&(this.#Do(t),this.#uo())}#Do({drawOutlines:t,drawId:e,drawingOptions:i}){this.#So=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Fo(t,this.parent),this.#Oo(t.box)}#Fo(t,e){const{id:i}=e.drawLayer.draw(Cs._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){D("Not implemented")}static get typesMap(){D("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(Cs.#Co.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=t=>{s.updateProperty(e,t);const i=this.#So.updateProperty(e,t);i&&this.#Oo(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,Cs._mergeSVGProperties(this.#So.getPathResizingSVGProperties(this.#$o()),{bbox:this.#Lo()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Cs._mergeSVGProperties(this.#So.getPathResizedSVGProperties(this.#$o()),{bbox:this.#Lo()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Lo()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,Cs._mergeSVGProperties(this.#So.getPathTranslatedSVGProperties(this.#$o(),this.parentDimensions),{bbox:this.#Lo()}))}_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.#ko&&(this.#ko=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#wo(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#uo(),this.#Oo(this.#So.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#wo()):t&&(this._uiManager.addShouldRescale(this),this.#uo(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#wo(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#uo(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Fo(this.#So,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Bo([t,e,i,s]){const{parentDimensions:[n,r],rotation:o}=this;switch(o){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}}#$o(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:o}=this;switch(o){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}}#Oo(t){if([this.x,this.y,this.width,this.height]=this.#Bo(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Lo(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[o,h]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(o/h),s*(h/o),i*(o/h)];case 5:return[1-e,t,i*(o/h),s*(h/o)];case 6:return[1-t-s*(h/o),1-e,s*(h/o),i*(o/h)];case 7:return[e-i*(o/h),1-t-s*(h/o),i*(o/h),s*(h/o)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(h/o),e,s*(h/o),i*(o/h)];case 13:return[1-e-i*(o/h),t-s*(h/o),i*(o/h),s*(h/o)];case 14:return[1-t,1-e-i*(o/h),s*(h/o),i*(o/h)];case 15:return[e,1-t,i*(o/h),s*(h/o)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,Cs._mergeSVGProperties({bbox:this.#Lo()},this.#So.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Oo(this.#So.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 i=super.render();i.classList.add("draw");const s=document.createElement("div");i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal";const[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,n){D("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:r,offsetY:o,pointerId:h,pointerType:a}=s;if(Cs.#Ro&&Cs.#Ro!==a)return;const{viewport:{rotation:c}}=t,{width:l,height:u}=n.getBoundingClientRect(),d=Cs.#To=new AbortController,f=t.combinedSignal(d);Cs.#_o||=h,Cs.#Ro??=a,window.addEventListener("pointerup",(t=>{Cs.#_o===t.pointerId?this._endDraw(t):Cs.#No?.delete(t.pointerId)}),{signal:f}),window.addEventListener("pointercancel",(t=>{Cs.#_o===t.pointerId?this._currentParent.endDrawingSession():Cs.#No?.delete(t.pointerId)}),{signal:f}),window.addEventListener("pointerdown",(t=>{Cs.#Ro===t.pointerType&&((Cs.#No||=new Set).add(t.pointerId),Cs.#Co.isCancellable()&&(Cs.#Co.removeLastElement(),Cs.#Co.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",gt,{signal:f}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:f}),n.addEventListener("touchmove",(t=>{t.timeStamp===Cs.#Io&&mt(t)}),{signal:f}),t.toggleDrawing(),e._editorUndoBar?.hide(),Cs.#Co?t.drawLayer.updateProperties(this._currentDrawId,Cs.#Co.startNew(r,o,l,u,c)):(e.updateUIForDefaultProperties(this),Cs.#Co=this.createDrawerInstance(r,o,l,u,c),Cs.#Po=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(Cs.#Po.toSVGProperties(),Cs.#Co.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(Cs.#Io=-1,!Cs.#Co)return;const{offsetX:e,offsetY:i,pointerId:s}=t;Cs.#_o===s&&(Cs.#No?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Cs.#Co.add(e,i)),Cs.#Io=t.timeStamp,mt(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,Cs.#Co=null,Cs.#Po=null,Cs.#Ro=null,Cs.#Io=NaN),Cs.#To&&(Cs.#To.abort(),Cs.#To=null,Cs.#_o=NaN,Cs.#No=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,Cs.#Co.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=Cs.#Co,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:x.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(x.DRAW_STEP),!Cs.#Co.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Cs.#Co.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:Cs.#Po,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){D("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:o}}=e.viewport,h=this.deserializeDraw(r,o,s,n,this._INNER_MARGIN,t),a=await super.deserialize(t,e,i);return a.createDrawingOptions(t),a.#Do({drawOutlines:h}),a.#uo(),a.onScaleChanging(),a.rotate(),a}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#So.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Ts{#or=new Float64Array(6);#Tn;#Uo;#rs;#dr;#fr;#jo="";#zo=0;#Fr=new Ps;#Ho;#Go;constructor(t,e,i,s,n,r){this.#Ho=i,this.#Go=s,this.#rs=n,this.#dr=r,[t,e]=this.#Wo(t,e);const o=this.#Tn=[NaN,NaN,NaN,NaN,t,e];this.#fr=[t,e],this.#Uo=[{line:o,points:this.#fr}],this.#or.set(o,0)}updateProperty(t,e){"stroke-width"===t&&(this.#dr=e)}#Wo(t,e){return ws._normalizePoint(t,e,this.#Ho,this.#Go,this.#rs)}isEmpty(){return!this.#Uo||0===this.#Uo.length}isCancellable(){return this.#fr.length<=10}add(t,e){[t,e]=this.#Wo(t,e);const[i,s,n,r]=this.#or.subarray(2,6);return Math.hypot(this.#Ho*(t-n),this.#Go*(e-r))<=2?null:(this.#fr.push(t,e),isNaN(i)?(this.#or.set([n,r,t,e],2),this.#Tn.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#or[0])&&this.#Tn.splice(6,6),this.#or.set([i,s,n,r,t,e],0),this.#Tn.push(...ws.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){return this.add(t,e)||(2===this.#fr.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#Ho=i,this.#Go=s,this.#rs=n,[t,e]=this.#Wo(t,e);const r=this.#Tn=[NaN,NaN,NaN,NaN,t,e];this.#fr=[t,e];const o=this.#Uo.at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),this.#Uo.push({line:r,points:this.#fr}),this.#or.set(r,0),this.#zo=0,this.toSVGPath(),null}getLastElement(){return this.#Uo.at(-1)}setLastElement(t){return this.#Uo?(this.#Uo.push(t),this.#Tn=t.line,this.#fr=t.points,this.#zo=0,{path:{d:this.toSVGPath()}}):this.#Fr.setLastElement(t)}removeLastElement(){if(!this.#Uo)return this.#Fr.removeLastElement();this.#Uo.pop(),this.#jo="";for(let t=0,e=this.#Uo.length;t<e;t++){const{line:e,points:i}=this.#Uo[t];this.#Tn=e,this.#fr=i,this.#zo=0,this.toSVGPath()}return{path:{d:this.#jo}}}toSVGPath(){const t=ws.svgRound(this.#Tn[4]),e=ws.svgRound(this.#Tn[5]);if(2===this.#fr.length)return this.#jo=`${this.#jo} M ${t} ${e} Z`,this.#jo;if(this.#fr.length<=6){const i=this.#jo.lastIndexOf("M");this.#jo=`${this.#jo.slice(0,i)} M ${t} ${e}`,this.#zo=6}if(4===this.#fr.length){const t=ws.svgRound(this.#Tn[10]),e=ws.svgRound(this.#Tn[11]);return this.#jo=`${this.#jo} L ${t} ${e}`,this.#zo=12,this.#jo}const i=[];0===this.#zo&&(i.push(`M ${t} ${e}`),this.#zo=6);for(let t=this.#zo,e=this.#Tn.length;t<e;t+=6){const[e,s,n,r,o,h]=this.#Tn.slice(t,t+6).map(ws.svgRound);i.push(`C${e} ${s} ${n} ${r} ${o} ${h}`)}return this.#jo+=i.join(" "),this.#zo=this.#Tn.length,this.#jo}getOutlines(t,e,i,s){const n=this.#Uo.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Fr.build(this.#Uo,t,e,i,this.#rs,this.#dr,s),this.#or=null,this.#Tn=null,this.#Uo=null,this.#jo=null,this.#Fr}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Ps extends ws{#Er;#Vo=0;#sr;#Uo;#Ho;#Go;#Xo;#rs;#dr;build(t,e,i,s,n,r,o){this.#Ho=e,this.#Go=i,this.#Xo=s,this.#rs=n,this.#dr=r,this.#sr=o??0,this.#Uo=t,this.#Yo()}get thickness(){return this.#dr}setLastElement(t){return this.#Uo.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Uo.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Uo)if(t.push(`M${ws.svgRound(e[4])} ${ws.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${ws.svgRound(e[10])} ${ws.svgRound(e[11])}`);else for(let i=6,s=e.length;i<s;i+=6){const[s,n,r,o,h,a]=e.subarray(i,i+6).map(ws.svgRound);t.push(`C${s} ${n} ${r} ${o} ${h} ${a}`)}else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const r=[],o=[],[h,a,c,l]=this.#qo();let u,d,f,p,g,m,w,A,b;switch(this.#rs){case 0:b=ws._rescale,u=t,d=e+s,f=i,p=-s,g=t+h*i,m=e+(1-a-l)*s,w=t+(h+c)*i,A=e+(1-a)*s;break;case 90:b=ws._rescaleAndSwap,u=t,d=e,f=i,p=s,g=t+a*i,m=e+h*s,w=t+(a+l)*i,A=e+(h+c)*s;break;case 180:b=ws._rescale,u=t+i,d=e,f=-i,p=s,g=t+(1-h-c)*i,m=e+a*s,w=t+(1-h)*i,A=e+(a+l)*s;break;case 270:b=ws._rescaleAndSwap,u=t+i,d=e+s,f=-i,p=-s,g=t+(1-a-l)*i,m=e+(1-h-c)*s,w=t+(1-a)*i,A=e+(1-h)*s}for(const{line:t,points:e}of this.#Uo)r.push(b(t,u,d,f,p,n?new Array(t.length):null)),o.push(b(e,u,d,f,p,n?new Array(e.length):null));return{lines:r,points:o,rect:[g,m,w,A]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:o},rotation:h,thickness:a}){const c=[];let l,u,d,f,p;switch(h){case 0:p=ws._rescale,l=-t/i,u=e/s+1,d=1/i,f=-1/s;break;case 90:p=ws._rescaleAndSwap,l=-e/s,u=-t/i,d=1/s,f=1/i;break;case 180:p=ws._rescale,l=t/i+1,u=-e/s,d=-1/i,f=1/s;break;case 270:p=ws._rescaleAndSwap,l=e/s+1,u=t/i+1,d=-1/s,f=-1/i}if(!r){r=[];for(const t of o){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));r.push(i);let[s,n,o,h]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){const e=t[r],a=t[r+1];i.set(ws.createBezierPoints(s,n,o,h,e,a),3*(r-2)),[s,n,o,h]=[o,h,e,a]}}}for(let t=0,e=r.length;t<e;t++)c.push({line:p(r[t].map((t=>t??NaN)),l,u,d,f),points:p(o[t].map((t=>t??NaN)),l,u,d,f)});const g=new this.prototype.constructor;return g.build(c,i,s,1,h,a,n),g}#Qo(t=this.#dr){const e=this.#sr+t/2*this.#Xo;return this.#rs%180==0?[e/this.#Ho,e/this.#Go]:[e/this.#Go,e/this.#Ho]}#qo(){const[t,e,i,s]=this.#Er,[n,r]=this.#Qo(0);return[t+n,e+r,i-2*n,s-2*r]}#Yo(){const t=this.#Er=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#Uo){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)Q.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let n=6,r=e.length;n<r;n+=6){const[r,o,h,a,c,l]=e.subarray(n,n+6);Q.bezierBoundingBox(i,s,r,o,h,a,c,l,t),i=c,s=l}}const[e,i]=this.#Qo();t[0]=it(t[0]-e,0,1),t[1]=it(t[1]-i,0,1),t[2]=it(t[2]+e,0,1),t[3]=it(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#Er}updateProperty(t,e){return"stroke-width"===t?this.#po(e):null}#po(t){const[e,i]=this.#Qo();this.#dr=t;const[s,n]=this.#Qo(),[r,o]=[s-e,n-i],h=this.#Er;return h[0]-=r,h[1]-=o,h[2]+=2*r,h[3]+=2*o,h}updateParentDimensions([t,e],i){const[s,n]=this.#Qo();this.#Ho=t,this.#Go=e,this.#Xo=i;const[r,o]=this.#Qo(),h=r-s,a=o-n,c=this.#Er;return c[0]-=h,c[1]-=a,c[2]+=2*h,c[3]+=2*a,c}updateRotation(t){return this.#Vo=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#Er.map(ws.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#Er;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ws.svgRound(t)} ${ws.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#Er;let i=0,s=0,n=0,r=0,o=0,h=0;switch(this.#Vo){case 90:s=e/t,n=-t/e,o=t;break;case 180:i=-1,r=-1,o=t,h=e;break;case 270:s=-e/t,n=t/e,h=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${ws.svgRound(o)} ${ws.svgRound(h)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#Qo(),[o,h,a,c]=this.#Er;if(Math.abs(a-n)<=ws.PRECISION||Math.abs(c-r)<=ws.PRECISION){const n=t+i/2-(o+a/2),r=e+s/2-(h+c/2);return{path:{"transform-origin":`${ws.svgRound(t)} ${ws.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const l=(i-2*n)/(a-2*n),u=(s-2*r)/(c-2*r),d=a/i,f=c/s;return{path:{"transform-origin":`${ws.svgRound(o)} ${ws.svgRound(h)}`,transform:`${this.rotationTransform} scale(${d} ${f}) translate(${ws.svgRound(n)} ${ws.svgRound(r)}) scale(${l} ${u}) translate(${ws.svgRound(-n)} ${ws.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#Qo(),o=this.#Er,[h,a,c,l]=o;if(o[0]=t,o[1]=e,o[2]=i,o[3]=s,Math.abs(c-n)<=ws.PRECISION||Math.abs(l-r)<=ws.PRECISION){const n=t+i/2-(h+c/2),r=e+s/2-(a+l/2);for(const{line:t,points:e}of this.#Uo)ws._translate(t,n,r,t),ws._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ws.svgRound(t)} ${ws.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(i-2*n)/(c-2*n),d=(s-2*r)/(l-2*r),f=-u*(h+n)+t+n,p=-d*(a+r)+e+r;if(1!==u||1!==d||0!==f||0!==p)for(const{line:t,points:e}of this.#Uo)ws._rescale(t,f,p,u,d,t),ws._rescale(e,f,p,u,d,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ws.svgRound(t)} ${ws.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#Er,o=t-r[0],h=e-r[1];if(this.#Ho===s&&this.#Go===n)for(const{line:t,points:e}of this.#Uo)ws._translate(t,o,h,t),ws._translate(e,o,h,e);else{const t=this.#Ho/s,e=this.#Go/n;this.#Ho=s,this.#Go=n;for(const{line:i,points:s}of this.#Uo)ws._rescale(i,o,h,t,e,i),ws._rescale(s,o,h,t,e,s);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${ws.svgRound(t)} ${ws.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#Er;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${ws.svgRound(t[0])} ${ws.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class _s extends ks{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:Ot._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new _s(this._viewParameters);return t.updateAll(this),t}}class Rs extends Cs{static _type="ink";static _editorType=y.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){Ot.initialize(t,e),this._defaultDrawingOptions=new _s(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return L(this,"typesMap",new Map([[x.INK_THICKNESS,"stroke-width"],[x.INK_COLOR,"stroke"],[x.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new Ts(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return Ps.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof hs){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:o,opacity:h,borderStyle:{rawWidth:a},popupRef:c},parent:{page:{pageNumber:l}}}=t;s=t={annotationType:y.INK,color:Array.from(o),thickness:a,opacity:h,paths:{points:e},boxes:null,pageIndex:l-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:c}}const n=await super.deserialize(t,e,i);return n.annotationElementId=t.id||null,n._initialData=s,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.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:i}){this._drawingOptions=Rs.getDefaultDrawingOptions({stroke:Q.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":o}}=this,h={annotationType:y.INK,color:Ot._colorManager.convert(n),opacity:r,thickness:o,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(h.isCopy=!0,h):this.annotationElementId&&!this.#tr(h)?null:(h.id=this.annotationElementId,h)}#tr(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class Ns extends Ps{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class Is{static#Ko={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#Jo(t,e,i,s){return s-=e,0==(i-=t)?s>0?0:4:1===i?s+6:2-s}static#Zo=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#th(t,e,i,s,n,r,o){const h=this.#Jo(i,s,n,r);for(let n=0;n<8;n++){const r=(-n+h-o+16)%8;if(0!==t[(i+this.#Zo[2*r])*e+(s+this.#Zo[2*r+1])])return r}return-1}static#eh(t,e,i,s,n,r,o){const h=this.#Jo(i,s,n,r);for(let n=0;n<8;n++){const r=(n+h+o+16)%8;if(0!==t[(i+this.#Zo[2*r])*e+(s+this.#Zo[2*r+1])])return r}return-1}static#ih(t,e,i,s){const n=t.length,r=new Int32Array(n);for(let e=0;e<n;e++)r[e]=t[e]<=s?1:0;for(let t=1;t<i-1;t++)r[t*e]=r[t*e+e-1]=0;for(let t=0;t<e;t++)r[t]=r[e*i-1-t]=0;let o,h=1;const a=[];for(let t=1;t<i-1;t++){o=1;for(let i=1;i<e-1;i++){const s=t*e+i,n=r[s];if(0===n)continue;let c=t,l=i;if(1===n&&0===r[s-1])h+=1,l-=1;else{if(!(n>=1&&0===r[s+1])){1!==n&&(o=Math.abs(n));continue}h+=1,l+=1,n>1&&(o=n)}const u=[i,t],d=l===i+1,f={isHole:d,points:u,id:h,parent:0};let p;a.push(f);for(const t of a)if(t.id===o){p=t;break}f.parent=p?p.isHole?d?p.parent:o:d?o:p.parent:d?o:0;const g=this.#th(r,e,t,i,c,l,0);if(-1===g){r[s]=-h,1!==r[s]&&(o=Math.abs(r[s]));continue}let m=this.#Zo[2*g],w=this.#Zo[2*g+1];const A=t+m,b=i+w;c=A,l=b;let v=t,y=i;for(;;){const n=this.#eh(r,e,v,y,c,l,1);m=this.#Zo[2*n],w=this.#Zo[2*n+1];const a=v+m,d=y+w;u.push(d,a);const f=v*e+y;if(0===r[f+1]?r[f]=-h:1===r[f]&&(r[f]=h),a===t&&d===i&&v===A&&y===b){1!==r[s]&&(o=Math.abs(r[s]));break}c=v,l=y,v=a,y=d}}}return a}static#sh(t,e,i,s){if(i-e<=4){for(let n=e;n<i-2;n+=2)s.push(t[n],t[n+1]);return}const n=t[e],r=t[e+1],o=t[i-4]-n,h=t[i-3]-r,a=Math.hypot(o,h),c=o/a,l=h/a,u=c*r-l*n,d=1/a,f=Math.atan(h/o),p=Math.cos(f),g=Math.sin(f),m=d*(Math.abs(p)+Math.abs(g)),w=d*(1-m+m**2),A=Math.max(Math.atan(Math.abs(g+p)*w),Math.atan(Math.abs(g-p)*w));let b=0,v=e;for(let s=e+2;s<i-2;s+=2){const e=Math.abs(u-c*t[s+1]+l*t[s]);e>b&&(v=s,b=e)}b>(a*A)**2?(this.#sh(t,e,v+2,s),this.#sh(t,v,i,s)):s.push(n,r)}static#nh(t){const e=[],i=t.length;return this.#sh(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#rh(t,e,i,s,n,r){const o=new Float32Array(r**2),h=-2*s**2,a=r>>1;for(let t=0;t<r;t++){const e=(t-a)**2;for(let i=0;i<r;i++)o[t*r+i]=Math.exp((e+(i-a)**2)/h)}const c=new Float32Array(256),l=-2*n**2;for(let t=0;t<256;t++)c[t]=Math.exp(t**2/l);const u=new Uint8Array(t.length),d=new Uint32Array(256);for(let s=0;s<i;s++)for(let n=0;n<e;n++){const h=s*e+n,l=t[h];let f=0,p=0;for(let h=0;h<r;h++){const u=s+h-a;if(!(u<0||u>=i))for(let i=0;i<r;i++){const s=n+i-a;if(s<0||s>=e)continue;const d=t[u*e+s],g=o[h*r+i]*c[Math.abs(d-l)];f+=d*g,p+=g}}d[u[h]=Math.round(f/p)]++}return[u,d]}static#oh(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#hh(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let s=-1/0,n=1/0;for(let e=0,r=i.length;e<r;e++){if(0===t[3+(e<<2)]){s=i[e]=255;continue}const r=i[e]=t[e<<2];r>s&&(s=r),r<n&&(n=r)}const r=255/(s-n);for(let t=0;t<e;t++)i[t]=(i[t]-n)*r;return i}static#ah(t){let e,i=-1/0,s=-1/0;const n=t.findIndex((t=>0!==t));let r=n,o=n;for(e=n;e<256;e++){const n=t[e];n>i&&(e-r>s&&(s=e-r,o=e-1),i=n,r=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#ch(t){const e=t,{width:i,height:s}=t,{maxDim:n}=this.#Ko;let r=i,o=s;if(i>n||s>n){let h=i,a=s,c=Math.log2(Math.max(i,s)/n);const l=Math.floor(c);c=c===l?l-1:l;for(let i=0;i<c;i++){r=Math.ceil(h/2),o=Math.ceil(a/2);const i=new OffscreenCanvas(r,o);i.getContext("2d").drawImage(t,0,0,h,a,0,0,r,o),h=r,a=o,t!==e&&t.close(),t=i.transferToImageBitmap()}const u=Math.min(n/r,n/o);r=Math.round(r*u),o=Math.round(o*u)}const h=new OffscreenCanvas(r,o).getContext("2d",{willReadFrequently:!0});h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,r,o);const a=h.getImageData(0,0,r,o).data;return[this.#hh(a),r,o]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},n,r,o,h){let a=new OffscreenCanvas(1,1),c=a.getContext("2d",{alpha:!1});const l=c.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:u,actualBoundingBoxRight:d,actualBoundingBoxAscent:f,actualBoundingBoxDescent:p,fontBoundingBoxAscent:g,fontBoundingBoxDescent:m,width:w}=c.measureText(t),A=Math.ceil(1.5*Math.max(Math.abs(u)+Math.abs(d)||0,w)),b=Math.ceil(1.5*Math.max(Math.abs(f)+Math.abs(p)||200,Math.abs(g)+Math.abs(m)||200));a=new OffscreenCanvas(A,b),c=a.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=l,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,A,b),c.fillStyle="black",c.fillText(t,.5*A/2,1.5*b/2);const v=this.#hh(c.getImageData(0,0,A,b).data),y=this.#oh(v),x=this.#ah(y),M=this.#ih(v,A,b,x);return this.processDrawnLines({lines:{curves:M,width:A,height:b},pageWidth:n,pageHeight:r,rotation:o,innerMargin:h,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){const[r,o,h]=this.#ch(t),[a,c]=this.#rh(r,o,h,Math.hypot(o,h)*this.#Ko.sigmaSFactor,this.#Ko.sigmaR,this.#Ko.kernelSize),l=this.#ah(c),u=this.#ih(a,o,h,l);return this.processDrawnLines({lines:{curves:u,width:o,height:h},pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:n,mustSmooth:r,areContours:o}){s%180!=0&&([e,i]=[i,e]);const{curves:h,width:a,height:c}=t,l=t.thickness??0,u=[],d=Math.min(e/a,i/c),f=d/e,p=d/i,g=[];for(const{points:t}of h){const e=r?this.#nh(t):t;if(!e)continue;g.push(e);const i=e.length,s=new Float32Array(i),n=new Float32Array(3*(2===i?2:i-2));if(u.push({line:n,points:s}),2===i){s[0]=e[0]*f,s[1]=e[1]*p,n.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[o,h,a,c]=e;o*=f,h*=p,a*=f,c*=p,s.set([o,h,a,c],0),n.set([NaN,NaN,NaN,NaN,o,h],0);for(let t=4;t<i;t+=2){const i=s[t]=e[t]*f,r=s[t+1]=e[t+1]*p;n.set(ws.createBezierPoints(o,h,a,c,i,r),3*(t-2)),[o,h,a,c]=[a,c,i,r]}}if(0===u.length)return null;const m=o?new Ns:new Ps;return m.build(u,e,i,1,s,o?0:l,n),{outline:m,newCurves:g,areContours:o,thickness:l,width:a,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:n}){let r,o=1/0,h=-1/0,a=0;for(const e of t){a+=e.length;for(let t=2,i=e.length;t<i;t++){const i=e[t]-e[t-2];o=Math.min(o,i),h=Math.max(h,i)}}r=o>=-128&&h<=127?Int8Array:o>=-32768&&h<=32767?Int16Array:Int32Array;const c=t.length,l=8+3*c,u=new Uint32Array(l);let d=0;u[d++]=l*Uint32Array.BYTES_PER_ELEMENT+(a-2*c)*r.BYTES_PER_ELEMENT,u[d++]=0,u[d++]=s,u[d++]=n,u[d++]=e?0:1,u[d++]=Math.max(0,Math.floor(i??0)),u[d++]=c,u[d++]=r.BYTES_PER_ELEMENT;for(const e of t)u[d++]=e.length-2,u[d++]=e[0],u[d++]=e[1];const f=new CompressionStream("deflate-raw"),p=f.writable.getWriter();await p.ready,p.write(u);const g=r.prototype.constructor;for(const e of t){const t=new g(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];p.write(t)}p.close();const m=await new Response(f.readable).arrayBuffer();return st(new Uint8Array(m))}static async decompressSignature(t){try{const i=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):X(atob(e))),{readable:s,writable:n}=new DecompressionStream("deflate-raw"),r=n.getWriter();await r.ready,r.write(i).then((async()=>{await r.ready,await r.close()})).catch((()=>{}));let o=null,h=0;for await(const t of s)o||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),o.set(t,h),h+=t.length;const a=new Uint32Array(o.buffer,0,o.length>>2),c=a[1];if(0!==c)throw new Error(`Invalid version: ${c}`);const l=a[2],u=a[3],d=0===a[4],f=a[5],p=a[6],g=[],m=(8+3*p)*Uint32Array.BYTES_PER_ELEMENT;let w;switch(a[7]){case Int8Array.BYTES_PER_ELEMENT:w=new Int8Array(o.buffer,m);break;case Int16Array.BYTES_PER_ELEMENT:w=new Int16Array(o.buffer,m);break;case Int32Array.BYTES_PER_ELEMENT:w=new Int32Array(o.buffer,m)}h=0;for(let t=0;t<p;t++){const e=a[3*t+8],i=new Float32Array(e+2);g.push(i);for(let e=0;e<2;e++)i[e]=a[3*t+8+e+1];for(let t=0;t<e;t++)i[t+2]=i[t]+w[h++]}return{areContours:d,thickness:f,outlines:g,width:l,height:u}}catch(t){return I(`decompressSignature: ${t}`),null}var e}}class Ds extends ks{constructor(){super(),super.updateProperties({fill:Ot._defaultLineColor,"stroke-width":0})}clone(){const t=new Ds;return t.updateAll(this),t}}class Fs extends _s{constructor(t){super(t),super.updateProperties({stroke:Ot._defaultLineColor,"stroke-width":1})}clone(){const t=new Fs(this._viewParameters);return t.updateAll(this),t}}class Os extends Cs{#lh=!1;#uh=null;#dh=null;#fh=null;static _type="signature";static _editorType=y.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#dh=t.signatureData||null,this.#uh=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){Ot.initialize(t,e),this._defaultDrawingOptions=new Ds,this._defaultDrawnSignatureOptions=new Fs(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return L(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#uh}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#dh){const{lines:t,mustSmooth:e,areContours:i,description:s,uuid:n,heightInPage:r}=this.#dh,{rawDims:{pageWidth:o,pageHeight:h},rotation:a}=this.parent.viewport,c=Is.processDrawnLines({lines:t,pageWidth:o,pageHeight:h,rotation:a,innerMargin:Os._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(c,r,s,n)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#fh=t,this.addEditToolbar()}getUuid(){return this.#fh}get description(){return this.#uh}set description(t){this.#uh=t,super.addEditToolbar().then((e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:s,height:n}=this.#dh,r=Math.max(s,n);return{areContours:e,outline:Is.processDrawnLines({lines:{curves:t.map((t=>({points:t}))),thickness:i,width:s,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.signatureManager&&null!==this.#uh&&(await t.addEditSignatureButton(this._uiManager.signatureManager,this.#fh,this.#uh),t.show()),t):null}addSignature(t,e,i,s){const{x:n,y:r}=this,{outline:o}=this.#dh=t;let h;this.#lh=o instanceof Ns,this.#uh=i,this.div.setAttribute("data-l10n-args",JSON.stringify({description:i})),this.#lh?h=Os.getDefaultDrawingOptions():(h=Os._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":o.thickness})),this._addOutlines({drawOutlines:o,drawingOptions:h});const[a,c]=this.parentDimensions,[,l]=this.pageDimensions;let u=e/l;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(a*this.width,c*this.height),this.x=n,this.y=r,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return Is.process(t,e,i,s,Os._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return Is.extractContoursFromText(t,e,i,s,n,Os._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return Is.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:Os._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=Os.getDefaultDrawingOptions():(this._drawingOptions=Os._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,r={annotationType:y.SIGNATURE,isSignature:!0,areContours:this.#lh,color:[0,0,0],thickness:this.#lh?0:n,pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?(r.paths={lines:e,points:i},r.uuid=this.#fh,r.isCopy=!0):r.lines=e,this.#uh&&(r.accessibilityData={type:"Figure",alt:this.#uh}),r}static deserializeDraw(t,e,i,s,n,r){return r.areContours?Ns.deserialize(t,e,i,s,n,r):Ps.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){const s=await super.deserialize(t,e,i);return s.#lh=t.areContours,s.#uh=t.accessibilityData?.alt||"",s.#fh=t.uuid,s}}class $s extends Ot{#ph=null;#gh=null;#mh=null;#wh=null;#Ah=null;#bh="";#vh=null;#yh=!1;#xh=null;#Mh=!1;#Eh=!1;static _type="stamp";static _editorType=y.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#wh=t.bitmapUrl,this.#Ah=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){Ot.initialize(t,e)}static isHandlingMimeForPasting(t){return Et.includes(t)}static paste(t,e){e.pasteEditor({mode:y.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}}#Sh(t,e=!1){t?(this.#ph=t.bitmap,e||(this.#gh=t.id,this.#Mh=t.isSvg),t.file&&(this.#bh=t.file.name),this.#kh()):this.remove()}#Ch(){if(this.#mh=null,this._uiManager.enableWaiting(!1),this.#vh){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#ph)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#ph){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:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,o=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!o)throw new Error("No response from the AI service.");if(o.error)throw new Error("Error from the AI service.");if(o.cancel)return null;if(!o.output)throw new Error("No valid response from the AI service.");const h=o.output;return await this.setGuessedAltText(h),e&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}#Th(){if(this.#gh)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#gh).then((t=>this.#Sh(t,!0))).finally((()=>this.#Ch()));if(this.#wh){const t=this.#wh;return this.#wh=null,this._uiManager.enableWaiting(!0),void(this.#mh=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Sh(t))).finally((()=>this.#Ch())))}if(this.#Ah){const t=this.#Ah;return this.#Ah=null,this._uiManager.enableWaiting(!0),void(this.#mh=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Sh(t))).finally((()=>this.#Ch())))}const t=document.createElement("input");t.type="file",t.accept=Et.join(",");const e=this._uiManager._signal;this.#mh=new Promise((i=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Sh(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Ch())),t.click()}remove(){this.#gh&&(this.#ph=null,this._uiManager.imageManager.deleteId(this.#gh),this.#vh?.remove(),this.#vh=null,this.#xh&&(clearTimeout(this.#xh),this.#xh=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#gh&&null===this.#vh&&this.#Th(),this.isAttachedToDOM||this.parent.add(this))):this.#gh&&this.#Th()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#mh||this.#ph||this.#wh||this.#Ah||this.#gh||this.#yh)}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.addAltTextButton(),this.#yh||(this.#ph?this.#kh():this.#Th()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#gh=i,s&&(this.#ph=s),this.#yh=!1,this.#kh())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#xh&&clearTimeout(this.#xh),this.#xh=setTimeout((()=>{this.#xh=null,this.#Ph()}),200))}#kh(){const{div:t}=this;let{width:e,height:i}=this.#ph;const[s,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>r*s||i>r*n){const t=Math.min(r*s/e,r*n/i);e*=t,i*=t}const[o,h]=this.parentDimensions;this.setDims(e*o/s,i*h/n),this._uiManager.enableWaiting(!1);const a=this.#vh=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#Ph(),this.#Eh||(this.parent.addUndoableEditor(this),this.#Eh=!0),this._reportTelemetry({action:"inserted_image"}),this.#bh&&this.div.setAttribute("aria-description",this.#bh)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#ph,r=new Mt;let o=this.#ph,h=s,a=n,c=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);h=Math.floor(s*t),a=Math.floor(n*t)}c=document.createElement("canvas");const t=c.width=Math.ceil(h*r.sx),i=c.height=Math.ceil(a*r.sy);this.#Mh||(o=this.#_h(t,i));const l=c.getContext("2d");l.filter=this._uiManager.hcmFilter;let u="white",d="#cfcfd8";"none"!==this._uiManager.hcmFilter?d="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(u="#8f8f9d",d="#42414d");const f=15,p=f*r.sx,g=f*r.sy,m=new OffscreenCanvas(2*p,2*g),w=m.getContext("2d");w.fillStyle=u,w.fillRect(0,0,2*p,2*g),w.fillStyle=d,w.fillRect(0,0,p,g),w.fillRect(p,g,p,g),l.fillStyle=l.createPattern(m,"repeat"),l.fillRect(0,0,t,i),l.drawImage(o,0,0,o.width,o.height,0,0,t,i)}let l=null;if(i){let e,i;if(r.symmetric&&o.width<t&&o.height<t)e=o.width,i=o.height;else if(o=this.#ph,s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#Mh||(o=this.#_h(e,i))}const h=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});h.drawImage(o,0,0,o.width,o.height,0,0,e,i),l={width:e,height:i,data:h.getImageData(0,0,e,i).data}}return{canvas:c,width:h,height:a,imageData:l}}#_h(t,e){const{width:i,height:s}=this.#ph;let n=i,r=s,o=this.#ph;for(;n>2*t||r>2*e;){const i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const h=new OffscreenCanvas(n,r);h.getContext("2d").drawImage(o,0,0,i,s,0,0,n,r),o=h.transferToImageBitmap()}return o}#Ph(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Mt,r=Math.ceil(i*t*n.sx),o=Math.ceil(s*e*n.sy),h=this.#vh;if(!h||h.width===r&&h.height===o)return;h.width=r,h.height=o;const a=this.#Mh?this.#ph:this.#_h(r,o),c=h.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(a,0,0,a.width,a.height,0,0,r,o)}#Rh(t){if(t){if(this.#Mh){const t=this._uiManager.imageManager.getSvgUrl(this.#gh);if(t)return t}const t=document.createElement("canvas");return({width:t.width,height:t.height}=this.#ph),t.getContext("2d").drawImage(this.#ph,0,0),t.toDataURL()}if(this.#Mh){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*rt.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*rt.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#ph,0,0,this.#ph.width,this.#ph.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#ph)}static async deserialize(t,e,i){let s=null,n=!1;if(t instanceof ds){const{data:{rect:r,rotation:o,id:h,structParent:a,popupRef:c},container:l,parent:{page:{pageNumber:u}},canvas:d}=t;let f,p;d?(delete t.canvas,({id:f,bitmap:p}=i.imageManager.getFromCanvas(l.id,d)),d.remove()):(n=!0,t._hasNoCanvas=!0);const g=(await e._structTree.getAriaAttributes(`${et}${h}`))?.get("aria-label")||"";s=t={annotationType:y.STAMP,bitmapId:f,bitmap:p,pageIndex:u-1,rect:r.slice(0),rotation:o,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:g},isSvg:!1,structParent:a,popupRef:c}}const r=await super.deserialize(t,e,i),{rect:o,bitmap:h,bitmapUrl:a,bitmapId:c,isSvg:l,accessibilityData:u}=t;n?(i.addMissingCanvas(t.id,r),r.#yh=!0):c&&i.imageManager.isValidId(c)?(r.#gh=c,h&&(r.#ph=h)):r.#wh=a,r.#Mh=l;const[d,f]=r.pageDimensions;return r.width=(o[2]-o[0])/d,r.height=(o[3]-o[1])/f,r.annotationElementId=t.id||null,u&&(r.altTextData=u),r._initialData=s,r.#Eh=!!s,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:y.STAMP,bitmapId:this.#gh,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Mh,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#Rh(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#tr(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const r=this.#Mh?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#gh)){if(this.#Mh){const t=e.stamps.get(this.#gh);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#Rh(!1))}}else e.stamps.set(this.#gh,{area:r,serialized:i}),i.bitmap=this.#Rh(!1);return i}#tr(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}class Ls{#$n;#Nh=!1;#Ih=null;#Dh=null;#Fh=null;#Oh=new Map;#$h=!1;#Lh=!1;#Bh=!1;#Uh=null;#jh=null;#zh=null;#Hh=null;#m;static _initialized=!1;static#z=new Map([ms,Rs,$s,Ss,Os].map((t=>[t._editorType,t])));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:n,annotationLayer:r,drawLayer:o,textLayer:h,viewport:a,l10n:c}){const l=[...Ls.#z.values()];if(!Ls._initialized){Ls._initialized=!0;for(const e of l)e.initialize(c,t)}t.registerEditorTypes(l),this.#m=t,this.pageIndex=e,this.div=i,this.#$n=n,this.#Ih=r,this.viewport=a,this.#zh=h,this.drawLayer=o,this._structTree=s,this.#m.addLayer(this)}get isEmpty(){return 0===this.#Oh.size}get isInvisible(){return this.isEmpty&&this.#m.getMode()===y.NONE}updateToolbar(t){this.#m.updateToolbar(t)}updateMode(t=this.#m.getMode()){switch(this.#Gh(),t){case y.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case y.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case y.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;for(const i of Ls.#z.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#zh?.div}setEditingState(t){this.#m.setEditingState(t)}addCommands(t){this.#m.addCommands(t)}cleanUndoStack(t){this.#m.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#Ih?.div.classList.toggle("disabled",!t)}async enable(){this.#Bh=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#Oh.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#m.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#Ih)return void(this.#Bh=!1);const e=this.#Ih.getEditableAnnotations();for(const i of e){if(i.hide(),this.#m.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#Bh=!1}disable(){this.#Lh=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of this.#Oh.values())i.disableEditing(),i.annotationElementId&&(null===i.serialize()?(e.set(i.annotationElementId,i),this.getEditableAnnotation(i.annotationElementId)?.show(),i.remove()):t.set(i.annotationElementId,i));if(this.#Ih){const i=this.#Ih.getEditableAnnotations();for(const s of i){const{id:i}=s.data;if(this.#m.isDeletedAnnotationElement(i))continue;let n=e.get(i);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=t.get(i),n&&(this.#m.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#Gh(),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const t of Ls.#z.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#Lh=!1}getEditableAnnotation(t){return this.#Ih?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#m.getActive()!==t&&this.#m.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#zh?.div&&!this.#Hh){this.#Hh=new AbortController;const t=this.#m.combinedSignal(this.#Hh);this.#zh.div.addEventListener("pointerdown",this.#Wh.bind(this),{signal:t}),this.#zh.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#zh?.div&&this.#Hh&&(this.#Hh.abort(),this.#Hh=null,this.#zh.div.classList.remove("highlighting"))}#Wh(t){this.#m.unselectAll();const{target:e}=t;if(e===this.#zh.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#zh.div.contains(e)){const{isMac:e}=Y.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#m.showAllEditors("highlight",!0,!0),this.#zh.div.classList.add("free"),this.toggleDrawing(),Ss.startHighlighting(this,"ltr"===this.#m.direction,{target:this.#zh.div,x:t.x,y:t.y}),this.#zh.div.addEventListener("pointerup",(()=>{this.#zh.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#m._signal}),t.preventDefault()}}enableClick(){if(this.#Dh)return;this.#Dh=new AbortController;const t=this.#m.combinedSignal(this.#Dh);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.#Dh?.abort(),this.#Dh=null}attach(t){this.#Oh.set(t.id,t);const{annotationElementId:e}=t;e&&this.#m.isDeletedAnnotationElement(e)&&this.#m.removeDeletedAnnotationElement(t)}detach(t){this.#Oh.delete(t.id),this.#$n?.removePointerInTextLayer(t.contentDiv),!this.#Lh&&t.annotationElementId&&this.#m.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#m.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#m.addDeletedAnnotationElement(t.annotationElementId),Ot.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.#m.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#Bh),this.#m.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Fh&&(t._focusEventsAllowed=!1,this.#Fh=setTimeout((()=>{this.#Fh=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#m._signal}),e.focus())}),0)),t._structTreeParentId=this.#$n?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#m.getId()}get#Vh(){return Ls.#z.get(this.#m.getMode())}combinedSignal(t){return this.#m.combinedSignal(t)}#Xh(t){const e=this.#Vh;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#Vh?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#m.updateMode(t.mode);const{offsetX:i,offsetY:s}=this.#Yh(),n=this.getNextId(),r=this.#Xh({parent:this,id:n,x:i,y:s,uiManager:this.#m,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await(Ls.#z.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#m))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#Xh({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#m,isCentered:e,...i});return n&&this.add(n),n}#Yh(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),o=(n+Math.min(window.innerWidth,t+i))/2-t,h=(r+Math.min(window.innerHeight,e+s))/2-e,[a,c]=this.viewport.rotation%180==0?[o,h]:[h,o];return{offsetX:a,offsetY:c}}addNewEditor(t={}){this.createAndAddNewEditor(this.#Yh(),!0,t)}setSelected(t){this.#m.setSelected(t)}toggleSelected(t){this.#m.toggleSelected(t)}unselect(t){this.#m.unselect(t)}pointerup(t){const{isMac:e}=Y.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#$h)return;if(this.#$h=!1,this.#Vh?.isDrawer&&this.#Vh.supportMultipleDrawings)return;if(!this.#Nh)return void(this.#Nh=!0);const i=this.#m.getMode();i!==y.STAMP&&i!==y.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#m.unselectAll()}pointerdown(t){if(this.#m.getMode()===y.HIGHLIGHT&&this.enableTextSelection(),this.#$h)return void(this.#$h=!1);const{isMac:e}=Y.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#$h=!0,this.#Vh?.isDrawer)return void this.startDrawingSession(t);const i=this.#m.getActive();this.#Nh=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#Uh)return void this.#Vh.startDrawing(this,this.#m,!1,t);this.#m.setCurrentDrawingSession(this),this.#Uh=new AbortController;const e=this.#m.combinedSignal(this.#Uh);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#jh=null,this.commitOrRemove())}),{signal:e}),this.#Vh.startDrawing(this,this.#m,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#jh=t)}else this.#jh&&setTimeout((()=>{this.#jh?.focus(),this.#jh=null}),0)}endDrawingSession(t=!1){return this.#Uh?(this.#m.setCurrentDrawingSession(null),this.#Uh.abort(),this.#Uh=null,this.#jh=null,this.#Vh.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#m.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#Uh&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#Uh&&this.#Vh.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#m.getActive()?.parent===this&&(this.#m.commitOrRemove(),this.#m.setActiveEditor(null)),this.#Fh&&(clearTimeout(this.#Fh),this.#Fh=null);for(const t of this.#Oh.values())this.#$n?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#Oh.clear(),this.#m.removeLayer(this)}#Gh(){for(const t of this.#Oh.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,xt(this.div,t);for(const t of this.#m.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#m.commitOrRemove(),this.#Gh();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,xt(this.div,{rotation:i}),e!==i)for(const t of this.#Oh.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#m.viewParameters.realScale}}class Bs{#gn=null;#qh=new Map;#Qh=new Map;static#v=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#gn){if(this.#gn!==t){if(this.#qh.size>0)for(const e of this.#qh.values())e.remove(),t.append(e);this.#gn=t}}else this.#gn=t}static get _svgFactory(){return L(this,"_svgFactory",new $i)}static#Kh(t,[e,i,s,n]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*s+"%",r.height=100*n+"%"}#Jh(){const t=Bs._svgFactory.create(1,1,!0);return this.#gn.append(t),t.setAttribute("aria-hidden",!0),t}#Zh(t,e){const i=Bs._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=Bs._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}#ta(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){const s=Bs.#v++,n=this.#Jh(),r=Bs._svgFactory.createElement("defs");n.append(r);const o=Bs._svgFactory.createElement("path");r.append(o);const h=`path_p${this.pageIndex}_${s}`;o.setAttribute("id",h),o.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#Qh.set(s,o);const a=i?this.#Zh(r,h):null,c=Bs._svgFactory.createElement("use");return n.append(c),c.setAttribute("href",`#${h}`),this.updateProperties(n,t),this.#qh.set(s,n),{id:s,clipPathId:`url(#${a})`}}drawOutline(t,e){const i=Bs.#v++,s=this.#Jh(),n=Bs._svgFactory.createElement("defs");s.append(n);const r=Bs._svgFactory.createElement("path");n.append(r);const o=`path_p${this.pageIndex}_${i}`;let h;if(r.setAttribute("id",o),r.setAttribute("vector-effect","non-scaling-stroke"),e){const t=Bs._svgFactory.createElement("mask");n.append(t),h=`mask_p${this.pageIndex}_${i}`,t.setAttribute("id",h),t.setAttribute("maskUnits","objectBoundingBox");const e=Bs._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");const s=Bs._svgFactory.createElement("use");t.append(s),s.setAttribute("href",`#${o}`),s.setAttribute("stroke","none"),s.setAttribute("fill","black"),s.setAttribute("fill-rule","nonzero"),s.classList.add("mask")}const a=Bs._svgFactory.createElement("use");s.append(a),a.setAttribute("href",`#${o}`),h&&a.setAttribute("mask",`url(#${h})`);const c=a.cloneNode();return s.append(c),a.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(s,t),this.#qh.set(i,s),i}finalizeDraw(t,e){this.#Qh.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:i,bbox:s,rootClass:n,path:r}=e,o="number"==typeof t?this.#qh.get(t):t;if(o){if(i&&this.#ta(o,i),s&&Bs.#Kh(o,s),n){const{classList:t}=o;for(const[e,i]of Object.entries(n))t.toggle(e,i)}r&&this.#ta(o.firstChild.firstChild,r)}}updateParent(t,e){if(e===this)return;const i=this.#qh.get(t);i&&(e.#gn.append(i),this.#qh.delete(t),e.#qh.set(t,i))}remove(t){this.#Qh.delete(t),null!==this.#gn&&(this.#qh.get(t).remove(),this.#qh.delete(t))}destroy(){this.#gn=null;for(const t of this.#qh.values())t.remove();this.#qh.clear(),this.#Qh.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:vs},globalThis.pdfjsLib={AbortException:W,AnnotationEditorLayer:Ls,AnnotationEditorParamsType:x,AnnotationEditorType:y,AnnotationEditorUIManager:It,AnnotationLayer:ps,AnnotationMode:v,AnnotationType:S,build:Ni,ColorPicker:Es,createValidAbsoluteUrl:O,DOMSVGFactory:$i,DrawLayer:Bs,FeatureTest:Y,fetchData:ot,getDocument:xi,getFilenameFromUrl:ut,getPdfFilenameFromUrl:dt,getUuid:tt,getXfaPageViewport:At,GlobalWorkerOptions:We,ImageKind:E,InvalidPDFException:z,isDataScheme:ct,isPdfFile:lt,isValidExplicitDest:qt,MathClamp:it,noContextMenu:gt,normalizeUnicode:Z,OPS:C,OutputScale:Mt,PasswordResponses:T,PDFDataRangeTransport:Ei,PDFDateString:wt,PDFWorker:Ci,PermissionFlag:M,PixelsPerInch:rt,RenderingCancelledException:at,ResponseException:H,setLayerDimensions:xt,shadow:L,SignatureExtractor:Is,stopEvent:mt,SupportedImageMimeTypes:Et,TextLayer:vi,TouchManager:Ft,updateUrlHash:$,Util:Q,VerbosityLevel:k,version:Ri,XfaLayer:Li},window.pdf=Object.freeze({__proto__:null,AbortException:W,AnnotationEditorLayer:Ls,AnnotationEditorParamsType:x,AnnotationEditorType:y,AnnotationEditorUIManager:It,AnnotationLayer:ps,AnnotationMode:v,AnnotationType:S,ColorPicker:Es,DOMSVGFactory:$i,DrawLayer:Bs,FeatureTest:Y,GlobalWorkerOptions:We,ImageKind:E,InvalidPDFException:z,MathClamp:it,OPS:C,OutputScale:Mt,PDFDataRangeTransport:Ei,PDFDateString:wt,PDFWorker:Ci,PasswordResponses:T,PermissionFlag:M,PixelsPerInch:rt,RenderingCancelledException:at,ResponseException:H,SignatureExtractor:Is,SupportedImageMimeTypes:Et,TextLayer:vi,TouchManager:Ft,Util:Q,VerbosityLevel:k,XfaLayer:Li,build:Ni,createValidAbsoluteUrl:O,fetchData:ot,getDocument:xi,getFilenameFromUrl:ut,getPdfFilenameFromUrl:dt,getUuid:tt,getXfaPageViewport:At,isDataScheme:ct,isPdfFile:lt,isValidExplicitDest:qt,noContextMenu:gt,normalizeUnicode:Z,setLayerDimensions:xt,shadow:L,stopEvent:mt,updateUrlHash:$,version:Ri});const Us=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.activate=i(this,"activate",7),this.visiblePagesChange=i(this,"visiblePagesChange",7),this.errorMessage="File could not be loaded.",this.viewMode="single",this.workerSrc="/pdfjs/pdf.worker.min.mjs",this.wasmUrl="/pdfjs/wasm/",this.zoom=1,this.currentPage=null,this.loading=!0,this.renderedPages=[],this.singlePageModePage=1,this.visiblePages=[],this.pages=[],this.renderingPageNumbers=[],this.recentScrollPosition={x:0,y:0},this.storeRecentScrollPosition=()=>{this.recentScrollPosition={x:Math.round(this.scrollContainer?.scrollLeft/this.scrollContainer?.scrollWidth*100)/100,y:Math.round(this.scrollContainer?.scrollTop/this.scrollContainer?.scrollHeight*100)/100}},this.onScroll=h((()=>{this.updateVisiblePages(),this.storeRecentScrollPosition()}),60)}componentWillLoad(){window.pdf.GlobalWorkerOptions.workerSrc=this.workerSrc}async componentDidLoad(){await this.getPages(),await this.updateVisiblePages(),this.activate.emit(this.el)}componentDidRender(){this.updateVisiblePages()}disconnectedCallback(){this.doc?.destroy()}async onWindowResize(){this.visiblePages=[],this.renderedPages=[],await this.updateVisiblePages()}async watchProps(){await this.getPages(),await this.updateVisiblePages()}async watchViewMode(){queueMicrotask((async()=>{this.visiblePages=[],this.renderedPages=[],await this.updateVisiblePages()}))}watchZoom(){queueMicrotask((async()=>{this.restoreScrollPosition(),this.visiblePages=[],this.renderedPages=[],await this.updateVisiblePages()}))}async getThumbnails(){return await Promise.all(this.pages.filter(Boolean).map((t=>{const e=t.getViewport({scale:1}),i=document.createElement("canvas");i.width=e.width,i.height=e.height;const s=Math.min(i.width/e.width,i.height/e.height);return t.render({canvasContext:i.getContext("2d"),viewport:t.getViewport({scale:s})}).promise.then((function(){return i}))})))}async print(){this.loading=!0,await this.updateVisiblePages(!0),await this.openPrintDialog(),this.loading=!1}async nextPage(){await this.setPage(this.singlePageModePage+1),await this.updateVisiblePages()}async previousPage(){await this.setPage(this.singlePageModePage-1),await this.updateVisiblePages()}async setPage(t){this.singlePageModePage=Math.min(Math.max(t,1),this.pages.length-1),await this.updateVisiblePages()}async getPages(){this.error=!1,this.loading=!0;try{Boolean(this.doc)&&this.doc.destroy(),this.doc=await xi({isEvalSupported:!1,url:this.file,wasmUrl:this.wasmUrl}).promise;const t=[];for(let e=1;e<=this.doc.numPages;e++)t.push(this.doc.getPage(e));this.pages=await Promise.all(t),this.loading=!1}catch(t){this.error=!0,this.loading=!1}}async renderVisiblePages(t){const e=Array.from(this.el.shadowRoot.querySelectorAll("canvas")),i=[];for(const s of e){const e=s.closest(".file-viewer-pdf__page"),n=this.pages.find((t=>t?.pageNumber===+e?.dataset.pageNumber));Boolean(n)&&!this.renderingPageNumbers.includes(n.pageNumber)&&(this.visiblePages.includes(n.pageNumber)||t?!this.renderedPages.includes(n.pageNumber)||t?(await this.renderPage(n,s,t),i.push(n.pageNumber)):i.push(n.pageNumber):this.destroyPage(n))}this.renderedPages=i}async renderPage(t,e,i){const s=e.closest(".file-viewer-pdf__page"),n=s?.querySelector(".file-viewer-pdf__text-container"),r=s?.querySelector(".file-viewer-pdf__annotation-container");this.renderingPageNumbers=[...this.renderingPageNumbers,t.pageNumber];const o=i?this.getPrintScale(t):this.getScale(t),h=Math.max(window.devicePixelRatio||2,2),a=[h,0,0,h,0,0],c=t.getViewport({scale:o}),l=e.getContext("2d");e.height=Math.floor(c.height*h),e.width=Math.floor(c.width*h);const u={canvasContext:l,transform:a,viewport:c};try{await t.render(u).promise,t.cleanup(),n.innerHTML="",r.innerHTML="",this.renderTextLayer(t,n).catch(),this.renderAnnotationLayer(t,r).catch(),this.renderingPageNumbers=this.renderingPageNumbers.filter((e=>e!==t.pageNumber))}catch(t){}}destroyPage(t){const e=this.el.shadowRoot.querySelector(`[data-page-number="${t.pageNumber}"]`),i=e.querySelector("canvas"),s=e.querySelector(".file-viewer-pdf__text-container"),n=e.querySelector(".file-viewer-pdf__annotation-container");i.width=1,i.height=1,i.getContext("2d").clearRect(0,0,i.width,i.height),s.innerHTML="",n.innerHTML=""}async updateVisiblePages(t){const e=Array.from(this.el.shadowRoot.querySelectorAll(".file-viewer-pdf__page"));let i=[],s=null;if(this.singlePageMode)i=[this.singlePageModePage],s=this.singlePageModePage;else if(t)i=e.map((t=>+t.dataset.pageNumber));else{const t=e.map((t=>({pageNumber:+t.dataset.pageNumber,visibleHeight:a(t,this.scrollContainer)}))).filter((({visibleHeight:t})=>t>0));i=t.map((t=>t.pageNumber)),t.length>0&&(s=t.reduce(((t,e)=>e.visibleHeight>t.visibleHeight?e:t),t[0]).pageNumber)}this.visiblePages.length===i.length&&this.visiblePages.every((t=>i.includes(t)))&&this.currentPage===s||(this.visiblePages=i,this.currentPage=s,await this.renderVisiblePages(t),this.visiblePagesChange.emit(this.visiblePages))}async renderTextLayer(t,e){return new vi({container:e,textContentSource:await t.getTextContent(),viewport:t.getViewport({scale:this.getScale(t)})}).render()}async renderAnnotationLayer(t,e){const i=t.getViewport({scale:this.getScale(t)}),s=await t.getAnnotations();if(!s||0===s.length)return;const n=new ps({div:e,page:t,viewport:i,accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,structTreeLayer:null});await n.render({annotations:s,div:e,page:t,viewport:i,linkService:{externalLinkEnabled:!0,pagesCount:this.doc?.numPages??0,page:0,rotation:0,isInPresentationMode:!1,getDestinationHash:()=>"#",getAnchorUrl:()=>"#",setHash:()=>{},executeNamedAction:()=>{},executeSetOCGState:()=>{},addLinkAttributes:(t,e)=>{t.href=e,t.rel="noopener noreferrer nofollow",t.target="_blank"},goToDestination:async t=>{const e="string"==typeof t?await this.doc.getDestination(t):t;if(!e)return;const i=await this.doc.getPageIndex(e[0]);this.scrollToPage(i+1)},goToPage:t=>{const e="string"==typeof t?parseInt(t,10):t;this.scrollToPage(e)}},renderForms:!1})}scrollToPage(t){if(this.singlePageMode)return void this.setPage(t);const e=this.el.shadowRoot.querySelector(`[data-page-number="${t}"]`);e?.scrollIntoView({behavior:"smooth"})}async openPrintDialog(){const t=Array.from(this.scrollContainer.querySelectorAll("canvas"));let e=`\n <!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8">\n <meta http-equiv="X-UA-Compatible" content="IE=edge">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>${this.file}</title>\n <style>\n *, *:before, *:after {\n margin: 0;\n padding: 0;\n outline: 0;\n }\n\n @page {\n size: a4 !important;\n margin: 0;\n padding: 0;\n }\n\n html, body {\n width: 210mm;\n height: 297mm;\n }\n\n img {\n display: block;\n max-width: 100%;\n max-height: 100%;\n page-break-after: always;\n }\n </style>\n </head>\n <body>\n `;for(const i of t)e+=`<img src="${i.toDataURL()}">`;e+="\n </body>\n </html>\n ";const i=document.createElement("iframe");this.el.append(i);const s=i.contentWindow;s.document.write(e),s.focus(),await new Promise((t=>setTimeout(t,100))),s.print(),i.remove()}getScale(t){const e=c()?0:32;return"auto"===this.zoom?(this.scrollContainer?.clientWidth-e)/t.view[2]:isNaN(this.zoom)?1:this.zoom}getPrintScale(t){return Math.min(Math.min(2480/t.view[2],3508/t.view[3]),2)}restoreScrollPosition(){this.scrollContainer.scrollTop=this.recentScrollPosition.y*this.scrollContainer?.scrollHeight,this.scrollContainer.scrollLeft=this.recentScrollPosition.x*this.scrollContainer?.scrollWidth}render(){const t=!this.error&&!this.loading&&this.visiblePages.length>0,e=this.loading,i=o("file-viewer-pdf",`file-viewer-pdf--view-mode-${this.viewMode}`);return s(n,{key:"d977930ae1c59c9cb11bab634a45b38aa6b289b3",class:i,exportparts:"file-viewer-pdf__pagination"},this.error&&s("swirl-inline-error",{key:"1599701f41b105e5da3e22f993b936774038534f",class:"file-viewer-pdf__error",message:this.errorMessage}),s("div",{key:"e38c6cab8ac2f2fff08e1795dc22bb0d8798b45f","aria-describedby":"pagination",class:"file-viewer-pdf__pages",onScroll:this.onScroll,ref:t=>this.scrollContainer=t},this.pages.map((t=>{const e=t.getViewport({scale:this.getScale(t)}),i=e.height,n=e.width,r=this.renderedPages.includes(t.pageNumber);return s("div",{"aria-label":t.pageNumber,class:"file-viewer-pdf__page","data-page-number":t.pageNumber,hidden:!(!this.singlePageMode||t.pageNumber===this.singlePageModePage)||void 0,id:`page-${t.pageNumber}`,key:t.pageNumber,role:"region",style:{width:`${n}px`,height:`${i}px`},tabIndex:0},!r&&s("swirl-spinner",{class:"file-viewer-pdf__page-spinner"}),s("canvas",{class:"file-viewer-pdf__canvas",style:{opacity:r?"1":"0"}}),s("div",{class:"file-viewer-pdf__text-container"}),s("div",{class:"file-viewer-pdf__annotation-container"}))}))),t&&s("span",{key:"d61abeb592dc3c50aeeca9de1a7646e385137684",class:"file-viewer-pdf__pagination",id:"pagination",part:"file-viewer-pdf__pagination"},s("span",{key:"ad4f2f10f4b6578fcf8dc1b331515faa6a0fb050","aria-current":"page"},this.currentPage)," /"," ",this.doc.numPages),e&&s("div",{key:"03a53c31b2875e3b4f89c85fcef65254e52f915b",class:"file-viewer-pdf__spinner"},s("swirl-spinner",{key:"0f63537fa4e277677a0a55ecde25122c51b3f7eb"})))}get el(){return this}static get watchers(){return{file:[{watchProps:0}],viewMode:[{watchViewMode:0}],zoom:[{watchZoom:0}]}}static get style(){return":host{position:relative;display:inline-flex;width:100%;height:100%;pointer-events:auto}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__pages{display:grid;grid-template-columns:repeat(2, 1fr);grid-row-gap:var(--s-space-8);grid-column-gap:var(--s-space-8);grid-auto-rows:auto}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__page{margin:0}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__page:nth-child(odd){justify-self:end}:host(.file-viewer-pdf--view-mode-side-by-side) .file-viewer-pdf__page:nth-child(even){justify-self:start}:host *{box-sizing:border-box}.file-viewer-pdf__pages{overflow:auto;width:100%;height:100%}@media (min-width: 768px){.file-viewer-pdf__pages{padding:var(--s-space-16)}}.file-viewer-pdf__page{position:relative;margin-right:auto;margin-left:auto;border-bottom:var(--s-border-width-default) solid var(--s-border-default);background-color:#fff}@media (min-width: 768px){.file-viewer-pdf__page{border:var(--s-border-width-default) solid var(--s-border-default)}.file-viewer-pdf__page:not(:last-of-type){margin-bottom:var(--s-space-8)}}.file-viewer-pdf__page-spinner{position:absolute;top:50%;left:50%;transform:translate3d(-50%, -50%, 0)}.file-viewer-pdf__canvas{display:flex;width:100%;height:100%;margin-right:auto;margin-left:auto}.file-viewer-pdf__text-container{position:absolute;overflow:hidden;line-height:1;text-align:initial;-webkit-user-select:none;-moz-user-select:none;user-select:none;inset:0;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;forced-color-adjust:none}.file-viewer-pdf__text-container>*{position:absolute;color:transparent;white-space:pre;cursor:text;transform-origin:0% 0%}.file-viewer-pdf__text-container>*.markedContent{top:0;height:0}.file-viewer-pdf__text-container>*.highlight{margin:-1px;padding:1px;border-radius:4px;background-color:rgba(180, 0, 170, 1)}.file-viewer-pdf__text-container>*.highlight.appended{position:initial}.file-viewer-pdf__text-container>*.highlight.begin{border-radius:4px 0 0 4px}.file-viewer-pdf__text-container>*.highlight.end{border-radius:0 4px 4px 0}.file-viewer-pdf__text-container>*.highlight.middle{border-radius:0}.file-viewer-pdf__text-container>*.highlight.selected{background-color:rgba(0, 100, 0, 1)}.file-viewer-pdf__text-container>*.endOfContent{position:absolute;z-index:-1;top:100%;right:0;bottom:0;left:0;display:block;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none}.file-viewer-pdf__text-container>*.endOfContent.active{top:0}.file-viewer-pdf__text-container>br::-moz-selection{background:transparent}.file-viewer-pdf__text-container>br::selection{background:transparent}@media (min-width: 768px){.file-viewer-pdf__text-container{-webkit-user-select:auto;-moz-user-select:auto;user-select:auto}}.file-viewer-pdf__annotation-container{position:absolute;overflow:hidden;inset:0;pointer-events:none}.file-viewer-pdf__annotation-container section{position:absolute;pointer-events:auto}.file-viewer-pdf__annotation-container section a{display:block;width:100%;height:100%}.file-viewer-pdf__spinner{position:absolute;display:flex;justify-content:center;align-items:center;background-color:rgba(0, 0, 0, 0.2);inset:0}.file-viewer-pdf__error{position:absolute;top:50%;left:50%;transform:translate3d(-50%, -50%, 0)}.file-viewer-pdf__pagination{position:absolute;bottom:var(--s-space-16);left:50%;padding:var(--s-space-4) var(--s-space-12);border-radius:var(--s-border-radius-base);color:var(--s-text-on-image);background-color:rgba(0, 0, 0, 0.6);font-weight:var(--s-font-weight-medium);line-height:var(--s-line-height-base);transform:translateX(-50%);pointer-events:none}@media (min-width: 992px) and (max-width: 1439px) and (hover: hover),(min-width: 1440px){.file-viewer-pdf__pagination{font-size:var(--s-font-size-sm);line-height:var(--s-line-height-sm)}}"}},[1,"swirl-file-viewer-pdf",{errorMessage:[1,"error-message"],file:[1],singlePageMode:[4,"single-page-mode"],viewMode:[1,"view-mode"],workerSrc:[1,"worker-src"],wasmUrl:[1,"wasm-url"],zoom:[8],currentPage:[32],doc:[32],error:[32],loading:[32],renderedPages:[32],singlePageModePage:[32],visiblePages:[32],getThumbnails:[64],print:[64],nextPage:[64],previousPage:[64],setPage:[64]},[[9,"resize","onWindowResize"]],{file:[{watchProps:0}],viewMode:[{watchViewMode:0}],zoom:[{watchZoom:0}]}]);function js(){"undefined"!=typeof customElements&&["swirl-file-viewer-pdf","swirl-icon-error","swirl-inline-error","swirl-spinner","swirl-visually-hidden"].forEach((t=>{switch(t){case"swirl-file-viewer-pdf":customElements.get(r(t))||customElements.define(r(t),Us);break;case"swirl-icon-error":customElements.get(r(t))||l();break;case"swirl-inline-error":customElements.get(r(t))||u();break;case"swirl-spinner":customElements.get(r(t))||d();break;case"swirl-visually-hidden":customElements.get(r(t))||f()}}))}export{Us as S,js as d}