1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,67034,(t,e,i)=>{var r={675:function(t,e){"use strict";e.byteLength=function(t){var e=l(t),i=e[0],r=e[1];return(i+r)*3/4-r},e.toByteArray=function(t){var e,i,n=l(t),a=n[0],o=n[1],h=new s((a+o)*3/4-o),d=0,c=o>0?a-4:a;for(i=0;i<c;i+=4)e=r[t.charCodeAt(i)]<<18|r[t.charCodeAt(i+1)]<<12|r[t.charCodeAt(i+2)]<<6|r[t.charCodeAt(i+3)],h[d++]=e>>16&255,h[d++]=e>>8&255,h[d++]=255&e;return 2===o&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[d++]=255&e),1===o&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[d++]=e>>8&255,h[d++]=255&e),h},e.fromByteArray=function(t){for(var e,r=t.length,s=r%3,n=[],a=0,o=r-s;a<o;a+=16383)n.push(function(t,e,r){for(var s,n=[],a=e;a<r;a+=3)s=(t[a]<<16&0xff0000)+(t[a+1]<<8&65280)+(255&t[a+2]),n.push(i[s>>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return n.join("")}(t,a,a+16383>o?o:a+16383));return 1===s?n.push(i[(e=t[r-1])>>2]+i[e<<4&63]+"=="):2===s&&n.push(i[(e=(t[r-2]<<8)+t[r-1])>>10]+i[e>>4&63]+i[e<<2&63]+"="),n.join("")};for(var i=[],r=[],s="u">typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,o=n.length;a<o;++a)i[a]=n[a],r[n.charCodeAt(a)]=a;function l(t){var e=t.length;if(e%4>0)throw Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");-1===i&&(i=e);var r=i===e?0:4-i%4;return[i,r]}r[45]=62,r[95]=63},72:function(t,e,i){"use strict";var r=i(675),s=i(783),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function a(t){if(t>0x7fffffff)throw RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,o.prototype),e}function o(t,e,i){if("number"==typeof t){if("string"==typeof e)throw TypeError('The "string" argument must be of type string. Received type number');return d(t)}return l(t,e,i)}function l(t,e,i){if("string"==typeof t){var r=t,s=e;if(("string"!=typeof s||""===s)&&(s="utf8"),!o.isEncoding(s))throw TypeError("Unknown encoding: "+s);var n=0|p(r,s),l=a(n),h=l.write(r,s);return h!==n&&(l=l.slice(0,h)),l}if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(M(t,ArrayBuffer)||t&&M(t.buffer,ArrayBuffer)||"u">typeof SharedArrayBuffer&&(M(t,SharedArrayBuffer)||t&&M(t.buffer,SharedArrayBuffer)))return function(t,e,i){var r;if(e<0||t.byteLength<e)throw RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(i||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(r=void 0===e&&void 0===i?new Uint8Array(t):void 0===i?new Uint8Array(t,e):new Uint8Array(t,e,i),o.prototype),r}(t,e,i);if("number"==typeof t)throw TypeError('The "value" argument must not be of type number. Received type number');var d=t.valueOf&&t.valueOf();if(null!=d&&d!==t)return o.from(d,e,i);var g=function(t){if(o.isBuffer(t)){var e=0|u(t.length),i=a(e);return 0===i.length||t.copy(i,0,0,e),i}return void 0!==t.length?"number"!=typeof t.length||function(t){return t!=t}(t.length)?a(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(t.data):void 0}(t);if(g)return g;if("u">typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return o.from(t[Symbol.toPrimitive]("string"),e,i);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function h(t){if("number"!=typeof t)throw TypeError('"size" argument must be of type number');if(t<0)throw RangeError('The value "'+t+'" is invalid for option "size"')}function d(t){return h(t),a(t<0?0:0|u(t))}function c(t){for(var e=t.length<0?0:0|u(t.length),i=a(e),r=0;r<e;r+=1)i[r]=255&t[r];return i}e.Buffer=o,e.SlowBuffer=function(t){return+t!=t&&(t=0),o.alloc(+t)},e.INSPECT_MAX_BYTES=50,e.kMaxLength=0x7fffffff,o.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),!o.TYPED_ARRAY_SUPPORT&&"u">typeof console&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}
vendor: 13,493 bytes, line 1
1),o.poolSize=8192,o.from=function(t,e,i){return l(t,e,i)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(t,e,i){return(h(t),t<=0)?a(t):void 0!==e?"string"==typeof i?a(t).fill(e,i):a(t).fill(e):a(t)},o.allocUnsafe=function(t){return d(t)},o.allocUnsafeSlow=function(t){return d(t)};function u(t){if(t>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|t}function p(t,e){if(o.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||M(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var i=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===i)return 0;for(var s=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return S(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return T(t).length;default:if(s)return r?-1:S(t).length;e=(""+e).toLowerCase(),s=!0}}function g(t,e,i){var s,n,a,o=!1;if((void 0===e||e<0)&&(e=0),e>this.length||((void 0===i||i>this.length)&&(i=this.length),i<=0||(i>>>=0)<=(e>>>=0)))return"";for(t||(t="utf8");;)switch(t){case"hex":return function(t,e,i){var r=t.length;(!e||e<0)&&(e=0),(!i||i<0||i>r)&&(i=r);for(var s="",n=e;n<i;++n)s+=P[t[n]];return s}(this,e,i);case"utf8":case"utf-8":return y(this,e,i);case"ascii":return function(t,e,i){var r="";i=Math.min(t.length,i);for(var s=e;s<i;++s)r+=String.fromCharCode(127&t[s]);return r}(this,e,i);case"latin1":case"binary":return function(t,e,i){var r="";i=Math.min(t.length,i);for(var s=e;s<i;++s)r+=String.fromCharCode(t[s]);return r}(this,e,i);case"base64":return s=this,n=e,a=i,0===n&&a===s.length?r.fromByteArray(s):r.fromByteArray(s.slice(n,a));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(t,e,i){for(var r=t.slice(e,i),s="",n=0;n<r.length;n+=2)s+=String.fromCharCode(r[n]+256*r[n+1]);return s}(this,e,i);default:if(o)throw TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),o=!0}}function f(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function m(t,e,i,r,s){var n;if(0===t.length)return -1;if("string"==typeof i?(r=i,i=0):i>0x7fffffff?i=0x7fffffff:i<-0x80000000&&(i=-0x80000000),(n=i*=1)!=n&&(i=s?0:t.length-1),i<0&&(i=t.length+i),i>=t.length)if(s)return -1;else i=t.length-1;else if(i<0)if(!s)return -1;else i=0;if("string"==typeof e&&(e=o.from(e,r)),o.isBuffer(e))return 0===e.length?-1:b(t,e,i,r,s);if("number"==typeof e){if(e&=255,"function"==typeof Uint8Array.prototype.indexOf)if(s)return Uint8Array.prototype.indexOf.call(t,e,i);else return Uint8Array.prototype.lastIndexOf.call(t,e,i);return b(t,[e],i,r,s)}throw TypeError("val must be string, number or Buffer")}function b(t,e,i,r,s){var n,a=1,o=t.length,l=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return -1;a=2,o/=2,l/=2,i/=2}function h(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(s){var d=-1;for(n=i;n<o;n++)if(h(t,n)===h(e,-1===d?0:n-d)){if(-1===d&&(d=n),n-d+1===l)return d*a}else -1!==d&&(n-=n-d),d=-1}else for(i+l>o&&(i=o-l),n=i;n>=0;n--){for(var c=!0,u=0;u<l;u++)if(h(t,n+u)!==h(e,u)){c=!1;break}if(c)return n}return -1}o.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==o.prototype},o.compare=function(t,e){if(M(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),M(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(t)||!o.isBuffer(e))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var i=t.length,r=e.length,s=0,n=Math.min(i,r);s<n;++s)if(t[s]!==e[s]){i=t[s],r=e[s];break}return i<r?-1:+(r<i)},o.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(t,e){if(!Array.isArray(t))throw TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return o.alloc(0);if(void 0===e)for(i=0,e=0;i<t.length;++i)e+=t[i].length;var i,r=o.allocUnsafe(e),s=0;for(i=0;i<t.length;++i){var n=t[i];if(M(n,Uint8Array)&&(n=o.from(n)),!o.isBuffer(n))throw TypeError('"list" argument must be an Array of Buffers');n.copy(r,s),s+=n.length}return r},o.byteLength=p,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)f(this,e,e+1);return this},o.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)f(this,e,e+3),f(this,e+1,e+2);return this},o.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)f(this,e,e+7),f(this,e+1,e+6),f(this,e+2,e+5),f(this,e+3,e+4);return this},o.prototype.toString=function(){var t=this.length;return 0===t?"":0==arguments.length?y(this,0,t):g.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(t){if(!o.isBuffer(t))throw TypeError("Argument must be a Buffer");return this===t||0===o.compare(this,t)},o.prototype.inspect=function(){var t="",i=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(t+=" ... "),"<Buffer "+t+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(t,e,i,r,s){if(M(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(t))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===r&&(r=0),void 0===s&&(s=this.length),e<0||i>t.length||r<0||s>this.length)throw RangeError("out of range index");if(r>=s&&e>=i)return 0;if(r>=s)return -1;if(e>=i)return 1;if(e>>>=0,i>>>=0,r>>>=0,s>>>=0,this===t)return 0;for(var n=s-r,a=i-e,l=Math.min(n,a),h=this.slice(r,s),d=t.slice(e,i),c=0;c<l;++c)if(h[c]!==d[c]){n=h[c],a=d[c];break}return n<a?-1:+(a<n)},o.prototype.includes=function(t,e,i){return -1!==this.indexOf(t,e,i)},o.prototype.indexOf=function(t,e,i){return m(this,t,e,i,!0)},o.prototype.lastIndexOf=function(t,e,i){return m(this,t,e,i,!1)};function y(t,e,i){i=Math.min(t.length,i);for(var r=[],s=e;s<i;){var n,a,o,l,h=t[s],d=null,c=h>239?4:h>223?3:h>191?2:1;if(s+c<=i)switch(c){case 1:h<128&&(d=h);break;case 2:(192&(n=t[s+1]))==128&&(l=(31&h)<<6|63&n)>127&&(d=l);break;case 3:n=t[s+1],a=t[s+2],(192&n)==128&&(192&a)==128&&(l=(15&h)<<12|(63&n)<<6|63&a)>2047&&(l<55296||l>57343)&&(d=l);break;case 4:n=t[s+1],a=t[s+2],o=t[s+3],(192&n)==128&&(192&a)==128&&(192&o)==128&&(l=(15&h)<<18|(63&n)<<12|(63&a)<<6|63&o)>65535&&l<1114112&&(d=l)}null===d?(d=65533,c=1):d>65535&&(d-=65536,r.push(d>>>10&1023|55296),d=56320|1023&d),r.push(d),s+=c}var u=r,p=u.length;if(p<=4096)return String.fromCharCode.apply(String,u);for(var g="",f=0;f<p;)g+=String.fromCharCode.apply(String,u.slice(f,f+=4096));return g}function v(t,e,i){if(t%1!=0||t<0)throw RangeError("offset is not uint");if(t+e>i)throw RangeError("Trying to access beyond buffer length")}function w(t,e,i,r,s,n){if(!o.isBuffer(t))throw TypeError('"buffer" argument must be a Buffer instance');if(e>s||e<n)throw RangeError('"value" argument is out of bounds');if(i+r>t.length)throw RangeError("Index out of range")}function x(t,e,i,r,s,n){if(i+r>t.length||i<0)throw RangeError("Index out of range")}function A(t,e,i,r,n){return e*=1,i>>>=0,n||x(t,e,i,4,34028234663852886e22,-34028234663852886e22),s.write(t,e,i,r,23,4),i+4}function _(t,e,i,r,n){return e*=1,i>>>=0,n||x(t,e,i,8,17976931348623157e292,-17976931348623157e292),s.write(t,e,i,r,52,8),i+8}o.prototype.write=function(t,e,i,r){if(void 0===e)r="utf8",i=this.length,e=0;else if(void 0===i&&"string"==typeof e)r=e,i=this.length,e=0;else if(isFinite(e))e>>>=0,isFinite(i)?(i>>>=0,void 0===r&&(r="utf8")):(r=i,i=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s,n,a,o,l,h,d,c,u=this.length-e;if((void 0===i||i>u)&&(i=u),t.length>0&&(i<0||e<0)||e>this.length)throw RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var p=!1;;)switch(r){case"hex":return function(t,e,i,r){i=Number(i)||0;var s=t.length-i;r?(r=Number(r))>s&&(r=s):r=s;var n=e.length;r>n/2&&(r=n/2);for(var a=0;a<r;++a){var o,l=parseInt(e.substr(2*a,2),16);if((o=l)!=o)break;t[i+a]=l}return a}(this,t,e,i);case"utf8":case"utf-8":return s=e,n=i,k(S(t,this.length-s),this,s,n);case"ascii":return a=e,o=i,k(C(t),this,a,o);case"latin1":case"binary":return function(t,e,i,r){return k(C(e),t,i,r)}(this,t,e,i);case"base64":return l=e,h=i,k(T(t),this,l,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d=e,c=i,k(function(t,e){for(var i,r,s=[],n=0;n<t.length&&!((e-=2)<0);++n)r=(i=t.charCodeAt(n))>>8,s.push(i%256),s.push(r);return s}(t,this.length-d),this,d,c);default:if(p)throw TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),p=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(t,e){var i=this.length;t=~~t,e=void 0===e?i:~~e,t<0?(t+=i)<0&&(t=0):t>i&&(t=i),e<0?(e+=i)<0&&(e=0):e>i&&(e=i),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,o.prototype),r},o.prototype.readUIntLE=function(t,e,i){t>>>=0,e>>>=0,i||v(t,e,this.length);for(var r=this[t],s=1,n=0;++n<e&&(s*=256);)r+=this[t+n]*s;return r},o.prototype.readUIntBE=function(t,e,i){t>>>=0,e>>>=0,i||v(t,e,this.length);for(var r=this[t+--e],s=1;e>0&&(s*=256);)r+=this[t+--e]*s;return r},o.prototype.readUInt8=function(t,e){return t>>>=0,e||v(t,1,this.length),this[t]},o.prototype.readUInt16LE=function(t,e){return t>>>=0,e||v(t,2,this.length),this[t]|this[t+1]<<8},o.prototype.readUInt16BE=function(t,e){return t>>>=0,e||v(t,2,this.length),this[t]<<8|this[t+1]},o.prototype.readUInt32LE=function(t,e){return t>>>=0,e||v(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+0x1000000*this[t+3]},o.prototype.readUInt32BE=function(t,e){return t>>>=0,e||v(t,4,this.length),0x1000000*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},o.prototype.readIntLE=function(t,e,i){t>>>=0,e>>>=0,i||v(t,e,this.length);for(var r=this[t],s=1,n=0;++n<e&&(s*=256);)r+=this[t+n]*s;return r>=(s*=128)&&(r-=Math.pow(2,8*e)),r},o.prototype.readIntBE=function(t,e,i){t>>>=0,e>>>=0,i||v(t,e,this.length);for(var r=e,s=1,n=this[t+--r];r>0&&(s*=256);)n+=this[t+--r]*s;return n>=(s*=128)&&(n-=Math.pow(2,8*e)),n},o.prototype.readInt8=function(t,e){return(t>>>=0,e||v(t,1,this.length),128&this[t])?-((255-this[t]+1)*1):this[t]},o.prototype.readInt16LE=function(t,e){t>>>=0,e||v(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?0xffff0000|i:i},o.prototype.readInt16BE=function(t,e){t>>>=0,e||v(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?0xffff0000|i:i},o.prototype.readInt32LE=function(t,e){return t>>>=0,e||v(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},o.prototype.readInt32BE=function(t,e){return t>>>=0,e||v(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},o.prototype.readFloatLE=function(t,e){return t>>>=0,e||v(t,4,this.length),s.read(this,t,!0,23,4)},o.prototype.readFloatBE=function(t,e){return t>>>=0,e||v(t,4,this.length),s.read(this,t,!1,23,4)},o.prototype.readDoubleLE=function(t,e){return t>>>=0,e||v(t,8,this.length),s.read(this,t,!0,52,8)},o.prototype.readDoubleBE=function(t,e){return t>>>=0,e||v(t,8,this.length),s.read(this,t,!1,52,8)},o.prototype.writeUIntLE=function(t,e,i,r){if(t*=1,e>>>=0,i>>>=0,!r){var s=Math.pow(2,8*i)-1;w(this,t,e,i,s,0)}var n=1,a=0;for(this[e]=255&t;++a<i&&(n*=256);)this[e+a]=t/n&255;return e+i},o.prototype.writeUIntBE=function(t,e,i,r){if(t*=1,e>>>=0,i>>>=0,!r){var s=Math.pow(2,8*i)-1;w(this,t,e,i,s,0)}var n=i-1,a=1;for(this[e+n]=255&t;--n>=0&&(a*=256);)this[e+n]=t/a&255;return e+i},o.prototype.writeUInt8=function(t,e,i){return t*=1,e>>>=0,i||w(this,t,e,1,255,0),this[e]=255&t,e+1},o.prototype.writeUInt16LE=function(t,e,i){return t*=1,e>>>=0,i||w(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeUInt16BE=function(t,e,i){return t*=1,e>>>=0,i||w(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},o.prototype.writeUInt32LE=function(t,e,i){return t*=1,e>>>=0,i||w(this,t,e,4,0xffffffff,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},o.prototype.writeUInt32BE=function(t,e,i){return t*=1,e>>>=0,i||w(this,t,e,4,0xffffffff,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeIntLE=function(t,e,i,r){if(t*=1,e>>>=0,!r){var s=Math.pow(2,8*i-1);w(this,t,e,i,s-1,-s)}var n=0,a=1,o=0;for(this[e]=255&t;++n<i&&(a*=256);)t<0&&0===o&&0!==this[e+n-1]&&(o=1),this[e+n]=(t/a|0)-o&255;return e+i},o.prototype.writeIntBE=function(t,e,i,r){if(t*=1,e>>>=0,!r){var s=Math.pow(2,8*i-1);w(this,t,e,i,s-1,-s)}var n=i-1,a=1,o=0;for(this[e+n]=255&t;--n>=0&&(a*=256);)t<0&&0===o&&0!==this[e+n+1]&&(o=1),this[e+n]=(t/a|0)-o&255;return e+i},o.prototype.writeInt8=function(t,e,i){return t*=1,e>>>=0,i||w(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},o.prototype.writeInt16LE=function(t,e,i){return t*=1,e>>>=0,i||w(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},o.prototype.writeInt16BE=function(t,e,i){return t*=1,e>>>=0,i||w(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2}
1,o.prototype.writeInt32LE=function(t,e,i){return t*=1,e>>>=0,i||w(this,t,e,4,0x7fffffff,-0x80000000),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},o.prototype.writeInt32BE=function(t,e,i){return t*=1,e>>>=0,i||w(this,t,e,4,0x7fffffff,-0x80000000),t<0&&(t=0xffffffff+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},o.prototype.writeFloatLE=function(t,e,i){return A(this,t,e,!0,i)},o.prototype.writeFloatBE=function(t,e,i){return A(this,t,e,!1,i)},o.prototype.writeDoubleLE=function(t,e,i){return _(this,t,e,!0,i)},o.prototype.writeDoubleBE=function(t,e,i){return _(this,t,e,!1,i)},o.prototype.copy=function(t,e,i,r){if(!o.isBuffer(t))throw TypeError("argument should be a Buffer");if(i||(i=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<i&&(r=i),r===i||0===t.length||0===this.length)return 0;if(e<0)throw RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw RangeError("Index out of range");if(r<0)throw RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-i&&(r=t.length-e+i);var s=r-i;if(this===t&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(e,i,r);else if(this===t&&i<e&&e<r)for(var n=s-1;n>=0;--n)t[n+e]=this[n+i];else Uint8Array.prototype.set.call(t,this.subarray(i,r),e);return s},o.prototype.fill=function(t,e,i,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,i=this.length):"string"==typeof i&&(r=i,i=this.length),void 0!==r&&"string"!=typeof r)throw TypeError("encoding must be a string");if("string"==typeof r&&!o.isEncoding(r))throw TypeError("Unknown encoding: "+r);if(1===t.length){var s,n=t.charCodeAt(0);("utf8"===r&&n<128||"latin1"===r)&&(t=n)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<i)throw RangeError("Out of range index");if(i<=e)return this;if(e>>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s<i;++s)this[s]=t;else{var a=o.isBuffer(t)?t:o.from(t,r),l=a.length;if(0===l)throw TypeError('The value "'+t+'" is invalid for argument "value"');for(s=0;s<i-e;++s)this[s+e]=a[s%l]}return this};var E=/[^+/0-9A-Za-z-_]/g;function S(t,e){e=e||1/0;for(var i,r=t.length,s=null,n=[],a=0;a<r;++a){if((i=t.charCodeAt(a))>55295&&i<57344){if(!s){if(i>56319||a+1===r){(e-=3)>-1&&n.push(239,191,189);continue}s=i;continue}if(i<56320){(e-=3)>-1&&n.push(239,191,189),s=i;continue}i=(s-55296<<10|i-56320)+65536}else s&&(e-=3)>-1&&n.push(239,191,189);if(s=null,i<128){if((e-=1)<0)break;n.push(i)}else if(i<2048){if((e-=2)<0)break;n.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;n.push(i>>12|224,i>>6&63|128,63&i|128)}else if(i<1114112){if((e-=4)<0)break;n.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}else throw Error("Invalid code point")}return n}function C(t){for(var e=[],i=0;i<t.length;++i)e.push(255&t.charCodeAt(i));return e}function T(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(E,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function k(t,e,i,r){for(var s=0;s<r&&!(s+i>=e.length)&&!(s>=t.length);++s)e[s+i]=t[s];return s}function M(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}var P=function(){for(var t="0123456789abcdef",e=Array(256),i=0;i<16;++i)for(var r=16*i,s=0;s<16;++s)e[r+s]=t[i]+t[s];return e}()},783:function(t,e){e.read=function(t,e,i,r,s){var n,a,o=8*s-r-1,l=(1<<o)-1,h=l>>1,d=-7,c=i?s-1:0,u=i?-1:1,p=t[e+c];for(c+=u,n=p&(1<<-d)-1,p>>=-d,d+=o;d>0;n=256*n+t[e+c],c+=u,d-=8);for(a=n&(1<<-d)-1,n>>=-d,d+=r;d>0;a=256*a+t[e+c],c+=u,d-=8);if(0===n)n=1-h;else{if(n===l)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),n-=h}return(p?-1:1)*a*Math.pow(2,n-r)},e.write=function(t,e,i,r,s,n){var a,o,l,h=8*n-s-1,d=(1<<h)-1,c=d>>1,u=5960464477539062e-23*(23===s),p=r?0:n-1,g=r?1:-1,f=+(e<0||0===e&&1/e<0);for(isNaN(e=Math.abs(e))||e===1/0?(o=+!!isNaN(e),a=d):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+c>=1?e+=u/l:e+=u*Math.pow(2,1-c),e*l>=2&&(a++,l/=2),a+c>=d?(o=0,a=d):a+c>=1?(o=(e*l-1)*Math.pow(2,s),a+=c):(o=e*Math.pow(2,c-1)*Math.pow(2,s),a=0));s>=8;t[i+p]=255&o,p+=g,o/=256,s-=8);for(a=a<<s|o,h+=s;h>0;t[i+p]=255&a,p+=g,a/=256,h-=8);t[i+p-g]|=128*f}}},s={};function n(t){var e=s[t];if(void 0!==e)return e.exports;var i=s[t]={exports:{}},a=!0;try{r[t](i,i.exports,n),a=!1}finally{a&&delete s[t]}return i.exports}n.ab="/ROOT/node_modules/next/dist/compiled/buffer/",e.exports=n(72)},42656,(t,e,i)=>{"use strict";e.exports=function(){}},89411,t=>{"use strict";var e=t.i(43476),i=t.i(71645);let r=function(){for(var t,e,i=0,r="",s=arguments.length;i<s;i++)(t=arguments[i])&&(e=function t(e){var i,r,s="";if("string"==typeof e||"number"==typeof e)s+=e;else if("object"==typeof e)if(Array.isArray(e)){var n=e.length;for(i=0;i<n;i++)e[i]&&(r=t(e[i]))&&(s&&(s+=" "),s+=r)}else for(r in e)e[r]&&(s&&(s+=" "),s+=r);return s}(t))&&(r&&(r+=" "),r+=e);return r};var s=Object.prototype.hasOwnProperty;function n(t,e,i){for(i of t.keys())if(a(i,e))return i}function a(t,e){var i,r,o;
1if(t===e)return!0;if(t&&e&&(i=t.constructor)===e.constructor){if(i===Date)return t.getTime()===e.getTime();if(i===RegExp)return t.toString()===e.toString();if(i===Array){if((r=t.length)===e.length)for(;r--&&a(t[r],e[r]););return -1===r}if(i===Set){if(t.size!==e.size)return!1;for(r of t)if((o=r)&&"object"==typeof o&&!(o=n(e,o))||!e.has(o))return!1;return!0}if(i===Map){if(t.size!==e.size)return!1;for(r of t)if((o=r[0])&&"object"==typeof o&&!(o=n(e,o))||!a(r[1],e.get(o)))return!1;return!0}if(i===ArrayBuffer)t=new Uint8Array(t),e=new Uint8Array(e);else if(i===DataView){if((r=t.byteLength)===e.byteLength)for(;r--&&t.getInt8(r)===e.getInt8(r););return -1===r}if(ArrayBuffer.isView(t)){if((r=t.byteLength)===e.byteLength)for(;r--&&t[r]===e[r];);return -1===r}if(!i||"object"==typeof t){for(i in r=0,t)if(s.call(t,i)&&++r&&!s.call(e,i)||!(i in e)||!a(t[i],e[i]))return!1;return Object.keys(e).length===r}}return t!=t&&e!=e}function o(t){let e=!1;return{promise:new Promise((i,r)=>{t.then(t=>!e&&i(t)).catch(t=>!e&&r(t))}),cancel(){e=!0}}}let l=["onCopy","onCut","onPaste","onCompositionEnd","onCompositionStart","onCompositionUpdate","onFocus","onBlur","onInput","onInvalid","onReset","onSubmit","onLoad","onError","onKeyDown","onKeyPress","onKeyUp","onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting","onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp","onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop","onSelect","onTouchCancel","onTouchEnd","onTouchMove","onTouchStart","onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut","onScroll","onWheel","onAnimationStart","onAnimationEnd","onAnimationIteration","onTransitionEnd","onChange","onToggle"];function h(t,e){let i={};for(let r of l){let s=t[r];s&&(e?i[r]=t=>s(t,e(r)):i[r]=s)}return i}var d=t.i(47167),c=t.i(67034);let u={get url(){return`file://${t.P("node_modules/pdfjs-dist/build/pdf.mjs")}`}};var p={};p.d=(t,e)=>{for(var i in e)p.o(e,i)&&!p.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},p.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let g="object"==typeof d.default&&d.default+""=="[object process]"&&!d.default.versions.nw&&!(d.default.versions.electron&&d.default.type&&"browser"!==d.default.type),f=[.001,0,0,.001,0,0],m={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},b="pdfjs_internal_editor_",y={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},v={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},w={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},x={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},A={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},_={ERRORS:0,WARNINGS:1,INFOS:5},E={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},S={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},C=_.WARNINGS;function T(t){C>=_.INFOS&&console.info(`Info: ${t}`)}function k(t){C>=_.WARNINGS&&console.warn(`Warning: ${t}`)}function M(t){throw Error(t)}function P(t,e){t||M(e)}function D(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){let e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{var r;r=t,t=decodeURIComponent(escape(r))}catch{}}let 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)?null:s}function I(t,e,i=!1){let r=URL.parse(t);return r?(r.hash=e,r.href):i&&D(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function R(t,e,i,r=!1){return Object.defineProperty(t,e,{value:i,enumerable:!r,configurable:!0,writable:!1}),i}let L=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=Error(),t.constructor=t,t}();class B extends L{constructor(t,e){super(t,"PasswordException"),this.code=e}}class F extends L{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class N extends L{constructor(t){super(t,"InvalidPDFException")}}class O extends L{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class U extends L{constructor(t){super(t,"FormatError")}}class j extends L{constructor(t){super(t,"AbortException")}}function z(t){("object"!=typeof t||t?.length===void 0)&&M("Invalid argument for bytesToString");let e=t.length;if(e<8192)return String.fromCharCode.apply(null,t);let i=[];for(let r=0;r<e;r+=8192){let s=Math.min(r+8192,e),n=t.subarray(r,s);i.push(String.fromCharCode.apply(null,n))}return i.join("")}function H(t){"string"!=typeof t&&M("Invalid argument for stringToBytes");let e=t.length,i=new Uint8Array(e);for(let r=0;r<e;++r)i[r]=255&t.charCodeAt(r);return i}class ${static get isLittleEndian(){let t;return R(this,"isLittleEndian",((t=new Uint8Array(4))[0]=1,1===new Uint32Array(t.buffer,0,1)[0]))}static get isEvalSupported(){return R(this,"isEvalSupported",function(){try{return Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return R(this,"isOffscreenCanvasSupported","u">typeof OffscreenCanvas)}static get isImageDecoderSupported(){return R(this,"isImageDecoderSupported","u">typeof ImageDecoder)}static get platform(){let{platform:t,userAgent:e}=navigator;return R(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 R(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}let G=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class V{static makeHexColor(t,e,i){return`#${G[t]}${G[e]}${G[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){let r=t[i],s=t[i+1];t[i]=r*e[0]+s*e[2]+e[4],t[i+1]=r*e[1]+s*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){let r=e[0],s=e[1],n=e[2],a=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){let h=t[i+e],d=t[i+e+1];t[i+e]=h*r+d*n+o,t[i+e+1]=h*s+d*a+l}}static applyInverseTransform(t,e){let i=t[0],r=t[1],s=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-r*e[2]+e[2]*e[5]-e[4]*e[3])/s,t[1]=(-i*e[1]+r*e[0]+e[4]*e[1]-e[5]*e[0])/s}static axialAlignedBoundingBox(t,e,i){let r=e[0],s=e[1],n=e[2],a=e[3],o=e[4],l=e[5],h=t[0],d=t[1],c=t[2],u=t[3],p=r*h+o,g=p,f=r*c+o,m=f,b=a*d+l,y=b,v=a*u+l,w=v;if(0!==s||0!==n){let t=s*h,e=s*c,i=n*d,r=n*u;p+=i,m+=i,f+=r,g+=r,b+=t,w+=t,v+=e,y+=e}i[0]=Math.min(i[0],p,f,g,m),i[1]=Math.min(i[1],b,v,y,w),i[2]=Math.max(i[2],p,f,g,m),i[3]=Math.max(i[3],b,v,y,w)}static inverseTransform(t){let 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){let i=t[0],r=t[1],s=t[2],n=t[3],a=i**2+r**2,o=s**2+n**2,l=(a+o)/2,h=Math.sqrt(l**2-(a*o-(i*s+r*n)**2));e[0]=Math.sqrt(l+h||1),e[1]=Math.sqrt(l-h||1)}static normalizeRect(t){let 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){let i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),r
1=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>r)return null;let s=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),n=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return s>n?null:[i,s,r,n]}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,r,s){s[0]=Math.min(s[0],t,i),s[1]=Math.min(s[1],e,r),s[2]=Math.max(s[2],t,i),s[3]=Math.max(s[3],e,r)}static #t(t,e,i,r,s,n,a,o,l,h){if(l<=0||l>=1)return;let d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*r,g=d*(d*(d*s+3*l*n)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static #e(t,e,i,r,s,n,a,o,l,h,d,c){if(1e-12>Math.abs(l)){Math.abs(h)>=1e-12&&this.#t(t,e,i,r,s,n,a,o,-d/h,c);return}let u=h**2-4*d*l;if(u<0)return;let p=Math.sqrt(u),g=2*l;this.#t(t,e,i,r,s,n,a,o,(-h+p)/g,c),this.#t(t,e,i,r,s,n,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,r,s,n,a,o,l){l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o),this.#e(t,i,s,a,e,r,n,o,3*(-t+3*(i-s)+a),6*(t-2*i+s),3*(i-t),l),this.#e(t,i,s,a,e,r,n,o,3*(-e+3*(r-n)+o),6*(e-2*r+n),3*(r-e),l)}}let W=null,q=null;function X(t){return W||(W=/([\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,q=new Map([["ï¬
","ſt"]])),t.replaceAll(W,(t,e,i)=>e?e.normalize("NFKC"):q.get(i))}function K(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),z(t)}let Y="pdfjs_internal_id_";function J(t,e,i){return Math.min(Math.max(t,e),i)}function Q(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(z(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise(i=>{i(t(...e))})}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce((t,e)=>t+e,0)});class Z{static textContent(t){let e=[],i={items:e,styles:Object.create(null)};return!function t(i){if(!i)return;let r=null,s=i.name;if("#text"===s)r=i.value;else{if(!Z.shouldBuildText(s))return;i?.attributes?.textContent?r=i.attributes.textContent:i.value&&(r=i.value)}if(null!==r&&e.push({str:r}),i.children)for(let e of i.children)t(e)}(t),i}static shouldBuildText(t){return"textarea"!==t&&"input"!==t&&"option"!==t&&"select"!==t}}class tt{static setupStorage(t,e,i,r,s){let n=r.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==n.value&&(t.textContent=n.value),"print"===s)break;t.addEventListener("input",t=>{r.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(n.value===i.attributes.xfaOn?t.setAttribute("checked",!0):n.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===s)break;t.addEventListener("change",t=>{r.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==n.value&&t.setAttribute("value",n.value),"print"===s)break;t.addEventListener("input",t=>{r.setValue(e,{value:t.target.value})})}break;case"select":if(null!==n.value)for(let e of(t.setAttribute("value",n.value),i.children))e.attributes.value===n.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected;t.addEventListener("input",t=>{let i=t.target.options,s=-1===i.selectedIndex?"":i[i.selectedIndex].value;r.setValue(e,{value:s})})}}static setAttributes({html:t,element:e,storage:i=null,intent:r,linkService:s}){let{attributes:n}=e,a=t instanceof HTMLAnchorElement;for(let[e,i]of("radio"===n.type&&(n.name=`${n.name}-${r}`),Object.entries(n)))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:a&&("href"===e||"newWindow"===e)||t.setAttribute(e,i)}a&&s.addLinkAttributes(t,n.href,n.newWindow),i&&n.dataId&&this.setupStorage(t,n.dataId,e,i)}static render(t){let e=t.annotationStorage,i=t.linkService,r=t.xfaHtml,s=t.
1intent||"display",n=document.createElement(r.name);r.attributes&&this.setAttributes({html:n,element:r,intent:s,linkService:i});let a="richText"!==s,o=t.div;if(o.append(n),t.viewport){let e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===r.children.length){if(r.value){let t=document.createTextNode(r.value);n.append(t),a&&Z.shouldBuildText(r.name)&&l.push(t)}return{textDivs:l}}let h=[[r,-1,n]];for(;h.length>0;){let[t,r,n]=h.at(-1);if(r+1===t.children.length){h.pop();continue}let o=t.children[++h.at(-1)[1]];if(null===o)continue;let{name:d}=o;if("#text"===d){let t=document.createTextNode(o.value);l.push(t),n.append(t);continue}let c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(n.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:s,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){let t=document.createTextNode(o.value);a&&Z.shouldBuildText(d)&&l.push(t),c.append(t)}}for(let t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}let te="http://www.w3.org/2000/svg";class ti{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function tr(t,e="text"){if(tc(t,document.baseURI)){let i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise((i,r)=>{let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType=e,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE){if(200===s.status||0===s.status){switch(e){case"arraybuffer":case"blob":case"json":i(s.response);return}i(s.responseText);return}r(Error(s.statusText))}},s.send(null)})}class ts{constructor({viewBox:t,userUnit:e,scale:i,rotation:r,offsetX:s=0,offsetY:n=0,dontFlip:a=!1}){let o,l,h,d,c,u,p,g;this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=r,this.offsetX=s,this.offsetY=n,i*=e;const f=(t[2]+t[0])/2,m=(t[3]+t[1])/2;switch((r%=360)<0&&(r+=360),r){case 180:o=-1,l=0,h=0,d=1;break;case 90:o=0,l=1,h=1,d=0;break;case 270:o=0,l=-1,h=-1,d=0;break;case 0:o=1,l=0,h=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(h=-h,d=-d),0===o?(c=Math.abs(m-t[1])*i+s,u=Math.abs(f-t[0])*i+n,p=(t[3]-t[1])*i,g=(t[2]-t[0])*i):(c=Math.abs(f-t[0])*i+s,u=Math.abs(m-t[1])*i+n,p=(t[2]-t[0])*i,g=(t[3]-t[1])*i),this.transform=[o*i,l*i,h*i,d*i,c-o*i*f-h*i*m,u-l*i*f-d*i*m],this.width=p,this.height=g}get rawDims(){let t=this.viewBox;return R(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:r=this.offsetY,dontFlip:s=!1}={}){return new ts({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:r,dontFlip:s})}convertToViewportPoint(t,e){let i=[t,e];return V.applyTransform(i,this.transform),i}convertToViewportRectangle(t){let e=[t[0],t[1]];V.applyTransform(e,this.transform);let i=[t[2],t[3]];return V.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){let i=[t,e];return V.applyInverseTransform(i,this.transform),i}}class tn extends L{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function ta(t){let e=t.length,i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function to(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function tl(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function th(t,e="document.pdf"){if("string"!=typeof t)return e;if(ta(t))return k('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let 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;let r=t=>{try{let e=decodeURIComponent(t);if(e.includes("/")){if((e=e.split("/").at(-1)).test(/^\.pdf$/i))return e;return t}return e}catch{return t}},s=/\.pdf$/i,n=i.pathname.split("/").at(-1);if(s.test(n))return r(n);if(i.searchParams.size>0){for(let t of Array.from(i.searchParams.values()).reverse())if(s.test(t))return r(t);for(let t of Array.from(i.searchParams.keys()).reverse())if(s.test(t))return r(t)}if(i.hash){let t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return r(t[0])}return e}class td{started=Object.create(null);times=[];time(t){t in this.started&&k(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||k(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){let t=[],e=0;for(let{name:t}of this.times)e=Math.max(t.length,e);for(let{name:i,start:r,end:s}of this.times)t.push(`${i.padEnd(e)} ${s-r}ms 2`);return t.join("")}}function tc(t,e){let i=e?URL.parse(t,e):URL.parse(t);return i?.protocol==="http:"||i?.protocol==="https:"}function tu(t){t.preventDefault()}function tp(t){t.preventDefault(),t.stopPropagation()}class tg{static #i;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#i||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#i.exec(t);if(!e)return null;let i=parseInt(e[1],10),r=parseInt(e[2],10);r=r>=1&&r<=12?r-1:0;let s=parseInt(e[3],10);s=s>=1&&s<=31?s:1;let n=parseInt(e[4],10);n=n>=0&&n<=23?n:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(n+=h,a+=d):"+"===l&&(n-=h,a-=d),new Date(Date.UTC(i,r,s,n,a,o))}}function tf(t,{scale:e=1,rotation:i=0}){let{width:r,height:s}=t.attributes.style;return new ts({viewBox:[0,0,parseInt(r),parseInt(s)],userUnit:1,scale:e,rotation:i})}function tm(t){if(t.startsWith("#")){let e=parseInt(t.slice(1),16);return[(0xff0000&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(k(`Not a valid color format: "${t}"`),[0,0,0])}function tb(t){let{a:e,b:i,c:r,d:s,e:n,f:a}=t.getTransform();return[e,i,r,s,n,a]}function ty(t){let{a:e,b:i,c:r,d:s,e:n,f:a}=t.getTransform().invertSelf();return[e,i,r,s,n,a]}function tv(t,e,i=!1,r=!0){if(e instanceof ts){let{pageWidth:r,pageHeight:s}=e.rawDims,{style:n}=t,a=$.isCSSRoundSupported,o=`var(--total-scale-factor) * ${r}px`,l=`var(--total-scale-factor) * ${s}px`,h=a?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,d=a?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(n.width=d,n.height=h):(n.width=h,n.height=d)}r&&t.setAttribute("data-main-rotation",e.rotation)}class tw{constructor(){const{pixelRatio:t}=tw;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,r,s=-1){let n=1/0,a=1/0,o=1/0;(i=tw.capPixels(i,s))>0&&(n=Math.sqrt(i/(t*e))),-1!==r&&(a=r/t,o=r/e);let l=Math.min(n,a,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>
2=0){let 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}}let tx=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class tA{static get isDarkMode(){return R(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class t_{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:i}=window.getComputedStyle(t);return t.remove(),R(this,"commentForegroundColor",tm(i))}}function tE(t,e,i,r){let s=255*(1-(r=Math.min(Math.max(r??1,0),1)));return[t=Math.round(t*r+s),e=Math.round(e*r+s),i=Math.round(i*r+s)]}function tS(t,e){let i=t[0]/255,r=t[1]/255,s=t[2]/255,n=Math.max(i,r,s),a=Math.min(i,r,s),o=(n+a)/2;if(n===a)e[0]=e[1]=0;else{let t=n-a;switch(e[1]=o<.5?t/(n+a):t/(2-n-a),n){case i:e[0]=((r-s)/t+6*(r<s))*60;break;case r:e[0]=((s-i)/t+2)*60;break;case s:e[0]=((i-r)/t+4)*60}}e[2]=o}function tC(t,e){let i=t[0],r=t[1],s=t[2],n=(1-Math.abs(2*s-1))*r,a=n*(1-Math.abs(i/60%2-1)),o=s-n/2;switch(Math.floor(i/60)){case 0:e[0]=n+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=n+o,e[2]=o;break;case 2:e[0]=o,e[1]=n+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=n+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=n+o;break;case 5:case 6:e[0]=n+o,e[1]=o,e[2]=a+o}}function tT(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function tk(t,e,i){tC(t,i),i.map(tT);let r=.2126*i[0]+.7152*i[1]+.0722*i[2];tC(e,i),i.map(tT);let s=.2126*i[0]+.7152*i[1]+.0722*i[2];return r>s?(r+.05)/(s+.05):(s+.05)/(r+.05)}let tM=new Map;function tP(t,e){let i=t[0]+256*t[1]+65536*t[2]+0x1000000*e[0]+0x100000000*e[1]+0x10000000000*e[2],r=tM.get(i);if(r)return r;let s=new Float32Array(9),n=s.subarray(0,3),a=s.subarray(3,6);tS(t,a);let o=s.subarray(6,9);tS(e,o);let l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),tk(a,o,n)<h){let t,e;for(l?(t=a[2],e=1):(t=0,e=a[2]);e-t>.005;){let i=a[2]=(t+e)/2;l===tk(a,o,n)<h?t=i:e=i}a[2]=l?e:t}return tC(a,n),r=V.makeHexColor(Math.round(255*n[0]),Math.round(255*n[1]),Math.round(255*n[2])),tM.set(i,r),r}function tD({html:t,dir:e,className:i},r){let s=document.createDocumentFragment();if("string"==typeof t){let i=document.createElement("p");i.dir=e||"auto";let r=t.split(/(?:\r\n?|\n)/);for(let t=0,e=r.length;t<e;++t){let s=r[t];i.append(document.createTextNode(s)),t<e-1&&i.append(document.createElement("br"))}s.append(i)}else tt.render({xfaHtml:t,div:s,intent:"richText"});s.firstChild.classList.add("richText",i),r.append(s)}class tI{#r=null;#s=null;#n;#a=null;#o=null;#l=null;#h=null;#d=null;static #c=null;constructor(t){this.#n=t,tI.#c||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#r=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#n._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",tu,{signal:e}),t.addEventListener("pointerdown",tI.#u,{signal:e}));let i=this.#a=document.createElement("div");i.className="buttons",t.append(i);let r=this.#n.toolbarPosition;if(r){let{style:e}=t,i="ltr"===this.#n._uiManager.direction?1-r[0]:r[0];e.insetInlineEnd=`${100*i}%`,e.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#r}static #u(t){t.stopPropagation()}#p(t){this.#n._focusEventsAllowed=!1,tp(t)}#g(t){this.#n._focusEventsAllowed=!0,tp(t)}#f(t){let e=this.#n._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",tu,{signal:e}),!0)}hide(){this.#r.classList.add("hidden"),this.#s?.hideDropdown()}show(){this.#r.classList.remove("hidden"),this.#o?.shown(),this.#l?.shown()}
2addDeleteButton(){let{editorType:t,_uiManager:e}=this.#n,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",tI.#c[t]),this.#f(i)&&i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#a.append(i)}get #m(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#f(e),this.#a.append(e,this.#m),this.#o=t}addComment(t,e=null){if(this.#l)return;let i=t.renderForToolbar();if(!i)return;this.#f(i);let r=this.#h=this.#m;e?(this.#a.insertBefore(i,e),this.#a.insertBefore(r,e)):this.#a.append(i,r),this.#l=t,t.toolbar=this}addColorPicker(t){if(this.#s)return;this.#s=t;let e=t.renderButton();this.#f(e),this.#a.append(e,this.#m)}async addEditSignatureButton(t){let e=this.#d=await t.renderEditButton(this.#n);this.#f(e),this.#a.append(e,this.#m)}removeButton(t){"comment"===t&&(this.#l?.removeToolbarCommentButton(),this.#l=null,this.#h?.remove(),this.#h=null)}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e)}}async addButtonBefore(t,e,i){let r=this.#a.querySelector(i);r&&"comment"===t&&this.addComment(e,r)}updateEditSignatureButton(t){this.#d&&(this.#d.title=t)}remove(){this.#r.remove(),this.#s?.destroy(),this.#s=null}}class tR{#a=null;#r=null;#b;constructor(t){this.#b=t}#y(){let t=this.#r=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");let e=this.#b._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",tu,{signal:e});let i=this.#a=document.createElement("div");return i.className="buttons",t.append(i),this.#b.hasCommentManager()&&this.#v("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#b.commentSelection("floating_button")}),this.#v("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#b.highlightSelection("floating_button")}),t}#w(t,e){let i=0,r=0;for(let s of t){let t=s.y+s.height;if(t<i)continue;let n=s.x+(e?s.width:0);if(t>i){r=n,i=t;continue}e?n>r&&(r=n):n<r&&(r=n)}return[e?1-r:r,i]}show(t,e,i){let[r,s]=this.#w(e,i),{style:n}=this.#r||=this.#y();t.append(this.#r),n.insetInlineEnd=`${100*r}%`,n.top=`calc(${100*s}% + var(--editor-toolbar-vert-offset))`}hide(){this.#r.remove()}#v(t,e,i,r){let s=document.createElement("button");s.classList.add("basic",t),s.tabIndex=0,s.setAttribute("data-l10n-id",e);let n=document.createElement("span");s.append(n),n.className="visuallyHidden",n.setAttribute("data-l10n-id",i);let a=this.#b._signal;a instanceof AbortSignal&&!a.aborted&&(s.addEventListener("contextmenu",tu,{signal:a}),s.addEventListener("click",r,{signal:a})),this.#a.append(s)}}function tL(t,e,i){for(let r of i)e.addEventListener(r,t[r].bind(t))}class tB{#x=0;get id(){return`${b}${this.#x++}`}}class tF{#A=K();#x=0;#_=null;static get _isSVGFittingCanvas(){let 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>',R(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 #E(t,e){this.#_||=new Map;let i=this.#_.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.#A}_${this.#x++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await tr(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){let e=tF._isSVGFittingCanvas,r=new FileReader,s=new Image,n=new Promise((t,n)=>{s.onload=()=>{i.bitmap=s,i.isSvg=!0,t()},r.onload=async()=>{let t=i.svgUrl=r.result;s.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},s.onerror=r.onerror=n});r.readAsDataURL(t),await n}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){k(t),i=null}return this.#_.set(t,i),i&&this.#_.set(i.id,i),i}async getFromFile(t){let{lastModified:e,name:i,size:r,type:s}=t;return this.#E(`${e}_${i}_${r}_${s}`,t)}async getFromUrl(t){return this.#E(t,t)}async getFromBlob(t,e){let i=await e;return this.#E(t,i)}async getFromId(t){this.#_||=new Map;let e=this.#_.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){let{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#_||=new Map;let i=this.#_.get(t);if(i?.bitmap)return i.refCounter+=1,i;let r=new OffscreenCanvas(e.width,e.height);return r.getContext("2d").drawImage(e,0,0),i={bitmap:r.transferToImageBitmap(),id:`image_${this.#A}_${this.#x++}`,refCounter:1,isSvg:!1},this.#_.set(t,i),this.#_.set(i.id,i),i}getSvgUrl(t){let e=this.#_.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#_||=new Map;let e=this.#_.get(t);if(!e||(e.refCounter-=1,0!==e.refCounter))return;let{bitmap:i}=e;if(!e.url&&!e.file){let 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.#A}_`)}}class tN{#S=[];#C=!1;#T;#k=-1;constructor(t=128){this.#T=t}add({cmd:t,undo:e,post:i,mustExec:r,type:s=NaN,overwriteIfSameType:n=!1,keepUndo:a=!1}){if(r&&t(),this.#C)return;let o={cmd:t,undo:e,post:i,type:s};if(-1===this.#k){this.#S.length>0&&(this.#S.length=0),this.#k=0,this.#S.push(o);return}if(n&&this.#S[this.#k].type===s){a&&(o.undo=this.#S[this.#k].undo),this.#S[this.#k]=o;return}let l=this.#k+1;l===this.#T?this.#S.splice(0,1):(this.#k=l,l<this.#S.length&&this.#S.splice(l)),this.#S.push(o)}undo(){if(-1===this.#k)return;this.#C=!0;let{undo:t,post:e}=this.#S[this.#k];t(),e?.(),this.#C=!1,this.#k-=1}redo(){if(this.#k<this.#S.length-1){this.#k+=1,this.#C=!0;let{cmd:t,post:e}=this.#S[this.#k];t(),e?.(),this.#C=!1}}hasSomethingToUndo(){return -1!==this.#k}hasSomethingToRedo(){return this.#k<this.#S.length-1}cleanType(t){if(-1!==this.#k){for(let e=this.#k;e>=0;e--)if(this.#S[e].type!==t){this.#S.splice(e+1,this.#k-e),this.#k=e;return}this.#S.length=0,this.#k=-1}}destroy(){this.#S=null}}class tO{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=$.platform;for(const[i,r,s={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:r,options:s}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:r,options:s}),this.allKeys.add(t.split("+").at(-1)))}}#M(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);let e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;let i=this.callbacks.get(this.#M(e));if(!i)return;let{callback:r,options:{bubbles:s=!1,args:n=[],checker:a=null}}=i;(!a||a(t,e))&&(r.bind(t,...n,e)(),s||tp(e))}}class tU{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]),e=document.createElement("span");for(let i of(e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e),t.keys())){e.style.color=i;let r=window.getComputedStyle(e).color;t.set(i,tm(r))}return e.remove(),R(this,"_colors",t)}convert(t){let e=tm(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return tU._colorsMapping.get(t);return e}getHexCode(t){let e=this._colors.get(t);return e?V.makeHexColor(...e):t}}class tj{#P=new AbortController;#D=null;#I=null;#R=new Map;#L=new Map;#B=null;#F=null;#N=null;#O=new tN;#U=null;#j=null;#z=null;#H=0;#$=new Set;#G=null;#V=null;#W=new Set;_editorUndoBar=null;#q=!1;#X=!1;#K=!1;#Y=null;#J=null;#Q=null;#Z=null;#tt=!1;#te=null;#ti=new tB;#tr=!1;#ts=!1;#tn=!1;#ta=null;#to=null;#tl=null;#th=null;#td=null;#tc=y.NONE;#tu=new Set;#tp=null;#tg=null;#tf=null;#tm=null;#tb=null;#ty={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#tv=[0,0];#tw=null;#tx=null;#tA=null;#t_=null;#tE=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=tj.prototype,e=t=>t.#tx.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>
vendor: 4,857 bytes, line 2
2{if(e instanceof HTMLInputElement){let{type:t}=e;return"text"!==t&&"number"!==t}return!0},r=this.TRANSLATE_SMALL,s=this.TRANSLATE_BIG;return R(this,"_keyboardManager",new tO([[["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.#tx.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tx.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}]]))}constructor(t,e,i,r,s,n,a,o,l,h,d,c,u,p,g,f){const m=this._signal=this.#P.signal;this.#tx=t,this.#tA=e,this.#t_=i,this.#B=r,this.#U=s,this.#tg=n,this.#tb=o,this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:m}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),a._on("setpreference",this.onSetPreference.bind(this),{signal:m}),a._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:m}),window.addEventListener("pointerdown",()=>{this.#ts=!0},{capture:!0,signal:m}),window.addEventListener("pointerup",()=>{this.#ts=!1},{capture:!0,signal:m}),this.#tS(),this.#tC(),this.#tT(),this.#F=o.annotationStorage,this.#Y=o.filterFactory,this.#tf=l,this.#Z=h||null,this.#q=d,this.#X=c,this.#K=u,this.#td=p||null,this.viewParameters={realScale:ti.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==f,s?.setSidebarUiManager(this)}destroy(){for(let t of(this.#tE?.resolve(),this.#tE=null,this.#P?.abort(),this.#P=null,this._signal=null,this.#L.values()))t.destroy();this.#L.clear(),this.#R.clear(),this.#W.clear(),this.#th?.clear(),this.#D=null,this.#tu.clear(),this.#O.destroy(),this.#B?.destroy(),this.#U?.destroy(),this.#tg?.destroy(),this.#te?.hide(),this.#te=null,this.#tl?.destroy(),this.#tl=null,this.#I=null,this.#J&&(clearTimeout(this.#J),this.#J=null),this.#tw&&(clearTimeout(this.#tw),this.#tw=null),this._editorUndoBar?.destroy(),this.#tb=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#td}get useNewAltTextFlow(){return this.#X}get useNewAltTextWhenAddingImage(){return this.#K}get hcmFilter(){return R(this,"hcmFilter",this.#tf?this.#Y.addHCMFilter(this.#tf.foreground,this.#tf.background):"none")}get direction(){return R(this,"direction",getComputedStyle(this.#tx).direction)}get _highlightColors(){return R(this,"_highlightColors",this.#Z?new Map(this.#Z.split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return R(this,"highlightColors",null);let e=new Map,i=!!this.#tf;for(let[r,s]of t){let t=r.endsWith("_HCM");if(i&&t){e.set(r.replace("_HCM",""),s);continue}i||t||e.set(r,s)}return R(this,"highlightColors",e)}get highlightColorNames(){return R(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let 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.#z=t}setMainHighlightColorPicker(t){this.#tl=t}editAltText(t,e=!1){this.#B?.editAltText(this,t,e)}hasCommentManager(){return!!this.#U}editComment(t,e,i,r){this.#U?.showDialog(this,t,e,i,r)}selectComment(t,e){let i=this.#L.get(t),r=i?.getEditorByUID(e);r?.toggleComment(!0,!0)}updateComment(t){this.#U?.updateComment(t.getData())}updatePopupColor(t){this.#U?.updatePopupColor(t)}
2removeComment(t){this.#U?.removeComments([t.uid])}toggleComment(t,e,i){this.#U?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#U?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#U?.dialogElement||null}async waitForEditorsRendered(t){if(this.#L.has(t-1))return;let{resolve:e,promise:i}=Promise.withResolvers(),r=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",r),e())};this._eventBus.on("editorsrendered",r),await i}getSignature(t){this.#tg?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#tg}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.#K=e)}onPageChanging({pageNumber:t}){this.#H=t-1}focusMainContainer(){this.#tx.focus()}findParent(t,e){for(let i of this.#L.values()){let{x:r,y:s,width:n,height:a}=i.div.getBoundingClientRect();if(t>=r&&t<=r+n&&e>=s&&e<=s+a)return i}return null}disableUserSelect(t=!1){this.#tA.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#W.add(t)}removeShouldRescale(t){this.#W.delete(t)}onScaleChanging({scale:t}){for(let e of(this.commitOrRemove(),this.viewParameters.realScale=t*ti.PDF_TO_CSS_UNITS,this.#W))e.onScaleChanging();this.#z?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#tk({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#tM(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let e of this.#L.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){let i=document.getSelection();if(!i||i.isCollapsed)return;let{anchorNode:r,anchorOffset:s,focusNode:n,focusOffset:a}=i,o=i.toString(),l=this.#tk(i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();let d=this.#tM(l),c=this.#tc===y.NONE,u=()=>{let i=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:r,anchorOffset:s,focusNode:n,focusOffset:a,text:o});c&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};c?this.switchToMode(y.HIGHLIGHT,u):u()}commentSelection(t=""){this.highlightSelection(t,!0)}#tP(){let t=document.getSelection();if(!t||t.isCollapsed)return;let e=this.#tk(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#te||=new tR(this),this.#te.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#F)return null;let e=`${b}${t}`,i=this.#F.getRawValue(e);return i&&this.#F.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#F||this.#F.has(t.id)||this.#F.setValue(t.id,t)}a11yAlert(t,e=null){let i=this.#t_;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#tD(){let t=document.getSelection();if(!t||t.isCollapsed){this.#tp&&(this.#te?.hide(),this.#tp=null,this.#tI({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#tp)return;let i=this.#tk(t).closest(".textLayer");if(!i){this.#tp&&(this.#te?.hide(),this.#tp=null,this.#tI({hasSelectedText:!1}));return}if(this.#te?.hide(),this.#tp=e,this.#tI({hasSelectedText:!0}),(this.#tc===y.HIGHLIGHT||this.#tc===y.NONE)&&(this.#tc===y.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#tt=this.isShiftKeyDown,!this.isShiftKeyDown)){let t=this.#tc===y.HIGHLIGHT?this.#tM(i):null;if(t?.toggleDrawing(),this.#ts){let e=new AbortController,i=this.combinedSignal(e),r=i=>{("pointerup"!==i.type||0===i.button)&&(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#tR("main_toolbar"))};window.addEventListener("pointerup",r,{signal:i}),window.addEventListener("blur",r,{signal:i})}else t?.toggleDrawing(!0),this.#tR("main_toolbar")}}#tR(t=""){this.#tc===y.HIGHLIGHT?this.highlightSelection(t):this.#q&&this.#tP()}#tS(){document.addEventListener("selectionchange",this.#tD.bind(this),{signal:this._signal})}#tL(){if(this.#Q)return;this.#Q=new AbortController;let t=this.combinedSignal(this.#Q);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#tB(){this.#Q?.abort(),this.#Q=null}blur(){if(this.isShiftKeyDown=!1,this.#tt&&(this.#tt=!1,this.#tR("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#tu)if(e.div.contains(t)){this.#to=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#to)return;let[t,e]=this.#to;this.#to=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#tT(){if(this.#ta)return;this.#ta=new AbortController;let t=this.combinedSignal(this.#ta);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#tF(){this.#ta?.abort(),this.#ta=null}#tN(){if(this.#j)return;this.#j=new AbortController;let t=this.combinedSignal(this.#j);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})}#tO(){this.#j?.abort(),this.#j=null}#tC(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#tT(),this.#tN()}removeEditListeners(){this.#tF(),this.#tO()}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let i of this.#V)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let i of this.#V)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#D?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let t of this.#tu){let 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();let{clipboardData:e}=t;for(let t of e.items)for(let e of this.#V)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){k(`paste: "${t.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let r=this.currentLayer;try{let t=[];for(let e of i){let i=await r.deserialize(e);if(!i)return;t.push(i)}let e=()=>{for(let e of t)this.#tU(e);this.#tj(t)};this.addCommands({cmd:e,undo:()=>{for(let e of t)e.remove()},mustExec:!0})}catch(t){k(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#tc===y.NONE||this.isEditorHandlingKeyboard||tj._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#tt&&(this.#tt=!1,this.#tR("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")}}#tI(t){Object.entries(t).some(([t,e])=>this.#ty[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#ty,t)}),this.#tc===y.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#tz([[v.HIGHLIGHT_FREE,!0]]))}#tz(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#tL(),this.#tN(),this.#tI({isEditing:this.#tc!==y.NONE,isEmpty:this.#tH(),hasSomethingToUndo:this.#O.hasSomethingToUndo(),hasSomethingToRedo:this.#O.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#tB(),this.#tO(),this.#tI({isEditing:!1}),this.disableUserSelect(!1))}
2registerEditorTypes(t){if(!this.#V)for(let e of(this.#V=t,this.#V))this.#tz(e.defaultPropertiesToUpdate)}getId(){return this.#ti.id}get currentLayer(){return this.#L.get(this.#H)}getLayer(t){return this.#L.get(t)}get currentPageIndex(){return this.#H}addLayer(t){this.#L.set(t.pageIndex,t),this.#tr?t.enable():t.disable()}removeLayer(t){this.#L.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,r=!1,s=!1){if(this.#tc!==t&&(!this.#tE||(await this.#tE.promise,this.#tE))){if(this.#tE=Promise.withResolvers(),this.#z?.commitOrRemove(),this.#tc===y.POPUP&&this.#U?.hideSidebar(),this.#U?.destroyPopup(),this.#tc=t,t===y.NONE){for(let t of(this.setEditingState(!1),this.#t$(),this.#R.values()))t.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#tE.resolve();return}for(let t of this.#R.values())t.addStandaloneCommentButton();for(let e of(t===y.SIGNATURE&&await this.#tg?.loadSignatures(),this.setEditingState(!0),await this.#tG(),this.unselectAll(),this.#L.values()))e.updateMode(t);if(t===y.POPUP){this.#I||=await this.#tb.getAnnotationsByType(new Set(this.#V.map(t=>t._editorType)));let t=new Set,e=[];for(let i of this.#R.values()){let{annotationElementId:r,hasComment:s,deleted:n}=i;r&&t.add(r),s&&!n&&e.push(i.getData())}for(let i of this.#I){let{id:r,popupRef:s,contentsObj:n}=i;s&&n?.str&&!t.has(r)&&!this.#$.has(r)&&e.push(i)}this.#U?.showSidebar(e)}if(!e){i&&this.addNewEditorFromKeyboard(),this.#tE.resolve();return}for(let t of this.#R.values())t.uid===e?(this.setSelected(t),s?t.editComment():r?t.enterInEditMode():t.focus()):t.unselect();this.#tE.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#tc&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#V){switch(t){case v.CREATE:this.currentLayer.addNewEditor(e);return;case v.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#tm||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(let i of this.#tu)i.updateParams(t,e);else for(let i of this.#V)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(let i of this.#R.values())i.editorType===t&&i.show(e);(this.#tm?.get(v.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#tz([[v.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tn!==t)for(let e of(this.#tn=t,this.#L.values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}async #tG(){if(!this.#tr){this.#tr=!0;let t=[];for(let e of this.#L.values())t.push(e.enable());for(let e of(await Promise.all(t),this.#R.values()))e.enable()}}#t$(){if(this.unselectAll(),this.#tr){for(let t of(this.#tr=!1,this.#L.values()))t.disable();for(let t of this.#R.values())t.disable()}}*getEditors(t){for(let e of this.#R.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#R.get(t)}addEditor(t){this.#R.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#J&&clearTimeout(this.#J),this.#J=setTimeout(()=>{this.focusMainContainer(),this.#J=null},0)),this.#R.delete(t.id),t.annotationElementId&&this.#th?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#$.has(t.annotationElementId)||this.#F?.remove(t.id)}addDeletedAnnotationElement(t){this.#$.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#$.has(t)}removeDeletedAnnotationElement(t){this.#$.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tU(t){let e=this.#L.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#D!==t&&(this.#D=t,t&&this.#tz(t.propertiesToUpdate))}get #tV(){let t=null;for(t of this.#tu);return t}updateUI(t){this.#tV===t&&this.#tz(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#tz(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#tu.has(t)){this.#tu.delete(t),t.unselect(),this.#tI({hasSelectedEditor:this.hasSelection});return}this.#tu.add(t),t.select(),this.#tz(t.propertiesToUpdate),this.#tI({hasSelectedEditor:!0})}setSelected(t){for(let e of(this.updateToolbar({mode:t.mode,editId:t.id}),this.#z?.commitOrRemove(),this.#tu))e!==t&&e.unselect();this.#tu.clear(),this.#tu.add(t),t.select(),this.#tz(t.propertiesToUpdate),this.#tI({hasSelectedEditor:!0})}isSelected(t){return this.#tu.has(t)}get firstSelectedEditor(){return this.#tu.values().next().value}unselect(t){t.unselect(),this.#tu.delete(t),this.#tI({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#tu.size}get isEnterHandled(){return 1===this.#tu.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#O.undo(),this.#tI({hasSomethingToUndo:this.#O.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#tH()}),this._editorUndoBar?.hide()}redo(){this.#O.redo(),this.#tI({hasSomethingToUndo:!0,hasSomethingToRedo:this.#O.hasSomethingToRedo(),isEmpty:this.#tH()})}addCommands(t){this.#O.add(t),this.#tI({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#tH()})}cleanUndoStack(t){this.#O.cleanType(t)}#tH(){if(0===this.#R.size)return!0;
2if(1===this.#R.size)for(let t of this.#R.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#tu],i=()=>{for(let t of(this._editorUndoBar?.show(r,1===e.length?e[0].editorType:e.length),e))t.remove()},r=()=>{for(let t of e)this.#tU(t)};this.addCommands({cmd:i,undo:r,mustExec:!0})}commitOrRemove(){this.#D?.commitOrRemove()}hasSomethingToControl(){return this.#D||this.hasSelection}#tj(t){for(let t of this.#tu)t.unselect();for(let e of(this.#tu.clear(),t))e.isEmpty()||(this.#tu.add(e),e.select());this.#tI({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#tu)t.commit();this.#tj(this.#R.values())}unselectAll(){if(!this.#D||(this.#D.commitOrRemove(),this.#tc===y.NONE)){if(!this.#z?.commitOrRemove()&&this.hasSelection){for(let t of this.#tu)t.unselect();this.#tu.clear(),this.#tI({hasSelectedEditor:!1})}}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#tv[0]+=t,this.#tv[1]+=e;let[r,s]=this.#tv,n=[...this.#tu];for(let i of(this.#tw&&clearTimeout(this.#tw),this.#tw=setTimeout(()=>{this.#tw=null,this.#tv[0]=this.#tv[1]=0,this.addCommands({cmd:()=>{for(let t of n)this.#R.has(t.id)&&(t.translateInPage(r,s),t.translationDone())},undo:()=>{for(let t of n)this.#R.has(t.id)&&(t.translateInPage(-r,-s),t.translationDone())},mustExec:!1})},1e3),n))i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection)for(let t of(this.disableUserSelect(!0),this.#G=new Map,this.#tu))this.#G.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#G)return!1;this.disableUserSelect(!1);let t=this.#G;this.#G=null;let e=!1;for(let[{x:i,y:r,pageIndex:s},n]of t)n.newX=i,n.newY=r,n.newPageIndex=s,e||=i!==n.savedX||r!==n.savedY||s!==n.savedPageIndex;if(!e)return!1;let i=(t,e,i,r)=>{if(this.#R.has(t.id)){let s=this.#L.get(r);s?t._setParentAndPosition(s,e,i):(t.pageIndex=r,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(let[e,{newX:r,newY:s,newPageIndex:n}]of t)i(e,r,s,n)},undo:()=>{for(let[e,{savedX:r,savedY:s,savedPageIndex:n}]of t)i(e,r,s,n)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#G)for(let i of this.#G.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){let 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.#tu.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#D===t}getActive(){return this.#D}getMode(){return this.#tc}isEditingMode(){return this.#tc!==y.NONE}get imageManager(){return R(this,"imageManager",new tF)}getSelectionBoxes(t){let e;if(!t)return null;let i=document.getSelection();for(let e=0,r=i.rangeCount;e<r;e++)if(!t.contains(i.getRangeAt(e).commonAncestorContainer))return null;let{x:r,y:s,width:n,height:a}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":e=(t,e,i,o)=>({x:(e-s)/a,y:1-(t+i-r)/n,width:o/a,height:i/n});break;case"180":e=(t,e,i,o)=>({x:1-(t+i-r)/n,y:1-(e+o-s)/a,width:i/n,height:o/a});break;case"270":e=(t,e,i,o)=>({x:1-(e+o-s)/a,y:(t-r)/n,width:o/a,height:i/n});break;default:e=(t,e,i,o)=>({x:(t-r)/n,y:(e-s)/a,width:i/n,height:o/a})}let o=[];for(let t=0,r=i.rangeCount;t<r;t++){let r=i.getRangeAt(t);if(!r.collapsed)for(let{x:t,y:i,width:s,height:n}of r.getClientRects())0!==s&&0!==n&&o.push(e(t,i,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#N||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#N?.delete(t)}renderAnnotationElement(t){let e=this.#N?.get(t.data.id);if(!e)return;let i=this.#F.getRawValue(e);!i||(this.#tc!==y.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){let r=this.#th?.get(t);r&&(r.setCanvas(e,i),this.#th.delete(t))}addMissingCanvas(t,e){(this.#th||=new Map).set(t,e)}}class tz{#o=null;#tW=!1;#tq=null;#tX=null;#tK=null;#tY=null;#tJ=!1;#tQ=null;#n=null;#tZ=null;#t0=null;#t1=!1;static #t2=null;static _l10n=null;constructor(t){this.#n=t,this.#t1=t._uiManager.useNewAltTextFlow,tz.#t2||=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){tz._l10n??=t}async render(){let t=this.#tq=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#tX=document.createElement("span");t.append(e),this.#t1?(t.classList.add("new"),t.setAttribute("data-l10n-id",tz.#t2.missing),e.setAttribute("data-l10n-id",tz.#t2["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#n._uiManager._signal;t.addEventListener("contextmenu",tu,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let r=t=>{t.preventDefault(),this.#n._uiManager.editAltText(this.#n),this.#t1&&this.#n._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#t3}})};return t.addEventListener("click",r,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#tJ=!0,r(e))},{signal:i}),await this.#t5(),t}get #t3(){return this.#o&&"added"||null===this.#o&&this.guessedText&&"review"||"missing"}finish(){this.#tq&&(this.#tq.focus({focusVisible:this.#tJ}),this.#tJ=!1)}isEmpty(){return this.#t1?null===this.#o:!this.#o&&!this.#tW}hasData(){return this.#t1?null!==this.#o||!!this.#tZ:this.isEmpty()}get guessedText(){return this.#tZ}async setGuessedText(t){null===this.#o&&(this.#tZ=t,this.#t0=await tz._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#t5())}toggleAltTextBadge(t=!1){if(!this.#t1||this.#o){this.#tQ?.remove(),this.#tQ=null;return}if(!this.#tQ){let t=this.#tQ=document.createElement("div");t.className="noAltTextBadge",this.#n.div.append(t)}this.#tQ.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#tZ!==e||(e=this.#t0),{altText:e,decorative:this.#tW,guessedText:this.#tZ,textWithDisclaimer:this.#t0}}get data(){return{altText:this.#o,decorative:this.#tW}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:r,cancel:s=!1}){i&&(this.#tZ=i,this.#t0=r),(this.#o!==t||this.#tW!==e)&&(s||(this.#o=t,this.#tW=e),this.#t5())}toggle(t=!1){this.#tq&&(!t&&this.#tY&&(clearTimeout(this.#tY),this.#tY=null),this.#tq.disabled=!t)}shown(){this.#n._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#t3}})}destroy(){this.#tq?.remove(),this.#tq=null,this.#tX=null,this.#tK=null,this.#tQ?.remove(),this.#tQ=null}async #t5(){let t=this.#tq;if(!t)return;if(this.#t1){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",tz.#t2[this.#t3]),this.#tX?.setAttribute("data-l10n-id",tz.#t2[`${this.#t3}-label`]),!this.#o)return void this.#tK?.remove()}else{if(!this.#o&&!this.#tW){t.classList.remove("done"),this.#tK?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#tK;if(!e){this.#tK=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#n.id}`;let i=this.#n._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#tY),this.#tY=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#tY=setTimeout(()=>{this.#tY=null,this.#tK.classList.add("show"),this.#n._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#tY&&(clearTimeout(this.#tY),this.#tY=null),this.#tK?.classList.remove("show")},{signal:i})}this.#tW?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);let i=this.#n.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class tH{#t6=null;#t4=null;#t8=!1;#n=null;#t7=null;#t9=null;#et=null;#ee=null;#ei=!1;#er=null;constructor(t){this.#n=t}renderForToolbar(){let t=this.#t4=document.createElement("button");
vendor: 9,619 bytes, line 2
2return t.className="comment",this.#y(t,!1)}renderForStandalone(){let t=this.#t6=document.createElement("button");t.className="annotationCommentButton";let e=this.#n.commentButtonPosition;if(e){let{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#n._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let r=this.#n.commentButtonColor;r&&(i.backgroundColor=r)}return this.#y(t,!0)}focusButton(){setTimeout(()=>{(this.#t6??this.#t4)?.focus()},0)}onUpdatedColor(){if(!this.#t6)return;let t=this.#n.commentButtonColor;t&&(this.#t6.style.backgroundColor=t),this.#n._uiManager.updatePopupColor(this.#n)}get commentButtonWidth(){return(this.#t6?.getBoundingClientRect().width??0)/this.#n.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#er)return this.#er;if(!this.#t6)return null;let{x:t,y:e,height:i}=this.#t6.getBoundingClientRect(),{x:r,y:s,width:n,height:a}=this.#n.parent.boundingClientRect;return[(t-r)/n,(e+i-s)/a]}set commentPopupPositionInLayer(t){this.#er=t}hasDefaultPopupPosition(){return null===this.#er}removeStandaloneCommentButton(){this.#t6?.remove(),this.#t6=null}removeToolbarCommentButton(){this.#t4?.remove(),this.#t4=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t6&&(this.#t6.classList.toggle("selected",t),this.#t6.ariaExpanded=e)}#y(t,e){if(!this.#n._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.#n._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));let i=this.#n._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",tu,{signal:i}),e&&(t.addEventListener("focusin",t=>{this.#n._focusEventsAllowed=!1,tp(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{this.#n._focusEventsAllowed=!0,tp(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let r=e=>{e.preventDefault(),t===this.#t4?this.edit():this.#n.toggleComment(!0)};return t.addEventListener("click",r,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#t8=!0,r(e))},{signal:i}),t.addEventListener("pointerenter",()=>{this.#n.toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{this.#n.toggleComment(!1,!1)},{signal:i}),t}edit(t){let e,i,r=this.commentPopupPositionInLayer;if(r)[e,i]=r;else{[e,i]=this.#n.commentButtonPosition;let{width:t,height:r,x:s,y:n}=this.#n;e=s+e*t,i=n+i*r}let s=this.#n.parent.boundingClientRect,{x:n,y:a,width:o,height:l}=s;this.#n._uiManager.editComment(this.#n,n+e*o,a+i*l,{...t,parentDimensions:s})}finish(){this.#t4&&(this.#t4.focus({focusVisible:this.#t8}),this.#t8=!1)}isDeleted(){return this.#ei||""===this.#et}isEmpty(){return null===this.#et}hasBeenEdited(){return this.isDeleted()||this.#et!==this.#t7}serialize(){return this.data}get data(){return{text:this.#et,richText:this.#t9,date:this.#ee,deleted:this.isDeleted()}}set data(t){if(t!==this.#et&&(this.#t9=null),null===t){this.#et="",this.#ei=!0;return}this.#et=t,this.#ee=new Date,this.#ei=!1}setInitialText(t,e=null){this.#t7=t,this.data=t,this.#ee=null,this.#t9=e}shown(){}destroy(){this.#t4?.remove(),this.#t4=null,this.#t6?.remove(),this.#t6=null,this.#et="",this.#t9=null,this.#ee=null,this.#n=null,this.#t8=!1,this.#ei=!1}}class t${#tx;#es=!1;#en=null;#ea;#eo;#el;#eh;#ed=null;#ec;#eu=null;#ep;#eg=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:r=null,onPinching:s=null,onPinchEnd:n=null,signal:a}){this.#tx=t,this.#en=i,this.#ea=e,this.#eo=r,this.#el=s,this.#eh=n,this.#ep=new AbortController,this.#ec=AbortSignal.any([a,this.#ep.signal]),t.addEventListener("touchstart",this.#ef.bind(this),{passive:!1,signal:this.#ec})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/tw.pixelRatio}#ef(t){if(this.#ea?.())return;if(1===t.touches.length){if(this.#ed)return;let t=this.#ed=new AbortController,e=AbortSignal.any([this.#ec,t.signal]),i=this.#tx,r={capture:!0,signal:e,passive:!1},s=t=>{"touch"===t.pointerType&&(this.#ed?.abort(),this.#ed=null)};i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(tp(t),s(t))},r),i.addEventListener("pointerup",s,r),i.addEventListener("pointercancel",s,r);return}if(!this.#eg){this.#eg=new AbortController;let t=AbortSignal.any([this.#ec,this.#eg.signal]),e=this.#tx,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#em.bind(this),i);let r=this.#eb.bind(this);e.addEventListener("touchend",r,i),e.addEventListener("touchcancel",r,i),i.capture=!0,e.addEventListener("pointerdown",tp,i),e.addEventListener("pointermove",tp,i),e.addEventListener("pointercancel",tp,i),e.addEventListener("pointerup",tp,i),this.#eo?.()}if(tp(t),2!==t.touches.length||this.#en?.()){this.#eu=null;return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#eu={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#em(t){if(!this.#eu||2!==t.touches.length)return;tp(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);let{screenX:r,screenY:s}=e,{screenX:n,screenY:a}=i,o=this.#eu,{touch0X:l,touch0Y:h,touch1X:d,touch1Y:c}=o,u=Math.hypot(n-r,a-s)||1,p=Math.hypot(d-l,c-h)||1;if(!this.#es&&Math.abs(p-u)<=t$.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=r,o.touch0Y=s,o.touch1X=n,o.touch1Y=a,!this.#es){this.#es=!0;return}let g=[(r+n)/2,(s+a)/2];this.#el?.(g,p,u)}#eb(t){t.touches.length>=2||(this.#eg&&(this.#eg.abort(),this.#eg=null,this.#eh?.()),this.#eu&&(tp(t),this.#eu=null,this.#es=!1))}destroy(){this.#ep?.abort(),this.#ep=null,this.#ed?.abort(),this.#ed=null}}class tG{#ey=null;#ev=null;#o=null;#l=null;#t6=null;#ew=!1;#ex=null;#eA="";#e_=null;#eE=null;#eS=null;#eC=null;#eT=null;#ek="";#eM=!1;#eP=null;#eD=!1;#eI=!1;#eR=!1;#eL=null;#eB=0;#eF=0;#eN=null;#eO=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;#eU=!1;#ej=tG._zIndex++;static _borderLineWidth=-1;static _colorManager=new tU;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=tG.prototype._resizeWithKeyboard,e=tj.TRANSLATE_SMALL,i=tj.TRANSLATE_BIG;return R(this,"_resizerKeyboardManager",new tO([[["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"],tG.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:r,pageX:s,pageY:n}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,r],this.pageTranslation=[s,n];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return R(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new tV({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(tG._l10n??=t,tG._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!==tG._borderLineWidth)return;let i=getComputedStyle(document.documentElement);tG._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){M("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#eU}set _isDraggable(t){this.#eU=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[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}
vendor: 4,730 bytes, line 2
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#ej}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#ez(),this.#eC?.remove(),this.#eC=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#eM?this.#eM=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let 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,r){let[s,n]=this.parentDimensions;[i,r]=this.screenToPageTranslation(i,r),this.x=(t+i)/s,this.y=(e+r)/n,this.fixAndSetPosition()}_moveAfterPaste(t,e){let[i,r]=this.parentDimensions;this.setAt(t*i,e*r,this.width*i,this.height*r),this._onTranslated()}#eH([t,e],i,r){[i,r]=this.screenToPageTranslation(i,r),this.x+=i/t,this.y+=r/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#eH(this.parentDimensions,t,e)}translateInPage(t,e){this.#eP||=[this.x,this.y,this.width,this.height],this.#eH(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#eP||=[this.x,this.y,this.width,this.height];let{div:i,parentDimensions:[r,s]}=this;if(this.x+=t/r,this.y+=e/s,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{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:n,y:a}=this,[o,l]=this.getBaseTranslation();n+=o,a+=l;let{style:h}=i;h.left=`${(100*n).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(n,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#eP&&(this.#eP[0]!==this.x||this.#eP[1]!==this.y)}get _hasBeenResized(){return!!this.#eP&&(this.#eP[2]!==this.width||this.#eP[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:i}=tG,r=i/t,s=i/e;switch(this.rotation){case 90:return[-r,s];case 180:return[r,s];case 270:return[r,-s];default:return[-r,-s]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[i,r]}=this,{x:s,y:n,width:a,height:o}=this;if(a*=i,o*=r,s*=i,n*=r,this._mustFixPosition)switch(t){case 0:s=J(s,0,i-a),n=J(n,0,r-o);break;case 90:s=J(s,0,i-o),n=J(n,a,r);break;case 180:s=J(s,a,i),n=J(n,o,r);break;case 270:s=J(s,o,i),n=J(n,0,r-a)}this.x=s/=i,this.y=n/=r;let[l,h]=this.getBaseTranslation();s+=l,n+=h,e.left=`${(100*s).toFixed(2)}%`,e.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static #e$(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 tG.#e$(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return tG.#e$(t,e,360-this.parentRotation)}#eG(t){switch(t){case 90:{let[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{let[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(){let{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){let{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#eV(){if(this.#e_)return;this.#e_=document.createElement("div"),this.#e_.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let i of t){let t=document.createElement("div");this.#e_.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#eW.bind(this,i),{signal:e}),t.addEventListener("contextmenu",tu,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#e_)}#eW(t,e){e.preventDefault();let{isMac:i}=$.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);let r=this._isDraggable;this._isDraggable=!1,this.#eE=[e.screenX,e.screenY];let s=new AbortController,n=this._uiManager.combinedSignal(s);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#eq.bind(this,t),{passive:!0,capture:!0,signal:n}),window.addEventListener("touchmove",tp,{passive:!1,signal:n}),window.addEventListener("contextmenu",tu,{signal:n}
2),this.#eS={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{s.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#eX()};window.addEventListener("pointerup",l,{signal:n}),window.addEventListener("blur",l,{signal:n})}#eK(t,e,i,r){this.width=i,this.height=r,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#eX(){if(!this.#eS)return;let{savedX:t,savedY:e,savedWidth:i,savedHeight:r}=this.#eS;this.#eS=null;let s=this.x,n=this.y,a=this.width,o=this.height;(s!==t||n!==e||a!==i||o!==r)&&this.addCommands({cmd:this.#eK.bind(this,s,n,a,o),undo:this.#eK.bind(this,t,e,i,r),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#eq(t,e){let i,r,s,n,a,o,[l,h]=this.parentDimensions,d=this.x,c=this.y,u=this.width,p=this.height,g=tG.MIN_SIZE/l,f=tG.MIN_SIZE/h,m=this.#eG(this.rotation),b=(t,e)=>[m[0]*t+m[2]*e,m[1]*t+m[3]*e],y=this.#eG(360-this.rotation),v=!1,w=!1;switch(t){case"topLeft":v=!0,i=(t,e)=>[0,0],r=(t,e)=>[t,e];break;case"topMiddle":i=(t,e)=>[t/2,0],r=(t,e)=>[t/2,e];break;case"topRight":v=!0,i=(t,e)=>[t,0],r=(t,e)=>[0,e];break;case"middleRight":w=!0,i=(t,e)=>[t,e/2],r=(t,e)=>
2[0,e/2];break;case"bottomRight":v=!0,i=(t,e)=>[t,e],r=(t,e)=>[0,0];break;case"bottomMiddle":i=(t,e)=>[t/2,e],r=(t,e)=>[t/2,0];break;case"bottomLeft":v=!0,i=(t,e)=>[0,e],r=(t,e)=>[t,0];break;case"middleLeft":w=!0,i=(t,e)=>[0,e/2],r=(t,e)=>[t,e/2]}let x=i(u,p),A=r(u,p),_=b(...A),E=tG._round(d+_[0]),S=tG._round(c+_[1]),C=1,T=1;if(e.fromKeyboard)({deltaX:s,deltaY:n}=e);else{let{screenX:t,screenY:i}=e,[r,a]=this.#eE;[s,n]=this.screenToPageTranslation(t-r,i-a),this.#eE[0]=t,this.#eE[1]=i}if([s,n]=(a=s/l,o=n/h,[y[0]*a+y[2]*o,y[1]*a+y[3]*o]),v){let t=Math.hypot(u,p);C=T=Math.max(Math.min(Math.hypot(A[0]-x[0]-s,A[1]-x[1]-n)/t,1/u,1/p),g/u,f/p)}else w?C=J(Math.abs(A[0]-x[0]-s),g,1)/u:T=J(Math.abs(A[1]-x[1]-n),f,1)/p;let k=tG._round(u*C),M=tG._round(p*T),P=E-(_=b(...r(k,M)))[0],D=S-_[1];this.#eP||=[this.x,this.y,this.width,this.height],this.width=k,this.height=M,this.x=P,this.y=D,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#eI)return this._editToolbar;this._editToolbar=new tI(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[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.#o?.destroy()}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return!this.#o&&(tz.initialize(tG._l10n),this.#o=new tz(this),this.#ey&&(this.#o.data=this.#ey,this.#ey=null)),this.#o}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await this.#o?.setGuessedText(t)}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}focusCommentButton(){this.#l?.focusButton()}addCommentButton(){return this.#l||=new tH(this)}addStandaloneCommentButton(){if(this.#t6){this._uiManager.isEditingMode()&&this.#t6.classList.remove("hidden");return}this.hasComment&&(this.#t6=this.#l.renderForStandalone(),this.div.append(this.#t6))}removeStandaloneCommentButton(){this.#l.removeStandaloneCommentButton(),this.#t6=null}hideStandaloneCommentButton(){this.#t6?.classList.add("hidden")}get comment(){let{data:{richText:t,text:e,date:i,deleted:r}}=this.#l;return{text:e,richText:t,date:i,deleted:r,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#l||=new tH(this),this.#l.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||(this.#l||=new tH(this),this.#l.setInitialText(t,i),!this.annotationElementId))return;let r=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);r&&this.updateFromAnnotationLayer(r)}get hasEditedComment(){return this.#l?.hasBeenEdited()}get hasDeletedComment(){return this.#l?.isDeleted()}get hasComment(){return!!this.#l&&!this.#l.isEmpty()&&!this.#l.isDeleted()}async editComment(t){this.#l||=new tH(this),this.#l.edit(t)}toggleComment(t,e){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#l.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,e]=t.rect,[i]=this.pageDimensions,[r]=this.pageTranslation,s=r+i+1;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[s,e-100,s+180,e]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#l.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let 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.#ew?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#eY();let[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);let[r,s]=this.getInitialTranslation();return this.translate(r,s),tL(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#eO||=new t$({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#eJ.bind(this),onPinching:this.#eQ.bind(this),onPinchEnd:this.#eZ.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}
2#eJ(){this.#eS={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#eQ(t,e,i){let r=i/e*.7+1-.7;if(1===r)return;let s=this.#eG(this.rotation),n=(t,e)=>[s[0]*t+s[2]*e,s[1]*t+s[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height;r=Math.max(Math.min(r,1/d,1/c),tG.MIN_SIZE/a/d,tG.MIN_SIZE/o/c);let u=tG._round(d*r),p=tG._round(c*r);if(u===d&&p===c)return;this.#eP||=[l,h,d,c];let g=n(d/2,c/2),f=tG._round(l+g[0]),m=tG._round(h+g[1]),b=n(u/2,p/2);this.x=f-b[0],this.y=m-b[1],this.width=u,this.height=p,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#eZ(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#eX()}pointerdown(t){let{isMac:e}=$.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#eM=!0,this._isDraggable)?this.#e0(t):this.#e1(t)}#e1(t){let{isMac:e}=$.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#e0(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1,r=new AbortController,s=this._uiManager.combinedSignal(r),n={capture:!0,passive:!1,signal:s},a=t=>{r.abort(),this.#ex=null,this.#eM=!1,this._uiManager.endDragSession()||this.#e1(t),i&&this._onStopDragging()};e&&(this.#eB=t.clientX,this.#eF=t.clientY,this.#ex=t.pointerId,this.#eA=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:e,clientY:r,pointerId:s}=t;if(s!==this.#ex)return void tp(t);let[n,a]=this.screenToPageTranslation(e-this.#eB,r-this.#eF);this.#eB=e,this.#eF=r,this._uiManager.dragSelectedEditors(n,a)},n),window.addEventListener("touchmove",tp,n),window.addEventListener("pointerdown",t=>{t.pointerType===this.#eA&&(this.#eO||t.isPrimary)&&a(t),tp(t)},n));let o=t=>{this.#ex&&this.#ex!==t.pointerId?tp(t):a(t)};window.addEventListener("pointerup",o,{signal:s}),window.addEventListener("blur",o,{signal:s})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#eL&&clearTimeout(this.#eL),this.#eL=setTimeout(()=>{this.#eL=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){let r=this.parentScale,[s,n]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/r,h=e/r,d=this.x*s,c=this.y*n,u=this.width*s,p=this.height*n;switch(i){case 0:return[d+l+a,n-c-h-p+o,d+l+u+a,n-c-h+o];case 90:return[d+h+a,n-c+l+o,d+h+p+a,n-c+l+u+o];case 180:return[d-l-u+a,n-c+h+o,d-l+a,n-c+h+p+o];case 270:return[d-h-p+a,n-c-l-u+o,d-h+a,n-c-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[i,r,s,n]=t,a=s-i,o=n-r;switch(this.rotation){case 0:return[i,e-n,a,o];case 90:return[i,e-r,o,a];case 180:return[s,e-r,a,o];case 270:return[s,e-n,o,a];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&tG._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#l?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:i,opacity:r,deleted:s,richText:n},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:n,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!s,color:e,opacity:r}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#eI=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#eI=!1,!0)}isInEditMode(){return this.#eI}shouldGetKeyboardEvents(){return this.#eR}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:i,right:r}=this.getClientDimensions(),{innerHeight:s,innerWidth:n}=window;return e<n&&r>0&&t<s&&i>0}#eY(){if(this.#eT||!this.div)return;this.#eT=new AbortController;let t=this._uiManager.combinedSignal(this.#eT);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#eY()}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){let r=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});r.rotation=t.rotation,r.#ey=t.accessibilityData,r._isCopy=t.isCopy||!1;let[s,n]=r.pageDimensions,[a,o,l,h]=r.getRectInCurrentCoords(t.rect,n);
2return r.x=a/s,r.y=o/n,r.width=l/s,r.height=h/n,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#eT?.abort(),this.#eT=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#eL&&(clearTimeout(this.#eL),this.#eL=null),this.#ez(),this.removeEditToolbar(),this.#eN){for(let t of this.#eN.values())clearTimeout(t);this.#eN=null}this.parent=null,this.#eO?.destroy(),this.#eO=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#eV(),this.#e_.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[i,r,s,n]=this.getPDFRect();return[tG._round(i+(s-i)*t),tG._round(r+(n-r)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#l.commentPopupPositionInLayer}set commentPopupPosition(t){this.#l.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#l.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#l.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#l.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#eS={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#e_.children;if(!this.#ev){this.#ev=Array.from(e);let t=this.#e2.bind(this),i=this.#e3.bind(this),r=this._uiManager._signal;for(let e of this.#ev){let s=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:r}),e.addEventListener("blur",i,{signal:r}),e.addEventListener("focus",this.#e5.bind(this,s),{signal:r}),e.setAttribute("data-l10n-id",tG._l10nResizer[s])}}let i=this.#ev[0],r=0;for(let t of e){if(t===i)break;r++}let s=(360-this.rotation+this.parentRotation)%360/90*(this.#ev.length/4);if(s!==r){if(s<r)for(let t=0;t<r-s;t++)this.#e_.append(this.#e_.firstChild);else if(s>r)for(let t=0;t<s-r;t++)this.#e_.firstChild.before(this.#e_.lastChild);let t=0;for(let i of e){let e=this.#ev[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",tG._l10nResizer[e])}}this.#e6(0),this.#eR=!0,this.#e_.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#e2(t){tG._resizerKeyboardManager.exec(this,t)}#e3(t){this.#eR&&t.relatedTarget?.parentNode!==this.#e_&&this.#ez()}#e5(t){this.#ek=this.#eR?t:""}#e6(t){if(this.#ev)for(let e of this.#ev)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#eR&&this.#eq(this.#ek,{deltaX:t,deltaY:e,fromKeyboard:!0})}#ez(){this.#eR=!1,this.#e6(-1),this.#eX()}_stopResizingWithKeyboard(){this.#ez(),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.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#e_?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#eD}set isEditing(t){this.#eD=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.#eN||=new Map;let{action:e}=t,i=this.#eN.get(e);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#eN.delete(e),0===this.#eN.size&&(this.#eN=null)},tG._telemetryTimeout),this.#eN.set(e,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}
2show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#ew=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ew=!0}updateFakeAnnotationElement(t){if(!this.#eC&&!this.deleted){this.#eC=t.addFakeAnnotation(this);return}if(this.deleted){this.#eC.remove(),this.#eC=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#eC.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){let t=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){let{firstChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class tV extends tG{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}class tW{constructor(t){this.h1=t?0|t:0xc3d2e1f0,this.h2=t?0|t:0xc3d2e1f0}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let r=0,s=t.length;r<s;r++){let s=t.charCodeAt(r);s<=255?e[i++]=s:(e[i++]=s>>>8,e[i++]=255&s)}}else if(ArrayBuffer.isView(t))i=(e=t.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let r=i>>2,s=i-4*r,n=new Uint32Array(e.buffer,0,r),a=0,o=0,l=this.h1,h=this.h2;for(let t=0;t<r;t++)1&t?(l^=a=0x1b873593*(a=(a=0xcc9e2d51*(a=n[t])&0xffff0000|11601*a&65535)<<15|a>>>17)&0xffff0000|13715*a&65535,l=5*(l=l<<13|l>>>19)+0xe6546b64):(h^=o=0x1b873593*(o=(o=0xcc9e2d51*(o=n[t])&0xffff0000|11601*o&65535)<<15|o>>>17)&0xffff0000|13715*o&65535,h=5*(h=h<<13|h>>>19)+0xe6546b64);switch(a=0,s){case 3:a^=e[4*r+2]<<16;case 2:a^=e[4*r+1]<<8;case 1:a^=e[4*r],a=0x1b873593*(a=(a=0xcc9e2d51*a&0xffff0000|11601*a&65535)<<15|a>>>17)&0xffff0000|13715*a&65535,1&r?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,e=0xff51afd7*e&0xffff0000|((e<<16|(t=0xed558ccd*t&0xffff0000|36045*t&65535)>>>16)*0xafd7ed55&0xffff0000)>>>16,t^=e>>>1,e=0xc4ceb9fe*e&0xffff0000|((e<<16|(t=0x1a85ec53*t&0xffff0000|60499*t&65535)>>>16)*0xb9fe1a85&0xffff0000)>>>16,((t^=e>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}let tq=Object.freeze({map:null,hash:"",transfer:void 0});class tX{#e4=!1;#e8=null;#e7=null;#e9=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){let i=this.#e9.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#e9.get(t)}remove(t){let e=this.#e9.get(t);if(void 0!==e&&(e instanceof tG&&this.#e7.delete(e.annotationElementId),this.#e9.delete(t),0===this.#e9.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor)){for(let t of this.#e9.values())if(t instanceof tG)return;this.onAnnotationEditor(null)}}setValue(t,e){let i=this.#e9.get(t),r=!1;if(void 0!==i)for(let[t,s]of Object.entries(e))i[t]!==s&&(r=!0,i[t]=s);else r=!0,this.#e9.set(t,e);r&&this.#it(),e instanceof tG&&((this.#e7||=new Map).set(e.annotationElementId,e),"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type))}has(t){return this.#e9.has(t)}get size(){return this.#e9.size}#it(){this.#e4||(this.#e4=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#e4&&(this.#e4=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new tK(this)}get serializable(){if(0===this.#e9.size)return tq;let t=new Map,e=new tW,i=[],r=Object.create(null),s=!1;for(let[i,n]of this.#e9){let a=n instanceof tG?n.serialize(!1,r):n;a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),s||=!!a.bitmap)}if(s)for(let e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:tq}get editorStats(){let t=null,e=new Map,i=0,r=0;for(let s of this.#e9.values()){if(!(s instanceof tG)){s.popup&&(s.popup.deleted?r+=1:i+=1);continue}s.isCommentDeleted?r+=1:s.hasEditedComment&&(i+=1);let n=s.telemetryFinalData;if(!n)continue;let{type:a}=n;e.has(a)||e.set(a,Object.getPrototypeOf(s).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[t,e]of Object.entries(n)){if("type"===t)continue;let i=o.get(t);i||(i=new Map,o.set(t,i));let r=i.get(e)??0;i.set(e,r+1)}}if((r>0||i>0)&&((t||=Object.create(null)).comments={deleted:r,edited:i}),!t)return null;for(let[i,r]of e)t[i]=r.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#e8=null}updateEditor(t,e){let i=this.#e7?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#e7?.get(t)||null}get modifiedIds(){if(this.#e8)return this.#e8;let t=[];
2if(this.#e7)for(let e of this.#e7.values())e.serialize()&&t.push(e.annotationElementId);return this.#e8={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#e9.entries()}}class tK extends tX{#ie;constructor(t){super();const{map:e,hash:i,transfer:r}=t.serializable,s=structuredClone(e,r?{transfer:r}:null);this.#ie={map:s,hash:i,transfer:r}}get print(){M("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ie}get modifiedIds(){return R(this,"modifiedIds",{ids:new Set,hash:""})}}class tY{#ii=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));let e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#ii.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(!(!t||this.#ii.has(t.loadedName))){if(P(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:e,src:r,style:s}=t,n=new FontFace(e,r,s);this.addNativeFontFace(n);try{await n.load(),this.#ii.add(e),i?.(t)}catch{k(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(n)}return}M("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){let e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw k(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{let i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return R(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return R(this,"isSyncFontLoadingSupported",g||$.platform.isFirefox)}_queueLoadingCallback(t){let{loadingRequests:e}=this,i={done:!1,complete:function(){for(P(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;)setTimeout(e.shift().callback,0)},callback:t};return e.push(i),i}get _loadTestFont(){return R(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){var i;let r,s;function n(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function a(t,e,i,r){return t.substring(0,e)+r+t.substring(e+i)}let o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,d=`lt${Date.now()}${this.loadTestFontId++}`,c=this._loadTestFont,u=n(c=a(c,976,d.length,d),16);for(r=0,s=d.length-3;r<s;r+=4)u=u-0x58585858+n(d,r)|0;r<d.length&&(u=u-0x58585858+n(d+"XXX",r)|0),c=a(c,16,4,String.fromCharCode((i=u)>>24&255,i>>16&255,i>>8&255,255&i));let p=`url(data:font/opentype;base64,${btoa(c)});`,g=`@font-face {font-family:"${d}";src:${p}}`;this.insertRule(g);let f=this._document.createElement("div");
2for(let e of(f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px",[t.loadedName,d])){let t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,f.append(t)}this._document.body.append(f),function t(e,i){if(++h>30){k("Load test font never loaded."),i();return}(l.font="30px "+e,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0)?i():setTimeout(t.bind(null,e,i))}(d,()=>{f.remove(),e.complete()})}}class tJ{#ir;constructor(t,e=null,i,r){this.compiledGlyphs=Object.create(null),this.#ir=t,this._inspectFont=e,i&&Object.assign(this,i),r&&(this.charProcOperatorList=r)}createNativeFontFace(){let t;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){let 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(){let t;if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${Q(this.data)});`;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),t}getPathGenerator(t,e){let i;if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let r=this.loadedName+"_path_"+e;try{i=t.get(r)}catch(t){k(`getPathGenerator - ignoring character: "${t}".`)}let s=new Path2D(i||"");return this.fontExtraProperties||t.delete(r),this.compiledGlyphs[e]=s}get black(){return this.#ir.black}get bold(){return this.#ir.bold}get disableFontFace(){return this.#ir.disableFontFace??!1}get fontExtraProperties(){return this.#ir.fontExtraProperties??!1}get isInvalidPDFjsFont(){return this.#ir.isInvalidPDFjsFont}get isType3Font(){return this.#ir.isType3Font}get italic(){return this.#ir.italic}get missingFile(){return this.#ir.missingFile}get remeasure(){return this.#ir.remeasure}get vertical(){return this.#ir.vertical}get ascent(){return this.#ir.ascent}get defaultWidth(){return this.#ir.defaultWidth}get descent(){return this.#ir.descent}get bbox(){return this.#ir.bbox}get fontMatrix(){return this.#ir.fontMatrix}get fallbackName(){return this.#ir.fallbackName}get loadedName(){return this.#ir.loadedName}get mimetype(){return this.#ir.mimetype}get name(){return this.#ir.name}get data(){return this.#ir.data}clearData(){this.#ir.clearData()}get cssFontInfo(){return this.#ir.cssFontInfo}get systemFontInfo(){return this.#ir.systemFontInfo}get defaultVMetrics(){return this.#ir.defaultVMetrics}}function tQ(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}let tZ=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,t0=(function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;let[r,s,...n]=i;if(!t(r)&&!Number.isInteger(r)||!e(s))return!1;let a=n.length,o=!0;switch(s.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return 0===a;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(4!==a)return!1;o=!1;break;default:return!1}for(let t of n)if("number"!=typeof t&&(!o||null!==t))return!1;return!0}).bind(null,tZ,t=>"object"==typeof t&&"string"==typeof t?.name);class t1{#is=new Map;#ia=Promise.resolve();postMessage(t,e){let i={data:structuredClone(t,e?{transfer:e}:null)};this.#ia.then(()=>{for(let[t]of this.#is)t.call(this,i)})}addEventListener(t,e,i=null){let r=null;if(i?.signal instanceof AbortSignal){let{signal:s}=i;if(s.aborted)return void k("LoopbackPort - cannot use an `aborted` signal.");let n=()=>this.removeEventListener(t,e);r=()=>s.removeEventListener("abort",n),s.addEventListener("abort",n)}this.#is.set(e,r)}removeEventListener(t,e){let i=this.#is.get(e);i?.(),this.#is.delete(e)}terminate(){for(let[,t]of this.#is)t?.();this.#is.clear()}}function t2(){}function t3(t){if(t instanceof j||t instanceof N||t instanceof B||t instanceof O||t instanceof F)return t;switch(!(t instanceof Error||"object"==typeof t&&null!==t)&&M('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new j(t.message);case"InvalidPDFException":return new N(t.message);case"PasswordException":return new B(t.message,t.code);case"ResponseException":return new O(t.message,t.status,t.missing);case"UnknownErrorException":return new F(t.message,t.details)}return new F(t.message,t.toString())}class t5{#io=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.#il.bind(this),{signal:this.#io.signal})}#il({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ih(t);if(t.callback){let e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else if(2===t.callback)i.reject(t3(t.reason));else throw Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let i=this.sourceName,r=t.sourceName,s=this.comObj;Promise.try(e,t.data).then(function(e){s.postMessage({sourceName:i,targetName:r,callback:1,callbackId:t.callbackId,data:e})},function(e){s.postMessage({sourceName:i,targetName:r,callback:2,callbackId:t.callbackId,reason:t3(e)}
2)});return}t.streamId?this.#id(t):e(t.data)}on(t,e){let i=this.actionHandler;if(i[t])throw Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){let r=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[r]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:r,data:e},i)}catch(t){s.reject(t)}return s.promise}sendWithStream(t,e,i,r){let s=this.streamId++,n=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=Promise.withResolvers();return this.streamControllers[s]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:n,targetName:a,action:t,streamId:s,data:e,desiredSize:i.desiredSize},r),l.promise},pull:t=>{let e=Promise.withResolvers();return this.streamControllers[s].pullCall=e,o.postMessage({sourceName:n,targetName:a,stream:6,streamId:s,desiredSize:t.desiredSize}),e.promise},cancel:t=>{P(t instanceof Error,"cancel must have a valid reason");let e=Promise.withResolvers();return this.streamControllers[s].cancelCall=e,this.streamControllers[s].isClosed=!0,o.postMessage({sourceName:n,targetName:a,stream:1,streamId:s,reason:t3(t)}),e.promise}},i)}#id(t){let e=t.streamId,i=this.sourceName,r=t.sourceName,s=this.comObj,n=this,a=this.actionHandler[t.action],o={enqueue(t,n=1,a){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=n,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),s.postMessage({sourceName:i,targetName:r,stream:4,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:r,stream:3,streamId:e}),delete n.streamSinks[e])},error(t){P(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:r,stream:5,streamId:e,reason:t3(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){s.postMessage({sourceName:i,targetName:r,stream:8,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:r,stream:8,streamId:e,reason:t3(t)})})}#ih(t){let e=t.streamId,i=this.sourceName,r=t.sourceName,s=this.comObj,n=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case 8:t.success?n.startCall.resolve():n.startCall.reject(t3(t.reason));break;case 7:t.success?n.pullCall.resolve():n.pullCall.reject(t3(t.reason));break;case 6:if(!a){s.postMessage({sourceName:i,targetName:r,stream:7,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||t2).then(function(){s.postMessage({sourceName:i,targetName:r,stream:7,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:r,stream:7,streamId:e,reason:t3(t)})});break;case 4:if(P(n,"enqueue should have stream controller"),n.isClosed)break;n.controller.enqueue(t.chunk);break;case 3:if(P(n,"close should have stream controller"),n.isClosed)break;n.isClosed=!0,n.controller.close(),this.#ic(n,e);break;case 5:P(n,"error should have stream controller"),n.controller.error(t3(t.reason)),this.#ic(n,e);break;case 2:t.success?n.cancelCall.resolve():n.cancelCall.reject(t3(t.reason)),this.#ic(n,e);break;case 1:if(!a)break;let o=t3(t.reason);Promise.try(a.onCancel||t2,o).then(function(){s.postMessage({sourceName:i,targetName:r,stream:2,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:r,stream:2,streamId:e,reason:t3(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async #ic(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#io?.abort(),this.#io=null}}class t6{#iu=!1;constructor({enableHWA:t=!1}){this.#iu=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#iu})}}reset(t,e,i){if(!t.canvas)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){M("Abstract method `_createCanvas` called.")}}class t4 extends t6{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class t8{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw Error("CMap name must be specified.");let e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){M("Abstract method `_fetch` called.")}}class t7 extends t8{async _fetch(t){let e=await tr(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):H(e)}}class t9{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,r,s){return"none"}destroy(t=!1){}}class et extends t9{#ip;#ig;#im;#ib;#iy;#iv;#x=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ib=t,this.#iy=e}get #_(){return this.#ig||=new Map}get #iw(){return this.#iv||=new Map}get #ix(){if(!this.#im){let t=this.#iy.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;let i=this.#iy.createElementNS(te,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#im=this.#iy.createElementNS(te,"defs"),t.append(i),i.append(this.#im),this.#iy.body.append(t)}return this.#im}#iA(t){if(1===t.length){let e=t[0],i=Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;let r=i.join(",");return[r,r,r]}let[e,i,r]=t,s=Array(256),n=Array(256),a=Array(256);for(let t=0;t<256;t++)s[t]=e[t]/255,n[t]=i[t]/255,a[t]=r[t]/255;return[s.join(","),n.join(","),a.join(",")]}#i_(t){if(void 0===this.#ip){this.#ip="";let t=this.#iy.URL;t!==this.#iy.baseURI&&(ta(t)?k('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ip=I(t,""))}return`url(${this.#ip}#${t})`}addFilter(t){if(!t)return"none";let e=this.#_.get(t);if(e)return e;
2let[i,r,s]=this.#iA(t),n=1===t.length?i:`${i}${r}${s}`;if(e=this.#_.get(n))return this.#_.set(t,e),e;let a=`g_${this.#ib}_transfer_map_${this.#x++}`,o=this.#i_(a);this.#_.set(t,o),this.#_.set(n,o);let l=this.#iE(a);return this.#iS(i,r,s,l),o}addHCMFilter(t,e){let i=`${t}-${e}`,r="base",s=this.#iw.get(r);if(s?.key===i||(s?(s.filter?.remove(),s.key=i,s.url="none",s.filter=null):(s={key:i,url:"none",filter:null},this.#iw.set(r,s)),!t||!e))return s.url;let n=this.#iC(t);t=V.makeHexColor(...n);let a=this.#iC(e);if(e=V.makeHexColor(...a),this.#ix.style.color="","#000000"===t&&"#ffffff"===e||t===e)return s.url;let o=Array(256);for(let t=0;t<=255;t++){let e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}let l=o.join(","),h=`g_${this.#ib}_hcm_filter`,d=s.filter=this.#iE(h);this.#iS(l,l,l,d),this.#iT(d);let c=(t,e)=>{let i=n[t]/255,r=a[t]/255,s=Array(e+1);for(let t=0;t<=e;t++)s[t]=i+t/e*(r-i);return s.join(",")};return this.#iS(c(0,5),c(1,5),c(2,5),d),s.url=this.#i_(h),s.url}addAlphaFilter(t){let e=this.#_.get(t);if(e)return e;let[i]=this.#iA([t]),r=`alpha_${i}`;if(e=this.#_.get(r))return this.#_.set(t,e),e;let s=`g_${this.#ib}_alpha_map_${this.#x++}`,n=this.#i_(s);this.#_.set(t,n),this.#_.set(r,n);let a=this.#iE(s);return this.#ik(i,a),n}addLuminosityFilter(t){let e,i,r=this.#_.get(t||"luminosity");if(r)return r;if(t?([e]=this.#iA([t]),i=`luminosity_${e}`):i="luminosity",r=this.#_.get(i))return this.#_.set(t,r),r;let s=`g_${this.#ib}_luminosity_map_${this.#x++}`,n=this.#i_(s);this.#_.set(t,n),this.#_.set(i,n);let a=this.#iE(s);return this.#iM(a),t&&this.#ik(e,a),n}addHighlightHCMFilter(t,e,i,r,s){let n=`${e}-${i}-${r}-${s}`,a=this.#iw.get(t);if(a?.key===n||(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},this.#iw.set(t,a)),!e||!i))return a.url;let[o,l]=[e,i].map(this.#iC.bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[r,s].map(this.#iC.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#ix.style.color="";let p=(t,e,i)=>{let r=Array(256),s=(d-h)/i,n=t/255,a=(e-t)/(255*i),o=0;for(let t=0;t<=i;t++){let e=Math.round(h+t*s),i=n+t*a;for(let t=o;t<=e;t++)r[t]=i;o=e+1}for(let t=o;t<256;t++)r[t]=r[o-1];return r.join(",")},g=`g_${this.#ib}_hcm_${t}_filter`,f=a.filter=this.#iE(g);return this.#iT(f),this.#iS(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),f),a.url=this.#i_(g),a.url}destroy(t=!1){t&&this.#iv?.size||(this.#im?.parentNode.parentNode.remove(),this.#im=null,this.#ig?.clear(),this.#ig=null,this.#iv?.clear(),this.#iv=null,this.#x=0)}#iM(t){let e=this.#iy.createElementNS(te,"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)}#iT(t){let e=this.#iy.createElementNS(te,"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)}#iE(t){let e=this.#iy.createElementNS(te,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#ix.append(e),e}#iP(t,e,i){let r=this.#iy.createElementNS(te,e);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),t.append(r)}#iS(t,e,i,r){let s=this.#iy.createElementNS(te,"feComponentTransfer");r.append(s),this.#iP(s,"feFuncR",t),this.#iP(s,"feFuncG",e),this.#iP(s,"feFuncB",i)}#ik(t,e){let i=this.#iy.createElementNS(te,"feComponentTransfer");e.append(i),this.#iP(i,"feFuncA",t)}#iC(t){return this.#ix.style.color=t,tm(getComputedStyle(this.#ix).getPropertyValue("color"))}}class ee{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw Error("Font filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw Error(`Unable to load font data at: ${e}`)})}async _fetch(t){M("Abstract method `_fetch` called.")}}class ei extends ee{async _fetch(t){return new Uint8Array(await tr(t,"arraybuffer"))}}class er{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw Error("Wasm filename must be specified.");let e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){M("Abstract method `_fetch` called.")}}class es extends er{async _fetch(t){return new Uint8Array(await tr(t,"arraybuffer"))}}async function en(t){let e=d.default.getBuiltinModule("fs");return new Uint8Array(await e.promises.readFile(t))}g&&k("Please use the `legacy` build in Node.js environments.");class ea extends t9{}class eo extends t6{_createCanvas(t,e){return d.default.getBuiltinModule("module").createRequire(u.url)("@napi-rs/canvas").createCanvas(t,e)}}class el extends t8{async _fetch(t){return en(t)}}class eh extends ee{async _fetch(t){return en(t)}}class ed extends er{async _fetch(t){return en(t)}}let ec="__forcedDependency",{floor:eu,ceil:ep}=Math;function eg(t,e,i,r,s,n){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],r),t[4*e+2]=Math.max(t[4*e+2],s),t[4*e+3]=Math.max(t[4*e+3],n)}let ef=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class em{#iD;#iI;constructor(t,e){this.#iD=t,this.#iI=e}get length(){return this.#iD.length}isEmpty(t){return this.#iD[t]===ef}minX(t){return this.#iI[4*t+0]/256}minY(t){return this.#iI[4*t+1]/256}maxX(t){return(this.#iI[4*t+2]+1)/256}maxY(t){return(this.#iI[4*t+3]+1)/256}}let eb=(t,e)=>{if(!t)return;let i=t.get(e);
2return i||(i={dependencies:new Set,isRenderingOperation:!1},t.set(e,i)),i};class ey{#iR={__proto__:null};#iL={__proto__:null,transform:[],moveText:[],sameLineText:[],[ec]:[]};#iB=new Map;#iF=[];#iN=[];#iO=[[1,0,0,1,0,0]];#iU=[-1/0,-1/0,1/0,1/0];#ij=new Float64Array([1/0,1/0,-1/0,-1/0]);#iz=-1;#iH=new Set;#i$=new Map;#iG=new Map;#iV;#iW;#iq;#iD;#iX;constructor(t,e,i=!1){this.#iV=t.width,this.#iW=t.height,this.#iK(e),i&&(this.#iX=new Map)}growOperationsCount(t){t>=this.#iD.length&&this.#iK(t,this.#iD)}#iK(t,e){let i=new ArrayBuffer(4*t);this.#iq=new Uint8ClampedArray(i),this.#iD=new Uint32Array(i),e&&e.length>0?(this.#iD.set(e),this.#iD.fill(ef,e.length)):this.#iD.fill(ef)}save(t){return this.#iR={__proto__:this.#iR},this.#iL={__proto__:this.#iL,transform:{__proto__:this.#iL.transform},moveText:{__proto__:this.#iL.moveText},sameLineText:{__proto__:this.#iL.sameLineText},[ec]:{__proto__:this.#iL[ec]}},this.#iU={__proto__:this.#iU},this.#iF.push(t),this}restore(t){let e=Object.getPrototypeOf(this.#iR);if(null===e)return this;this.#iR=e,this.#iL=Object.getPrototypeOf(this.#iL),this.#iU=Object.getPrototypeOf(this.#iU);let i=this.#iF.pop();return void 0!==i&&(eb(this.#iX,t)?.dependencies.add(i),this.#iD[t]=this.#iD[i]),this}recordOpenMarker(t){return this.#iF.push(t),this}getOpenMarker(){return 0===this.#iF.length?null:this.#iF.at(-1)}recordCloseMarker(t){let e=this.#iF.pop();return void 0!==e&&(eb(this.#iX,t)?.dependencies.add(e),this.#iD[t]=this.#iD[e]),this}beginMarkedContent(t){return this.#iN.push(t),this}endMarkedContent(t){let e=this.#iN.pop();return void 0!==e&&(eb(this.#iX,t)?.dependencies.add(e),this.#iD[t]=this.#iD[e]),this}pushBaseTransform(t){return this.#iO.push(V.multiplyByDOMMatrix(this.#iO.at(-1),t.getTransform())),this}popBaseTransform(){return this.#iO.length>1&&this.#iO.pop(),this}recordSimpleData(t,e){return this.#iR[t]=e,this}recordIncrementalData(t,e){return this.#iL[t].push(e),this}resetIncrementalData(t,e){return this.#iL[t].length=0,this}recordNamedData(t,e){return this.#iB.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#iR[t]=this.#iB.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(ec,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)e in this.#iR&&this.recordFutureForcedDependency(e,this.#iR[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#iH)this.recordFutureForcedDependency(ec,t);return this}resetBBox(t){return this.#iz!==t&&(this.#iz=t,this.#ij[0]=1/0,this.#ij[1]=1/0,this.#ij[2]=-1/0,this.#ij[3]=-1/0),this}recordClipBox(t,e,i,r,s,n){let a=V.multiplyByDOMMatrix(this.#iO.at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];V.axialAlignedBoundingBox([i,s,r,n],a,o);let l=V.intersect(this.#iU,o);return l?(this.#iU[0]=l[0],this.#iU[1]=l[1],this.#iU[2]=l[2],this.#iU[3]=l[3]):(this.#iU[0]=this.#iU[1]=1/0,this.#iU[2]=this.#iU[3]=-1/0),this}recordBBox(t,e,i,r,s,n){let a=this.#iU;if(a[0]===1/0)return this;let o=V.multiplyByDOMMatrix(this.#iO.at(-1),e.getTransform());if(a[0]===-1/0)return V.axialAlignedBoundingBox([i,s,r,n],o,this.#ij),this;let l=[1/0,1/0,-1/0,-1/0];return V.axialAlignedBoundingBox([i,s,r,n],o,l),this.#ij[0]=Math.min(this.#ij[0],Math.max(l[0],a[0])),this.#ij[1]=Math.min(this.#ij[1],Math.max(l[1],a[1])),this.#ij[2]=Math.max(this.#ij[2],Math.min(l[2],a[2])),this.#ij[3]=Math.max(this.#ij[3],Math.min(l[3],a[3])),this}recordCharacterBBox(t,e,i,r=1,s=0,n=0,a){let o,l,h=i.bbox;if(h&&!1!==(o=h[2]!==h[0]&&h[3]!==h[1]&&this.#iG.get(i))&&(l=[0,0,0,0],V.axialAlignedBoundingBox(h,i.fontMatrix,l),(1!==r||0!==s||
20!==n)&&V.scaleMinMax([r,0,0,-r,s,n],l),o))return this.recordBBox(t,e,l[0],l[2],l[1],l[3]);if(!a)return this.recordFullPageBBox(t);let d=a();return h&&l&&void 0===o&&(o=l[0]<=s-d.actualBoundingBoxLeft&&l[2]>=s+d.actualBoundingBoxRight&&l[1]<=n-d.actualBoundingBoxAscent&&l[3]>=n+d.actualBoundingBoxDescent,this.#iG.set(i,o),o)?this.recordBBox(t,e,l[0],l[2],l[1],l[3]):this.recordBBox(t,e,s-d.actualBoundingBoxLeft,s+d.actualBoundingBoxRight,n-d.actualBoundingBoxAscent,n+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#ij[0]=Math.max(0,this.#iU[0]),this.#ij[1]=Math.max(0,this.#iU[1]),this.#ij[2]=Math.min(this.#iV,this.#iU[2]),this.#ij[3]=Math.min(this.#iW,this.#iU[3]),this}getSimpleIndex(t){return this.#iR[t]}recordDependencies(t,e){let i=this.#iH,r=this.#iR,s=this.#iL;for(let t of e)t in this.#iR?i.add(r[t]):t in s&&s[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#iB.has(e)&&this.#iH.add(this.#iB.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[ec]),this.#iX){let e=eb(this.#iX,t),{dependencies:i}=e;this.#iH.forEach(i.add,i),this.#iF.forEach(i.add,i),this.#iN.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}if(this.#iz===t){let i=eu(256*this.#ij[0]/this.#iV),r=eu(256*this.#ij[1]/this.#iW),s=ep(256*this.#ij[2]/this.#iV),n=ep(256*this.#ij[3]/this.#iW);for(let e of(eg(this.#iq,t,i,r,s,n),this.#iH))e!==t&&eg(this.#iq,e,i,r,s,n);for(let e of this.#iF)e!==t&&eg(this.#iq,e,i,r,s,n);for(let e of this.#iN)e!==t&&eg(this.#iq,e,i,r,s,n);e||(this.#iH.clear(),this.#iz=-1)}return this}recordShowTextOperation(t,e=!1){let i=Array.from(this.#iH);for(let r of(this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t),i))this.recordIncrementalData("sameLineText",r);return this}bboxToClipBoxDropOperation(t,e=!1){return this.#iz===t&&(this.#iz=-1,this.#iU[0]=Math.max(this.#iU[0],this.#ij[0]),this.#iU[1]=Math.max(this.#iU[1],this.#ij[1]),this.#iU[2]=Math.min(this.#iU[2],this.#ij[2]),this.#iU[3]=Math.min(this.#iU[3],this.#ij[3]),e||this.#iH.clear()),this}_takePendingDependencies(){let t=this.#iH;return this.#iH=new Set,t}_extractOperation(t){let e=this.#i$.get(t);return this.#i$.delete(t),e}_pushPendingDependencies(t){for(let e of t)this.#iH.add(e)}take(){return this.#iG.clear(),new em(this.#iD,this.#iq)}takeDebugMetadata(){return this.#iX}}class ev{#iY;#iJ;#iQ;#iZ=0;#i0=0;constructor(t,e,i){if(t instanceof ev&&!!i===t.#iQ)return t;this.#iY=t,this.#iJ=e,this.#iQ=!!i}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#i0++,this.#iY.save(this.#iJ),this}restore(t){return this.#i0>0&&(this.#iY.restore(this.#iJ),this.#i0--),this}recordOpenMarker(t){return this.#iZ++,this}getOpenMarker(){return this.#iZ>0?this.#iJ:this.#iY.getOpenMarker()}recordCloseMarker(t){return this.#iZ--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#iY.pushBaseTransform(t),this}popBaseTransform(){return this.#iY.popBaseTransform(),this}recordSimpleData(t,e){return this.#iY.recordSimpleData(t,this.#iJ),this}recordIncrementalData(t,e){return this.#iY.recordIncrementalData(t,this.#iJ),this}resetIncrementalData(t,e){return this.#iY.resetIncrementalData(t,this.#iJ),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#iY.recordSimpleDataFromNamed(t,e,this.#iJ),this}recordFutureForcedDependency(t,e){return this.#iY.recordFutureForcedDependency(t,this.#iJ),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#iY.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#iY.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#iQ||this.#iY.resetBBox(this.#iJ),this}recordClipBox(t,e,i,r,s,n){return this.#iQ||this.#iY.recordClipBox(this.#iJ,e,i,r,s,n),this}recordBBox(t,e,i,r,s,n){return this.#iQ||this.#iY.recordBBox(this.#iJ,e,i,r,s,n),this}recordCharacterBBox(t,e,i,r,s,n,a){return this.#iQ||this.#iY.recordCharacterBBox(this.#iJ,e,i,r,s,n,a),this}recordFullPageBBox(t){return this.#iQ||this.#iY.recordFullPageBBox(this.#iJ),this}getSimpleIndex(t){return this.#iY.getSimpleIndex(t)}recordDependencies(t,e){return this.#iY.recordDependencies(this.#iJ,e),this}recordNamedDependency(t,e){return this.#iY.recordNamedDependency(this.#iJ,e),this}recordOperation(t){return this.#iY.recordOperation(this.#iJ,!0),this}recordShowTextOperation(t){return this.#iY.recordShowTextOperation(this.#iJ,!0),this}bboxToClipBoxDropOperation(t){return this.#iQ||this.#iY.bboxToClipBoxDropOperation(this.#iJ,!0),this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}let ew=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],ex=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],eA=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],e_=["filter","fillColor","fillAlpha"],eE=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],eS=["transform"],eC=["transform","fillColor"],eT="Fill",ek="Stroke",eM="Shading";function eP(t,e){if(!e)return;let i=e[2]-e[0],r=e[3]-e[1],s=new Path2D;s.rect(e[0],e[1],i,r),t.clip(s)}class eD{isModifyingCurrentTransform(){return!1}getPattern(){M("Abstract method `getPattern` called.")}}class eI extends eD{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;for(let i of("axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1)),this._colorStops))e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,r){let s;if(r===ek||r===eT){let n=e.current.getClippedPathBoundingBox(r,tb(t))||[0,0,0,0],a=Math.ceil(n[2]-n[0])||1,o=Math.ceil(n[3]-n[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-n[0],-n[1]),i=V.transform(i,[1,0,0,1,n[0],n[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix
2),eP(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),s=t.createPattern(l.canvas,"no-repeat");let d=new DOMMatrix(i);s.setTransform(d)}else eP(t,this._bbox),s=this._createGradient(t);return s}}function eR(t,e,i,r,s,n,a,o){let l,h,d,c,u,p,g,f,m,b=e.coords,y=e.colors,v=t.data,w=4*t.width;b[i+1]>b[r+1]&&(l=i,i=r,r=l,l=n,n=a,a=l),b[r+1]>b[s+1]&&(l=r,r=s,s=l,l=a,a=o,o=l),b[i+1]>b[r+1]&&(l=i,i=r,r=l,l=n,n=a,a=l);let x=(b[i]+e.offsetX)*e.scaleX,A=(b[i+1]+e.offsetY)*e.scaleY,_=(b[r]+e.offsetX)*e.scaleX,E=(b[r+1]+e.offsetY)*e.scaleY,S=(b[s]+e.offsetX)*e.scaleX,C=(b[s+1]+e.offsetY)*e.scaleY;if(A>=C)return;let T=y[n],k=y[n+1],M=y[n+2],P=y[a],D=y[a+1],I=y[a+2],R=y[o],L=y[o+1],B=y[o+2],F=Math.round(A),N=Math.round(C);for(let t=F;t<=N;t++){let e;if(t<E){let e=t<A?0:(A-t)/(A-E);h=x-(x-_)*e,d=T-(T-P)*e,c=k-(k-D)*e,u=M-(M-I)*e}else{let e;h=_-(_-S)*(e=t>C?1:E===C?0:(E-t)/(E-C)),d=P-(P-R)*e,c=D-(D-L)*e,u=I-(I-B)*e}p=x-(x-S)*(e=t<A?0:t>C?1:(A-t)/(A-C)),g=T-(T-R)*e,f=k-(k-L)*e,m=M-(M-B)*e;let i=Math.round(Math.min(h,p)),r=Math.round(Math.max(h,p)),s=w*t+4*i;for(let t=i;t<=r;t++)(e=(h-t)/(h-p))<0?e=0:e>1&&(e=1),v[s++]=d-(d-g)*e|0,v[s++]=c-(c-f)*e|0,v[s++]=u-(u-m)*e|0,v[s++]=255}}class eL extends eD{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){let r=Math.floor(this._bounds[0]),s=Math.floor(this._bounds[1]),n=Math.ceil(this._bounds[2])-r,a=Math.ceil(this._bounds[3])-s,o=Math.min(Math.ceil(Math.abs(n*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=n/o,d=a/l,c={coords:this._coords,colors:this._colors,offsetX:-r,offsetY:-s,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){let t=m.data;for(let i=0,r=t.length;i<r;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(let t of this._figures)!function(t,e,i){let r,s,n=e.coords,a=e.colors;switch(e.type){case"lattice":let o=e.verticesPerRow,l=Math.floor(n.length/o)-1,h=o-1;for(r=0;r<l;r++){let e=r*o;for(let r=0;r<h;r++,e++)eR(t,i,n[e],n[e+1],n[e+o],a[e],a[e+1],a[e+o]),eR(t,i,n[e+o+1],n[e+1],n[e+o],a[e+o+1],a[e+1],a[e+o])}break;case"triangles":for(r=0,s=n.length;r<s;r+=3)eR(t,i,n[r],n[r+1],n[r+2],a[r],a[r+1],a[r+2]);break;default:throw Error("illegal figure")}}(m,t,c);return f.putImageData(m,2,2),{canvas:g.canvas,offsetX:r-2*h,offsetY:s-2*d,scaleX:h,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,r){eP(t,this._bbox);let s=new Float32Array(2);if(r===eM)V.singularValueDecompose2dScale(tb(t),s);else if(this.matrix){V.singularValueDecompose2dScale(this.matrix,s);let[t,i]=s;V.singularValueDecompose2dScale(e.baseTransform,s),s[0]*=t,s[1]*=i}else V.singularValueDecompose2dScale(e.baseTransform,s);let n=this._createMeshCanvas(s,r===eM?null:this._background,e.cachedCanvases);return r!==eM&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(n.offsetX,n.offsetY),t.scale(n.scaleX,n.scaleY),t.createPattern(n.canvas,"no-repeat")}}class eB extends eD{getPattern(){return"hotpink"}}class eF{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,r){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=r}createPatternCanvas(t,e){let{bbox:i,operatorList:r,paintType:s,tilingType:n,color:a,canvasGraphicsFactory:o}=this,{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),T("TilingType: "+n);let d=i[0],c=i[1],u=i[2],p=i[3],g=u-d,f=p-c,m=new Float32Array(2);V.singularValueDecompose2dScale(this.matrix,m);let[b,y]=m;V.singularValueDecompose2dScale(this.baseTransform,m);let v=b*m[0],w=y*m[1],x=g,A=f,_=!1,E=!1,S=Math.ceil(h*w),C=Math.ceil(f*w);Math.ceil(l*v)>=Math.ceil(g*v)?x=l:_=!0,S>=C?A=h:E=!0;let k=this.getSizeAndScale(x,this.ctx.canvas.width,v),M=this.getSizeAndScale(A,this.ctx.canvas.height,w),P=t.cachedCanvases.getCanvas("pattern",k.size,M.size),D=P.context,I=o.createCanvasGraphics(D,e);if(I.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(I,s,a),D.translate(-k.scale*d,-M.scale*c),I.transform(0,k.scale,0,0,M.scale,0,0),D.save(),I.dependencyTracker?.save(),this.clipBbox(I,d,
2c,u,p),I.baseTransform=tb(I.ctx),I.executeOperatorList(r),I.endDrawing(),I.dependencyTracker?.restore(),D.restore(),_||E){let e=P.canvas;_&&(x=l),E&&(A=h);let i=this.getSizeAndScale(x,this.ctx.canvas.width,v),r=this.getSizeAndScale(A,this.ctx.canvas.height,w),s=i.size,n=r.size,a=t.cachedCanvases.getCanvas("pattern-workaround",s,n),o=a.context,u=_?Math.floor(g/l):0,p=E?Math.floor(f/h):0;for(let t=0;t<=u;t++)for(let i=0;i<=p;i++)o.drawImage(e,s*t,n*i,s,n,0,0,s,n);return{canvas:a.canvas,scaleX:i.scale,scaleY:r.scale,offsetX:d,offsetY:c}}return{canvas:P.canvas,scaleX:k.scale,scaleY:M.scale,offsetX:d,offsetY:c}}getSizeAndScale(t,e,i){let r=Math.max(eF.MAX_PATTERN_SIZE,e),s=Math.ceil(t*i);return s>=r?s=r:i=s/t,{scale:i,size:s}}clipBbox(t,e,i,r,s){let n=r-e,a=s-i;t.ctx.rect(e,i,n,a),V.axialAlignedBoundingBox([e,i,r,s],tb(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){let r=t.ctx,s=t.current;switch(e){case 1:let{fillStyle:n,strokeStyle:a}=this.ctx;r.fillStyle=s.fillColor=n,r.strokeStyle=s.strokeColor=a;break;case 2:r.fillStyle=r.strokeStyle=i,s.fillColor=s.strokeColor=i;break;default:throw new U(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,r,s){let n=i;r!==eM&&(n=V.transform(n,e.baseTransform),this.matrix&&(n=V.transform(n,this.matrix)));let a=this.createPatternCanvas(e,s),o=new DOMMatrix(n);o=(o=o.translate(a.offsetX,a.offsetY)).scale(1/a.scaleX,1/a.scaleY);let l=t.createPattern(a.canvas,"repeat");return l.setTransform(o),l}}let eN=new DOMMatrix,eO=new Float32Array(2),eU=new Float32Array([1/0,1/0,-1/0,-1/0]);class ej{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let r;return void 0!==this.cache[t]?(r=this.cache[t],this.canvasFactory.reset(r,e,i)):(r=this.canvasFactory.create(e,i),this.cache[t]=r),r}delete(t){delete this.cache[t]}clear(){for(let t in this.cache){let e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function ez(t,e,i,r,s,n,a,o,l,h){let[d,c,u,p,g,f]=tb(t);if(0===c&&0===u){let m=Math.round(a*d+g),b=Math.round(o*p+f),y=Math.abs(Math.round((a+l)*d+g)-m)||1,v=Math.abs(Math.round((o+h)*p+f)-b)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),m,b),t.drawImage(e,i,r,s,n,0,0,y,v),t.setTransform(d,c,u,p,g,f),[y,v]}if(0===d&&0===p){let m=Math.round(o*u+g),b=Math.round(a*c+f),y=Math.abs(Math.round((o+h)*u+g)-m)||1,v=Math.abs(Math.round((a+l)*c+f)-b)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,m,b),t.drawImage(e,i,r,s,n,0,0,v,y),t.setTransform(d,c,u,p,g,f),[v,y]}return t.drawImage(e,i,r,s,n,a,o,l,h),[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class eH{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=f;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e,i){i?.(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=eU.slice()}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=eT,e=null){let i=this.minMax.slice();if(t===ek){e||M("Stroke bounding box must include transform."),V.singularValueDecompose2dScale(e,eO);let t=eO[0]*this.lineWidth/2,r=eO[1]*this.lineWidth/2;i[0]-=t,i[1]-=r,i[2]+=t,i[3]+=r}return i}updateClipFromPath(){let t=V.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(eU,0)}getClippedPathBoundingBox(t=eT,e=null){return V.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function e$(t,e){let i,r,s,n;if(e instanceof ImageData)return void t.putImageData(e,0,0);let a=e.height,o=e.width,l=a%16,h=(a-l)/16,d=0===l?h:h+1,c=t.createImageData(o,16),u=0,p,g=e.data,f=c.data;if(e.kind===x.GRAYSCALE_1BPP){let e=g.byteLength,n=new Uint32Array(f.buffer,0,f.byteLength>>2),a=n.length,m=o+7>>3,b=$.isLittleEndian?0xff000000:255;for(i=0;i<d;i++){for(r=0,s=i<h?16:l,p=0;r<s;r++){let t=e-u,i=0,r=t>m?o:8*t-7,s=-8&r,a=0,l=0;for(;i<s;i+=8)l=g[u++],n[p++]=128&l?0xffffffff:b,n[p++]=64&l?0xffffffff:b,n[p++]=32&l?0xffffffff:b,n[p++]=16&l?0xffffffff:b,n[p++]=8&l?0xffffffff:b,n[p++]=4&l?0xffffffff:b,n[p++]=2&l?0xffffffff:b,n[p++]=1&l?0xffffffff:b;for(;i<r;i++)0===a&&(l=g[u++],a=128),n[p++]=l&a?0xffffffff:b,a>
2>=1}for(;p<a;)n[p++]=0;t.putImageData(c,0,16*i)}}else if(e.kind===x.RGBA_32BPP){for(i=0,r=0,n=16*o*4;i<h;i++)f.set(g.subarray(u,u+n)),u+=n,t.putImageData(c,0,r),r+=16;i<d&&(n=o*l*4,f.set(g.subarray(u,u+n)),t.putImageData(c,0,r))}else if(e.kind===x.RGB_24BPP)for(i=0,n=o*(s=16);i<d;i++){for(i>=h&&(n=o*(s=l)),p=0,r=n;r--;)f[p++]=g[u++],f[p++]=g[u++],f[p++]=g[u++],f[p++]=255;t.putImageData(c,0,16*i)}else throw Error(`bad image kind: ${e.kind}`)}function eG(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);let i=e.height,r=e.width,s=i%16,n=(i-s)/16,a=0===s?n:n+1,o=t.createImageData(r,16),l=0,h=e.data,d=o.data;for(let e=0;e<a;e++){let i=e<n?16:s;({srcPos:l}=function({src:t,srcPos:e=0,dest:i,width:r,height:s,nonBlackColor:n=0xffffffff,inverseDecode:a=!1}){let o=$.isLittleEndian?0xff000000:255,[l,h]=a?[n,o]:[o,n],d=r>>3,c=7&r,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let r=0;r<s;r++){for(let r=e+d;e<r;e++){let r=e<u?t[e]:255;i[p++]=128&r?h:l,i[p++]=64&r?h:l,i[p++]=32&r?h:l,i[p++]=16&r?h:l,i[p++]=8&r?h:l,i[p++]=4&r?h:l,i[p++]=2&r?h:l,i[p++]=1&r?h:l}if(0===c)continue;let r=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=r&1<<7-t?h:l}return{srcPos:e,destPos:p}}({src:h,srcPos:l,dest:d,width:r,height:i,nonBlackColor:0})),t.putImageData(o,0,16*e)}}function eV(t,e){for(let i of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function eW(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);let{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function eq(t,e){if(e)return!0;V.singularValueDecompose2dScale(t,eO);let i=Math.fround(tw.pixelRatio*ti.PDF_TO_CSS_UNITS);return eO[0]<=i&&eO[1]<=i}let eX=["butt","round","square"],eK=["miter","round","bevel"],eY={},eJ={};class eQ{constructor(t,e,i,r,s,{optionalContentConfig:n,markedContentStack:a=null},o,l,h){this.ctx=t,this.current=new eH(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=r,this.filterFactory=s,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=n,this.cachedCanvases=new ej(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??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:r=null}){let s=this.ctx.canvas.width,n=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,s,n),this.ctx.fillStyle=a,i){let t=this.cachedCanvases.getCanvas("transparent",s,n);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...tb(this.compositeCtx))}this.ctx.save(),eW(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=tb(this.ctx)}executeOperatorList(t,e,i,r,s){let n,a,o=t.argsArray,l=t.fnArray,h=e||0,d=o.length;if(d===h)return h;let c=d-h>10&&"function"==typeof i,u=c?Date.now()+15:0,p=0,g=this.commonObjs,f=this.objs;for(;;){if(void 0!==r&&h===r.nextBreakPoint)return r.breakIt(h,i),h;if(!s||s(h))if(n=l[h],a=o[h]??null,n!==E.dependency)null===a?this[n](h):this[n](h,...a);else for(let t of a){this.dependencyTracker?.recordNamedData(t,h);let e=t.startsWith("g_")?g:f;if(!e.has(t))return e.get(t,i),h}if(++h===d)return h;if(c&&++p>10){if(Date.now()>u)return i(),h;p=0}}}#i1(){for(;this.stateStack.length||this.inSMaskMode;
2)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){for(let t of(this.#i1(),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let e of t.values())"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#i2()}#i2(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let i,r,s=t.width??t.displayWidth,n=t.height??t.displayHeight,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=s,h=n,d="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,s=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(s=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/s),(r=(i=this.cachedCanvases.getCanvas(d,e,s)).context).clearRect(0,0,e,s),r.drawImage(t,0,0,l,h,0,0,e,s),t=i.canvas,l=e,h=s,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t,e){let i,r,s,n,a=this.ctx,{width:o,height:l}=e,h=this.current.fillColor,d=this.current.patternFill,c=tb(a);if((e.bitmap||e.data)&&e.count>1){let n=e.bitmap||e.data.buffer;r=JSON.stringify(d?c:[c.slice(0,4),h]),(i=this._cachedBitmapsMap.get(n))||(i=new Map,this._cachedBitmapsMap.set(n,i));let a=i.get(r);if(a&&!d){let e=Math.round(Math.min(c[0],c[2])+c[4]),i=Math.round(Math.min(c[1],c[3])+c[5]);return this.dependencyTracker?.recordDependencies(t,eC),{canvas:a,offsetX:e,offsetY:i}}s=a}s||eG((n=this.cachedCanvases.getCanvas("maskCanvas",o,l)).context,e);let u=V.transform(c,[1/o,0,0,-1/l,0,0]);u=V.transform(u,[1,0,0,1,0,-l]);let p=eU.slice();V.axialAlignedBoundingBox([0,0,o,l],u,p);let[g,f,m,b]=p,y=Math.round(m-g)||1,v=Math.round(b-f)||1,w=this.cachedCanvases.getCanvas("fillCanvas",y,v),x=w.context;x.translate(-g,-f),x.transform(...u),!s&&(s=(s=this._scaleImage(n.canvas,ty(x))).img,i&&d&&i.set(r,s)),x.imageSmoothingEnabled=eq(tb(x),e.interpolate),ez(x,s,0,0,s.width,s.height,0,0,o,l),x.globalCompositeOperation="source-in";let A=V.transform(ty(x),[1,0,0,1,-g,-f]);return x.fillStyle=d?h.getPattern(a,this,A,eT,t):h,x.fillRect(0,0,o,l),i&&!d&&(this.cachedCanvases.delete("fillCanvas"),i.set(r,w.canvas)),this.dependencyTracker?.recordDependencies(t,eC),{canvas:w.canvas,offsetX:Math.round(g),offsetY:Math.round(f)}}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=eX[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=eK[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);let r=this.ctx;void 0!==r.setLineDash&&(r.setLineDash(e),r.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[i,r]of e)switch(i){case"LW":this.setLineWidth(t,r);break;case"LC":this.setLineCap(t,r);break;case"LJ":this.setLineJoin(t,r);break;case"ML":this.setMiterLimit(t,r);break;case"D":this.setDash(t,r[0],r[1]);break;case"RI":this.setRenderingIntent(t,r);break;case"FL":this.setFlatness(t,r);break;case"Font":this.setFont(t,r[0],r[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=r;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=r;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=r;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=r?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(r)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,i=this.ctx.canvas.height,r="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(r,e,i);this.suspendedCtx=this.ctx;let n=this.ctx=s.context;n.setTransform(this.suspendedCtx.getTransform()),eV(this.suspendedCtx,n);var a=this.suspendedCtx;if(n._removeMirroring)throw Error("Context is already forwarding operations.");n.__originalSave=n.save,n.__originalRestore=n.restore,n.__originalRotate=n.rotate,n.__originalScale=n.scale,n.__originalTranslate=n.translate,n.__originalTransform=n.transform,n.__originalSetTransform=n.setTransform,n.__originalResetTransform=n.resetTransform,n.__originalClip=n.clip,n.__originalMoveTo=n.moveTo,n.__originalLineTo=n.lineTo,n.__originalBezierCurveTo=n.bezierCurveTo,n.__originalRect=n.rect,n.__originalClosePath=n.closePath,n.__originalBeginPath=n.beginPath,n._removeMirroring=()=>{n.save=n.__originalSave,n.restore=n.__originalRestore,n.rotate=n.__originalRotate,n.scale=n.__originalScale,n.translate=n.__originalTranslate,n.transform=n.__originalTransform,n.setTransform=n.__originalSetTransform,n.resetTransform=n.__originalResetTransform,n.clip=n.__originalClip,n.moveTo=n.__originalMoveTo,n.lineTo=n.__originalLineTo,n.bezierCurveTo=n.__originalBezierCurveTo,n.rect=n.__originalRect,n.closePath=n.__originalClosePath,n.beginPath=n.__originalBeginPath,delete n._removeMirroring},n.save=function(){a.save(),this.__originalSave()}
2,n.restore=function(){a.restore(),this.__originalRestore()},n.translate=function(t,e){a.translate(t,e),this.__originalTranslate(t,e)},n.scale=function(t,e){a.scale(t,e),this.__originalScale(t,e)},n.transform=function(t,e,i,r,s,n){a.transform(t,e,i,r,s,n),this.__originalTransform(t,e,i,r,s,n)},n.setTransform=function(t,e,i,r,s,n){a.setTransform(t,e,i,r,s,n),this.__originalSetTransform(t,e,i,r,s,n)},n.resetTransform=function(){a.resetTransform(),this.__originalResetTransform()},n.rotate=function(t){a.rotate(t),this.__originalRotate(t)},n.clip=function(t){a.clip(t),this.__originalClip(t)},n.moveTo=function(t,e){a.moveTo(t,e),this.__originalMoveTo(t,e)},n.lineTo=function(t,e){a.lineTo(t,e),this.__originalLineTo(t,e)},n.bezierCurveTo=function(t,e,i,r,s,n){a.bezierCurveTo(t,e,i,r,s,n),this.__originalBezierCurveTo(t,e,i,r,s,n)},n.rect=function(t,e,i,r){a.rect(t,e,i,r),this.__originalRect(t,e,i,r)},n.closePath=function(){a.closePath(),this.__originalClosePath()},n.beginPath=function(){a.beginPath(),this.__originalBeginPath()},this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),eV(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,r){let s=r[0],n=r[1],a=r[2]-s,o=r[3]-n;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,s,n,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,r,s,n,a,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(n)if(u<0||p<0||u+i>c.width||p+r>c.height){let t=this.cachedCanvases.getCanvas("maskExtension",i,r),e=t.context;e.drawImage(c,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=n,e.fillRect(0,0,i,r),e.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);let e=new Path2D;e.rect(u,p,i,r),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=n,t.fillRect(u,p,i,r),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===s&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===s&&(e.filter=this.filterFactory.addLuminosityFilter(a));let g=new Path2D;g.rect(o,l,i,r),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,r,o,l,i,r),e.restore()}save(t){this.inSMaskMode&&eV(this.ctx,this.suspendedCtx),this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),0===this.stateStack.length){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&eV(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,i,r,s,n,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,r,s,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,r){let[s]=i;if(!r){s||=i[0]=new Path2D,this[e](t,s);return}if(null!==this.dependencyTracker){let i=e===E.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,r[0]-i,r[2]+i,r[1]-i,r[3]+i).recordDependencies(t,["transform"])}if(!(s instanceof Path2D)){let t=i[0]=new Path2D;for(let e=0,i=s.length;e<i;)switch(s[e++]){case 0:t.moveTo(s[e++],s[e++]);break;case 1:t.lineTo(s[e++],s[e++]);break;case 2:t.bezierCurveTo(s[e++],s[e++],s[e++],s[e++],s[e++],s[e++]);break;case 3:t.closePath();break;default:k(`Unrecognized drawing path operator: ${s[e-1]}`)}s=t}V.axialAlignedBoundingBox(r,tb(this.ctx),this.current.minMax),this[e](t,s),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){let r=this.ctx,s=this.current.strokeColor;if(r.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof s&&s?.getPattern){let i=s.isModifyingCurrentTransform()?r.getTransform():null;if(r.save(),r.strokeStyle=s.getPattern(r,this,ty(r),ek,t),i){let t=new Path2D;t.addPath(e,r.getTransform().invertSelf().multiplySelf(i)),e=t}
2this.rescaleAndStroke(e,!1),r.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,ew),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(ek,tb(this.ctx))),r.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){let r=this.ctx,s=this.current.fillColor,n=this.current.patternFill,a=!1;if(n){let i=s.isModifyingCurrentTransform()?r.getTransform():null;if(this.dependencyTracker?.save(t),r.save(),r.fillStyle=s.getPattern(r,this,ty(r),eT,t),i){let t=new Path2D;t.addPath(e,r.getTransform().invertSelf().multiplySelf(i)),e=t}a=!0}let o=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==o&&(this.pendingEOFill?(r.fill(e,"evenodd"),this.pendingEOFill=!1):r.fill(e)),this.dependencyTracker?.recordDependencies(t,ex),a&&(r.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,o)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,e_).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=eY}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=eJ}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){let e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){let t=new Path2D,r=i.getTransform().invertSelf();for(let{transform:i,x:s,y:n,fontSize:a,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(r).translate(s,n).scale(a,-a));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);let r=this.commonObjs.get(e),s=this.current;if(!r)throw Error(`Can't find font for ${e}`);if(s.fontMatrix=r.fontMatrix||f,(0===s.fontMatrix[0]||0===s.fontMatrix[3])&&k("Invalid font matrix for font "+e),i<0?(i=-i,s.fontDirection=-1):s.fontDirection=1,this.current.font=r,this.current.fontSize=i,r.isType3Font)return;let n=r.loadedName||"sans-serif",a=r.systemFontInfo?.css||`"${n}", ${r.fallbackName}`,o="normal";r.black?o="900":r.bold&&(o="bold");let l=r.italic?"italic":"normal",h=i;i<16?h=16:i>100&&(h=100),this.current.fontSizeScale=i/h,this.ctx.font=`${l} ${o} ${h}px ${a}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,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?.recordSimpleData("textMatrix",t);let{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)}#i3(t,e,i){let r=new Path2D;return r.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),r}paintChar(t,e,i,r,s,n){let a,o=this.ctx,l=this.current,h=l.font,d=l.textRenderingMode,c=l.fontSize/l.fontSizeScale,u=3&d,p=!!(4&d),g=l.patternFill&&!h.missingFile,f=l.patternStroke&&!h.missingFile;if((h.disableFontFace||p||g||f)&&!h.missingFile&&(a=h.getPathGenerator(this.commonObjs,e)),a&&(h.disableFontFace||g||f)){let e;if(o.save(),o.translate(i,r),o.scale(c,-c),this.dependencyTracker?.recordCharacterBBox(t,o,h),0===u||2===u)if(s){e=o.getTransform(),o.setTransform(...s);let t=this.#i3(a,e,s);o.fill(t)}else o.fill(a);if(1===u||2===u)if(n){e||=o.getTransform(),o.setTransform(...n);let{a:t,b:i,c:r,d:s}=e,l=V.inverseTransform(n),h=V.transform([t,i,r,s,0,0],l);V.singularValueDecompose2dScale(h,eO),o.lineWidth*=Math.max(eO[0],eO[1])/c,o.stroke(this.#i3(a,e,n))}else o.lineWidth/=c,o.stroke(a);
2o.restore()}else(0===u||2===u)&&(o.fillText(e,i,r),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,r,()=>o.measureText(e))),(1===u||2===u)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,r,()=>o.measureText(e)).recordDependencies(t,ew),o.strokeText(e,i,r));p&&((this.pendingTextPaths||=[]).push({transform:tb(o),x:i,y:r,fontSize:c,path:a}),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,r))}get isFontSubpixelAAEnabled(){let{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);let e=t.getImageData(0,0,10,10).data,i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return R(this,"isFontSubpixelAAEnabled",i)}showText(t,e){let i,r;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,eE).resetBBox(t),4&this.current.textRenderingMode&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());let s=this.current,n=s.font;if(n.isType3Font){this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t);return}let a=s.fontSize;if(0===a)return void this.dependencyTracker?.recordOperation(t);let o=this.ctx,l=s.fontSizeScale,h=s.charSpacing,d=s.wordSpacing,c=s.fontDirection,u=s.textHScale*c,p=e.length,g=n.vertical,f=g?1:-1,m=n.defaultVMetrics,b=a*s.fontMatrix[0],y=0===s.textRenderingMode&&!n.disableFontFace&&!s.patternFill;if(o.save(),s.textMatrix&&o.transform(...s.textMatrix),o.translate(s.x,s.y+s.textRise),c>0?o.scale(u,-1):o.scale(u,1),s.patternFill){o.save();let e=s.fillColor.getPattern(o,this,ty(o),eT,t);i=tb(o),o.restore(),o.fillStyle=e}if(s.patternStroke){o.save();let e=s.strokeColor.getPattern(o,this,ty(o),ek,t);r=tb(o),o.restore(),o.strokeStyle=e}let v=s.lineWidth,w=s.textMatrixScale;if(0===w||0===v){let t=3&s.textRenderingMode;(1===t||2===t)&&(v=this.getSinglePixelWidth())}else v/=w;if(1!==l&&(o.scale(l,l),v/=l),o.lineWidth=v,n.isInvalidPDFjsFont){let i=[],r=0;for(let t of e)i.push(t.unicode),r+=t.width;let n=i.join("");if(o.fillText(n,0,0),null!==this.dependencyTracker){let e=o.measureText(n);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}
2s.x+=r*b*u,o.restore(),this.compose();return}let x=0,A;for(A=0;A<p;++A){let s,u,p,v=e[A];if("number"==typeof v){x+=f*v*a/1e3;continue}let w=!1,_=(v.isSpace?d:0)+h,E=v.fontChar,S=v.accent,C=v.width;if(g){let t=v.vmetric||m,e=-(v.vmetric?t[1]:.5*C)*b,i=t[2]*b;C=t?-t[0]:C,s=e/l,u=(x+i)/l}else s=x/l,u=0;if(n.remeasure&&C>0){let t=1e3*(p=o.measureText(E)).width/a*l;if(C<t&&this.isFontSubpixelAAEnabled){let e=C/t;w=!0,o.save(),o.scale(e,1),s/=e}else C!==t&&(s+=(C-t)/2e3*a/l)}if(this.contentVisible&&(v.isInFont||n.missingFile)){if(y&&!S)o.fillText(E,s,u),this.dependencyTracker?.recordCharacterBBox(t,o,p?{bbox:null}:n,a/l,s,u,()=>p??o.measureText(E));else if(this.paintChar(t,E,s,u,i,r),S){let e=s+a*S.offset.x/l,n=u-a*S.offset.y/l;this.paintChar(t,S.fontChar,e,n,i,r)}}x+=g?C*b-_*c:C*b+_*c,w&&o.restore()}g?s.y-=x:s.x+=x*u,o.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,e){let i,r,s,n,a=this.ctx,o=this.current,l=o.font,h=o.fontSize,d=o.fontDirection,c=l.vertical?1:-1,u=o.charSpacing,p=o.wordSpacing,g=o.textHScale*d,m=o.fontMatrix||f,b=e.length;if(3===o.textRenderingMode||0===h)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),o.textMatrix&&a.transform(...o.textMatrix),a.translate(o.x,o.y+o.textRise),a.scale(g,d);let y=this.dependencyTracker;for(i=0,this.dependencyTracker=y?new ev(y,t):null;i<b;++i){if("number"==typeof(r=e[i])){n=c*r*h/1e3,this.ctx.translate(n,0),o.x+=n*g;continue}let t=(r.isSpace?p:0)+u,d=l.charProcOperatorList[r.operatorListId];d?this.contentVisible&&(this.save(),a.scale(h,h),a.transform(...m),this.executeOperatorList(d),this.restore()):k(`Type3 character "${r.operatorListId}" is not available.`);let f=[r.width,0];V.applyTransform(f,m),s=f[0]*h+t,a.translate(s,0),o.x+=s*g}a.restore(),y&&(this.dependencyTracker=y)}setCharWidth(t,e,i){}
2setCharWidthAndBounds(t,e,i,r,s,n,a){let o=new Path2D;o.rect(r,s,n-r,a-s),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,r,n,s,a).recordClipBox(t,this.ctx,r,n,s,a),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){let t=this.baseTransform||tb(this.ctx);i=new eF(e,this.ctx,{createCanvasGraphics:(t,e)=>new eQ(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new ev(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),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}
2setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,i=null){let r;return this.cachedPatterns.has(e)?r=this.cachedPatterns.get(e):(r=function(t){switch(t[0]){case"RadialAxial":return new eI(t);case"Mesh":return new eL(t);case"Dummy":return new eB}throw Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,r)),i&&(r.matrix=i),r}shadingFill(t,e){if(!this.contentVisible)return;let i=this.ctx;this.save(t),i.fillStyle=this._getPattern(t,e).getPattern(i,this,ty(i),eM,t);let r=ty(i);{let{width:t,height:e}=i.canvas,s=eU.slice();V.axialAlignedBoundingBox([0,0,t,e],r,s);let[n,a,o,l]=s;this.ctx.fillRect(n,a,o-n,l-a)}this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,eS).recordDependencies(t,ex).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){M("Should not call beginInlineImage")}beginImageData(){M("Should not call beginImageData")}
2paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=tb(this.ctx),i)){V.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);let[e,r,s,n]=i,a=new Path2D;a.rect(e,r,s-e,n-r),this.ctx.clip(a),this.dependencyTracker?.recordClipBox(t,this.ctx,e,s,r,n),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let i=this.ctx;e.isolated||T("TODO: Support non-isolated groups."),e.knockout&&k("Knockout groups not supported.");let r=tb(i);if(e.matrix&&i.transform(...e.matrix),!e.bbox)throw Error("Bounding box is required.");let s=eU.slice();V.axialAlignedBoundingBox(e.bbox,tb(i),s);let n=[0,0,i.canvas.width,i.canvas.height],a=Math.floor((s=V.intersect(s,n)||[0,0,0,0])[0]),o=Math.floor(s[1]),l=Math.max(Math.ceil(s[2])-a,1),h=Math.max(Math.ceil(s[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,h]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);let c=this.cachedCanvases.getCanvas(d,l,h),u=c.context;u.translate(-a,-o),u.transform(...r);let p=new Path2D,[g,f,m,b]=e.bbox;if(p.rect(g,f,m-g,b-f),e.matrix){let t=new Path2D;t.addPath(p,new DOMMatrix(e.matrix)),p=t}u.clip(p),e.smask&&this.smaskStack.push({canvas:c.canvas,context:u,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(a,o),i.save()),eV(i,u),this.ctx=u,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(i),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let i=this.ctx,r=this.groupStack.pop();if(this.ctx=r,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();let e=tb(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);let r=eU.slice();V.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,r),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.compose(r)}}beginAnnotation(t,e,i,r,s,n){if(this.#i1(),eW(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){let s=i[2]-i[0],a=i[3]-i[1];if(n&&this.annotationCanvasMap){r=r.slice(),r[4]-=i[0],r[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=s,i[3]=a,V.singularValueDecompose2dScale(tb(this.ctx),eO);let{viewportScale:t}=this,n=Math.ceil(s*this.outputScaleX*t),o=Math.ceil(a*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(n,o);let{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(eO[0],0,0,-eO[1],0,a*eO[1]),eW(this.ctx)}else{eW(this.ctx),this.endPath(t);let e=new Path2D;e.rect(i[0],i[1],s,a),this.ctx.clip(e)}}this.current=new eH(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...r),this.transform(t,...s)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#i2(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let i=e.count;(e=this.getObject(t,e.data,e)).count=i;let r=this.ctx,s=this._createMaskCanvas(t,e),n=s.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(n,s.offsetX,s.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,s.offsetX,s.offsetX+n.width,s.offsetY,s.offsetY+n.height).recordOperation(t),r.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i,r=0,s=0,n,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.ctx;o.save();let l=tb(o);o.transform(i,r,s,n,0,0);let h=this._createMaskCanvas(t,e);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,d=a.length;e<d;e+=2){let d=V.transform(l,[i,r,s,n,a[e],a[e+1]]);o.drawImage(h.canvas,d[4],d[5]),this.dependencyTracker?.recordBBox(t,this.ctx,d[4],d[4]+h.canvas.width,d[5],d[5]+h.canvas.height)}
2o.restore(),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let i=this.ctx,r=this.current.fillColor,s=this.current.patternFill;for(let n of(this.dependencyTracker?.resetBBox(t).recordDependencies(t,eC),e)){let{data:e,width:a,height:o,transform:l}=n,h=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=h.context;d.save(),eG(d,this.getObject(t,e,n)),d.globalCompositeOperation="source-in",d.fillStyle=s?r.getPattern(d,this,ty(i),eT,t):r,d.fillRect(0,0,a,o),d.restore(),i.save(),i.transform(...l),i.scale(1,-1),ez(i,h.canvas,0,0,a,o,0,-1,1,1),this.dependencyTracker?.recordBBox(t,i,0,a,0,o),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;let i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):k("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,r,s){if(!this.contentVisible)return;let n=this.getObject(t,e);if(!n)return void k("Dependent image isn't ready yet");let a=n.width,o=n.height,l=[];for(let t=0,e=s.length;t<e;t+=2)l.push({transform:[i,0,0,r,s[t],s[t+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,n,l)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;let{bitmap:e,width:i,height:r}=t,s=this.cachedCanvases.getCanvas("inlineImage",i,r),n=s.context;return n.filter=this.current.transferMaps,n.drawImage(e,0,0),n.filter="none",s.canvas}paintInlineImageXObject(t,e){let i;if(!this.contentVisible)return;let r=e.width,s=e.height,n=this.ctx;this.save(t);let{filter:a}=n;if("none"!==a&&""!==a&&(n.filter="none"),n.scale(1/r,-1/s),e.bitmap)i=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)i=e;else{let t=this.cachedCanvases.getCanvas("inlineImage",r,s).context;e$(t,e),i=this.applyTransferMapsToCanvas(t)}let o=this._scaleImage(i,ty(n));n.imageSmoothingEnabled=eq(tb(n),e.interpolate),this.dependencyTracker?.resetBBox(t).recordBBox(t,n,0,r,-s,0).recordDependencies(t,eA).recordOperation(t),ez(n,o.img,0,0,o.paintWidth,o.paintHeight,0,-s,r,s),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){let r;if(!this.contentVisible)return;let s=this.ctx;if(e.bitmap)r=e.bitmap;else{let t=e.width,i=e.height,s=this.cachedCanvases.getCanvas("inlineImage",t,i).context;e$(s,e),r=this.applyTransferMapsToCanvas(s)}for(let e of(this.dependencyTracker?.resetBBox(t),i))s.save(),s.transform(...e.transform),s.scale(1,-1),ez(s,r,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,s,0,1,-1,0),s.restore();this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,ex).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}
2markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){let r=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);let s=this.ctx;this.pendingClip?(r||(this.pendingClip===eJ?s.clip(e,"evenodd"):s.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){let t=tb(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),r=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,r)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let t,e,{lineWidth:i}=this.current,{a:r,b:s,c:n,d:a}=this.ctx.getTransform();if(0===s&&0===n){let s=Math.abs(r),n=Math.abs(a);if(s===n)if(0===i)t=e=1/s;else{let r=s*i;t=e=r<1?1/r:1}else if(0===i)t=1/s,e=1/n;else{let r=s*i,a=n*i;t=r<1?1/r:1,e=a<1?1/a:1}}else{let o=Math.abs(r*a-s*n),l=Math.hypot(r,s),h=Math.hypot(n,a);if(0===i)t=h/o,e=l/o;else{let r=i*o;t=h>r?h/r:1,e=l>r?l/r:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:i,current:{lineWidth:r}}=this,[s,n]=this.getScaleForStroking();if(s===n){i.lineWidth=(r||1)*s,i.stroke(t);return}let a=i.getLineDash();e&&i.save(),i.scale(s,n),eN.a=1/s,eN.d=1/n;let o=new Path2D;if(o.addPath(t,eN),a.length>0){let t=Math.max(s,n);i.setLineDash(a.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=r||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in E)void 0!==eQ.prototype[t]&&(eQ.prototype[E[t]]=eQ.prototype[t]);class eZ{#i5;#i6;#i4;static strings=["fontFamily","fontWeight","italicAngle"];static write(t){let e=new TextEncoder,i={},r=0;for(let s of eZ.strings){let n=e.encode(t[s]);i[s]=n,r+=4+n.length}let s=new ArrayBuffer(r),n=new Uint8Array(s),a=new DataView(s),o=0;for(let t of eZ.strings){let e=i[t],r=e.length;a.setUint32(o,r),n.set(e,o+4),o+=4+r}return P(o===s.byteLength,"CssFontInfo.write: Buffer overflow"),s}constructor(t){this.#i5=t,this.#i6=new DataView(this.#i5),this.#i4=new TextDecoder}#i8(t){P(t<eZ.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#i6.getUint32(e)+4;let i=this.#i6.getUint32(e);return this.#i4.decode(new Uint8Array(this.#i5,e+4,i))}get fontFamily(){return this.#i8(0)}get fontWeight(){return this.#i8(1)}get italicAngle(){return this.#i8(2)}}class e0{#i5;#i6;#i4;static strings=["css","loadedName","baseFontName","src"];static write(t){let e=new TextEncoder,i={},r=0;for(let s of e0.strings){let n=e.encode(t[s]);i[s]=n,r+=4+n.length}let s,n,a=1+(r+=4);t.style&&(s=e.encode(t.style.style),n=e.encode(t.style.weight),a+=4+s.length+4+n.length);let o=new ArrayBuffer(a),l=new Uint8Array(o),h=new DataView(o),d=0;for(let e of(h.setUint8(d++,+!!t.guessFallback),h.setUint32(d,0),d+=4,r=0,e0.strings)){let t=i[e],s=t.length;r+=4+s,h.setUint32(d,s),l.set(t,d+4),d+=4+s}return h.setUint32(d-r-4,r),t.style&&(h.setUint32(d,s.length),l.set(s,d+4),d+=4+s.length,h.setUint32(d,n.length),l.set(n,d+4),d+=4+n.length),P(d<=o.byteLength,"SubstitionInfo.write: Buffer overflow"),o.transferToFixedLength(d)}constructor(t){this.#i5=t,this.#i6=new DataView(this.#i5),this.#i4=new TextDecoder}get guessFallback(){return 0!==this.#i6.getUint8(0)}#i8(t){P(t<e0.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#i6.getUint32(e)+4;let i=this.#i6.getUint32(e);return this.#i4.decode(new Uint8Array(this.#i5,e+4,i))}get css(){return this.#i8(0)}get loadedName(){return this.#i8(1)}get baseFontName(){return this.#i8(2)}get src(){return this.#i8(3)}get style(){let t=1;t+=4+this.#i6.getUint32(t);let e=this.#i6.getUint32(t),i=this.#i4.decode(new Uint8Array(this.#i5,t+4,e));t+=4+e;let r=this.#i6.getUint32(t),s=this.#i4.decode(new Uint8Array(this.#i5,t+4,r));return{style:i,weight:s}}}
2class e1{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static #i7=Math.ceil(2*this.bools.length/8);static #i9=this.#i7+8*this.numbers.length;static #rt=this.#i9+1+8;static #re=this.#rt+1+48;static #ri=this.#re+1+6;#i5;#i4;#i6;constructor({data:t,extra:e}){this.#i5=t,this.#i4=new TextDecoder,this.#i6=new DataView(this.#i5),e&&Object.assign(this,e)}#rr(t){P(t<e1.bools.length,"Invalid boolean index");let e=Math.floor(t/4),i=this.#i6.getUint8(e)>>2*t%8&3;return 0===i?void 0:2===i}get black(){return this.#rr(0)}get bold(){return this.#rr(1)}get disableFontFace(){return this.#rr(2)}get fontExtraProperties(){return this.#rr(3)}get isInvalidPDFjsFont(){return this.#rr(4)}get isType3Font(){return this.#rr(5)}get italic(){return this.#rr(6)}get missingFile(){return this.#rr(7)}get remeasure(){return this.#rr(8)}get vertical(){return this.#rr(9)}#rs(t){return P(t<e1.numbers.length,"Invalid number index"),this.#i6.getFloat64(e1.#i7+8*t)}get ascent(){return this.#rs(0)}get defaultWidth(){return this.#rs(1)}get descent(){return this.#rs(2)}get bbox(){let t=e1.#i9;if(0===this.#i6.getUint8(t))return;t+=1;let e=[];for(let i=0;i<4;i++)e.push(this.#i6.getInt16(t,!0)),t+=2;return e}get fontMatrix(){let t=e1.#rt;if(0===this.#i6.getUint8(t))return;t+=1;let e=[];for(let i=0;i<6;i++)e.push(this.#i6.getFloat64(t,!0)),t+=8;return e}get defaultVMetrics(){let t=e1.#re;if(0===this.#i6.getUint8(t))return;t+=1;let e=[];for(let i=0;i<3;i++)e.push(this.#i6.getInt16(t,!0)),t+=2;return e}#i8(t){P(t<e1.strings.length,"Invalid string index");let e=e1.#ri+4;for(let i=0;i<t;i++)e+=this.#i6.getUint32(e)+4;let i=this.#i6.getUint32(e),r=new Uint8Array(i);return r.set(new Uint8Array(this.#i5,e+4,i)),this.#i4.decode(r)}get fallbackName(){return this.#i8(0)}get loadedName(){return this.#i8(1)}get mimetype(){return this.#i8(2)}get name(){return this.#i8(3)}get data(){let t=e1.#ri,e=this.#i6.getUint32(t);t+=4+e;let i=this.#i6.getUint32(t);t+=4+i;let r=this.#i6.getUint32(t);t+=4+r;let s=this.#i6.getUint32(t);if(0!==s)return new Uint8Array(this.#i5,t+4,s)}clearData(){let t=e1.#ri,e=this.#i6.getUint32(t);t+=4+e;let i=this.#i6.getUint32(t);t+=4+i;let r=this.#i6.getUint32(t);t+=4+r;let s=this.#i6.getUint32(t);new Uint8Array(this.#i5,t+4,s).fill(0),this.#i6.setUint32(t,0)}get cssFontInfo(){let t=e1.#ri,e=this.#i6.getUint32(t);t+=4+e;let i=this.#i6.getUint32(t);t+=4+i;let r=this.#i6.getUint32(t);if(0===r)return null;let s=new Uint8Array(r);return s.set(new Uint8Array(this.#i5,t+4,r)),new eZ(s.buffer)}get systemFontInfo(){let t=e1.#ri,e=this.#i6.getUint32(t);t+=4+e;let i=this.#i6.getUint32(t);if(0===i)return null;let r=new Uint8Array(i);return r.set(new Uint8Array(this.#i5,t+4,i)),new e0(r.buffer)}static write(t){let e=t.systemFontInfo?e0.write(t.systemFontInfo):null,i=t.cssFontInfo?eZ.write(t.cssFontInfo):null,r=new TextEncoder,s={},n=0;for(let e of e1.strings)s[e]=r.encode(t[e]),n+=4+s[e].length;let a=new ArrayBuffer(e1.#ri+4+n+4+(e?e.byteLength:0)+4+(i?i.byteLength:0)+4+(t.data?t.data.length:0)),o=new Uint8Array(a),l=new DataView(a),h=0,d=e1.bools.length,c=0,u=0;for(let e=0;e<d;e++){let i=t[e1.bools[e]];c|=(void 0===i?0:i?2:1)<<u,(8===(u+=2)||e===d-1)&&(l.setUint8(h++,c),c=0,u=0)}for(let e of(P(h===e1.#i7,"FontInfo.write: Boolean properties offset mismatch"),e1.numbers))l.setFloat64(h,t[e]),h+=8;if(P(h===e1.#i9,"FontInfo.write: Number properties offset mismatch"),t.bbox)for(let e of(l.setUint8(h++,4),t.bbox))l.setInt16(h,e,!0),h+=2;else l.setUint8(h++,0),h+=8;if(P(h===e1.#rt,"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix)for(let e of(l.setUint8(h++,6),t.fontMatrix))l.setFloat64(h,e,!0),h+=8;else l.setUint8(h++,0),h+=48;if(P(h===e1.#re,"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics)for(let e of(l.setUint8(h++,1),t.defaultVMetrics))l.setInt16(h,e,!0),h+=2;else l.setUint8(h++,0),h+=6;for(let t of(P(h===e1.#ri,"FontInfo.write: DefaultVMetrics properties offset mismatch"),l.setUint32(e1.#ri,0),h+=4,e1.strings)){let e=s[t],i=e.length;l.setUint32(h,i),o.set(e,h+4),h+=4+i}if(l.setUint32(e1.#ri,h-e1.#ri-4),e){let t=e.byteLength;l.setUint32(h,t),P(h+4+t<=a.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),o.set(new Uint8Array(e),h+4),h+=4+t}else l.setUint32(h,0),h+=4;if(i){let t=i.byteLength;l.setUint32(h,t),P(h+4+t<=a.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),o.set(new Uint8Array(i),h+4),h+=4+t}else l.setUint32(h,0),h+=4;return void 0===t.data?(l.setUint32(h,0),h+=4):(l.setUint32(h,t.data.length),o.set(t.data,h+4),h+=4+t.data.length),P(h<=a.byteLength,"FontInfo.write: Buffer overflow"),a.transferTo
2FixedLength(h)}}class e2{static #rn=null;static #ra="";static get workerPort(){return this.#rn}static set workerPort(t){if(!("u">typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#rn=t}static get workerSrc(){return this.#ra}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#ra=t}}class e3{#ro;#rl;constructor({parsedData:t,rawData:e}){this.#ro=t,this.#rl=e}getRaw(){return this.#rl}get(t){return this.#ro.get(t)??null}[Symbol.iterator](){return this.#ro.entries()}}let e5=Symbol("INTERNAL");class e6{#rh=!1;#rd=!1;#rc=!1;#ru=!0;constructor(t,{name:e,intent:i,usage:r,rbGroups:s}){this.#rh=!!(2&t),this.#rd=!!(4&t),this.name=e,this.intent=i,this.usage=r,this.rbGroups=s}get visible(){if(this.#rc)return this.#ru;if(!this.#ru)return!1;let{print:t,view:e}=this.usage;return this.#rh?e?.viewState!=="OFF":!this.#rd||t?.printState!=="OFF"}_setVisible(t,e,i=!1){t!==e5&&M("Internal method `_setVisible` called."),this.#rc=i,this.#ru=e}}class e4{#rp=null;#rg=new Map;#rf=null;#rm=null;constructor(t,e=2){if(this.renderingIntent=e,this.name=null,this.creator=null,null===t)return;for(const i of(this.name=t.name,this.creator=t.creator,this.#rm=t.order,t.groups))this.#rg.set(i.id,new e6(e,i));if("OFF"===t.baseState)for(const t of this.#rg.values())t._setVisible(e5,!1);for(const e of t.on)this.#rg.get(e)._setVisible(e5,!0);for(const e of t.off)this.#rg.get(e)._setVisible(e5,!1);this.#rf=this.getHash()}#rb(t){let e=t.length;if(e<2)return!0;let i=t[0];for(let r=1;r<e;r++){let e,s=t[r];if(Array.isArray(s))e=this.#rb(s);else{if(!this.#rg.has(s))return k(`Optional content group not found: ${s}`),!0;e=this.#rg.get(s).visible}switch(i){case"And":if(!e)return!1;break;case"Or":if(e)return!0;break;case"Not":return!e;default:return!0}}return"And"===i}isVisible(t){if(0===this.#rg.size)return!0;if(!t)return T("Optional content group not defined."),!0;if("OCG"===t.type)return this.#rg.has(t.id)?this.#rg.get(t.id).visible:(k(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#rb(t.expression);if(t.policy&&"AnyOn"!==t.policy){if("AllOn"===t.policy){for(let e of t.ids){if(!this.#rg.has(e)){k(`Optional content group not found: ${e}`);break}if(!this.#rg.get(e).visible)return!1}return!0}else if("AnyOff"===t.policy){for(let e of t.ids){if(!this.#rg.has(e))return k(`Optional content group not found: ${e}`),!0;if(!this.#rg.get(e).visible)return!0}return!1}else if("AllOff"===t.policy){for(let e of t.ids){if(!this.#rg.has(e)){k(`Optional content group not found: ${e}`);break}if(this.#rg.get(e).visible)return!1}return!0}}else{for(let e of t.ids){if(!this.#rg.has(e))return k(`Optional content group not found: ${e}`),!0;if(this.#rg.get(e).visible)return!0}return!1}return k(`Unknown optional content policy ${t.policy}.`),!0}return k(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){let r=this.#rg.get(t);if(!r)return void k(`Optional content group not found: ${t}`);if(i&&e&&r.rbGroups.length)for(let e of r.rbGroups)for(let i of e)i!==t&&this.#rg.get(i)?._setVisible(e5,!1,!0);r._setVisible(e5,!!e,!0),this.#rp=null}setOCGState({state:t,preserveRB:e}){let i;for(let r of t){switch(r){case"ON":case"OFF":case"Toggle":i=r;continue}let t=this.#rg.get(r);if(t)switch(i){case"ON":this.setVisibility(r,!0,e);break;case"OFF":this.setVisibility(r,!1,e);break;case"Toggle":this.setVisibility(r,!t.visible,e)}}this.#rp=null}get hasInitialVisibility(){return null===this.#rf||this.getHash()===this.#rf}getOrder(){return this.#rg.size?this.#rm?this.#rm.slice():[...this.#rg.keys()]:null}getGroup(t){return this.#rg.get(t)||null}getHash(){if(null!==this.#rp)return this.#rp;let t=new tW;for(let[e,i]of this.#rg)t.update(`${e}:${i.visible}`);return this.#rp=t.hexdigest()}[Symbol.iterator](){return this.#rg.entries()}}class e8{constructor(t,{disableRange:e=!1,disableStream:i=!1}){P(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:r,initialData:s,progressiveDone:n,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=n,this._contentDispositionFilename=a,s?.length>0){const t=s instanceof Uint8Array&&s.byteLength===s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){let i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;void 0===t?this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i):P(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(i),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){let e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){P(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let t=this._queuedChunks;return this._queuedChunks=null,new e7(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new e9(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeReaders.slice(0)))e.cancel(t);this._pdfDataRangeTransport.abort()}}class e7{constructor(t,e,i=!1,r=null){for(const s of(this._stream=t,this._done=i||!1,this._filename=to(r)?r:null,this._queuedChunks=e||[],this._loaded=0,this._queuedChunks))this._loaded+=s.byteLength;
2this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class e9{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{for(let e of(this._requests.shift().resolve({value:t,done:!1}),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function it(t,e){let i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(let t in e){let r=e[t];void 0!==r&&i.append(t,r)}return i}function ie(t){return URL.parse(t)?.origin??null}function ii({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:r}){let s={allowRangeRequests:!1,suggestedLength:void 0},n=parseInt(t.get("Content-Length"),10);return Number.isInteger(n)&&(s.suggestedLength=n,n<=2*i||r||!e||"bytes"!==t.get("Accept-Ranges")||"identity"!==(t.get("Content-Encoding")||"identity")||(s.allowRangeRequests=!0)),s}function ir(t){let e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=r("filename\\*","i").exec(t);if(i){let t=a(i=i[1]);return n(t=l(t=o(t=unescape(t))))}if(i=function(t){let e,i=[],s=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=s.exec(t));){let[,t,r,s]=e;if((t=parseInt(t,10))in i){if(0===t)break;continue}i[t]=[r,s]}let n=[];for(let t=0;t<i.length&&t in i;++t){let[e,r]=i[t];r=a(r),e&&(r=unescape(r),0===t&&(r=o(r))),n.push(r)}return n.join("")}(t))return n(l(i));if(i=r("filename","i").exec(t)){let t=a(i=i[1]);return n(t=l(t))}function r(t,e){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function s(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let r=new TextDecoder(t,{fatal:!0}),s=H(i);i=r.decode(s),e=!1}catch{}}return i}function n(t){return e&&/[\x80-\xff]/.test(t)&&(t=s("utf-8",t),e&&(t=s("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){let e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){let 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 o(t){let e=t.indexOf("'");return -1===e?t:s(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,i,r){if("q"===i||"Q"===i)return s(e,r=(r=r.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{r=atob(r)}catch{}return s(e,r)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(to(t))return t}return null}function is(t,e){return new O(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function ia(t){return 200===t||206===t}function io(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function il(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(k(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class ih{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=it(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return P(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new id(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new ic(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}
2class id{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),r=e.url;fetch(r,io(i,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=ie(e.url),!ia(e.status))throw is(e.status,r);this._reader=e.body.getReader(),this._headersCapability.resolve();let i=e.headers,{allowRangeRequests:s,suggestedLength:n}=ii({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=s,this._contentLength=n||this._contentLength,this._filename=ir(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new j("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:il(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ic{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const r=t.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;const s=new Headers(t.headers);s.append("Range",`bytes=${e}-${i-1}`);const n=r.url;fetch(n,io(s,this._withCredentials,this._abortController)).then(e=>{let i=ie(e.url);if(i!==t._responseOrigin)throw Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!ia(e.status))throw is(e.status,n);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:il(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class iu{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=it(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){let e=new XMLHttpRequest,i=this.currXhrId++,r=this.pendingRequests[i]={xhr:e};for(let[t,i]of(e.open("GET",this.url),e.withCredentials=this.withCredentials,this.headers))e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),r.expectedStatus=206):r.expectedStatus=200,e.responseType="arraybuffer",P(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),r.onHeadersReceived=t.onHeadersReceived,r.onDone=t.onDone,r.onError=t.onError,r.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){let i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){let i,r=this.pendingRequests[t];if(!r)return;let s=r.xhr;if(s.readyState>=2&&r.onHeadersReceived&&(r.onHeadersReceived(),delete r.onHeadersReceived),4!==s.readyState||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void r.onError(s.status);let n=s.status||200;if((200!==n||206!==r.expectedStatus)&&n!==r.expectedStatus)return void r.onError(s.status);let a="string"!=typeof(i=s.response)?i:H(i).buffer;if(206===n){let t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?r.onDone({begin:parseInt(e[1],10),chunk:a}):(k('Missing or invalid "Content-Range" header.'),r.onError(0))}else a?r.onDone({begin:0,chunk:a}):r.onError(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}
2abortRequest(t){let e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class ip{constructor(t){this._source=t,this._manager=new iu(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){let e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return P(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new ig(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){let i=new im(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class ig{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=ie(e.responseURL);let i=e.getAllResponseHeaders(),r=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{let[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{allowRangeRequests:s,suggestedLength:n}=ii({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});s&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=ir(r),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){for(let e of(this._storedError=is(t,this._url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let e of(this._done=!0,this._headersCapability.reject(t),this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class im{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){let t=ie(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){let e=t.chunk;for(let t of(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){for(let e of(this._storedError??=is(t,this._url),this._requests))e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){for(let t of(this._done=!0,this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest
2(this._requestId),this._close()}}let ib=/^[a-z][a-z0-9\-+.]+:/i;class iy{constructor(t){this.source=t,this.url=function(t){return new URL(ib.test(t)?t:d.default.getBuiltinModule("url").pathToFileURL(t))}(t.url),P("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return P(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new iv(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new iw(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){for(let e of(this._fullRequestReader?.cancel(t),this._rangeRequestReaders.slice(0)))e.cancel(t)}}class iv{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=d.default.getBuiltinModule("fs");i.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=is(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new j("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class iw{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const r=t.source;this._isStreamingSupported=!r.disableStream;const s=d.default.getBuiltinModule("fs");this._setReadableStream(s.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}let ix=Symbol("INITIAL_DATA");class iA{#ry=Object.create(null);#rv(t){return this.#ry[t]||={...Promise.withResolvers(),data:ix}}get(t,e=null){if(e){let i=this.#rv(t);return i.promise.then(()=>e(i.data)),null}let i=this.#ry[t];if(!i||i.data===ix)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#ry[t];return!!e&&e.data!==ix}delete(t){let e=this.#ry[t];return!!e&&e.data!==ix&&(delete this.#ry[t],!0)}resolve(t,e=null){let i=this.#rv(t);i.data=e,i.resolve()}clear(){for(let t in this.#ry){let{data:e}=this.#ry[t];e?.bitmap?.close()}this.#ry=Object.create(null)}*[Symbol.iterator](){for(let t in this.#ry){let{data:e}=this.#ry[t];e!==ix&&(yield[t,e])}}}class i_{#rw=Promise.withResolvers();#tx=null;#rx=!1;#rA=!!globalThis.FontInspector?.enabled;#r_=null;#rE=null;#rS=0;#rC=0;#rT=null;#rk=null;#rM=0;#rP=0;#rD=Object.create(null);#rI=[];#rR=null;#rL=[];#rB=new WeakMap;#rF=null;static #rN=new Map;static #rO=new Map;static #rU=new WeakMap;static #rj=null;static #rz=new Set;constructor({textContentSource:t,container:e,viewport:i}){if(t instanceof ReadableStream)this.#rR=t;else if("object"==typeof t)this.#rR=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error('No "textContentSource" parameter specified.');this.#tx=this.#rk=e,this.#rP=i.scale*tw.pixelRatio,this.#rM=i.rotation,this.#rE={div:null,properties:null,ctx:null};const{pageWidth:r,pageHeight:s,pageX:n,pageY:a}=i.rawDims;this.#rF=[1,0,0,-1,-n,a+s],this.#rC=r,this.#rS=s,i_.#rH(),tv(e,i),this.#rw.promise.finally(()=>{i_.#rz.delete(this),this.#rE=null,this.#rD=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=$.platform;return R(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){let t=()=>{this.#rT.read().then(({value:e,done:i})=>{i?this.#rw.resolve():(this.#r_??=e.lang,Object.assign(this.#rD,e.styles),this.#r$(e.items),t())},this.#rw.reject)};return this.#rT=this.#rR.getReader(),i_.#rz.add(this),t(),this.#rw.promise}update({viewport:t,onBefore:e=null}){let i=t.scale*tw.pixelRatio,r=t.rotation;if(r!==this.#rM&&(e?.(),this.#rM=r,tv(this.#rk,{rotation:r})),i!==this.#rP){e?.(),this.#rP=i;let t={div:null,properties:null,ctx:i_.#rG(this.#r_)};for(let e of this.#rL)t.properties=this.#rB.get(e),t.div=e,this.#rV(t)}}cancel(){let t=new j("TextLayer task cancelled.");this.#rT?.cancel(t).catch(()=>{}),this.#rT=null,this.#rw.reject(t)}get textDivs(){return this.#rL}get textContentItemsStr(){return this.#rI}#r$(t){if(this.#rx)return;this.#rE.ctx??=i_.#rG(this.#r_);let e=this.#rL,i=this.#rI;for(let r of t){if(e.length>1e5){k("Ignoring additional textDivs for performance reasons."),this.#rx=!0;return}if(void 0===r.str){if("beginMarkedContentProps"===r.type||"beginMarkedContent"===r.type){let t=this.#tx;this.#tx=document.createElement("span"),this.#tx.classList.add("markedContent"),r.id&&this.#tx.setAttribute("id",`${r.id}`),t.append(this.#tx)}else"endMarkedContent"===r.type&&(this.#tx=this.#tx.parentNode);continue}i.push(r.str),this.#rW(r)}}#rW(t){let e,i,r=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#rL.push(r);let n=V.transform(this.#rF,t.transform),a=Math.atan2(n[1],n[0]),o=this.#rD[t.fontName];o.vertical&&(a+=Math.PI/2);let l=this.#rA&&o.fontSubstitution||o.fontFamily;l=i_.fontFamilyMap.get(l)||l;let h=Math.hypot(n[2],n[3]),d=h*i_.#rq(l,o,this.#r_);0===a?(e=n[4],i=n[5]-d):(e=n[4]+d*Math.sin(a),i=n[5]-d*Math.cos(a));let c="calc(var(--total-scale-factor) *",u=r.style;this.#tx===this.#rk?(u.left=`${(100*e/this.#rC).toFixed(2)}%`,u.top=`${(100*i/this.#rS).toFixed(2)}%`):(u.left=`${c}${e.toFixed(2)}px)`,u.top=`${c}${i.toFixed(2)}px)`),u.fontSize=`${c}${(i_.#rj*h).toFixed(2)}px)`,u.fontFamily=l,s.fontSize=h,r.setAttribute("role","presentation"),r.textContent=t.str,r.dir=t.dir,this.#rA&&(r.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),0!==a&&(s.angle=180/Math.PI*a);let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(p=!0)}if(p&&(s.canvasWidth=o.vertical?t.height:t.width),this.#rB.set(r,s),this.#rE.div=r,this.#rE.properties=s,this.#rV(this.#rE),s.hasText&&this.#tx.append(r),s.hasEOL){let t=document.createElement("br");t.setAttribute("role","presentation"),this.#tx.append(t)}}#rV(t){let{div:e,properties:i,ctx:r}=t,{style:s}=e,n="";if(i_.#rj>1&&(n=`scale(${1/i_.#rj})`),0!==i.canvasWidth&&i.hasText){let{fontFamily:t}=s,{canvasWidth:a,fontSize:o}=i;i_.#rX(r,o*this.#rP,t);let{width:l}=r.measureText(e.textContent);l>0&&(n=`scaleX(${a*this.#rP/l}) ${n}`)}0!==i.angle&&(n=`rotate(${i.angle}deg) ${n}`),n.length>0&&(s.transform=n)}static cleanup(){if(!(this.#rz.size>0)){for(let{canvas:t}
2of(this.#rN.clear(),this.#rO.values()))t.remove();this.#rO.clear()}}static #rG(t=null){let e=this.#rO.get(t||="");if(!e){let i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#rO.set(t,e),this.#rU.set(e,{size:0,family:""})}return e}static #rX(t,e,i){let r=this.#rU.get(t);(e!==r.size||i!==r.family)&&(t.font=`${e}px ${i}`,r.size=e,r.family=i)}static #rH(){if(null!==this.#rj)return;let 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.#rj=t.getBoundingClientRect().height,t.remove()}static #rq(t,e,i){let r=this.#rN.get(t);if(r)return r;let s=this.#rG(i);s.canvas.width=s.canvas.height=30,this.#rX(s,30,t);let n=s.measureText(""),a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);s.canvas.width=s.canvas.height=0;let l=.8;return a?l=a/(a+o):($.platform.isFirefox&&k("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.desce
2nt)),this.#rN.set(t,l),l}}function iE(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});let e=new iS,{docId:i}=e,r=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(g)return t;let e=URL.parse(t,window.location);if(e)return e.href}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,s=t.data?function(t){if(g&&void 0!==c.Buffer&&t instanceof c.Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return H(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,n=t.httpHeaders||null,a=!0===t.withCredentials,o=t.password??null,l=t.range instanceof iC?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,d=t.worker instanceof iM?t.worker:null,u=t.verbosity,p="string"!=typeof t.docBaseUrl||ta(t.docBaseUrl)?null:t.docBaseUrl,f=tQ(t.cMapUrl),m=!1!==t.cMapPacked,b=t.CMapReaderFactory||(g?el:t7),y=tQ(t.iccUrl),v=tQ(t.standardFontDataUrl),w=t.StandardFontDataFactory||(g?eh:ei),x=tQ(t.wasmUrl),A=t.WasmFactory||(g?ed:es),_=!0!==t.stopAtErrors,E=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,S=!1!==t.isEvalSupported,T="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!g,k="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!g&&($.platform.isFirefox||!globalThis.chrome),M=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,P="boolean"==typeof t.disableFontFace?t.disableFontFace:g,D=!0===t.fontExtraProperties,I=!0===t.enableXfa,R=t.ownerDocument||globalThis.document,L=!0===t.disableRange,B=!0===t.disableStream,F=!0===t.disableAutoFetch,N=!0===t.pdfBug,O=t.CanvasFactory||(g?eo:t4),U=t.FilterFactory||(g?ea:et),j=!0===t.enableHWA,z=!1!==t.useWasm,G=l?l.length:t.length??NaN,V="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!g&&!P,W="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(b===t7&&w===ei&&A===es&&f&&v&&x&&tc(f,document.baseURI)&&tc(v,document.baseURI)&&tc(x,document.baseURI));Number.isInteger(u)&&(C=u);let q={canvasFactory:new O({ownerDocument:R,enableHWA:j}),filterFactory:new U({docId:i,ownerDocument:R}),cMapReaderFactory:W?null:new b({baseUrl:f,isCompressed:m}),standardFontDataFactory:W?null:new w({baseUrl:v}),wasmFactory:W?null:new A({baseUrl:x})};d||(e._worker=d=iM.create({verbosity:u,port:e2.workerPort}));let X={docId:i,apiVersion:"5.4.296",data:s,password:o,disableAutoFetch:F,rangeChunkSize:h,length:G,docBaseUrl:p,enableXfa:I,evaluatorOptions:{maxImageSize:E,disableFontFace:P,ignoreErrors:_,isEvalSupported:S,isOffscreenCanvasSupported:T,isImageDecoderSupported:k,canvasMaxAreaInBytes:M,fontExtraProperties:D,useSystemFonts:V,useWasm:z,useWorkerFetch:W,cMapUrl:f,iccUrl:y,standardFontDataUrl:v,wasmUrl:x}},K={ownerDocument:R,pdfBug:N,styleElement:null,loadingParams:{disableAutoFetch:F,enableXfa:I}};return d.promise.then(function(){let t;if(e.destroyed)throw Error("Loading aborted");if(d.destroyed)throw Error("Worker was destroyed");let o=d.messageHandler.sendWithPromise("GetDocRequest",X,s?[s.buffer]:null);if(l)t=new e8(l,{disableRange:L,disableStream:B});else if(!s){if(!r)throw Error("getDocument - no `url` parameter provided.");t=new(tc(r)?ih:g?iy:ip)({url:r,length:G,httpHeaders:n,withCredentials:a,rangeChunkSize:h,disableRange:L,disableStream:B})}return o.then(r=>{if(e.destroyed)throw Error("Loading aborted");if(d.destroyed)throw Error("Worker was destroyed");let s=new t5(i,r,d.port),n=new iP(s,e,t,K,q,j);e._transport=n,s.send("Ready",null)})}).catch(e._capability.reject),e}class iS{static #ib=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${iS.#ib++}`;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 iC{#rw=Promise.withResolvers();#rK=[];#rY=[];#rJ=[];#rQ=[];constructor(t,e,i=!1,r=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=r}addRangeListener(t){this.#rQ.push(t)}addProgressListener(t){this.#rJ.push(t)}addProgressiveReadListener(t){this.#rY.push(t)}addProgressiveDoneListener(t){this.#rK.push(t)}onDataRange(t,e){for(let i of this.#rQ)i(t,e)}onDataProgress(t,e){this.#rw.promise.then(()=>{for(let i of this.#rJ)i(t,e)})}onDataProgressiveRead(t){this.#rw.promise.then(()=>{for(let e of this.#rY)e(t)})}onDataProgressiveDone(){this.#rw.promise.then(()=>{for(let t of this.#rK)t()})}transportReady(){this.#rw.resolve()}requestDataRange(t,e){M("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class iT{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return R(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"}={}){let{renderingIntent:e}
vendor: 1,981 bytes, line 2
2=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class ik{#rZ=!1;constructor(t,e,i,r=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=r?new td:null,this._pdfBug=r,this.commonObjs=i.commonObjs,this.objs=new iA,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:r=0,dontFlip:s=!1}={}){return new ts({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:r,dontFlip:s})}getAnnotations({intent:t="display"}={}){let{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 R(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}
2render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:r="display",annotationMode:s=m.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:c=!1,recordOperations:u=!1,operationsFilter:p=null}){this._stats?.time("Overall");let g=this._transport.getRenderingIntent(r,s,d,c),{renderingIntent:f,cacheKey:b}=g;this.#rZ=!1,o||=this._transport.getOptionalContentConfig(f);let y=this._intentStates.get(b);y||(y=Object.create(null),this._intentStates.set(b,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);let v=!!(4&f);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(g));let w=!!(this._pdfBug&&globalThis.StepperManager?.enabled),x=!this.recordedBBoxes&&(u||w),A=t=>{if(y.renderTasks.delete(_),x){let t=_.gfx?.dependencyTracker.take();t&&(_.stepper&&_.stepper.setOperatorBBoxes(t,_.gfx.dependencyTracker.takeDebugMetadata()),u&&(this.recordedBBoxes=t))}v&&(this.#rZ=!0),this.#r0(),t?(_.capability.reject(t),this._abortOperatorList({intentState:y,reason:t instanceof Error?t:Error(t)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},_=new iI({callback:A,params:{canvas:e,canvasContext:t,dependencyTracker:x?new ey(e,y.operatorList.length,w):null,viewport:i,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:p});(y.renderTasks||=new Set).add(_);let E=_.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([t,e])=>{if(this.destroyed)return void A();if(this._stats?.time("Rendering"),!(e.renderingIntent&f))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:t,optionalContentConfig:e}),_.operatorListChanged()}).catch(A),E}getOperatorList({intent:t="display",annotationMode:e=m.ENABLE,printAnnotationStorage:i=null,isEditing:r=!1}={}){let s,n=this._transport.getRenderingIntent(t,e,i,r,!0),a=this._intentStates.get(n.cacheKey);return a||(a=Object.create(null),this._intentStates.set(n.cacheKey,a)),a.opListReadCapability||((s=Object.create(null)).operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(s))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(s),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>Z.textContent(t));let e=this.streamTextContent(t);return new Promise(function(t,i){let r=e.getReader(),s={items:[],styles:Object.create(null),lang:null};!function e(){r.read().then(function({value:i,done:r}){r?t(s):(s.lang??=i.lang,Object.assign(s.styles,i.styles),s.items.push(...i.items),e())},i)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#rZ=!1,Promise.all(t)}cleanup(t=!1){this.#rZ=!0;let e=this.#r0();
2return t&&e&&(this._stats&&=new td),e}#r0(){if(!this.#rZ||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#rZ=!1,!0}_startRenderPage(t,e){let i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,r=t.length;i<r;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);for(let i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&this.#r0()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:r}){let{map:s,transfer:n}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:s,modifiedIds:r},n).getReader(),o=this._intentStates.get(e);o.streamReader=a;let l=()=>{a.read().then(({value:t,done:e})=>{if(e){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){for(let t of(o.operatorList.lastChunk=!0,o.renderTasks))t.operatorListChanged();this.#r0()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else if(o.opListReadCapability)o.opListReadCapability.reject(t);else throw t}})};l()}_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 tn){let i=100;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new j(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class iM{#rw=Promise.withResolvers();#r1=null;#rn=null;#r2=null;static #r3=0;static #r5=!1;static #r6=new WeakMap;static{g&&(this.#r5=!0,e2.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;let r=new URL(e,i);return i.origin===r.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},this.fromPort=t=>{if(console.log("Deprecated API usage: `PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!t?.port)throw Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:t=null,port:e=null,verbosity:i=C}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(iM.#r6.has(e))throw Error("Cannot use more than one PDFWorker per port.");iM.#r6.set(e,this),this.#r4(e)}else this.#r8()}get promise(){return this.#rw.promise}#r7(){this.#rw.resolve(),this.#r1.send("configure",{verbosity:this.verbosity})}get port(){return this.#rn}get messageHandler(){return this.#r1}#r4(t){this.#rn=t,this.#r1=new t5("main","worker",t),this.#r1.on("ready",()=>{}),this.#r7()}#r8(){if(iM.#r5||iM.#r9)return void this.#st();let{workerSrc:t}=iM;try{iM._isSameOrigin(window.location,t)||(t=iM._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),i=new t5("main","worker",e),r=()=>{s.abort(),i.destroy(),e.terminate(),this.destroyed?this.#rw.reject(Error("Worker was destroyed")):this.#st()},s=new AbortController;e.addEventListener("error",()=>{this.#r2||r()},{signal:s.signal}),i.on("test",t=>{(s.abort(),this.destroyed||!t)?r():(this.#r1=i,this.#rn=e,this.#r2=e,this.#r7())}),i.on("ready",t=>{if(s.abort(),this.destroyed)return void r();try{n()}catch{this.#st()}});let n=()=>{let t=new Uint8Array;i.send("test",t,[t.buffer])};n();return}catch{T("The worker has been disabled.")}this.#st()}
2#st(){iM.#r5||(k("Setting up fake worker."),iM.#r5=!0),iM._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this.#rw.reject(Error("Worker was destroyed"));let e=new t1;this.#rn=e;let i=`fake${iM.#r3++}`,r=new t5(i+"_worker",i,e);t.setup(r,e),this.#r1=new t5(i,i+"_worker",e),this.#r7()}).catch(t=>{this.#rw.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#r2?.terminate(),this.#r2=null,iM.#r6.delete(this.#rn),this.#rn=null,this.#r1?.destroy(),this.#r1=null}static create(t){let e=this.#r6.get(t?.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new iM(t)}static get workerSrc(){if(e2.workerSrc)return e2.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #r9(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return R(this,"_setupFakeWorkerGlobal",(async()=>this.#r9?this.#r9:(await import(this.workerSrc)).WorkerMessageHandler)())}}class iP{#se=new Map;#si=new Map;#sr=new Map;#ss=new Map;#sn=null;constructor(t,e,i,r,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new iA,this.fontLoader=new tY({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=s.canvasFactory,this.filterFactory=s.filterFactory,this.cMapReaderFactory=s.cMapReaderFactory,this.standardFontDataFactory=s.standardFontDataFactory,this.wasmFactory=s.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=n,this.setupMessageHandler()}#sa(t,e=null){let i=this.#se.get(t);if(i)return i;let r=this.messageHandler.sendWithPromise(t,e);return this.#se.set(t,r),r}get annotationStorage(){return R(this,"annotationStorage",new tX)}getRenderingIntent(t,e=m.ENABLE,i=null,r=!1,s=!1){let n=2,a=tq;switch(t){case"any":n=1;break;case"display":break;case"print":n=4;break;default:k(`getRenderingIntent - invalid intent: ${t}`)}let o=4&n&&i instanceof tK?i:this.annotationStorage;switch(e){case m.DISABLE:n+=64;break;case m.ENABLE:break;case m.ENABLE_FORMS:n+=16;break;case m.ENABLE_STORAGE:n+=32,a=o.serializable;break;default:k(`getRenderingIntent - invalid annotationMode: ${e}`)}r&&(n+=128),s&&(n+=256);let{ids:l,hash:h}=o.modifiedIds,d=[n,a.hash,h];return{renderingIntent:n,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#sn?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let e of this.#si.values())t.push(e._destroy());this.#si.clear(),this.#sr.clear(),this.#ss.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#se.clear(),this.filterFactory.destroy(),i_.cleanup(),this._networkStream?.cancelAllRequests(new j("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{P(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:i}){i?e.close():(P(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this._fullReader.headersReady;let{isStreamingSupported:i,isRangeSupported:r,contentLength:s}=this._fullReader;return i&&r||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:r,contentLength:s}}),t.on("GetRangeReader",(t,e)=>{P(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(P(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new iT(t,this))}),t.on("DocException",t=>{e._capability.reject(t3(t))}
2),t.on("PasswordRequest",t=>{this.#sn=Promise.withResolvers();try{if(!e.onPassword)throw t3(t);let i=t=>{t instanceof Error?this.#sn.reject(t):this.#sn.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#sn.reject(t)}return this.#sn.promise}),t.on("DataLoaded",t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#si.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,r])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in r){let t=r.error;k(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let s=new tJ(new e1(r),this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,r.extra,r.charProcOperatorList);this.fontLoader.bind(s).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!s.fontExtraProperties&&s.data&&s.clearData(),this.commonObjs.resolve(e,s)});break;case"CopyLocalImage":let{imageRef:n}=r;for(let t of(P(n,"The imageRef must be defined."),this.#si.values()))for(let[,i]of t.objs)if(i?.ref===n){if(!i.dataLen)return null;return this.commonObjs.resolve(e,structuredClone(i)),i.dataLen}break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,r);break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,r])=>{if(this.destroyed)return;let s=this.#si.get(e);if(!s.objs.has(t)){if(0===s._intentStates.size)return void r?.bitmap?.close();switch(i){case"Image":case"Pattern":s.objs.resolve(t,r);break;default:throw Error(`Got unknown object type ${i}`)}}}),t.on("DocProgress",t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");let e=this[t.type];if(!e)throw Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&k("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(Error("Invalid page request."));let e=t-1,i=this.#sr.get(e);if(i)return i;let r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(i=>{if(this.destroyed)throw Error("Transport destroyed");i.refStr&&this.#ss.set(i.refStr,t);let r=new ik(e,i,this,this._params.pdfBug);return this.#si.set(e,r),r});return this.#sr.set(e,r),r}getPageIndex(t){return tZ(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#sa("GetFieldObjects")}hasJSActions(){return this.#sa("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithProm
2ise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#sa("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#sa("GetOptionalContentConfig").then(e=>new e4(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata",e=this.#se.get(t);if(e)return e;let i=this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new e3(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#se.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){for(let t of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#si.values()))if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#se.clear(),this.filterFactory.destroy(!0),i_.cleanup()}}cachedPageNumber(t){if(!tZ(t))return null;let e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#ss.get(e)??null}}class iD{#so=null;onContinue=null;onError=null;constructor(t){this.#so=t}get promise(){return this.#so.capability.promise}cancel(t=0){this.#so.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this.#so.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this.#so;return t.form||t.canvas&&e?.size>0}}class iI{#sl=null;static #sh=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:r,annotationCanvasMap:s,operatorList:n,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null,enableHWA:u=!1,operationsFilter:p=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=r,this.annotationCanvasMap=s,this.operatorListIdx=null,this.operatorList=n,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"u">typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new iD(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=u,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(iI.#sh.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");iI.#sh.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());let{viewport:i,transform:r,background:s,dependencyTracker:n}=this.params,a=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new eQ(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,n),this.gfx.beginDrawing({transform:r,viewport:i,transparency:t,background:s}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#sl&&(window.cancelAnimationFrame(this.#sl),this.#sl=null),iI.#sh.delete(this._canvas),t||=new tn(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#sl=window.requestAnimationFrame(()=>{this.#sl=null,this._nextBound().catch(this._cancelBound)}
2):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(),iI.#sh.delete(this._canvas),this.callback())))}}let iR="5.4.296",iL="f56dc8601";class iB{#sd=null;#sc=null;#su;#sp=null;#sg=!1;#sf=!1;#n=null;#sm;#sb=null;#b=null;static #sy=null;static get _keyboardManager(){return R(this,"_keyboardManager",new tO([[["Escape","mac+Escape"],iB.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],iB.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],iB.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],iB.prototype._moveToPrevious],[["Home","mac+Home"],iB.prototype._moveToBeginning],[["End","mac+End"],iB.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#sf=!1,this.#n=t):this.#sf=!0,this.#b=t?._uiManager||e,this.#sm=this.#b._eventBus,this.#su=t?.color?.toUpperCase()||this.#b?.highlightColors.values().next().value||"#FFFF98",iB.#sy||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#sd=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#n&&(t.ariaControls=`${this.#n.id}_colorpicker_dropdown`);let e=this.#b._signal;t.addEventListener("click",this.#sv.bind(this),{signal:e}),t.addEventListener("keydown",this.#sw.bind(this),{signal:e});let i=this.#sc=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#su,t.append(i),t}renderMainDropdown(){let t=this.#sp=this.#sx();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#sx(){let t=document.createElement("div"),e=this.#b._signal;for(let[i,r]of(t.addEventListener("contextmenu",tu,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#n&&(t.id=`${this.#n.id}_colorpicker_dropdown`),this.#b.highlightColors)){let s=document.createElement("button");s.tabIndex="0",s.role="option",s.setAttribute("data-color",r),s.title=i,s.setAttribute("data-l10n-id",iB.#sy[i]);let n=document.createElement("span");s.append(n),n.className="swatch",n.style.backgroundColor=r,s.ariaSelected=r===this.#su,s.addEventListener("click",this.#sA.bind(this,r),{signal:e}),t.append(s)}return t.addEventListener("keydown",this.#sw.bind(this),{signal:e}),t}#sA(t,e){e.stopPropagation(),this.#sm.dispatch("switchannotationeditorparams",{source:this,type:v.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#sd)return void this.#sv(t);let e=t.target.getAttribute("data-color");e&&this.#sA(e,t)}_moveToNext(t){this.#s_?t.target===this.#sd?this.#sp.firstChild?.focus():t.target.nextSibling?.focus():this.#sv(t)}_moveToPrevious(t){if(t.target===this.#sp?.firstChild||t.target===this.#sd){this.#s_&&this._hideDropdownFromKeyboard();return}this.#s_||this.#sv(t),t.target.previousSibling?.focus()}_moveToBeginning(t){this.#s_?this.#sp.firstChild?.focus():this.#sv(t)}_moveToEnd(t){this.#s_?this.#sp.lastChild?.focus():this.#sv(t)}#sw(t){iB._keyboardManager.exec(this,t)}#sv(t){if(this.#s_)return void this.hideDropdown();if(this.#sg=0===t.detail,this.#sb||(this.#sb=new AbortController,window.addEventListener("pointerdown",this.#u.bind(this),{signal:this.#b.combinedSignal(this.#sb)})),this.#sd.ariaExpanded="true",this.#sp)return void this.#sp.classList.remove("hidden");let e=this.#sp=this.#sx();this.#sd.append(e)}#u(t){this.#sp?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#sp?.classList.add("hidden"),this.#sd.ariaExpanded="false",this.#sb?.abort(),this.#sb=null}get #s_(){return this.#sp&&!this.#sp.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#sf){if(!this.#s_)return void this.#n?.unselect();this.hideDropdown(),this.#sd.focus({preventScroll:!0,focusVisible:this.#sg})}}updateColor(t){if(this.#sc&&(this.#sc.style.backgroundColor=t),!this.#sp)return;let e=this.#b.highlightColors.values();for(let i of this.#sp.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#sd?.remove(),this.#sd=null,this.#sc=null,this.#sp?.remove(),this.#sp=null}}class iF{#sE=null;#n=null;
2#b=null;static #sy=null;constructor(t){this.#n=t,this.#b=t._uiManager,iF.#sy||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#sE)return this.#sE;let{editorType:t,colorType:e,colorValue:i}=this.#n,r=this.#sE=document.createElement("input");return r.type="color",r.value=i||"#000000",r.className="basicColorPicker",r.tabIndex=0,r.setAttribute("data-l10n-id",iF.#sy[t]),r.addEventListener("input",()=>{this.#b.updateParams(e,r.value)},{signal:this.#b._signal}),r}update(t){this.#sE&&(this.#sE.value=t)}destroy(){this.#sE?.remove(),this.#sE=null}hideDropdown(){}}function iN(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function iO(t){return Math.max(0,Math.min(255,255*t))}class iU{static CMYK_G([t,e,i,r]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+r)]}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=iO(t),t,t]}static G_HTML([t]){let e=iN(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(iO)}static RGB_HTML(t){return`#${t.map(iN).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,r]){return["RGB",1-Math.min(1,t+r),1-Math.min(1,i+r),1-Math.min(1,e+r)]}static CMYK_rgb([t,e,i,r]){return[iO(1-Math.min(1,t+r)),iO(1-Math.min(1,i+r)),iO(1-Math.min(1,e+r))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){let r=1-t,s=1-e,n=1-i,a=Math.min(r,s,n);return["CMYK",r,s,n,a]}}class ij{create(t,e,i=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let r=this._createSVG("svg:svg");return r.setAttribute("version","1.1"),i||(r.setAttribute("width",`${t}px`),r.setAttribute("height",`${e}px`)),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${t} ${e}`),r}createElement(t){if("string"!=typeof t)throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){M("Abstract method `_createSVG` called.")}}class iz extends ij{_createSVG(t){return document.createElementNS(te,t)}}let iH=new WeakSet,i$=60*new Date().getTimezoneOffset()*1e3;class iG{static create(t){switch(t.data.annotationType){case A.LINK:return new iq(t);case A.TEXT:return new iX(t);case A.WIDGET:switch(t.data.fieldType){case"Tx":return new iY(t);case"Btn":if(t.data.radioButton)return new iZ(t);if(t.data.checkBox)return new iQ(t);return new i0(t);case"Ch":return new i1(t);case"Sig":return new iJ(t)}return new iK(t);case A.POPUP:return new i2(t);case A.FREETEXT:return new i5(t);case A.LINE:return new i6(t);case A.SQUARE:return new i4(t);case A.CIRCLE:return new i8(t);case A.POLYLINE:return new i7(t);case A.CARET:return new rt(t);case A.INK:return new re(t);case A.POLYGON:return new i9(t);case A.HIGHLIGHT:return new ri(t);case A.UNDERLINE:return new rr(t);case A.SQUIGGLY:return new rs(t);case A.STRIKEOUT:return new rn(t);case A.STAMP:return new ra(t);case A.FILEATTACHMENT:return new ro(t);default:return new iV(t)}}}class iV{#sS=null;#sC=!1;#sT=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:r=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),r&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return iV._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}
2get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:i,rect:r}=this.data,s=-1/0,n=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>n?(n=e[t+1],s=e[t+2]):e[t+1]===n&&(s=Math.max(s,e[t+2]));return[s,n]}if(i?.length>=1){for(let t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>n?(n=t[e+1],s=t[e]):t[e+1]===n&&(s=Math.max(s,t[e]));if(s!==1/0)return[s,n]}return r?[r[2],r[3]]:null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:r,pageX:s,pageY:n}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-s)/i,t[1]=100*(t[1]-n)/r,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${b}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${b}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#sT?.popup||this.popup)?.remove(),this.#sT=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#sS||={rect:this.data.rect.slice(0)});let{rect:e,popup:i}=t;e&&this.#sk(e);let r=this.#sT?.popup||this.popup;!r&&i?.text&&(this._createPopup(i),r=this.#sT.popup),r&&(r.updateEdited(t),i?.deleted&&(r.remove(),this.#sT=null,this.popup=null))}resetEdited(){this.#sS&&(this.#sk(this.#sS.rect),this.#sT?.popup.resetEdited(),this.#sS=null)}#sk(t){let{container:{style:e},data:{rect:i,rotation:r},parent:{viewport:{rawDims:{pageWidth:s,pageHeight:n,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=`${100*(t[0]-a)/s}%`,e.top=`${100*(n-t[3]+o)/n}%`,0===r?(e.width=`${100*(t[2]-t[0])/s}%`,e.height=`${100*(t[3]-t[1])/n}%`):this.setRotation(r)}_createContainer(t){let{data:e,parent:{page:i,viewport:r}}=this,s=document.createElement("section");s.setAttribute("data-annotation-id",e.id),this instanceof iK||this instanceof iq||(s.tabIndex=0);let{style:n}=s;if(n.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(s.title=e.alternativeText),e.noRotate&&s.classList.add("norotate"),!e.rect||this instanceof i2){let{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,s),s}let{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){n.borderWidth=`${e.borderStyle.width}px`;let t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;switch(t>0||i>0?n.borderRadius=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`:this instanceof iZ&&(n.borderRadius=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`),e.borderStyle.style){case 1:n.borderStyle="solid";break;case 2:n.borderStyle="dashed";break;case 3:k("Unimplemented border style: beveled");break;case 4:k("Unimplemented border style: inset");break;case 5:n.borderBottomStyle="solid"}let r=e.borderColor||null;r?(this.#sC=!0,n.borderColor=V.makeHexColor(0|r[0],0|r[1],0|r[2])):n.borderWidth=0}let l=V.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:h,pageHeight:d,pageX:c,pageY:u}=r.rawDims;n.left=`${100*(l[0]-c)/h}%`,n.top=`${100*(l[1]-u)/d}%`;let{rotation:p}=e;return e.hasOwnCanvas||0===p?(n.width=`${100*a/h}%`,n.height=`${100*o/d}%`):this.setRotation(p,s),s}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:i,pageHeight:r}=this.parent.viewport.rawDims,{width:s,height:n}=this;t%180!=0&&([s,n]=[n,s]),e.style.width=`${100*s/i}%`,e.style.height=`${100*n/r}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(t,e,i)=>{let r=i.detail[t],s=r[0],n=r.slice(1);i.target.style[e]=iU[`${s}_HTML`](n),this.annotationStorage.setValue(this.data.id,{[e]:iU[`${s}_rgb`](n)})};return R(this,"_commonActions",{display:t=>{let{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=>{let{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>
2t.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=>{let e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){let i=this._commonActions;for(let r of Object.keys(e.detail)){let s=t[r]||i[r];s?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let i=this._commonActions;for(let[r,s]of Object.entries(e)){let n=i[r];n&&(n({detail:{[r]:s},target:t}),delete e[r])}}_createQuadrilaterals(){let t;if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[i,r,s,n]=this.data.rect.map(t=>Math.fround(t));if(8===e.length){let[t,a,o,l]=e.subarray(2,6);if(s===t&&n===a&&i===o&&r===l)return}let{style:a}=this.container;if(this.#sC){let{borderColor:e,borderWidth:i}=a;a.borderWidth=0,t=["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="${e}" stroke-width="${i}">`],this.container.classList.add("hasBorder")}let o=s-i,l=n-r,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";let c=h.createElement("defs");d.append(c);let u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let r=2,s=e.length;r<s;r+=8){let s=e[r],a=e[r+1],d=e[r+2],c=e[r+3],p=h.createElement("rect"),g=(d-i)/o,f=(n-a)/l,m=(s-d)/o,b=(a-c)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",b),u.append(p),t?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${b}"/>`)}this.#sC&&(t.push("</g></svg>')"),a.backgroundImage=t.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){let e,i,{data:r}=this;t?(e={str:t.text},i=t.date):(e=r.contentsObj,i=r.modificationDate);let s=this.#sT=new i2({data:{color:r.color,titleObj:r.titleObj,modificationDate:i,contentsObj:e,richText:r.richText,parentRect:r.rect,borderStyle:0,id:`popup_${r.id}`,rotation:r.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]});this.parent._commentManager||this.parent.div.append(s.render())}get hasPopupElement(){return!!(this.#sT||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#sT}render(){M("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let i=[];if(this._fieldObjects){let r=this._fieldObjects[t];if(r)for(let{page:t,id:s,exportValues:n}of r){if(-1===t||s===e)continue;let r="string"==typeof n?n:null,a=document.querySelector(`[data-element-id="${s}"]`);if(a&&!iH.has(a)){k(`_getElementsByName - element not allowed: ${s}`);continue}i.push({id:s,exportValue:r,domElement:a})}return i}for(let r of document.getElementsByName(t)){let{exportValue:t}=r,s=r.getAttribute("data-element-id");s!==e&&iH.has(r)&&i.push({id:s,exportValue:t,domElement:r})}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(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{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 iW extends iV{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:t}=this;t.hasComment&&(this._createPopup(t.comment),this.extraPopupElement.popup.renderCommentButton())}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}
2get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}class iq extends iV{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let r=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),r=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),r=!0):t.attachment?(this.#sM(i,t.attachment,t.overlaidText,t.attachmentDest),r=!0):t.setOCGState?(this.#sP(i,t.setOCGState,t.overlaidText),r=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),r=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),r=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(i),this.container}#sD(){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.#sD(),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.#sD()}#sM(t,e,i="",r=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,r),!1),this.#sD()}#sP(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#sD()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let r of Object.keys(e.actions)){let s=i.get(r);s&&(t[s]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:r}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#sD()}_bindResetFormAction(t,e){let i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#sD(),!this._fieldObjects){k('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();let{fields:t,refs:r,include:s}=e,n=[];if(0!==t.length||0!==r.length){let e=new Set(r);for(let i of t)for(let{id:t}of this._fieldObjects[i]||[])e.add(t);for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===s&&n.push(i)}else for(let t of Object.values(this._fieldObjects))n.push(...t);let a=this.annotationStorage,o=[];for(let t of n){let{id:e}=t;switch(o.push(e),t.type){case"text":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);if(i){if(!iH.has(i)){k(`_bindResetFormAction - element not allowed: ${e}`);continue}i.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class iX extends iV{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}
2class iK extends iV{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&(t.previousSibling?.nodeName==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return $.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,r,s){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:s(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}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:s(t)}})})}_setEventListeners(t,e,i,r){for(let[s,n]of i)("Action"===n||this.data.actions?.[n])&&(("Focus"===n||"Blur"===n)&&(e||={focused:!1}),this._setEventListener(t,e,s,n,r),"Focus"!==n||this.data.actions?.Blur?"Blur"!==n||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){let e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":V.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){let e,{fontColor:i}=this.data.defaultAppearanceData,r=this.data.defaultAppearanceData.fontSize||9,s=t.style,n=t=>Math.round(10*t)/10;if(this.data.multiLine){let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),i=Math.round(t/(1.35*r))||1;e=Math.min(r,n(t/i/1.35))}else e=Math.min(r,n(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));s.fontSize=`calc(${e}px * var(--total-scale-factor))`,s.color=V.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(s.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class iY extends iK{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,i,r){let s=this.annotationStorage;
2for(let n of this._getElementsByName(t.name,t.id))n.domElement&&(n.domElement[e]=i),s.setValue(n.id,{[r]:i})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){let r=t.getValue(e,{value:this.data.fieldValue}),s=r.value||"",n=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;n&&s.length>n&&(s=s.slice(0,n));let a=r.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));let o={userValue:s,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((i=document.createElement("textarea")).textContent=a??s,this.data.doNotScroll&&(i.style.overflowY="hidden")):((i=document.createElement("input")).type=this.data.password?"password":"text",i.setAttribute("value",a??s),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),iH.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;let{datetimeFormat:l,datetimeType:h,timeStep:d}=this.data,c=!!h&&this.enableScripting;l&&(i.title=l),this._setRequired(i,this.data.required),n&&(i.maxLength=n),i.addEventListener("input",r=>{t.setValue(e,{value:r.target.value}),this.setPropertyOnSiblings(i,"value",r.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let u=t=>{let{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{if(o.focused)return;let{target:e}=t;if(c&&(e.type=h,d&&(e.step=d)),o.userValue){let t=o.userValue;if(c)if("time"===h){let i=new Date(t);e.value=[i.getHours(),i.getMinutes(),i.getSeconds()].map(t=>t.toString().padStart(2,"0")).join(":")}else e.value=new Date(t-i$).toISOString().split("date"===h?"T":".",1)[0];else e.value=t}o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target),this._dispatchEventFromSandbox({value(i){o.userValue=i.detail.value??"",c||t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){let{formattedValue:r}=i.detail;o.formattedValue=r,null!=r&&i.target!==document.activeElement&&(i.target.value=r);let s={formattedValue:r};c&&(s.value=r),t.setValue(e,s)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{let{charLimit:r}=i.detail,{target:s}=i;if(0===r)return void s.removeAttribute("maxLength");s.setAttribute("maxLength",r);let n=o.userValue;n&&!(n.length<=r)&&(s.value=o.userValue=n=n.slice(0,r),t.setValue(e,{value:n}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:1,selStart:s.selectionStart,selEnd:s.selectionEnd}}))}},i)}),i.addEventListener("keydown",t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;let{value:r}=t.target;o.lastCommittedValue!==r&&(o.lastCommittedValue=r,o.userValue=r,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});let r=u;u=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{target:i}=t,{value:s}=i;if(c){if(s&&"time"===h){let t=s.split(":").map(t=>parseInt(t,10));s=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),i.step=""}else s.includes("T")||(s=`${s}T00:00`),s=new Date(s).valueOf();i.type="text"}o.userValue=s,o.lastCommittedValue!==s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),r(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;let{data:i,target:r}=t,{value:s,selectionStart:n,selectionEnd:a}=r,l=n,h=a;switch(t.inputType){case"deleteWordBackward":{let t=s.substring(0,n).match(/\w*[^\
2w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{let t=s.substring(n).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":n===a&&(l-=1);break;case"deleteContentForward":n===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,change:i||"",willCommit:!1,selStart:l,selEnd:h}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(u&&i.addEventListener("blur",u),this.data.comb){let t=(this.data.rect[2]-this.data.rect[0])/n;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else(i=document.createElement("div")).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 iJ extends iK{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class iQ extends iK{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,i=e.id,r=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof r&&(r="Off"!==r,t.setValue(i,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let s=document.createElement("input");return iH.add(s),s.setAttribute("data-element-id",i),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="checkbox",s.name=e.fieldName,r&&s.setAttribute("checked",!0),s.setAttribute("exportValue",e.exportValue),s.tabIndex=0,s.addEventListener("change",r=>{let{name:s,checked:n}=r.target;for(let r of this._getElementsByName(s,i)){let i=n&&r.exportValue===e.exportValue;r.domElement&&(r.domElement.checked=i),t.setValue(r.id,{value:i})}t.setValue(i,{value:n})}),s.addEventListener("resetform",t=>{let i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(s.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},e)}),this._setEventListeners(s,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(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class iZ extends iK{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,i=e.id,r=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof r&&(r=r!==e.buttonValue,t.setValue(i,{value:r})),r)for(let r of this._getElementsByName(e.fieldName,i))t.setValue(r.id,{value:!1});let s=document.createElement("input");if(iH.add(s),s.setAttribute("data-element-id",i),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="radio",s.name=e.fieldName,r&&s.setAttribute("checked",!0),s.tabIndex=0,s.addEventListener("change",e=>{let{name:r,checked:s}=e.target;for(let e of this._getElementsByName(r,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:s})}),s.addEventListener("resetform",t=>{let i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){let r=e.buttonValue;s.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value:e=>{let s=r===e.detail.value;for(let r of this._getElementsByName(e.target.name)){let e=s&&r.id===i;r.domElement&&(r.domElement.checked=e),t.setValue(r.id,{value:e})}}},e)}),this._setEventListeners(s,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)}
2return this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class i0 extends iq{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class i1 extends iK{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),r=document.createElement("select");iH.add(r),r.setAttribute("data-element-id",e),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=0;let s=this.data.combo&&this.data.options.length>0;for(let t of(!this.data.combo&&(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue;for(let t of r.options)t.selected=t.value===e}),this.data.options)){let e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),s=!1),r.append(e)}let n=null;if(s){let t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),r.prepend(t),n=()=>{t.remove(),r.removeEventListener("input",n),n=null},r.addEventListener("input",n)}let a=t=>{let e=t?"value":"textContent",{options:i,multiple:s}=r;return s?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]},o=a(!1),l=t=>{let e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({value(i){n?.();let s=i.detail.value,l=new Set(Array.isArray(s)?s:[s]);for(let t of r.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){r.multiple=!0},remove(i){let s=r.options,n=i.detail.remove;s[n].selected=!1,r.remove(n),s.length>0&&-1===Array.prototype.findIndex.call(s,t=>t.selected)&&(s[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==r.length;)r.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){let{index:s,displayValue:n,exportValue:h}=i.detail.insert,d=r.children[s],c=document.createElement("option");c.textContent=n,c.value=h,d?d.before(c):r.append(c),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){let{items:s}=i.detail;for(;0!==r.length;)r.remove(0);for(let t of s){let{displayValue:e,exportValue:i}=t,s=document.createElement("option");s.textContent=e,s.value=i,r.append(s)}r.options.length>0&&(r.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){let r=new Set(i.detail.indices);for(let t of i.target.options)t.selected=r.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)}),r.addEventListener("input",i=>{let r=a(!0),s=a(!1);t.setValue(e,{value:r}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:s,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(r,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)):r.addEventListener("input",function(i){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class i2 extends iV{constructor(t){const{data:e,elements:i,parent:r}=t,s=!!r._commentManager;if(super(t,{isRenderable:!s&&iV._hasPopupData(e)}),this.elements=i,s&&iV._hasPopupData(e)){const t=this.popup=this.#sI();for(const e of i)e.popup=t}else this.popup=null}#sI(){return new i3({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,c
2ommentManager:this.parent._commentManager})}render(){let{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#sI(),i=[];for(let 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=>`${Y}${t}`).join(",")),this.container}}class i3{#U=null;#sR=this.#sw.bind(this);#sL=this.#sB.bind(this);#sF=this.#sN.bind(this);#sO=this.#sU.bind(this);#sj=null;#tx=null;#sz=null;#sH=null;#s$=null;#sG=null;#sV=null;#sW=!1;#sq=null;#sX=null;#k=null;#sK=null;#sY=null;#er=null;#sJ=null;#t9=null;#sQ=null;#sS=null;#sZ=!1;#s0=null;#s1=null;constructor({container:t,color:e,elements:i,titleObj:r,modificationDate:s,contentsObj:n,richText:a,parent:o,rect:l,parentRect:h,open:d,commentManager:c=null}){this.#tx=t,this.#sQ=r,this.#sz=n,this.#t9=a,this.#sG=o,this.#sj=e,this.#sJ=l,this.#sV=h,this.#s$=i,this.#U=c,this.#s0=i[0],this.#sH=tg.toDateObject(s),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),c?this.renderCommentButton():(this.#s2(),this.#tx.hidden=!0,d&&this.#sU())}#s2(){if(this.#sX)return;this.#sX=new AbortController;let{signal:t}=this.#sX;for(let e of this.trigger)e.addEventListener("click",this.#sO,{signal:t}),e.addEventListener("pointerenter",this.#sF,{signal:t}),e.addEventListener("pointerleave",this.#sL,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#s$)e.container?.addEventListener("keydown",this.#sR,{signal:t})}#s3(){let t=this.#s$.find(t=>t.hasCommentButton);t&&(this.#sY=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#sK||(this.#sY||this.#s3(),!this.#sY))return;let{signal:t}=this.#sX=new AbortController,e=!!this.#s0.extraPopupElement,i=()=>{this.#U.toggleCommentPopup(this,!0,void 0,!e)},r=()=>{this.#U.toggleCommentPopup(this,!1,!0,!e)},s=()=>{this.#U.toggleCommentPopup(this,!1,!1)};if(e)for(let e of(this.#sK=this.#s0.container,this.trigger))e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#sR,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",r,{signal:t}),e.addEventListener("pointerleave",s,{signal:t}),e.classList.add("popupTriggerArea");else{let e=this.#sK=document.createElement("button");e.className="annotationCommentButton";let n=this.#s0.container;e.style.zIndex=n.style.zIndex+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#s5(),this.#s6(),e.addEventListener("keydown",this.#sR,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",r,{signal:t}),e.addEventListener("pointerleave",s,{signal:t}),n.after(e)}}#s6(){if(this.#s0.extraPopupElement&&!this.#s0.editor)return;this.renderCommentButton();let[t,e]=this.#sY,{style:i}=this.#sK;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#s5(){this.#s0.extraPopupElement||(this.renderCommentButton(),this.#sK.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){let{color:t,opacity:e}=this.#s0.commentData;return t?this.#sG._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#sK?.focus()},0)}getData(){let{richText:t,color:e,opacity:i,creationDate:r,modificationDate:s}=this.#s0.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:r,modificationDate:s}}get elementBeforePopup(){return this.#sK}get comment(){return this.#s1||=this.#s0.commentText,this.#s1}set comment(t){t!==this.comment&&(this.#s0.commentText=this.#s1=t)}get parentBoundingClientRect(){return this.#s0.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#sK&&(this.#sK.classList.toggle("selected",t),this.#sK.ariaExpanded=e)}setSelectedCommentButton(t){this.#sK.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#er)return this.#er;let{x:t,y:e,height:i}=this.#sK.getBoundingClientRect(),{x:r,y:s,width:n,height:a}=this.#s0.layer.getBoundingClientRect();return[(t-r)/n,(e+i-s)/a]}set commentPopupPosition(t){this.#er=t}hasDefaultPopupPosition(){return null===this.#er}get commentButtonPosition(){return this.#sY}get commentButtonWidth(){return this.#sK.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,i]=this.#er||this.commentButtonPosition.map(t=>t/100),r=this.parentBoundingClientRect,{x:s,y:n,width:a,height:o}=r;this.#U.showDialog(null,this,s+e*a,n+i*o,{...t,parentDimensions:r})}
2render(){if(this.#sq)return;let t=this.#sq=document.createElement("div");if(t.className="popup",this.#sj){let e=t.style.outlineColor=V.makeHexColor(...this.#sj);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#sQ?.str){let t=document.createElement("span");t.className="title",e.append(t),{dir:t.dir,str:t.textContent}=this.#sQ}if(t.append(e),this.#sH){let 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.#sH.valueOf()})),t.dateTime=this.#sH.toISOString(),e.append(t)}tD({html:this.#s4||this.#sz.str,dir:this.#sz?.dir,className:"popupContent"},t),this.#tx.append(t)}get #s4(){let t=this.#t9,e=this.#sz;return t?.str&&(!e?.str||e.str===t.str)&&this.#t9.html||null}get #s8(){return this.#s4?.attributes?.style?.fontSize||0}get #s7(){return this.#s4?.attributes?.style?.color||null}#s9(t){let e=[],i={style:{color:this.#s7,fontSize:this.#s8?`calc(${this.#s8}px * var(--total-scale-factor))`:""}};for(let r of t.split("\n"))e.push({name:"span",value:r,attributes:i});return{str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}}}#sw(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#sW)&&this.#sU()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#U){i?(this.remove(),this.#s1=null):e&&(e.deleted?this.remove():(this.#s5(),this.#s1=e.text)),t&&(this.#sY=null,this.#s3(),this.#s6());return}i||e?.deleted?this.remove():(this.#s2(),this.#sS||={contentsObj:this.#sz,richText:this.#t9},t&&(this.#k=null),e&&e.text&&(this.#t9=this.#s9(e.text),this.#sH=tg.toDateObject(e.date),this.#sz=null),this.#sq?.remove(),this.#sq=null)}resetEdited(){this.#sS&&({contentsObj:this.#sz,richText:this.#t9}=this.#sS,this.#sS=null,this.#sq?.remove(),this.#sq=null,this.#k=null)}remove(){if(this.#sX?.abort(),this.#sX=null,this.#sq?.remove(),this.#sq=null,this.#sZ=!1,this.#sW=!1,this.#sK?.remove(),this.#sK=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#nt(){if(null!==this.#k)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:r,pageY:s}}}=this.#sG,n=!!this.#sV,a=n?this.#sV:this.#sJ;for(let t of this.#s$)if(!a||null!==V.intersect(t.data.rect,a)){a=t.data.rect,n=!0;break}let o=V.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=n?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#k=[100*(h-r)/e,100*(d-s)/i];let{style:c}=this.#tx;c.left=`${this.#k[0]}%`,c.top=`${this.#k[1]}%`}#sU(){this.#U?this.#U.toggleCommentPopup(this,!1):(this.#sW=!this.#sW,this.#sW?(this.#sN(),this.#tx.addEventListener("click",this.#sO),this.#tx.addEventListener("keydown",this.#sR)):(this.#sB(),this.#tx.removeEventListener("click",this.#sO),this.#tx.removeEventListener("keydown",this.#sR)))}#sN(){this.#sq||this.render(),this.isVisible?this.#sW&&this.#tx.classList.add("focused"):(this.#nt(),this.#tx.hidden=!1,this.#tx.style.zIndex=parseInt(this.#tx.style.zIndex)+1e3)}#sB(){this.#tx.classList.remove("focused"),!this.#sW&&this.isVisible&&(this.#tx.hidden=!0,this.#tx.style.zIndex=parseInt(this.#tx.style.zIndex)-1e3)}forceHide(){this.#sZ=this.isVisible,this.#sZ&&(this.#tx.hidden=!0)}maybeShow(){this.#U||(this.#s2(),this.#sZ&&(this.#sq||this.#sN(),this.#sZ=!1,this.#tx.hidden=!1))}get isVisible(){return!this.#U&&!1===this.#tx.hidden}}class i5 extends iV{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=y.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=document.createElement("div");for(let e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){let i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class i6 extends iV{#ne=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:t,width:e,height:i}=this,r=this.svgFactory.create(e,i,!0),s=this.#ne=this.svgFactory.createElement("svg:line");return s.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),s.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),s.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),s.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),s.setAttribute("stroke-width",t.borderStyle.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),r.append(s),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ne}addHighlightArea(){this.container.classList.add("highlightArea")}}class i4 extends iV{#ni=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:t,width:e,height:i}=this,r=this.svgFactory.create(e,i,!0),s=t.borderStyle.width,n=this.#ni=this.svgFactory.createElement("svg:rect");return n.setAttribute("x",s/2),n.setAttribute("y",s/2),n.setAttribute("width",e-s),n.setAttribute("height",i-s),n.setAttribute("stroke-width",s||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),r.append(n),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ni}addHighlightArea(){this.container.classList.add("highlightArea")}}class i8 extends iV{#nr=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:t,width:e,height:i}=this,r=this.svgFactory.create(e,i,!0),s=t.borderStyle.width,n=this.#nr=this.svgFactory.createElement("svg:ellipse");return n.setAttribute("cx",e/2),n.setAttribute("cy",i/2),n.setAttribute("rx",e/2-s/2),n.setAttribute("ry",i/2-s/2),n.setAttribute("stroke-width",s||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),r.append(n),this.container.append(r),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#nr}addHighlightArea(){this.container.classList.add("highlightArea")}}class i7 extends iV{#ns=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:i,popupRef:r},width:s,height:n}=this;if(!e)return this.container;let a=this.svgFactory.create(s,n,!0),o=[];for(let i=0,r=e.length;i<r;i+=2){let r=e[i]-t[0],s=t[3]-e[i+1];o.push(`${r},${s}`)}o=o.join(" ");let l=this.#ns=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ns}
2addHighlightArea(){this.container.classList.add("highlightArea")}}class i9 extends i7{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class rt extends iV{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class re extends iV{#nn=null;#na=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?y.HIGHLIGHT:y.INK}#no(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);let{data:{rect:t,rotation:e,inkLists:i,borderStyle:r,popupRef:s}}=this,{transform:n,width:a,height:o}=this.#no(e,t),l=this.svgFactory.create(a,o,!0),h=this.#nn=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",r.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",n);for(let t=0,e=i.length;t<e;t++){let e=this.svgFactory.createElement(this.svgElementName);this.#na.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!s&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:i,rect:r}=t,s=this.#nn;if(e>=0&&s.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#na.length;t<e;t++)this.#na[t].setAttribute("points",i[t].join(","));if(r){let{transform:t,width:e,height:i}=this.#no(this.data.rotation,r);s.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),s.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#na}addHighlightArea(){this.container.classList.add("highlightArea")}}class ri extends iV{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=y.HIGHLIGHT}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class rr extends iV{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class rs extends iV{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class rn extends iV{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){let e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class ra extends iV{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=y.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}
2class ro extends iV{#nl=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(){let t;this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:i}=this;i.hasAppearance||0===i.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(t.style=`filter: opacity(${Math.round(100*i.fillAlpha)}%);`)),t.addEventListener("dblclick",this.#nh.bind(this)),this.#nl=t;let{isMac:r}=$.platform;return e.addEventListener("keydown",t=>{"Enter"===t.key&&(r?t.metaKey:t.ctrlKey)&&this.#nh()}),!i.popupRef&&this.hasPopupData?this._createPopup():t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return this.#nl}addHighlightArea(){this.container.classList.add("highlightArea")}#nh(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class rl{#nd=null;#nc=null;#F=null;#nu=new Map;#np=null;#ng=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:r,page:s,viewport:n,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#nd=e,this.#nc=i,this.#np=a||null,this.#ng=l||null,this.#F=h||new tX,this.page=s,this.viewport=n,this.zIndex=0,this._annotationEditorUIManager=r,this._commentManager=o||null}hasEditableAnnotations(){return this.#nu.size>0}async #nf(t,e,i){let r=t.firstChild||t,s=r.id=`${Y}${e}`,n=await this.#np?.getAriaAttributes(s);if(n)for(let[t,e]of n)r.setAttribute(t,e);i?i.at(-1).container.after(t):(this.div.append(t),this.#nd?.moveElementInDOM(this.div,t,r,!1))}async render(t){let{annotations:e}=t,i=this.div;tv(i,this.viewport);let r=new Map,s={data:null,layer:i,linkService:this.#ng,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new iz,annotationStorage:this.#F,enableComment:!0===t.enableComment,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let t of e){if(t.noHTML)continue;let e=t.annotationType===A.POPUP;if(e){let e=r.get(t.id);if(!e)continue;s.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;s.data=t;let i=iG.create(s);if(!i.isRenderable)continue;if(!e&&t.popupRef){let e=r.get(t.popupRef);e?e.push(i):r.set(t.popupRef,[i])}let n=i.render();t.hidden&&(n.style.visibility="hidden"),await this.#nf(n,t.id,s.elements),i.extraPopupElement?.popup?.renderCommentButton(),i._isEditable&&(this.#nu.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#nm()}async addLinkAnnotations(t){let e={data:null,layer:this.div,linkService:this.#ng,svgFactory:new iz,parent:this};for(let i of t){i.borderStyle||=rl._defaultBorderStyle,e.data=i;let t=iG.create(e);if(!t.isRenderable)continue;let r=t.render();await this.#nf(r,i.id,null)}}update({viewport:t}){let e=this.div;this.viewport=t,tv(e,{rotation:t.rotation}),this.#nm(),e.hidden=!1}#nm(){if(!this.#nc)return;let t=this.div;for(let[e,i]of this.#nc){let r=t.querySelector(`[data-annotation-id="${e}"]`);if(!r)continue;i.className="annotationContent";let{firstChild:s}=r;s?"CANVAS"===s.nodeName?s.replaceWith(i):s.classList.contains("annotationContent")?s.after(i):s.before(i):r.append(i);let n=this.#nu.get(e);n&&(n._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,r.id,i),n._hasNoCanvas=!1):n.canvas=i)}this.#nc.clear()}getEditableAnnotations(){return Array.from(this.#nu.values())}getEditableAnnotation(t){return this.#nu.get(t)}addFakeAnnotation(t){let{div:e}=this,{id:i,rotation:r}=t,s=new iW({data:{id:i,rect:t.getPDFRect(),rotation:r},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#ng,annotationStorage:this.#F}),n=s.render();return e.append(n),this.#nd?.moveElementInDOM(e,n,n,!1),s.createOrUpdatePopup(),s}static get _defaultBorderStyle(){return R(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:1,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}let rh=/\r\n?|\n/g;class rd extends tG{#nb="";#ny=`${this.id}-editor`;#nv=null;#s8;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=rd.prototype,e=t=>t.isEmpty(),i=tj.TRANSLATE_SMALL,r=tj.TRANSLATE_BIG;return R(this,"_keyboardManager",new tO([[["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:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,r],checker:e}]]))}static _type="freetext";static _editorType=y.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||rd._defaultColor||tG._defaultLineColor,this.#s8=t.fontSize||rd._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static initialize(t,e){tG.initialize(t,e);let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}
2static updateDefaultParams(t,e){switch(t){case v.FREETEXT_SIZE:rd._defaultFontSize=e;break;case v.FREETEXT_COLOR:rd._defaultColor=e}}updateParams(t,e){switch(t){case v.FREETEXT_SIZE:this.#nw(e);break;case v.FREETEXT_COLOR:this.#s5(e)}}static get defaultPropertiesToUpdate(){return[[v.FREETEXT_SIZE,rd._defaultFontSize],[v.FREETEXT_COLOR,rd._defaultColor||tG._defaultLineColor]]}get propertiesToUpdate(){return[[v.FREETEXT_SIZE,this.#s8],[v.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new iF(this),[["colorPicker",this._colorPicker]]}get colorType(){return v.FREETEXT_COLOR}#nw(t){let e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#s8)*this.parentScale),this.#s8=t,this.#nx()},i=this.#s8;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#s5(t){let 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:v.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-rd._internalPadding*t,-(rd._internalPadding+this.#s8)*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.#nv=new AbortController;let t=this._uiManager.combinedSignal(this.#nv);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.#ny),this._isDraggable=!0,this.#nv?.abort(),this.#nv=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()}#nA(){let t=[];this.editorDiv.normalize();let e=null;for(let i of this.editorDiv.childNodes)(e?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName)&&(t.push(rd.#n_(i)),e=i);return t.join("\n")}#nx(){let t,[e,i]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{let{currentLayer:e,div:i}=this,r=i.style.display,s=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",e.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=r,i.classList.toggle("hidden",s)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/i):(this.width=t.height/e,this.height=t.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#nb,e=this.#nb=this.#nA().trimEnd();if(t===e)return;let i=t=>{(this.#nb=t,t)?(this.#nE(),this._uiManager.rebuild(this),this.#nx()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#nx()}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){rd._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(){let t,e;if(this.div)return this.div;(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.#ny),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#s8}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){let[i,r]=this.parentDimensions;
2if(this.annotationElementId){let s,n,{position:a}=this._initialData,[o,l]=this.getInitialTranslation();[o,l]=this.pageTranslationToScreen(o,l);let[h,d]=this.pageDimensions,[c,u]=this.pageTranslation;switch(this.rotation){case 0:s=t+(a[0]-c)/h,n=e+this.height-(a[1]-u)/d;break;case 90:s=t+(a[0]-c)/h,n=e-(a[1]-u)/d,[o,l]=[l,-o];break;case 180:s=t-this.width+(a[0]-c)/h,n=e-(a[1]-u)/d,[o,l]=[-o,-l];break;case 270:s=t+(a[0]-c-this.height*d)/h,n=e+(a[1]-u-this.width*h)/d,[o,l]=[-l,o]}this.setAt(s*i,n*r,o,l)}else this._moveAfterPaste(t,e);this.#nE(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #n_(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(rh,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();let r=rd.#nS(e.getData("text")||"").replaceAll(rh,"\n");if(!r)return;let s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize(),s.deleteFromDocument();let n=s.getRangeAt(0);if(!r.includes("\n")){n.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),s.collapseToStart();return}let{startContainer:a,startOffset:o}=n,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){let t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(rh,"")),t!==this.editorDiv){let e=l;for(let i of this.editorDiv.childNodes){if(i===t){e=h;continue}e.push(rd.#n_(i))}}l.push(a.nodeValue.slice(0,o).replaceAll(rh,""))}else if(a===this.editorDiv){let t=l,e=0;for(let i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(rd.#n_(i))}this.#nb=`${l.join("\n")}${r}${h.join("\n")}`,this.#nE();let d=new Range,c=Math.sumPrecise(l.map(t=>t.length));for(let{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){let e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}s.removeAllRanges(),s.addRange(d)}#nE(){if(this.editorDiv.replaceChildren(),this.#nb)for(let t of this.#nb.split("\n")){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#nC(){return this.#nb.replaceAll("Â "," ")}static #nS(t){return t.replaceAll(" ","Â ")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=rd._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let r=null;if(t instanceof i5){let{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:s,rotation:n,id:a,popupRef:o,richText:l,contentsObj:h,creationDate:d,modificationDate:c},textContent:u,textPosition:p,parent:{page:{pageNumber:g}}}=t;if(!u||0===u.length)return null;r=t={annotationType:y.FREETEXT,color:Array.from(i),fontSize:e,value:u.join("\n"),position:p,pageIndex:g-1,rect:s.slice(0),rotation:n,annotationElementId:a,id:a,deleted:!1,popupRef:o,comment:h?.str||null,richText:l,creationDate:d,modificationDate:c}}let s=await super.deserialize(t,e,i);return s.#s8=t.fontSize,s.color=V.makeHexColor(...t.color),s.#nb=rd.#nS(t.value),s._initialData=r,t.comment&&s.setCommentData(t),s}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=tG._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#s8,value:this.#nC()});return(this.addComment(i),t)?(i.isCopy=!0,i):this.annotationElementId&&!this.#nT(i)?null:(i.id=this.annotationElementId,i)}#nT(t){let{value:e,fontSize:i,color:r,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==r[e])||t.pageIndex!==s}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:i}=e;for(let t of(i.fontSize=`calc(${this.#s8}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren(),this.#nb.split("\n"))){let 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.#nb}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class rc{static PRECISION=1e-4;toSVGPath(){M("Abstract method `toSVGPath` must be implemented.")}get box(){M("Abstract getter `box` must be implemented.")}serialize(t,e){M("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,r,s,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a]*r,n[a+1]=i+t[a+1]*s;return n}static _rescaleAndSwap(t,e,i,r,s,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a+1]*r,n[a+1]=i+t[a]*s;return n}static _translate(t,e,i,r){r||=new Float32Array(t.length);for(let s=0,n=t.length;s<n;s+=2)r[s]=e+t[s],r[s+1]=i+t[s+1];return r}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,r,s){switch(s){case 90:return[1-e/i,t/r];case 180:return[1-t/i,1-e/r];case 270:return[e/i,1-t/r];default:return[t/i,e/r]}}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,r,s,n){return[(t+5*i)/6,(e+5*r)/6,(5*i+s)/6,(5*r+n)/6,(i+s)/2,(r+n)/2]}}class ru{#nk;#nM=[];#nP;#nD;#nI=[];#nR=new Float32Array(18);#nL;#nB;#nF;#nN;#nO;#nU;#nj=[];static #nz=8;static #nH=2;static #n$=ru.#nz+ru.#nH;constructor({x:t,y:e},i,r,s,n,a=0){this.#nk=i,this.#nU=s*r,this.#nD=n,this.#nR.set([NaN,NaN,NaN,NaN,t,e],6),this.#nP=a,this.#nN=ru.#nz*r,this.#nF=ru.#n$*r,this.#nO=r,this.#nj.push(t,e)}isEmpty(){return isNaN(this.#nR[8])}#nG(){let t=this.#nR.subarray(4,6),e=this.#nR.subarray(16,18),[i,r,s,n]=this.#nk;return[(this.#nL+(t[0]-e[0])/2-i)/s,(this.#nB+(t[1]-e[1])/2-r)/n,(this.#nL+(e[0]-t[0])/2-i)/s,(this.#nB+(e[1]-t[1])/2-r)/n]}add({x:t,y:e}){this.#nL=t,this.#nB=e;let[i,r,s,n]=this.#nk,[a,o,l,h]=this.#nR.subarray(8,12),d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#nF)return!1;
2let p=u-this.#nN,g=p/u,f=g*d,m=g*c,b=a,y=o;a=l,o=h,l+=f,h+=m,this.#nj?.push(t,e);let v=-m/p*this.#nU,w=f/p*this.#nU;return(this.#nR.set(this.#nR.subarray(2,8),0),this.#nR.set([l+v,h+w],4),this.#nR.set(this.#nR.subarray(14,18),12),this.#nR.set([l-v,h-w],16),isNaN(this.#nR[6]))?(0===this.#nI.length&&(this.#nR.set([a+v,o+w],2),this.#nI.push(NaN,NaN,NaN,NaN,(a+v-i)/s,(o+w-r)/n),this.#nR.set([a-v,o-w],14),this.#nM.push(NaN,NaN,NaN,NaN,(a-v-i)/s,(o-w-r)/n)),this.#nR.set([b,y,a,o,l,h],6),!this.isEmpty()):((this.#nR.set([b,y,a,o,l,h],6),Math.abs(Math.atan2(y-o,b-a)-Math.atan2(m,f))<Math.PI/2)?([a,o,l,h]=this.#nR.subarray(2,6),this.#nI.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/s,((o+h)/2-r)/n),[a,o,b,y]=this.#nR.subarray(14,18),this.#nM.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/s,((y+o)/2-r)/n)):([b,y,a,o,l,h]=this.#nR.subarray(0,6),this.#nI.push(((b+5*a)/6-i)/s,((y+5*o)/6-r)/n,((5*a+l)/6-i)/s,((5*o+h)/6-r)/n,((a+l)/2-i)/s,((o+h)/2-r)/n),[l,h,a,o,b,y]=this.#nR.subarray(12,18),this.#nM.push(((b+5*a)/6-i)/s,((y+5*o)/6-r)/n,((5*a+l)/6-i)/s,((5*o+h)/6-r)/n,((a+l)/2-i)/s,((o+h)/2-r)/n)),!0)}toSVGPath(){if(this.isEmpty())return"";let t=this.#nI,e=this.#nM;if(isNaN(this.#nR[6])&&!this.isEmpty())return this.#nV();let 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.#nW(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.#nq(i),i.join(" ")}#nV(){let[t,e,i,r]=this.#nk,[s,n,a,o]=this.#nG();return`M${(this.#nR[2]-t)/i} ${(this.#nR[3]-e)/r} L${(this.#nR[4]-t)/i} ${(this.#nR[5]-e)/r} L${s} ${n} L${a} ${o} L${(this.#nR[16]-t)/i} ${(this.#nR[17]-e)/r} L${(this.#nR[14]-t)/i} ${(this.#nR[15]-e)/r} Z`}#nq(t){let e=this.#nM;t.push(`L${e[4]} ${e[5]} Z`)}#nW(t){let[e,i,r,s]=this.#nk,n=this.#nR.subarray(4,6),a=this.#nR.subarray(16,18),[o,l,h,d]=this.#nG();t.push(`L${(n[0]-e)/r} ${(n[1]-i)/s} L${o} ${l} L${h} ${d} L${(a[0]-e)/r} ${(a[1]-i)/s}`)}newFreeDrawOutline(t,e,i,r,s,n){return new rp(t,e,i,r,s,n)}getOutlines(){let t=this.#nI,e=this.#nM,i=this.#nR,[r,s,n,a]=this.#nk,o=new Float32Array((this.#nj?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#nj[t]-r)/n,o[t+1]=(this.#nj[t+1]-s)/a;if(o[o.length-2]=(this.#nL-r)/n,o[o.length-1]=(this.#nB-s)/a,isNaN(i[6])&&!this.isEmpty())return this.#nX(o);let l=new Float32Array(this.#nI.length+24+this.#nM.length),h=t.length;for(let e=0;e<h;e+=2){if(isNaN(t[e])){l[e]=l[e+1]=NaN;continue}l[e]=t[e],l[e+1]=t[e+1]}h=this.#nK(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2){if(isNaN(e[t+i])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2}return this.#nY(l,h),this.newFreeDrawOutline(l,o,this.#nk,this.#nO,this.#nP,this.#nD)}#nX(t){let e=this.#nR,[i,r,s,n]=this.#nk,[a,o,l,h]=this.#nG(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/s,(e[3]-r)/n,NaN,NaN,NaN,NaN,(e[4]-i)/s,(e[5]-r)/n,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/s,(e[17]-r)/n,NaN,NaN,NaN,NaN,(e[14]-i)/s,(e[15]-r)/n],0),this.newFreeDrawOutline(d,t,this.#nk,this.#nO,this.#nP,this.#nD)}#nY(t,e){let i=this.#nM;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6}#nK(t,e){let i=this.#nR.subarray(4,6),r=this.#nR.subarray(16,18),[s,n,a,o]=this.#nk,[l,h,d,c]=this.#nG();return t.set([NaN,NaN,NaN,NaN,(i[0]-s)/a,(i[1]-n)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(r[0]-s)/a,(r[1]-n)/o],e),e+=24}}class rp extends rc{#nk;#nJ=new Float32Array(4);#nP;#nD;#nj;#nO;#nQ;constructor(t,e,i,r,s,n){super(),this.#nQ=t,this.#nj=e,this.#nk=i,this.#nO=r,this.#nP=s,this.#nD=n,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#nZ(n);const[a,o,l,h]=this.#nJ;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){let t=[`M${this.#nQ[4]} ${this.#nQ[5]}`];for(let e=6,i=this.#nQ.length;e<i;e+=6){if(isNaN(this.#nQ[e])){t.push(`L${this.#nQ[e+4]} ${this.#nQ[e+5]}`);continue}t.push(`C${this.#nQ[e]} ${this.#nQ[e+1]} ${this.#nQ[e+2]} ${this.#nQ[e+3]} ${this.#nQ[e+4]} ${this.#nQ[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,r],s){let n,a,o=i-t,l=r-e;switch(s){case 0:n=rc._rescale(this.#nQ,t,r,o,-l),a=rc._rescale(this.#nj,t,r,o,-l);break;case 90:n=rc._rescaleAndSwap(this.#nQ,t,e,o,l),a=rc._rescaleAndSwap(this.#nj,t,e,o,l);break;
2case 180:n=rc._rescale(this.#nQ,i,e,-o,l),a=rc._rescale(this.#nj,i,e,-o,l);break;case 270:n=rc._rescaleAndSwap(this.#nQ,i,r,-o,-l),a=rc._rescaleAndSwap(this.#nj,i,r,-o,-l)}return{outline:Array.from(n),points:[Array.from(a)]}}#nZ(t){let e=this.#nQ,i=e[4],r=e[5],s=[i,r,i,r],n=i,a=r,o=i,l=r,h=t?Math.max:Math.min,d=new Float32Array(4);for(let t=6,c=e.length;t<c;t+=6){let c=e[t+4],u=e[t+5];isNaN(e[t])?(V.pointBoundingBox(c,u,s),a>u?(n=c,a=u):a===u&&(n=h(n,c)),l<u?(o=c,l=u):l===u&&(o=h(o,c))):(d[0]=d[1]=1/0,d[2]=d[3]=-1/0,V.bezierBoundingBox(i,r,...e.slice(t,t+6),d),V.rectBoundingBox(d[0],d[1],d[2],d[3],s),a>d[1]?(n=d[0],a=d[1]):a===d[1]&&(n=h(n,d[0])),l<d[3]?(o=d[2],l=d[3]):l===d[3]&&(o=h(o,d[2]))),i=c,r=u}let c=this.#nJ;c[0]=s[0]-this.#nP,c[1]=s[1]-this.#nP,c[2]=s[2]-s[0]+2*this.#nP,c[3]=s[3]-s[1]+2*this.#nP,this.firstPoint=[n,a],this.lastPoint=[o,l]}get box(){return this.#nJ}newOutliner(t,e,i,r,s,n=0){return new ru(t,e,i,r,s,n)}getNewOutline(t,e){let[i,r,s,n]=this.#nJ,[a,o,l,h]=this.#nk,d=s*l,c=n*h,u=i*l+a,p=r*h+o,g=this.newOutliner({x:this.#nj[0]*d+u,y:this.#nj[1]*c+p},this.#nk,this.#nO,t,this.#nD,e??this.#nP);for(let t=2;t<this.#nj.length;t+=2)g.add({x:this.#nj[t]*d+u,y:this.#nj[t+1]*c+p});return g.getOutlines()}}class rg{#nk;#n0;#n1;#n2=[];#n3=[];constructor(t,e=0,i=0,r=!0){const s=[1/0,1/0,-1/0,-1/0];for(const{x:i,y:r,width:n,height:a}of t){const t=1e-4*Math.floor((i-e)/1e-4),o=1e-4*Math.ceil((i+n+e)/1e-4),l=1e-4*Math.floor((r-e)/1e-4),h=1e-4*Math.ceil((r+a+e)/1e-4),d=[t,l,h,!0],c=[o,l,h,!1];this.#n2.push(d,c),V.rectBoundingBox(t,l,o,h,s)}const n=s[2]-s[0]+2*i,a=s[3]-s[1]+2*i,o=s[0]-i,l=s[1]-i;let h=r?-1/0:1/0,d=1/0;const c=this.#n2.at(r?-1:-2),u=[c[0],c[2]];for(const t of this.#n2){const[e,i,s,c]=t;!c&&r?i<d?(d=i,h=e):i===d&&(h=Math.max(h,e)):c&&!r&&(i<d?(d=i,h=e):i===d&&(h=Math.min(h,e))),t[0]=(e-o)/n,t[1]=(i-l)/a,t[2]=(s-l)/a}this.#nk=new Float32Array([o,l,n,a]),this.#n0=[h,d],this.#n1=u}getOutlines(){this.#n2.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);let t=[];for(let e of this.#n2)e[3]?(t.push(...this.#n5(e)),this.#n6(e)):(this.#n4(e),t.push(...this.#n5(e)));return this.#n8(t)}#n8(t){let e,i=[],r=new Set;for(let e of t){let[t,r,s]=e;i.push([t,r,e],[t,s,e])}i.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,e=i.length;t<e;t+=2){let e=i[t][2],s=i[t+1][2];e.push(s),s.push(e),r.add(e),r.add(s)}let s=[];for(;r.size>0;){let t=r.values().next().value,[i,n,a,o,l]=t;r.delete(t);let h=i,d=n;for(e=[i,a],s.push(e);;){let t;if(r.has(o))t=o;else if(r.has(l))t=l;else break;r.delete(t),[i,n,a,o,l]=t,h!==i&&(e.push(h,d,i,d===n?n:a),h=i),d=d===n?a:n}e.push(h,d)}return new rf(s,this.#nk,this.#n0,this.#n1)}#n7(t){let e=this.#n3,i=0,r=e.length-1;for(;i<=r;){let s=i+r>>1,n=e[s][0];if(n===t)return s;n<t?i=s+1:r=s-1}return r+1}#n6([,t,e]){let i=this.#n7(t);this.#n3.splice(i,0,[t,e])}#n4([,t,e]){let i=this.#n7(t);for(let r=i;r<this.#n3.length;r++){let[i,s]=this.#n3[r];if(i!==t)break;if(i===t&&s===e)return void this.#n3.splice(r,1)}for(let r=i-1;r>=0;r--){let[i,s]=this.#n3[r];if(i!==t)break;if(i===t&&s===e)return void this.#n3.splice(r,1)}}#n5(t){let[e,i,r]=t,s=[[e,i,r]],n=this.#n7(r);for(let t=0;t<n;t++){let[i,r]=this.#n3[t];for(let t=0,n=s.length;t<n;t++){let[,a,o]=s[t];if(!(r<=a)&&!(o<=i)){if(a>=i){if(o>r)s[t][1]=r;else{if(1===n)return[];s.splice(t,1),t--,n--}continue}s[t][2]=i,o>r&&s.push([e,r,o])}}}return s}}class rf extends rc{#nk;#n9;constructor(t,e,i,r){super(),this.#n9=t,this.#nk=e,this.firstPoint=i,this.lastPoint=r}toSVGPath(){let t=[];for(let e of this.#n9){let[i,r]=e;t.push(`M${i} ${r}`);for(let s=2;s<e.length;s+=2){let n=e[s],a=e[s+1];n===i?(t.push(`V${a}`),r=a):a===r&&(t.push(`H${n}`),i=n)}t.push("Z")}return t.join(" ")}serialize([t,e,i,r],s){let n=[],a=i-t,o=r-e;for(let e of this.#n9){let i=Array(e.length);for(let s=0;s<e.length;s+=2)i[s]=t+e[s]*a,i[s+1]=r-e[s+1]*o;n.push(i)}return n}get box(){return this.#nk}get classNamesForOutlining(){return["highlightOutline"]}}class rm extends ru{newFreeDrawOutline(t,e,i,r,s,n){return new rb(t,e,i,r,s,n)}}class rb extends rp{newOutliner(t,e,i,r,s,n=0){return new rm(t,e,i,r,s,n)}}class ry extends tG{#at=null;#ae=0;#ai;#ar=null;#s=null;#as=null;#an=null;#aa=0;#ao=null;#al=null;#x=null;#ah=!1;#n0=null;#n1=null;#ad=null;#et="";#nU;#ac="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=y.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=ry.prototype;return R(this,"_keyboardManager",new tO([[["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||ry._defaultColor,this.#nU=t.thickness||ry._defaultThickness,this.opacity=t.opacity||ry._defaultOpacity,this.#ai=t.boxes||null,this.#ac=t.methodOfCreation||"",this.#et=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>
vendor: 5,592 bytes, line 2
2-1?(this.#ah=!0,this.#au(t),this.#ap()):this.#ai&&(this.#at=t.anchorNode,this.#ae=t.anchorOffset,this.#an=t.focusNode,this.#aa=t.focusOffset,this.#ag(),this.#ap(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#ah?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#nU,methodOfCreation:this.#ac}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ag(){let t=new rg(this.#ai,.001);this.#al=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#al.box;let e=new rg(this.#ai,.0025,.001,"ltr"===this._uiManager.direction);this.#as=e.getOutlines();let{firstPoint:i}=this.#al;this.#n0=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];let{lastPoint:r}=this.#as;this.#n1=[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height]}#au({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#al=t,this.#as=t.getNewOutline(this.#nU/2+1.5,.0025),e>=0)this.#x=e,this.#ar=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#ad=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#as.box,path:{d:this.#as.toSVGPath()}},!0);else if(this.parent){let e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#x,{bbox:ry.#af(this.#al.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#ad,{bbox:ry.#af(this.#as.box,e),path:{d:this.#as.toSVGPath()}})}let[r,s,n,a]=t.box;switch(this.rotation){case 0:this.x=r,this.y=s,this.width=n,this.height=a;break;case 90:{let[t,e]=this.parentDimensions;this.x=s,this.y=1-r,this.width=n*e/t,this.height=a*t/e;break}case 180:this.x=1-r,this.y=1-s,this.width=n,this.height=a;break;case 270:{let[t,e]=this.parentDimensions;this.x=1-s,this.y=r,this.width=n*e/t,this.height=a*t/e}}let{firstPoint:o}=t;this.#n0=[(o[0]-r)/n,(o[1]-s)/a];let{lastPoint:l}=this.#as;this.#n1=[(l[0]-r)/n,(l[1]-s)/a]}static initialize(t,e){tG.initialize(t,e),ry._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case v.HIGHLIGHT_COLOR:ry._defaultColor=e;break;case v.HIGHLIGHT_THICKNESS:ry._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#n1}get commentButtonPosition(){return this.#n0}updateParams(t,e){switch(t){case v.HIGHLIGHT_COLOR:this.#s5(e);break;case v.HIGHLIGHT_THICKNESS:this.#am(e)}}static get defaultPropertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,ry._defaultColor],[v.HIGHLIGHT_THICKNESS,ry._defaultThickness]]}get propertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,this.color||ry._defaultColor],[v.HIGHLIGHT_THICKNESS,this.#nU||ry._defaultThickness],[v.HIGHLIGHT_FREE,this.#ah]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#x,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#s?.updateColor(this.color),super.onUpdatedColor()}#s5(t){let e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,r=this.opacity;this.addCommands({cmd:e.bind(this,t,ry._defaultOpacity),undo:e.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#am(t){let e=this.#nU,i=t=>{this.#nU=t,this.#ab(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#s=new iB({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.#ay())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#ay())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#av(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#ap(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#av():t&&(this.#ap(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#ab(t){this.#ah&&(this.#au({highlightOutlines:this.#al.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims(this.width,this.height))}#av(){null!==this.#x&&this.parent&&(this.parent.drawLayer.remove(this.#x),this.#x=null,this.parent.drawLayer.remove(this.#ad),this.#ad=null)}#ap(t=this.parent){null===this.#x&&({id:this.#x,clipPathId:this.#ar}=t.drawLayer.draw({bbox:this.#al.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#ah},path:{d:this.#al.toSVGPath()}},!1,!0),this.#ad=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#ah},bbox:this.#as.box,path:{d:this.#as.toSVGPath()}},this.#ah),this.#ao&&(this.#ao.style.clipPath=this.#ar))}static #af([t,e,i,r],s){switch(s){case 90:return[1-e-r,t,r,i];case 180:return[1-t-i,1-e-r,i,r];case 270:return[e,1-t-i,r,i]}return[t,e,i,r]}rotate(t){let e,{drawLayer:i}
2=this.parent;this.#ah?(t=(t-this.rotation+360)%360,e=ry.#af(this.#al.box,t)):e=ry.#af([this.x,this.y,this.width,this.height],t),i.updateProperties(this.#x,{bbox:e,root:{"data-main-rotation":t}}),i.updateProperties(this.#ad,{bbox:ry.#af(this.#as.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#et&&(t.setAttribute("aria-label",this.#et),t.setAttribute("role","mark")),this.#ah?t.classList.add("free"):this.div.addEventListener("keydown",this.#aw.bind(this),{signal:this._uiManager._signal});let e=this.#ao=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#ar,this.setDims(this.width,this.height),tL(this,this.#ao,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{hovered:!1}})}#aw(t){ry._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#ax(!0);break;case 1:case 3:this.#ax(!1)}}#ax(t){if(!this.#at)return;let e=window.getSelection();t?e.setPosition(this.#at,this.#ae):e.setPosition(this.#an,this.#aa)}select(){super.select(),this.#ad&&this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#ad&&(this.parent?.drawLayer.updateProperties(this.#ad,{rootClass:{selected:!1}}),this.#ah||this.#ax(!1))}get _mustFixPosition(){return!this.#ah}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#x,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#ad,{rootClass:{hidden:!t}}))}#ay(){return this.#ah?this.rotation:0}#aA(){if(this.#ah)return null;let[t,e]=this.pageDimensions,[i,r]=this.pageTranslation,s=this.#ai,n=new Float32Array(8*s.length),a=0;for(let{x:o,y:l,width:h,height:d}of s){let s=o*t+i,c=(1-l)*e+r;n[a]=n[a+4]=s,n[a+1]=n[a+3]=c,n[a+2]=n[a+6]=s+h*t,n[a+5]=n[a+7]=c-d*e,a+=8}return n}#a_(t){return this.#al.serialize(t,this.#ay())}static startHighlighting(t,e,{target:i,x:r,y:s}){let{x:n,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#aE(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",tp,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",tu,{signal:d}),i.addEventListener("pointermove",this.#aS.bind(this,t),{signal:d}),this._freeHighlight=new rm({x:r,y:s},[n,a,o,l],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 #aS(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static #aE(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 r=null;if(t instanceof ri){let{data:{quadPoints:e,rect:i,rotation:s,id:n,color:a,opacity:o,popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:u},parent:{page:{pageNumber:p}}}=t;r=t={annotationType:y.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:u}}else if(t instanceof re){let{data:{inkLists:e,rect:i,rotation:s,id:n,color:a,borderStyle:{rawWidth:o},popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:u},parent:{page:{pageNumber:p}}}=t;r=t={annotationType:y.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:u}}let{color:s,quadPoints:n,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=V.makeHexColor(...s),l.opacity=o||1,a&&(l.#nU=t.thickness),l._initialData=r,t.comment&&l.setCommentData(t);let[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(n){let t=l.#ai=[];for(let e=0;e<n.length;e+=8)t.push({x:(n[e]-c)/h,y:1-(n[e+1]-u)/d,width:(n[e+2]-n[e])/h,height:(n[e+1]-n[e+5])/d});l.#ag(),l.#ap(),l.rotate(l.rotation)}else if(a){l.#ah=!0;let t=a[0],i={x:t[0]-c,y:d-(t[1]-u)}
2,r=new rm(i,[0,0,h,d],1,l.#nU/2,!0,.001);for(let e=0,s=t.length;e<s;e+=2)i.x=t[e]-c,i.y=d-(t[e+1]-u),r.add(i);let{id:s,clipPathId:n}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);l.#au({highlightOutlines:r.getOutlines(),highlightId:s,clipPathId:n}),l.#ap(),l.rotate(l.parentRotation)}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=tG._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return(Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#nU,quadPoints:this.#aA(),outlines:this.#a_(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#nT(i))?null:(i.id=this.annotationElementId,i)}#nT(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}static canCreateNewEmptyEditor(){return!1}}class rv{#aC=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#aC[t]=e}toSVGProperties(){let t=this.#aC;return this.#aC=Object.create(null),{root:t}}reset(){this.#aC=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){M("Not implemented")}}class rw extends tG{#aT=null;#ak;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static #aM=null;static #aP=null;static #aD=null;static #aI=NaN;static #aR=null;static #aL=null;static #aB=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#ak=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}_addOutlines(t){t.drawOutlines&&(this.#aF(t),this.#ap())}#aF({drawOutlines:t,drawId:e,drawingOptions:i}){this.#aT=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.#aN(t,this.parent),this.#aO(t.box)}#aN(t,e){let{id:i}=e.drawLayer.draw(rw._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){let i=new Set(Object.keys(t));for(let[r,s]of Object.entries(e))i.has(r)?Object.assign(t[r],s):t[r]=s;return t}static getDefaultDrawingOptions(t){M("Not implemented")}static get typesMap(){M("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(rw.#aM.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[i,r]of this.typesMap)t.push([i,e[r]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[i,r]of this.constructor.typesMap)t.push([i,e[r]]);return t}_updateProperty(t,e,i){let r=this._drawingOptions,s=r[e],n=i=>{r.updateProperty(e,i);let s=this.#aT.updateProperty(e,i);s&&this.#aO(s),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),t===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:n.bind(this,i),undo:n.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,rw._mergeSVGProperties(this.#aT.getPathResizingSVGProperties(this.#aU()),{bbox:this.#aj()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,rw._mergeSVGProperties(this.#aT.getPathResizedSVGProperties(this.#aU()),{bbox:this.#aj()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#aj()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,rw._mergeSVGProperties(this.#aT.getPathTranslatedSVGProperties(this.#aU(),this.parentDimensions),{bbox:this.#aj()}))}_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.#ak&&(this.#ak=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#av(),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#ap(),this.#aO
2(this.#aT.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#av()):t&&(this._uiManager.addShouldRescale(this),this.#ap(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#av(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ap(t=this.parent){if(null===this._drawId||this.parent!==t){if(null!==this._drawId)return void this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);this._drawingOptions.updateAll(),this._drawId=this.#aN(this.#aT,t)}}#az([t,e,i,r]){let{parentDimensions:[s,n],rotation:a}=this;switch(a){case 90:return[e,1-t,n/s*i,s/n*r];case 180:return[1-t,1-e,i,r];case 270:return[1-e,t,n/s*i,s/n*r];default:return[t,e,i,r]}}#aU(){let{x:t,y:e,width:i,height:r,parentDimensions:[s,n],rotation:a}=this;switch(a){case 90:return[1-e,t,s/n*i,n/s*r];case 180:return[1-t,1-e,i,r];case 270:return[e,1-t,s/n*i,n/s*r];default:return[t,e,i,r]}}#aO(t){[this.x,this.y,this.width,this.height]=this.#az(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#aj(){let{x:t,y:e,width:i,height:r,rotation:s,parentRotation:n,parentDimensions:[a,o]}=this;switch((4*s+n)/90){case 1:return[1-e-r,t,r,i];case 2:return[1-t-i,1-e-r,i,r];case 3:return[e,1-t-i,r,i];case 4:return[t,e-a/o*i,o/a*r,a/o*i];case 5:return[1-e,t,a/o*i,o/a*r];case 6:return[1-t-o/a*r,1-e,o/a*r,a/o*i];case 7:return[e-a/o*i,1-t-o/a*r,a/o*i,o/a*r];case 8:return[t-i,e-r,i,r];case 9:return[1-e,t-i,r,i];case 10:return[1-t,1-e,i,r];case 11:return[e-r,1-t,r,i];case 12:return[t-o/a*r,e,o/a*r,a/o*i];case 13:return[1-e-a/o*i,t-o/a*r,a/o*i,o/a*r];case 14:return[1-t,1-e-a/o*i,o/a*r,a/o*i];case 15:return[e,1-t,a/o*i,o/a*r];default:return[t,e,i,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,rw._mergeSVGProperties({bbox:this.#aj()},this.#aT.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#aO(this.#aT.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){let t,e;if(this.div)return this.div;this._isCopy&&(t=this.x,e=this.y);let i=super.render();i.classList.add("draw");let r=document.createElement("div");return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,r,s){M("Not implemented")}static startDrawing(t,e,i,r){let{target:s,offsetX:n,offsetY:a,pointerId:o,pointerType:l}=r;if(rw.#aR&&rw.#aR!==l)return;let{viewport:{rotation:h}}=t,{width:d,height:c}=s.getBoundingClientRect(),u=rw.#aP=new AbortController,p=t.combinedSignal(u);(rw.#aI||=o,rw.#aR??=l,window.addEventListener("pointerup",t=>{rw.#aI===t.pointerId?this._endDraw(t):rw.#aL?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointercancel",t=>{rw.#aI===t.pointerId?this._currentParent.endDrawingSession():rw.#aL?.delete(t.pointerId)},{signal:p}),window.addEventListener("pointerdown",t=>{rw.#aR===t.pointerType&&((rw.#aL||=new Set).add(t.pointerId),rw.#aM.isCancellable()&&(rw.#aM.removeLastElement(),rw.#aM.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",tu,{signal:p}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),s.addEventListener("touchmove",t=>{t.timeStamp===rw.#aB&&tp(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),rw.#aM)?t.drawLayer.updateProperties(this._currentDrawId,rw.#aM.startNew(n,a,d,c,h)):(e.updateUIForDefaultProperties(this),rw.#aM=this.createDrawerInstance(n,a,d,c,h),rw.#aD=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(rw.#aD.toSVGProperties(),rw.#aM.defaultSVGProperties),!0,!1))}static _drawMove(t){if(rw.#aB=-1,!rw.#aM)return;let{offsetX:e,offsetY:i,pointerId:r}=t;if(rw.#aI===r){if(rw.#aL?.size>=1)return void this._endDraw(t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,rw.#aM.add(e,i)),rw.#aB=t.t
2imeStamp,tp(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,rw.#aM=null,rw.#aD=null,rw.#aR=null,rw.#aB=NaN),rw.#aP&&(rw.#aP.abort(),rw.#aP=null,rw.#aI=NaN,rw.#aL=null)}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,rw.#aM.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=rw.#aM,i=this._currentDrawId,r=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(r))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:v.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(v.DRAW_STEP),!rw.#aM.isEmpty()){let{pageDimensions:[i,r],scale:s}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:rw.#aM.getOutlines(i*s,r*s,s,this._INNER_MARGIN),drawingOptions:rw.#aD,mustBeCommitted:!t});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,r,s,n){M("Not implemented")}static async deserialize(t,e,i){let{rawDims:{pageWidth:r,pageHeight:s,pageX:n,pageY:a}}=e.viewport,o=this.deserializeDraw(n,a,r,s,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#aF({drawOutlines:o}),l.#ap(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,i]=this.pageTranslation,[r,s]=this.pageDimensions;return this.#aT.serialize([e,i,r,s],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class rx{#nR=new Float64Array(6);#ne;#aH;#rM;#nU;#nj;#a$="";#aG=0;#n9=new rA;#aV;#aW;constructor(t,e,i,r,s,n){this.#aV=i,this.#aW=r,this.#rM=s,this.#nU=n,[t,e]=this.#aq(t,e);const a=this.#ne=[NaN,NaN,NaN,NaN,t,e];this.#nj=[t,e],this.#aH=[{line:a,points:this.#nj}],this.#nR.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#nU=e)}#aq(t,e){return rc._normalizePoint(t,e,this.#aV,this.#aW,this.#rM)}isEmpty(){return!this.#aH||0===this.#aH.length}isCancellable(){return this.#nj.length<=10}add(t,e){[t,e]=this.#aq(t,e);let[i,r,s,n]=this.#nR.subarray(2,6),a=t-s,o=e-n;return 2>=Math.hypot(this.#aV*a,this.#aW*o)?null:((this.#nj.push(t,e),isNaN(i))?(this.#nR.set([s,n,t,e],2),this.#ne.push(NaN,NaN,NaN,NaN,t,e)):(isNaN(this.#nR[0])&&this.#ne.splice(6,6),this.#nR.set([i,r,s,n,t,e],0),this.#ne.push(...rc.createBezierPoints(i,r,s,n,t,e))),{path:{d:this.toSVGPath()}})}end(t,e){let i=this.add(t,e);return i||(2===this.#nj.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,r,s){this.#aV=i,this.#aW=r,this.#rM=s,[t,e]=this.#aq(t,e);let n=this.#ne=[NaN,NaN,NaN,NaN,t,e];this.#nj=[t,e];let a=this.#aH.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#aH.push({line:n,points:this.#nj}),this.#nR.set(n,0),this.#aG=0,this.toSVGPath(),null}getLastElement(){return this.#aH.at(-1)}setLastElement(t){return this.#aH?(this.#aH.push(t),this.#ne=t.line,this.#nj=t.points,this.#aG=0,{path:{d:this.toSVGPath()}}):this.#n9.setLastElement(t)}removeLastElement(){if(!this.#aH)return this.#n9.removeLastElement();this.#aH.pop(),this.#a$="";for(let t=0,e=this.#aH.length;t<e;t++){let{line:e,points:i}=this.#aH[t];this.#ne=e,this.#nj=i,this.#aG=0,this.toSVGPath()}return{path:{d:this.#a$}}}toSVGPath(){let t=rc.svgRound(this.#ne[4]),e=rc.svgRound(this.#ne[5]);if(2===this.#nj.length)return this.#a$=`${this.#a$} M ${t} ${e} Z`,this.#a$;if(this.#nj.length<=6){let i=this.#a$.lastIndexOf("M");this.#a$=`${this.#a$.slice(0,i)} M ${t} ${e}`,this.#aG=6}if(4===this.#nj.length){let t=rc.svgRound(this.#ne[10]),e=rc.svgRound(this.#ne[11]);return this.#a$=`${this.#a$} L ${t} ${e}`,this.#aG=12,this.#a$}let i=[];0===this.#aG&&(i.push(`M ${t} ${e}`),this.#aG=6);for(let t=this.#aG,e=this.#ne.length;t<e;t+=6){let[e,r,s,n,a,o]=this.#ne.slice(t,t+6).map(rc.svgRound);i.push(`C${e} ${r} ${s} ${n} ${a} ${o}`)}return this.#a$+=i.join(" "),this.#aG=this.#ne.length,this.#a$}getOutlines(t,e,i,r){let s=this.#aH.at(-1);return s.line=new Float32Array(s.line),s.points=new Float32Array(s.points),this.#n9.build(this.#aH,t,e,i,this.#rM,this.#nU,r),this.#nR=null,this.#ne=null,this.#aH=null,this.#a$=null,this.#n9}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class rA extends rc{#nJ;#aX=0;#nP;#aH;#aV;#aW;#aK;#rM;#nU;build(t,e,i,r,s,n,a){this.#aV=e,this.#aW=i,this.#aK=r,this.#rM=s,this.#nU=n,this.#nP=a??0,this.#aH=t,this.#aY()}get thickness(){return this.#nU}setLastElement(t){return this.#aH.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#aH.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#aH){if(t.push(`M${rc.svgRound(e[4])} ${rc.svgRound(e[5])}`),6===e.length){t.push("Z");continue}if(12===e.length&&isNaN(e[6])){t.push(`L${rc.svgRound(e[10])} ${rc.svgRound(e[11])}`);continue}for(let i=6,r=e.length;i<r;i+=6){let[r,s,n,a,o,l]=e.subarray(i,i+6).map(rc.svgRound);t.push(`C${r} ${s} ${n} ${a} ${o} ${l}`)}}return t.join("")}serialize([t,e,i,r],s){let n,a,o,l,h,d,c,u,p,g=[],f=[],[m,b,y,v]=this.#aJ();switch(this.#rM){case 0:p=rc._rescale,n=t,a=e+r,o=i,l=-r,h=t+m*i,d=e+(1-b-v)*r,c=t+(m+y)*i,u=e+(1-b)*r;break;case 90:p=rc._rescaleAndSwap,n=t,a=e,o=i,l=r,h=t+b*i,d=e+m*r,c=t+(b+v)*i,u=e+(m+y)*r;break;case 180:p=rc._rescale,n=t+i,a=e,o=-i,l=r,h=t+(1-m-y)*i,d=e+b*r,c=t+(1-m)*i,u=e+(b+v)*r;break;case 270:p=rc._rescaleAndSwap,n=t+i,a=e+r,o=-i,l=-r,h=t+(1-b-v)*i,d=e+(1-m-y)*r,c=t+(1-b)*i,u=e+(1-m)*r}for(let{line:t,points:e}of this.#aH)g.push(p(t,n,a,o,l,s?Array(t.length):null)),f.push(p(e,n,a,o,l,s?Array(e.length):null));return{lines:g,points:f,rect:[h,d,c,u]}}static deserialize(t,e,i,r,s,{paths:{lines:n,points:a},rotation:o,thickness:l}){let h,d,c,u,p,g=[];switch(o){case 0:p=rc._rescale,h=-t/i,d=e/r+1,c=1/i,u=-1/r;break;case 90:p=rc._rescaleAndSwap,h=-e/r,d=-t/i,c=1/r,u=1/i;break;case 180:p=rc._rescale,h=t/i+1,d=-e/r,c=-1/i,u=1/r;break;case 270:p=rc._rescaleAndSwap,h=e/r+1,d=t/i+1,c=-1/r,u=-1/i}if(!n)for(let t of(n=[],a)){let e=t.length;if(2===e){n.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){n.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}let i=new Float32Array(3*(e-2));n.push(i);let[r,s,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,r,s],0);for(let n=4;n<e;n+=2){let e=t[n],l=t[n+1];i.set(rc.createBezierPoints(r,s,a,o,e,l),(n-2)*3),[r,s,a,o]=[a,o,e,l]}}for(let t=0,e=n.length;t<e;t++)g.push({line:p(n[t].map(t=>t??NaN),h,d,c,u),points:p(a[t].map(t=>t??NaN),h,d,c,u)});let f=new this.prototype.constructor;return f.build(g,i,r,1,o,l,s),f}#aQ(t=this.#nU){let e=this.#nP+t/2*this.#aK;return this.#rM%180==0?[e/this.#aV,e/this.#aW]:[e/this.#aW,e/this.#aV]}#aJ(){let[t,e,i,r]=this.#nJ,[s,n]=this.#aQ(0);return[t+s,e+n,i-2*s,r-2*n]}#aY(){let t=this.#nJ=new Float32Array([1/0,1/0,-1/0,-1/0]);for(let{line:e}of this.#aH){if(e.length<=12){for(let i=4,r=e.length;i<r;i+=6)V.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],r=e[5];for(let s=6,n=e.length;s<n;s+=6){let[n,a,o,l,h,d]=e.subarray(s,s+6);V.bezierBoundingBox(i,r,n,a,o,l,h,d,t),i=h,r=d}}let[e,i]=this.#aQ();t[0]=J(t[0]-e,0,1),t[1]=J(t[1]-i,0,1),t[2]=J(t[2]+e,0,1),t[3]=J(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#nJ}updateProperty(t,e){return"stroke-width"===t?this.#am(e):null}#am(t){let[e,i]=this.#aQ();this.#nU=t;let[r,s]=this.#aQ(),[n,a]=[r-e,s-i],o=this.#nJ;return o[0]-=n,o[1]-=a,o[2]+=2*n,o[3]+=2*a,o}updateParentDimensions([t,e],i){let[r,s]=this.#aQ();this.#aV=t,this.#aW=e,this.#aK=i;
2let[n,a]=this.#aQ(),o=n-r,l=a-s,h=this.#nJ;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#aX=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#nJ.map(rc.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#nJ;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${rc.svgRound(t)} ${rc.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#nJ,i=0,r=0,s=0,n=0,a=0,o=0;switch(this.#aX){case 90:r=e/t,s=-t/e,a=t;break;case 180:i=-1,n=-1,a=t,o=e;break;case 270:r=-e/t,s=t/e,o=e;break;default:return""}return`matrix(${i} ${r} ${s} ${n} ${rc.svgRound(a)} ${rc.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,r]){let[s,n]=this.#aQ(),[a,o,l,h]=this.#nJ;if(Math.abs(l-s)<=rc.PRECISION||Math.abs(h-n)<=rc.PRECISION){let s=t+i/2-(a+l/2),n=e+r/2-(o+h/2);return{path:{"transform-origin":`${rc.svgRound(t)} ${rc.svgRound(e)}`,transform:`${this.rotationTransform} translate(${s} ${n})`}}}let d=(i-2*s)/(l-2*s),c=(r-2*n)/(h-2*n);return{path:{"transform-origin":`${rc.svgRound(a)} ${rc.svgRound(o)}`,transform:`${this.rotationTransform} scale(${l/i} ${h/r}) translate(${rc.svgRound(s)} ${rc.svgRound(n)}) scale(${d} ${c}) translate(${rc.svgRound(-s)} ${rc.svgRound(-n)})`}}}getPathResizedSVGProperties([t,e,i,r]){let[s,n]=this.#aQ(),a=this.#nJ,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=r,Math.abs(h-s)<=rc.PRECISION||Math.abs(d-n)<=rc.PRECISION){let s=t+i/2-(o+h
2/2),n=e+r/2-(l+d/2);for(let{line:t,points:e}of this.#aH)rc._translate(t,s,n,t),rc._translate(e,s,n,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${rc.svgRound(t)} ${rc.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let c=(i-2*s)/(h-2*s),u=(r-2*n)/(d-2*n),p=-c*(o+s)+t+s,g=-u*(l+n)+e+n;if(1!==c||1!==u||0!==p||0!==g)for(let{line:t,points:e}of this.#aH)rc._rescale(t,p,g,c,u,t),rc._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${rc.svgRound(t)} ${rc.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){let[r,s]=i,n=this.#nJ,a=t-n[0],o=e-n[1];if(this.#aV===r&&this.#aW===s)for(let{line:t,points:e}of this.#aH)rc._translate(t,a,o,t),rc._translate(e,a,o,e);else{let t=this.#aV/r,e=this.#aW/s;for(let{line:i,points:n}of(this.#aV=r,this.#aW=s,this.#aH))rc._rescale(i,a,o,t,e,i),rc._rescale(n,a,o,t,e,n);n[2]*=t,n[3]*=e}return n[0]=t,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${rc.svgRound(t)} ${rc.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#nJ;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${rc.svgRound(t[0])} ${rc.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class r_ extends rv{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:tG._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(){let t=new r_(this._viewParameters);return t.updateAll(this),t}}class rE extends rw{static _type="ink";static _editorType=y.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){tG.initialize(t,e),this._defaultDrawingOptions=new r_(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return R(this,"typesMap",new Map([[v.INK_THICKNESS,"stroke-width"],[v.INK_COLOR,"stroke"],[v.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,r,s){return new rx(t,e,i,r,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,r,s,n){return rA.deserialize(t,e,i,r,s,n)}static async deserialize(t,e,i){let r=null;if(t instanceof re){let{data:{inkLists:e,rect:i,rotation:s,id:n,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:d,contentsObj:c,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;r=t={annotationType:y.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:s,annotationElementId:n,id:n,deleted:!1,popupRef:h,richText:d,comment:c?.str||null,creationDate:u,modificationDate:p}}let s=await super.deserialize(t,e,i);return s._initialData=r,t.comment&&s.setCommentData(t),s}get toolbarButtons(){return this._colorPicker||=new iF(this),[["colorPicker",this._colorPicker]]}get colorType(){return v.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();let{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let 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=rE.getDefaultDrawingOptions({stroke:V.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:r,"stroke-opacity":s,"stroke-width":n}}
2=this,a=Object.assign(super.serialize(t),{color:tG._colorManager.convert(r),opacity:s,thickness:n,paths:{lines:e,points:i}});return(this.addComment(a),t)?(a.isCopy=!0,a):this.annotationElementId&&!this.#nT(a)?null:(a.id=this.annotationElementId,a)}#nT(t){let{color:e,thickness:i,opacity:r,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==r||t.pageIndex!==s}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class rS extends rA{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class rC{static #aZ={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static #a0(t,e,i,r){return(i-=t,r-=e,0===i)?r>0?0:4:1===i?r+6:2-r}static #a1=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static #a2(t,e,i,r,s,n,a){let o=this.#a0(i,r,s,n);for(let s=0;s<8;s++){let n=(-s+o-a+16)%8;if(0!==t[(i+this.#a1[2*n])*e+(r+this.#a1[2*n+1])])return n}return -1}static #a3(t,e,i,r,s,n,a){let o=this.#a0(i,r,s,n);for(let s=0;s<8;s++){let n=(s+o+a+16)%8;if(0!==t[(i+this.#a1[2*n])*e+(r+this.#a1[2*n+1])])return n}return -1}static #a5(t,e,i,r){let s,n=t.length,a=new Int32Array(n);for(let e=0;e<n;e++)a[e]=+(t[e]<=r);for(let t=1;t<i-1;t++)a[t*e]=a[t*e+e-1]=0;for(let t=0;t<e;t++)a[t]=a[e*i-1-t]=0;let o=1,l=[];for(let t=1;t<i-1;t++){s=1;for(let i=1;i<e-1;i++){let r,n=t*e+i,h=a[n];if(0===h)continue;let d=t,c=i;if(1===h&&0===a[n-1])o+=1,c-=1;else if(h>=1&&0===a[n+1])o+=1,c+=1,h>1&&(s=h);else{1!==h&&(s=Math.abs(h));continue}let u=[i,t],p=c===i+1,g={isHole:p,points:u,id:o,parent:0};for(let t of(l.push(g),l))if(t.id===s){r=t;break}r?r.isHole?g.parent=p?r.parent:s:g.parent=p?s:r.parent:g.parent=p?s:0;let f=this.#a2(a,e,t,i,d,c,0);if(-1===f){a[n]=-o,1!==a[n]&&(s=Math.abs(a[n]));continue}let m=this.#a1[2*f],b=this.#a1[2*f+1],y=t+m,v=i+b;d=y,c=v;let w=t,x=i;for(;;){let r=this.#a3(a,e,w,x,d,c,1);m=this.#a1[2*r],b=this.#a1[2*r+1];let l=w+m,h=x+b;u.push(h,l);let p=w*e+x;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),l===t&&h===i&&w===y&&x===v){1!==a[n]&&(s=Math.abs(a[n]));break}d=w,c=x,w=l,x=h}}}return l}static #a6(t,e,i,r){if(i-e<=4){for(let s=e;s<i-2;s+=2)r.push(t[s],t[s+1]);return}let s=t[e],n=t[e+1],a=t[i-4]-s,o=t[i-3]-n,l=Math.hypot(a,o),h=a/l,d=o/l,c=h*n-d*s,u=1/l,p=Math.atan(o/a),g=Math.cos(p),f=Math.sin(p),m=u*(Math.abs(g)+Math.abs(f)),b=u*(1-m+m**2),y=Math.max(Math.atan(Math.abs(f+g)*b),Math.atan(Math.abs(f-g)*b)),v=0,w=e;for(let r=e+2;r<i-2;r+=2){let e=Math.abs(c-h*t[r+1]+d*t[r]);e>v&&(w=r,v=e)}v>(l*y)**2?(this.#a6(t,e,w+2,r),this.#a6(t,w,i,r)):r.push(s,n)}static #a4(t){let e=[],i=t.length;return this.#a6(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static #a8(t,e,i,r,s,n){let a=new Float32Array(n**2),o=-2*r**2,l=n>>1;for(let t=0;t<n;t++){let e=(t-l)**2;for(let i=0;i<n;i++)a[t*n+i]=Math.exp((e+(i-l)**2)/o)}let h=new Float32Array(256),d=-2*s**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/d);let c=new Uint8Array(t.length),u=new Uint32Array(256);for(let r=0;r<i;r++)for(let s=0;s<e;s++){let o=r*e+s,d=t[o],p=0,g=0;for(let o=0;o<n;o++){let c=r+o-l;if(!(c<0)&&!(c>=i))for(let i=0;i<n;i++){let r=s+i-l;if(r<0||r>=e)continue;let u=t[c*e+r],f=a[o*n+i]*h[Math.abs(u-d)];p+=u*f,g+=f}}let f=c[o]=Math.round(p/g);u[f]++}return[c,u]}static #a7(t){let e=new Uint32Array(256);for(let i of t)e[i]++;return e}static #a9(t){let e=new Uint8ClampedArray(t.length>>2),i=-1/0,r=1/0;for(let s=0,n=e.length;s<n;s++){let n=e[s]=t[s<<2];i=Math.max(i,n),r=Math.min(r,n)}let s=255/(i-r);for(let t=0,i=e.length;t<i;t++)e[t]=(e[t]-r)*s;return e}static #ot(t){let e,i=-1/0,r=-1/0,s=t.findIndex(t=>0!==t),n=s,a=s;for(e=s;e<256;e++){let s=t[e];s>i&&(e-n>r&&(r=e-n,a=e-1),i=s,n=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static #oe(t){let e=t,{width:i,height:r}=t,{maxDim:s}=this.#aZ,n=i,a=r;if(i>s||r>s){let o=i,l=r,h=Math.log2(Math.max(i,r)/s),d=Math.floor(h);h=h===d?d-1:d;for(let i=0;i<h;i++){let i=new OffscreenCanvas(n=Math.ceil(o/2),a=Math.ceil(l/2));i.getContext("2d").drawImage(t,0,0,o,l,0,0,n,a),o=n,l=a,t!==e&&t.close(),t=i.transferToImageBitmap()}let c=Math.min(s/n,s/a);n=Math.round(n*c),a=Math.round(a*c)}let o=new OffscreenCanvas(n,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,n,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,n,a);let l=o.getImageData(0,0,n,a).data;return[this.#a9(l),n,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:r},s,n,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1}),d=h.font=`${i} ${r} 200px ${e}`,{actualBoundingBoxLeft:c,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:f,fontBoundingBoxDescent:m,width:b}=h.measureText(t),y=Math.ceil(1.5*Math.max(Math.abs(c)+Math.abs(u)||0,b)),v=Math.ceil(1.5*Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(f)+Math.abs(m)||200));(h=(l=new OffscreenCanvas(y,v)).getContext("2d",{alpha:!0,willReadFrequently:!0})).font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,y,v),h.fillStyle="black",h.fillText(t,.5*y/2,1.5*v/2);let w=this.#a9(h.getImageData(0,0,y,v).data),x=this.#a7(w),A=this.#ot(x),_=this.#a5(w,y,v,A);return this.processDrawnLines({lines:{curves:_,width:y,height:v},pageWidth:s,pageHeight:n,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}
2static process(t,e,i,r,s){let[n,a,o]=this.#oe(t),[l,h]=this.#a8(n,a,o,Math.hypot(a,o)*this.#aZ.sigmaSFactor,this.#aZ.sigmaR,this.#aZ.kernelSize),d=this.#ot(h),c=this.#a5(l,a,o,d);return this.processDrawnLines({lines:{curves:c,width:a,height:o},pageWidth:e,pageHeight:i,rotation:r,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:r,innerMargin:s,mustSmooth:n,areContours:a}){r%180!=0&&([e,i]=[i,e]);let{curves:o,width:l,height:h}=t,d=t.thickness??0,c=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,f=[];for(let{points:t}of o){let e=n?this.#a4(t):t;if(!e)continue;f.push(e);let i=e.length,r=new Float32Array(i),s=new Float32Array(3*(2===i?2:i-2));if(c.push({line:s,points:r}),2===i){r[0]=e[0]*p,r[1]=e[1]*g,s.set([NaN,NaN,NaN,NaN,r[0],r[1]],0);continue}let[a,o,l,h]=e;a*=p,o*=g,l*=p,h*=g,r.set([a,o,l,h],0),s.set([NaN,NaN,NaN,NaN,a,o],0);for(let t=4;t<i;t+=2){let i=r[t]=e[t]*p,n=r[t+1]=e[t+1]*g;s.set(rc.createBezierPoints(a,o,l,h,i,n),(t-2)*3),[a,o,l,h]=[l,h,i,n]}}if(0===c.length)return null;let m=a?new rS:new rA;return m.build(c,e,i,1,r,a?0:d,s),{outline:m,newCurves:f,areContours:a,thickness:d,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:r,height:s}){let n,a=1/0,o=-1/0,l=0;for(let e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){let i=e[t]-e[t-2];a=Math.min(a,i),o=Math.max(o,i)}}n=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;let h=t.length,d=8+3*h,c=new Uint32Array(d),u=0;for(let a of(c[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*n.BYTES_PER_ELEMENT,c[u++]=0,c[u++]=r,c[u++]=s,c[u++]=+!e,c[u++]=Math.max(0,Math.floor(i??0)),c[u++]=h,c[u++]=n.BYTES_PER_ELEMENT,t))c[u++]=a.length-2,c[u++]=a[0],c[u++]=a[1];let p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(c);let f=n.prototype.constructor;for(let e of t){let t=new f(e.length-2);for(let i=2,r=e.length;i<r;i++)t[i-2]=e[i]-e[i-2];g.write(t)}return g.close(),Q(new Uint8Array(await new Response(p.readable).arrayBuffer()))}static async decompressSignature(t){try{let e,i=Uint8Array.fromBase64?Uint8Array.fromBase64(t):H(atob(t)),{readable:r,writable:s}=new DecompressionStream("deflate-raw"),n=s.getWriter();await n.ready,n.write(i).then(async()=>{await n.ready,await n.close()}).catch(()=>{});let a=null,o=0;for await(let t of r)(a||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])).set(t,o),o+=t.length;let l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(0!==h)throw Error(`Invalid version: ${h}`);let d=l[2],c=l[3],u=0===l[4],p=l[5],g=l[6],f=l[7],m=[],b=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;switch(f){case Int8Array.BYTES_PER_ELEMENT:e=new Int8Array(a.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:e=new Int16Array(a.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:e=new Int32Array(a.buffer,b)}o=0;for(let t=0;t<g;t++){let i=l[3*t+8],r=new Float32Array(i+2);m.push(r);for(let e=0;e<2;e++)r[e]=l[3*t+8+e+1];for(let t=0;t<i;t++)r[t+2]=r[t]+e[o++]}return{areContours:u,thickness:p,outlines:m,width:d,height:c}}catch(t){return k(`decompressSignature: ${t}`),null}}}class rT extends rv{constructor(){super(),super.updateProperties({fill:tG._defaultLineColor,"stroke-width":0})}clone(){let t=new rT;return t.updateAll(this),t}}class rk extends r_{constructor(t){super(t),super.updateProperties({stroke:tG._defaultLineColor,"stroke-width":1})}clone(){let t=new rk(this._viewParameters);return t.updateAll(this),t}}class rM extends rw{#oi=!1;#or=null;#os=null;#on=null;static _type="signature";static _editorType=y.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#os=t.signatureData||null,this.#or=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){tG.initialize(t,e),this._defaultDrawingOptions=new rT,this._defaultDrawnSignatureOptions=new rk(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return R(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#or}}static computeTelemetryFinalData(t){let 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(){let t,e;if(this.div)return this.div;let{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#os){let{lines:t,mustSmooth:e,areContours:i,description:r,uuid:s,heightInPage:n}=this.#os,{rawDims:{pageWidth:a,pageHeight:o},rotation:l}=this.parent.viewport,h=rC.processDrawnLines({lines:t,pageWidth:a,pageHeight:o,rotation:l,innerMargin:rM._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,n,r,s)}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.#or||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#on=t,this.addEditToolbar()}getUuid(){return this.#on}get description(){return this.#or}set description(t){this.#or=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){let{newCurves:t,areContours:e,thickness:i,width:r,height:s}=this.#os,n=Math.max(r,s),a=rC.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:r,height:s},pageWidth:n,pageHeight:n,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e});return{areContours:e,outline:a.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,r){let s,{x:n,y:a}=this,{outline:o}=this.#os=t;this.#oi=o instanceof rS,this.description=i,this.#oi?s=rM.getDefaultDrawingOptions():(s=rM._defaultDrawnSignatureOptions.clone()).updateProperties({"stroke-width":o.thickness}),this._addOutlines({drawOutlines:o,drawingOptions:s});let[,l]=this.pageDimensions,h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=n,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:r}=this.parent.viewport;
2return rC.process(t,e,i,r,rM._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:i,pageHeight:r},rotation:s}=this.parent.viewport;return rC.extractContoursFromText(t,e,i,r,s,rM._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:r}=this.parent.viewport;return rC.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:r,innerMargin:rM._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=rM.getDefaultDrawingOptions():(this._drawingOptions=rM._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":r}}=this,s=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#oi,color:[0,0,0],thickness:this.#oi?0:r});return this.addComment(s),t?(s.paths={lines:e,points:i},s.uuid=this.#on,s.isCopy=!0):s.lines=e,this.#or&&(s.accessibilityData={type:"Figure",alt:this.#or}),s}static deserializeDraw(t,e,i,r,s,n){return n.areContours?rS.deserialize(t,e,i,r,s,n):rA.deserialize(t,e,i,r,s,n)}static async deserialize(t,e,i){let r=await super.deserialize(t,e,i);return r.#oi=t.areContours,r.description=t.accessibilityData?.alt||"",r.#on=t.uuid,r}}class rP extends tG{#oa=null;#oo=null;#ol=null;#oh=null;#od=null;#oc="";#ou=null;#op=!1;#og=null;#of=!1;#om=!1;static _type="stamp";static _editorType=y.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#oh=t.bitmapUrl,this.#od=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){tG.initialize(t,e)}static isHandlingMimeForPasting(t){return tx.includes(t)}static paste(t,e){e.pasteEditor({mode:y.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#ob(t,e=!1){t?(this.#oa=t.bitmap,e||(this.#oo=t.id,this.#of=t.isSvg),t.file&&(this.#oc=t.file.name),this.#oy()):this.remove()}#ov(){if(this.#ol=null,this._uiManager.enableWaiting(!1),this.#ou){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#oa)return void this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#oa){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;let{mlManager:i}=this._uiManager;if(!i)throw Error("No ML.");if(!await i.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:r,width:s,height:n}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:r,width:s,height:n,channels:r.length/(s*n)}});if(!a)throw Error("No response from the AI service.");if(a.error)throw Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw Error("No valid response from the AI service.");let o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#ow(){if(this.#oo){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#oo).then(t=>this.#ob(t,!0)).finally(()=>this.#ov());return}if(this.#oh){let t=this.#oh;this.#oh=null,this._uiManager.enableWaiting(!0),this.#ol=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#ob(t)).finally(()=>this.#ov());return}if(this.#od){let t=this.#od;this.#od=null,this._uiManager.enableWaiting(!0),this.#ol=this._uiManager.imageManager.getFromFile(t).then(t=>this.#ob(t)).finally(()=>this.#ov());return}let t=document.createElement("input");t.type="file",t.accept=tx.join(",");let e=this._uiManager._signal;this.#ol=new Promise(i=>{t.addEventListener("change",async()=>
2{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);let e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#ob(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#ov()),t.click()}remove(){this.#oo&&(this.#oa=null,this._uiManager.imageManager.deleteId(this.#oo),this.#ou?.remove(),this.#ou=null,this.#og&&(clearTimeout(this.#og),this.#og=null)),super.remove()}rebuild(){if(!this.parent){this.#oo&&this.#ow();return}super.rebuild(),null!==this.div&&(this.#oo&&null===this.#ou&&this.#ow(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#ol||this.#oa||this.#oh||this.#od||this.#oo||this.#op)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){let t,e;return this.div||(this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#op||(this.#oa?this.#oy():this.#ow()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this)),this.div}setCanvas(t,e){let{id:i,bitmap:r}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#oo=i,r&&(this.#oa=r),this.#op=!1,this.#oy())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#og&&clearTimeout(this.#og),this.#og=setTimeout(()=>{this.#og=null,this.#ox()},200))}#oy(){let{div:t}=this,{width:e,height:i}=this.#oa,[r,s]=this.pageDimensions;if(this.width)e=this.width*r,i=this.height*s;else if(e>.75*r||i>.75*s){let t=Math.min(.75*r/e,.75*s/i);e*=t,i*=t}this._uiManager.enableWaiting(!1);let n=this.#ou=document.createElement("canvas");n.setAttribute("role","img"),this.addContainer(n),this.width=e/r,this.height=i/s,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#ox(),this.#om||(this.parent.addUndoableEditor(this),this.#om=!0),this._reportTelemetry({action:"inserted_image"}),this.#oc&&this.div.setAttribute("aria-description",this.#oc),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,i=!1){t||(t=224);let{width:r,height:s}=this.#oa,n=new tw,a=this.#oa,o=r,l=s,h=null;if(e){if(r>e||s>e){let t=Math.min(e/r,e/s);o=Math.floor(r*t),l=Math.floor(s*t)}let t=(h=document.createElement("canvas")).width=Math.ceil(o*n.sx),i=h.height=Math.ceil(l*n.sy);this.#of||(a=this.#oA(t,i));let d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":tA.isDarkMode&&(c="#8f8f9d",u="#42414d");let p=15*n.sx,g=15*n.sy,f=new OffscreenCanvas(2*p,2*g),m=f.getContext("2d");m.fillStyle=c,m.fillRect(0,0,2*p,2*g),m.fillStyle=u,m.fillRect(0,0,p,g),m.fillRect(p,g,p,g),d.fillStyle=d.createPattern(f,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(n.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#oa,r>t||s>t){let n=Math.min(t/r,t/s);e=Math.floor(r*n),i=Math.floor(s*n),this.#of||(a=this.#oA(e,i))}let o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#oA(t,e){let{width:i,height:r}=this.#oa,s=i,n=r,a=this.#oa;for(;s>2*t||n>2*e;){let i=s,r=n;s>2*t&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2)),n>2*e&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2));let o=new OffscreenCanvas(s,n);o.getContext("2d").drawImage(a,0,0,i,r,0,0,s,n),a=o.transferToImageBitmap()}return a}#ox(){let[t,e]=this.parentDimensions,{width:i,height:r}=this,s=new tw,n=Math.ceil(i*t*s.sx),a=Math.ceil(r*e*s.sy),o=this.#ou;if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;let l=this.#of?this.#oa:this.#oA(n,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,n,a)}#o_(t){if(t){if(this.#of){let t=this._uiManager.imageManager.getSvgUrl(this.#oo);if(t)return t}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#oa,t.getContext("2d").drawImage(this.#oa,0,0),t.toDataURL()}if(this.#of){let[t,e]=this.pageDimensions,i=Math.round(this.width*t*ti.PDF_TO_CSS_UNITS),r=Math.round(this.height*e*ti.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(i,r);return s.getContext("2d").drawImage(this.#oa,0,0,this.#oa.width,this.#oa.height,0,0,i,r),s.transferToImageBitmap()}return structuredClone(this.#oa)}static async deserialize(t,e,i){let r=null,s=!1;if(t instanceof ra){let n,a,{data:{rect:o,rotation:l,id:h,structParent:d,popupRef:c,richText:u,contentsObj:p,creationDate:g,modificationDate:f},container:m,parent:{page:{pageNumber:b}},canvas:v}=t;v?(delete t.canvas,{id:n,bitmap:a}=i.imageManager.getFromCanvas(m.id,v),v.remove()):(s=!0,t._hasNoCanvas=!0);let w=(await e._structTree.getAriaAttributes(`${Y}${h}`))?.get("aria-label")||"";r=t={annotationType:y.STAMP,bitmapId:n,bitmap:a,pageIndex:b-1,rect:o.slice(0),rotation:l,annotationElementId:h,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:w},isSvg:!1,structParent:d,popupRef:c,richText:u,comment:p?.str||null,creationDate:g,modificationDate:f}}let n=await super.deserialize(t,e,i),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:d,accessibilityData:c}=t;s?(i.addMissingCanvas(t.id,n),n.#op=!0):h&&i.imageManager.isValidId(h)?(n.#oo=h,o&&(n.#oa=o)):n.#oh=l,n.#of=d;let[u,p]=n.pageDimensions;return n.width=(a[2]-a[0])/u,n.height=(a[3]-a[1])/p,c&&(n.altTextData=c),n._initialData=r,t.comment&&n.setCommentData(t),n.#om=!!r,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let i=Object.assign(super.serialize(t),{bitmapId:this.#oo,isSvg:this.#of});if(this.addComment(i),t)return i.bitmapUrl=this.#o_(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;let{decorative:r,altText:s}=this.serializeAltText(!1);if(!r&&s&&(i.accessibilityData={type:"Figure",alt:s}
2),this.annotationElementId){let t=this.#nT(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;let n=this.#of?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#oo)){if(this.#of){let t=e.stamps.get(this.#oo);n>t.area&&(t.area=n,t.serialized.bitmap.close(),t.serialized.bitmap=this.#o_(!1))}}else e.stamps.set(this.#oo,{area:n,serialized:i}),i.bitmap=this.#o_(!1);return i}#nT(t){let{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,r=t.pageIndex===e,s=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&s,isSameAltText:s}}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class rD{#nd;#oE=!1;#oS=null;#oC=null;#oT=null;#ok=new Map;#oM=!1;#oP=!1;#oD=!1;#oI=null;#oR=null;#oL=null;#oB=null;#oF=null;#oN=-1;#b;static _initialized=!1;static #V=new Map([rd,rE,rP,ry,rM].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:r,accessibilityManager:s,annotationLayer:n,drawLayer:a,textLayer:o,viewport:l,l10n:h}){const d=[...rD.#V.values()];if(!rD._initialized)for(const e of(rD._initialized=!0,d))e.initialize(h,t);t.registerEditorTypes(d),this.#b=t,this.pageIndex=e,this.div=i,this.#nd=s,this.#oS=n,this.viewport=l,this.#oL=o,this.drawLayer=a,this._structTree=r,this.#b.addLayer(this)}get isEmpty(){return 0===this.#ok.size}get isInvisible(){return this.isEmpty&&this.#b.getMode()===y.NONE}updateToolbar(t){this.#b.updateToolbar(t)}updateMode(t=this.#b.getMode()){switch(this.#oO(),t){case y.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case y.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case y.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===y.POPUP)e.toggle("commentEditing",!0);else for(let i of(e.toggle("commentEditing",!1),rD.#V.values()))e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#oL?.div}setEditingState(t){this.#b.setEditingState(t)}addCommands(t){this.#b.addCommands(t)}cleanUndoStack(t){this.#b.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#oS?.div.classList.toggle("disabled",!t)}get #oU(){return 0!==this.#ok.size?this.#ok.values():this.#b.getEditors(this.pageIndex)}async enable(){this.#oD=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#oF?.abort(),this.#oF=null;let t=new Set;for(let e of this.#oU)e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#b.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));let e=this.#oS;if(e)for(let i of e.getEditableAnnotations()){if(i.hide(),this.#b.isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;let e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#oD=!1,this.#b._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#oP=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#oL&&!this.#oF){this.#oF=new AbortController;let t=this.#b.combinedSignal(this.#oF);this.#oL.div.addEventListener("pointerdown",t=>{let e,{clientX:i,clientY:r,timeStamp:s}=t;if(s-this.#oN>500){this.#oN=s;return}this.#oN=-1;let{classList:n}=this.div;n.toggle("getElements",!0);let a=document.elementsFromPoint(i,r);if(n.toggle("getElements",!1),!this.div.contains(a[0]))return;let o=RegExp(`^${b}[0-9]+$`);for(let t of a)if(o.test(t.id)){e=t.id;break}if(!e)return;let l=this.#ok.get(e);l?.annotationElementId===null&&(t.stopPropagation(),t.preventDefault(),l.dblclick(t))},{signal:t,capture:!0})}let t=this.#oS;if(t){let e=new Map,i=new Map;for(let r of this.#oU){if(r.disableEditing(),!r.annotationElementId){r.updateFakeAnnotationElement(t);continue}if(null!==r.serialize()){e.set(r.annotationElementId,r);continue}i.set(r.annotationElementId,r),this.getEditableAnnotation(r.annotationElementId)?.show(),r.remove()}for(let r of t.getEditableAnnotations()){let{id:t}=r.data;if(this.#b.isDeletedAnnotationElement(t)){r.updateEdited({deleted:!0}
2);continue}let s=i.get(t);if(s){s.resetAnnotationElement(r),s.show(!1),r.show();continue}(s=e.get(t))&&(this.#b.addChangedExistingAnnotation(s),s.renderAnnotationElement(r)&&s.show(!1)),r.show()}}this.#oO(),this.isEmpty&&(this.div.hidden=!0);let{classList:e}=this.div;for(let t of rD.#V.values())e.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#oP=!1}getEditableAnnotation(t){return this.#oS?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#b.getActive()!==t&&this.#b.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#oL?.div&&!this.#oB){this.#oB=new AbortController;let t=this.#b.combinedSignal(this.#oB);this.#oL.div.addEventListener("pointerdown",this.#oj.bind(this),{signal:t}),this.#oL.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#oL?.div&&this.#oB&&(this.#oB.abort(),this.#oB=null,this.#oL.div.classList.remove("highlighting"))}#oj(t){this.#b.unselectAll();let{target:e}=t;if(e===this.#oL.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#oL.div.contains(e)){let{isMac:e}=$.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#b.showAllEditors("highlight",!0,!0),this.#oL.div.classList.add("free"),this.toggleDrawing(),ry.startHighlighting(this,"ltr"===this.#b.direction,{target:this.#oL.div,x:t.x,y:t.y}),this.#oL.div.addEventListener("pointerup",()=>{this.#oL.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#b._signal}),t.preventDefault()}}enableClick(){if(this.#oC)return;this.#oC=new AbortController;let t=this.#b.combinedSignal(this.#oC);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#oC?.abort(),this.#oC=null}attach(t){this.#ok.set(t.id,t);let{annotationElementId:e}=t;e&&this.#b.isDeletedAnnotationElement(e)&&this.#b.removeDeletedAnnotationElement(t)}detach(t){this.#ok.delete(t.id),this.#nd?.removePointerInTextLayer(t.contentDiv),!this.#oP&&t.annotationElementId&&this.#b.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#b.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#b.addDeletedAnnotationElement(t.annotationElementId),tG.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.#b.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#oD),this.#b.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#oT&&(t._focusEventsAllowed=!1,this.#oT=setTimeout(()=>{this.#oT=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#b._signal}),e.focus())},0)),t._structTreeParentId=this.#nd?.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(let e of this.#ok.values())if(e.uid===t)return e;return null}getNextId(){return this.#b.getId()}get #oz(){return rD.#V.get(this.#b.getMode())}combinedSignal(t){return this.#b.combinedSignal(t)}#oH(t){let e=this.#oz;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#oz?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#b.updateMode(t.mode);let{offsetX:i,offsetY:r}=this.#o$(),s=this.getNextId(),n=this.#oH({parent:this,id:s,x:i,y:r,uiManager:this.#b,isCentered:!0,...e});n&&this.add(n)}async deserialize(t){return await rD.#V.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#b)||null}createAndAddNewEditor(t,e,i={}){let r=this.getNextId(),s=this.#oH({parent:this,id:r,x:t.offsetX,y:t.offsetY,uiManager:this.#b,isCentered:e,...i});return s&&this.add(s),s}get boundingClientRect(){return this.div.getBoundingClientRect()}#o$(){let{x:t,y:e,width:i,height:r}=this.boundingClientRect,s=Math.max(0,t),n=Math.max(0,e),a=Math.min(window.innerWidth,t+i),o=Math.min(window.innerHeight,e+r),l=(s+a)/2-t,h=(n+o)/2-e,[d,c]=this.viewport.rotation%180==0?[l,h]:[h,l];return{offsetX:d,offsetY:c}}addNewEditor(t={}){this.createAndAddNewEditor(this.#o$(),!0,t)}setSelected(t){this.#b.setSelected(t)}toggleSelected(t){this.#b.toggleSelected(t)}unselect(t){this.#b.unselect(t)}pointerup(t){let{isMac:e}=$.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div||!this.#oM||(this.#oM=!1,this.#oz?.isDrawer&&this.#oz.supportMultipleDrawings))return;if(!this.#oE){this.#oE=!0;return}let i=this.#b.getMode();i===y.STAMP||i===y.SIGNATURE?this.#b.unselectAll():this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#b.getMode()===y.HIGHLIGHT&&this.enableTextSelection(),this.#oM){this.#oM=!1;return}let{isMac:e}=$.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div)return;if(this.#oM=!0,this.#oz?.isDrawer)return void this.startDrawingSession(t);let i=this.#b.getActive();this.#oE=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#oI)return void this.#oz.startDrawing(this,this.#b,!1,t);this.#b.setCurrentDrawingSession(this),this.#oI=new AbortController;let e=this.#b.combinedSignal(this.#oI);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#oR=null,this.commitOrRemove())},{signal:e}),this.#oz.startDrawing(this,this.#b,!1,t)}pause(t){if(t){let{activeElement:t}=document;this.div.contains(t)&&(this.#oR=t);return}this.#oR&&setTimeout(()=>
2{this.#oR?.focus(),this.#oR=null},0)}endDrawingSession(t=!1){return this.#oI?(this.#b.setCurrentDrawingSession(null),this.#oI.abort(),this.#oI=null,this.#oR=null,this.#oz.endDrawing(t)):null}findNewParent(t,e,i){let r=this.#b.findParent(e,i);return null!==r&&r!==this&&(r.changeParent(t),!0)}commitOrRemove(){return!!this.#oI&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#oI&&this.#oz.onScaleChangingWhenDrawing(this)}destroy(){for(let t of(this.commitOrRemove(),this.#b.getActive()?.parent===this&&(this.#b.commitOrRemove(),this.#b.setActiveEditor(null)),this.#oT&&(clearTimeout(this.#oT),this.#oT=null),this.#ok.values()))this.#nd?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#ok.clear(),this.#b.removeLayer(this)}#oO(){for(let t of this.#ok.values())t.isEmpty()&&t.remove()}render({viewport:t}){for(let e of(this.viewport=t,tv(this.div,t),this.#b.getEditors(this.pageIndex)))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){this.#b.commitOrRemove(),this.#oO();let e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,tv(this.div,{rotation:i}),e!==i)for(let t of this.#ok.values())t.rotate(i)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#b.viewParameters.realScale}}class rI{#sG=null;#oG=new Map;#oV=new Map;static #x=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(!this.#sG){this.#sG=t;return}if(this.#sG!==t){if(this.#oG.size>0)for(let e of this.#oG.values())e.remove(),t.append(e);this.#sG=t}}static get _svgFactory(){return R(this,"_svgFactory",new iz)}static #oW(t,[e,i,r,s]){let{style:n}=t;n.top=`${100*i}%`,n.left=`${100*e}%`,n.width=`${100*r}%`,n.height=`${100*s}%`}#oq(){let t=rI._svgFactory.create(1,1,!0);return this.#sG.append(t),t.setAttribute("aria-hidden",!0),t}#oX(t,e){let i=rI._svgFactory.createElement("clipPath");t.append(i);let r=`clip_${e}`;i.setAttribute("id",r),i.setAttribute("clipPathUnits","objectBoundingBox");let s=rI._svgFactory.createElement("use");return i.append(s),s.setAttribute("href",`#${e}`),s.classList.add("clip"),r}#oK(t,e){for(let[i,r]of Object.entries(e))null===r?t.removeAttribute(i):t.setAttribute(i,r)}draw(t,e=!1,i=!1){let r=rI.#x++,s=this.#oq(),n=rI._svgFactory.createElement("defs");s.append(n);let a=rI._svgFactory.createElement("path");n.append(a);let o=`path_p${this.pageIndex}_${r}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#oV.set(r,a);let l=i?this.#oX(n,o):null,h=rI._svgFactory.createElement("use");return s.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(s,t),this.#oG.set(r,s),{id:r,clipPathId:`url(#${l})`}}drawOutline(t,e){let i,r=rI.#x++,s=this.#oq(),n=rI._svgFactory.createElement("defs");s.append(n);let a=rI._svgFactory.createElement("path");n.append(a);let o=`path_p${this.pageIndex}_${r}`;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e){let t=rI._svgFactory.createElement("mask");n.append(t),i=`mask_p${this.pageIndex}_${r}`,t.setAttribute("id",i),t.setAttribute("maskUnits","objectBoundingBox");let e=rI._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");let s=rI._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")}let l=rI._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${o}`),i&&l.setAttribute("mask",`url(#${i})`);let h=l.cloneNode();return s.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(s,t),this.#oG.set(r,s),r}finalizeDraw(t,e){this.#oV.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:i,bbox:r,rootClass:s,path:n}=e,a="number"==typeof t?this.#oG.get(t):t;if(a){if(i&&this.#oK(a,i),r&&rI.#oW(a,r),s){let{classList:t}=a;for(let[e,i]of Object.entries(s))t.toggle(e,i)}if(n){let t=a.firstChild.firstChild;this.#oK(t,n)}}}updateParent(t,e){if(e===this)return;let i=this.#oG.get(t);i&&(e.#sG.append(i),this.#oG.delete(t),e.#oG.set(t,i))}remove(t){this.#oV.delete(t),null!==this.#sG&&(this.#oG.get(t).remove(),this.#oG.delete(t))}
2destroy(){for(let t of(this.#sG=null,this.#oG.values()))t.remove();this.#oG.clear(),this.#oV.clear()}}globalThis._pdfjsTestingUtils={HighlightOutliner:rg},globalThis.pdfjsLib={AbortException:j,AnnotationEditorLayer:rD,AnnotationEditorParamsType:v,AnnotationEditorType:y,AnnotationEditorUIManager:tj,AnnotationLayer:rl,AnnotationMode:m,AnnotationType:A,applyOpacity:tE,build:iL,ColorPicker:iB,createValidAbsoluteUrl:D,CSSConstants:t_,DOMSVGFactory:iz,DrawLayer:rI,FeatureTest:$,fetchData:tr,findContrastColor:tP,getDocument:iE,getFilenameFromUrl:tl,getPdfFilenameFromUrl:th,getRGB:tm,getUuid:K,getXfaPageViewport:tf,GlobalWorkerOptions:e2,ImageKind:x,InvalidPDFException:N,isDataScheme:ta,isPdfFile:to,isValidExplicitDest:t0,MathClamp:J,noContextMenu:tu,normalizeUnicode:X,OPS:E,OutputScale:tw,PasswordResponses:S,PDFDataRangeTransport:iC,PDFDateString:tg,PDFWorker:iM,PermissionFlag:w,PixelsPerInch:ti,RenderingCancelledException:tn,renderRichText:tD,ResponseException:O,setLayerDimensions:tv,shadow:R,SignatureExtractor:rC,stopEvent:tp,SupportedImageMimeTypes:tx,TextLayer:i_,TouchManager:t$,updateUrlHash:I,Util:V,VerbosityLevel:_,version:iR,XfaLayer:tt},t.s(["AbortException",0,j,"AnnotationEditorLayer",0,rD,"AnnotationEditorParamsType",0,v,"AnnotationEditorType",0,y,"AnnotationEditorUIManager",0,tj,"AnnotationLayer",0,rl,"AnnotationMode",0,m,"AnnotationType",0,A,"CSSConstants",0,t_,"ColorPicker",0,iB,"DOMSVGFactory",0,iz,"DrawLayer",0,rI,"FeatureTest",0,$,"GlobalWorkerOptions",0,e2,"ImageKind",0,x,"InvalidPDFException",0,N,"MathClamp",0,J,"OPS",0,E,"OutputScale",0,tw,"PDFDataRangeTransport",0,iC,"PDFDateString",0,tg,"PDFWorker",0,iM,"PasswordResponses",0,S,"PermissionFlag",0,w,"PixelsPerInch",0,ti,"RenderingCancelledException",0,tn,"ResponseException",0,O,"SignatureExtractor",0,rC,"SupportedImageMimeTypes",0,tx,"TextLayer",0,i_,"TouchManager",0,t$,"Util",0,V,"VerbosityLevel",0,_,"XfaLayer",0,tt,"applyOpacity",0,tE,"build",0,iL,"createValidAbsoluteUrl",0,D,"fetchData",0,tr,"findContrastColor",0,tP,"getDocument",0,iE,"getFilenameFromUrl",0,tl,"getPdfFilenameFromUrl",0,th,"getRGB",0,tm,"getUuid",0,K,"getXfaPageViewport",0,tf,"isDataScheme",0,ta,"isPdfFile",0,to,"isValidExplicitDest",0,t0,"noContextMenu",0,tu,"normalizeUnicode",0,X,"renderRichText",0,tD,"setLayerDimensions",0,tv,"shadow",0,R,"stopEvent",0,tp,"updateUrlHash",0,I,"version",0,iR],18657);var rR=t.i(18657);function rL(t,e){if(!t)throw Error("Invariant failed")}var rB=t.i(42656);let rF=(0,i.createContext)(null);class rN{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(t){this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setExternalLinkRel(t){this.externalLinkRel=t}setExternalLinkTarget(t){this.externalLinkTarget=t}setHash(){}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return rL(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber||0}set page(t){rL(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}addLinkAttributes(t,e,i){t.href=e,t.rel=this.externalLinkRel||"noopener noreferrer nofollow",t.target=i?"_blank":this.externalLinkTarget||""}goToDestination(t){return new Promise(e=>{rL(this.pdfDocument,"PDF document not loaded."),rL(t,"Destination is not specified."),"string"==typeof t?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(t=>{rL(Array.isArray(t),`"${t}" is not a valid destination array.`);let e=t[0];new Promise(t=>{rL(this.pdfDocument,"PDF document not loaded."),e instanceof Object?this.pdfDocument.getPageIndex(e).then(e=>{t(e)}).catch(()=>{rL(!1,`"${e}" is not a valid page reference.`)}):"number"==typeof e?t(e):rL(!1,`"${e}" is not a valid destination reference.`)}).then(e=>{let i=e+1;rL(this.pdfViewer,"PDF viewer is not initialized."),rL(i>=1&&i<=this.pagesCount,`"${i}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({dest:t,pageIndex:e,pageNumber:i})})})}goToPage(t){rL(this.pdfViewer,"PDF viewer is not initialized."),rL(t>=1&&t<=this.pagesCount,`"${t}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({pageIndex:t-1,pageNumber:t})}goToXY(){}cachePageRef(){}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}executeNamedAction(){}executeSetOCGState(){}isPageVisible(){return!0}isPageCached(){return!0}navigateTo(t){this.goToDestination(t)}}function rO({children:t,type:i}){return(0,e.jsx)("div",{className:`react-pdf__message react-pdf__message--${i}`,children:t})}function rU(t,e){switch(e.type){case"RESOLVE":return{value:e.value,error:void 0};case"REJECT":return{value:!1,error:e.error};case"RESET":return{value:void 0,error:void 0};default:return t}}function rj(){return(0,i.useReducer)(rU,{value:void 0,error:void 0})}let rz="u">typeof window,rH=rz&&"file:"===window.location.protocol;function r$(t){return null!=t}function rG(t){return"string"==typeof t&&/^data:/.test(t)}function rV(t){rL(rG(t),"Invalid data URI.");let[e="",i=""]=t.split(",");return -1!==e.split(";").indexOf("base64")?atob(i):unescape(i)}function rW(){(0,rB.default)(!rH,"Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.")}function rq(t){(null==t?void 0:t.cancel)&&t.cancel()}function rX(t,e){return Object.defineProperty(t,"width",{get(){return this.getViewport({scale:e}).width},configurable:!0}),Object.defineProperty(t,"height",{get(){return this.getViewport({scale:e}).height},configurable:!0}),Object.defineProperty(t,"originalWidth",{get(){return this.getViewport({scale:1}).width},configurable:!0}),Object.defineProperty(t,"originalHeight",{get(){return this.getViewport({scale:1}).height},configurable:!0}),t}function rK(t){return"AbortException"===t.name||"RenderingCancelledException"===t.name}let{PDFDataRangeTransport:rY}=rR,rJ=(t,e)=>{switch(e){case 1:t(prompt("Enter the password to open this PDF file."));break;case 2:t(prompt("Invalid password. Please try again."))}};function rQ(t){return"object"==typeof t&&null!==t&&("data"in t||"range"in t||"url"in t)}let rZ=(0,i.forwardRef)(function({children:t,className:s,error:n="Failed to load PDF file.",externalLinkRel:l,externalLinkTarget:d,file:c,inputRef:u,imageResourcesPath:p,loading:g="Loading PDFâ¦",noData:f="No PDF file specified.",onItemClick:m,onLoadError:b,onLoadProgress:y,onLoadSuccess:v,onPassword:w=rJ,onSourceError:x,onSourceSuccess:A,options:_,renderMode:E,rotate:S,scale:C,...T},k){let[M,P]=rj(),{value:D,error:I}=M,[R,L]=rj(),{value:B,error:F}=R,N=(0,i.useRef)(new rN),O=(0,i.useRef)([]),U=(0,i.useRef)(void 0),j=(0,i.useRef)(void 0);c&&c!==U.current&&rQ(c)&&((0,rB.default)(!a(c,U.current),'File prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.'),U.current=c),_&&_!==j.current&&((0,rB.default)(!a(_,j.current),'Options prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.'),j.current=_);let z=(0,i.useRef)({scrollPageIntoView:t=>{let{dest:e,pageNumber:i,pageIndex:r=i-1}=t;if(m)return void m({dest:e,pageIndex:r,pageNumber:i});let s=O.current[r];s?s.scrollIntoView():(0,rB.default)(!1,`An internal link leading to page ${i} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document>
2 and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});(0,i.useImperativeHandle)(k,()=>({linkService:N,pages:O,viewer:z}),[]),(0,i.useEffect)(function(){P({type:"RESET"})},[c,P]);let H=(0,i.useCallback)(async()=>{if(!c)return null;if("string"==typeof c)return rG(c)?{data:rV(c)}:(rW(),{url:c});if(c instanceof rY)return{range:c};if(c instanceof ArrayBuffer)return{data:c};if(rz&&(rL(rz,"isBlob can only be used in a browser environment"),c instanceof Blob))return{data:await new Promise((t,e)=>{let i=new FileReader;i.onload=()=>{if(!i.result)return e(Error("Error while reading a file."));t(i.result)},i.onerror=t=>{if(!t.target)return e(Error("Error while reading a file."));let{error:i}=t.target;if(!i)return e(Error("Error while reading a file."));switch(i.code){case i.NOT_FOUND_ERR:return e(Error("Error while reading a file: File not found."));case i.SECURITY_ERR:return e(Error("Error while reading a file: Security error."));case i.ABORT_ERR:return e(Error("Error while reading a file: Aborted."));default:return e(Error("Error while reading a file."))}},i.readAsArrayBuffer(c)})};if(rL("object"==typeof c,"Invalid parameter in file, need either Uint8Array, string or a parameter object"),rL(rQ(c),"Invalid parameter object: need either .data, .range or .url"),"url"in c&&"string"==typeof c.url){if(rG(c.url)){let{url:t,...e}=c;return{data:rV(t),...e}}rW()}return c},[c]);(0,i.useEffect)(()=>
2{let t=o(H());return t.promise.then(t=>{P({type:"RESOLVE",value:t})}).catch(t=>{P({type:"REJECT",error:t})}),()=>{rq(t)}},[H,P]),(0,i.useEffect)(()=>{if(void 0!==D){if(!1===D)return void(I&&((0,rB.default)(!1,I.toString()),x&&x(I)));A&&A()}},[D]),(0,i.useEffect)(function(){L({type:"RESET"})},[L,D]),(0,i.useEffect)(function(){if(!D)return;let t=_?{...D,..._}:D,e=rR.getDocument(t);return y&&(e.onProgress=y),w&&(e.onPassword=w),e.promise.then(t=>{e.destroyed||L({type:"RESOLVE",value:t})}).catch(t=>{e.destroyed||L({type:"REJECT",error:t})}),()=>{e.destroy()}},[_,L,D]),(0,i.useEffect)(()=>{if(void 0!==B){if(!1===B)return void(F&&((0,rB.default)(!1,F.toString()),b&&b(F)));B&&(v&&v(B),O.current=Array(B.numPages),N.current.setDocument(B))}},[B]),(0,i.useEffect)(function(){N.current.setViewer(z.current),N.current.setExternalLinkRel(l),N.current.setExternalLinkTarget(d)},[l,d]);let $=(0,i.useCallback)((t,e)=>{O.current[t]=e},[]),G=(0,i.useCallback)(t=>{delete O.current[t]},[]),V=(0,i.useMemo)(()=>({imageResourcesPath:p,linkService:N.current,onItemClick:m,pdf:B,registerPage:$,renderMode:E,rotate:S,scale:C,unregisterPage:G}),[p,m,B,$,E,S,C,G]),W=(0,i.useMemo)(()=>h(T,()=>B),[T,B]);return(0,e.jsx)("div",{className:r("react-pdf__Document",s),ref:u,...W,children:function(){if(!c)return(0,e.jsx)(rO,{type:"no-data",children:"function"==typeof f?f():f});if(null==B)return(0,e.jsx)(rO,{type:"loading",children:"function"==typeof g?g():g});if(!1===B)return(0,e.jsx)(rO,{type:"error",children:"function"==typeof n?n():n});if(!(null==V?void 0:V.pdf))throw Error("pdf is undefined");let i="function"==typeof t?t(V):t;return(0,e.jsx)(rF.Provider,{value:V,children:i})}()})});function r0(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t.filter(Boolean);return i.length<=1?i[0]||null:function(t){for(var e=0;e<i.length;e++){var r=i[e];"function"==typeof r?r(t):r&&(r.current=t)}}}function r1(){return(0,i.useContext)(rF)}let r2=(0,i.createContext)(null);function r3(){return(0,i.useContext)(r2)}function r5(){let t=r1(),s=r3();rL(s,"Unable to find Page context.");let{filterAnnotations:n,imageResourcesPath:a,linkService:l,onGetAnnotationsError:h,onGetAnnotationsSuccess:d,onRenderAnnotationLayerError:c,onRenderAnnotationLayerSuccess:u,page:p,pdf:g,renderForms:f,rotate:m,scale:b=1}={...t,...s};rL(g,"Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop."),rL(p,"Attempted to load page annotations, but no page was specified."),rL(l,"Attempted to load page annotations, but no linkService was specified.");let[y,v]=rj(),{value:w,error:x}=y,A=(0,i.useRef)(null);(0,rB.default)(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10),"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations"),(0,i.useEffect)(function(){v({type:"RESET"})},[v,p]),(0,i.useEffect)(function(){if(!p)return;let t=o(p.getAnnotations());return t.promise.then(t=>{v({type:"RESOLVE",value:t})}).catch(t=>{v({type:"REJECT",error:t})}),()=>{rq(t)}},[v,p]),(0,i.useEffect)(()=>{if(void 0!==w){if(!1===w)return void(x&&((0,rB.default)(!1,x.toString()),h&&h(x)));w&&d&&d(w)}},[w]);let _=(0,i.useMemo)(()=>p.getViewport({scale:b,rotation:m}),[p,m,b]);return(0,i.useEffect)(function(){if(!g||!p||!l||!w)return;let{current:t}=A;if(!t)return;let e=_.clone({dontFlip:!0}),i={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,annotationStorage:g.annotationStorage,commentManager:null,div:t,l10n:null,linkService:l,page:p,structTreeLayer:null,viewport:e},r={annotations:n?n({annotations:w}):w,annotationStorage:g.annotationStorage,div:t,imageResourcesPath:a,linkService:l,page:p,renderForms:f,viewport:e};t.innerHTML="";try{new rl(i).render(r),u&&u()}catch(t){(0,rB.default)(!1,`${t}`),c&&c(t)}return()=>{}},[w,n,a,l,p,g,f,_]),(0,e.jsx)("div",{className:r("react-pdf__Page__annotations","annotationLayer"),ref:A})}let r6={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P
2:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},r4=/^H(\d+)$/;function r8(t){return"children"in t}function r7(t){return!!r8(t)&&1===t.children.length&&0 in t.children&&"id"in t.children[0]}function r9({className:t,node:r}){let s=(0,i.useMemo)(()=>r?{...function(t){let e={};if(r8(t)){let{role:i}=t,r=i.match(r4);if(r)e.role="heading",e["aria-level"]=Number(r[1]);else if(i in r6){let t=r6[i];t&&(e.role=t)}}return e}(r),...function t(e){let i={};if(r8(e)){if(void 0!==e.alt&&(i["aria-label"]=e.alt),void 0!==e.lang&&(i.lang=e.lang),r7(e)){let[r]=e.children;if(r){let e=t(r);return{...i,...e}}}}else"id"in e&&(i["aria-owns"]=e.id);return i}(r)}:null,[r]),n=(0,i.useMemo)(()=>!r8(r)||r7(r)?null:r.children.map((t,i)=>(0,e.jsx)(r9,{node:t},i)),[r]);return(0,e.jsx)("span",{className:t,...s,children:n})}function st(){let t=r3();rL(t,"Unable to find Page context.");let{onGetStructTreeError:r,onGetStructTreeSuccess:s}=t,[n,a]=rj(),{value:l,error:h}=n,{customTextRenderer:d,page:c}=t;return((0,i.useEffect)(function(){a({type:"RESET"})},[a,c]),(0,i.useEffect)(function(){if(d||!c)return;let t=o(c.getStructTree());return t.promise.then(t=>{a({type:"RESOLVE",value:t})}).catch(t=>{a({type:"REJECT",error:t})}),()=>rq(t)},[d,c,a]),(0,i.useEffect)(()=>{if(void 0!==l){if(!1===l)return void(h&&((0,rB.default)(!1,h.toString()),r&&r(h)));l&&s&&s(l)}},[l]),l)?(0,e.jsx)(r9,{className:"react-pdf__Page__structTree structTree",node:l}):null}function se(t){let r=r3();rL(r,"Unable to find Page context.");let{_className:s,canvasBackground:n,devicePixelRatio:a=rz&&window.devicePixelRatio||1,onRenderError:o,onRenderSuccess:l,page:h,renderForms:d,renderTextLayer:c,pageColors:u,rotate:p,scale:g}={...r,...t},{canvasRef:f}=t;rL(h,"Attempted to render page canvas, but no page was specified.");let b=(0,i.useRef)(null);function y(t){!rK(t)&&((0,rB.default)(!1,t.toString()),o&&o(t))}let v=(0,i.useMemo)(()=>h.getViewport({scale:g*a,rotation:p}),[a,h,p,g]),w=(0,i.useMemo)(()=>h.getViewport({scale:g,rotation:p}),[h,p,g]);(0,i.useEffect)(function(){if(!h)return;h.cleanup();let{current:t}=b;if(!t)return;t.width=v.width,t.height=v.height,t.style.width=`${Math.floor(w.width)}px`,t.style.height=`${Math.floor(w.height)}px`,t.style.visibility="hidden";let e={annotationMode:d?m.ENABLE_FORMS:m.ENABLE,canvas:t,canvasContext:t.getContext("2d",{alpha:!1}),pageColors:u,viewport:v};n&&(e.background=n);let i=h.render(e);return i.promise.then(()=>{t.style.visibility="",h&&l&&l(rX(h,g))}).catch(y),()=>rq(i)},[n,h,u,d,v,w]);let x=(0,i.useCallback)(()=>{let{current:t}=b;t&&(t.width=0,t.height=0)},[]);return(0,i.useEffect)(()=>x,[x]),(0,e.jsx)("canvas",{className:`${s}__canvas`,dir:"ltr",ref:r0(f,b),style:{display:"block",userSelect:"none"},children:c?(0,e.jsx)(st,{}):null})}let si=new Set(["base","embed","iframe","link","meta","object","script","style","template"]),sr=new Set(["action","formaction","href","poster","src","xlink:href"]);function ss(t){return t.nodeType===Node.ELEMENT_NODE&&t instanceof HTMLElement}function sn(){let t=r3();rL(t,"Unable to find Page context.");let{customTextRenderer:s,onGetTextError:n,onGetTextSuccess:a,onRenderTextLayerError:l,onRenderTextLayerSuccess:h,page:d,pageIndex:c,pageNumber:u,rotate:p,scale:g}=t;rL(d,"Attempted to load page text content, but no page was specified.");let[f,m]=rj(),{value:b,error:y}=f,v=(0,i.useRef)(null);(0,rB.default)(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10),"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer"),(0,i.useEffect)(function(){m({type:"RESET"})},[d,m]),(0,i.useEffect)(function(){if(!d)return;let t=o(d.getTextContent());return t.promise.then(t=>{m({type:"RESOLVE",value:t})}).catch(t=>{m({type:"REJECT",error:t})}),()=>rq(t)},[d,m]),(0,i.useEffect)(()=>
2{if(void 0!==b){if(!1===b)return void(y&&((0,rB.default)(!1,y.toString()),n&&n(y)));b&&a&&a(b)}},[b]);let w=(0,i.useCallback)(()=>{h&&h()},[h]),x=(0,i.useCallback)(t=>{!rK(t)&&((0,rB.default)(!1,t.toString()),l&&l(t))},[l]),A=(0,i.useMemo)(()=>d.getViewport({scale:g,rotation:p}),[d,p,g]);return(0,i.useLayoutEffect)(function(){if(!d||!b)return;let{current:t}=v;if(!t)return;t.innerHTML="";let e=new i_({container:t,textContentSource:d.streamTextContent({includeMarkedContent:!0}),viewport:A});return e.render().then(()=>{let e=document.createElement("div");e.className="endOfContent",t.append(e);let i=t.querySelectorAll('[role="presentation"]');if(s){let t=0;b.items.forEach((e,r)=>{let n,a;if(!("str"in e))return;let o=i[t];if(!o)return;let l=s({pageIndex:c,pageNumber:u,itemIndex:r,...e});(n=document.createElement("template")).innerHTML=l,a=document.createDocumentFragment(),Array.from(n.content.childNodes).forEach(t=>{a.append(function t(e){var i;if(ss(e)&&!(ss(e)&&si.has(e.tagName.toLowerCase()))){let i;return i=document.createElement(e.tagName.toLowerCase()),Array.from(e.attributes).forEach(t=>{let e=t.name.toLowerCase();e.startsWith("on")||"srcdoc"===e||sr.has(e)&&function(t){let e="";for(let i of t){let t=i.charCodeAt(0);t<=32||127===t||(e+=i.toLowerCase())}return e.startsWith("javascript:")||e.startsWith("vbscript:")}(t.value)||i.setAttribute(t.name,t.value)}),Array.from(e.childNodes).forEach(e=>{i.append(t(e))}),i}return document.createTextNode(null!=(i=e.textContent)?i:"")}(t))}),o.replaceChildren(a),t+=e.str&&e.hasEOL?2:1})}w()}).catch(x),()=>rq(e)},[s,x,w,d,c,u,b,A]),(0,e.jsx)("div",{className:r("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){let t=v.current;t&&t.classList.remove("selecting")},onMouseDown:function(){let t=v.current;t&&t.classList.add("selecting")},ref:v})}function sa(t){let{_className:s="react-pdf__Page",_enableRegisterUnregisterPage:n=!0,canvasBackground:a,canvasRef:l,children:d,className:c,customRenderer:u,customTextRenderer:p,devicePixelRatio:g,error:f="Failed to load the page.",filterAnnotations:m,height:b,inputRef:y,loading:v="Loading pageâ¦",noData:w="No page specified.",onGetAnnotationsError:x,onGetAnnotationsSuccess:A,onGetStructTreeError:_,onGetStructTreeSuccess:E,onGetTextError:S,onGetTextSuccess:C,onLoadError:T,onLoadSuccess:k,onRenderAnnotationLayerError:M,onRenderAnnotationLayerSuccess:P,onRenderError:D,onRenderSuccess:I,onRenderTextLayerError:R,onRenderTextLayerSuccess:L,pageColors:B,pageIndex:F,pageNumber:N,pdf:O,registerPage:U,renderAnnotationLayer:j=!0,renderForms:z=!1,renderMode:H="canvas",renderTextLayer:$=!0,rotate:G,scale:V=1,unregisterPage:W,width:q,...X}={...r1(),...t},[K,Y]=rj(),{value:J,error:Q}=K,Z=(0,i.useRef)(null);rL(O,"Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.");let tt=r$(N)?N-1:null!=F?F:null,te=null!=N?N:r$(F)?F+1:null,ti=null!=G?G:J?J.rotate:null,tr=(0,i.useMemo)(()=>{if(!J)return null;let t=1,e=null!=V?V:1;if(q||b){let e=J.getViewport({scale:1,rotation:ti});q?t=q/e.width:b&&(t=b/e.height)}return e*t},[b,J,ti,V,q]);(0,i.useEffect)(function(){return()=>{r$(tt)&&n&&W&&W(tt)}},[n,O,tt,W]),(0,i.useEffect)(function(){Y({type:"RESET"})},[Y,O,tt]),(0,i.useEffect)(function(){if(!O||!te)return;let t=o(O.getPage(te));return t.promise.then(t=>{Y({type:"RESOLVE",value:t})}).catch(t=>{Y({type:"REJECT",error:t})}),()=>rq(t)},[Y,O,te]),(0,i.useEffect)(()=>{if(void 0!==J){if(!1===J)return void(Q&&((0,rB.default)(!1,Q.toString()),T&&T(Q)));!function(){if(k){if(!J||!tr)return;k(rX(J,tr))}if(n&&U){if(!r$(tt)||!Z.current)return;U(tt,Z.current)}}()}},[J,tr]);let ts=(0,i.useMemo)(()=>r$(tt)&&te&&r$(ti)&&r$(tr)?{_className:s,canvasBackground:a,customTextRenderer:p,devicePixelRatio:g,filterAnnotations:m,onGetAnnotationsError:x,onGetAnnotationsSuccess:A,onGetStructTreeError:_,onGetStructTreeSuccess:E,onGetTextError:S,onGetTextSuccess:C,onRenderAnnotationLayerError:M,onRenderAnnotationLayerSuccess:P,onRenderError:D,onRenderSuccess:I,onRenderTextLayerError:R,onRenderTextLayerSuccess:L,page:J,pageColors:B,pageIndex:tt,pageNumber:te,renderForms:z,renderTextLayer:$,rotate:ti,scale:tr}:null,[s,a,p,g,m,x,A,_,E,S,C,M,P,D,I,R,L,J,B,tt,te,z,$,ti,tr]),tn=(0,i.useMemo)(()=>h(X,()=>J?tr?rX(J,tr):void 0:J),[X,J,tr]),ta=`${tt}@${tr}/${ti}`;return(0,e.jsx)("div",{className:r(s,c),"data-page-number":te,ref:r0(y,Z),style:{"--scale-round-x":"1px","--scale-round-y":"1px","--scale-factor":"1","--user-unit":`${tr}`,"--total-scale-factor":"calc(var(--scale-factor) * var(--user-unit))",backgroundColor:a||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"},...tn,children:function(){if(!te)return(0,e.jsx)(rO,{type:"no-data",children:"function"==typeof w?w():w});if(null===O||null==J)return(0,e.jsx)(rO,{type:"loading",children:"function"==typeof v?v():v});if(!1===O||!1===J)return(0,e.jsx)(rO,{type:"error",children:"function"==typeof f?f():f});if(!(null==ts?void 0:ts.page))throw Error("page is undefined");let t="function"==typeof d?d(ts):d;return(0,e.jsxs)(r2.Provider,{value:ts,children:[function(){switch(H){case"custom"
2:return rL(u,'renderMode was set to "custom", but no customRenderer was passed.'),(0,e.jsx)(u,{},`${ta}_custom`);case"none":return null;default:return(0,e.jsx)(se,{canvasRef:l},`${ta}_canvas`)}}(),$?(0,e.jsx)(sn,{},`${ta}_text`):null,j?(0,e.jsx)(r5,{},`${ta}_annotations`):null,t]})}()})}var so=t.i(56420);let sl=(0,so.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),sh=(0,so.default)("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),sd=(0,so.default)("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),sc=(0,so.default)("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),su=(0,so.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),sp=(0,so.default)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);var sg=t.i(32781);let sf=(0,so.default)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]),sm=(0,so.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);rR.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${rR.version}/build/pdf.worker.min.mjs`;let sb=[{label:"Abstract",page:1},{label:"Contents",page:2},{label:"Background",page:5},{label:"Section I",page:20},{label:"Section II",page:84},{label:"Section III",page:95}];t.s(["default",0,function({fileUrl:t,fileName:r,isDark:s}){let[n,a]=(0,i.useState)(0),[o,l]=(0,i.useState)(1),[h,d]=(0,i.useState)(1),[c,u]=(0,i.useState)(!0),[p,g]=(0,i.useState)(null),[f,m]=(0,i.useState)(0),[b,y]=(0,i.useState)(!1),[v,w]=(0,i.useState)(""),[x,A]=(0,i.useState)(!1),[_,E]=(0,i.useState)(0),S=(0,i.useRef)(null),C=(0,i.useRef)(null),T=(0,i.useRef)(o),k=(0,i.useRef)(0);(0,i.useEffect)(()=>{T.current=o},[o]),(0,i.useEffect)(()=>(document.body.style.overflow=x?"hidden":"",()=>{document.body.style.overflow=""}),[x]),(0,i.useEffect)(()=>{function t(){S.current&&m(S.current.clientWidth)}return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),(0,i.useEffect)(()=>{function t(t){x||b||("ArrowLeft"===t.key||"ArrowUp"===t.key?(t.preventDefault(),l(t=>Math.max(t-1,1))):("ArrowRight"===t.key||"ArrowDown"===t.key)&&(t.preventDefault(),l(t=>Math.min(t+1,n))))}let e=C.current;return e?.addEventListener("keydown",t),()=>e?.removeEventListener("keydown",t)},[n,b,x]),(0,i.useEffect)(()=>{function t(t){"Escape"===t.key&&x&&A(!1)}return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[x]),(0,i.useEffect)(()=>{E(0)},[h]);let M=f>0?Math.min(f-32,x?900:800)*h:void 0,P=_>0?_:M?1.294*M:900;(0,i.useEffect)(()=>{k.current=P},[P]);let D=Math.max(0,o-1-5),I=Math.min(n-1,o-1+5),R=D*(P+16),L=Math.max(0,n-1-I)*(P+16),B=(0,i.useCallback)(()=>{x&&S.current&&l(Math.min(n,Math.max(1,Math.floor(S.current.scrollTop/(k.current+16))+1)))},[x,n]),F=(0,i.useCallback)(t=>{let e=Math.max(1,Math.min(t,n));l(e),x&&S.current&&S.current.scrollTo({top:(e-1)*(k.current+16),behavior:"smooth"})},[x,n]),N=(0,i.useCallback)(()=>F(o-1),[F,o]),O=(0,i.useCallback)(()=>F(o+1),[F,o]),U=(0,i.useCallback)(()=>d(t=>Math.min(t+.25,3)),[]),j=(0,i.useCallback)(()=>d(t=>Math.max(t-.25,.5)),[]),z=(0,i.useCallback)(()=>d(1),[]),H=(0,i.useRef)(F);(0,i.useEffect)(()=>{H.current=F},[F]);let $=(0,i.useCallback)(({pageIndex:t,pageNumber:e})=>{H.current(e??t+1)},[]),G=(0,i.useCallback)(({numPages:t})=>{a(t),u(!1)},[]),V=(0,i.useCallback)(t=>{g(t.message),u(!1)},[]),W=(0,i.useCallback)(()=>{let t=parseInt(v,10);isNaN(t)||F(t),y(!1),w("")},[v,F]),q=(0,i.useCallback)(t=>E(t.height),[]);(0,i.useEffect)(()=>{x&&S.current&&S.current.scrollTo({top:(T.current-1)*(k.current+16),behavior:"instant"})},[x]);let X=(0,i.useCallback)(()=>A(t=>
2!t),[]),K="p-1.5 sm:p-2 rounded-lg bg-polkadot-grey-200 dark:bg-polkadot-grey-800 hover:bg-polkadot-grey-300 dark:hover:bg-polkadot-grey-700 active:bg-polkadot-grey-300 dark:active:bg-polkadot-grey-600 text-polkadot-grey-700 dark:text-polkadot-grey-200 hover:text-polkadot-grey-950 dark:hover:text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed",Y=o>=95?5:o>=84?4:o>=10?3:o>=4?2:+(o>=2),J=(0,e.jsxs)("div",{className:`flex flex-wrap items-center justify-between gap-2 sm:gap-3 px-3 py-2.5 bg-polkadot-grey-100/95 dark:bg-polkadot-grey-900/95 backdrop-blur-md border-b border-b-polkadot-grey-200 dark:border-b-polkadot-grey-800/60 ${x?"border-x-0 rounded-none border border-polkadot-grey-300 dark:border-polkadot-grey-700/30":"sticky top-14 sm:top-16 z-40 rounded-t-xl border border-polkadot-grey-300 dark:border-polkadot-grey-700/30"}`,children:[(0,e.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,e.jsx)("button",{onClick:N,disabled:o<=1,className:K,"aria-label":"Previous page",children:(0,e.jsx)(sl,{className:"w-4 h-4"})}),b?(0,e.jsx)("input",{type:"number",min:1,max:n,value:v,onChange:t=>w(t.target.value),onBlur:W,onKeyDown:t=>{"Enter"===t.key&&W(),"Escape"===t.key&&(y(!1),w(""))},autoFocus:!0,className:"w-12 sm:w-14 h-8 text-center text-xs sm:text-sm font-medium rounded-lg border border-polkadot-grey-400 dark:border-polkadot-grey-600 bg-white dark:bg-polkadot-grey-800 text-polkadot-grey-900 dark:text-polkadot-grey-100 outline-none"}):(0,e.jsx)("button",{onClick:()=>{w(String(o)),y(!0)},className:"text-xs sm:text-sm font-medium text-polkadot-grey-700 dark:text-polkadot-grey-200 min-w-[64px] sm:min-w-[80px] text-center hover:bg-polkadot-grey-200 dark:hover:bg-polkadot-grey-800 hover:text-polkadot-grey-950 dark:hover:text-white active:bg-polkadot-grey-200 dark:active:bg-polkadot-grey-700 rounded-lg px-2 py-1 transition-colors cursor-text",title:"Click to jump to page",children:c?"...":`${o} / ${n}`}),(0,e.jsx)("button",{onClick:O,disabled:o>=n,className:K,"aria-label":"Next page",children:(0,e.jsx)(sh,{className:"w-4 h-4"})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,e.jsx)("button",{onClick:j,disabled:h<=.5,className:K,"aria-label":"Zoom out",children:(0,e.jsx)(sc,{className:"w-4 h-4"})}),(0,e.jsxs)("span",{className:"text-xs sm:text-sm font-medium text-polkadot-grey-700 dark:text-polkadot-grey-300 min-w-[40px] sm:min-w-[48px] text-center",children:[Math.round(100*h),"%"]}),(0,e.jsx)("button",{onClick:U,disabled:h>=3,className:K,"aria-label":"Zoom in",children:(0,e.jsx)(sd,{className:"w-4 h-4"})}),(0,e.jsx)("button",{onClick:z,className:K,"aria-label":"Reset zoom",children:(0,e.jsx)(su,{className:"w-4 h-4"})})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[(0,e.jsx)("button",{onClick:X,className:`${K} flex items-center gap-1.5 px-2.5 sm:px-3 text-xs font-semibold`,title:x?"Minimize viewer":"Full page view","aria-label":x?"Minimize":"Full page",children:x?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(sf,{className:"w-4 h-4"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:"Minimize"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(sm,{className:"w-4 h-4"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:"Full Page"})]})}),(0,e.jsxs)("a",{href:t,download:r,className:"inline-flex items-center gap-1.5 sm:gap-2 h-8 sm:h-9 px-3 sm:px-4 text-xs sm:text-sm font-medium rounded-md bg-polkadot-grey-950 dark:bg-polkadot-grey-700 hover:bg-polkadot-grey-800 dark:hover:bg-polkadot-grey-600 active:bg-polkadot-grey-700 dark:active:bg-polkadot-grey-500 text-polkadot-grey-50 transition-colors","aria-label":"Download PDF",children:[(0,e.jsx)(sp,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"}),(0,e.jsx)("span",{className:"hidden sm:inline",children:"Download"})]})]})]}),Q=(0,e.jsx)("div",{className:"overflow-x-auto border-x border-polkadot-grey-300 dark:border-polkadot-grey-700/30 bg-polkadot-grey-100/95 dark:bg-polkadot-grey-900/95 backdrop-blur-md border-b border-b-polkadot-grey-200 dark:border-b-polkadot-grey-800/40",children:(0,e.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-2 min-w-max",children:[(0,e.jsx)("span",{className:"text-xs font-medium text-polkadot-grey-400 dark:text-polkadot-grey-600 mr-1 whitespace-nowrap shrink-0",children:"Jump to:"}),sb.map((t,i)=>(0,e.jsx)("button",{onClick:()=>
2F(t.page),disabled:c,className:`px-2.5 sm:px-3 py-1 rounded-full text-xs font-semibold whitespace-nowrap transition-all duration-150 ${Y===i?"bg-polkadot-grey-950 dark:bg-polkadot-grey-100 text-polkadot-grey-50 dark:text-polkadot-grey-950 scale-105 shadow-md ring-1 ring-polkadot-grey-700/20 dark:ring-polkadot-grey-200/30":"bg-polkadot-grey-200 dark:bg-polkadot-grey-800 text-polkadot-grey-600 dark:text-polkadot-grey-300 hover:bg-polkadot-grey-300 dark:hover:bg-polkadot-grey-700 hover:text-polkadot-grey-950 dark:hover:text-white hover:scale-105"} disabled:opacity-40 disabled:cursor-not-allowed`,children:t.label},t.label))]})}),Z=(0,e.jsx)(rZ,{file:t,onLoadSuccess:G,onLoadError:V,onItemClick:$,externalLinkTarget:"_blank",externalLinkRel:"noopener noreferrer",loading:(0,e.jsx)("div",{className:"flex items-center justify-center h-96",children:(0,e.jsx)(sg.Loader2,{className:"w-8 h-8 animate-spin text-polkadot-grey-500"})}),children:x?(0,e.jsxs)("div",{className:"flex flex-col",children:[R>0&&(0,e.jsx)("div",{style:{height:R},"aria-hidden":!0}),Array.from({length:I-D+1},(t,i)=>{let r=D+i+1;return(0,e.jsx)("div",{style:{marginBottom:16},className:"shadow-2xl rounded-sm",children:(0,e.jsx)(sa,{pageNumber:r,width:M,onRenderSuccess:1===r?q:void 0,loading:(0,e.jsx)("div",{className:"flex items-center justify-center bg-white dark:bg-polkadot-grey-900 rounded-sm",style:{width:M??600,height:Math.round(P)},children:(0,e.jsx)(sg.Loader2,{className:"w-6 h-6 animate-spin text-polkadot-grey-400"})})})},r)}),L>0&&(0,e.jsx)("div",{style:{height:L},"aria-hidden":!0})]}):(0,e.jsx)("div",{className:"shadow-2xl rounded-sm",children:(0,e.jsx)(sa,{pageNumber:o,width:M,loading:(0,e.jsx)("div",{className:"flex items-center justify-center h-96",children:(0,e.jsx)(sg.Loader2,{className:"w-8 h-8 animate-spin text-polkadot-grey-500"})})})})});return x?(0,e.jsxs)("div",{className:"fixed inset-0 z-[60] flex flex-col outline-none",children:[J,Q,(0,e.jsx)("div",{ref:S,onScroll:B,className:`flex-1 overflow-auto flex justify-center p-3 sm:p-6 backdrop-blur-sm ${s?"bg-polkadot-grey-950/75":"bg-polkadot-grey-100/75"}`,children:p?(0,e.jsx)("div",{className:"flex items-center justify-center text-polkadot-grey-600 dark:text-polkadot-grey-400 px-4 text-center",children:(0,e.jsxs)("p",{children:["Failed to load PDF: ",p]})}):Z}),(0,e.jsxs)("p",{className:`text-xs text-center py-2 flex-none backdrop-blur-md ${s?"text-polkadot-grey-400 bg-polkadot-grey-950/80":"text-polkadot-grey-500 bg-polkadot-grey-50/80"}`,children:["Scroll to read · Click page number to jump · ",(0,e.jsx)("kbd",{className:"font-mono",children:"Esc"})," to minimize"]})]}):(0,e.jsxs)("div",{ref:C,tabIndex:0,className:"flex flex-col gap-0 outline-none",children:[J,Q,(0,e.jsx)("div",{ref:S,className:`overflow-auto rounded-b-xl border border-t-0 border-polkadot-grey-300 dark:border-polkadot-grey-700/30 flex justify-center items-center min-h-[400px] sm:min-h-[500px] p-3 sm:p-4 ${s?"bg-polkadot-grey-800":"bg-polkadot-grey-200"}`,children:p?(0,e.jsx)("div",{className:"flex items-center justify-center h-96 text-polkadot-grey-600 dark:text-polkadot-grey-400 px-4 text-center",children:(0,e.jsxs)("p",{children:["Failed to load PDF: ",p]})}):Z}),(0,e.jsx)("p",{className:"text-xs text-polkadot-grey-400 dark:text-polkadot-grey-600 text-center mt-2",children:"Use arrow keys to navigate · Click page number to jump"})]})}],89411)},859,t=>{t.n(t.i(89411))}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.