@vertexvis/doc-viewer 0.24.5-canary.8 → 1.0.0-testing.6
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 +2 -2
- package/dist/cjs/{index-DY-_Uhw6.js → index-UmtQ5Ckn.js} +36 -9
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/vertex-document-viewer.cjs.entry.js +5671 -5139
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/p-qzDSS9cP.js +4 -0
- package/dist/components/vertex-document-viewer.js +2 -16
- package/dist/doc-viewer/doc-viewer.esm.js +1 -1
- package/dist/doc-viewer/p-CZJPiyR_.js +5 -0
- package/dist/doc-viewer/p-e5411da0.entry.js +25 -0
- package/dist/esm/doc-viewer.js +3 -3
- package/dist/esm/{index-Ct6uMP9a.js → index-CZJPiyR_.js} +36 -9
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/loader.mjs +13 -0
- package/dist/esm/vertex-document-viewer.entry.js +5671 -5139
- package/dist/index.cjs +1 -0
- package/dist/types/lib/interactions/pan-interaction-handler.d.ts +2 -2
- package/package.json +16 -14
- package/dist/components/p-DRNDkVQa.js +0 -4
- package/dist/doc-viewer/p-Ct6uMP9a.js +0 -5
- package/dist/doc-viewer/p-b8e2846a.entry.js +0 -39
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Vertex Software LLC. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import{r as t,c as e,h as i,H as s,a as n}from"./p-CZJPiyR_.js";function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},o(t,e)},h=function(){return h=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},h.apply(this,arguments)};function a(t,e,i){return(i=Math.max(0,Math.min(1,i)))*(e-t)+t}function c(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),{x:t,y:e}}function l(t,e){return{x:t.x-e.x,y:t.y-e.y}}function u(t,e){return{x:t.x*e,y:t.y*e}}function d(t){return Math.sqrt(t.x*t.x+t.y*t.y)}function f(t){var e=d(t);return 0===e?c(0,0):u(t,1/e)}function p(t,e){return f(l(e,t))}"function"==typeof SuppressedError&&SuppressedError;var g=Object.freeze({__proto__:null,create:c,polar:function(t,e){return c(Math.cos(e)*t,Math.sin(e)*t)},distance:function(t,e){var i=l(t,e);return Math.sqrt(i.x*i.x+i.y*i.y)},subtract:l,add:function(t,e){return{x:t.x+e.x,y:t.y+e.y}},isEqual:function(t,e){return t.x===e.x&&t.y===e.y},lerp:function(t,e,i){return{x:a(t.x,e.x,i),y:a(t.y,e.y,i)}},negate:function(t){return c(-t.x,-t.y)},scale:function(t,e,i){return{x:t.x*e,y:t.y*i}},scaleProportional:u,magnitude:d,normalizeVector:f,normalDirectionVector:p,orthogonalVector:function(t,e){var i=p(t,e);return 0===i.x||0===i.y?c(-1*i.y,i.x):Math.abs(i.x)>Math.abs(i.y)?f(c(1-Math.pow(i.x,2),-1*i.x*i.y)):f(c(-1*i.x*i.y,1-Math.pow(i.y,2)))},fromJson:function(t){var e=JSON.parse(t);return Array.isArray(e)?c(e[0],e[1]):c(e.x,e.y)}});function m(t,e){return{x:t.x,y:t.y,width:e.width,height:e.height}}function w(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}var A=function(t,e){return{width:t,height:e}},v=function(t,e,i){return{width:i.width*t,height:i.height*e}},b=function(t,e){return v(t,t,e)},y=function(t){return{width:Math.floor(t.width),height:Math.floor(t.height)}},x=function(t){return{x:t.width/2,y:t.height/2}};function M(t,e){return void 0===e&&(e=c()),m(e,t)}var S,C,E=Object.freeze({__proto__:null,create:A,square:function(t){return A(t,t)},isEqual:function(t,e){return t.width===e.width&&t.height===e.height},scale:v,proportionalScale:b,trim:function(t,e){return{width:Math.min(t.width,e.width),height:Math.min(t.height,e.height)}},containFit:function(t,e){var i=function(t,e){var i=Math.min(t.width/e.width,t.height/e.height),s=b(i,e);return m(l(w(t),x(s)),s)}(M(t),M(e));return{width:i.width,height:i.height}},cropFit:function(t,e){var i=function(t,e){var i=Math.max(t.width/e.width,t.height/e.height),s=b(i,e);return m(l(w(t),x(s)),s)}(M(t),M(e));return{width:i.width,height:i.height}},scaleFit:function(t,e){var i=function(t,e){var i=Math.min(Math.sqrt(t/function(t){return t.width*t.height}(e)),1),s=y(b(i,e));return m(l(w(e),x(s)),s)}(t,M(e));return{width:i.width,height:i.height}},round:function(t){return{width:Math.round(t.width),height:Math.round(t.height)}},floor:y,center:x,aspectRatio:function(t){return t.width/t.height},area:function(t){return t.width*t.height},fitToRatio:function(t,e){return e.width>=e.height*t?A(e.height*t,e.height):A(e.width,e.width/t)},toRectangle:M}),k={exports:{}},T=(S||(S=1,C=k,function(){var t={}.hasOwnProperty;function e(){for(var t="",e=0;e<arguments.length;e++){var n=arguments[e];n&&(t=s(t,i(n)))}return t}function i(i){if("string"==typeof i||"number"==typeof i)return i;if("object"!=typeof i)return"";if(Array.isArray(i))return e.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var n="";for(var r in i)t.call(i,r)&&i[r]&&(n=s(n,r));return n}function s(t,e){return e?t?t+" "+e:t+e:t}C.exports?(e.default=e,C.exports=e):window.classNames=e}()),k.exports),P=r(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,e){return this.getApi().setLayerVisibility(t,e)}getApi(){if(null==this.api)throw new Error("The current document does not support layers.");return this.api}}class I{constructor(t,e){this.element=t,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),window.addEventListener("wheel",this.handleWheel)}dispose(){this.element.removeEventListener("pointerdown",this.handlePointerDown),this.element.removeEventListener("wheel",this.handleWheel),this.removeWindowListeners()}handleWheel(t){t.preventDefault();const e=-t.deltaX/2,i=-t.deltaY/2;0===e&&0===i||this.api.panByDelta(g.create(e,i))}handlePointerDown(t){0===t.button&&(t.preventDefault(),this.downPosition=g.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 e=g.create(t.clientX,t.clientY);if(!this.isDragging&&g.distance(e,this.downPosition)<2)return;this.isDragging=!0;const i=g.subtract(e,this.lastPosition);this.lastPosition=e,this.api.panByDelta(i)}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),window.removeEventListener("wheel",this.handleWheel)}}
|
|
5
|
+
/**
|
|
6
|
+
* @licstart The following is the entire license notice for the
|
|
7
|
+
* JavaScript code in this page
|
|
8
|
+
*
|
|
9
|
+
* Copyright 2024 Mozilla Foundation
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*
|
|
23
|
+
* @licend The above is the entire license notice for the
|
|
24
|
+
* JavaScript code in this page
|
|
25
|
+
*/var R={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,R=a.TypeError,N=b("toStringTag"),_=y("TYPED_ARRAY_TAG"),O="TypedArrayConstructor",F=o&&!!v&&"Opera"!==d(a.opera),B=!1,$={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},L={BigInt64Array:8,BigUint64Array:8},U=function(t){var e=A(t);if(l(e)){var i=S(e);return i&&u(i,O)?i[O]:U(e)}},j=function(t){if(!l(t))return!1;var e=d(t);return u($,e)||u(L,e)};for(s in $)(r=(n=a[s])&&n.prototype)?M(r)[O]=n:F=!1;for(s in L)(r=(n=a[s])&&n.prototype)&&(M(r)[O]=n);if((!F||!c(P)||P===Function.prototype)&&(P=function(){throw new R("Incorrect invocation")},F))for(s in $)a[s]&&v(a[s],P);if((!F||!D||D===I)&&(D=P.prototype,F))for(s in $)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[_]:void 0}}),$)a[s]&&p(a[s].prototype,_,s);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:F,TYPED_ARRAY_TAG:B&&_,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,e,i,s){if(h){if(i)for(var n in $){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 $)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 $)!(n=a[s])||n[t]&&!i||g(n,t,e)}},getTypedArrayConstructor:U,isView:function(t){if(!l(t))return!1;var e=d(t);return"DataView"===e||u($,e)||u(L,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?String(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=String(new n("zxcasd").stack),h=/\n\s*at [^:]*:[^\n]*/,a=h.test(o);t.exports=function(t,e){if(a&&"string"==typeof t&&!n.prepareStackTrace)for(;e--;)t=r(t,h,"");return t}},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&&"something"===function(){}.name,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?n(i=s[t])?i:void 0:s[t]&&s[t][e];var i}},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 String(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(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){}var t,e,i;w="undefined"!=typeof document?document.domain&&s?m(s):(e=c("iframe"),i="java"+d+":",e.style.display="none",a.appendChild(e),e.src=String(i),(t=e.contentWindow.document).open(),t.write(g("document.F=Object")),t.close(),t.F):m(s);for(var n=o.length;n--;)delete w[u][o[n]];return w()};h[f]=!0,t.exports=Object.create||function(t,e){var i;return null!==t?(p[u]=n(t),i=new p,p[u]=null,i[f]=t):i=w(),void 0===e?i:r.f(i,e)}},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 new Error("e")}}};t.exports=function(t,e){var i=s("Set");try{(new i)[t](n(0));try{return(new i)[t](n(-1)),!1}catch(s){if(!e)return!0;try{return(new i)[t](r(-1/0)),!1}catch(s){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="[object z]"===String(s)},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")||"a=1"!==String(new URLSearchParams("?a=1"))||!e[h]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==s||"x"!==new URL("https://x",void 0).host}))},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(String(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!Array(1).includes()})),a=r((function(){return[,1].includes(void 0,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-]$/,R=/^[\t\n\r ]$/,N=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++)_(f,h,N(f,""+h,i,h<n?A[h]:void 0));else for(r=M(f),o=p(r),h=0;h<o;h++)_(f,c=r[h],N(f,c,i,d(A,c)?A[c]:void 0))}return a(i,t,e,f,m)},_=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)},O=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(R,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 O(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(R,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(R,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(R,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})),$=A&&!m((function(){return 1/x("-0 \t")!=-1/0}));s({target:"JSON",stat:!0,forced:B},{parse:function(t,e){return $&&!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(R,s.end);if(r<t.length)throw new y('Unexpected extra character: "'+C(t,r)+'" after the parsed data at: '+r);return c(e)?N({"":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]$/,R=w(),N=R.length,_=!A||a((function(){var t=n("Symbol")("stringify detection");return"[null]"!==y([t])||"{}"!==y({a:t})||"{}"!==y(Object(t))})),O=a((function(){return'"\\udf06\\ud834"'!==y("\udf06\ud834")||'"\\udead"'!==y("\udead")})),F=_?function(t,e){var i=g(arguments),s=$(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},$=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=$(e),n=[],r=F(t,(function(t,e){var i=l(s)?o(s,this,b(t),e):e;return!v&&u(i)?R+(k(n,i.rawJSON)-1):i}),i);if("string"!=typeof r)return r;if(O&&(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,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 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,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"3,2"!==String(Array.from(new Set([1,2,3]).intersection(new Set([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}}})}},N={};function _(t){var e=N[t];if(void 0!==e)return e.exports;var i=N[t]={exports:{}};return R[t].call(i.exports,i,i.exports,_),i.exports}_.d=(t,e)=>{for(var i in e)_.o(e,i)&&!_.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},_.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),_(4423),_(4114),_(6573),_(8100),_(7936),_(5367),_(2731),_(9577),_(6632),_(4226),_(9486),_(456),_(5781);const O=!("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),$=[.001,0,0,.001,0,0],L=1.35,U={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 new 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=decodeURIComponent(escape(t))}catch{}}const s=e?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s)?s:null}function 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=new 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=Math.min(n+i,e),o=t.subarray(n,r);s.push(String.fromCharCode.apply(null,o))}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}),_(8111),_(1701),_(4603),_(7566),_(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(Nt(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new 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(new 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 new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(u=-u,d=-d),0===c?(f=Math.abs(a-t[1])*i+n,p=Math.abs(h-t[0])*i+r,g=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(f=Math.abs(h-t[0])*i+n,p=Math.abs(a-t[1])*i+r,g=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[c*i,l*i,u*i,d*i,f-c*i*h-u*i*a,p-l*i*h-d*i*a],this.width=g,this.height=m}get rawDims(){const t=this.viewBox;return 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 Rt{#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 Nt(t,e){const i=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(i?.protocol??"")}function _t(t){t.preventDefault()}function Ot(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||=new 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 $t(t){const e=Bt(t);return e?e.slice(0,3):(J(`Not a valid color format: "${t}"`),[0,0,0])}function Lt(t){const{a:e,b:i,c:s,d:n,e:r,f:o}=t.getTransform();return[e,i,s,n,r,o]}function Ut(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}_(4972),_(4628),_(7642),_(8004),_(3853),_(5876),_(2475),_(5024),_(1698),_(8454),_(9452),_(4979),_(3579),_(3110),_(9314),_(1148),_(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",_t,{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,Ot(t)}#g(t){this.#o._focusEventsAllowed=!0,Ot(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",_t,{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",_t,{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",_t,{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;#R;#N=-1;constructor(t=128){this.#R=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.#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:e}=this.#D[this.#N];t(),e?.(),this.#I=!1,this.#N-=1}redo(){if(this.#N<this.#D.length-1){this.#N+=1,this.#I=!0;const{cmd:t,post:e}=this.#D[this.#N];t(),e?.(),this.#I=!1}}hasSomethingToUndo(){return-1!==this.#N}hasSomethingToRedo(){return this.#N<this.#D.length-1}cleanType(t){if(-1!==this.#N){for(let e=this.#N;e>=0;e--)if(this.#D[e].type!==t)return this.#D.splice(e+1,this.#N-e),void(this.#N=e);this.#D.length=0,this.#N=-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)))}}#_(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.#_(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||Ot(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,$t(s))}e.remove()}(t),nt(this,"_colors",t)}convert(t){const e=$t(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{#O=new AbortController;#F=null;#B=null;#$=new Map;#L=new Map;#U=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.#O.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.#Rt(),this.#Nt(),this.#_t(),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.#O?.abort(),this.#O=null,this._signal=null;for(const t of this.#L.values())t.destroy();this.#L.clear(),this.#$.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.#L.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.#L.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.#L.delete(t),this.#X===t&&(this.#X=0)}focusMainContainer(){this.#kt.focus()}findParent(t,e){for(const i of this.#L.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}#Ot({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.#L.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.toString(),a=this.#Ot(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.#Ot(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"))}#$t(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#vt&&(this.#ht?.hide(),this.#vt=null,this.#Lt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#vt)return;const i=this.#Ot(t).closest(".textLayer");if(i){if(this.#ht?.hide(),this.#vt=e,this.#Lt({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.#Ut("main_toolbar"))};window.addEventListener("pointerup",s,{signal:i}),window.addEventListener("blur",s,{signal:i})}else t?.toggleDrawing(!0),this.#Ut("main_toolbar")}}else this.#vt&&(this.#ht?.hide(),this.#vt=null,this.#Lt({hasSelectedText:!1}))}#Ut(t=""){this.#wt===z.HIGHLIGHT?this.highlightSelection(t):this.#Z&&this.#Bt()}#Rt(){document.addEventListener("selectionchange",this.#$t.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.#Ut("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()}#_t(){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.#_t(),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.#Ut("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.#U.get(t);i&&(i.pageIndex=e,this.#L.set(e,i),this.#ct?i.enable():i.disable())}startUpdatePages(){this.#U=new Map(this.#L),this.#L.clear()}endUpdatePages(){this.#U=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)}#Lt(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.#Lt({isEditing:this.#wt!==z.NONE,isEmpty:this.#qt(),hasSomethingToUndo:this.#W.hasSomethingToUndo(),hasSomethingToRedo:this.#W.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#zt(),this.#Gt(),this.#Lt({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.#L.get(this.#X)}getLayer(t){return this.#L.get(t)}get currentPageIndex(){return this.#X}addLayer(t){this.#L.set(t.pageIndex,t),this.#ct?t.enable():t.disable()}removeLayer(t){this.#L.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.#$.values())t.hideStandaloneCommentButton();return this._editorUndoBar?.hide(),this.toggleComment(null),void this.#Dt.resolve()}for(const t of this.#$.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.#L.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.#$.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.#$.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.#$.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.#L.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.#L.values())t.push(e.enable());await Promise.all(t);for(const t of this.#$.values())t.enable()}}#Qt(){if(this.unselectAll(),this.#ct){this.#ct=!1;for(const t of this.#L.values())t.disable();for(const t of this.#$.values())t.disable()}}*getEditors(t){for(const e of this.#$.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#$.get(t)}addEditor(t){this.#$.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.#$.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.#L.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.#Lt({hasSelectedEditor:this.hasSelection});this.#At.add(t),t.select(),this.#Xt(t.propertiesToUpdate),this.#Lt({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.#Lt({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.#Lt({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.#Lt({hasSomethingToUndo:this.#W.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#qt()}),this._editorUndoBar?.hide()}redo(){this.#W.redo(),this.#Lt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#W.hasSomethingToRedo(),isEmpty:this.#qt()})}addCommands(t){this.#W.add(t),this.#Lt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#qt()})}cleanUndoStack(t){this.#W.cleanType(t)}#qt(){if(0===this.#$.size)return!0;if(1===this.#$.size)for(const t of this.#$.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.#Lt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#At)t.commit();this.#Yt(this.#$.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.#Lt({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.#$.has(t.id)&&(t.translateInPage(s,n),t.translationDone())},undo:()=>{for(const t of r)this.#$.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.#$.has(t.id)){const n=this.#L.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",_t,{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",_t,{signal:i}),e&&(t.addEventListener("focusin",(t=>{this.#o._focusEventsAllowed=!1,Ot(t)}),{capture:!0,signal:i}),t.addEventListener("focusout",(t=>{this.#o._focusEventsAllowed=!0,Ot(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.#Re.bind(this),{passive:!1,signal:this.#Te})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/zt.pixelRatio}#Re(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&&(Ot(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.#Ne.bind(this),i);const s=this.#_e.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",Ot,i),e.addEventListener("pointermove",Ot,i),e.addEventListener("pointercancel",Ot,i),e.addEventListener("pointerup",Ot,i),this.#Se?.()}if(Ot(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}}#Ne(t){if(!this.#Pe||2!==t.touches.length)return;Ot(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)}#_e(t){t.touches.length>=2||(this.#Ie&&(this.#Ie.abort(),this.#Ie=null,this.#Ee?.()),this.#Pe&&(Ot(t),this.#Pe=null,this.#ye=!1))}destroy(){this.#De?.abort(),this.#De=null,this.#ke?.abort(),this.#ke=null}}class ue{#Oe=null;#Fe=null;#a=null;#c=null;#de=null;#Be=!1;#$e=null;#Le="";#Ue=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.#Ue)return;this.#Ue=document.createElement("div"),this.#Ue.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.#Ue.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",_t,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#Ue)}#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",Ot,{passive:!1,signal:r}),window.addEventListener("contextmenu",_t,{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}var E,k;if([x,M]=[d[0]*(E=x/i)+d[2]*(k=M/s),d[1]*E+d[3]*k],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 T=ue._round(o*S),P=ue._round(h*C);v=u(...p(T,P));const D=b-v[0],I=y-v[1];this.#Ye||=[this.x,this.y,this.width,this.height],this.width=T,this.height=P,this.x=D,this.y=I,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.#Oe&&(this.#a.data=this.#Oe,this.#Oe=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.#$e=null,this.#Ve=!1,this._uiManager.endDragSession()||this.#Ai(t),i&&this._onStopDragging()};e&&(this.#Je=t.clientX,this.#Ze=t.clientY,this.#$e=t.pointerId,this.#Le=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.#$e)return void Ot(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",Ot,r),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#Le&&(this.#ei||t.isPrimary)&&o(t),Ot(t)}),r));const h=t=>{this.#$e&&this.#$e!==t.pointerId?Ot(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 new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,o=n-i,h=r-s;switch(this.rotation){case 0:return[i,e-r,o,h];case 90:return[i,e-s,h,o];case 180:return[n,e-s,o,h];case 270:return[n,e-r,h,o];default:throw new Error("Invalid rotation")}}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.#Oe=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.#Ue.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.#Ue.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.#Ue.append(this.#Ue.firstElementChild);else if(n>s)for(let t=0;t<n-s;t++)this.#Ue.firstElementChild.before(this.#Ue.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.#Ue.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#vi(t){ue._resizerKeyboardManager.exec(this,t)}#bi(t){this.#Qe&&t.relatedTarget?.parentNode!==this.#Ue&&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.#Ue?.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 new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s);let o=0,h=0,a=this.h1,c=this.h2;const l=3432918353,u=461845907,d=11601,f=13715;for(let t=0;t<s;t++)1&t?(o=r[t],o=o*l&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:""})}}_(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]];#Ri=[-1/0,-1/0,1/0,1/0];#Ni=new Float64Array(F);_pendingBBoxIdx=-1;#_i;#Oi;#Fi;#Pi;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#_i=t.width,this.#Oi=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.#Ri}save(t){return this.#Ri={__proto__:this.#Ri},this._savesStack.push(t),this}restore(t,e){const i=Object.getPrototypeOf(this.#Ri);if(null===i)return this;this.#Ri=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.#Ni.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.#Ri,h);return a?(this.#Ri[0]=a[0],this.#Ri[1]=a[1],this.#Ri[2]=a[2],this.#Ri[3]=a[3]):(this.#Ri[0]=this.#Ri[1]=1/0,this.#Ri[2]=this.#Ri[3]=-1/0),this}recordBBox(t,e,i,s,n,r){const o=this.#Ri;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.#Ni),this;const a=F.slice();return pt.axialAlignedBoundingBox([i,n,s,r],h,a),this.#Ni[0]=xt(a[0],o[0],this.#Ni[0]),this.#Ni[1]=xt(a[1],o[1],this.#Ni[1]),this.#Ni[2]=xt(a[2],this.#Ni[2],o[2]),this.#Ni[3]=xt(a[3],this.#Ni[3],o[3]),this}recordFullPageBBox(t){return this.#Ni[0]=Math.max(0,this.#Ri[0]),this.#Ni[1]=Math.max(0,this.#Ri[1]),this.#Ni[2]=Math.min(this.#_i,this.#Ri[2]),this.#Ni[3]=Math.min(this.#Oi,this.#Ri[3]),this}recordOperation(t,e=!1,i){if(this._pendingBBoxIdx!==t)return this;const s=ye(256*this.#Ni[0]/this.#_i),n=ye(256*this.#Ni[1]/this.#Oi),r=xe(256*this.#Ni[2]/this.#_i),o=xe(256*this.#Ni[3]/this.#Oi);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.#Ri[0]=Math.max(this.#Ri[0],this.#Ni[0]),this.#Ri[1]=Math.max(this.#Ri[1],this.#Ni[1]),this.#Ri[2]=Math.min(this.#Ri[2],this.#Ni[2]),this.#Ri[3]=Math.min(this.#Ri[3],this.#Ni[3])),this}take(){return new Ce(this.#Pi,this.#Fi)}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,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{#$i={__proto__:null};#Li={__proto__:null,transform:[],moveText:[],sameLineText:[],[be]:[]};#Ui=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.#$i={__proto__:this.#$i},this.#Li={__proto__:this.#Li,transform:{__proto__:this.#Li.transform},moveText:{__proto__:this.#Li.moveText},sameLineText:{__proto__:this.#Li.sameLineText},[be]:{__proto__:this.#Li[be]}},this.#Gi.save(t),this}restore(t){this.#Gi.restore(t,this.#Wi);const e=Object.getPrototypeOf(this.#$i);return null===e||(this.#$i=e,this.#Li=Object.getPrototypeOf(this.#Li)),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.#$i[t]=e,this}recordIncrementalData(t,e){return this.#Li[t].push(e),this}resetIncrementalData(t,e){return this.#Li[t].length=0,this}recordNamedData(t,e){return this.#Ui.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#$i[t]=this.#Ui.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(be,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#$i&&this.recordFutureForcedDependency(e,this.#$i[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.#$i[t]}recordDependencies(t,e){const i=this.#ji,s=this.#$i,n=this.#Li;for(const t of e)t in this.#$i?i.add(s[t]):t in n&&n[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#Ui.has(e)&&this.#ji.add(this.#Ui.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 new 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 new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const De=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],Ie=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],Re=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],Ne=["filter","fillColor","fillAlpha"],_e=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],Oe=["transform"],Fe=["transform","fillColor"];class Be{#_i;#Oi;#Ki=4;#Ji=0;#Di=new Be.#Zi(6*this.#Ki);static#Zi=ft.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#_i=t.width,this.#Oi=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.#_i,r[1]/=this.#Oi,r[2]/=this.#_i,r[3]/=this.#Oi,r[4]/=this.#_i,r[5]/=this.#Oi,this.#Di.set(r,6*this.#Ji),this.#Ji++}take(){return this.#Di.subarray(0,6*this.#Ji)}}class $e{#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",O||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;var f;n<c.length&&(d=d-u+i(c+"XXX",n)|0),l=s(l,16,4,(f=d,String.fromCharCode(f>>24&255,f>>16&255,f>>8&255,255&f)));const p=`url(data:font/opentype;base64,${btoa(l)});`;this.insertRule(`@font-face {font-family:"${c}";src:${p}}`);const g=this._document.createElement("div");g.style.visibility="hidden",g.style.width=g.style.height="10px",g.style.position="absolute",g.style.top=g.style.left="0px";for(const e of[t.loadedName,c]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,g.append(t)}this._document.body.append(g),function t(e,i){if(++a>30)return 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,(()=>{g.remove(),e.complete()}))}}class Le{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 Ue{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<Ue.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=Math.floor(t/4),i=2*t%8,s=this.#ns.getUint8(e)>>i&3;return 0===s?void 0:2===s}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=new 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 new 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 new 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()}}_(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.toString())}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 new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else{if(2!==t.callback)throw new Error("Unexpected callback case");i.reject(ti(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then((function(e){n.postMessage({sourceName:i,targetName:s,callback:1,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:2,callbackId:t.callbackId,reason:ti(e)})}))}else t.streamId?this.#gs(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,o=this.targetName,h=this.comObj;return new ReadableStream({start:i=>{const a=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:a,pullCall:null,cancelCall:null,isClosed:!1},h.postMessage({sourceName:r,targetName:o,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),a.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,h.postMessage({sourceName:r,targetName:o,stream:6,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{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 new 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 new Error(`Ensure that the \`${t}\` API parameter is provided.`);const s=`${i}${e}`;return this._fetch(s,t).catch((()=>{throw new 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 new 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 new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.width=e,t.height=i}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){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}}_(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=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),r=new Array(256),o=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,r[t]=i[t]/255,o[t]=s[t]/255;return[n.join(","),r.join(","),o.join(",")]}#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=new Array(256);for(let t=0;t<=255;t++){const e=t/255;h[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const a=h.join(","),c=`g_${this.#xs}_hcm_filter`,l=n.filter=this.#Ps(c);this.#Ds(a,a,a,l),this.#Rs(l);const u=(t,e)=>{const i=r[t]/255,s=o[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#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.#Ns(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.#_s(o),t&&this.#Ns(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=new Array(256),n=(l-c)/i,r=t/255,o=(e-t)/(255*i);let h=0;for(let t=0;t<=i;t++){const e=Math.round(c+t*n),i=r+t*o;for(let t=h;t<=e;t++)s[t]=i;h=e+1}for(let t=h;t<256;t++)s[t]=s[h-1];return s.join(",")},p=`g_${this.#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)}#_s(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)}#Rs(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}#Os(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.#Os(n,"feFuncR",t),this.#Os(n,"feFuncG",e),this.#Os(n,"feFuncB",i)}#Ns(t,e){const i=this.#Ms.createElementNS(Ct,"feComponentTransfer");e.append(i),this.#Os(i,"feFuncA",t)}#Is(t){return this.#Es.style.color=t,$t(getComputedStyle(this.#Es).getPropertyValue("color"))}}if(O){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;#$s=null;#Ls=null;async#Us(){if(!globalThis.navigator?.gpu)return!1;try{const t=await navigator.gpu.requestAdapter();return!!t&&(this.#Ls=navigator.gpu.getPreferredCanvasFormat(),this.#Bs=await t.requestDevice(),!0)}catch{return!1}}init(){return this.#Fs||=this.#Us()}get isReady(){return null!==this.#Bs}loadMeshShader(){if(!this.#Bs||this.#$s)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.#$s=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.#Ls}]},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.#$s.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:g}}]}),w=new OffscreenCanvas(r,o),A=w.getContext("webgpu");A.configure({device:a,format:this.#Ls,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.#$s),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,Lt(t))||[0,0,0,0],o=Math.ceil(r[2]-r[0])||1,h=Math.ceil(r[3]-r[1])||1,a=e.canvasFactory.create(o,h),c=a.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-r[0],-r[1]),i=pt.transform(i,[1,0,0,1,r[0],r[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),gi(c,this._bbox),this.areConic()&&(c.fillStyle=this._createReversedGradient(c),c.fill()),c.fillStyle=this._createGradient(c),c.fill(),n=t.createPattern(a.canvas,"no-repeat"),e.canvasFactory.destroy(a);const l=new DOMMatrix(i);n.setTransform(l)}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,R,N,_,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,R=b-(b-M)*e,N=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,R=M-(M-E)*e,N=S-(S-k)*e}let e;e=t<p?0:t>A?1:(p-t)/(p-A),_=f-(f-w)*e,O=v-(v-C)*e,F=b-(b-E)*e,B=y-(y-k)*e;const i=Math.round(Math.min(D,_)),s=Math.round(Math.max(D,_));let n=u*t+4*i;for(let t=i;t<=s;t++)e=(D-t)/(D-_),e<0?e=0:e>1&&(e=1),l[n++]=I-(I-O)*e|0,l[n++]=R-(R-F)*e|0,l[n++]=N-(N-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(Lt(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,f=Math.ceil((s+e-r)/c)-1;return u<=l&&f<=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=Lt(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=Lt(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],Lt(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]=Lt(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=$;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 new 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 Ri(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 Ni=["butt","round","square"],_i=["miter","round","bevel"],Oi={},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(...Lt(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=Lt(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=Lt(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=Math.round(m-p)||1,v=Math.round(w-g)||1,b=this.canvasFactory.create(A,v),y=b.context,x=p,M=g;y.translate(-x,-M),y.transform(...d);let S=null;if(!l){const t=this._scaleImage(u.canvas,Ut(y));l=t.img,S=t.tmpCanvas,l!==u.canvas&&(this.canvasFactory.destroy(u),u=null),a&&o&&(a.set(c,l),S=null,u=null)}y.imageSmoothingEnabled=Ri(Lt(y),e.interpolate),Ei(y,l,0,0,l.width,l.height,0,0,s,n),S&&this.canvasFactory.destroy(S),u&&this.canvasFactory.destroy(u),y.globalCompositeOperation="source-in";const C=pt.transform(Ut(y),[1,0,0,1,-x,-M]);return y.fillStyle=o?r.getPattern(i,this,C,di,t):r,y.fillRect(0,0,s,n),a&&!o&&a.set(c,b.canvas),this.dependencyTracker?.recordDependencies(t,Fe),{canvas:b.canvas,canvasEntry:a&&!o?null:b,offsetX:Math.round(x),offsetY:Math.round(M)}}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=Ni[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=_i[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 new 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 new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,r,o){e.transform(t,i,s,n,r,o),this.__originalTransform(t,i,s,n,r,o)},t.setTransform=function(t,i,s,n,r,o){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 new 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,Lt(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,Ut(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,Lt(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,Ut(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,Ne).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Oi}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 new Error(`Can't find font for ${e}`);if(n.fontMatrix=s.fontMatrix||$,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:Lt(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,_e).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,Ut(r),di,t);w=Lt(r),r.restore(),r.fillStyle=e}if(y&&i.patternStroke){r.save();const e=i.strokeColor.getPattern(r,this,Ut(r),fi,t);A=Lt(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||$,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||Lt(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 new 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,Ut(i),pi,t);const n=Ut(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,Oe).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=Lt(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=Lt(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,Lt(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=Lt(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(Lt(this.ctx),Ci);const{viewportScale:t}=this,r=Math.ceil(n*this.outputScaleX*t),h=Math.ceil(o*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(r,h);const{canvas:a,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(e,a),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,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=Lt(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=Lt(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,Ut(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,Ut(n));n.imageSmoothingEnabled=Ri(Lt(n),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,n,0,i,-s,0).recordDependencies(t,Re).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=Lt(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 $i{#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 Li{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 Ui{_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 new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=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 new 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 new Error(`getArrayBuffer - unexpected data: ${t}`)}class Qi extends $i{_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 Li{_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 Ui{_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}_(116);class es extends $i{_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 Li{#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 Ui{#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 $i{#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="string"!=typeof(r=t.response)?r:dt(r).buffer;var r;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 Li{#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 Ui{#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 $i{constructor(t){super(t,cs,ls);const{url:e}=t;tt("file:"===e.protocol,"PDFNodeStream only supports file:// URLs.")}}class cs extends Li{_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 Ui{_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 new Error("Invalid `workerPort` type.");this.#tn=t}static get workerSrc(){return this.#en}static set workerSrc(t){if("string"!=typeof t)throw new 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=new 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 new 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 new 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;#Rn=0;#Nn=0;#_n=Object.create(null);#On=[];#Fn=null;#Bn=[];#$n=new WeakMap;#Ln=null;static#Un=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 new 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.#Nn=s.scale*zt.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.#Ln=[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.#_n=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.#_n,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.#Rn&&(e?.(),this.#Rn=s,jt(this.#In,{rotation:s})),i!==this.#Nn){e?.(),this.#Nn=i;const t={div:null,properties:null,ctx:bs.#Yn(this.#En)};for(const e of this.#Bn)t.properties=this.#$n.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.#On}#Vn(t){if(this.#Mn)return;this.#kn.ctx??=bs.#Yn(this.#En);const e=this.#Bn,i=this.#On;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.#Ln,t.transform);let n=Math.atan2(s[1],s[0]);const r=this.#_n[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.#$n.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.#Nn,t);const{width:h}=s.measureText(e.textContent);h>0&&n.setProperty("--scale-x",r*this.#Nn/h)}0!==i.angle&&n.setProperty("--rotate",`${i.angle}deg`)}static cleanup(){if(!(this.#Wn.size>0)){this.#Un.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.#Un.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.#Un.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(O){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 new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(O&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return dt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,o=!0===t.withCredentials,h=t.password??null,a=t.range instanceof 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:!O,y="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!O&&(ft.platform.isFirefox||!globalThis.chrome),x=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,M="boolean"==typeof t.disableFontFace?t.disableFontFace:O,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||(O?ci:ri),R=t.FilterFactory||(O?ai:hi),N=t.BinaryDataFactory||(O?li:si),_=!0===t.enableHWA,F=!0===t.enableWebGPU?ui.init():Promise.resolve(!1),B=!1!==t.useWasm,$=t.pagesMapper||new ms,L="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!O&&!M,U="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(N===si&&f&&p&&m&&w&&Nt(f,document.baseURI)&&Nt(m,document.baseURI)&&Nt(w,document.baseURI));q(u);const j={canvasFactory:new I({ownerDocument:E,enableHWA:_}),filterFactory:new R({docId:i,ownerDocument:E}),binaryDataFactory:U?null:new N({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:L,useWasm:B,useWorkerFetch:U,cMapUrl:f,cMapPacked:p,iccUrl:g,standardFontDataUrl:m,wasmUrl:w,hasGPU:!1}},H={ownerDocument:E,pdfBug:D,styleElement:null,enableHWA:_,loadingParams:{disableAutoFetch:P,enableXfa:C}};return Promise.all([l.promise,F]).then((function([,t]){if(e.destroyed)throw new Error("Loading aborted");if(l.destroyed)throw new 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 new Error("getDocument - expected either `data`, `range`, or `url` parameter.");{const t=function(t){return Nt(t)?Qi:O?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 new Error("Loading aborted");if(l.destroyed)throw new Error("Worker was destroyed");const s=new ei(i,t,l.port),n=new ks(s,e,u,H,j,$);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 Rt: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=U.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:new 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 new 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=U.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:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#Zn=!1,Promise.all(t)}cleanup(t=!1){this.#Zn=!0;const e=this.#er();return t&&e&&(this._stats&&=new Rt),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{O&&(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 new 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(new 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(new 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(new 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 new 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 new 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 $e({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=U.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 U.DISABLE:r+=64;break;case U.ENABLE:break;case U.ENABLE_FORMS:r+=16;break;case U.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(new 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 Le(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 new 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 new 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 new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new 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(new 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 new 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 new 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 new 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(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#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 new 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 new 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())))}}_(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.#Rr.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.#Nr();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#Nr(){const t=document.createElement("div"),e=this.#A._signal;t.addEventListener("contextmenu",_t,{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.#_r.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#Rr.bind(this),{signal:e}),t}#_r(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.#_r(e,t)}_moveToNext(t){this.#Or?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.#Or||this.#Ir(t),t.target.previousSibling?.focus()):this.#Or&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Or?this.#Cr.firstElementChild?.focus():this.#Ir(t)}_moveToEnd(t){this.#Or?this.#Cr.lastElementChild?.focus():this.#Ir(t)}#Rr(t){Ds._keyboardManager.exec(this,t)}#Ir(t){if(this.#Or)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.#Nr();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#Or(){return this.#Cr&&!this.#Cr.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#kr||(this.#Or?(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");if(h.type="color",o){h.setAttribute("alpha","");const t=pt.hexNums[Math.round(255*(r??1))];h.value=(n||"#000000")+t}else h.value=n||"#000000";return 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){if(!this.#Fr||!this.#Br)return;const e=pt.hexNums[Math.round(255*t)];this.#Fr.value=this.#o.color+e}destroy(){this.#Fr?.remove(),this.#Fr=null}hideDropdown(){}}function Rs(t){return Math.floor(255*xt(t,0,1)).toString(16).padStart(2,"0")}function Ns(t){return 255*xt(t,0,1)}_(531);class _s{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=Ns(t),t,t]}static G_HTML([t]){const e=Rs(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(Ns)}static RGB_HTML(t){return`#${t.map(Rs).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[Ns(1-Math.min(1,t+s)),Ns(1-Math.min(1,i+s)),Ns(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 Os{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){Z("Abstract method `_createSVG` called.")}}class Fs extends Os{_createSVG(t){return document.createElementNS(Ct,t)}}const Bs=new WeakSet,$s=60*(new Date).getTimezoneOffset()*1e3;class Ls{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 Us(t)}}}class Us{#$r=null;#Lr=!1;#Ur=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 Us._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.#Ur?.popup||this.popup)?.remove(),this.#Ur=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#$r||={rect:this.data.rect.slice(0)});const{rect:e,popup:i}=t;e&&this.#jr(e);let s=this.#Ur?.popup||this.popup;!s&&i?.text&&(this._createPopup(i),s=this.#Ur.popup),s&&(s.updateEdited(t),i?.deleted&&(s.remove(),this.#Ur=null,this.popup=null))}resetEdited(){this.#$r&&(this.#jr(this.#$r.rect),this.#Ur?.popup.resetEdited(),this.#$r=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.#Lr=!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]=_s[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:_s[`${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.#Lr){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.#Lr&&(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.#Ur=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.#Ur||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#Ur}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 Us{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 Us{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 Us{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 Us{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),e=Math.round(t/(L*i))||1;n=Math.min(i,r(t/e/L))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);n=Math.min(i,r(t/L))}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.toString().padStart(2,"0"))).join(":")}else e.value=new Date(t-$s).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.toString()}),i.target.value=h.userValue},formattedValue(i){const{formattedValue:s}=i.detail;h.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s);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=`${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 Us{constructor(t){const{data:e,elements:i,parent:s}=t,n=!!s._commentManager;if(super(t,{isRenderable:!n&&Us._hasPopupData(e)}),this.elements=i,n&&Us._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.#Rr.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;#N=null;#ao=null;#co=null;#be=null;#lo=null;#me=null;#uo=null;#$r=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}#Rr(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.#$r||={contentsObj:this.#to,richText:this.#me},t&&(this.#N=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.#$r&&(({contentsObj:this.#to,richText:this.#me}=this.#$r),this.#$r=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: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.#N=[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.#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 Zs extends Us{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 Us{#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 Us{#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 Us{#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 Us{#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 Us{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 Us{#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 Us{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 Us{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 Us{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 Us{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 Us{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 Us{#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.#Ro.bind(this)),this.#Io=i;const{isMac:s}=ft.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Ro()})),!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")}#Ro(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class pn{#No=null;#_o=null;#z=null;#Oo=new Map;#Fo=null;#Bo=null;#io=[];#$o=!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.#No=e,this.#_o=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.#Oo.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=Ls.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.#Oo.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}await this.#Lo();for(const t of n){const e=r.elements=s.get(t.id);r.data=t;const i=Ls.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.#Uo()}async#Lo(){if(0===this.#io.length)return;this.div.replaceChildren();const t=[];if(!this.#$o){this.#$o=!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.#No)for(const t of this.#io)this.#No.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=Ls.create(e);t.isRenderable&&(t.render(),t.contentElement.id=`${At}${i.id}`,this.#io.push(t))}await this.#Lo()}update({viewport:t}){const e=this.div;this.viewport=t,jt(e,{rotation:t.rotation}),this.#Uo(),e.hidden=!1}#Uo(){if(!this.#_o)return;const t=this.div;for(const[e,i]of this.#_o){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.#Oo.get(e);r&&(r._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),r._hasNoCanvas=!1):r.canvas=i)}this.#_o.clear()}getEditableAnnotations(){return this.#Oo.values()}getEditableAnnotation(t){return this.#Oo.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.#No?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(0!==t.length){for(const e of t)e.updateFakeAnnotationElement(this);this.#Lo()}}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)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#mh(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#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)}#Rh(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.#Rh(t);this.#kh.splice(i,0,[t,e])}#Dh([,t,e]){const i=this.#Rh(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.#Rh(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;#Nh;constructor(t,e,i,s){super(),this.#Nh=t,this.#Jo=e,this.firstPoint=i,this.lastPoint=s}toSVGPath(){const t=[];for(const e of this.#Nh){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.#Nh){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*o,i[n+1]=s-e[n+1]*h;r.push(i)}return r}get box(){return this.#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{#_h=null;#Oh=0;#Fh;#Bh=null;#r=null;#$h=null;#Lh=null;#Uh=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.#_h=t.anchorNode,this.#Oh=t.anchorOffset,this.#Lh=t.focusNode,this.#Uh=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.#$h=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.#$h;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.#$h=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.#$h.box,path:{d:this.#$h.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.#$h.box,e),path:{d:this.#$h.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.#$h;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.#$h.box,path:{d:this.#$h.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.#$h.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.#_h)return;const e=window.getSelection();t?e.setPosition(this.#_h,this.#Oh):e.setPosition(this.#Lh,this.#Uh)}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",Ot,{capture:!0,passive:!1,signal:l}),window.addEventListener("contextmenu",_t,{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",_t,{signal:f}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:f}),n.addEventListener("touchmove",(t=>{ee.isSameTimeStamp(t.timeStamp)&&Ot(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),Ot(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;#Rn;#ch;#lh;#va="";#ba=0;#Nh=new Tn;#ya;#xa;constructor(t,e,i,s,n,r){this.#ya=i,this.#xa=s,this.#Rn=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.#Rn)}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.#Rn=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.#Nh.setLastElement(t)}removeLastElement(){if(!this.#Aa)return this.#Nh.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.#Nh.build(this.#Aa,t,e,i,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 Tn extends wn{#yh;#Sa=0;#th;#Aa;#ya;#xa;#Ca;#Rn;#ch;build(t,e,i,s,n,r,o){this.#ya=e,this.#xa=i,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: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.#Rn){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?new Array(t.length):null)),o.push(v(e,u,d,f,p,n?new Array(e.length):null));return{lines:r,points:o,rect:[g,m,w,A]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:o},rotation:h,thickness:a}){const c=[];let l,u,d,f,p;switch(h){case 0:p=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.#Rn%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}}_(5213);class Rn{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#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#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#_a(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.#Ra(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.#Na(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#Oa(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.#Oa(t,e,b+2,s),this.#Oa(t,b,i,s)):s.push(n,r)}static#Fa(t){const e=[],i=t.length;return this.#Oa(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#$a(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#La(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#Ua(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.#La(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.#La(c.getImageData(0,0,A,v).data),y=this.#$a(b),x=this.#Ua(y),M=this.#_a(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.#Ua(c),u=this.#_a(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 new 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 Nn extends Cn{constructor(){super(),super.updateProperties({fill:ue._defaultLineColor,"stroke-width":0})}clone(){const t=new Nn;return t.updateAll(this),t}}class _n extends Pn{constructor(t){super(t),super.updateProperties({stroke:ue._defaultLineColor,"stroke-width":1})}clone(){const t=new _n(this._viewParameters);return t.updateAll(this),t}}class On 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 Nn,this._defaultDrawnSignatureOptions=new _n(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=Rn.processDrawnLines({lines:t,pageWidth:o,pageHeight:h,rotation:a,innerMargin:On._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:Rn.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=On.getDefaultDrawingOptions():(h=On._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 Rn.process(t,e,i,s,On._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:s},rotation:n}=this.parent.viewport;return Rn.extractContoursFromText(t,e,i,s,n,On._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return Rn.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:On._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=On.getDefaultDrawingOptions():(this._drawingOptions=On._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 new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,o=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!o)throw new Error("No response from the AI service.");if(o.error)throw new Error("Error from the AI service.");if(o.cancel)return null;if(!o.output)throw new Error("No valid response from the AI service.");const h=o.output;return await this.setGuessedAltText(h),e&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}#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{#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([mn,Dn,Fn,Sn,On].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.#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()===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=new 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&&(Ot(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.#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),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.#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 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.#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,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 $n{#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#Rc(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+"%"}#Nc(){const t=$n._svgFactory.create(1,1,!0);return this.#so.append(t),t.setAttribute("aria-hidden",!0),t}#_c(t,e){const i=$n._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=$n._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}#Oc(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=$n.#E++,n=this.#Nc(),r=$n._svgFactory.createElement("defs");n.append(r);const o=$n._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.#_c(r,h):null,c=$n._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=$n.#E++,s=this.#Nc(),n=$n._svgFactory.createElement("defs");s.append(n);const r=$n._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=$n._svgFactory.createElement("mask");n.append(t),h=`mask_${i}`,t.setAttribute("id",h),t.setAttribute("maskUnits","objectBoundingBox");const e=$n._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");const s=$n._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=$n._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.#Oc(o,i),s&&$n.#Rc(o,s),n){const{classList:t}=o;for(const[e,i]of Object.entries(n))t.toggle(e,i)}r&&this.#Oc(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 Ln(t){return`${(100*t).toFixed(2)}%`}class Un{#Fc=[];#Bc=new Map;#$c=null;#Lc=0;#Pn=0;#Tn=0;static#Uc=null;constructor(t,e,i,s){this.#Lc=t,this.#Fc=e,this.#Pn=i.rawDims.pageWidth,this.#Tn=i.rawDims.pageHeight,this.#$c=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=Un.#Uc?.deref();if(s===e)return;s&&(s.width=0,s.height=0),Un.#Uc=new WeakRef(e);const{inverseTransform:n,x1:r,y1:o,width:h,height:a}=i,c=this.#$c(),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.#Lc||h<this.#Lc)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:Ln(t),top:Ln(e),width:Ln(o/this.#Pn),height:Ln(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}}var jn;globalThis._pdfjsTestingUtils={HighlightOutliner:bn},globalThis.pdfjsLib={AbortException:ut,AnnotationEditorLayer:Bn,AnnotationEditorParamsType:H,AnnotationEditorType:z,AnnotationEditorUIManager:he,AnnotationLayer:pn,AnnotationMode:U,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",$t(i))}},DOMSVGFactory:Fs,DrawLayer:$n,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:$t,getRGBA:Bt,getUuid:wt,getXfaPageViewport:function(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s,10),parseInt(n,10)];return new Tt({viewBox:r,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:_t,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:Rn,stopEvent:Ot,SupportedImageMimeTypes:Ht,TextLayer:bs,TextLayerImages:Un,TouchManager:le,updateUrlHash:it,Util:pt,VerbosityLevel:V,version:"5.7.284",XfaLayer:St},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}((function t(e){var i=jn.call(this,"Validation error mapping object.")||this;return i.errors=e,Object.setPrototypeOf(i,t.prototype),i}),jn=Error);var zn=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 e=this,i=arguments,n=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))}),h(h({},e),{abort:i.signal}))}))]}))},new((s=Promise)||(s=Promise))((function(t,r){function o(t){try{a(n.next(t))}catch(t){r(t)}}function h(t){try{a(n.throw(t))}catch(t){r(t)}}function a(e){var i;e.done?t(e.value):(i=e.value,i instanceof s?i:new s((function(t){t(i)}))).then(o,h)}a((n=n.apply(e,i||[])).next())}));var e,i,s,n},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 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 e=this.constrainPanOffset(g.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 new Error("Viewport is not defined. Unable to perform zoom operation.");{const n=Math.min(Math.max(10,t),600),r=n/i,o=g.add(g.scaleProportional(E.center(e),1-r),g.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 g.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 e;super({panOffset:g.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{resource:{type:"url",url:t}};throw new Error("Invalid URI. Provided URI must be a valid URL or URN.")}(t);if("url"!==e.resource.type)throw new 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 new Error(`Unable to load page ${t}. The provided page number must be greater than 0.`);if(t>s)throw new 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:g.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 new 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 Gn{constructor(t,e){this.api=t,this.canvas=e,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,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=Math.max(0,(c.width-l.width*u)/2),f=h.getViewport({scale:u,offsetX:n.x+d,offsetY:n.y});this.offscreenCanvas.width=this.canvas.width,this.offscreenCanvas.height=this.canvas.height,await h.render({canvas:this.offscreenCanvas,viewport:f,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 Yn{create(t,e){const i=new Wn(e);return{api:i,renderer:new Vn(i,t)}}}const Xn=class{constructor(i){t(this,i),this.documentReady=e(this,"documentReady"),this.documentStateChanged=e(this,"documentStateChanged"),this.pageLoaded=e(this,"pageLoaded"),this.pageDrawn=e(this,"pageDrawn"),this.provider=new Yn,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 i(s,{key:"9ebb0012f2edde7189b42f35fd2ecefb779b16ef"},i("div",{key:"ef52dd8c6367213d173f3847ff65deac1da6620e",ref:t=>this.viewerContainerElement=t,class:"viewer-container",onContextMenu:t=>t.preventDefault()},i("div",{key:"db0bede43e0798c1c8097f8079d1bbf4bea3fe15",ref:t=>this.canvasContainerElement=t,class:P("canvas-container",{"enable-pointer-events ":null!=window.PointerEvent})},i("canvas",{key:"3a705edd1985b11256e565880298a729a5e7260b",role:"presentation",ref:t=>this.canvasEl=t})),i("slot",{key:"9ccb82cc0493342c4e4caf7188c23ad8a55ca93b"})))}getDocumentApi(){if(null==this.documentApi)throw new 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:this.hostEl.getBoundingClientRect(),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 n(this)}static get watchers(){return{src:[{handleSrcChange:0}],config:[{handleConfigChange:0}],interactionMode:[{handleInteractionModeChange:0}]}}};Xn.style=":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}";export{Xn as vertex_document_viewer}
|