@vertexvis/doc-viewer 1.0.0-testing.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/doc-viewer.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/vertex-document-viewer.cjs.entry.js +60 -6
- package/dist/collection/components/document-viewer/document-viewer.js +88 -4
- package/dist/collection/lib/dom.js +8 -0
- package/dist/collection/lib/interactions/pan-interaction-handler.js +4 -3
- package/dist/components/vertex-document-viewer.js +2 -2
- package/dist/doc-viewer/doc-viewer.esm.js +1 -1
- package/dist/doc-viewer/p-00895e2d.entry.js +25 -0
- package/dist/esm/doc-viewer.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/loader.mjs +1 -1
- package/dist/esm/vertex-document-viewer.entry.js +60 -6
- package/dist/types/components/document-viewer/document-viewer.d.ts +19 -2
- package/dist/types/components.d.ts +8 -0
- package/dist/types/lib/dom.d.ts +1 -0
- package/dist/types/lib/interactions/pan-interaction-handler.d.ts +2 -1
- package/package.json +5 -5
- package/readme.md +1 -1
- package/dist/doc-viewer/p-e5411da0.entry.js +0 -25
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
import{t,p as
|
|
4
|
+
import{t,p as i,H as e,d as s,h as n,e as r}from"./p-qzDSS9cP.js";function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var h=function(t,i){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])},h(t,i)},a=function(){return a=Object.assign||function(t){for(var i,e=1,s=arguments.length;e<s;e++)for(var n in i=arguments[e])Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n]);return t},a.apply(this,arguments)};function c(t,i,e){return(e=function(t){return Math.max(0,Math.min(1,t))}(e))*(i-t)+t}function l(t,i){return void 0===t&&(t=0),void 0===i&&(i=0),{x:t,y:i}}function u(t,i){return{x:t.x-i.x,y:t.y-i.y}}function d(t,i){return{x:t.x*i,y:t.y*i}}function f(t){return Math.sqrt(t.x*t.x+t.y*t.y)}function p(t){var i=f(t);return 0===i?l(0,0):d(t,1/i)}function g(t,i){return p(u(i,t))}"function"==typeof SuppressedError&&SuppressedError;var m=Object.freeze({__proto__:null,create:l,polar:function(t,i){return l(Math.cos(i)*t,Math.sin(i)*t)},distance:function(t,i){var e=u(t,i);return Math.sqrt(e.x*e.x+e.y*e.y)},subtract:u,add:function(t,i){return{x:t.x+i.x,y:t.y+i.y}},isEqual:function(t,i){return t.x===i.x&&t.y===i.y},lerp:function(t,i,e){return{x:c(t.x,i.x,e),y:c(t.y,i.y,e)}},negate:function(t){return l(-t.x,-t.y)},scale:function(t,i,e){return{x:t.x*i,y:t.y*e}},scaleProportional:d,magnitude:f,normalizeVector:p,normalDirectionVector:g,orthogonalVector:function(t,i){var e=g(t,i);return 0===e.x||0===e.y?l(-1*e.y,e.x):p(Math.abs(e.x)>Math.abs(e.y)?l(1-Math.pow(e.x,2),-1*e.x*e.y):l(-1*e.x*e.y,1-Math.pow(e.y,2)))},fromJson:function(t){var i=JSON.parse(t);return Array.isArray(i)?l(i[0],i[1]):l(i.x,i.y)}});function w(t,i){return function(t,i,e,s){return{x:t,y:i,width:e,height:s}}(t.x,t.y,i.width,i.height)}function A(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}var v=function(t,i){return{width:t,height:i}},b=function(t,i,e){return{width:e.width*t,height:e.height*i}},y=function(t,i){return b(t,t,i)},x=function(t){return{width:Math.floor(t.width),height:Math.floor(t.height)}},M=function(t){return{x:t.width/2,y:t.height/2}};function S(t,i){return void 0===i&&(i=l()),w(i,t)}var C,E=Object.freeze({__proto__:null,create:v,square:function(t){return v(t,t)},isEqual:function(t,i){return t.width===i.width&&t.height===i.height},scale:b,proportionalScale:y,trim:function(t,i){return{width:Math.min(t.width,i.width),height:Math.min(t.height,i.height)}},containFit:function(t,i){var e=function(t,i){var e=y(Math.min(t.width/i.width,t.height/i.height),i);return w(u(A(t),M(e)),e)}(S(t),S(i));return{width:e.width,height:e.height}},cropFit:function(t,i){var e=function(t,i){var e=y(Math.max(t.width/i.width,t.height/i.height),i);return w(u(A(t),M(e)),e)}(S(t),S(i));return{width:e.width,height:e.height}},scaleFit:function(t,i){var e=function(t,i){var e=Math.min(Math.sqrt(t/function(t){return t.width*t.height}(i)),1),s=x(y(e,i));return w(u(A(i),M(s)),s)}(t,S(i));return{width:e.width,height:e.height}},round:function(t){return{width:Math.round(t.width),height:Math.round(t.height)}},floor:x,center:M,aspectRatio:function(t){return t.width/t.height},area:function(t){return t.width*t.height},fitToRatio:function(t,i){return i.width>=i.height*t?v(i.height*t,i.height):v(i.width,i.width/t)},toRectangle:S}),k={exports:{}},T=(C||(C=1,function(t){!function(){var i={}.hasOwnProperty;function e(){for(var t="",i=0;i<arguments.length;i++){var e=arguments[i];e&&(t=n(t,s(e)))}return t}function s(t){if("string"==typeof t||"number"==typeof t)return t;if("object"!=typeof t)return"";if(Array.isArray(t))return e.apply(null,t);if(t.toString!==Object.prototype.toString&&!(""+t.toString).includes("[native code]"))return""+t;var s="";for(var r in t)i.call(t,r)&&t[r]&&(s=n(s,r));return s}function n(t,i){return i?t?t+" "+i:t+i:t}t.exports?(e.default=e,t.exports=e):window.classNames=e}()}(k)),k.exports),P=o(T);class D{constructor(t){this.apiSupportsLayers=!1,function(t){return null!=t&&"function"==typeof t.getLayers&&"function"==typeof t.setLayerVisibility}(t)&&(this.apiSupportsLayers=!0,this.api=t)}get enabled(){return this.apiSupportsLayers}async getLayers(){return this.getApi().getLayers()}async setLayerVisibility(t,i){return this.getApi().setLayerVisibility(t,i)}getApi(){if(null==this.api)throw Error("The current document does not support layers.");return this.api}}function I(t){return Array.from(t.querySelectorAll("*"))}class R{constructor(t,i,e){this.element=t,this.hostElement=i,this.api=e,this.isDragging=!1,this.handlePointerDown=this.handlePointerDown.bind(this),this.handlePointerMove=this.handlePointerMove.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleWheel=this.handleWheel.bind(this),this.element.addEventListener("pointerdown",this.handlePointerDown),this.element.addEventListener("wheel",this.handleWheel),this.hostElement.addEventListener("wheel",this.handleWheel)}dispose(){this.element.removeEventListener("pointerdown",this.handlePointerDown),this.element.removeEventListener("wheel",this.handleWheel),this.hostElement.removeEventListener("wheel",this.handleWheel),this.removeWindowListeners()}handleWheel(t){t.preventDefault();const i=-t.deltaX/2,e=-t.deltaY/2;0===i&&0===e||this.api.panByDelta(m.create(i,e))}handlePointerDown(t){0===t.button&&(t.preventDefault(),this.downPosition=m.create(t.clientX,t.clientY),this.lastPosition=this.downPosition,this.isDragging=!1,window.addEventListener("pointermove",this.handlePointerMove),window.addEventListener("pointerup",this.handlePointerUp))}handlePointerMove(t){if(null==this.lastPosition||null==this.downPosition)return;const i=m.create(t.clientX,t.clientY);if(!this.isDragging&&m.distance(i,this.downPosition)<2)return;this.isDragging=!0;const e=m.subtract(i,this.lastPosition);this.lastPosition=i,this.api.panByDelta(e)}handlePointerUp(){this.lastPosition=void 0,this.downPosition=void 0,this.isDragging=!1,this.removeWindowListeners()}removeWindowListeners(){window.removeEventListener("pointermove",this.handlePointerMove),window.removeEventListener("pointerup",this.handlePointerUp)}}
|
|
5
5
|
/**
|
|
6
6
|
* @licstart The following is the entire license notice for the
|
|
7
7
|
* JavaScript code in this page
|
|
@@ -22,4 +22,4 @@ import{t,p as e,H as i,d as s,h as n,e as r}from"./p-qzDSS9cP.js";function o(t){
|
|
|
22
22
|
*
|
|
23
23
|
* @licend The above is the entire license notice for the
|
|
24
24
|
* JavaScript code in this page
|
|
25
|
-
*/var N={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")}},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")}},7080(t,e,i){var s=i(4402).has;t.exports=function(t){return s(t),t}},3463(t){var e=TypeError;t.exports=function(t){if("string"==typeof t)return t;throw new e("Argument is not a string")}},4328(t,e,i){var s=i(4995),n=new s.WeakMap,r=s.set,o=s.remove;t.exports=function(t){return r(n,t,1),o(n,t),t}},6557(t,e,i){var s=i(4995).has;t.exports=function(t){return s(t),t}},6469(t,e,i){var s=i(608),n=i(2360),r=i(4913).f,o=s("unscopables"),h=Array.prototype;void 0===h[o]&&r(h,o,{configurable:!0,value:n(null)}),t.exports=function(t){h[o][t]=!0}},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")}},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")}},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")}},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")}},7811(t){t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},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}},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}}},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}},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.max,g=Math.min,m=d.prototype,w=f.prototype,A=n(m.slice),v=r(m,"resizable","get"),b=r(m,"maxByteLength","get"),y=n(w.getInt8),x=n(w.setInt8);t.exports=(l||c)&&function(t,e,i){var s,n=a(t),r=void 0===e?n:o(e),m=!v||!v(t);if(h(t),l&&(t=u(t,{transfer:[t]}),n===r&&(i||m)))return t;if(n>=r&&(!i||m))s=A(t,0,r);else{var w=i&&!m&&b?{maxByteLength:p(r,b(t))}:void 0;s=new d(r,w);for(var M=new f(t),S=new f(s),C=g(r,n),E=0;E<C;E++)x(S,E,y(M,E))}return l||c(t),s}},4644(t,e,i){var s,n,r,o=i(7811),h=i(3724),a=i(4576),c=i(4901),l=i(34),u=i(9297),d=i(6955),f=i(6823),p=i(6699),g=i(6840),m=i(2106),w=i(1625),A=i(2787),v=i(2967),b=i(608),y=i(3392),x=i(1181),M=x.enforce,S=x.get,C=a.Int8Array,E=C&&C.prototype,k=a.Uint8ClampedArray,T=k&&k.prototype,P=C&&A(C),D=E&&A(E),I=Object.prototype,N=a.TypeError,R=b("toStringTag"),O=y("TYPED_ARRAY_TAG"),_="TypedArrayConstructor",F=o&&!!v&&"Opera"!==d(a.opera),B=!1,L={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},U={BigInt64Array:8,BigUint64Array:8},$=function(t){var e=A(t);if(l(e)){var i=S(e);return i&&u(i,_)?i[_]:$(e)}},j=function(t){if(!l(t))return!1;var e=d(t);return u(L,e)||u(U,e)};for(s in L)(r=(n=a[s])&&n.prototype)?M(r)[_]=n:F=!1;for(s in U)(r=(n=a[s])&&n.prototype)&&(M(r)[_]=n);if((!F||!c(P)||P===Function.prototype)&&(P=function(){throw new N("Incorrect invocation")},F))for(s in L)a[s]&&v(a[s],P);if((!F||!D||D===I)&&(D=P.prototype,F))for(s in L)a[s]&&v(a[s].prototype,D);if(F&&A(T)!==D&&v(T,D),h&&!u(D,R))for(s in B=!0,m(D,R,{configurable:!0,get:function(){return l(this)?this[O]:void 0}}),L)a[s]&&p(a[s].prototype,O,s);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:F,TYPED_ARRAY_TAG:B&&O,aTypedArray:function(t){if(j(t))return t;throw new N("Target is not a typed array")},aTypedArrayConstructor:function(t){if(c(t)&&(!v||w(P,t)))return t;throw new N(f(t)+" is not a typed array constructor")},exportTypedArrayMethod:function(t,e,i,s){if(h){if(i)for(var n in L){var r=a[n];if(r&&u(r.prototype,t))try{delete r.prototype[t]}catch(i){try{r.prototype[t]=e}catch(t){}}}D[t]&&!i||g(D,t,i?e:F&&E[t]||e,s)}},exportTypedArrayStaticMethod:function(t,e,i){var s,n;if(h){if(v){if(i)for(s in L)if((n=a[s])&&u(n,t))try{delete n[t]}catch(t){}if(P[t]&&!i)return;try{return g(P,t,i?e:F&&P[t]||e)}catch(t){}}for(s in L)!(n=a[s])||n[t]&&!i||g(n,t,e)}},getTypedArrayConstructor:$,isView:function(t){if(!l(t))return!1;var e=d(t);return"DataView"===e||u(L,e)||u(U,e)},isTypedArray:j,TypedArray:P,TypedArrayPrototype:D}},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}},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)}},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}},7680(t,e,i){var s=i(9504);t.exports=s([].slice)},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)}},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)}}},2195(t,e,i){var s=i(9504),n=s({}.toString),r=s("".slice);t.exports=function(t){return r(n(t),8,-1)}},6955(t,e,i){var s=i(2140),n=i(4901),r=i(2195),o=i(608)("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}},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))}}},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}))},2529(t){t.exports=function(t,e){return{value:t,done:e}}},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}},6980(t){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},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}},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)}},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}},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}},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}},3724(t,e,i){var s=i(9039);t.exports=!s((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[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},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):{}}},6837(t){var e=TypeError;t.exports=function(t){if(t>9007199254740991)throw new e("Maximum allowed index exceeded");return t}},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}}},8727(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},6193(t,e,i){var s=i(4215);t.exports="NODE"===s},2839(t,e,i){var s=i(4576).navigator,n=s&&s.userAgent;t.exports=n?n+"":""},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},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"},8574(t,e,i){var s=i(9504),n=Error,r=s("".replace),o=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}},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)}}},9039(t){t.exports=function(t){try{return!!t()}catch(t){return!0}}},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)})},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)}}},616(t,e,i){var s=i(9039);t.exports=!s((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},9565(t,e,i){var s=i(616),n=Function.prototype.call;t.exports=s?n.bind(n):function(){return n.apply(n,arguments)}},350(t,e,i){var s=i(3724),n=i(9297),r=Function.prototype,o=s&&Object.getOwnPropertyDescriptor,h=n(r,"name"),a=h&&!1,c=h&&(!s||s&&o(r,"name").configurable);t.exports={EXISTS:h,PROPER:a,CONFIGURABLE:c}},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){}}},7476(t,e,i){var s=i(2195),n=i(9504);t.exports=function(t){if("Function"===s(t))return n(t)}},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)}}},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")}},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){}}}},7751(t,e,i){var s=i(4576),n=i(4901);t.exports=function(t,e){return arguments.length<2?function(t){return n(t)?t:void 0}(s[t]):s[t]&&s[t][e]}},1767(t){t.exports=function(t){return{iterator:t,next:t.next,done:!1}}},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))}},851(t,e,i){var s=i(6955),n=i(5966),r=i(4117),o=i(6269),h=i(608)("iterator");t.exports=function(t){if(!r(t))return n(t,h)||n(t,"@@iterator")||o[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")}},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)}},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)}},4576(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")()},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)}},421(t){t.exports={}},397(t,e,i){var s=i(7751);t.exports=s("document","documentElement")},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}))},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},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}},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},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}}}},4209(t,e,i){var s=i(608),n=i(6269),r=s("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(n.Array===t||o[r]===t)}},4376(t,e,i){var s=i(2195);t.exports=Array.isArray||function(t){return"Array"===s(t)}},1108(t,e,i){var s=i(6955);t.exports=function(t){var e=s(t);return"BigInt64Array"===e||"BigUint64Array"===e}},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}},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(t+"").replace(r,".").toLowerCase()},a=o.data={},c=o.NATIVE="N",l=o.POLYFILL="P";t.exports=o},4117(t){t.exports=function(t){return null==t}},34(t,e,i){var s=i(4901);t.exports=function(t){return"object"==typeof t?null!==t:s(t)}},3925(t,e,i){var s=i(34);t.exports=function(t){return s(t)||null===t}},6395(t){t.exports=!1},5810(t,e,i){var s=i(34),n=i(1181).get;t.exports=function(t){if(!s(t))return!1;var e=n(t);return!!e&&"RawJSON"===e.type}},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))}},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}},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,v,b,y,x,M=!(!i||!i.AS_ENTRIES),S=!(!i||!i.IS_RECORD),C=!(!i||!i.IS_ITERATOR),E=!(!i||!i.INTERRUPTED),k=s(e,i&&i.that),T=function(t){var e=m;return m=void 0,e&&d(e,"normal"),new p(!0,t)},P=function(t){return M?(r(t),E?k(t[0],t[1],T):k(t[0],t[1])):E?k(t,T):k(t)};if(S)m=t.iterator;else if(C)m=t;else{if(!(w=u(t)))throw new f(o(t)+" is not iterable");if(h(w)){for(A=0,v=a(t);v>A;A++)if((b=P(t[A]))&&c(g,b))return b;return new p(!1)}m=l(t,w)}for(y=S?t.next:m.next;!(x=n(y,m)).done;){var D=x.value;try{b=P(D)}catch(t){if(!m)throw t;d(m,"throw",t)}if("object"==typeof b&&b&&c(g,b))return b}return new p(!1)}},1385(t,e,i){var s=i(9539);t.exports=function(t,e,i){for(var n=t.length-1;n>=0;n--)if(void 0!==t[n])try{i=s(t[n].iterator,e,i)}catch(t){e="throw",i=t}if("throw"===e)throw i;return i}},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}},9462(t,e,i){var s=i(9565),n=i(2360),r=i(6699),o=i(6279),h=i(608),a=i(1181),c=i(5966),l=i(7657).IteratorPrototype,u=i(2529),d=i(9539),f=i(1385),p=h("toStringTag"),g="IteratorHelper",m="WrapForValidIterator",w="normal",A="throw",v=a.set,b=function(t){var e=a.getterFor(t?m:g);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,r=i.done;if(i.done=!0,t){var o=c(n,"return");return o?s(o,n):u(void 0,!0)}if(r)return u(void 0,!0);if(i.inner)try{d(i.inner.iterator,w)}catch(t){return d(n,A,t)}if(i.openIters)try{f(i.openIters,w)}catch(t){if(n)return d(n,A,t);throw t}return n&&d(n,w),u(void 0,!0)}})},y=b(!0),x=b(!1);r(x,p,"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?m:g,n.returnHandlerResult=!!i,n.nextHandler=t,n.counter=0,n.done=!1,v(this,n)};return s.prototype=e?y:x,s}},684(t){t.exports=function(t,e){var i="function"==typeof Iterator&&Iterator.prototype[t];if(i)try{i.call({next:null},e).next()}catch(t){return!0}}},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}},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(608),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}},6269(t){t.exports={}},6198(t,e,i){var s=i(8014);t.exports=function(t){return s(t.length)}},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})),v=(String+"").split("String"),b=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(v,"string"==typeof e?e:"")),t};Function.prototype.toString=b((function(){return r(this)&&d(this).source||c(this)}),"toString")},2248(t,e,i){var s=i(9504),n=Map.prototype;t.exports={Map,set:s(n.set),get:s(n.get),has:s(n.has),remove:s(n.delete),proto:n}},741(t){var e=Math.ceil,i=Math.floor;t.exports=Math.trunc||function(t){var s=+t;return(s>0?i:e)(s)}},7819(t,e,i){var s=i(9039);t.exports=!s((function(){var t="9007199254740993",e=JSON.rawJSON(t);return!JSON.isRawJSON(e)||JSON.stringify(e)!==t}))},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)}},2603(t,e,i){var s=i(655);t.exports=function(t,e){return void 0===t?arguments.length<2?"":e:s(t)}},4149(t){var e=RangeError;t.exports=function(t){if(t==t)return t;throw new e("NaN is not allowed")}},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){}w="undefined"!=typeof document?document.domain&&s?m(s):function(){var t,e=c("iframe"),i="java"+d+":";return e.style.display="none",a.appendChild(e),e.src=i+"",(t=e.contentWindow.document).open(),t.write(g("document.F=Object")),t.close(),t.F}():m(s);for(var t=o.length;t--;)delete w[u][o[t]];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)}},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}},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}},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])}},8480(t,e,i){var s=i(1828),n=i(8727).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return s(t,n)}},3717(t,e){e.f=Object.getOwnPropertySymbols},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}},1625(t,e,i){var s=i(9504);t.exports=s({}.isPrototypeOf)},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}},1072(t,e,i){var s=i(1828),n=i(8727);t.exports=Object.keys||function(t){return s(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},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)},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")}},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}},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}}},1103(t){t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},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}},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}},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(n)<=i.size?a(n,(function(t){i.includes(t)&&u(n,t)})):c(i.getIterator(),(function(t){l(n,t)&&u(n,t)})),n}},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}},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}},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.iterator,"normal",!1)}))}},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)}},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.iterator,"normal",!1)}))}},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)}},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 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){return e(new i([1,2])[t](r(1/0)))}}}catch(t){return!1}}},9835(t){t.exports=function(t){try{var e=new Set,i={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return e.clear(),e.add(4),function(){return{done:!0}}}})}},s=e[t](i);return 1===s.size&&4===s.values().next().value}catch(t){return!1}}},5170(t,e,i){var s=i(6706),n=i(4402);t.exports=s(n.proto,"size","get")||function(t){return t.size}},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}},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}},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))}},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.49.0",mode:s?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745(t,e,i){var s=i(7629);t.exports=function(t,e){return s[t]||(s[t]=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}))},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}))},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)}},5854(t,e,i){var s=i(2777),n=TypeError;t.exports=function(t){var e=s(t,"number");if("number"==typeof e)throw new n("Can't convert number to bigint");return BigInt(e)}},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}},5397(t,e,i){var s=i(7055),n=i(7750);t.exports=function(t){return s(n(t))}},1291(t,e,i){var s=i(741);t.exports=function(t){var e=+t;return e!=e||0===e?0:s(e)}},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}},8981(t,e,i){var s=i(7750),n=Object;t.exports=function(t){return n(s(t))}},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}},2777(t,e,i){var s=i(9565),n=i(34),r=i(757),o=i(5966),h=i(4270),a=i(608),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)}},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+""}},2140(t,e,i){var s={};s[i(608)("toStringTag")]="z",t.exports=s+""=="[object z]"},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)}},6823(t){var e=String;t.exports=function(t){try{return e(t)}catch(t){return"Object"}}},3392(t,e,i){var s=i(9504),n=0,r=Math.random(),o=s(1.1.toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+o(++n+r,36)}},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 v=t.length,b=i||[],y=0,x=0,M="",S=0;if(s)for(;;){if((S=m(t,S))===v){if(M.length>0){if("stop-before-partial"===a)break;if("loose"!==a)throw new f("Missing padding");if(1===M.length)throw new f("Malformed padding: exactly one additional character");y=A(b,w(M,n,!1),y)}x=v;break}var C=g(t,S);if(++S,"="===C){if(M.length<2)throw new f("Padding is too early");if(S=m(t,S),2===M.length){if(S===v){if("stop-before-partial"===a)break;throw new f("Malformed padding: only one =")}"="===g(t,S)&&(++S,S=m(t,S))}if(S<v)throw new f("Unexpected character after padding");y=A(b,w(M,n,"strict"===a),y),x=v;break}if(!h(n,C))throw new f("Unexpected character");var E=s-y;if(1===E&&2===M.length||2===E&&3===M.length)break;if(4===(M+=C).length&&(y=A(b,w(M,n,!1),y),M="",x=S,y===s))break}return{bytes:b,read:x,written:y}}},2303(t,e,i){var s=i(4576),n=i(9504),r=s.Uint8Array,o=s.SyntaxError,h=Math.min,a=n("".match);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?h(e.length,i/2):i/2,n=e||new r(s),c=a(t,/.{2}/g),l=0;l<s;l++){var u=+("0x"+c[l]+"0");if(u!=u)throw new o("String should only contain hex characters");n[l]=u>>4}return{bytes:n,read:l<<1}}},7416(t,e,i){var s=i(9039),n=i(608),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")||new URLSearchParams("?a=1")+""!="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}))},7040(t,e,i){var s=i(4495);t.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},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}))},2812(t){var e=TypeError;t.exports=function(t,i){if(t<i)throw new e("Not enough arguments");return t}},8622(t,e,i){var s=i(4576),n=i(4901),r=s.WeakMap;t.exports=n(r)&&/native code/.test(r+"")},4995(t,e,i){var s=i(9504),n=WeakMap.prototype;t.exports={WeakMap,set:s(n.set),get:s(n.get),has:s(n.has),remove:s(n.delete)}},608(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]}},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)}})},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)}})},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)}})},4423(t,e,i){var s=i(6518),n=i(9617).includes,r=i(9039),o=i(6469),h=r((function(){return!1})),a=r((function(){return!1}));s({target:"Array",proto:!0,forced:h||a},{includes:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}}),o("includes")},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}})},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(608),p=i(7657).IteratorPrototype,g=i(3724),m=i(6395),w="constructor",A="Iterator",v=f("toStringTag"),b=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 b("Abstract class Iterator not directly constructable")},S=function(t,e){g?c(p,t,{configurable:!0,get:function(){return e},set:function(e){if(o(this),this===p)throw new b("You can't redefine this property");d(this,t)?this[t]=e:l(this,t,e)}}):p[t]=e};d(p,v)||S(v,A),!x&&d(p,w)&&p[w]!==Object||S(w,M),M.prototype=p,s({global:!0,constructor:!0,forced:x},{Iterator:M})},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(684),d=i(4549),f=i(6395),p=!f&&!u("drop",0),g=!f&&!p&&d("drop",RangeError),m=f||p||g,w=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:m},{drop:function(t){var e;r(this);try{e=a(h(+t))}catch(t){c(this,"throw",t)}return g?n(g,this,e):new w(o(this),{remaining:e})}})},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}})},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(684),f=i(4549),p=!l&&!d("filter",(function(){})),g=!l&&!p&&f("filter",TypeError),m=l||p||g,w=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:m},{filter:function(t){o(this);try{r(t)}catch(t){u(this,"throw",t)}return g?n(g,this,t):new w(h(this),{predicate:t})}})},116(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)("find",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:l},{find: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(e)}),{IS_RECORD:!0,INTERRUPTED:!0}).result}})},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(684),f=i(4549),p=!u&&!d("flatMap",(function(){})),g=!u&&!p&&f("flatMap",TypeError),m=u||p||g||function(){try{var t=Iterator.prototype.flatMap.call(new Map([[4,5]]).entries(),(function(t){return t}));t.next(),t.return()}catch(t){return!0}}(),w=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:m},{flatMap:function(t){o(this);try{r(t)}catch(t){l(this,"throw",t)}return g?n(g,this,t):new w(h(this),{mapper:t,inner:null})}})},7588(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)("forEach",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:l},{forEach: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;r(e,(function(e){t(e,i++)}),{IS_RECORD:!0})}})},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(684),d=i(4549),f=i(6395),p=!f&&!u("map",(function(){})),g=!f&&!p&&d("map",TypeError),m=f||p||g,w=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:m},{map:function(t){o(this);try{r(t)}catch(t){l(this,"throw",t)}return g?n(g,this,t):new w(h(this),{mapper:t})}})},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}})},4972(t,e,i){var s=i(6518),n=i(9565),r=i(8551),o=i(1767),h=i(4149),a=i(9590),c=i(9462),l=i(9539),u=i(684),d=i(4549),f=i(6395),p=!f&&!u("take",1),g=!f&&!p&&d("take",RangeError),m=f||p||g,w=c((function(){var t=this.iterator;if(!this.remaining--)return this.done=!0,l(t,"normal",void 0);var e=r(n(this.next,t));return(this.done=!!e.done)?void 0:e.value}));s({target:"Iterator",proto:!0,real:!0,forced:m},{take:function(t){var e;r(this);try{e=a(h(+t))}catch(t){l(this,"throw",t)}return g?n(g,this,e):new w(o(this),{remaining:e})}})},9112(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),v=r.JSON,b=r.Number,y=r.SyntaxError,x=v&&v.parse,M=o("Object","keys"),S=Object.getOwnPropertyDescriptor,C=h("".charAt),E=h("".slice),k=h(/./.exec),T=h([].push),P=/^\d$/,D=/^[1-9]$/,I=/^[\d-]$/,N=/^[\t\n\r ]$/,R=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++)O(f,h,R(f,""+h,i,h<n?A[h]:void 0));else for(r=M(f),o=p(r),h=0;h<o;h++)O(f,c=r[h],R(f,c,i,d(A,c)?A[c]:void 0))}return a(i,t,e,f,m)},O=function(t,e,i){if(n){var s=S(t,e);if(s&&!s.configurable)return}void 0===i?delete t[e]:g(t,e,i)},_=function(t,e,i,s){this.value=t,this.end=e,this.source=i,this.nodes=s},F=function(t,e){this.source=t,this.index=e};F.prototype={fork:function(t){return new F(this.source,t)},parse:function(){var t=this.source,e=this.skip(N,this.index),i=this.fork(e),s=C(t,e);if(k(I,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 _(e,s,t?null:E(this.source,i,s),n)},object:function(){for(var t=this.source,e=this.index+1,i=!1,s={},n={},r=!1;e<t.length;){if(e=this.until(['"',"}"],e),"}"===C(t,e)&&!i){e++,r=!0;break}var o=this.fork(e).string(),h=o.value;e=this.until([":"],e=o.end)+1,e=this.skip(N,e),o=this.fork(e).parse(),g(n,h,o),g(s,h,o.value),e=this.until([",","}"],o.end);var a=C(t,e);if(","===a)i=!0,e++;else if("}"===a){e++,r=!0;break}}if(!r)throw new y("Unterminated object at: "+e);return this.node(1,s,this.index,e,n)},array:function(){for(var t=this.source,e=this.index+1,i=!1,s=[],n=[],r=!1;e<t.length;){if(e=this.skip(N,e),"]"===C(t,e)&&!i){e++,r=!0;break}var o=this.fork(e).parse();if(T(n,o),T(s,o.value),e=this.until([",","]"],o.end),","===C(t,e))i=!0,e++;else if("]"===C(t,e)){e++,r=!0;break}}if(!r)throw new y("Unterminated array at: "+e);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("-"===C(t,i)&&i++,"0"===C(t,i))i++;else{if(!k(D,C(t,i)))throw new y("Failed to parse number at: "+i);i=this.skip(P,i+1)}if("."===C(t,i)){var s=i+1;if(s===(i=this.skip(P,s)))throw new y("Failed to parse number's fraction at: "+i)}if(("e"===C(t,i)||"E"===C(t,i))&&(i++,"+"!==C(t,i)&&"-"!==C(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,b(E(t,e,i)),e,i)},keyword:function(t){var e=""+t,i=this.index,s=i+e.length;if(E(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&&k(t,C(i,e));e++);return e},until:function(t,e){e=this.skip(N,e);for(var i=C(this.source,e),s=0;s<t.length;s++)if(t[s]===i)return e;throw new y('Unexpected character: "'+i+'" at: '+e)}};var B=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:B},{parse:function(t,e){return L&&!c(e)?x(t):function(t,e){t=f(t);var i=new F(t,0),s=i.parse(),n=s.value,r=i.skip(N,s.end);if(r<t.length)throw new y('Unexpected extra character: "'+C(t,r)+'" after the parsed data at: '+r);return c(e)?R({"":n},"",e,s):n}(t,e)}})},3110(t,e,i){var s=i(6518),n=i(7751),r=i(8745),o=i(9565),h=i(9504),a=i(9039),c=i(4376),l=i(4901),u=i(5810),d=i(757),f=i(2195),p=i(655),g=i(7680),m=i(8235),w=i(3392),A=i(4495),v=i(7819),b=String,y=n("JSON","stringify"),x=h(/./.exec),M=h("".charAt),S=h("".charCodeAt),C=h("".replace),E=h("".slice),k=h([].push),T=h(1.1.toString),P=/[\uD800-\uDFFF]/g,D=/^[\uD800-\uDBFF]$/,I=/^[\uDC00-\uDFFF]$/,N=w(),R=N.length,O=!A||a((function(){var t=n("Symbol")("stringify detection");return"[null]"!==y([t])||"{}"!==y({a:t})||"{}"!==y(Object(t))})),_=a((function(){return'"\\udf06\\ud834"'!==y("\udf06\ud834")||'"\\udead"'!==y("\udead")})),F=O?function(t,e){var i=g(arguments),s=L(e);if(l(s)||void 0!==t&&!d(t))return i[1]=function(t,e){if(l(s)&&(e=o(s,this,b(t),e)),!d(e))return e},r(y,null,i)}:y,B=function(t,e,i){var s=M(i,e-1),n=M(i,e+1);return x(D,t)&&!x(I,n)||x(I,t)&&!x(D,s)?"\\u"+T(S(t,0),16):t},L=function(t){if(l(t))return t;if(c(t)){for(var e=t.length,i=[],s=0;s<e;s++){var n=t[s];"string"==typeof n?k(i,n):"number"!=typeof n&&"Number"!==f(n)&&"String"!==f(n)||k(i,p(n))}var r=i.length,o=!0;return function(t,e){if(o)return o=!1,e;if(c(this))return e;for(var s=0;s<r;s++)if(i[s]===t)return e}}};y&&s({target:"JSON",stat:!0,arity:3,forced:O||_||!v},{stringify:function(t,e,i){var s=L(e),n=[],r=F(t,(function(t,e){var i=l(s)?o(s,this,b(t),e):e;return!v&&u(i)?N+(k(n,i.rawJSON)-1):i}),i);if("string"!=typeof r)return r;if(_&&(r=C(r,P,B)),v)return r;for(var h="",a=r.length,c=0;c<a;c++){var d=M(r,c);if('"'===d){var f=m(r,++c).end-1,p=E(r,c,f);h+=E(p,0,R)===N?n[E(p,R)]:'"'+p+'"',c=f}else h+=d}return h}})},2731(t,e,i){var s=i(6518),n=i(9306),r=i(2248),o=i(6395),h=r.get,a=r.has,c=r.set;s({target:"Map",proto:!0,real:!0,forced:o},{getOrInsertComputed:function(t,e){var i=a(this,t);if(n(e),i)return h(this,t);0===t&&1/t==-1/0&&(t=0);var s=e(t);return c(this,t,s),s}})},5367(t,e,i){var s=i(6518),n=i(2248),r=i(6395),o=n.get,h=n.has,a=n.set;s({target:"Map",proto:!0,real:!0,forced:r},{getOrInsert:function(t,e){return h(this,t)?o(this,t):(a(this,t,e),e)}})},3068(t,e,i){var s=i(6518),n=i(9504),r=i(2652),o=RangeError,h=TypeError,a=1/0,c=Math.abs,l=Math.pow,u=n([].push),d=l(2,1023),f=l(2,53)-1,p=Number.MAX_VALUE,g=l(2,971),m={},w={},A={},v={},b={},y=function(t,e){var i=t+e;return{hi:i,lo:e-(i-t)}};s({target:"Math",stat:!0},{sumPrecise:function(t){var e=[],i=0,s=v;switch(r(t,(function(t){if(++i>f)throw new o("Maximum allowed index exceeded");if("number"!=typeof t)throw new h("Value is not a number");s!==m&&(t!=t?s=m:t===a?s=s===w?m:A:t===-1/0?s=s===A?m:w:0===t&&1/t!==a||s!==v&&s!==b||(s=b,u(e,t)))})),s){case m:return NaN;case w:return-1/0;case A:return a;case v:return-0}for(var n,l,x,M,S,C,E=[],k=0,T=0;T<e.length;T++){n=e[T];for(var P=0,D=0;D<E.length;D++){if(l=E[D],c(n)<c(l)&&(C=n,n=l,l=C),S=(x=y(n,l)).lo,c(M=x.hi)===a){var I=M===a?1:-1;k+=I,c(n=n-I*d-I*d)<c(l)&&(C=n,n=l,l=C),M=(x=y(n,l)).hi,S=x.lo}0!==S&&(E[P++]=S),n=M}E.length=P,0!==n&&u(E,n)}var N=E.length-1;if(M=0,S=0,0!==k){var R=N>=0?E[N]:0;if(N--,c(k)>1||k>0&&R>0||k<0&&R<0)return k>0?a:-1/0;if(S=(x=y(k*d,R/2)).lo,S*=2,c(2*(M=x.hi))===a)return M>0?M===d&&S===-g/2&&N>=0&&E[N]<0?p:a:M===-d&&S===g/2&&N>=0&&E[N]>0?-p:-1/0;0!==S&&(E[++N]=S,S=0),M*=2}for(;N>=0&&(M=(x=y(M,E[N--])).hi,0===(S=x.lo)););return N>=0&&(S<0&&E[N]<0||S>0&&E[N]>0)&&(l=2*S)==(n=M+l)-M&&(M=n),M}})},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}})},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}}})},7642(t,e,i){var s=i(6518),n=i(3440),r=i(9039);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("difference",(function(t){return 0===t.size}))||r((function(){var t={size:1,has:function(){return!0},keys:function(){var t=0;return{next:function(){var i=t++>1;return e.has(1)&&e.clear(),{done:i,value:2}}}}},e=new Set([1,2,3,4]);return 3!==e.difference(t).size}))},{difference:n})},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 Array.from(new Set([1,2,3]).intersection(new Set([3,2])))+""!="3,2"}))},{intersection:r})},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})},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})},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})},5024(t,e,i){var s=i(6518),n=i(3650),r=i(9835);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("symmetricDifference")||!r("symmetricDifference")},{symmetricDifference:n})},1698(t,e,i){var s=i(6518),n=i(4204),r=i(9835);s({target:"Set",proto:!0,real:!0,forced:!i(4916)("union")||!r("union")},{union:n})},9577(t,e,i){var s=i(4644),n=i(1108),r=i(6198),o=i(1291),h=i(5854),a=s.aTypedArray,c=s.getTypedArrayConstructor,l=s.exportTypedArrayMethod,u=RangeError,d=function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(t){return 8===t}}(),f=d&&function(){try{new Int8Array(1).with(-.5,1)}catch(t){return!0}}();l("with",{with:function(t,e){var i=a(this),s=r(i),l=o(t),d=l<0?s+l:l,f=n(i)?h(e):+e;if(d>=s||d<0)throw new u("Incorrect index");for(var p=new(c(i))(s),g=0;g<s;g++)p[g]=g===d?f:i[g];return p}}.with,!d||f)},5213(t,e,i){var s=i(6518),n=i(4576),r=i(5370),o=i(9143),h=n.Uint8Array,a=!h||!h.fromBase64||!function(){try{return void h.fromBase64("a")}catch(t){}try{h.fromBase64("",null)}catch(t){return!0}}();h&&s({target:"Uint8Array",stat:!0,forced:a},{fromBase64:function(t){var e=o(t,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return r(h,e.bytes)}})},6632(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{return void t.setFromBase64("",null)}catch(t){}try{return void t.setFromBase64("a")}catch(t){}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}}})},4226(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,forced:function(){try{var t=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(t).setFromHex("cafed00d")}catch(t){return!0}}()},{setFromHex:function(t){o(this),r(t),h(this.buffer);var e=a(t,this).read;return{read:e,written:e/2}}})},9486(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),p=n.Uint8Array,g=!p||!p.prototype.toBase64||!function(){try{(new p).toBase64(null)}catch(t){return!0}}();p&&s({target:"Uint8Array",proto:!0,forced:g},{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}})},456(t,e,i){var s=i(6518),n=i(4576),r=i(9504),o=i(4154),h=i(5169),a=r(1.1.toString),c=r([].join),l=Array,u=n.Uint8Array,d=!u||!u.prototype.toHex||!function(){try{return"ffffffffffffffff"===new u([255,255,255,255,255,255,255,255]).toHex()}catch(t){return!1}}();u&&s({target:"Uint8Array",proto:!0,forced:d},{toHex:function(){o(this),h(this.buffer);for(var t=l(this.length),e=0,i=this.length;e<i;e++){var s=a(this[e],16);t[e]=1===s.length?"0"+s:s}return c(t,"")}})},9452(t,e,i){var s=i(6518),n=i(9306),r=i(6557),o=i(4328),h=i(4995),a=i(6395),c=h.get,l=h.has,u=h.set;s({target:"WeakMap",proto:!0,real:!0,forced:a||!function(){try{WeakMap.prototype.getOrInsertComputed&&(new WeakMap).getOrInsertComputed(1,(function(){throw 1}))}catch(t){return t instanceof TypeError}}()},{getOrInsertComputed:function(t,e){if(a||r(this),o(t),n(e),l(this,t))return c(this,t);var i=e(t);return u(this,t,i),i}})},8454(t,e,i){var s=i(6518),n=i(4995),r=i(6395),o=n.get,h=n.has,a=n.set;s({target:"WeakMap",proto:!0,real:!0,forced:r},{getOrInsert:function(t,e){return h(this,t)?o(this,t):(a(this,t,e),e)}})},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),v=function(){c(this,b);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,v),s},b=v.prototype=A.prototype,y="stack"in new w(m),x="stack"in new A(1,2),M=A&&p&&Object.getOwnPropertyDescriptor(n,m),S=y&&!!(!M||M.writable&&M.configurable)&&!x;s({global:!0,constructor:!0,forced:g||S},{DOMException:S?v:A});var C=r(m),E=C.prototype;if(E.constructor!==C)for(var k in g||h(E,"constructor",o(1,C)),d)if(a(d,k)){var T=d[k],P=T.s;a(C,P)||h(C,P,o(6,T.c))}},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=s.length;f<p;)l(this,(n=s[f]).key),f++;for(f=0;f<p;)(n=s[f++]).key===h&&n.value===a||c(this,n.key,n.value)}),{enumerable:!0,unsafe:!0})},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})},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})},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}}})}},R={};function O(t){var e=R[t];if(void 0!==e)return e.exports;var i=R[t]={exports:{}};return N[t].call(i.exports,i,i.exports,O),i.exports}O.d=(t,e)=>{for(var i in e)O.o(e,i)&&!O.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},O.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),O(4423),O(4114),O(6573),O(8100),O(7936),O(5367),O(2731),O(9577),O(6632),O(4226),O(9486),O(456),O(5781);const _=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),F=[1/0,1/0,-1/0,-1/0],B=new Float32Array(F),L=[.001,0,0,.001,0,0],U=1.35,$={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},j="pdfjs_internal_editor_",z={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},H={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},W={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},G={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},V={ERRORS:0,WARNINGS:1,INFOS:5},Y={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};let X=V.WARNINGS;function q(t){Number.isInteger(t)&&(X=t)}function Q(){return X}function K(t){X>=V.INFOS&&console.info("Info: "+t)}function J(t){X>=V.WARNINGS&&console.warn("Warning: "+t)}function Z(t){throw Error(t)}function tt(t,e){t||Z(e)}function et(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=function(t){return decodeURIComponent(escape(t))}(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 it(t,e,i=!1){const s=URL.parse(t);return s?(s.hash=e,s.href):i&&et(t,"http://example.com")?t.split("#",1)[0]+""+(e?"#"+e:""):""}function st(t){return t.substring(t.lastIndexOf("/")+1)}function nt(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const rt=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=Error(),t.constructor=t,t}();class ot extends rt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class ht extends rt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class at extends rt{constructor(t){super(t,"InvalidPDFException")}}class ct extends rt{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class lt extends rt{constructor(t){super(t,"FormatError")}}class ut extends rt{constructor(t){super(t,"AbortException")}}function dt(t){"string"!=typeof t&&Z("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 ft{static get isLittleEndian(){return nt(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isOffscreenCanvasSupported(){return nt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return nt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get isFloat16ArraySupported(){return nt(this,"isFloat16ArraySupported","undefined"!=typeof Float16Array)}static get isSanitizerSupported(){return nt(this,"isSanitizerSupported","undefined"!=typeof Sanitizer)}static get platform(){const{platform:t,userAgent:e}=navigator;return nt(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 nt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}static get isAlphaColorInputSupported(){return nt(this,"isAlphaColorInputSupported",(()=>{if("undefined"==typeof document)return!1;const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080","#ff0000"!==t.value})())}}class pt{static get hexNums(){return nt(this,"hexNums",Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0"))))}static makeHexColor(t,e,i){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){const 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,v=o*d+a,b=v;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,b+=t,v+=e,A+=e}i[0]=Math.min(i[0],f,g,p,m),i[1]=Math.min(i[1],w,v,A,b),i[2]=Math.max(i[2],f,g,p,m),i[3]=Math.max(i[3],w,v,A,b)}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 gt=null,mt=null;function wt(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),function(t){"object"==typeof t&&void 0!==t?.length||Z("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=t.subarray(n,Math.min(n+i,e));s.push(String.fromCharCode.apply(null,r))}return s.join("")}(t)}const At="pdfjs_internal_id_",vt=()=>[],bt=()=>new Map,yt=()=>Object.create(null);function xt(t,e,i){return Math.min(Math.max(t,e),i)}"function"!=typeof Blob.prototype.bytes&&(Blob.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())}),"function"!=typeof Response.prototype.bytes&&(Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())}),"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}),O(8111),O(1701),O(4603),O(7566),O(8721);class Mt{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(!Mt.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)}}class St{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:Object.hasOwn(t.attributes,"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&&Mt.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&&Mt.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 Ct="http://www.w3.org/2000/svg";class Et{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function kt(t,e="text"){if(Rt(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"blob":return i.blob();case"bytes":return i.bytes();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="bytes"===e?"arraybuffer":e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(Error(n.statusText));else{switch(e){case"bytes":return void i(new Uint8Array(n.response));case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class Tt{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 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 nt(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 Tt({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 pt.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];pt.applyTransform(e,this.transform);const i=[t[2],t[3]];return pt.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return pt.applyInverseTransform(i,this.transform),i}}class Pt extends rt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Dt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function It(t){return"string"==typeof t&&/\.pdf$/i.test(t)}class Nt{#i=new Map;times=[];time(t){this.#i.has(t)&&J("Timer is already running for "+t),this.#i.set(t,Date.now())}timeEnd(t){this.#i.has(t)||J("Timer has not been started for "+t),this.times.push({name:t,start:this.#i.get(t),end:Date.now()}),this.#i.delete(t)}toString(){const t=Math.max(...this.times.map((t=>t.name.length)));return this.times.map((e=>`${e.name.padEnd(t)} ${e.end-e.start}ms\n`)).join("")}}function Rt(t,e){const i=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(i?.protocol??"")}function Ot(t){t.preventDefault()}function _t(t){t.preventDefault(),t.stopPropagation()}class Ft{static#s;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#s||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#s.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 Bt(t){if(t.startsWith("#")){const e=t.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(t.startsWith("rgb(")){const[e,i,s]=t.slice(4,-1).split(",").map((t=>parseInt(t,10)));return[e,i,s,1]}if(t.startsWith("rgba(")){const e=t.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const e=t.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return e?[Math.round(255*parseFloat(e[1])),Math.round(255*parseFloat(e[2])),Math.round(255*parseFloat(e[3])),void 0!==e[4]&&"none"!==e[4]?parseFloat(e[4]):1]:null}function Lt(t){const e=Bt(t);return e?e.slice(0,3):(J(`Not a valid color format: "${t}"`),[0,0,0])}function Ut(t){const{a:e,b:i,c:s,d:n,e:r,f:o}=t.getTransform();return[e,i,s,n,r,o]}function $t(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 jt(t,e,i=!1,s=!0){if(e instanceof Tt){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,o=ft.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 zt{constructor(){const{pixelRatio:t}=zt;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=zt.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 Ht=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Wt{static get isDarkMode(){return nt(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}function Gt(t,e){const i=t[0]/255,s=t[1]/255,n=t[2]/255,r=Math.max(i,s,n),o=Math.min(i,s,n),h=(r+o)/2;if(r===o)e[0]=e[1]=0;else{const t=r-o;switch(e[1]=h<.5?t/(r+o):t/(2-r-o),r){case i:e[0]=60*((s-n)/t+(s<n?6:0));break;case s:e[0]=60*((n-i)/t+2);break;case n:e[0]=60*((i-s)/t+4)}}e[2]=h}function Vt(t,e){const i=t[0],s=t[1],n=t[2],r=(1-Math.abs(2*n-1))*s,o=r*(1-Math.abs(i/60%2-1)),h=n-r/2;switch(Math.floor(i/60)){case 0:e[0]=r+h,e[1]=o+h,e[2]=h;break;case 1:e[0]=o+h,e[1]=r+h,e[2]=h;break;case 2:e[0]=h,e[1]=r+h,e[2]=o+h;break;case 3:e[0]=h,e[1]=o+h,e[2]=r+h;break;case 4:e[0]=o+h,e[1]=h,e[2]=r+h;break;case 5:case 6:e[0]=r+h,e[1]=h,e[2]=o+h}}function Yt(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Xt(t,e,i){Vt(t,i),i.map(Yt);const s=.2126*i[0]+.7152*i[1]+.0722*i[2];Vt(e,i),i.map(Yt);const n=.2126*i[0]+.7152*i[1]+.0722*i[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}const qt=new Map;function Qt({html:t,dir:e,className:i},s){const n=document.createDocumentFragment();if("string"==typeof t){const i=document.createElement("p");i.dir=e||"auto";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"));n.append(i)}else St.render({xfaHtml:t,div:n,intent:"richText"});n.firstElementChild.classList.add("richText",i),s.append(n)}function Kt(t){const e=new Path2D;if(!t)return e;for(let i=0,s=t.length;i<s;)switch(t[i++]){case 0:e.moveTo(t[i++],t[i++]);break;case 1:e.lineTo(t[i++],t[i++]);break;case 2:e.bezierCurveTo(t[i++],t[i++],t[i++],t[i++],t[i++],t[i++]);break;case 3:e.quadraticCurveTo(t[i++],t[i++],t[i++],t[i++]);break;case 4:e.closePath();break;default:J("Unrecognized drawing path operator: "+t[i-1])}return e}O(4972),O(4628),O(7642),O(8004),O(3853),O(5876),O(2475),O(5024),O(1698),O(8454),O(9452),O(4979),O(3579),O(3110),O(9314),O(1148),O(9112);class Jt{#n=null;#r=null;#o;#h=null;#a=null;#c=null;#l=null;#u=null;static#d=null;constructor(t){this.#o=t,Jt.#d||=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.#n=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#o._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",Ot,{signal:e}),t.addEventListener("pointerdown",Jt.#f,{signal:e}));const i=this.#h=document.createElement("div");i.className="buttons",t.append(i);const s=this.#o.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#o._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#n}static#f(t){t.stopPropagation()}#p(t){this.#o._focusEventsAllowed=!1,_t(t)}#g(t){this.#o._focusEventsAllowed=!0,_t(t)}#m(t){const e=this.#o._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",this.#p.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#g.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ot,{signal:e}),!0)}hide(){this.#n.classList.add("hidden"),this.#r?.hideDropdown()}show(){this.#n.classList.remove("hidden"),this.#a?.shown(),this.#c?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#o,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",Jt.#d[t]),this.#m(i)&&i.addEventListener("click",(()=>{e.delete()}),{signal:e._signal}),this.#h.append(i)}get#w(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#m(e),this.#h.append(e,this.#w),this.#a=t}addComment(t,e=null){if(this.#c)return;const i=t.renderForToolbar();if(!i)return;this.#m(i);const s=this.#l=this.#w;e?(this.#h.insertBefore(i,e),this.#h.insertBefore(s,e)):this.#h.append(i,s),this.#c=t,t.toolbar=this}addColorPicker(t){if(this.#r)return;this.#r=t;const e=t.renderButton();this.#m(e),this.#h.append(e,this.#w)}async addEditSignatureButton(t){const e=this.#u=await t.renderEditButton(this.#o);this.#m(e),this.#h.append(e,this.#w)}removeButton(t){"comment"===t&&(this.#c?.removeToolbarCommentButton(),this.#c=null,this.#l?.remove(),this.#l=null)}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e)}}async addButtonBefore(t,e,i){if(!e&&"comment"===t)return;const s=this.#h.querySelector(i);s&&"comment"===t&&this.addComment(e,s)}updateEditSignatureButton(t){this.#u&&(this.#u.title=t)}remove(){this.#n.remove(),this.#r?.destroy(),this.#r=null}}class Zt{#h=null;#n=null;#A;constructor(t){this.#A=t}#v(){const t=this.#n=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#A._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",Ot,{signal:e});const i=this.#h=document.createElement("div");return i.className="buttons",t.append(i),this.#A.hasCommentManager()&&this.#b("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",(()=>{this.#A.commentSelection("floating_button")})),this.#b("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",(()=>{this.#A.highlightSelection("floating_button")})),t}#y(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.#y(e,i),{style:r}=this.#n||=this.#v();t.append(this.#n),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#n.remove()}#b(t,e,i,s){const n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",e);const r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",i);const o=this.#A._signal;o instanceof AbortSignal&&!o.aborted&&(n.addEventListener("contextmenu",Ot,{signal:o}),n.addEventListener("click",s,{signal:o})),this.#h.append(n)}}function te(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class ee{static#x=NaN;static#M=null;static#S=NaN;static#C=null;static initializeAndAddPointerId(t){(ee.#M||=new Set).add(t)}static setPointer(t,e){ee.#x||=e,ee.#C??=t}static setTimeStamp(t){ee.#S=t}static isSamePointerId(t){return ee.#x===t}static isSamePointerIdOrRemove(t){return ee.#x===t||(ee.#M?.delete(t),!1)}static isSamePointerType(t){return ee.#C===t}static isInitializedAndDifferentPointerType(t){return null!==ee.#C&&!ee.isSamePointerType(t)}static isSameTimeStamp(t){return ee.#S===t}static isUsingMultiplePointers(){return ee.#M?.size>=1}static clearPointerType(){ee.#C=null}static clearPointerIds(){ee.#x=NaN,ee.#M=null}static clearTimeStamp(){ee.#S=NaN}}class ie{#E=0;get id(){return`${j}${this.#E++}`}}class se{#k=wt();#E=0;#T=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>',nt(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#P(t,e){this.#T||=new Map;let i=this.#T.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.#k}_${this.#E++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await kt(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=se._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){J(t),i=null}return this.#T.set(t,i),i&&this.#T.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#P(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#P(t,t)}async getFromBlob(t,e){const i=await e;return this.#P(t,i)}async getFromId(t){this.#T||=new Map;const e=this.#T.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.#T||=new Map;let i=this.#T.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.#k}_${this.#E++}`,refCounter:1,isSvg:!1},this.#T.set(t,i),this.#T.set(i.id,i),i}getSvgUrl(t){const e=this.#T.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#T||=new Map;const e=this.#T.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.#k}_`)}}class ne{#D=[];#I=!1;#N;#R=-1;constructor(t=128){this.#N=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:o=!1}){if(s&&t(),this.#I)return;const h={cmd:t,undo:e,post:i,type:n};if(-1===this.#R)return this.#D.length>0&&(this.#D.length=0),this.#R=0,void this.#D.push(h);if(r&&this.#D[this.#R].type===n)return o&&(h.undo=this.#D[this.#R].undo),void(this.#D[this.#R]=h);const a=this.#R+1;a===this.#N?this.#D.splice(0,1):(this.#R=a,a<this.#D.length&&this.#D.splice(a)),this.#D.push(h)}undo(){if(-1===this.#R)return;this.#I=!0;const{undo:t,post:e}=this.#D[this.#R];t(),e?.(),this.#I=!1,this.#R-=1}redo(){if(this.#R<this.#D.length-1){this.#R+=1,this.#I=!0;const{cmd:t,post:e}=this.#D[this.#R];t(),e?.(),this.#I=!1}}hasSomethingToUndo(){return-1!==this.#R}hasSomethingToRedo(){return this.#R<this.#D.length-1}cleanType(t){if(-1!==this.#R){for(let e=this.#R;e>=0;e--)if(this.#D[e].type!==t)return this.#D.splice(e+1,this.#R-e),void(this.#R=e);this.#D.length=0,this.#R=-1}}destroy(){this.#D=null}}class re{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ft.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)))}}#O(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.#O(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||_t(e))}}class oe{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,Lt(s))}e.remove()}(t),nt(this,"_colors",t)}convert(t){const e=Lt(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 oe._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?pt.makeHexColor(...e):t}}class he{#_=new AbortController;#F=null;#B=null;#L=new Map;#U=new Map;#$=null;#j=null;#z=null;#H=null;#W=new ne;#G=null;#V=null;#Y=null;#X=0;#q=new Set;#Q=null;#K=null;#J=new Set;_editorUndoBar=null;#Z=!1;#tt=!1;#et=!1;#it=null;#st=null;#nt=null;#rt=null;#ot=!1;#ht=null;#at=new ie;#ct=!1;#lt=!1;#ut=!1;#dt=null;#ft=null;#pt=null;#gt=null;#mt=null;#wt=z.NONE;#At=new Set;#vt=null;#bt=null;#yt=null;#xt=null;#Mt=null;#St={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#Ct=[0,0];#Et=null;#kt=null;#Tt=null;#Pt=null;#Dt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=he.prototype,e=t=>t.#kt.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 nt(this,"_keyboardManager",new re([[["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.#kt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#kt.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,p,g){const m=this._signal=this.#_.signal;this.#kt=t,this.#Tt=e,this.#Pt=i,this.#j=s,this.#G=n,this.#bt=r,this.#Mt=h,this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:m}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),o._on("setpreference",this.onSetPreference.bind(this),{signal:m}),o._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:m}),window.addEventListener("pointerdown",(()=>{this.#lt=!0}),{capture:!0,signal:m}),window.addEventListener("pointerup",(()=>{this.#lt=!1}),{capture:!0,signal:m}),window.addEventListener("beforeunload",this.#It.bind(this),{capture:!0,signal:m}),this.#Nt(),this.#Rt(),this.#Ot(),this.#z=h.annotationStorage,this.#it=h.filterFactory,this.#yt=a,this.#rt=c||null,this.#Z=l,this.#tt=u,this.#et=d,this.#mt=f||null,this.viewParameters={realScale:Et.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=p||null,this._supportsPinchToZoom=!1!==g,n?.setSidebarUiManager(this)}destroy(){this.#Dt?.resolve(),this.#Dt=null,this.#_?.abort(),this.#_=null,this._signal=null;for(const t of this.#U.values())t.destroy();this.#U.clear(),this.#L.clear(),this.#J.clear(),this.#gt?.clear(),this.#F=null,this.#At.clear(),this.#W.destroy(),this.#j?.destroy(),this.#G?.destroy(),this.#bt?.destroy(),this.#ht?.hide(),this.#ht=null,this.#pt?.destroy(),this.#pt=null,this.#B=null,this.#st&&(clearTimeout(this.#st),this.#st=null),this.#Et&&(clearTimeout(this.#Et),this.#Et=null),this._editorUndoBar?.destroy(),this.#Mt=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#mt}get useNewAltTextFlow(){return this.#tt}get useNewAltTextWhenAddingImage(){return this.#et}get hcmFilter(){return nt(this,"hcmFilter",this.#yt?this.#it.addHCMFilter(this.#yt.foreground,this.#yt.background):"none")}get direction(){return nt(this,"direction",getComputedStyle(this.#kt).direction)}get _highlightColors(){return nt(this,"_highlightColors",this.#rt?new Map(this.#rt.split(",").map((t=>((t=t.split("=").map((t=>t.trim())))[1]=t[1].toUpperCase(),t)))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return nt(this,"highlightColors",null);const e=new Map,i=!!this.#yt;for(const[s,n]of t){const t=s.endsWith("_HCM");i&&t?e.set(s.replace("_HCM",""),n):i||t||e.set(s,n)}return nt(this,"highlightColors",e)}get highlightColorNames(){return nt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#Y=t}setMainHighlightColorPicker(t){this.#pt=t}editAltText(t,e=!1){this.#j?.editAltText(this,t,e)}hasCommentManager(){return!!this.#G}editComment(t,e,i,s){this.#G?.showDialog(this,t,e,i,s)}selectComment(t,e){const i=this.#U.get(t),s=i?.getEditorByUID(e);s?.toggleComment(!0,!0)}updateComment(t){this.#G?.updateComment(t.getData())}updatePopupColor(t){this.#G?.updatePopupColor(t)}removeComment(t){this.#G?.removeComments([t.uid])}deleteComment(t,e){const i=()=>{t.comment=e};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,"comment"),this.toggleComment(null),t.comment=null},undo:i,mustExec:!0})}toggleComment(t,e,i){this.#G?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#G?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#G?.dialogElement||null}async waitForEditorsRendered(t){if(this.#U.has(t-1))return;const{resolve:e,promise:i}=Promise.withResolvers(),s=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",s),e())};this._eventBus.on("editorsrendered",s),await i}getSignature(t){this.#bt?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#bt}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.#et=e)}onPageChanging({pageNumber:t}){this.#X=t-1}deletePage(t){for(const e of this.getEditors(t))e.remove();this.#U.delete(t),this.#X===t&&(this.#X=0)}focusMainContainer(){this.#kt.focus()}findParent(t,e){for(const i of this.#U.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.#Tt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#J.add(t)}removeShouldRescale(t){this.#J.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Et.PDF_TO_CSS_UNITS;for(const t of this.#J)t.onScaleChanging();this.#Y?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#_t({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#Ft(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#U.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:o}=i,h=""+i,a=this.#_t(i).closest(".textLayer"),c=this.getSelectionBoxes(a);if(!c)return;i.empty();const l=this.#Ft(a),u=this.#wt===z.NONE,d=()=>{const i=l?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:o,text:h});u&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};u?this.switchToMode(z.HIGHLIGHT,d):d()}commentSelection(t=""){this.highlightSelection(t,!0)}#It(t){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#Bt(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#_t(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#ht||=new Zt(this),this.#ht.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#z)return null;const e=`${j}${t}`,i=this.#z.getRawValue(e);return i&&this.#z.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#z||this.#z.has(t.id)||this.#z.setValue(t.id,t)}a11yAlert(t,e=null){const i=this.#Pt;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#Lt(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#vt&&(this.#ht?.hide(),this.#vt=null,this.#Ut({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#vt)return;const i=this.#_t(t).closest(".textLayer");if(i){if(this.#ht?.hide(),this.#vt=e,this.#Ut({hasSelectedText:!0}),(this.#wt===z.HIGHLIGHT||this.#wt===z.NONE)&&(this.#wt===z.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#ot=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#wt===z.HIGHLIGHT?this.#Ft(i):null;if(t?.toggleDrawing(),this.#lt){const e=new AbortController,i=this.combinedSignal(e),s=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#$t("main_toolbar"))};window.addEventListener("pointerup",s,{signal:i}),window.addEventListener("blur",s,{signal:i})}else t?.toggleDrawing(!0),this.#$t("main_toolbar")}}else this.#vt&&(this.#ht?.hide(),this.#vt=null,this.#Ut({hasSelectedText:!1}))}#$t(t=""){this.#wt===z.HIGHLIGHT?this.highlightSelection(t):this.#Z&&this.#Bt()}#Nt(){document.addEventListener("selectionchange",this.#Lt.bind(this),{signal:this._signal})}#jt(){if(this.#nt)return;this.#nt=new AbortController;const t=this.combinedSignal(this.#nt);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#zt(){this.#nt?.abort(),this.#nt=null}blur(){if(this.isShiftKeyDown=!1,this.#ot&&(this.#ot=!1,this.#$t("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#At)if(e.div.contains(t)){this.#ft=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#ft)return;const[t,e]=this.#ft;this.#ft=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#Ot(){if(this.#dt)return;this.#dt=new AbortController;const t=this.combinedSignal(this.#dt);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Ht(){this.#dt?.abort(),this.#dt=null}#Wt(){if(this.#V)return;this.#V=new AbortController;const t=this.combinedSignal(this.#V);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})}#Gt(){this.#V?.abort(),this.#V=null}#Rt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Ot(),this.setEditingState(!0)}removeEditListeners(){this.#Ht(),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#K)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.#K)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#F?.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.#K)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 J(`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.#Vt(e);this.#Yt(t)},undo:()=>{for(const e of t)e.remove()},mustExec:!0})}catch(t){J(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#wt===z.NONE||this.isEditorHandlingKeyboard||he._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#ot&&(this.#ot=!1,this.#$t("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}updatePageIndex(t,e){for(const i of this.getEditors(t))i.pageIndex=e;const i=this.#$.get(t);i&&(i.pageIndex=e,this.#U.set(e,i),this.#ct?i.enable():i.disable())}startUpdatePages(){this.#$=new Map(this.#U),this.#U.clear()}endUpdatePages(){this.#$=null}clonePage(t,e){for(const i of this.getEditors(t)){const t=i.serialize(i.mode!==z.HIGHLIGHT);t&&(t.pageIndex=e,t.id=this.getId(),t.isClone=!0,delete t.popupRef,this.#z.setValue(t.id,t))}}findClonesForPage(t){const e=[],{pageIndex:i}=t;for(const[s,n]of this.#z)n.pageIndex===i&&n.isClone&&(this.#z.remove(s),e.push(t.deserialize(n).then((e=>{e&&(e.isClone=!0,t.addOrRebuild(e))}))));return Promise.all(e)}#Ut(t){Object.entries(t).some((([t,e])=>this.#St[t]!==e))&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#St,t)}),this.#wt===z.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Xt([[H.HIGHLIGHT_FREE,!0]]))}#Xt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#jt(),this.#Wt(),this.#Ut({isEditing:this.#wt!==z.NONE,isEmpty:this.#qt(),hasSomethingToUndo:this.#W.hasSomethingToUndo(),hasSomethingToRedo:this.#W.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#zt(),this.#Gt(),this.#Ut({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#K){this.#K=t;for(const t of this.#K)this.#Xt(t.defaultPropertiesToUpdate)}}getId(){return this.#at.id}get currentLayer(){return this.#U.get(this.#X)}getLayer(t){return this.#U.get(t)}get currentPageIndex(){return this.#X}addLayer(t){this.#U.set(t.pageIndex,t),this.#ct?t.enable():t.disable()}removeLayer(t){this.#U.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,s=!1,n=!1,r=!1){if(this.#wt!==t&&(!this.#Dt||(await this.#Dt.promise,this.#Dt))){if(this.#Dt=Promise.withResolvers(),this.#Y?.commitOrRemove(),this.#wt===z.POPUP&&this.#G?.hideSidebar(),this.#G?.destroyPopup(),this.#wt=t,t===z.NONE){this.setEditingState(!1),this.#Qt();for(const t of this.#L.values())t.hideStandaloneCommentButton();return this._editorUndoBar?.hide(),this.toggleComment(null),void this.#Dt.resolve()}for(const t of this.#L.values())t.addStandaloneCommentButton();t===z.SIGNATURE&&await(this.#bt?.loadSignatures()),i&&ee.clearPointerType(),this.setEditingState(!0),await this.#Kt(),this.unselectAll();for(const e of this.#U.values())e.updateMode(t);if(t===z.POPUP){this.#B||=await this.#Mt.getAnnotationsByType(new Set(this.#K.map((t=>t._editorType))));const t=new Set,e=[];for(const i of this.#L.values()){const{annotationElementId:s,hasComment:n,deleted:r}=i;s&&t.add(s),n&&!r&&e.push(i.getData())}for(const i of this.#B){const{id:s,popupRef:n,contentsObj:r}=i;n&&r?.str&&!t.has(s)&&!this.#q.has(s)&&e.push(i)}this.#G?.showSidebar(e)}if(!e)return s&&this.addNewEditorFromKeyboard(),void this.#Dt.resolve();for(const t of this.#L.values())t.uid===e?(this.setSelected(t),r?t.editComment():n?t.enterInEditMode():t.focus()):t.unselect();this.#Dt.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#wt&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#K){switch(t){case H.CREATE:return void this.currentLayer.addNewEditor(e);case H.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#xt||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const i of this.#At)i.updateParams(t,e);else for(const i of this.#K)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#L.values())i.editorType===t&&i.show(e);(this.#xt?.get(H.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Xt([[H.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#ut!==t){this.#ut=t;for(const e of this.#U.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Kt(){if(!this.#ct){this.#ct=!0;const t=[];for(const e of this.#U.values())t.push(e.enable());await Promise.all(t);for(const t of this.#L.values())t.enable()}}#Qt(){if(this.unselectAll(),this.#ct){this.#ct=!1;for(const t of this.#U.values())t.disable();for(const t of this.#L.values())t.disable()}}*getEditors(t){for(const e of this.#L.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#L.get(t)}addEditor(t){this.#L.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#st&&clearTimeout(this.#st),this.#st=setTimeout((()=>{this.focusMainContainer(),this.#st=null}),0)),this.#L.delete(t.id),t.annotationElementId&&this.#gt?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#q.has(t.annotationElementId)||this.#z?.remove(t.id)}addDeletedAnnotationElement(t){this.#q.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#q.has(t)}removeDeletedAnnotationElement(t){this.#q.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Vt(t){const e=this.#U.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#F!==t&&(this.#F=t,t&&this.#Xt(t.propertiesToUpdate))}get#Jt(){let t=null;for(t of this.#At);return t}updateUI(t){this.#Jt===t&&this.#Xt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Xt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#At.has(t))return this.#At.delete(t),t.unselect(),void this.#Ut({hasSelectedEditor:this.hasSelection});this.#At.add(t),t.select(),this.#Xt(t.propertiesToUpdate),this.#Ut({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#Y?.commitOrRemove();for(const e of this.#At)e!==t&&e.unselect();this.#G?.destroyPopup(),this.#At.clear(),this.#At.add(t),t.select(),this.#Xt(t.propertiesToUpdate),this.#Ut({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.#Ut({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#At.size}get isEnterHandled(){return 1===this.#At.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#W.undo(),this.#Ut({hasSomethingToUndo:this.#W.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#qt()}),this._editorUndoBar?.hide()}redo(){this.#W.redo(),this.#Ut({hasSomethingToUndo:!0,hasSomethingToRedo:this.#W.hasSomethingToRedo(),isEmpty:this.#qt()})}addCommands(t){this.#W.add(t),this.#Ut({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#qt()})}cleanUndoStack(t){this.#W.cleanType(t)}#qt(){if(0===this.#L.size)return!0;if(1===this.#L.size)for(const t of this.#L.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.#Vt(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.#F?.commitOrRemove()}hasSomethingToControl(){return this.#F||this.hasSelection}#Yt(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.#Ut({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#At)t.commit();this.#Yt(this.#L.values())}unselectAll(){if((!this.#F||(this.#F.commitOrRemove(),this.#wt===z.NONE))&&!this.#Y?.commitOrRemove()&&(this.#G?.destroyPopup(),this.hasSelection)){for(const t of this.#At)t.unselect();this.#At.clear(),this.#Ut({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#Ct[0]+=t,this.#Ct[1]+=e;const[s,n]=this.#Ct,r=[...this.#At];this.#Et&&clearTimeout(this.#Et),this.#Et=setTimeout((()=>{this.#Et=null,this.#Ct[0]=this.#Ct[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#L.has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(const t of r)this.#L.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.#Q=new Map;for(const t of this.#At)this.#Q.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#Q)return!1;this.disableUserSelect(!1);const t=this.#Q;this.#Q=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.#L.has(t.id)){const n=this.#U.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.#Q)for(const i of this.#Q.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.#F===t}getActive(){return this.#F}getMode(){return this.#wt}isEditingMode(){return this.#wt!==z.NONE}get imageManager(){return nt(this,"imageManager",new se)}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.#H||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#H?.delete(t)}renderAnnotationElement(t){const e=this.#H?.get(t.data.id);if(!e)return;const i=this.#z.getRawValue(e);i&&(this.#wt!==z.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){const s=this.#gt?.get(t);s&&(s.setCanvas(e,i),this.#gt.delete(t))}addMissingCanvas(t,e){(this.#gt||=new Map).set(t,e)}}class ae{#a=null;#Zt=!1;#te=null;#ee=null;#ie=null;#se=null;#ne=!1;#re=null;#o=null;#oe=null;#he=null;#ae=!1;static#ce=null;static _l10n=null;constructor(t){this.#o=t,this.#ae=t._uiManager.useNewAltTextFlow,ae.#ce||=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){ae._l10n??=t}async render(){const t=this.#te=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#ee=document.createElement("span");t.append(e),this.#ae?(t.classList.add("new"),t.setAttribute("data-l10n-id",ae.#ce.missing),e.setAttribute("data-l10n-id",ae.#ce["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.#o._uiManager._signal;t.addEventListener("contextmenu",Ot,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#o._uiManager.editAltText(this.#o),this.#ae&&this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#le}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#ne=!0,s(e))}),{signal:i}),await this.#ue(),t}get#le(){return(this.#a?"added":null===this.#a&&this.guessedText&&"review")||"missing"}finish(){this.#te&&(this.#te.focus({focusVisible:this.#ne}),this.#ne=!1)}isEmpty(){return this.#ae?null===this.#a:!this.#a&&!this.#Zt}hasData(){return this.#ae?null!==this.#a||!!this.#oe:this.isEmpty()}get guessedText(){return this.#oe}async setGuessedText(t){null===this.#a&&(this.#oe=t,this.#he=await ae._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#ue())}toggleAltTextBadge(t=!1){if(!this.#ae||this.#a)return this.#re?.remove(),void(this.#re=null);if(!this.#re){const t=this.#re=document.createElement("div");t.className="noAltTextBadge",this.#o.div.append(t)}this.#re.classList.toggle("hidden",!t)}serialize(t){let e=this.#a;return t||this.#oe!==e||(e=this.#he),{altText:e,decorative:this.#Zt,guessedText:this.#oe,textWithDisclaimer:this.#he}}get data(){return{altText:this.#a,decorative:this.#Zt}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#oe=i,this.#he=s),this.#a===t&&this.#Zt===e||(n||(this.#a=t,this.#Zt=e),this.#ue())}toggle(t=!1){this.#te&&(!t&&this.#se&&(clearTimeout(this.#se),this.#se=null),this.#te.disabled=!t)}shown(){this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#le}})}destroy(){this.#te?.remove(),this.#te=null,this.#ee=null,this.#ie=null,this.#re?.remove(),this.#re=null}async#ue(){const t=this.#te;if(!t)return;if(this.#ae){if(t.classList.toggle("done",!!this.#a),t.setAttribute("data-l10n-id",ae.#ce[this.#le]),this.#ee?.setAttribute("data-l10n-id",ae.#ce[this.#le+"-label"]),!this.#a)return void this.#ie?.remove()}else{if(!this.#a&&!this.#Zt)return t.classList.remove("done"),void this.#ie?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#ie;if(!e){this.#ie=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id="alt-text-tooltip-"+this.#o.id;const i=100,s=this.#o._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#se),this.#se=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#se=setTimeout((()=>{this.#se=null,this.#ie.classList.add("show"),this.#o._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#se&&(clearTimeout(this.#se),this.#se=null),this.#ie?.classList.remove("show")}),{signal:s})}this.#Zt?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#a),e.parentNode||t.append(e);const i=this.#o.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class ce{#de=null;#fe=null;#pe=!1;#o=null;#ge=null;#me=null;#we=null;#Ae=null;#ve=!1;#be=null;constructor(t){this.#o=t}renderForToolbar(){const t=this.#fe=document.createElement("button");return t.className="comment",this.#v(t,!1)}renderForStandalone(){const t=this.#de=document.createElement("button");t.className="annotationCommentButton";const e=this.#o.commentButtonPosition;if(e){const{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#o._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const s=this.#o.commentButtonColor;s&&(i.backgroundColor=s)}return this.#v(t,!0)}focusButton(){setTimeout((()=>{(this.#de??this.#fe)?.focus()}),0)}onUpdatedColor(){if(!this.#de)return;const t=this.#o.commentButtonColor;t&&(this.#de.style.backgroundColor=t),this.#o._uiManager.updatePopupColor(this.#o)}get commentButtonWidth(){return(this.#de?.getBoundingClientRect().width??0)/this.#o.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#be)return this.#be;if(!this.#de)return null;const{x:t,y:e,height:i}=this.#de.getBoundingClientRect(),{x:s,y:n,width:r,height:o}=this.#o.parent.boundingClientRect;return[(t-s)/r,(e+i-n)/o]}set commentPopupPositionInLayer(t){this.#be=t}hasDefaultPopupPosition(){return null===this.#be}removeStandaloneCommentButton(){this.#de?.remove(),this.#de=null}removeToolbarCommentButton(){this.#fe?.remove(),this.#fe=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#de&&(this.#de.classList.toggle("selected",t),this.#de.ariaExpanded=e)}#v(t,e){if(!this.#o._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#o._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const i=this.#o._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",Ot,{signal:i}),e&&(t.addEventListener("focusin",(t=>{this.#o._focusEventsAllowed=!1,_t(t)}),{capture:!0,signal:i}),t.addEventListener("focusout",(t=>{this.#o._focusEventsAllowed=!0,_t(t)}),{capture:!0,signal:i})),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=e=>{e.preventDefault(),t===this.#fe?this.edit():this.#o.toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#pe=!0,s(e))}),{signal:i}),t.addEventListener("pointerenter",(()=>{this.#o.toggleComment(!1,!0)}),{signal:i}),t.addEventListener("pointerleave",(()=>{this.#o.toggleComment(!1,!1)}),{signal:i}),t}edit(t){const e=this.commentPopupPositionInLayer;let i,s;if(e)[i,s]=e;else{[i,s]=this.#o.commentButtonPosition;const{width:t,height:e,x:n,y:r}=this.#o;i=n+i*t,s=r+s*e}const n=this.#o.parent.boundingClientRect,{x:r,y:o,width:h,height:a}=n;this.#o._uiManager.editComment(this.#o,r+i*h,o+s*a,{...t,parentDimensions:n})}finish(){this.#fe&&(this.#fe.focus({focusVisible:this.#pe}),this.#pe=!1)}isDeleted(){return this.#ve||""===this.#we}isEmpty(){return null===this.#we}hasBeenEdited(){return this.isDeleted()||this.#we!==this.#ge}serialize(){return this.data}get data(){return{text:this.#we,richText:this.#me,date:this.#Ae,deleted:this.isDeleted()}}set data(t){if(t!==this.#we&&(this.#me=null),null===t)return this.#we="",void(this.#ve=!0);this.#we=t,this.#Ae=new Date,this.#ve=!1}restoreData({text:t,richText:e,date:i}){this.#we=t,this.#me=e,this.#Ae=i,this.#ve=!1}setInitialText(t,e=null){this.#ge=t,this.data=t,this.#Ae=null,this.#me=e}shown(){}destroy(){this.#fe?.remove(),this.#fe=null,this.#de?.remove(),this.#de=null,this.#we="",this.#me=null,this.#Ae=null,this.#o=null,this.#pe=!1,this.#ve=!1}}class le{#kt;#ye=!1;#xe=null;#Me;#Se;#Ce;#Ee;#ke=null;#Te;#Pe=null;#De;#Ie=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:o}){this.#kt=t,this.#xe=i,this.#Me=e,this.#Se=s,this.#Ce=n,this.#Ee=r,this.#De=new AbortController,this.#Te=AbortSignal.any([o,this.#De.signal]),t.addEventListener("touchstart",this.#Ne.bind(this),{passive:!1,signal:this.#Te})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/zt.pixelRatio}#Ne(t){if(this.#Me?.())return;if(1===t.touches.length){if(this.#ke)return;const t=this.#ke=new AbortController,e=AbortSignal.any([this.#Te,t.signal]),i=this.#kt,s={capture:!0,signal:e,passive:!1},n=t=>{"touch"===t.pointerType&&(this.#ke?.abort(),this.#ke=null)};return i.addEventListener("pointerdown",(t=>{"touch"===t.pointerType&&(_t(t),n(t))}),s),i.addEventListener("pointerup",n,s),void i.addEventListener("pointercancel",n,s)}if(!this.#Ie){this.#Ie=new AbortController;const t=AbortSignal.any([this.#Te,this.#Ie.signal]),e=this.#kt,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#Re.bind(this),i);const s=this.#Oe.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",_t,i),e.addEventListener("pointermove",_t,i),e.addEventListener("pointercancel",_t,i),e.addEventListener("pointerup",_t,i),this.#Se?.()}if(_t(t),2!==t.touches.length||this.#xe?.())return void(this.#Pe=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#Pe={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#Re(t){if(!this.#Pe||2!==t.touches.length)return;_t(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.#Pe,{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.#ye&&Math.abs(g-p)<=le.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(h.touch0X=s,h.touch0Y=n,h.touch1X=r,h.touch1Y=o,!this.#ye)return void(this.#ye=!0);const m=[(s+r)/2,(n+o)/2];this.#Ce?.(m,g,p)}#Oe(t){t.touches.length>=2||(this.#Ie&&(this.#Ie.abort(),this.#Ie=null,this.#Ee?.()),this.#Pe&&(_t(t),this.#Pe=null,this.#ye=!1))}destroy(){this.#De?.abort(),this.#De=null,this.#ke?.abort(),this.#ke=null}}class ue{#_e=null;#Fe=null;#a=null;#c=null;#de=null;#Be=!1;#Le=null;#Ue="";#$e=null;#je=null;#ze=null;#He=null;#We=null;#Ge="";#Ve=!1;#Ye=null;#Xe=!1;#qe=!1;#Qe=!1;#Ke=null;#Je=0;#Ze=0;#ti=null;#ei=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;#ii=!1;#si=ue._zIndex++;static _borderLineWidth=-1;static _colorManager=new oe;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=ue.prototype._resizeWithKeyboard,e=he.TRANSLATE_SMALL,i=he.TRANSLATE_BIG;return nt(this,"_resizerKeyboardManager",new re([[["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"],ue.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;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}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return nt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new de({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(ue._l10n??=t,ue._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!==ue._borderLineWidth)return;const i=getComputedStyle(document.documentElement);ue._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Z("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ii}set _isDraggable(t){this.#ii=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(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.#si}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#ni(),this.#He?.remove(),this.#He=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#Ve?this.#Ve=!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.isInEditMode()&&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){if(this.isClone)return void delete this.isClone;const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#ri([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.#ri(this.parentDimensions,t,e)}translateInPage(t,e){this.#Ye||=[this.x,this.y,this.width,this.height],this.#ri(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#Ye||=[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.#Ye&&(this.#Ye[0]!==this.x||this.#Ye[1]!==this.y)}get _hasBeenResized(){return!!this.#Ye&&(this.#Ye[2]!==this.width||this.#Ye[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=ue,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=xt(n,0,i-o),r=xt(r,0,s-h);break;case 90:n=xt(n,0,i-h),r=xt(r,o,s);break;case 180:n=xt(n,o,i),r=xt(r,h,s);break;case 270:n=xt(n,h,i),r=xt(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#oi(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 ue.#oi(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return ue.#oi(t,e,360-this.parentRotation)}#hi(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(){const{div:{style:t},width:e,height:i}=this;t.width=(100*e).toFixed(2)+"%",t.height=(100*i).toFixed(2)+"%"}getInitialTranslation(){return[0,0]}#ai(){if(this.#$e)return;this.#$e=document.createElement("div"),this.#$e.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.#$e.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#ci.bind(this,i),{signal:e}),t.addEventListener("contextmenu",Ot,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#$e)}#ci(t,e){e.preventDefault();const{isMac:i}=ft.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#a?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#je=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#li.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",_t,{passive:!1,signal:r}),window.addEventListener("contextmenu",Ot,{signal:r}),this.#ze={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.#a?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=o,this.div.style.cursor=h,this.#ui()};window.addEventListener("pointerup",a,{signal:r}),window.addEventListener("blur",a,{signal:r})}#di(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#ui(){if(!this.#ze)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#ze;this.#ze=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.#di.bind(this,n,r,o,h),undo:this.#di.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#li(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,o=this.width,h=this.height,a=ue.MIN_SIZE/i,c=ue.MIN_SIZE/s,l=this.#hi(this.rotation),u=(t,e)=>[l[0]*t+l[2]*e,l[1]*t+l[3]*e],d=this.#hi(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 v=u(...A);const b=ue._round(n+v[0]),y=ue._round(r+v[1]);let x,M,S=1,C=1;if(e.fromKeyboard)({deltaX:x,deltaY:M}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#je;[x,M]=this.screenToPageTranslation(t-s,i-n),this.#je[0]=t,this.#je[1]=i}if([x,M]=((t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e])(x/i,M/s),g){const t=Math.hypot(o,h);S=C=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?S=xt(Math.abs(A[0]-w[0]-x),a,1)/o:C=xt(Math.abs(A[1]-w[1]-M),c,1)/h;const E=ue._round(o*S),k=ue._round(h*C);v=u(...p(E,k));const T=b-v[0],P=y-v[1];this.#Ye||=[this.x,this.y,this.width,this.height],this.width=E,this.height=k,this.x=T,this.y=P,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#a?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#qe)return this._editToolbar;this._editToolbar=new Jt(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#a?.destroy()}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#a||(ae.initialize(ue._l10n),this.#a=new ae(this),this.#_e&&(this.#a.data=this.#_e,this.#_e=null)),this.#a}get altTextData(){return this.#a?.data}set altTextData(t){this.#a&&(this.#a.data=t)}get guessedAltText(){return this.#a?.guessedText}async setGuessedAltText(t){await(this.#a?.setGuessedText(t))}serializeAltText(t){return this.#a?.serialize(t)}hasAltText(){return!!this.#a&&!this.#a.isEmpty()}hasAltTextData(){return this.#a?.hasData()??!1}focusCommentButton(){this.#c?.focusButton()}addCommentButton(){return this.canAddComment?this.#c||=new ce(this):null}addStandaloneCommentButton(){this._uiManager.hasCommentManager()&&(this.#de?this._uiManager.isEditingMode()&&this.#de.classList.remove("hidden"):this.hasComment&&(this.#de=this.#c.renderForStandalone(),this.div.append(this.#de)))}removeStandaloneCommentButton(){this.#c.removeStandaloneCommentButton(),this.#de=null}hideStandaloneCommentButton(){this.#de?.classList.add("hidden")}get comment(){if(!this.#c)return null;const{data:{richText:t,text:e,date:i,deleted:s}}=this.#c;return{text:e,richText:t,date:i,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#c||=new ce(this),"object"==typeof t&&null!==t?this.#c.restoreData(t):this.#c.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e)return;if(this.#c||=new ce(this),this.#c.setInitialText(t,i),!this.annotationElementId)return;const s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return this.#c?.hasBeenEdited()}get hasDeletedComment(){return this.#c?.isDeleted()}get hasComment(){return!!this.#c&&!this.#c.isEmpty()&&!this.#c.isDeleted()}async editComment(t){this.#c||=new ce(this),this.#c.edit(t)}toggleComment(t,e){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#c.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const e=180,i=100,[,,,s]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,o=r+n+1;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,s-i,o+e,s]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#c.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#Be?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#fi();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),te(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#ei||=new le({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#pi.bind(this),onPinching:this.#gi.bind(this),onPinchEnd:this.#mi.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#pi(){this.#ze={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#a?.toggle(!1),this.parent.togglePointerEvents(!1)}#gi(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#hi(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=ue.MIN_SIZE/o,f=ue.MIN_SIZE/h;s=Math.max(Math.min(s,1/l,1/u),d/l,f/u);const p=ue._round(l*s),g=ue._round(u*s);if(p===l&&g===u)return;this.#Ye||=[a,c,l,u];const m=r(l/2,u/2),w=ue._round(a+m[0]),A=ue._round(c+m[1]),v=r(p/2,g/2);this.x=w-v[0],this.y=A-v[1],this.width=p,this.height=g,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#mi(){this.#a?.toggle(!0),this.parent.togglePointerEvents(!0),this.#ui()}pointerdown(t){const{isMac:e}=ft.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#Ve=!0,this._isDraggable?this.#wi(t):this.#Ai(t))}#Ai(t){const{isMac:e}=ft.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#wi(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.#Le=null,this.#Ve=!1,this._uiManager.endDragSession()||this.#Ai(t),i&&this._onStopDragging()};e&&(this.#Je=t.clientX,this.#Ze=t.clientY,this.#Le=t.pointerId,this.#Ue=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#Le)return void _t(t);const[r,o]=this.screenToPageTranslation(e-this.#Je,s-this.#Ze);this.#Je=e,this.#Ze=s,this._uiManager.dragSelectedEditors(r,o)}),r),window.addEventListener("touchmove",_t,r),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#Ue&&(this.#ei||t.isPrimary)&&o(t),_t(t)}),r));const h=t=>{this.#Le&&this.#Le!==t.pointerId?_t(t):o(t)};window.addEventListener("pointerup",h,{signal:n}),window.addEventListener("blur",h,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ke&&clearTimeout(this.#Ke),this.#Ke=setTimeout((()=>{this.#Ke=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 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 Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&ue._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#c?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:i,opacity:s,deleted:n,richText:r},uid:o,pageIndex:h,creationDate:a,modificationDate:c}=this;return{id:o,pageIndex:h,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:a,modificationDate:i||c,popupRef:!n,color:e,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#qe=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#qe=!1,!0)}isInEditMode(){return this.#qe}shouldGetKeyboardEvents(){return this.#Qe}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}#fi(){if(this.#We||!this.div)return;this.#We=new AbortController;const t=this._uiManager.combinedSignal(this.#We);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#fi()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:i.getId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,s.#_e=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.#We?.abort(),this.#We=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#Ke&&(clearTimeout(this.#Ke),this.#Ke=null),this.#ni(),this.removeEditToolbar(),this.#ti){for(const t of this.#ti.values())clearTimeout(t);this.#ti=null}this.parent=null,this.#ei?.destroy(),this.#ei=null,this.#He?.remove(),this.#He=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#ai(),this.#$e.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[i,s,n,r]=this.getPDFRect();return[ue._round(i+(n-i)*t),ue._round(s+(r-s)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#c.commentPopupPositionInLayer}set commentPopupPosition(t){this.#c.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#c.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#c.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#c?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#ze={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#$e.children;if(!this.#Fe){this.#Fe=Array.from(e);const t=this.#vi.bind(this),i=this.#bi.bind(this),s=this._uiManager._signal;for(const e of this.#Fe){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.#yi.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",ue._l10nResizer[n])}}const i=this.#Fe[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#Fe.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#$e.append(this.#$e.firstElementChild);else if(n>s)for(let t=0;t<n-s;t++)this.#$e.firstElementChild.before(this.#$e.lastElementChild);let t=0;for(const i of e){const e=this.#Fe[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",ue._l10nResizer[e])}}this.#xi(0),this.#Qe=!0,this.#$e.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#vi(t){ue._resizerKeyboardManager.exec(this,t)}#bi(t){this.#Qe&&t.relatedTarget?.parentNode!==this.#$e&&this.#ni()}#yi(t){this.#Ge=this.#Qe?t:""}#xi(t){if(this.#Fe)for(const e of this.#Fe)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Qe&&this.#li(this.#Ge,{deltaX:t,deltaY:e,fromKeyboard:!0})}#ni(){this.#Qe=!1,this.#xi(-1),this.#ui()}_stopResizingWithKeyboard(){this.#ni(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#a?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})))}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout((()=>this.div?.focus({preventScroll:!0})),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#$e?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#a?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#Xe}set isEditing(t){this.#Xe=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#ti||=new Map;const{action:e}=t;let i=this.#ti.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#ti.delete(e),0===this.#ti.size&&(this.#ti=null)}),ue._telemetryTimeout),void this.#ti.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.#Be=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#Be=!0}updateFakeAnnotationElement(t){if(this.#He||this.deleted)return this.deleted?(this.#He.remove(),void(this.#He=null)):void((this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#He.updateEdited({rect:this.getPDFRect(),popup:this.comment}));this.#He=t.addFakeAnnotation(this)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;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{firstElementChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class de extends ue{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const fe=3285377520,pe=4294901760,ge=65535;class me{constructor(t){this.h1=t?4294967295&t:fe,this.h2=t?4294967295&t:fe}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 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&pe|o*d&ge,o=o<<15|o>>>17,o=o*u&pe|o*f&ge,a^=o,a=a<<13|a>>>19,a=5*a+3864292196):(h=r[t],h=h*l&pe|h*d&ge,h=h<<15|h>>>17,h=h*u&pe|h*f&ge,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&pe|o*d&ge,o=o<<15|o>>>17,o=o*u&pe|o*f&ge,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&pe|36045*t&ge,e=4283543511*e&pe|(2950163797*(e<<16|t>>>16)&pe)>>>16,t^=e>>>1,t=444984403*t&pe|60499*t&ge,e=3301882366*e&pe|(3120437893*(e<<16|t>>>16)&pe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const we=Object.freeze({map:null,hash:"",transfer:void 0});class Ae{#Mi=!1;#Si=null;#Ci=null;#Ei=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){const i=this.#Ei.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Ei.get(t)}remove(t){const e=this.#Ei.get(t);void 0!==e&&(e instanceof ue&&this.#Ci.delete(e.annotationElementId),this.#Ei.delete(t),0===this.#Ei.size&&this.resetModified(),this.#Ei.values().some((t=>t instanceof ue))||this.onAnnotationEditor?.(null))}setValue(t,e){const i=this.#Ei.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.#Ei.set(t,e);s&&this.#ki(),e instanceof ue&&((this.#Ci||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#Ei.has(t)}get size(){return this.#Ei.size}#ki(){this.#Mi||(this.#Mi=!0,this.onSetModified?.())}resetModified(){this.#Mi&&(this.#Mi=!1,this.onResetModified?.())}get print(){return new ve(this)}get serializable(){if(0===this.#Ei.size)return we;const t=new Map,e=new me,i=[],s=Object.create(null);let n=!1;for(const[i,r]of this.#Ei){const o=r instanceof ue?r.serialize(!1,s):r;r.page&&(r.pageIndex=r.page._pageIndex,delete r.page),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}:we}get editorStats(){let t=null;const e=new Map;let i=0,s=0;for(const n of this.#Ei.values()){if(!(n instanceof ue)){n.popup&&(n.popup.deleted?s+=1:i+=1);continue}n.isCommentDeleted?s+=1:n.hasEditedComment&&(i+=1);const r=n.telemetryFinalData;if(!r)continue;const{type:o}=r;e.has(o)||e.set(o,Object.getPrototypeOf(n).constructor),t||=Object.create(null);const h=t[o]||=new Map;for(const[t,e]of Object.entries(r)){if("type"===t)continue;const i=h.getOrInsertComputed(t,bt);i.set(e,(i.get(e)??0)+1)}}if((s>0||i>0)&&(t||=Object.create(null),t.comments={deleted:s,edited:i}),!t)return null;for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#Si=null}updateEditor(t,e){const i=this.#Ci?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#Ci?.get(t)||null}get modifiedIds(){if(this.#Si)return this.#Si;const t=[];if(this.#Ci)for(const e of this.#Ci.values())e.serialize()&&t.push(e.annotationElementId);let e="";if(t.length){const i=new me;i.update(t.join(",")),e=i.hexdigest()}return this.#Si={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#Ei.entries()}}class ve extends Ae{#Ti=we;constructor(t){super();const{serializable:e}=t;if(e===we)return;const{map:i,hash:s,transfer:n}=e,r=structuredClone(i,n?{transfer:n}:null);this.#Ti={map:r,hash:s,transfer:[]}}get print(){Z("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#Ti}get modifiedIds(){return nt(this,"modifiedIds",{ids:new Set,hash:""})}}O(7588);const be="__forcedDependency",{floor:ye,ceil:xe}=Math;function Me(t,e,i,s,n,r){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],s),t[4*e+2]=Math.max(t[4*e+2],n),t[4*e+3]=Math.max(t[4*e+3],r)}const Se=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class Ce{#Pi;#Di;constructor(t,e){this.#Pi=t,this.#Di=e}get length(){return this.#Pi.length}isEmpty(t){return this.#Pi[t]===Se}minX(t){return this.#Di[4*t+0]/256}minY(t){return this.#Di[4*t+1]/256}maxX(t){return(this.#Di[4*t+2]+1)/256}maxY(t){return(this.#Di[4*t+3]+1)/256}}const Ee=(t,e)=>t?.getOrInsertComputed(e,(()=>({dependencies:new Set,isRenderingOperation:!1})));class ke{#Ii=[[1,0,0,1,0,0]];#Ni=[-1/0,-1/0,1/0,1/0];#Ri=new Float64Array(F);_pendingBBoxIdx=-1;#Oi;#_i;#Fi;#Pi;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#Oi=t.width,this.#_i=t.height,this.#Bi(e)}growOperationsCount(t){t>=this.#Pi.length&&this.#Bi(t,this.#Pi)}#Bi(t,e){const i=new ArrayBuffer(4*t);this.#Fi=new Uint8ClampedArray(i),this.#Pi=new Uint32Array(i),e&&e.length>0?(this.#Pi.set(e),this.#Pi.fill(Se,e.length)):this.#Pi.fill(Se)}get clipBox(){return this.#Ni}save(t){return this.#Ni={__proto__:this.#Ni},this._savesStack.push(t),this}restore(t,e){const i=Object.getPrototypeOf(this.#Ni);if(null===i)return this;this.#Ni=i;const s=this._savesStack.pop();return void 0!==s&&(e?.(s,t),this.#Pi[t]=this.#Pi[s]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return 0===this._savesStack.length?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const i=this._savesStack.pop();return void 0!==i&&(e?.(i,t),this.#Pi[t]=this.#Pi[i]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const i=this._markedContentStack.pop();return void 0!==i&&(e?.(i,t),this.#Pi[t]=this.#Pi[i]),this}pushBaseTransform(t){return this.#Ii.push(pt.multiplyByDOMMatrix(this.#Ii.at(-1),t.getTransform())),this}popBaseTransform(){return this.#Ii.length>1&&this.#Ii.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#Ri.set(F,0)),this}recordClipBox(t,e,i,s,n,r){const o=pt.multiplyByDOMMatrix(this.#Ii.at(-1),e.getTransform()),h=F.slice();pt.axialAlignedBoundingBox([i,n,s,r],o,h);const a=pt.intersect(this.#Ni,h);return a?(this.#Ni[0]=a[0],this.#Ni[1]=a[1],this.#Ni[2]=a[2],this.#Ni[3]=a[3]):(this.#Ni[0]=this.#Ni[1]=1/0,this.#Ni[2]=this.#Ni[3]=-1/0),this}recordBBox(t,e,i,s,n,r){const o=this.#Ni;if(o[0]===1/0)return this;const h=pt.multiplyByDOMMatrix(this.#Ii.at(-1),e.getTransform());if(o[0]===-1/0)return pt.axialAlignedBoundingBox([i,n,s,r],h,this.#Ri),this;const a=F.slice();return pt.axialAlignedBoundingBox([i,n,s,r],h,a),this.#Ri[0]=xt(a[0],o[0],this.#Ri[0]),this.#Ri[1]=xt(a[1],o[1],this.#Ri[1]),this.#Ri[2]=xt(a[2],this.#Ri[2],o[2]),this.#Ri[3]=xt(a[3],this.#Ri[3],o[3]),this}recordFullPageBBox(t){return this.#Ri[0]=Math.max(0,this.#Ni[0]),this.#Ri[1]=Math.max(0,this.#Ni[1]),this.#Ri[2]=Math.min(this.#Oi,this.#Ni[2]),this.#Ri[3]=Math.min(this.#_i,this.#Ni[3]),this}recordOperation(t,e=!1,i){if(this._pendingBBoxIdx!==t)return this;const s=ye(256*this.#Ri[0]/this.#Oi),n=ye(256*this.#Ri[1]/this.#_i),r=xe(256*this.#Ri[2]/this.#Oi),o=xe(256*this.#Ri[3]/this.#_i);if(Me(this.#Fi,t,s,n,r,o),i)for(const e of i)for(const i of e)i!==t&&Me(this.#Fi,i,s,n,r,o);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#Ni[0]=Math.max(this.#Ni[0],this.#Ri[0]),this.#Ni[1]=Math.max(this.#Ni[1],this.#Ri[1]),this.#Ni[2]=Math.min(this.#Ni[2],this.#Ri[2]),this.#Ni[3]=Math.min(this.#Ni[3],this.#Ri[3])),this}take(){return new Ce(this.#Pi,this.#Fi)}takeDebugMetadata(){throw Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,i,s=1,n=0,r=0,o){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class Te{#Li={__proto__:null};#Ui={__proto__:null,transform:[],moveText:[],sameLineText:[],[be]:[]};#$i=new Map;#ji=new Set;#zi=new Map;#Hi;#Wi;#Gi;constructor(t,e=!1){this.#Gi=t,e&&(this.#Hi=new Map,this.#Wi=(t,e)=>{Ee(this.#Hi,e).dependencies.add(t)})}get clipBox(){return this.#Gi.clipBox}growOperationsCount(t){this.#Gi.growOperationsCount(t)}save(t){return this.#Li={__proto__:this.#Li},this.#Ui={__proto__:this.#Ui,transform:{__proto__:this.#Ui.transform},moveText:{__proto__:this.#Ui.moveText},sameLineText:{__proto__:this.#Ui.sameLineText},[be]:{__proto__:this.#Ui[be]}},this.#Gi.save(t),this}restore(t){this.#Gi.restore(t,this.#Wi);const e=Object.getPrototypeOf(this.#Li);return null===e||(this.#Li=e,this.#Ui=Object.getPrototypeOf(this.#Ui)),this}recordOpenMarker(t){return this.#Gi.recordOpenMarker(t,this.#Wi),this}getOpenMarker(){return this.#Gi.getOpenMarker()}recordCloseMarker(t){return this.#Gi.recordCloseMarker(t,this.#Wi),this}beginMarkedContent(t){return this.#Gi.beginMarkedContent(t),this}endMarkedContent(t){return this.#Gi.endMarkedContent(t,this.#Wi),this}pushBaseTransform(t){return this.#Gi.pushBaseTransform(t),this}popBaseTransform(){return this.#Gi.popBaseTransform(),this}recordSimpleData(t,e){return this.#Li[t]=e,this}recordIncrementalData(t,e){return this.#Ui[t].push(e),this}resetIncrementalData(t,e){return this.#Ui[t].length=0,this}recordNamedData(t,e){return this.#$i.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#Li[t]=this.#$i.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(be,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#Li&&this.recordFutureForcedDependency(e,this.#Li[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#ji)this.recordFutureForcedDependency(be,t);return this}resetBBox(t){return this.#Gi.resetBBox(t),this}recordClipBox(t,e,i,s,n,r){return this.#Gi.recordClipBox(t,e,i,s,n,r),this}recordBBox(t,e,i,s,n,r){return this.#Gi.recordBBox(t,e,i,s,n,r),this}recordCharacterBBox(t,e,i,s=1,n=0,r=0,o){const h=i.bbox;let a,c;if(h&&(a=h[2]!==h[0]&&h[3]!==h[1]&&this.#zi.get(i),!1!==a&&(c=[0,0,0,0],pt.axialAlignedBoundingBox(h,i.fontMatrix,c),1===s&&0===n&&0===r||pt.scaleMinMax([s,0,0,-s,n,r],c),a)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(t);const l=o();return h&&c&&void 0===a&&(a=c[0]<=n-l.actualBoundingBoxLeft&&c[2]>=n+l.actualBoundingBoxRight&&c[1]<=r-l.actualBoundingBoxAscent&&c[3]>=r+l.actualBoundingBoxDescent,this.#zi.set(i,a),a)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,n-l.actualBoundingBoxLeft,n+l.actualBoundingBoxRight,r-l.actualBoundingBoxAscent,r+l.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#Gi.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#Li[t]}recordDependencies(t,e){const i=this.#ji,s=this.#Li,n=this.#Ui;for(const t of e)t in this.#Li?i.add(s[t]):t in n&&n[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#$i.has(e)&&this.#ji.add(this.#$i.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[be]),this.#Hi){const e=Ee(this.#Hi,t),{dependencies:i}=e;this.#ji.forEach(i.add,i),this.#Gi._savesStack.forEach(i.add,i),this.#Gi._markedContentStack.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}const i=!e&&t===this.#Gi._pendingBBoxIdx;return this.#Gi.recordOperation(t,e,[this.#ji,this.#Gi._savesStack,this.#Gi._markedContentStack]),i&&this.#ji.clear(),this}recordShowTextOperation(t,e=!1){const i=Array.from(this.#ji);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const t of i)this.recordIncrementalData("sameLineText",t);return this}bboxToClipBoxDropOperation(t,e=!1){const i=!e&&t===this.#Gi._pendingBBoxIdx;return this.#Gi.bboxToClipBoxDropOperation(t),i&&this.#ji.clear(),this}take(){return this.#zi.clear(),this.#Gi.take()}takeDebugMetadata(){return this.#Hi}}class Pe{#Vi;#Yi;#Xi;#qi=0;#Qi=0;constructor(t,e,i){if(t instanceof Pe&&t.#Xi===!!i)return t;this.#Vi=t,this.#Yi=e,this.#Xi=!!i}get clipBox(){return this.#Vi.clipBox}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#Qi++,this.#Vi.save(this.#Yi),this}restore(t){return this.#Qi>0&&(this.#Vi.restore(this.#Yi),this.#Qi--),this}recordOpenMarker(t){return this.#qi++,this}getOpenMarker(){return this.#qi>0?this.#Yi:this.#Vi.getOpenMarker()}recordCloseMarker(t){return this.#qi--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#Vi.pushBaseTransform(t),this}popBaseTransform(){return this.#Vi.popBaseTransform(),this}recordSimpleData(t,e){return this.#Vi.recordSimpleData(t,this.#Yi),this}recordIncrementalData(t,e){return this.#Vi.recordIncrementalData(t,this.#Yi),this}resetIncrementalData(t,e){return this.#Vi.resetIncrementalData(t,this.#Yi),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#Vi.recordSimpleDataFromNamed(t,e,this.#Yi),this}recordFutureForcedDependency(t,e){return this.#Vi.recordFutureForcedDependency(t,this.#Yi),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#Vi.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#Vi.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#Xi||this.#Vi.resetBBox(this.#Yi),this}recordClipBox(t,e,i,s,n,r){return this.#Xi||this.#Vi.recordClipBox(this.#Yi,e,i,s,n,r),this}recordBBox(t,e,i,s,n,r){return this.#Xi||this.#Vi.recordBBox(this.#Yi,e,i,s,n,r),this}recordCharacterBBox(t,e,i,s,n,r,o){return this.#Xi||this.#Vi.recordCharacterBBox(this.#Yi,e,i,s,n,r,o),this}recordFullPageBBox(t){return this.#Xi||this.#Vi.recordFullPageBBox(this.#Yi),this}getSimpleIndex(t){return this.#Vi.getSimpleIndex(t)}recordDependencies(t,e){return this.#Vi.recordDependencies(this.#Yi,e),this}recordNamedDependency(t,e){return this.#Vi.recordNamedDependency(this.#Yi,e),this}recordOperation(t){return this.#Vi.recordOperation(this.#Yi,!0),this}recordShowTextOperation(t){return this.#Vi.recordShowTextOperation(this.#Yi,!0),this}bboxToClipBoxDropOperation(t){return this.#Xi||this.#Vi.bboxToClipBoxDropOperation(this.#Yi,!0),this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}const De=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],Ie=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],Ne=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],Re=["filter","fillColor","fillAlpha"],Oe=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],_e=["transform"],Fe=["transform","fillColor"];class Be{#Oi;#_i;#Ki=4;#Ji=0;#Di=new Be.#Zi(6*this.#Ki);static#Zi=ft.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#Oi=t.width,this.#_i=t.height}record(t,e,i,s){if(this.#Ji===this.#Ki){this.#Ki*=2;const t=new Be.#Zi(6*this.#Ki);t.set(this.#Di),this.#Di=t}const n=pt.domMatrixToTransform(t.getTransform());let r;if(s[0]!==1/0){const t=F.slice();pt.axialAlignedBoundingBox([0,-i,e,0],n,t);const o=pt.intersect(s,t);if(!o)return;const[h,a,c,l]=o;if(h!==t[0]||a!==t[1]||c!==t[2]||l!==t[3]){const t=Math.atan2(n[1],n[0]),e=Math.abs(Math.sin(t)),i=Math.abs(Math.cos(t));if(e<1e-6||i<1e-6||Math.abs(e-i)<1e-6)r=[h,a,h,l,c,a];else{const t=c-h,s=l-a,n=e*e,o=i*i,u=i*e,d=o-n,f=(s*o-t*u)/d;r=[h+(s*u-t*n)/d,a,h,a+f,c,l-f]}}}r||(r=[0,-i,0,0,e,-i],pt.applyTransform(r,n,0),pt.applyTransform(r,n,2),pt.applyTransform(r,n,4)),r[0]/=this.#Oi,r[1]/=this.#_i,r[2]/=this.#Oi,r[3]/=this.#_i,r[4]/=this.#Oi,r[5]/=this.#_i,this.#Di.set(r,6*this.#Ji),this.#Ji++}take(){return this.#Di.subarray(0,6*this.#Ji)}}class Le{#ts=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.#ts.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!this.#ts.has(t.loadedName))if(tt(!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.#ts.add(e),i?.(t)}catch{J(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else Z("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 J(`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 nt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return nt(this,"isSyncFontLoadingSupported",_||ft.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(tt(!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 nt(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;n<c.length&&(d=d-u+i(c+"XXX",n)|0),l=s(l,16,4,function(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}(d));const f=`url(data:font/opentype;base64,${btoa(l)});`;this.insertRule(`@font-face {font-family:"${c}";src:${f}}`);const p=this._document.createElement("div");p.style.visibility="hidden",p.style.width=p.style.height="10px",p.style.position="absolute",p.style.top=p.style.left="0px";for(const e of[t.loadedName,c]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,p.append(t)}this._document.body.append(p),function t(e,i){if(++a>30)return J("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,(()=>{p.remove(),e.complete()}))}}class Ue{compiledGlyphs=Object.create(null);#es;constructor(t,e=null,i,s){this.#es=t,this._inspectFont=e,i&&(this.charProcOperatorList=i),s&&Object.assign(this,s)}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,${this.data.toBase64()});`;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){J(`getPathGenerator - ignoring character: "${t}".`)}const n=Kt(s?.path);return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}get black(){return this.#es.black}get bold(){return this.#es.bold}get disableFontFace(){return this.#es.disableFontFace}set disableFontFace(t){nt(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#es.fontExtraProperties}get isInvalidPDFjsFont(){return this.#es.isInvalidPDFjsFont}get isType3Font(){return this.#es.isType3Font}get italic(){return this.#es.italic}get missingFile(){return this.#es.missingFile}get remeasure(){return this.#es.remeasure}get vertical(){return this.#es.vertical}get ascent(){return this.#es.ascent}get defaultWidth(){return this.#es.defaultWidth}get descent(){return this.#es.descent}get bbox(){return this.#es.bbox}get fontMatrix(){return this.#es.fontMatrix}get fallbackName(){return this.#es.fallbackName}get loadedName(){return this.#es.loadedName}get mimetype(){return this.#es.mimetype}get name(){return this.#es.name}get data(){return this.#es.data}clearData(){this.#es.clearData()}get cssFontInfo(){return this.#es.cssFontInfo}get systemFontInfo(){return this.#es.systemFontInfo}get defaultVMetrics(){return this.#es.defaultVMetrics}}class $e{static strings=["fontFamily","fontWeight","italicAngle"]}class je{static strings=["css","loadedName","baseFontName","src"]}class ze{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(2*this.bools.length/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+8*this.numbers.length;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class He{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class We{#is;#ss=new TextDecoder;#ns;constructor(t){this.#is=t,this.#ns=new DataView(t)}#rs(t){tt(t<$e.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#ns.getUint32(e)+4;const i=this.#ns.getUint32(e);return this.#ss.decode(new Uint8Array(this.#is,e+4,i))}get fontFamily(){return this.#rs(0)}get fontWeight(){return this.#rs(1)}get italicAngle(){return this.#rs(2)}}class Ge{#is;#ss=new TextDecoder;#ns;constructor(t){this.#is=t,this.#ns=new DataView(t)}get guessFallback(){return 0!==this.#ns.getUint8(0)}#rs(t){tt(t<je.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#ns.getUint32(e)+4;const i=this.#ns.getUint32(e);return this.#ss.decode(new Uint8Array(this.#is,e+4,i))}get css(){return this.#rs(0)}get loadedName(){return this.#rs(1)}get baseFontName(){return this.#rs(2)}get src(){return this.#rs(3)}get style(){let t=1;t+=4+this.#ns.getUint32(t);const e=this.#ns.getUint32(t),i=this.#ss.decode(new Uint8Array(this.#is,t+4,e));t+=4+e;const s=this.#ns.getUint32(t);return{style:i,weight:this.#ss.decode(new Uint8Array(this.#is,t+4,s))}}}class Ve{#is;#ss=new TextDecoder;#ns;constructor({buffer:t,extra:e}){this.#is=t,this.#ns=new DataView(t),e&&Object.assign(this,e)}#os(t){tt(t<ze.bools.length,"Invalid boolean index");const e=2*t%8,i=this.#ns.getUint8(Math.floor(t/4))>>e&3;return 0===i?void 0:2===i}get black(){return this.#os(0)}get bold(){return this.#os(1)}get disableFontFace(){return this.#os(2)}get fontExtraProperties(){return this.#os(3)}get isInvalidPDFjsFont(){return this.#os(4)}get isType3Font(){return this.#os(5)}get italic(){return this.#os(6)}get missingFile(){return this.#os(7)}get remeasure(){return this.#os(8)}get vertical(){return this.#os(9)}#hs(t){return tt(t<ze.numbers.length,"Invalid number index"),this.#ns.getFloat64(ze.OFFSET_NUMBERS+8*t)}get ascent(){return this.#hs(0)}get defaultWidth(){return this.#hs(1)}get descent(){return this.#hs(2)}#as(t,e,i,s){const n=this.#ns.getUint8(t);if(0===n)return;tt(n===e,"Invalid array length."),t+=1;const r=Array(n);for(let e=0;e<n;e++)r[e]=this.#ns[i](t,!0),t+=s;return r}get bbox(){return this.#as(ze.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#as(ze.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#as(ze.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#rs(t){tt(t<ze.strings.length,"Invalid string index");let e=ze.OFFSET_STRINGS+4;for(let i=0;i<t;i++)e+=this.#ns.getUint32(e)+4;const i=this.#ns.getUint32(e);return this.#ss.decode(new Uint8Array(this.#is,e+4,i))}get fallbackName(){return this.#rs(0)}get loadedName(){return this.#rs(1)}get mimetype(){return this.#rs(2)}get name(){return this.#rs(3)}#cs(){let t=ze.OFFSET_STRINGS;return t+=4+this.#ns.getUint32(t),t+=4+this.#ns.getUint32(t),t+=4+this.#ns.getUint32(t),{offset:t,length:this.#ns.getUint32(t)}}get data(){const{offset:t,length:e}=this.#cs();return 0===e?void 0:new Uint8Array(this.#is,t+4,e)}clearData(){const{offset:t,length:e}=this.#cs();0!==e&&(this.#ns.setUint32(t,0),this.#is=new Uint8Array(this.#is,0,t+4).slice().buffer,this.#ns=new DataView(this.#is))}get cssFontInfo(){let t=ze.OFFSET_STRINGS;t+=4+this.#ns.getUint32(t),t+=4+this.#ns.getUint32(t);const e=this.#ns.getUint32(t);if(0===e)return null;const i=new Uint8Array(e);return i.set(new Uint8Array(this.#is,t+4,e)),new We(i.buffer)}get systemFontInfo(){let t=ze.OFFSET_STRINGS;t+=4+this.#ns.getUint32(t);const e=this.#ns.getUint32(t);if(0===e)return null;const i=new Uint8Array(e);return i.set(new Uint8Array(this.#is,t+4,e)),new Ge(i.buffer)}}class Ye{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[He.KIND],i=!!this.data[He.HAS_BBOX],s=!!this.data[He.HAS_BACKGROUND],n=t.getUint32(He.N_COORD,!0),r=t.getUint32(He.N_COLOR,!0),o=t.getUint32(He.N_STOP,!0);let h=20;const a=new Float32Array(this.buffer,h,2*n);h+=8*n;const c=new Uint8Array(this.buffer,h,4*r);h+=4*r;const l=[];for(let e=0;e<o;++e){const e=t.getFloat32(h,!0);h+=4;const i=t.getUint32(h,!0);h+=4,l.push([e,"#"+i.toString(16).padStart(6,"0")])}let u=null;if(i){u=[];for(let e=0;e<4;++e)u.push(t.getFloat32(h,!0)),h+=4}let d=null;if(s&&(d=new Uint8Array(this.buffer,h,3),h+=3),1===e)return["RadialAxial","axial",u,l,Array.from(a.slice(0,2)),Array.from(a.slice(2,4)),null,null];if(2===e)return["RadialAxial","radial",u,l,[a[0],a[1]],[a[3],a[4]],a[2],a[5]];if(3===e){const t=this.data[He.SHADING_TYPE];let e=null;if(a.length>0){e=F.slice();for(let t=0,i=a.length;t<i;t+=2)pt.pointBoundingBox(a[t],a[t+1],e)}return["Mesh",t,a,c,n,e,u,d]}throw Error("Unsupported pattern kind: "+e)}}class Xe{#is;constructor(t){this.#is=t}get path(){return ft.isFloat16ArraySupported?new Float16Array(this.#is):new Float32Array(this.#is)}}function qe(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}const Qe=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,Ke=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,Qe,(t=>"object"==typeof t&&"string"==typeof t?.name));class Je{#ls=new Map;#us=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#us.then((()=>{for(const[t]of this.#ls)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 J("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#ls.set(e,s)}removeEventListener(t,e){const i=this.#ls.get(e);i?.(),this.#ls.delete(e)}terminate(){for(const[,t]of this.#ls)t?.();this.#ls.clear()}}O(1689);function Ze(){}function ti(t){if(t instanceof ut||t instanceof at||t instanceof ot||t instanceof ct||t instanceof ht)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||Z('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new ut(t.message);case"InvalidPDFException":return new at(t.message);case"PasswordException":return new ot(t.message,t.code);case"ResponseException":return new ct(t.message,t.status,t.missing);case"UnknownErrorException":return new ht(t.message,t.details)}return new ht(t.message,""+t)}class ei{#ds=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.#fs.bind(this),{signal:this.#ds.signal})}#fs({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ps(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw Error("Cannot resolve callback "+e);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else{if(2!==t.callback)throw Error("Unexpected callback case");i.reject(ti(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw 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:ti(e)})}))}else t.streamId?this.#gs(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw 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=>{tt(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:ti(t)}),e.promise}},i)}#gs(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){tt(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:ti(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:ti(t)})}))}#ps(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(ti(t.reason));break;case 7:t.success?r.pullCall.resolve():r.pullCall.reject(ti(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||Ze).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:ti(t)})}));break;case 4:if(tt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case 3:if(tt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#ms(r,e);break;case 5:tt(r,"error should have stream controller"),r.controller.error(ti(t.reason)),this.#ms(r,e);break;case 2:t.success?r.cancelCall.resolve():r.cancelCall.reject(ti(t.reason)),this.#ms(r,e);break;case 1:if(!o)break;const h=ti(t.reason);Promise.try(o.onCancel||Ze,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:ti(t)})})),o.sinkCapability.reject(h),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async#ms(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#ds?.abort(),this.#ds=null}}class ii{#ws=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:i=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=i}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:Z("Not implemented: "+t)}const i=this[t];if(!i)throw Error(`Ensure that the \`${t}\` API parameter is provided.`);const s=`${i}${e}`;return this._fetch(s,t).catch((()=>{throw Error(`Unable to load ${this.#ws[t]} data at: ${s}`)}))}async _fetch(t,e){Z("Abstract method `_fetch` called.")}}class si extends ii{async _fetch(t,e){const i="cMapUrl"!==e||t.endsWith(".bcmap")?"bytes":"text",s=await kt(t,i);return s instanceof Uint8Array?s:dt(s)}}class ni{#As=!1;constructor({enableHWA:t=!1}){this.#As=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#As})}}reset({canvas:t},e,i){if(!t)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.width=e,t.height=i}destroy(t){const{canvas:e}=t;if(!e)throw Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){Z("Abstract method `_createCanvas` called.")}}class ri extends ni{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}}O(2489);class oi{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 hi extends oi{#vs;#bs;#ys;#xs;#Ms;#Ss;#E=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#xs=t,this.#Ms=e}get#T(){return this.#bs||=new Map}get#Cs(){return this.#Ss||=new Map}get#Es(){if(!this.#ys){const t=this.#Ms.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.#Ms.createElementNS(Ct,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#ys=this.#Ms.createElementNS(Ct,"defs"),t.append(i),i.append(this.#ys),this.#Ms.body.append(t)}return this.#ys}#ks(t){if(1===t.length){const e=t[0],i=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=Array(256),r=Array(256),o=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(",")]}#Ts(t){if(void 0===this.#vs){this.#vs="";const t=this.#Ms.URL;t!==this.#Ms.baseURI&&(Dt(t)?J('#createUrl: ignore "data:"-URL for performance reasons.'):this.#vs=it(t,""))}return`url(${this.#vs}#${t})`}addFilter(t){if(!t)return"none";let e=this.#T.get(t);if(e)return e;const[i,s,n]=this.#ks(t),r=1===t.length?i:`${i}${s}${n}`;if(e=this.#T.get(r),e)return this.#T.set(t,e),e;const o=`g_${this.#xs}_transfer_map_${this.#E++}`,h=this.#Ts(o);this.#T.set(t,h),this.#T.set(r,h);const a=this.#Ps(o);return this.#Ds(i,s,n,a),h}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#Cs.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.#Cs.set(s,n)),!t||!e)return n.url;const r=this.#Is(t);t=pt.makeHexColor(...r);const o=this.#Is(e);if(e=pt.makeHexColor(...o),this.#Es.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const h=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.#xs}_hcm_filter`,l=n.filter=this.#Ps(c);this.#Ds(a,a,a,l),this.#Ns(l);const u=(t,e)=>{const i=r[t]/255,s=o[t]/255,n=Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#Ds(u(0,5),u(1,5),u(2,5),l),n.url=this.#Ts(c),n.url}addAlphaFilter(t){let e=this.#T.get(t);if(e)return e;const[i]=this.#ks([t]),s="alpha_"+i;if(e=this.#T.get(s),e)return this.#T.set(t,e),e;const n=`g_${this.#xs}_alpha_map_${this.#E++}`,r=this.#Ts(n);this.#T.set(t,r),this.#T.set(s,r);const o=this.#Ps(n);return this.#Rs(i,o),r}addLuminosityFilter(t){let e,i,s=this.#T.get(t||"luminosity");if(s)return s;if(t?([e]=this.#ks([t]),i="luminosity_"+e):i="luminosity",s=this.#T.get(i),s)return this.#T.set(t,s),s;const n=`g_${this.#xs}_luminosity_map_${this.#E++}`,r=this.#Ts(n);this.#T.set(t,r),this.#T.set(i,r);const o=this.#Ps(n);return this.#Os(o),t&&this.#Rs(e,o),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let o=this.#Cs.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.#Cs.set(t,o)),!e||!i)return o.url;const[h,a]=[e,i].map(this.#Is.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.#Is.bind(this));l<c&&([c,l,u,d]=[l,c,d,u]),this.#Es.style.color="";const f=(t,e,i)=>{const s=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.#xs}_hcm_${t}_filter`,g=o.filter=this.#Ps(p);return this.#Ns(g),this.#Ds(f(u[0],d[0],5),f(u[1],d[1],5),f(u[2],d[2],5),g),o.url=this.#Ts(p),o.url}destroy(t=!1){t&&this.#Ss?.size||(this.#ys?.parentNode.parentNode.remove(),this.#ys=null,this.#bs?.clear(),this.#bs=null,this.#Ss?.clear(),this.#Ss=null,this.#E=0)}#Os(t){const e=this.#Ms.createElementNS(Ct,"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)}#Ns(t){const e=this.#Ms.createElementNS(Ct,"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)}#Ps(t){const e=this.#Ms.createElementNS(Ct,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#Es.append(e),e}#_s(t,e,i){const s=this.#Ms.createElementNS(Ct,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#Ds(t,e,i,s){const n=this.#Ms.createElementNS(Ct,"feComponentTransfer");s.append(n),this.#_s(n,"feFuncR",t),this.#_s(n,"feFuncG",e),this.#_s(n,"feFuncB",i)}#Rs(t,e){const i=this.#Ms.createElementNS(Ct,"feComponentTransfer");e.append(i),this.#_s(i,"feFuncA",t)}#Is(t){return this.#Es.style.color=t,Lt(getComputedStyle(this.#Es).getPropertyValue("color"))}}if(_){let t;try{const e=process.getBuiltinModule("module").createRequire(import.meta.url);try{t=e("@napi-rs/canvas")}catch(t){J(`Cannot load "@napi-rs/canvas" package: "${t}".`)}}catch(t){J(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(t?.DOMMatrix?globalThis.DOMMatrix=t.DOMMatrix:J("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(t?.ImageData?globalThis.ImageData=t.ImageData:J("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(t?.Path2D?globalThis.Path2D=t.Path2D:J("Cannot polyfill `Path2D`, rendering may be broken.")),globalThis.navigator?.language||(globalThis.navigator={language:"en-US",platform:"",userAgent:""})}class ai extends oi{}class ci extends ni{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class li extends ii{async _fetch(t,e){return async function(t){const e=process.getBuiltinModule("fs/promises"),i=await e.readFile(t);return new Uint8Array(i)}(t)}}const ui=new class{#Fs=null;#Bs=null;#Ls=null;#Us=null;async#$s(){if(!globalThis.navigator?.gpu)return!1;try{const t=await navigator.gpu.requestAdapter();return!!t&&(this.#Us=navigator.gpu.getPreferredCanvasFormat(),this.#Bs=await t.requestDevice(),!0)}catch{return!1}}init(){return this.#Fs||=this.#$s()}get isReady(){return null!==this.#Bs}loadMeshShader(){if(!this.#Bs||this.#Ls)return;const t=this.#Bs.createShaderModule({code:"\nstruct Uniforms {\n offsetX : f32,\n offsetY : f32,\n scaleX : f32,\n scaleY : f32,\n paddedWidth : f32,\n paddedHeight : f32,\n borderSize : f32,\n _pad : f32,\n};\n\n@group(0) @binding(0) var<uniform> u : Uniforms;\n\nstruct VertexInput {\n @location(0) position : vec2<f32>,\n @location(1) color : vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) color : vec3<f32>,\n};\n\n@vertex\nfn vs_main(in : VertexInput) -> VertexOutput {\n var out : VertexOutput;\n let cx = (in.position.x + u.offsetX) * u.scaleX;\n let cy = (in.position.y + u.offsetY) * u.scaleY;\n out.position = vec4<f32>(\n ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,\n 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,\n 0.0,\n 1.0\n );\n out.color = in.color.rgb;\n return out;\n}\n\n@fragment\nfn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {\n return vec4<f32>(in.color, 1.0);\n}\n"});this.#Ls=this.#Bs.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#Us}]},primitive:{topology:"triangle-list"}})}draw(t,e,i,s,n,r,o,h){this.loadMeshShader();const a=this.#Bs,{offsetX:c,offsetY:l,scaleX:u,scaleY:d}=s,f=a.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&a.queue.writeBuffer(f,0,t);const p=a.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&a.queue.writeBuffer(p,0,e);const g=a.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});a.queue.writeBuffer(g,0,new Float32Array([c,l,u,d,r,o,h,0]));const m=a.createBindGroup({layout:this.#Ls.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:g}}]}),w=new OffscreenCanvas(r,o),A=w.getContext("webgpu");A.configure({device:a,format:this.#Us,alphaMode:n?"opaque":"premultiplied"});const v=n?{r:n[0]/255,g:n[1]/255,b:n[2]/255,a:1}:{r:0,g:0,b:0,a:0},b=a.createCommandEncoder(),y=b.beginRenderPass({colorAttachments:[{view:A.getCurrentTexture().createView(),clearValue:v,loadOp:"clear",storeOp:"store"}]});return i>0&&(y.setPipeline(this.#Ls),y.setBindGroup(0,m),y.setVertexBuffer(0,f),y.setVertexBuffer(1,p),y.draw(i)),y.end(),a.queue.submit([b.finish()]),f.destroy(),p.destroy(),g.destroy(),w.transferToImageBitmap()}},di="Fill",fi="Stroke",pi="Shading";function gi(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 mi{isModifyingCurrentTransform(){return!1}getPattern(){Z("Abstract method `getPattern` called.")}}class wi extends mi{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let i,s=this._p0,n=this._p1;if(e&&(s=s.slice(),n=n.slice(),pt.applyTransform(s,e),pt.applyTransform(n,e)),"axial"===this._type)i=t.createLinearGradient(s[0],s[1],n[0],n[1]);else if("radial"===this._type){let r=this._r0,o=this._r1;if(e){const t=new Float32Array(2);pt.singularValueDecompose2dScale(e,t),r*=t[0],o*=t[0]}i=t.createRadialGradient(s[0],s[1],r,n[0],n[1],o)}for(const t of this._colorStops)i.addColorStop(t[0],t[1]);return i}_createReversedGradient(t,e=null){let i=this._p1,s=this._p0;e&&(i=i.slice(),s=s.slice(),pt.applyTransform(i,e),pt.applyTransform(s,e));let n=this._r1,r=this._r0;if(e){const t=new Float32Array(2);pt.singularValueDecompose2dScale(e,t),n*=t[0],r*=t[0]}const o=t.createRadialGradient(i[0],i[1],n,s[0],s[1],r),h=this._colorStops.map((([t,e])=>[1-t,e])).reverse();for(const[t,e]of h)o.addColorStop(t,e);return o}getPattern(t,e,i,s){let n;if(s===fi||s===di){if(this.isOriginBased()){let s=pt.transform(i,e.baseTransform);this.matrix&&(s=pt.transform(s,this.matrix));const n=.001,r=Math.hypot(s[0],s[1]),o=Math.hypot(s[2],s[3]);if(Math.abs((s[0]*s[2]+s[1]*s[3])/(r*o))<n){if(!this.isRadial())return this._createGradient(t,s);if(Math.abs(r-o)<n)return this._createGradient(t,s)}}const r=e.current.getClippedPathBoundingBox(s,Ut(t))||[0,0,0,0],o=e.canvasFactory.create(Math.ceil(r[2]-r[0])||1,Math.ceil(r[3]-r[1])||1),h=o.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=pt.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),gi(h,this._bbox),this.areConic()&&(h.fillStyle=this._createReversedGradient(h),h.fill()),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(o.canvas,"no-repeat"),e.canvasFactory.destroy(o);const a=new DOMMatrix(i);n.setTransform(a)}else this.areConic()&&(t.save(),gi(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),gi(t,this._bbox),n=this._createGradient(t);return n}}function Ai(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[2*i+1]>a[2*s+1]&&(d=i,i=s,s=d,d=r,r=o,o=d),a[2*s+1]>a[2*n+1]&&(d=s,s=n,n=d,d=o,o=h,h=d),a[2*i+1]>a[2*s+1]&&(d=i,i=s,s=d,d=r,r=o,o=d);const f=(a[2*i]+e.offsetX)*e.scaleX,p=(a[2*i+1]+e.offsetY)*e.scaleY,g=(a[2*s]+e.offsetX)*e.scaleX,m=(a[2*s+1]+e.offsetY)*e.scaleY,w=(a[2*n]+e.offsetX)*e.scaleX,A=(a[2*n+1]+e.offsetY)*e.scaleY;if(p>=A)return;const v=c[4*r],b=c[4*r+1],y=c[4*r+2],x=c[4*o],M=c[4*o+1],S=c[4*o+2],C=c[4*h],E=c[4*h+1],k=c[4*h+2],T=Math.round(p),P=Math.round(A);let D,I,N,R,O,_,F,B;for(let t=T;t<=P;t++){if(t<m){const e=t<p?0:(p-t)/(p-m);D=f-(f-g)*e,I=v-(v-x)*e,N=b-(b-M)*e,R=y-(y-S)*e}else{let e;e=t>A?1:m===A?0:(m-t)/(m-A),D=g-(g-w)*e,I=x-(x-C)*e,N=M-(M-E)*e,R=S-(S-k)*e}let e;e=t<p?0:t>A?1:(p-t)/(p-A),O=f-(f-w)*e,_=v-(v-C)*e,F=b-(b-E)*e,B=y-(y-k)*e;const i=Math.round(Math.min(D,O)),s=Math.round(Math.max(D,O));let n=u*t+4*i;for(let t=i;t<=s;t++)e=(D-t)/(D-O),e<0?e=0:e>1&&(e=1),l[n++]=I-(I-_)*e|0,l[n++]=N-(N-F)*e|0,l[n++]=R-(R-B)*e|0,l[n++]=255}}class vi extends mi{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null,ui.loadMeshShader()}_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)||1,a=Math.min(Math.ceil(Math.abs(o*t[1]*1.1)),3e3)||1,c=r?r/h:1,l=o?o/a:1,u={coords:this._posData,colors:this._colData,offsetX:-s,offsetY:-n,scaleX:1/c,scaleY:1/l},d=h+4,f=a+4,p=i.create(d,f);if(ui.isReady&&this._vertexCount>48)p.context.drawImage(function(t,e,i,s,n,r,o){return ui.draw(t,e,i,s,n,r,o,2)}(this._posData,this._colData,this._vertexCount,u,e,d,f),0,0);else{const t=p.context.createImageData(h,a);if(e){const i=t.data;for(let t=0,s=i.length;t<s;t+=4)i[t]=e[0],i[t+1]=e[1],i[t+2]=e[2],i[t+3]=255}for(let e=0,i=this._vertexCount;e<i;e+=3)Ai(t,u,e,e+1,e+2,e,e+1,e+2);p.context.putImageData(t,2,2)}return{canvas:p.canvas,offsetX:s-2*c,offsetY:n-2*l,scaleX:c,scaleY:l}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){gi(t,this._bbox);const n=new Float32Array(2);if(s===pi)pt.singularValueDecompose2dScale(Ut(t),n);else if(this.matrix){pt.singularValueDecompose2dScale(this.matrix,n);const[t,i]=n;pt.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=i}else pt.singularValueDecompose2dScale(e.baseTransform,n);const r=this._createMeshCanvas(n,s===pi?null:this._background,e.canvasFactory);s!==pi&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY);const o=t.createPattern(r.canvas,"no-repeat");return e.canvasFactory.destroy(r),o}}class bi extends mi{getPattern(){return"hotpink"}}class yi{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.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s,this.patternBaseMatrix=this.matrix?pt.transform(s,this.matrix):s}canSkipPatternCanvas([t,e,i,s]){const[n,r,o,h]=this.bbox,a=Math.abs(this.xstep),c=Math.abs(this.ystep);if(t>a+1e-6||e>c+1e-6)return null;const l=Math.floor((i-o)/a)+1,u=Math.ceil((i+t-n)/a)-1,d=Math.floor((s-h)/c)+1;return u<=l&&Math.ceil((s+e-r)/c)-1<=d?[l,d]:null}updatePatternDims(t,e){const i=pt.inverseTransform(this.patternBaseMatrix),s=[t[0],t[1]],n=[t[2],t[3]];pt.applyTransform(s,i),pt.applyTransform(n,i),e[0]=Math.abs(n[0]-s[0]),e[1]=Math.abs(n[1]-s[1]),e[2]=Math.min(s[0],n[0]),e[3]=Math.min(s[1],n[1])}_renderTileCanvas(t,e,i,s){const[n,r,o,h]=this.bbox,a=t.canvasFactory.create(i.size,s.size),c=a.context,l=this.canvasGraphicsFactory.createCanvasGraphics(c,e);return l.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(l,this.paintType,this.color),c.translate(-i.scale*n,-s.scale*r),l.transform(0,i.scale,0,0,s.scale,0,0),c.save(),l.dependencyTracker?.save(),this.clipBbox(l,n,r,o,h),l.baseTransform=Ut(l.ctx),l.executeOperatorList(this.operatorList),l.endDrawing(),l.dependencyTracker?.restore(),c.restore(),a}_getCombinedScales(){const t=new Float32Array(2);pt.singularValueDecompose2dScale(this.matrix,t);const[e,i]=t;return pt.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],i*t[1]]}drawPattern(t,e,i=!1,[s,n],r){const[o,h,a,c]=this.bbox,l=t.dependencyTracker;if(l&&(t.dependencyTracker=new Pe(l,r)),t.save(),i?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(s*this.xstep,n*this.ystep),this.needsIsolation||1!==t.ctx.globalAlpha||"source-over"!==t.ctx.globalCompositeOperation||t.inSMaskMode){const e=a-o,i=c-h,[s,n]=this._getCombinedScales(),l=this.getSizeAndScale(e,this.ctx.canvas.width,s),u=this.getSizeAndScale(i,this.ctx.canvas.height,n),d=this._renderTileCanvas(t,r,l,u);t.ctx.drawImage(d.canvas,o,h,e,i),t.canvasFactory.destroy(d)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,o,h,a,c),t.baseTransformStack.push(t.baseTransform),t.baseTransform=Ut(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),l&&(t.dependencyTracker=l)}createPatternCanvas(t,e){const[i,s,n,r]=this.bbox,o=n-i,h=r-s;let{xstep:a,ystep:c}=this;a=Math.abs(a),c=Math.abs(c),K("TilingType: "+this.tilingType);const[l,u]=this._getCombinedScales();let d=o,f=h,p=!1,g=!1;Math.ceil(a*l)>=Math.ceil(o*l)?d=a:p=!0,Math.ceil(c*u)>=Math.ceil(h*u)?f=c:g=!0;const m=this.getSizeAndScale(d,this.ctx.canvas.width,l),w=this.getSizeAndScale(f,this.ctx.canvas.height,u),A=this._renderTileCanvas(t,e,m,w);if(p||g){const e=A.canvas;p&&(d=a),g&&(f=c);const n=this.getSizeAndScale(d,this.ctx.canvas.width,l),r=this.getSizeAndScale(f,this.ctx.canvas.height,u),m=n.size,w=r.size,v=t.canvasFactory.create(m,w),b=v.context,y=p?Math.floor(o/a):0,x=g?Math.floor(h/c):0;for(let t=0;t<=y;t++)for(let i=0;i<=x;i++)b.drawImage(e,m*t,w*i,m,w,0,0,m,w);return t.canvasFactory.destroy(A),{canvas:v.canvas,canvasEntry:v,scaleX:n.scale,scaleY:r.scale,offsetX:i,offsetY:s}}return{canvas:A.canvas,canvasEntry:A,scaleX:m.scale,scaleY:w.scale,offsetX:i,offsetY:s}}getSizeAndScale(t,e,i){const s=Math.max(yi.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){const r=s-e,o=n-i,h=new Path2D;h.rect(e,i,r,o),pt.axialAlignedBoundingBox([e,i,s,n],Ut(t.ctx),t.current.minMax),t.ctx.clip(h),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(n.patternFill=n.patternStroke=!1,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 lt("Unsupported paint type: "+e)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s,n){const r=s!==pi?pt.transform(i,this.patternBaseMatrix):i,o=this.createPatternCanvas(e,n);let h=new DOMMatrix(r);h=h.translate(o.offsetX,o.offsetY),h=h.scale(1/o.scaleX,1/o.scaleY);const a=t.createPattern(o.canvas,"repeat");return e.canvasFactory.destroy(o.canvasEntry),a.setTransform(h),a}}function xi({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:o=!1}){const h=ft.isLittleEndian?4278190080:255,[a,c]=o?[r,h]:[h,r],l=s>>3,u=7&s,d=a^c,f=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<n;++s){for(const s=e+l;e<s;++e,p+=8){const s=t[e];i[p]=a^-(s>>7&1)&d,i[p+1]=a^-(s>>6&1)&d,i[p+2]=a^-(s>>5&1)&d,i[p+3]=a^-(s>>4&1)&d,i[p+4]=a^-(s>>3&1)&d,i[p+5]=a^-(s>>2&1)&d,i[p+6]=a^-(s>>1&1)&d,i[p+7]=a^-(1&s)&d}if(0===u)continue;const s=e<f?t[e++]:255;for(let t=0;t<u;++t,++p)i[p]=a^-(s>>7-t&1)&d}return{srcPos:e,destPos:p}}const Mi=16,Si=new DOMMatrix,Ci=new Float32Array(2);function Ei(t,e,i,s,n,r,o,h,a,c){const[l,u,d,f,p,g]=Ut(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,v=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,v),t.setTransform(l,u,d,f,p,g),[A,v]}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,v=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,v,A),t.setTransform(l,u,d,f,p,g),[v,A]}return t.drawImage(e,i,s,n,r,o,h,a,c),[Math.hypot(l,u)*a,Math.hypot(d,f)*c]}class ki{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=L;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=B.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=di,e=null){const i=this.minMax.slice();if(t===fi){e||Z("Stroke bounding box must include transform."),pt.singularValueDecompose2dScale(e,Ci);const t=Ci[0]*this.lineWidth/2,s=Ci[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){const t=pt.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(B,0)}getClippedPathBoundingBox(t=di,e=null){return pt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Ti(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%Mi,r=(i-n)/Mi,o=0===n?r:r+1,h=t.createImageData(s,Mi);let a,c=0;const l=e.data,u=h.data;let d,f,p,g;if(e.kind===W.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=ft.isLittleEndian?4278190080:255;for(d=0;d<o;d++){for(p=d<r?Mi: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*Mi)}}else if(e.kind===W.RGBA_32BPP){for(f=0,g=s*Mi*4,d=0;d<r;d++)u.set(l.subarray(c,c+g)),c+=g,t.putImageData(h,0,f),f+=Mi;d<o&&(g=s*n*4,u.set(l.subarray(c,c+g)),t.putImageData(h,0,f))}else{if(e.kind!==W.RGB_24BPP)throw Error("bad image kind: "+e.kind);for(p=Mi,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*Mi)}}}function Pi(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%Mi,r=(i-n)/Mi,o=0===n?r:r+1,h=t.createImageData(s,Mi);let a=0;const c=e.data,l=h.data;for(let e=0;e<o;e++){const i=e<r?Mi:n;({srcPos:a}=xi({src:c,srcPos:a,dest:l,width:s,height:i,nonBlackColor:0})),t.putImageData(h,0,e*Mi)}}function Di(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 Ii(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 Ni(t,e){if(e)return!0;pt.singularValueDecompose2dScale(t,Ci);const i=Math.fround(zt.pixelRatio*Et.PDF_TO_CSS_UNITS);return Ci[0]<=i&&Ci[1]<=i}const Ri=["butt","round","square"],Oi=["miter","round","bevel"],_i={},Fi={};class Bi{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:o=null},h,a,c,l){this.ctx=t,this.current=new ki(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,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.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=r,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,this.dependencyTracker=c??null,this.imagesTracker=l??null}getObject(t,e,i=null){return"string"==typeof e?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}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.transparentCanvasEntry=this.canvasFactory.create(n,r);this.compositeCtx=this.ctx,({canvas:this.transparentCanvas,context:this.ctx}=t),this.ctx.save(),this.ctx.transform(...Ut(this.compositeCtx))}this.ctx.save(),Ii(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Ut(this.ctx)}executeOperatorList(t,e,i,s,n){const r=t.argsArray,o=t.fnArray;let h=e||0;const a=r.length;if(a===h)return h;const c=a-h>10&&"function"==typeof i,l=c?Date.now()+15:0;let u=0;const d=this.commonObjs,f=this.objs;let p,g;for(;;){if(void 0!==s){if(h===s.nextBreakPoint)return s.breakIt(h,i),h;if(s.shouldSkip(h)){if(++h===a)return h;continue}}if(!n||n(h))if(p=o[h],g=r[h]??null,p!==Y.dependency)null===g?this[p](h):this[p](h,...g);else for(const t of g){this.dependencyTracker?.recordNamedData(t,h);const e=t.startsWith("g_")?d:f;if(!e.has(t))return e.get(t,i),h}if(h++,h===a)return h;if(c&&++u>10){if(Date.now()>l)return i(),h;u=0}}}#js(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)}endDrawing(){this.#js();for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0,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.#zs()}#zs(){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,n=[];let r=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),h=i,a=s;for(;r>2&&h>1||o>2&&a>1;){let t=h,e=a;r>2&&h>1&&(t=Math.ceil(h/2),r/=h/t),o>2&&a>1&&(e=Math.ceil(a/2),o/=a/e),n.push({newWidth:t,newHeight:e}),h=t,a=e}if(0===n.length)return{img:t,paintWidth:i,paintHeight:s,tmpCanvas:null};if(1===n.length){const{newWidth:e,newHeight:r}=n[0],o=this.canvasFactory.create(e,r);return o.context.drawImage(t,0,0,i,s,0,0,e,r),{img:o.canvas,paintWidth:e,paintHeight:r,tmpCanvas:o}}let c=this.canvasFactory.create(1,1),l=this.canvasFactory.create(1,1),u=i,d=s,f=t;for(const{newWidth:t,newHeight:e}of n)this.canvasFactory.reset(l,t,e),l.context.drawImage(f,0,0,u,d,0,0,t,e),[c,l]=[l,c],f=c.canvas,u=t,d=e;return this.canvasFactory.destroy(l),{img:c.canvas,paintWidth:u,paintHeight:d,tmpCanvas:c}}_createMaskCanvas(t,e){const i=this.ctx,{width:s,height:n}=e,r=this.current.fillColor,o=this.current.patternFill,h=Ut(i);let a,c,l,u;if((e.bitmap||e.data)&&e.count>1){const i=e.bitmap||e.data.buffer;c=JSON.stringify(o?h:[h.slice(0,4),r]),a=this._cachedBitmapsMap.getOrInsertComputed(i,bt);const s=a.get(c);if(s&&!o){const e=Math.round(Math.min(h[0],h[2])+h[4]),i=Math.round(Math.min(h[1],h[3])+h[5]);return this.dependencyTracker?.recordDependencies(t,Fe),{canvas:s,offsetX:e,offsetY:i}}l=s}l||(u=this.canvasFactory.create(s,n),Pi(u.context,e));let d=pt.transform(h,[1/s,0,0,-1/n,0,0]);d=pt.transform(d,[1,0,0,1,0,-n]);const f=B.slice();pt.axialAlignedBoundingBox([0,0,s,n],d,f);const[p,g,m,w]=f,A=this.canvasFactory.create(Math.round(m-p)||1,Math.round(w-g)||1),v=A.context,b=p,y=g;v.translate(-b,-y),v.transform(...d);let x=null;if(!l){const t=this._scaleImage(u.canvas,$t(v));l=t.img,x=t.tmpCanvas,l!==u.canvas&&(this.canvasFactory.destroy(u),u=null),a&&o&&(a.set(c,l),x=null,u=null)}v.imageSmoothingEnabled=Ni(Ut(v),e.interpolate),Ei(v,l,0,0,l.width,l.height,0,0,s,n),x&&this.canvasFactory.destroy(x),u&&this.canvasFactory.destroy(u),v.globalCompositeOperation="source-in";const M=pt.transform($t(v),[1,0,0,1,-b,-y]);return v.fillStyle=o?r.getPattern(i,this,M,di,t):r,v.fillRect(0,0,s,n),a&&!o&&a.set(c,A.canvas),this.dependencyTracker?.recordDependencies(t,Fe),{canvas:A.canvas,canvasEntry:a&&!o?null:A,offsetX:Math.round(b),offsetY:Math.round(y)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=Ri[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Oi[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);const s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(e),s.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(const[i,s]of e)switch(i){case"LW":this.setLineWidth(t,s);break;case"LC":this.setLineCap(t,s);break;case"LJ":this.setLineJoin(t,s);break;case"ML":this.setMiterLimit(t,s);break;case"D":this.setDash(t,s[0],s[1]);break;case"RI":this.setRenderingIntent(t,s);break;case"FL":this.setFlatness(t,s);break;case"Font":this.setFont(t,s[0],s[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=s;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=s;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=s;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=s?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0}_ensurePreparedSMask(t,e,i){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t,e,i))}checkSMaskState(t){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask,this.ctx.canvas.width,this.ctx.canvas.height)}_prepareSMaskCanvas(t,e,i){const{canvas:s,subtype:n,backdrop:r,transferMap:o}=t,h="Luminosity"===n||"Alpha"===n&&o;if(!r&&!h)return void(this.smaskPreparedFor=t);let a,c,l;if(r&&h){const h=this.canvasFactory.create(e,i),u=h.context;u.drawImage(s,t.offsetX,t.offsetY),u.globalCompositeOperation="destination-atop",u.fillStyle=r,u.fillRect(0,0,e,i),u.globalCompositeOperation="source-over",a=this.canvasFactory.create(e,i);const d=a.context;d.filter="Alpha"===n?this.filterFactory.addAlphaFilter(o):this.filterFactory.addLuminosityFilter(o),d.drawImage(h.canvas,0,0),d.filter="none",this.canvasFactory.destroy(h),c=l=0}else if(h){a=this.canvasFactory.create(s.width,s.height);const e=a.context;e.filter="Alpha"===n?this.filterFactory.addAlphaFilter(o):this.filterFactory.addLuminosityFilter(o),e.drawImage(s,0,0),e.filter="none",({offsetX:c,offsetY:l}=t)}else{a=this.canvasFactory.create(e,i);const n=a.context;n.drawImage(s,t.offsetX,t.offsetY),n.globalCompositeOperation="destination-atop",n.fillStyle=r,n.fillRect(0,0,e,i),n.globalCompositeOperation="source-over",c=l=0}this.smaskPreparedEntry=a,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=c,this.smaskPreparedOffsetY=l}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");const{width:e,height:i}=this.ctx.canvas,s=this.canvasFactory.create(e,i);this.smaskScratchCanvas=s,this.suspendedCtx=this.ctx;const n=this.ctx=s.context;n.setTransform(this.suspendedCtx.getTransform()),Di(this.suspendedCtx,n),function(t,e){if(t._removeMirroring)throw 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){void 0===i?(e.setTransform(t),this.__originalSetTransform(t)):(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()}}(n,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask,e,i),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Di(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}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(t[0],t[1],t[2]-t[0],t[3]-t[1]),this.ctx.restore())}composeSMask(t,e,i,s){const n=s[0],r=s[1],o=s[2]-n,h=s[3]-r;if(0===o||0===h)return;const a=this.smaskPreparedEntry;if(a){const t=n-this.smaskPreparedOffsetX,e=r-this.smaskPreparedOffsetY;i.save(),i.globalAlpha=1,i.setTransform(1,0,0,1,0,0);const s=new Path2D;s.rect(n,r,o,h),i.clip(s),i.globalCompositeOperation="destination-in",i.drawImage(a.canvas,t,e,o,h,n,r,o,h),i.restore()}else this.genericComposeSMask(e.context,i,o,h,n,r,e.offsetX,e.offsetY);t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,n,r,o,h,n,r,o,h),t.restore()}genericComposeSMask(t,e,i,s,n,r,o,h){const a=t.canvas,c=n-o,l=r-h;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const u=new Path2D;u.rect(n,r,i,s),e.clip(u),e.globalCompositeOperation="destination-in",e.drawImage(a,c,l,i,s,n,r,i,s),e.restore()}save(t){this.inSMaskMode&&Di(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){this.dependencyTracker?.restore(t),0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(Di(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,s,n,r,o){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,s,n,r,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,s){let[n]=i;if(!s)return n||=i[0]=new Path2D,e!==Y.stroke&&e!==Y.closeStroke&&(this.current.tilingPatternDims=null),void this[e](t,n);if(null!==this.dependencyTracker){const i=e===Y.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-i,s[2]+i,s[1]-i,s[3]+i).recordDependencies(t,["transform"])}n instanceof Path2D||(n=i[0]=Kt(n)),pt.axialAlignedBoundingBox(s,Ut(this.ctx),this.current.minMax);const r=this.current.tilingPatternDims;if(r&&e!==Y.stroke&&e!==Y.closeStroke&&this.current.fillColor instanceof yi){const t=pt.intersect(this.current.clipBox,this.current.minMax);t?this.current.fillColor.updatePatternDims(t,r):this.current.tilingPatternDims=null}this[e](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){const s=this.ctx,n=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof n&&n?.getPattern){const i=n.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=n.getPattern(s,this,$t(s),fi,t),i){const t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),s.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,De),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(fi,Ut(this.ctx))),s.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){const s=this.ctx,n=this.current.fillColor,r=this.current.patternFill;let o=!1;const h=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,Ie),r){const r=this.current.tilingPatternDims,a=r&&n.canSkipPatternCanvas(r);if(a)return n.drawPattern(this,e,this.pendingEOFill,a,t),this.pendingEOFill=!1,i&&this.consumePath(t,e,h),void(this.current.tilingPatternDims=null);const c=n.isModifyingCurrentTransform()?s.getTransform():null;if(this.dependencyTracker?.save(t),s.save(),s.fillStyle=n.getPattern(s,this,$t(s),di,t),c){const t=new Path2D;t.addPath(e,s.getTransform().invertSelf().multiplySelf(c)),e=t}o=!0}this.contentVisible&&null!==h&&(this.pendingEOFill?(s.fill(e,"evenodd"),this.pendingEOFill=!1):s.fill(e)),o&&(s.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,h)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,Re).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=_i}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Fi}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){const t=new Path2D,s=i.getTransform().invertSelf();for(const{transform:i,x:n,y:r,fontSize:o,path:h}of e)h&&t.addPath(h,new DOMMatrix(i).preMultiplySelf(s).translate(n,r).scale(o,-o));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const s=this.commonObjs.get(e),n=this.current;if(!s)throw Error("Can't find font for "+e);if(n.fontMatrix=s.fontMatrix||L,0!==n.fontMatrix[0]&&0!==n.fontMatrix[3]||J("Invalid font matrix for font "+e),i<0?(i=-i,n.fontDirection=-1):n.fontDirection=1,this.current.font=s,this.current.fontSize=i,s.isType3Font)return;const r=s.loadedName||"sans-serif",o=s.systemFontInfo?.css||`"${r}", ${s.fallbackName}`;let h="normal";s.black?h="900":s.bold&&(h="bold");const a=s.italic?"italic":"normal";let c=i;i<16?c=16:i>100&&(c=100),this.current.fontSizeScale=i/c,this.ctx.font=`${a} ${h} ${c}px ${o}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#Hs(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,n,r){const o=this.ctx,h=this.current,a=h.font,c=h.textRenderingMode,l=h.fontSize/h.fontSizeScale,u=3&c,d=!!(4&c),f=h.patternFill&&!a.missingFile,p=h.patternStroke&&!a.missingFile;let g;if((a.disableFontFace||d||f||p)&&!a.missingFile&&(g=a.getPathGenerator(this.commonObjs,e)),g&&(a.disableFontFace||f||p)){let e;if(o.save(),o.translate(i,s),o.scale(l,-l),this.dependencyTracker?.recordCharacterBBox(t,o,a),0===u||2===u)if(n){e=o.getTransform(),o.setTransform(...n);const t=this.#Hs(g,e,n);o.fill(t)}else o.fill(g);if(1===u||2===u)if(r){e||=o.getTransform(),o.setTransform(...r);const{a:t,b:i,c:s,d:n}=e,h=pt.inverseTransform(r),a=pt.transform([t,i,s,n,0,0],h);pt.singularValueDecompose2dScale(a,Ci),o.lineWidth*=Math.max(Ci[0],Ci[1])/l,o.stroke(this.#Hs(g,e,r))}else o.lineWidth/=l,o.stroke(g);o.restore()}else 0!==u&&2!==u||(o.fillText(e,i,s),this.dependencyTracker?.recordCharacterBBox(t,o,a,l,i,s,(()=>o.measureText(e)))),1!==u&&2!==u||(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,o,a,l,i,s,(()=>o.measureText(e))).recordDependencies(t,De),o.strokeText(e,i,s));d&&((this.pendingTextPaths||=[]).push({transform:Ut(o),x:i,y:s,fontSize:l,path:g}),this.dependencyTracker?.recordCharacterBBox(t,o,a,l,i,s))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const i=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let s=!1;for(let t=3;t<i.length;t+=4)if(i[t]>0&&i[t]<255){s=!0;break}return nt(this,"isFontSubpixelAAEnabled",s)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Oe).resetBBox(t),4&this.current.textRenderingMode&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const i=this.current,s=i.font;if(s.isType3Font)return this.showType3Text(t,e),void this.dependencyTracker?.recordShowTextOperation(t);const n=i.fontSize;if(0===n)return void this.dependencyTracker?.recordOperation(t);const r=this.ctx,o=i.fontSizeScale,h=i.charSpacing,a=i.wordSpacing,c=i.fontDirection,l=i.textHScale*c,u=e.length,d=s.vertical,f=d?1:-1,p=s.defaultVMetrics,g=n*i.fontMatrix[0],m=0===i.textRenderingMode&&!s.disableFontFace&&!i.patternFill;let w,A;r.save(),i.textMatrix&&r.transform(...i.textMatrix),r.translate(i.x,i.y+i.textRise),r.scale(l,c>0?-1:1);const v=3&i.textRenderingMode,b=0===v||2===v,y=1===v||2===v;let x=i.lineWidth;const M=i.textMatrixScale;if(0===M||0===x?y&&(x=this.getSinglePixelWidth()):x/=M,1!==o&&(r.scale(o,o),x/=o),r.lineWidth=x,b&&i.patternFill){r.save();const e=i.fillColor.getPattern(r,this,$t(r),di,t);w=Ut(r),r.restore(),r.fillStyle=e}if(y&&i.patternStroke){r.save();const e=i.strokeColor.getPattern(r,this,$t(r),fi,t);A=Ut(r),r.restore(),r.strokeStyle=e}if(s.isInvalidPDFjsFont){const s=[];let n=0;for(const t of e)s.push(t.unicode),n+=t.width;const o=s.join("");if(r.fillText(o,0,0),null!==this.dependencyTracker){const e=r.measureText(o);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}return i.x+=n*g*l,r.restore(),void this.compose()}let S,C=0;for(S=0;S<u;++S){const i=e[S];if("number"==typeof i){C+=f*i*n/1e3;continue}let l=!1;const u=(i.isSpace?a:0)+h,v=i.fontChar,b=i.accent;let y,x,M,E=i.width;if(d){const t=i.vmetric||p,e=-(i.vmetric?t[1]:.5*E)*g;E=t?-t[0]:E,y=e/o,x=(C+t[2]*g)/o}else y=C/o,x=0;if(s.remeasure&&E>0){M=r.measureText(v);const t=1e3*M.width/n*o;if(E<t&&this.isFontSubpixelAAEnabled){const e=E/t;l=!0,r.save(),r.scale(e,1),y/=e}else E!==t&&(y+=(E-t)/2e3*n/o)}this.contentVisible&&(i.isInFont||s.missingFile)&&(m&&!b?(r.fillText(v,y,x),this.dependencyTracker?.recordCharacterBBox(t,r,M?{bbox:null}:s,n/o,y,x,(()=>M??r.measureText(v)))):(this.paintChar(t,v,y,x,w,A),b&&this.paintChar(t,b.fontChar,y+n*b.offset.x/o,x-n*b.offset.y/o,w,A))),C+=d?E*g-u*c:E*g+u*c,l&&r.restore()}d?i.y-=C:i.x+=C*l,r.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,e){const i=this.ctx,s=this.current,n=s.font,r=s.fontSize,o=s.fontDirection,h=n.vertical?1:-1,a=s.charSpacing,c=s.wordSpacing,l=s.textHScale*o,u=s.fontMatrix||L,d=e.length;let f,p,g,m;if(3===s.textRenderingMode||0===r)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,i.save(),s.textMatrix&&i.transform(...s.textMatrix),i.translate(s.x,s.y+s.textRise),i.scale(l,o);const w=this.dependencyTracker;for(this.dependencyTracker=w?new Pe(w,t):null,f=0;f<d;++f){if(p=e[f],"number"==typeof p){m=h*p*r/1e3,this.ctx.translate(m,0),s.x+=m*l;continue}const t=(p.isSpace?c:0)+a,o=n.charProcOperatorList[p.operatorListId];o?this.contentVisible&&(this.save(),i.scale(r,r),i.transform(...u),this.executeOperatorList(o),this.restore()):J(`Type3 character "${p.operatorListId}" is not available.`);const d=[p.width,0];pt.applyTransform(d,u),g=d[0]*r+t,i.translate(g,0),s.x+=g*l}i.restore(),w&&(this.dependencyTracker=w)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,s,n,r,o){const h=new Path2D;h.rect(s,n,r-s,o-n),this.ctx.clip(h),this.dependencyTracker?.recordBBox(t,this.ctx,s,r,n,o).recordClipBox(t,this.ctx,s,r,n,o),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){const t=this.baseTransform||Ut(this.ctx);i=new yi(e,this.ctx,{createCanvasGraphics:(t,e)=>new Bi(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Pe(this.dependencyTracker,e,!0):null)},t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);const i=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=i instanceof yi?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,i=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=function(t){switch(t[0]){case"RadialAxial":return new wi(t);case"Mesh":return new vi(t);case"Dummy":return new bi}throw Error("Unknown IR type: "+t[0])}(this.getObject(t,e)),this.cachedPatterns.set(e,s)),i&&(s.matrix=i),s}shadingFill(t,e){if(!this.contentVisible)return;const i=this.ctx;this.save(t);const s=this._getPattern(t,e);i.fillStyle=s.getPattern(i,this,$t(i),pi,t);const n=$t(i);if(n){const{width:t,height:e}=i.canvas,s=B.slice();pt.axialAlignedBoundingBox([0,0,t,e],n,s);const[r,o,h,a]=s;this.ctx.fillRect(r,o,h-r,a-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,_e).recordDependencies(t,Ie).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){Z("Should not call beginInlineImage")}beginImageData(){Z("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Ut(this.ctx),i)){pt.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[e,s,n,r]=i,o=new Path2D;o.rect(e,s,n-e,r-s),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(t,this.ctx,e,n,s,r),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t);const{inSMaskMode:i}=this;i&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;if(e.isolated||K("TODO: Support non-isolated groups."),e.knockout&&J("Knockout groups not supported."),!e.needsIsolation&&1===s.globalAlpha&&"source-over"===s.globalCompositeOperation&&!i){if(e.bbox){let t=new Path2D;const[i,n,r,o]=e.bbox;if(t.rect(i,n,r-i,o-n),e.matrix){const i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix)),t=i}s.clip(t)}return this.groupStack.push(null),void this.groupLevel++}const n=Ut(s);e.matrix&&s.transform(...e.matrix);const r=[0,0,s.canvas.width,s.canvas.height];let o;e.bbox?(o=B.slice(),pt.axialAlignedBoundingBox(e.bbox,Ut(s),o),o=pt.intersect(o,r)||[0,0,0,0]):o=r;const h=Math.floor(o[0]),a=Math.floor(o[1]),c=Math.max(Math.ceil(o[2])-h,1),l=Math.max(Math.ceil(o[3])-a,1);this.current.startNewPathAndClipBox([0,0,c,l]);const u=this.canvasFactory.create(c,l);e.smask&&this.smaskGroupCanvases.push(u);const d=u.context;if(d.translate(-h,-a),d.transform(...n),!e.isolated&&!e.smask&&i&&e.needsIsolation&&(d.save(),d.setTransform(1,0,0,1,0,0),d.drawImage(s.canvas,-h,-a),d.restore()),e.bbox){let t=new Path2D;const[i,s,n,r]=e.bbox;if(t.rect(i,s,n-i,r-s),e.matrix){const i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix)),t=i}d.clip(t)}e.smask&&this.smaskStack.push({canvas:u.canvas,context:d,offsetX:h,offsetY:a,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),e.smask&&!this.dependencyTracker||(s.setTransform(1,0,0,1,0,0),s.translate(h,a),s.save()),Di(s,d),this.ctx=d,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(s),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,s=this.groupStack.pop();if(null!==s)if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform()));else{this.ctx.restore();const e=Ut(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);const s=B.slice();pt.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,s),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy({canvas:i.canvas,context:i}),this.compose(s)}else this.restore(t)}beginAnnotation(t,e,i,s,n,r){if(this.#js(),Ii(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){const n=i[2]-i[0],o=i[3]-i[1];if(r&&this.annotationCanvasMap){(s=s.slice())[4]-=i[0],s[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=n,i[3]=o,pt.singularValueDecompose2dScale(Ut(this.ctx),Ci);const{viewportScale:t}=this;this.annotationCanvas=this.canvasFactory.create(Math.ceil(n*this.outputScaleX*t),Math.ceil(o*this.outputScaleY*t));const{canvas:r,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,r),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(Ci[0],0,0,-Ci[1],0,o*Ci[1]),Ii(this.ctx)}else{Ii(this.ctx),this.endPath(t);const e=new Path2D;e.rect(i[0],i[1],n,o),this.ctx.clip(e)}}this.current=new ki(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...s),this.transform(t,...n),this.baseTransform=Ut(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#zs(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;const i=e.count;(e=this.getObject(t,e.data,e)).count=i;const s=this.ctx,n=this._createMaskCanvas(t,e),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,n.offsetX,n.offsetX+r.width,n.offsetY,n.offsetY+r.height).recordOperation(t),s.restore(),n.canvasEntry&&this.canvasFactory.destroy(n.canvasEntry),this.compose()}paintImageMaskXObjectRepeat(t,e,i,s=0,n=0,r,o){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const h=this.ctx;h.save();const a=Ut(h);h.transform(i,s,n,r,0,0);const c=this._createMaskCanvas(t,e);h.setTransform(1,0,0,1,c.offsetX-a[4],c.offsetY-a[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,l=o.length;e<l;e+=2){const l=pt.transform(a,[i,s,n,r,o[e],o[e+1]]);h.drawImage(c.canvas,l[4],l[5]),this.dependencyTracker?.recordBBox(t,this.ctx,l[4],l[4]+c.canvas.width,l[5],l[5]+c.canvas.height)}h.restore(),c.canvasEntry&&this.canvasFactory.destroy(c.canvasEntry),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx,s=this.current.fillColor,n=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Fe);for(const r of e){const{data:e,width:o,height:h,transform:a}=r,c=this.canvasFactory.create(o,h),l=c.context;l.save(),Pi(l,this.getObject(t,e,r)),l.globalCompositeOperation="source-in",l.fillStyle=n?s.getPattern(l,this,$t(i),di,t):s,l.fillRect(0,0,o,h),l.restore(),i.save(),i.transform(...a),i.scale(1,-1),Ei(i,c.canvas,0,0,o,h,0,-1,1,1),this.canvasFactory.destroy(c),this.dependencyTracker?.recordBBox(t,i,0,o,0,h),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):J("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s,n){if(!this.contentVisible)return;const r=this.getObject(t,e);if(!r)return void J("Dependent image isn't ready yet");const o=r.width,h=r.height,a=[];for(let t=0,e=n.length;t<e;t+=2)a.push({transform:[i,0,0,s,n[t],n[t+1]],x:0,y:0,w:o,h});this.paintInlineImageXObjectGroup(t,r,a)}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{img:t.bitmap,canvasEntry:null};const{bitmap:e,width:i,height:s}=t,n=this.canvasFactory.create(i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",{img:n.canvas,canvasEntry:n}}paintInlineImageXObject(t,e){if(!this.contentVisible)return;const i=e.width,s=e.height,n=this.ctx;this.save(t);const{filter:r}=n;let o;"none"!==r&&""!==r&&(n.filter="none"),n.scale(1/i,-1/s);let h=null;if(e.bitmap){const t=this.applyTransferMapsToBitmap(e);o=t.img,h=t.canvasEntry}else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)o=e;else{const t=this.canvasFactory.create(i,s);Ti(t.context,e),o=this.applyTransferMapsToCanvas(t.context),h=t}const a=this._scaleImage(o,$t(n));n.imageSmoothingEnabled=Ni(Ut(n),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,n,0,i,-s,0).recordDependencies(t,Ne).recordOperation(t),this.imagesTracker?.record(n,i,s,this.dependencyTracker.clipBox)),Ei(n,a.img,0,0,a.paintWidth,a.paintHeight,0,-s,i,s),a.tmpCanvas&&this.canvasFactory.destroy(a.tmpCanvas),h&&this.canvasFactory.destroy(h),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){if(!this.contentVisible)return;const s=this.ctx;let n,r=null;if(e.bitmap)n=e.bitmap;else{const t=this.canvasFactory.create(e.width,e.height);Ti(t.context,e),n=this.applyTransferMapsToCanvas(t.context),r=t}this.dependencyTracker?.resetBBox(t);for(const e of i)s.save(),s.transform(...e.transform),s.scale(1,-1),Ei(s,n,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,s,0,1,-1,0),s.restore();r&&this.canvasFactory.destroy(r),this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ie).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push("OC"===e?{visible:this.optionalContentConfig.isVisible(i)}:{visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){const s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);const n=this.ctx;this.pendingClip?(s||(this.pendingClip===Fi?n.clip(e,"evenodd"):n.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Ut(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),Si.a=1/n,Si.d=1/r;const h=new Path2D;if(h.addPath(t,Si),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 Y)void 0!==Bi.prototype[t]&&(Bi.prototype[Y[t]]=Bi.prototype[t]);class Li{#Ws=null;#Gs=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,i){this._source=t,this.#Ws=e,this.#Gs=i}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return tt(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#Ws(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new this.#Gs(this,t,e);return this._rangeReaders.add(i),i}cancelAllRequests(t){this._fullReader?.cancel(t);for(const e of new Set(this._rangeReaders))e.cancel(t)}}class Ui{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){Z("Abstract method `read` called")}cancel(t){Z("Abstract method `cancel` called")}}class $i{_stream=null;constructor(t,e,i){this._stream=t}async read(){Z("Abstract method `read` called")}cancel(t){Z("Abstract method `cancel` called")}}function ji(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 zi(t){return URL.parse(t)?.origin??null}function Hi({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={contentLength:0,isRangeSupported:!1},r=parseInt(t.get("Content-Length"),10);return Number.isInteger(r)?(n.contentLength=r,r<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"===(t.get("Content-Encoding")||"identity")&&(n.isRangeSupported=!0),n):n}function Wi(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 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=dt(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(It(t))return t}return null}function Gi(t,e){return new ct(`Unexpected server response (${t}) while retrieving PDF "${e.href}".`,t,404===t||0===t&&"file:"===e.protocol)}function Vi(t,e){if(t!==e)throw Error(`Expected range response-origin "${t}" to match "${e}".`)}function Yi(t,e,i,s){return fetch(t,{method:"GET",headers:e,signal:s.signal,mode:"cors",credentials:i?"include":"same-origin",redirect:"follow"})}function Xi(t,e){if(200!==t&&206!==t)throw Gi(t,e)}function qi(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;throw Error("getArrayBuffer - unexpected data: "+t)}class Qi extends Li{_responseOrigin=null;constructor(t){super(t,Ki,Ji);const{httpHeaders:e,url:i}=t;tt(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=ji(!0,e)}}class Ki extends Ui{_abortController=new AbortController;_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,rangeChunkSize:s,url:n,withCredentials:r}=t._source;this._isStreamingSupported=!i;const o=new Headers(t.headers);Yi(n,o,r,this._abortController).then((i=>{t._responseOrigin=zi(i.url),Xi(i.status,n),this._reader=i.body.getReader();const r=i.headers,{contentLength:o,isRangeSupported:h}=Hi({responseHeaders:r,isHttp:!0,rangeChunkSize:s,disableRange:e});this._contentLength=o,this._isRangeSupported=h,this._filename=Wi(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ut("Streaming is disabled.")),this._headersCapability.resolve()})).catch(this._headersCapability.reject)}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._callOnProgress(),{value:qi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Ji extends $i{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:s,withCredentials:n}=t._source,r=new Headers(t.headers);r.append("Range",`bytes=${e}-${i-1}`),Yi(s,r,n,this._abortController).then((e=>{Vi(zi(e.url),t._responseOrigin),Xi(e.status,s),this._reader=e.body.getReader(),this._readCapability.resolve()})).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:qi(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}function Zi(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function ts(){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}O(116);class es extends Li{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,is,ss);const{pdfDataRangeTransport:e}=t,{initialData:i,progressiveDone:s}=e;if(i?.length>0){const t=Zi(i);this._queuedChunks.push(t)}this._progressiveDone=s,e.transportReady((t=>{switch(t.type){case"range":case"progressiveRead":this.#Vs(t.begin,t.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0}}))}#Vs(t,e){const i=Zi(e);if(void 0===t)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const e=this._rangeReaders.keys().find((e=>e._begin===t));tt(e,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),e._enqueue(i)}}getFullReader(){const t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){const i=super.getRangeReader(t,e);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(t,e)),i}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class is extends Ui{#Ys=ts.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);const{pdfDataRangeTransport:e,disableRange:i,disableStream:s}=t._source,{length:n,contentDispositionFilename:r}=e;this._queuedChunks=t._queuedChunks||[];for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._done=t._progressiveDone,this._contentLength=n,this._isStreamingSupported=!s,this._isRangeSupported=!i,It(r)&&(this._filename=r),this._headersCapability.resolve();const o=this._loaded;Promise.resolve().then((()=>{o>0&&this._loaded===o&&this._callOnProgress()}))}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#Ys()}progressiveDone(){this._done||=!0,0===this._queuedChunks.length&&this.#Ys()}}class ss extends $i{#Ys=ts.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,i){super(t,e,i),this._begin=e}_enqueue(t){this._done||(0===this._requests.length?this._queuedChunk=t:(this._requests.shift().resolve({value:t,done:!1}),this.#Ys()),this._done=!0,this.onDone?.())}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,this.#Ys(),this.onDone?.()}}class ns extends Li{#Xs=new WeakMap;_responseOrigin=null;constructor(t){super(t,rs,os);const{httpHeaders:e,url:i}=t;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=ji(this.isHttp,e)}_request(t){const e=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#Xs.set(e,i),e.open("GET",this.url),e.withCredentials=this._source.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}`),i.validateStatus=t=>206===t||200===t):i.validateStatus=t=>200===t,e.responseType="arraybuffer",tt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#qs.bind(this,e),e.onprogress=this.#Qs.bind(this,e),e.send(null),e}#Qs(t,e){const i=this.#Xs.get(t);i?.onProgress?.(e)}#qs(t,e){const i=this.#Xs.get(t);if(!i)return;if(t.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==t.readyState)return;if(!this.#Xs.has(t))return;if(this.#Xs.delete(t),0===t.status&&this.isHttp)return void i.onError(t.status);const s=t.status||200;if(!i.validateStatus(s))return void i.onError(t.status);const n=function(t){return"string"!=typeof t?t:dt(t).buffer}(t.response);if(206===s){const e=t.getResponseHeader("Content-Range");/bytes (\d+)-(\d+)\/(\d+)/.test(e)?i.onDone(n):(J('Missing or invalid "Content-Range" header.'),i.onError(0))}else n?i.onDone(n):i.onError(t.status)}_abortRequest(t){this.#Xs.has(t)&&(this.#Xs.delete(t),t.abort())}getRangeReader(t,e){const i=super.getRangeReader(t,e);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}class rs extends Ui{#Ys=ts.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t),this._fullRequestXhr=t._request({onHeadersReceived:this.#Ks.bind(this),onDone:this.#Js.bind(this),onError:this.#Zs.bind(this),onProgress:this.#Qs.bind(this)})}#Ks(){const t=this._stream,{disableRange:e,rangeChunkSize:i}=t._source,s=this._fullRequestXhr;t._responseOrigin=zi(s.responseURL);const n=s.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{contentLength:o,isRangeSupported:h}=Hi({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:i,disableRange:e});this._contentLength=o,this._isRangeSupported=h,this._filename=Wi(r),this._isRangeSupported&&t._abortRequest(s),this._headersCapability.resolve()}#Js(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,0===this._cachedChunks.length&&this.#Ys()}#Zs(t){this._storedError=Gi(t,this._stream.url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#Qs(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}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),this.#Ys(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class os extends $i{#Ys=ts.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,i){super(t,e,i),this._requestXhr=t._request({begin:e,end:i,onHeadersReceived:this.#Ks.bind(this),onDone:this.#Js.bind(this),onError:this.#Zs.bind(this),onProgress:null})}#Ks(){const t=zi(this._requestXhr?.responseURL);try{Vi(t,this._stream._responseOrigin)}catch(t){this._storedError=t,this.#Zs(0)}}#Js(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this.#Ys(),this.onClosed?.()}#Zs(t){this._storedError??=Gi(t,this._stream.url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}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,this.#Ys(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function hs(t,e=null){const i=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),n=i.createReadStream(t,e);return s.toWeb(n)}class as extends Li{constructor(t){super(t,cs,ls);const{url:e}=t;tt("file:"===e.protocol,"PDFNodeStream only supports file:// URLs.")}}class cs extends Ui{_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,rangeChunkSize:s,url:n}=t._source;this._isStreamingSupported=!i,process.getBuiltinModule("fs/promises").lstat(n).then((t=>{const i=hs(n);this._reader=i.getReader();const{size:r}=t;this._contentLength=r,this._isRangeSupported=!e&&r>2*s,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ut("Streaming is disabled.")),this._headersCapability.resolve()})).catch((t=>{"ENOENT"===t.code&&(t=Gi(0,n)),this._headersCapability.reject(t)}))}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._callOnProgress(),{value:qi(t),done:!1})}cancel(t){this._reader?.cancel(t)}}class ls extends $i{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:s}=t._source;try{const t=hs(s,{start:e,end:i-1});this._reader=t.getReader(),this._readCapability.resolve()}catch(t){this._readCapability.reject(t)}}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:qi(t),done:!1}}cancel(t){this._reader?.cancel(t)}}class us{static#tn=null;static#en="";static get workerPort(){return this.#tn}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#tn=t}static get workerSrc(){return this.#en}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#en=t}}class ds{#in;#sn;constructor({parsedData:t,rawData:e}){this.#in=t,this.#sn=e}getRaw(){return this.#sn}get(t){return this.#in.get(t)??null}[Symbol.iterator](){return this.#in.entries()}}const fs=Symbol("INTERNAL");class ps{#nn=!1;#rn=!1;#on=!1;#hn=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#nn=!!(2&t),this.#rn=!!(4&t),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#on)return this.#hn;if(!this.#hn)return!1;const{print:t,view:e}=this.usage;return this.#nn?"OFF"!==e?.viewState:!this.#rn||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==fs&&Z("Internal method `_setVisible` called."),this.#on=i,this.#hn=e}}class gs{#an=null;#cn=new Map;#ln=null;#un=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.#un=t.order;for(const i of t.groups)this.#cn.set(i.id,new ps(e,i));if("OFF"===t.baseState)for(const t of this.#cn.values())t._setVisible(fs,!1);for(const e of t.on)this.#cn.get(e)._setVisible(fs,!0);for(const e of t.off)this.#cn.get(e)._setVisible(fs,!1);this.#ln=this.getHash()}}#dn(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.#dn(e);else{if(!this.#cn.has(e))return J("Optional content group not found: "+e),!0;n=this.#cn.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.#cn.size)return!0;if(!t)return K("Optional content group not defined."),!0;if("OCG"===t.type)return this.#cn.has(t.id)?this.#cn.get(t.id).visible:(J("Optional content group not found: "+t.id),!0);if("OCMD"===t.type){if(t.expression)return this.#dn(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#cn.has(e))return J("Optional content group not found: "+e),!0;if(this.#cn.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#cn.has(e))return J("Optional content group not found: "+e),!0;if(!this.#cn.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#cn.has(e))return J("Optional content group not found: "+e),!0;if(!this.#cn.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#cn.has(e))return J("Optional content group not found: "+e),!0;if(this.#cn.get(e).visible)return!1}return!0}return J(`Unknown optional content policy ${t.policy}.`),!0}return J(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#cn.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#cn.get(i)?._setVisible(fs,!1,!0);s._setVisible(fs,!!e,!0),this.#an=null}else J("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.#cn.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.#an=null}get hasInitialVisibility(){return null===this.#ln||this.getHash()===this.#ln}getOrder(){return this.#cn.size?this.#un?this.#un.slice():[...this.#cn.keys()]:null}getGroup(t){return this.#cn.get(t)||null}getHash(){if(null!==this.#an)return this.#an;const t=new me;for(const[e,i]of this.#cn)t.update(`${e}:${i.visible}`);return this.#an=t.hexdigest()}[Symbol.iterator](){return this.#cn.entries()}}class ms{#fn=null;#pn=null;#gn=0;#mn=null;#wn=null;get pagesNumber(){return this.#gn}set pagesNumber(t){this.#gn!==t&&(this.#gn=t,this.#fn=null,this.#pn=null)}#An(){if(this.#fn)return;const t=this.#gn,e=this.#fn=new Uint32Array(t);for(let i=0;i<t;i++)e[i]=i+1;this.#pn=new Int32Array(e)}#vn(){const t=new Map,e=this.#fn;for(let i=0,s=this.#gn;i<s;i++){const s=e[i],n=t.get(s);n?n.push(i+1):t.set(s,[i+1])}return t}movePages(t,e,i){this.#An();const s=this.#fn,n=this.#vn(),r=e.length,o=new Uint32Array(r);let h=0;for(let t=0;t<r;t++){const n=e[t]-1;o[t]=s[n],n<i&&h++}const a=this.#gn,c=a-r,l=xt(i-h,0,c);for(let e=0,i=0;e<a;e++)t.has(e+1)||(s[i++]=s[e]);s.copyWithin(l+r,l,c),s.set(o,l),this.#bn(n),s.every(((t,e)=>t===e+1))&&(this.#fn=null)}deletePages(t){this.#An();const e=this.#fn,i=this.#vn();this.#wn={pageNumberToId:e.slice(),pagesNumber:this.#gn,prevPageNumbers:this.#pn.slice()};const s=this.#gn-t.length;this.#gn=s;const n=this.#fn=new Uint32Array(s);this.#pn=new Int32Array(s);let r=0,o=0;for(const i of t){const t=i-1;t!==r&&(n.set(e.subarray(r,t),o),o+=t-r),r=t+1}r<e.length&&n.set(e.subarray(r),o),this.#bn(i,new Set(t))}cancelDelete(){this.#wn&&(this.#fn=this.#wn.pageNumberToId,this.#gn=this.#wn.pagesNumber,this.#pn=this.#wn.prevPageNumbers,this.#wn=null)}cleanSavedData(){this.#wn=null}copyPages(t){this.#An(),this.#mn={pageNumbers:t,pageIds:t.map((t=>this.#fn[t-1]))}}cancelCopy(){this.#mn=null}pastePages(t){this.#An();const e=this.#fn,i=this.#vn(),{pageNumbers:s,pageIds:n}=this.#mn,r=this.#gn+s.length;this.#gn=r;const o=this.#fn=new Uint32Array(r);this.#pn=new Int32Array(r),o.set(e.subarray(0,t),0),o.set(n,t),o.set(e.subarray(t),t+s.length),this.#bn(i,null,t,s),this.#mn=null}#bn(t,e=null,i=-1,s=null){const n=this.#pn,r=this.#fn,o=i+(s?.length??0),h=new Map;for(let a=0,c=this.#gn;a<c;a++){if(a>=i&&a<o){n[a]=-s[a-i];continue}const c=r[a],l=t.get(c);let u=h.get(c)||0;if(e&&l)for(;u<l.length&&e.has(l[u]);)u++;n[a]=l?.[u],h.set(c,u+1)}}hasBeenAltered(){return null!==this.#fn}getPageMappingForSaving(t=null){t??=this.#vn();let e=0;for(const i of t.values())e=Math.max(e,i.length);const i=Array(e);for(let t=0;t<e;t++)i[t]={document:null,pageIndices:[],includePages:[]};for(const[e,s]of t)for(let t=0,n=s.length;t<n;t++)i[t].includePages.push([e-1,s[t]-1]);for(const{includePages:t,pageIndices:e}of i){t.sort(((t,e)=>t[0]-e[0]));for(let i=0,s=t.length;i<s;i++)e.push(t[i][1]),t[i]=t[i][0]}return i}extractPages(t){t=Array.from(t).sort(((t,e)=>t-e));const e=new Map;for(let i=0,s=t.length;i<s;i++){const s=this.getPageId(t[i]);e.getOrInsertComputed(s,vt).push(i+1)}return this.getPageMappingForSaving(e)}getPrevPageNumber(t){return this.#pn?.[t-1]??0}getPageNumber(t){if(!this.#fn)return t;const e=this.#fn;for(let i=0,s=this.#gn;i<s;i++)if(e[i]===t)return i+1;return 0}getPageId(t){return this.#fn?.[t-1]??t}getMapping(){return this.#fn?.subarray(0,this.pagesNumber)}}const ws=Symbol("INITIAL_DATA"),As=()=>({...Promise.withResolvers(),data:ws});class vs{#yn=new Map;get(t,e=null){if(e){const i=this.#yn.getOrInsertComputed(t,As);return i.promise.then((()=>e(i.data))),null}const i=this.#yn.get(t);if(!i||i.data===ws)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#yn.get(t);return!!e&&e.data!==ws}delete(t){const e=this.#yn.get(t);return!(!e||e.data===ws||(this.#yn.delete(t),0))}resolve(t,e=null){const i=this.#yn.getOrInsertComputed(t,As);if(i.data!==ws)throw Error(`Object already resolved ${t}.`);i.data=e,i.resolve()}clear(){for(const{data:t}of this.#yn.values())t?.bitmap?.close();this.#yn.clear()}*[Symbol.iterator](){for(const[t,{data:e}]of this.#yn)e!==ws&&(yield[t,e])}}class bs{#xn=Promise.withResolvers();#kt=null;#Mn=!1;#Sn=!!globalThis.FontInspector?.enabled;#Cn=null;#En=null;#kn=null;#Tn=0;#Pn=0;#Dn=null;#In=null;#Nn=0;#Rn=0;#On=Object.create(null);#_n=[];#Fn=null;#Bn=[];#Ln=new WeakMap;#Un=null;static#$n=new Map;static#jn=new Map;static#zn=new WeakMap;static#Hn=null;static#Wn=new Set;constructor({textContentSource:t,images:e,container:i,viewport:s}){if(t instanceof ReadableStream)this.#Fn=t;else{if("object"!=typeof t)throw Error('No "textContentSource" parameter specified.');this.#Fn=new ReadableStream({start(e){e.enqueue(t),e.close()}})}this.#kt=this.#In=i,this.#Cn=e,this.#Rn=s.scale*zt.pixelRatio,this.#Nn=s.rotation,this.#kn={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:r,pageX:o,pageY:h}=s.rawDims;this.#Un=[1,0,0,-1,-o,h+r],this.#Pn=n,this.#Tn=r,bs.#Gn(),i.style.setProperty("--min-font-size",bs.#Hn),jt(i,s),this.#xn.promise.finally((()=>{bs.#Wn.delete(this),this.#kn=null,this.#On=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ft.platform;return nt(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){this.#Cn&&this.#kt.append(this.#Cn.render());const t=()=>{this.#Dn.read().then((({value:e,done:i})=>{i?this.#xn.resolve():(this.#En??=e.lang,Object.assign(this.#On,e.styles),this.#Vn(e.items),t())}),this.#xn.reject)};return this.#Dn=this.#Fn.getReader(),bs.#Wn.add(this),t(),this.#xn.promise}update({viewport:t,onBefore:e=null}){const i=t.scale*zt.pixelRatio,s=t.rotation;if(s!==this.#Nn&&(e?.(),this.#Nn=s,jt(this.#In,{rotation:s})),i!==this.#Rn){e?.(),this.#Rn=i;const t={div:null,properties:null,ctx:bs.#Yn(this.#En)};for(const e of this.#Bn)t.properties=this.#Ln.get(e),t.div=e,this.#Xn(t)}}cancel(){const t=new ut("TextLayer task cancelled.");this.#Dn?.cancel(t).catch((()=>{})),this.#Dn=null,this.#xn.reject(t)}get textDivs(){return this.#Bn}get textContentItemsStr(){return this.#_n}#Vn(t){if(this.#Mn)return;this.#kn.ctx??=bs.#Yn(this.#En);const e=this.#Bn,i=this.#_n;for(const s of t){if(e.length>1e5)return J("Ignoring additional textDivs for performance reasons."),void(this.#Mn=!0);if(void 0!==s.str)i.push(s.str),this.#qn(s);else if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){const t=this.#kt;this.#kt=document.createElement("span"),this.#kt.classList.add("markedContent"),s.id&&this.#kt.setAttribute("id",""+s.id),"Artifact"===s.tag&&(this.#kt.ariaHidden=!0),t.append(this.#kt)}else"endMarkedContent"===s.type&&(this.#kt=this.#kt.parentNode)}}#qn(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#Bn.push(e);const s=pt.transform(this.#Un,t.transform);let n=Math.atan2(s[1],s[0]);const r=this.#On[t.fontName];r.vertical&&(n+=Math.PI/2);let o=this.#Sn&&r.fontSubstitution||r.fontFamily;o=bs.fontFamilyMap.get(o)||o;const h=Math.hypot(s[2],s[3]),a=h*bs.#Qn(o,r,this.#En);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=e.style;u.left=(100*c/this.#Pn).toFixed(2)+"%",u.top=(100*l/this.#Tn).toFixed(2)+"%",u.setProperty("--font-height",h.toFixed(2)+"px"),u.fontFamily=o,i.fontSize=h,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#Sn&&(e.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),0!==n&&(i.angle=n*(180/Math.PI));let d=!1;if(t.str.length>1)d=!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&&(d=!0)}if(d&&(i.canvasWidth=r.vertical?t.height:t.width),this.#Ln.set(e,i),this.#kn.div=e,this.#kn.properties=i,this.#Xn(this.#kn),i.hasText&&this.#kt.append(e),i.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#kt.append(t)}}#Xn(t){const{div:e,properties:i,ctx:s}=t,{style:n}=e;if(0!==i.canvasWidth&&i.hasText){const{fontFamily:t}=n,{canvasWidth:r,fontSize:o}=i;bs.#Kn(s,o*this.#Rn,t);const{width:h}=s.measureText(e.textContent);h>0&&n.setProperty("--scale-x",r*this.#Rn/h)}0!==i.angle&&n.setProperty("--rotate",i.angle+"deg")}static cleanup(){if(!(this.#Wn.size>0)){this.#$n.clear();for(const{canvas:t}of this.#jn.values())t.remove();this.#jn.clear()}}static#Yn(t=null){let e=this.#jn.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.#jn.set(t,e),this.#zn.set(e,{size:0,family:""})}return e}static#Kn(t,e,i){const s=this.#zn.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#Gn(){if(null!==this.#Hn)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.#Hn=t.getBoundingClientRect().height,t.remove()}static#Qn(t,e,i){const s=this.#$n.get(t);if(s)return s;const n=this.#Yn(i);n.canvas.width=n.canvas.height=30,this.#Kn(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):(ft.platform.isFirefox&&J("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.#$n.set(t,a),a}}function ys(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new xs,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t;if("string"==typeof t){if(_){if(/^[a-z][a-z0-9\-+.]+:/i.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}const e=URL.parse(t,window.location);if(e)return e}throw 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(_&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw 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 dt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw 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 Ms?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let l=t.worker instanceof Es?t.worker:null;const u=t.verbosity,d="string"!=typeof t.docBaseUrl||Dt(t.docBaseUrl)?null:t.docBaseUrl,f=qe(t.cMapUrl),p=!1!==t.cMapPacked,g=qe(t.iccUrl),m=qe(t.standardFontDataUrl),w=qe(t.wasmUrl),A=!0!==t.stopAtErrors,v=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,b="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!_,y="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!_&&(ft.platform.isFirefox||!globalThis.chrome),x=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,M="boolean"==typeof t.disableFontFace?t.disableFontFace:_,S=!0===t.fontExtraProperties,C=!0===t.enableXfa,E=t.ownerDocument||globalThis.document,k=!0===t.disableRange,T=!0===t.disableStream,P=!0===t.disableAutoFetch,D=!0===t.pdfBug,I=t.CanvasFactory||(_?ci:ri),N=t.FilterFactory||(_?ai:hi),R=t.BinaryDataFactory||(_?li:si),O=!0===t.enableHWA,F=!0===t.enableWebGPU?ui.init():Promise.resolve(!1),B=!1!==t.useWasm,L=t.pagesMapper||new ms,U="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!_&&!M,$="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(R===si&&f&&p&&m&&w&&Rt(f,document.baseURI)&&Rt(m,document.baseURI)&&Rt(w,document.baseURI));q(u);const j={canvasFactory:new I({ownerDocument:E,enableHWA:O}),filterFactory:new N({docId:i,ownerDocument:E}),binaryDataFactory:$?null:new R({cMapUrl:f,standardFontDataUrl:m,wasmUrl:w})};l||(l=Es.create({verbosity:u,port:us.workerPort}),e._worker=l);const z={docId:i,apiVersion:"5.7.284",data:n,password:h,disableAutoFetch:P,rangeChunkSize:c,docBaseUrl:d,enableXfa:C,evaluatorOptions:{maxImageSize:v,disableFontFace:M,ignoreErrors:A,isOffscreenCanvasSupported:b,isImageDecoderSupported:y,canvasMaxAreaInBytes:x,fontExtraProperties:S,useSystemFonts:U,useWasm:B,useWorkerFetch:$,cMapUrl:f,cMapPacked:p,iccUrl:g,standardFontDataUrl:m,wasmUrl:w,hasGPU:!1}},H={ownerDocument:E,pdfBug:D,styleElement:null,enableHWA:O,loadingParams:{disableAutoFetch:P,enableXfa:C}};return Promise.all([l.promise,F]).then((function([,t]){if(e.destroyed)throw Error("Loading aborted");if(l.destroyed)throw Error("Worker was destroyed");z.evaluatorOptions.hasGPU=t;const h=l.messageHandler.sendWithPromise("GetDocRequest",z,n?[n.buffer]:null);let u;if(n);else if(a)u=new es({pdfDataRangeTransport:a,disableRange:k,disableStream:T});else{if(!s)throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");{const t=function(t){return Rt(t)?Qi:_?as:ns}(s);u=new t({url:s,httpHeaders:r,withCredentials:o,rangeChunkSize:c,disableRange:k,disableStream:T})}}return h.then((t=>{if(e.destroyed)throw Error("Loading aborted");if(l.destroyed)throw Error("Worker was destroyed");const s=new ei(i,t,l.port),n=new ks(s,e,u,H,j,L);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}class xs{static#xs=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+xs.#xs++;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 Ms{#xn=Promise.withResolvers();#Jn=null;constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,Object.defineProperty(this,"onDataProgress",{value:()=>{console.log("Deprecated API usage: `PDFDataRangeTransport.prototype.onDataProgress` - method was removed, since loading progress is now reported automatically through the `PDFDataTransportStream` class (and related code).")}})}onDataRange(t,e){this.#Jn({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#xn.promise.then((()=>{this.#Jn({type:"progressiveRead",chunk:t})}))}onDataProgressiveDone(){this.#xn.promise.then((()=>{this.#Jn({type:"progressiveDone"})}))}transportReady(t){this.#Jn=t,this.#xn.resolve()}requestDataRange(t,e){Z("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Ss{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return nt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}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 Cs{#Zn=!1;#tr=null;constructor(t,e,i,s,n=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=n?new Nt:null,this._pdfBug=n,this.commonObjs=i.commonObjs,this.objs=new vs,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#tr=s,this.imageCoordinates=null}clone(t){const e=new Cs(t,this._pageInfo,this._transport,this.#tr,this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new Tt({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 nt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:n=$.ENABLE,transform:r=null,background:o=null,optionalContentConfigPromise:h=null,annotationCanvasMap:a=null,pageColors:c=null,printAnnotationStorage:l=null,isEditing:u=!1,recordImages:d=!1,recordOperations:f=!1,operationsFilter:p=null}){this._stats?.time("Overall");const g=this._transport.getRenderingIntent(s,n,l,u),{renderingIntent:m,cacheKey:w}=g;this.#Zn=!1,h||=this._transport.getOptionalContentConfig(m);const A=this._intentStates.getOrInsertComputed(w,yt);A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);const v=!!(4&m);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(g));const b=!(!this._pdfBug||!globalThis.StepperManager?.enabled),y=!!e&&!this.recordedBBoxes&&(f||b),x=!!e&&!this.imageCoordinates&&d,M=t=>{if(A.renderTasks.delete(E),y){const t=E.gfx?.dependencyTracker.take();t&&(E.stepper?.setOperatorBBoxes(t,E.gfx.dependencyTracker.takeDebugMetadata()),f&&(this.recordedBBoxes=t))}x&&!t&&(this.imageCoordinates=E.gfx?.imagesTracker.take()),v&&(this.#Zn=!0),this.#er(),t?(E.capability.reject(t),this._abortOperatorList({intentState:A,reason:t instanceof Error?t:Error(t)})):E.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let S=null,C=null;(y||x)&&(C=new ke(e,A.operatorList.length)),y&&(S=new Te(C,b));const E=new Ps({callback:M,params:{canvas:e,canvasContext:t,dependencyTracker:S??C,imagesTracker:x?new Be(e):null,viewport:i,transform:r,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:a,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:p});(A.renderTasks||=new Set).add(E);const k=E.task;return Promise.all([A.displayReadyCapability.promise,h]).then((([t,e])=>{if(this.destroyed)M();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&m))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");E.initializeGraphics({transparency:t,optionalContentConfig:e}),E.operatorListChanged()}})).catch(M),k}getOperatorList({intent:t="display",annotationMode:e=$.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0),r=this._intentStates.getOrInsertComputed(n.cacheKey,yt);let o;return r.opListReadCapability||(o=Object.create(null),o.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(o))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(o),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#tr.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>Mt.textContent(t)));const e=this.streamTextContent(t),i={items:[],styles:Object.create(null),lang:null};for await(const t of e)i.lang??=t.lang,Object.assign(i.styles,t.styles),i.items.push(...t.items);return 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: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.#Zn=!1,Promise.all(t)}cleanup(t=!1){this.#Zn=!0;const e=this.#er();return t&&e&&(this._stats&&=new Nt),e}#er(){if(!this.#Zn||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.#Zn=!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.#er()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#tr.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},void 0,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.#er()}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 Pt){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 ut(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 Es{#xn=Promise.withResolvers();#ir=null;#tn=null;#sr=null;static#nr=0;static#rr=!1;static#or=new WeakMap;static{_&&(this.#rr=!0,us.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"}))}constructor({name:t=null,port:e=null,verbosity:i=Q()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(Es.#or.has(e))throw Error("Cannot use more than one PDFWorker per port.");Es.#or.set(e,this),this.#hr(e)}else this.#ar()}get promise(){return this.#xn.promise}#cr(){this.#xn.resolve(),this.#ir.send("configure",{verbosity:this.verbosity})}get port(){return this.#tn}get messageHandler(){return this.#ir}#hr(t){this.#tn=t,this.#ir=new ei("main","worker",t),this.#ir.on("ready",(()=>{})),this.#cr()}#ar(){if(Es.#rr||Es.#lr)return void this.#ur();let{workerSrc:t}=Es;try{Es._isSameOrigin(window.location,t)||(t=Es._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new ei("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this.#xn.reject(Error("Worker was destroyed")):this.#ur()},n=new AbortController;e.addEventListener("error",(()=>{this.#sr||s()}),{signal:n.signal}),i.on("test",(t=>{n.abort(),!this.destroyed&&t?(this.#ir=i,this.#tn=e,this.#sr=e,this.#cr()):s()})),i.on("ready",(()=>{if(n.abort(),this.destroyed)s();else try{r()}catch{this.#ur()}}));const r=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};return void r()}catch{K("The worker has been disabled.")}this.#ur()}#ur(){Es.#rr||(J("Setting up fake worker."),Es.#rr=!0),Es._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this.#xn.reject(Error("Worker was destroyed"));const e=new Je;this.#tn=e;const i="fake"+Es.#nr++,s=new ei(i+"_worker",i,e);t.setup(s,e),this.#ir=new ei(i,i+"_worker",e),this.#cr()})).catch((t=>{this.#xn.reject(Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this.#sr?.terminate(),this.#sr=null,Es.#or.delete(this.#tn),this.#tn=null,this.#ir?.destroy(),this.#ir=null}static create(t){const e=this.#or.get(t?.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Es(t)}static get workerSrc(){if(us.workerSrc)return us.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#lr(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return nt(this,"_setupFakeWorkerGlobal",(async()=>this.#lr?this.#lr:(await import(this.workerSrc)).WorkerMessageHandler)())}}class ks{downloadInfoCapability=Promise.withResolvers();#dr=null;#fr=new Map;#pr=null;#gr=new Map;#mr=new Map;#wr=new Map;#Ar=null;constructor(t,e,i,s,n,r){this.messageHandler=t,this.loadingTask=e,this.#pr=i,this.commonObjs=new vs,this.fontLoader=new Le({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.enableHWA=s.enableHWA,this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.binaryDataFactory=n.binaryDataFactory,this.pagesMapper=r,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){const{_pageIndex:e}=t;this.#gr.set(e,t),this.#mr.set(e,Promise.resolve(t))}#vr(t,e=null){return this.#fr.getOrInsertComputed(t,(()=>this.messageHandler.sendWithPromise(t,e)))}#Qs({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?xt(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return nt(this,"annotationStorage",new Ae)}getRenderingIntent(t,e=$.ENABLE,i=null,s=!1,n=!1){let r=2,o=we;switch(t){case"any":r=1;break;case"display":break;case"print":r=4;break;default:J("getRenderingIntent - invalid intent: "+t)}const h=4&r&&i instanceof ve?i:this.annotationStorage;switch(e){case $.DISABLE:r+=64;break;case $.ENABLE:break;case $.ENABLE_FORMS:r+=16;break;case $.ENABLE_STORAGE:r+=32,o=h.serializable;break;default:J("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.#Ar?.reject(Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#gr.values())t.push(e._destroy());this.#gr.clear(),this.#mr.clear(),this.#wr.clear(),Object.hasOwn(this,"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.#fr.clear(),this.filterFactory.destroy(),bs.cleanup(),this.#pr?.cancelAllRequests(new ut("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)=>{tt(this.#pr,"GetReader - no `BasePDFStream` instance available."),this.#dr=this.#pr.getFullReader(),this.#dr.onProgress=t=>this.#Qs(t),e.onPull=()=>{this.#dr.read().then((function({value:t,done:i}){i?e.close():(tt(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this.#dr.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async()=>{await this.#dr.headersReady;const{isStreamingSupported:t,isRangeSupported:e,contentLength:i}=this.#dr;return t&&e&&(this.#dr.onProgress=null),{isStreamingSupported:t,isRangeSupported:e,contentLength:i}})),t.on("GetRangeReader",((t,e)=>{tt(this.#pr,"GetRangeReader - no `BasePDFStream` instance available.");const i=this.#pr.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then((function({value:t,done:i}){i?e.close():(tt(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.pagesMapper.pagesNumber=t.numPages,this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Ss(t,this))})),t.on("DocException",(t=>{e._capability.reject(ti(t))})),t.on("PasswordRequest",(t=>{this.#Ar=Promise.withResolvers();try{if(!e.onPassword)throw ti(t);e.onPassword((t=>{t instanceof Error?this.#Ar.reject(t):this.#Ar.resolve({password:t})}),t.code)}catch(t){this.#Ar.reject(t)}return this.#Ar.promise})),t.on("DataLoaded",(t=>{this.#Qs({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{this.destroyed||this.#gr.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;J("Error during font loading: "+t),this.commonObjs.resolve(e,t);break}const n=new Ve(s),r=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,o=new Ue(n,r,s.charProcOperatorList,s.extra);this.fontLoader.bind(o).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{o.fontExtraProperties||o.clearData(),this.commonObjs.resolve(e,o)}));break;case"CopyLocalImage":const{imageRef:h}=s;tt(h,"The imageRef must be defined.");for(const t of this.#gr.values())for(const[,i]of t.objs){if(i?.ref!==h)continue;if(!i.dataLen)return null;const t=structuredClone(i);return this.commonObjs.resolve(e,t),i.dataLen}break;case"FontPath":this.commonObjs.resolve(e,new Xe(s));break;case"Image":this.commonObjs.resolve(e,s);break;case"Pattern":const a=new Ye(s);this.commonObjs.resolve(e,a.getIR());break;default:throw Error("Got unknown common object type "+i)}return null})),t.on("obj",(([t,e,i,s])=>{if(this.destroyed)return;const n=this.#gr.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 Error("Got unknown object type "+i)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||this.#Qs(t)})),t.on("FetchBinaryData",(async t=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&J("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#dr?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}extractPages(t){const e={pageInfos:t};let i;if(this.annotationStorage.size>0){const{map:t,transfer:s}=this.annotationStorage.serializable;e.annotationStorage=t,i=s}return this.messageHandler.sendWithPromise("ExtractPages",e,i).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(Error("Invalid page request."));const e=t-1,i=this.pagesMapper.getPageId(t)-1,s=this.#mr.get(e);if(s)return s;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then((t=>{if(this.destroyed)throw Error("Transport destroyed");t.refStr&&this.#wr.set(t.refStr,i);const s=new Cs(e,t,this,this.pagesMapper,this._params.pdfBug);return this.#gr.set(e,s),s}));return this.#mr.set(e,n),n}async getPageIndex(t){if(!Qe(t))throw Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),i=this.pagesMapper.getPageNumber(e+1);if(0===i)throw Error("GetPageIndex: page has been removed.");return i-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#vr("GetFieldObjects")}hasJSActions(){return this.#vr("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#vr("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#vr("GetOptionalContentConfig").then((e=>new gs(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return this.#fr.getOrInsertComputed(t,(()=>this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new ds(t[1]):null,contentDispositionFilename:this.#dr?.filename??null,contentLength:this.#dr?.contentLength??null,hasStructTree:t[2]})))))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#gr.values())if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#fr.clear(),this.filterFactory.destroy(!0),bs.cleanup()}}cachedPageNumber(t){if(!Qe(t))return null;const e=this.#wr.get(0===t.gen?t.num+"R":`${t.num}R${t.gen}`);if(e>=0){const t=this.pagesMapper.getPageNumber(e+1);if(0!==t)return t}return null}}class Ts{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class Ps{#br=null;static#yr=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,enableHWA:d=!1,operationsFilter:f=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 Ts(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=d,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=f}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(Ps.#yr.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Ps.#yr.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:i,transform:s,background:n,dependencyTracker:r,imagesTracker:o}=this.params,h=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Bi(h,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r,o),this.gfx.beginDrawing({transform:s,viewport:i,transparency:t,background:n}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#br&&(window.cancelAnimationFrame(this.#br),this.#br=null),Ps.#yr.delete(this._canvas),t||=new Pt("Rendering cancelled, page "+(this._pageIndex+1),e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){this.graphicsReady?(this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),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.#br=window.requestAnimationFrame((()=>{this.#br=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),Ps.#yr.delete(this._canvas),this.callback())))}}O(3068);class Ds{#xr=null;#Mr=null;#Sr;#Cr=null;#Er=!1;#kr=!1;#o=null;#Tr;#Pr=null;#A=null;static#Dr=null;static get _keyboardManager(){return nt(this,"_keyboardManager",new re([[["Escape","mac+Escape"],Ds.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Ds.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Ds.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Ds.prototype._moveToPrevious],[["Home","mac+Home"],Ds.prototype._moveToBeginning],[["End","mac+End"],Ds.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#kr=!1,this.#o=t):this.#kr=!0,this.#A=t?._uiManager||e,this.#Tr=this.#A._eventBus,this.#Sr=t?.color?.toUpperCase()||this.#A?.highlightColors.values().next().value||"#FFFF98",Ds.#Dr||=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.#xr=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#o&&(t.ariaControls=this.#o.id+"_colorpicker_dropdown");const e=this.#A._signal;t.addEventListener("click",this.#Ir.bind(this),{signal:e}),t.addEventListener("keydown",this.#Nr.bind(this),{signal:e});const i=this.#Mr=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#Sr,t.append(i),t}renderMainDropdown(){const t=this.#Cr=this.#Rr();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#Rr(){const t=document.createElement("div"),e=this.#A._signal;t.addEventListener("contextmenu",Ot,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#o&&(t.id=this.#o.id+"_colorpicker_dropdown");for(const[i,s]of this.#A.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",Ds.#Dr[i]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.ariaSelected=s===this.#Sr,n.addEventListener("click",this.#Or.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#Nr.bind(this),{signal:e}),t}#Or(t,e){e.stopPropagation(),this.#Tr.dispatch("switchannotationeditorparams",{source:this,type:H.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#xr)return void this.#Ir(t);const e=t.target.getAttribute("data-color");e&&this.#Or(e,t)}_moveToNext(t){this.#_r?t.target!==this.#xr?t.target.nextSibling?.focus():this.#Cr.firstElementChild?.focus():this.#Ir(t)}_moveToPrevious(t){t.target!==this.#Cr?.firstElementChild&&t.target!==this.#xr?(this.#_r||this.#Ir(t),t.target.previousSibling?.focus()):this.#_r&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#_r?this.#Cr.firstElementChild?.focus():this.#Ir(t)}_moveToEnd(t){this.#_r?this.#Cr.lastElementChild?.focus():this.#Ir(t)}#Nr(t){Ds._keyboardManager.exec(this,t)}#Ir(t){if(this.#_r)return void this.hideDropdown();if(this.#Er=0===t.detail,this.#Pr||(this.#Pr=new AbortController,window.addEventListener("pointerdown",this.#f.bind(this),{signal:this.#A.combinedSignal(this.#Pr)})),this.#xr.ariaExpanded="true",this.#Cr)return void this.#Cr.classList.remove("hidden");const e=this.#Cr=this.#Rr();this.#xr.append(e)}#f(t){this.#Cr?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Cr?.classList.add("hidden"),this.#xr.ariaExpanded="false",this.#Pr?.abort(),this.#Pr=null}get#_r(){return this.#Cr&&!this.#Cr.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#kr||(this.#_r?(this.hideDropdown(),this.#xr.focus({preventScroll:!0,focusVisible:this.#Er})):this.#o?.unselect())}updateColor(t){if(this.#Mr&&(this.#Mr.style.backgroundColor=t),!this.#Cr)return;const e=this.#A.highlightColors.values();for(const i of this.#Cr.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#xr?.remove(),this.#xr=null,this.#Mr=null,this.#Cr?.remove(),this.#Cr=null}}class Is{#Fr=null;#Br=!1;#o=null;#A=null;static#Dr=null;constructor(t){this.#o=t,this.#A=t._uiManager,Is.#Dr||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#Fr)return this.#Fr;const{editorType:t,colorType:e,colorAndOpacityType:i,opacityType:s,color:n,opacity:r}=this.#o,o=this.#Br=ft.isAlphaColorInputSupported&&void 0!==s,h=this.#Fr=document.createElement("input");return h.type="color",o?(h.setAttribute("alpha",""),h.value=(n||"#000000")+pt.hexNums[Math.round(255*(r??1))]):h.value=n||"#000000",h.className="basicColorPicker",h.tabIndex=0,h.setAttribute("data-l10n-id",Is.#Dr[t]),h.addEventListener("input",(()=>{if(o){const t=Bt(h.value);if(!t)return;const[n,r,o,a]=t,c=pt.makeHexColor(n,r,o);void 0!==i?this.#A.updateParams(i,{color:c,opacity:a}):(this.#A.updateParams(e,c),this.#A.updateParams(s,a))}else this.#A.updateParams(e,h.value)}),{signal:this.#A._signal}),h}update(t){if(this.#Fr)if(this.#Br){const e=pt.hexNums[Math.round(255*this.#o.opacity)];this.#Fr.value=t+e}else this.#Fr.value=t}updateOpacity(t){this.#Fr&&this.#Br&&(this.#Fr.value=this.#o.color+pt.hexNums[Math.round(255*t)])}destroy(){this.#Fr?.remove(),this.#Fr=null}hideDropdown(){}}function Ns(t){return Math.floor(255*xt(t,0,1)).toString(16).padStart(2,"0")}function Rs(t){return 255*xt(t,0,1)}O(531);class Os{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=Rs(t),t,t]}static G_HTML([t]){const e=Ns(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(Rs)}static RGB_HTML(t){return"#"+t.map(Ns).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[Rs(1-Math.min(1,t+s)),Rs(1-Math.min(1,i+s)),Rs(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 _s{create(t,e,i=!1){if(t<=0||e<=0)throw 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 Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Z("Abstract method `_createSVG` called.")}}class Fs extends _s{_createSVG(t){return document.createElementNS(Ct,t)}}const Bs=new WeakSet,Ls=60*(new Date).getTimezoneOffset()*1e3;class Us{static create(t){switch(t.data.annotationType){case G.LINK:return new zs(t);case G.TEXT:return new Hs(t);case G.WIDGET:switch(t.data.fieldType){case"Tx":return new Gs(t);case"Btn":return t.data.radioButton?new Xs(t):t.data.checkBox?new Ys(t):new qs(t);case"Ch":return new Qs(t);case"Sig":return new Vs(t)}return new Ws(t);case G.POPUP:return new Ks(t);case G.FREETEXT:return new Zs(t);case G.LINE:return new tn(t);case G.SQUARE:return new en(t);case G.CIRCLE:return new sn(t);case G.POLYLINE:return new nn(t);case G.CARET:return new on(t);case G.INK:return new hn(t);case G.POLYGON:return new rn(t);case G.HIGHLIGHT:return new an(t);case G.UNDERLINE:return new cn(t);case G.SQUIGGLY:return new ln(t);case G.STRIKEOUT:return new un(t);case G.STAMP:return new dn(t);case G.FILEATTACHMENT:return new fn(t);default:return new $s(t)}}}class $s{#Lr=null;#Ur=!1;#$r=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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!(!t?.str&&!e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return $s._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:i,rect:s}=this.data;let n=-1/0,r=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>r?(r=e[t+1],n=e[t+2]):e[t+1]===r&&(n=Math.max(n,e[t+2]));return[n,r]}if(i?.length>=1){for(const t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>r?(r=t[e+1],n=t[e]):t[e+1]===r&&(n=Math.max(n,t[e]));if(n!==1/0)return[n,r]}return s?[s[2],s[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-n)/i,t[1]=100*(t[1]-r)/s,t}get commentText(){const{data:t}=this;return this.annotationStorage.getRawValue(`${j}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${j}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#$r?.popup||this.popup)?.remove(),this.#$r=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#Lr||={rect:this.data.rect.slice(0)});const{rect:e,popup:i}=t;e&&this.#jr(e);let s=this.#$r?.popup||this.popup;!s&&i?.text&&(this._createPopup(i),s=this.#$r.popup),s&&(s.updateEdited(t),i?.deleted&&(s.remove(),this.#$r=null,this.popup=null))}resetEdited(){this.#Lr&&(this.#jr(this.#Lr.rect),this.#$r?.popup.resetEdited(),this.#Lr=null)}#jr(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 Ws||this instanceof zs||(n.tabIndex=0);const{style:r}=n;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Ks){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 Xs&&(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:J("Unimplemented border style: beveled");break;case 4:J("Unimplemented border style: inset");break;case 5:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Ur=!0,r.borderColor=pt.makeHexColor(...s)):r.borderWidth=0}const a=pt.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]=Os[n+"_HTML"](r),this.annotationStorage.setValue(this.data.id,{[e]:Os[n+"_rgb"](r)})};return nt(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.#Ur){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),l.role="none";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.#Ur&&(o.push("</g></svg>')"),r.backgroundImage=o.join("")),this.container.append(l),this.container.style.clipPath=`url(#${f})`}_createPopup(t=null){const{data:e}=this;let i,s;t?(i={str:t.text},s=t.date):(i=e.contentsObj,s=e.modificationDate),this.#$r=new Ks({data:{color:e.color,titleObj:e.titleObj,modificationDate:s,contentsObj:i,richText:e.richText,parentRect:e.rect,borderStyle:0,id:"popup_"+e.id,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#$r||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#$r}render(){Z("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||Bs.has(o)?i.push({id:n,exportValue:s,domElement:o}):J("_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&&Bs.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,mustEnterInEditMode:!0})}))}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class js extends $s{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class zs extends $s{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,t.overlaidText),s=!0):t.attachment?(this.#zr(i,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(this.#Hr(i,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),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.contentElement=i,this.container.append(i)),this.container}#Wr(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#Wr(),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#Wr()}#zr(t,e,i="",s=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,s),!1),this.#Wr()}#Hr(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#Wr()}_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))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#Wr()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#Wr(),!this._fieldObjects)return J('_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&&(Bs.has(i)?i.dispatchEvent(new Event("resetform")):J("_bindResetFormAction - element not allowed: "+e))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}}class Hs extends $s{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class Ws extends $s{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ft.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":pt.makeHexColor(...e)}_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);n=Math.min(i,r(t/(Math.round(t/(U*i))||1)/U))}else n=Math.min(i,r(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/U));s.fontSize=`calc(${n}px * var(--total-scale-factor))`,s.color=pt.makeHexColor(...e),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 Gs extends Ws{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),Bs.add(i),this.contentElement=i,i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;const{datetimeFormat:a,datetimeType:c,timeStep:l}=this.data,u=!!c&&this.enableScripting;a&&(i.title=a),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 d=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;if(u&&(e.type=c,l&&(e.step=l)),h.userValue){const t=h.userValue;if(u)if("time"===c){const i=new Date(t),s=[i.getHours(),i.getMinutes(),i.getSeconds()];e.value=s.map((t=>(""+t).padStart(2,"0"))).join(":")}else e.value=new Date(t-Ls).toISOString().split("date"===c?"T":".",1)[0];else e.value=t}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??"",u||t.setValue(e,{value:""+h.userValue}),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);const n={formattedValue:s};u&&(n.value=s),t.setValue(e,n)},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=d;d=null,i.addEventListener("blur",(t=>{if(!h.focused||!t.relatedTarget)return;this.data.actions?.Blur||(h.focused=!1);const{target:i}=t;let{value:n}=i;if(u){if(n&&"time"===c){const t=n.split(":").map((t=>parseInt(t,10)));n=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),i.step=""}else n.includes("T")||(n+="T00:00"),n=new Date(n).valueOf();i.type="text"}h.userValue=n,h.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,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(d&&i.addEventListener("blur",d),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 Vs extends Ws{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Ys extends Ws{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 Bs.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=0,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 Xs extends Ws{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(Bs.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=0,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 qs extends zs{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 Qs extends Ws{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");Bs.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=0;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}));const r=(t,e)=>{const i=e.replaceAll(" "," ");t.textContent=i,i!==e&&t.setAttribute("display-value",e)};for(const t of this.data.options){const e=document.createElement("option");r(e,t.displayValue),e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let o=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),o=()=>{t.remove(),s.removeEventListener("input",o),o=null},s.addEventListener("input",o)}const h=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 a=h(!1);const c=t=>Array.prototype.map.call(t.target.options,(t=>({displayValue:t.getAttribute("display-value")||t.textContent,exportValue:t.value})));return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{this._dispatchEventFromSandbox({value(i){o?.();const n=i.detail.value,r=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=r.has(t.value);t.setValue(e,{value:h(!0)}),a=h(!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:h(!0),items:c(i)}),a=h(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),a=h(!1)},insert(i){const{index:n,displayValue:o,exportValue:l}=i.detail.insert,u=s.children[n],d=document.createElement("option");r(d,o),d.value=l,u?u.before(d):s.append(d),t.setValue(e,{value:h(!0),items:c(i)}),a=h(!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");r(n,e),n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:h(!0),items:c(i)}),a=h(!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:h(!0)}),a=h(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)})),s.addEventListener("input",(i=>{const s=h(!0),n=h(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,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:h(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Ks extends $s{constructor(t){const{data:e,elements:i,parent:s}=t,n=!!s._commentManager;if(super(t,{isRenderable:!n&&$s._hasPopupData(e)}),this.elements=i,n&&$s._hasPopupData(e)){const t=this.popup=this.#Gr();for(const e of i)e.popup=t}else this.popup=null}#Gr(){return new Js({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=this.#Gr(),i=[];for(const t of this.elements)t.popup=e,t.container.ariaHasPopup="dialog",i.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",i.map((t=>`${At}${t}`)).join(",")),this.container}}class Js{#G=null;#Vr=this.#Nr.bind(this);#Yr=this.#Xr.bind(this);#qr=this.#Qr.bind(this);#Kr=this.#Jr.bind(this);#Zr=null;#kt=null;#to=null;#eo=null;#io=null;#so=null;#no=null;#ro=!1;#oo=null;#ho=null;#R=null;#ao=null;#co=null;#be=null;#lo=null;#me=null;#uo=null;#Lr=null;#do=!1;#fo=null;#po=null;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:o,parent:h,rect:a,parentRect:c,open:l,commentManager:u=null}){this.#kt=t,this.#uo=s,this.#to=r,this.#me=o,this.#so=h,this.#Zr=e,this.#lo=a,this.#no=c,this.#io=i,this.#G=u,this.#fo=i[0],this.#eo=Ft.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup())),u||(this.#go(),this.#kt.hidden=!0,l&&this.#Jr())}#go(){if(this.#ho)return;this.#ho=new AbortController;const{signal:t}=this.#ho;for(const e of this.trigger)e.addEventListener("click",this.#Kr,{signal:t}),e.addEventListener("pointerenter",this.#qr,{signal:t}),e.addEventListener("pointerleave",this.#Yr,{signal:t}),e.classList.add("popupTriggerArea");for(const e of this.#io)e.container?.addEventListener("keydown",this.#Vr,{signal:t})}#mo(){const t=this.#io.find((t=>t.hasCommentButton));t&&(this.#co=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#ao)return void(this.#ao.parentNode||this.#fo.container.after(this.#ao));if(this.#co||this.#mo(),!this.#co)return;const{signal:t}=this.#ho=new AbortController,e=this.#fo.hasOwnCommentButton,i=()=>{this.#G.toggleCommentPopup(this,!0,void 0,!e)},s=()=>{this.#G.toggleCommentPopup(this,!1,!0,!e)},n=()=>{this.#G.toggleCommentPopup(this,!1,!1)};if(e){this.#ao=this.#fo.container;for(const e of this.trigger)e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#Vr,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",n,{signal:t}),e.classList.add("popupTriggerArea")}else{const e=this.#ao=document.createElement("button");e.className="annotationCommentButton";const r=this.#fo.container;e.style.zIndex=parseInt(r.style.zIndex,10)+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#wo(),this.#Ao(),e.addEventListener("keydown",this.#Vr,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",n,{signal:t}),r.after(e)}}#Ao(){if(this.#fo.extraPopupElement&&!this.#fo.editor)return;this.#ao||this.renderCommentButton();const[t,e]=this.#co,{style:i}=this.#ao;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#wo(){this.#fo.extraPopupElement||(this.#ao||this.renderCommentButton(),this.#ao.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){const{color:t,opacity:e}=this.#fo.commentData;return t?this.#so._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout((()=>{this.#ao?.focus()}),0)}getData(){const{richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}=this.#fo.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:s,modificationDate:n}}get elementBeforePopup(){return this.#ao}get comment(){return this.#po||=this.#fo.commentText,this.#po}set comment(t){t!==this.comment&&(this.#fo.commentText=this.#po=t)}focus(){this.#fo.container?.focus()}get parentBoundingClientRect(){return this.#fo.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#ao&&(this.#ao.classList.toggle("selected",t),this.#ao.ariaExpanded=e)}setSelectedCommentButton(t){this.#ao.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#be)return this.#be;const{x:t,y:e,height:i}=this.#ao.getBoundingClientRect(),{x:s,y:n,width:r,height:o}=this.#fo.layer.getBoundingClientRect();return[(t-s)/r,(e+i-n)/o]}set commentPopupPosition(t){this.#be=t}hasDefaultPopupPosition(){return null===this.#be}get commentButtonPosition(){return this.#co}get commentButtonWidth(){return this.#ao.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,i]=this.#be||this.commentButtonPosition.map((t=>t/100)),s=this.parentBoundingClientRect,{x:n,y:r,width:o,height:h}=s;this.#G.showDialog(null,this,n+e*o,r+i*h,{...t,parentDimensions:s})}render(){if(this.#oo)return;const t=this.#oo=document.createElement("div");if(t.className="popup",this.#Zr){const e=t.style.outlineColor=pt.makeHexColor(...this.#Zr);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");if(e.className="header",this.#uo?.str){const t=document.createElement("span");t.className="title",e.append(t),({dir:t.dir,str:t.textContent}=this.#uo)}if(t.append(e),this.#eo){const t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#eo.valueOf()})),t.dateTime=this.#eo.toISOString(),e.append(t)}Qt({html:this.#vo||this.#to.str,dir:this.#to?.dir,className:"popupContent"},t),this.#kt.append(t)}get#vo(){const t=this.#me,e=this.#to;return!t?.str||e?.str&&e.str!==t.str?null:this.#me.html||null}get#bo(){return this.#vo?.attributes?.style?.fontSize||0}get#yo(){return this.#vo?.attributes?.style?.color||null}#xo(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#yo,fontSize:this.#bo?`calc(${this.#bo}px * var(--total-scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}#Nr(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#ro)&&this.#Jr()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#G)return i?(this.remove(),this.#po=null):e&&(e.deleted?this.remove():(this.#wo(),this.#po=e.text)),void(t&&(this.#co=null,this.#mo(),this.#Ao()));i||e?.deleted?this.remove():(this.#go(),this.#Lr||={contentsObj:this.#to,richText:this.#me},t&&(this.#R=null),e&&e.text&&(this.#me=this.#xo(e.text),this.#eo=Ft.toDateObject(e.date),this.#to=null),this.#oo?.remove(),this.#oo=null)}resetEdited(){this.#Lr&&(({contentsObj:this.#to,richText:this.#me}=this.#Lr),this.#Lr=null,this.#oo?.remove(),this.#oo=null,this.#R=null)}remove(){if(this.#ho?.abort(),this.#ho=null,this.#oo?.remove(),this.#oo=null,this.#do=!1,this.#ro=!1,this.#ao?.remove(),this.#ao=null,this.trigger)for(const t of this.trigger)t.classList.remove("popupTriggerArea")}#Mo(){if(null!==this.#R)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#so;let r=!!this.#no,o=r?this.#no:this.#lo;for(const t of this.#io)if(!o||null!==pt.intersect(t.data.rect,o)){o=t.data.rect,r=!0;break}const h=pt.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]);this.#R=[100*(h[0]+(r?o[2]-o[0]+5:0)-s)/e,100*(h[1]-n)/i];const{style:a}=this.#kt;a.left=this.#R[0]+"%",a.top=this.#R[1]+"%"}#Jr(){this.#G?this.#G.toggleCommentPopup(this,!1):(this.#ro=!this.#ro,this.#ro?(this.#Qr(),this.#kt.addEventListener("click",this.#Kr),this.#kt.addEventListener("keydown",this.#Vr)):(this.#Xr(),this.#kt.removeEventListener("click",this.#Kr),this.#kt.removeEventListener("keydown",this.#Vr)))}#Qr(){this.#oo||this.render(),this.isVisible?this.#ro&&this.#kt.classList.add("focused"):(this.#Mo(),this.#kt.hidden=!1,this.#kt.style.zIndex=parseInt(this.#kt.style.zIndex,10)+1e3)}#Xr(){this.#kt.classList.remove("focused"),!this.#ro&&this.isVisible&&(this.#kt.hidden=!0,this.#kt.style.zIndex=parseInt(this.#kt.style.zIndex,10)-1e3)}forceHide(){this.#do=this.isVisible,this.#do&&(this.#kt.hidden=!0)}maybeShow(){this.#G||(this.#go(),this.#do&&(this.#oo||this.#Qr(),this.#do=!1,this.#kt.hidden=!1))}get isVisible(){return!this.#G&&!1===this.#kt.hidden}}class Zs extends $s{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=z.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class tn extends $s{#So=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.#So=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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#So}addHighlightArea(){this.container.classList.add("highlightArea")}}class en extends $s{#Co=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.#Co=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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#Co}addHighlightArea(){this.container.classList.add("highlightArea")}}class sn extends $s{#Eo=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.#Eo=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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#Eo}addHighlightArea(){this.container.classList.add("highlightArea")}}class nn extends $s{#ko=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.#ko=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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#ko}addHighlightArea(){this.container.classList.add("highlightArea")}}class rn extends nn{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class on extends $s{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}class hn extends $s{#To=null;#Po=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?z.HIGHLIGHT:z.INK}#Do(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.#Do(e,t),a=this.svgFactory.create(o,h,!0),c=this.#To=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.#Po.push(e),e.setAttribute("points",i[t].join(",")),c.append(e)}return!n&&this.hasPopupData&&(this.hasOwnCommentButton=!0,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.#To;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#Po.length;t<e;t++)this.#Po[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#Do(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#Po}addHighlightArea(){this.container.classList.add("highlightArea")}}class an extends $s{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=z.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class cn extends $s{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class ln extends $s{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class un extends $s{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class dn extends $s{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=z.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class fn extends $s{#Io=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.#No.bind(this)),this.#Io=i;const{isMac:s}=ft.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#No()})),!e.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#Io}addHighlightArea(){this.container.classList.add("highlightArea")}#No(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class pn{#Ro=null;#Oo=null;#z=null;#_o=new Map;#Fo=null;#Bo=null;#io=[];#Lo=!1;zIndex=0;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:o,commentManager:h,linkService:a,annotationStorage:c}){this.div=t,this.#Ro=e,this.#Oo=i,this.#Fo=o||null,this.#Bo=a||null,this.#z=c||new Ae,this.page=n,this.viewport=r,this._annotationEditorUIManager=s,this._commentManager=h||null}hasEditableAnnotations(){return this.#_o.size>0}async render(t){const{annotations:e}=t,i=this.div;jt(i,this.viewport);const s=new Map,n=[],r={data:null,layer:i,linkService:this.#Bo,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Fs,annotationStorage:this.#z,enableComment:!0===t.enableComment,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===G.POPUP;if(e){const e=s.get(t.id);if(!e)continue;if(!this._commentManager){n.push(t);continue}r.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;r.data=t;const i=Us.create(r);if(!i.isRenderable)continue;e||(this.#io.push(i),t.popupRef&&s.getOrInsertComputed(t.popupRef,vt).push(i));const o=i.render();t.hidden&&(o.style.visibility="hidden"),i._isEditable&&(this.#_o.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}await this.#Uo();for(const t of n){const e=r.elements=s.get(t.id);r.data=t;const i=Us.create(r);if(!i.isRenderable)continue;const n=i.render();i.contentElement.id=`${At}${t.id}`,t.hidden&&(n.style.visibility="hidden"),e.at(-1).container.after(n)}this.#$o()}async#Uo(){if(0===this.#io.length)return;this.div.replaceChildren();const t=[];if(!this.#Lo){this.#Lo=!0;for(const{contentElement:e,data:{id:i}}of this.#io){const s=e.id=`${At}${i}`;t.push(this.#Fo?.getAriaAttributes(s).then((t=>{if(t)for(const[i,s]of t)e.setAttribute(i,s)})))}}this.#io.sort((({data:{rect:[t,e,i,s]}},{data:{rect:[n,r,o,h]}})=>{if(t===i&&e===s)return 1;if(n===o&&r===h)return-1;const a=(e+s)/2,c=(r+h)/2;return a>=h&&c<=e?-1:c>=s&&a<=r?1:(t+i)/2-(n+o)/2}));const e=document.createDocumentFragment();for(const t of this.#io)e.append(t.container),this._commentManager?(t.extraPopupElement?.popup||t.popup)?.renderCommentButton():t.extraPopupElement&&e.append(t.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#Ro)for(const t of this.#io)this.#Ro.addPointerInTextLayer(t.contentElement,!1)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:this.#Bo,svgFactory:new Fs,parent:this};for(const i of t){i.borderStyle||=pn._defaultBorderStyle,e.data=i;const t=Us.create(e);t.isRenderable&&(t.render(),t.contentElement.id=`${At}${i.id}`,this.#io.push(t))}await this.#Uo()}update({viewport:t}){const e=this.div;this.viewport=t,jt(e,{rotation:t.rotation}),this.#$o(),e.hidden=!1}#$o(){if(!this.#Oo)return;const t=this.div;for(const[e,i]of this.#Oo){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.#_o.get(e);r&&(r._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),r._hasNoCanvas=!1):r.canvas=i)}this.#Oo.clear()}getEditableAnnotations(){return this.#_o.values()}getEditableAnnotation(t){return this.#_o.get(t)}addFakeAnnotation(t){const{div:e}=this,{id:i,rotation:s}=t,n=new js({data:{id:i,rect:t.getPDFRect(),rotation:s},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#Bo,annotationStorage:this.#z});return n.render(),n.contentElement.id=`${At}${i}`,n.createOrUpdatePopup(),this.#io.push(n),n}removeAnnotation(t){const e=this.#io.findIndex((e=>e.data.id===t));if(e<0)return;const[i]=this.#io.splice(e,1);this.#Ro?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(0!==t.length){for(const e of t)e.updateFakeAnnotationElement(this);this.#Uo()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return nt(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:1,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const gn=/\r\n?|\n/g;class mn extends ue{#jo="";#zo=this.id+"-editor";#Ho=null;#bo;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=mn.prototype,e=t=>t.isEmpty(),i=he.TRANSLATE_SMALL,s=he.TRANSLATE_BIG;return nt(this,"_keyboardManager",new re([[["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=z.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||mn._defaultColor||ue._defaultLineColor,this.#bo=t.fontSize||mn._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static initialize(t,e){ue.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case H.FREETEXT_SIZE:mn._defaultFontSize=e;break;case H.FREETEXT_COLOR:mn._defaultColor=e}}updateParams(t,e){switch(t){case H.FREETEXT_SIZE:this.#Wo(e);break;case H.FREETEXT_COLOR:this.#wo(e)}}static get defaultPropertiesToUpdate(){return[[H.FREETEXT_SIZE,mn._defaultFontSize],[H.FREETEXT_COLOR,mn._defaultColor||ue._defaultLineColor]]}get propertiesToUpdate(){return[[H.FREETEXT_SIZE,this.#bo],[H.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new Is(this),[["colorPicker",this._colorPicker]]}get colorType(){return H.FREETEXT_COLOR}#Wo(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#bo)*this.parentScale),this.#bo=t,this.#Go()},i=this.#bo;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:H.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#wo(t){const e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:H.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-mn._internalPadding*t,-(mn._internalPadding+this.#bo)*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.#Ho=new AbortController;const t=this._uiManager.combinedSignal(this.#Ho);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.#zo),this._isDraggable=!0,this.#Ho?.abort(),this.#Ho=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()}#Vo(){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(mn.#Yo(i)),e=i);return t.join("\n")}#Go(){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.#jo,e=this.#jo=this.#Vo().trimEnd();if(t===e)return;const i=t=>{this.#jo=t,t?(this.#Xo(),this._uiManager.rebuild(this),this.#Go()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#Go()}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){mn._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.#zo),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.#bo}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[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.#Xo(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Yo(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(gn,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=mn.#qo(e.getData("text")||"").replaceAll(gn,"\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(gn,"")),t!==this.editorDiv){let e=a;for(const i of this.editorDiv.childNodes)i!==t?e.push(mn.#Yo(i)):e=c}a.push(o.nodeValue.slice(0,h).replaceAll(gn,""))}else if(o===this.editorDiv){let t=a,e=0;for(const i of this.editorDiv.childNodes)e++===h&&(t=c),t.push(mn.#Yo(i))}this.#jo=`${a.join("\n")}${s}${c.join("\n")}`,this.#Xo();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)}#Xo(){if(this.editorDiv.replaceChildren(),this.#jo)for(const t of this.#jo.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#Qo(){return this.#jo.replaceAll(" "," ")}static#qo(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=mn._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let s=null;if(t instanceof Zs){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:r,id:o,popupRef:h,richText:a,contentsObj:c,creationDate:l,modificationDate:u},textContent:d,textPosition:f,parent:{page:{pageNumber:p}}}=t;if(!d||0===d.length)return null;s=t={annotationType:z.FREETEXT,color:Array.from(i),fontSize:e,value:d.join("\n"),position:f,pageIndex:p-1,rect:n.slice(0),rotation:r,annotationElementId:o,id:o,deleted:!1,popupRef:h,comment:c?.str||null,richText:a,creationDate:l,modificationDate:u}}const n=await super.deserialize(t,e,i);return n.#bo=t.fontSize,n.color=pt.makeHexColor(...t.color),n.#jo=mn.#qo(t.value),n._initialData=s,t.comment&&n.setCommentData(t),n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=ue._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#bo,value:this.#Qo()});return this.addComment(i),t?(i.isCopy=!0,i):this.annotationElementId&&!this.#Ko(i)?null:(i.id=this.annotationElementId,i)}#Ko(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this.hasEditedComment||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(!e)return null;const{style:i}=e;i.fontSize=`calc(${this.#bo}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren();for(const t of this.#jo.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#jo}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class wn{static PRECISION=1e-4;toSVGPath(){Z("Abstract method `toSVGPath` must be implemented.")}get box(){Z("Abstract getter `box` must be implemented.")}serialize(t,e){Z("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 An{#Jo;#Zo=[];#th;#eh;#ih=[];#sh=new Float32Array(18);#nh;#rh;#oh;#hh;#ah;#ch;#lh=[];static#uh=8;static#dh=2;static#fh=An.#uh+An.#dh;constructor({x:t,y:e},i,s,n,r,o=0){this.#Jo=i,this.#ch=n*s,this.#eh=r,this.#sh.set([NaN,NaN,NaN,NaN,t,e],6),this.#th=o,this.#hh=An.#uh*s,this.#oh=An.#fh*s,this.#ah=s,this.#lh.push(t,e)}isEmpty(){return isNaN(this.#sh[8])}#ph(){const t=this.#sh.subarray(4,6),e=this.#sh.subarray(16,18),[i,s,n,r]=this.#Jo;return[(this.#nh+(t[0]-e[0])/2-i)/n,(this.#rh+(t[1]-e[1])/2-s)/r,(this.#nh+(e[0]-t[0])/2-i)/n,(this.#rh+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#nh=t,this.#rh=e;const[i,s,n,r]=this.#Jo;let[o,h,a,c]=this.#sh.subarray(8,12);const l=t-a,u=e-c,d=Math.hypot(l,u);if(d<this.#oh)return!1;const f=d-this.#hh,p=f/d,g=p*l,m=p*u;let w=o,A=h;o=a,h=c,a+=g,c+=m,this.#lh?.push(t,e);const v=-m/f*this.#ch,b=g/f*this.#ch;return this.#sh.set(this.#sh.subarray(2,8),0),this.#sh.set([a+v,c+b],4),this.#sh.set(this.#sh.subarray(14,18),12),this.#sh.set([a-v,c-b],16),isNaN(this.#sh[6])?(0===this.#ih.length&&(this.#sh.set([o+v,h+b],2),this.#ih.push(NaN,NaN,NaN,NaN,(o+v-i)/n,(h+b-s)/r),this.#sh.set([o-v,h-b],14),this.#Zo.push(NaN,NaN,NaN,NaN,(o-v-i)/n,(h-b-s)/r)),this.#sh.set([w,A,o,h,a,c],6),!this.isEmpty()):(this.#sh.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.#sh.subarray(2,6),this.#ih.push(NaN,NaN,NaN,NaN,((o+a)/2-i)/n,((h+c)/2-s)/r),[o,h,w,A]=this.#sh.subarray(14,18),this.#Zo.push(NaN,NaN,NaN,NaN,((w+o)/2-i)/n,((A+h)/2-s)/r),!0):([w,A,o,h,a,c]=this.#sh.subarray(0,6),this.#ih.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.#sh.subarray(12,18),this.#Zo.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.#ih,e=this.#Zo;if(isNaN(this.#sh[6])&&!this.isEmpty())return this.#gh();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)i.push(isNaN(t[e])?`L${t[e+4]} ${t[e+5]}`:`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#mh(i);for(let t=e.length-6;t>=6;t-=6)i.push(isNaN(e[t])?`L${e[t+4]} ${e[t+5]}`:`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#wh(i),i.join(" ")}#gh(){const[t,e,i,s]=this.#Jo,[n,r,o,h]=this.#ph();return`M${(this.#sh[2]-t)/i} ${(this.#sh[3]-e)/s} L${(this.#sh[4]-t)/i} ${(this.#sh[5]-e)/s} L${n} ${r} L${o} ${h} L${(this.#sh[16]-t)/i} ${(this.#sh[17]-e)/s} L${(this.#sh[14]-t)/i} ${(this.#sh[15]-e)/s} Z`}#wh(t){const e=this.#Zo;t.push(`L${e[4]} ${e[5]} Z`)}#mh(t){const[e,i,s,n]=this.#Jo,r=this.#sh.subarray(4,6),o=this.#sh.subarray(16,18),[h,a,c,l]=this.#ph();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 vn(t,e,i,s,n,r)}getOutlines(){const t=this.#ih,e=this.#Zo,i=this.#sh,[s,n,r,o]=this.#Jo,h=new Float32Array((this.#lh?.length??0)+2);for(let t=0,e=h.length-2;t<e;t+=2)h[t]=(this.#lh[t]-s)/r,h[t+1]=(this.#lh[t+1]-n)/o;if(h[h.length-2]=(this.#nh-s)/r,h[h.length-1]=(this.#rh-n)/o,isNaN(i[6])&&!this.isEmpty())return this.#Ah(h);const a=new Float32Array(this.#ih.length+24+this.#Zo.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.#vh(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.#bh(a,c),this.newFreeDrawOutline(a,h,this.#Jo,this.#ah,this.#th,this.#eh)}#Ah(t){const e=this.#sh,[i,s,n,r]=this.#Jo,[o,h,a,c]=this.#ph(),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.#Jo,this.#ah,this.#th,this.#eh)}#bh(t,e){const i=this.#Zo;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#vh(t,e){const i=this.#sh.subarray(4,6),s=this.#sh.subarray(16,18),[n,r,o,h]=this.#Jo,[a,c,l,u]=this.#ph();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 vn extends wn{#Jo;#yh=new Float32Array(4);#th;#eh;#lh;#ah;#xh;constructor(t,e,i,s,n,r){super(),this.#xh=t,this.#lh=e,this.#Jo=i,this.#ah=s,this.#th=n,this.#eh=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#Mh(r);const[o,h,a,c]=this.#yh;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.#xh[4]} ${this.#xh[5]}`];for(let e=6,i=this.#xh.length;e<i;e+=6)isNaN(this.#xh[e])?t.push(`L${this.#xh[e+4]} ${this.#xh[e+5]}`):t.push(`C${this.#xh[e]} ${this.#xh[e+1]} ${this.#xh[e+2]} ${this.#xh[e+3]} ${this.#xh[e+4]} ${this.#xh[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=wn._rescale(this.#xh,t,s,r,-o),a=wn._rescale(this.#lh,t,s,r,-o);break;case 90:h=wn._rescaleAndSwap(this.#xh,t,e,r,o),a=wn._rescaleAndSwap(this.#lh,t,e,r,o);break;case 180:h=wn._rescale(this.#xh,i,e,-r,o),a=wn._rescale(this.#lh,i,e,-r,o);break;case 270:h=wn._rescaleAndSwap(this.#xh,i,s,-r,-o),a=wn._rescaleAndSwap(this.#lh,i,s,-r,-o)}return{outline:Array.from(h),points:[Array.from(a)]}}#Mh(t){const e=this.#xh;let i=e[4],s=e[5];const n=[i,s,i,s];let r=i,o=s,h=i,a=s;const c=t?Math.max:Math.min,l=new Float32Array(4);for(let t=6,u=e.length;t<u;t+=6){const u=e[t+4],d=e[t+5];isNaN(e[t])?(pt.pointBoundingBox(u,d,n),o>d?(r=u,o=d):o===d&&(r=c(r,u)),a<d?(h=u,a=d):a===d&&(h=c(h,u))):(l.set(F,0),pt.bezierBoundingBox(i,s,...e.slice(t,t+6),l),pt.rectBoundingBox(...l,n),o>l[1]?(r=l[0],o=l[1]):o===l[1]&&(r=c(r,l[0])),a<l[3]?(h=l[2],a=l[3]):a===l[3]&&(h=c(h,l[2]))),i=u,s=d}const u=this.#yh;u[0]=n[0]-this.#th,u[1]=n[1]-this.#th,u[2]=n[2]-n[0]+2*this.#th,u[3]=n[3]-n[1]+2*this.#th,this.firstPoint=[r,o],this.lastPoint=[h,a]}get box(){return this.#yh}newOutliner(t,e,i,s,n,r=0){return new An(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=this.#yh,[o,h,a,c]=this.#Jo,l=n*a,u=r*c,d=i*a+o,f=s*c+h,p=this.newOutliner({x:this.#lh[0]*l+d,y:this.#lh[1]*u+f},this.#Jo,this.#ah,t,this.#eh,e??this.#th);for(let t=2;t<this.#lh.length;t+=2)p.add({x:this.#lh[t]*l+d,y:this.#lh[t+1]*u+f});return p.getOutlines()}}class bn{#Jo;#Sh;#Ch;#Eh=[];#kh=[];constructor(t,e=0,i=0,s=!0){const n=F.slice(),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.#Eh.push([t,c,l,!0],[a,c,l,!1]),pt.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;let l=s?-1/0:1/0,u=1/0;const d=this.#Eh.at(s?-1:-2),f=[d[0],d[2]];for(const t of this.#Eh){const[e,i,n,r]=t;!r&&s?i<u?(u=i,l=e):i===u&&(l=Math.max(l,e)):r&&!s&&(i<u?(u=i,l=e):i===u&&(l=Math.min(l,e))),t[0]=(e-a)/o,t[1]=(i-c)/h,t[2]=(n-c)/h}this.#Jo=new Float32Array([a,c,o,h]),this.#Sh=[l,u],this.#Ch=f}getOutlines(){this.#Eh.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#Eh)e[3]?(t.push(...this.#Th(e)),this.#Ph(e)):(this.#Dh(e),t.push(...this.#Th(e)));return this.#Ih(t)}#Ih(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 yn(s,this.#Jo,this.#Sh,this.#Ch)}#Nh(t){const e=this.#kh;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}#Ph([,t,e]){const i=this.#Nh(t);this.#kh.splice(i,0,[t,e])}#Dh([,t,e]){const i=this.#Nh(t);for(let s=i;s<this.#kh.length;s++){const[i,n]=this.#kh[s];if(i!==t)break;if(i===t&&n===e)return void this.#kh.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#kh[s];if(i!==t)break;if(i===t&&n===e)return void this.#kh.splice(s,1)}}#Th(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#Nh(s);for(let t=0;t<r;t++){const[i,s]=this.#kh[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 yn extends wn{#Jo;#Rh;constructor(t,e,i,s){super(),this.#Rh=t,this.#Jo=e,this.firstPoint=i,this.lastPoint=s}toSVGPath(){const t=[];for(const e of this.#Rh){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.#Rh){const i=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.#Jo}get classNamesForOutlining(){return["highlightOutline"]}}class xn extends An{newFreeDrawOutline(t,e,i,s,n,r){return new Mn(t,e,i,s,n,r)}}class Mn extends vn{newOutliner(t,e,i,s,n,r=0){return new xn(t,e,i,s,n,r)}}class Sn extends ue{#Oh=null;#_h=0;#Fh;#Bh=null;#r=null;#Lh=null;#Uh=null;#$h=0;#jh=null;#zh=null;#E=null;#Hh=!1;#Sh=null;#Ch=null;#Wh=null;#we="";#ch;#Gh="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=z.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Sn.prototype;return nt(this,"_keyboardManager",new re([[["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||Sn._defaultColor,this.#ch=t.thickness||Sn._defaultThickness,this.opacity=t.opacity||Sn._defaultOpacity,this.#Fh=t.boxes||null,this.#Gh=t.methodOfCreation||"",this.#we=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#Hh=!0,this.#Vh(t),this.#Yh()):this.#Fh&&(this.#Oh=t.anchorNode,this.#_h=t.anchorOffset,this.#Uh=t.focusNode,this.#$h=t.focusOffset,this.#Xh(),this.#Yh(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#Hh?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#ch,methodOfCreation:this.#Gh}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#Xh(){const t=new bn(this.#Fh,.001);this.#zh=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#zh.box;const e=new bn(this.#Fh,.0025,.001,"ltr"===this._uiManager.direction);this.#Lh=e.getOutlines();const{firstPoint:i}=this.#zh;this.#Sh=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];const{lastPoint:s}=this.#Lh;this.#Ch=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#Vh({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#zh=t,this.#Lh=t.getNewOutline(this.#ch/2+1.5,.0025),e>=0)this.#E=e,this.#Bh=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Wh=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Lh.box,path:{d:this.#Lh.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#E,{bbox:Sn.#qh(this.#zh.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Wh,{bbox:Sn.#qh(this.#Lh.box,e),path:{d:this.#Lh.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{firstPoint:h}=t;this.#Sh=[(h[0]-s)/r,(h[1]-n)/o];const{lastPoint:a}=this.#Lh;this.#Ch=[(a[0]-s)/r,(a[1]-n)/o]}static initialize(t,e){ue.initialize(t,e),Sn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case H.HIGHLIGHT_COLOR:Sn._defaultColor=e;break;case H.HIGHLIGHT_THICKNESS:Sn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#Ch}get commentButtonPosition(){return this.#Sh}updateParams(t,e){switch(t){case H.HIGHLIGHT_COLOR:this.#wo(e);break;case H.HIGHLIGHT_THICKNESS:this.#Qh(e)}}static get defaultPropertiesToUpdate(){return[[H.HIGHLIGHT_COLOR,Sn._defaultColor],[H.HIGHLIGHT_THICKNESS,Sn._defaultThickness]]}get propertiesToUpdate(){return[[H.HIGHLIGHT_COLOR,this.color||Sn._defaultColor],[H.HIGHLIGHT_THICKNESS,this.#ch||Sn._defaultThickness],[H.HIGHLIGHT_FREE,this.#Hh]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#E,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#r?.updateColor(this.color),super.onUpdatedColor()}#wo(t){const e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,s=this.opacity;this.addCommands({cmd:e.bind(this,t,Sn._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:H.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#Qh(t){const e=this.#ch,i=t=>{this.#ch=t,this.#Kh(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:H.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#r=new Ds({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#Jh())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#Jh())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#Zh(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Yh(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#Zh():t&&(this.#Yh(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#Kh(t){this.#Hh&&(this.#Vh({highlightOutlines:this.#zh.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#Zh(){null!==this.#E&&this.parent&&(this.parent.drawLayer.remove(this.#E),this.#E=null,this.parent.drawLayer.remove(this.#Wh),this.#Wh=null)}#Yh(t=this.parent){null===this.#E&&(({id:this.#E,clipPathId:this.#Bh}=t.drawLayer.draw({bbox:this.#zh.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#Hh},path:{d:this.#zh.toSVGPath()}},!1,!0)),this.#Wh=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Hh},bbox:this.#Lh.box,path:{d:this.#Lh.toSVGPath()}},this.#Hh),this.#jh&&(this.#jh.style.clipPath=this.#Bh))}static#qh([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.#Hh?Sn.#qh(this.#zh.box,t=(t-this.rotation+360)%360):Sn.#qh([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#E,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#Wh,{bbox:Sn.#qh(this.#Lh.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#we&&(t.setAttribute("aria-label",this.#we),t.setAttribute("role","mark")),this.#Hh?t.classList.add("free"):this.div.addEventListener("keydown",this.#ta.bind(this),{signal:this._uiManager._signal});const e=this.#jh=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#Bh,this.setDims(),te(this,this.#jh,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Wh,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Wh,{rootClass:{hovered:!1}})}#ta(t){Sn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#ea(!0);break;case 1:case 3:this.#ea(!1)}}#ea(t){if(!this.#Oh)return;const e=window.getSelection();t?e.setPosition(this.#Oh,this.#_h):e.setPosition(this.#Uh,this.#$h)}select(){super.select(),this.#Wh&&this.parent?.drawLayer.updateProperties(this.#Wh,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Wh&&(this.parent?.drawLayer.updateProperties(this.#Wh,{rootClass:{selected:!1}}),this.#Hh||this.#ea(!1))}get _mustFixPosition(){return!this.#Hh}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#E,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Wh,{rootClass:{hidden:!t}}))}#Jh(){return this.#Hh?this.rotation:0}#ia(){if(this.#Hh)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Fh,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}#sa(t){return this.#zh.serialize(t,this.#Jh())}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.#na(t,e)};window.addEventListener("blur",u,{signal:l}),window.addEventListener("pointerup",u,{signal:l}),window.addEventListener("pointerdown",_t,{capture:!0,passive:!1,signal:l}),window.addEventListener("contextmenu",Ot,{signal:l}),i.addEventListener("pointermove",this.#ra.bind(this,t),{signal:l}),this._freeHighlight=new xn({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#ra(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#na(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 an){const{data:{quadPoints:e,rect:i,rotation:n,id:r,color:o,opacity:h,popupRef:a,richText:c,contentsObj:l,creationDate:u,modificationDate:d},parent:{page:{pageNumber:f}}}=t;s=t={annotationType:z.HIGHLIGHT,color:Array.from(o),opacity:h,quadPoints:e,boxes:null,pageIndex:f-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:a,richText:c,comment:l?.str||null,creationDate:u,modificationDate:d}}else if(t instanceof hn){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:o,borderStyle:{rawWidth:h},popupRef:a,richText:c,contentsObj:l,creationDate:u,modificationDate:d},parent:{page:{pageNumber:f}}}=t;s=t={annotationType:z.HIGHLIGHT,color:Array.from(o),thickness:h,inkLists:e,boxes:null,pageIndex:f-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:a,richText:c,comment:l?.str||null,creationDate:u,modificationDate:d}}const{color:n,quadPoints:r,inkLists:o,outlines:h,opacity:a}=t,c=await super.deserialize(t,e,i);c.color=pt.makeHexColor(...n),c.opacity=a||1,o&&(c.#ch=t.thickness),c._initialData=s,t.comment&&c.setCommentData(t);const[l,u]=c.pageDimensions,[d,f]=c.pageTranslation;if(r){const t=c.#Fh=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-d)/l,y:1-(r[e+1]-f)/u,width:(r[e+2]-r[e])/l,height:(r[e+1]-r[e+5])/u});c.#Xh(),c.#Yh(),c.rotate(c.rotation)}else if(o||h){c.#Hh=!0;const t=(o||h.points)[0],i={x:t[0]-d,y:u-(t[1]-f)},s=new xn(i,[0,0,l,u],1,c.#ch/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-d,i.y=u-(t[e+1]-f),s.add(i);const{id:n,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:c.color,"fill-opacity":c._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);c.#Vh({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),c.#Yh(),c.rotate(c.parentRotation)}return c}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=ue._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#ch,quadPoints:this.#ia(),outlines:this.#sa(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#Ko(i)?null:(i.id=this.annotationElementId,i)}#Ko(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}}class Cn{#oa=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.#oa[t]=e}toSVGProperties(){const t=this.#oa;return this.#oa=Object.create(null),{root:t}}reset(){this.#oa=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){Z("Not implemented")}}class En extends ue{#ha=null;#aa;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#ca=null;static#la=null;static#ua=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#aa=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){t.drawOutlines&&(this.#da(t),this.#Yh())}#da({drawOutlines:t,drawId:e,drawingOptions:i}){this.#ha=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#fa(t,this.parent),this.#pa(t.box)}#fa(t,e){const{id:i}=e.drawLayer.draw(En._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){Z("Not implemented")}static get typesMap(){Z("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&&(En.#ca.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=i=>{s.updateProperty(e,i);const n=this.#ha.updateProperty(e,i);n&&this.#pa(n),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};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})}_updateColorAndOpacity(t,e){const i=this.constructor.typesMap.get(this.colorType),s=this.constructor.typesMap.get(this.opacityType),n=this._drawingOptions,r=n[i],o=n[s],h=(t,e)=>{n.updateProperty(i,t),n.updateProperty(s,e),this.#ha.updateProperty(i,t),this.#ha.updateProperty(s,e),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:h.bind(this,t,e),undo:h.bind(this,r,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:H.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,En._mergeSVGProperties(this.#ha.getPathResizingSVGProperties(this.#ga()),{bbox:this.#ma()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,En._mergeSVGProperties(this.#ha.getPathResizedSVGProperties(this.#ga()),{bbox:this.#ma()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#ma()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,En._mergeSVGProperties(this.#ha.getPathTranslatedSVGProperties(this.#ga(),this.parentDimensions),{bbox:this.#ma()}))}_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.#aa&&(this.#aa=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#Zh(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Yh(),this.#pa(this.#ha.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#Zh()):t&&(this._uiManager.addShouldRescale(this),this.#Yh(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#Zh(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#Yh(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#fa(this.#ha,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#wa([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]}}#ga(){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]}}#pa(t){[this.x,this.y,this.width,this.height]=this.#wa(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#ma(){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,En._mergeSVGProperties({bbox:this.#ma()},this.#ha.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#pa(this.#ha.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");return i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,n){Z("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:r,offsetY:o,pointerId:h,pointerType:a}=s;if(ee.isInitializedAndDifferentPointerType(a))return;const{viewport:{rotation:c}}=t,{width:l,height:u}=n.getBoundingClientRect(),d=En.#la=new AbortController,f=t.combinedSignal(d);ee.setPointer(a,h),window.addEventListener("pointerup",(t=>{ee.isSamePointerIdOrRemove(t.pointerId)&&this._endDraw(t)}),{signal:f}),window.addEventListener("pointercancel",(t=>{ee.isSamePointerIdOrRemove(t.pointerId)&&this._currentParent.endDrawingSession()}),{signal:f}),window.addEventListener("pointerdown",(t=>{ee.isSamePointerType(t.pointerType)&&(ee.initializeAndAddPointerId(t.pointerId),En.#ca.isCancellable()&&(En.#ca.removeLastElement(),En.#ca.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Ot,{signal:f}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:f}),n.addEventListener("touchmove",(t=>{ee.isSameTimeStamp(t.timeStamp)&&_t(t)}),{signal:f}),t.toggleDrawing(),e._editorUndoBar?.hide(),En.#ca?t.drawLayer.updateProperties(this._currentDrawId,En.#ca.startNew(r,o,l,u,c)):(e.updateUIForDefaultProperties(this),En.#ca=this.createDrawerInstance(r,o,l,u,c),En.#ua=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(En.#ua.toSVGProperties(),En.#ca.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(!En.#ca)return;const{offsetX:e,offsetY:i,pointerId:s}=t;ee.isSamePointerId(s)&&(ee.isUsingMultiplePointers()?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,En.#ca.add(e,i)),ee.setTimeStamp(t.timeStamp),_t(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,En.#ca=null,En.#ua=null,ee.clearTimeStamp()),En.#la&&(En.#la.abort(),En.#la=null,ee.clearPointerIds())}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,En.#ca.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=En.#ca,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:H.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(H.DRAW_STEP),!En.#ca.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:En.#ca.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:En.#ua,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){Z("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.#da({drawOutlines:h}),a.#Yh(),a.onScaleChanging(),a.rotate(),a}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#ha.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class kn{#sh=new Float64Array(6);#So;#Aa;#Nn;#ch;#lh;#va="";#ba=0;#Rh=new Tn;#ya;#xa;constructor(t,e,i,s,n,r){this.#ya=i,this.#xa=s,this.#Nn=n,this.#ch=r,[t,e]=this.#Ma(t,e);const o=this.#So=[NaN,NaN,NaN,NaN,t,e];this.#lh=[t,e],this.#Aa=[{line:o,points:this.#lh}],this.#sh.set(o,0)}updateProperty(t,e){"stroke-width"===t&&(this.#ch=e)}#Ma(t,e){return wn._normalizePoint(t,e,this.#ya,this.#xa,this.#Nn)}isEmpty(){return!this.#Aa||0===this.#Aa.length}isCancellable(){return this.#lh.length<=10}add(t,e){[t,e]=this.#Ma(t,e);const[i,s,n,r]=this.#sh.subarray(2,6);return Math.hypot(this.#ya*(t-n),this.#xa*(e-r))<=2?null:(this.#lh.push(t,e),isNaN(i)?(this.#sh.set([n,r,t,e],2),this.#So.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#sh[0])&&this.#So.splice(6,6),this.#sh.set([i,s,n,r,t,e],0),this.#So.push(...wn.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){return this.add(t,e)||(2===this.#lh.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#ya=i,this.#xa=s,this.#Nn=n,[t,e]=this.#Ma(t,e);const r=this.#So=[NaN,NaN,NaN,NaN,t,e];this.#lh=[t,e];const o=this.#Aa.at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),this.#Aa.push({line:r,points:this.#lh}),this.#sh.set(r,0),this.#ba=0,this.toSVGPath(),null}getLastElement(){return this.#Aa.at(-1)}setLastElement(t){return this.#Aa?(this.#Aa.push(t),this.#So=t.line,this.#lh=t.points,this.#ba=0,{path:{d:this.toSVGPath()}}):this.#Rh.setLastElement(t)}removeLastElement(){if(!this.#Aa)return this.#Rh.removeLastElement();this.#Aa.pop(),this.#va="";for(let t=0,e=this.#Aa.length;t<e;t++){const{line:e,points:i}=this.#Aa[t];this.#So=e,this.#lh=i,this.#ba=0,this.toSVGPath()}return{path:{d:this.#va}}}toSVGPath(){const t=wn.svgRound(this.#So[4]),e=wn.svgRound(this.#So[5]);if(2===this.#lh.length)return this.#va=`${this.#va} M ${t} ${e} Z`,this.#va;if(this.#lh.length<=6){const i=this.#va.lastIndexOf("M");this.#va=`${this.#va.slice(0,i)} M ${t} ${e}`,this.#ba=6}if(4===this.#lh.length){const t=wn.svgRound(this.#So[10]),e=wn.svgRound(this.#So[11]);return this.#va=`${this.#va} L ${t} ${e}`,this.#ba=12,this.#va}const i=[];0===this.#ba&&(i.push(`M ${t} ${e}`),this.#ba=6);for(let t=this.#ba,e=this.#So.length;t<e;t+=6){const[e,s,n,r,o,h]=this.#So.slice(t,t+6).map(wn.svgRound);i.push(`C${e} ${s} ${n} ${r} ${o} ${h}`)}return this.#va+=i.join(" "),this.#ba=this.#So.length,this.#va}getOutlines(t,e,i,s){const n=this.#Aa.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Rh.build(this.#Aa,t,e,i,this.#Nn,this.#ch,s),this.#sh=null,this.#So=null,this.#Aa=null,this.#va=null,this.#Rh}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Tn extends wn{#yh;#Sa=0;#th;#Aa;#ya;#xa;#Ca;#Nn;#ch;build(t,e,i,s,n,r,o){this.#ya=e,this.#xa=i,this.#Ca=s,this.#Nn=n,this.#ch=r,this.#th=o??0,this.#Aa=t,this.#Ea()}get thickness(){return this.#ch}setLastElement(t){return this.#Aa.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Aa.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Aa)if(t.push(`M${wn.svgRound(e[4])} ${wn.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${wn.svgRound(e[10])} ${wn.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(wn.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.#ka();let u,d,f,p,g,m,w,A,v;switch(this.#Nn){case 0:v=wn._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:v=wn._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:v=wn._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:v=wn._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.#Aa)r.push(v(t,u,d,f,p,n?Array(t.length):null)),o.push(v(e,u,d,f,p,n?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=wn._rescale,l=-t/i,u=e/s+1,d=1/i,f=-1/s;break;case 90:p=wn._rescaleAndSwap,l=-e/s,u=-t/i,d=1/s,f=1/i;break;case 180:p=wn._rescale,l=t/i+1,u=-e/s,d=-1/i,f=1/s;break;case 270:p=wn._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(wn.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}#Ta(t=this.#ch){const e=this.#th+t/2*this.#Ca;return this.#Nn%180==0?[e/this.#ya,e/this.#xa]:[e/this.#xa,e/this.#ya]}#ka(){const[t,e,i,s]=this.#yh,[n,r]=this.#Ta(0);return[t+n,e+r,i-2*n,s-2*r]}#Ea(){const t=this.#yh=B.slice();for(const{line:e}of this.#Aa){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)pt.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);pt.bezierBoundingBox(i,s,r,o,h,a,c,l,t),i=c,s=l}}const[e,i]=this.#Ta();t[0]=xt(t[0]-e,0,1),t[1]=xt(t[1]-i,0,1),t[2]=xt(t[2]+e,0,1),t[3]=xt(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#yh}updateProperty(t,e){return"stroke-width"===t?this.#Qh(e):null}#Qh(t){const[e,i]=this.#Ta();this.#ch=t;const[s,n]=this.#Ta(),[r,o]=[s-e,n-i],h=this.#yh;return h[0]-=r,h[1]-=o,h[2]+=2*r,h[3]+=2*o,h}updateParentDimensions([t,e],i){const[s,n]=this.#Ta();this.#ya=t,this.#xa=e,this.#Ca=i;const[r,o]=this.#Ta(),h=r-s,a=o-n,c=this.#yh;return c[0]-=h,c[1]-=a,c[2]+=2*h,c[3]+=2*a,c}updateRotation(t){return this.#Sa=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#yh.map(wn.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#yh;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${wn.svgRound(t)} ${wn.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#yh;let i=0,s=0,n=0,r=0,o=0,h=0;switch(this.#Sa){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} ${wn.svgRound(o)} ${wn.svgRound(h)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#Ta(),[o,h,a,c]=this.#yh;if(Math.abs(a-n)<=wn.PRECISION||Math.abs(c-r)<=wn.PRECISION){const n=t+i/2-(o+a/2),r=e+s/2-(h+c/2);return{path:{"transform-origin":`${wn.svgRound(t)} ${wn.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":`${wn.svgRound(o)} ${wn.svgRound(h)}`,transform:`${this.rotationTransform} scale(${d} ${f}) translate(${wn.svgRound(n)} ${wn.svgRound(r)}) scale(${l} ${u}) translate(${wn.svgRound(-n)} ${wn.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#Ta(),o=this.#yh,[h,a,c,l]=o;if(o[0]=t,o[1]=e,o[2]=i,o[3]=s,Math.abs(c-n)<=wn.PRECISION||Math.abs(l-r)<=wn.PRECISION){const n=t+i/2-(h+c/2),r=e+s/2-(a+l/2);for(const{line:t,points:e}of this.#Aa)wn._translate(t,n,r,t),wn._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${wn.svgRound(t)} ${wn.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.#Aa)wn._rescale(t,f,p,u,d,t),wn._rescale(e,f,p,u,d,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${wn.svgRound(t)} ${wn.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#yh,o=t-r[0],h=e-r[1];if(this.#ya===s&&this.#xa===n)for(const{line:t,points:e}of this.#Aa)wn._translate(t,o,h,t),wn._translate(e,o,h,e);else{const t=this.#ya/s,e=this.#xa/n;this.#ya=s,this.#xa=n;for(const{line:i,points:s}of this.#Aa)wn._rescale(i,o,h,t,e,i),wn._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":`${wn.svgRound(t)} ${wn.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#yh;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${wn.svgRound(t[0])} ${wn.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Pn extends Cn{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:ue._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 Pn(this._viewParameters);return t.updateAll(this),t}}class Dn extends En{static _type="ink";static _editorType=z.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){ue.initialize(t,e),this._defaultDrawingOptions=new Pn(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return nt(this,"typesMap",new Map([[H.INK_THICKNESS,"stroke-width"],[H.INK_COLOR,"stroke"],[H.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new kn(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return Tn.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof hn){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:o,opacity:h,borderStyle:{rawWidth:a},popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=t;s=t={annotationType:z.INK,color:Array.from(o),thickness:a,opacity:h,paths:{points:e},boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}const n=await super.deserialize(t,e,i);return n._initialData=s,t.comment&&n.setCommentData(t),n}get toolbarButtons(){return this._colorPicker||=new Is(this),[["colorPicker",this._colorPicker]]}get colorType(){return H.INK_COLOR}get colorAndOpacityType(){return H.INK_COLOR_AND_OPACITY}get opacityType(){return H.INK_OPACITY}updateParams(t,e){t!==H.INK_COLOR_AND_OPACITY?super.updateParams(t,e):this._updateColorAndOpacity(e.color,e.opacity)}static updateDefaultParams(t,e){if(t===H.INK_COLOR_AND_OPACITY)return super.updateDefaultParams(H.INK_COLOR,e.color),void super.updateDefaultParams(H.INK_OPACITY,e.opacity);super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent: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=Dn.getDefaultDrawingOptions({stroke:pt.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}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":n,"stroke-width":r}}=this,o=Object.assign(super.serialize(t),{color:ue._colorManager.convert(s),opacity:n,thickness:r,paths:{lines:e,points:i}});return this.addComment(o),t?(o.isCopy=!0,o):this.annotationElementId&&!this.#Ko(o)?null:(o.id=this.annotationElementId,o)}#Ko(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class In extends Tn{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}O(5213);class Nn{static#Pa={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#Da(t,e,i,s){return s-=e,0==(i-=t)?s>0?0:4:1===i?s+6:2-s}static#Ia=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#Na(t,e,i,s,n,r,o){const h=this.#Da(i,s,n,r);for(let n=0;n<8;n++){const r=(-n+h-o+16)%8;if(0!==t[(i+this.#Ia[2*r])*e+(s+this.#Ia[2*r+1])])return r}return-1}static#Ra(t,e,i,s,n,r,o){const h=this.#Da(i,s,n,r);for(let n=0;n<8;n++){const r=(n+h+o+16)%8;if(0!==t[(i+this.#Ia[2*r])*e+(s+this.#Ia[2*r+1])])return r}return-1}static#Oa(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.#Na(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.#Ia[2*g],w=this.#Ia[2*g+1];const A=t+m,v=i+w;c=A,l=v;let b=t,y=i;for(;;){const n=this.#Ra(r,e,b,y,c,l,1);m=this.#Ia[2*n],w=this.#Ia[2*n+1];const a=b+m,d=y+w;u.push(d,a);const f=b*e+y;if(0===r[f+1]?r[f]=-h:1===r[f]&&(r[f]=h),a===t&&d===i&&b===A&&y===v){1!==r[s]&&(o=Math.abs(r[s]));break}c=b,l=y,b=a,y=d}}}return a}static#_a(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 v=0,b=e;for(let s=e+2;s<i-2;s+=2){const e=Math.abs(u-c*t[s+1]+l*t[s]);e>v&&(b=s,v=e)}v>(a*A)**2?(this.#_a(t,e,b+2,s),this.#_a(t,b,i,s)):s.push(n,r)}static#Fa(t){const e=[],i=t.length;return this.#_a(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#Ba(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#La(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#Ua(t){const e=new Uint8ClampedArray(t.length>>2);let i=-1/0,s=1/0;for(let n=0,r=e.length;n<r;n++){const r=e[n]=t[n<<2];i=Math.max(i,r),s=Math.min(s,r)}const n=255/(i-s);for(let t=0,i=e.length;t<i;t++)e[t]=(e[t]-s)*n;return e}static#$a(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#ja(t){const e=t,{width:i,height:s}=t,{maxDim:n}=this.#Pa;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.fillStyle="white",h.fillRect(0,0,r,o),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.#Ua(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)),v=Math.ceil(1.5*Math.max(Math.abs(f)+Math.abs(p)||200,Math.abs(g)+Math.abs(m)||200));a=new OffscreenCanvas(A,v),c=a.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=l,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,A,v),c.fillStyle="black",c.fillText(t,.5*A/2,1.5*v/2);const b=this.#Ua(c.getImageData(0,0,A,v).data),y=this.#La(b),x=this.#$a(y),M=this.#Oa(b,A,v,x);return this.processDrawnLines({lines:{curves:M,width:A,height:v},pageWidth:n,pageHeight:r,rotation:o,innerMargin:h,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,n){const[r,o,h]=this.#ja(t),[a,c]=this.#Ba(r,o,h,Math.hypot(o,h)*this.#Pa.sigmaSFactor,this.#Pa.sigmaR,this.#Pa.kernelSize),l=this.#$a(c),u=this.#Oa(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.#Fa(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(wn.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 In:new Tn;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)}return p.close(),(await new Response(f.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:i,writable:s}=new DecompressionStream("deflate-raw"),n=s.getWriter();await n.ready,n.write(e).then((async()=>{await n.ready,await n.close()})).catch((()=>{}));let r=null,o=0;for await(const t of i)r||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),r.set(t,o),o+=t.length;const h=new Uint32Array(r.buffer,0,r.length>>2),a=h[1];if(0!==a)throw Error("Invalid version: "+a);const c=h[2],l=h[3],u=0===h[4],d=h[5],f=h[6],p=[],g=(8+3*f)*Uint32Array.BYTES_PER_ELEMENT;let m;switch(h[7]){case Int8Array.BYTES_PER_ELEMENT:m=new Int8Array(r.buffer,g);break;case Int16Array.BYTES_PER_ELEMENT:m=new Int16Array(r.buffer,g);break;case Int32Array.BYTES_PER_ELEMENT:m=new Int32Array(r.buffer,g)}o=0;for(let t=0;t<f;t++){const e=h[3*t+8],i=new Float32Array(e+2);p.push(i);for(let e=0;e<2;e++)i[e]=h[3*t+8+e+1];for(let t=0;t<e;t++)i[t+2]=i[t]+m[o++]}return{areContours:u,thickness:d,outlines:p,width:c,height:l}}catch(t){return J("decompressSignature: "+t),null}}}class Rn extends Cn{constructor(){super(),super.updateProperties({fill:ue._defaultLineColor,"stroke-width":0})}clone(){const t=new Rn;return t.updateAll(this),t}}class On extends Pn{constructor(t){super(t),super.updateProperties({stroke:ue._defaultLineColor,"stroke-width":1})}clone(){const t=new On(this._viewParameters);return t.updateAll(this),t}}class _n extends En{#za=!1;#Ha=null;#Wa=null;#Ga=null;static _type="signature";static _editorType=z.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#Wa=t.signatureData||null,this.#Ha=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){ue.initialize(t,e),this._defaultDrawingOptions=new Rn,this._defaultDrawnSignatureOptions=new On(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return nt(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#Ha}}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.#Wa){const{lines:t,mustSmooth:e,areContours:i,description:s,uuid:n,heightInPage:r}=this.#Wa,{rawDims:{pageWidth:o,pageHeight:h},rotation:a}=this.parent.viewport,c=Nn.processDrawnLines({lines:t,pageWidth:o,pageHeight:h,rotation:a,innerMargin:_n._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);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#Ha||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#Ga=t,this.addEditToolbar()}getUuid(){return this.#Ga}get description(){return this.#Ha}set description(t){this.#Ha=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then((e=>{e?.updateEditSignatureButton(t)})))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:s,height:n}=this.#Wa,r=Math.max(s,n);return{areContours:e,outline:Nn.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}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,s){const{x:n,y:r}=this,{outline:o}=this.#Wa=t;let h;this.#za=o instanceof In,this.description=i,this.#za?h=_n.getDefaultDrawingOptions():(h=_n._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":o.thickness})),this._addOutlines({drawOutlines:o,drawingOptions:h});const[,a]=this.pageDimensions;let c=e/a;c=c>=1?.5:c,this.width*=c/this.height,this.width>=1&&(c*=.9/this.width,this.width=.9),this.height=c,this.setDims(),this.x=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 Nn.process(t,e,i,s,_n._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return Nn.extractContoursFromText(t,e,i,s,n,_n._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return Nn.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:_n._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=_n.getDefaultDrawingOptions():(this._drawingOptions=_n._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#za,color:[0,0,0],thickness:this.#za?0:s});return this.addComment(n),t?(n.paths={lines:e,points:i},n.uuid=this.#Ga,n.isCopy=!0):n.lines=e,this.#Ha&&(n.accessibilityData={type:"Figure",alt:this.#Ha}),n}static deserializeDraw(t,e,i,s,n,r){return r.areContours?In.deserialize(t,e,i,s,n,r):Tn.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){const s=await super.deserialize(t,e,i);return s.#za=t.areContours,s.description=t.accessibilityData?.alt||"",s.#Ga=t.uuid,s}}class Fn extends ue{#Va=null;#Ya=null;#Xa=null;#qa=null;#Qa=null;#Ka="";#Ja=null;#Za=!1;#tc=null;#ec=!1;#ic=!1;static _type="stamp";static _editorType=z.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#qa=t.bitmapUrl,this.#Qa=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){ue.initialize(t,e)}static isHandlingMimeForPasting(t){return Ht.includes(t)}static paste(t,e){e.pasteEditor({mode:z.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}}#sc(t,e=!1){t?(this.#Va=t.bitmap,e||(this.#Ya=t.id,this.#ec=t.isSvg),t.file&&(this.#Ka=t.file.name),this.#nc()):this.remove()}#rc(){if(this.#Xa=null,this._uiManager.enableWaiting(!1),this.#Ja)if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Va)this.addEditToolbar().then((()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)}));else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Va){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 Error("No ML.");if(!await i.isEnabledFor("altText"))throw 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 Error("No response from the AI service.");if(o.error)throw Error("Error from the AI service.");if(o.cancel)return null;if(!o.output)throw 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}#oc(){if(this.#Ya)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#Ya).then((t=>this.#sc(t,!0))).finally((()=>this.#rc()));if(this.#qa){const t=this.#qa;return this.#qa=null,this._uiManager.enableWaiting(!0),void(this.#Xa=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#sc(t))).finally((()=>this.#rc())))}if(this.#Qa){const t=this.#Qa;return this.#Qa=null,this._uiManager.enableWaiting(!0),void(this.#Xa=this._uiManager.imageManager.getFromFile(t).then((t=>this.#sc(t))).finally((()=>this.#rc())))}const t=document.createElement("input");t.type="file",t.accept=Ht.join(",");const e=this._uiManager._signal;this.#Xa=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.#sc(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#rc())),t.click()}remove(){this.#Ya&&(this.#Va=null,this._uiManager.imageManager.deleteId(this.#Ya),this.#Ja?.remove(),this.#Ja=null,this.#tc&&(clearTimeout(this.#tc),this.#tc=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#Ya&&null===this.#Ja&&this.#oc(),this.isAttachedToDOM||this.parent.add(this))):this.#Ya&&this.#oc()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#Xa||this.#Va||this.#qa||this.#Qa||this.#Ya||this.#Za)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#Za||(this.#Va?this.#nc():this.#oc()),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.#Ya=i,s&&(this.#Va=s),this.#Za=!1,this.#nc())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#tc&&clearTimeout(this.#tc),this.#tc=setTimeout((()=>{this.#tc=null,this.#hc()}),200))}#nc(){const{div:t}=this;let{width:e,height:i}=this.#Va;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}this._uiManager.enableWaiting(!1);const o=this.#Ja=document.createElement("canvas");o.setAttribute("role","img"),this.addContainer(o),this.width=e/s,this.height=i/n,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#hc(),this.#ic||(this.parent.addUndoableEditor(this),this.#ic=!0),this._reportTelemetry({action:"inserted_image"}),this.#Ka&&this.div.setAttribute("aria-description",this.#Ka),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#Va,r=new zt;let o=this.#Va,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.#ec||(o=this.#ac(t,i));const l=c.getContext("2d");l.filter=this._uiManager.hcmFilter;let u="white",d="#cfcfd8";"none"!==this._uiManager.hcmFilter?d="black":Wt.isDarkMode&&(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.#Va,s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#ec||(o=this.#ac(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}}#ac(t,e){const{width:i,height:s}=this.#Va;let n=i,r=s,o=this.#Va;for(;n>2*t||r>2*e;){const i=n,s=r;n>2*t&&(n=Math.ceil(n/2)),r>2*e&&(r=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}#hc(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new zt,r=Math.ceil(i*t*n.sx),o=Math.ceil(s*e*n.sy),h=this.#Ja;if(!h||h.width===r&&h.height===o)return;h.width=r,h.height=o;const a=this.#ec?this.#Va:this.#ac(r,o),c=h.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(a,0,0,a.width,a.height,0,0,r,o)}#cc(t){if(t){if(this.#ec){const t=this._uiManager.imageManager.getSvgUrl(this.#Ya);if(t)return t}const t=document.createElement("canvas");return({width:t.width,height:t.height}=this.#Va),t.getContext("2d").drawImage(this.#Va,0,0),t.toDataURL()}if(this.#ec){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*Et.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Et.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#Va,0,0,this.#Va.width,this.#Va.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#Va)}static async deserialize(t,e,i){let s=null,n=!1;if(t instanceof dn){const{data:{rect:r,rotation:o,id:h,structParent:a,popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},container:p,parent:{page:{pageNumber:g}},canvas:m}=t;let w,A;m?(delete t.canvas,({id:w,bitmap:A}=i.imageManager.getFromCanvas(p.id,m)),m.remove()):(n=!0,t._hasNoCanvas=!0);const v=(await e._structTree.getAriaAttributes(`${At}${h}`))?.get("aria-label")||"";s=t={annotationType:z.STAMP,bitmapId:w,bitmap:A,pageIndex:g-1,rect:r.slice(0),rotation:o,annotationElementId:h,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:v},isSvg:!1,structParent:a,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}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.#Za=!0):c&&i.imageManager.isValidId(c)?(r.#Ya=c,h&&(r.#Va=h)):r.#qa=a,r.#ec=l;const[d,f]=r.pageDimensions;return r.width=(o[2]-o[0])/d,r.height=(o[3]-o[1])/f,u&&(r.altTextData=u),r._initialData=s,t.comment&&r.setCommentData(t),r.#ic=!!s,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(t),{bitmapId:this.#Ya,isSvg:this.#ec});if(this.addComment(i),t)return i.bitmapUrl=this.#cc(!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.#Ko(i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||=new Map;const r=this.#ec?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#Ya)){if(this.#ec){const t=e.stamps.get(this.#Ya);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#cc(!1))}}else e.stamps.set(this.#Ya,{area:r,serialized:i}),i.bitmap=this.#cc(!1);return i}#Ko(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class Bn{#Ro;#lc=!1;#uc=null;#dc=null;#fc=null;#pc=new Map;#gc=!1;#mc=!1;#wc=!1;#Ac=null;#vc=null;#bc=null;#yc=null;#xc=null;#Mc=-1;#A;static _initialized=!1;static#K=new Map([mn,Dn,Fn,Sn,_n].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=[...Bn.#K.values()];if(!Bn._initialized){Bn._initialized=!0;for(const e of l)e.initialize(c,t)}t.registerEditorTypes(l),this.#A=t,this.pageIndex=e,this.div=i,this.#Ro=n,this.#uc=r,this.viewport=a,this.#bc=h,this.drawLayer=o,this._structTree=s,this.#A.addLayer(this)}get isEmpty(){return 0===this.#pc.size}get isInvisible(){return this.isEmpty&&this.#A.getMode()===z.NONE}updateToolbar(t){this.#A.updateToolbar(t)}updateMode(t=this.#A.getMode()){switch(this.#Sc(),t){case z.NONE:return this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case z.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case z.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===z.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const i of Bn.#K.values())e.toggle(i._type+"Editing",t===i._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#bc?.div}setEditingState(t){this.#A.setEditingState(t)}addCommands(t){this.#A.addCommands(t)}cleanUndoStack(t){this.#A.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#uc?.togglePointerEvents(t)}get#Cc(){return 0!==this.#pc.size?this.#pc.values():this.#A.getEditors(this.pageIndex)}async enable(){this.#wc=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#xc?.abort(),this.#xc=null;const t=new Set;for(const e of this.#Cc)e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#A.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));const e=this.#uc;if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),this.#A.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.#wc=!1,this.#A._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#mc=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#bc&&!this.#xc){this.#xc=new AbortController;const t=this.#A.combinedSignal(this.#xc);this.#bc.div.addEventListener("pointerdown",(t=>{const{clientX:e,clientY:i,timeStamp:s}=t;if(s-this.#Mc>500)return void(this.#Mc=s);this.#Mc=-1;const{classList:n}=this.div;n.toggle("getElements",!0);const r=document.elementsFromPoint(e,i);if(n.toggle("getElements",!1),!this.div.contains(r[0]))return;let o;const h=RegExp(`^${j}[0-9]+$`);for(const t of r)if(h.test(t.id)){o=t.id;break}if(!o)return;const a=this.#pc.get(o);null===a?.annotationElementId&&(_t(t),a.dblclick(t))}),{signal:t,capture:!0})}const t=this.#uc,e=[];if(t){const i=new Map,s=new Map;for(const t of this.#Cc)t.disableEditing(),t.annotationElementId?null===t.serialize()?(s.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()):i.set(t.annotationElementId,t):e.push(t);for(const e of t.getEditableAnnotations()){const{id:t}=e.data;if(this.#A.isDeletedAnnotationElement(t)){e.updateEdited({deleted:!0});continue}let n=s.get(t);n?(n.resetAnnotationElement(e),n.show(!1),e.show()):(n=i.get(t),n&&(this.#A.addChangedExistingAnnotation(n),n.renderAnnotationElement(e)&&n.show(!1)),e.show())}}this.#Sc(),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const t of Bn.#K.values())i.remove(t._type+"Editing");this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#mc=!1}getEditableAnnotation(t){return this.#uc?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#A.getActive()!==t&&this.#A.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#bc?.div&&!this.#yc){this.#yc=new AbortController;const t=this.#A.combinedSignal(this.#yc);this.#bc.div.addEventListener("pointerdown",this.#Ec.bind(this),{signal:t}),this.#bc.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#bc?.div&&this.#yc&&(this.#yc.abort(),this.#yc=null,this.#bc.div.classList.remove("highlighting"))}#Ec(t){this.#A.unselectAll();const{target:e}=t;if(e===this.#bc.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent")||e.classList.contains("textLayerImagePlaceholder"))&&this.#bc.div.contains(e)){const{isMac:e}=ft.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#A.showAllEditors("highlight",!0,!0),this.#bc.div.classList.add("free"),this.toggleDrawing(),Sn.startHighlighting(this,"ltr"===this.#A.direction,{target:this.#bc.div,x:t.x,y:t.y}),this.#bc.div.addEventListener("pointerup",(()=>{this.#bc.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#A._signal}),t.preventDefault()}}enableClick(){if(this.#dc)return;this.#dc=new AbortController;const t=this.#A.combinedSignal(this.#dc);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.#dc?.abort(),this.#dc=null}attach(t){this.#pc.set(t.id,t);const{annotationElementId:e}=t;e&&this.#A.isDeletedAnnotationElement(e)&&this.#A.removeDeletedAnnotationElement(t)}detach(t){this.#pc.delete(t.id),this.#Ro?.removePointerInTextLayer(t.contentDiv),!this.#mc&&t.annotationElementId&&this.#A.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#A.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#A.addDeletedAnnotationElement(t),ue.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.#A.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#wc),this.#A.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#fc&&(t._focusEventsAllowed=!1,this.#fc=setTimeout((()=>{this.#fc=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#A._signal}),e.focus())}),0)),t._structTreeParentId=this.#Ro?.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})}getEditorByUID(t){for(const e of this.#pc.values())if(e.uid===t)return e;return null}get#kc(){return Bn.#K.get(this.#A.getMode())}combinedSignal(t){return this.#A.combinedSignal(t)}#Tc(t){const e=this.#kc;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#kc?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#A.updateMode(t.mode);const{offsetX:i,offsetY:s}=this.#Pc(),n=this.#A.getId(),r=this.#Tc({parent:this,id:n,x:i,y:s,uiManager:this.#A,isCentered:!0,...e});r&&this.add(r)}async deserialize(t){return await(Bn.#K.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#A))||null}createAndAddNewEditor(t,e,i={}){const s=this.#A.getId(),n=this.#Tc({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#A,isCentered:e,...i});return n&&this.add(n),n}get boundingClientRect(){return this.div.getBoundingClientRect()}#Pc(){const{x:t,y:e,width:i,height:s}=this.boundingClientRect,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.#Pc(),!0,t)}setSelected(t){this.#A.setSelected(t)}toggleSelected(t){this.#A.toggleSelected(t)}unselect(t){this.#A.unselect(t)}pointerup(t){const{isMac:e}=ft.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#gc)return;if(this.#gc=!1,this.#kc?.isDrawer&&this.#kc.supportMultipleDrawings)return;if(!this.#lc)return void(this.#lc=!0);const i=this.#A.getMode();i!==z.STAMP&&i!==z.POPUP&&i!==z.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#A.unselectAll()}pointerdown(t){if(this.#A.getMode()===z.HIGHLIGHT&&this.enableTextSelection(),this.#gc)return void(this.#gc=!1);const{isMac:e}=ft.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#gc=!0,this.#kc?.isDrawer)return void this.startDrawingSession(t);const i=this.#A.getActive();this.#lc=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#Ac)return void this.#kc.startDrawing(this,this.#A,!1,t);this.#A.setCurrentDrawingSession(this),this.#Ac=new AbortController;const e=this.#A.combinedSignal(this.#Ac);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#vc=null,this.commitOrRemove())}),{signal:e}),this.#kc.startDrawing(this,this.#A,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#vc=t)}else this.#vc&&setTimeout((()=>{this.#vc?.focus(),this.#vc=null}),0)}endDrawingSession(t=!1){return this.#Ac?(this.#A.setCurrentDrawingSession(null),this.#Ac.abort(),this.#Ac=null,this.#vc=null,this.#kc.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#A.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#Ac&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#Ac&&this.#kc.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#A.getActive()?.parent===this&&(this.#A.commitOrRemove(),this.#A.setActiveEditor(null)),this.#fc&&(clearTimeout(this.#fc),this.#fc=null);for(const t of this.#pc.values())this.#Ro?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#pc.clear(),this.#A.removeLayer(this)}#Sc(){for(const t of this.#pc.values())t.isEmpty()&&t.remove()}async render({viewport:t}){this.viewport=t,jt(this.div,t);for(const t of this.#A.getEditors(this.pageIndex))this.add(t),t.rebuild();await this.#A.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#A.commitOrRemove(),this.#Sc();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,jt(this.div,{rotation:i}),e!==i)for(const t of this.#pc.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#A.viewParameters.realScale}}class Ln{#so=null;#Dc=new Map;#Ic=new Map;static#E=0;setParent(t){if(this.#so){if(this.#so!==t){if(this.#Dc.size>0)for(const e of this.#Dc.values())e.remove(),t.append(e);this.#so=t}}else this.#so=t}static get _svgFactory(){return nt(this,"_svgFactory",new Fs)}static#Nc(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+"%"}#Rc(){const t=Ln._svgFactory.create(1,1,!0);return this.#so.append(t),t.setAttribute("aria-hidden",!0),t}#Oc(t,e){const i=Ln._svgFactory.createElement("clipPath");t.append(i);const s="clip_"+e;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=Ln._svgFactory.createElement("use");return i.append(n),n.setAttribute("href","#"+e),n.classList.add("clip"),s}#_c(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=Ln.#E++,n=this.#Rc(),r=Ln._svgFactory.createElement("defs");n.append(r);const o=Ln._svgFactory.createElement("path");r.append(o);const h="path_"+s;o.setAttribute("id",h),o.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#Ic.set(s,o);const a=i?this.#Oc(r,h):null,c=Ln._svgFactory.createElement("use");return n.append(c),c.setAttribute("href","#"+h),this.updateProperties(n,t),this.#Dc.set(s,n),{id:s,clipPathId:`url(#${a})`}}drawOutline(t,e){const i=Ln.#E++,s=this.#Rc(),n=Ln._svgFactory.createElement("defs");s.append(n);const r=Ln._svgFactory.createElement("path");n.append(r);const o="path_"+i;let h;if(r.setAttribute("id",o),r.setAttribute("vector-effect","non-scaling-stroke"),e){const t=Ln._svgFactory.createElement("mask");n.append(t),h="mask_"+i,t.setAttribute("id",h),t.setAttribute("maskUnits","objectBoundingBox");const e=Ln._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");const s=Ln._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=Ln._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.#Dc.set(i,s),i}finalizeDraw(t,e){this.#Ic.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.#Dc.get(t):t;if(o){if(i&&this.#_c(o,i),s&&Ln.#Nc(o,s),n){const{classList:t}=o;for(const[e,i]of Object.entries(n))t.toggle(e,i)}r&&this.#_c(o.firstElementChild.firstElementChild,r)}}updateParent(t,e){if(e===this)return;const i=this.#Dc.get(t);i&&(e.#so.append(i),this.#Dc.delete(t),e.#Dc.set(t,i))}remove(t){this.#Ic.delete(t),null!==this.#so&&(this.#Dc.get(t).remove(),this.#Dc.delete(t))}destroy(){this.#so=null;for(const t of this.#Dc.values())t.remove();this.#Dc.clear(),this.#Ic.clear()}}function Un(t){return(100*t).toFixed(2)+"%"}class $n{#Fc=[];#Bc=new Map;#Lc=null;#Uc=0;#Pn=0;#Tn=0;static#$c=null;constructor(t,e,i,s){this.#Uc=t,this.#Fc=e,this.#Pn=i.rawDims.pageWidth,this.#Tn=i.rawDims.pageHeight,this.#Lc=s}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#Fc.length;e+=6){const i=this.#jc(this.#Fc.subarray(e,e+6));i&&t.append(i)}return t.addEventListener("contextmenu",(t=>{if(!(t.target instanceof HTMLCanvasElement))return;const e=t.target,i=this.#Bc.get(e);if(!i)return;const s=$n.#$c?.deref();if(s===e)return;s&&(s.width=0,s.height=0),$n.#$c=new WeakRef(e);const{inverseTransform:n,x1:r,y1:o,width:h,height:a}=i,c=this.#Lc(),l=Math.ceil(r*c.width),u=Math.ceil(o*c.height),d=Math.floor((r+h/this.#Pn)*c.width),f=Math.floor((o+a/this.#Tn)*c.height);e.width=d-l,e.height=f-u;const p=e.getContext("2d");p.setTransform(...n),p.translate(-l,-u),p.drawImage(c,0,0)})),t}#jc([t,e,i,s,n,r]){const o=Math.hypot((n-t)*this.#Pn,(r-e)*this.#Tn),h=Math.hypot((i-t)*this.#Pn,(s-e)*this.#Tn);if(o<this.#Uc||h<this.#Uc)return null;const a=[(n-t)*this.#Pn/o,(r-e)*this.#Tn/o,(i-t)*this.#Pn/h,(s-e)*this.#Tn/h,0,0],c=pt.inverseTransform(a),l=document.createElement("canvas");return l.className="textLayerImagePlaceholder",l.width=0,l.height=0,Object.assign(l.style,{opacity:0,position:"absolute",left:Un(t),top:Un(e),width:Un(o/this.#Pn),height:Un(h/this.#Tn),transformOrigin:"0% 0%",transform:`matrix(${a.join(",")})`}),this.#Bc.set(l,{inverseTransform:c,width:o,height:h,x1:t,y1:e}),l}}globalThis._pdfjsTestingUtils={HighlightOutliner:bn},globalThis.pdfjsLib={AbortException:ut,AnnotationEditorLayer:Bn,AnnotationEditorParamsType:H,AnnotationEditorType:z,AnnotationEditorUIManager:he,AnnotationLayer:pn,AnnotationMode:$,AnnotationType:G,applyOpacity:function(t,e){const i=255*(1-(e=xt(e??1,0,1)));return t.map((t=>Math.round(t*e+i)))},build:"7e5b36c2d",ColorPicker:Ds,createValidAbsoluteUrl:et,CSSConstants:class{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:i}=window.getComputedStyle(t);return t.remove(),nt(this,"commentForegroundColor",Lt(i))}},DOMSVGFactory:Fs,DrawLayer:Ln,FeatureTest:ft,fetchData:kt,findContrastColor:function(t,e){const i=t[0]+256*t[1]+65536*t[2]+16777216*e[0]+4294967296*e[1]+1099511627776*e[2];let s=qt.get(i);if(s)return s;const n=new Float32Array(9),r=n.subarray(0,3),o=n.subarray(3,6);Gt(t,o);const h=n.subarray(6,9);Gt(e,h);const a=h[2]<.5,c=a?12:4.5;if(o[2]=a?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),Xt(o,h,r)<c){let t,e;a?(t=o[2],e=1):(t=0,e=o[2]);const i=.005;for(;e-t>i;){const i=o[2]=(t+e)/2;a===Xt(o,h,r)<c?t=i:e=i}o[2]=a?e:t}return Vt(o,r),s=pt.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2])),qt.set(i,s),s},getDocument:ys,getFilenameFromUrl:function(t){return[t]=t.split(/[#?]/,1),st(t)},getPdfFilenameFromUrl:function(t,e="document.pdf"){if("string"!=typeof t)return e;if(Dt(t))return J('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!i)return e;const s=t=>{try{let e=decodeURIComponent(t);return e.includes("/")&&(e=st(e),/^\.pdf$/i.test(e))?t:e}catch{return t}},n=/\.pdf$/i,r=st(i.pathname);if(n.test(r))return s(r);if(i.searchParams.size>0){const t=t=>[...t].findLast((t=>n.test(t))),e=t(i.searchParams.values())??t(i.searchParams.keys());if(e)return s(e)}if(i.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return s(t[0])}return e},getRGB:Lt,getRGBA:Bt,getUuid:wt,getXfaPageViewport:function(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style;return new Tt({viewBox:[0,0,parseInt(s,10),parseInt(n,10)],userUnit:1,scale:e,rotation:i})},GlobalWorkerOptions:us,ImageKind:W,InvalidPDFException:at,isDataScheme:Dt,isPdfFile:It,isValidExplicitDest:Ke,makeArr:vt,makeMap:bt,makeObj:yt,MathClamp:xt,noContextMenu:Ot,normalizeUnicode:function(t){return gt||(gt=/([\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,mt=new Map([["ſt","ſt"]])),t.replaceAll(gt,((t,e,i)=>e?e.normalize("NFKC"):mt.get(i)))},OPS:Y,OutputScale:zt,PasswordResponses:{NEED_PASSWORD:1,INCORRECT_PASSWORD:2},PDFDataRangeTransport:Ms,PDFDateString:Ft,PDFWorker:Es,PermissionFlag:{PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},PixelsPerInch:Et,RenderingCancelledException:Pt,renderRichText:Qt,ResponseException:ct,setLayerDimensions:jt,shadow:nt,SignatureExtractor:Nn,stopEvent:_t,SupportedImageMimeTypes:Ht,TextLayer:bs,TextLayerImages:$n,TouchManager:le,updateUrlHash:it,Util:pt,VerbosityLevel:V,version:"5.7.284",XfaLayer:St},function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+e+" is not a constructor or null");function i(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}((function e(i){var s=t.call(this,"Validation error mapping object.")||this;return s.errors=i,Object.setPrototypeOf(s,e.prototype),s}),t)}(Error);var jn=function(){function t(){this.listeners=[]}return t.prototype.on=function(t,e){var i,s=this;void 0===e&&(e={}),this.listeners.push(t);var n=new AbortController;return n.signal.addEventListener("abort",(function(){return s.off(t)})),null===(i=e.abort)||void 0===i||i.addEventListener("abort",(function(){return n.abort()})),{dispose:function(){return n.abort()}}},t.prototype.once=function(t){var e=this;return void 0===t&&(t={}),new Promise((function(i){var s=e.on((function(t){s.dispose(),i(t)}),t)}))},t.prototype.onceWhen=function(t){return function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{a(s.next(t))}catch(t){r(t)}}function h(t){try{a(s.throw(t))}catch(t){r(t)}}function a(t){t.done?n(t.value):function(t){return t instanceof i?t:new i((function(e){e(t)}))}(t.value).then(o,h)}a((s=s.apply(t,e||[])).next())}))}(this,arguments,Promise,(function(t,e){var i,s,n=this;return void 0===e&&(e={}),function(t,e){var i,s,n,r={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=h(0),o.throw=h(1),o.return=h(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function h(h){return function(a){return function(h){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(r=0)),r;)try{if(i=1,s&&(n=2&h[0]?s.return:h[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,h[1])).done)return n;switch(s=0,n&&(h=[2&h[0],n.value]),h[0]){case 0:case 1:n=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,s=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(!((n=(n=r.trys).length>0&&n[n.length-1])||6!==h[0]&&2!==h[0])){r=0;continue}if(3===h[0]&&(!n||h[1]>n[0]&&h[1]<n[3])){r.label=h[1];break}if(6===h[0]&&r.label<n[1]){r.label=n[1],n=h;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(h);break}n[2]&&r.ops.pop(),r.trys.pop();continue}h=e.call(t,r)}catch(t){h=[6,t],s=0}finally{i=n=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([h,a])}}}(this,(function(){return i=new AbortController,null===(s=e.abort)||void 0===s||s.addEventListener("abort",(function(){return i.abort()})),[2,new Promise((function(s){n.when(t,(function(e){t(e)&&(i.abort(),s(e))}),a(a({},e),{abort:i.signal}))}))]}))}))},t.prototype.when=function(t,e,i){return void 0===i&&(i={}),this.on((function(i){t(i)&&e(i)}),i)},t.prototype.off=function(t){var e=this.listeners.indexOf(t);-1!==e&&this.listeners.splice(e,1)},t.prototype.emit=function(t){this.listeners.forEach((function(e){return e(t)}))},t}();class zn{constructor(t){this.defaultState=t,this.stateChanged=new jn,this.state=t}updateState(t){this.state={...this.defaultState,...this.state,...t},this.stateChanged.emit(this.state)}onStateChanged(t){return this.stateChanged.on(t)}async updateViewport(t){null!=this.state.viewport&&E.isEqual(this.state.viewport,t)||this.updateState({viewport:t})}async panByDelta(t){const e=this.constrainPanOffset(m.add(this.state.panOffset,t),this.state.zoomPercentage);this.updateState({panOffset:e})}async zoomTo(t){const{viewport:e,zoomPercentage:i,panOffset:s}=this.state;if(null==e)throw Error("Viewport is not defined. Unable to perform zoom operation.");{const n=Math.min(Math.max(10,t),600),r=n/i,o=m.add(m.scaleProportional(E.center(e),1-r),m.scaleProportional(s,r)),h=this.constrainPanOffset(o,n);this.updateState({zoomPercentage:n,panOffset:h})}}constrainPanOffset(t,e){const{viewport:i,contentDimensions:s}=this.state;if(null!=i&&null!=s){const n=E.scale(window.devicePixelRatio,window.devicePixelRatio,i),r=Math.min(n.width/s.width,n.height/s.height),o=s.height*r*(e/100),h=Math.min(0,n.width-s.width*r*(e/100)),a=Math.min(0,n.height-o),c=0;return m.create(Math.max(h,Math.min(0,t.x)),Math.max(a,Math.min(c,t.y)))}return t}}class Hn extends zn{constructor(t){var e;super({panOffset:m.create(0,0),zoomPercentage:100}),this.config=t,us.workerSrc=null!==(e=null==t?void 0:t.pdfJs.workerSrc)&&void 0!==e?e:"./assets/pdf.worker.min.mjs"}dispose(){var t;null===(t=this.state.document)||void 0===t||t.destroy()}async load(t){const e=function(t){if(t.startsWith("http"))return function(t){return{resource:{type:"url",url:t}}}(t);throw Error("Invalid URI. Provided URI must be a valid URL or URN.")}(t);if("url"!==e.resource.type)throw Error("Invalid resource URI provided. Expected a URL to retrieve a PDF.");{const t=await ys(e.resource.url).promise,i=await t.getOptionalContentConfig();this.updateState({document:t,totalPageCount:t.numPages,optionalContentConfig:i,layers:Array.from(i).map((([t,e])=>{var i;return{id:t,name:null!==(i=e.name)&&void 0!==i?i:t,visible:e.visible}}))})}}async loadPage(t){var e,i;const s=null!==(e=this.state.totalPageCount)&&void 0!==e?e:1;if(t<=0)throw Error(`Unable to load page ${t}. The provided page number must be greater than 0.`);if(t>s)throw Error(`Unable to load page ${t}. The document only has ${s} page(s).`);const n=await(null===(i=this.state.document)||void 0===i?void 0:i.getPage(t)),r=null==n?void 0:n.getViewport({scale:1}),o=null!=r?E.create(r.width,r.height):void 0;this.updateState({loadedPageNumber:t,contentDimensions:o,panOffset:m.create(0,0)})}getLayers(){var t;return null!==(t=this.state.layers)&&void 0!==t?t:[]}setLayerVisibility(t,e){const{optionalContentConfig:i}=this.state;if(null==i)throw Error("No document has been loaded. Unable to set layer visibility.");i.setVisibility(t,e),this.updateState({optionalContentConfig:i,layers:Array.from(i).map((([t,e])=>{var i;return{id:t,name:null!==(i=e.name)&&void 0!==i?i:t,visible:e.visible}}))})}}class Wn{constructor(t,e){this.api=t,this.canvas=e,this.pageLoaded=new jn,this.pageDrawn=new jn}onPageLoaded(t){return this.pageLoaded.on(t)}onPageDrawn(t){return this.pageDrawn.on(t)}}class Gn extends Wn{constructor(t,e){super(t,e),this.state={pages:{},rendering:!1},this.offscreenCanvas=document.createElement("canvas"),this.handleStateChanged=this.handleStateChanged.bind(this),this.stateChangedDisposable=this.api.onStateChanged(this.handleStateChanged)}dispose(){this.stateChangedDisposable.dispose()}async handleStateChanged(t){await this.renderPage(t)}async renderPage(t){const{document:e,loadedPageNumber:i,viewport:s,panOffset:n,zoomPercentage:r,optionalContentConfig:o}=t;if(this.state.rendering)this.state.pendingStateChange=t;else if(null!=e&&null!=i){this.state.rendering=!0,null==this.state.pages[i]&&(this.state.pages[i]=await e.getPage(i));const h=this.state.pages[i],a=null!=s?s:E.create(0,0),c=E.scale(window.devicePixelRatio,window.devicePixelRatio,a),l=h.getViewport({scale:1}),u=Math.max(.1,Math.min(c.width/l.width,c.height/l.height))*(r/100),d=h.getViewport({scale:u,offsetX:n.x+Math.max(0,(c.width-l.width*u)/2),offsetY:n.y});this.offscreenCanvas.width=this.canvas.width,this.offscreenCanvas.height=this.canvas.height,await h.render({canvas:this.offscreenCanvas,viewport:d,intent:"display",optionalContentConfigPromise:null!=o?Promise.resolve(o):void 0}).promise,this.pageLoaded.emit(t),await new Promise((t=>{window.requestAnimationFrame((()=>{const e=this.canvas.getContext("2d");null!=e&&(e.clearRect(0,0,this.canvas.width,this.canvas.height),e.drawImage(this.offscreenCanvas,0,0)),t()}))})),this.pageDrawn.emit(t),this.state.rendering=!1}}}class Vn{create(t,e){const i=new Hn(e);return{api:i,renderer:new Gn(i,t)}}}const Yn=e(class extends i{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.documentReady=s(this,"documentReady"),this.documentStateChanged=s(this,"documentStateChanged"),this.pageLoaded=s(this,"pageLoaded"),this.pageDrawn=s(this,"pageDrawn"),this.provider=new Vn,this.interactionMode="pan",this.resizeDebounce=100,this.dimensions=E.create(0,0)}componentWillLoad(){this.handleElementResize=this.handleElementResize.bind(this),this.handleDocumentApiStateChanged=this.handleDocumentApiStateChanged.bind(this),this.handlePageLoaded=this.handlePageLoaded.bind(this),this.handlePageDrawn=this.handlePageDrawn.bind(this),this.resizeObserver=new ResizeObserver(this.handleElementResize)}componentShouldUpdate(t,e,i){return"documentState"!==i}componentDidLoad(){var t;null===(t=this.resizeObserver)||void 0===t||t.observe(this.hostEl),this.updateComponentDimensions(),this.handleSrcChange()}disconnectedCallback(){var t;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),this.clearCurrentDocument()}async panByDelta(t){await this.getDocumentApi().panByDelta(t)}async zoomTo(t){await this.getDocumentApi().zoomTo(t)}async loadPage(t){const e=this.getDocumentApi();await e.loadPage(t)}async handleSrcChange(){if(null!=this.src&&null!=this.canvasEl){this.clearCurrentDocument();const{api:t,renderer:e}=this.provider.create(this.canvasEl,this.config);this.documentApi=t,this.documentRenderer=e,this.layers=new D(t),this.updateInteractionHandler(),this.updateDocumentApiListeners(),await this.documentApi.updateViewport(this.dimensions),await this.documentApi.load(this.src),await this.documentApi.loadPage(1),this.documentReady.emit()}}handleConfigChange(){this.clearCurrentDocument(),this.handleSrcChange()}handleInteractionModeChange(){this.updateInteractionHandler()}render(){return n(r,{key:"9ebb0012f2edde7189b42f35fd2ecefb779b16ef"},n("div",{key:"ef52dd8c6367213d173f3847ff65deac1da6620e",ref:t=>this.viewerContainerElement=t,class:"viewer-container",onContextMenu:t=>t.preventDefault()},n("div",{key:"db0bede43e0798c1c8097f8079d1bbf4bea3fe15",ref:t=>this.canvasContainerElement=t,class:P("canvas-container",{"enable-pointer-events ":null!=window.PointerEvent})},n("canvas",{key:"3a705edd1985b11256e565880298a729a5e7260b",role:"presentation",ref:t=>this.canvasEl=t})),n("slot",{key:"9ccb82cc0493342c4e4caf7188c23ad8a55ca93b"})))}getDocumentApi(){if(null==this.documentApi)throw Error("No document has been loaded. Ensure that the `src` property is set and the resource is accessible.");return this.documentApi}clearCurrentDocument(){var t,e,i,s,n,r;null===(t=this.documentRenderer)||void 0===t||t.dispose(),null===(e=this.documentApi)||void 0===e||e.dispose(),null===(i=this.panInteractionHandler)||void 0===i||i.dispose(),null===(s=this.documentApiStateChangedDisposable)||void 0===s||s.dispose(),null===(n=this.pageLoadedDisposable)||void 0===n||n.dispose(),null===(r=this.pageDrawnDisposable)||void 0===r||r.dispose(),this.layers=void 0}handleDocumentApiStateChanged(t){this.documentState=t,this.documentStateChanged.emit(t)}handlePageLoaded(t){this.pageLoaded.emit(t)}handlePageDrawn(t){this.pageDrawn.emit(t)}updateDocumentApiListeners(){var t,e,i;this.documentApiStateChangedDisposable=null===(t=this.documentApi)||void 0===t?void 0:t.onStateChanged(this.handleDocumentApiStateChanged),this.pageLoadedDisposable=null===(e=this.documentRenderer)||void 0===e?void 0:e.onPageLoaded(this.handlePageLoaded),this.pageDrawnDisposable=null===(i=this.documentRenderer)||void 0===i?void 0:i.onPageDrawn(this.handlePageDrawn)}updateInteractionHandler(){var t;null===(t=this.panInteractionHandler)||void 0===t||t.dispose(),"pan"===this.interactionMode&&null!=this.canvasEl&&null!=this.documentApi&&(this.panInteractionHandler=new I(this.canvasEl,this.documentApi))}updateComponentDimensions(t){this.dimensions=null!=t?t:function(t){return t.getBoundingClientRect()}(this.hostEl),null!=this.canvasEl&&(this.canvasEl.width=Math.floor(this.dimensions.width*window.devicePixelRatio),this.canvasEl.height=Math.floor(this.dimensions.height*window.devicePixelRatio),this.canvasEl.style.width=this.dimensions.width+"px",this.canvasEl.style.height=this.dimensions.height+"px")}async handleElementResize(t){t.length>0&&null!=this.dimensions&&!E.isEqual(t[0].contentRect,this.dimensions)&&this.restartResizeTimer(E.create(t[0].contentRect.width,t[0].contentRect.height))}restartResizeTimer(t){null!=this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((async()=>{var e;this.updateComponentDimensions(t),await(null===(e=this.documentApi)||void 0===e?void 0:e.updateViewport(this.dimensions))}),this.resizeDebounce)}get hostEl(){return this}static get watchers(){return{src:[{handleSrcChange:0}],config:[{handleConfigChange:0}],interactionMode:[{handleInteractionModeChange:0}]}}static get style(){return":host{display:block;position:relative;width:300px;height:300px;min-width:1px;min-height:1px;user-select:none;-webkit-user-select:none}.viewer-container{width:100%;height:100%;overflow:hidden}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative}"}},[257,"vertex-document-viewer",{src:[1],documentId:[513,"document-id"],provider:[1040],interactionMode:[1,"interaction-mode"],documentState:[1040],layers:[1040],config:[16],resizeDebounce:[2,"resize-debounce"],panByDelta:[64],zoomTo:[64],loadPage:[64]},void 0,{src:[{handleSrcChange:0}],config:[{handleConfigChange:0}],interactionMode:[{handleInteractionModeChange:0}]}]);function Xn(){"undefined"!=typeof customElements&&["vertex-document-viewer"].forEach((e=>{"vertex-document-viewer"===e&&(customElements.get(t(e))||customElements.define(t(e),Yn))}))}Xn();const qn=Yn,Qn=Xn;export{qn as VertexDocumentViewer,Qn as defineCustomElement}
|
|
25
|
+
*/var N={9306(t,i,e){var s=e(4901),n=e(6823),r=TypeError;t.exports=function(t){if(s(t))return t;throw new r(n(t)+" is not a function")}},3506(t,i,e){var s=e(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")}},7080(t,i,e){var s=e(4402).has;t.exports=function(t){return s(t),t}},3463(t){var i=TypeError;t.exports=function(t){if("string"==typeof t)return t;throw new i("Argument is not a string")}},4328(t,i,e){var s=e(4995),n=new s.WeakMap,r=s.set,o=s.remove;t.exports=function(t){return r(n,t,1),o(n,t),t}},6557(t,i,e){var s=e(4995).has;t.exports=function(t){return s(t),t}},6469(t,i,e){var s=e(608),n=e(2360),r=e(4913).f,o=s("unscopables"),h=Array.prototype;void 0===h[o]&&r(h,o,{configurable:!0,value:n(null)}),t.exports=function(t){h[o][t]=!0}},679(t,i,e){var s=e(1625),n=TypeError;t.exports=function(t,i){if(s(i,t))return t;throw new n("Incorrect invocation")}},3972(t,i,e){var s=e(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")}},8551(t,i,e){var s=e(34),n=String,r=TypeError;t.exports=function(t){if(s(t))return t;throw new r(n(t)+" is not an object")}},4154(t,i,e){var s=e(6955),n=TypeError;t.exports=function(t){if("Uint8Array"===s(t))return t;throw new n("Argument is not an Uint8Array")}},7811(t){t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},7394(t,i,e){var s=e(4576),n=e(6706),r=e(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}},3238(t,i,e){var s=e(4576),n=e(7811),r=e(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}}},5169(t,i,e){var s=e(3238),n=TypeError;t.exports=function(t){if(s(t))throw new n("ArrayBuffer is detached");return t}},5636(t,i,e){var s=e(4576),n=e(9504),r=e(6706),o=e(7696),h=e(5169),a=e(7394),c=e(4483),l=e(1548),u=s.structuredClone,d=s.ArrayBuffer,f=s.DataView,p=Math.max,g=Math.min,m=d.prototype,w=f.prototype,A=n(m.slice),v=r(m,"resizable","get"),b=r(m,"maxByteLength","get"),y=n(w.getInt8),x=n(w.setInt8);t.exports=(l||c)&&function(t,i,e){var s,n=a(t),r=void 0===i?n:o(i),m=!v||!v(t);if(h(t),l&&(t=u(t,{transfer:[t]}),n===r&&(e||m)))return t;if(n>=r&&(!e||m))s=A(t,0,r);else{var w=e&&!m&&b?{maxByteLength:p(r,b(t))}:void 0;s=new d(r,w);for(var M=new f(t),S=new f(s),C=g(r,n),E=0;E<C;E++)x(S,E,y(M,E))}return l||c(t),s}},4644(t,i,e){var s,n,r,o=e(7811),h=e(3724),a=e(4576),c=e(4901),l=e(34),u=e(9297),d=e(6955),f=e(6823),p=e(6699),g=e(6840),m=e(2106),w=e(1625),A=e(2787),v=e(2967),b=e(608),y=e(3392),x=e(1181),M=x.enforce,S=x.get,C=a.Int8Array,E=C&&C.prototype,k=a.Uint8ClampedArray,T=k&&k.prototype,P=C&&A(C),D=E&&A(E),I=Object.prototype,R=a.TypeError,N=b("toStringTag"),O=y("TYPED_ARRAY_TAG"),_="TypedArrayConstructor",F=o&&!!v&&"Opera"!==d(a.opera),B=!1,L={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},U={BigInt64Array:8,BigUint64Array:8},$=function(t){var i=A(t);if(l(i)){var e=S(i);return e&&u(e,_)?e[_]:$(i)}},j=function(t){if(!l(t))return!1;var i=d(t);return u(L,i)||u(U,i)};for(s in L)(r=(n=a[s])&&n.prototype)?M(r)[_]=n:F=!1;for(s in U)(r=(n=a[s])&&n.prototype)&&(M(r)[_]=n);if((!F||!c(P)||P===Function.prototype)&&(P=function(){throw new R("Incorrect invocation")},F))for(s in L)a[s]&&v(a[s],P);if((!F||!D||D===I)&&(D=P.prototype,F))for(s in L)a[s]&&v(a[s].prototype,D);if(F&&A(T)!==D&&v(T,D),h&&!u(D,N))for(s in B=!0,m(D,N,{configurable:!0,get:function(){return l(this)?this[O]:void 0}}),L)a[s]&&p(a[s].prototype,O,s);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:F,TYPED_ARRAY_TAG:B&&O,aTypedArray:function(t){if(j(t))return t;throw new R("Target is not a typed array")},aTypedArrayConstructor:function(t){if(c(t)&&(!v||w(P,t)))return t;throw new R(f(t)+" is not a typed array constructor")},exportTypedArrayMethod:function(t,i,e,s){if(h){if(e)for(var n in L){var r=a[n];if(r&&u(r.prototype,t))try{delete r.prototype[t]}catch(e){try{r.prototype[t]=i}catch(t){}}}D[t]&&!e||g(D,t,e?i:F&&E[t]||i,s)}},exportTypedArrayStaticMethod:function(t,i,e){var s,n;if(h){if(v){if(e)for(s in L)if((n=a[s])&&u(n,t))try{delete n[t]}catch(t){}if(P[t]&&!e)return;try{return g(P,t,e?i:F&&P[t]||i)}catch(t){}}for(s in L)!(n=a[s])||n[t]&&!e||g(n,t,i)}},getTypedArrayConstructor:$,isView:function(t){if(!l(t))return!1;var i=d(t);return"DataView"===i||u(L,i)||u(U,i)},isTypedArray:j,TypedArray:P,TypedArrayPrototype:D}},5370(t,i,e){var s=e(6198);t.exports=function(t,i,e){for(var n=0,r=arguments.length>2?e:s(i),o=new t(r);r>n;)o[n]=i[n++];return o}},9617(t,i,e){var s=e(5397),n=e(5610),r=e(6198),o=function(t){return function(i,e,o){var h=s(i),a=r(h);if(0===a)return!t&&-1;var c,l=n(o,a);if(t&&e!=e){for(;a>l;)if((c=h[l++])!=c)return!0}else for(;a>l;l++)if((t||l in h)&&h[l]===e)return t||l||0;return!t&&-1}};t.exports={includes:o(!0),indexOf:o(!1)}},4527(t,i,e){var s=e(3724),n=e(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,i){if(n(t)&&!o(t,"length").writable)throw new r("Cannot set read only .length");return t.length=i}:function(t,i){return t.length=i}},7680(t,i,e){var s=e(9504);t.exports=s([].slice)},2804(t){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=i+"+/",s=i+"-_",n=function(t){for(var i={},e=0;e<64;e++)i[t.charAt(e)]=e;return i};t.exports={i2c:e,c2i:n(e),i2cUrl:s,c2iUrl:n(s)}},6319(t,i,e){var s=e(8551),n=e(9539);t.exports=function(t,i,e,r){try{return r?i(s(e)[0],e[1]):i(e)}catch(i){n(t,"throw",i)}}},2195(t,i,e){var s=e(9504),n=s({}.toString),r=s("".slice);t.exports=function(t){return r(n(t),8,-1)}},6955(t,i,e){var s=e(2140),n=e(4901),r=e(2195),o=e(608)("toStringTag"),h=Object,a="Arguments"===r(function(){return arguments}());t.exports=s?r:function(t){var i,e,s;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=function(t,i){try{return t[i]}catch(t){}}(i=h(t),o))?e:a?r(i):"Object"===(s=r(i))&&n(i.callee)?"Arguments":s}},7740(t,i,e){var s=e(9297),n=e(5031),r=e(7347),o=e(4913);t.exports=function(t,i,e){for(var h=n(i),a=o.f,c=r.f,l=0;l<h.length;l++){var u=h[l];s(t,u)||e&&s(e,u)||a(t,u,c(i,u))}}},2211(t,i,e){var s=e(9039);t.exports=!s((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}))},2529(t){t.exports=function(t,i){return{value:t,done:i}}},6699(t,i,e){var s=e(3724),n=e(4913),r=e(6980);t.exports=s?function(t,i,e){return n.f(t,i,r(1,e))}:function(t,i,e){return t[i]=e,t}},6980(t){t.exports=function(t,i){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:i}}},4659(t,i,e){var s=e(3724),n=e(4913),r=e(6980);t.exports=function(t,i,e){s?n.f(t,i,r(0,e)):t[i]=e}},2106(t,i,e){var s=e(283),n=e(4913);t.exports=function(t,i,e){return e.get&&s(e.get,i,{getter:!0}),e.set&&s(e.set,i,{setter:!0}),n.f(t,i,e)}},6840(t,i,e){var s=e(4901),n=e(4913),r=e(283),o=e(9433);t.exports=function(t,i,e,h){h||(h={});var a=h.enumerable,c=void 0!==h.name?h.name:i;if(s(e)&&r(e,c,h),h.global)a?t[i]=e:o(i,e);else{try{h.unsafe?t[i]&&(a=!0):delete t[i]}catch(t){}a?t[i]=e:n.f(t,i,{value:e,enumerable:!1,configurable:!h.nonConfigurable,writable:!h.nonWritable})}return t}},6279(t,i,e){var s=e(6840);t.exports=function(t,i,e){for(var n in i)s(t,n,i[n],e);return t}},9433(t,i,e){var s=e(4576),n=Object.defineProperty;t.exports=function(t,i){try{n(s,t,{value:i,configurable:!0,writable:!0})}catch(e){s[t]=i}return i}},3724(t,i,e){var s=e(9039);t.exports=!s((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))},4483(t,i,e){var s,n,r,o,h=e(4576),a=e(9429),c=e(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},4055(t,i,e){var s=e(4576),n=e(34),r=s.document,o=n(r)&&n(r.createElement);t.exports=function(t){return o?r.createElement(t):{}}},6837(t){var i=TypeError;t.exports=function(t){if(t>9007199254740991)throw new i("Maximum allowed index exceeded");return t}},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}}},8727(t){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},6193(t,i,e){var s=e(4215);t.exports="NODE"===s},2839(t,i,e){var s=e(4576).navigator,n=s&&s.userAgent;t.exports=n?n+"":""},9519(t,i,e){var s,n,r=e(4576),o=e(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},4215(t,i,e){var s=e(4576),n=e(2839),r=e(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"},8574(t,i,e){var s=e(9504),n=Error,r=s("".replace),o=new n("zxcasd").stack+"",h=/\n\s*at [^:]*:[^\n]*/,a=h.test(o);t.exports=function(t,i){if(a&&"string"==typeof t&&!n.prepareStackTrace)for(;i--;)t=r(t,h,"");return t}},6518(t,i,e){var s=e(4576),n=e(7347).f,r=e(6699),o=e(6840),h=e(9433),a=e(7740),c=e(2796);t.exports=function(t,i){var e,l,u,d,f,p=t.target,g=t.global,m=t.stat;if(e=g?s:m?s[p]||h(p,{}):s[p]&&s[p].prototype)for(l in i){if(d=i[l],u=t.dontCallGetSet?(f=n(e,l))&&f.value:e[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(e,l,d,t)}}},9039(t){t.exports=function(t){try{return!!t()}catch(t){return!0}}},8745(t,i,e){var s=e(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)})},6080(t,i,e){var s=e(7476),n=e(9306),r=e(616),o=s(s.bind);t.exports=function(t,i){return n(t),void 0===i?t:r?o(t,i):function(){return t.apply(i,arguments)}}},616(t,i,e){var s=e(9039);t.exports=!s((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},9565(t,i,e){var s=e(616),n=Function.prototype.call;t.exports=s?n.bind(n):function(){return n.apply(n,arguments)}},350(t,i,e){var s=e(3724),n=e(9297),r=Function.prototype,o=s&&Object.getOwnPropertyDescriptor,h=n(r,"name"),a=h&&!1,c=h&&(!s||s&&o(r,"name").configurable);t.exports={EXISTS:h,PROPER:a,CONFIGURABLE:c}},6706(t,i,e){var s=e(9504),n=e(9306);t.exports=function(t,i,e){try{return s(n(Object.getOwnPropertyDescriptor(t,i)[e]))}catch(t){}}},7476(t,i,e){var s=e(2195),n=e(9504);t.exports=function(t){if("Function"===s(t))return n(t)}},9504(t,i,e){var s=e(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)}}},944(t){var i=TypeError;t.exports=function(t){var e=t&&t.alphabet;if(void 0===e||"base64"===e||"base64url"===e)return e||"base64";throw new i("Incorrect `alphabet` option")}},9429(t,i,e){var s=e(4576),n=e(6193);t.exports=function(t){if(n){try{return s.process.getBuiltinModule(t)}catch(t){}try{return Function('return require("'+t+'")')()}catch(t){}}}},7751(t,i,e){var s=e(4576),n=e(4901);t.exports=function(t,i){return arguments.length<2?function(t){return n(t)?t:void 0}(s[t]):s[t]&&s[t][i]}},1767(t){t.exports=function(t){return{iterator:t,next:t.next,done:!1}}},8646(t,i,e){var s=e(9565),n=e(8551),r=e(1767),o=e(851);t.exports=function(t,i){i&&"string"==typeof t||n(t);var e=o(t);return r(n(void 0!==e?s(e,t):t))}},851(t,i,e){var s=e(6955),n=e(5966),r=e(4117),o=e(6269),h=e(608)("iterator");t.exports=function(t){if(!r(t))return n(t,h)||n(t,"@@iterator")||o[s(t)]}},81(t,i,e){var s=e(9565),n=e(9306),r=e(8551),o=e(6823),h=e(851),a=TypeError;t.exports=function(t,i){var e=arguments.length<2?h(t):i;if(n(e))return r(s(e,t));throw new a(o(t)+" is not iterable")}},5966(t,i,e){var s=e(9306),n=e(4117);t.exports=function(t,i){var e=t[i];return n(e)?void 0:s(e)}},3789(t,i,e){var s=e(9306),n=e(8551),r=e(9565),o=e(1291),h=e(1767),a="Invalid size",c=RangeError,l=TypeError,u=Math.max,d=function(t,i){this.set=t,this.size=u(i,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 i=+t.size;if(i!=i)throw new l(a);var e=o(i);if(e<0)throw new c(a);return new d(t,e)}},4576(t){var i=function(t){return t&&t.Math===Math&&t};t.exports=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof global&&global)||i("object"==typeof this&&this)||function(){return this}()||Function("return this")()},9297(t,i,e){var s=e(9504),n=e(8981),r=s({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,i){return r(n(t),i)}},421(t){t.exports={}},397(t,i,e){var s=e(7751);t.exports=s("document","documentElement")},5917(t,i,e){var s=e(3724),n=e(9039),r=e(4055);t.exports=!s&&!n((function(){return 7!==Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))},7055(t,i,e){var s=e(9504),n=e(9039),r=e(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},3167(t,i,e){var s=e(4901),n=e(34),r=e(2967);t.exports=function(t,i,e){var o,h;return r&&s(o=i.constructor)&&o!==e&&n(h=o.prototype)&&h!==e.prototype&&r(t,h),t}},3706(t,i,e){var s=e(9504),n=e(4901),r=e(7629),o=s(Function.toString);n(r.inspectSource)||(r.inspectSource=function(t){return o(t)}),t.exports=r.inspectSource},1181(t,i,e){var s,n,r,o=e(8622),h=e(4576),a=e(34),c=e(6699),l=e(9297),u=e(7629),d=e(6119),f=e(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,i){if(m.has(t))throw new g(p);return i.facade=t,m.set(t,i),i},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,i){if(l(t,w))throw new g(p);return i.facade=t,c(t,w,i),i},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(i){var e;if(!a(i)||(e=n(i)).type!==t)throw new g("Incompatible receiver, "+t+" required");return e}}}},4209(t,i,e){var s=e(608),n=e(6269),r=s("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(n.Array===t||o[r]===t)}},4376(t,i,e){var s=e(2195);t.exports=Array.isArray||function(t){return"Array"===s(t)}},1108(t,i,e){var s=e(6955);t.exports=function(t){var i=s(t);return"BigInt64Array"===i||"BigUint64Array"===i}},4901(t){var i="object"==typeof document&&document.all;t.exports=void 0===i&&void 0!==i?function(t){return"function"==typeof t||t===i}:function(t){return"function"==typeof t}},2796(t,i,e){var s=e(9039),n=e(4901),r=/#|\.prototype\./,o=function(t,i){var e=a[h(t)];return e===l||e!==c&&(n(i)?s(i):!!i)},h=o.normalize=function(t){return(t+"").replace(r,".").toLowerCase()},a=o.data={},c=o.NATIVE="N",l=o.POLYFILL="P";t.exports=o},4117(t){t.exports=function(t){return null==t}},34(t,i,e){var s=e(4901);t.exports=function(t){return"object"==typeof t?null!==t:s(t)}},3925(t,i,e){var s=e(34);t.exports=function(t){return s(t)||null===t}},6395(t){t.exports=!1},5810(t,i,e){var s=e(34),n=e(1181).get;t.exports=function(t){if(!s(t))return!1;var i=n(t);return!!i&&"RawJSON"===i.type}},757(t,i,e){var s=e(7751),n=e(4901),r=e(1625),o=e(7040),h=Object;t.exports=o?function(t){return"symbol"==typeof t}:function(t){var i=s("Symbol");return n(i)&&r(i.prototype,h(t))}},507(t,i,e){var s=e(9565);t.exports=function(t,i,e){for(var n,r,o=e?t:t.iterator,h=t.next;!(n=s(h,o)).done;)if(void 0!==(r=i(n.value)))return r}},2652(t,i,e){var s=e(6080),n=e(9565),r=e(8551),o=e(6823),h=e(4209),a=e(6198),c=e(1625),l=e(81),u=e(851),d=e(9539),f=TypeError,p=function(t,i){this.stopped=t,this.result=i},g=p.prototype;t.exports=function(t,i,e){var m,w,A,v,b,y,x,M=!(!e||!e.AS_ENTRIES),S=!(!e||!e.IS_RECORD),C=!(!e||!e.IS_ITERATOR),E=!(!e||!e.INTERRUPTED),k=s(i,e&&e.that),T=function(t){var i=m;return m=void 0,i&&d(i,"normal"),new p(!0,t)},P=function(t){return M?(r(t),E?k(t[0],t[1],T):k(t[0],t[1])):E?k(t,T):k(t)};if(S)m=t.iterator;else if(C)m=t;else{if(!(w=u(t)))throw new f(o(t)+" is not iterable");if(h(w)){for(A=0,v=a(t);v>A;A++)if((b=P(t[A]))&&c(g,b))return b;return new p(!1)}m=l(t,w)}for(y=S?t.next:m.next;!(x=n(y,m)).done;){var D=x.value;try{b=P(D)}catch(t){if(!m)throw t;d(m,"throw",t)}if("object"==typeof b&&b&&c(g,b))return b}return new p(!1)}},1385(t,i,e){var s=e(9539);t.exports=function(t,i,e){for(var n=t.length-1;n>=0;n--)if(void 0!==t[n])try{e=s(t[n].iterator,i,e)}catch(t){i="throw",e=t}if("throw"===i)throw e;return e}},9539(t,i,e){var s=e(9565),n=e(8551),r=e(5966);t.exports=function(t,i,e){var o,h;n(t);try{if(!(o=r(t,"return"))){if("throw"===i)throw e;return e}o=s(o,t)}catch(t){h=!0,o=t}if("throw"===i)throw e;if(h)throw o;return n(o),e}},9462(t,i,e){var s=e(9565),n=e(2360),r=e(6699),o=e(6279),h=e(608),a=e(1181),c=e(5966),l=e(7657).IteratorPrototype,u=e(2529),d=e(9539),f=e(1385),p=h("toStringTag"),g="IteratorHelper",m="WrapForValidIterator",w="normal",A="throw",v=a.set,b=function(t){var i=a.getterFor(t?m:g);return o(n(l),{next:function(){var e=i(this);if(t)return e.nextHandler();if(e.done)return u(void 0,!0);try{var s=e.nextHandler();return e.returnHandlerResult?s:u(s,e.done)}catch(t){throw e.done=!0,t}},return:function(){var e=i(this),n=e.iterator,r=e.done;if(e.done=!0,t){var o=c(n,"return");return o?s(o,n):u(void 0,!0)}if(r)return u(void 0,!0);if(e.inner)try{d(e.inner.iterator,w)}catch(t){return d(n,A,t)}if(e.openIters)try{f(e.openIters,w)}catch(t){if(n)return d(n,A,t);throw t}return n&&d(n,w),u(void 0,!0)}})},y=b(!0),x=b(!1);r(x,p,"Iterator Helper"),t.exports=function(t,i,e){var s=function(s,n){n?(n.iterator=s.iterator,n.next=s.next):n=s,n.type=i?m:g,n.returnHandlerResult=!!e,n.nextHandler=t,n.counter=0,n.done=!1,v(this,n)};return s.prototype=i?y:x,s}},684(t){t.exports=function(t,i){var e="function"==typeof Iterator&&Iterator.prototype[t];if(e)try{e.call({next:null},i).next()}catch(t){return!0}}},4549(t,i,e){var s=e(4576);t.exports=function(t,i){var e=s.Iterator,n=e&&e.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 i||(o=!1)}if(!o)return r}},7657(t,i,e){var s,n,r,o=e(9039),h=e(4901),a=e(34),c=e(2360),l=e(2787),u=e(6840),d=e(608),f=e(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}},6269(t){t.exports={}},6198(t,i,e){var s=e(8014);t.exports=function(t){return s(t.length)}},283(t,i,e){var s=e(9504),n=e(9039),r=e(4901),o=e(9297),h=e(3724),a=e(350).CONFIGURABLE,c=e(3706),l=e(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})),v=(String+"").split("String"),b=t.exports=function(t,i,e){"Symbol("===g(f(i),0,7)&&(i="["+m(f(i),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),e&&e.getter&&(i="get "+i),e&&e.setter&&(i="set "+i),(!o(t,"name")||a&&t.name!==i)&&(h?p(t,"name",{value:i,configurable:!0}):t.name=i),A&&e&&o(e,"arity")&&t.length!==e.arity&&p(t,"length",{value:e.arity});try{e&&o(e,"constructor")&&e.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(v,"string"==typeof i?i:"")),t};Function.prototype.toString=b((function(){return r(this)&&d(this).source||c(this)}),"toString")},2248(t,i,e){var s=e(9504),n=Map.prototype;t.exports={Map,set:s(n.set),get:s(n.get),has:s(n.has),remove:s(n.delete),proto:n}},741(t){var i=Math.ceil,e=Math.floor;t.exports=Math.trunc||function(t){var s=+t;return(s>0?e:i)(s)}},7819(t,i,e){var s=e(9039);t.exports=!s((function(){var t="9007199254740993",i=JSON.rawJSON(t);return!JSON.isRawJSON(i)||JSON.stringify(i)!==t}))},6043(t,i,e){var s=e(9306),n=TypeError,r=function(t){var i,e;this.promise=new t((function(t,s){if(void 0!==i||void 0!==e)throw new n("Bad Promise constructor");i=t,e=s})),this.resolve=s(i),this.reject=s(e)};t.exports.f=function(t){return new r(t)}},2603(t,i,e){var s=e(655);t.exports=function(t,i){return void 0===t?arguments.length<2?"":i:s(t)}},4149(t){var i=RangeError;t.exports=function(t){if(t==t)return t;throw new i("NaN is not allowed")}},2360(t,i,e){var s,n=e(8551),r=e(6801),o=e(8727),h=e(421),a=e(397),c=e(4055),l=e(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 i=t.parentWindow.Object;return t=null,i},w=function(){try{s=new ActiveXObject("htmlfile")}catch(t){}w="undefined"!=typeof document?document.domain&&s?m(s):function(){var t,i=c("iframe"),e="java"+d+":";return i.style.display="none",a.appendChild(i),i.src=e+"",(t=i.contentWindow.document).open(),t.write(g("document.F=Object")),t.close(),t.F}():m(s);for(var t=o.length;t--;)delete w[u][o[t]];return w()};h[f]=!0,t.exports=Object.create||function(t,i){var e;return null!==t?(p[u]=n(t),e=new p,p[u]=null,e[f]=t):e=w(),void 0===i?e:r.f(e,i)}},6801(t,i,e){var s=e(3724),n=e(8686),r=e(4913),o=e(8551),h=e(5397),a=e(1072);i.f=s&&!n?Object.defineProperties:function(t,i){o(t);for(var e,s=h(i),n=a(i),c=n.length,l=0;c>l;)r.f(t,e=n[l++],s[e]);return t}},4913(t,i,e){var s=e(3724),n=e(5917),r=e(8686),o=e(8551),h=e(6969),a=TypeError,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u="enumerable",d="configurable",f="writable";i.f=s?r?function(t,i,e){if(o(t),i=h(i),o(e),"function"==typeof t&&"prototype"===i&&"value"in e&&f in e&&!e[f]){var s=l(t,i);s&&s[f]&&(t[i]=e.value,e={configurable:d in e?e[d]:s[d],enumerable:u in e?e[u]:s[u],writable:!1})}return c(t,i,e)}:c:function(t,i,e){if(o(t),i=h(i),o(e),n)try{return c(t,i,e)}catch(t){}if("get"in e||"set"in e)throw new a("Accessors not supported");return"value"in e&&(t[i]=e.value),t}},7347(t,i,e){var s=e(3724),n=e(9565),r=e(8773),o=e(6980),h=e(5397),a=e(6969),c=e(9297),l=e(5917),u=Object.getOwnPropertyDescriptor;i.f=s?u:function(t,i){if(t=h(t),i=a(i),l)try{return u(t,i)}catch(t){}if(c(t,i))return o(!n(r.f,t,i),t[i])}},8480(t,i,e){var s=e(1828),n=e(8727).concat("length","prototype");i.f=Object.getOwnPropertyNames||function(t){return s(t,n)}},3717(t,i){i.f=Object.getOwnPropertySymbols},2787(t,i,e){var s=e(9297),n=e(4901),r=e(8981),o=e(6119),h=e(2211),a=o("IE_PROTO"),c=Object,l=c.prototype;t.exports=h?c.getPrototypeOf:function(t){var i=r(t);if(s(i,a))return i[a];var e=i.constructor;return n(e)&&i instanceof e?e.prototype:i instanceof c?l:null}},1625(t,i,e){var s=e(9504);t.exports=s({}.isPrototypeOf)},1828(t,i,e){var s=e(9504),n=e(9297),r=e(5397),o=e(9617).indexOf,h=e(421),a=s([].push);t.exports=function(t,i){var e,s=r(t),c=0,l=[];for(e in s)!n(h,e)&&n(s,e)&&a(l,e);for(;i.length>c;)n(s,e=i[c++])&&(~o(l,e)||a(l,e));return l}},1072(t,i,e){var s=e(1828),n=e(8727);t.exports=Object.keys||function(t){return s(t,n)}},8773(t,i){var e={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,n=s&&!e.call({1:2},1);i.f=n?function(t){var i=s(this,t);return!!i&&i.enumerable}:e},2967(t,i,e){var s=e(6706),n=e(34),r=e(7750),o=e(3506);t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t,i=!1,e={};try{(t=s(Object.prototype,"__proto__","set"))(e,[]),i=e instanceof Array}catch(t){}return function(e,s){return r(e),o(s),n(e)?(i?t(e,s):e.__proto__=s,e):e}}():void 0)},4270(t,i,e){var s=e(9565),n=e(4901),r=e(34),o=TypeError;t.exports=function(t,i){var e,h;if("string"===i&&n(e=t.toString)&&!r(h=s(e,t)))return h;if(n(e=t.valueOf)&&!r(h=s(e,t)))return h;if("string"!==i&&n(e=t.toString)&&!r(h=s(e,t)))return h;throw new o("Can't convert object to primitive value")}},5031(t,i,e){var s=e(7751),n=e(9504),r=e(8480),o=e(3717),h=e(8551),a=n([].concat);t.exports=s("Reflect","ownKeys")||function(t){var i=r.f(h(t)),e=o.f;return e?a(i,e(t)):i}},8235(t,i,e){var s=e(9504),n=e(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,i){for(var e=!0,s="";i<t.length;){var p=a(t,i);if("\\"===p){var g=c(t,i,i+2);if(n(u,g))s+=u[g],i+=2;else{if("\\u"!==g)throw new r('Unknown escape sequence: "'+g+'"');var m=c(t,i+=2,i+4);if(!l(d,m))throw new r("Bad Unicode escape at: "+i);s+=h(o(m,16)),i+=4}}else{if('"'===p){e=!1,i++;break}if(l(f,p))throw new r("Bad control character in string literal at: "+i);s+=p,i++}}if(e)throw new r("Unterminated string at: "+i);return{value:s,end:i}}},1103(t){t.exports=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}}},7750(t,i,e){var s=e(4117),n=TypeError;t.exports=function(t){if(s(t))throw new n("Can't call method on "+t);return t}},9286(t,i,e){var s=e(4402),n=e(8469),r=s.Set,o=s.add;t.exports=function(t){var i=new r;return n(t,(function(t){o(i,t)})),i}},3440(t,i,e){var s=e(7080),n=e(4402),r=e(9286),o=e(5170),h=e(3789),a=e(8469),c=e(507),l=n.has,u=n.remove;t.exports=function(t){var i=s(this),e=h(t),n=r(i);return o(n)<=e.size?a(n,(function(t){e.includes(t)&&u(n,t)})):c(e.getIterator(),(function(t){l(n,t)&&u(n,t)})),n}},4402(t,i,e){var s=e(9504),n=Set.prototype;t.exports={Set,add:s(n.add),has:s(n.has),remove:s(n.delete),proto:n}},8750(t,i,e){var s=e(7080),n=e(4402),r=e(5170),o=e(3789),h=e(8469),a=e(507),c=n.Set,l=n.add,u=n.has;t.exports=function(t){var i=s(this),e=o(t),n=new c;return r(i)>e.size?a(e.getIterator(),(function(t){u(i,t)&&l(n,t)})):h(i,(function(t){e.includes(t)&&l(n,t)})),n}},4449(t,i,e){var s=e(7080),n=e(4402).has,r=e(5170),o=e(3789),h=e(8469),a=e(507),c=e(9539);t.exports=function(t){var i=s(this),e=o(t);if(r(i)<=e.size)return!1!==h(i,(function(t){if(e.includes(t))return!1}),!0);var l=e.getIterator();return!1!==a(l,(function(t){if(n(i,t))return c(l.iterator,"normal",!1)}))}},3838(t,i,e){var s=e(7080),n=e(5170),r=e(8469),o=e(3789);t.exports=function(t){var i=s(this),e=o(t);return!(n(i)>e.size)&&!1!==r(i,(function(t){if(!e.includes(t))return!1}),!0)}},8527(t,i,e){var s=e(7080),n=e(4402).has,r=e(5170),o=e(3789),h=e(507),a=e(9539);t.exports=function(t){var i=s(this),e=o(t);if(r(i)<e.size)return!1;var c=e.getIterator();return!1!==h(c,(function(t){if(!n(i,t))return a(c.iterator,"normal",!1)}))}},8469(t,i,e){var s=e(9504),n=e(507),r=e(4402),o=r.Set,h=r.proto,a=s(h.forEach),c=s(h.keys),l=c(new o).next;t.exports=function(t,i,e){return e?n({iterator:c(t),next:l},i):a(t,i)}},4916(t,i,e){var s=e(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 Error("e")}}};t.exports=function(t,i){var e=s("Set");try{(new e)[t](n(0));try{return(new e)[t](n(-1)),!1}catch(s){if(!i)return!0;try{return(new e)[t](r(-1/0)),!1}catch(s){return i(new e([1,2])[t](r(1/0)))}}}catch(t){return!1}}},9835(t){t.exports=function(t){try{var i=new Set,e={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return i.clear(),i.add(4),function(){return{done:!0}}}})}},s=i[t](e);return 1===s.size&&4===s.values().next().value}catch(t){return!1}}},5170(t,i,e){var s=e(6706),n=e(4402);t.exports=s(n.proto,"size","get")||function(t){return t.size}},3650(t,i,e){var s=e(7080),n=e(4402),r=e(9286),o=e(3789),h=e(507),a=n.add,c=n.has,l=n.remove;t.exports=function(t){var i=s(this),e=o(t).getIterator(),n=r(i);return h(e,(function(t){c(i,t)?l(n,t):a(n,t)})),n}},4204(t,i,e){var s=e(7080),n=e(4402).add,r=e(9286),o=e(3789),h=e(507);t.exports=function(t){var i=s(this),e=o(t).getIterator(),a=r(i);return h(e,(function(t){n(a,t)})),a}},6119(t,i,e){var s=e(5745),n=e(3392),r=s("keys");t.exports=function(t){return r[t]||(r[t]=n(t))}},7629(t,i,e){var s=e(6395),n=e(4576),r=e(9433),o="__core-js_shared__",h=t.exports=n[o]||r(o,{});(h.versions||(h.versions=[])).push({version:"3.49.0",mode:s?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745(t,i,e){var s=e(7629);t.exports=function(t,i){return s[t]||(s[t]=i||{})}},1548(t,i,e){var s=e(4576),n=e(9039),r=e(9519),o=e(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),i=h(t,{transfer:[t]});return 0!==t.byteLength||8!==i.byteLength}))},4495(t,i,e){var s=e(9519),n=e(9039),r=e(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}))},5610(t,i,e){var s=e(1291),n=Math.max,r=Math.min;t.exports=function(t,i){var e=s(t);return e<0?n(e+i,0):r(e,i)}},5854(t,i,e){var s=e(2777),n=TypeError;t.exports=function(t){var i=s(t,"number");if("number"==typeof i)throw new n("Can't convert number to bigint");return BigInt(i)}},7696(t,i,e){var s=e(1291),n=e(8014),r=RangeError;t.exports=function(t){if(void 0===t)return 0;var i=s(t),e=n(i);if(i!==e)throw new r("Wrong length or index");return e}},5397(t,i,e){var s=e(7055),n=e(7750);t.exports=function(t){return s(n(t))}},1291(t,i,e){var s=e(741);t.exports=function(t){var i=+t;return i!=i||0===i?0:s(i)}},8014(t,i,e){var s=e(1291),n=Math.min;t.exports=function(t){var i=s(t);return i>0?n(i,9007199254740991):0}},8981(t,i,e){var s=e(7750),n=Object;t.exports=function(t){return n(s(t))}},9590(t,i,e){var s=e(1291),n=RangeError;t.exports=function(t){var i=s(t);if(i<0)throw new n("The argument can't be less than 0");return i}},2777(t,i,e){var s=e(9565),n=e(34),r=e(757),o=e(5966),h=e(4270),a=e(608),c=TypeError,l=a("toPrimitive");t.exports=function(t,i){if(!n(t)||r(t))return t;var e,a=o(t,l);if(a){if(void 0===i&&(i="default"),e=s(a,t,i),!n(e)||r(e))return e;throw new c("Can't convert object to primitive value")}return void 0===i&&(i="number"),h(t,i)}},6969(t,i,e){var s=e(2777),n=e(757);t.exports=function(t){var i=s(t,"string");return n(i)?i:i+""}},2140(t,i,e){var s={};s[e(608)("toStringTag")]="z",t.exports=s+""=="[object z]"},655(t,i,e){var s=e(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)}},6823(t){var i=String;t.exports=function(t){try{return i(t)}catch(t){return"Object"}}},3392(t,i,e){var s=e(9504),n=0,r=Math.random(),o=s(1.1.toString);t.exports=function(t){return"Symbol("+(void 0===t?"":t)+")_"+o(++n+r,36)}},9143(t,i,e){var s=e(4576),n=e(9504),r=e(3972),o=e(3463),h=e(9297),a=e(2804),c=e(944),l=e(5169),u=a.c2i,d=a.c2iUrl,f=s.SyntaxError,p=s.TypeError,g=n("".charAt),m=function(t,i){for(var e=t.length;i<e;i++){var s=g(t,i);if(" "!==s&&"\t"!==s&&"\n"!==s&&"\f"!==s&&"\r"!==s)break}return i},w=function(t,i,e){var s=t.length;s<4&&(t+=2===s?"AA":"A");var n=(i[g(t,0)]<<18)+(i[g(t,1)]<<12)+(i[g(t,2)]<<6)+i[g(t,3)],r=[n>>16&255,n>>8&255,255&n];if(2===s){if(e&&0!==r[1])throw new f("Extra bits");return[r[0]]}if(3===s){if(e&&0!==r[2])throw new f("Extra bits");return[r[0],r[1]]}return r},A=function(t,i,e){for(var s=i.length,n=0;n<s;n++)t[e+n]=i[n];return e+s};t.exports=function(t,i,e,s){o(t),r(i);var n="base64"===c(i)?u:d,a=i?i.lastChunkHandling:void 0;if(void 0===a&&(a="loose"),"loose"!==a&&"strict"!==a&&"stop-before-partial"!==a)throw new p("Incorrect `lastChunkHandling` option");e&&l(e.buffer);var v=t.length,b=e||[],y=0,x=0,M="",S=0;if(s)for(;;){if((S=m(t,S))===v){if(M.length>0){if("stop-before-partial"===a)break;if("loose"!==a)throw new f("Missing padding");if(1===M.length)throw new f("Malformed padding: exactly one additional character");y=A(b,w(M,n,!1),y)}x=v;break}var C=g(t,S);if(++S,"="===C){if(M.length<2)throw new f("Padding is too early");if(S=m(t,S),2===M.length){if(S===v){if("stop-before-partial"===a)break;throw new f("Malformed padding: only one =")}"="===g(t,S)&&(++S,S=m(t,S))}if(S<v)throw new f("Unexpected character after padding");y=A(b,w(M,n,"strict"===a),y),x=v;break}if(!h(n,C))throw new f("Unexpected character");var E=s-y;if(1===E&&2===M.length||2===E&&3===M.length)break;if(4===(M+=C).length&&(y=A(b,w(M,n,!1),y),M="",x=S,y===s))break}return{bytes:b,read:x,written:y}}},2303(t,i,e){var s=e(4576),n=e(9504),r=s.Uint8Array,o=s.SyntaxError,h=Math.min,a=n("".match);t.exports=function(t,i){var e=t.length;if(e%2!=0)throw new o("String should be an even number of characters");for(var s=i?h(i.length,e/2):e/2,n=i||new r(s),c=a(t,/.{2}/g),l=0;l<s;l++){var u=+("0x"+c[l]+"0");if(u!=u)throw new o("String should only contain hex characters");n[l]=u>>4}return{bytes:n,read:l<<1}}},7416(t,i,e){var s=e(9039),n=e(608),r=e(3724),o=e(6395),h=n("iterator");t.exports=!s((function(){var t=new URL("b?a=1&b=2&c=3","https://a"),i=t.searchParams,e=new URLSearchParams("a=1&a=2&b=3"),s="";return t.pathname="c%20d",i.forEach((function(t,e){i.delete("b"),s+=e+t})),e.delete("a",2),e.delete("b",void 0),o&&(!t.toJSON||!e.has("a",1)||e.has("a",2)||!e.has("a",void 0)||e.has("b"))||!i.size&&(o||!r)||!i.sort||"https://a/c%20d?a=1&c=3"!==t.href||"3"!==i.get("c")||new URLSearchParams("?a=1")+""!="a=1"||!i[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}))},7040(t,i,e){var s=e(4495);t.exports=s&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},8686(t,i,e){var s=e(3724),n=e(9039);t.exports=s&&n((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},2812(t){var i=TypeError;t.exports=function(t,e){if(t<e)throw new i("Not enough arguments");return t}},8622(t,i,e){var s=e(4576),n=e(4901),r=s.WeakMap;t.exports=n(r)&&/native code/.test(r+"")},4995(t,i,e){var s=e(9504),n=WeakMap.prototype;t.exports={WeakMap,set:s(n.set),get:s(n.get),has:s(n.has),remove:s(n.delete)}},608(t,i,e){var s=e(4576),n=e(5745),r=e(9297),o=e(3392),h=e(4495),a=e(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]}},6573(t,i,e){var s=e(3724),n=e(2106),r=e(3238),o=ArrayBuffer.prototype;s&&!("detached"in o)&&n(o,"detached",{configurable:!0,get:function(){return r(this)}})},7936(t,i,e){var s=e(6518),n=e(5636);n&&s({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function(){return n(this,arguments.length?arguments[0]:void 0,!1)}})},8100(t,i,e){var s=e(6518),n=e(5636);n&&s({target:"ArrayBuffer",proto:!0},{transfer:function(){return n(this,arguments.length?arguments[0]:void 0,!0)}})},4423(t,i,e){var s=e(6518),n=e(9617).includes,r=e(9039),o=e(6469),h=r((function(){return!1})),a=r((function(){return!1}));s({target:"Array",proto:!0,forced:h||a},{includes:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}}),o("includes")},4114(t,i,e){var s=e(6518),n=e(8981),r=e(6198),o=e(4527),h=e(6837);s({target:"Array",proto:!0,arity:1,forced:e(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 i=n(this),e=r(i),s=arguments.length;h(e+s);for(var a=0;a<s;a++)i[e]=arguments[a],e++;return o(i,e),e}})},8111(t,i,e){var s=e(6518),n=e(4576),r=e(679),o=e(8551),h=e(4901),a=e(2787),c=e(2106),l=e(4659),u=e(9039),d=e(9297),f=e(608),p=e(7657).IteratorPrototype,g=e(3724),m=e(6395),w="constructor",A="Iterator",v=f("toStringTag"),b=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 b("Abstract class Iterator not directly constructable")},S=function(t,i){g?c(p,t,{configurable:!0,get:function(){return i},set:function(i){if(o(this),this===p)throw new b("You can't redefine this property");d(this,t)?this[t]=i:l(this,t,i)}}):p[t]=i};d(p,v)||S(v,A),!x&&d(p,w)&&p[w]!==Object||S(w,M),M.prototype=p,s({global:!0,constructor:!0,forced:x},{Iterator:M})},9314(t,i,e){var s=e(6518),n=e(9565),r=e(8551),o=e(1767),h=e(4149),a=e(9590),c=e(9539),l=e(9462),u=e(684),d=e(4549),f=e(6395),p=!f&&!u("drop",0),g=!f&&!p&&d("drop",RangeError),m=f||p||g,w=l((function(){for(var t,i=this.iterator,e=this.next;this.remaining;)if(this.remaining--,t=r(n(e,i)),this.done=!!t.done)return;if(t=r(n(e,i)),!(this.done=!!t.done))return t.value}));s({target:"Iterator",proto:!0,real:!0,forced:m},{drop:function(t){var i;r(this);try{i=a(h(+t))}catch(t){c(this,"throw",t)}return g?n(g,this,i):new w(o(this),{remaining:i})}})},1148(t,i,e){var s=e(6518),n=e(9565),r=e(2652),o=e(9306),h=e(8551),a=e(1767),c=e(9539),l=e(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 i=a(this),e=0;return!r(i,(function(i,s){if(!t(i,e++))return s()}),{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},2489(t,i,e){var s=e(6518),n=e(9565),r=e(9306),o=e(8551),h=e(1767),a=e(9462),c=e(6319),l=e(6395),u=e(9539),d=e(684),f=e(4549),p=!l&&!d("filter",(function(){})),g=!l&&!p&&f("filter",TypeError),m=l||p||g,w=a((function(){for(var t,i,e=this.iterator,s=this.predicate,r=this.next;;){if(t=o(n(r,e)),this.done=!!t.done)return;if(c(e,s,[i=t.value,this.counter++],!0))return i}}));s({target:"Iterator",proto:!0,real:!0,forced:m},{filter:function(t){o(this);try{r(t)}catch(t){u(this,"throw",t)}return g?n(g,this,t):new w(h(this),{predicate:t})}})},116(t,i,e){var s=e(6518),n=e(9565),r=e(2652),o=e(9306),h=e(8551),a=e(1767),c=e(9539),l=e(4549)("find",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:l},{find:function(t){h(this);try{o(t)}catch(t){c(this,"throw",t)}if(l)return n(l,this,t);var i=a(this),e=0;return r(i,(function(i,s){if(t(i,e++))return s(i)}),{IS_RECORD:!0,INTERRUPTED:!0}).result}})},531(t,i,e){var s=e(6518),n=e(9565),r=e(9306),o=e(8551),h=e(1767),a=e(8646),c=e(9462),l=e(9539),u=e(6395),d=e(684),f=e(4549),p=!u&&!d("flatMap",(function(){})),g=!u&&!p&&f("flatMap",TypeError),m=u||p||g||function(){try{var t=Iterator.prototype.flatMap.call(new Map([[4,5]]).entries(),(function(t){return t}));t.next(),t.return()}catch(t){return!0}}(),w=c((function(){for(var t,i,e=this.iterator,s=this.mapper;;){if(i=this.inner)try{if(!(t=o(n(i.next,i.iterator))).done)return t.value;this.inner=null}catch(t){l(e,"throw",t)}if(t=o(n(this.next,e)),this.done=!!t.done)return;try{this.inner=a(s(t.value,this.counter++),!1)}catch(t){l(e,"throw",t)}}}));s({target:"Iterator",proto:!0,real:!0,forced:m},{flatMap:function(t){o(this);try{r(t)}catch(t){l(this,"throw",t)}return g?n(g,this,t):new w(h(this),{mapper:t,inner:null})}})},7588(t,i,e){var s=e(6518),n=e(9565),r=e(2652),o=e(9306),h=e(8551),a=e(1767),c=e(9539),l=e(4549)("forEach",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:l},{forEach:function(t){h(this);try{o(t)}catch(t){c(this,"throw",t)}if(l)return n(l,this,t);var i=a(this),e=0;r(i,(function(i){t(i,e++)}),{IS_RECORD:!0})}})},1701(t,i,e){var s=e(6518),n=e(9565),r=e(9306),o=e(8551),h=e(1767),a=e(9462),c=e(6319),l=e(9539),u=e(684),d=e(4549),f=e(6395),p=!f&&!u("map",(function(){})),g=!f&&!p&&d("map",TypeError),m=f||p||g,w=a((function(){var t=this.iterator,i=o(n(this.next,t));if(!(this.done=!!i.done))return c(t,this.mapper,[i.value,this.counter++],!0)}));s({target:"Iterator",proto:!0,real:!0,forced:m},{map:function(t){o(this);try{r(t)}catch(t){l(this,"throw",t)}return g?n(g,this,t):new w(h(this),{mapper:t})}})},3579(t,i,e){var s=e(6518),n=e(9565),r=e(2652),o=e(9306),h=e(8551),a=e(1767),c=e(9539),l=e(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 i=a(this),e=0;return r(i,(function(i,s){if(t(i,e++))return s()}),{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},4972(t,i,e){var s=e(6518),n=e(9565),r=e(8551),o=e(1767),h=e(4149),a=e(9590),c=e(9462),l=e(9539),u=e(684),d=e(4549),f=e(6395),p=!f&&!u("take",1),g=!f&&!p&&d("take",RangeError),m=f||p||g,w=c((function(){var t=this.iterator;if(!this.remaining--)return this.done=!0,l(t,"normal",void 0);var i=r(n(this.next,t));return(this.done=!!i.done)?void 0:i.value}));s({target:"Iterator",proto:!0,real:!0,forced:m},{take:function(t){var i;r(this);try{i=a(h(+t))}catch(t){l(this,"throw",t)}return g?n(g,this,i):new w(o(this),{remaining:i})}})},9112(t,i,e){var s=e(6518),n=e(3724),r=e(4576),o=e(7751),h=e(9504),a=e(9565),c=e(4901),l=e(34),u=e(4376),d=e(9297),f=e(655),p=e(6198),g=e(4659),m=e(9039),w=e(8235),A=e(4495),v=r.JSON,b=r.Number,y=r.SyntaxError,x=v&&v.parse,M=o("Object","keys"),S=Object.getOwnPropertyDescriptor,C=h("".charAt),E=h("".slice),k=h(/./.exec),T=h([].push),P=/^\d$/,D=/^[1-9]$/,I=/^[\d-]$/,R=/^[\t\n\r ]$/,N=function(t,i,e,s){var n,r,o,h,c,f=t[i],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++)O(f,h,N(f,""+h,e,h<n?A[h]:void 0));else for(r=M(f),o=p(r),h=0;h<o;h++)O(f,c=r[h],N(f,c,e,d(A,c)?A[c]:void 0))}return a(e,t,i,f,m)},O=function(t,i,e){if(n){var s=S(t,i);if(s&&!s.configurable)return}void 0===e?delete t[i]:g(t,i,e)},_=function(t,i,e,s){this.value=t,this.end=i,this.source=e,this.nodes=s},F=function(t,i){this.source=t,this.index=i};F.prototype={fork:function(t){return new F(this.source,t)},parse:function(){var t=this.source,i=this.skip(R,this.index),e=this.fork(i),s=C(t,i);if(k(I,s))return e.number();switch(s){case"{":return e.object();case"[":return e.array();case'"':return e.string();case"t":return e.keyword(!0);case"f":return e.keyword(!1);case"n":return e.keyword(null)}throw new y('Unexpected character: "'+s+'" at: '+i)},node:function(t,i,e,s,n){return new _(i,s,t?null:E(this.source,e,s),n)},object:function(){for(var t=this.source,i=this.index+1,e=!1,s={},n={},r=!1;i<t.length;){if(i=this.until(['"',"}"],i),"}"===C(t,i)&&!e){i++,r=!0;break}var o=this.fork(i).string(),h=o.value;i=this.until([":"],i=o.end)+1,i=this.skip(R,i),o=this.fork(i).parse(),g(n,h,o),g(s,h,o.value),i=this.until([",","}"],o.end);var a=C(t,i);if(","===a)e=!0,i++;else if("}"===a){i++,r=!0;break}}if(!r)throw new y("Unterminated object at: "+i);return this.node(1,s,this.index,i,n)},array:function(){for(var t=this.source,i=this.index+1,e=!1,s=[],n=[],r=!1;i<t.length;){if(i=this.skip(R,i),"]"===C(t,i)&&!e){i++,r=!0;break}var o=this.fork(i).parse();if(T(n,o),T(s,o.value),i=this.until([",","]"],o.end),","===C(t,i))e=!0,i++;else if("]"===C(t,i)){i++,r=!0;break}}if(!r)throw new y("Unterminated array at: "+i);return this.node(1,s,this.index,i,n)},string:function(){var t=this.index,i=w(this.source,this.index+1);return this.node(0,i.value,t,i.end)},number:function(){var t=this.source,i=this.index,e=i;if("-"===C(t,e)&&e++,"0"===C(t,e))e++;else{if(!k(D,C(t,e)))throw new y("Failed to parse number at: "+e);e=this.skip(P,e+1)}if("."===C(t,e)){var s=e+1;if(s===(e=this.skip(P,s)))throw new y("Failed to parse number's fraction at: "+e)}if(("e"===C(t,e)||"E"===C(t,e))&&(e++,"+"!==C(t,e)&&"-"!==C(t,e)||e++,e===(e=this.skip(P,e))))throw new y("Failed to parse number's exponent value at: "+e);return this.node(0,b(E(t,i,e)),i,e)},keyword:function(t){var i=""+t,e=this.index,s=e+i.length;if(E(this.source,e,s)!==i)throw new y("Failed to parse value at: "+e);return this.node(0,t,e,s)},skip:function(t,i){for(var e=this.source;i<e.length&&k(t,C(e,i));i++);return i},until:function(t,i){i=this.skip(R,i);for(var e=C(this.source,i),s=0;s<t.length;s++)if(t[s]===e)return i;throw new y('Unexpected character: "'+e+'" at: '+i)}};var B=m((function(){var t,i="9007199254740993";return x(i,(function(i,e,s){t=s.source})),t!==i})),L=A&&!m((function(){return 1/x("-0 \t")!=-1/0}));s({target:"JSON",stat:!0,forced:B},{parse:function(t,i){return L&&!c(i)?x(t):function(t,i){t=f(t);var e=new F(t,0),s=e.parse(),n=s.value,r=e.skip(R,s.end);if(r<t.length)throw new y('Unexpected extra character: "'+C(t,r)+'" after the parsed data at: '+r);return c(i)?N({"":n},"",i,s):n}(t,i)}})},3110(t,i,e){var s=e(6518),n=e(7751),r=e(8745),o=e(9565),h=e(9504),a=e(9039),c=e(4376),l=e(4901),u=e(5810),d=e(757),f=e(2195),p=e(655),g=e(7680),m=e(8235),w=e(3392),A=e(4495),v=e(7819),b=String,y=n("JSON","stringify"),x=h(/./.exec),M=h("".charAt),S=h("".charCodeAt),C=h("".replace),E=h("".slice),k=h([].push),T=h(1.1.toString),P=/[\uD800-\uDFFF]/g,D=/^[\uD800-\uDBFF]$/,I=/^[\uDC00-\uDFFF]$/,R=w(),N=R.length,O=!A||a((function(){var t=n("Symbol")("stringify detection");return"[null]"!==y([t])||"{}"!==y({a:t})||"{}"!==y(Object(t))})),_=a((function(){return'"\\udf06\\ud834"'!==y("\udf06\ud834")||'"\\udead"'!==y("\udead")})),F=O?function(t,i){var e=g(arguments),s=L(i);if(l(s)||void 0!==t&&!d(t))return e[1]=function(t,i){if(l(s)&&(i=o(s,this,b(t),i)),!d(i))return i},r(y,null,e)}:y,B=function(t,i,e){var s=M(e,i-1),n=M(e,i+1);return x(D,t)&&!x(I,n)||x(I,t)&&!x(D,s)?"\\u"+T(S(t,0),16):t},L=function(t){if(l(t))return t;if(c(t)){for(var i=t.length,e=[],s=0;s<i;s++){var n=t[s];"string"==typeof n?k(e,n):"number"!=typeof n&&"Number"!==f(n)&&"String"!==f(n)||k(e,p(n))}var r=e.length,o=!0;return function(t,i){if(o)return o=!1,i;if(c(this))return i;for(var s=0;s<r;s++)if(e[s]===t)return i}}};y&&s({target:"JSON",stat:!0,arity:3,forced:O||_||!v},{stringify:function(t,i,e){var s=L(i),n=[],r=F(t,(function(t,i){var e=l(s)?o(s,this,b(t),i):i;return!v&&u(e)?R+(k(n,e.rawJSON)-1):e}),e);if("string"!=typeof r)return r;if(_&&(r=C(r,P,B)),v)return r;for(var h="",a=r.length,c=0;c<a;c++){var d=M(r,c);if('"'===d){var f=m(r,++c).end-1,p=E(r,c,f);h+=E(p,0,N)===R?n[E(p,N)]:'"'+p+'"',c=f}else h+=d}return h}})},2731(t,i,e){var s=e(6518),n=e(9306),r=e(2248),o=e(6395),h=r.get,a=r.has,c=r.set;s({target:"Map",proto:!0,real:!0,forced:o},{getOrInsertComputed:function(t,i){var e=a(this,t);if(n(i),e)return h(this,t);0===t&&1/t==-1/0&&(t=0);var s=i(t);return c(this,t,s),s}})},5367(t,i,e){var s=e(6518),n=e(2248),r=e(6395),o=n.get,h=n.has,a=n.set;s({target:"Map",proto:!0,real:!0,forced:r},{getOrInsert:function(t,i){return h(this,t)?o(this,t):(a(this,t,i),i)}})},3068(t,i,e){var s=e(6518),n=e(9504),r=e(2652),o=RangeError,h=TypeError,a=1/0,c=Math.abs,l=Math.pow,u=n([].push),d=l(2,1023),f=l(2,53)-1,p=Number.MAX_VALUE,g=l(2,971),m={},w={},A={},v={},b={},y=function(t,i){var e=t+i;return{hi:e,lo:i-(e-t)}};s({target:"Math",stat:!0},{sumPrecise:function(t){var i=[],e=0,s=v;switch(r(t,(function(t){if(++e>f)throw new o("Maximum allowed index exceeded");if("number"!=typeof t)throw new h("Value is not a number");s!==m&&(t!=t?s=m:t===a?s=s===w?m:A:t===-1/0?s=s===A?m:w:0===t&&1/t!==a||s!==v&&s!==b||(s=b,u(i,t)))})),s){case m:return NaN;case w:return-1/0;case A:return a;case v:return-0}for(var n,l,x,M,S,C,E=[],k=0,T=0;T<i.length;T++){n=i[T];for(var P=0,D=0;D<E.length;D++){if(l=E[D],c(n)<c(l)&&(C=n,n=l,l=C),S=(x=y(n,l)).lo,c(M=x.hi)===a){var I=M===a?1:-1;k+=I,c(n=n-I*d-I*d)<c(l)&&(C=n,n=l,l=C),M=(x=y(n,l)).hi,S=x.lo}0!==S&&(E[P++]=S),n=M}E.length=P,0!==n&&u(E,n)}var R=E.length-1;if(M=0,S=0,0!==k){var N=R>=0?E[R]:0;if(R--,c(k)>1||k>0&&N>0||k<0&&N<0)return k>0?a:-1/0;if(S=(x=y(k*d,N/2)).lo,S*=2,c(2*(M=x.hi))===a)return M>0?M===d&&S===-g/2&&R>=0&&E[R]<0?p:a:M===-d&&S===g/2&&R>=0&&E[R]>0?-p:-1/0;0!==S&&(E[++R]=S,S=0),M*=2}for(;R>=0&&(M=(x=y(M,E[R--])).hi,0===(S=x.lo)););return R>=0&&(S<0&&E[R]<0||S>0&&E[R]>0)&&(l=2*S)==(n=M+l)-M&&(M=n),M}})},1689(t,i,e){var s=e(6518),n=e(4576),r=e(8745),o=e(7680),h=e(6043),a=e(9306),c=e(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 i=arguments.length>1?o(arguments,1):[],e=h.f(this),s=c((function(){return r(a(t),void 0,i)}));return(s.error?e.reject:e.resolve)(s.value),e.promise}})},4628(t,i,e){var s=e(6518),n=e(6043);s({target:"Promise",stat:!0},{withResolvers:function(){var t=n.f(this);return{promise:t.promise,resolve:t.resolve,reject:t.reject}}})},7642(t,i,e){var s=e(6518),n=e(3440),r=e(9039);s({target:"Set",proto:!0,real:!0,forced:!e(4916)("difference",(function(t){return 0===t.size}))||r((function(){var t={size:1,has:function(){return!0},keys:function(){var t=0;return{next:function(){var e=t++>1;return i.has(1)&&i.clear(),{done:e,value:2}}}}},i=new Set([1,2,3,4]);return 3!==i.difference(t).size}))},{difference:n})},8004(t,i,e){var s=e(6518),n=e(9039),r=e(8750);s({target:"Set",proto:!0,real:!0,forced:!e(4916)("intersection",(function(t){return 2===t.size&&t.has(1)&&t.has(2)}))||n((function(){return Array.from(new Set([1,2,3]).intersection(new Set([3,2])))+""!="3,2"}))},{intersection:r})},3853(t,i,e){var s=e(6518),n=e(4449);s({target:"Set",proto:!0,real:!0,forced:!e(4916)("isDisjointFrom",(function(t){return!t}))},{isDisjointFrom:n})},5876(t,i,e){var s=e(6518),n=e(3838);s({target:"Set",proto:!0,real:!0,forced:!e(4916)("isSubsetOf",(function(t){return t}))},{isSubsetOf:n})},2475(t,i,e){var s=e(6518),n=e(8527);s({target:"Set",proto:!0,real:!0,forced:!e(4916)("isSupersetOf",(function(t){return!t}))},{isSupersetOf:n})},5024(t,i,e){var s=e(6518),n=e(3650),r=e(9835);s({target:"Set",proto:!0,real:!0,forced:!e(4916)("symmetricDifference")||!r("symmetricDifference")},{symmetricDifference:n})},1698(t,i,e){var s=e(6518),n=e(4204),r=e(9835);s({target:"Set",proto:!0,real:!0,forced:!e(4916)("union")||!r("union")},{union:n})},9577(t,i,e){var s=e(4644),n=e(1108),r=e(6198),o=e(1291),h=e(5854),a=s.aTypedArray,c=s.getTypedArrayConstructor,l=s.exportTypedArrayMethod,u=RangeError,d=function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(t){return 8===t}}(),f=d&&function(){try{new Int8Array(1).with(-.5,1)}catch(t){return!0}}();l("with",{with:function(t,i){var e=a(this),s=r(e),l=o(t),d=l<0?s+l:l,f=n(e)?h(i):+i;if(d>=s||d<0)throw new u("Incorrect index");for(var p=new(c(e))(s),g=0;g<s;g++)p[g]=g===d?f:e[g];return p}}.with,!d||f)},5213(t,i,e){var s=e(6518),n=e(4576),r=e(5370),o=e(9143),h=n.Uint8Array,a=!h||!h.fromBase64||!function(){try{return void h.fromBase64("a")}catch(t){}try{h.fromBase64("",null)}catch(t){return!0}}();h&&s({target:"Uint8Array",stat:!0,forced:a},{fromBase64:function(t){var i=o(t,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return r(h,i.bytes)}})},6632(t,i,e){var s=e(6518),n=e(4576),r=e(9143),o=e(4154),h=n.Uint8Array,a=!h||!h.prototype.setFromBase64||!function(){var t=new h([255,255,255,255,255]);try{return void t.setFromBase64("",null)}catch(t){}try{return void t.setFromBase64("a")}catch(t){}try{t.setFromBase64("MjYyZg===")}catch(i){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 i=r(t,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:i.read,written:i.written}}})},4226(t,i,e){var s=e(6518),n=e(4576),r=e(3463),o=e(4154),h=e(5169),a=e(2303);n.Uint8Array&&s({target:"Uint8Array",proto:!0,forced:function(){try{var t=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(t).setFromHex("cafed00d")}catch(t){return!0}}()},{setFromHex:function(t){o(this),r(t),h(this.buffer);var i=a(t,this).read;return{read:i,written:i/2}}})},9486(t,i,e){var s=e(6518),n=e(4576),r=e(9504),o=e(3972),h=e(4154),a=e(5169),c=e(2804),l=e(944),u=c.i2c,d=c.i2cUrl,f=r("".charAt),p=n.Uint8Array,g=!p||!p.prototype.toBase64||!function(){try{(new p).toBase64(null)}catch(t){return!0}}();p&&s({target:"Uint8Array",proto:!0,forced:g},{toBase64:function(){var t=h(this),i=arguments.length?o(arguments[0]):void 0,e="base64"===l(i)?u:d,s=!!i&&!!i.omitPadding;a(this.buffer);for(var n,r="",c=0,p=t.length,g=function(t){return f(e,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}})},456(t,i,e){var s=e(6518),n=e(4576),r=e(9504),o=e(4154),h=e(5169),a=r(1.1.toString),c=r([].join),l=Array,u=n.Uint8Array,d=!u||!u.prototype.toHex||!function(){try{return"ffffffffffffffff"===new u([255,255,255,255,255,255,255,255]).toHex()}catch(t){return!1}}();u&&s({target:"Uint8Array",proto:!0,forced:d},{toHex:function(){o(this),h(this.buffer);for(var t=l(this.length),i=0,e=this.length;i<e;i++){var s=a(this[i],16);t[i]=1===s.length?"0"+s:s}return c(t,"")}})},9452(t,i,e){var s=e(6518),n=e(9306),r=e(6557),o=e(4328),h=e(4995),a=e(6395),c=h.get,l=h.has,u=h.set;s({target:"WeakMap",proto:!0,real:!0,forced:a||!function(){try{WeakMap.prototype.getOrInsertComputed&&(new WeakMap).getOrInsertComputed(1,(function(){throw 1}))}catch(t){return t instanceof TypeError}}()},{getOrInsertComputed:function(t,i){if(a||r(this),o(t),n(i),l(this,t))return c(this,t);var e=i(t);return u(this,t,e),e}})},8454(t,i,e){var s=e(6518),n=e(4995),r=e(6395),o=n.get,h=n.has,a=n.set;s({target:"WeakMap",proto:!0,real:!0,forced:r},{getOrInsert:function(t,i){return h(this,t)?o(this,t):(a(this,t,i),i)}})},4979(t,i,e){var s=e(6518),n=e(4576),r=e(7751),o=e(6980),h=e(4913).f,a=e(9297),c=e(679),l=e(3167),u=e(2603),d=e(5002),f=e(8574),p=e(3724),g=e(6395),m="DOMException",w=r("Error"),A=r(m),v=function(){c(this,b);var t=arguments.length,i=u(t<1?void 0:arguments[0]),e=u(t<2?void 0:arguments[1],"Error"),s=new A(i,e),n=new w(i);return n.name=m,h(s,"stack",o(1,f(n.stack,1))),l(s,this,v),s},b=v.prototype=A.prototype,y="stack"in new w(m),x="stack"in new A(1,2),M=A&&p&&Object.getOwnPropertyDescriptor(n,m),S=y&&!!(!M||M.writable&&M.configurable)&&!x;s({global:!0,constructor:!0,forced:g||S},{DOMException:S?v:A});var C=r(m),E=C.prototype;if(E.constructor!==C)for(var k in g||h(E,"constructor",o(1,C)),d)if(a(d,k)){var T=d[k],P=T.s;a(C,P)||h(C,P,o(6,T.c))}},4603(t,i,e){var s=e(6840),n=e(9504),r=e(655),o=e(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 i=arguments.length,e=i<2?void 0:arguments[1];if(i&&void 0===e)return l(this,t);var s=[];u(this,(function(t,i){d(s,{key:i,value:t})})),o(i,1);for(var n,h=r(t),a=r(e),f=0,p=s.length;f<p;)l(this,(n=s[f]).key),f++;for(f=0;f<p;)(n=s[f++]).key===h&&n.value===a||c(this,n.key,n.value)}),{enumerable:!0,unsafe:!0})},7566(t,i,e){var s=e(6840),n=e(9504),r=e(655),o=e(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 i=arguments.length,e=i<2?void 0:arguments[1];if(i&&void 0===e)return l(this,t);var s=c(this,t);o(i,1);for(var n=r(e),h=0;h<s.length;)if(s[h++]===n)return!0;return!1}),{enumerable:!0,unsafe:!0})},8721(t,i,e){var s=e(3724),n=e(9504),r=e(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})},5781(t,i,e){var s=e(6518),n=e(7751),r=e(2812),o=e(655),h=e(7416),a=n("URL");s({target:"URL",stat:!0,forced:!h},{parse:function(t){var i=r(arguments.length,1),e=o(t),s=i<2||void 0===arguments[1]?void 0:o(arguments[1]);try{return new a(e,s)}catch(t){return null}}})}},O={};function _(t){var i=O[t];if(void 0!==i)return i.exports;var e=O[t]={exports:{}};return N[t].call(e.exports,e,e.exports,_),e.exports}_.d=(t,i)=>{for(var e in i)_.o(i,e)&&!_.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:i[e]})},_.o=(t,i)=>Object.prototype.hasOwnProperty.call(t,i),_(4423),_(4114),_(6573),_(8100),_(7936),_(5367),_(2731),_(9577),_(6632),_(4226),_(9486),_(456),_(5781);const F=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),B=[1/0,1/0,-1/0,-1/0],L=new Float32Array(B),U=[.001,0,0,.001,0,0],$=1.35,j={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},z="pdfjs_internal_editor_",H={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},W={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},G={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},V={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},Y={ERRORS:0,WARNINGS:1,INFOS:5},X={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};let q=Y.WARNINGS;function Q(t){Number.isInteger(t)&&(q=t)}function K(){return q}function J(t){q>=Y.INFOS&&console.info("Info: "+t)}function Z(t){q>=Y.WARNINGS&&console.warn("Warning: "+t)}function tt(t){throw Error(t)}function it(t,i){t||tt(i)}function et(t,i=null,e=null){if(!t)return null;if(e&&"string"==typeof t){if(e.addDefaultProtocol&&t.startsWith("www.")){const i=t.match(/\./g);i?.length>=2&&(t="http://"+t)}if(e.tryConvertEncoding)try{t=function(t){return decodeURIComponent(escape(t))}(t)}catch{}}const s=i?URL.parse(t,i):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 st(t,i,e=!1){const s=URL.parse(t);return s?(s.hash=i,s.href):e&&et(t,"http://example.com")?t.split("#",1)[0]+""+(i?"#"+i:""):""}function nt(t){return t.substring(t.lastIndexOf("/")+1)}function rt(t,i,e,s=!1){return Object.defineProperty(t,i,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const ot=function(){function t(t,i){this.message=t,this.name=i}return t.prototype=Error(),t.constructor=t,t}();class ht extends ot{constructor(t,i){super(t,"PasswordException"),this.code=i}}class at extends ot{constructor(t,i){super(t,"UnknownErrorException"),this.details=i}}class ct extends ot{constructor(t){super(t,"InvalidPDFException")}}class lt extends ot{constructor(t,i,e){super(t,"ResponseException"),this.status=i,this.missing=e}}class ut extends ot{constructor(t){super(t,"FormatError")}}class dt extends ot{constructor(t){super(t,"AbortException")}}function ft(t){"string"!=typeof t&&tt("Invalid argument for stringToBytes");const i=t.length,e=new Uint8Array(i);for(let s=0;s<i;++s)e[s]=255&t.charCodeAt(s);return e}class pt{static get isLittleEndian(){return rt(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isOffscreenCanvasSupported(){return rt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return rt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get isFloat16ArraySupported(){return rt(this,"isFloat16ArraySupported","undefined"!=typeof Float16Array)}static get isSanitizerSupported(){return rt(this,"isSanitizerSupported","undefined"!=typeof Sanitizer)}static get platform(){const{platform:t,userAgent:i}=navigator;return rt(this,"platform",{isAndroid:i.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:i.includes("Firefox")})}static get isCSSRoundSupported(){return rt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}static get isAlphaColorInputSupported(){return rt(this,"isAlphaColorInputSupported",(()=>{if("undefined"==typeof document)return!1;const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080","#ff0000"!==t.value})())}}class gt{static get hexNums(){return rt(this,"hexNums",Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0"))))}static makeHexColor(t,i,e){return`#${this.hexNums[t]}${this.hexNums[i]}${this.hexNums[e]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,i){let e;t[0]?(t[0]<0&&(e=i[0],i[0]=i[2],i[2]=e),i[0]*=t[0],i[2]*=t[0],t[3]<0&&(e=i[1],i[1]=i[3],i[3]=e),i[1]*=t[3],i[3]*=t[3]):(e=i[0],i[0]=i[1],i[1]=e,e=i[2],i[2]=i[3],i[3]=e,t[1]<0&&(e=i[1],i[1]=i[3],i[3]=e),i[1]*=t[1],i[3]*=t[1],t[2]<0&&(e=i[0],i[0]=i[2],i[2]=e),i[0]*=t[2],i[2]*=t[2]),i[0]+=t[4],i[1]+=t[5],i[2]+=t[4],i[3]+=t[5]}static transform(t,i){return[t[0]*i[0]+t[2]*i[1],t[1]*i[0]+t[3]*i[1],t[0]*i[2]+t[2]*i[3],t[1]*i[2]+t[3]*i[3],t[0]*i[4]+t[2]*i[5]+t[4],t[1]*i[4]+t[3]*i[5]+t[5]]}static multiplyByDOMMatrix(t,i){return[t[0]*i.a+t[2]*i.b,t[1]*i.a+t[3]*i.b,t[0]*i.c+t[2]*i.d,t[1]*i.c+t[3]*i.d,t[0]*i.e+t[2]*i.f+t[4],t[1]*i.e+t[3]*i.f+t[5]]}static applyTransform(t,i,e=0){const s=t[e],n=t[e+1];t[e]=s*i[0]+n*i[2]+i[4],t[e+1]=s*i[1]+n*i[3]+i[5]}static applyTransformToBezier(t,i,e=0){const s=i[0],n=i[1],r=i[2],o=i[3],h=i[4],a=i[5];for(let i=0;i<6;i+=2){const c=t[e+i],l=t[e+i+1];t[e+i]=c*s+l*r+h,t[e+i+1]=c*n+l*o+a}}static applyInverseTransform(t,i){const e=t[0],s=t[1],n=i[0]*i[3]-i[1]*i[2];t[0]=(e*i[3]-s*i[2]+i[2]*i[5]-i[4]*i[3])/n,t[1]=(-e*i[1]+s*i[0]+i[4]*i[1]-i[5]*i[0])/n}static axialAlignedBoundingBox(t,i,e){const s=i[0],n=i[1],r=i[2],o=i[3],h=i[4],a=i[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,v=o*d+a,b=v;if(0!==n||0!==r){const t=n*c,i=n*u,e=r*l,s=r*d;f+=e,m+=e,g+=s,p+=s,w+=t,b+=t,v+=i,A+=i}e[0]=Math.min(e[0],f,g,p,m),e[1]=Math.min(e[1],w,v,A,b),e[2]=Math.max(e[2],f,g,p,m),e[3]=Math.max(e[3],w,v,A,b)}static inverseTransform(t){const i=t[0]*t[3]-t[1]*t[2];return[t[3]/i,-t[1]/i,-t[2]/i,t[0]/i,(t[2]*t[5]-t[4]*t[3])/i,(t[4]*t[1]-t[5]*t[0])/i]}static singularValueDecompose2dScale(t,i){const e=t[0],s=t[1],n=t[2],r=t[3],o=e**2+s**2,h=n**2+r**2,a=(o+h)/2,c=Math.sqrt(a**2-(o*h-(e*n+s*r)**2));i[0]=Math.sqrt(a+c||1),i[1]=Math.sqrt(a-c||1)}static normalizeRect(t){const i=t.slice(0);return t[0]>t[2]&&(i[0]=t[2],i[2]=t[0]),t[1]>t[3]&&(i[1]=t[3],i[3]=t[1]),i}static intersect(t,i){const e=Math.max(Math.min(t[0],t[2]),Math.min(i[0],i[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(i[0],i[2]));if(e>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(i[1],i[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(i[1],i[3]));return n>r?null:[e,n,s,r]}static pointBoundingBox(t,i,e){e[0]=Math.min(e[0],t),e[1]=Math.min(e[1],i),e[2]=Math.max(e[2],t),e[3]=Math.max(e[3],i)}static rectBoundingBox(t,i,e,s,n){n[0]=Math.min(n[0],t,e),n[1]=Math.min(n[1],i,s),n[2]=Math.max(n[2],t,e),n[3]=Math.max(n[3],i,s)}static#t(t,i,e,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*i)+3*u*e)+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#i(t,i,e,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,i,e,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,i,e,s,n,r,o,h,(-c+f)/p,u),this.#t(t,i,e,s,n,r,o,h,(-c-f)/p,u)}static bezierBoundingBox(t,i,e,s,n,r,o,h,a){a[0]=Math.min(a[0],t,o),a[1]=Math.min(a[1],i,h),a[2]=Math.max(a[2],t,o),a[3]=Math.max(a[3],i,h),this.#i(t,e,n,o,i,s,r,h,3*(3*(e-n)-t+o),6*(t-2*e+n),3*(e-t),a),this.#i(t,e,n,o,i,s,r,h,3*(3*(s-r)-i+h),6*(i-2*s+r),3*(s-i),a)}}let mt=null,wt=null;function At(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),function(t){"object"==typeof t&&void 0!==t?.length||tt("Invalid argument for bytesToString");const i=t.length,e=8192;if(i<e)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<i;n+=e){const r=t.subarray(n,Math.min(n+e,i));s.push(String.fromCharCode.apply(null,r))}return s.join("")}(t)}const vt="pdfjs_internal_id_",bt=()=>[],yt=()=>new Map,xt=()=>Object.create(null);function Mt(t,i,e){return Math.min(Math.max(t,i),e)}"function"!=typeof Blob.prototype.bytes&&(Blob.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())}),"function"!=typeof Response.prototype.bytes&&(Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())}),"function"!=typeof AbortSignal.any&&(AbortSignal.any=function(t){const i=new AbortController,{signal:e}=i;for(const s of t)if(s.aborted)return i.abort(s.reason),e;for(const s of t)s.addEventListener("abort",(()=>{i.abort(s.reason)}),{signal:e});return e}),_(8111),_(1701),_(4603),_(7566),_(8721);class St{static textContent(t){const i=[],e={items:i,styles:Object.create(null)};return function t(e){if(!e)return;let s=null;const n=e.name;if("#text"===n)s=e.value;else{if(!St.shouldBuildText(n))return;e?.attributes?.textContent?s=e.attributes.textContent:e.value&&(s=e.value)}if(null!==s&&i.push({str:s}),e.children)for(const i of e.children)t(i)}(t),e}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}class Ct{static setupStorage(t,i,e,s,n){const r=s.getValue(i,{value:null});switch(e.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(i,{value:t.target.value})}));break;case"input":if("radio"===e.attributes.type||"checkbox"===e.attributes.type){if(r.value===e.attributes.xfaOn?t.setAttribute("checked",!0):r.value===e.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{s.setValue(i,{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(i,{value:t.target.value})}))}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of e.children)t.attributes.value===r.value?t.attributes.selected=!0:Object.hasOwn(t.attributes,"selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const e=t.target.options;s.setValue(i,{value:-1===e.selectedIndex?"":e[e.selectedIndex].value})}))}}static setAttributes({html:t,element:i,storage:e=null,intent:s,linkService:n}){const{attributes:r}=i,o=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${s}`);for(const[i,e]of Object.entries(r))if(null!=e)switch(i){case"class":e.length&&t.setAttribute(i,e.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",e);break;case"style":Object.assign(t.style,e);break;case"textContent":t.textContent=e;break;default:(!o||"href"!==i&&"newWindow"!==i)&&t.setAttribute(i,e)}o&&n.addLinkAttributes(t,r.href,r.newWindow),e&&r.dataId&&this.setupStorage(t,r.dataId,i,e)}static render(t){const i=t.annotationStorage,e=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:e});const o="richText"!==n,h=t.div;if(h.append(r),t.viewport){const i=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=i}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&&St.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:i,intent:n,linkService:e}),h.children?.length>0)c.push([h,-1,u]);else if(h.value){const t=document.createTextNode(h.value);o&&St.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 i=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=i,t.div.hidden=!1}}const Et="http://www.w3.org/2000/svg";class kt{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Tt(t,i="text"){if(Ot(t,document.baseURI)){const e=await fetch(t);if(!e.ok)throw Error(e.statusText);switch(i){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise(((e,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType="bytes"===i?"arraybuffer":i,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(Error(n.statusText));else{switch(i){case"bytes":return void e(new Uint8Array(n.response));case"blob":case"json":return void e(n.response)}e(n.responseText)}},n.send(null)}))}class Pt{constructor({viewBox:t,userUnit:i,scale:e,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=i,this.scale=e,this.rotation=s,this.offsetX=n,this.offsetY=r,e*=i;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 Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(u=-u,d=-d),0===c?(f=Math.abs(a-t[1])*e+n,p=Math.abs(h-t[0])*e+r,g=(t[3]-t[1])*e,m=(t[2]-t[0])*e):(f=Math.abs(h-t[0])*e+n,p=Math.abs(a-t[1])*e+r,g=(t[2]-t[0])*e,m=(t[3]-t[1])*e),this.transform=[c*e,l*e,u*e,d*e,f-c*e*h-u*e*a,p-l*e*h-d*e*a],this.width=g,this.height=m}get rawDims(){const t=this.viewBox;return rt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:i=this.rotation,offsetX:e=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new Pt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:i,offsetX:e,offsetY:s,dontFlip:n})}convertToViewportPoint(t,i){const e=[t,i];return gt.applyTransform(e,this.transform),e}convertToViewportRectangle(t){const i=[t[0],t[1]];gt.applyTransform(i,this.transform);const e=[t[2],t[3]];return gt.applyTransform(e,this.transform),[i[0],i[1],e[0],e[1]]}convertToPdfPoint(t,i){const e=[t,i];return gt.applyInverseTransform(e,this.transform),e}}class Dt extends ot{constructor(t,i=0){super(t,"RenderingCancelledException"),this.extraDelay=i}}function It(t){const i=t.length;let e=0;for(;e<i&&""===t[e].trim();)e++;return"data:"===t.substring(e,e+5).toLowerCase()}function Rt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}class Nt{#e=new Map;times=[];time(t){this.#e.has(t)&&Z("Timer is already running for "+t),this.#e.set(t,Date.now())}timeEnd(t){this.#e.has(t)||Z("Timer has not been started for "+t),this.times.push({name:t,start:this.#e.get(t),end:Date.now()}),this.#e.delete(t)}toString(){const t=Math.max(...this.times.map((t=>t.name.length)));return this.times.map((i=>`${i.name.padEnd(t)} ${i.end-i.start}ms\n`)).join("")}}function Ot(t,i){const e=i?URL.parse(t,i):URL.parse(t);return/https?:/.test(e?.protocol??"")}function _t(t){t.preventDefault()}function Ft(t){t.preventDefault(),t.stopPropagation()}class Bt{static#s;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#s||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const i=this.#s.exec(t);if(!i)return null;const e=parseInt(i[1],10);let s=parseInt(i[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(i[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(i[4],10);r=r>=0&&r<=23?r:0;let o=parseInt(i[5],10);o=o>=0&&o<=59?o:0;let h=parseInt(i[6],10);h=h>=0&&h<=59?h:0;const a=i[7]||"Z";let c=parseInt(i[8],10);c=c>=0&&c<=23?c:0;let l=parseInt(i[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(e,s,n,r,o,h))}}function Lt(t){if(t.startsWith("#")){const i=t.slice(1);return[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),i.length>=8?parseInt(i.slice(6,8),16)/255:1]}if(t.startsWith("rgb(")){const[i,e,s]=t.slice(4,-1).split(",").map((t=>parseInt(t,10)));return[i,e,s,1]}if(t.startsWith("rgba(")){const i=t.slice(5,-1).split(",");return[parseInt(i[0],10),parseInt(i[1],10),parseInt(i[2],10),parseFloat(i[3])]}const i=t.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return i?[Math.round(255*parseFloat(i[1])),Math.round(255*parseFloat(i[2])),Math.round(255*parseFloat(i[3])),void 0!==i[4]&&"none"!==i[4]?parseFloat(i[4]):1]:null}function Ut(t){const i=Lt(t);return i?i.slice(0,3):(Z(`Not a valid color format: "${t}"`),[0,0,0])}function $t(t){const{a:i,b:e,c:s,d:n,e:r,f:o}=t.getTransform();return[i,e,s,n,r,o]}function jt(t){const{a:i,b:e,c:s,d:n,e:r,f:o}=t.getTransform().invertSelf();return[i,e,s,n,r,o]}function zt(t,i,e=!1,s=!0){if(i instanceof Pt){const{pageWidth:s,pageHeight:n}=i.rawDims,{style:r}=t,o=pt.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})`;e&&i.rotation%180!=0?(r.width=l,r.height=c):(r.width=c,r.height=l)}s&&t.setAttribute("data-main-rotation",i.rotation)}class Ht{constructor(){const{pixelRatio:t}=Ht;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,i,e,s,n=-1){let r=1/0,o=1/0,h=1/0;(e=Ht.capPixels(e,n))>0&&(r=Math.sqrt(e/(t*i))),-1!==s&&(o=s/t,h=s/i);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,i){if(i>=0){const e=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+i/100));return t>0?Math.min(t,e):e}return t}}const Wt=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Gt{static get isDarkMode(){return rt(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}function Vt(t,i){const e=t[0]/255,s=t[1]/255,n=t[2]/255,r=Math.max(e,s,n),o=Math.min(e,s,n),h=(r+o)/2;if(r===o)i[0]=i[1]=0;else{const t=r-o;switch(i[1]=h<.5?t/(r+o):t/(2-r-o),r){case e:i[0]=60*((s-n)/t+(s<n?6:0));break;case s:i[0]=60*((n-e)/t+2);break;case n:i[0]=60*((e-s)/t+4)}}i[2]=h}function Yt(t,i){const e=t[0],s=t[1],n=t[2],r=(1-Math.abs(2*n-1))*s,o=r*(1-Math.abs(e/60%2-1)),h=n-r/2;switch(Math.floor(e/60)){case 0:i[0]=r+h,i[1]=o+h,i[2]=h;break;case 1:i[0]=o+h,i[1]=r+h,i[2]=h;break;case 2:i[0]=h,i[1]=r+h,i[2]=o+h;break;case 3:i[0]=h,i[1]=o+h,i[2]=r+h;break;case 4:i[0]=o+h,i[1]=h,i[2]=r+h;break;case 5:case 6:i[0]=r+h,i[1]=h,i[2]=o+h}}function Xt(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function qt(t,i,e){Yt(t,e),e.map(Xt);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];Yt(i,e),e.map(Xt);const n=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>n?(s+.05)/(n+.05):(n+.05)/(s+.05)}const Qt=new Map;function Kt({html:t,dir:i,className:e},s){const n=document.createDocumentFragment();if("string"==typeof t){const e=document.createElement("p");e.dir=i||"auto";const s=t.split(/(?:\r\n?|\n)/);for(let t=0,i=s.length;t<i;++t)e.append(document.createTextNode(s[t])),t<i-1&&e.append(document.createElement("br"));n.append(e)}else Ct.render({xfaHtml:t,div:n,intent:"richText"});n.firstElementChild.classList.add("richText",e),s.append(n)}function Jt(t){const i=new Path2D;if(!t)return i;for(let e=0,s=t.length;e<s;)switch(t[e++]){case 0:i.moveTo(t[e++],t[e++]);break;case 1:i.lineTo(t[e++],t[e++]);break;case 2:i.bezierCurveTo(t[e++],t[e++],t[e++],t[e++],t[e++],t[e++]);break;case 3:i.quadraticCurveTo(t[e++],t[e++],t[e++],t[e++]);break;case 4:i.closePath();break;default:Z("Unrecognized drawing path operator: "+t[e-1])}return i}_(4972),_(4628),_(7642),_(8004),_(3853),_(5876),_(2475),_(5024),_(1698),_(8454),_(9452),_(4979),_(3579),_(3110),_(9314),_(1148),_(9112);class Zt{#n=null;#r=null;#o;#h=null;#a=null;#c=null;#l=null;#u=null;static#d=null;constructor(t){this.#o=t,Zt.#d||=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.#n=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const i=this.#o._uiManager._signal;i instanceof AbortSignal&&!i.aborted&&(t.addEventListener("contextmenu",_t,{signal:i}),t.addEventListener("pointerdown",Zt.#f,{signal:i}));const e=this.#h=document.createElement("div");e.className="buttons",t.append(e);const s=this.#o.toolbarPosition;if(s){const{style:i}=t,e="ltr"===this.#o._uiManager.direction?1-s[0]:s[0];i.insetInlineEnd=100*e+"%",i.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#n}static#f(t){t.stopPropagation()}#p(t){this.#o._focusEventsAllowed=!1,Ft(t)}#g(t){this.#o._focusEventsAllowed=!0,Ft(t)}#m(t){const i=this.#o._uiManager._signal;return i instanceof AbortSignal&&!i.aborted&&(t.addEventListener("focusin",this.#p.bind(this),{capture:!0,signal:i}),t.addEventListener("focusout",this.#g.bind(this),{capture:!0,signal:i}),t.addEventListener("contextmenu",_t,{signal:i}),!0)}hide(){this.#n.classList.add("hidden"),this.#r?.hideDropdown()}show(){this.#n.classList.remove("hidden"),this.#a?.shown(),this.#c?.shown()}addDeleteButton(){const{editorType:t,_uiManager:i}=this.#o,e=document.createElement("button");e.classList.add("basic","deleteButton"),e.tabIndex=0,e.setAttribute("data-l10n-id",Zt.#d[t]),this.#m(e)&&e.addEventListener("click",(()=>{i.delete()}),{signal:i._signal}),this.#h.append(e)}get#w(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const i=await t.render();this.#m(i),this.#h.append(i,this.#w),this.#a=t}addComment(t,i=null){if(this.#c)return;const e=t.renderForToolbar();if(!e)return;this.#m(e);const s=this.#l=this.#w;i?(this.#h.insertBefore(e,i),this.#h.insertBefore(s,i)):this.#h.append(e,s),this.#c=t,t.toolbar=this}addColorPicker(t){if(this.#r)return;this.#r=t;const i=t.renderButton();this.#m(i),this.#h.append(i,this.#w)}async addEditSignatureButton(t){const i=this.#u=await t.renderEditButton(this.#o);this.#m(i),this.#h.append(i,this.#w)}removeButton(t){"comment"===t&&(this.#c?.removeToolbarCommentButton(),this.#c=null,this.#l?.remove(),this.#l=null)}async addButton(t,i){switch(t){case"colorPicker":i&&this.addColorPicker(i);break;case"altText":i&&await this.addAltText(i);break;case"editSignature":i&&await this.addEditSignatureButton(i);break;case"delete":this.addDeleteButton();break;case"comment":i&&this.addComment(i)}}async addButtonBefore(t,i,e){if(!i&&"comment"===t)return;const s=this.#h.querySelector(e);s&&"comment"===t&&this.addComment(i,s)}updateEditSignatureButton(t){this.#u&&(this.#u.title=t)}remove(){this.#n.remove(),this.#r?.destroy(),this.#r=null}}class ti{#h=null;#n=null;#A;constructor(t){this.#A=t}#v(){const t=this.#n=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const i=this.#A._signal;i instanceof AbortSignal&&!i.aborted&&t.addEventListener("contextmenu",_t,{signal:i});const e=this.#h=document.createElement("div");return e.className="buttons",t.append(e),this.#A.hasCommentManager()&&this.#b("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",(()=>{this.#A.commentSelection("floating_button")})),this.#b("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",(()=>{this.#A.highlightSelection("floating_button")})),t}#y(t,i){let e=0,s=0;for(const n of t){const t=n.y+n.height;if(t<e)continue;const r=n.x+(i?n.width:0);t>e?(s=r,e=t):i?r>s&&(s=r):r<s&&(s=r)}return[i?1-s:s,e]}show(t,i,e){const[s,n]=this.#y(i,e),{style:r}=this.#n||=this.#v();t.append(this.#n),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#n.remove()}#b(t,i,e,s){const n=document.createElement("button");n.classList.add("basic",t),n.tabIndex=0,n.setAttribute("data-l10n-id",i);const r=document.createElement("span");n.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",e);const o=this.#A._signal;o instanceof AbortSignal&&!o.aborted&&(n.addEventListener("contextmenu",_t,{signal:o}),n.addEventListener("click",s,{signal:o})),this.#h.append(n)}}function ii(t,i,e){for(const s of e)i.addEventListener(s,t[s].bind(t))}class ei{static#x=NaN;static#M=null;static#S=NaN;static#C=null;static initializeAndAddPointerId(t){(ei.#M||=new Set).add(t)}static setPointer(t,i){ei.#x||=i,ei.#C??=t}static setTimeStamp(t){ei.#S=t}static isSamePointerId(t){return ei.#x===t}static isSamePointerIdOrRemove(t){return ei.#x===t||(ei.#M?.delete(t),!1)}static isSamePointerType(t){return ei.#C===t}static isInitializedAndDifferentPointerType(t){return null!==ei.#C&&!ei.isSamePointerType(t)}static isSameTimeStamp(t){return ei.#S===t}static isUsingMultiplePointers(){return ei.#M?.size>=1}static clearPointerType(){ei.#C=null}static clearPointerIds(){ei.#x=NaN,ei.#M=null}static clearTimeStamp(){ei.#S=NaN}}class si{#E=0;get id(){return`${z}${this.#E++}`}}class ni{#k=At();#E=0;#T=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;return i.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>',rt(this,"_isSVGFittingCanvas",i.decode().then((()=>(t.drawImage(i,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#P(t,i){this.#T||=new Map;let e=this.#T.get(t);if(null===e)return null;if(e?.bitmap)return e.refCounter+=1,e;try{let t;if(e||={bitmap:null,id:`image_${this.#k}_${this.#E++}`,refCounter:0,isSvg:!1},"string"==typeof i?(e.url=i,t=await Tt(i,"blob")):i instanceof File?t=e.file=i:i instanceof Blob&&(t=i),"image/svg+xml"===t.type){const i=ni._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise(((t,r)=>{n.onload=()=>{e.bitmap=n,e.isSvg=!0,t()},s.onload=async()=>{const t=e.svgUrl=s.result;n.src=await i?t+"#svgView(preserveAspectRatio(none))":t},n.onerror=s.onerror=r}));s.readAsDataURL(t),await r}else e.bitmap=await createImageBitmap(t);e.refCounter=1}catch(t){Z(t),e=null}return this.#T.set(t,e),e&&this.#T.set(e.id,e),e}async getFromFile(t){const{lastModified:i,name:e,size:s,type:n}=t;return this.#P(`${i}_${e}_${s}_${n}`,t)}async getFromUrl(t){return this.#P(t,t)}async getFromBlob(t,i){const e=await i;return this.#P(t,e)}async getFromId(t){this.#T||=new Map;const i=this.#T.get(t);if(!i)return null;if(i.bitmap)return i.refCounter+=1,i;if(i.file)return this.getFromFile(i.file);if(i.blobPromise){const{blobPromise:t}=i;return delete i.blobPromise,this.getFromBlob(i.id,t)}return this.getFromUrl(i.url)}getFromCanvas(t,i){this.#T||=new Map;let e=this.#T.get(t);if(e?.bitmap)return e.refCounter+=1,e;const s=new OffscreenCanvas(i.width,i.height);return s.getContext("2d").drawImage(i,0,0),e={bitmap:s.transferToImageBitmap(),id:`image_${this.#k}_${this.#E++}`,refCounter:1,isSvg:!1},this.#T.set(t,e),this.#T.set(e.id,e),e}getSvgUrl(t){const i=this.#T.get(t);return i?.isSvg?i.svgUrl:null}deleteId(t){this.#T||=new Map;const i=this.#T.get(t);if(!i)return;if(i.refCounter-=1,0!==i.refCounter)return;const{bitmap:e}=i;if(!i.url&&!i.file){const t=new OffscreenCanvas(e.width,e.height);t.getContext("bitmaprenderer").transferFromImageBitmap(e),i.blobPromise=t.convertToBlob()}e.close?.(),i.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#k}_`)}}class ri{#D=[];#I=!1;#R;#N=-1;constructor(t=128){this.#R=t}add({cmd:t,undo:i,post:e,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:o=!1}){if(s&&t(),this.#I)return;const h={cmd:t,undo:i,post:e,type:n};if(-1===this.#N)return this.#D.length>0&&(this.#D.length=0),this.#N=0,void this.#D.push(h);if(r&&this.#D[this.#N].type===n)return o&&(h.undo=this.#D[this.#N].undo),void(this.#D[this.#N]=h);const a=this.#N+1;a===this.#R?this.#D.splice(0,1):(this.#N=a,a<this.#D.length&&this.#D.splice(a)),this.#D.push(h)}undo(){if(-1===this.#N)return;this.#I=!0;const{undo:t,post:i}=this.#D[this.#N];t(),i?.(),this.#I=!1,this.#N-=1}redo(){if(this.#N<this.#D.length-1){this.#N+=1,this.#I=!0;const{cmd:t,post:i}=this.#D[this.#N];t(),i?.(),this.#I=!1}}hasSomethingToUndo(){return-1!==this.#N}hasSomethingToRedo(){return this.#N<this.#D.length-1}cleanType(t){if(-1!==this.#N){for(let i=this.#N;i>=0;i--)if(this.#D[i].type!==t)return this.#D.splice(i+1,this.#N-i),void(this.#N=i);this.#D.length=0,this.#N=-1}}destroy(){this.#D=null}}class oi{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:i}=pt.platform;for(const[e,s,n={}]of t)for(const t of e){const e=t.startsWith("mac+");i&&e?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):i||e||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#O(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 i=this.buffer.join("+");return this.buffer.length=0,i}exec(t,i){if(!this.allKeys.has(i.key))return;const e=this.callbacks.get(this.#O(i));if(!e)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:o=null}}=e;o&&!o(t,i)||(s.bind(t,...r,i)(),n||Ft(i))}}class hi{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 i=document.createElement("span");i.style.visibility="hidden",i.style.colorScheme="only light",document.body.append(i);for(const e of t.keys()){i.style.color=e;const s=window.getComputedStyle(i).color;t.set(e,Ut(s))}i.remove()}(t),rt(this,"_colors",t)}convert(t){const i=Ut(t);if(!window.matchMedia("(forced-colors: active)").matches)return i;for(const[t,e]of this._colors)if(e.every(((t,e)=>t===i[e])))return hi._colorsMapping.get(t);return i}getHexCode(t){const i=this._colors.get(t);return i?gt.makeHexColor(...i):t}}class ai{#_=new AbortController;#F=null;#B=null;#L=new Map;#U=new Map;#$=null;#j=null;#z=null;#H=null;#W=new ri;#G=null;#V=null;#Y=null;#X=0;#q=new Set;#Q=null;#K=null;#J=new Set;_editorUndoBar=null;#Z=!1;#tt=!1;#it=!1;#et=null;#st=null;#nt=null;#rt=null;#ot=!1;#ht=null;#at=new si;#ct=!1;#lt=!1;#ut=!1;#dt=null;#ft=null;#pt=null;#gt=null;#mt=null;#wt=H.NONE;#At=new Set;#vt=null;#bt=null;#yt=null;#xt=null;#Mt=null;#St={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#Ct=[0,0];#Et=null;#kt=null;#Tt=null;#Pt=null;#Dt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=ai.prototype,i=t=>t.#kt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),e=(t,{target:i})=>{if(i instanceof HTMLInputElement){const{type:t}=i;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return rt(this,"_keyboardManager",new oi([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:e}],[["ctrl+z","mac+meta+z"],t.undo,{checker:e}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:e}],[["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:e}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:i})=>!(i instanceof HTMLButtonElement)&&t.#kt.contains(i)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:i})=>!(i instanceof HTMLButtonElement)&&t.#kt.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:i}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:i}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:i}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:i}]]))}constructor(t,i,e,s,n,r,o,h,a,c,l,u,d,f,p,g){const m=this._signal=this.#_.signal;this.#kt=t,this.#Tt=i,this.#Pt=e,this.#j=s,this.#G=n,this.#bt=r,this.#Mt=h,this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:m}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),o._on("setpreference",this.onSetPreference.bind(this),{signal:m}),o._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:m}),window.addEventListener("pointerdown",(()=>{this.#lt=!0}),{capture:!0,signal:m}),window.addEventListener("pointerup",(()=>{this.#lt=!1}),{capture:!0,signal:m}),window.addEventListener("beforeunload",this.#It.bind(this),{capture:!0,signal:m}),this.#Rt(),this.#Nt(),this.#Ot(),this.#z=h.annotationStorage,this.#et=h.filterFactory,this.#yt=a,this.#rt=c||null,this.#Z=l,this.#tt=u,this.#it=d,this.#mt=f||null,this.viewParameters={realScale:kt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=p||null,this._supportsPinchToZoom=!1!==g,n?.setSidebarUiManager(this)}destroy(){this.#Dt?.resolve(),this.#Dt=null,this.#_?.abort(),this.#_=null,this._signal=null;for(const t of this.#U.values())t.destroy();this.#U.clear(),this.#L.clear(),this.#J.clear(),this.#gt?.clear(),this.#F=null,this.#At.clear(),this.#W.destroy(),this.#j?.destroy(),this.#G?.destroy(),this.#bt?.destroy(),this.#ht?.hide(),this.#ht=null,this.#pt?.destroy(),this.#pt=null,this.#B=null,this.#st&&(clearTimeout(this.#st),this.#st=null),this.#Et&&(clearTimeout(this.#Et),this.#Et=null),this._editorUndoBar?.destroy(),this.#Mt=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#mt}get useNewAltTextFlow(){return this.#tt}get useNewAltTextWhenAddingImage(){return this.#it}get hcmFilter(){return rt(this,"hcmFilter",this.#yt?this.#et.addHCMFilter(this.#yt.foreground,this.#yt.background):"none")}get direction(){return rt(this,"direction",getComputedStyle(this.#kt).direction)}get _highlightColors(){return rt(this,"_highlightColors",this.#rt?new Map(this.#rt.split(",").map((t=>((t=t.split("=").map((t=>t.trim())))[1]=t[1].toUpperCase(),t)))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return rt(this,"highlightColors",null);const i=new Map,e=!!this.#yt;for(const[s,n]of t){const t=s.endsWith("_HCM");e&&t?i.set(s.replace("_HCM",""),n):e||t||i.set(s,n)}return rt(this,"highlightColors",i)}get highlightColorNames(){return rt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const i=this.highlightColorNames.get(t);return this._highlightColors.get(i)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#Y=t}setMainHighlightColorPicker(t){this.#pt=t}editAltText(t,i=!1){this.#j?.editAltText(this,t,i)}hasCommentManager(){return!!this.#G}editComment(t,i,e,s){this.#G?.showDialog(this,t,i,e,s)}selectComment(t,i){const e=this.#U.get(t),s=e?.getEditorByUID(i);s?.toggleComment(!0,!0)}updateComment(t){this.#G?.updateComment(t.getData())}updatePopupColor(t){this.#G?.updatePopupColor(t)}removeComment(t){this.#G?.removeComments([t.uid])}deleteComment(t,i){const e=()=>{t.comment=i};this.addCommands({cmd:()=>{this._editorUndoBar?.show(e,"comment"),this.toggleComment(null),t.comment=null},undo:e,mustExec:!0})}toggleComment(t,i,e){this.#G?.toggleCommentPopup(t,i,e)}makeCommentColor(t,i){return t&&this.#G?.makeCommentColor(t,i)||null}getCommentDialogElement(){return this.#G?.dialogElement||null}async waitForEditorsRendered(t){if(this.#U.has(t-1))return;const{resolve:i,promise:e}=Promise.withResolvers(),s=e=>{e.pageNumber===t&&(this._eventBus._off("editorsrendered",s),i())};this._eventBus.on("editorsrendered",s),await e}getSignature(t){this.#bt?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#bt}switchToMode(t,i){this._eventBus.on("annotationeditormodechanged",i,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,i){this._eventBus.dispatch("setpreference",{source:this,name:t,value:i})}onSetPreference({name:t,value:i}){"enableNewAltTextWhenAddingImage"===t&&(this.#it=i)}onPageChanging({pageNumber:t}){this.#X=t-1}deletePage(t){for(const i of this.getEditors(t))i.remove();this.#U.delete(t),this.#X===t&&(this.#X=0)}focusMainContainer(){this.#kt.focus()}findParent(t,i){for(const e of this.#U.values()){const{x:s,y:n,width:r,height:o}=e.div.getBoundingClientRect();if(t>=s&&t<=s+r&&i>=n&&i<=n+o)return e}return null}disableUserSelect(t=!1){this.#Tt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#J.add(t)}removeShouldRescale(t){this.#J.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*kt.PDF_TO_CSS_UNITS;for(const t of this.#J)t.onScaleChanging();this.#Y?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#_t({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#Ft(t){const{currentLayer:i}=this;if(i.hasTextLayer(t))return i;for(const i of this.#U.values())if(i.hasTextLayer(t))return i;return null}highlightSelection(t="",i=!1){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:o}=e,h=""+e,a=this.#_t(e).closest(".textLayer"),c=this.getSelectionBoxes(a);if(!c)return;e.empty();const l=this.#Ft(a),u=this.#wt===H.NONE,d=()=>{const e=l?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:c,anchorNode:s,anchorOffset:n,focusNode:r,focusOffset:o,text:h});u&&this.showAllEditors("highlight",!0,!0),i&&e?.editComment()};u?this.switchToMode(H.HIGHLIGHT,d):d()}commentSelection(t=""){this.highlightSelection(t,!0)}#It(t){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#Bt(){const t=document.getSelection();if(!t||t.isCollapsed)return;const i=this.#_t(t).closest(".textLayer"),e=this.getSelectionBoxes(i);e&&(this.#ht||=new ti(this),this.#ht.show(i,e,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#z)return null;const i=`${z}${t}`,e=this.#z.getRawValue(i);return e&&this.#z.remove(i),e}addToAnnotationStorage(t){t.isEmpty()||!this.#z||this.#z.has(t.id)||this.#z.setValue(t.id,t)}a11yAlert(t,i=null){const e=this.#Pt;e&&(e.setAttribute("data-l10n-id",t),i?e.setAttribute("data-l10n-args",JSON.stringify(i)):e.removeAttribute("data-l10n-args"))}#Lt(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#vt&&(this.#ht?.hide(),this.#vt=null,this.#Ut({hasSelectedText:!1})));const{anchorNode:i}=t;if(i===this.#vt)return;const e=this.#_t(t).closest(".textLayer");if(e){if(this.#ht?.hide(),this.#vt=i,this.#Ut({hasSelectedText:!0}),(this.#wt===H.HIGHLIGHT||this.#wt===H.NONE)&&(this.#wt===H.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#ot=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#wt===H.HIGHLIGHT?this.#Ft(e):null;if(t?.toggleDrawing(),this.#lt){const i=new AbortController,e=this.combinedSignal(i),s=e=>{"pointerup"===e.type&&0!==e.button||(i.abort(),t?.toggleDrawing(!0),"pointerup"===e.type&&this.#$t("main_toolbar"))};window.addEventListener("pointerup",s,{signal:e}),window.addEventListener("blur",s,{signal:e})}else t?.toggleDrawing(!0),this.#$t("main_toolbar")}}else this.#vt&&(this.#ht?.hide(),this.#vt=null,this.#Ut({hasSelectedText:!1}))}#$t(t=""){this.#wt===H.HIGHLIGHT?this.highlightSelection(t):this.#Z&&this.#Bt()}#Rt(){document.addEventListener("selectionchange",this.#Lt.bind(this),{signal:this._signal})}#jt(){if(this.#nt)return;this.#nt=new AbortController;const t=this.combinedSignal(this.#nt);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#zt(){this.#nt?.abort(),this.#nt=null}blur(){if(this.isShiftKeyDown=!1,this.#ot&&(this.#ot=!1,this.#$t("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const i of this.#At)if(i.div.contains(t)){this.#ft=[i,t],i._focusEventsAllowed=!1;break}}focus(){if(!this.#ft)return;const[t,i]=this.#ft;this.#ft=null,i.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),i.focus()}#Ot(){if(this.#dt)return;this.#dt=new AbortController;const t=this.combinedSignal(this.#dt);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Ht(){this.#dt?.abort(),this.#dt=null}#Wt(){if(this.#V)return;this.#V=new AbortController;const t=this.combinedSignal(this.#V);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})}#Gt(){this.#V?.abort(),this.#V=null}#Nt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Ot(),this.setEditingState(!0)}removeEditListeners(){this.#Ht(),this.setEditingState(!1)}dragOver(t){for(const{type:i}of t.dataTransfer.items)for(const e of this.#K)if(e.isHandlingMimeForPasting(i))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const i of t.dataTransfer.items)for(const e of this.#K)if(e.isHandlingMimeForPasting(i.type))return e.paste(i,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#F?.commitOrRemove(),!this.hasSelection)return;const i=[];for(const t of this.#At){const e=t.serialize(!0);e&&i.push(e)}0!==i.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(i))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:i}=t;for(const t of i.items)for(const i of this.#K)if(i.isHandlingMimeForPasting(t.type))return void i.paste(t,this.currentLayer);let e=i.getData("application/pdfjs");if(!e)return;try{e=JSON.parse(e)}catch(t){return void Z(`paste: "${t.message}".`)}if(!Array.isArray(e))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const i of e){const e=await s.deserialize(i);if(!e)return;t.push(e)}this.addCommands({cmd:()=>{for(const i of t)this.#Vt(i);this.#Yt(t)},undo:()=>{for(const i of t)i.remove()},mustExec:!0})}catch(t){Z(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#wt===H.NONE||this.isEditorHandlingKeyboard||ai._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#ot&&(this.#ot=!1,this.#$t("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}updatePageIndex(t,i){for(const e of this.getEditors(t))e.pageIndex=i;const e=this.#$.get(t);e&&(e.pageIndex=i,this.#U.set(i,e),this.#ct?e.enable():e.disable())}startUpdatePages(){this.#$=new Map(this.#U),this.#U.clear()}endUpdatePages(){this.#$=null}clonePage(t,i){for(const e of this.getEditors(t)){const t=e.serialize(e.mode!==H.HIGHLIGHT);t&&(t.pageIndex=i,t.id=this.getId(),t.isClone=!0,delete t.popupRef,this.#z.setValue(t.id,t))}}findClonesForPage(t){const i=[],{pageIndex:e}=t;for(const[s,n]of this.#z)n.pageIndex===e&&n.isClone&&(this.#z.remove(s),i.push(t.deserialize(n).then((i=>{i&&(i.isClone=!0,t.addOrRebuild(i))}))));return Promise.all(i)}#Ut(t){Object.entries(t).some((([t,i])=>this.#St[t]!==i))&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#St,t)}),this.#wt===H.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Xt([[W.HIGHLIGHT_FREE,!0]]))}#Xt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#jt(),this.#Wt(),this.#Ut({isEditing:this.#wt!==H.NONE,isEmpty:this.#qt(),hasSomethingToUndo:this.#W.hasSomethingToUndo(),hasSomethingToRedo:this.#W.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#zt(),this.#Gt(),this.#Ut({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#K){this.#K=t;for(const t of this.#K)this.#Xt(t.defaultPropertiesToUpdate)}}getId(){return this.#at.id}get currentLayer(){return this.#U.get(this.#X)}getLayer(t){return this.#U.get(t)}get currentPageIndex(){return this.#X}addLayer(t){this.#U.set(t.pageIndex,t),this.#ct?t.enable():t.disable()}removeLayer(t){this.#U.delete(t.pageIndex)}async updateMode(t,i=null,e=!1,s=!1,n=!1,r=!1){if(this.#wt!==t&&(!this.#Dt||(await this.#Dt.promise,this.#Dt))){if(this.#Dt=Promise.withResolvers(),this.#Y?.commitOrRemove(),this.#wt===H.POPUP&&this.#G?.hideSidebar(),this.#G?.destroyPopup(),this.#wt=t,t===H.NONE){this.setEditingState(!1),this.#Qt();for(const t of this.#L.values())t.hideStandaloneCommentButton();return this._editorUndoBar?.hide(),this.toggleComment(null),void this.#Dt.resolve()}for(const t of this.#L.values())t.addStandaloneCommentButton();t===H.SIGNATURE&&await(this.#bt?.loadSignatures()),e&&ei.clearPointerType(),this.setEditingState(!0),await this.#Kt(),this.unselectAll();for(const i of this.#U.values())i.updateMode(t);if(t===H.POPUP){this.#B||=await this.#Mt.getAnnotationsByType(new Set(this.#K.map((t=>t._editorType))));const t=new Set,i=[];for(const e of this.#L.values()){const{annotationElementId:s,hasComment:n,deleted:r}=e;s&&t.add(s),n&&!r&&i.push(e.getData())}for(const e of this.#B){const{id:s,popupRef:n,contentsObj:r}=e;n&&r?.str&&!t.has(s)&&!this.#q.has(s)&&i.push(e)}this.#G?.showSidebar(i)}if(!i)return s&&this.addNewEditorFromKeyboard(),void this.#Dt.resolve();for(const t of this.#L.values())t.uid===i?(this.setSelected(t),r?t.editComment():n?t.enterInEditMode():t.focus()):t.unselect();this.#Dt.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#wt&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,i){if(this.#K){switch(t){case W.CREATE:return void this.currentLayer.addNewEditor(i);case W.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#xt||=new Map).set(t,i),this.showAllEditors("highlight",i)}if(this.hasSelection)for(const e of this.#At)e.updateParams(t,i);else for(const e of this.#K)e.updateDefaultParams(t,i)}}showAllEditors(t,i,e=!1){for(const e of this.#L.values())e.editorType===t&&e.show(i);(this.#xt?.get(W.HIGHLIGHT_SHOW_ALL)??!0)!==i&&this.#Xt([[W.HIGHLIGHT_SHOW_ALL,i]])}enableWaiting(t=!1){if(this.#ut!==t){this.#ut=t;for(const i of this.#U.values())t?i.disableClick():i.enableClick(),i.div.classList.toggle("waiting",t)}}async#Kt(){if(!this.#ct){this.#ct=!0;const t=[];for(const i of this.#U.values())t.push(i.enable());await Promise.all(t);for(const t of this.#L.values())t.enable()}}#Qt(){if(this.unselectAll(),this.#ct){this.#ct=!1;for(const t of this.#U.values())t.disable();for(const t of this.#L.values())t.disable()}}*getEditors(t){for(const i of this.#L.values())i.pageIndex===t&&(yield i)}getEditor(t){return this.#L.get(t)}addEditor(t){this.#L.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#st&&clearTimeout(this.#st),this.#st=setTimeout((()=>{this.focusMainContainer(),this.#st=null}),0)),this.#L.delete(t.id),t.annotationElementId&&this.#gt?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#q.has(t.annotationElementId)||this.#z?.remove(t.id)}addDeletedAnnotationElement(t){this.#q.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#q.has(t)}removeDeletedAnnotationElement(t){this.#q.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#Vt(t){const i=this.#U.get(t.pageIndex);i?i.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#F!==t&&(this.#F=t,t&&this.#Xt(t.propertiesToUpdate))}get#Jt(){let t=null;for(t of this.#At);return t}updateUI(t){this.#Jt===t&&this.#Xt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Xt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#At.has(t))return this.#At.delete(t),t.unselect(),void this.#Ut({hasSelectedEditor:this.hasSelection});this.#At.add(t),t.select(),this.#Xt(t.propertiesToUpdate),this.#Ut({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#Y?.commitOrRemove();for(const i of this.#At)i!==t&&i.unselect();this.#G?.destroyPopup(),this.#At.clear(),this.#At.add(t),t.select(),this.#Xt(t.propertiesToUpdate),this.#Ut({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.#Ut({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#At.size}get isEnterHandled(){return 1===this.#At.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#W.undo(),this.#Ut({hasSomethingToUndo:this.#W.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#qt()}),this._editorUndoBar?.hide()}redo(){this.#W.redo(),this.#Ut({hasSomethingToUndo:!0,hasSomethingToRedo:this.#W.hasSomethingToRedo(),isEmpty:this.#qt()})}addCommands(t){this.#W.add(t),this.#Ut({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#qt()})}cleanUndoStack(t){this.#W.cleanType(t)}#qt(){if(0===this.#L.size)return!0;if(1===this.#L.size)for(const t of this.#L.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const i=t?[t]:[...this.#At],e=()=>{for(const t of i)this.#Vt(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(e,1===i.length?i[0].editorType:i.length);for(const t of i)t.remove()},undo:e,mustExec:!0})}commitOrRemove(){this.#F?.commitOrRemove()}hasSomethingToControl(){return this.#F||this.hasSelection}#Yt(t){for(const t of this.#At)t.unselect();this.#At.clear();for(const i of t)i.isEmpty()||(this.#At.add(i),i.select());this.#Ut({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#At)t.commit();this.#Yt(this.#L.values())}unselectAll(){if((!this.#F||(this.#F.commitOrRemove(),this.#wt===H.NONE))&&!this.#Y?.commitOrRemove()&&(this.#G?.destroyPopup(),this.hasSelection)){for(const t of this.#At)t.unselect();this.#At.clear(),this.#Ut({hasSelectedEditor:!1})}}translateSelectedEditors(t,i,e=!1){if(e||this.commitOrRemove(),!this.hasSelection)return;this.#Ct[0]+=t,this.#Ct[1]+=i;const[s,n]=this.#Ct,r=[...this.#At];this.#Et&&clearTimeout(this.#Et),this.#Et=setTimeout((()=>{this.#Et=null,this.#Ct[0]=this.#Ct[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#L.has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(const t of r)this.#L.has(t.id)&&(t.translateInPage(-s,-n),t.translationDone())},mustExec:!1})}),1e3);for(const e of r)e.translateInPage(t,i),e.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#Q=new Map;for(const t of this.#At)this.#Q.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#Q)return!1;this.disableUserSelect(!1);const t=this.#Q;this.#Q=null;let i=!1;for(const[{x:e,y:s,pageIndex:n},r]of t)r.newX=e,r.newY=s,r.newPageIndex=n,i||=e!==r.savedX||s!==r.savedY||n!==r.savedPageIndex;if(!i)return!1;const e=(t,i,e,s)=>{if(this.#L.has(t.id)){const n=this.#U.get(s);n?t._setParentAndPosition(n,i,e):(t.pageIndex=s,t.x=i,t.y=e)}};return this.addCommands({cmd:()=>{for(const[i,{newX:s,newY:n,newPageIndex:r}]of t)e(i,s,n,r)},undo:()=>{for(const[i,{savedX:s,savedY:n,savedPageIndex:r}]of t)e(i,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,i){if(this.#Q)for(const e of this.#Q.keys())e.drag(t,i)}rebuild(t){if(null===t.parent){const i=this.getLayer(t.pageIndex);i?(i.changeParent(t),i.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.#F===t}getActive(){return this.#F}getMode(){return this.#wt}isEditingMode(){return this.#wt!==H.NONE}get imageManager(){return rt(this,"imageManager",new ni)}getSelectionBoxes(t){if(!t)return null;const i=document.getSelection();for(let e=0,s=i.rangeCount;e<s;e++)if(!t.contains(i.getRangeAt(e).commonAncestorContainer))return null;const{x:e,y:s,width:n,height:r}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(t,i,o,h)=>({x:(i-s)/r,y:1-(t+o-e)/n,width:h/r,height:o/n});break;case"180":o=(t,i,o,h)=>({x:1-(t+o-e)/n,y:1-(i+h-s)/r,width:o/n,height:h/r});break;case"270":o=(t,i,o,h)=>({x:1-(i+h-s)/r,y:(t-e)/n,width:h/r,height:o/n});break;default:o=(t,i,o,h)=>({x:(t-e)/n,y:(i-s)/r,width:o/n,height:h/r})}const h=[];for(let t=0,e=i.rangeCount;t<e;t++){const e=i.getRangeAt(t);if(!e.collapsed)for(const{x:t,y:i,width:s,height:n}of e.getClientRects())0!==s&&0!==n&&h.push(o(t,i,s,n))}return 0===h.length?null:h}addChangedExistingAnnotation({annotationElementId:t,id:i}){(this.#H||=new Map).set(t,i)}removeChangedExistingAnnotation({annotationElementId:t}){this.#H?.delete(t)}renderAnnotationElement(t){const i=this.#H?.get(t.data.id);if(!i)return;const e=this.#z.getRawValue(i);e&&(this.#wt!==H.NONE||e.hasBeenModified)&&e.renderAnnotationElement(t)}setMissingCanvas(t,i,e){const s=this.#gt?.get(t);s&&(s.setCanvas(i,e),this.#gt.delete(t))}addMissingCanvas(t,i){(this.#gt||=new Map).set(t,i)}}class ci{#a=null;#Zt=!1;#ti=null;#ii=null;#ei=null;#si=null;#ni=!1;#ri=null;#o=null;#oi=null;#hi=null;#ai=!1;static#ci=null;static _l10n=null;constructor(t){this.#o=t,this.#ai=t._uiManager.useNewAltTextFlow,ci.#ci||=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){ci._l10n??=t}async render(){const t=this.#ti=document.createElement("button");t.className="altText",t.tabIndex="0";const i=this.#ii=document.createElement("span");t.append(i),this.#ai?(t.classList.add("new"),t.setAttribute("data-l10n-id",ci.#ci.missing),i.setAttribute("data-l10n-id",ci.#ci["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const e=this.#o._uiManager._signal;t.addEventListener("contextmenu",_t,{signal:e}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:e});const s=t=>{t.preventDefault(),this.#o._uiManager.editAltText(this.#o),this.#ai&&this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#li}})};return t.addEventListener("click",s,{capture:!0,signal:e}),t.addEventListener("keydown",(i=>{i.target===t&&"Enter"===i.key&&(this.#ni=!0,s(i))}),{signal:e}),await this.#ui(),t}get#li(){return(this.#a?"added":null===this.#a&&this.guessedText&&"review")||"missing"}finish(){this.#ti&&(this.#ti.focus({focusVisible:this.#ni}),this.#ni=!1)}isEmpty(){return this.#ai?null===this.#a:!this.#a&&!this.#Zt}hasData(){return this.#ai?null!==this.#a||!!this.#oi:this.isEmpty()}get guessedText(){return this.#oi}async setGuessedText(t){null===this.#a&&(this.#oi=t,this.#hi=await ci._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#ui())}toggleAltTextBadge(t=!1){if(!this.#ai||this.#a)return this.#ri?.remove(),void(this.#ri=null);if(!this.#ri){const t=this.#ri=document.createElement("div");t.className="noAltTextBadge",this.#o.div.append(t)}this.#ri.classList.toggle("hidden",!t)}serialize(t){let i=this.#a;return t||this.#oi!==i||(i=this.#hi),{altText:i,decorative:this.#Zt,guessedText:this.#oi,textWithDisclaimer:this.#hi}}get data(){return{altText:this.#a,decorative:this.#Zt}}set data({altText:t,decorative:i,guessedText:e,textWithDisclaimer:s,cancel:n=!1}){e&&(this.#oi=e,this.#hi=s),this.#a===t&&this.#Zt===i||(n||(this.#a=t,this.#Zt=i),this.#ui())}toggle(t=!1){this.#ti&&(!t&&this.#si&&(clearTimeout(this.#si),this.#si=null),this.#ti.disabled=!t)}shown(){this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#li}})}destroy(){this.#ti?.remove(),this.#ti=null,this.#ii=null,this.#ei=null,this.#ri?.remove(),this.#ri=null}async#ui(){const t=this.#ti;if(!t)return;if(this.#ai){if(t.classList.toggle("done",!!this.#a),t.setAttribute("data-l10n-id",ci.#ci[this.#li]),this.#ii?.setAttribute("data-l10n-id",ci.#ci[this.#li+"-label"]),!this.#a)return void this.#ei?.remove()}else{if(!this.#a&&!this.#Zt)return t.classList.remove("done"),void this.#ei?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let i=this.#ei;if(!i){this.#ei=i=document.createElement("span"),i.className="tooltip",i.setAttribute("role","tooltip"),i.id="alt-text-tooltip-"+this.#o.id;const e=100,s=this.#o._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#si),this.#si=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#si=setTimeout((()=>{this.#si=null,this.#ei.classList.add("show"),this.#o._reportTelemetry({action:"alt_text_tooltip"})}),e)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#si&&(clearTimeout(this.#si),this.#si=null),this.#ei?.classList.remove("show")}),{signal:s})}this.#Zt?i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(i.removeAttribute("data-l10n-id"),i.textContent=this.#a),i.parentNode||t.append(i);const e=this.#o.getElementForAltText();e?.setAttribute("aria-describedby",i.id)}}class li{#di=null;#fi=null;#pi=!1;#o=null;#gi=null;#mi=null;#wi=null;#Ai=null;#vi=!1;#bi=null;constructor(t){this.#o=t}renderForToolbar(){const t=this.#fi=document.createElement("button");return t.className="comment",this.#v(t,!1)}renderForStandalone(){const t=this.#di=document.createElement("button");t.className="annotationCommentButton";const i=this.#o.commentButtonPosition;if(i){const{style:e}=t;e.insetInlineEnd=`calc(${100*("ltr"===this.#o._uiManager.direction?1-i[0]:i[0])}% - var(--comment-button-dim))`,e.top=`calc(${100*i[1]}% - var(--comment-button-dim))`;const s=this.#o.commentButtonColor;s&&(e.backgroundColor=s)}return this.#v(t,!0)}focusButton(){setTimeout((()=>{(this.#di??this.#fi)?.focus()}),0)}onUpdatedColor(){if(!this.#di)return;const t=this.#o.commentButtonColor;t&&(this.#di.style.backgroundColor=t),this.#o._uiManager.updatePopupColor(this.#o)}get commentButtonWidth(){return(this.#di?.getBoundingClientRect().width??0)/this.#o.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#bi)return this.#bi;if(!this.#di)return null;const{x:t,y:i,height:e}=this.#di.getBoundingClientRect(),{x:s,y:n,width:r,height:o}=this.#o.parent.boundingClientRect;return[(t-s)/r,(i+e-n)/o]}set commentPopupPositionInLayer(t){this.#bi=t}hasDefaultPopupPosition(){return null===this.#bi}removeStandaloneCommentButton(){this.#di?.remove(),this.#di=null}removeToolbarCommentButton(){this.#fi?.remove(),this.#fi=null}setCommentButtonStates({selected:t,hasPopup:i}){this.#di&&(this.#di.classList.toggle("selected",t),this.#di.ariaExpanded=i)}#v(t,i){if(!this.#o._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",i?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#o._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const e=this.#o._uiManager._signal;if(!(e instanceof AbortSignal)||e.aborted)return t;t.addEventListener("contextmenu",_t,{signal:e}),i&&(t.addEventListener("focusin",(t=>{this.#o._focusEventsAllowed=!1,Ft(t)}),{capture:!0,signal:e}),t.addEventListener("focusout",(t=>{this.#o._focusEventsAllowed=!0,Ft(t)}),{capture:!0,signal:e})),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:e});const s=i=>{i.preventDefault(),t===this.#fi?this.edit():this.#o.toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:e}),t.addEventListener("keydown",(i=>{i.target===t&&"Enter"===i.key&&(this.#pi=!0,s(i))}),{signal:e}),t.addEventListener("pointerenter",(()=>{this.#o.toggleComment(!1,!0)}),{signal:e}),t.addEventListener("pointerleave",(()=>{this.#o.toggleComment(!1,!1)}),{signal:e}),t}edit(t){const i=this.commentPopupPositionInLayer;let e,s;if(i)[e,s]=i;else{[e,s]=this.#o.commentButtonPosition;const{width:t,height:i,x:n,y:r}=this.#o;e=n+e*t,s=r+s*i}const n=this.#o.parent.boundingClientRect,{x:r,y:o,width:h,height:a}=n;this.#o._uiManager.editComment(this.#o,r+e*h,o+s*a,{...t,parentDimensions:n})}finish(){this.#fi&&(this.#fi.focus({focusVisible:this.#pi}),this.#pi=!1)}isDeleted(){return this.#vi||""===this.#wi}isEmpty(){return null===this.#wi}hasBeenEdited(){return this.isDeleted()||this.#wi!==this.#gi}serialize(){return this.data}get data(){return{text:this.#wi,richText:this.#mi,date:this.#Ai,deleted:this.isDeleted()}}set data(t){if(t!==this.#wi&&(this.#mi=null),null===t)return this.#wi="",void(this.#vi=!0);this.#wi=t,this.#Ai=new Date,this.#vi=!1}restoreData({text:t,richText:i,date:e}){this.#wi=t,this.#mi=i,this.#Ai=e,this.#vi=!1}setInitialText(t,i=null){this.#gi=t,this.data=t,this.#Ai=null,this.#mi=i}shown(){}destroy(){this.#fi?.remove(),this.#fi=null,this.#di?.remove(),this.#di=null,this.#wi="",this.#mi=null,this.#Ai=null,this.#o=null,this.#pi=!1,this.#vi=!1}}class ui{#kt;#yi=!1;#xi=null;#Mi;#Si;#Ci;#Ei;#ki=null;#Ti;#Pi=null;#Di;#Ii=null;constructor({container:t,isPinchingDisabled:i=null,isPinchingStopped:e=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:o}){this.#kt=t,this.#xi=e,this.#Mi=i,this.#Si=s,this.#Ci=n,this.#Ei=r,this.#Di=new AbortController,this.#Ti=AbortSignal.any([o,this.#Di.signal]),t.addEventListener("touchstart",this.#Ri.bind(this),{passive:!1,signal:this.#Ti})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ht.pixelRatio}#Ri(t){if(this.#Mi?.())return;if(1===t.touches.length){if(this.#ki)return;const t=this.#ki=new AbortController,i=AbortSignal.any([this.#Ti,t.signal]),e=this.#kt,s={capture:!0,signal:i,passive:!1},n=t=>{"touch"===t.pointerType&&(this.#ki?.abort(),this.#ki=null)};return e.addEventListener("pointerdown",(t=>{"touch"===t.pointerType&&(Ft(t),n(t))}),s),e.addEventListener("pointerup",n,s),void e.addEventListener("pointercancel",n,s)}if(!this.#Ii){this.#Ii=new AbortController;const t=AbortSignal.any([this.#Ti,this.#Ii.signal]),i=this.#kt,e={signal:t,capture:!1,passive:!1};i.addEventListener("touchmove",this.#Ni.bind(this),e);const s=this.#Oi.bind(this);i.addEventListener("touchend",s,e),i.addEventListener("touchcancel",s,e),e.capture=!0,i.addEventListener("pointerdown",Ft,e),i.addEventListener("pointermove",Ft,e),i.addEventListener("pointercancel",Ft,e),i.addEventListener("pointerup",Ft,e),this.#Si?.()}if(Ft(t),2!==t.touches.length||this.#xi?.())return void(this.#Pi=null);let[i,e]=t.touches;i.identifier>e.identifier&&([i,e]=[e,i]),this.#Pi={touch0X:i.screenX,touch0Y:i.screenY,touch1X:e.screenX,touch1Y:e.screenY}}#Ni(t){if(!this.#Pi||2!==t.touches.length)return;Ft(t);let[i,e]=t.touches;i.identifier>e.identifier&&([i,e]=[e,i]);const{screenX:s,screenY:n}=i,{screenX:r,screenY:o}=e,h=this.#Pi,{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.#yi&&Math.abs(g-p)<=ui.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(h.touch0X=s,h.touch0Y=n,h.touch1X=r,h.touch1Y=o,!this.#yi)return void(this.#yi=!0);const m=[(s+r)/2,(n+o)/2];this.#Ci?.(m,g,p)}#Oi(t){t.touches.length>=2||(this.#Ii&&(this.#Ii.abort(),this.#Ii=null,this.#Ei?.()),this.#Pi&&(Ft(t),this.#Pi=null,this.#yi=!1))}destroy(){this.#Di?.abort(),this.#Di=null,this.#ki?.abort(),this.#ki=null}}class di{#_i=null;#Fi=null;#a=null;#c=null;#di=null;#Bi=!1;#Li=null;#Ui="";#$i=null;#ji=null;#zi=null;#Hi=null;#Wi=null;#Gi="";#Vi=!1;#Yi=null;#Xi=!1;#qi=!1;#Qi=!1;#Ki=null;#Ji=0;#Zi=0;#te=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;#ee=!1;#se=di._zIndex++;static _borderLineWidth=-1;static _colorManager=new hi;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=di.prototype._resizeWithKeyboard,i=ai.TRANSLATE_SMALL,e=ai.TRANSLATE_BIG;return rt(this,"_resizerKeyboardManager",new oi([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-i,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-e,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[i,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[e,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-i]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-e]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,i]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,e]}],[["Escape","mac+Escape"],di.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:i,rawDims:{pageWidth:e,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=i,this.pageRotation=(360+i-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[e,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}updatePageIndex(t){this.pageIndex=t}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return rt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const i=new fi({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});i.annotationElementId=t.annotationElementId,i.deleted=!0,i._uiManager.addToAnnotationStorage(i)}static initialize(t,i){if(di._l10n??=t,di._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!==di._borderLineWidth)return;const e=getComputedStyle(document.documentElement);di._borderLineWidth=parseFloat(e.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,i){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,i){tt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ee}set _isDraggable(t){this.#ee=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,i]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*i/(2*t),this.y+=this.width*t/(2*i);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*i/(2*t),this.y-=this.width*t/(2*i);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.#se}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#ne(),this.#Hi?.remove(),this.#Hi=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#Vi?this.#Vi=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const i=t.relatedTarget;i?.closest("#"+this.id)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,i,e,s){const[n,r]=this.parentDimensions;[e,s]=this.screenToPageTranslation(e,s),this.x=(t+e)/n,this.y=(i+s)/r,this.fixAndSetPosition()}_moveAfterPaste(t,i){if(this.isClone)return void delete this.isClone;const[e,s]=this.parentDimensions;this.setAt(t*e,i*s,this.width*e,this.height*s),this._onTranslated()}#re([t,i],e,s){[e,s]=this.screenToPageTranslation(e,s),this.x+=e/t,this.y+=s/i,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,i){this.#re(this.parentDimensions,t,i)}translateInPage(t,i){this.#Yi||=[this.x,this.y,this.width,this.height],this.#re(this.pageDimensions,t,i),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,i){this.#Yi||=[this.x,this.y,this.width,this.height];const{div:e,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=i/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:i}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,i)&&(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}=e;c.left=(100*r).toFixed(2)+"%",c.top=(100*o).toFixed(2)+"%",this._onTranslating(r,o),e.scrollIntoView({block:"nearest"})}_onTranslating(t,i){}_onTranslated(t,i){}get _hasBeenMoved(){return!!this.#Yi&&(this.#Yi[0]!==this.x||this.#Yi[1]!==this.y)}get _hasBeenResized(){return!!this.#Yi&&(this.#Yi[2]!==this.width||this.#Yi[3]!==this.height)}getBaseTranslation(){const[t,i]=this.parentDimensions,{_borderLineWidth:e}=di,s=e/t,n=e/i;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:i},pageDimensions:[e,s]}=this;let{x:n,y:r,width:o,height:h}=this;if(o*=e,h*=s,n*=e,r*=s,this._mustFixPosition)switch(t){case 0:n=Mt(n,0,e-o),r=Mt(r,0,s-h);break;case 90:n=Mt(n,0,e-h),r=Mt(r,o,s);break;case 180:n=Mt(n,o,e),r=Mt(r,h,s);break;case 270:n=Mt(n,h,e),r=Mt(r,0,s-o)}this.x=n/=e,this.y=r/=s;const[a,c]=this.getBaseTranslation();n+=a,r+=c,i.left=(100*n).toFixed(2)+"%",i.top=(100*r).toFixed(2)+"%",this.moveInDOM()}static#oe(t,i,e){switch(e){case 90:return[i,-t];case 180:return[-t,-i];case 270:return[-i,t];default:return[t,i]}}screenToPageTranslation(t,i){return di.#oe(t,i,this.parentRotation)}pageTranslationToScreen(t,i){return di.#oe(t,i,360-this.parentRotation)}#he(t){switch(t){case 90:{const[t,i]=this.pageDimensions;return[0,-t/i,i/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,i]=this.pageDimensions;return[0,t/i,-i/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:[i,e]}=this;return[i*t,e*t]}setDims(){const{div:{style:t},width:i,height:e}=this;t.width=(100*i).toFixed(2)+"%",t.height=(100*e).toFixed(2)+"%"}getInitialTranslation(){return[0,0]}#ae(){if(this.#$i)return;this.#$i=document.createElement("div"),this.#$i.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],i=this._uiManager._signal;for(const e of t){const t=document.createElement("div");this.#$i.append(t),t.classList.add("resizer",e),t.setAttribute("data-resizer-name",e),t.addEventListener("pointerdown",this.#ce.bind(this,e),{signal:i}),t.addEventListener("contextmenu",_t,{signal:i}),t.tabIndex=-1}this.div.prepend(this.#$i)}#ce(t,i){i.preventDefault();const{isMac:e}=pt.platform;if(0!==i.button||i.ctrlKey&&e)return;this.#a?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#ji=[i.screenX,i.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#le.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",Ft,{passive:!1,signal:r}),window.addEventListener("contextmenu",_t,{signal:r}),this.#zi={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(i.target).cursor;const a=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#a?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=o,this.div.style.cursor=h,this.#ue()};window.addEventListener("pointerup",a,{signal:r}),window.addEventListener("blur",a,{signal:r})}#de(t,i,e,s){this.width=e,this.height=s,this.x=t,this.y=i,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#ue(){if(!this.#zi)return;const{savedX:t,savedY:i,savedWidth:e,savedHeight:s}=this.#zi;this.#zi=null;const n=this.x,r=this.y,o=this.width,h=this.height;n===t&&r===i&&o===e&&h===s||this.addCommands({cmd:this.#de.bind(this,n,r,o,h),undo:this.#de.bind(this,t,i,e,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#le(t,i){const[e,s]=this.parentDimensions,n=this.x,r=this.y,o=this.width,h=this.height,a=di.MIN_SIZE/e,c=di.MIN_SIZE/s,l=this.#he(this.rotation),u=(t,i)=>[l[0]*t+l[2]*i,l[1]*t+l[3]*i],d=this.#he(360-this.rotation);let f,p,g=!1,m=!1;switch(t){case"topLeft":g=!0,f=()=>[0,0],p=(t,i)=>[t,i];break;case"topMiddle":f=t=>[t/2,0],p=(t,i)=>[t/2,i];break;case"topRight":g=!0,f=t=>[t,0],p=(t,i)=>[0,i];break;case"middleRight":m=!0,f=(t,i)=>[t,i/2],p=(t,i)=>[0,i/2];break;case"bottomRight":g=!0,f=(t,i)=>[t,i],p=()=>[0,0];break;case"bottomMiddle":f=(t,i)=>[t/2,i],p=t=>[t/2,0];break;case"bottomLeft":g=!0,f=(t,i)=>[0,i],p=t=>[t,0];break;case"middleLeft":m=!0,f=(t,i)=>[0,i/2],p=(t,i)=>[t,i/2]}const w=f(o,h),A=p(o,h);let v=u(...A);const b=di._round(n+v[0]),y=di._round(r+v[1]);let x,M,S=1,C=1;if(i.fromKeyboard)({deltaX:x,deltaY:M}=i);else{const{screenX:t,screenY:e}=i,[s,n]=this.#ji;[x,M]=this.screenToPageTranslation(t-s,e-n),this.#ji[0]=t,this.#ji[1]=e}if([x,M]=((t,i)=>[d[0]*t+d[2]*i,d[1]*t+d[3]*i])(x/e,M/s),g){const t=Math.hypot(o,h);S=C=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?S=Mt(Math.abs(A[0]-w[0]-x),a,1)/o:C=Mt(Math.abs(A[1]-w[1]-M),c,1)/h;const E=di._round(o*S),k=di._round(h*C);v=u(...p(E,k));const T=b-v[0],P=y-v[1];this.#Yi||=[this.x,this.y,this.width,this.height],this.width=E,this.height=k,this.x=T,this.y=P,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#a?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#qi)return this._editToolbar;this._editToolbar=new Zt(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[i,e]of t)await this._editToolbar.addButton(i,e);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#a?.destroy()}addContainer(t){const i=this._editToolbar?.div;i?i.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#a||(ci.initialize(di._l10n),this.#a=new ci(this),this.#_i&&(this.#a.data=this.#_i,this.#_i=null)),this.#a}get altTextData(){return this.#a?.data}set altTextData(t){this.#a&&(this.#a.data=t)}get guessedAltText(){return this.#a?.guessedText}async setGuessedAltText(t){await(this.#a?.setGuessedText(t))}serializeAltText(t){return this.#a?.serialize(t)}hasAltText(){return!!this.#a&&!this.#a.isEmpty()}hasAltTextData(){return this.#a?.hasData()??!1}focusCommentButton(){this.#c?.focusButton()}addCommentButton(){return this.canAddComment?this.#c||=new li(this):null}addStandaloneCommentButton(){this._uiManager.hasCommentManager()&&(this.#di?this._uiManager.isEditingMode()&&this.#di.classList.remove("hidden"):this.hasComment&&(this.#di=this.#c.renderForStandalone(),this.div.append(this.#di)))}removeStandaloneCommentButton(){this.#c.removeStandaloneCommentButton(),this.#di=null}hideStandaloneCommentButton(){this.#di?.classList.add("hidden")}get comment(){if(!this.#c)return null;const{data:{richText:t,text:i,date:e,deleted:s}}=this.#c;return{text:i,richText:t,date:e,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#c||=new li(this),"object"==typeof t&&null!==t?this.#c.restoreData(t):this.#c.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:i,richText:e}){if(!i)return;if(this.#c||=new li(this),this.#c.setInitialText(t,e),!this.annotationElementId)return;const s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return this.#c?.hasBeenEdited()}get hasDeletedComment(){return this.#c?.isDeleted()}get hasComment(){return!!this.#c&&!this.#c.isEmpty()&&!this.#c.isDeleted()}async editComment(t){this.#c||=new li(this),this.#c.edit(t)}toggleComment(t,i){this.hasComment&&this._uiManager.toggleComment(this,t,i)}setSelectedCommentButton(t){this.#c.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const i=180,e=100,[,,,s]=t.rect,[n]=this.pageDimensions,[r]=this.pageTranslation,o=r+n+1;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,s-e,o+i,s]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:i}}){this.#c.data=i?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#Bi?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#fe();const[i,e]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=(100*e/i).toFixed(2)+"%",t.style.maxHeight=(100*i/e).toFixed(2)+"%");const[s,n]=this.getInitialTranslation();return this.translate(s,n),ii(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#ie||=new ui({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#pe.bind(this),onPinching:this.#ge.bind(this),onPinchEnd:this.#me.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#pe(){this.#zi={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#a?.toggle(!1),this.parent.togglePointerEvents(!1)}#ge(t,i,e){let s=e/i*.7+1-.7;if(1===s)return;const n=this.#he(this.rotation),r=(t,i)=>[n[0]*t+n[2]*i,n[1]*t+n[3]*i],[o,h]=this.parentDimensions,a=this.x,c=this.y,l=this.width,u=this.height,d=di.MIN_SIZE/o,f=di.MIN_SIZE/h;s=Math.max(Math.min(s,1/l,1/u),d/l,f/u);const p=di._round(l*s),g=di._round(u*s);if(p===l&&g===u)return;this.#Yi||=[a,c,l,u];const m=r(l/2,u/2),w=di._round(a+m[0]),A=di._round(c+m[1]),v=r(p/2,g/2);this.x=w-v[0],this.y=A-v[1],this.width=p,this.height=g,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#me(){this.#a?.toggle(!0),this.parent.togglePointerEvents(!0),this.#ue()}pointerdown(t){const{isMac:i}=pt.platform;0!==t.button||t.ctrlKey&&i?t.preventDefault():(this.#Vi=!0,this._isDraggable?this.#we(t):this.#Ae(t))}#Ae(t){const{isMac:i}=pt.platform;t.ctrlKey&&!i||t.shiftKey||t.metaKey&&i?this.parent.toggleSelected(this):this.parent.setSelected(this)}#we(t){const{isSelected:i}=this;this._uiManager.setUpDragSession();let e=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},o=t=>{s.abort(),this.#Li=null,this.#Vi=!1,this._uiManager.endDragSession()||this.#Ae(t),e&&this._onStopDragging()};i&&(this.#Ji=t.clientX,this.#Zi=t.clientY,this.#Li=t.pointerId,this.#Ui=t.pointerType,window.addEventListener("pointermove",(t=>{e||(e=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:i,clientY:s,pointerId:n}=t;if(n!==this.#Li)return void Ft(t);const[r,o]=this.screenToPageTranslation(i-this.#Ji,s-this.#Zi);this.#Ji=i,this.#Zi=s,this._uiManager.dragSelectedEditors(r,o)}),r),window.addEventListener("touchmove",Ft,r),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#Ui&&(this.#ie||t.isPrimary)&&o(t),Ft(t)}),r));const h=t=>{this.#Li&&this.#Li!==t.pointerId?Ft(t):o(t)};window.addEventListener("pointerup",h,{signal:n}),window.addEventListener("blur",h,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ki&&clearTimeout(this.#Ki),this.#Ki=setTimeout((()=>{this.#Ki=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,i,e){t.changeParent(this),this.x=i,this.y=e,this.fixAndSetPosition(),this._onTranslated()}getRect(t,i,e=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[o,h]=this.pageTranslation,a=t/s,c=i/s,l=this.x*n,u=this.y*r,d=this.width*n,f=this.height*r;switch(e){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 Error("Invalid rotation")}}getRectInCurrentCoords(t,i){const[e,s,n,r]=t,o=n-e,h=r-s;switch(this.rotation){case 0:return[e,i-r,o,h];case 90:return[e,i-s,h,o];case 180:return[n,i-s,o,h];case 270:return[n,i-r,h,o];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&di._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#c?.onUpdatedColor()}getData(){const{comment:{text:t,color:i,date:e,opacity:s,deleted:n,richText:r},uid:o,pageIndex:h,creationDate:a,modificationDate:c}=this;return{id:o,pageIndex:h,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:a,modificationDate:e||c,popupRef:!n,color:i,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#qi=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#qi=!1,!0)}isInEditMode(){return this.#qi}shouldGetKeyboardEvents(){return this.#Qi}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:i,bottom:e,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return i<r&&s>0&&t<n&&e>0}#fe(){if(this.#Wi||!this.div)return;this.#Wi=new AbortController;const t=this._uiManager.combinedSignal(this.#Wi);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#fe()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,i=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,i,e){const s=new this.prototype.constructor({parent:i,id:e.getId(),uiManager:e,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,s.#_i=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.#Wi?.abort(),this.#Wi=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#Ki&&(clearTimeout(this.#Ki),this.#Ki=null),this.#ne(),this.removeEditToolbar(),this.#te){for(const t of this.#te.values())clearTimeout(t);this.#te=null}this.parent=null,this.#ie?.destroy(),this.#ie=null,this.#Hi?.remove(),this.#Hi=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#ae(),this.#$i.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,i]}=this,[e,s,n,r]=this.getPDFRect();return[di._round(e+(n-e)*t),di._round(s+(r-s)*(1-i))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#c.commentPopupPositionInLayer}set commentPopupPosition(t){this.#c.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#c.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#c.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#c?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#zi={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const i=this.#$i.children;if(!this.#Fi){this.#Fi=Array.from(i);const t=this.#ve.bind(this),e=this.#be.bind(this),s=this._uiManager._signal;for(const i of this.#Fi){const n=i.getAttribute("data-resizer-name");i.setAttribute("role","spinbutton"),i.addEventListener("keydown",t,{signal:s}),i.addEventListener("blur",e,{signal:s}),i.addEventListener("focus",this.#ye.bind(this,n),{signal:s}),i.setAttribute("data-l10n-id",di._l10nResizer[n])}}const e=this.#Fi[0];let s=0;for(const t of i){if(t===e)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#Fi.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#$i.append(this.#$i.firstElementChild);else if(n>s)for(let t=0;t<n-s;t++)this.#$i.firstElementChild.before(this.#$i.lastElementChild);let t=0;for(const e of i){const i=this.#Fi[t++].getAttribute("data-resizer-name");e.setAttribute("data-l10n-id",di._l10nResizer[i])}}this.#xe(0),this.#Qi=!0,this.#$i.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#ve(t){di._resizerKeyboardManager.exec(this,t)}#be(t){this.#Qi&&t.relatedTarget?.parentNode!==this.#$i&&this.#ne()}#ye(t){this.#Gi=this.#Qi?t:""}#xe(t){if(this.#Fi)for(const i of this.#Fi)i.tabIndex=t}_resizeWithKeyboard(t,i){this.#Qi&&this.#le(this.#Gi,{deltaX:t,deltaY:i,fromKeyboard:!0})}#ne(){this.#Qi=!1,this.#xe(-1),this.#ue()}_stopResizingWithKeyboard(){this.#ne(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#a?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})))}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout((()=>this.div?.focus({preventScroll:!0})),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#$i?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#a?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,i){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#Xi}set isEditing(t){this.#Xi=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,i=!1){if(i){this.#te||=new Map;const{action:i}=t;let e=this.#te.get(i);return e&&clearTimeout(e),e=setTimeout((()=>{this._reportTelemetry(t),this.#te.delete(i),0===this.#te.size&&(this.#te=null)}),di._telemetryTimeout),void this.#te.set(i,e)}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.#Bi=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#Bi=!0}updateFakeAnnotationElement(t){if(this.#Hi||this.deleted)return this.deleted?(this.#Hi.remove(),void(this.#Hi=null)):void((this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#Hi.updateEdited({rect:this.getPDFRect(),popup:this.comment}));this.#Hi=t.addFakeAnnotation(this)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let i=t.container.querySelector(".annotationContent");if(i){if("CANVAS"===i.nodeName){const t=i;i=document.createElement("div"),i.classList.add("annotationContent",this.editorType),t.before(i)}}else i=document.createElement("div"),i.classList.add("annotationContent",this.editorType),t.container.prepend(i);return i}resetAnnotationElement(t){const{firstElementChild:i}=t.container;"DIV"===i?.nodeName&&i.classList.contains("annotationContent")&&i.remove()}}class fi extends di{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const pi=3285377520,gi=4294901760,mi=65535;class wi{constructor(t){this.h1=t?4294967295&t:pi,this.h2=t?4294967295&t:pi}update(t){let i,e;if("string"==typeof t){i=new Uint8Array(2*t.length),e=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?i[e++]=n:(i[e++]=n>>>8,i[e++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw Error("Invalid data format, must be a string or TypedArray.");i=t.slice(),e=i.byteLength}const s=e>>2,n=e-4*s,r=new Uint32Array(i.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&gi|o*d&mi,o=o<<15|o>>>17,o=o*u&gi|o*f&mi,a^=o,a=a<<13|a>>>19,a=5*a+3864292196):(h=r[t],h=h*l&gi|h*d&mi,h=h<<15|h>>>17,h=h*u&gi|h*f&mi,c^=h,c=c<<13|c>>>19,c=5*c+3864292196);switch(o=0,n){case 3:o^=i[4*s+2]<<16;case 2:o^=i[4*s+1]<<8;case 1:o^=i[4*s],o=o*l&gi|o*d&mi,o=o<<15|o>>>17,o=o*u&gi|o*f&mi,1&s?a^=o:c^=o}this.h1=a,this.h2=c}hexdigest(){let t=this.h1,i=this.h2;return t^=i>>>1,t=3981806797*t&gi|36045*t&mi,i=4283543511*i&gi|(2950163797*(i<<16|t>>>16)&gi)>>>16,t^=i>>>1,t=444984403*t&gi|60499*t&mi,i=3301882366*i&gi|(3120437893*(i<<16|t>>>16)&gi)>>>16,t^=i>>>1,(t>>>0).toString(16).padStart(8,"0")+(i>>>0).toString(16).padStart(8,"0")}}const Ai=Object.freeze({map:null,hash:"",transfer:void 0});class vi{#Me=!1;#Se=null;#Ce=null;#Ee=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,i){const e=this.#Ee.get(t);return void 0===e?i:Object.assign(i,e)}getRawValue(t){return this.#Ee.get(t)}remove(t){const i=this.#Ee.get(t);void 0!==i&&(i instanceof di&&this.#Ce.delete(i.annotationElementId),this.#Ee.delete(t),0===this.#Ee.size&&this.resetModified(),this.#Ee.values().some((t=>t instanceof di))||this.onAnnotationEditor?.(null))}setValue(t,i){const e=this.#Ee.get(t);let s=!1;if(void 0!==e)for(const[t,n]of Object.entries(i))e[t]!==n&&(s=!0,e[t]=n);else s=!0,this.#Ee.set(t,i);s&&this.#ke(),i instanceof di&&((this.#Ce||=new Map).set(i.annotationElementId,i),this.onAnnotationEditor?.(i.constructor._type))}has(t){return this.#Ee.has(t)}get size(){return this.#Ee.size}#ke(){this.#Me||(this.#Me=!0,this.onSetModified?.())}resetModified(){this.#Me&&(this.#Me=!1,this.onResetModified?.())}get print(){return new bi(this)}get serializable(){if(0===this.#Ee.size)return Ai;const t=new Map,i=new wi,e=[],s=Object.create(null);let n=!1;for(const[e,r]of this.#Ee){const o=r instanceof di?r.serialize(!1,s):r;r.page&&(r.pageIndex=r.page._pageIndex,delete r.page),o&&(t.set(e,o),i.update(`${e}:${JSON.stringify(o)}`),n||=!!o.bitmap)}if(n)for(const i of t.values())i.bitmap&&e.push(i.bitmap);return t.size>0?{map:t,hash:i.hexdigest(),transfer:e}:Ai}get editorStats(){let t=null;const i=new Map;let e=0,s=0;for(const n of this.#Ee.values()){if(!(n instanceof di)){n.popup&&(n.popup.deleted?s+=1:e+=1);continue}n.isCommentDeleted?s+=1:n.hasEditedComment&&(e+=1);const r=n.telemetryFinalData;if(!r)continue;const{type:o}=r;i.has(o)||i.set(o,Object.getPrototypeOf(n).constructor),t||=Object.create(null);const h=t[o]||=new Map;for(const[t,i]of Object.entries(r)){if("type"===t)continue;const e=h.getOrInsertComputed(t,yt);e.set(i,(e.get(i)??0)+1)}}if((s>0||e>0)&&(t||=Object.create(null),t.comments={deleted:s,edited:e}),!t)return null;for(const[e,s]of i)t[e]=s.computeTelemetryFinalData(t[e]);return t}resetModifiedIds(){this.#Se=null}updateEditor(t,i){const e=this.#Ce?.get(t);return!!e&&(e.updateFromAnnotationLayer(i),!0)}getEditor(t){return this.#Ce?.get(t)||null}get modifiedIds(){if(this.#Se)return this.#Se;const t=[];if(this.#Ce)for(const i of this.#Ce.values())i.serialize()&&t.push(i.annotationElementId);let i="";if(t.length){const e=new wi;e.update(t.join(",")),i=e.hexdigest()}return this.#Se={ids:new Set(t),hash:i}}[Symbol.iterator](){return this.#Ee.entries()}}class bi extends vi{#Te=Ai;constructor(t){super();const{serializable:i}=t;if(i===Ai)return;const{map:e,hash:s,transfer:n}=i,r=structuredClone(e,n?{transfer:n}:null);this.#Te={map:r,hash:s,transfer:[]}}get print(){tt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#Te}get modifiedIds(){return rt(this,"modifiedIds",{ids:new Set,hash:""})}}_(7588);const yi="__forcedDependency",{floor:xi,ceil:Mi}=Math;function Si(t,i,e,s,n,r){t[4*i+0]=Math.min(t[4*i+0],e),t[4*i+1]=Math.min(t[4*i+1],s),t[4*i+2]=Math.max(t[4*i+2],n),t[4*i+3]=Math.max(t[4*i+3],r)}const Ci=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class Ei{#Pe;#De;constructor(t,i){this.#Pe=t,this.#De=i}get length(){return this.#Pe.length}isEmpty(t){return this.#Pe[t]===Ci}minX(t){return this.#De[4*t+0]/256}minY(t){return this.#De[4*t+1]/256}maxX(t){return(this.#De[4*t+2]+1)/256}maxY(t){return(this.#De[4*t+3]+1)/256}}const ki=(t,i)=>t?.getOrInsertComputed(i,(()=>({dependencies:new Set,isRenderingOperation:!1})));class Ti{#Ie=[[1,0,0,1,0,0]];#Re=[-1/0,-1/0,1/0,1/0];#Ne=new Float64Array(B);_pendingBBoxIdx=-1;#Oe;#_e;#Fe;#Pe;_savesStack=[];_markedContentStack=[];constructor(t,i){this.#Oe=t.width,this.#_e=t.height,this.#Be(i)}growOperationsCount(t){t>=this.#Pe.length&&this.#Be(t,this.#Pe)}#Be(t,i){const e=new ArrayBuffer(4*t);this.#Fe=new Uint8ClampedArray(e),this.#Pe=new Uint32Array(e),i&&i.length>0?(this.#Pe.set(i),this.#Pe.fill(Ci,i.length)):this.#Pe.fill(Ci)}get clipBox(){return this.#Re}save(t){return this.#Re={__proto__:this.#Re},this._savesStack.push(t),this}restore(t,i){const e=Object.getPrototypeOf(this.#Re);if(null===e)return this;this.#Re=e;const s=this._savesStack.pop();return void 0!==s&&(i?.(s,t),this.#Pe[t]=this.#Pe[s]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return 0===this._savesStack.length?null:this._savesStack.at(-1)}recordCloseMarker(t,i){const e=this._savesStack.pop();return void 0!==e&&(i?.(e,t),this.#Pe[t]=this.#Pe[e]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,i){const e=this._markedContentStack.pop();return void 0!==e&&(i?.(e,t),this.#Pe[t]=this.#Pe[e]),this}pushBaseTransform(t){return this.#Ie.push(gt.multiplyByDOMMatrix(this.#Ie.at(-1),t.getTransform())),this}popBaseTransform(){return this.#Ie.length>1&&this.#Ie.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#Ne.set(B,0)),this}recordClipBox(t,i,e,s,n,r){const o=gt.multiplyByDOMMatrix(this.#Ie.at(-1),i.getTransform()),h=B.slice();gt.axialAlignedBoundingBox([e,n,s,r],o,h);const a=gt.intersect(this.#Re,h);return a?(this.#Re[0]=a[0],this.#Re[1]=a[1],this.#Re[2]=a[2],this.#Re[3]=a[3]):(this.#Re[0]=this.#Re[1]=1/0,this.#Re[2]=this.#Re[3]=-1/0),this}recordBBox(t,i,e,s,n,r){const o=this.#Re;if(o[0]===1/0)return this;const h=gt.multiplyByDOMMatrix(this.#Ie.at(-1),i.getTransform());if(o[0]===-1/0)return gt.axialAlignedBoundingBox([e,n,s,r],h,this.#Ne),this;const a=B.slice();return gt.axialAlignedBoundingBox([e,n,s,r],h,a),this.#Ne[0]=Mt(a[0],o[0],this.#Ne[0]),this.#Ne[1]=Mt(a[1],o[1],this.#Ne[1]),this.#Ne[2]=Mt(a[2],this.#Ne[2],o[2]),this.#Ne[3]=Mt(a[3],this.#Ne[3],o[3]),this}recordFullPageBBox(t){return this.#Ne[0]=Math.max(0,this.#Re[0]),this.#Ne[1]=Math.max(0,this.#Re[1]),this.#Ne[2]=Math.min(this.#Oe,this.#Re[2]),this.#Ne[3]=Math.min(this.#_e,this.#Re[3]),this}recordOperation(t,i=!1,e){if(this._pendingBBoxIdx!==t)return this;const s=xi(256*this.#Ne[0]/this.#Oe),n=xi(256*this.#Ne[1]/this.#_e),r=Mi(256*this.#Ne[2]/this.#Oe),o=Mi(256*this.#Ne[3]/this.#_e);if(Si(this.#Fe,t,s,n,r,o),e)for(const i of e)for(const e of i)e!==t&&Si(this.#Fe,e,s,n,r,o);return i||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#Re[0]=Math.max(this.#Re[0],this.#Ne[0]),this.#Re[1]=Math.max(this.#Re[1],this.#Ne[1]),this.#Re[2]=Math.min(this.#Re[2],this.#Ne[2]),this.#Re[3]=Math.min(this.#Re[3],this.#Ne[3])),this}take(){return new Ei(this.#Pe,this.#Fe)}takeDebugMetadata(){throw Error("Unreachable")}recordSimpleData(t,i){return this}recordIncrementalData(t,i){return this}resetIncrementalData(t,i){return this}recordNamedData(t,i){return this}recordSimpleDataFromNamed(t,i,e){return this}recordFutureForcedDependency(t,i){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,i,e,s=1,n=0,r=0,o){return this}getSimpleIndex(t){}recordDependencies(t,i){return this}recordNamedDependency(t,i){return this}recordShowTextOperation(t,i=!1){return this}}class Pi{#Le={__proto__:null};#Ue={__proto__:null,transform:[],moveText:[],sameLineText:[],[yi]:[]};#$e=new Map;#je=new Set;#ze=new Map;#He;#We;#Ge;constructor(t,i=!1){this.#Ge=t,i&&(this.#He=new Map,this.#We=(t,i)=>{ki(this.#He,i).dependencies.add(t)})}get clipBox(){return this.#Ge.clipBox}growOperationsCount(t){this.#Ge.growOperationsCount(t)}save(t){return this.#Le={__proto__:this.#Le},this.#Ue={__proto__:this.#Ue,transform:{__proto__:this.#Ue.transform},moveText:{__proto__:this.#Ue.moveText},sameLineText:{__proto__:this.#Ue.sameLineText},[yi]:{__proto__:this.#Ue[yi]}},this.#Ge.save(t),this}restore(t){this.#Ge.restore(t,this.#We);const i=Object.getPrototypeOf(this.#Le);return null===i||(this.#Le=i,this.#Ue=Object.getPrototypeOf(this.#Ue)),this}recordOpenMarker(t){return this.#Ge.recordOpenMarker(t,this.#We),this}getOpenMarker(){return this.#Ge.getOpenMarker()}recordCloseMarker(t){return this.#Ge.recordCloseMarker(t,this.#We),this}beginMarkedContent(t){return this.#Ge.beginMarkedContent(t),this}endMarkedContent(t){return this.#Ge.endMarkedContent(t,this.#We),this}pushBaseTransform(t){return this.#Ge.pushBaseTransform(t),this}popBaseTransform(){return this.#Ge.popBaseTransform(),this}recordSimpleData(t,i){return this.#Le[t]=i,this}recordIncrementalData(t,i){return this.#Ue[t].push(i),this}resetIncrementalData(t,i){return this.#Ue[t].length=0,this}recordNamedData(t,i){return this.#$e.set(t,i),this}recordSimpleDataFromNamed(t,i,e){this.#Le[t]=this.#$e.get(i)??e}recordFutureForcedDependency(t,i){return this.recordIncrementalData(yi,i),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const i of t)i in this.#Le&&this.recordFutureForcedDependency(i,this.#Le[i]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#je)this.recordFutureForcedDependency(yi,t);return this}resetBBox(t){return this.#Ge.resetBBox(t),this}recordClipBox(t,i,e,s,n,r){return this.#Ge.recordClipBox(t,i,e,s,n,r),this}recordBBox(t,i,e,s,n,r){return this.#Ge.recordBBox(t,i,e,s,n,r),this}recordCharacterBBox(t,i,e,s=1,n=0,r=0,o){const h=e.bbox;let a,c;if(h&&(a=h[2]!==h[0]&&h[3]!==h[1]&&this.#ze.get(e),!1!==a&&(c=[0,0,0,0],gt.axialAlignedBoundingBox(h,e.fontMatrix,c),1===s&&0===n&&0===r||gt.scaleMinMax([s,0,0,-s,n,r],c),a)))return this.recordBBox(t,i,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(t);const l=o();return h&&c&&void 0===a&&(a=c[0]<=n-l.actualBoundingBoxLeft&&c[2]>=n+l.actualBoundingBoxRight&&c[1]<=r-l.actualBoundingBoxAscent&&c[3]>=r+l.actualBoundingBoxDescent,this.#ze.set(e,a),a)?this.recordBBox(t,i,c[0],c[2],c[1],c[3]):this.recordBBox(t,i,n-l.actualBoundingBoxLeft,n+l.actualBoundingBoxRight,r-l.actualBoundingBoxAscent,r+l.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#Ge.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#Le[t]}recordDependencies(t,i){const e=this.#je,s=this.#Le,n=this.#Ue;for(const t of i)t in this.#Le?e.add(s[t]):t in n&&n[t].forEach(e.add,e);return this}recordNamedDependency(t,i){return this.#$e.has(i)&&this.#je.add(this.#$e.get(i)),this}recordOperation(t,i=!1){if(this.recordDependencies(t,[yi]),this.#He){const i=ki(this.#He,t),{dependencies:e}=i;this.#je.forEach(e.add,e),this.#Ge._savesStack.forEach(e.add,e),this.#Ge._markedContentStack.forEach(e.add,e),e.delete(t),i.isRenderingOperation=!0}const e=!i&&t===this.#Ge._pendingBBoxIdx;return this.#Ge.recordOperation(t,i,[this.#je,this.#Ge._savesStack,this.#Ge._markedContentStack]),e&&this.#je.clear(),this}recordShowTextOperation(t,i=!1){const e=Array.from(this.#je);this.recordOperation(t,i),this.recordIncrementalData("sameLineText",t);for(const t of e)this.recordIncrementalData("sameLineText",t);return this}bboxToClipBoxDropOperation(t,i=!1){const e=!i&&t===this.#Ge._pendingBBoxIdx;return this.#Ge.bboxToClipBoxDropOperation(t),e&&this.#je.clear(),this}take(){return this.#ze.clear(),this.#Ge.take()}takeDebugMetadata(){return this.#He}}class Di{#Ve;#Ye;#Xe;#qe=0;#Qe=0;constructor(t,i,e){if(t instanceof Di&&t.#Xe===!!e)return t;this.#Ve=t,this.#Ye=i,this.#Xe=!!e}get clipBox(){return this.#Ve.clipBox}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#Qe++,this.#Ve.save(this.#Ye),this}restore(t){return this.#Qe>0&&(this.#Ve.restore(this.#Ye),this.#Qe--),this}recordOpenMarker(t){return this.#qe++,this}getOpenMarker(){return this.#qe>0?this.#Ye:this.#Ve.getOpenMarker()}recordCloseMarker(t){return this.#qe--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#Ve.pushBaseTransform(t),this}popBaseTransform(){return this.#Ve.popBaseTransform(),this}recordSimpleData(t,i){return this.#Ve.recordSimpleData(t,this.#Ye),this}recordIncrementalData(t,i){return this.#Ve.recordIncrementalData(t,this.#Ye),this}resetIncrementalData(t,i){return this.#Ve.resetIncrementalData(t,this.#Ye),this}recordNamedData(t,i){return this}recordSimpleDataFromNamed(t,i,e){return this.#Ve.recordSimpleDataFromNamed(t,i,this.#Ye),this}recordFutureForcedDependency(t,i){return this.#Ve.recordFutureForcedDependency(t,this.#Ye),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#Ve.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#Ve.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#Xe||this.#Ve.resetBBox(this.#Ye),this}recordClipBox(t,i,e,s,n,r){return this.#Xe||this.#Ve.recordClipBox(this.#Ye,i,e,s,n,r),this}recordBBox(t,i,e,s,n,r){return this.#Xe||this.#Ve.recordBBox(this.#Ye,i,e,s,n,r),this}recordCharacterBBox(t,i,e,s,n,r,o){return this.#Xe||this.#Ve.recordCharacterBBox(this.#Ye,i,e,s,n,r,o),this}recordFullPageBBox(t){return this.#Xe||this.#Ve.recordFullPageBBox(this.#Ye),this}getSimpleIndex(t){return this.#Ve.getSimpleIndex(t)}recordDependencies(t,i){return this.#Ve.recordDependencies(this.#Ye,i),this}recordNamedDependency(t,i){return this.#Ve.recordNamedDependency(this.#Ye,i),this}recordOperation(t){return this.#Ve.recordOperation(this.#Ye,!0),this}recordShowTextOperation(t){return this.#Ve.recordShowTextOperation(this.#Ye,!0),this}bboxToClipBoxDropOperation(t){return this.#Xe||this.#Ve.bboxToClipBoxDropOperation(this.#Ye,!0),this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}const Ii=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],Ri=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],Ni=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],Oi=["filter","fillColor","fillAlpha"],_i=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],Fi=["transform"],Bi=["transform","fillColor"];class Li{#Oe;#_e;#Ke=4;#Je=0;#De=new Li.#Ze(6*this.#Ke);static#Ze=pt.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#Oe=t.width,this.#_e=t.height}record(t,i,e,s){if(this.#Je===this.#Ke){this.#Ke*=2;const t=new Li.#Ze(6*this.#Ke);t.set(this.#De),this.#De=t}const n=gt.domMatrixToTransform(t.getTransform());let r;if(s[0]!==1/0){const t=B.slice();gt.axialAlignedBoundingBox([0,-e,i,0],n,t);const o=gt.intersect(s,t);if(!o)return;const[h,a,c,l]=o;if(h!==t[0]||a!==t[1]||c!==t[2]||l!==t[3]){const t=Math.atan2(n[1],n[0]),i=Math.abs(Math.sin(t)),e=Math.abs(Math.cos(t));if(i<1e-6||e<1e-6||Math.abs(i-e)<1e-6)r=[h,a,h,l,c,a];else{const t=c-h,s=l-a,n=i*i,o=e*e,u=e*i,d=o-n,f=(s*o-t*u)/d;r=[h+(s*u-t*n)/d,a,h,a+f,c,l-f]}}}r||(r=[0,-e,0,0,i,-e],gt.applyTransform(r,n,0),gt.applyTransform(r,n,2),gt.applyTransform(r,n,4)),r[0]/=this.#Oe,r[1]/=this.#_e,r[2]/=this.#Oe,r[3]/=this.#_e,r[4]/=this.#Oe,r[5]/=this.#_e,this.#De.set(r,6*this.#Je),this.#Je++}take(){return this.#De.subarray(0,6*this.#Je)}}class Ui{#ts=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:i=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 i=this.styleElement.sheet;i.insertRule(t,i.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ts.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:i,_inspectFont:e}){if(t&&!this.#ts.has(t.loadedName))if(it(!i,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:s,style:n}=t,r=new FontFace(i,s,n);this.addNativeFontFace(r);try{await r.load(),this.#ts.add(i),e?.(t)}catch{Z(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else tt("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 i=t.createNativeFontFace();if(i){this.addNativeFontFace(i);try{await i.loaded}catch(e){throw Z(`Failed to load font '${i.family}': '${e}'.`),t.disableFontFace=!0,e}}return}const i=t.createFontFaceRule();if(i){if(this.insertRule(i),this.isSyncFontLoadingSupported)return;await new Promise((i=>{const e=this._queueLoadingCallback(i);this._prepareFontLoadEvent(t,e)}))}}get isFontLoadingAPISupported(){return rt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return rt(this,"isSyncFontLoadingSupported",F||pt.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:i}=this,e={done:!1,complete:function(){for(it(!e.done,"completeRequest() cannot be called twice."),e.done=!0;i.length>0&&i[0].done;){const t=i.shift();setTimeout(t.callback,0)}},callback:t};return i.push(e),e}get _loadTestFont(){return rt(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,i){function e(t,i){return t.charCodeAt(i)<<24|t.charCodeAt(i+1)<<16|t.charCodeAt(i+2)<<8|255&t.charCodeAt(i+3)}function s(t,i,e,s){return t.substring(0,i)+s+t.substring(i+e)}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=e(l,16);for(n=0,r=c.length-3;n<r;n+=4)d=d-u+e(c,n)|0;n<c.length&&(d=d-u+e(c+"XXX",n)|0),l=s(l,16,4,function(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)}(d));const f=`url(data:font/opentype;base64,${btoa(l)});`;this.insertRule(`@font-face {font-family:"${c}";src:${f}}`);const p=this._document.createElement("div");p.style.visibility="hidden",p.style.width=p.style.height="10px",p.style.position="absolute",p.style.top=p.style.left="0px";for(const i of[t.loadedName,c]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=i,p.append(t)}this._document.body.append(p),function t(i,e){if(++a>30)return Z("Load test font never loaded."),void e();h.font="30px "+i,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0?e():setTimeout(t.bind(null,i,e))}(c,(()=>{p.remove(),i.complete()}))}}class $i{compiledGlyphs=Object.create(null);#is;constructor(t,i=null,e,s){this.#is=t,this._inspectFont=i,e&&(this.charProcOperatorList=e),s&&Object.assign(this,s)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const i={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(i.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,i)}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,${this.data.toBase64()});`;let i;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${t}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),i}getPathGenerator(t,i){if(void 0!==this.compiledGlyphs[i])return this.compiledGlyphs[i];const e=this.loadedName+"_path_"+i;let s;try{s=t.get(e)}catch(t){Z(`getPathGenerator - ignoring character: "${t}".`)}const n=Jt(s?.path);return this.fontExtraProperties||t.delete(e),this.compiledGlyphs[i]=n}get black(){return this.#is.black}get bold(){return this.#is.bold}get disableFontFace(){return this.#is.disableFontFace}set disableFontFace(t){rt(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#is.fontExtraProperties}get isInvalidPDFjsFont(){return this.#is.isInvalidPDFjsFont}get isType3Font(){return this.#is.isType3Font}get italic(){return this.#is.italic}get missingFile(){return this.#is.missingFile}get remeasure(){return this.#is.remeasure}get vertical(){return this.#is.vertical}get ascent(){return this.#is.ascent}get defaultWidth(){return this.#is.defaultWidth}get descent(){return this.#is.descent}get bbox(){return this.#is.bbox}get fontMatrix(){return this.#is.fontMatrix}get fallbackName(){return this.#is.fallbackName}get loadedName(){return this.#is.loadedName}get mimetype(){return this.#is.mimetype}get name(){return this.#is.name}get data(){return this.#is.data}clearData(){this.#is.clearData()}get cssFontInfo(){return this.#is.cssFontInfo}get systemFontInfo(){return this.#is.systemFontInfo}get defaultVMetrics(){return this.#is.defaultVMetrics}}class ji{static strings=["fontFamily","fontWeight","italicAngle"]}class zi{static strings=["css","loadedName","baseFontName","src"]}class Hi{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(2*this.bools.length/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+8*this.numbers.length;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class Wi{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class Gi{#es;#ss=new TextDecoder;#ns;constructor(t){this.#es=t,this.#ns=new DataView(t)}#rs(t){it(t<ji.strings.length,"Invalid string index");let i=0;for(let e=0;e<t;e++)i+=this.#ns.getUint32(i)+4;const e=this.#ns.getUint32(i);return this.#ss.decode(new Uint8Array(this.#es,i+4,e))}get fontFamily(){return this.#rs(0)}get fontWeight(){return this.#rs(1)}get italicAngle(){return this.#rs(2)}}class Vi{#es;#ss=new TextDecoder;#ns;constructor(t){this.#es=t,this.#ns=new DataView(t)}get guessFallback(){return 0!==this.#ns.getUint8(0)}#rs(t){it(t<zi.strings.length,"Invalid string index");let i=5;for(let e=0;e<t;e++)i+=this.#ns.getUint32(i)+4;const e=this.#ns.getUint32(i);return this.#ss.decode(new Uint8Array(this.#es,i+4,e))}get css(){return this.#rs(0)}get loadedName(){return this.#rs(1)}get baseFontName(){return this.#rs(2)}get src(){return this.#rs(3)}get style(){let t=1;t+=4+this.#ns.getUint32(t);const i=this.#ns.getUint32(t),e=this.#ss.decode(new Uint8Array(this.#es,t+4,i));t+=4+i;const s=this.#ns.getUint32(t);return{style:e,weight:this.#ss.decode(new Uint8Array(this.#es,t+4,s))}}}class Yi{#es;#ss=new TextDecoder;#ns;constructor({buffer:t,extra:i}){this.#es=t,this.#ns=new DataView(t),i&&Object.assign(this,i)}#os(t){it(t<Hi.bools.length,"Invalid boolean index");const i=2*t%8,e=this.#ns.getUint8(Math.floor(t/4))>>i&3;return 0===e?void 0:2===e}get black(){return this.#os(0)}get bold(){return this.#os(1)}get disableFontFace(){return this.#os(2)}get fontExtraProperties(){return this.#os(3)}get isInvalidPDFjsFont(){return this.#os(4)}get isType3Font(){return this.#os(5)}get italic(){return this.#os(6)}get missingFile(){return this.#os(7)}get remeasure(){return this.#os(8)}get vertical(){return this.#os(9)}#hs(t){return it(t<Hi.numbers.length,"Invalid number index"),this.#ns.getFloat64(Hi.OFFSET_NUMBERS+8*t)}get ascent(){return this.#hs(0)}get defaultWidth(){return this.#hs(1)}get descent(){return this.#hs(2)}#as(t,i,e,s){const n=this.#ns.getUint8(t);if(0===n)return;it(n===i,"Invalid array length."),t+=1;const r=Array(n);for(let i=0;i<n;i++)r[i]=this.#ns[e](t,!0),t+=s;return r}get bbox(){return this.#as(Hi.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#as(Hi.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#as(Hi.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#rs(t){it(t<Hi.strings.length,"Invalid string index");let i=Hi.OFFSET_STRINGS+4;for(let e=0;e<t;e++)i+=this.#ns.getUint32(i)+4;const e=this.#ns.getUint32(i);return this.#ss.decode(new Uint8Array(this.#es,i+4,e))}get fallbackName(){return this.#rs(0)}get loadedName(){return this.#rs(1)}get mimetype(){return this.#rs(2)}get name(){return this.#rs(3)}#cs(){let t=Hi.OFFSET_STRINGS;return t+=4+this.#ns.getUint32(t),t+=4+this.#ns.getUint32(t),t+=4+this.#ns.getUint32(t),{offset:t,length:this.#ns.getUint32(t)}}get data(){const{offset:t,length:i}=this.#cs();return 0===i?void 0:new Uint8Array(this.#es,t+4,i)}clearData(){const{offset:t,length:i}=this.#cs();0!==i&&(this.#ns.setUint32(t,0),this.#es=new Uint8Array(this.#es,0,t+4).slice().buffer,this.#ns=new DataView(this.#es))}get cssFontInfo(){let t=Hi.OFFSET_STRINGS;t+=4+this.#ns.getUint32(t),t+=4+this.#ns.getUint32(t);const i=this.#ns.getUint32(t);if(0===i)return null;const e=new Uint8Array(i);return e.set(new Uint8Array(this.#es,t+4,i)),new Gi(e.buffer)}get systemFontInfo(){let t=Hi.OFFSET_STRINGS;t+=4+this.#ns.getUint32(t);const i=this.#ns.getUint32(t);if(0===i)return null;const e=new Uint8Array(i);return e.set(new Uint8Array(this.#es,t+4,i)),new Vi(e.buffer)}}class Xi{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,i=this.data[Wi.KIND],e=!!this.data[Wi.HAS_BBOX],s=!!this.data[Wi.HAS_BACKGROUND],n=t.getUint32(Wi.N_COORD,!0),r=t.getUint32(Wi.N_COLOR,!0),o=t.getUint32(Wi.N_STOP,!0);let h=20;const a=new Float32Array(this.buffer,h,2*n);h+=8*n;const c=new Uint8Array(this.buffer,h,4*r);h+=4*r;const l=[];for(let i=0;i<o;++i){const i=t.getFloat32(h,!0);h+=4;const e=t.getUint32(h,!0);h+=4,l.push([i,"#"+e.toString(16).padStart(6,"0")])}let u=null;if(e){u=[];for(let i=0;i<4;++i)u.push(t.getFloat32(h,!0)),h+=4}let d=null;if(s&&(d=new Uint8Array(this.buffer,h,3),h+=3),1===i)return["RadialAxial","axial",u,l,Array.from(a.slice(0,2)),Array.from(a.slice(2,4)),null,null];if(2===i)return["RadialAxial","radial",u,l,[a[0],a[1]],[a[3],a[4]],a[2],a[5]];if(3===i){const t=this.data[Wi.SHADING_TYPE];let i=null;if(a.length>0){i=B.slice();for(let t=0,e=a.length;t<e;t+=2)gt.pointBoundingBox(a[t],a[t+1],i)}return["Mesh",t,a,c,n,i,u,d]}throw Error("Unsupported pattern kind: "+i)}}class qi{#es;constructor(t){this.#es=t}get path(){return pt.isFloat16ArraySupported?new Float16Array(this.#es):new Float32Array(this.#es)}}function Qi(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}const Ki=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,Ji=function(t,i,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,n,...r]=e;if(!t(s)&&!Number.isInteger(s))return!1;if(!i(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,Ki,(t=>"object"==typeof t&&"string"==typeof t?.name));class Zi{#ls=new Map;#us=Promise.resolve();postMessage(t,i){const e={data:structuredClone(t,i?{transfer:i}:null)};this.#us.then((()=>{for(const[t]of this.#ls)t.call(this,e)}))}addEventListener(t,i,e=null){let s=null;if(e?.signal instanceof AbortSignal){const{signal:n}=e;if(n.aborted)return void Z("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,i);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#ls.set(i,s)}removeEventListener(t,i){const e=this.#ls.get(i);e?.(),this.#ls.delete(i)}terminate(){for(const[,t]of this.#ls)t?.();this.#ls.clear()}}_(1689);function te(){}function ie(t){if(t instanceof dt||t instanceof ct||t instanceof ht||t instanceof lt||t instanceof at)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||tt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new dt(t.message);case"InvalidPDFException":return new ct(t.message);case"PasswordException":return new ht(t.message,t.code);case"ResponseException":return new lt(t.message,t.status,t.missing);case"UnknownErrorException":return new at(t.message,t.details)}return new at(t.message,""+t)}class ee{#ds=new AbortController;constructor(t,i,e){this.sourceName=t,this.targetName=i,this.comObj=e,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),e.addEventListener("message",this.#fs.bind(this),{signal:this.#ds.signal})}#fs({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ps(t);if(t.callback){const i=t.callbackId,e=this.callbackCapabilities[i];if(!e)throw Error("Cannot resolve callback "+i);if(delete this.callbackCapabilities[i],1===t.callback)e.resolve(t.data);else{if(2!==t.callback)throw Error("Unexpected callback case");e.reject(ie(t.reason))}return}const i=this.actionHandler[t.action];if(!i)throw Error("Unknown action from worker: "+t.action);if(t.callbackId){const e=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(i,t.data).then((function(i){n.postMessage({sourceName:e,targetName:s,callback:1,callbackId:t.callbackId,data:i})}),(function(i){n.postMessage({sourceName:e,targetName:s,callback:2,callbackId:t.callbackId,reason:ie(i)})}))}else t.streamId?this.#gs(t):i(t.data)}on(t,i){const e=this.actionHandler;if(e[t])throw Error(`There is already an actionName called "${t}"`);e[t]=i}send(t,i,e){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:i},e)}sendWithPromise(t,i,e){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:i},e)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,i,e,s){const n=this.streamId++,r=this.sourceName,o=this.targetName,h=this.comObj;return new ReadableStream({start:e=>{const a=Promise.withResolvers();return this.streamControllers[n]={controller:e,startCall:a,pullCall:null,cancelCall:null,isClosed:!1},h.postMessage({sourceName:r,targetName:o,action:t,streamId:n,data:i,desiredSize:e.desiredSize},s),a.promise},pull:t=>{const i=Promise.withResolvers();return this.streamControllers[n].pullCall=i,h.postMessage({sourceName:r,targetName:o,stream:6,streamId:n,desiredSize:t.desiredSize}),i.promise},cancel:t=>{it(t instanceof Error,"cancel must have a valid reason");const i=Promise.withResolvers();return this.streamControllers[n].cancelCall=i,this.streamControllers[n].isClosed=!0,h.postMessage({sourceName:r,targetName:o,stream:1,streamId:n,reason:ie(t)}),i.promise}},e)}#gs(t){const i=t.streamId,e=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:e,targetName:s,stream:4,streamId:i,chunk:t},o)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:e,targetName:s,stream:3,streamId:i}),delete r.streamSinks[i])},error(t){it(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:e,targetName:s,stream:5,streamId:i,reason:ie(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[i]=h,Promise.try(o,t.data,h).then((function(){n.postMessage({sourceName:e,targetName:s,stream:8,streamId:i,success:!0})}),(function(t){n.postMessage({sourceName:e,targetName:s,stream:8,streamId:i,reason:ie(t)})}))}#ps(t){const i=t.streamId,e=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[i],o=this.streamSinks[i];switch(t.stream){case 8:t.success?r.startCall.resolve():r.startCall.reject(ie(t.reason));break;case 7:t.success?r.pullCall.resolve():r.pullCall.reject(ie(t.reason));break;case 6:if(!o){n.postMessage({sourceName:e,targetName:s,stream:7,streamId:i,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||te).then((function(){n.postMessage({sourceName:e,targetName:s,stream:7,streamId:i,success:!0})}),(function(t){n.postMessage({sourceName:e,targetName:s,stream:7,streamId:i,reason:ie(t)})}));break;case 4:if(it(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case 3:if(it(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#ms(r,i);break;case 5:it(r,"error should have stream controller"),r.controller.error(ie(t.reason)),this.#ms(r,i);break;case 2:t.success?r.cancelCall.resolve():r.cancelCall.reject(ie(t.reason)),this.#ms(r,i);break;case 1:if(!o)break;const h=ie(t.reason);Promise.try(o.onCancel||te,h).then((function(){n.postMessage({sourceName:e,targetName:s,stream:2,streamId:i,success:!0})}),(function(t){n.postMessage({sourceName:e,targetName:s,stream:2,streamId:i,reason:ie(t)})})),o.sinkCapability.reject(h),o.isCancelled=!0,delete this.streamSinks[i];break;default:throw Error("Unexpected stream case")}}async#ms(t,i){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[i]}destroy(){this.#ds?.abort(),this.#ds=null}}class se{#ws=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:i=null,wasmUrl:e=null}){this.cMapUrl=t,this.standardFontDataUrl=i,this.wasmUrl=e}async fetch({kind:t,filename:i}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:tt("Not implemented: "+t)}const e=this[t];if(!e)throw Error(`Ensure that the \`${t}\` API parameter is provided.`);const s=`${e}${i}`;return this._fetch(s,t).catch((()=>{throw Error(`Unable to load ${this.#ws[t]} data at: ${s}`)}))}async _fetch(t,i){tt("Abstract method `_fetch` called.")}}class ne extends se{async _fetch(t,i){const e="cMapUrl"!==i||t.endsWith(".bcmap")?"bytes":"text",s=await Tt(t,e);return s instanceof Uint8Array?s:ft(s)}}class re{#As=!1;constructor({enableHWA:t=!1}){this.#As=t}create(t,i){if(t<=0||i<=0)throw Error("Invalid canvas size");const e=this._createCanvas(t,i);return{canvas:e,context:e.getContext("2d",{willReadFrequently:!this.#As})}}reset({canvas:t},i,e){if(!t)throw Error("Canvas is not specified");if(i<=0||e<=0)throw Error("Invalid canvas size");t.width=i,t.height=e}destroy(t){const{canvas:i}=t;if(!i)throw Error("Canvas is not specified");i.width=i.height=0,t.canvas=null,t.context=null}_createCanvas(t,i){tt("Abstract method `_createCanvas` called.")}}class oe extends re{constructor({ownerDocument:t=globalThis.document,enableHWA:i=!1}){super({enableHWA:i}),this._document=t}_createCanvas(t,i){const e=this._document.createElement("canvas");return e.width=t,e.height=i,e}}_(2489);class he{addFilter(t){return"none"}addHCMFilter(t,i){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,i,e,s,n){return"none"}destroy(t=!1){}}class ae extends he{#vs;#bs;#ys;#xs;#Ms;#Ss;#E=0;constructor({docId:t,ownerDocument:i=globalThis.document}){super(),this.#xs=t,this.#Ms=i}get#T(){return this.#bs||=new Map}get#Cs(){return this.#Ss||=new Map}get#Es(){if(!this.#ys){const t=this.#Ms.createElement("div"),{style:i}=t;i.visibility="hidden",i.contain="strict",i.width=i.height=0,i.position="absolute",i.top=i.left=0,i.zIndex=-1;const e=this.#Ms.createElementNS(Et,"svg");e.setAttribute("width",0),e.setAttribute("height",0),this.#ys=this.#Ms.createElementNS(Et,"defs"),t.append(e),e.append(this.#ys),this.#Ms.body.append(t)}return this.#ys}#ks(t){if(1===t.length){const i=t[0],e=Array(256);for(let t=0;t<256;t++)e[t]=i[t]/255;const s=e.join(",");return[s,s,s]}const[i,e,s]=t,n=Array(256),r=Array(256),o=Array(256);for(let t=0;t<256;t++)n[t]=i[t]/255,r[t]=e[t]/255,o[t]=s[t]/255;return[n.join(","),r.join(","),o.join(",")]}#Ts(t){if(void 0===this.#vs){this.#vs="";const t=this.#Ms.URL;t!==this.#Ms.baseURI&&(It(t)?Z('#createUrl: ignore "data:"-URL for performance reasons.'):this.#vs=st(t,""))}return`url(${this.#vs}#${t})`}addFilter(t){if(!t)return"none";let i=this.#T.get(t);if(i)return i;const[e,s,n]=this.#ks(t),r=1===t.length?e:`${e}${s}${n}`;if(i=this.#T.get(r),i)return this.#T.set(t,i),i;const o=`g_${this.#xs}_transfer_map_${this.#E++}`,h=this.#Ts(o);this.#T.set(t,h),this.#T.set(r,h);const a=this.#Ps(o);return this.#Ds(e,s,n,a),h}addHCMFilter(t,i){const e=`${t}-${i}`,s="base";let n=this.#Cs.get(s);if(n?.key===e)return n.url;if(n?(n.filter?.remove(),n.key=e,n.url="none",n.filter=null):(n={key:e,url:"none",filter:null},this.#Cs.set(s,n)),!t||!i)return n.url;const r=this.#Is(t);t=gt.makeHexColor(...r);const o=this.#Is(i);if(i=gt.makeHexColor(...o),this.#Es.style.color="","#000000"===t&&"#ffffff"===i||t===i)return n.url;const h=Array(256);for(let t=0;t<=255;t++){const i=t/255;h[t]=i<=.03928?i/12.92:((i+.055)/1.055)**2.4}const a=h.join(","),c=`g_${this.#xs}_hcm_filter`,l=n.filter=this.#Ps(c);this.#Ds(a,a,a,l),this.#Rs(l);const u=(t,i)=>{const e=r[t]/255,s=o[t]/255,n=Array(i+1);for(let t=0;t<=i;t++)n[t]=e+t/i*(s-e);return n.join(",")};return this.#Ds(u(0,5),u(1,5),u(2,5),l),n.url=this.#Ts(c),n.url}addAlphaFilter(t){let i=this.#T.get(t);if(i)return i;const[e]=this.#ks([t]),s="alpha_"+e;if(i=this.#T.get(s),i)return this.#T.set(t,i),i;const n=`g_${this.#xs}_alpha_map_${this.#E++}`,r=this.#Ts(n);this.#T.set(t,r),this.#T.set(s,r);const o=this.#Ps(n);return this.#Ns(e,o),r}addLuminosityFilter(t){let i,e,s=this.#T.get(t||"luminosity");if(s)return s;if(t?([i]=this.#ks([t]),e="luminosity_"+i):e="luminosity",s=this.#T.get(e),s)return this.#T.set(t,s),s;const n=`g_${this.#xs}_luminosity_map_${this.#E++}`,r=this.#Ts(n);this.#T.set(t,r),this.#T.set(e,r);const o=this.#Ps(n);return this.#Os(o),t&&this.#Ns(i,o),r}addHighlightHCMFilter(t,i,e,s,n){const r=`${i}-${e}-${s}-${n}`;let o=this.#Cs.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.#Cs.set(t,o)),!i||!e)return o.url;const[h,a]=[i,e].map(this.#Is.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.#Is.bind(this));l<c&&([c,l,u,d]=[l,c,d,u]),this.#Es.style.color="";const f=(t,i,e)=>{const s=Array(256),n=(l-c)/e,r=t/255,o=(i-t)/(255*e);let h=0;for(let t=0;t<=e;t++){const i=Math.round(c+t*n),e=r+t*o;for(let t=h;t<=i;t++)s[t]=e;h=i+1}for(let t=h;t<256;t++)s[t]=s[h-1];return s.join(",")},p=`g_${this.#xs}_hcm_${t}_filter`,g=o.filter=this.#Ps(p);return this.#Rs(g),this.#Ds(f(u[0],d[0],5),f(u[1],d[1],5),f(u[2],d[2],5),g),o.url=this.#Ts(p),o.url}destroy(t=!1){t&&this.#Ss?.size||(this.#ys?.parentNode.parentNode.remove(),this.#ys=null,this.#bs?.clear(),this.#bs=null,this.#Ss?.clear(),this.#Ss=null,this.#E=0)}#Os(t){const i=this.#Ms.createElementNS(Et,"feColorMatrix");i.setAttribute("type","matrix"),i.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(i)}#Rs(t){const i=this.#Ms.createElementNS(Et,"feColorMatrix");i.setAttribute("type","matrix"),i.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(i)}#Ps(t){const i=this.#Ms.createElementNS(Et,"filter");return i.setAttribute("color-interpolation-filters","sRGB"),i.setAttribute("id",t),this.#Es.append(i),i}#_s(t,i,e){const s=this.#Ms.createElementNS(Et,i);s.setAttribute("type","discrete"),s.setAttribute("tableValues",e),t.append(s)}#Ds(t,i,e,s){const n=this.#Ms.createElementNS(Et,"feComponentTransfer");s.append(n),this.#_s(n,"feFuncR",t),this.#_s(n,"feFuncG",i),this.#_s(n,"feFuncB",e)}#Ns(t,i){const e=this.#Ms.createElementNS(Et,"feComponentTransfer");i.append(e),this.#_s(e,"feFuncA",t)}#Is(t){return this.#Es.style.color=t,Ut(getComputedStyle(this.#Es).getPropertyValue("color"))}}if(F){let t;try{const i=process.getBuiltinModule("module").createRequire(import.meta.url);try{t=i("@napi-rs/canvas")}catch(t){Z(`Cannot load "@napi-rs/canvas" package: "${t}".`)}}catch(t){Z(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(t?.DOMMatrix?globalThis.DOMMatrix=t.DOMMatrix:Z("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.ImageData||(t?.ImageData?globalThis.ImageData=t.ImageData:Z("Cannot polyfill `ImageData`, rendering may be broken.")),globalThis.Path2D||(t?.Path2D?globalThis.Path2D=t.Path2D:Z("Cannot polyfill `Path2D`, rendering may be broken.")),globalThis.navigator?.language||(globalThis.navigator={language:"en-US",platform:"",userAgent:""})}class ce extends he{}class le extends re{_createCanvas(t,i){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,i)}}class ue extends se{async _fetch(t,i){return async function(t){const i=process.getBuiltinModule("fs/promises"),e=await i.readFile(t);return new Uint8Array(e)}(t)}}const de=new class{#Fs=null;#Bs=null;#Ls=null;#Us=null;async#$s(){if(!globalThis.navigator?.gpu)return!1;try{const t=await navigator.gpu.requestAdapter();return!!t&&(this.#Us=navigator.gpu.getPreferredCanvasFormat(),this.#Bs=await t.requestDevice(),!0)}catch{return!1}}init(){return this.#Fs||=this.#$s()}get isReady(){return null!==this.#Bs}loadMeshShader(){if(!this.#Bs||this.#Ls)return;const t=this.#Bs.createShaderModule({code:"\nstruct Uniforms {\n offsetX : f32,\n offsetY : f32,\n scaleX : f32,\n scaleY : f32,\n paddedWidth : f32,\n paddedHeight : f32,\n borderSize : f32,\n _pad : f32,\n};\n\n@group(0) @binding(0) var<uniform> u : Uniforms;\n\nstruct VertexInput {\n @location(0) position : vec2<f32>,\n @location(1) color : vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) color : vec3<f32>,\n};\n\n@vertex\nfn vs_main(in : VertexInput) -> VertexOutput {\n var out : VertexOutput;\n let cx = (in.position.x + u.offsetX) * u.scaleX;\n let cy = (in.position.y + u.offsetY) * u.scaleY;\n out.position = vec4<f32>(\n ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,\n 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,\n 0.0,\n 1.0\n );\n out.color = in.color.rgb;\n return out;\n}\n\n@fragment\nfn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {\n return vec4<f32>(in.color, 1.0);\n}\n"});this.#Ls=this.#Bs.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#Us}]},primitive:{topology:"triangle-list"}})}draw(t,i,e,s,n,r,o,h){this.loadMeshShader();const a=this.#Bs,{offsetX:c,offsetY:l,scaleX:u,scaleY:d}=s,f=a.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&a.queue.writeBuffer(f,0,t);const p=a.createBuffer({size:Math.max(i.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});i.byteLength>0&&a.queue.writeBuffer(p,0,i);const g=a.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});a.queue.writeBuffer(g,0,new Float32Array([c,l,u,d,r,o,h,0]));const m=a.createBindGroup({layout:this.#Ls.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:g}}]}),w=new OffscreenCanvas(r,o),A=w.getContext("webgpu");A.configure({device:a,format:this.#Us,alphaMode:n?"opaque":"premultiplied"});const v=n?{r:n[0]/255,g:n[1]/255,b:n[2]/255,a:1}:{r:0,g:0,b:0,a:0},b=a.createCommandEncoder(),y=b.beginRenderPass({colorAttachments:[{view:A.getCurrentTexture().createView(),clearValue:v,loadOp:"clear",storeOp:"store"}]});return e>0&&(y.setPipeline(this.#Ls),y.setBindGroup(0,m),y.setVertexBuffer(0,f),y.setVertexBuffer(1,p),y.draw(e)),y.end(),a.queue.submit([b.finish()]),f.destroy(),p.destroy(),g.destroy(),w.transferToImageBitmap()}},fe="Fill",pe="Stroke",ge="Shading";function me(t,i){if(!i)return;const e=i[2]-i[0],s=i[3]-i[1],n=new Path2D;n.rect(i[0],i[1],e,s),t.clip(n)}class we{isModifyingCurrentTransform(){return!1}getPattern(){tt("Abstract method `getPattern` called.")}}class Ae extends we{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,i=null){let e,s=this._p0,n=this._p1;if(i&&(s=s.slice(),n=n.slice(),gt.applyTransform(s,i),gt.applyTransform(n,i)),"axial"===this._type)e=t.createLinearGradient(s[0],s[1],n[0],n[1]);else if("radial"===this._type){let r=this._r0,o=this._r1;if(i){const t=new Float32Array(2);gt.singularValueDecompose2dScale(i,t),r*=t[0],o*=t[0]}e=t.createRadialGradient(s[0],s[1],r,n[0],n[1],o)}for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}_createReversedGradient(t,i=null){let e=this._p1,s=this._p0;i&&(e=e.slice(),s=s.slice(),gt.applyTransform(e,i),gt.applyTransform(s,i));let n=this._r1,r=this._r0;if(i){const t=new Float32Array(2);gt.singularValueDecompose2dScale(i,t),n*=t[0],r*=t[0]}const o=t.createRadialGradient(e[0],e[1],n,s[0],s[1],r),h=this._colorStops.map((([t,i])=>[1-t,i])).reverse();for(const[t,i]of h)o.addColorStop(t,i);return o}getPattern(t,i,e,s){let n;if(s===pe||s===fe){if(this.isOriginBased()){let s=gt.transform(e,i.baseTransform);this.matrix&&(s=gt.transform(s,this.matrix));const n=.001,r=Math.hypot(s[0],s[1]),o=Math.hypot(s[2],s[3]);if(Math.abs((s[0]*s[2]+s[1]*s[3])/(r*o))<n){if(!this.isRadial())return this._createGradient(t,s);if(Math.abs(r-o)<n)return this._createGradient(t,s)}}const r=i.current.getClippedPathBoundingBox(s,$t(t))||[0,0,0,0],o=i.canvasFactory.create(Math.ceil(r[2]-r[0])||1,Math.ceil(r[3]-r[1])||1),h=o.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),e=gt.transform(e,[1,0,0,1,r[0],r[1]]),h.transform(...i.baseTransform),this.matrix&&h.transform(...this.matrix),me(h,this._bbox),this.areConic()&&(h.fillStyle=this._createReversedGradient(h),h.fill()),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(o.canvas,"no-repeat"),i.canvasFactory.destroy(o);const a=new DOMMatrix(e);n.setTransform(a)}else this.areConic()&&(t.save(),me(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),me(t,this._bbox),n=this._createGradient(t);return n}}function ve(t,i,e,s,n,r,o,h){const a=i.coords,c=i.colors,l=t.data,u=4*t.width;let d;a[2*e+1]>a[2*s+1]&&(d=e,e=s,s=d,d=r,r=o,o=d),a[2*s+1]>a[2*n+1]&&(d=s,s=n,n=d,d=o,o=h,h=d),a[2*e+1]>a[2*s+1]&&(d=e,e=s,s=d,d=r,r=o,o=d);const f=(a[2*e]+i.offsetX)*i.scaleX,p=(a[2*e+1]+i.offsetY)*i.scaleY,g=(a[2*s]+i.offsetX)*i.scaleX,m=(a[2*s+1]+i.offsetY)*i.scaleY,w=(a[2*n]+i.offsetX)*i.scaleX,A=(a[2*n+1]+i.offsetY)*i.scaleY;if(p>=A)return;const v=c[4*r],b=c[4*r+1],y=c[4*r+2],x=c[4*o],M=c[4*o+1],S=c[4*o+2],C=c[4*h],E=c[4*h+1],k=c[4*h+2],T=Math.round(p),P=Math.round(A);let D,I,R,N,O,_,F,B;for(let t=T;t<=P;t++){if(t<m){const i=t<p?0:(p-t)/(p-m);D=f-(f-g)*i,I=v-(v-x)*i,R=b-(b-M)*i,N=y-(y-S)*i}else{let i;i=t>A?1:m===A?0:(m-t)/(m-A),D=g-(g-w)*i,I=x-(x-C)*i,R=M-(M-E)*i,N=S-(S-k)*i}let i;i=t<p?0:t>A?1:(p-t)/(p-A),O=f-(f-w)*i,_=v-(v-C)*i,F=b-(b-E)*i,B=y-(y-k)*i;const e=Math.round(Math.min(D,O)),s=Math.round(Math.max(D,O));let n=u*t+4*e;for(let t=e;t<=s;t++)i=(D-t)/(D-O),i<0?i=0:i>1&&(i=1),l[n++]=I-(I-_)*i|0,l[n++]=R-(R-F)*i|0,l[n++]=N-(N-B)*i|0,l[n++]=255}}class be extends we{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null,de.loadMeshShader()}_createMeshCanvas(t,i,e){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)||1,a=Math.min(Math.ceil(Math.abs(o*t[1]*1.1)),3e3)||1,c=r?r/h:1,l=o?o/a:1,u={coords:this._posData,colors:this._colData,offsetX:-s,offsetY:-n,scaleX:1/c,scaleY:1/l},d=h+4,f=a+4,p=e.create(d,f);if(de.isReady&&this._vertexCount>48)p.context.drawImage(function(t,i,e,s,n,r,o){return de.draw(t,i,e,s,n,r,o,2)}(this._posData,this._colData,this._vertexCount,u,i,d,f),0,0);else{const t=p.context.createImageData(h,a);if(i){const e=t.data;for(let t=0,s=e.length;t<s;t+=4)e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=255}for(let i=0,e=this._vertexCount;i<e;i+=3)ve(t,u,i,i+1,i+2,i,i+1,i+2);p.context.putImageData(t,2,2)}return{canvas:p.canvas,offsetX:s-2*c,offsetY:n-2*l,scaleX:c,scaleY:l}}isModifyingCurrentTransform(){return!0}getPattern(t,i,e,s){me(t,this._bbox);const n=new Float32Array(2);if(s===ge)gt.singularValueDecompose2dScale($t(t),n);else if(this.matrix){gt.singularValueDecompose2dScale(this.matrix,n);const[t,e]=n;gt.singularValueDecompose2dScale(i.baseTransform,n),n[0]*=t,n[1]*=e}else gt.singularValueDecompose2dScale(i.baseTransform,n);const r=this._createMeshCanvas(n,s===ge?null:this._background,i.canvasFactory);s!==ge&&(t.setTransform(...i.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY);const o=t.createPattern(r.canvas,"no-repeat");return i.canvasFactory.destroy(r),o}}class ye extends we{getPattern(){return"hotpink"}}class xe{static MAX_PATTERN_SIZE=3e3;constructor(t,i,e,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.needsIsolation=t[9]??!0,this.ctx=i,this.canvasGraphicsFactory=e,this.baseTransform=s,this.patternBaseMatrix=this.matrix?gt.transform(s,this.matrix):s}canSkipPatternCanvas([t,i,e,s]){const[n,r,o,h]=this.bbox,a=Math.abs(this.xstep),c=Math.abs(this.ystep);if(t>a+1e-6||i>c+1e-6)return null;const l=Math.floor((e-o)/a)+1,u=Math.ceil((e+t-n)/a)-1,d=Math.floor((s-h)/c)+1;return u<=l&&Math.ceil((s+i-r)/c)-1<=d?[l,d]:null}updatePatternDims(t,i){const e=gt.inverseTransform(this.patternBaseMatrix),s=[t[0],t[1]],n=[t[2],t[3]];gt.applyTransform(s,e),gt.applyTransform(n,e),i[0]=Math.abs(n[0]-s[0]),i[1]=Math.abs(n[1]-s[1]),i[2]=Math.min(s[0],n[0]),i[3]=Math.min(s[1],n[1])}_renderTileCanvas(t,i,e,s){const[n,r,o,h]=this.bbox,a=t.canvasFactory.create(e.size,s.size),c=a.context,l=this.canvasGraphicsFactory.createCanvasGraphics(c,i);return l.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(l,this.paintType,this.color),c.translate(-e.scale*n,-s.scale*r),l.transform(0,e.scale,0,0,s.scale,0,0),c.save(),l.dependencyTracker?.save(),this.clipBbox(l,n,r,o,h),l.baseTransform=$t(l.ctx),l.executeOperatorList(this.operatorList),l.endDrawing(),l.dependencyTracker?.restore(),c.restore(),a}_getCombinedScales(){const t=new Float32Array(2);gt.singularValueDecompose2dScale(this.matrix,t);const[i,e]=t;return gt.singularValueDecompose2dScale(this.baseTransform,t),[i*t[0],e*t[1]]}drawPattern(t,i,e=!1,[s,n],r){const[o,h,a,c]=this.bbox,l=t.dependencyTracker;if(l&&(t.dependencyTracker=new Di(l,r)),t.save(),e?t.ctx.clip(i,"evenodd"):t.ctx.clip(i),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(s*this.xstep,n*this.ystep),this.needsIsolation||1!==t.ctx.globalAlpha||"source-over"!==t.ctx.globalCompositeOperation||t.inSMaskMode){const i=a-o,e=c-h,[s,n]=this._getCombinedScales(),l=this.getSizeAndScale(i,this.ctx.canvas.width,s),u=this.getSizeAndScale(e,this.ctx.canvas.height,n),d=this._renderTileCanvas(t,r,l,u);t.ctx.drawImage(d.canvas,o,h,i,e),t.canvasFactory.destroy(d)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,o,h,a,c),t.baseTransformStack.push(t.baseTransform),t.baseTransform=$t(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),l&&(t.dependencyTracker=l)}createPatternCanvas(t,i){const[e,s,n,r]=this.bbox,o=n-e,h=r-s;let{xstep:a,ystep:c}=this;a=Math.abs(a),c=Math.abs(c),J("TilingType: "+this.tilingType);const[l,u]=this._getCombinedScales();let d=o,f=h,p=!1,g=!1;Math.ceil(a*l)>=Math.ceil(o*l)?d=a:p=!0,Math.ceil(c*u)>=Math.ceil(h*u)?f=c:g=!0;const m=this.getSizeAndScale(d,this.ctx.canvas.width,l),w=this.getSizeAndScale(f,this.ctx.canvas.height,u),A=this._renderTileCanvas(t,i,m,w);if(p||g){const i=A.canvas;p&&(d=a),g&&(f=c);const n=this.getSizeAndScale(d,this.ctx.canvas.width,l),r=this.getSizeAndScale(f,this.ctx.canvas.height,u),m=n.size,w=r.size,v=t.canvasFactory.create(m,w),b=v.context,y=p?Math.floor(o/a):0,x=g?Math.floor(h/c):0;for(let t=0;t<=y;t++)for(let e=0;e<=x;e++)b.drawImage(i,m*t,w*e,m,w,0,0,m,w);return t.canvasFactory.destroy(A),{canvas:v.canvas,canvasEntry:v,scaleX:n.scale,scaleY:r.scale,offsetX:e,offsetY:s}}return{canvas:A.canvas,canvasEntry:A,scaleX:m.scale,scaleY:w.scale,offsetX:e,offsetY:s}}getSizeAndScale(t,i,e){const s=Math.max(xe.MAX_PATTERN_SIZE,i);let n=Math.ceil(t*e);return n>=s?n=s:e=n/t,{scale:e,size:n}}clipBbox(t,i,e,s,n){const r=s-i,o=n-e,h=new Path2D;h.rect(i,e,r,o),gt.axialAlignedBoundingBox([i,e,s,n],$t(t.ctx),t.current.minMax),t.ctx.clip(h),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,i,e){const s=t.ctx,n=t.current;switch(n.patternFill=n.patternStroke=!1,i){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=e,n.fillColor=n.strokeColor=e;break;default:throw new ut("Unsupported paint type: "+i)}}isModifyingCurrentTransform(){return!1}getPattern(t,i,e,s,n){const r=s!==ge?gt.transform(e,this.patternBaseMatrix):e,o=this.createPatternCanvas(i,n);let h=new DOMMatrix(r);h=h.translate(o.offsetX,o.offsetY),h=h.scale(1/o.scaleX,1/o.scaleY);const a=t.createPattern(o.canvas,"repeat");return i.canvasFactory.destroy(o.canvasEntry),a.setTransform(h),a}}function Me({src:t,srcPos:i=0,dest:e,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:o=!1}){const h=pt.isLittleEndian?4278190080:255,[a,c]=o?[r,h]:[h,r],l=s>>3,u=7&s,d=a^c,f=t.length;e=new Uint32Array(e.buffer);let p=0;for(let s=0;s<n;++s){for(const s=i+l;i<s;++i,p+=8){const s=t[i];e[p]=a^-(s>>7&1)&d,e[p+1]=a^-(s>>6&1)&d,e[p+2]=a^-(s>>5&1)&d,e[p+3]=a^-(s>>4&1)&d,e[p+4]=a^-(s>>3&1)&d,e[p+5]=a^-(s>>2&1)&d,e[p+6]=a^-(s>>1&1)&d,e[p+7]=a^-(1&s)&d}if(0===u)continue;const s=i<f?t[i++]:255;for(let t=0;t<u;++t,++p)e[p]=a^-(s>>7-t&1)&d}return{srcPos:i,destPos:p}}const Se=16,Ce=new DOMMatrix,Ee=new Float32Array(2);function ke(t,i,e,s,n,r,o,h,a,c){const[l,u,d,f,p,g]=$t(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,v=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(i,e,s,n,r,0,0,A,v),t.setTransform(l,u,d,f,p,g),[A,v]}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,v=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(i,e,s,n,r,0,0,v,A),t.setTransform(l,u,d,f,p,g),[v,A]}return t.drawImage(i,e,s,n,r,o,h,a,c),[Math.hypot(l,u)*a,Math.hypot(d,f)*c]}class Te{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=U;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=L.slice();constructor(t,i){this.clipBox=new Float32Array([0,0,t,i])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=fe,i=null){const e=this.minMax.slice();if(t===pe){i||tt("Stroke bounding box must include transform."),gt.singularValueDecompose2dScale(i,Ee);const t=Ee[0]*this.lineWidth/2,s=Ee[1]*this.lineWidth/2;e[0]-=t,e[1]-=s,e[2]+=t,e[3]+=s}return e}updateClipFromPath(){const t=gt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(L,0)}getClippedPathBoundingBox(t=fe,i=null){return gt.intersect(this.clipBox,this.getPathBoundingBox(t,i))}}function Pe(t,i){if(i instanceof ImageData)return void t.putImageData(i,0,0);const e=i.height,s=i.width,n=e%Se,r=(e-n)/Se,o=0===n?r:r+1,h=t.createImageData(s,Se);let a,c=0;const l=i.data,u=h.data;let d,f,p,g;if(i.kind===G.GRAYSCALE_1BPP){const i=l.byteLength,e=new Uint32Array(u.buffer,0,u.byteLength>>2),g=e.length,m=s+7>>3,w=4294967295,A=pt.isLittleEndian?4278190080:255;for(d=0;d<o;d++){for(p=d<r?Se:n,a=0,f=0;f<p;f++){const t=i-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++],e[a++]=128&u?w:A,e[a++]=64&u?w:A,e[a++]=32&u?w:A,e[a++]=16&u?w:A,e[a++]=8&u?w:A,e[a++]=4&u?w:A,e[a++]=2&u?w:A,e[a++]=1&u?w:A;for(;n<r;n++)0===h&&(u=l[c++],h=128),e[a++]=u&h?w:A,h>>=1}for(;a<g;)e[a++]=0;t.putImageData(h,0,d*Se)}}else if(i.kind===G.RGBA_32BPP){for(f=0,g=s*Se*4,d=0;d<r;d++)u.set(l.subarray(c,c+g)),c+=g,t.putImageData(h,0,f),f+=Se;d<o&&(g=s*n*4,u.set(l.subarray(c,c+g)),t.putImageData(h,0,f))}else{if(i.kind!==G.RGB_24BPP)throw Error("bad image kind: "+i.kind);for(p=Se,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*Se)}}}function De(t,i){if(i.bitmap)return void t.drawImage(i.bitmap,0,0);const e=i.height,s=i.width,n=e%Se,r=(e-n)/Se,o=0===n?r:r+1,h=t.createImageData(s,Se);let a=0;const c=i.data,l=h.data;for(let i=0;i<o;i++){const e=i<r?Se:n;({srcPos:a}=Me({src:c,srcPos:a,dest:l,width:s,height:e,nonBlackColor:0})),t.putImageData(h,0,i*Se)}}function Ie(t,i){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)void 0!==t[s]&&(i[s]=t[s]);void 0!==t.setLineDash&&(i.setLineDash(t.getLineDash()),i.lineDashOffset=t.lineDashOffset)}function Re(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:i}=t;"none"!==i&&""!==i&&(t.filter="none")}function Ne(t,i){if(i)return!0;gt.singularValueDecompose2dScale(t,Ee);const e=Math.fround(Ht.pixelRatio*kt.PDF_TO_CSS_UNITS);return Ee[0]<=e&&Ee[1]<=e}const Oe=["butt","round","square"],_e=["miter","round","bevel"],Fe={},Be={};class Le{constructor(t,i,e,s,n,{optionalContentConfig:r,markedContentStack:o=null},h,a,c,l){this.ctx=t,this.current=new Te(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=i,this.objs=e,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=r,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,this.dependencyTracker=c??null,this.imagesTracker=l??null}getObject(t,i,e=null){return"string"==typeof i?(this.dependencyTracker?.recordNamedDependency(t,i),i.startsWith("g_")?this.commonObjs.get(i):this.objs.get(i)):e}beginDrawing({transform:t,viewport:i,transparency:e=!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,e){const t=this.transparentCanvasEntry=this.canvasFactory.create(n,r);this.compositeCtx=this.ctx,({canvas:this.transparentCanvas,context:this.ctx}=t),this.ctx.save(),this.ctx.transform(...$t(this.compositeCtx))}this.ctx.save(),Re(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...i.transform),this.viewportScale=i.scale,this.baseTransform=$t(this.ctx)}executeOperatorList(t,i,e,s,n){const r=t.argsArray,o=t.fnArray;let h=i||0;const a=r.length;if(a===h)return h;const c=a-h>10&&"function"==typeof e,l=c?Date.now()+15:0;let u=0;const d=this.commonObjs,f=this.objs;let p,g;for(;;){if(void 0!==s){if(h===s.nextBreakPoint)return s.breakIt(h,e),h;if(s.shouldSkip(h)){if(++h===a)return h;continue}}if(!n||n(h))if(p=o[h],g=r[h]??null,p!==X.dependency)null===g?this[p](h):this[p](h,...g);else for(const t of g){this.dependencyTracker?.recordNamedData(t,h);const i=t.startsWith("g_")?d:f;if(!i.has(t))return i.get(t,e),h}if(h++,h===a)return h;if(c&&++u>10){if(Date.now()>l)return e(),h;u=0}}}#js(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)}endDrawing(){this.#js();for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0,this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const i of t.values())"undefined"!=typeof HTMLCanvasElement&&i instanceof HTMLCanvasElement&&(i.width=i.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#zs()}#zs(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const i=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=i}}}_scaleImage(t,i){const e=t.width??t.displayWidth,s=t.height??t.displayHeight,n=[];let r=Math.max(Math.hypot(i[0],i[1]),1),o=Math.max(Math.hypot(i[2],i[3]),1),h=e,a=s;for(;r>2&&h>1||o>2&&a>1;){let t=h,i=a;r>2&&h>1&&(t=Math.ceil(h/2),r/=h/t),o>2&&a>1&&(i=Math.ceil(a/2),o/=a/i),n.push({newWidth:t,newHeight:i}),h=t,a=i}if(0===n.length)return{img:t,paintWidth:e,paintHeight:s,tmpCanvas:null};if(1===n.length){const{newWidth:i,newHeight:r}=n[0],o=this.canvasFactory.create(i,r);return o.context.drawImage(t,0,0,e,s,0,0,i,r),{img:o.canvas,paintWidth:i,paintHeight:r,tmpCanvas:o}}let c=this.canvasFactory.create(1,1),l=this.canvasFactory.create(1,1),u=e,d=s,f=t;for(const{newWidth:t,newHeight:i}of n)this.canvasFactory.reset(l,t,i),l.context.drawImage(f,0,0,u,d,0,0,t,i),[c,l]=[l,c],f=c.canvas,u=t,d=i;return this.canvasFactory.destroy(l),{img:c.canvas,paintWidth:u,paintHeight:d,tmpCanvas:c}}_createMaskCanvas(t,i){const e=this.ctx,{width:s,height:n}=i,r=this.current.fillColor,o=this.current.patternFill,h=$t(e);let a,c,l,u;if((i.bitmap||i.data)&&i.count>1){const e=i.bitmap||i.data.buffer;c=JSON.stringify(o?h:[h.slice(0,4),r]),a=this._cachedBitmapsMap.getOrInsertComputed(e,yt);const s=a.get(c);if(s&&!o){const i=Math.round(Math.min(h[0],h[2])+h[4]),e=Math.round(Math.min(h[1],h[3])+h[5]);return this.dependencyTracker?.recordDependencies(t,Bi),{canvas:s,offsetX:i,offsetY:e}}l=s}l||(u=this.canvasFactory.create(s,n),De(u.context,i));let d=gt.transform(h,[1/s,0,0,-1/n,0,0]);d=gt.transform(d,[1,0,0,1,0,-n]);const f=L.slice();gt.axialAlignedBoundingBox([0,0,s,n],d,f);const[p,g,m,w]=f,A=this.canvasFactory.create(Math.round(m-p)||1,Math.round(w-g)||1),v=A.context,b=p,y=g;v.translate(-b,-y),v.transform(...d);let x=null;if(!l){const t=this._scaleImage(u.canvas,jt(v));l=t.img,x=t.tmpCanvas,l!==u.canvas&&(this.canvasFactory.destroy(u),u=null),a&&o&&(a.set(c,l),x=null,u=null)}v.imageSmoothingEnabled=Ne($t(v),i.interpolate),ke(v,l,0,0,l.width,l.height,0,0,s,n),x&&this.canvasFactory.destroy(x),u&&this.canvasFactory.destroy(u),v.globalCompositeOperation="source-in";const M=gt.transform(jt(v),[1,0,0,1,-b,-y]);return v.fillStyle=o?r.getPattern(e,this,M,fe,t):r,v.fillRect(0,0,s,n),a&&!o&&a.set(c,A.canvas),this.dependencyTracker?.recordDependencies(t,Bi),{canvas:A.canvas,canvasEntry:a&&!o?null:A,offsetX:Math.round(b),offsetY:Math.round(y)}}setLineWidth(t,i){this.dependencyTracker?.recordSimpleData("lineWidth",t),i!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=i,this.ctx.lineWidth=i}setLineCap(t,i){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=Oe[i]}setLineJoin(t,i){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=_e[i]}setMiterLimit(t,i){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=i}setDash(t,i,e){this.dependencyTracker?.recordSimpleData("dash",t);const s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(i),s.lineDashOffset=e)}setRenderingIntent(t,i){}setFlatness(t,i){}setGState(t,i){for(const[e,s]of i)switch(e){case"LW":this.setLineWidth(t,s);break;case"LC":this.setLineCap(t,s);break;case"LJ":this.setLineJoin(t,s);break;case"ML":this.setMiterLimit(t,s);break;case"D":this.setDash(t,s[0],s[1]);break;case"RI":this.setRenderingIntent(t,s);break;case"FL":this.setFlatness(t,s);break;case"Font":this.setFont(t,s[0],s[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=s;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=s;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=s;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=s?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0}_ensurePreparedSMask(t,i,e){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t,i,e))}checkSMaskState(t){const i=this.inSMaskMode;this.current.activeSMask&&!i?this.beginSMaskMode(t):!this.current.activeSMask&&i?this.endSMaskMode():this.current.activeSMask&&i&&this._ensurePreparedSMask(this.current.activeSMask,this.ctx.canvas.width,this.ctx.canvas.height)}_prepareSMaskCanvas(t,i,e){const{canvas:s,subtype:n,backdrop:r,transferMap:o}=t,h="Luminosity"===n||"Alpha"===n&&o;if(!r&&!h)return void(this.smaskPreparedFor=t);let a,c,l;if(r&&h){const h=this.canvasFactory.create(i,e),u=h.context;u.drawImage(s,t.offsetX,t.offsetY),u.globalCompositeOperation="destination-atop",u.fillStyle=r,u.fillRect(0,0,i,e),u.globalCompositeOperation="source-over",a=this.canvasFactory.create(i,e);const d=a.context;d.filter="Alpha"===n?this.filterFactory.addAlphaFilter(o):this.filterFactory.addLuminosityFilter(o),d.drawImage(h.canvas,0,0),d.filter="none",this.canvasFactory.destroy(h),c=l=0}else if(h){a=this.canvasFactory.create(s.width,s.height);const i=a.context;i.filter="Alpha"===n?this.filterFactory.addAlphaFilter(o):this.filterFactory.addLuminosityFilter(o),i.drawImage(s,0,0),i.filter="none",({offsetX:c,offsetY:l}=t)}else{a=this.canvasFactory.create(i,e);const n=a.context;n.drawImage(s,t.offsetX,t.offsetY),n.globalCompositeOperation="destination-atop",n.fillStyle=r,n.fillRect(0,0,i,e),n.globalCompositeOperation="source-over",c=l=0}this.smaskPreparedEntry=a,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=c,this.smaskPreparedOffsetY=l}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");const{width:i,height:e}=this.ctx.canvas,s=this.canvasFactory.create(i,e);this.smaskScratchCanvas=s,this.suspendedCtx=this.ctx;const n=this.ctx=s.context;n.setTransform(this.suspendedCtx.getTransform()),Ie(this.suspendedCtx,n),function(t,i){if(t._removeMirroring)throw 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(){i.save(),this.__originalSave()},t.restore=function(){i.restore(),this.__originalRestore()},t.translate=function(t,e){i.translate(t,e),this.__originalTranslate(t,e)},t.scale=function(t,e){i.scale(t,e),this.__originalScale(t,e)},t.transform=function(t,e,s,n,r,o){i.transform(t,e,s,n,r,o),this.__originalTransform(t,e,s,n,r,o)},t.setTransform=function(t,e,s,n,r,o){void 0===e?(i.setTransform(t),this.__originalSetTransform(t)):(i.setTransform(t,e,s,n,r,o),this.__originalSetTransform(t,e,s,n,r,o))},t.resetTransform=function(){i.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){i.rotate(t),this.__originalRotate(t)},t.clip=function(t){i.clip(t),this.__originalClip(t)},t.moveTo=function(t,e){i.moveTo(t,e),this.__originalMoveTo(t,e)},t.lineTo=function(t,e){i.lineTo(t,e),this.__originalLineTo(t,e)},t.bezierCurveTo=function(t,e,s,n,r,o){i.bezierCurveTo(t,e,s,n,r,o),this.__originalBezierCurveTo(t,e,s,n,r,o)},t.rect=function(t,e,s,n){i.rect(t,e,s,n),this.__originalRect(t,e,s,n)},t.closePath=function(){i.closePath(),this.__originalClosePath()},t.beginPath=function(){i.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask,i,e),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Ie(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}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(t[0],t[1],t[2]-t[0],t[3]-t[1]),this.ctx.restore())}composeSMask(t,i,e,s){const n=s[0],r=s[1],o=s[2]-n,h=s[3]-r;if(0===o||0===h)return;const a=this.smaskPreparedEntry;if(a){const t=n-this.smaskPreparedOffsetX,i=r-this.smaskPreparedOffsetY;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const s=new Path2D;s.rect(n,r,o,h),e.clip(s),e.globalCompositeOperation="destination-in",e.drawImage(a.canvas,t,i,o,h,n,r,o,h),e.restore()}else this.genericComposeSMask(i.context,e,o,h,n,r,i.offsetX,i.offsetY);t.save(),t.globalAlpha=1,t.globalCompositeOperation=i.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(e.canvas,n,r,o,h,n,r,o,h),t.restore()}genericComposeSMask(t,i,e,s,n,r,o,h){const a=t.canvas,c=n-o,l=r-h;i.save(),i.globalAlpha=1,i.setTransform(1,0,0,1,0,0);const u=new Path2D;u.rect(n,r,e,s),i.clip(u),i.globalCompositeOperation="destination-in",i.drawImage(a,c,l,e,s,n,r,e,s),i.restore()}save(t){this.inSMaskMode&&Ie(this.ctx,this.suspendedCtx),this.ctx.save();const i=this.current;this.stateStack.push(i),this.current=i.clone(),this.dependencyTracker?.save(t)}restore(t){this.dependencyTracker?.restore(t),0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(Ie(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,i,e,s,n,r,o){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(i,e,s,n,r,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,i,e,s){let[n]=e;if(!s)return n||=e[0]=new Path2D,i!==X.stroke&&i!==X.closeStroke&&(this.current.tilingPatternDims=null),void this[i](t,n);if(null!==this.dependencyTracker){const e=i===X.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-e,s[2]+e,s[1]-e,s[3]+e).recordDependencies(t,["transform"])}n instanceof Path2D||(n=e[0]=Jt(n)),gt.axialAlignedBoundingBox(s,$t(this.ctx),this.current.minMax);const r=this.current.tilingPatternDims;if(r&&i!==X.stroke&&i!==X.closeStroke&&this.current.fillColor instanceof xe){const t=gt.intersect(this.current.clipBox,this.current.minMax);t?this.current.fillColor.updatePatternDims(t,r):this.current.tilingPatternDims=null}this[i](t,n),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,i,e=!0){const s=this.ctx,n=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof n&&n?.getPattern){const e=n.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=n.getPattern(s,this,jt(s),pe,t),e){const t=new Path2D;t.addPath(i,s.getTransform().invertSelf().multiplySelf(e)),i=t}this.rescaleAndStroke(i,!1),s.restore()}else this.rescaleAndStroke(i,!0);this.dependencyTracker?.recordDependencies(t,Ii),e&&this.consumePath(t,i,this.current.getClippedPathBoundingBox(pe,$t(this.ctx))),s.globalAlpha=this.current.fillAlpha}closeStroke(t,i){this.stroke(t,i)}fill(t,i,e=!0){const s=this.ctx,n=this.current.fillColor,r=this.current.patternFill;let o=!1;const h=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,Ri),r){const r=this.current.tilingPatternDims,a=r&&n.canSkipPatternCanvas(r);if(a)return n.drawPattern(this,i,this.pendingEOFill,a,t),this.pendingEOFill=!1,e&&this.consumePath(t,i,h),void(this.current.tilingPatternDims=null);const c=n.isModifyingCurrentTransform()?s.getTransform():null;if(this.dependencyTracker?.save(t),s.save(),s.fillStyle=n.getPattern(s,this,jt(s),fe,t),c){const t=new Path2D;t.addPath(i,s.getTransform().invertSelf().multiplySelf(c)),i=t}o=!0}this.contentVisible&&null!==h&&(this.pendingEOFill?(s.fill(i,"evenodd"),this.pendingEOFill=!1):s.fill(i)),o&&(s.restore(),this.dependencyTracker?.restore(t)),e&&this.consumePath(t,i,h)}eoFill(t,i){this.pendingEOFill=!0,this.fill(t,i)}fillStroke(t,i){this.fill(t,i,!1),this.stroke(t,i,!1),this.consumePath(t,i)}eoFillStroke(t,i){this.pendingEOFill=!0,this.fillStroke(t,i)}closeFillStroke(t,i){this.fillStroke(t,i)}closeEOFillStroke(t,i){this.pendingEOFill=!0,this.fillStroke(t,i)}endPath(t,i){this.consumePath(t,i)}rawFillPath(t,i){this.ctx.fill(i),this.dependencyTracker?.recordDependencies(t,Oi).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Fe}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Be}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const i=this.pendingTextPaths,e=this.ctx;if(this.dependencyTracker){const{dependencyTracker:e}=this;void 0!==i&&e.recordFutureForcedDependency("textClip",e.getOpenMarker()).recordFutureForcedDependency("textClip",t),e.recordCloseMarker(t)}if(void 0!==i){const t=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:r,fontSize:o,path:h}of i)h&&t.addPath(h,new DOMMatrix(e).preMultiplySelf(s).translate(n,r).scale(o,-o));e.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,i){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=i}setWordSpacing(t,i){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=i}setHScale(t,i){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=i/100}setLeading(t,i){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-i}setFont(t,i,e){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",i,t);const s=this.commonObjs.get(i),n=this.current;if(!s)throw Error("Can't find font for "+i);if(n.fontMatrix=s.fontMatrix||U,0!==n.fontMatrix[0]&&0!==n.fontMatrix[3]||Z("Invalid font matrix for font "+i),e<0?(e=-e,n.fontDirection=-1):n.fontDirection=1,this.current.font=s,this.current.fontSize=e,s.isType3Font)return;const r=s.loadedName||"sans-serif",o=s.systemFontInfo?.css||`"${r}", ${s.fallbackName}`;let h="normal";s.black?h="900":s.bold&&(h="bold");const a=s.italic?"italic":"normal";let c=e;e<16?c=16:e>100&&(c=100),this.current.fontSizeScale=e/c,this.ctx.font=`${a} ${h} ${c}px ${o}`}setTextRenderingMode(t,i){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=i}setTextRise(t,i){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=i}moveText(t,i,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=i,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,i,e){this.setLeading(t,-e),this.moveText(t,i,e)}setTextMatrix(t,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:e}=this;e.textMatrix=i,e.textMatrixScale=Math.hypot(i[0],i[1]),e.x=e.lineX=0,e.y=e.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#Hs(t,i,e){const s=new Path2D;return s.addPath(t,new DOMMatrix(e).invertSelf().multiplySelf(i)),s}paintChar(t,i,e,s,n,r){const o=this.ctx,h=this.current,a=h.font,c=h.textRenderingMode,l=h.fontSize/h.fontSizeScale,u=3&c,d=!!(4&c),f=h.patternFill&&!a.missingFile,p=h.patternStroke&&!a.missingFile;let g;if((a.disableFontFace||d||f||p)&&!a.missingFile&&(g=a.getPathGenerator(this.commonObjs,i)),g&&(a.disableFontFace||f||p)){let i;if(o.save(),o.translate(e,s),o.scale(l,-l),this.dependencyTracker?.recordCharacterBBox(t,o,a),0===u||2===u)if(n){i=o.getTransform(),o.setTransform(...n);const t=this.#Hs(g,i,n);o.fill(t)}else o.fill(g);if(1===u||2===u)if(r){i||=o.getTransform(),o.setTransform(...r);const{a:t,b:e,c:s,d:n}=i,h=gt.inverseTransform(r),a=gt.transform([t,e,s,n,0,0],h);gt.singularValueDecompose2dScale(a,Ee),o.lineWidth*=Math.max(Ee[0],Ee[1])/l,o.stroke(this.#Hs(g,i,r))}else o.lineWidth/=l,o.stroke(g);o.restore()}else 0!==u&&2!==u||(o.fillText(i,e,s),this.dependencyTracker?.recordCharacterBBox(t,o,a,l,e,s,(()=>o.measureText(i)))),1!==u&&2!==u||(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,o,a,l,e,s,(()=>o.measureText(i))).recordDependencies(t,Ii),o.strokeText(i,e,s));d&&((this.pendingTextPaths||=[]).push({transform:$t(o),x:e,y:s,fontSize:l,path:g}),this.dependencyTracker?.recordCharacterBBox(t,o,a,l,e,s))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),i=t.context;i.scale(1.5,1),i.fillText("I",0,10);const e=i.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let s=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){s=!0;break}return rt(this,"isFontSubpixelAAEnabled",s)}showText(t,i){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,_i).resetBBox(t),4&this.current.textRenderingMode&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t,i),void this.dependencyTracker?.recordShowTextOperation(t);const n=e.fontSize;if(0===n)return void this.dependencyTracker?.recordOperation(t);const r=this.ctx,o=e.fontSizeScale,h=e.charSpacing,a=e.wordSpacing,c=e.fontDirection,l=e.textHScale*c,u=i.length,d=s.vertical,f=d?1:-1,p=s.defaultVMetrics,g=n*e.fontMatrix[0],m=0===e.textRenderingMode&&!s.disableFontFace&&!e.patternFill;let w,A;r.save(),e.textMatrix&&r.transform(...e.textMatrix),r.translate(e.x,e.y+e.textRise),r.scale(l,c>0?-1:1);const v=3&e.textRenderingMode,b=0===v||2===v,y=1===v||2===v;let x=e.lineWidth;const M=e.textMatrixScale;if(0===M||0===x?y&&(x=this.getSinglePixelWidth()):x/=M,1!==o&&(r.scale(o,o),x/=o),r.lineWidth=x,b&&e.patternFill){r.save();const i=e.fillColor.getPattern(r,this,jt(r),fe,t);w=$t(r),r.restore(),r.fillStyle=i}if(y&&e.patternStroke){r.save();const i=e.strokeColor.getPattern(r,this,jt(r),pe,t);A=$t(r),r.restore(),r.strokeStyle=i}if(s.isInvalidPDFjsFont){const s=[];let n=0;for(const t of i)s.push(t.unicode),n+=t.width;const o=s.join("");if(r.fillText(o,0,0),null!==this.dependencyTracker){const i=r.measureText(o);this.dependencyTracker.recordBBox(t,this.ctx,-i.actualBoundingBoxLeft,i.actualBoundingBoxRight,-i.actualBoundingBoxAscent,i.actualBoundingBoxDescent).recordShowTextOperation(t)}return e.x+=n*g*l,r.restore(),void this.compose()}let S,C=0;for(S=0;S<u;++S){const e=i[S];if("number"==typeof e){C+=f*e*n/1e3;continue}let l=!1;const u=(e.isSpace?a:0)+h,v=e.fontChar,b=e.accent;let y,x,M,E=e.width;if(d){const t=e.vmetric||p,i=-(e.vmetric?t[1]:.5*E)*g;E=t?-t[0]:E,y=i/o,x=(C+t[2]*g)/o}else y=C/o,x=0;if(s.remeasure&&E>0){M=r.measureText(v);const t=1e3*M.width/n*o;if(E<t&&this.isFontSubpixelAAEnabled){const i=E/t;l=!0,r.save(),r.scale(i,1),y/=i}else E!==t&&(y+=(E-t)/2e3*n/o)}this.contentVisible&&(e.isInFont||s.missingFile)&&(m&&!b?(r.fillText(v,y,x),this.dependencyTracker?.recordCharacterBBox(t,r,M?{bbox:null}:s,n/o,y,x,(()=>M??r.measureText(v)))):(this.paintChar(t,v,y,x,w,A),b&&this.paintChar(t,b.fontChar,y+n*b.offset.x/o,x-n*b.offset.y/o,w,A))),C+=d?E*g-u*c:E*g+u*c,l&&r.restore()}d?e.y-=C:e.x+=C*l,r.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,i){const e=this.ctx,s=this.current,n=s.font,r=s.fontSize,o=s.fontDirection,h=n.vertical?1:-1,a=s.charSpacing,c=s.wordSpacing,l=s.textHScale*o,u=s.fontMatrix||U,d=i.length;let f,p,g,m;if(3===s.textRenderingMode||0===r)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),s.textMatrix&&e.transform(...s.textMatrix),e.translate(s.x,s.y+s.textRise),e.scale(l,o);const w=this.dependencyTracker;for(this.dependencyTracker=w?new Di(w,t):null,f=0;f<d;++f){if(p=i[f],"number"==typeof p){m=h*p*r/1e3,this.ctx.translate(m,0),s.x+=m*l;continue}const t=(p.isSpace?c:0)+a,o=n.charProcOperatorList[p.operatorListId];o?this.contentVisible&&(this.save(),e.scale(r,r),e.transform(...u),this.executeOperatorList(o),this.restore()):Z(`Type3 character "${p.operatorListId}" is not available.`);const d=[p.width,0];gt.applyTransform(d,u),g=d[0]*r+t,e.translate(g,0),s.x+=g*l}e.restore(),w&&(this.dependencyTracker=w)}setCharWidth(t,i,e){}setCharWidthAndBounds(t,i,e,s,n,r,o){const h=new Path2D;h.rect(s,n,r-s,o-n),this.ctx.clip(h),this.dependencyTracker?.recordBBox(t,this.ctx,s,r,n,o).recordClipBox(t,this.ctx,s,r,n,o),this.endPath(t)}getColorN_Pattern(t,i){let e;if("TilingPattern"===i[0]){const t=this.baseTransform||$t(this.ctx);e=new xe(i,this.ctx,{createCanvasGraphics:(t,i)=>new Le(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Di(this.dependencyTracker,i,!0):null)},t)}else e=this._getPattern(t,i[1],i[2]);return e}setStrokeColorN(t,...i){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,i),this.current.patternStroke=!0}setFillColorN(t,...i){this.dependencyTracker?.recordSimpleData("fillColor",t);const e=this.current.fillColor=this.getColorN_Pattern(t,i);this.current.patternFill=!0,this.current.tilingPatternDims=e instanceof xe?[0,0,0,0]:null}setStrokeRGBColor(t,i){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=i,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,i){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=i,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,i,e=null){let s;return this.cachedPatterns.has(i)?s=this.cachedPatterns.get(i):(s=function(t){switch(t[0]){case"RadialAxial":return new Ae(t);case"Mesh":return new be(t);case"Dummy":return new ye}throw Error("Unknown IR type: "+t[0])}(this.getObject(t,i)),this.cachedPatterns.set(i,s)),e&&(s.matrix=e),s}shadingFill(t,i){if(!this.contentVisible)return;const e=this.ctx;this.save(t);const s=this._getPattern(t,i);e.fillStyle=s.getPattern(e,this,jt(e),ge,t);const n=jt(e);if(n){const{width:t,height:i}=e.canvas,s=L.slice();gt.axialAlignedBoundingBox([0,0,t,i],n,s);const[r,o,h,a]=s;this.ctx.fillRect(r,o,h-r,a-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Fi).recordDependencies(t,Ri).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){tt("Should not call beginInlineImage")}beginImageData(){tt("Should not call beginImageData")}paintFormXObjectBegin(t,i,e){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),i&&this.transform(t,...i),this.baseTransform=$t(this.ctx),e)){gt.axialAlignedBoundingBox(e,this.baseTransform,this.current.minMax);const[i,s,n,r]=e,o=new Path2D;o.rect(i,s,n-i,r-s),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(t,this.ctx,i,n,s,r),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,i){if(!this.contentVisible)return;this.save(t);const{inSMaskMode:e}=this;e&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;if(i.isolated||J("TODO: Support non-isolated groups."),i.knockout&&Z("Knockout groups not supported."),!i.needsIsolation&&1===s.globalAlpha&&"source-over"===s.globalCompositeOperation&&!e){if(i.bbox){let t=new Path2D;const[e,n,r,o]=i.bbox;if(t.rect(e,n,r-e,o-n),i.matrix){const e=new Path2D;e.addPath(t,new DOMMatrix(i.matrix)),t=e}s.clip(t)}return this.groupStack.push(null),void this.groupLevel++}const n=$t(s);i.matrix&&s.transform(...i.matrix);const r=[0,0,s.canvas.width,s.canvas.height];let o;i.bbox?(o=L.slice(),gt.axialAlignedBoundingBox(i.bbox,$t(s),o),o=gt.intersect(o,r)||[0,0,0,0]):o=r;const h=Math.floor(o[0]),a=Math.floor(o[1]),c=Math.max(Math.ceil(o[2])-h,1),l=Math.max(Math.ceil(o[3])-a,1);this.current.startNewPathAndClipBox([0,0,c,l]);const u=this.canvasFactory.create(c,l);i.smask&&this.smaskGroupCanvases.push(u);const d=u.context;if(d.translate(-h,-a),d.transform(...n),!i.isolated&&!i.smask&&e&&i.needsIsolation&&(d.save(),d.setTransform(1,0,0,1,0,0),d.drawImage(s.canvas,-h,-a),d.restore()),i.bbox){let t=new Path2D;const[e,s,n,r]=i.bbox;if(t.rect(e,s,n-e,r-s),i.matrix){const e=new Path2D;e.addPath(t,new DOMMatrix(i.matrix)),t=e}d.clip(t)}i.smask&&this.smaskStack.push({canvas:u.canvas,context:d,offsetX:h,offsetY:a,subtype:i.smask.subtype,backdrop:i.smask.backdrop,transferMap:i.smask.transferMap||null}),i.smask&&!this.dependencyTracker||(s.setTransform(1,0,0,1,0,0),s.translate(h,a),s.save()),Ie(s,d),this.ctx=d,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(s),this.groupLevel++}endGroup(t,i){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();if(null!==s)if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),i.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform()));else{this.ctx.restore();const i=$t(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...i);const s=L.slice();gt.axialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i,s),this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy({canvas:e.canvas,context:e}),this.compose(s)}else this.restore(t)}beginAnnotation(t,i,e,s,n,r){if(this.#js(),Re(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const n=e[2]-e[0],o=e[3]-e[1];if(r&&this.annotationCanvasMap){(s=s.slice())[4]-=e[0],s[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=n,e[3]=o,gt.singularValueDecompose2dScale($t(this.ctx),Ee);const{viewportScale:t}=this;this.annotationCanvas=this.canvasFactory.create(Math.ceil(n*this.outputScaleX*t),Math.ceil(o*this.outputScaleY*t));const{canvas:r,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(i,r),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(Ee[0],0,0,-Ee[1],0,o*Ee[1]),Re(this.ctx)}else{Re(this.ctx),this.endPath(t);const i=new Path2D;i.rect(e[0],e[1],n,o),this.ctx.clip(i)}}this.current=new Te(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...s),this.transform(t,...n),this.baseTransform=$t(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#zs(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,i){if(!this.contentVisible)return;const e=i.count;(i=this.getObject(t,i.data,i)).count=e;const s=this.ctx,n=this._createMaskCanvas(t,i),r=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(r,n.offsetX,n.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,n.offsetX,n.offsetX+r.width,n.offsetY,n.offsetY+r.height).recordOperation(t),s.restore(),n.canvasEntry&&this.canvasFactory.destroy(n.canvasEntry),this.compose()}paintImageMaskXObjectRepeat(t,i,e,s=0,n=0,r,o){if(!this.contentVisible)return;i=this.getObject(t,i.data,i);const h=this.ctx;h.save();const a=$t(h);h.transform(e,s,n,r,0,0);const c=this._createMaskCanvas(t,i);h.setTransform(1,0,0,1,c.offsetX-a[4],c.offsetY-a[5]),this.dependencyTracker?.resetBBox(t);for(let i=0,l=o.length;i<l;i+=2){const l=gt.transform(a,[e,s,n,r,o[i],o[i+1]]);h.drawImage(c.canvas,l[4],l[5]),this.dependencyTracker?.recordBBox(t,this.ctx,l[4],l[4]+c.canvas.width,l[5],l[5]+c.canvas.height)}h.restore(),c.canvasEntry&&this.canvasFactory.destroy(c.canvasEntry),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,i){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,n=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Bi);for(const r of i){const{data:i,width:o,height:h,transform:a}=r,c=this.canvasFactory.create(o,h),l=c.context;l.save(),De(l,this.getObject(t,i,r)),l.globalCompositeOperation="source-in",l.fillStyle=n?s.getPattern(l,this,jt(e),fe,t):s,l.fillRect(0,0,o,h),l.restore(),e.save(),e.transform(...a),e.scale(1,-1),ke(e,c.canvas,0,0,o,h,0,-1,1,1),this.canvasFactory.destroy(c),this.dependencyTracker?.recordBBox(t,e,0,o,0,h),e.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,i){if(!this.contentVisible)return;const e=this.getObject(t,i);e?this.paintInlineImageXObject(t,e):Z("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,i,e,s,n){if(!this.contentVisible)return;const r=this.getObject(t,i);if(!r)return void Z("Dependent image isn't ready yet");const o=r.width,h=r.height,a=[];for(let t=0,i=n.length;t<i;t+=2)a.push({transform:[e,0,0,s,n[t],n[t+1]],x:0,y:0,w:o,h});this.paintInlineImageXObjectGroup(t,r,a)}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{img:t.bitmap,canvasEntry:null};const{bitmap:i,width:e,height:s}=t,n=this.canvasFactory.create(e,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(i,0,0),r.filter="none",{img:n.canvas,canvasEntry:n}}paintInlineImageXObject(t,i){if(!this.contentVisible)return;const e=i.width,s=i.height,n=this.ctx;this.save(t);const{filter:r}=n;let o;"none"!==r&&""!==r&&(n.filter="none"),n.scale(1/e,-1/s);let h=null;if(i.bitmap){const t=this.applyTransferMapsToBitmap(i);o=t.img,h=t.canvasEntry}else if("function"==typeof HTMLElement&&i instanceof HTMLElement||!i.data)o=i;else{const t=this.canvasFactory.create(e,s);Pe(t.context,i),o=this.applyTransferMapsToCanvas(t.context),h=t}const a=this._scaleImage(o,jt(n));n.imageSmoothingEnabled=Ne($t(n),i.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,n,0,e,-s,0).recordDependencies(t,Ni).recordOperation(t),this.imagesTracker?.record(n,e,s,this.dependencyTracker.clipBox)),ke(n,a.img,0,0,a.paintWidth,a.paintHeight,0,-s,e,s),a.tmpCanvas&&this.canvasFactory.destroy(a.tmpCanvas),h&&this.canvasFactory.destroy(h),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,i,e){if(!this.contentVisible)return;const s=this.ctx;let n,r=null;if(i.bitmap)n=i.bitmap;else{const t=this.canvasFactory.create(i.width,i.height);Pe(t.context,i),n=this.applyTransferMapsToCanvas(t.context),r=t}this.dependencyTracker?.resetBBox(t);for(const i of e)s.save(),s.transform(...i.transform),s.scale(1,-1),ke(s,n,i.x,i.y,i.w,i.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,s,0,1,-1,0),s.restore();r&&this.canvasFactory.destroy(r),this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Ri).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,i){}markPointProps(t,i,e){}beginMarkedContent(t,i){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,i,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push("OC"===i?{visible:this.optionalContentConfig.isVisible(e)}:{visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,i,e){const s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const n=this.ctx;this.pendingClip?(s||(this.pendingClip===Be?n.clip(i,"evenodd"):n.clip(i)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=$t(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const i=Math.abs(t[0]*t[3]-t[2]*t[1]),e=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(e,s)/i}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:i,b:e,c:s,d:n}=this.ctx.getTransform();let r,o;if(0===e&&0===s){const e=Math.abs(i),s=Math.abs(n);if(e===s)if(0===t)r=o=1/e;else{const i=e*t;r=o=i<1?1/i:1}else if(0===t)r=1/e,o=1/s;else{const i=e*t,n=s*t;r=i<1?1/i:1,o=n<1?1/n:1}}else{const h=Math.abs(i*n-e*s),a=Math.hypot(i,e),c=Math.hypot(s,n);if(0===t)r=c/h,o=a/h;else{const i=t*h;r=c>i?c/i:1,o=a>i?a/i:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,i){const{ctx:e,current:{lineWidth:s}}=this,[n,r]=this.getScaleForStroking();if(n===r)return e.lineWidth=(s||1)*n,void e.stroke(t);const o=e.getLineDash();i&&e.save(),e.scale(n,r),Ce.a=1/n,Ce.d=1/r;const h=new Path2D;if(h.addPath(t,Ce),o.length>0){const t=Math.max(n,r);e.setLineDash(o.map((i=>i/t))),e.lineDashOffset/=t}e.lineWidth=s||1,e.stroke(h),i&&e.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 X)void 0!==Le.prototype[t]&&(Le.prototype[X[t]]=Le.prototype[t]);class Ue{#Ws=null;#Gs=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,i,e){this._source=t,this.#Ws=i,this.#Gs=e}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return it(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#Ws(this)}getRangeReader(t,i){if(i<=this._progressiveDataLength)return null;const e=new this.#Gs(this,t,i);return this._rangeReaders.add(e),e}cancelAllRequests(t){this._fullReader?.cancel(t);for(const i of new Set(this._rangeReaders))i.cancel(t)}}class $e{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){tt("Abstract method `read` called")}cancel(t){tt("Abstract method `cancel` called")}}class je{_stream=null;constructor(t,i,e){this._stream=t}async read(){tt("Abstract method `read` called")}cancel(t){tt("Abstract method `cancel` called")}}function ze(t,i){const e=new Headers;if(!t||!i||"object"!=typeof i)return e;for(const t in i){const s=i[t];void 0!==s&&e.append(t,s)}return e}function He(t){return URL.parse(t)?.origin??null}function We({responseHeaders:t,isHttp:i,rangeChunkSize:e,disableRange:s}){const n={contentLength:0,isRangeSupported:!1},r=parseInt(t.get("Content-Length"),10);return Number.isInteger(r)?(n.contentLength=r,r<=2*e||s||!i||"bytes"!==t.get("Accept-Ranges")||"identity"===(t.get("Content-Encoding")||"identity")&&(n.isRangeSupported=!0),n):n}function Ge(t){const i=t.get("Content-Disposition");if(i){let t=function(t){let i=!0,e=s("filename\\*","i").exec(t);if(e){e=e[1];let t=o(e);return t=unescape(t),t=h(t),t=a(t),r(t)}if(e=function(t){const i=[];let e;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=n.exec(t));){let[,t,s,n]=e;if(t=parseInt(t,10),t in i){if(0===t)break}else i[t]=[s,n]}const r=[];for(let t=0;t<i.length&&t in i;++t){let[e,s]=i[t];s=o(s),e&&(s=unescape(s),0===t&&(s=h(s))),r.push(s)}return r.join("")}(t),e)return r(a(e));if(e=s("filename","i").exec(t),e){e=e[1];let t=o(e);return t=a(t),r(t)}function s(t,i){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',i)}function n(t,e){if(t){if(!/^[\x00-\xFF]+$/.test(e))return e;try{const s=new TextDecoder(t,{fatal:!0}),n=ft(e);e=s.decode(n),i=!1}catch{}}return e}function r(t){return i&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),i&&(t=n("iso-8859-1",t))),t}function o(t){if(t.startsWith('"')){const i=t.slice(1).split('\\"');for(let t=0;t<i.length;++t){const e=i[t].indexOf('"');-1!==e&&(i[t]=i[t].slice(0,e),i.length=t+1),i[t]=i[t].replaceAll(/\\(.)/g,"$1")}t=i.join('"')}return t}function h(t){const i=t.indexOf("'");return-1===i?t:n(t.slice(0,i),t.slice(i+1).replace(/^[^']*'/,""))}function a(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,i,e,s){if("q"===e||"Q"===e)return n(i,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,i){return String.fromCharCode(parseInt(i,16))})));try{s=atob(s)}catch{}return n(i,s)}))}return""}(i);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Rt(t))return t}return null}function Ve(t,i){return new lt(`Unexpected server response (${t}) while retrieving PDF "${i.href}".`,t,404===t||0===t&&"file:"===i.protocol)}function Ye(t,i){if(t!==i)throw Error(`Expected range response-origin "${t}" to match "${i}".`)}function Xe(t,i,e,s){return fetch(t,{method:"GET",headers:i,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function qe(t,i){if(200!==t&&206!==t)throw Ve(t,i)}function Qe(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;throw Error("getArrayBuffer - unexpected data: "+t)}class Ke extends Ue{_responseOrigin=null;constructor(t){super(t,Je,Ze);const{httpHeaders:i,url:e}=t;it(/https?:/.test(e.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=ze(!0,i)}}class Je extends $e{_abortController=new AbortController;_reader=null;constructor(t){super(t);const{disableRange:i,disableStream:e,rangeChunkSize:s,url:n,withCredentials:r}=t._source;this._isStreamingSupported=!e;const o=new Headers(t.headers);Xe(n,o,r,this._abortController).then((e=>{t._responseOrigin=He(e.url),qe(e.status,n),this._reader=e.body.getReader();const r=e.headers,{contentLength:o,isRangeSupported:h}=We({responseHeaders:r,isHttp:!0,rangeChunkSize:s,disableRange:i});this._contentLength=o,this._isRangeSupported=h,this._filename=Ge(r),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new dt("Streaming is disabled.")),this._headersCapability.resolve()})).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:t,done:i}=await this._reader.read();return i?{value:t,done:i}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:Qe(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Ze extends je{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,i,e){super(t,i,e);const{url:s,withCredentials:n}=t._source,r=new Headers(t.headers);r.append("Range",`bytes=${i}-${e-1}`),Xe(s,r,n,this._abortController).then((i=>{Ye(He(i.url),t._responseOrigin),qe(i.status,s),this._reader=i.body.getReader(),this._readCapability.resolve()})).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:t,done:i}=await this._reader.read();return i?{value:t,done:i}:{value:Qe(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}function ts(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function is(){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}_(116);class es extends Ue{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,ss,ns);const{pdfDataRangeTransport:i}=t,{initialData:e,progressiveDone:s}=i;if(e?.length>0){const t=ts(e);this._queuedChunks.push(t)}this._progressiveDone=s,i.transportReady((t=>{switch(t.type){case"range":case"progressiveRead":this.#Vs(t.begin,t.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0}}))}#Vs(t,i){const e=ts(i);if(void 0===t)this._fullReader?this._fullReader._enqueue(e):this._queuedChunks.push(e);else{const i=this._rangeReaders.keys().find((i=>i._begin===t));it(i,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),i._enqueue(e)}}getFullReader(){const t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,i){const e=super.getRangeReader(t,i);return e&&(e.onDone=()=>this._rangeReaders.delete(e),this._source.pdfDataRangeTransport.requestDataRange(t,i)),e}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class ss extends $e{#Ys=is.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);const{pdfDataRangeTransport:i,disableRange:e,disableStream:s}=t._source,{length:n,contentDispositionFilename:r}=i;this._queuedChunks=t._queuedChunks||[];for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._done=t._progressiveDone,this._contentLength=n,this._isStreamingSupported=!s,this._isRangeSupported=!e,Rt(r)&&(this._filename=r),this._headersCapability.resolve();const o=this._loaded;Promise.resolve().then((()=>{o>0&&this._loaded===o&&this._callOnProgress()}))}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#Ys()}progressiveDone(){this._done||=!0,0===this._queuedChunks.length&&this.#Ys()}}class ns extends je{#Ys=is.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,i,e){super(t,i,e),this._begin=i}_enqueue(t){this._done||(0===this._requests.length?this._queuedChunk=t:(this._requests.shift().resolve({value:t,done:!1}),this.#Ys()),this._done=!0,this.onDone?.())}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,this.#Ys(),this.onDone?.()}}class rs extends Ue{#Xs=new WeakMap;_responseOrigin=null;constructor(t){super(t,os,hs);const{httpHeaders:i,url:e}=t;this.url=e,this.isHttp=/https?:/.test(e.protocol),this.headers=ze(this.isHttp,i)}_request(t){const i=new XMLHttpRequest,e={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#Xs.set(i,e),i.open("GET",this.url),i.withCredentials=this._source.withCredentials;for(const[t,e]of this.headers)i.setRequestHeader(t,e);return this.isHttp&&"begin"in t&&"end"in t?(i.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),e.validateStatus=t=>206===t||200===t):e.validateStatus=t=>200===t,i.responseType="arraybuffer",it(t.onError,"Expected `onError` callback to be provided."),i.onerror=()=>t.onError(i.status),i.onreadystatechange=this.#qs.bind(this,i),i.onprogress=this.#Qs.bind(this,i),i.send(null),i}#Qs(t,i){const e=this.#Xs.get(t);e?.onProgress?.(i)}#qs(t,i){const e=this.#Xs.get(t);if(!e)return;if(t.readyState>=2&&e.onHeadersReceived&&(e.onHeadersReceived(),delete e.onHeadersReceived),4!==t.readyState)return;if(!this.#Xs.has(t))return;if(this.#Xs.delete(t),0===t.status&&this.isHttp)return void e.onError(t.status);const s=t.status||200;if(!e.validateStatus(s))return void e.onError(t.status);const n=function(t){return"string"!=typeof t?t:ft(t).buffer}(t.response);if(206===s){const i=t.getResponseHeader("Content-Range");/bytes (\d+)-(\d+)\/(\d+)/.test(i)?e.onDone(n):(Z('Missing or invalid "Content-Range" header.'),e.onError(0))}else n?e.onDone(n):e.onError(t.status)}_abortRequest(t){this.#Xs.has(t)&&(this.#Xs.delete(t),t.abort())}getRangeReader(t,i){const e=super.getRangeReader(t,i);return e&&(e.onClosed=()=>this._rangeReaders.delete(e)),e}}class os extends $e{#Ys=is.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t),this._fullRequestXhr=t._request({onHeadersReceived:this.#Ks.bind(this),onDone:this.#Js.bind(this),onError:this.#Zs.bind(this),onProgress:this.#Qs.bind(this)})}#Ks(){const t=this._stream,{disableRange:i,rangeChunkSize:e}=t._source,s=this._fullRequestXhr;t._responseOrigin=He(s.responseURL);const n=s.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[i,...e]=t.split(": ");return[i,e.join(": ")]})):[]),{contentLength:o,isRangeSupported:h}=We({responseHeaders:r,isHttp:t.isHttp,rangeChunkSize:e,disableRange:i});this._contentLength=o,this._isRangeSupported=h,this._filename=Ge(r),this._isRangeSupported&&t._abortRequest(s),this._headersCapability.resolve()}#Js(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,0===this._cachedChunks.length&&this.#Ys()}#Zs(t){this._storedError=Ve(t,this._stream.url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#Qs(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}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),this.#Ys(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class hs extends je{#Ys=is.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,i,e){super(t,i,e),this._requestXhr=t._request({begin:i,end:e,onHeadersReceived:this.#Ks.bind(this),onDone:this.#Js.bind(this),onError:this.#Zs.bind(this),onProgress:null})}#Ks(){const t=He(this._requestXhr?.responseURL);try{Ye(t,this._stream._responseOrigin)}catch(t){this._storedError=t,this.#Zs(0)}}#Js(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this.#Ys(),this.onClosed?.()}#Zs(t){this._storedError??=Ve(t,this._stream.url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}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,this.#Ys(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function as(t,i=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),n=e.createReadStream(t,i);return s.toWeb(n)}class cs extends Ue{constructor(t){super(t,ls,us);const{url:i}=t;it("file:"===i.protocol,"PDFNodeStream only supports file:// URLs.")}}class ls extends $e{_reader=null;constructor(t){super(t);const{disableRange:i,disableStream:e,rangeChunkSize:s,url:n}=t._source;this._isStreamingSupported=!e,process.getBuiltinModule("fs/promises").lstat(n).then((t=>{const e=as(n);this._reader=e.getReader();const{size:r}=t;this._contentLength=r,this._isRangeSupported=!i&&r>2*s,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new dt("Streaming is disabled.")),this._headersCapability.resolve()})).catch((t=>{"ENOENT"===t.code&&(t=Ve(0,n)),this._headersCapability.reject(t)}))}async read(){await this._headersCapability.promise;const{value:t,done:i}=await this._reader.read();return i?{value:t,done:i}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:Qe(t),done:!1})}cancel(t){this._reader?.cancel(t)}}class us extends je{_readCapability=Promise.withResolvers();_reader=null;constructor(t,i,e){super(t,i,e);const{url:s}=t._source;try{const t=as(s,{start:i,end:e-1});this._reader=t.getReader(),this._readCapability.resolve()}catch(t){this._readCapability.reject(t)}}async read(){await this._readCapability.promise;const{value:t,done:i}=await this._reader.read();return i?{value:t,done:i}:{value:Qe(t),done:!1}}cancel(t){this._reader?.cancel(t)}}class ds{static#tn=null;static#in="";static get workerPort(){return this.#tn}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#tn=t}static get workerSrc(){return this.#in}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#in=t}}class fs{#en;#sn;constructor({parsedData:t,rawData:i}){this.#en=t,this.#sn=i}getRaw(){return this.#sn}get(t){return this.#en.get(t)??null}[Symbol.iterator](){return this.#en.entries()}}const ps=Symbol("INTERNAL");class gs{#nn=!1;#rn=!1;#on=!1;#hn=!0;constructor(t,{name:i,intent:e,usage:s,rbGroups:n}){this.#nn=!!(2&t),this.#rn=!!(4&t),this.name=i,this.intent=e,this.usage=s,this.rbGroups=n}get visible(){if(this.#on)return this.#hn;if(!this.#hn)return!1;const{print:t,view:i}=this.usage;return this.#nn?"OFF"!==i?.viewState:!this.#rn||"OFF"!==t?.printState}_setVisible(t,i,e=!1){t!==ps&&tt("Internal method `_setVisible` called."),this.#on=e,this.#hn=i}}class ms{#an=null;#cn=new Map;#ln=null;#un=null;constructor(t,i=2){if(this.renderingIntent=i,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#un=t.order;for(const e of t.groups)this.#cn.set(e.id,new gs(i,e));if("OFF"===t.baseState)for(const t of this.#cn.values())t._setVisible(ps,!1);for(const i of t.on)this.#cn.get(i)._setVisible(ps,!0);for(const i of t.off)this.#cn.get(i)._setVisible(ps,!1);this.#ln=this.getHash()}}#dn(t){const i=t.length;if(i<2)return!0;const e=t[0];for(let s=1;s<i;s++){const i=t[s];let n;if(Array.isArray(i))n=this.#dn(i);else{if(!this.#cn.has(i))return Z("Optional content group not found: "+i),!0;n=this.#cn.get(i).visible}switch(e){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===e}isVisible(t){if(0===this.#cn.size)return!0;if(!t)return J("Optional content group not defined."),!0;if("OCG"===t.type)return this.#cn.has(t.id)?this.#cn.get(t.id).visible:(Z("Optional content group not found: "+t.id),!0);if("OCMD"===t.type){if(t.expression)return this.#dn(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const i of t.ids){if(!this.#cn.has(i))return Z("Optional content group not found: "+i),!0;if(this.#cn.get(i).visible)return!0}return!1}if("AllOn"===t.policy){for(const i of t.ids){if(!this.#cn.has(i))return Z("Optional content group not found: "+i),!0;if(!this.#cn.get(i).visible)return!1}return!0}if("AnyOff"===t.policy){for(const i of t.ids){if(!this.#cn.has(i))return Z("Optional content group not found: "+i),!0;if(!this.#cn.get(i).visible)return!0}return!1}if("AllOff"===t.policy){for(const i of t.ids){if(!this.#cn.has(i))return Z("Optional content group not found: "+i),!0;if(this.#cn.get(i).visible)return!1}return!0}return Z(`Unknown optional content policy ${t.policy}.`),!0}return Z(`Unknown group type ${t.type}.`),!0}setVisibility(t,i=!0,e=!0){const s=this.#cn.get(t);if(s){if(e&&i&&s.rbGroups.length)for(const i of s.rbGroups)for(const e of i)e!==t&&this.#cn.get(e)?._setVisible(ps,!1,!0);s._setVisible(ps,!!i,!0),this.#an=null}else Z("Optional content group not found: "+t)}setOCGState({state:t,preserveRB:i}){let e;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":e=s;continue}const t=this.#cn.get(s);if(t)switch(e){case"ON":this.setVisibility(s,!0,i);break;case"OFF":this.setVisibility(s,!1,i);break;case"Toggle":this.setVisibility(s,!t.visible,i)}}this.#an=null}get hasInitialVisibility(){return null===this.#ln||this.getHash()===this.#ln}getOrder(){return this.#cn.size?this.#un?this.#un.slice():[...this.#cn.keys()]:null}getGroup(t){return this.#cn.get(t)||null}getHash(){if(null!==this.#an)return this.#an;const t=new wi;for(const[i,e]of this.#cn)t.update(`${i}:${e.visible}`);return this.#an=t.hexdigest()}[Symbol.iterator](){return this.#cn.entries()}}class ws{#fn=null;#pn=null;#gn=0;#mn=null;#wn=null;get pagesNumber(){return this.#gn}set pagesNumber(t){this.#gn!==t&&(this.#gn=t,this.#fn=null,this.#pn=null)}#An(){if(this.#fn)return;const t=this.#gn,i=this.#fn=new Uint32Array(t);for(let e=0;e<t;e++)i[e]=e+1;this.#pn=new Int32Array(i)}#vn(){const t=new Map,i=this.#fn;for(let e=0,s=this.#gn;e<s;e++){const s=i[e],n=t.get(s);n?n.push(e+1):t.set(s,[e+1])}return t}movePages(t,i,e){this.#An();const s=this.#fn,n=this.#vn(),r=i.length,o=new Uint32Array(r);let h=0;for(let t=0;t<r;t++){const n=i[t]-1;o[t]=s[n],n<e&&h++}const a=this.#gn,c=a-r,l=Mt(e-h,0,c);for(let i=0,e=0;i<a;i++)t.has(i+1)||(s[e++]=s[i]);s.copyWithin(l+r,l,c),s.set(o,l),this.#bn(n),s.every(((t,i)=>t===i+1))&&(this.#fn=null)}deletePages(t){this.#An();const i=this.#fn,e=this.#vn();this.#wn={pageNumberToId:i.slice(),pagesNumber:this.#gn,prevPageNumbers:this.#pn.slice()};const s=this.#gn-t.length;this.#gn=s;const n=this.#fn=new Uint32Array(s);this.#pn=new Int32Array(s);let r=0,o=0;for(const e of t){const t=e-1;t!==r&&(n.set(i.subarray(r,t),o),o+=t-r),r=t+1}r<i.length&&n.set(i.subarray(r),o),this.#bn(e,new Set(t))}cancelDelete(){this.#wn&&(this.#fn=this.#wn.pageNumberToId,this.#gn=this.#wn.pagesNumber,this.#pn=this.#wn.prevPageNumbers,this.#wn=null)}cleanSavedData(){this.#wn=null}copyPages(t){this.#An(),this.#mn={pageNumbers:t,pageIds:t.map((t=>this.#fn[t-1]))}}cancelCopy(){this.#mn=null}pastePages(t){this.#An();const i=this.#fn,e=this.#vn(),{pageNumbers:s,pageIds:n}=this.#mn,r=this.#gn+s.length;this.#gn=r;const o=this.#fn=new Uint32Array(r);this.#pn=new Int32Array(r),o.set(i.subarray(0,t),0),o.set(n,t),o.set(i.subarray(t),t+s.length),this.#bn(e,null,t,s),this.#mn=null}#bn(t,i=null,e=-1,s=null){const n=this.#pn,r=this.#fn,o=e+(s?.length??0),h=new Map;for(let a=0,c=this.#gn;a<c;a++){if(a>=e&&a<o){n[a]=-s[a-e];continue}const c=r[a],l=t.get(c);let u=h.get(c)||0;if(i&&l)for(;u<l.length&&i.has(l[u]);)u++;n[a]=l?.[u],h.set(c,u+1)}}hasBeenAltered(){return null!==this.#fn}getPageMappingForSaving(t=null){t??=this.#vn();let i=0;for(const e of t.values())i=Math.max(i,e.length);const e=Array(i);for(let t=0;t<i;t++)e[t]={document:null,pageIndices:[],includePages:[]};for(const[i,s]of t)for(let t=0,n=s.length;t<n;t++)e[t].includePages.push([i-1,s[t]-1]);for(const{includePages:t,pageIndices:i}of e){t.sort(((t,i)=>t[0]-i[0]));for(let e=0,s=t.length;e<s;e++)i.push(t[e][1]),t[e]=t[e][0]}return e}extractPages(t){t=Array.from(t).sort(((t,i)=>t-i));const i=new Map;for(let e=0,s=t.length;e<s;e++){const s=this.getPageId(t[e]);i.getOrInsertComputed(s,bt).push(e+1)}return this.getPageMappingForSaving(i)}getPrevPageNumber(t){return this.#pn?.[t-1]??0}getPageNumber(t){if(!this.#fn)return t;const i=this.#fn;for(let e=0,s=this.#gn;e<s;e++)if(i[e]===t)return e+1;return 0}getPageId(t){return this.#fn?.[t-1]??t}getMapping(){return this.#fn?.subarray(0,this.pagesNumber)}}const As=Symbol("INITIAL_DATA"),vs=()=>({...Promise.withResolvers(),data:As});class bs{#yn=new Map;get(t,i=null){if(i){const e=this.#yn.getOrInsertComputed(t,vs);return e.promise.then((()=>i(e.data))),null}const e=this.#yn.get(t);if(!e||e.data===As)throw Error(`Requesting object that isn't resolved yet ${t}.`);return e.data}has(t){const i=this.#yn.get(t);return!!i&&i.data!==As}delete(t){const i=this.#yn.get(t);return!(!i||i.data===As||(this.#yn.delete(t),0))}resolve(t,i=null){const e=this.#yn.getOrInsertComputed(t,vs);if(e.data!==As)throw Error(`Object already resolved ${t}.`);e.data=i,e.resolve()}clear(){for(const{data:t}of this.#yn.values())t?.bitmap?.close();this.#yn.clear()}*[Symbol.iterator](){for(const[t,{data:i}]of this.#yn)i!==As&&(yield[t,i])}}class ys{#xn=Promise.withResolvers();#kt=null;#Mn=!1;#Sn=!!globalThis.FontInspector?.enabled;#Cn=null;#En=null;#kn=null;#Tn=0;#Pn=0;#Dn=null;#In=null;#Rn=0;#Nn=0;#On=Object.create(null);#_n=[];#Fn=null;#Bn=[];#Ln=new WeakMap;#Un=null;static#$n=new Map;static#jn=new Map;static#zn=new WeakMap;static#Hn=null;static#Wn=new Set;constructor({textContentSource:t,images:i,container:e,viewport:s}){if(t instanceof ReadableStream)this.#Fn=t;else{if("object"!=typeof t)throw Error('No "textContentSource" parameter specified.');this.#Fn=new ReadableStream({start(i){i.enqueue(t),i.close()}})}this.#kt=this.#In=e,this.#Cn=i,this.#Nn=s.scale*Ht.pixelRatio,this.#Rn=s.rotation,this.#kn={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:r,pageX:o,pageY:h}=s.rawDims;this.#Un=[1,0,0,-1,-o,h+r],this.#Pn=n,this.#Tn=r,ys.#Gn(),e.style.setProperty("--min-font-size",ys.#Hn),zt(e,s),this.#xn.promise.finally((()=>{ys.#Wn.delete(this),this.#kn=null,this.#On=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:i}=pt.platform;return rt(this,"fontFamilyMap",new Map([["sans-serif",(t&&i?"Calibri, ":"")+"sans-serif"],["monospace",(t&&i?"Lucida Console, ":"")+"monospace"]]))}render(){this.#Cn&&this.#kt.append(this.#Cn.render());const t=()=>{this.#Dn.read().then((({value:i,done:e})=>{e?this.#xn.resolve():(this.#En??=i.lang,Object.assign(this.#On,i.styles),this.#Vn(i.items),t())}),this.#xn.reject)};return this.#Dn=this.#Fn.getReader(),ys.#Wn.add(this),t(),this.#xn.promise}update({viewport:t,onBefore:i=null}){const e=t.scale*Ht.pixelRatio,s=t.rotation;if(s!==this.#Rn&&(i?.(),this.#Rn=s,zt(this.#In,{rotation:s})),e!==this.#Nn){i?.(),this.#Nn=e;const t={div:null,properties:null,ctx:ys.#Yn(this.#En)};for(const i of this.#Bn)t.properties=this.#Ln.get(i),t.div=i,this.#Xn(t)}}cancel(){const t=new dt("TextLayer task cancelled.");this.#Dn?.cancel(t).catch((()=>{})),this.#Dn=null,this.#xn.reject(t)}get textDivs(){return this.#Bn}get textContentItemsStr(){return this.#_n}#Vn(t){if(this.#Mn)return;this.#kn.ctx??=ys.#Yn(this.#En);const i=this.#Bn,e=this.#_n;for(const s of t){if(i.length>1e5)return Z("Ignoring additional textDivs for performance reasons."),void(this.#Mn=!0);if(void 0!==s.str)e.push(s.str),this.#qn(s);else if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){const t=this.#kt;this.#kt=document.createElement("span"),this.#kt.classList.add("markedContent"),s.id&&this.#kt.setAttribute("id",""+s.id),"Artifact"===s.tag&&(this.#kt.ariaHidden=!0),t.append(this.#kt)}else"endMarkedContent"===s.type&&(this.#kt=this.#kt.parentNode)}}#qn(t){const i=document.createElement("span"),e={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#Bn.push(i);const s=gt.transform(this.#Un,t.transform);let n=Math.atan2(s[1],s[0]);const r=this.#On[t.fontName];r.vertical&&(n+=Math.PI/2);let o=this.#Sn&&r.fontSubstitution||r.fontFamily;o=ys.fontFamilyMap.get(o)||o;const h=Math.hypot(s[2],s[3]),a=h*ys.#Qn(o,r,this.#En);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=i.style;u.left=(100*c/this.#Pn).toFixed(2)+"%",u.top=(100*l/this.#Tn).toFixed(2)+"%",u.setProperty("--font-height",h.toFixed(2)+"px"),u.fontFamily=o,e.fontSize=h,i.setAttribute("role","presentation"),i.textContent=t.str,i.dir=t.dir,this.#Sn&&(i.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),0!==n&&(e.angle=n*(180/Math.PI));let d=!1;if(t.str.length>1)d=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const i=Math.abs(t.transform[0]),e=Math.abs(t.transform[3]);i!==e&&Math.max(i,e)/Math.min(i,e)>1.5&&(d=!0)}if(d&&(e.canvasWidth=r.vertical?t.height:t.width),this.#Ln.set(i,e),this.#kn.div=i,this.#kn.properties=e,this.#Xn(this.#kn),e.hasText&&this.#kt.append(i),e.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#kt.append(t)}}#Xn(t){const{div:i,properties:e,ctx:s}=t,{style:n}=i;if(0!==e.canvasWidth&&e.hasText){const{fontFamily:t}=n,{canvasWidth:r,fontSize:o}=e;ys.#Kn(s,o*this.#Nn,t);const{width:h}=s.measureText(i.textContent);h>0&&n.setProperty("--scale-x",r*this.#Nn/h)}0!==e.angle&&n.setProperty("--rotate",e.angle+"deg")}static cleanup(){if(!(this.#Wn.size>0)){this.#$n.clear();for(const{canvas:t}of this.#jn.values())t.remove();this.#jn.clear()}}static#Yn(t=null){let i=this.#jn.get(t||="");if(!i){const e=document.createElement("canvas");e.className="hiddenCanvasElement",e.lang=t,document.body.append(e),i=e.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#jn.set(t,i),this.#zn.set(i,{size:0,family:""})}return i}static#Kn(t,i,e){const s=this.#zn.get(t);i===s.size&&e===s.family||(t.font=`${i}px ${e}`,s.size=i,s.family=e)}static#Gn(){if(null!==this.#Hn)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.#Hn=t.getBoundingClientRect().height,t.remove()}static#Qn(t,i,e){const s=this.#$n.get(t);if(s)return s;const n=this.#Yn(e);n.canvas.width=n.canvas.height=30,this.#Kn(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):(pt.platform.isFirefox&&Z("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),i.ascent?a=i.ascent:i.descent&&(a=1+i.descent)),this.#$n.set(t,a),a}}function xs(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const i=new Ms,{docId:e}=i,s=t.url?function(t){if(t instanceof URL)return t;if("string"==typeof t){if(F){if(/^[a-z][a-z0-9\-+.]+:/i.test(t))return new URL(t);const i=process.getBuiltinModule("url");return new URL(i.pathToFileURL(t))}const i=URL.parse(t,window.location);if(i)return i}throw 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(F&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw 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 ft(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw 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 Ss?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let l=t.worker instanceof ks?t.worker:null;const u=t.verbosity,d="string"!=typeof t.docBaseUrl||It(t.docBaseUrl)?null:t.docBaseUrl,f=Qi(t.cMapUrl),p=!1!==t.cMapPacked,g=Qi(t.iccUrl),m=Qi(t.standardFontDataUrl),w=Qi(t.wasmUrl),A=!0!==t.stopAtErrors,v=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,b="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!F,y="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!F&&(pt.platform.isFirefox||!globalThis.chrome),x=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,M="boolean"==typeof t.disableFontFace?t.disableFontFace:F,S=!0===t.fontExtraProperties,C=!0===t.enableXfa,E=t.ownerDocument||globalThis.document,k=!0===t.disableRange,T=!0===t.disableStream,P=!0===t.disableAutoFetch,D=!0===t.pdfBug,I=t.CanvasFactory||(F?le:oe),R=t.FilterFactory||(F?ce:ae),N=t.BinaryDataFactory||(F?ue:ne),O=!0===t.enableHWA,_=!0===t.enableWebGPU?de.init():Promise.resolve(!1),B=!1!==t.useWasm,L=t.pagesMapper||new ws,U="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!F&&!M,$="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(N===ne&&f&&p&&m&&w&&Ot(f,document.baseURI)&&Ot(m,document.baseURI)&&Ot(w,document.baseURI));Q(u);const j={canvasFactory:new I({ownerDocument:E,enableHWA:O}),filterFactory:new R({docId:e,ownerDocument:E}),binaryDataFactory:$?null:new N({cMapUrl:f,standardFontDataUrl:m,wasmUrl:w})};l||(l=ks.create({verbosity:u,port:ds.workerPort}),i._worker=l);const z={docId:e,apiVersion:"5.7.284",data:n,password:h,disableAutoFetch:P,rangeChunkSize:c,docBaseUrl:d,enableXfa:C,evaluatorOptions:{maxImageSize:v,disableFontFace:M,ignoreErrors:A,isOffscreenCanvasSupported:b,isImageDecoderSupported:y,canvasMaxAreaInBytes:x,fontExtraProperties:S,useSystemFonts:U,useWasm:B,useWorkerFetch:$,cMapUrl:f,cMapPacked:p,iccUrl:g,standardFontDataUrl:m,wasmUrl:w,hasGPU:!1}},H={ownerDocument:E,pdfBug:D,styleElement:null,enableHWA:O,loadingParams:{disableAutoFetch:P,enableXfa:C}};return Promise.all([l.promise,_]).then((function([,t]){if(i.destroyed)throw Error("Loading aborted");if(l.destroyed)throw Error("Worker was destroyed");z.evaluatorOptions.hasGPU=t;const h=l.messageHandler.sendWithPromise("GetDocRequest",z,n?[n.buffer]:null);let u;if(n);else if(a)u=new es({pdfDataRangeTransport:a,disableRange:k,disableStream:T});else{if(!s)throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");{const t=function(t){return Ot(t)?Ke:F?cs:rs}(s);u=new t({url:s,httpHeaders:r,withCredentials:o,rangeChunkSize:c,disableRange:k,disableStream:T})}}return h.then((t=>{if(i.destroyed)throw Error("Loading aborted");if(l.destroyed)throw Error("Worker was destroyed");const s=new ee(e,t,l.port),n=new Ts(s,i,u,H,j,L);i._transport=n,s.send("Ready",null)}))})).catch(i._capability.reject),i}class Ms{static#xs=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+Ms.#xs++;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 Ss{#xn=Promise.withResolvers();#Jn=null;constructor(t,i,e=!1,s=null){this.length=t,this.initialData=i,this.progressiveDone=e,this.contentDispositionFilename=s,Object.defineProperty(this,"onDataProgress",{value:()=>{console.log("Deprecated API usage: `PDFDataRangeTransport.prototype.onDataProgress` - method was removed, since loading progress is now reported automatically through the `PDFDataTransportStream` class (and related code).")}})}onDataRange(t,i){this.#Jn({type:"range",begin:t,chunk:i})}onDataProgressiveRead(t){this.#xn.promise.then((()=>{this.#Jn({type:"progressiveRead",chunk:t})}))}onDataProgressiveDone(){this.#xn.promise.then((()=>{this.#Jn({type:"progressiveDone"})}))}transportReady(t){this.#Jn=t,this.#xn.resolve()}requestDataRange(t,i){tt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Cs{constructor(t,i){this._pdfInfo=t,this._transport=i}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return rt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(t,i){return this._transport.getAnnotationsByType(t,i)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:i}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(i)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}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 Es{#Zn=!1;#tr=null;constructor(t,i,e,s,n=!1){this._pageIndex=t,this._pageInfo=i,this._transport=e,this._stats=n?new Nt:null,this._pdfBug=n,this.commonObjs=e.commonObjs,this.objs=new bs,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#tr=s,this.imageCoordinates=null}clone(t){const i=new Es(t,this._pageInfo,this._transport,this.#tr,this._pdfBug);return i.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(i),i}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:i=this.rotate,offsetX:e=0,offsetY:s=0,dontFlip:n=!1}={}){return new Pt({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:i,offsetX:e,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:i}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,i)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return rt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:i=t.canvas,viewport:e,intent:s="display",annotationMode:n=j.ENABLE,transform:r=null,background:o=null,optionalContentConfigPromise:h=null,annotationCanvasMap:a=null,pageColors:c=null,printAnnotationStorage:l=null,isEditing:u=!1,recordImages:d=!1,recordOperations:f=!1,operationsFilter:p=null}){this._stats?.time("Overall");const g=this._transport.getRenderingIntent(s,n,l,u),{renderingIntent:m,cacheKey:w}=g;this.#Zn=!1,h||=this._transport.getOptionalContentConfig(m);const A=this._intentStates.getOrInsertComputed(w,xt);A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);const v=!!(4&m);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(g));const b=!(!this._pdfBug||!globalThis.StepperManager?.enabled),y=!!i&&!this.recordedBBoxes&&(f||b),x=!!i&&!this.imageCoordinates&&d,M=t=>{if(A.renderTasks.delete(E),y){const t=E.gfx?.dependencyTracker.take();t&&(E.stepper?.setOperatorBBoxes(t,E.gfx.dependencyTracker.takeDebugMetadata()),f&&(this.recordedBBoxes=t))}x&&!t&&(this.imageCoordinates=E.gfx?.imagesTracker.take()),v&&(this.#Zn=!0),this.#ir(),t?(E.capability.reject(t),this._abortOperatorList({intentState:A,reason:t instanceof Error?t:Error(t)})):E.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let S=null,C=null;(y||x)&&(C=new Ti(i,A.operatorList.length)),y&&(S=new Pi(C,b));const E=new Ds({callback:M,params:{canvas:i,canvasContext:t,dependencyTracker:S??C,imagesTracker:x?new Li(i):null,viewport:e,transform:r,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:a,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:p});(A.renderTasks||=new Set).add(E);const k=E.task;return Promise.all([A.displayReadyCapability.promise,h]).then((([t,i])=>{if(this.destroyed)M();else{if(this._stats?.time("Rendering"),!(i.renderingIntent&m))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");E.initializeGraphics({transparency:t,optionalContentConfig:i}),E.operatorListChanged()}})).catch(M),k}getOperatorList({intent:t="display",annotationMode:i=j.ENABLE,printAnnotationStorage:e=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,i,e,s,!0),r=this._intentStates.getOrInsertComputed(n.cacheKey,xt);let o;return r.opListReadCapability||(o=Object.create(null),o.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(o))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(o),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:i=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#tr.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===i},{highWaterMark:100,size:t=>t.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>St.textContent(t)));const i=this.streamTextContent(t),e={items:[],styles:Object.create(null),lang:null};for await(const t of i)e.lang??=t.lang,Object.assign(e.styles,t.styles),e.items.push(...t.items);return e}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const i of this._intentStates.values())if(this._abortOperatorList({intentState:i,reason:Error("Page was destroyed."),force:!0}),!i.opListReadCapability)for(const e of i.renderTasks)t.push(e.completed),e.cancel();return this.objs.clear(),this.#Zn=!1,Promise.all(t)}cleanup(t=!1){this.#Zn=!0;const i=this.#ir();return t&&i&&(this._stats&&=new Nt),i}#ir(){if(!this.#Zn||this.destroyed)return!1;for(const{renderTasks:t,operatorList:i}of this._intentStates.values())if(t.size>0||!i.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#Zn=!1,!0}_startRenderPage(t,i){const e=this._intentStates.get(i);e&&(this._stats?.timeEnd("Page Request"),e.displayReadyCapability?.resolve(t))}_renderPageChunk(t,i){for(let e=0,s=t.length;e<s;e++)i.operatorList.fnArray.push(t.fnArray[e]),i.operatorList.argsArray.push(t.argsArray[e]);i.operatorList.lastChunk=t.lastChunk,i.operatorList.separateAnnots=t.separateAnnots;for(const t of i.renderTasks)t.operatorListChanged();t.lastChunk&&this.#ir()}_pumpOperatorList({renderingIntent:t,cacheKey:i,annotationStorageSerializable:e,modifiedIds:s}){const{map:n,transfer:r}=e,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#tr.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:i,annotationStorage:n,modifiedIds:s},void 0,r).getReader(),h=this._intentStates.get(i);h.streamReader=o;const a=()=>{o.read().then((({value:t,done:i})=>{i?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.#ir()}if(h.displayReadyCapability)h.displayReadyCapability.reject(t);else{if(!h.opListReadCapability)throw t;h.opListReadCapability.reject(t)}}}))};a()}_abortOperatorList({intentState:t,reason:i,force:e=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!e){if(t.renderTasks.size>0)return;if(i instanceof Dt){let e=100;return i.extraDelay>0&&i.extraDelay<1e3&&(e+=i.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:i,force:!0})}),e))}}if(t.streamReader.cancel(new dt(i.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[i,e]of this._intentStates)if(e===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}class ks{#xn=Promise.withResolvers();#er=null;#tn=null;#sr=null;static#nr=0;static#rr=!1;static#or=new WeakMap;static{F&&(this.#rr=!0,ds.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,i)=>{const e=URL.parse(t);if(!e?.origin||"null"===e.origin)return!1;const s=new URL(i,e);return e.origin===s.origin},this._createCDNWrapper=t=>URL.createObjectURL(new Blob([`await import("${t}");`],{type:"text/javascript"}))}constructor({name:t=null,port:i=null,verbosity:e=K()}={}){if(this.name=t,this.destroyed=!1,this.verbosity=e,i){if(ks.#or.has(i))throw Error("Cannot use more than one PDFWorker per port.");ks.#or.set(i,this),this.#hr(i)}else this.#ar()}get promise(){return this.#xn.promise}#cr(){this.#xn.resolve(),this.#er.send("configure",{verbosity:this.verbosity})}get port(){return this.#tn}get messageHandler(){return this.#er}#hr(t){this.#tn=t,this.#er=new ee("main","worker",t),this.#er.on("ready",(()=>{})),this.#cr()}#ar(){if(ks.#rr||ks.#lr)return void this.#ur();let{workerSrc:t}=ks;try{ks._isSameOrigin(window.location,t)||(t=ks._createCDNWrapper(new URL(t,window.location).href));const i=new Worker(t,{type:"module"}),e=new ee("main","worker",i),s=()=>{n.abort(),e.destroy(),i.terminate(),this.destroyed?this.#xn.reject(Error("Worker was destroyed")):this.#ur()},n=new AbortController;i.addEventListener("error",(()=>{this.#sr||s()}),{signal:n.signal}),e.on("test",(t=>{n.abort(),!this.destroyed&&t?(this.#er=e,this.#tn=i,this.#sr=i,this.#cr()):s()})),e.on("ready",(()=>{if(n.abort(),this.destroyed)s();else try{r()}catch{this.#ur()}}));const r=()=>{const t=new Uint8Array;e.send("test",t,[t.buffer])};return void r()}catch{J("The worker has been disabled.")}this.#ur()}#ur(){ks.#rr||(Z("Setting up fake worker."),ks.#rr=!0),ks._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this.#xn.reject(Error("Worker was destroyed"));const i=new Zi;this.#tn=i;const e="fake"+ks.#nr++,s=new ee(e+"_worker",e,i);t.setup(s,i),this.#er=new ee(e,e+"_worker",i),this.#cr()})).catch((t=>{this.#xn.reject(Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this.#sr?.terminate(),this.#sr=null,ks.#or.delete(this.#tn),this.#tn=null,this.#er?.destroy(),this.#er=null}static create(t){const i=this.#or.get(t?.port);if(i){if(i._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new ks(t)}static get workerSrc(){if(ds.workerSrc)return ds.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#lr(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return rt(this,"_setupFakeWorkerGlobal",(async()=>this.#lr?this.#lr:(await import(this.workerSrc)).WorkerMessageHandler)())}}class Ts{downloadInfoCapability=Promise.withResolvers();#dr=null;#fr=new Map;#pr=null;#gr=new Map;#mr=new Map;#wr=new Map;#Ar=null;constructor(t,i,e,s,n,r){this.messageHandler=t,this.loadingTask=i,this.#pr=e,this.commonObjs=new bs,this.fontLoader=new Ui({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.enableHWA=s.enableHWA,this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.binaryDataFactory=n.binaryDataFactory,this.pagesMapper=r,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){const{_pageIndex:i}=t;this.#gr.set(i,t),this.#mr.set(i,Promise.resolve(t))}#vr(t,i=null){return this.#fr.getOrInsertComputed(t,(()=>this.messageHandler.sendWithPromise(t,i)))}#Qs({loaded:t,total:i}){this.loadingTask.onProgress?.({loaded:t,total:i,percent:i?Mt(Math.round(t/i*100),0,100):NaN})}get annotationStorage(){return rt(this,"annotationStorage",new vi)}getRenderingIntent(t,i=j.ENABLE,e=null,s=!1,n=!1){let r=2,o=Ai;switch(t){case"any":r=1;break;case"display":break;case"print":r=4;break;default:Z("getRenderingIntent - invalid intent: "+t)}const h=4&r&&e instanceof bi?e:this.annotationStorage;switch(i){case j.DISABLE:r+=64;break;case j.ENABLE:break;case j.ENABLE_FORMS:r+=16;break;case j.ENABLE_STORAGE:r+=32,o=h.serializable;break;default:Z("getRenderingIntent - invalid annotationMode: "+i)}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.#Ar?.reject(Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of this.#gr.values())t.push(i._destroy());this.#gr.clear(),this.#mr.clear(),this.#wr.clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const i=this.messageHandler.sendWithPromise("Terminate",null);return t.push(i),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#fr.clear(),this.filterFactory.destroy(),ys.cleanup(),this.#pr?.cancelAllRequests(new dt("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:i}=this;t.on("GetReader",((t,i)=>{it(this.#pr,"GetReader - no `BasePDFStream` instance available."),this.#dr=this.#pr.getFullReader(),this.#dr.onProgress=t=>this.#Qs(t),i.onPull=()=>{this.#dr.read().then((function({value:t,done:e}){e?i.close():(it(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{i.error(t)}))},i.onCancel=t=>{this.#dr.cancel(t),i.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async()=>{await this.#dr.headersReady;const{isStreamingSupported:t,isRangeSupported:i,contentLength:e}=this.#dr;return t&&i&&(this.#dr.onProgress=null),{isStreamingSupported:t,isRangeSupported:i,contentLength:e}})),t.on("GetRangeReader",((t,i)=>{it(this.#pr,"GetRangeReader - no `BasePDFStream` instance available.");const e=this.#pr.getRangeReader(t.begin,t.end);e?(i.onPull=()=>{e.read().then((function({value:t,done:e}){e?i.close():(it(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{i.error(t)}))},i.onCancel=t=>{e.cancel(t),i.ready.catch((t=>{if(!this.destroyed)throw t}))}):i.close()})),t.on("GetDoc",(({pdfInfo:t})=>{this.pagesMapper.pagesNumber=t.numPages,this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,i._capability.resolve(new Cs(t,this))})),t.on("DocException",(t=>{i._capability.reject(ie(t))})),t.on("PasswordRequest",(t=>{this.#Ar=Promise.withResolvers();try{if(!i.onPassword)throw ie(t);i.onPassword((t=>{t instanceof Error?this.#Ar.reject(t):this.#Ar.resolve({password:t})}),t.code)}catch(t){this.#Ar.reject(t)}return this.#Ar.promise})),t.on("DataLoaded",(t=>{this.#Qs({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{this.destroyed||this.#gr.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([i,e,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(i))return null;switch(e){case"Font":if("error"in s){const t=s.error;Z("Error during font loading: "+t),this.commonObjs.resolve(i,t);break}const n=new Yi(s),r=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,i)=>globalThis.FontInspector.fontAdded(t,i):null,o=new $i(n,r,s.charProcOperatorList,s.extra);this.fontLoader.bind(o).catch((()=>t.sendWithPromise("FontFallback",{id:i}))).finally((()=>{o.fontExtraProperties||o.clearData(),this.commonObjs.resolve(i,o)}));break;case"CopyLocalImage":const{imageRef:h}=s;it(h,"The imageRef must be defined.");for(const t of this.#gr.values())for(const[,e]of t.objs){if(e?.ref!==h)continue;if(!e.dataLen)return null;const t=structuredClone(e);return this.commonObjs.resolve(i,t),e.dataLen}break;case"FontPath":this.commonObjs.resolve(i,new qi(s));break;case"Image":this.commonObjs.resolve(i,s);break;case"Pattern":const a=new Xi(s);this.commonObjs.resolve(i,a.getIR());break;default:throw Error("Got unknown common object type "+e)}return null})),t.on("obj",(([t,i,e,s])=>{if(this.destroyed)return;const n=this.#gr.get(i);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(e){case"Image":case"Pattern":n.objs.resolve(t,s);break;default:throw Error("Got unknown object type "+e)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||this.#Qs(t)})),t.on("FetchBinaryData",(async t=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&Z("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:i}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#dr?.filename??null},i).finally((()=>{this.annotationStorage.resetModified()}))}extractPages(t){const i={pageInfos:t};let e;if(this.annotationStorage.size>0){const{map:t,transfer:s}=this.annotationStorage.serializable;i.annotationStorage=t,e=s}return this.messageHandler.sendWithPromise("ExtractPages",i,e).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(Error("Invalid page request."));const i=t-1,e=this.pagesMapper.getPageId(t)-1,s=this.#mr.get(i);if(s)return s;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((t=>{if(this.destroyed)throw Error("Transport destroyed");t.refStr&&this.#wr.set(t.refStr,e);const s=new Es(i,t,this,this.pagesMapper,this._params.pdfBug);return this.#gr.set(i,s),s}));return this.#mr.set(i,n),n}async getPageIndex(t){if(!Ki(t))throw Error("Invalid pageIndex request.");const i=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),e=this.pagesMapper.getPageNumber(i+1);if(0===e)throw Error("GetPageIndex: page has been removed.");return e-1}getAnnotations(t,i){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:i})}getFieldObjects(){return this.#vr("GetFieldObjects")}hasJSActions(){return this.#vr("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,i){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:i})}getDocJSActions(){return this.#vr("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#vr("GetOptionalContentConfig").then((i=>new ms(i,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return this.#fr.getOrInsertComputed(t,(()=>this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new fs(t[1]):null,contentDispositionFilename:this.#dr?.filename??null,contentLength:this.#dr?.contentLength??null,hasStructTree:t[2]})))))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#gr.values())if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#fr.clear(),this.filterFactory.destroy(!0),ys.cleanup()}}cachedPageNumber(t){if(!Ki(t))return null;const i=this.#wr.get(0===t.gen?t.num+"R":`${t.num}R${t.gen}`);if(i>=0){const t=this.pagesMapper.getPageNumber(i+1);if(0!==t)return t}return null}}class Ps{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:i}=this._internalRenderTask;return t.form||t.canvas&&i?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class Ds{#br=null;static#yr=new WeakSet;constructor({callback:t,params:i,objs:e,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:o,canvasFactory:h,filterFactory:a,useRequestAnimationFrame:c=!1,pdfBug:l=!1,pageColors:u=null,enableHWA:d=!1,operationsFilter:f=null}){this.callback=t,this.params=i,this.objs=e,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 Ps(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=i.canvas,this._canvasContext=i.canvas?null:i.canvasContext,this._enableHWA=d,this._dependencyTracker=i.dependencyTracker,this._imagesTracker=i.imagesTracker,this._operationsFilter=f}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:i}){if(this.cancelled)return;if(this._canvas){if(Ds.#yr.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Ds.#yr.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:e,transform:s,background:n,dependencyTracker:r,imagesTracker:o}=this.params,h=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Le(h,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:i},this.annotationCanvasMap,this.pageColors,r,o),this.gfx.beginDrawing({transform:s,viewport:e,transparency:t,background:n}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,i=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#br&&(window.cancelAnimationFrame(this.#br),this.#br=null),Ds.#yr.delete(this._canvas),t||=new Dt("Rendering cancelled, page "+(this._pageIndex+1),i),this.callback(t),this.task.onError?.(t)}operatorListChanged(){this.graphicsReady?(this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),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.#br=window.requestAnimationFrame((()=>{this.#br=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),Ds.#yr.delete(this._canvas),this.callback())))}}_(3068);class Is{#xr=null;#Mr=null;#Sr;#Cr=null;#Er=!1;#kr=!1;#o=null;#Tr;#Pr=null;#A=null;static#Dr=null;static get _keyboardManager(){return rt(this,"_keyboardManager",new oi([[["Escape","mac+Escape"],Is.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Is.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Is.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Is.prototype._moveToPrevious],[["Home","mac+Home"],Is.prototype._moveToBeginning],[["End","mac+End"],Is.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:i=null}){t?(this.#kr=!1,this.#o=t):this.#kr=!0,this.#A=t?._uiManager||i,this.#Tr=this.#A._eventBus,this.#Sr=t?.color?.toUpperCase()||this.#A?.highlightColors.values().next().value||"#FFFF98",Is.#Dr||=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.#xr=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#o&&(t.ariaControls=this.#o.id+"_colorpicker_dropdown");const i=this.#A._signal;t.addEventListener("click",this.#Ir.bind(this),{signal:i}),t.addEventListener("keydown",this.#Rr.bind(this),{signal:i});const e=this.#Mr=document.createElement("span");return e.className="swatch",e.ariaHidden="true",e.style.backgroundColor=this.#Sr,t.append(e),t}renderMainDropdown(){const t=this.#Cr=this.#Nr();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#Nr(){const t=document.createElement("div"),i=this.#A._signal;t.addEventListener("contextmenu",_t,{signal:i}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#o&&(t.id=this.#o.id+"_colorpicker_dropdown");for(const[e,s]of this.#A.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=e,n.setAttribute("data-l10n-id",Is.#Dr[e]);const r=document.createElement("span");n.append(r),r.className="swatch",r.style.backgroundColor=s,n.ariaSelected=s===this.#Sr,n.addEventListener("click",this.#Or.bind(this,s),{signal:i}),t.append(n)}return t.addEventListener("keydown",this.#Rr.bind(this),{signal:i}),t}#Or(t,i){i.stopPropagation(),this.#Tr.dispatch("switchannotationeditorparams",{source:this,type:W.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#xr)return void this.#Ir(t);const i=t.target.getAttribute("data-color");i&&this.#Or(i,t)}_moveToNext(t){this.#_r?t.target!==this.#xr?t.target.nextSibling?.focus():this.#Cr.firstElementChild?.focus():this.#Ir(t)}_moveToPrevious(t){t.target!==this.#Cr?.firstElementChild&&t.target!==this.#xr?(this.#_r||this.#Ir(t),t.target.previousSibling?.focus()):this.#_r&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#_r?this.#Cr.firstElementChild?.focus():this.#Ir(t)}_moveToEnd(t){this.#_r?this.#Cr.lastElementChild?.focus():this.#Ir(t)}#Rr(t){Is._keyboardManager.exec(this,t)}#Ir(t){if(this.#_r)return void this.hideDropdown();if(this.#Er=0===t.detail,this.#Pr||(this.#Pr=new AbortController,window.addEventListener("pointerdown",this.#f.bind(this),{signal:this.#A.combinedSignal(this.#Pr)})),this.#xr.ariaExpanded="true",this.#Cr)return void this.#Cr.classList.remove("hidden");const i=this.#Cr=this.#Nr();this.#xr.append(i)}#f(t){this.#Cr?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Cr?.classList.add("hidden"),this.#xr.ariaExpanded="false",this.#Pr?.abort(),this.#Pr=null}get#_r(){return this.#Cr&&!this.#Cr.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#kr||(this.#_r?(this.hideDropdown(),this.#xr.focus({preventScroll:!0,focusVisible:this.#Er})):this.#o?.unselect())}updateColor(t){if(this.#Mr&&(this.#Mr.style.backgroundColor=t),!this.#Cr)return;const i=this.#A.highlightColors.values();for(const e of this.#Cr.children)e.ariaSelected=i.next().value===t.toUpperCase()}destroy(){this.#xr?.remove(),this.#xr=null,this.#Mr=null,this.#Cr?.remove(),this.#Cr=null}}class Rs{#Fr=null;#Br=!1;#o=null;#A=null;static#Dr=null;constructor(t){this.#o=t,this.#A=t._uiManager,Rs.#Dr||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#Fr)return this.#Fr;const{editorType:t,colorType:i,colorAndOpacityType:e,opacityType:s,color:n,opacity:r}=this.#o,o=this.#Br=pt.isAlphaColorInputSupported&&void 0!==s,h=this.#Fr=document.createElement("input");return h.type="color",o?(h.setAttribute("alpha",""),h.value=(n||"#000000")+gt.hexNums[Math.round(255*(r??1))]):h.value=n||"#000000",h.className="basicColorPicker",h.tabIndex=0,h.setAttribute("data-l10n-id",Rs.#Dr[t]),h.addEventListener("input",(()=>{if(o){const t=Lt(h.value);if(!t)return;const[n,r,o,a]=t,c=gt.makeHexColor(n,r,o);void 0!==e?this.#A.updateParams(e,{color:c,opacity:a}):(this.#A.updateParams(i,c),this.#A.updateParams(s,a))}else this.#A.updateParams(i,h.value)}),{signal:this.#A._signal}),h}update(t){if(this.#Fr)if(this.#Br){const i=gt.hexNums[Math.round(255*this.#o.opacity)];this.#Fr.value=t+i}else this.#Fr.value=t}updateOpacity(t){this.#Fr&&this.#Br&&(this.#Fr.value=this.#o.color+gt.hexNums[Math.round(255*t)])}destroy(){this.#Fr?.remove(),this.#Fr=null}hideDropdown(){}}function Ns(t){return Math.floor(255*Mt(t,0,1)).toString(16).padStart(2,"0")}function Os(t){return 255*Mt(t,0,1)}_(531);class _s{static CMYK_G([t,i,e,s]){return["G",1-Math.min(1,.3*t+.59*e+.11*i+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=Os(t),t,t]}static G_HTML([t]){const i=Ns(t);return`#${i}${i}${i}`}static RGB_G([t,i,e]){return["G",.3*t+.59*i+.11*e]}static RGB_rgb(t){return t.map(Os)}static RGB_HTML(t){return"#"+t.map(Ns).join("")}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,i,e,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,e+s),1-Math.min(1,i+s)]}static CMYK_rgb([t,i,e,s]){return[Os(1-Math.min(1,t+s)),Os(1-Math.min(1,e+s)),Os(1-Math.min(1,i+s))]}static CMYK_HTML(t){const i=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(i)}static RGB_CMYK([t,i,e]){const s=1-t,n=1-i,r=1-e;return["CMYK",s,n,r,Math.min(s,n,r)]}}class Fs{create(t,i,e=!1){if(t<=0||i<=0)throw Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),e||(s.setAttribute("width",t+"px"),s.setAttribute("height",i+"px")),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${i}`),s}createElement(t){if("string"!=typeof t)throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){tt("Abstract method `_createSVG` called.")}}class Bs extends Fs{_createSVG(t){return document.createElementNS(Et,t)}}const Ls=new WeakSet,Us=60*(new Date).getTimezoneOffset()*1e3;class $s{static create(t){switch(t.data.annotationType){case V.LINK:return new Hs(t);case V.TEXT:return new Ws(t);case V.WIDGET:switch(t.data.fieldType){case"Tx":return new Vs(t);case"Btn":return t.data.radioButton?new qs(t):t.data.checkBox?new Xs(t):new Qs(t);case"Ch":return new Ks(t);case"Sig":return new Ys(t)}return new Gs(t);case V.POPUP:return new Js(t);case V.FREETEXT:return new tn(t);case V.LINE:return new en(t);case V.SQUARE:return new sn(t);case V.CIRCLE:return new nn(t);case V.POLYLINE:return new rn(t);case V.CARET:return new hn(t);case V.INK:return new an(t);case V.POLYGON:return new on(t);case V.HIGHLIGHT:return new cn(t);case V.UNDERLINE:return new ln(t);case V.SQUIGGLY:return new un(t);case V.STRIKEOUT:return new dn(t);case V.STAMP:return new fn(t);case V.FILEATTACHMENT:return new pn(t);default:return new js(t)}}}class js{#Lr=null;#Ur=!1;#$r=null;constructor(t,{isRenderable:i=!1,ignoreBorder:e=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=i,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,i&&(this.contentElement=this.container=this._createContainer(e)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:i}){return!(!t?.str&&!i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return js._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:t}=this,i=this.annotationStorage?.getEditor(t.id);return i?i.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:i,inkLists:e,rect:s}=this.data;let n=-1/0,r=-1/0;if(i?.length>=8){for(let t=0;t<i.length;t+=8)i[t+1]>r?(r=i[t+1],n=i[t+2]):i[t+1]===r&&(n=Math.max(n,i[t+2]));return[n,r]}if(e?.length>=1){for(const t of e)for(let i=0,e=t.length;i<e;i+=2)t[i+1]>r?(r=t[i+1],n=t[i]):t[i+1]===r&&(n=Math.max(n,t[i]));if(n!==1/0)return[n,r]}return s?[s[2],s[3]]:null}_normalizePoint(t){const{page:{view:i},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:n,pageY:r}}}=this.parent;return t[1]=i[3]-t[1]+i[1],t[0]=100*(t[0]-n)/e,t[1]=100*(t[1]-r)/s,t}get commentText(){const{data:t}=this;return this.annotationStorage.getRawValue(`${z}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:i}=this,e={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(i.id,{popup:e})||this.annotationStorage.setValue(`${z}${i.id}`,{id:i.id,annotationType:i.annotationType,page:this.parent.page,popup:e,popupRef:i.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#$r?.popup||this.popup)?.remove(),this.#$r=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#Lr||={rect:this.data.rect.slice(0)});const{rect:i,popup:e}=t;i&&this.#jr(i);let s=this.#$r?.popup||this.popup;!s&&e?.text&&(this._createPopup(e),s=this.#$r.popup),s&&(s.updateEdited(t),e?.deleted&&(s.remove(),this.#$r=null,this.popup=null))}resetEdited(){this.#Lr&&(this.#jr(this.#Lr.rect),this.#$r?.popup.resetEdited(),this.#Lr=null)}#jr(t){const{container:{style:i},data:{rect:e,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:o,pageY:h}}}}=this;e?.splice(0,4,...t),i.left=100*(t[0]-o)/n+"%",i.top=100*(r-t[3]+h)/r+"%",0===s?(i.width=100*(t[2]-t[0])/n+"%",i.height=100*(t[3]-t[1])/r+"%"):this.setRotation(s)}_createContainer(t){const{data:i,parent:{page:e,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",i.id),this instanceof Gs||this instanceof Hs||(n.tabIndex=0);const{style:r}=n;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,i.alternativeText&&(n.title=i.alternativeText),i.noRotate&&n.classList.add("norotate"),!i.rect||this instanceof Js){const{rotation:t}=i;return i.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:o,height:h}=this;if(!t&&i.borderStyle.width>0){r.borderWidth=i.borderStyle.width+"px";const t=i.borderStyle.horizontalCornerRadius,e=i.borderStyle.verticalCornerRadius;switch(t>0||e>0?r.borderRadius=`calc(${t}px * var(--total-scale-factor)) / calc(${e}px * var(--total-scale-factor))`:this instanceof qs&&(r.borderRadius=`calc(${o}px * var(--total-scale-factor)) / calc(${h}px * var(--total-scale-factor))`),i.borderStyle.style){case 1:r.borderStyle="solid";break;case 2:r.borderStyle="dashed";break;case 3:Z("Unimplemented border style: beveled");break;case 4:Z("Unimplemented border style: inset");break;case 5:r.borderBottomStyle="solid"}const s=i.borderColor||null;s?(this.#Ur=!0,r.borderColor=gt.makeHexColor(...s)):r.borderWidth=0}const a=gt.normalizeRect([i.rect[0],e.view[3]-i.rect[1]+e.view[1],i.rect[2],e.view[3]-i.rect[3]+e.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}=i;return i.hasOwnCanvas||0===f?(r.width=100*o/c+"%",r.height=100*h/l+"%"):this.setRotation(f,n),n}setRotation(t,i=this.container){if(!this.data.rect)return;const{pageWidth:e,pageHeight:s}=this.parent.viewport.rawDims;let{width:n,height:r}=this;t%180!=0&&([n,r]=[r,n]),i.style.width=100*n/e+"%",i.style.height=100*r/s+"%",i.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,i,e)=>{const s=e.detail[t],n=s[0],r=s.slice(1);e.target.style[i]=_s[n+"_HTML"](r),this.annotationStorage.setValue(this.data.id,{[i]:_s[n+"_rgb"](r)})};return rt(this,"_commonActions",{display:t=>{const{display:i}=t.detail,e=i%2==1;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:e,noPrint:1===i||2===i})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:i}=t.detail;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:i,noView:i})},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:i=>{t("bgColor","backgroundColor",i)},fillColor:i=>{t("fillColor","backgroundColor",i)},fgColor:i=>{t("fgColor","color",i)},textColor:i=>{t("textColor","color",i)},borderColor:i=>{t("borderColor","borderColor",i)},strokeColor:i=>{t("strokeColor","borderColor",i)},rotation:t=>{const i=t.detail.rotation;this.setRotation(i),this.annotationStorage.setValue(this.data.id,{rotation:i})}})}_dispatchEventFromSandbox(t,i){const e=this._commonActions;for(const s of Object.keys(i.detail)){const n=t[s]||e[s];n?.(i)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const i=this.annotationStorage.getRawValue(this.data.id);if(!i)return;const e=this._commonActions;for(const[s,n]of Object.entries(i)){const r=e[s];r&&(r({detail:{[s]:n},target:t}),delete i[s])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[i,e,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&&i===h&&e===a)return}const{style:r}=this.container;let o;if(this.#Ur){const{borderColor:t,borderWidth:i}=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="${i}">`],this.container.classList.add("hasBorder")}const h=s-i,a=n-e,{svgFactory:c}=this,l=c.createElement("svg");l.classList.add("quadrilateralsContainer"),l.setAttribute("width",0),l.setAttribute("height",0),l.role="none";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 e=2,s=t.length;e<s;e+=8){const s=t[e],r=t[e+1],l=t[e+2],u=t[e+3],f=c.createElement("rect"),p=(l-i)/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.#Ur&&(o.push("</g></svg>')"),r.backgroundImage=o.join("")),this.container.append(l),this.container.style.clipPath=`url(#${f})`}_createPopup(t=null){const{data:i}=this;let e,s;t?(e={str:t.text},s=t.date):(e=i.contentsObj,s=i.modificationDate),this.#$r=new Js({data:{color:i.color,titleObj:i.titleObj,modificationDate:s,contentsObj:e,richText:i.richText,parentRect:i.rect,borderStyle:0,id:"popup_"+i.id,rotation:i.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#$r||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#$r}render(){tt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,i=null){const e=[];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===i)continue;const s="string"==typeof r?r:null,o=document.querySelector(`[data-element-id="${n}"]`);!o||Ls.has(o)?e.push({id:n,exportValue:s,domElement:o}):Z("_getElementsByName - element not allowed: "+n)}return e}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==i&&Ls.has(s)&&e.push({id:n,exportValue:t,domElement:s})}return e}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 i of t)i.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:i}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:i,mustEnterInEditMode:!0})}))}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class zs extends js{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class Hs extends js{constructor(t,i=null){super(t,{isRenderable:!0,ignoreBorder:!!i?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:i}=this,e=document.createElement("a");e.setAttribute("data-element-id",t.id);let s=!1;return t.url?(i.addLinkAttributes(e,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(e,t.action,t.overlaidText),s=!0):t.attachment?(this.#zr(e,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(this.#Hr(e,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(e,t.dest,t.overlaidText),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(e,t),s=!0),t.resetForm?(this._bindResetFormAction(e,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(e,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&(this.contentElement=e,this.container.append(e)),this.container}#Wr(){this.container.setAttribute("data-internal-link","")}_bindLink(t,i,e=""){t.href=this.linkService.getDestinationHash(i),t.onclick=()=>(i&&this.linkService.goToDestination(i),!1),(i||""===i)&&this.#Wr(),e&&(t.title=e)}_bindNamedAction(t,i,e=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(i),!1),e&&(t.title=e),this.#Wr()}#zr(t,i,e="",s=null){t.href=this.linkService.getAnchorUrl(""),i.description?t.title=i.description:e&&(t.title=e),t.onclick=()=>(this.downloadManager?.openOrDownloadData(i.content,i.filename,s),!1),this.#Wr()}#Hr(t,i,e=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(i),!1),e&&(t.title=e),this.#Wr()}_bindJSAction(t,i){t.href=this.linkService.getAnchorUrl("");const e=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(i.actions)){const n=e.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i.id,name:s}}),!1))}i.overlaidText&&(t.title=i.overlaidText),t.onclick||(t.onclick=()=>!1),this.#Wr()}_bindResetFormAction(t,i){const e=t.onclick;if(e||(t.href=this.linkService.getAnchorUrl("")),this.#Wr(),!this._fieldObjects)return Z('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(e||(t.onclick=()=>!1));t.onclick=()=>{e?.();const{fields:t,refs:s,include:n}=i,r=[];if(0!==t.length||0!==s.length){const i=new Set(s);for(const e of t){const t=this._fieldObjects[e]||[];for(const{id:e}of t)i.add(e)}for(const t of Object.values(this._fieldObjects))for(const e of t)i.has(e.id)===n&&r.push(e)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const o=this.annotationStorage,h=[];for(const t of r){const{id:i}=t;switch(h.push(i),t.type){case"text":case"combobox":case"listbox":o.setValue(i,{value:t.defaultValue||""});break;case"checkbox":case"radiobutton":o.setValue(i,{value:t.defaultValue===t.exportValues});break;default:continue}const e=document.querySelector(`[data-element-id="${i}"]`);e&&(Ls.has(e)?e.dispatchEvent(new Event("resetform")):Z("_bindResetFormAction - element not allowed: "+i))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}}),!1}}}class Ws extends js{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class Gs extends js{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return pt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,i,e,s,n){e.includes("mouse")?t.addEventListener(e,(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(e,(t=>{if("blur"===e){if(!i.focused||!t.relatedTarget)return;i.focused=!1}else if("focus"===e){if(i.focused)return;i.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,i,e,s){for(const[n,r]of e)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(i||={focused:!1}),this._setEventListener(t,i,n,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,i,"focus","Focus",null):this._setEventListener(t,i,"blur","Blur",null))}_setBackgroundColor(t){const i=this.data.backgroundColor||null;t.style.backgroundColor=null===i?"transparent":gt.makeHexColor(...i)}_setTextStyle(t){const{fontColor:i}=this.data.defaultAppearanceData,e=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);n=Math.min(e,r(t/(Math.round(t/($*e))||1)/$))}else n=Math.min(e,r(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/$));s.fontSize=`calc(${n}px * var(--total-scale-factor))`,s.color=gt.makeHexColor(...i),null!==this.data.textAlignment&&(s.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,i){i?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",i)}}class Vs extends Gs{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,i,e,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[i]=e),n.setValue(r.id,{[s]:e})}render(){const t=this.annotationStorage,i=this.data.id;this.container.classList.add("textWidgetAnnotation");let e=null;if(this.renderForms){const s=t.getValue(i,{value:this.data.fieldValue});let n=s.value||"";const r=t.getValue(i,{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?(e=document.createElement("textarea"),e.textContent=o??n,this.data.doNotScroll&&(e.style.overflowY="hidden")):(e=document.createElement("input"),e.type=this.data.password?"password":"text",e.setAttribute("value",o??n),this.data.doNotScroll&&(e.style.overflowX="hidden")),this.data.hasOwnCanvas&&(e.hidden=!0),Ls.add(e),this.contentElement=e,e.setAttribute("data-element-id",i),e.disabled=this.data.readOnly,e.name=this.data.fieldName,e.tabIndex=0;const{datetimeFormat:a,datetimeType:c,timeStep:l}=this.data,u=!!c&&this.enableScripting;a&&(e.title=a),this._setRequired(e,this.data.required),r&&(e.maxLength=r),e.addEventListener("input",(s=>{t.setValue(i,{value:s.target.value}),this.setPropertyOnSiblings(e,"value",s.target.value,"value"),h.formattedValue=null})),e.addEventListener("resetform",(()=>{e.value=h.userValue=this.data.defaultFieldValue??"",h.formattedValue=null}));let d=t=>{const{formattedValue:i}=h;null!=i&&(t.target.value=i),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){e.addEventListener("focus",(t=>{if(h.focused)return;const{target:i}=t;if(u&&(i.type=c,l&&(i.step=l)),h.userValue){const t=h.userValue;if(u)if("time"===c){const e=new Date(t),s=[e.getHours(),e.getMinutes(),e.getSeconds()];i.value=s.map((t=>(""+t).padStart(2,"0"))).join(":")}else i.value=new Date(t-Us).toISOString().split("date"===c?"T":".",1)[0];else i.value=t}h.lastCommittedValue=i.value,h.commitKey=1,this.data.actions?.Focus||(h.focused=!0)})),e.addEventListener("updatefromsandbox",(e=>{this.showElementAndHideCanvas(e.target),this._dispatchEventFromSandbox({value(e){h.userValue=e.detail.value??"",u||t.setValue(i,{value:""+h.userValue}),e.target.value=h.userValue},formattedValue(e){const{formattedValue:s}=e.detail;h.formattedValue=s,null!=s&&e.target!==document.activeElement&&(e.target.value=s);const n={formattedValue:s};u&&(n.value=s),t.setValue(i,n)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:e=>{const{charLimit:s}=e.detail,{target:n}=e;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(i,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}},e)})),e.addEventListener("keydown",(t=>{h.commitKey=1;let e=-1;if("Escape"===t.key?e=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(h.commitKey=3):e=2,-1===e)return;const{value:s}=t.target;h.lastCommittedValue!==s&&(h.lastCommittedValue=s,h.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:s,willCommit:!0,commitKey:e,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const s=d;d=null,e.addEventListener("blur",(t=>{if(!h.focused||!t.relatedTarget)return;this.data.actions?.Blur||(h.focused=!1);const{target:e}=t;let{value:n}=e;if(u){if(n&&"time"===c){const t=n.split(":").map((t=>parseInt(t,10)));n=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),e.step=""}else n.includes("T")||(n+="T00:00"),n=new Date(n).valueOf();e.type="text"}h.userValue=n,h.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:n,willCommit:!0,commitKey:h.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)})),this.data.actions?.Keystroke&&e.addEventListener("beforeinput",(t=>{h.lastCommittedValue=null;const{data:e,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:i,name:"Keystroke",value:n,change:e||"",willCommit:!1,selStart:a,selEnd:c}})})),this._setEventListeners(e,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(d&&e.addEventListener("blur",d),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/r;e.classList.add("comb"),e.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else e=document.createElement("div"),e.textContent=this.data.fieldValue,e.style.verticalAlign="middle",e.style.display="table-cell",this.data.hasOwnCanvas&&(e.hidden=!0);return this._setTextStyle(e),this._setBackgroundColor(e),this._setDefaultPropertiesFromJS(e),this.container.append(e),this.container}}class Ys extends Gs{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Xs extends Gs{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,i=this.data,e=i.id;let s=t.getValue(e,{value:i.exportValue===i.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(e,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Ls.add(n),n.setAttribute("data-element-id",e),n.disabled=i.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=i.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",i.exportValue),n.tabIndex=0,n.addEventListener("change",(s=>{const{name:n,checked:r}=s.target;for(const s of this._getElementsByName(n,e)){const e=r&&s.exportValue===i.exportValue;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}t.setValue(e,{value:r})})),n.addEventListener("resetform",(t=>{t.target.checked=(i.defaultFieldValue||"Off")===i.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(i=>{this._dispatchEventFromSandbox({value(i){i.target.checked="Off"!==i.detail.value,t.setValue(e,{value:i.target.checked})}},i)})),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 qs extends Gs{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,i=this.data,e=i.id;let s=t.getValue(e,{value:i.fieldValue===i.buttonValue}).value;if("string"==typeof s&&(s=s!==i.buttonValue,t.setValue(e,{value:s})),s)for(const s of this._getElementsByName(i.fieldName,e))t.setValue(s.id,{value:!1});const n=document.createElement("input");if(Ls.add(n),n.setAttribute("data-element-id",e),n.disabled=i.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=i.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=0,n.addEventListener("change",(i=>{const{name:s,checked:n}=i.target;for(const i of this._getElementsByName(s,e))t.setValue(i.id,{value:!1});t.setValue(e,{value:n})})),n.addEventListener("resetform",(t=>{const e=i.defaultFieldValue;t.target.checked=null!=e&&e===i.buttonValue})),this.enableScripting&&this.hasJSActions){const s=i.buttonValue;n.addEventListener("updatefromsandbox",(i=>{this._dispatchEventFromSandbox({value:i=>{const n=s===i.detail.value;for(const s of this._getElementsByName(i.target.name)){const i=n&&s.id===e;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}}},i)})),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 Qs extends Hs{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const i=t.lastChild;return this.enableScripting&&this.hasJSActions&&i&&(this._setDefaultPropertiesFromJS(i),i.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Ks extends Gs{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,i=this.data.id,e=t.getValue(i,{value:this.data.fieldValue}),s=document.createElement("select");Ls.add(s),s.setAttribute("data-element-id",i),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=0;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 i of s.options)i.selected=i.value===t}));const r=(t,i)=>{const e=i.replaceAll(" "," ");t.textContent=e,e!==i&&t.setAttribute("display-value",i)};for(const t of this.data.options){const i=document.createElement("option");r(i,t.displayValue),i.value=t.exportValue,e.value.includes(t.exportValue)&&(i.setAttribute("selected",!0),n=!1),s.append(i)}let o=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),o=()=>{t.remove(),s.removeEventListener("input",o),o=null},s.addEventListener("input",o)}const h=t=>{const i=t?"value":"textContent",{options:e,multiple:n}=s;return n?Array.prototype.filter.call(e,(t=>t.selected)).map((t=>t[i])):-1===e.selectedIndex?null:e[e.selectedIndex][i]};let a=h(!1);const c=t=>Array.prototype.map.call(t.target.options,(t=>({displayValue:t.getAttribute("display-value")||t.textContent,exportValue:t.value})));return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({value(e){o?.();const n=e.detail.value,r=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=r.has(t.value);t.setValue(i,{value:h(!0)}),a=h(!1)},multipleSelection(t){s.multiple=!0},remove(e){const n=s.options,r=e.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(i,{value:h(!0),items:c(e)}),a=h(!1)},clear(e){for(;0!==s.length;)s.remove(0);t.setValue(i,{value:null,items:[]}),a=h(!1)},insert(e){const{index:n,displayValue:o,exportValue:l}=e.detail.insert,u=s.children[n],d=document.createElement("option");r(d,o),d.value=l,u?u.before(d):s.append(d),t.setValue(i,{value:h(!0),items:c(e)}),a=h(!1)},items(e){const{items:n}=e.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:i,exportValue:e}=t,n=document.createElement("option");r(n,i),n.value=e,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(i,{value:h(!0),items:c(e)}),a=h(!1)},indices(e){const s=new Set(e.detail.indices);for(const t of e.target.options)t.selected=s.has(t.index);t.setValue(i,{value:h(!0)}),a=h(!1)},editable(t){t.target.disabled=!t.detail.editable}},e)})),s.addEventListener("input",(e=>{const s=h(!0),n=h(!1);t.setValue(i,{value:s}),e.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:a,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(i,{value:h(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Js extends js{constructor(t){const{data:i,elements:e,parent:s}=t,n=!!s._commentManager;if(super(t,{isRenderable:!n&&js._hasPopupData(i)}),this.elements=e,n&&js._hasPopupData(i)){const t=this.popup=this.#Gr();for(const i of e)i.popup=t}else this.popup=null}#Gr(){return new Zs({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const i=this.popup=this.#Gr(),e=[];for(const t of this.elements)t.popup=i,t.container.ariaHasPopup="dialog",e.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${vt}${t}`)).join(",")),this.container}}class Zs{#G=null;#Vr=this.#Rr.bind(this);#Yr=this.#Xr.bind(this);#qr=this.#Qr.bind(this);#Kr=this.#Jr.bind(this);#Zr=null;#kt=null;#to=null;#io=null;#eo=null;#so=null;#no=null;#ro=!1;#oo=null;#ho=null;#N=null;#ao=null;#co=null;#bi=null;#lo=null;#mi=null;#uo=null;#Lr=null;#do=!1;#fo=null;#po=null;constructor({container:t,color:i,elements:e,titleObj:s,modificationDate:n,contentsObj:r,richText:o,parent:h,rect:a,parentRect:c,open:l,commentManager:u=null}){this.#kt=t,this.#uo=s,this.#to=r,this.#mi=o,this.#so=h,this.#Zr=i,this.#lo=a,this.#no=c,this.#eo=e,this.#G=u,this.#fo=e[0],this.#io=Bt.toDateObject(n),this.trigger=e.flatMap((t=>t.getElementsToTriggerPopup())),u||(this.#go(),this.#kt.hidden=!0,l&&this.#Jr())}#go(){if(this.#ho)return;this.#ho=new AbortController;const{signal:t}=this.#ho;for(const i of this.trigger)i.addEventListener("click",this.#Kr,{signal:t}),i.addEventListener("pointerenter",this.#qr,{signal:t}),i.addEventListener("pointerleave",this.#Yr,{signal:t}),i.classList.add("popupTriggerArea");for(const i of this.#eo)i.container?.addEventListener("keydown",this.#Vr,{signal:t})}#mo(){const t=this.#eo.find((t=>t.hasCommentButton));t&&(this.#co=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#ao)return void(this.#ao.parentNode||this.#fo.container.after(this.#ao));if(this.#co||this.#mo(),!this.#co)return;const{signal:t}=this.#ho=new AbortController,i=this.#fo.hasOwnCommentButton,e=()=>{this.#G.toggleCommentPopup(this,!0,void 0,!i)},s=()=>{this.#G.toggleCommentPopup(this,!1,!0,!i)},n=()=>{this.#G.toggleCommentPopup(this,!1,!1)};if(i){this.#ao=this.#fo.container;for(const i of this.trigger)i.ariaHasPopup="dialog",i.ariaControls="commentPopup",i.addEventListener("keydown",this.#Vr,{signal:t}),i.addEventListener("click",e,{signal:t}),i.addEventListener("pointerenter",s,{signal:t}),i.addEventListener("pointerleave",n,{signal:t}),i.classList.add("popupTriggerArea")}else{const i=this.#ao=document.createElement("button");i.className="annotationCommentButton";const r=this.#fo.container;i.style.zIndex=parseInt(r.style.zIndex,10)+1,i.tabIndex=0,i.ariaHasPopup="dialog",i.ariaControls="commentPopup",i.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#wo(),this.#Ao(),i.addEventListener("keydown",this.#Vr,{signal:t}),i.addEventListener("click",e,{signal:t}),i.addEventListener("pointerenter",s,{signal:t}),i.addEventListener("pointerleave",n,{signal:t}),r.after(i)}}#Ao(){if(this.#fo.extraPopupElement&&!this.#fo.editor)return;this.#ao||this.renderCommentButton();const[t,i]=this.#co,{style:e}=this.#ao;e.left=`calc(${t}%)`,e.top=`calc(${i}% - var(--comment-button-dim))`}#wo(){this.#fo.extraPopupElement||(this.#ao||this.renderCommentButton(),this.#ao.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){const{color:t,opacity:i}=this.#fo.commentData;return t?this.#so._commentManager.makeCommentColor(t,i):null}focusCommentButton(){setTimeout((()=>{this.#ao?.focus()}),0)}getData(){const{richText:t,color:i,opacity:e,creationDate:s,modificationDate:n}=this.#fo.commentData;return{contentsObj:{str:this.comment},richText:t,color:i,opacity:e,creationDate:s,modificationDate:n}}get elementBeforePopup(){return this.#ao}get comment(){return this.#po||=this.#fo.commentText,this.#po}set comment(t){t!==this.comment&&(this.#fo.commentText=this.#po=t)}focus(){this.#fo.container?.focus()}get parentBoundingClientRect(){return this.#fo.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:i}){this.#ao&&(this.#ao.classList.toggle("selected",t),this.#ao.ariaExpanded=i)}setSelectedCommentButton(t){this.#ao.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#bi)return this.#bi;const{x:t,y:i,height:e}=this.#ao.getBoundingClientRect(),{x:s,y:n,width:r,height:o}=this.#fo.layer.getBoundingClientRect();return[(t-s)/r,(i+e-n)/o]}set commentPopupPosition(t){this.#bi=t}hasDefaultPopupPosition(){return null===this.#bi}get commentButtonPosition(){return this.#co}get commentButtonWidth(){return this.#ao.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[i,e]=this.#bi||this.commentButtonPosition.map((t=>t/100)),s=this.parentBoundingClientRect,{x:n,y:r,width:o,height:h}=s;this.#G.showDialog(null,this,n+i*o,r+e*h,{...t,parentDimensions:s})}render(){if(this.#oo)return;const t=this.#oo=document.createElement("div");if(t.className="popup",this.#Zr){const i=t.style.outlineColor=gt.makeHexColor(...this.#Zr);t.style.backgroundColor=`color-mix(in srgb, ${i} 30%, white)`}const i=document.createElement("span");if(i.className="header",this.#uo?.str){const t=document.createElement("span");t.className="title",i.append(t),({dir:t.dir,str:t.textContent}=this.#uo)}if(t.append(i),this.#io){const t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#io.valueOf()})),t.dateTime=this.#io.toISOString(),i.append(t)}Kt({html:this.#vo||this.#to.str,dir:this.#to?.dir,className:"popupContent"},t),this.#kt.append(t)}get#vo(){const t=this.#mi,i=this.#to;return!t?.str||i?.str&&i.str!==t.str?null:this.#mi.html||null}get#bo(){return this.#vo?.attributes?.style?.fontSize||0}get#yo(){return this.#vo?.attributes?.style?.color||null}#xo(t){const i=[],e={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:i}]}},s={style:{color:this.#yo,fontSize:this.#bo?`calc(${this.#bo}px * var(--total-scale-factor))`:""}};for(const e of t.split("\n"))i.push({name:"span",value:e,attributes:s});return e}#Rr(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#ro)&&this.#Jr()}updateEdited({rect:t,popup:i,deleted:e}){if(this.#G)return e?(this.remove(),this.#po=null):i&&(i.deleted?this.remove():(this.#wo(),this.#po=i.text)),void(t&&(this.#co=null,this.#mo(),this.#Ao()));e||i?.deleted?this.remove():(this.#go(),this.#Lr||={contentsObj:this.#to,richText:this.#mi},t&&(this.#N=null),i&&i.text&&(this.#mi=this.#xo(i.text),this.#io=Bt.toDateObject(i.date),this.#to=null),this.#oo?.remove(),this.#oo=null)}resetEdited(){this.#Lr&&(({contentsObj:this.#to,richText:this.#mi}=this.#Lr),this.#Lr=null,this.#oo?.remove(),this.#oo=null,this.#N=null)}remove(){if(this.#ho?.abort(),this.#ho=null,this.#oo?.remove(),this.#oo=null,this.#do=!1,this.#ro=!1,this.#ao?.remove(),this.#ao=null,this.trigger)for(const t of this.trigger)t.classList.remove("popupTriggerArea")}#Mo(){if(null!==this.#N)return;const{page:{view:t},viewport:{rawDims:{pageWidth:i,pageHeight:e,pageX:s,pageY:n}}}=this.#so;let r=!!this.#no,o=r?this.#no:this.#lo;for(const t of this.#eo)if(!o||null!==gt.intersect(t.data.rect,o)){o=t.data.rect,r=!0;break}const h=gt.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]);this.#N=[100*(h[0]+(r?o[2]-o[0]+5:0)-s)/i,100*(h[1]-n)/e];const{style:a}=this.#kt;a.left=this.#N[0]+"%",a.top=this.#N[1]+"%"}#Jr(){this.#G?this.#G.toggleCommentPopup(this,!1):(this.#ro=!this.#ro,this.#ro?(this.#Qr(),this.#kt.addEventListener("click",this.#Kr),this.#kt.addEventListener("keydown",this.#Vr)):(this.#Xr(),this.#kt.removeEventListener("click",this.#Kr),this.#kt.removeEventListener("keydown",this.#Vr)))}#Qr(){this.#oo||this.render(),this.isVisible?this.#ro&&this.#kt.classList.add("focused"):(this.#Mo(),this.#kt.hidden=!1,this.#kt.style.zIndex=parseInt(this.#kt.style.zIndex,10)+1e3)}#Xr(){this.#kt.classList.remove("focused"),!this.#ro&&this.isVisible&&(this.#kt.hidden=!0,this.#kt.style.zIndex=parseInt(this.#kt.style.zIndex,10)-1e3)}forceHide(){this.#do=this.isVisible,this.#do&&(this.#kt.hidden=!0)}maybeShow(){this.#G||(this.#go(),this.#do&&(this.#oo||this.#Qr(),this.#do=!1,this.#kt.hidden=!1))}get isVisible(){return!this.#G&&!1===this.#kt.hidden}}class tn extends js{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=H.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const i of this.textContent){const e=document.createElement("span");e.textContent=i,t.append(e)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class en extends js{#So=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:i,height:e}=this,s=this.svgFactory.create(i,e,!0),n=this.#So=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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#So}addHighlightArea(){this.container.classList.add("highlightArea")}}class sn extends js{#Co=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:i,height:e}=this,s=this.svgFactory.create(i,e,!0),n=t.borderStyle.width,r=this.#Co=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",i-n),r.setAttribute("height",e-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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#Co}addHighlightArea(){this.container.classList.add("highlightArea")}}class nn extends js{#Eo=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:i,height:e}=this,s=this.svgFactory.create(i,e,!0),n=t.borderStyle.width,r=this.#Eo=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",i/2),r.setAttribute("cy",e/2),r.setAttribute("rx",i/2-n/2),r.setAttribute("ry",e/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.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#Eo}addHighlightArea(){this.container.classList.add("highlightArea")}}class rn extends js{#ko=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:i,borderStyle:e,popupRef:s},width:n,height:r}=this;if(!i)return this.container;const o=this.svgFactory.create(n,r,!0);let h=[];for(let e=0,s=i.length;e<s;e+=2)h.push(`${i[e]-t[0]},${t[3]-i[e+1]}`);h=h.join(" ");const a=this.#ko=this.svgFactory.createElement(this.svgElementName);return a.setAttribute("points",h),a.setAttribute("stroke-width",e.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),o.append(a),this.container.append(o),!s&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#ko}addHighlightArea(){this.container.classList.add("highlightArea")}}class on extends rn{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class hn extends js{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}class an extends js{#To=null;#Po=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?H.HIGHLIGHT:H.INK}#Do(t,i){switch(t){case 90:return{transform:`rotate(90) translate(${-i[0]},${i[1]}) scale(1,-1)`,width:i[3]-i[1],height:i[2]-i[0]};case 180:return{transform:`rotate(180) translate(${-i[2]},${i[1]}) scale(1,-1)`,width:i[2]-i[0],height:i[3]-i[1]};case 270:return{transform:`rotate(270) translate(${-i[2]},${i[3]}) scale(1,-1)`,width:i[3]-i[1],height:i[2]-i[0]};default:return{transform:`translate(${-i[0]},${i[3]}) scale(1,-1)`,width:i[2]-i[0],height:i[3]-i[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:i,inkLists:e,borderStyle:s,popupRef:n}}=this,{transform:r,width:o,height:h}=this.#Do(i,t),a=this.svgFactory.create(o,h,!0),c=this.#To=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,i=e.length;t<i;t++){const i=this.svgFactory.createElement(this.svgElementName);this.#Po.push(i),i.setAttribute("points",e[t].join(",")),c.append(i)}return!n&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(a),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:i,points:e,rect:s}=t,n=this.#To;if(i>=0&&n.setAttribute("stroke-width",i||1),e)for(let t=0,i=this.#Po.length;t<i;t++)this.#Po[t].setAttribute("points",e[t].join(","));if(s){const{transform:t,width:i,height:e}=this.#Do(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${i} ${e}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#Po}addHighlightArea(){this.container.classList.add("highlightArea")}}class cn extends js{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=H.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:i}}=this;if(!i&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const i=document.createElement("mark");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class ln extends js{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:i}}=this;if(!i&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const i=document.createElement("u");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class un extends js{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:i}}=this;if(!i&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const i=document.createElement("u");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class dn extends js{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:i}}=this;if(!i&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const i=document.createElement("s");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class fn extends js{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=H.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class pn extends js{#Io=null;constructor(t){super(t,{isRenderable:!0});const{file:i}=this.data;this.filename=i.filename,this.content=i.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:i}=this;let e;i.hasAppearance||0===i.fillAlpha?e=document.createElement("div"):(e=document.createElement("img"),e.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(e.style=`filter: opacity(${Math.round(100*i.fillAlpha)}%);`)),e.addEventListener("dblclick",this.#Ro.bind(this)),this.#Io=e;const{isMac:s}=pt.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Ro()})),!i.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):e.classList.add("popupTriggerArea"),t.append(e),t}getElementsToTriggerPopup(){return this.#Io}addHighlightArea(){this.container.classList.add("highlightArea")}#Ro(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class gn{#No=null;#Oo=null;#z=null;#_o=new Map;#Fo=null;#Bo=null;#eo=[];#Lo=!1;zIndex=0;constructor({div:t,accessibilityManager:i,annotationCanvasMap:e,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:o,commentManager:h,linkService:a,annotationStorage:c}){this.div=t,this.#No=i,this.#Oo=e,this.#Fo=o||null,this.#Bo=a||null,this.#z=c||new vi,this.page=n,this.viewport=r,this._annotationEditorUIManager=s,this._commentManager=h||null}hasEditableAnnotations(){return this.#_o.size>0}async render(t){const{annotations:i}=t,e=this.div;zt(e,this.viewport);const s=new Map,n=[],r={data:null,layer:e,linkService:this.#Bo,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Bs,annotationStorage:this.#z,enableComment:!0===t.enableComment,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of i){if(t.noHTML)continue;const i=t.annotationType===V.POPUP;if(i){const i=s.get(t.id);if(!i)continue;if(!this._commentManager){n.push(t);continue}r.elements=i}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;r.data=t;const e=$s.create(r);if(!e.isRenderable)continue;i||(this.#eo.push(e),t.popupRef&&s.getOrInsertComputed(t.popupRef,bt).push(e));const o=e.render();t.hidden&&(o.style.visibility="hidden"),e._isEditable&&(this.#_o.set(e.data.id,e),this._annotationEditorUIManager?.renderAnnotationElement(e))}await this.#Uo();for(const t of n){const i=r.elements=s.get(t.id);r.data=t;const e=$s.create(r);if(!e.isRenderable)continue;const n=e.render();e.contentElement.id=`${vt}${t.id}`,t.hidden&&(n.style.visibility="hidden"),i.at(-1).container.after(n)}this.#$o()}async#Uo(){if(0===this.#eo.length)return;this.div.replaceChildren();const t=[];if(!this.#Lo){this.#Lo=!0;for(const{contentElement:i,data:{id:e}}of this.#eo){const s=i.id=`${vt}${e}`;t.push(this.#Fo?.getAriaAttributes(s).then((t=>{if(t)for(const[e,s]of t)i.setAttribute(e,s)})))}}this.#eo.sort((({data:{rect:[t,i,e,s]}},{data:{rect:[n,r,o,h]}})=>{if(t===e&&i===s)return 1;if(n===o&&r===h)return-1;const a=(i+s)/2,c=(r+h)/2;return a>=h&&c<=i?-1:c>=s&&a<=r?1:(t+e)/2-(n+o)/2}));const i=document.createDocumentFragment();for(const t of this.#eo)i.append(t.container),this._commentManager?(t.extraPopupElement?.popup||t.popup)?.renderCommentButton():t.extraPopupElement&&i.append(t.extraPopupElement.render());if(this.div.append(i),await Promise.all(t),this.#No)for(const t of this.#eo)this.#No.addPointerInTextLayer(t.contentElement,!1)}async addLinkAnnotations(t){const i={data:null,layer:this.div,linkService:this.#Bo,svgFactory:new Bs,parent:this};for(const e of t){e.borderStyle||=gn._defaultBorderStyle,i.data=e;const t=$s.create(i);t.isRenderable&&(t.render(),t.contentElement.id=`${vt}${e.id}`,this.#eo.push(t))}await this.#Uo()}update({viewport:t}){const i=this.div;this.viewport=t,zt(i,{rotation:t.rotation}),this.#$o(),i.hidden=!1}#$o(){if(!this.#Oo)return;const t=this.div;for(const[i,e]of this.#Oo){const s=t.querySelector(`[data-annotation-id="${i}"]`);if(!s)continue;e.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(e):n.classList.contains("annotationContent")?n.after(e):n.before(e):s.append(e);const r=this.#_o.get(i);r&&(r._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(i,s.id,e),r._hasNoCanvas=!1):r.canvas=e)}this.#Oo.clear()}getEditableAnnotations(){return this.#_o.values()}getEditableAnnotation(t){return this.#_o.get(t)}addFakeAnnotation(t){const{div:i}=this,{id:e,rotation:s}=t,n=new zs({data:{id:e,rect:t.getPDFRect(),rotation:s},editor:t,layer:i,parent:this,enableComment:!!this._commentManager,linkService:this.#Bo,annotationStorage:this.#z});return n.render(),n.contentElement.id=`${vt}${e}`,n.createOrUpdatePopup(),this.#eo.push(n),n}removeAnnotation(t){const i=this.#eo.findIndex((i=>i.data.id===t));if(i<0)return;const[e]=this.#eo.splice(i,1);this.#No?.removePointerInTextLayer(e.contentElement)}updateFakeAnnotations(t){if(0!==t.length){for(const i of t)i.updateFakeAnnotationElement(this);this.#Uo()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return rt(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:1,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const mn=/\r\n?|\n/g;class wn extends di{#jo="";#zo=this.id+"-editor";#Ho=null;#bo;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=wn.prototype,i=t=>t.isEmpty(),e=ai.TRANSLATE_SMALL,s=ai.TRANSLATE_BIG;return rt(this,"_keyboardManager",new oi([[["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:[-e,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:i}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[e,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:i}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-e],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:i}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,e],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:i}]]))}static _type="freetext";static _editorType=H.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||wn._defaultColor||di._defaultLineColor,this.#bo=t.fontSize||wn._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static initialize(t,i){di.initialize(t,i);const e=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(e.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,i){switch(t){case W.FREETEXT_SIZE:wn._defaultFontSize=i;break;case W.FREETEXT_COLOR:wn._defaultColor=i}}updateParams(t,i){switch(t){case W.FREETEXT_SIZE:this.#Wo(i);break;case W.FREETEXT_COLOR:this.#wo(i)}}static get defaultPropertiesToUpdate(){return[[W.FREETEXT_SIZE,wn._defaultFontSize],[W.FREETEXT_COLOR,wn._defaultColor||di._defaultLineColor]]}get propertiesToUpdate(){return[[W.FREETEXT_SIZE,this.#bo],[W.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new Rs(this),[["colorPicker",this._colorPicker]]}get colorType(){return W.FREETEXT_COLOR}#Wo(t){const i=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#bo)*this.parentScale),this.#bo=t,this.#Go()},e=this.#bo;this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:W.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#wo(t){const i=t=>{this.color=t,this.onUpdatedColor()},e=this.color;this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:W.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,i){this._uiManager.translateSelectedEditors(t,i,!0)}getInitialTranslation(){const t=this.parentScale;return[-wn._internalPadding*t,-(wn._internalPadding+this.#bo)*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.#Ho=new AbortController;const t=this._uiManager.combinedSignal(this.#Ho);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.#zo),this._isDraggable=!0,this.#Ho?.abort(),this.#Ho=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()}#Vo(){const t=[];this.editorDiv.normalize();let i=null;for(const e of this.editorDiv.childNodes)i?.nodeType===Node.TEXT_NODE&&"BR"===e.nodeName||(t.push(wn.#Yo(e)),i=e);return t.join("\n")}#Go(){const[t,i]=this.parentDimensions;let e;if(this.isAttachedToDOM)e=this.div.getBoundingClientRect();else{const{currentLayer:t,div:i}=this,s=i.style.display,n=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",t.div.append(this.div),e=i.getBoundingClientRect(),i.remove(),i.style.display=s,i.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=e.width/t,this.height=e.height/i):(this.width=e.height/t,this.height=e.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#jo,i=this.#jo=this.#Vo().trimEnd();if(t===i)return;const e=t=>{this.#jo=t,t?(this.#Xo(),this._uiManager.rebuild(this),this.#Go()):this.remove()};this.addCommands({cmd:()=>{e(i)},undo:()=>{e(t)},mustExec:!1}),this.#Go()}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){wn._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,i;(this._isCopy||this.annotationElementId)&&(t=this.x,i=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#zo),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:e}=this.editorDiv;if(e.fontSize=`calc(${this.#bo}px * var(--total-scale-factor))`,e.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[e,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=i+this.height-(n[1]-l)/a;break;case 90:u=t+(n[0]-c)/h,d=i-(n[1]-l)/a,[r,o]=[o,-r];break;case 180:u=t-this.width+(n[0]-c)/h,d=i-(n[1]-l)/a,[r,o]=[-r,-o];break;case 270:u=t+(n[0]-c-this.height*a)/h,d=i+(n[1]-l-this.width*h)/a,[r,o]=[-o,r]}this.setAt(u*e,d*s,r,o)}else this._moveAfterPaste(t,i);this.#Xo(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Yo(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(mn,"")}editorDivPaste(t){const i=t.clipboardData||window.clipboardData,{types:e}=i;if(1===e.length&&"text/plain"===e[0])return;t.preventDefault();const s=wn.#qo(i.getData("text")||"").replaceAll(mn,"\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(mn,"")),t!==this.editorDiv){let i=a;for(const e of this.editorDiv.childNodes)e!==t?i.push(wn.#Yo(e)):i=c}a.push(o.nodeValue.slice(0,h).replaceAll(mn,""))}else if(o===this.editorDiv){let t=a,i=0;for(const e of this.editorDiv.childNodes)i++===h&&(t=c),t.push(wn.#Yo(e))}this.#jo=`${a.join("\n")}${s}${c.join("\n")}`,this.#Xo();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 i=t.nodeValue.length;if(u<=i){l.setStart(t,u),l.setEnd(t,u);break}u-=i}n.removeAllRanges(),n.addRange(l)}#Xo(){if(this.editorDiv.replaceChildren(),this.#jo)for(const t of this.#jo.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(i)}}#Qo(){return this.#jo.replaceAll(" "," ")}static#qo(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=wn._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,i,e){let s=null;if(t instanceof tn){const{data:{defaultAppearanceData:{fontSize:i,fontColor:e},rect:n,rotation:r,id:o,popupRef:h,richText:a,contentsObj:c,creationDate:l,modificationDate:u},textContent:d,textPosition:f,parent:{page:{pageNumber:p}}}=t;if(!d||0===d.length)return null;s=t={annotationType:H.FREETEXT,color:Array.from(e),fontSize:i,value:d.join("\n"),position:f,pageIndex:p-1,rect:n.slice(0),rotation:r,annotationElementId:o,id:o,deleted:!1,popupRef:h,comment:c?.str||null,richText:a,creationDate:l,modificationDate:u}}const n=await super.deserialize(t,i,e);return n.#bo=t.fontSize,n.color=gt.makeHexColor(...t.color),n.#jo=wn.#qo(t.value),n._initialData=s,t.comment&&n.setCommentData(t),n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=di._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),e=Object.assign(super.serialize(t),{color:i,fontSize:this.#bo,value:this.#Qo()});return this.addComment(e),t?(e.isCopy=!0,e):this.annotationElementId&&!this.#Ko(e)?null:(e.id=this.annotationElementId,e)}#Ko(t){const{value:i,fontSize:e,color:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==i||t.fontSize!==e||t.color.some(((t,i)=>t!==s[i]))||t.pageIndex!==n}renderAnnotationElement(t){const i=super.renderAnnotationElement(t);if(!i)return null;const{style:e}=i;e.fontSize=`calc(${this.#bo}px * var(--total-scale-factor))`,e.color=this.color,i.replaceChildren();for(const t of this.#jo.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),i.append(e)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#jo}}),i}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class An{static PRECISION=1e-4;toSVGPath(){tt("Abstract method `toSVGPath` must be implemented.")}get box(){tt("Abstract getter `box` must be implemented.")}serialize(t,i){tt("Abstract method `serialize` must be implemented.")}static _rescale(t,i,e,s,n,r){r||=new Float32Array(t.length);for(let o=0,h=t.length;o<h;o+=2)r[o]=i+t[o]*s,r[o+1]=e+t[o+1]*n;return r}static _rescaleAndSwap(t,i,e,s,n,r){r||=new Float32Array(t.length);for(let o=0,h=t.length;o<h;o+=2)r[o]=i+t[o+1]*s,r[o+1]=e+t[o]*n;return r}static _translate(t,i,e,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=i+t[n],s[n+1]=e+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,i,e,s,n){switch(n){case 90:return[1-i/e,t/s];case 180:return[1-t/e,1-i/s];case 270:return[i/e,1-t/s];default:return[t/e,i/s]}}static _normalizePagePoint(t,i,e){switch(e){case 90:return[1-i,t];case 180:return[1-t,1-i];case 270:return[i,1-t];default:return[t,i]}}static createBezierPoints(t,i,e,s,n,r){return[(t+5*e)/6,(i+5*s)/6,(5*e+n)/6,(5*s+r)/6,(e+n)/2,(s+r)/2]}}class vn{#Jo;#Zo=[];#th;#ih;#eh=[];#sh=new Float32Array(18);#nh;#rh;#oh;#hh;#ah;#ch;#lh=[];static#uh=8;static#dh=2;static#fh=vn.#uh+vn.#dh;constructor({x:t,y:i},e,s,n,r,o=0){this.#Jo=e,this.#ch=n*s,this.#ih=r,this.#sh.set([NaN,NaN,NaN,NaN,t,i],6),this.#th=o,this.#hh=vn.#uh*s,this.#oh=vn.#fh*s,this.#ah=s,this.#lh.push(t,i)}isEmpty(){return isNaN(this.#sh[8])}#ph(){const t=this.#sh.subarray(4,6),i=this.#sh.subarray(16,18),[e,s,n,r]=this.#Jo;return[(this.#nh+(t[0]-i[0])/2-e)/n,(this.#rh+(t[1]-i[1])/2-s)/r,(this.#nh+(i[0]-t[0])/2-e)/n,(this.#rh+(i[1]-t[1])/2-s)/r]}add({x:t,y:i}){this.#nh=t,this.#rh=i;const[e,s,n,r]=this.#Jo;let[o,h,a,c]=this.#sh.subarray(8,12);const l=t-a,u=i-c,d=Math.hypot(l,u);if(d<this.#oh)return!1;const f=d-this.#hh,p=f/d,g=p*l,m=p*u;let w=o,A=h;o=a,h=c,a+=g,c+=m,this.#lh?.push(t,i);const v=-m/f*this.#ch,b=g/f*this.#ch;return this.#sh.set(this.#sh.subarray(2,8),0),this.#sh.set([a+v,c+b],4),this.#sh.set(this.#sh.subarray(14,18),12),this.#sh.set([a-v,c-b],16),isNaN(this.#sh[6])?(0===this.#eh.length&&(this.#sh.set([o+v,h+b],2),this.#eh.push(NaN,NaN,NaN,NaN,(o+v-e)/n,(h+b-s)/r),this.#sh.set([o-v,h-b],14),this.#Zo.push(NaN,NaN,NaN,NaN,(o-v-e)/n,(h-b-s)/r)),this.#sh.set([w,A,o,h,a,c],6),!this.isEmpty()):(this.#sh.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.#sh.subarray(2,6),this.#eh.push(NaN,NaN,NaN,NaN,((o+a)/2-e)/n,((h+c)/2-s)/r),[o,h,w,A]=this.#sh.subarray(14,18),this.#Zo.push(NaN,NaN,NaN,NaN,((w+o)/2-e)/n,((A+h)/2-s)/r),!0):([w,A,o,h,a,c]=this.#sh.subarray(0,6),this.#eh.push(((w+5*o)/6-e)/n,((A+5*h)/6-s)/r,((5*o+a)/6-e)/n,((5*h+c)/6-s)/r,((o+a)/2-e)/n,((h+c)/2-s)/r),[a,c,o,h,w,A]=this.#sh.subarray(12,18),this.#Zo.push(((w+5*o)/6-e)/n,((A+5*h)/6-s)/r,((5*o+a)/6-e)/n,((5*h+c)/6-s)/r,((o+a)/2-e)/n,((h+c)/2-s)/r),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#eh,i=this.#Zo;if(isNaN(this.#sh[6])&&!this.isEmpty())return this.#gh();const e=[];e.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)e.push(isNaN(t[i])?`L${t[i+4]} ${t[i+5]}`:`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#mh(e);for(let t=i.length-6;t>=6;t-=6)e.push(isNaN(i[t])?`L${i[t+4]} ${i[t+5]}`:`C${i[t]} ${i[t+1]} ${i[t+2]} ${i[t+3]} ${i[t+4]} ${i[t+5]}`);return this.#wh(e),e.join(" ")}#gh(){const[t,i,e,s]=this.#Jo,[n,r,o,h]=this.#ph();return`M${(this.#sh[2]-t)/e} ${(this.#sh[3]-i)/s} L${(this.#sh[4]-t)/e} ${(this.#sh[5]-i)/s} L${n} ${r} L${o} ${h} L${(this.#sh[16]-t)/e} ${(this.#sh[17]-i)/s} L${(this.#sh[14]-t)/e} ${(this.#sh[15]-i)/s} Z`}#wh(t){const i=this.#Zo;t.push(`L${i[4]} ${i[5]} Z`)}#mh(t){const[i,e,s,n]=this.#Jo,r=this.#sh.subarray(4,6),o=this.#sh.subarray(16,18),[h,a,c,l]=this.#ph();t.push(`L${(r[0]-i)/s} ${(r[1]-e)/n} L${h} ${a} L${c} ${l} L${(o[0]-i)/s} ${(o[1]-e)/n}`)}newFreeDrawOutline(t,i,e,s,n,r){return new bn(t,i,e,s,n,r)}getOutlines(){const t=this.#eh,i=this.#Zo,e=this.#sh,[s,n,r,o]=this.#Jo,h=new Float32Array((this.#lh?.length??0)+2);for(let t=0,i=h.length-2;t<i;t+=2)h[t]=(this.#lh[t]-s)/r,h[t+1]=(this.#lh[t+1]-n)/o;if(h[h.length-2]=(this.#nh-s)/r,h[h.length-1]=(this.#rh-n)/o,isNaN(e[6])&&!this.isEmpty())return this.#Ah(h);const a=new Float32Array(this.#eh.length+24+this.#Zo.length);let c=t.length;for(let i=0;i<c;i+=2)isNaN(t[i])?a[i]=a[i+1]=NaN:(a[i]=t[i],a[i+1]=t[i+1]);c=this.#vh(a,c);for(let t=i.length-6;t>=6;t-=6)for(let e=0;e<6;e+=2)isNaN(i[t+e])?(a[c]=a[c+1]=NaN,c+=2):(a[c]=i[t+e],a[c+1]=i[t+e+1],c+=2);return this.#bh(a,c),this.newFreeDrawOutline(a,h,this.#Jo,this.#ah,this.#th,this.#ih)}#Ah(t){const i=this.#sh,[e,s,n,r]=this.#Jo,[o,h,a,c]=this.#ph(),l=new Float32Array(36);return l.set([NaN,NaN,NaN,NaN,(i[2]-e)/n,(i[3]-s)/r,NaN,NaN,NaN,NaN,(i[4]-e)/n,(i[5]-s)/r,NaN,NaN,NaN,NaN,o,h,NaN,NaN,NaN,NaN,a,c,NaN,NaN,NaN,NaN,(i[16]-e)/n,(i[17]-s)/r,NaN,NaN,NaN,NaN,(i[14]-e)/n,(i[15]-s)/r],0),this.newFreeDrawOutline(l,t,this.#Jo,this.#ah,this.#th,this.#ih)}#bh(t,i){const e=this.#Zo;return t.set([NaN,NaN,NaN,NaN,e[4],e[5]],i),i+6}#vh(t,i){const e=this.#sh.subarray(4,6),s=this.#sh.subarray(16,18),[n,r,o,h]=this.#Jo,[a,c,l,u]=this.#ph();return t.set([NaN,NaN,NaN,NaN,(e[0]-n)/o,(e[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],i),i+24}}class bn extends An{#Jo;#yh=new Float32Array(4);#th;#ih;#lh;#ah;#xh;constructor(t,i,e,s,n,r){super(),this.#xh=t,this.#lh=i,this.#Jo=e,this.#ah=s,this.#th=n,this.#ih=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#Mh(r);const[o,h,a,c]=this.#yh;for(let i=0,e=t.length;i<e;i+=2)t[i]=(t[i]-o)/a,t[i+1]=(t[i+1]-h)/c;for(let t=0,e=i.length;t<e;t+=2)i[t]=(i[t]-o)/a,i[t+1]=(i[t+1]-h)/c}toSVGPath(){const t=[`M${this.#xh[4]} ${this.#xh[5]}`];for(let i=6,e=this.#xh.length;i<e;i+=6)isNaN(this.#xh[i])?t.push(`L${this.#xh[i+4]} ${this.#xh[i+5]}`):t.push(`C${this.#xh[i]} ${this.#xh[i+1]} ${this.#xh[i+2]} ${this.#xh[i+3]} ${this.#xh[i+4]} ${this.#xh[i+5]}`);return t.push("Z"),t.join(" ")}serialize([t,i,e,s],n){const r=e-t,o=s-i;let h,a;switch(n){case 0:h=An._rescale(this.#xh,t,s,r,-o),a=An._rescale(this.#lh,t,s,r,-o);break;case 90:h=An._rescaleAndSwap(this.#xh,t,i,r,o),a=An._rescaleAndSwap(this.#lh,t,i,r,o);break;case 180:h=An._rescale(this.#xh,e,i,-r,o),a=An._rescale(this.#lh,e,i,-r,o);break;case 270:h=An._rescaleAndSwap(this.#xh,e,s,-r,-o),a=An._rescaleAndSwap(this.#lh,e,s,-r,-o)}return{outline:Array.from(h),points:[Array.from(a)]}}#Mh(t){const i=this.#xh;let e=i[4],s=i[5];const n=[e,s,e,s];let r=e,o=s,h=e,a=s;const c=t?Math.max:Math.min,l=new Float32Array(4);for(let t=6,u=i.length;t<u;t+=6){const u=i[t+4],d=i[t+5];isNaN(i[t])?(gt.pointBoundingBox(u,d,n),o>d?(r=u,o=d):o===d&&(r=c(r,u)),a<d?(h=u,a=d):a===d&&(h=c(h,u))):(l.set(B,0),gt.bezierBoundingBox(e,s,...i.slice(t,t+6),l),gt.rectBoundingBox(...l,n),o>l[1]?(r=l[0],o=l[1]):o===l[1]&&(r=c(r,l[0])),a<l[3]?(h=l[2],a=l[3]):a===l[3]&&(h=c(h,l[2]))),e=u,s=d}const u=this.#yh;u[0]=n[0]-this.#th,u[1]=n[1]-this.#th,u[2]=n[2]-n[0]+2*this.#th,u[3]=n[3]-n[1]+2*this.#th,this.firstPoint=[r,o],this.lastPoint=[h,a]}get box(){return this.#yh}newOutliner(t,i,e,s,n,r=0){return new vn(t,i,e,s,n,r)}getNewOutline(t,i){const[e,s,n,r]=this.#yh,[o,h,a,c]=this.#Jo,l=n*a,u=r*c,d=e*a+o,f=s*c+h,p=this.newOutliner({x:this.#lh[0]*l+d,y:this.#lh[1]*u+f},this.#Jo,this.#ah,t,this.#ih,i??this.#th);for(let t=2;t<this.#lh.length;t+=2)p.add({x:this.#lh[t]*l+d,y:this.#lh[t+1]*u+f});return p.getOutlines()}}class yn{#Jo;#Sh;#Ch;#Eh=[];#kh=[];constructor(t,i=0,e=0,s=!0){const n=B.slice(),r=10**-4;for(const{x:e,y:s,width:o,height:h}of t){const t=Math.floor((e-i)/r)*r,a=Math.ceil((e+o+i)/r)*r,c=Math.floor((s-i)/r)*r,l=Math.ceil((s+h+i)/r)*r;this.#Eh.push([t,c,l,!0],[a,c,l,!1]),gt.rectBoundingBox(t,c,a,l,n)}const o=n[2]-n[0]+2*e,h=n[3]-n[1]+2*e,a=n[0]-e,c=n[1]-e;let l=s?-1/0:1/0,u=1/0;const d=this.#Eh.at(s?-1:-2),f=[d[0],d[2]];for(const t of this.#Eh){const[i,e,n,r]=t;!r&&s?e<u?(u=e,l=i):e===u&&(l=Math.max(l,i)):r&&!s&&(e<u?(u=e,l=i):e===u&&(l=Math.min(l,i))),t[0]=(i-a)/o,t[1]=(e-c)/h,t[2]=(n-c)/h}this.#Jo=new Float32Array([a,c,o,h]),this.#Sh=[l,u],this.#Ch=f}getOutlines(){this.#Eh.sort(((t,i)=>t[0]-i[0]||t[1]-i[1]||t[2]-i[2]));const t=[];for(const i of this.#Eh)i[3]?(t.push(...this.#Th(i)),this.#Ph(i)):(this.#Dh(i),t.push(...this.#Th(i)));return this.#Ih(t)}#Ih(t){const i=[],e=new Set;for(const e of t){const[t,s,n]=e;i.push([t,s,e],[t,n,e])}i.sort(((t,i)=>t[1]-i[1]||t[0]-i[0]));for(let t=0,s=i.length;t<s;t+=2){const s=i[t][2],n=i[t+1][2];s.push(n),n.push(s),e.add(s),e.add(n)}const s=[];let n;for(;e.size>0;){const t=e.values().next().value;let[i,r,o,h,a]=t;e.delete(t);let c=i,l=r;for(n=[i,o],s.push(n);;){let t;if(e.has(h))t=h;else{if(!e.has(a))break;t=a}e.delete(t),[i,r,o,h,a]=t,c!==i&&(n.push(c,l,i,l===r?r:o),c=i),l=l===r?o:r}n.push(c,l)}return new xn(s,this.#Jo,this.#Sh,this.#Ch)}#Rh(t){const i=this.#kh;let e=0,s=i.length-1;for(;e<=s;){const n=e+s>>1,r=i[n][0];if(r===t)return n;r<t?e=n+1:s=n-1}return s+1}#Ph([,t,i]){const e=this.#Rh(t);this.#kh.splice(e,0,[t,i])}#Dh([,t,i]){const e=this.#Rh(t);for(let s=e;s<this.#kh.length;s++){const[e,n]=this.#kh[s];if(e!==t)break;if(e===t&&n===i)return void this.#kh.splice(s,1)}for(let s=e-1;s>=0;s--){const[e,n]=this.#kh[s];if(e!==t)break;if(e===t&&n===i)return void this.#kh.splice(s,1)}}#Th(t){const[i,e,s]=t,n=[[i,e,s]],r=this.#Rh(s);for(let t=0;t<r;t++){const[e,s]=this.#kh[t];for(let t=0,r=n.length;t<r;t++){const[,o,h]=n[t];if(!(s<=o||h<=e))if(o>=e)if(h>s)n[t][1]=s;else{if(1===r)return[];n.splice(t,1),t--,r--}else n[t][2]=e,h>s&&n.push([i,s,h])}}return n}}class xn extends An{#Jo;#Nh;constructor(t,i,e,s){super(),this.#Nh=t,this.#Jo=i,this.firstPoint=e,this.lastPoint=s}toSVGPath(){const t=[];for(const i of this.#Nh){let[e,s]=i;t.push(`M${e} ${s}`);for(let n=2;n<i.length;n+=2){const r=i[n],o=i[n+1];r===e?(t.push("V"+o),s=o):o===s&&(t.push("H"+r),e=r)}t.push("Z")}return t.join(" ")}serialize([t,i,e,s],n){const r=[],o=e-t,h=s-i;for(const i of this.#Nh){const e=Array(i.length);for(let n=0;n<i.length;n+=2)e[n]=t+i[n]*o,e[n+1]=s-i[n+1]*h;r.push(e)}return r}get box(){return this.#Jo}get classNamesForOutlining(){return["highlightOutline"]}}class Mn extends vn{newFreeDrawOutline(t,i,e,s,n,r){return new Sn(t,i,e,s,n,r)}}class Sn extends bn{newOutliner(t,i,e,s,n,r=0){return new Mn(t,i,e,s,n,r)}}class Cn extends di{#Oh=null;#_h=0;#Fh;#Bh=null;#r=null;#Lh=null;#Uh=null;#$h=0;#jh=null;#zh=null;#E=null;#Hh=!1;#Sh=null;#Ch=null;#Wh=null;#wi="";#ch;#Gh="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=H.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Cn.prototype;return rt(this,"_keyboardManager",new oi([[["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||Cn._defaultColor,this.#ch=t.thickness||Cn._defaultThickness,this.opacity=t.opacity||Cn._defaultOpacity,this.#Fh=t.boxes||null,this.#Gh=t.methodOfCreation||"",this.#wi=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#Hh=!0,this.#Vh(t),this.#Yh()):this.#Fh&&(this.#Oh=t.anchorNode,this.#_h=t.anchorOffset,this.#Uh=t.focusNode,this.#$h=t.focusOffset,this.#Xh(),this.#Yh(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#Hh?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#ch,methodOfCreation:this.#Gh}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#Xh(){const t=new yn(this.#Fh,.001);this.#zh=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#zh.box;const i=new yn(this.#Fh,.0025,.001,"ltr"===this._uiManager.direction);this.#Lh=i.getOutlines();const{firstPoint:e}=this.#zh;this.#Sh=[(e[0]-this.x)/this.width,(e[1]-this.y)/this.height];const{lastPoint:s}=this.#Lh;this.#Ch=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#Vh({highlightOutlines:t,highlightId:i,clipPathId:e}){if(this.#zh=t,this.#Lh=t.getNewOutline(this.#ch/2+1.5,.0025),i>=0)this.#E=i,this.#Bh=e,this.parent.drawLayer.finalizeDraw(i,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Wh=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Lh.box,path:{d:this.#Lh.toSVGPath()}},!0);else if(this.parent){const i=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#E,{bbox:Cn.#qh(this.#zh.box,(i-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Wh,{bbox:Cn.#qh(this.#Lh.box,i),path:{d:this.#Lh.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,i]=this.parentDimensions;this.x=n,this.y=1-s,this.width=r*i/t,this.height=o*t/i;break}case 180:this.x=1-s,this.y=1-n,this.width=r,this.height=o;break;case 270:{const[t,i]=this.parentDimensions;this.x=1-n,this.y=s,this.width=r*i/t,this.height=o*t/i;break}}const{firstPoint:h}=t;this.#Sh=[(h[0]-s)/r,(h[1]-n)/o];const{lastPoint:a}=this.#Lh;this.#Ch=[(a[0]-s)/r,(a[1]-n)/o]}static initialize(t,i){di.initialize(t,i),Cn._defaultColor||=i.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,i){switch(t){case W.HIGHLIGHT_COLOR:Cn._defaultColor=i;break;case W.HIGHLIGHT_THICKNESS:Cn._defaultThickness=i}}translateInPage(t,i){}get toolbarPosition(){return this.#Ch}get commentButtonPosition(){return this.#Sh}updateParams(t,i){switch(t){case W.HIGHLIGHT_COLOR:this.#wo(i);break;case W.HIGHLIGHT_THICKNESS:this.#Qh(i)}}static get defaultPropertiesToUpdate(){return[[W.HIGHLIGHT_COLOR,Cn._defaultColor],[W.HIGHLIGHT_THICKNESS,Cn._defaultThickness]]}get propertiesToUpdate(){return[[W.HIGHLIGHT_COLOR,this.color||Cn._defaultColor],[W.HIGHLIGHT_THICKNESS,this.#ch||Cn._defaultThickness],[W.HIGHLIGHT_FREE,this.#Hh]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#E,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#r?.updateColor(this.color),super.onUpdatedColor()}#wo(t){const i=(t,i)=>{this.color=t,this.opacity=i,this.onUpdatedColor()},e=this.color,s=this.opacity;this.addCommands({cmd:i.bind(this,t,Cn._defaultOpacity),undo:i.bind(this,e,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:W.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#Qh(t){const i=this.#ch,e=t=>{this.#ch=t,this.#Kh(t)};this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:W.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#r=new Is({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#Jh())}getBaseTranslation(){return[0,0]}getRect(t,i){return super.getRect(t,i,this.#Jh())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#Zh(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Yh(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let i=!1;this.parent&&!t?this.#Zh():t&&(this.#Yh(t),i=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),i&&this.select()}#Kh(t){this.#Hh&&(this.#Vh({highlightOutlines:this.#zh.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#Zh(){null!==this.#E&&this.parent&&(this.parent.drawLayer.remove(this.#E),this.#E=null,this.parent.drawLayer.remove(this.#Wh),this.#Wh=null)}#Yh(t=this.parent){null===this.#E&&(({id:this.#E,clipPathId:this.#Bh}=t.drawLayer.draw({bbox:this.#zh.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#Hh},path:{d:this.#zh.toSVGPath()}},!1,!0)),this.#Wh=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Hh},bbox:this.#Lh.box,path:{d:this.#Lh.toSVGPath()}},this.#Hh),this.#jh&&(this.#jh.style.clipPath=this.#Bh))}static#qh([t,i,e,s],n){switch(n){case 90:return[1-i-s,t,s,e];case 180:return[1-t-e,1-i-s,e,s];case 270:return[i,1-t-e,s,e]}return[t,i,e,s]}rotate(t){const{drawLayer:i}=this.parent;let e;e=this.#Hh?Cn.#qh(this.#zh.box,t=(t-this.rotation+360)%360):Cn.#qh([this.x,this.y,this.width,this.height],t),i.updateProperties(this.#E,{bbox:e,root:{"data-main-rotation":t}}),i.updateProperties(this.#Wh,{bbox:Cn.#qh(this.#Lh.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#wi&&(t.setAttribute("aria-label",this.#wi),t.setAttribute("role","mark")),this.#Hh?t.classList.add("free"):this.div.addEventListener("keydown",this.#ta.bind(this),{signal:this._uiManager._signal});const i=this.#jh=document.createElement("div");return t.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",i.style.clipPath=this.#Bh,this.setDims(),ii(this,this.#jh,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Wh,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Wh,{rootClass:{hovered:!1}})}#ta(t){Cn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#ia(!0);break;case 1:case 3:this.#ia(!1)}}#ia(t){if(!this.#Oh)return;const i=window.getSelection();t?i.setPosition(this.#Oh,this.#_h):i.setPosition(this.#Uh,this.#$h)}select(){super.select(),this.#Wh&&this.parent?.drawLayer.updateProperties(this.#Wh,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Wh&&(this.parent?.drawLayer.updateProperties(this.#Wh,{rootClass:{selected:!1}}),this.#Hh||this.#ia(!1))}get _mustFixPosition(){return!this.#Hh}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#E,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Wh,{rootClass:{hidden:!t}}))}#Jh(){return this.#Hh?this.rotation:0}#ea(){if(this.#Hh)return null;const[t,i]=this.pageDimensions,[e,s]=this.pageTranslation,n=this.#Fh,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+e,u=(1-a)*i+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*i,o+=8}return r}#sa(t){return this.#zh.serialize(t,this.#Jh())}static startHighlighting(t,i,{target:e,x:s,y:n}){const{x:r,y:o,width:h,height:a}=e.getBoundingClientRect(),c=new AbortController,l=t.combinedSignal(c),u=i=>{c.abort(),this.#na(t,i)};window.addEventListener("blur",u,{signal:l}),window.addEventListener("pointerup",u,{signal:l}),window.addEventListener("pointerdown",Ft,{capture:!0,passive:!1,signal:l}),window.addEventListener("contextmenu",_t,{signal:l}),e.addEventListener("pointermove",this.#ra.bind(this,t),{signal:l}),this._freeHighlight=new Mn({x:s,y:n},[r,o,h,a],t.scale,this._defaultThickness/2,i,.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#ra(t,i){this._freeHighlight.add(i)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#na(t,i){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(i,!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,i,e){let s=null;if(t instanceof cn){const{data:{quadPoints:i,rect:e,rotation:n,id:r,color:o,opacity:h,popupRef:a,richText:c,contentsObj:l,creationDate:u,modificationDate:d},parent:{page:{pageNumber:f}}}=t;s=t={annotationType:H.HIGHLIGHT,color:Array.from(o),opacity:h,quadPoints:i,boxes:null,pageIndex:f-1,rect:e.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:a,richText:c,comment:l?.str||null,creationDate:u,modificationDate:d}}else if(t instanceof an){const{data:{inkLists:i,rect:e,rotation:n,id:r,color:o,borderStyle:{rawWidth:h},popupRef:a,richText:c,contentsObj:l,creationDate:u,modificationDate:d},parent:{page:{pageNumber:f}}}=t;s=t={annotationType:H.HIGHLIGHT,color:Array.from(o),thickness:h,inkLists:i,boxes:null,pageIndex:f-1,rect:e.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:a,richText:c,comment:l?.str||null,creationDate:u,modificationDate:d}}const{color:n,quadPoints:r,inkLists:o,outlines:h,opacity:a}=t,c=await super.deserialize(t,i,e);c.color=gt.makeHexColor(...n),c.opacity=a||1,o&&(c.#ch=t.thickness),c._initialData=s,t.comment&&c.setCommentData(t);const[l,u]=c.pageDimensions,[d,f]=c.pageTranslation;if(r){const t=c.#Fh=[];for(let i=0;i<r.length;i+=8)t.push({x:(r[i]-d)/l,y:1-(r[i+1]-f)/u,width:(r[i+2]-r[i])/l,height:(r[i+1]-r[i+5])/u});c.#Xh(),c.#Yh(),c.rotate(c.rotation)}else if(o||h){c.#Hh=!0;const t=(o||h.points)[0],e={x:t[0]-d,y:u-(t[1]-f)},s=new Mn(e,[0,0,l,u],1,c.#ch/2,!0,.001);for(let i=0,n=t.length;i<n;i+=2)e.x=t[i]-d,e.y=u-(t[i+1]-f),s.add(e);const{id:n,clipPathId:r}=i.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:c.color,"fill-opacity":c._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);c.#Vh({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),c.#Yh(),c.rotate(c.parentRotation)}return c}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const i=di._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),e=super.serialize(t);return Object.assign(e,{color:i,opacity:this.opacity,thickness:this.#ch,quadPoints:this.#ea(),outlines:this.#sa(e.rect)}),this.addComment(e),this.annotationElementId&&!this.#Ko(e)?null:(e.id=this.annotationElementId,e)}#Ko(t){const{color:i}=this._initialData;return this.hasEditedComment||t.color.some(((t,e)=>t!==i[e]))}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}}class En{#oa=Object.create(null);updateProperty(t,i){this[t]=i,this.updateSVGProperty(t,i)}updateProperties(t){if(t)for(const[i,e]of Object.entries(t))i.startsWith("_")||this.updateProperty(i,e)}updateSVGProperty(t,i){this.#oa[t]=i}toSVGProperties(){const t=this.#oa;return this.#oa=Object.create(null),{root:t}}reset(){this.#oa=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){tt("Not implemented")}}class kn extends di{#ha=null;#aa;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#ca=null;static#la=null;static#ua=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#aa=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){t.drawOutlines&&(this.#da(t),this.#Yh())}#da({drawOutlines:t,drawId:i,drawingOptions:e}){this.#ha=t,this._drawingOptions||=e,this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),i>=0?(this._drawId=i,this.parent.drawLayer.finalizeDraw(i,t.defaultProperties)):this._drawId=this.#fa(t,this.parent),this.#pa(t.box)}#fa(t,i){const{id:e}=i.drawLayer.draw(kn._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return e}static _mergeSVGProperties(t,i){const e=new Set(Object.keys(t));for(const[s,n]of Object.entries(i))e.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){tt("Not implemented")}static get typesMap(){tt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,i){const e=this.typesMap.get(t);e&&this._defaultDrawingOptions.updateProperty(e,i),this._currentParent&&(kn.#ca.updateProperty(e,i),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,i){const e=this.constructor.typesMap.get(t);e&&this._updateProperty(t,e,i)}static get defaultPropertiesToUpdate(){const t=[],i=this._defaultDrawingOptions;for(const[e,s]of this.typesMap)t.push([e,i[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:i}=this;for(const[e,s]of this.constructor.typesMap)t.push([e,i[s]]);return t}_updateProperty(t,i,e){const s=this._drawingOptions,n=s[i],r=e=>{s.updateProperty(i,e);const n=this.#ha.updateProperty(i,e);n&&this.#pa(n),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:r.bind(this,e),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,i){const e=this.constructor.typesMap.get(this.colorType),s=this.constructor.typesMap.get(this.opacityType),n=this._drawingOptions,r=n[e],o=n[s],h=(t,i)=>{n.updateProperty(e,t),n.updateProperty(s,i),this.#ha.updateProperty(e,t),this.#ha.updateProperty(s,i),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:h.bind(this,t,i),undo:h.bind(this,r,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:W.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,kn._mergeSVGProperties(this.#ha.getPathResizingSVGProperties(this.#ga()),{bbox:this.#ma()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,kn._mergeSVGProperties(this.#ha.getPathResizedSVGProperties(this.#ga()),{bbox:this.#ma()}))}_onTranslating(t,i){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#ma()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,kn._mergeSVGProperties(this.#ha.getPathTranslatedSVGProperties(this.#ga(),this.parentDimensions),{bbox:this.#ma()}))}_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.#aa&&(this.#aa=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#Zh(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Yh(),this.#pa(this.#ha.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let i=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#Zh()):t&&(this._uiManager.addShouldRescale(this),this.#Yh(t),i=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),i&&this.select()}#Zh(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#Yh(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#fa(this.#ha,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#wa([t,i,e,s]){const{parentDimensions:[n,r],rotation:o}=this;switch(o){case 90:return[i,1-t,e*(r/n),s*(n/r)];case 180:return[1-t,1-i,e,s];case 270:return[1-i,t,e*(r/n),s*(n/r)];default:return[t,i,e,s]}}#ga(){const{x:t,y:i,width:e,height:s,parentDimensions:[n,r],rotation:o}=this;switch(o){case 90:return[1-i,t,e*(n/r),s*(r/n)];case 180:return[1-t,1-i,e,s];case 270:return[i,1-t,e*(n/r),s*(r/n)];default:return[t,i,e,s]}}#pa(t){[this.x,this.y,this.width,this.height]=this.#wa(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#ma(){const{x:t,y:i,width:e,height:s,rotation:n,parentRotation:r,parentDimensions:[o,h]}=this;switch((4*n+r)/90){case 1:return[1-i-s,t,s,e];case 2:return[1-t-e,1-i-s,e,s];case 3:return[i,1-t-e,s,e];case 4:return[t,i-e*(o/h),s*(h/o),e*(o/h)];case 5:return[1-i,t,e*(o/h),s*(h/o)];case 6:return[1-t-s*(h/o),1-i,s*(h/o),e*(o/h)];case 7:return[i-e*(o/h),1-t-s*(h/o),e*(o/h),s*(h/o)];case 8:return[t-e,i-s,e,s];case 9:return[1-i,t-e,s,e];case 10:return[1-t,1-i,e,s];case 11:return[i-s,1-t,s,e];case 12:return[t-s*(h/o),i,s*(h/o),e*(o/h)];case 13:return[1-i-e*(o/h),t-s*(h/o),e*(o/h),s*(h/o)];case 14:return[1-t,1-i-e*(o/h),s*(h/o),e*(o/h)];case 15:return[i,1-t,e*(o/h),s*(h/o)];default:return[t,i,e,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,kn._mergeSVGProperties({bbox:this.#ma()},this.#ha.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#pa(this.#ha.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,i;this._isCopy&&(t=this.x,i=this.y);const e=super.render();e.classList.add("draw");const s=document.createElement("div");return e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,i),e}static createDrawerInstance(t,i,e,s,n){tt("Not implemented")}static startDrawing(t,i,e,s){const{target:n,offsetX:r,offsetY:o,pointerId:h,pointerType:a}=s;if(ei.isInitializedAndDifferentPointerType(a))return;const{viewport:{rotation:c}}=t,{width:l,height:u}=n.getBoundingClientRect(),d=kn.#la=new AbortController,f=t.combinedSignal(d);ei.setPointer(a,h),window.addEventListener("pointerup",(t=>{ei.isSamePointerIdOrRemove(t.pointerId)&&this._endDraw(t)}),{signal:f}),window.addEventListener("pointercancel",(t=>{ei.isSamePointerIdOrRemove(t.pointerId)&&this._currentParent.endDrawingSession()}),{signal:f}),window.addEventListener("pointerdown",(t=>{ei.isSamePointerType(t.pointerType)&&(ei.initializeAndAddPointerId(t.pointerId),kn.#ca.isCancellable()&&(kn.#ca.removeLastElement(),kn.#ca.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",_t,{signal:f}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:f}),n.addEventListener("touchmove",(t=>{ei.isSameTimeStamp(t.timeStamp)&&Ft(t)}),{signal:f}),t.toggleDrawing(),i._editorUndoBar?.hide(),kn.#ca?t.drawLayer.updateProperties(this._currentDrawId,kn.#ca.startNew(r,o,l,u,c)):(i.updateUIForDefaultProperties(this),kn.#ca=this.createDrawerInstance(r,o,l,u,c),kn.#ua=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(kn.#ua.toSVGProperties(),kn.#ca.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(!kn.#ca)return;const{offsetX:i,offsetY:e,pointerId:s}=t;ei.isSamePointerId(s)&&(ei.isUsingMultiplePointers()?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,kn.#ca.add(i,e)),ei.setTimeStamp(t.timeStamp),Ft(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,kn.#ca=null,kn.#ua=null,ei.clearTimeStamp()),kn.#la&&(kn.#la.abort(),kn.#la=null,ei.clearPointerIds())}static _endDraw(t){const i=this._currentParent;if(i)if(i.toggleDrawing(!0),this._cleanup(!1),t?.target===i.div&&i.drawLayer.updateProperties(this._currentDrawId,kn.#ca.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=kn.#ca,e=this._currentDrawId,s=t.getLastElement();i.addCommands({cmd:()=>{i.drawLayer.updateProperties(e,t.setLastElement(s))},undo:()=>{i.drawLayer.updateProperties(e,t.removeLastElement())},mustExec:!1,type:W.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const i=this._currentParent;if(!i)return null;if(i.toggleDrawing(!0),i.cleanUndoStack(W.DRAW_STEP),!kn.#ca.isEmpty()){const{pageDimensions:[e,s],scale:n}=i,r=i.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:kn.#ca.getOutlines(e*n,s*n,n,this._INNER_MARGIN),drawingOptions:kn.#ua,mustBeCommitted:!t});return this._cleanup(!0),r}return i.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,i,e,s,n,r){tt("Not implemented")}static async deserialize(t,i,e){const{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:o}}=i.viewport,h=this.deserializeDraw(r,o,s,n,this._INNER_MARGIN,t),a=await super.deserialize(t,i,e);return a.createDrawingOptions(t),a.#da({drawOutlines:h}),a.#Yh(),a.onScaleChanging(),a.rotate(),a}serializeDraw(t){const[i,e]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#ha.serialize([i,e,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class Tn{#sh=new Float64Array(6);#So;#Aa;#Rn;#ch;#lh;#va="";#ba=0;#Nh=new Pn;#ya;#xa;constructor(t,i,e,s,n,r){this.#ya=e,this.#xa=s,this.#Rn=n,this.#ch=r,[t,i]=this.#Ma(t,i);const o=this.#So=[NaN,NaN,NaN,NaN,t,i];this.#lh=[t,i],this.#Aa=[{line:o,points:this.#lh}],this.#sh.set(o,0)}updateProperty(t,i){"stroke-width"===t&&(this.#ch=i)}#Ma(t,i){return An._normalizePoint(t,i,this.#ya,this.#xa,this.#Rn)}isEmpty(){return!this.#Aa||0===this.#Aa.length}isCancellable(){return this.#lh.length<=10}add(t,i){[t,i]=this.#Ma(t,i);const[e,s,n,r]=this.#sh.subarray(2,6);return Math.hypot(this.#ya*(t-n),this.#xa*(i-r))<=2?null:(this.#lh.push(t,i),isNaN(e)?(this.#sh.set([n,r,t,i],2),this.#So.push(NaN,NaN,NaN,NaN,t,i),{path:{d:this.toSVGPath()}}):(isNaN(this.#sh[0])&&this.#So.splice(6,6),this.#sh.set([e,s,n,r,t,i],0),this.#So.push(...An.createBezierPoints(e,s,n,r,t,i)),{path:{d:this.toSVGPath()}}))}end(t,i){return this.add(t,i)||(2===this.#lh.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,i,e,s,n){this.#ya=e,this.#xa=s,this.#Rn=n,[t,i]=this.#Ma(t,i);const r=this.#So=[NaN,NaN,NaN,NaN,t,i];this.#lh=[t,i];const o=this.#Aa.at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),this.#Aa.push({line:r,points:this.#lh}),this.#sh.set(r,0),this.#ba=0,this.toSVGPath(),null}getLastElement(){return this.#Aa.at(-1)}setLastElement(t){return this.#Aa?(this.#Aa.push(t),this.#So=t.line,this.#lh=t.points,this.#ba=0,{path:{d:this.toSVGPath()}}):this.#Nh.setLastElement(t)}removeLastElement(){if(!this.#Aa)return this.#Nh.removeLastElement();this.#Aa.pop(),this.#va="";for(let t=0,i=this.#Aa.length;t<i;t++){const{line:i,points:e}=this.#Aa[t];this.#So=i,this.#lh=e,this.#ba=0,this.toSVGPath()}return{path:{d:this.#va}}}toSVGPath(){const t=An.svgRound(this.#So[4]),i=An.svgRound(this.#So[5]);if(2===this.#lh.length)return this.#va=`${this.#va} M ${t} ${i} Z`,this.#va;if(this.#lh.length<=6){const e=this.#va.lastIndexOf("M");this.#va=`${this.#va.slice(0,e)} M ${t} ${i}`,this.#ba=6}if(4===this.#lh.length){const t=An.svgRound(this.#So[10]),i=An.svgRound(this.#So[11]);return this.#va=`${this.#va} L ${t} ${i}`,this.#ba=12,this.#va}const e=[];0===this.#ba&&(e.push(`M ${t} ${i}`),this.#ba=6);for(let t=this.#ba,i=this.#So.length;t<i;t+=6){const[i,s,n,r,o,h]=this.#So.slice(t,t+6).map(An.svgRound);e.push(`C${i} ${s} ${n} ${r} ${o} ${h}`)}return this.#va+=e.join(" "),this.#ba=this.#So.length,this.#va}getOutlines(t,i,e,s){const n=this.#Aa.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Nh.build(this.#Aa,t,i,e,this.#Rn,this.#ch,s),this.#sh=null,this.#So=null,this.#Aa=null,this.#va=null,this.#Nh}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Pn extends An{#yh;#Sa=0;#th;#Aa;#ya;#xa;#Ca;#Rn;#ch;build(t,i,e,s,n,r,o){this.#ya=i,this.#xa=e,this.#Ca=s,this.#Rn=n,this.#ch=r,this.#th=o??0,this.#Aa=t,this.#Ea()}get thickness(){return this.#ch}setLastElement(t){return this.#Aa.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Aa.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:i}of this.#Aa)if(t.push(`M${An.svgRound(i[4])} ${An.svgRound(i[5])}`),6!==i.length)if(12===i.length&&isNaN(i[6]))t.push(`L${An.svgRound(i[10])} ${An.svgRound(i[11])}`);else for(let e=6,s=i.length;e<s;e+=6){const[s,n,r,o,h,a]=i.subarray(e,e+6).map(An.svgRound);t.push(`C${s} ${n} ${r} ${o} ${h} ${a}`)}else t.push("Z");return t.join("")}serialize([t,i,e,s],n){const r=[],o=[],[h,a,c,l]=this.#ka();let u,d,f,p,g,m,w,A,v;switch(this.#Rn){case 0:v=An._rescale,u=t,d=i+s,f=e,p=-s,g=t+h*e,m=i+(1-a-l)*s,w=t+(h+c)*e,A=i+(1-a)*s;break;case 90:v=An._rescaleAndSwap,u=t,d=i,f=e,p=s,g=t+a*e,m=i+h*s,w=t+(a+l)*e,A=i+(h+c)*s;break;case 180:v=An._rescale,u=t+e,d=i,f=-e,p=s,g=t+(1-h-c)*e,m=i+a*s,w=t+(1-h)*e,A=i+(a+l)*s;break;case 270:v=An._rescaleAndSwap,u=t+e,d=i+s,f=-e,p=-s,g=t+(1-a-l)*e,m=i+(1-h-c)*s,w=t+(1-a)*e,A=i+(1-h)*s}for(const{line:t,points:i}of this.#Aa)r.push(v(t,u,d,f,p,n?Array(t.length):null)),o.push(v(i,u,d,f,p,n?Array(i.length):null));return{lines:r,points:o,rect:[g,m,w,A]}}static deserialize(t,i,e,s,n,{paths:{lines:r,points:o},rotation:h,thickness:a}){const c=[];let l,u,d,f,p;switch(h){case 0:p=An._rescale,l=-t/e,u=i/s+1,d=1/e,f=-1/s;break;case 90:p=An._rescaleAndSwap,l=-i/s,u=-t/e,d=1/s,f=1/e;break;case 180:p=An._rescale,l=t/e+1,u=-i/s,d=-1/e,f=1/s;break;case 270:p=An._rescaleAndSwap,l=i/s+1,u=t/e+1,d=-1/s,f=-1/e}if(!r){r=[];for(const t of o){const i=t.length;if(2===i){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===i){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const e=new Float32Array(3*(i-2));r.push(e);let[s,n,o,h]=t.subarray(0,4);e.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<i;r+=2){const i=t[r],a=t[r+1];e.set(An.createBezierPoints(s,n,o,h,i,a),3*(r-2)),[s,n,o,h]=[o,h,i,a]}}}for(let t=0,i=r.length;t<i;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,e,s,1,h,a,n),g}#Ta(t=this.#ch){const i=this.#th+t/2*this.#Ca;return this.#Rn%180==0?[i/this.#ya,i/this.#xa]:[i/this.#xa,i/this.#ya]}#ka(){const[t,i,e,s]=this.#yh,[n,r]=this.#Ta(0);return[t+n,i+r,e-2*n,s-2*r]}#Ea(){const t=this.#yh=L.slice();for(const{line:i}of this.#Aa){if(i.length<=12){for(let e=4,s=i.length;e<s;e+=6)gt.pointBoundingBox(i[e],i[e+1],t);continue}let e=i[4],s=i[5];for(let n=6,r=i.length;n<r;n+=6){const[r,o,h,a,c,l]=i.subarray(n,n+6);gt.bezierBoundingBox(e,s,r,o,h,a,c,l,t),e=c,s=l}}const[i,e]=this.#Ta();t[0]=Mt(t[0]-i,0,1),t[1]=Mt(t[1]-e,0,1),t[2]=Mt(t[2]+i,0,1),t[3]=Mt(t[3]+e,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#yh}updateProperty(t,i){return"stroke-width"===t?this.#Qh(i):null}#Qh(t){const[i,e]=this.#Ta();this.#ch=t;const[s,n]=this.#Ta(),[r,o]=[s-i,n-e],h=this.#yh;return h[0]-=r,h[1]-=o,h[2]+=2*r,h[3]+=2*o,h}updateParentDimensions([t,i],e){const[s,n]=this.#Ta();this.#ya=t,this.#xa=i,this.#Ca=e;const[r,o]=this.#Ta(),h=r-s,a=o-n,c=this.#yh;return c[0]-=h,c[1]-=a,c[2]+=2*h,c[3]+=2*a,c}updateRotation(t){return this.#Sa=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#yh.map(An.svgRound).join(" ")}get defaultProperties(){const[t,i]=this.#yh;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${An.svgRound(t)} ${An.svgRound(i)}`}}}get rotationTransform(){const[,,t,i]=this.#yh;let e=0,s=0,n=0,r=0,o=0,h=0;switch(this.#Sa){case 90:s=i/t,n=-t/i,o=t;break;case 180:e=-1,r=-1,o=t,h=i;break;case 270:s=-i/t,n=t/i,h=i;break;default:return""}return`matrix(${e} ${s} ${n} ${r} ${An.svgRound(o)} ${An.svgRound(h)})`}getPathResizingSVGProperties([t,i,e,s]){const[n,r]=this.#Ta(),[o,h,a,c]=this.#yh;if(Math.abs(a-n)<=An.PRECISION||Math.abs(c-r)<=An.PRECISION){const n=t+e/2-(o+a/2),r=i+s/2-(h+c/2);return{path:{"transform-origin":`${An.svgRound(t)} ${An.svgRound(i)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const l=(e-2*n)/(a-2*n),u=(s-2*r)/(c-2*r),d=a/e,f=c/s;return{path:{"transform-origin":`${An.svgRound(o)} ${An.svgRound(h)}`,transform:`${this.rotationTransform} scale(${d} ${f}) translate(${An.svgRound(n)} ${An.svgRound(r)}) scale(${l} ${u}) translate(${An.svgRound(-n)} ${An.svgRound(-r)})`}}}getPathResizedSVGProperties([t,i,e,s]){const[n,r]=this.#Ta(),o=this.#yh,[h,a,c,l]=o;if(o[0]=t,o[1]=i,o[2]=e,o[3]=s,Math.abs(c-n)<=An.PRECISION||Math.abs(l-r)<=An.PRECISION){const n=t+e/2-(h+c/2),r=i+s/2-(a+l/2);for(const{line:t,points:i}of this.#Aa)An._translate(t,n,r,t),An._translate(i,n,r,i);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${An.svgRound(t)} ${An.svgRound(i)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(e-2*n)/(c-2*n),d=(s-2*r)/(l-2*r),f=-u*(h+n)+t+n,p=-d*(a+r)+i+r;if(1!==u||1!==d||0!==f||0!==p)for(const{line:t,points:i}of this.#Aa)An._rescale(t,f,p,u,d,t),An._rescale(i,f,p,u,d,i);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${An.svgRound(t)} ${An.svgRound(i)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,i],e){const[s,n]=e,r=this.#yh,o=t-r[0],h=i-r[1];if(this.#ya===s&&this.#xa===n)for(const{line:t,points:i}of this.#Aa)An._translate(t,o,h,t),An._translate(i,o,h,i);else{const t=this.#ya/s,i=this.#xa/n;this.#ya=s,this.#xa=n;for(const{line:e,points:s}of this.#Aa)An._rescale(e,o,h,t,i,e),An._rescale(s,o,h,t,i,s);r[2]*=t,r[3]*=i}return r[0]=t,r[1]=i,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${An.svgRound(t)} ${An.svgRound(i)}`}}}get defaultSVGProperties(){const t=this.#yh;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${An.svgRound(t[0])} ${An.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Dn extends En{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:di._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,i){"stroke-width"===t&&(i??=this["stroke-width"],i*=this._viewParameters.realScale),super.updateSVGProperty(t,i)}clone(){const t=new Dn(this._viewParameters);return t.updateAll(this),t}}class In extends kn{static _type="ink";static _editorType=H.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,i){di.initialize(t,i),this._defaultDrawingOptions=new Dn(i.viewParameters)}static getDefaultDrawingOptions(t){const i=this._defaultDrawingOptions.clone();return i.updateProperties(t),i}static get supportMultipleDrawings(){return!0}static get typesMap(){return rt(this,"typesMap",new Map([[W.INK_THICKNESS,"stroke-width"],[W.INK_COLOR,"stroke"],[W.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,i,e,s,n){return new Tn(t,i,e,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,i,e,s,n,r){return Pn.deserialize(t,i,e,s,n,r)}static async deserialize(t,i,e){let s=null;if(t instanceof an){const{data:{inkLists:i,rect:e,rotation:n,id:r,color:o,opacity:h,borderStyle:{rawWidth:a},popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},parent:{page:{pageNumber:p}}}=t;s=t={annotationType:H.INK,color:Array.from(o),thickness:a,opacity:h,paths:{points:i},boxes:null,pageIndex:p-1,rect:e.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}const n=await super.deserialize(t,i,e);return n._initialData=s,t.comment&&n.setCommentData(t),n}get toolbarButtons(){return this._colorPicker||=new Rs(this),[["colorPicker",this._colorPicker]]}get colorType(){return W.INK_COLOR}get colorAndOpacityType(){return W.INK_COLOR_AND_OPACITY}get opacityType(){return W.INK_OPACITY}updateParams(t,i){t!==W.INK_COLOR_AND_OPACITY?super.updateParams(t,i):this._updateColorAndOpacity(i.color,i.opacity)}static updateDefaultParams(t,i){if(t===W.INK_COLOR_AND_OPACITY)return super.updateDefaultParams(W.INK_COLOR,i.color),void super.updateDefaultParams(W.INK_OPACITY,i.opacity);super.updateDefaultParams(t,i)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:i,parent:e}=this;i.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(t,i.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:i,opacity:e}){this._drawingOptions=In.getDefaultDrawingOptions({stroke:gt.makeHexColor(...t),"stroke-width":i,"stroke-opacity":e})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:i,points:e}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":n,"stroke-width":r}}=this,o=Object.assign(super.serialize(t),{color:di._colorManager.convert(s),opacity:n,thickness:r,paths:{lines:i,points:e}});return this.addComment(o),t?(o.isCopy=!0,o):this.annotationElementId&&!this.#Ko(o)?null:(o.id=this.annotationElementId,o)}#Ko(t){const{color:i,thickness:e,opacity:s,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,e)=>t!==i[e]))||t.thickness!==e||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:i,rect:e}=this.serializeDraw(!1);return t.updateEdited({rect:e,thickness:this._drawingOptions["stroke-width"],points:i,popup:this.comment}),null}}class Rn extends Pn{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}_(5213);class Nn{static#Pa={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#Da(t,i,e,s){return s-=i,0==(e-=t)?s>0?0:4:1===e?s+6:2-s}static#Ia=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#Ra(t,i,e,s,n,r,o){const h=this.#Da(e,s,n,r);for(let n=0;n<8;n++){const r=(-n+h-o+16)%8;if(0!==t[(e+this.#Ia[2*r])*i+(s+this.#Ia[2*r+1])])return r}return-1}static#Na(t,i,e,s,n,r,o){const h=this.#Da(e,s,n,r);for(let n=0;n<8;n++){const r=(n+h+o+16)%8;if(0!==t[(e+this.#Ia[2*r])*i+(s+this.#Ia[2*r+1])])return r}return-1}static#Oa(t,i,e,s){const n=t.length,r=new Int32Array(n);for(let i=0;i<n;i++)r[i]=t[i]<=s?1:0;for(let t=1;t<e-1;t++)r[t*i]=r[t*i+i-1]=0;for(let t=0;t<i;t++)r[t]=r[i*e-1-t]=0;let o,h=1;const a=[];for(let t=1;t<e-1;t++){o=1;for(let e=1;e<i-1;e++){const s=t*i+e,n=r[s];if(0===n)continue;let c=t,l=e;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=[e,t],d=l===e+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.#Ra(r,i,t,e,c,l,0);if(-1===g){r[s]=-h,1!==r[s]&&(o=Math.abs(r[s]));continue}let m=this.#Ia[2*g],w=this.#Ia[2*g+1];const A=t+m,v=e+w;c=A,l=v;let b=t,y=e;for(;;){const n=this.#Na(r,i,b,y,c,l,1);m=this.#Ia[2*n],w=this.#Ia[2*n+1];const a=b+m,d=y+w;u.push(d,a);const f=b*i+y;if(0===r[f+1]?r[f]=-h:1===r[f]&&(r[f]=h),a===t&&d===e&&b===A&&y===v){1!==r[s]&&(o=Math.abs(r[s]));break}c=b,l=y,b=a,y=d}}}return a}static#_a(t,i,e,s){if(e-i<=4){for(let n=i;n<e-2;n+=2)s.push(t[n],t[n+1]);return}const n=t[i],r=t[i+1],o=t[e-4]-n,h=t[e-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 v=0,b=i;for(let s=i+2;s<e-2;s+=2){const i=Math.abs(u-c*t[s+1]+l*t[s]);i>v&&(b=s,v=i)}v>(a*A)**2?(this.#_a(t,i,b+2,s),this.#_a(t,b,e,s)):s.push(n,r)}static#Fa(t){const i=[],e=t.length;return this.#_a(t,0,e,i),i.push(t[e-2],t[e-1]),i.length<=4?null:i}static#Ba(t,i,e,s,n,r){const o=new Float32Array(r**2),h=-2*s**2,a=r>>1;for(let t=0;t<r;t++){const i=(t-a)**2;for(let e=0;e<r;e++)o[t*r+e]=Math.exp((i+(e-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<e;s++)for(let n=0;n<i;n++){const h=s*i+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>=e))for(let e=0;e<r;e++){const s=n+e-a;if(s<0||s>=i)continue;const d=t[u*i+s],g=o[h*r+e]*c[Math.abs(d-l)];f+=d*g,p+=g}}d[u[h]=Math.round(f/p)]++}return[u,d]}static#La(t){const i=new Uint32Array(256);for(const e of t)i[e]++;return i}static#Ua(t){const i=new Uint8ClampedArray(t.length>>2);let e=-1/0,s=1/0;for(let n=0,r=i.length;n<r;n++){const r=i[n]=t[n<<2];e=Math.max(e,r),s=Math.min(s,r)}const n=255/(e-s);for(let t=0,e=i.length;t<e;t++)i[t]=(i[t]-s)*n;return i}static#$a(t){let i,e=-1/0,s=-1/0;const n=t.findIndex((t=>0!==t));let r=n,o=n;for(i=n;i<256;i++){const n=t[i];n>e&&(i-r>s&&(s=i-r,o=i-1),e=n,r=i)}for(i=o-1;i>=0&&!(t[i]>t[i+1]);i--);return i}static#ja(t){const i=t,{width:e,height:s}=t,{maxDim:n}=this.#Pa;let r=e,o=s;if(e>n||s>n){let h=e,a=s,c=Math.log2(Math.max(e,s)/n);const l=Math.floor(c);c=c===l?l-1:l;for(let e=0;e<c;e++){r=Math.ceil(h/2),o=Math.ceil(a/2);const e=new OffscreenCanvas(r,o);e.getContext("2d").drawImage(t,0,0,h,a,0,0,r,o),h=r,a=o,t!==i&&t.close(),t=e.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.fillStyle="white",h.fillRect(0,0,r,o),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.#Ua(a),r,o]}static extractContoursFromText(t,{fontFamily:i,fontStyle:e,fontWeight:s},n,r,o,h){let a=new OffscreenCanvas(1,1),c=a.getContext("2d",{alpha:!1});const l=c.font=`${e} ${s} 200px ${i}`,{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)),v=Math.ceil(1.5*Math.max(Math.abs(f)+Math.abs(p)||200,Math.abs(g)+Math.abs(m)||200));a=new OffscreenCanvas(A,v),c=a.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=l,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,A,v),c.fillStyle="black",c.fillText(t,.5*A/2,1.5*v/2);const b=this.#Ua(c.getImageData(0,0,A,v).data),y=this.#La(b),x=this.#$a(y),M=this.#Oa(b,A,v,x);return this.processDrawnLines({lines:{curves:M,width:A,height:v},pageWidth:n,pageHeight:r,rotation:o,innerMargin:h,mustSmooth:!0,areContours:!0})}static process(t,i,e,s,n){const[r,o,h]=this.#ja(t),[a,c]=this.#Ba(r,o,h,Math.hypot(o,h)*this.#Pa.sigmaSFactor,this.#Pa.sigmaR,this.#Pa.kernelSize),l=this.#$a(c),u=this.#Oa(a,o,h,l);return this.processDrawnLines({lines:{curves:u,width:o,height:h},pageWidth:i,pageHeight:e,rotation:s,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:i,pageHeight:e,rotation:s,innerMargin:n,mustSmooth:r,areContours:o}){s%180!=0&&([i,e]=[e,i]);const{curves:h,width:a,height:c}=t,l=t.thickness??0,u=[],d=Math.min(i/a,e/c),f=d/i,p=d/e,g=[];for(const{points:t}of h){const i=r?this.#Fa(t):t;if(!i)continue;g.push(i);const e=i.length,s=new Float32Array(e),n=new Float32Array(3*(2===e?2:e-2));if(u.push({line:n,points:s}),2===e){s[0]=i[0]*f,s[1]=i[1]*p,n.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[o,h,a,c]=i;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<e;t+=2){const e=s[t]=i[t]*f,r=s[t+1]=i[t+1]*p;n.set(An.createBezierPoints(o,h,a,c,e,r),3*(t-2)),[o,h,a,c]=[a,c,e,r]}}if(0===u.length)return null;const m=o?new Rn:new Pn;return m.build(u,i,e,1,s,o?0:l,n),{outline:m,newCurves:g,areContours:o,thickness:l,width:a,height:c}}static async compressSignature({outlines:t,areContours:i,thickness:e,width:s,height:n}){let r,o=1/0,h=-1/0,a=0;for(const i of t){a+=i.length;for(let t=2,e=i.length;t<e;t++){const e=i[t]-i[t-2];o=Math.min(o,e),h=Math.max(h,e)}}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++]=i?0:1,u[d++]=Math.max(0,Math.floor(e??0)),u[d++]=c,u[d++]=r.BYTES_PER_ELEMENT;for(const i of t)u[d++]=i.length-2,u[d++]=i[0],u[d++]=i[1];const f=new CompressionStream("deflate-raw"),p=f.writable.getWriter();await p.ready,p.write(u);const g=r.prototype.constructor;for(const i of t){const t=new g(i.length-2);for(let e=2,s=i.length;e<s;e++)t[e-2]=i[e]-i[e-2];p.write(t)}return p.close(),(await new Response(f.readable).bytes()).toBase64()}static async decompressSignature(t){try{const i=Uint8Array.fromBase64(t),{readable:e,writable:s}=new DecompressionStream("deflate-raw"),n=s.getWriter();await n.ready,n.write(i).then((async()=>{await n.ready,await n.close()})).catch((()=>{}));let r=null,o=0;for await(const t of e)r||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),r.set(t,o),o+=t.length;const h=new Uint32Array(r.buffer,0,r.length>>2),a=h[1];if(0!==a)throw Error("Invalid version: "+a);const c=h[2],l=h[3],u=0===h[4],d=h[5],f=h[6],p=[],g=(8+3*f)*Uint32Array.BYTES_PER_ELEMENT;let m;switch(h[7]){case Int8Array.BYTES_PER_ELEMENT:m=new Int8Array(r.buffer,g);break;case Int16Array.BYTES_PER_ELEMENT:m=new Int16Array(r.buffer,g);break;case Int32Array.BYTES_PER_ELEMENT:m=new Int32Array(r.buffer,g)}o=0;for(let t=0;t<f;t++){const i=h[3*t+8],e=new Float32Array(i+2);p.push(e);for(let i=0;i<2;i++)e[i]=h[3*t+8+i+1];for(let t=0;t<i;t++)e[t+2]=e[t]+m[o++]}return{areContours:u,thickness:d,outlines:p,width:c,height:l}}catch(t){return Z("decompressSignature: "+t),null}}}class On extends En{constructor(){super(),super.updateProperties({fill:di._defaultLineColor,"stroke-width":0})}clone(){const t=new On;return t.updateAll(this),t}}class _n extends Dn{constructor(t){super(t),super.updateProperties({stroke:di._defaultLineColor,"stroke-width":1})}clone(){const t=new _n(this._viewParameters);return t.updateAll(this),t}}class Fn extends kn{#za=!1;#Ha=null;#Wa=null;#Ga=null;static _type="signature";static _editorType=H.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#Wa=t.signatureData||null,this.#Ha=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,i){di.initialize(t,i),this._defaultDrawingOptions=new On,this._defaultDrawnSignatureOptions=new _n(i.viewParameters)}static getDefaultDrawingOptions(t){const i=this._defaultDrawingOptions.clone();return i.updateProperties(t),i}static get supportMultipleDrawings(){return!1}static get typesMap(){return rt(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#Ha}}static computeTelemetryFinalData(t){const i=t.get("hasDescription");return{hasAltText:i.get(!0)??0,hasNoAltText:i.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,i;const{_isCopy:e}=this;if(e&&(this._isCopy=!1,t=this.x,i=this.y),super.render(),null===this._drawId)if(this.#Wa){const{lines:t,mustSmooth:i,areContours:e,description:s,uuid:n,heightInPage:r}=this.#Wa,{rawDims:{pageWidth:o,pageHeight:h},rotation:a}=this.parent.viewport,c=Nn.processDrawnLines({lines:t,pageWidth:o,pageHeight:h,rotation:a,innerMargin:Fn._INNER_MARGIN,mustSmooth:i,areContours:e});this.addSignature(c,r,s,n)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#Ha||""}));return e&&(this._isCopy=!0,this._moveAfterPaste(t,i)),this.div}setUuid(t){this.#Ga=t,this.addEditToolbar()}getUuid(){return this.#Ga}get description(){return this.#Ha}set description(t){this.#Ha=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then((i=>{i?.updateEditSignatureButton(t)})))}getSignaturePreview(){const{newCurves:t,areContours:i,thickness:e,width:s,height:n}=this.#Wa,r=Math.max(s,n);return{areContours:i,outline:Nn.processDrawnLines({lines:{curves:t.map((t=>({points:t}))),thickness:e,width:s,height:n},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:i}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,i,e,s){const{x:n,y:r}=this,{outline:o}=this.#Wa=t;let h;this.#za=o instanceof Rn,this.description=e,this.#za?h=Fn.getDefaultDrawingOptions():(h=Fn._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":o.thickness})),this._addOutlines({drawOutlines:o,drawingOptions:h});const[,a]=this.pageDimensions;let c=i/a;c=c>=1?.5:c,this.width*=c/this.height,this.width>=1&&(c*=.9/this.width,this.width=.9),this.height=c,this.setDims(),this.x=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:!!e}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:i,pageHeight:e},rotation:s}=this.parent.viewport;return Nn.process(t,i,e,s,Fn._INNER_MARGIN)}getFromText(t,i){const{rawDims:{pageWidth:e,pageHeight:s},rotation:n}=this.parent.viewport;return Nn.extractContoursFromText(t,i,e,s,n,Fn._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:i,pageHeight:e},rotation:s}=this.parent.viewport;return Nn.processDrawnLines({lines:t,pageWidth:i,pageHeight:e,rotation:s,innerMargin:Fn._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:i}){t?this._drawingOptions=Fn.getDefaultDrawingOptions():(this._drawingOptions=Fn._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":i}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:i,points:e}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,n=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#za,color:[0,0,0],thickness:this.#za?0:s});return this.addComment(n),t?(n.paths={lines:i,points:e},n.uuid=this.#Ga,n.isCopy=!0):n.lines=i,this.#Ha&&(n.accessibilityData={type:"Figure",alt:this.#Ha}),n}static deserializeDraw(t,i,e,s,n,r){return r.areContours?Rn.deserialize(t,i,e,s,n,r):Pn.deserialize(t,i,e,s,n,r)}static async deserialize(t,i,e){const s=await super.deserialize(t,i,e);return s.#za=t.areContours,s.description=t.accessibilityData?.alt||"",s.#Ga=t.uuid,s}}class Bn extends di{#Va=null;#Ya=null;#Xa=null;#qa=null;#Qa=null;#Ka="";#Ja=null;#Za=!1;#tc=null;#ic=!1;#ec=!1;static _type="stamp";static _editorType=H.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#qa=t.bitmapUrl,this.#Qa=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,i){di.initialize(t,i)}static isHandlingMimeForPasting(t){return Wt.includes(t)}static paste(t,i){i.pasteEditor({mode:H.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 i=t.get("hasAltText");return{hasAltText:i.get(!0)??0,hasNoAltText:i.get(!1)??0}}#sc(t,i=!1){t?(this.#Va=t.bitmap,i||(this.#Ya=t.id,this.#ic=t.isSvg),t.file&&(this.#Ka=t.file.name),this.#nc()):this.remove()}#rc(){if(this.#Xa=null,this._uiManager.enableWaiting(!1),this.#Ja)if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Va)this.addEditToolbar().then((()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)}));else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Va){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,i=!0){if(this.hasAltTextData())return null;const{mlManager:e}=this._uiManager;if(!e)throw Error("No ML.");if(!await e.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,o=await e.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!o)throw Error("No response from the AI service.");if(o.error)throw Error("Error from the AI service.");if(o.cancel)return null;if(!o.output)throw Error("No valid response from the AI service.");const h=o.output;return await this.setGuessedAltText(h),i&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}#oc(){if(this.#Ya)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#Ya).then((t=>this.#sc(t,!0))).finally((()=>this.#rc()));if(this.#qa){const t=this.#qa;return this.#qa=null,this._uiManager.enableWaiting(!0),void(this.#Xa=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#sc(t))).finally((()=>this.#rc())))}if(this.#Qa){const t=this.#Qa;return this.#Qa=null,this._uiManager.enableWaiting(!0),void(this.#Xa=this._uiManager.imageManager.getFromFile(t).then((t=>this.#sc(t))).finally((()=>this.#rc())))}const t=document.createElement("input");t.type="file",t.accept=Wt.join(",");const i=this._uiManager._signal;this.#Xa=new Promise((e=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#sc(i)}else this.remove();e()}),{signal:i}),t.addEventListener("cancel",(()=>{this.remove(),e()}),{signal:i})})).finally((()=>this.#rc())),t.click()}remove(){this.#Ya&&(this.#Va=null,this._uiManager.imageManager.deleteId(this.#Ya),this.#Ja?.remove(),this.#Ja=null,this.#tc&&(clearTimeout(this.#tc),this.#tc=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#Ya&&null===this.#Ja&&this.#oc(),this.isAttachedToDOM||this.parent.add(this))):this.#Ya&&this.#oc()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#Xa||this.#Va||this.#qa||this.#Qa||this.#Ya||this.#Za)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,i;return this._isCopy&&(t=this.x,i=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#Za||(this.#Va?this.#nc():this.#oc()),this._isCopy&&this._moveAfterPaste(t,i),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,i){const{id:e,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,i);i.remove(),e&&this._uiManager.imageManager.isValidId(e)&&(this.#Ya=e,s&&(this.#Va=s),this.#Za=!1,this.#nc())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#tc&&clearTimeout(this.#tc),this.#tc=setTimeout((()=>{this.#tc=null,this.#hc()}),200))}#nc(){const{div:t}=this;let{width:i,height:e}=this.#Va;const[s,n]=this.pageDimensions,r=.75;if(this.width)i=this.width*s,e=this.height*n;else if(i>r*s||e>r*n){const t=Math.min(r*s/i,r*n/e);i*=t,e*=t}this._uiManager.enableWaiting(!1);const o=this.#Ja=document.createElement("canvas");o.setAttribute("role","img"),this.addContainer(o),this.width=i/s,this.height=e/n,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#hc(),this.#ec||(this.parent.addUndoableEditor(this),this.#ec=!0),this._reportTelemetry({action:"inserted_image"}),this.#Ka&&this.div.setAttribute("aria-description",this.#Ka),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,i,e=!1){t||(t=224);const{width:s,height:n}=this.#Va,r=new Ht;let o=this.#Va,h=s,a=n,c=null;if(i){if(s>i||n>i){const t=Math.min(i/s,i/n);h=Math.floor(s*t),a=Math.floor(n*t)}c=document.createElement("canvas");const t=c.width=Math.ceil(h*r.sx),e=c.height=Math.ceil(a*r.sy);this.#ic||(o=this.#ac(t,e));const l=c.getContext("2d");l.filter=this._uiManager.hcmFilter;let u="white",d="#cfcfd8";"none"!==this._uiManager.hcmFilter?d="black":Gt.isDarkMode&&(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,e),l.drawImage(o,0,0,o.width,o.height,0,0,t,e)}let l=null;if(e){let i,e;if(r.symmetric&&o.width<t&&o.height<t)i=o.width,e=o.height;else if(o=this.#Va,s>t||n>t){const r=Math.min(t/s,t/n);i=Math.floor(s*r),e=Math.floor(n*r),this.#ic||(o=this.#ac(i,e))}const h=new OffscreenCanvas(i,e).getContext("2d",{willReadFrequently:!0});h.drawImage(o,0,0,o.width,o.height,0,0,i,e),l={width:i,height:e,data:h.getImageData(0,0,i,e).data}}return{canvas:c,width:h,height:a,imageData:l}}#ac(t,i){const{width:e,height:s}=this.#Va;let n=e,r=s,o=this.#Va;for(;n>2*t||r>2*i;){const e=n,s=r;n>2*t&&(n=Math.ceil(n/2)),r>2*i&&(r=Math.ceil(r/2));const h=new OffscreenCanvas(n,r);h.getContext("2d").drawImage(o,0,0,e,s,0,0,n,r),o=h.transferToImageBitmap()}return o}#hc(){const[t,i]=this.parentDimensions,{width:e,height:s}=this,n=new Ht,r=Math.ceil(e*t*n.sx),o=Math.ceil(s*i*n.sy),h=this.#Ja;if(!h||h.width===r&&h.height===o)return;h.width=r,h.height=o;const a=this.#ic?this.#Va:this.#ac(r,o),c=h.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(a,0,0,a.width,a.height,0,0,r,o)}#cc(t){if(t){if(this.#ic){const t=this._uiManager.imageManager.getSvgUrl(this.#Ya);if(t)return t}const t=document.createElement("canvas");return({width:t.width,height:t.height}=this.#Va),t.getContext("2d").drawImage(this.#Va,0,0),t.toDataURL()}if(this.#ic){const[t,i]=this.pageDimensions,e=Math.round(this.width*t*kt.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*kt.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(e,s);return n.getContext("2d").drawImage(this.#Va,0,0,this.#Va.width,this.#Va.height,0,0,e,s),n.transferToImageBitmap()}return structuredClone(this.#Va)}static async deserialize(t,i,e){let s=null,n=!1;if(t instanceof fn){const{data:{rect:r,rotation:o,id:h,structParent:a,popupRef:c,richText:l,contentsObj:u,creationDate:d,modificationDate:f},container:p,parent:{page:{pageNumber:g}},canvas:m}=t;let w,A;m?(delete t.canvas,({id:w,bitmap:A}=e.imageManager.getFromCanvas(p.id,m)),m.remove()):(n=!0,t._hasNoCanvas=!0);const v=(await i._structTree.getAriaAttributes(`${vt}${h}`))?.get("aria-label")||"";s=t={annotationType:H.STAMP,bitmapId:w,bitmap:A,pageIndex:g-1,rect:r.slice(0),rotation:o,annotationElementId:h,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:v},isSvg:!1,structParent:a,popupRef:c,richText:l,comment:u?.str||null,creationDate:d,modificationDate:f}}const r=await super.deserialize(t,i,e),{rect:o,bitmap:h,bitmapUrl:a,bitmapId:c,isSvg:l,accessibilityData:u}=t;n?(e.addMissingCanvas(t.id,r),r.#Za=!0):c&&e.imageManager.isValidId(c)?(r.#Ya=c,h&&(r.#Va=h)):r.#qa=a,r.#ic=l;const[d,f]=r.pageDimensions;return r.width=(o[2]-o[0])/d,r.height=(o[3]-o[1])/f,u&&(r.altTextData=u),r._initialData=s,t.comment&&r.setCommentData(t),r.#ec=!!s,r}serialize(t=!1,i=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=Object.assign(super.serialize(t),{bitmapId:this.#Ya,isSvg:this.#ic});if(this.addComment(e),t)return e.bitmapUrl=this.#cc(!0),e.accessibilityData=this.serializeAltText(!0),e.isCopy=!0,e;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(e.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#Ko(e);return t.isSame?null:(t.isSameAltText?delete e.accessibilityData:e.accessibilityData.structParent=this._initialData.structParent??-1,e.id=this.annotationElementId,delete e.bitmapId,e)}if(null===i)return e;i.stamps||=new Map;const r=this.#ic?(e.rect[2]-e.rect[0])*(e.rect[3]-e.rect[1]):null;if(i.stamps.has(this.#Ya)){if(this.#ic){const t=i.stamps.get(this.#Ya);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#cc(!1))}}else i.stamps.set(this.#Ya,{area:r,serialized:e}),e.bitmap=this.#cc(!1);return e}#Ko(t){const{pageIndex:i,accessibilityData:{altText:e}}=this._initialData,s=t.pageIndex===i,n=(t.accessibilityData?.alt||"")===e;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class Ln{#No;#lc=!1;#uc=null;#dc=null;#fc=null;#pc=new Map;#gc=!1;#mc=!1;#wc=!1;#Ac=null;#vc=null;#bc=null;#yc=null;#xc=null;#Mc=-1;#A;static _initialized=!1;static#K=new Map([wn,In,Bn,Cn,Fn].map((t=>[t._editorType,t])));constructor({uiManager:t,pageIndex:i,div:e,structTreeLayer:s,accessibilityManager:n,annotationLayer:r,drawLayer:o,textLayer:h,viewport:a,l10n:c}){const l=[...Ln.#K.values()];if(!Ln._initialized){Ln._initialized=!0;for(const i of l)i.initialize(c,t)}t.registerEditorTypes(l),this.#A=t,this.pageIndex=i,this.div=e,this.#No=n,this.#uc=r,this.viewport=a,this.#bc=h,this.drawLayer=o,this._structTree=s,this.#A.addLayer(this)}get isEmpty(){return 0===this.#pc.size}get isInvisible(){return this.isEmpty&&this.#A.getMode()===H.NONE}updateToolbar(t){this.#A.updateToolbar(t)}updateMode(t=this.#A.getMode()){switch(this.#Sc(),t){case H.NONE:return this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case H.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case H.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:i}=this.div;if(i.toggle("nonEditing",!1),t===H.POPUP)i.toggle("commentEditing",!0);else{i.toggle("commentEditing",!1);for(const e of Ln.#K.values())i.toggle(e._type+"Editing",t===e._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#bc?.div}setEditingState(t){this.#A.setEditingState(t)}addCommands(t){this.#A.addCommands(t)}cleanUndoStack(t){this.#A.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#uc?.togglePointerEvents(t)}get#Cc(){return 0!==this.#pc.size?this.#pc.values():this.#A.getEditors(this.pageIndex)}async enable(){this.#wc=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#xc?.abort(),this.#xc=null;const t=new Set;for(const i of this.#Cc)i.enableEditing(),i.show(!0),i.annotationElementId&&(this.#A.removeChangedExistingAnnotation(i),t.add(i.annotationElementId));const i=this.#uc;if(i)for(const e of i.getEditableAnnotations()){if(e.hide(),this.#A.isDeletedAnnotationElement(e.data.id))continue;if(t.has(e.data.id))continue;const i=await this.deserialize(e);i&&(this.addOrRebuild(i),i.enableEditing())}this.#wc=!1,this.#A._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#mc=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#bc&&!this.#xc){this.#xc=new AbortController;const t=this.#A.combinedSignal(this.#xc);this.#bc.div.addEventListener("pointerdown",(t=>{const{clientX:i,clientY:e,timeStamp:s}=t;if(s-this.#Mc>500)return void(this.#Mc=s);this.#Mc=-1;const{classList:n}=this.div;n.toggle("getElements",!0);const r=document.elementsFromPoint(i,e);if(n.toggle("getElements",!1),!this.div.contains(r[0]))return;let o;const h=RegExp(`^${z}[0-9]+$`);for(const t of r)if(h.test(t.id)){o=t.id;break}if(!o)return;const a=this.#pc.get(o);null===a?.annotationElementId&&(Ft(t),a.dblclick(t))}),{signal:t,capture:!0})}const t=this.#uc,i=[];if(t){const e=new Map,s=new Map;for(const t of this.#Cc)t.disableEditing(),t.annotationElementId?null===t.serialize()?(s.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()):e.set(t.annotationElementId,t):i.push(t);for(const i of t.getEditableAnnotations()){const{id:t}=i.data;if(this.#A.isDeletedAnnotationElement(t)){i.updateEdited({deleted:!0});continue}let n=s.get(t);n?(n.resetAnnotationElement(i),n.show(!1),i.show()):(n=e.get(t),n&&(this.#A.addChangedExistingAnnotation(n),n.renderAnnotationElement(i)&&n.show(!1)),i.show())}}this.#Sc(),this.isEmpty&&(this.div.hidden=!0);const{classList:e}=this.div;for(const t of Ln.#K.values())e.remove(t._type+"Editing");this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(i),this.#mc=!1}getEditableAnnotation(t){return this.#uc?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#A.getActive()!==t&&this.#A.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#bc?.div&&!this.#yc){this.#yc=new AbortController;const t=this.#A.combinedSignal(this.#yc);this.#bc.div.addEventListener("pointerdown",this.#Ec.bind(this),{signal:t}),this.#bc.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#bc?.div&&this.#yc&&(this.#yc.abort(),this.#yc=null,this.#bc.div.classList.remove("highlighting"))}#Ec(t){this.#A.unselectAll();const{target:i}=t;if(i===this.#bc.div||("img"===i.getAttribute("role")||i.classList.contains("endOfContent")||i.classList.contains("textLayerImagePlaceholder"))&&this.#bc.div.contains(i)){const{isMac:i}=pt.platform;if(0!==t.button||t.ctrlKey&&i)return;this.#A.showAllEditors("highlight",!0,!0),this.#bc.div.classList.add("free"),this.toggleDrawing(),Cn.startHighlighting(this,"ltr"===this.#A.direction,{target:this.#bc.div,x:t.x,y:t.y}),this.#bc.div.addEventListener("pointerup",(()=>{this.#bc.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#A._signal}),t.preventDefault()}}enableClick(){if(this.#dc)return;this.#dc=new AbortController;const t=this.#A.combinedSignal(this.#dc);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const i=this.pointerup.bind(this);this.div.addEventListener("pointerup",i,{signal:t}),this.div.addEventListener("pointercancel",i,{signal:t})}disableClick(){this.#dc?.abort(),this.#dc=null}attach(t){this.#pc.set(t.id,t);const{annotationElementId:i}=t;i&&this.#A.isDeletedAnnotationElement(i)&&this.#A.removeDeletedAnnotationElement(t)}detach(t){this.#pc.delete(t.id),this.#No?.removePointerInTextLayer(t.contentDiv),!this.#mc&&t.annotationElementId&&this.#A.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#A.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#A.addDeletedAnnotationElement(t),di.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.#A.addEditor(t),this.attach(t),!t.isAttachedToDOM){const i=t.render();this.div.append(i),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#wc),this.#A.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:i}=document;t.div.contains(i)&&!this.#fc&&(t._focusEventsAllowed=!1,this.#fc=setTimeout((()=>{this.#fc=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#A._signal}),i.focus())}),0)),t._structTreeParentId=this.#No?.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})}getEditorByUID(t){for(const i of this.#pc.values())if(i.uid===t)return i;return null}get#kc(){return Ln.#K.get(this.#A.getMode())}combinedSignal(t){return this.#A.combinedSignal(t)}#Tc(t){const i=this.#kc;return i?new i.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#kc?.canCreateNewEmptyEditor()}async pasteEditor(t,i){this.updateToolbar(t),await this.#A.updateMode(t.mode);const{offsetX:e,offsetY:s}=this.#Pc(),n=this.#A.getId(),r=this.#Tc({parent:this,id:n,x:e,y:s,uiManager:this.#A,isCentered:!0,...i});r&&this.add(r)}async deserialize(t){return await(Ln.#K.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#A))||null}createAndAddNewEditor(t,i,e={}){const s=this.#A.getId(),n=this.#Tc({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#A,isCentered:i,...e});return n&&this.add(n),n}get boundingClientRect(){return this.div.getBoundingClientRect()}#Pc(){const{x:t,y:i,width:e,height:s}=this.boundingClientRect,n=Math.max(0,t),r=Math.max(0,i),o=(n+Math.min(window.innerWidth,t+e))/2-t,h=(r+Math.min(window.innerHeight,i+s))/2-i,[a,c]=this.viewport.rotation%180==0?[o,h]:[h,o];return{offsetX:a,offsetY:c}}addNewEditor(t={}){this.createAndAddNewEditor(this.#Pc(),!0,t)}setSelected(t){this.#A.setSelected(t)}toggleSelected(t){this.#A.toggleSelected(t)}unselect(t){this.#A.unselect(t)}pointerup(t){const{isMac:i}=pt.platform;if(0!==t.button||t.ctrlKey&&i)return;if(t.target!==this.div)return;if(!this.#gc)return;if(this.#gc=!1,this.#kc?.isDrawer&&this.#kc.supportMultipleDrawings)return;if(!this.#lc)return void(this.#lc=!0);const e=this.#A.getMode();e!==H.STAMP&&e!==H.POPUP&&e!==H.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#A.unselectAll()}pointerdown(t){if(this.#A.getMode()===H.HIGHLIGHT&&this.enableTextSelection(),this.#gc)return void(this.#gc=!1);const{isMac:i}=pt.platform;if(0!==t.button||t.ctrlKey&&i)return;if(t.target!==this.div)return;if(this.#gc=!0,this.#kc?.isDrawer)return void this.startDrawingSession(t);const e=this.#A.getActive();this.#lc=!e||e.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#Ac)return void this.#kc.startDrawing(this,this.#A,!1,t);this.#A.setCurrentDrawingSession(this),this.#Ac=new AbortController;const i=this.#A.combinedSignal(this.#Ac);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#vc=null,this.commitOrRemove())}),{signal:i}),this.#kc.startDrawing(this,this.#A,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#vc=t)}else this.#vc&&setTimeout((()=>{this.#vc?.focus(),this.#vc=null}),0)}endDrawingSession(t=!1){return this.#Ac?(this.#A.setCurrentDrawingSession(null),this.#Ac.abort(),this.#Ac=null,this.#vc=null,this.#kc.endDrawing(t)):null}findNewParent(t,i,e){const s=this.#A.findParent(i,e);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#Ac&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#Ac&&this.#kc.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#A.getActive()?.parent===this&&(this.#A.commitOrRemove(),this.#A.setActiveEditor(null)),this.#fc&&(clearTimeout(this.#fc),this.#fc=null);for(const t of this.#pc.values())this.#No?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#pc.clear(),this.#A.removeLayer(this)}#Sc(){for(const t of this.#pc.values())t.isEmpty()&&t.remove()}async render({viewport:t}){this.viewport=t,zt(this.div,t);for(const t of this.#A.getEditors(this.pageIndex))this.add(t),t.rebuild();await this.#A.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#A.commitOrRemove(),this.#Sc();const i=this.viewport.rotation,e=t.rotation;if(this.viewport=t,zt(this.div,{rotation:e}),i!==e)for(const t of this.#pc.values())t.rotate(e)}get pageDimensions(){const{pageWidth:t,pageHeight:i}=this.viewport.rawDims;return[t,i]}get scale(){return this.#A.viewParameters.realScale}}class Un{#so=null;#Dc=new Map;#Ic=new Map;static#E=0;setParent(t){if(this.#so){if(this.#so!==t){if(this.#Dc.size>0)for(const i of this.#Dc.values())i.remove(),t.append(i);this.#so=t}}else this.#so=t}static get _svgFactory(){return rt(this,"_svgFactory",new Bs)}static#Rc(t,[i,e,s,n]){const{style:r}=t;r.top=100*e+"%",r.left=100*i+"%",r.width=100*s+"%",r.height=100*n+"%"}#Nc(){const t=Un._svgFactory.create(1,1,!0);return this.#so.append(t),t.setAttribute("aria-hidden",!0),t}#Oc(t,i){const e=Un._svgFactory.createElement("clipPath");t.append(e);const s="clip_"+i;e.setAttribute("id",s),e.setAttribute("clipPathUnits","objectBoundingBox");const n=Un._svgFactory.createElement("use");return e.append(n),n.setAttribute("href","#"+i),n.classList.add("clip"),s}#_c(t,i){for(const[e,s]of Object.entries(i))null===s?t.removeAttribute(e):t.setAttribute(e,s)}draw(t,i=!1,e=!1){const s=Un.#E++,n=this.#Nc(),r=Un._svgFactory.createElement("defs");n.append(r);const o=Un._svgFactory.createElement("path");r.append(o);const h="path_"+s;o.setAttribute("id",h),o.setAttribute("vector-effect","non-scaling-stroke"),i&&this.#Ic.set(s,o);const a=e?this.#Oc(r,h):null,c=Un._svgFactory.createElement("use");return n.append(c),c.setAttribute("href","#"+h),this.updateProperties(n,t),this.#Dc.set(s,n),{id:s,clipPathId:`url(#${a})`}}drawOutline(t,i){const e=Un.#E++,s=this.#Nc(),n=Un._svgFactory.createElement("defs");s.append(n);const r=Un._svgFactory.createElement("path");n.append(r);const o="path_"+e;let h;if(r.setAttribute("id",o),r.setAttribute("vector-effect","non-scaling-stroke"),i){const t=Un._svgFactory.createElement("mask");n.append(t),h="mask_"+e,t.setAttribute("id",h),t.setAttribute("maskUnits","objectBoundingBox");const i=Un._svgFactory.createElement("rect");t.append(i),i.setAttribute("width","1"),i.setAttribute("height","1"),i.setAttribute("fill","white");const s=Un._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=Un._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.#Dc.set(e,s),e}finalizeDraw(t,i){this.#Ic.delete(t),this.updateProperties(t,i)}updateProperties(t,i){if(!i)return;const{root:e,bbox:s,rootClass:n,path:r}=i,o="number"==typeof t?this.#Dc.get(t):t;if(o){if(e&&this.#_c(o,e),s&&Un.#Rc(o,s),n){const{classList:t}=o;for(const[i,e]of Object.entries(n))t.toggle(i,e)}r&&this.#_c(o.firstElementChild.firstElementChild,r)}}updateParent(t,i){if(i===this)return;const e=this.#Dc.get(t);e&&(i.#so.append(e),this.#Dc.delete(t),i.#Dc.set(t,e))}remove(t){this.#Ic.delete(t),null!==this.#so&&(this.#Dc.get(t).remove(),this.#Dc.delete(t))}destroy(){this.#so=null;for(const t of this.#Dc.values())t.remove();this.#Dc.clear(),this.#Ic.clear()}}function $n(t){return(100*t).toFixed(2)+"%"}class jn{#Fc=[];#Bc=new Map;#Lc=null;#Uc=0;#Pn=0;#Tn=0;static#$c=null;constructor(t,i,e,s){this.#Uc=t,this.#Fc=i,this.#Pn=e.rawDims.pageWidth,this.#Tn=e.rawDims.pageHeight,this.#Lc=s}render(){const t=document.createElement("div");t.className="textLayerImages";for(let i=0;i<this.#Fc.length;i+=6){const e=this.#jc(this.#Fc.subarray(i,i+6));e&&t.append(e)}return t.addEventListener("contextmenu",(t=>{if(!(t.target instanceof HTMLCanvasElement))return;const i=t.target,e=this.#Bc.get(i);if(!e)return;const s=jn.#$c?.deref();if(s===i)return;s&&(s.width=0,s.height=0),jn.#$c=new WeakRef(i);const{inverseTransform:n,x1:r,y1:o,width:h,height:a}=e,c=this.#Lc(),l=Math.ceil(r*c.width),u=Math.ceil(o*c.height),d=Math.floor((r+h/this.#Pn)*c.width),f=Math.floor((o+a/this.#Tn)*c.height);i.width=d-l,i.height=f-u;const p=i.getContext("2d");p.setTransform(...n),p.translate(-l,-u),p.drawImage(c,0,0)})),t}#jc([t,i,e,s,n,r]){const o=Math.hypot((n-t)*this.#Pn,(r-i)*this.#Tn),h=Math.hypot((e-t)*this.#Pn,(s-i)*this.#Tn);if(o<this.#Uc||h<this.#Uc)return null;const a=[(n-t)*this.#Pn/o,(r-i)*this.#Tn/o,(e-t)*this.#Pn/h,(s-i)*this.#Tn/h,0,0],c=gt.inverseTransform(a),l=document.createElement("canvas");return l.className="textLayerImagePlaceholder",l.width=0,l.height=0,Object.assign(l.style,{opacity:0,position:"absolute",left:$n(t),top:$n(i),width:$n(o/this.#Pn),height:$n(h/this.#Tn),transformOrigin:"0% 0%",transform:`matrix(${a.join(",")})`}),this.#Bc.set(l,{inverseTransform:c,width:o,height:h,x1:t,y1:i}),l}}globalThis._pdfjsTestingUtils={HighlightOutliner:yn},globalThis.pdfjsLib={AbortException:dt,AnnotationEditorLayer:Ln,AnnotationEditorParamsType:W,AnnotationEditorType:H,AnnotationEditorUIManager:ai,AnnotationLayer:gn,AnnotationMode:j,AnnotationType:V,applyOpacity:function(t,i){const e=255*(1-(i=Mt(i??1,0,1)));return t.map((t=>Math.round(t*i+e)))},build:"7e5b36c2d",ColorPicker:Is,createValidAbsoluteUrl:et,CSSConstants:class{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:i}=t;i.width=i.height="0",i.display="none",i.color="var(--comment-fg-color)",document.body.append(t);const{color:e}=window.getComputedStyle(t);return t.remove(),rt(this,"commentForegroundColor",Ut(e))}},DOMSVGFactory:Bs,DrawLayer:Un,FeatureTest:pt,fetchData:Tt,findContrastColor:function(t,i){const e=t[0]+256*t[1]+65536*t[2]+16777216*i[0]+4294967296*i[1]+1099511627776*i[2];let s=Qt.get(e);if(s)return s;const n=new Float32Array(9),r=n.subarray(0,3),o=n.subarray(3,6);Vt(t,o);const h=n.subarray(6,9);Vt(i,h);const a=h[2]<.5,c=a?12:4.5;if(o[2]=a?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),qt(o,h,r)<c){let t,i;a?(t=o[2],i=1):(t=0,i=o[2]);const e=.005;for(;i-t>e;){const e=o[2]=(t+i)/2;a===qt(o,h,r)<c?t=e:i=e}o[2]=a?i:t}return Yt(o,r),s=gt.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2])),Qt.set(e,s),s},getDocument:xs,getFilenameFromUrl:function(t){return[t]=t.split(/[#?]/,1),nt(t)},getPdfFilenameFromUrl:function(t,i="document.pdf"){if("string"!=typeof t)return i;if(It(t))return Z('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),i;const e=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!e)return i;const s=t=>{try{let i=decodeURIComponent(t);return i.includes("/")&&(i=nt(i),/^\.pdf$/i.test(i))?t:i}catch{return t}},n=/\.pdf$/i,r=nt(e.pathname);if(n.test(r))return s(r);if(e.searchParams.size>0){const t=t=>[...t].findLast((t=>n.test(t))),i=t(e.searchParams.values())??t(e.searchParams.keys());if(i)return s(i)}if(e.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(e.hash);if(t)return s(t[0])}return i},getRGB:Ut,getRGBA:Lt,getUuid:At,getXfaPageViewport:function(t,{scale:i=1,rotation:e=0}){const{width:s,height:n}=t.attributes.style;return new Pt({viewBox:[0,0,parseInt(s,10),parseInt(n,10)],userUnit:1,scale:i,rotation:e})},GlobalWorkerOptions:ds,ImageKind:G,InvalidPDFException:ct,isDataScheme:It,isPdfFile:Rt,isValidExplicitDest:Ji,makeArr:bt,makeMap:yt,makeObj:xt,MathClamp:Mt,noContextMenu:_t,normalizeUnicode:function(t){return mt||(mt=/([\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,wt=new Map([["ſt","ſt"]])),t.replaceAll(mt,((t,i,e)=>i?i.normalize("NFKC"):wt.get(e)))},OPS:X,OutputScale:Ht,PasswordResponses:{NEED_PASSWORD:1,INCORRECT_PASSWORD:2},PDFDataRangeTransport:Ss,PDFDateString:Bt,PDFWorker:ks,PermissionFlag:{PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},PixelsPerInch:kt,RenderingCancelledException:Dt,renderRichText:Kt,ResponseException:lt,setLayerDimensions:zt,shadow:rt,SignatureExtractor:Nn,stopEvent:Ft,SupportedImageMimeTypes:Wt,TextLayer:ys,TextLayerImages:jn,TouchManager:ui,updateUrlHash:st,Util:gt,VerbosityLevel:Y,version:"5.7.284",XfaLayer:Ct},function(t){!function(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+i+" is not a constructor or null");function e(){this.constructor=t}h(t,i),t.prototype=null===i?Object.create(i):(e.prototype=i.prototype,new e)}((function i(e){var s=t.call(this,"Validation error mapping object.")||this;return s.errors=e,Object.setPrototypeOf(s,i.prototype),s}),t)}(Error);var zn=function(){function t(){this.listeners=[]}return t.prototype.on=function(t,i){var e,s=this;void 0===i&&(i={}),this.listeners.push(t);var n=new AbortController;return n.signal.addEventListener("abort",(function(){return s.off(t)})),null===(e=i.abort)||void 0===e||e.addEventListener("abort",(function(){return n.abort()})),{dispose:function(){return n.abort()}}},t.prototype.once=function(t){var i=this;return void 0===t&&(t={}),new Promise((function(e){var s=i.on((function(t){s.dispose(),e(t)}),t)}))},t.prototype.onceWhen=function(t){return function(t,i,e,s){return new(e||(e=Promise))((function(n,r){function o(t){try{a(s.next(t))}catch(t){r(t)}}function h(t){try{a(s.throw(t))}catch(t){r(t)}}function a(t){t.done?n(t.value):function(t){return t instanceof e?t:new e((function(i){i(t)}))}(t.value).then(o,h)}a((s=s.apply(t,i||[])).next())}))}(this,arguments,Promise,(function(t,i){var e,s,n=this;return void 0===i&&(i={}),function(t,i){var e,s,n,r={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=h(0),o.throw=h(1),o.return=h(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function h(h){return function(a){return function(h){if(e)throw new TypeError("Generator is already executing.");for(;o&&(o=0,h[0]&&(r=0)),r;)try{if(e=1,s&&(n=2&h[0]?s.return:h[0]?s.throw||((n=s.return)&&n.call(s),0):s.next)&&!(n=n.call(s,h[1])).done)return n;switch(s=0,n&&(h=[2&h[0],n.value]),h[0]){case 0:case 1:n=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,s=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(!((n=(n=r.trys).length>0&&n[n.length-1])||6!==h[0]&&2!==h[0])){r=0;continue}if(3===h[0]&&(!n||h[1]>n[0]&&h[1]<n[3])){r.label=h[1];break}if(6===h[0]&&r.label<n[1]){r.label=n[1],n=h;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(h);break}n[2]&&r.ops.pop(),r.trys.pop();continue}h=i.call(t,r)}catch(t){h=[6,t],s=0}finally{e=n=0}if(5&h[0])throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}([h,a])}}}(this,(function(){return e=new AbortController,null===(s=i.abort)||void 0===s||s.addEventListener("abort",(function(){return e.abort()})),[2,new Promise((function(s){n.when(t,(function(i){t(i)&&(e.abort(),s(i))}),a(a({},i),{abort:e.signal}))}))]}))}))},t.prototype.when=function(t,i,e){return void 0===e&&(e={}),this.on((function(e){t(e)&&i(e)}),e)},t.prototype.off=function(t){var i=this.listeners.indexOf(t);-1!==i&&this.listeners.splice(i,1)},t.prototype.emit=function(t){this.listeners.forEach((function(i){return i(t)}))},t}();class Hn{constructor(t){this.defaultState=t,this.stateChanged=new zn,this.state=t}updateState(t){this.state={...this.defaultState,...this.state,...t},this.stateChanged.emit(this.state)}onStateChanged(t){return this.stateChanged.on(t)}async updateViewport(t){null!=this.state.viewport&&E.isEqual(this.state.viewport,t)||this.updateState({viewport:t})}async panByDelta(t){const i=this.constrainPanOffset(m.add(this.state.panOffset,t),this.state.zoomPercentage);this.updateState({panOffset:i})}async zoomTo(t){const{viewport:i,zoomPercentage:e,panOffset:s}=this.state;if(null==i)throw Error("Viewport is not defined. Unable to perform zoom operation.");{const n=Math.min(Math.max(10,t),600),r=n/e,o=m.add(m.scaleProportional(E.center(i),1-r),m.scaleProportional(s,r)),h=this.constrainPanOffset(o,n);this.updateState({zoomPercentage:n,panOffset:h})}}constrainPanOffset(t,i){const{viewport:e,contentDimensions:s}=this.state;if(null!=e&&null!=s){const n=E.scale(window.devicePixelRatio,window.devicePixelRatio,e),r=Math.min(n.width/s.width,n.height/s.height),o=s.height*r*(i/100),h=Math.min(0,n.width-s.width*r*(i/100)),a=Math.min(0,n.height-o),c=0;return m.create(Math.max(h,Math.min(0,t.x)),Math.max(a,Math.min(c,t.y)))}return t}}class Wn extends Hn{constructor(t){var i;super({panOffset:m.create(0,0),zoomPercentage:100}),this.config=t,ds.workerSrc=null!==(i=null==t?void 0:t.pdfJs.workerSrc)&&void 0!==i?i:"./assets/pdf.worker.min.mjs"}dispose(){var t;null===(t=this.state.document)||void 0===t||t.destroy()}async load(t){const i=function(t){if(t.startsWith("http"))return function(t){return{resource:{type:"url",url:t}}}(t);throw Error("Invalid URI. Provided URI must be a valid URL or URN.")}(t);if("url"!==i.resource.type)throw Error("Invalid resource URI provided. Expected a URL to retrieve a PDF.");{const t=await xs(i.resource.url).promise,e=await t.getOptionalContentConfig();this.updateState({document:t,totalPageCount:t.numPages,optionalContentConfig:e,layers:Array.from(e).map((([t,i])=>{var e;return{id:t,name:null!==(e=i.name)&&void 0!==e?e:t,visible:i.visible}}))})}}async loadPage(t){var i,e;const s=null!==(i=this.state.totalPageCount)&&void 0!==i?i:1;if(t<=0)throw Error(`Unable to load page ${t}. The provided page number must be greater than 0.`);if(t>s)throw Error(`Unable to load page ${t}. The document only has ${s} page(s).`);const n=await(null===(e=this.state.document)||void 0===e?void 0:e.getPage(t)),r=null==n?void 0:n.getViewport({scale:1}),o=null!=r?E.create(r.width,r.height):void 0;this.updateState({loadedPageNumber:t,contentDimensions:o,panOffset:m.create(0,0)})}getLayers(){var t;return null!==(t=this.state.layers)&&void 0!==t?t:[]}setLayerVisibility(t,i){const{optionalContentConfig:e}=this.state;if(null==e)throw Error("No document has been loaded. Unable to set layer visibility.");e.setVisibility(t,i),this.updateState({optionalContentConfig:e,layers:Array.from(e).map((([t,i])=>{var e;return{id:t,name:null!==(e=i.name)&&void 0!==e?e:t,visible:i.visible}}))})}}class Gn{constructor(t,i){this.api=t,this.canvas=i,this.pageLoaded=new zn,this.pageDrawn=new zn}onPageLoaded(t){return this.pageLoaded.on(t)}onPageDrawn(t){return this.pageDrawn.on(t)}}class Vn extends Gn{constructor(t,i){super(t,i),this.state={pages:{},rendering:!1},this.offscreenCanvas=document.createElement("canvas"),this.handleStateChanged=this.handleStateChanged.bind(this),this.stateChangedDisposable=this.api.onStateChanged(this.handleStateChanged)}dispose(){this.stateChangedDisposable.dispose()}async handleStateChanged(t){await this.renderPage(t)}async renderPage(t){const{document:i,loadedPageNumber:e,viewport:s,panOffset:n,zoomPercentage:r,optionalContentConfig:o}=t;if(this.state.rendering)this.state.pendingStateChange=t;else if(null!=i&&null!=e){this.state.rendering=!0,null==this.state.pages[e]&&(this.state.pages[e]=await i.getPage(e));const h=this.state.pages[e],a=null!=s?s:E.create(0,0),c=E.scale(window.devicePixelRatio,window.devicePixelRatio,a),l=h.getViewport({scale:1}),u=Math.max(.1,Math.min(c.width/l.width,c.height/l.height))*(r/100),d=h.getViewport({scale:u,offsetX:n.x+Math.max(0,(c.width-l.width*u)/2),offsetY:n.y});this.offscreenCanvas.width=this.canvas.width,this.offscreenCanvas.height=this.canvas.height,await h.render({canvas:this.offscreenCanvas,viewport:d,intent:"display",optionalContentConfigPromise:null!=o?Promise.resolve(o):void 0}).promise,this.pageLoaded.emit(t),await new Promise((t=>{window.requestAnimationFrame((()=>{const i=this.canvas.getContext("2d");null!=i&&(i.clearRect(0,0,this.canvas.width,this.canvas.height),i.drawImage(this.offscreenCanvas,0,0)),t()}))})),this.pageDrawn.emit(t),this.state.rendering=!1}}}class Yn{create(t,i){const e=new Wn(i);return{api:e,renderer:new Vn(e,t)}}}const Xn=i(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.documentReady=s(this,"documentReady"),this.documentStateChanged=s(this,"documentStateChanged"),this.pageLoaded=s(this,"pageLoaded"),this.pageDrawn=s(this,"pageDrawn"),this.provider=new Yn,this.interactionMode="pan",this.resizeDebounce=100,this.dimensions=E.create(0,0),this.interactionHandlers=[]}componentWillLoad(){this.handleElementResize=this.handleElementResize.bind(this),this.handleDocumentApiStateChanged=this.handleDocumentApiStateChanged.bind(this),this.handlePageLoaded=this.handlePageLoaded.bind(this),this.handlePageDrawn=this.handlePageDrawn.bind(this),this.resizeObserver=new ResizeObserver(this.handleElementResize),this.registerSlotChangeListeners()}componentShouldUpdate(t,i,e){return"documentState"!==e}componentDidLoad(){var t;null===(t=this.resizeObserver)||void 0===t||t.observe(this.hostEl),this.updateComponentDimensions(),this.handleSrcChange(),this.injectViewerApi()}disconnectedCallback(){var t;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),this.clearCurrentDocument()}async registerBasicInteractionHandler(t){return this.interactionHandlers.push(t),this.initializeInteractionHandler(t),{dispose:()=>{const i=this.interactionHandlers.indexOf(t);-1!==i&&(this.interactionHandlers[i].dispose(),this.interactionHandlers.splice(i,1))}}}async panByDelta(t){await this.getDocumentApi().panByDelta(t)}async zoomTo(t){await this.getDocumentApi().zoomTo(t)}async loadPage(t){const i=this.getDocumentApi();await i.loadPage(t)}async handleSrcChange(){if(null!=this.src&&null!=this.canvasEl){this.clearCurrentDocument();const{api:t,renderer:i}=this.provider.create(this.canvasEl,this.config);this.documentApi=t,this.documentRenderer=i,this.layers=new D(t),this.updateInteractionHandler(),this.updateDocumentApiListeners(),await this.documentApi.updateViewport(this.dimensions),await this.documentApi.load(this.src),await this.documentApi.loadPage(1),this.documentReady.emit()}}handleConfigChange(){this.clearCurrentDocument(),this.handleSrcChange()}handleInteractionModeChange(){this.updateInteractionHandler()}render(){return n(r,{key:"f1ddf0b4e321bc244a5d757e48f6d71c23caca3c"},n("div",{key:"174c64c537f4b0f1c45fc6543e5b7f54515e4063",ref:t=>this.viewerContainerElement=t,class:"viewer-container",onContextMenu:t=>t.preventDefault()},n("div",{key:"4c47dadba03b32bde017252a9a8ea7f6e6d323f3",ref:t=>this.canvasContainerElement=t,class:P("canvas-container",{"enable-pointer-events ":null!=window.PointerEvent})},n("canvas",{key:"b8697a0a5be45d212b16b3bd4b7b50a70c0a1143",role:"presentation",ref:t=>this.canvasEl=t})),n("slot",{key:"c9ec02fd4bfaa251d8fc742fc868b0d91ee70618"})))}getDocumentApi(){if(null==this.documentApi)throw Error("No document has been loaded. Ensure that the `src` property is set and the resource is accessible.");return this.documentApi}clearCurrentDocument(){var t,i,e,s,n,r;null===(t=this.documentRenderer)||void 0===t||t.dispose(),null===(i=this.documentApi)||void 0===i||i.dispose(),null===(e=this.panInteractionHandler)||void 0===e||e.dispose(),null===(s=this.documentApiStateChangedDisposable)||void 0===s||s.dispose(),null===(n=this.pageLoadedDisposable)||void 0===n||n.dispose(),null===(r=this.pageDrawnDisposable)||void 0===r||r.dispose(),this.layers=void 0}handleDocumentApiStateChanged(t){this.documentState=t,this.documentStateChanged.emit(t)}handlePageLoaded(t){this.pageLoaded.emit(t)}handlePageDrawn(t){this.pageDrawn.emit(t)}updateDocumentApiListeners(){var t,i,e;this.documentApiStateChangedDisposable=null===(t=this.documentApi)||void 0===t?void 0:t.onStateChanged(this.handleDocumentApiStateChanged),this.pageLoadedDisposable=null===(i=this.documentRenderer)||void 0===i?void 0:i.onPageLoaded(this.handlePageLoaded),this.pageDrawnDisposable=null===(e=this.documentRenderer)||void 0===e?void 0:e.onPageDrawn(this.handlePageDrawn)}updateInteractionHandler(){var t;null===(t=this.panInteractionHandler)||void 0===t||t.dispose(),"pan"===this.interactionMode&&null!=this.canvasEl&&null!=this.documentApi&&(this.panInteractionHandler=new R(this.canvasEl,this.hostEl,this.documentApi))}updateComponentDimensions(t){this.dimensions=null!=t?t:function(t){return t.getBoundingClientRect()}(this.hostEl),null!=this.canvasEl&&(this.canvasEl.width=Math.floor(this.dimensions.width*window.devicePixelRatio),this.canvasEl.height=Math.floor(this.dimensions.height*window.devicePixelRatio),this.canvasEl.style.width=this.dimensions.width+"px",this.canvasEl.style.height=this.dimensions.height+"px")}async handleElementResize(t){t.length>0&&null!=this.dimensions&&!E.isEqual(t[0].contentRect,this.dimensions)&&this.restartResizeTimer(E.create(t[0].contentRect.width,t[0].contentRect.height))}restartResizeTimer(t){null!=this.resizeTimer&&window.clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout((async()=>{var i;this.updateComponentDimensions(t),await(null===(i=this.documentApi)||void 0===i?void 0:i.updateViewport(this.dimensions))}),this.resizeDebounce)}initializeInteractionHandler(t){if(null==this.canvasEl)throw Error("Cannot initialize interaction handler");t.initialize(this.canvasEl)}registerSlotChangeListeners(){this.mutationObserver=new MutationObserver((()=>this.injectViewerApi())),this.mutationObserver.observe(this.hostEl,{childList:!0,subtree:!0})}injectViewerApi(){(function(t){return I(t).filter((t=>t.nodeName.startsWith("VERTEX-"))).reduce(((t,i)=>[...t,i,...I(i)]),[])})(this.hostEl).forEach((t=>{t.viewer=this.hostEl}))}get hostEl(){return this}static get watchers(){return{src:[{handleSrcChange:0}],config:[{handleConfigChange:0}],interactionMode:[{handleInteractionModeChange:0}]}}static get style(){return":host{display:block;position:relative;width:300px;height:300px;min-width:1px;min-height:1px;user-select:none;-webkit-user-select:none}.viewer-container{width:100%;height:100%;overflow:hidden}.canvas-container{display:flex;justify-content:center;align-items:center;width:100%;height:100%;position:relative}"}},[257,"vertex-document-viewer",{src:[1],documentId:[513,"document-id"],provider:[1040],interactionMode:[1,"interaction-mode"],documentState:[1040],layers:[1040],config:[16],resizeDebounce:[2,"resize-debounce"],registerBasicInteractionHandler:[64],panByDelta:[64],zoomTo:[64],loadPage:[64]},void 0,{src:[{handleSrcChange:0}],config:[{handleConfigChange:0}],interactionMode:[{handleInteractionModeChange:0}]}]);function qn(){"undefined"!=typeof customElements&&["vertex-document-viewer"].forEach((i=>{"vertex-document-viewer"===i&&(customElements.get(t(i))||customElements.define(t(i),Xn))}))}qn();const Qn=Xn,Kn=qn;export{Qn as VertexDocumentViewer,Kn as defineCustomElement}
|