ngx-extended-pdf-viewer
Version:
Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.
37 lines • 1.49 MB
JavaScript
/**
* @licstart The following is the entire license notice for the
* JavaScript code in this page
*
* Copyright 2024 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @licend The above is the entire license notice for the
* JavaScript code in this page
*/
/**
* pdfjsVersion = 6.0.1161
* pdfjsBuild = 2d346053b
*/var e={9306(e,t,i){var a=i(4901),s=i(6823),r=TypeError;e.exports=function(e){if(a(e))return e;throw new r(s(e)+" is not a function")}},3506(e,t,i){var a=i(3925),s=String,r=TypeError;e.exports=function(e){if(a(e))return e;throw new r("Can't set "+s(e)+" as a prototype")}},7080(e,t,i){var a=i(4402).has;e.exports=function(e){a(e);return e}},3463(e){var t=TypeError;e.exports=function(e){if("string"==typeof e)return e;throw new t("Argument is not a string")}},4328(e,t,i){var a=i(4995),s=new a.WeakMap,r=a.set,n=a.remove;e.exports=function(e){r(s,e,1);n(s,e);return e}},6557(e,t,i){var a=i(4995).has;e.exports=function(e){a(e);return e}},6469(e,t,i){var a=i(8227),s=i(2360),r=i(4913).f,n=a("unscopables"),o=Array.prototype;void 0===o[n]&&r(o,n,{configurable:!0,value:s(null)});e.exports=function(e){o[n][e]=!0}},679(e,t,i){var a=i(1625),s=TypeError;e.exports=function(e,t){if(a(t,e))return e;throw new s("Incorrect invocation")}},3972(e,t,i){var a=i(34),s=String,r=TypeError;e.exports=function(e){if(void 0===e||a(e))return e;throw new r(s(e)+" is not an object or undefined")}},8551(e,t,i){var a=i(34),s=String,r=TypeError;e.exports=function(e){if(a(e))return e;throw new r(s(e)+" is not an object")}},4154(e,t,i){var a=i(6955),s=TypeError;e.exports=function(e){if("Uint8Array"===a(e))return e;throw new s("Argument is not an Uint8Array")}},7811(e){e.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},7394(e,t,i){var a=i(4576),s=i(6706),r=i(2195),n=a.ArrayBuffer,o=a.TypeError;e.exports=n&&s(n.prototype,"byteLength","get")||function(e){if("ArrayBuffer"!==r(e))throw new o("ArrayBuffer expected");return e.byteLength}},3238(e,t,i){var a=i(4576),s=i(7811),r=i(7394),n=a.DataView;e.exports=function(e){if(!s||0!==r(e))return!1;try{new n(e);return!1}catch(e){return!0}}},5169(e,t,i){var a=i(3238),s=TypeError;e.exports=function(e){if(a(e))throw new s("ArrayBuffer is detached");return e}},5636(e,t,i){var a=i(4576),s=i(9504),r=i(6706),n=i(7696),o=i(5169),l=i(7394),c=i(4483),d=i(1548),h=a.structuredClone,u=a.ArrayBuffer,_=a.DataView,p=Math.max,g=Math.min,f=u.prototype,m=_.prototype,v=s(f.slice),y=r(f,"resizable","get"),P=r(f,"maxByteLength","get"),w=s(m.getInt8),b=s(m.setInt8);e.exports=(d||c)&&function(e,t,i){var a,s=l(e),r=void 0===t?s:n(t),f=!y||!y(e);o(e);if(d){e=h(e,{transfer:[e]});if(s===r&&(i||f))return e}if(s>=r&&(!i||f))a=v(e,0,r);else{var m=i&&!f&&P?{maxByteLength:p(r,P(e))}:void 0;a=new u(r,m);for(var S=new _(e),C=new _(a),A=g(r,s),x=0;x<A;x++)b(C,x,w(S,x))}d||c(e);return a}},4644(e,t,i){var a,s,r,n=i(7811),o=i(3724),l=i(4576),c=i(4901),d=i(34),h=i(9297),u=i(6955),_=i(6823),p=i(6699),g=i(6840),f=i(2106),m=i(1625),v=i(2787),y=i(2967),P=i(8227),w=i(3392),b=i(1181),S=b.enforce,C=b.get,A=l.Int8Array,x=A&&A.prototype,k=l.Uint8ClampedArray,E=k&&k.prototype,T=A&&v(A),I=x&&v(x),G=Object.prototype,B=l.TypeError,M=P("toStringTag"),D=w("TYPED_ARRAY_TAG"),L="TypedArrayConstructor",O=n&&!!y&&"Opera"!==u(l.opera),R=!1,N={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},j={BigInt64Array:8,BigUint64Array:8},getTypedArrayConstructor=function(e){var t=v(e);if(d(t)){var i=C(t);return i&&h(i,L)?i[L]:getTypedArrayConstructor(t)}},isTypedArray=function(e){if(!d(e))return!1;var t=u(e);return h(N,t)||h(j,t)};for(a in N)(r=(s=l[a])&&s.prototype)?S(r)[L]=s:O=!1;for(a in j)(r=(s=l[a])&&s.prototype)&&(S(r)[L]=s);if(!O||!c(T)||T===Function.prototype){T=function TypedArray(){throw new B("Incorrect invocation")};if(O)for(a in N)l[a]&&y(l[a],T)}if(!O||!I||I===G){I=T.prototype;if(O)for(a in N)l[a]&&y(l[a].prototype,I)}O&&v(E)!==I&&y(E,I);if(o&&!h(I,M)){R=!0;f(I,M,{configurable:!0,get:function(){return d(this)?this[D]:void 0}});for(a in N)l[a]&&p(l[a].prototype,D,a)}e.exports={NATIVE_ARRAY_BUFFER_VIEWS:O,TYPED_ARRAY_TAG:R&&D,aTypedArray:function(e){if(isTypedArray(e))return e;throw new B("Target is not a typed array")},aTypedArrayConstructor:function(e){if(c(e)&&(!y||m(T,e)))return e;throw new B(_(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,i,a){if(o){if(i)for(var s in N){var r=l[s];if(r&&h(r.prototype,e))try{delete r.prototype[e]}catch(i){try{r.prototype[e]=t}catch(e){}}}I[e]&&!i||g(I,e,i?t:O&&x[e]||t,a)}},exportTypedArrayStaticMethod:function(e,t,i){var a,s;if(o){if(y){if(i)for(a in N)if((s=l[a])&&h(s,e))try{delete s[e]}catch(e){}if(T[e]&&!i)return;try{return g(T,e,i?t:O&&T[e]||t)}catch(e){}}for(a in N)!(s=l[a])||s[e]&&!i||g(s,e,t)}},getTypedArrayConstructor,isView:function isView(e){if(!d(e))return!1;var t=u(e);return"DataView"===t||h(N,t)||h(j,t)},isTypedArray,TypedArray:T,TypedArrayPrototype:I}},4373(e,t,i){var a=i(8981),s=i(5610),r=i(6198);e.exports=function fill(e){for(var t=a(this),i=r(t),n=arguments.length,o=s(n>1?arguments[1]:void 0,i),l=n>2?arguments[2]:void 0,c=void 0===l?i:s(l,i);c>o;)t[o++]=e;return t}},5370(e,t,i){var a=i(6198);e.exports=function(e,t,i){for(var s=0,r=arguments.length>2?i:a(t),n=new e(r);r>s;)n[s]=t[s++];return n}},9617(e,t,i){var a=i(5397),s=i(5610),r=i(6198),createMethod=function(e){return function(t,i,n){var o=a(t),l=r(o);if(0===l)return!e&&-1;var c,d=s(n,l);if(e&&i!=i){for(;l>d;)if((c=o[d++])!=c)return!0}else for(;l>d;d++)if((e||d in o)&&o[d]===i)return e||d||0;return!e&&-1}};e.exports={includes:createMethod(!0),indexOf:createMethod(!1)}},3839(e,t,i){var a=i(6080),s=i(7055),r=i(8981),n=i(6198),createMethod=function(e){var t=1===e;return function(i,o,l){for(var c,d=r(i),h=s(d),u=n(h),_=a(o,l);u-- >0;)if(_(c=h[u],u,d))switch(e){case 0:return c;case 1:return u}return t?-1:void 0}};e.exports={findLast:createMethod(0),findLastIndex:createMethod(1)}},4527(e,t,i){var a=i(3724),s=i(4376),r=TypeError,n=Object.getOwnPropertyDescriptor,o=a&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}();e.exports=o?function(e,t){if(s(e)&&!n(e,"length").writable)throw new r("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t}},7680(e,t,i){var a=i(9504);e.exports=a([].slice)},4488(e,t,i){var a=i(7680),s=Math.floor,sort=function(e,t){var i=e.length;if(i<8)for(var r,n,o=1;o<i;){n=o;r=e[o];for(;n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}else for(var l=s(i/2),c=sort(a(e,0,l),t),d=sort(a(e,l),t),h=c.length,u=d.length,_=0,p=0;_<h||p<u;)e[_+p]=_<h&&p<u?t(c[_],d[p])<=0?c[_++]:d[p++]:_<h?c[_++]:d[p++];return e};e.exports=sort},2804(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",i=t+"+/",a=t+"-_",inverse=function(e){for(var t={},i=0;i<64;i++)t[e.charAt(i)]=i;return t};e.exports={i2c:i,c2i:inverse(i),i2cUrl:a,c2iUrl:inverse(a)}},6319(e,t,i){var a=i(8551),s=i(9539);e.exports=function(e,t,i,r){try{return r?t(a(i)[0],i[1]):t(i)}catch(t){s(e,"throw",t)}}},2195(e,t,i){var a=i(9504),s=a({}.toString),r=a("".slice);e.exports=function(e){return r(s(e),8,-1)}},6955(e,t,i){var a=i(2140),s=i(4901),r=i(2195),n=i(8227)("toStringTag"),o=Object,l="Arguments"===r(function(){return arguments}());e.exports=a?r:function(e){var t,i,a;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(i=function(e,t){try{return e[t]}catch(e){}}(t=o(e),n))?i:l?r(t):"Object"===(a=r(t))&&s(t.callee)?"Arguments":a}},7740(e,t,i){var a=i(9297),s=i(5031),r=i(7347),n=i(4913);e.exports=function(e,t,i){for(var o=s(t),l=n.f,c=r.f,d=0;d<o.length;d++){var h=o[d];a(e,h)||i&&a(i,h)||l(e,h,c(t,h))}}},2211(e,t,i){var a=i(9039);e.exports=!a(function(){function F(){}F.prototype.constructor=null;return Object.getPrototypeOf(new F)!==F.prototype})},2529(e){e.exports=function(e,t){return{value:e,done:t}}},6699(e,t,i){var a=i(3724),s=i(4913),r=i(6980);e.exports=a?function(e,t,i){return s.f(e,t,r(1,i))}:function(e,t,i){e[t]=i;return e}},6980(e){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},2278(e,t,i){var a=i(3724),s=i(4913),r=i(6980);e.exports=function(e,t,i){a?s.f(e,t,r(0,i)):e[t]=i}},2106(e,t,i){var a=i(283),s=i(4913);e.exports=function(e,t,i){i.get&&a(i.get,t,{getter:!0});i.set&&a(i.set,t,{setter:!0});return s.f(e,t,i)}},6840(e,t,i){var a=i(4901),s=i(4913),r=i(283),n=i(9433);e.exports=function(e,t,i,o){o||(o={});var l=o.enumerable,c=void 0!==o.name?o.name:t;a(i)&&r(i,c,o);if(o.global)l?e[t]=i:n(t,i);else{try{o.unsafe?e[t]&&(l=!0):delete e[t]}catch(e){}l?e[t]=i:s.f(e,t,{value:i,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return e}},6279(e,t,i){var a=i(6840);e.exports=function(e,t,i){for(var s in t)a(e,s,t[s],i);return e}},9433(e,t,i){var a=i(4576),s=Object.defineProperty;e.exports=function(e,t){try{s(a,e,{value:t,configurable:!0,writable:!0})}catch(i){a[e]=t}return t}},3724(e,t,i){var a=i(9039);e.exports=!a(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})},4483(e,t,i){var a,s,r,n,o=i(4576),l=i(9429),c=i(1548),d=o.structuredClone,h=o.ArrayBuffer,u=o.MessageChannel,_=!1;if(c)_=function(e){d(e,{transfer:[e]})};else if(h)try{u||(a=l("worker_threads"))&&(u=a.MessageChannel);if(u){s=new u;r=new h(2);n=function(e){s.port1.postMessage(null,[e])};if(2===r.byteLength){n(r);0===r.byteLength&&(_=n)}}}catch(e){}e.exports=_},4055(e,t,i){var a=i(4576),s=i(34),r=a.document,n=s(r)&&s(r.createElement);e.exports=function(e){return n?r.createElement(e):{}}},6837(e){var t=TypeError;e.exports=function(e){if(e>9007199254740991)throw new t("Maximum allowed index exceeded");return e}},5002(e){e.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8727(e){e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},3709(e,t,i){var a=i(2839).match(/firefox\/(\d+)/i);e.exports=!!a&&+a[1]},3763(e,t,i){var a=i(2839);e.exports=/MSIE|Trident/.test(a)},8574(e,t,i){var a=i(4215);e.exports="NODE"===a},2839(e,t,i){var a=i(4576).navigator,s=a&&a.userAgent;e.exports=s?String(s):""},9519(e,t,i){var a,s,r=i(4576),n=i(2839),o=r.process,l=r.Deno,c=o&&o.versions||l&&l.version,d=c&&c.v8;d&&(s=(a=d.split("."))[0]>0&&a[0]<4?1:+(a[0]+a[1]));!s&&n&&(!(a=n.match(/Edge\/(\d+)/))||a[1]>=74)&&(a=n.match(/Chrome\/(\d+)/))&&(s=+a[1]);e.exports=s},3607(e,t,i){var a=i(2839).match(/AppleWebKit\/(\d+)\./);e.exports=!!a&&+a[1]},4215(e,t,i){var a=i(4576),s=i(2839),r=i(2195),userAgentStartsWith=function(e){return s.slice(0,e.length)===e};e.exports=userAgentStartsWith("Bun/")?"BUN":userAgentStartsWith("Cloudflare-Workers")?"CLOUDFLARE":userAgentStartsWith("Deno/")?"DENO":userAgentStartsWith("Node.js/")?"NODE":a.Bun&&"string"==typeof Bun.version?"BUN":a.Deno&&"object"==typeof Deno.version?"DENO":"process"===r(a.process)?"NODE":a.window&&a.document?"BROWSER":"REST"},6193(e,t,i){var a=i(9504),s=Error,r=a("".replace),n=String(new s("zxcasd").stack),o=/\n\s*at [^:]*:[^\n]*/,l=o.test(n);e.exports=function(e,t){if(l&&"string"==typeof e&&!s.prepareStackTrace)for(;t--;)e=r(e,o,"");return e}},747(e,t,i){var a=i(6699),s=i(6193),r=i(4659),n=Error.captureStackTrace;e.exports=function(e,t,i,o){r&&(n?n(e,t):a(e,"stack",s(i,o)))}},4659(e,t,i){var a=i(9039),s=i(6980);e.exports=!a(function(){var e=new Error("a");if(!("stack"in e))return!0;Object.defineProperty(e,"stack",s(1,7));return 7!==e.stack})},6518(e,t,i){var a=i(4576),s=i(7347).f,r=i(6699),n=i(6840),o=i(9433),l=i(7740),c=i(2796);e.exports=function(e,t){var i,d,h,u,_,p=e.target,g=e.global,f=e.stat;if(i=g?a:f?a[p]||o(p,{}):a[p]&&a[p].prototype)for(d in t){u=t[d];h=e.dontCallGetSet?(_=s(i,d))&&_.value:i[d];if(!c(g?d:p+(f?".":"#")+d,e.forced)&&void 0!==h){if(typeof u==typeof h)continue;l(u,h)}(e.sham||h&&h.sham)&&r(u,"sham",!0);n(i,d,u,e)}}},9039(e){e.exports=function(e){try{return!!e()}catch(e){return!0}}},8745(e,t,i){var a=i(616),s=Function.prototype,r=s.apply,n=s.call;e.exports="object"==typeof Reflect&&Reflect.apply||(a?n.bind(r):function(){return n.apply(r,arguments)})},6080(e,t,i){var a=i(7476),s=i(9306),r=i(616),n=a(a.bind);e.exports=function(e,t){s(e);return void 0===t?e:r?n(e,t):function(){return e.apply(t,arguments)}}},616(e,t,i){var a=i(9039);e.exports=!a(function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})},9565(e,t,i){var a=i(616),s=Function.prototype.call;e.exports=a?s.bind(s):function(){return s.apply(s,arguments)}},350(e,t,i){var a=i(3724),s=i(9297),r=Function.prototype,n=a&&Object.getOwnPropertyDescriptor,o=s(r,"name"),l=o&&"something"===function something(){}.name,c=o&&(!a||a&&n(r,"name").configurable);e.exports={EXISTS:o,PROPER:l,CONFIGURABLE:c}},6706(e,t,i){var a=i(9504),s=i(9306);e.exports=function(e,t,i){try{return a(s(Object.getOwnPropertyDescriptor(e,t)[i]))}catch(e){}}},7476(e,t,i){var a=i(2195),s=i(9504);e.exports=function(e){if("Function"===a(e))return s(e)}},9504(e,t,i){var a=i(616),s=Function.prototype,r=s.call,n=a&&s.bind.bind(r,r);e.exports=a?n:function(e){return function(){return r.apply(e,arguments)}}},944(e){var t=TypeError;e.exports=function(e){var i=e&&e.alphabet;if(void 0===i||"base64"===i||"base64url"===i)return i||"base64";throw new t("Incorrect `alphabet` option")}},9429(e,t,i){var a=i(4576),s=i(8574);e.exports=function(e){if(s){try{return a.process.getBuiltinModule(e)}catch(e){}try{return Function('return require("'+e+'")')()}catch(e){}}}},7751(e,t,i){var a=i(4576),s=i(4901);e.exports=function(e,t){return arguments.length<2?(i=a[e],s(i)?i:void 0):a[e]&&a[e][t];var i}},1767(e){e.exports=function(e){return{iterator:e,next:e.next,done:!1}}},8646(e,t,i){var a=i(9565),s=i(8551),r=i(1767),n=i(851);e.exports=function(e,t){t&&"string"==typeof e||s(e);var i=n(e);return r(s(void 0!==i?a(i,e):e))}},851(e,t,i){var a=i(6955),s=i(5966),r=i(4117),n=i(6269),o=i(8227)("iterator");e.exports=function(e){if(!r(e))return s(e,o)||s(e,"@@iterator")||n[a(e)]}},81(e,t,i){var a=i(9565),s=i(9306),r=i(8551),n=i(6823),o=i(851),l=TypeError;e.exports=function(e,t){var i=arguments.length<2?o(e):t;if(s(i))return r(a(i,e));throw new l(n(e)+" is not iterable")}},5966(e,t,i){var a=i(9306),s=i(4117);e.exports=function(e,t){var i=e[t];return s(i)?void 0:a(i)}},3789(e,t,i){var a=i(9306),s=i(8551),r=i(9565),n=i(1291),o=i(1767),l="Invalid size",c=RangeError,d=TypeError,h=Math.max,SetRecord=function(e,t){this.set=e;this.size=h(t,0);this.has=a(e.has);this.keys=a(e.keys)};SetRecord.prototype={getIterator:function(){return o(s(r(this.keys,this.set)))},includes:function(e){return r(this.has,this.set,e)}};e.exports=function(e){s(e);var t=+e.size;if(t!=t)throw new d(l);var i=n(t);if(i<0)throw new c(l);return new SetRecord(e,i)}},4576(e){var check=function(e){return e&&e.Math===Math&&e};e.exports=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof global&&global)||check("object"==typeof this&&this)||function(){return this}()||Function("return this")()},9297(e,t,i){var a=i(9504),s=i(8981),r=a({}.hasOwnProperty);e.exports=Object.hasOwn||function hasOwn(e,t){return r(s(e),t)}},421(e){e.exports={}},397(e,t,i){var a=i(7751);e.exports=a("document","documentElement")},5917(e,t,i){var a=i(3724),s=i(9039),r=i(4055);e.exports=!a&&!s(function(){return 7!==Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a})},7055(e,t,i){var a=i(9504),s=i(9039),r=i(2195),n=Object,o=a("".split);e.exports=s(function(){return!n("z").propertyIsEnumerable(0)})?function(e){return"String"===r(e)?o(e,""):n(e)}:n},3167(e,t,i){var a=i(4901),s=i(34),r=i(2967);e.exports=function(e,t,i){var n,o;r&&a(n=t.constructor)&&n!==i&&s(o=n.prototype)&&o!==i.prototype&&r(e,o);return e}},3706(e,t,i){var a=i(9504),s=i(4901),r=i(7629),n=a(Function.toString);s(r.inspectSource)||(r.inspectSource=function(e){return n(e)});e.exports=r.inspectSource},7584(e,t,i){var a=i(34),s=i(6699);e.exports=function(e,t){a(t)&&"cause"in t&&s(e,"cause",t.cause)}},1181(e,t,i){var a,s,r,n=i(8622),o=i(4576),l=i(34),c=i(6699),d=i(9297),h=i(7629),u=i(6119),_=i(421),p="Object already initialized",g=o.TypeError,f=o.WeakMap;if(n||h.state){var m=h.state||(h.state=new f);m.get=m.get;m.has=m.has;m.set=m.set;a=function(e,t){if(m.has(e))throw new g(p);t.facade=e;m.set(e,t);return t};s=function(e){return m.get(e)||{}};r=function(e){return m.has(e)}}else{var v=u("state");_[v]=!0;a=function(e,t){if(d(e,v))throw new g(p);t.facade=e;c(e,v,t);return t};s=function(e){return d(e,v)?e[v]:{}};r=function(e){return d(e,v)}}e.exports={set:a,get:s,has:r,enforce:function(e){return r(e)?s(e):a(e,{})},getterFor:function(e){return function(t){var i;if(!l(t)||(i=s(t)).type!==e)throw new g("Incompatible receiver, "+e+" required");return i}}}},4209(e,t,i){var a=i(8227),s=i(6269),r=a("iterator"),n=Array.prototype;e.exports=function(e){return void 0!==e&&(s.Array===e||n[r]===e)}},4376(e,t,i){var a=i(2195);e.exports=Array.isArray||function isArray(e){return"Array"===a(e)}},1108(e,t,i){var a=i(6955);e.exports=function(e){var t=a(e);return"BigInt64Array"===t||"BigUint64Array"===t}},4901(e){var t="object"==typeof document&&document.all;e.exports=void 0===t&&void 0!==t?function(e){return"function"==typeof e||e===t}:function(e){return"function"==typeof e}},2796(e,t,i){var a=i(9039),s=i(4901),r=/#|\.prototype\./,isForced=function(e,t){var i=o[n(e)];return i===c||i!==l&&(s(t)?a(t):!!t)},n=isForced.normalize=function(e){return String(e).replace(r,".").toLowerCase()},o=isForced.data={},l=isForced.NATIVE="N",c=isForced.POLYFILL="P";e.exports=isForced},4117(e){e.exports=function(e){return null==e}},34(e,t,i){var a=i(4901);e.exports=function(e){return"object"==typeof e?null!==e:a(e)}},3925(e,t,i){var a=i(34);e.exports=function(e){return a(e)||null===e}},6395(e){e.exports=!1},5810(e,t,i){var a=i(34),s=i(1181).get;e.exports=function isRawJSON(e){if(!a(e))return!1;var t=s(e);return!!t&&"RawJSON"===t.type}},757(e,t,i){var a=i(7751),s=i(4901),r=i(1625),n=i(7040),o=Object;e.exports=n?function(e){return"symbol"==typeof e}:function(e){var t=a("Symbol");return s(t)&&r(t.prototype,o(e))}},507(e,t,i){var a=i(9565);e.exports=function(e,t,i){for(var s,r,n=i?e:e.iterator,o=e.next;!(s=a(o,n)).done;)if(void 0!==(r=t(s.value)))return r}},2652(e,t,i){var a=i(6080),s=i(9565),r=i(8551),n=i(6823),o=i(4209),l=i(6198),c=i(1625),d=i(81),h=i(851),u=i(9539),_=TypeError,Result=function(e,t){this.stopped=e;this.result=t},p=Result.prototype;e.exports=function(e,t,i){var g,f,m,v,y,P,w,b=i&&i.that,S=!(!i||!i.AS_ENTRIES),C=!(!i||!i.IS_RECORD),A=!(!i||!i.IS_ITERATOR),x=!(!i||!i.INTERRUPTED),k=a(t,b),stop=function(e){var t=g;g=void 0;t&&u(t,"normal");return new Result(!0,e)},callFn=function(e){if(S){r(e);return x?k(e[0],e[1],stop):k(e[0],e[1])}return x?k(e,stop):k(e)};if(C)g=e.iterator;else if(A)g=e;else{if(!(f=h(e)))throw new _(n(e)+" is not iterable");if(o(f)){for(m=0,v=l(e);v>m;m++)if((y=callFn(e[m]))&&c(p,y))return y;return new Result(!1)}g=d(e,f)}P=C?e.next:g.next;for(;!(w=s(P,g)).done;){var E=w.value;try{y=callFn(E)}catch(e){if(!g)throw e;u(g,"throw",e)}if("object"==typeof y&&y&&c(p,y))return y}return new Result(!1)}},1385(e,t,i){var a=i(9539);e.exports=function(e,t,i){for(var s=e.length-1;s>=0;s--)if(void 0!==e[s])try{i=a(e[s].iterator,t,i)}catch(e){t="throw";i=e}if("throw"===t)throw i;return i}},9539(e,t,i){var a=i(9565),s=i(8551),r=i(5966);e.exports=function(e,t,i){var n,o;s(e);try{if(!(n=r(e,"return"))){if("throw"===t)throw i;return i}n=a(n,e)}catch(e){o=!0;n=e}if("throw"===t)throw i;if(o)throw n;s(n);return i}},9462(e,t,i){var a=i(9565),s=i(2360),r=i(6699),n=i(6279),o=i(8227),l=i(1181),c=i(5966),d=i(7657).IteratorPrototype,h=i(2529),u=i(9539),_=i(1385),p=o("toStringTag"),g="IteratorHelper",f="WrapForValidIterator",m="normal",v="throw",y=l.set,createIteratorProxyPrototype=function(e){var t=l.getterFor(e?f:g);return n(s(d),{next:function next(){var i=t(this);if(e)return i.nextHandler();if(i.done)return h(void 0,!0);try{var a=i.nextHandler();return i.returnHandlerResult?a:h(a,i.done)}catch(e){i.done=!0;throw e}},return:function(){var i=t(this),s=i.iterator,r=i.done;i.done=!0;if(e){var n=c(s,"return");return n?a(n,s):h(void 0,!0)}if(r)return h(void 0,!0);if(i.inner)try{u(i.inner.iterator,m)}catch(e){return u(s,v,e)}if(i.openIters)try{_(i.openIters,m)}catch(e){if(s)return u(s,v,e);throw e}s&&u(s,m);return h(void 0,!0)}})},P=createIteratorProxyPrototype(!0),w=createIteratorProxyPrototype(!1);r(w,p,"Iterator Helper");e.exports=function(e,t,i){var a=function Iterator(a,s){if(s){s.iterator=a.iterator;s.next=a.next}else s=a;s.type=t?f:g;s.returnHandlerResult=!!i;s.nextHandler=e;s.counter=0;s.done=!1;y(this,s)};a.prototype=t?P:w;return a}},684(e){e.exports=function(e,t){var i="function"==typeof Iterator&&Iterator.prototype[e];if(i)try{i.call({next:null},t).next()}catch(e){return!0}}},4549(e,t,i){var a=i(4576);e.exports=function(e,t){var i=a.Iterator,s=i&&i.prototype,r=s&&s[e],n=!1;if(r)try{r.call({next:function(){return{done:!0}},return:function(){n=!0}},-1)}catch(e){e instanceof t||(n=!1)}if(!n)return r}},7657(e,t,i){var a,s,r,n=i(9039),o=i(4901),l=i(34),c=i(2360),d=i(2787),h=i(6840),u=i(8227),_=i(6395),p=u("iterator"),g=!1;[].keys&&("next"in(r=[].keys())?(s=d(d(r)))!==Object.prototype&&(a=s):g=!0);!l(a)||n(function(){var e={};return a[p].call(e)!==e})?a={}:_&&(a=c(a));o(a[p])||h(a,p,function(){return this});e.exports={IteratorPrototype:a,BUGGY_SAFARI_ITERATORS:g}},6269(e){e.exports={}},6198(e,t,i){var a=i(8014);e.exports=function(e){return a(e.length)}},283(e,t,i){var a=i(9504),s=i(9039),r=i(4901),n=i(9297),o=i(3724),l=i(350).CONFIGURABLE,c=i(3706),d=i(1181),h=d.enforce,u=d.get,_=String,p=Object.defineProperty,g=a("".slice),f=a("".replace),m=a([].join),v=o&&!s(function(){return 8!==p(function(){},"length",{value:8}).length}),y=String(String).split("String"),P=e.exports=function(e,t,i){"Symbol("===g(_(t),0,7)&&(t="["+f(_(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]");i&&i.getter&&(t="get "+t);i&&i.setter&&(t="set "+t);(!n(e,"name")||l&&e.name!==t)&&(o?p(e,"name",{value:t,configurable:!0}):e.name=t);v&&i&&n(i,"arity")&&e.length!==i.arity&&p(e,"length",{value:i.arity});try{i&&n(i,"constructor")&&i.constructor?o&&p(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var a=h(e);n(a,"source")||(a.source=m(y,"string"==typeof t?t:""));return e};Function.prototype.toString=P(function toString(){return r(this)&&u(this).source||c(this)},"toString")},2248(e,t,i){var a=i(9504),s=Map.prototype;e.exports={Map,set:a(s.set),get:a(s.get),has:a(s.has),remove:a(s.delete),proto:s}},741(e){var t=Math.ceil,i=Math.floor;e.exports=Math.trunc||function trunc(e){var a=+e;return(a>0?i:t)(a)}},7819(e,t,i){var a=i(9039);e.exports=!a(function(){var e="9007199254740993",t=JSON.rawJSON(e);return!JSON.isRawJSON(t)||JSON.stringify(t)!==e})},6043(e,t,i){var a=i(9306),s=TypeError,PromiseCapability=function(e){var t,i;this.promise=new e(function(e,a){if(void 0!==t||void 0!==i)throw new s("Bad Promise constructor");t=e;i=a});this.resolve=a(t);this.reject=a(i)};e.exports.f=function(e){return new PromiseCapability(e)}},2603(e,t,i){var a=i(655);e.exports=function(e,t){return void 0===e?arguments.length<2?"":t:a(e)}},4149(e){var t=RangeError;e.exports=function(e){if(e==e)return e;throw new t("NaN is not allowed")}},2360(e,t,i){var a,s=i(8551),r=i(6801),n=i(8727),o=i(421),l=i(397),c=i(4055),d=i(6119),h="prototype",u="script",_=d("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return"<"+u+">"+e+"</"+u+">"},NullProtoObjectViaActiveX=function(e){e.write(scriptTag(""));e.close();var t=e.parentWindow.Object;e=null;return t},NullProtoObject=function(){try{a=new ActiveXObject("htmlfile")}catch(e){}NullProtoObject="undefined"!=typeof document?document.domain&&a?NullProtoObjectViaActiveX(a):function(){var e,t=c("iframe"),i="java"+u+":";t.style.display="none";l.appendChild(t);t.src=String(i);(e=t.contentWindow.document).open();e.write(scriptTag("document.F=Object"));e.close();return e.F}():NullProtoObjectViaActiveX(a);for(var e=n.length;e--;)delete NullProtoObject[h][n[e]];return NullProtoObject()};o[_]=!0;e.exports=Object.create||function create(e,t){var i;if(null!==e){EmptyConstructor[h]=s(e);i=new EmptyConstructor;EmptyConstructor[h]=null;i[_]=e}else i=NullProtoObject();return void 0===t?i:r.f(i,t)}},6801(e,t,i){var a=i(3724),s=i(8686),r=i(4913),n=i(8551),o=i(5397),l=i(1072);t.f=a&&!s?Object.defineProperties:function defineProperties(e,t){n(e);for(var i,a=o(t),s=l(t),c=s.length,d=0;c>d;)r.f(e,i=s[d++],a[i]);return e}},4913(e,t,i){var a=i(3724),s=i(5917),r=i(8686),n=i(8551),o=i(6969),l=TypeError,c=Object.defineProperty,d=Object.getOwnPropertyDescriptor,h="enumerable",u="configurable",_="writable";t.f=a?r?function defineProperty(e,t,i){n(e);t=o(t);n(i);if("function"==typeof e&&"prototype"===t&&"value"in i&&_ in i&&!i[_]){var a=d(e,t);if(a&&a[_]){e[t]=i.value;i={configurable:u in i?i[u]:a[u],enumerable:h in i?i[h]:a[h],writable:!1}}}return c(e,t,i)}:c:function defineProperty(e,t,i){n(e);t=o(t);n(i);if(s)try{return c(e,t,i)}catch(e){}if("get"in i||"set"in i)throw new l("Accessors not supported");"value"in i&&(e[t]=i.value);return e}},7347(e,t,i){var a=i(3724),s=i(9565),r=i(8773),n=i(6980),o=i(5397),l=i(6969),c=i(9297),d=i(5917),h=Object.getOwnPropertyDescriptor;t.f=a?h:function getOwnPropertyDescriptor(e,t){e=o(e);t=l(t);if(d)try{return h(e,t)}catch(e){}if(c(e,t))return n(!s(r.f,e,t),e[t])}},8480(e,t,i){var a=i(1828),s=i(8727).concat("length","prototype");t.f=Object.getOwnPropertyNames||function getOwnPropertyNames(e){return a(e,s)}},3717(e,t){t.f=Object.getOwnPropertySymbols},2787(e,t,i){var a=i(9297),s=i(4901),r=i(8981),n=i(6119),o=i(2211),l=n("IE_PROTO"),c=Object,d=c.prototype;e.exports=o?c.getPrototypeOf:function(e){var t=r(e);if(a(t,l))return t[l];var i=t.constructor;return s(i)&&t instanceof i?i.prototype:t instanceof c?d:null}},1625(e,t,i){var a=i(9504);e.exports=a({}.isPrototypeOf)},1828(e,t,i){var a=i(9504),s=i(9297),r=i(5397),n=i(9617).indexOf,o=i(421),l=a([].push);e.exports=function(e,t){var i,a=r(e),c=0,d=[];for(i in a)!s(o,i)&&s(a,i)&&l(d,i);for(;t.length>c;)s(a,i=t[c++])&&(~n(d,i)||l(d,i));return d}},1072(e,t,i){var a=i(1828),s=i(8727);e.exports=Object.keys||function keys(e){return a(e,s)}},8773(e,t){var i={}.propertyIsEnumerable,a=Object.getOwnPropertyDescriptor,s=a&&!i.call({1:2},1);t.f=s?function propertyIsEnumerable(e){var t=a(this,e);return!!t&&t.enumerable}:i},2967(e,t,i){var a=i(6706),s=i(34),r=i(7750),n=i(3506);e.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,i={};try{(e=a(Object.prototype,"__proto__","set"))(i,[]);t=i instanceof Array}catch(e){}return function setPrototypeOf(i,a){r(i);n(a);if(!s(i))return i;t?e(i,a):i.__proto__=a;return i}}():void 0)},4270(e,t,i){var a=i(9565),s=i(4901),r=i(34),n=TypeError;e.exports=function(e,t){var i,o;if("string"===t&&s(i=e.toString)&&!r(o=a(i,e)))return o;if(s(i=e.valueOf)&&!r(o=a(i,e)))return o;if("string"!==t&&s(i=e.toString)&&!r(o=a(i,e)))return o;throw new n("Can't convert object to primitive value")}},5031(e,t,i){var a=i(7751),s=i(9504),r=i(8480),n=i(3717),o=i(8551),l=s([].concat);e.exports=a("Reflect","ownKeys")||function ownKeys(e){var t=r.f(o(e)),i=n.f;return i?l(t,i(e)):t}},8235(e,t,i){var a=i(9504),s=i(9297),r=SyntaxError,n=parseInt,o=String.fromCharCode,l=a("".charAt),c=a("".slice),d=a(/./.exec),h={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t"},u=/^[\da-f]{4}$/i,_=/^[\u0000-\u001F]$/;e.exports=function(e,t){for(var i=!0,a="";t<e.length;){var p=l(e,t);if("\\"===p){var g=c(e,t,t+2);if(s(h,g)){a+=h[g];t+=2}else{if("\\u"!==g)throw new r('Unknown escape sequence: "'+g+'"');var f=c(e,t+=2,t+4);if(!d(u,f))throw new r("Bad Unicode escape at: "+t);a+=o(n(f,16));t+=4}}else{if('"'===p){i=!1;t++;break}if(d(_,p))throw new r("Bad control character in string literal at: "+t);a+=p;t++}}if(i)throw new r("Unterminated string at: "+t);return{value:a,end:t}}},1103(e){e.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}},1056(e,t,i){var a=i(4913).f;e.exports=function(e,t,i){i in e||a(e,i,{configurable:!0,get:function(){return t[i]},set:function(e){t[i]=e}})}},7750(e,t,i){var a=i(4117),s=TypeError;e.exports=function(e){if(a(e))throw new s("Can't call method on "+e);return e}},9286(e,t,i){var a=i(4402),s=i(8469),r=a.Set,n=a.add;e.exports=function(e){var t=new r;s(e,function(e){n(t,e)});return t}},3440(e,t,i){var a=i(7080),s=i(4402),r=i(9286),n=i(5170),o=i(3789),l=i(8469),c=i(507),d=s.has,h=s.remove;e.exports=function difference(e){var t=a(this),i=o(e),s=r(t);n(s)<=i.size?l(s,function(e){i.includes(e)&&h(s,e)}):c(i.getIterator(),function(e){d(s,e)&&h(s,e)});return s}},4402(e,t,i){var a=i(9504),s=Set.prototype;e.exports={Set,add:a(s.add),has:a(s.has),remove:a(s.delete),proto:s}},8750(e,t,i){var a=i(7080),s=i(4402),r=i(5170),n=i(3789),o=i(8469),l=i(507),c=s.Set,d=s.add,h=s.has;e.exports=function intersection(e){var t=a(this),i=n(e),s=new c;r(t)>i.size?l(i.getIterator(),function(e){h(t,e)&&d(s,e)}):o(t,function(e){i.includes(e)&&d(s,e)});return s}},4449(e,t,i){var a=i(7080),s=i(4402).has,r=i(5170),n=i(3789),o=i(8469),l=i(507),c=i(9539);e.exports=function isDisjointFrom(e){var t=a(this),i=n(e);if(r(t)<=i.size)return!1!==o(t,function(e){if(i.includes(e))return!1},!0);var d=i.getIterator();return!1!==l(d,function(e){if(s(t,e))return c(d.iterator,"normal",!1)})}},3838(e,t,i){var a=i(7080),s=i(5170),r=i(8469),n=i(3789);e.exports=function isSubsetOf(e){var t=a(this),i=n(e);return!(s(t)>i.size)&&!1!==r(t,function(e){if(!i.includes(e))return!1},!0)}},8527(e,t,i){var a=i(7080),s=i(4402).has,r=i(5170),n=i(3789),o=i(507),l=i(9539);e.exports=function isSupersetOf(e){var t=a(this),i=n(e);if(r(t)<i.size)return!1;var c=i.getIterator();return!1!==o(c,function(e){if(!s(t,e))return l(c.iterator,"normal",!1)})}},8469(e,t,i){var a=i(9504),s=i(507),r=i(4402),n=r.Set,o=r.proto,l=a(o.forEach),c=a(o.keys),d=c(new n).next;e.exports=function(e,t,i){return i?s({iterator:c(e),next:d},t):l(e,t)}},4916(e,t,i){var a=i(7751),createSetLike=function(e){return{size:e,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},createSetLikeWithInfinitySize=function(e){return{size:e,has:function(){return!0},keys:function(){throw new Error("e")}}};e.exports=function(e,t){var i=a("Set");try{(new i)[e](createSetLike(0));try{(new i)[e](createSetLike(-1));return!1}catch(a){if(!t)return!0;try{(new i)[e](createSetLikeWithInfinitySize(-1/0));return!1}catch(a){return t(new i([1,2])[e](createSetLikeWithInfinitySize(1/0)))}}}catch(e){return!1}}},9835(e){e.exports=function(e){try{var t=new Set,i={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){t.clear();t.add(4);return function(){return{done:!0}}}})}},a=t[e](i);return 1===a.size&&4===a.values().next().value}catch(e){return!1}}},5170(e,t,i){var a=i(6706),s=i(4402);e.exports=a(s.proto,"size","get")||function(e){return e.size}},3650(e,t,i){var a=i(7080),s=i(4402),r=i(9286),n=i(3789),o=i(507),l=s.add,c=s.has,d=s.remove;e.exports=function symmetricDifference(e){var t=a(this),i=n(e).getIterator(),s=r(t);o(i,function(e){c(t,e)?d(s,e):l(s,e)});return s}},4204(e,t,i){var a=i(7080),s=i(4402).add,r=i(9286),n=i(3789),o=i(507);e.exports=function union(e){var t=a(this),i=n(e).getIterator(),l=r(t);o(i,function(e){s(l,e)});return l}},6119(e,t,i){var a=i(5745),s=i(3392),r=a("keys");e.exports=function(e){return r[e]||(r[e]=s(e))}},7629(e,t,i){var a=i(6395),s=i(4576),r=i(9433),n="__core-js_shared__",o=e.exports=s[n]||r(n,{});(o.versions||(o.versions=[])).push({version:"3.49.0",mode:a?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745(e,t,i){var a=i(7629);e.exports=function(e,t){return a[e]||(a[e]=t||{})}},533(e,t,i){var a=i(9504),s=i(8014),r=i(655),n=i(2333),o=i(7750),l=a(n),c=a("".slice),d=Math.ceil,createMethod=function(e){return function(t,i,a){var n=r(o(t)),h=s(i),u=n.length;if(h<=u)return n;var _,p,g=void 0===a?" ":r(a);if(""===g)return n;(p=l(g,d((_=h-u)/g.length))).length>_&&(p=c(p,0,_));return e?n+p:p+n}};e.exports={start:createMethod(!1),end:createMethod(!0)}},2333(e,t,i){var a=i(1291),s=i(655),r=i(7750),n=RangeError,o=Math.floor;e.exports=function repeat(e){var t=s(r(this)),i="",l=a(e);if(l<0||l===1/0)throw new n("Wrong number of repetitions");for(;l>0;(l=o(l/2))&&(t+=t))l%2&&(i+=t);return i}},1548(e,t,i){var a=i(4576),s=i(9039),r=i(9519),n=i(4215),o=a.structuredClone;e.exports=!!o&&!s(function(){if("DENO"===n&&r>92||"NODE"===n&&r>94||"BROWSER"===n&&r>97)return!1;var e=new ArrayBuffer(8),t=o(e,{transfer:[e]});return 0!==e.byteLength||8!==t.byteLength})},4495(e,t,i){var a=i(9519),s=i(9039),r=i(4576).String;e.exports=!!Object.getOwnPropertySymbols&&!s(function(){var e=Symbol("symbol detection");return!r(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&a&&a<41})},5610(e,t,i){var a=i(1291),s=Math.max,r=Math.min;e.exports=function(e,t){var i=a(e);return i<0?s(i+t,0):r(i,t)}},5854(e,t,i){var a=i(2777),s=TypeError;e.exports=function(e){var t=a(e,"number");if("number"==typeof t)throw new s("Can't convert number to bigint");return BigInt(t)}},7696(e,t,i){var a=i(1291),s=i(8014),r=RangeError;e.exports=function(e){if(void 0===e)return 0;var t=a(e),i=s(t);if(t!==i)throw new r("Wrong length or index");return i}},5397(e,t,i){var a=i(7055),s=i(7750);e.exports=function(e){return a(s(e))}},1291(e,t,i){var a=i(741);e.exports=function(e){var t=+e;return t!=t||0===t?0:a(t)}},8014(e,t,i){var a=i(1291),s=Math.min;e.exports=function(e){var t=a(e);return t>0?s(t,9007199254740991):0}},8981(e,t,i){var a=i(7750),s=Object;e.exports=function(e){return s(a(e))}},8229(e,t,i){var a=i(9590),s=RangeError;e.exports=function(e,t){var i=a(e);if(i%t)throw new s("Wrong offset");return i}},9590(e,t,i){var a=i(1291),s=RangeError;e.exports=function(e){var t=a(e);if(t<0)throw new s("The argument can't be less than 0");return t}},2777(e,t,i){var a=i(9565),s=i(34),r=i(757),n=i(5966),o=i(4270),l=i(8227),c=TypeError,d=l("toPrimitive");e.exports=function(e,t){if(!s(e)||r(e))return e;var i,l=n(e,d);if(l){void 0===t&&(t="default");i=a(l,e,t);if(!s(i)||r(i))return i;throw new c("Can't convert object to primitive value")}void 0===t&&(t="number");return o(e,t)}},6969(e,t,i){var a=i(2777),s=i(757);e.exports=function(e){var t=a(e,"string");return s(t)?t:t+""}},2140(e,t,i){var a={};a[i(8227)("toStringTag")]="z";e.exports="[object z]"===String(a)},655(e,t,i){var a=i(6955),s=String;e.exports=function(e){if("Symbol"===a(e))throw new TypeError("Cannot convert a Symbol value to a string");return s(e)}},6823(e){var t=String;e.exports=function(e){try{return t(e)}catch(e){return"Object"}}},3392(e,t,i){var a=i(9504),s=0,r=Math.random(),n=a(1.1.toString);e.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+n(++s+r,36)}},9143(e,t,i){var a=i(4576),s=i(9504),r=i(3972),n=i(3463),o=i(9297),l=i(2804),c=i(944),d=i(5169),h=l.c2i,u=l.c2iUrl,_=a.SyntaxError,p=a.TypeError,g=s("".charAt),skipAsciiWhitespace=function(e,t){for(var i=e.length;t<i;t++){var a=g(e,t);if(" "!==a&&"\t"!==a&&"\n"!==a&&"\f"!==a&&"\r"!==a)break}return t},decodeBase64Chunk=function(e,t,i){var a=e.length;a<4&&(e+=2===a?"AA":"A");var s=(t[g(e,0)]<<18)+(t[g(e,1)]<<12)+(t[g(e,2)]<<6)+t[g(e,3)],r=[s>>16&255,s>>8&255,255&s];if(2===a){if(i&&0!==r[1])throw new _("Extra bits");return[r[0]]}if(3===a){if(i&&0!==r[2])throw new _("Extra bits");return[r[0],r[1]]}return r},writeBytes=function(e,t,i){for(var a=t.length,s=0;s<a;s++)e[i+s]=t[s];return i+a};e.exports=function(e,t,i,a){n(e);r(t);var s="base64"===c(t)?h:u,l=t?t.lastChunkHandling:void 0;void 0===l&&(l="loose");if("loose"!==l&&"strict"!==l&&"stop-before-partial"!==l)throw new p("Incorrect `lastChunkHandling` option");i&&d(i.buffer);var f=e.length,m=i||[],v=0,y=0,P="",w=0;if(a)for(;;){if((w=skipAsciiWhitespace(e,w))===f){if(P.length>0){if("stop-before-partial"===l)break;if("loose"!==l)throw new _("Missing padding");if(1===P.length)throw new _("Malformed padding: exactly one additional character");v=writeBytes(m,decodeBase64Chunk(P,s,!1),v)}y=f;break}var b=g(e,w);++w;if("="===b){if(P.length<2)throw new _("Padding is too early");w=skipAsciiWhitespace(e,w);if(2===P.length){if(w===f){if("stop-before-partial"===l)break;throw new _("Malformed padding: only one =")}if("="===g(e,w)){++w;w=skipAsciiWhitespace(e,w)}}if(w<f)throw new _("Unexpected character after padding");v=writeBytes(m,decodeBase64Chunk(P,s,"strict"===l),v);y=f;break}if(!o(s,b))throw new _("Unexpected character");var S=a-v;if(1===S&&2===P.length||2===S&&3===P.length)break;if(4===(P+=b).length){v=writeBytes(m,decodeBase64Chunk(P,s,!1),v);P="";y=w;if(v===a)break}}return{bytes:m,read:y,written:v}}},2303(e,t,i){var a=i(4576),s=i(9504),r=a.Uint8Array,n=a.SyntaxError,o=Math.min,l=s("".match);e.exports=function(e,t){var i=e.length;if(i%2!=0)throw new n("String should be an even number of characters");for(var a=t?o(t.length,i/2):i/2,s=t||new r(a),c=l(e,/.{2}/g),d=0;d<a;d++){var h=+("0x"+c[d]+"0");if(h!=h)throw new n("String should only contain hex characters");s[d]=h>>4}return{bytes:s,read:d<<1}}},7416(e,t,i){var a=i(9039),s=i(8227),r=i(3724),n=i(6395),o=s("iterator");e.exports=!a(function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,i=new URLSearchParams("a=1&a=2&b=3"),a="";e.pathname="c%20d";t.forEach(function(e,i){t.delete("b");a+=i+e});i.delete("a",2);i.delete("b",void 0);return n&&(!e.toJSON||!i.has("a",1)||i.has("a",2)||!i.has("a",void 0)||i.has("b"))||!t.size&&(n||!r)||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[o]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==a||"x"!==new URL("https://x",void 0).host})},7040(e,t,i){var a=i(4495);e.exports=a&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},8686(e,t,i){var a=i(3724),s=i(9039);e.exports=a&&s(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})},2812(e){var t=TypeError;e.exports=function(e,i){if(e<i)throw new t("Not enough arguments");return e}},8622(e,t,i){var a=i(4576),s=i(4901),r=a.WeakMap;e.exports=s(r)&&/native code/.test(String(r))},4995(e,t,i){var a=i(9504),s=WeakMap.prototype;e.exports={WeakMap,set:a(s.set),get:a(s.get),has:a(s.has),remove:a(s.delete)}},8227(e,t,i){var a=i(4576),s=i(5745),r=i(9297),n=i(3392),o=i(4495),l=i(7040),c=a.Symbol,d=s("wks"),h=l?c.for||c:c&&c.withoutSetter||n;e.exports=function(e){r(d,e)||(d[e]=o&&r(c,e)?c[e]:h("Symbol."+e));return d[e]}},7452(e){e.exports="\t\n\v\f\r \u2028\u2029\ufeff"},4601(e,t,i){var a=i(7751),s=i(9297),r=i(6699),n=i(1625),o=i(2967),l=i(7740),c=i(1056),d=i(3167),h=i(2603),u=i(7584),_=i(747),p=i(3724),g=i(6395);e.exports=function(e,t,i,f){var m="stackTraceLimit",v=f?2:1,y=e.split("."),P=y[y.length-1],w=a.apply(null,y);if(w){var b=w.prototype;!g&&s(b,"cause")&&delete b.cause;if(!i)return w;var S=a("Error"),C=t(function(e,t){var i=h(f?t:e,void 0),a=f?new w(e):new w;void 0!==i&&r(a,"message",i);_(a,C,a.stack,2);this&&n(b,this)&&d(a,this,C);arguments.length>v&&u(a,arguments[v]);return a});C.prototype=b;if("Error"!==P)o?o(C,S):l(C,S,{name:!0});else if(p&&m in w){c(C,w,m);c(C,w,"prepareStackTrace")}l(C,w);if(!g)try{b.name!==P&&r(b,"name",P);b.constructor=C}catch(e){}return C}}},6573(e,t,i){var a=i(3724),s=i(2106),r=i(3238),n=ArrayBuffer.prototype;a&&!("detached"in n)&&s(n,"detached",{configurable:!0,get:function detached(){return r(this)}})},7936(e,t,i){var a=i(6518),s=i(5636);s&&a({target:"ArrayBuffer",proto:!0},{transferToFixedLength:function transferToFixedLength(){return s(this,arguments.length?arguments[0]:void 0,!1)}})},8100(e,t,i){var a=i(6518),s=i(5636);s&&a({target:"ArrayBuffer",proto:!0},{transfer:function transfer(){return s(this,arguments.length?arguments[0]:void 0,!0)}})},8107(e,t,i){var a=i(6518),s=i(8981),r=i(6198),n=i(1291),o=i(6469);a({target:"Array",proto:!0},{at:function at(e){var t=s(this),i=r(t),a=n(e),o=a>=0?a:i+a;return o<0||o>=i?void 0:t[o]}});o("at")},838(e,t,i){var a=i(6518),s=i(3839).findLast,r=i(6469);a({target:"Array",proto:!0},{findLast:function findLast(e){return s(this,e,arguments.length>1?arguments[1]:void 0)}});r("findLast")},4423(e,t,i){var a=i(6518),s=i(9617).includes,r=i(9039),n=i(6469),o=r(function(){return!Array(1).includes()}),l=r(function(){return[,1].includes(void 0,1)});a({target:"Array",proto:!0,forced:o||l},{includes:function includes(e){return s(this,e,arguments.length>1?arguments[1]:void 0)}});n("includes")},4114(e,t,i){var a=i(6518),s=i(8981),r=i(6198),n=i(4527),o=i(6837);a({target:"Array",proto:!0,arity:1,forced:i(9039)(function(){return 4294967297!==[].push.call({length:4294967296},1)})||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function push(e){var t=s(this),i=r(t),a=arguments.length;o(i+a);for(var l=0;l<a;l++){t[i]=arguments[l];i++}n(t,i);return i}})},6280(e,t,i){var a=i(6518),s=i(4576),r=i(8745),n=i(4601),o="WebAssembly",l=s[o],c=7!==new Error("e",{cause:7}).cause,exportGlobalErrorCauseWrapper=function(e,t){var i={};i[e]=n(e,t,c);a({global:!0,constructor:!0,arity:1,forced:c},i)},exportWebAssemblyErrorCauseWrapper=function(e,t){if(l&&l[e]){var i={};i[e]=n(o+"."+e,t,c);a({target:o,stat:!0,constructor:!0,arity:1,forced:c},i)}};exportGlobalErrorCauseWrapper("Error",function(e){return function Error(t){return r(e,this,arguments)}});exportGlobalErrorCauseWrapper("EvalError",function(e){return function EvalError(t){return r(e,this,arguments)}});exportGlobalErrorCauseWrapper("RangeError",function(e){return function RangeError(t){return r(e,this,arguments)}});exportGlobalErrorCauseWrapper("ReferenceError",function(e){return function ReferenceError(t){return r(e,this,arguments)}});exportGlobalErrorCauseWrapper("SyntaxError",function(e){return function SyntaxError(t){return r(e,this,arguments)}});exportGlobalErrorCauseWrapper("TypeError",function(e){return function TypeError(t){return r(e,this,arguments)}});exportGlobalErrorCauseWrapper("URIError",function(e){return function URIError(t){return r(e,this,arguments)}});exportWebAssemblyErrorCauseWrapper("CompileError",function(e){return function CompileError(t){return r(e,this,arguments)}});exportWebAssemblyErrorCauseWrapper("LinkError",function(e){return function LinkError(t){return r(e,this,arguments)}});exportWebAssemblyErrorCauseWrapper("RuntimeError",function(e){return function RuntimeError(t){return r(e,this,arguments)}})},8111(e,t,i){var a=i(6518),s=i(4576),r=i(679),n=i(8551),o=i(4901),l=i(2787),c=i(2106),d=i(2278),h=i(9039),u=i(9297),_=i(8227),p=i(7657).IteratorPrototype,g=i(3724),f=i(6395),m="constructor",v="Iterator",y=_("toStringTag"),P=TypeError,w=s[v],b=f||!o(w)||w.prototype!==p||!h(function(){w({})}),S=function Iterator(){r(this,p);if(l(this)===p)throw new P("Abstract class Iterator not directly constructable")},defineIteratorPrototypeAccessor=function(e,t){g?c(p,e,{configurable:!0,get:function(){return t},set:function(t){n(this);if(this===p)throw new P("You can't redefine this property");u(this,e)?this[e]=t:d(this,e,t)}}):p[e]=t};u(p,y)||defineIteratorPrototypeAccessor(y,v);!b&&u(p,m)&&p[m]!==Object||defineIteratorPrototypeAccessor(m,S);S.prototype=p;a({global:!0,constructor:!0,forced:b},{Iterator:S})},9314(e,t,i){var a=i(6518),s=i(9565),r=i(8551),n=i(1767),o=i(4149),l=i(9590),c=i(9539),d=i(9462),h=i(684),u=i(4549),_=i(6395),p=!_&&!h("drop",0),g=!_&&!p&&u("drop",RangeError),f=_||p||g,m=d(function(){for(var e,t=this.iterator,i=this.next;this.remaining;){this.remaining--;e=r(s(i,t));if(this.done=!!e.done)return}e=r(s(i,t));if(!(this.done=!!e.done))return e.value});a({target:"Iterator",proto:!0,real:!0,forced:f},{drop:function drop(e){r(this);var t;try{t=l(o(+e))}catch(e){c(this,"throw",e)}return g?s(g,this,t):new m(n(this),{remaining:t})}})},1148(e,t,i){var a=i(6518),s=i(9565),r=i(2652),n=i(9306),o=i(8551),l=i(1767),c=i(9539),d=i(4549)("every",TypeError);a({target:"Iterator",proto:!0,real:!0,forced:d},{every:function every(e){o(this);try{n(e)}catch(e){c(this,"throw",e)}if(d)return s(d,this,e);var t=l(this),i=0;return!r(t,function(t,a){if(!e(t,i++))return a()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},2489(e,t,i){var a=i(6518),s=i(9565),r=i(9306),n=i(8551),o=i(1767),l=i(9462),c=i(6319),d=i(6395),h=i(9539),u=i(684),_=i(4549),p=!d&&!u("filter",function(){}),g=!d&&!p&&_("filter",TypeError),f=d||p||g,m=l(function(){for(var e,t,i=this.iterator,a=this.predicate,r=this.next;;){e=n(s(r,i));if(this.done=!!e.done)return;t=e.value;if(c(i,a,[t,this.counter++],!0))return t}});a({target:"Iterator",proto:!0,real:!0,forced:f},{filter:function filter(e){n(this);try{r(e)}catch(e){h(this,"throw",e)}return g?s(g,this,e):new m(o(this),{predicate:e})}})},116(e,t,i){var a=i(6518),s=i(9565),r=i(2652),n=i(9306),o=i(8551),l=i(1767),c=i(9539),d=i(4549)("find",TypeError);a({target:"Iterator",proto:!0,real:!0,forced:d},{find:function find(e){o(this);try{n(e)}catch(e){c(this,"throw",e)}if(d)return s(d,this,e);var t=l(this),i=0;return r(t,function(t,a){if(e(t,i++))return a(t)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})},531(e,t,i){var a=i(6518),s=i(9565),r=i(9306),n=i(8551),o=i(1767),l=i(8646),c=i(9462),d=i(9539),h=i(6395),u=i(684),_=i(4549);var p=!h&&!u("flatMap",function(){}),g=!h&&!p&&_("flatMap",TypeError),f=h||p||g||function throwsOnIteratorWithoutReturn(){try{var e=Iterator.prototype.flatMap.call(new Map([[4,5]]).entries(),function(e){return e});e.next();e.return()}catch(e){return!0}}(),m=c(function(){for(var e,t,i=this.iterator,a=this.mapper;;){if(t=this.inner)try{if(!(e=n(s(t.next,t.iterator))).done)return e.value;this.inner=null}catch(e){d(i,"throw",e)}e=n(s(this.next,i));if(this.done=!!e.done)return;try{this.inner=l(a(e.value,this.counter++),!1)}catch(e){d(i,"throw",e)}}});a({target:"Iterator",proto:!0,real:!0,forced:f},{flatMap:function flatMap(e){n(this);try{r(e)}catch(e){d(this,"throw",e)}return g?s(g,this,e):new m(o(this),{mapper:e,inner:null})}})},7588(e,t,i){var a=i(6518),s=i(9565),r=i(2652),n=i(9306),o=i(8551),l=i(1767),c=i(9539),d=i(4549)("forEach",TypeError);a({target:"Iterator",proto:!0,real:!0,forced:d},{forEach:function forEach(e){o(this);try{n(e)}catch(e){c(this,"throw",e)}if(d)return s(d,this,e);var t=l(this),i=0;r(t,function(t){e(t,i++)},{IS_RECORD:!0})}})},1701(e,t,i){var a=i(6518),s=i(9565),r=i(9306),n=i(8551),o=i(1767),l=i(9462),c=i(6319),d=i(9539),h=i(684),u=i(4549),_=i(6395),p=!_&&!h("map",function(){}),g=!_&&!p&&u("map",TypeError),f=_||p||g,m=l(function(){var e=this.iterator,t=n(s(this.next,e));if(!(this.done=!!t.done))return c(e,this.mapper,[t.value,this.counter++],!0)});a({target:"Iterator",proto:!0,real:!0,forced:f},{map:function map(e){n(this);try{r(e)}catch(e){d(this,"throw",e)}return g?s(g,this,e):new m(o(this),{mapper:e})}})},3579(e,t,i){var a=i(6518),s=i(9565),r=i(2652),n=i(9306),o=i(8551),l=i(1767),c=i(9539),d=i(4549)("some",TypeError);a({target:"Iterator",proto:!0,real:!0,forced:d},{some:function some(e){o(this);try{n(e)}catch(e){c(this,"throw",e)}if(d)return s(d,this,e);var t=l(this),i=0;return r(t,function(t,a){if(e(t,i++))return a()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},4972(e,t,i){var a=i(6518),s=i(9565),r=i(8551),n=i(1767),o=i(4149),l=i(9590),c=i(9462),d=i(9539),h=i(684),u=i(4549),_=i(6395),p=!_&&!h("take",1),g=!_&&!p&&u("take",RangeError),f=_||p||g,m=c(function(){var e=this.iterator;if(!this.remaining--){this.done=!0;return d(e,"normal",void 0)}var t=r(s(this.next,e));if(!(this.done=!!t.done))return t.value});a({target:"Iterator",proto:!0,real:!0,forced:f},{take:function take(e){r(this);var t;try{t=l(o(+e))}catch(e){d(this,"throw",e)}return g?s(g,this,t):new m(n(this),{remaining:t})}})},9112(e,t,i){var a=i(6518),s=i(3724),r=i(4576),n=i(7751),o=i(9504),l=i(9565),c=i(4901),d=i(34),h=i(4376),u=i(9297),_=i(655),p=i(6198),g=i(2278),f=i(9039),m=i(8235),v=i(4495),y=r.JSON,P=r.Number,w=r.SyntaxError,b=y&&y.parse,S=n("Object","keys"),C=Object.getOwnPropertyDescriptor,A=o("".charAt),x=o("".slice),k=o(/./.exec),E=o([].push),T=/^\d$/,I=/^[1-9]$/,G=/^[\d-]$/,B=/^[\t\n\r ]$/,internalize=function(e,t,i,a){var s,r,n,o,c,_=e[t],g=a&&_===a.value,f=g&&"string"==typeof a.source?{source:a.source}:{};if(d(_)){var m=h(_),v=g?a.nodes:m?[]:{};if(m){s=v.length;n=p(_);for(o=0;o<n;o++)internalizeProperty(_,o,internalize(_,""+o,i,o<s?v[o]:void 0))}else{r=S(_);n=p(r);for(o=0;o<n;o++){c=r[o];internalizeProperty(_,c,internalize(_,c,i,u(v,c)?v[c]:void 0))}}}return l(i,e,t,_,f)},internalizeProperty=function(e,t,i){if(s){var a=C(e,t);if(a&&!a.configurable)return}void 0===i?delete e[t]:g(e,t,i)},Node=function(e,t,i,a){this.value=e;this.end=t;this.source=i;this.nodes=a},Context=function(e,t){this.source=e;this.index=t};Context.prototype={fork:function(e){return new Context(this.source,e)},parse:function(){var e=this.source,t=this.skip(B,this.index),i=this.fork(t),a=A(e,t);if(k(G,a))return i.number();switch(a){case"{":return i.object();case"[":return i.array();case'"':return i.string();case"t":return i.keyword(!0);case"f":return i.keyword(!1);case"n":return i.keyword(null)}throw new w('Unexpected character: "'+a+'" at: '+t)},node:function(e,t,i,a,s){return new Node(t,a,e?null:x(this.source,i,a),s)},object:function(){for(var e=this.source,t=this.index+1,i=!1,a={},s={},r=!1;t<e.length;){t=this.until(['"',"}"],t);if("}"===A(e,t)&&!i){t++;r=!0;break}var n=this.fork(t).string(),o=n.value;t=n.end;t=this.until([":"],t)+1;t=this.skip(B,t);n=this.fork(t).parse();g(s,o,n);g(a,o,n.value);t=this.until([",","}"],n.end);var l=A(e,t);if(","===l){i=!0;t++}else if("}"===l){t++;r=!0;break}}if(!r)throw new w("Unterminated object at: "+t);return this.node(1,a,this.index,t,s)},array:function(){for(var e=this.source,t=this.index+1,i=!1,a=[],s=[],r=!1;t<e.length;){t=this.skip(B,t);if("]"===A(e,t)&&!i){t++;r=!0;break}var n=this.fork(t).parse();E(s,n);E(a,n.value);t=this.until([",","]"],n.end);if(","===A(e,t)){i=!0;t++}else if("]"===A(e,t)){t++;r=!0;break}}if(!r)throw new w("Unterminated array at: "+t);return this.node(1,a,this.index,t,s)},string:function(){var e=this.index,t=m(this.source,this.index+1);return this.node(0,t.value,e,t.end)},number:function(){var e=this.source,t=this.index,i=t;"-"===A(e,i)&&i++;if("0"===A(e,i))i++;else{if(!k(I,A(e,i)))throw new w("Failed to parse number at: "+i);i=this.skip(T,i+1)}if("."===A(e,i)){var a=i+1;if(a===(i=this.skip(T,a)))throw new w("Failed to parse number's fraction at: "+i)}if("e"===A(e,i)||"E"===A(e,i)){i++;"+"!==A(e,i)&&"-"!==A(e,i)||i++;if(i===(i=this.skip(T,i)))throw new w("Failed to parse number's exponent value at: "+i)}return this.node(0,P(x(e,t,i)),t,i)},keyword:function(e){var t=""+e,i=this.index,a=i+t.length;if(x(this.source,i,a)!==t)throw new w("Failed to parse value at: "+i);return this.node(0,e,i,a)},skip:function(e,t){for(var i=this.source;t<i.length&&k(e,A(i,t));t++);return t},until:function(e,t){t=this.skip(B,t);for(var i=A(this.source,t),a=0;a<e.length;a++)if(e[a]===i)return t;throw new w('Unexpected character: "'+i+'" at: '+t)}};var M=f(function(){var e,t="9007199254740993";b(t,function(t,i,a){e=a.source});return e!==t}),D=v&&!f(function(){return 1/b("-0 \t")!=-1/0});a({target:"JSON",stat:!0,forced:M},{parse:function parse(e,t){return D&&!c(t)?b(e):function(e,t){e=_(e);var i=new Context(e,0,""),a=i.parse(),s=a.value,r=i.skip(B,a.end);if(r<e.length)throw new w('Unexpected extra character: "'+A(e,r)+'" after the parsed data at: '+r);return c(t)?internalize({"":s},"",t,a):s}(e,t)}})},3110(e,t,i){var a=i(6518),s=i(7751),r=i(8745),n=i(9565),o=i(9504),l=i(9039),c=i(4376),d=i(4901),h=i(5810),u=i(757),_=i(2195),p=i(655),g=i(7680),f=i(8235),m=i(3392),v=i(4495),y=i(7819),P=String,w=s("JSON","stringify"),b=o(/./.exec),S=o("".charAt),C=o("".charCodeAt),A=o("".replace),x=o("".slice),k=o([].push),E=o(1.1.toString),T=/[\uD800-\uDFFF]/g,I=/^[\uD800-\uDBFF]$/,G=/^[\uDC00-\uDFFF]$/,B=m(),M=B.length,D=!v||l(function(){var e=s("Symbol")("stringify detection");return"[null]"!==w([e])||"{}"!==w({a:e})||"{}"!==w(Object(e))}),L=l(function(){return'"\\udf06\\ud834"'!==w("\udf06\ud834")||'"\\udead"'!==w("\udead")}),O=D?function(e,t){var i=g(arguments),a=getReplacerFunction(t);if(d(a)||void 0!==e&&!u(e)){i[1]=function(e,t){d(a)&&(t=n(a,this,P(e),t));if(!u(t))return t};return r(w,null,i)}}:w,fixIllFormedJSON=function(e,t,i){var a=S(i,t-1),s=S(i,t+1);return b(I,e)&&!b(G,s)||b(G,e)&&!b(I,a)?"\\u"+E(C(e,0),16):e},getReplacerFunction=function(e){if(d(e))return e;if(c(e)){for(var t=e.length,i=[],a=0;a<t;a++){var s=e[a];"string"==typeof s?k(i,s):"number"!=typeof s&&"Number"!==_(s)&&"String"!==_(s)||k(i,p(s))}var r=i.length,n=!0;return function(e,t){if(n){n=!1;return t}if(c(this))return t;for(var a=0;a<r;a++)if(i[a]===e)return t}}};w&&a({target:"JSON",stat:!0,arity:3,forced:D||L||!y},{stringify:function stringify(e,t,i){var a=getReplacerFunction(t),s=[],r=O(e,function(e,t){var i=d(a)?n(a,this,P(e),t):t;return!y&&h(i)?B+(k(s,i.rawJSON)-1):i},i);if("string"!=typeof r)return r;L&&(r=A(r,T,fixIllFormedJSON));if(y)return r;for(var o="",l=r.length,c=0;c<l;c++){var u=S(r,c);if('"'===u){var _=f(r,++c).end-1,p=x(r,c,_);o+=x(p,0,M)===B?s[x(p,M)]:'"'+p+'"';c=_}else o+=u}return o}})},2731(e,t,i){var a=i(6518),s=i(9306),r=i(2248),n=i(6395),o=r.get,l=r.has,c=r.set;a({target:"Map",proto:!0,real:!0,forced:n},{getOrInsertComputed:function getOrInsertComputed(e,t){var i=l(this,e);s(t);if(i)return o(this,e);0===e&&1/e==-1/0&&(e=0);var a=t(e);c(this,e,a);return a}})},5367(e,t,i){var a=i(6518),s=i(2248),r=i(6395),n=s.get,o=s.has,l=s.set;a({target:"Map",proto:!0,real:!0,forced:r},{getOrInsert:function getOrInsert(e,t){if(o(this,e))return n(this,e);l(this,e,t);return t}})},3068(e,t,i){var a=i(6518),s=i(9504),r=i(2652),n=RangeError,o=TypeError,l=1/0,c=Math.abs,d=Math.pow,h=s([].push),u=d(2,1023),_=d(2,53)-1,p=Number.MAX_VALUE,g=d(2,971),f={},m={},v={},y={},P={},twosum=function(e,t){var i=e+t;return{hi:i,lo:t-(i-e)}};a({target:"Math",stat:!0},{sumPrecise:function sumPrecise(e){var t=[],i=0,a=y;r(e,function(e){if(++i>_)throw new n("Maximum allowed index exceeded");if("number"!=typeof e)throw new o("Value is not a number");if(a!==f)if(e!=e)a=f;else if(e===l)a=a===m?f:v;else if(e===-1/0)a=a===v?f:m;else if(!(0===e&&1/e!==l||a!==y&&a!==P)){a=P;h(t,e)}});switch(a){case f:return NaN;case m:return-1/0;case v:return l;case y:return-0}for(var s,d,w,b,S,C,A=[],x=0,k=0;k<t.length;k++){s=t[k];for(var E=0,T=0;T<A.length;T++){d=A[T];if(c(s)<c(d)){C=s;s=d;d=C}b=(w=twosum(s,d)).hi;S=w.lo;if(c(b)===l){var I=b===l?1:-1;x+=I;if(c(s=s-I*u-I*u)<c(d)){C=s;s=d;d=C}b=(w=twosum(s,d)).hi;S=w.lo}0!==S&&(A[E++]=S);s=b}A.length=E;0!==s&&h(A,s)}var G=A.length-1;b=0;S=0;if(0!==x){var B=G>=0?A[G]:0;G--;if(c(x)>1||x>0&&B>0||x<0&&B<0)return x>0?l:-1/0;b=(w=twosum(x*u,B/2)).hi;S=w.lo;S*=2;if(c(2*b)===l)return b>0?b===u&&S===-g/2&&G>=0&&A[G]<0?p:l:b===-u&&S===g/2&&G>=0&&A[G]>0?-p:-1/0;if(0!==S){A[++G]=S;S=0}b*=2}for(;G>=0;){b=(w=twosum(b,A[G--])).hi;if(0!==(S=w.lo))break}G>=0&&(S<0&&A[G]<0||S>0&&A[G]>0)&&(d=2*S)===(s=b+d)-b&&(b=s);return b}})},8347(e,t,i){i(6518)({target:"Object",stat:!0},{hasOwn:i(9297)})},1689(e,t,i){var a=i(6518),s=i(4576),r=i(8745),n=i(7680),o=i(6043),l=i(9306),c=i(1103),d=s.Promise,h=!1;a({target:"Promise",stat:!0,forced:!d||!d.try||c(function(){d.try(function(e){h=8===e},8)}).error||!h},{try:function(e){var t=arguments.length>1?n(arguments,1):[],i=o.f(this),a=c(function(){return r(l(e),void 0,t)});(a.error?i.reject:i.resolve)(a.value);return i.promise}})},4628(e,t,i){var a=i(6518),s=i(6043);a({target:"Promise",stat:!0},{withResolvers:function withResolvers(){var e=s.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}})},6069(e,t,i){var a=i(6518),s=i(9504),r=i(3463),n=i(9297),o=i(533).start,l=i(7452),c=Array,d=RegExp.escape,h=s("".charAt),u=s("".charCodeAt),_=s(1.1.toString),p=s([].join),g=/^[0-9a-z]/i,f=/^[$()*+./?[\\\]^{|}]/,m=RegExp("^[!\"#%&',\\-:;<=>@`~"+l+"]"),v=s(g.exec),y={"\t":"t","\n":"n","\v":"v","\f":"f","\r":"r"},escapeChar=function(e){var t=_(u(e,0),16);return t.length<3?"\\x"+o(t,2,"0"):"\\u"+o(t,4,"0")};a({target:"RegExp",stat:!0,forced:!d||"\\x61b"!==d("ab")},{escape:function escape(e){r(e);for(var t=e.length,i=c(t),a=0;a<t;a++){var s=h(e,a);if(0===a&&v(g,s))i[a]=escapeChar(s);else if(n(y,s))i[a]="\\"+y[s];else if(v(f,s))i[a]="\\"+s;else if(v(m,s))i[a]=escapeChar(s);else{var o=u(s,0);if(55296!=(63488&o))i[a]=s;else if(o>=56320||a+1>=t||56320!=(64512&u(e,a+1)))i[a]=escapeChar(s);else{i[a]=s;i[++a]=h(e,a)}}}return p(i,"")}})},7642(e,t,i){var a=i(6518),s=i(3440),r=i(9039);a({target:"Set",proto:!0,real:!0,forced:!i(4916)("difference",function(e){return 0===e.size})||r(function(){var e={size:1,has:function(){return!0},keys:function(){var e=0;return{next:function(){var i=e++>1;t.has(1)&&t.clear();return{done:i,value:2}}}}},t=new Set([1,2,3,4]);return 3!==t.difference(e).size})},{difference:s})},8004(e,t,i){var a=i(6518),s=i(9039),r=i(8750);a({target:"Set",proto:!0,real:!0,forced:!i(4916)("intersection",function(e){return 2===e.size&&e.has(1)&&e.has(2)})||s(function(){return"3,2"!==String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))})},{intersection:r})},3853(e,t,i){var a=i(6518),s=i(4449);a({target:"Set",proto:!0,real:!0,forced:!i(4916)("isDisjointFrom",function(e){return!e})},{isDisjointFrom:s})},5876(e,t,i){var a=i(6518),s=i(3838);a({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSubsetOf",function(e){return e})},{isSubsetOf:s})},2475(e,t,i){var a=i(6518),s=i(8527);a({target:"Set",proto:!0,real:!0,forced:!i(4916)("isSupersetOf",function(e){return!e})},{isSupersetOf:s})},5024(e,t,i){var a=i(6518),s=i(3650),r=i(9835);a({target:"Set",proto:!0,real:!0,forced:!i(4916)("symmetricDifference")||!r("symmetricDifference")},{symmetricDifference:s})},1698(e,t,i){var a=i(6518),s=i(4204),r=i(9835);a({target:"Set",proto:!0,real:!0,forced:!i(4916)("union")||!r("union")},{union:s})},7357(e,t,i){var a=i(6518),s=i(9504),r=i(7750),n=i(1291),o=i(655),l=i(9039),c=s("".charAt);a({target:"String",proto:!0,forced:l(function(){return"\ud842"!=="𠮷".at(-2)})},{at:function at(e){var t=o(r(this)),i=t.length,a=n(e),s=a>=0?a:i+a;return s<0||s>=i?void 0:c(t,s)}})},8140(e,t,i){var a=i(4644),s=i(6198),r=i(1291),n=a.aTypedArray;(0,a.exportTypedArrayMethod)("at",function at(e){var t=n(this),i=s(t),a=r(e),o=a>=0?a:i+a;return o<0||o>=i?void 0:t[o]})},5044(e,t,i){var a=i(4644),s=i(4373),r=i(5854),n=i(6955),o=i(9565),l=i(9504),c=i(9039),d=a.aTypedArray,h=a.exportTypedArrayMethod,u=l("".slice);h("fill",function fill(e){var t=arguments.length;d(this);var i="Big"===u(n(this),0,3)?r(e):+e;return o(s,this,i,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},c(function(){var e=0;new Int8Array(2).fill({valueOf:function(){return e++}});return 1!==e}))},1134(e,t,i){var a=i(4644),s=i(3839).findLastIndex,r=a.aTypedArray;(0,a.exportTypedArrayMethod)("findLastIndex",function findLastIndex(e){return s(r(this),e,arguments.length>1?arguments[1]:void 0)})},1903(e,t,i){var a=i(4644),s=i(3839).findLast,r=a.aTypedArray;(0,a.exportTypedArrayMethod)("findLast",function findLast(e){return s(r(this),e,arguments.length>1?arguments[1]:void 0)})},8845(e,t,i){var a=i(4576),s=i(9565),r=i(4644),n=i(6198),o=i(8229),l=i(8981),c=i(9039),d=a.RangeError,h=a.Int8Array,u=h&&h.prototype,_=u&&u.set,p=r.aTypedArray,g=r.exportTypedArrayMethod,f=!c(function(){var e=new Uint8ClampedArray(2);s(_,e,{length:1,0:3},1);return 3!==e[1]}),m=f&&r.NATIVE_ARRAY_BUFFER_VIEWS&&c(function(){var e=new h(2);e.set(1);e.set("2",1);return 0!==e[0]||2!==e[1]});g("set",function set(e){p(this);var t=o(arguments.length>1?arguments[1]:void 0,1),i=l(e);if(f)return s(_,this,i,t);var a=this.length,r=n(i),c=0;if(r+t>a)throw new d("Wrong length");for(;c<r;)this[t+c]=i[c++]},!f||m)},373(e,t,i){var a=i(4576),s=i(7476),r=i(9039),n=i(9306),o=i(4488),l=i(4644),c=i(3709),d=i(3763),h=i(9519),u=i(3607),_=l.aTypedArray,p=l.exportTypedArrayMethod,g=a.Uint16Array,f=g&&s(g.prototype.sort),m=!(!f||r(function(){f(new g(2),null)})&&r(function(){f(new g(2),{})})),v=!!f&&!r(function(){if(h)return h<74;if(c)return c<67;if(d)return!0;if(u)return u<602;var e,t,i=new g(516),a=Array(516);for(e=0;e<516;e++){t=e%4;i[e]=515-e;a[e]=e-2*t+3}f(i,function(e,t){return(e/4|0)-(t/4|0)});for(e=0;e<516;e++)if(i[e]!==a[e])return!0});p("sort",function sort(e){void 0!==e&&n(e);return v?f(this,e):o(_(this),function(e){return function(t,i){return void 0!==e?+e(t,i)||0:i!=i?t!=t?0:-1:t!=t?1:0===t&&0===i?1/t>0?1/i>0?0:1:1/i>0?-1:0:t>i?1:t<i?-1:0}}(e))},!v||m)},7467(e,t,i){var a=i(6198),s=i(4644),r=s.aTypedArray,n=s.exportTypedArrayMethod,o=s.getTypedArrayConstructor;n("toReversed",function toReversed(){for(var e=r(this),t=a(e),i=new(o(e))(t),s=0;s<t;s++)i[s]=e[t-s-1];return i})},4732(e,t,i){var a=i(4644),s=i(9504),r=i(9306),n=i(5370),o=a.aTypedArray,l=a.getTypedArrayConstructor,c=a.exportTypedArrayMethod,d=s(a.TypedArrayPrototype.sort);c("toSorted",function toSorted(e){void 0!==e&&r(e);var t=o(this),i=n(l(t),t);return d(i,e)})},9577(e,t,i){var a=i(4644),s=i(1108),r=i(6198),n=i(1291),o=i(5854),l=a.aTypedArray,c=a.getTypedArrayConstructor,d=a.exportTypedArrayMethod,h=RangeError,u=function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(e){return 8===e}}(),_=u&&function(){try{new Int8Array(1).with(-.5,1)}catch(e){return!0}}();d("with",{with:function(e,t){var i=l(this),a=r(i),d=n(e),u=d<0?a+d:d,_=s(i)?o(t):+t;if(u>=a||u<0)throw new h("Incorrect index");for(var p=new(c(i))(a),g=0;g<a;g++)p[g]=g===u?_:i[g];return p}}.with,!u||_)},5213(e,t,i){var a=i(6518),s=i(4576),r=i(5370),n=i(9143),o=s.Uint8Array,l=!o||!o.fromBase64||!function(){try{o.fromBase64("a");return}catch(e){}try{o.fromBase64("",null)}catch(e){return!0}}();o&&a({target:"Uint8Array",stat:!0,forced:l},{fromBase64:function fromBase64(e){var t=n(e,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return r(o,t.bytes)}})},6632(e,t,i){var a=i(6518),s=i(4576),r=i(9143),n=i(4154),o=s.Uint8Array,l=!o||!o.prototype.setFromBase64||!function(){var e=new o([255,255,255,255,255]);try{e.setFromBase64("",null);return}catch(e){}try{e.setFromBase64("a");return}catch(e){}try{e.setFromBase64("MjYyZg===")}catch(t){return 50===e[0]&&54===e[1]&&50===e[2]&&255===e[3]&&255===e[4]}}();o&&a({target:"Uint8Array",proto:!0,forced:l},{setFromBase64:function setFromBase64(e){n(this);var t=r(e,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:t.read,written:t.written}}})},4226(e,t,i){var a=i(6518),s=i(4576),r=i(3463),n=i(4154),o=i(5169),l=i(2303);s.Uint8Array&&a({target:"Uint8Array",proto:!0,forced:function throwsOnLengthTrackingView(){try{var e=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(e).setFromHex("cafed00d")}catch(e){return!0}}()},{setFromHex:function setFromHex(e){n(this);r(e);o(this.buffer);var t=l(e,this).read;return{read:t,written:t/2}}})},9486(e,t,i){var a=i(6518),s=i(4576),r=i(9504),n=i(3972),o=i(4154),l=i(5169),c=i(2804),d=i(944),h=c.i2c,u=c.i2cUrl,_=r("".charAt),p=s.Uint8Array,g=!p||!p.prototype.toBase64||!function(){try{(new p).toBase64(null)}catch(e){return!0}}();p&&a({target:"Uint8Array",proto:!0,forced:g},{toBase64:function toBase64(){var e=o(this),t=arguments.length?n(arguments[0]):void 0,i="base64"===d(t)?h:u,a=!!t&&!!t.omitPadding;l(this.buffer);for(var s,r="",c=0,p=e.length,at=function(e){return _(i,s>>6*e&63)};c+2<p;c+=3){s=(e[c]<<16)+(e[c+1]<<8)+e[c+2];r+=at(3)+at(2)+at(1)+at(0)}if(c+2===p){s=(e[c]<<16)+(e[c+1]<<8);r+=at(3)+at(2)+at(1)+(a?"":"=")}else if(c+1===p){s=e[c]<<16;r+=at(3)+at(2)+(a?"":"==")}return r}})},456(e,t,i){var a=i(6518),s=i(4576),r=i(9504),n=i(4154),o=i(5169),l=r(1.1.toString),c=r([].join),d=Array,h=s.Uint8Array,u=!h||!h.prototype.toHex||!function(){try{return"ffffffffffffffff"===new h([255,255,255,255,255,255,255,255]).toHex()}catch(e){return!1}}();h&&a({target:"Uint8Array",proto:!0,forced:u},{toHex:function toHex(){n(this);o(this.buffer);for(var e=d(this.length),t=0,i=this.length;t<i;t++){var a=l(this[t],16);e[t]=1===a.length?"0"+a:a}return c(e,"")}})},9452(e,t,i){var a=i(6518),s=i(9306),r=i(6557),n=i(4328),o=i(4995),l=i(6395),c=o.get,d=o.has,h=o.set;a({target:"WeakMap",proto:!0,real:!0,forced:l||!function(){try{WeakMap.prototype.getOrInsertComputed&&(new WeakMap).getOrInsertComputed(1,function(){throw 1})}catch(e){return e instanceof TypeError}}()},{getOrInsertComputed:function getOrInsertComputed(e,t){l||r(this);n(e);s(t);if(d(this,e))return c(this,e);var i=t(e);h(this,e,i);return i}})},8454(e,t,i){var a=i(6518),s=i(4995),r=i(6395),n=s.get,o=s.has,l=s.set;a({target:"WeakMap",proto:!0,real:!0,forced:r},{getOrInsert:function getOrInsert(e,t){if(o(this,e))return n(this,e);l(this,e,t);return t}})},4979(e,t,i){var a=i(6518),s=i(4576),r=i(7751),n=i(6980),o=i(4913).f,l=i(9297),c=i(679),d=i(3167),h=i(2603),u=i(5002),_=i(6193),p=i(3724),g=i(6395),f="DOMException",m=r("Error"),v=r(f),y=function DOMException(){c(this,P);var e=arguments.length,t=h(e<1?void 0:arguments[0]),i=h(e<2?void 0:arguments[1],"Error"),a=new v(t,i),s=new m(t);s.name=f;o(a,"stack",n(1,_(s.stack,1)));d(a,this,y);return a},P=y.prototype=v.prototype,w="stack"in new m(f),b="stack"in new v(1,2),S=v&&p&&Object.getOwnPropertyDescriptor(s,f),C=!(!S||S.writable&&S.configurable),A=w&&!C&&!b;a({global:!0,constructor:!0,forced:g||A},{DOMException:A?y:v});var x=r(f),k=x.prototype;if(k.constructor!==x){g||o(k,"constructor",n(1,x));for(var E in u)if(l(u,E)){var T=u[E],I=T.s;l(x,I)||o(x,I,n(6,T.c))}}},3611(e,t,i){var a=i(6518),s=i(4576),r=i(2106),n=i(3724),o=TypeError,l=Object.defineProperty,c=s.self!==s;try{if(n){var d=Object.getOwnPropertyDescriptor(s,"self");!c&&d&&d.get&&d.enumerable||r(s,"self",{get:function self(){return s},set:function self(e){if(this!==s)throw new o("Illegal invocation");l(s,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}else a({global:!0,simple:!0,forced:c},{self:s})}catch(e){}},4603(e,t,i){var a=i(6840),s=i(9504),r=i(655),n=i(2812),o=URLSearchParams,l=o.prototype,c=s(l.append),d=s(l.delete),h=s(l.forEach),u=s([].push),_=new o("a=1&a=2&b=3");_.delete("a",1);_.delete("b",void 0);_+""!="a=2"&&a(l,"delete",function(e){var t=arguments.length,i=t<2?void 0:arguments[1];if(t&&void 0===i)return d(this,e);var a=[];h(this,function(e,t){u(a,{key:t,value:e})});n(t,1);for(var s,o=r(e),l=r(i),_=0,p=a.length;_<p;){d(this,(s=a[_]).key);_++}_=0;for(;_<p;)(s=a[_++]).key===o&&s.value===l||c(this,s.key,s.value)},{enumerable:!0,unsafe:!0})},7566(e,t,i){var a=i(6840),s=i(9504),r=i(655),n=i(2812),o=URLSearchParams,l=o.prototype,c=s(l.getAll),d=s(l.has),h=new o("a=1");!h.has("a",2)&&h.has("a",void 0)||a(l,"has",function has(e){var t=arguments.length,i=t<2?void 0:arguments[1];if(t&&void 0===i)return d(this,e);var a=c(this,e);n(t,1);for(var s=r(i),o=0;o<a.length;)if(a[o++]===s)return!0;return!1},{enumerable:!0,unsafe:!0})},8721(e,t,i){var a=i(3724),s=i(9504),r=i(2106),n=URLSearchParams.prototype,o=s(n.forEach);a&&!("size"in n)&&r(n,"size",{get:function size(){var e=0;o(this,function(){e++});return e},configurable:!0,enumerable:!0})},5781(e,t,i){var a=i(6518),s=i(7751),r=i(2812),n=i(655),o=i(7416),l=s("URL");a({target:"URL",stat:!0,forced:!o},{parse:function parse(e){var t=r(arguments.length,1),i=n(e),a=t<2||void 0===arguments[1]?void 0:n(arguments[1]);try{return new l(i,a)}catch(e){return null}}})}},t={};function __webpack_require__(i){var a=t[i];if(void 0!==a)return a.exports;var s=t[i]={exports:{}};e[i].call(s.exports,s,s.exports,__webpack_require__);return s.exports}__webpack_require__.d=(e,t)=>{for(var i in t)__webpack_require__.o(t,i)&&!__webpack_require__.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})};__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i;__webpack_require__(6280),__webpack_require__(4423),__webpack_require__(4114),__webpack_require__(6573),__webpack_require__(8100),__webpack_require__(7936),__webpack_require__(8111),__webpack_require__(2489),__webpack_require__(5367),__webpack_require__(2731),__webpack_require__(8140),__webpack_require__(5044),__webpack_require__(1903),__webpack_require__(1134),__webpack_require__(8845),__webpack_require__(373),__webpack_require__(7467),__webpack_require__(4732),__webpack_require__(9577),__webpack_require__(6632),__webpack_require__(4226),__webpack_require__(9486),__webpack_require__(456),__webpack_require__(3611),__webpack_require__(5781);class ngx_console_NgxConsole{static log(e,t){ngx_console_NgxConsole.ngxConsoleFilter("log",e)&&(void 0!==t?console.log("%s",e,t):console.log(e))}static error(e,t){ngx_console_NgxConsole.ngxConsoleFilter("error",e)&&(void 0!==t?console.error("%s",e,t):console.error(e))}static warn(e,t){ngx_console_NgxConsole.ngxConsoleFilter("warn",e)&&(void 0!==t?console.warn("%s",e,t):console.warn(e))}static debug(e,t){ngx_console_NgxConsole.ngxConsoleFilter("debug",e)&&(void 0!==t?console.warn("%s",e,t):console.warn(e))}get ngxConsoleFilter(){return ngx_console_NgxConsole.ngxConsoleFilter}set ngxConsoleFilter(e){ngx_console_NgxConsole.ngxConsoleFilter=e}reset(){ngx_console_NgxConsole.ngxConsoleFilter=(e,t)=>!0}}!function _defineProperty(e,t,i){return(t=function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(ngx_console_NgxConsole,"ngxConsoleFilter",(e,t)=>!0);function _toArray(e){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(e,t):void 0}}(e)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function _assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const a=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),s=[1/0,1/0,-1/0,-1/0],r=new Float32Array(s),n=[.001,0,0,.001,0,0],o=1.35,l="http://www.w3.org/2000/svg",c=1,d=2,h=4,u=16,_=32,p=64,g=128,f=256,m={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},v="pdfjs_internal_id_",y="pdfjs_internal_editor_",P={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},w={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},b={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},S=0,C=1,A=2,x=3,k=3,E=4,T={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},I={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},G=1,B=2,M=3,D=4,L=5,O={ERRORS:0,WARNINGS:1,INFOS:5},R={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},N=0,j=1,W=2,U=3,V=4,H={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let z=O.WARNINGS;function setVerbosityLevel(e){Number.isInteger(e)&&(z=e)}function getVerbosityLevel(){return z}function info(e){z>=O.INFOS&&("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope||Window&&ngx_console_NgxConsole?ngx_console_NgxConsole.log(`Info: ${e}`):console.log(`Info: ${e}`))}function warn(e){z>=O.WARNINGS&&("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope||Window&&ngx_console_NgxConsole?ngx_console_NgxConsole.log(`Warning: ${e}`):console.log(`Warning: ${e}`))}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function createValidAbsoluteUrl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!e)return null;if(i&&"string"==typeof e){if(i.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(i.tryConvertEncoding)try{e=function stringToUTF8String(e){return decodeURIComponent(escape(e))}(e)}catch{}}const a=t?URL.parse(e,t):URL.parse(e);return function _isValidProtocol(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":case"capacitor":return!0;default:return!1}}(a)?a:null}function updateUrlHash(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const a=URL.parse(e);if(a){a.hash=t;return a.href}return i&&createValidAbsoluteUrl(e,"http://example.com")?e.split("#",1)[0]+""+(t?`#${t}`:""):""}function stripPath(e){return e.substring(e.lastIndexOf("/")+1)}function shadow(e,t,i){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Object.defineProperty(e,t,{value:i,enumerable:!a,configurable:!0,writable:!1});return i}const $=function BaseExceptionClosure(){function BaseException(e,t){this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();class PasswordException extends ${constructor(e,t){super(e,"PasswordException");this.code=t}}class UnknownErrorException extends ${constructor(e,t){super(e,"UnknownErrorException");this.details=t}}class InvalidPDFException extends ${constructor(e){super(e,"InvalidPDFException")}}class ResponseException extends ${constructor(e,t,i){super(e,"ResponseException");this.status=t;this.missing=i}}class FormatError extends ${constructor(e){super(e,"FormatError")}}class AbortException extends ${constructor(e){super(e,"AbortException")}}function stringToBytes(e){"string"!=typeof e&&unreachable("Invalid argument for stringToBytes");const t=e.length,i=new Uint8Array(t);for(let a=0;a<t;++a)i[a]=255&e.charCodeAt(a);return i}class FeatureTest{static get isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return shadow(this,"isLittleEndian",1===new Uint32Array(e.buffer,0,1)[0])}static get isOffscreenCanvasSupported(){return shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return shadow(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get isFloat16ArraySupported(){return shadow(this,"isFloat16ArraySupported","undefined"!=typeof Float16Array)}static get isSanitizerSupported(){return shadow(this,"isSanitizerSupported","undefined"!=typeof Sanitizer)}static get platform(){const e=navigator,t=e.platform,i=e.userAgent;return shadow(this,"platform",{isAndroid:i.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:i.includes("Firefox")})}static get isCanvasFilterSupported(){let e;this.isOffscreenCanvasSupported?e=new OffscreenCanvas(1,1).getContext("2d"):"undefined"!=typeof document&&(e=document.createElement("canvas").getContext("2d"));return shadow(this,"isCanvasFilterSupported",void 0!==e?.filter)}static get isAlphaColorInputSupported(){if("undefined"==typeof document)return shadow(this,"isAlphaColorInputSupported",!1);const e=document.createElement("input");e.type="color";e.setAttribute("alpha","");e.value="#ff000080";return shadow(this,"isAlphaColorInputSupported","#ff0000"!==e.value)}}class Util{static get hexNums(){return shadow(this,"hexNums",Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,"0")))}static makeHexColor(e,t,i){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[i]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const a=e[i],s=e[i+1];e[i]=a*t[0]+s*t[2]+t[4];e[i+1]=a*t[1]+s*t[3]+t[5]}static applyTransformToBezier(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const a=t[0],s=t[1],r=t[2],n=t[3],o=t[4],l=t[5];for(let t=0;t<6;t+=2){const c=e[i+t],d=e[i+t+1];e[i+t]=c*a+d*r+o;e[i+t+1]=c*s+d*n+l}}static applyInverseTransform(e,t){const i=e[0],a=e[1],s=t[0]*t[3]-t[1]*t[2];e[0]=(i*t[3]-a*t[2]+t[2]*t[5]-t[4]*t[3])/s;e[1]=(-i*t[1]+a*t[0]+t[4]*t[1]-t[5]*t[0])/s}static axialAlignedBoundingBox(e,t,i){const a=t[0],s=t[1],r=t[2],n=t[3],o=t[4],l=t[5],c=e[0],d=e[1],h=e[2],u=e[3];let _=a*c+o,p=_,g=a*h+o,f=g,m=n*d+l,v=m,y=n*u+l,P=y;if(0!==s||0!==r){const e=s*c,t=s*h,i=r*d,a=r*u;_+=i;f+=i;g+=a;p+=a;m+=e;P+=e;y+=t;v+=t}i[0]=Math.min(i[0],_,g,p,f);i[1]=Math.min(i[1],m,y,v,P);i[2]=Math.max(i[2],_,g,p,f);i[3]=Math.max(i[3],m,y,v,P)}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){const i=e[0],a=e[1],s=e[2],r=e[3],n=i**2+a**2,o=i*s+a*r,l=s**2+r**2,c=(n+l)/2,d=Math.sqrt(c**2-(n*l-o**2));t[0]=Math.sqrt(c+d||1);t[1]=Math.sqrt(c-d||1)}static normalizeRect(e){const t=e.slice(0);if(e[0]>e[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){const i=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(i>a)return null;const s=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),r=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return s>r?null:[i,s,a,r]}static pointBoundingBox(e,t,i){i[0]=Math.min(i[0],e);i[1]=Math.min(i[1],t);i[2]=Math.max(i[2],e);i[3]=Math.max(i[3],t)}static rectBoundingBox(e,t,i,a,s){s[0]=Math.min(s[0],e,i);s[1]=Math.min(s[1],t,a);s[2]=Math.max(s[2],e,i);s[3]=Math.max(s[3],t,a)}static bezierBoundingBox(e,t,i,a,s,r,n,o,l){l[0]=Math.min(l[0],e,n);l[1]=Math.min(l[1],t,o);l[2]=Math.max(l[2],e,n);l[3]=Math.max(l[3],t,o);_assertClassBrand(Util,this,_getExtremum).call(this,e,i,s,n,t,a,r,o,3*(3*(i-s)-e+n),6*(e-2*i+s),3*(i-e),l);_assertClassBrand(Util,this,_getExtremum).call(this,e,i,s,n,t,a,r,o,3*(3*(a-r)-t+o),6*(t-2*a+r),3*(a-t),l)}}i=Util;function _getExtremumOnCurve(e,t,i,a,s,r,n,o,l,c){if(l<=0||l>=1)return;const d=1-l,h=l*l,u=h*l,_=d*(d*(d*e+3*l*t)+3*h*i)+u*a,p=d*(d*(d*s+3*l*r)+3*h*n)+u*o;c[0]=Math.min(c[0],_);c[1]=Math.min(c[1],p);c[2]=Math.max(c[2],_);c[3]=Math.max(c[3],p)}function _getExtremum(e,t,a,s,r,n,o,l,c,d,h,u){if(Math.abs(c)<1e-12){Math.abs(d)>=1e-12&&_assertClassBrand(i,this,_getExtremumOnCurve).call(this,e,t,a,s,r,n,o,l,-h/d,u);return}const _=d**2-4*h*c;if(_<0)return;const p=Math.sqrt(_),g=2*c;_assertClassBrand(i,this,_getExtremumOnCurve).call(this,e,t,a,s,r,n,o,l,(-d+p)/g,u);_assertClassBrand(i,this,_getExtremumOnCurve).call(this,e,t,a,s,r,n,o,l,(-d-p)/g,u)}let q=null,X=null;function normalizeUnicode(e){if(!q){q=/([\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;X=new Map([["ſt","ſt"]])}return e.replaceAll(q,(e,t,i)=>t?t.normalize("NFKC"):X.get(i))}function getUuid(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=new Uint8Array(32);crypto.getRandomValues(e);return function bytesToString(e){"object"==typeof e&&void 0!==e?.length||unreachable("Invalid argument for bytesToString");const t=e.length,i=8192;if(t<i)return String.fromCharCode.apply(null,e);const a=[];for(let s=0;s<t;s+=i){const r=Math.min(s+i,t),n=e.subarray(s,r);a.push(String.fromCharCode.apply(null,n))}return a.join("")}(e)}const makeArr=()=>[],makeMap=()=>new Map,makeObj=()=>Object.create(null);__webpack_require__(838),__webpack_require__(1701),__webpack_require__(8454),__webpack_require__(9452),__webpack_require__(4603),__webpack_require__(7566),__webpack_require__(8721);function MathClamp(e,t,i){return Math.min(Math.max(e,t),i)}class PageViewport{constructor(e){let t=e.viewBox,i=e.userUnit,a=e.scale,s=e.rotation,r=e.offsetX,n=void 0===r?0:r,o=e.offsetY,l=void 0===o?0:o,c=e.dontFlip,d=void 0!==c&&c;this.viewBox=t;this.userUnit=i;this.scale=a;this.rotation=s;this.offsetX=n;this.offsetY=l;a*=i;const h=(t[2]+t[0])/2,u=(t[3]+t[1])/2;let _,p,g,f,m,v,y,P;s%=360;s<0&&(s+=360);switch(s){case 180:_=-1;p=0;g=0;f=1;break;case 90:_=0;p=1;g=1;f=0;break;case 270:_=0;p=-1;g=-1;f=0;break;case 0:_=1;p=0;g=0;f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(d){g=-g;f=-f}if(0===_){m=Math.abs(u-t[1])*a+n;v=Math.abs(h-t[0])*a+l;y=(t[3]-t[1])*a;P=(t[2]-t[0])*a}else{m=Math.abs(h-t[0])*a+n;v=Math.abs(u-t[1])*a+l;y=(t[2]-t[0])*a;P=(t[3]-t[1])*a}this.transform=[_*a,p*a,g*a,f*a,m-_*a*h-g*a*u,v-p*a*h-f*a*u];this.width=y;this.height=P}get rawDims(){const e=this.viewBox;return shadow(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.scale,i=void 0===t?this.scale:t,a=e.rotation,s=void 0===a?this.rotation:a,r=e.offsetX,n=void 0===r?this.offsetX:r,o=e.offsetY,l=void 0===o?this.offsetY:o,c=e.dontFlip,d=void 0!==c&&c;return new PageViewport({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:i,rotation:s,offsetX:n,offsetY:l,dontFlip:d})}convertToViewportPoint(e,t){const i=[e,t];Util.applyTransform(i,this.transform);return i}convertToViewportRectangle(e){const t=[e[0],e[1]];Util.applyTransform(t,this.transform);const i=[e[2],e[3]];Util.applyTransform(i,this.transform);return[t[0],t[1],i[0],i[1]]}convertToPdfPoint(e,t){const i=[e,t];Util.applyInverseTransform(i,this.transform);return i}}var K;__webpack_require__(8107),__webpack_require__(8347);class XfaText{static textContent(e){const t=[],i={items:t,styles:Object.create(null)};!function walk(e){if(!e)return;let i=null;const a=e.name;if("#text"===a)i=e.value;else{if(!XfaText.shouldBuildText(a))return;e?.attributes?.textContent?i=e.attributes.textContent:e.value&&(i=e.value)}null!==i&&t.push({str:i});if(e.children)for(const t of e.children)walk(t)}(e);return i}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}function _slicedToArray(e,t){return function xfa_layer_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function xfa_layer_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return xfa_layer_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?xfa_layer_arrayLikeToArray(e,t):void 0}}(e,t)||function xfa_layer_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function xfa_layer_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}class XfaLayer{static setupStorage(e,t,i,a,s){const r=window.getFormValueFromAngular(e);r.value&&a.setValue(t,r);const n=a.getValue(t,{value:null}),o=r.value?r:n;window.registerXFAField(e,o,n);e.addEventListener("updateFromAngular",e=>a.setValue(t,{value:e.detail}));switch(i.name){case"textarea":null!==o.value&&(e.textContent=o.value);if("print"===s)break;e.addEventListener("input",i=>{window.updateAngularFormValue(e,{value:i.target.value});a.setValue(t,{value:i.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){o.value===i.attributes.xfaOn?e.setAttribute("checked",!0):e.removeAttribute("checked");if("print"===s)break;e.addEventListener("change",i=>{window.updateAngularFormValue(e,{value:i.target.checked?i.target.getAttribute("xfaOn"):i.target.getAttribute("xfaOff")});a.setValue(t,{value:i.target.checked?i.target.getAttribute("xfaOn"):i.target.getAttribute("xfaOff")})})}else{null!==o.value&&e.setAttribute("value",o.value);if("print"===s)break;e.addEventListener("input",i=>{window.updateAngularFormValue(e,{value:i.target.value});a.setValue(t,{value:i.target.value})})}break;case"select":if(null!==o.value){e.setAttribute("value",o.value);for(const e of i.children)e.attributes.value===o.value?e.attributes.selected=!0:Object.hasOwn(e.attributes,"selected")&&delete e.attributes.selected}e.addEventListener("input",i=>{const s=i.target.options,r=-1===s.selectedIndex?"":s[s.selectedIndex].value;window.updateAngularFormValue(e,{value:r});a.setValue(t,{value:r})})}}static setAttributes(e){let t=e.html,i=e.element,a=e.storage,s=void 0===a?null:a,r=e.intent,n=e.linkService;const o=i.attributes,l=t instanceof HTMLAnchorElement;"radio"===o.type&&(o.name=`${o.name}-${r}`);for(const e of Object.entries(o)){var c=_slicedToArray(e,2);const i=c[0],a=c[1];if(null!=a)switch(i){case"class":a.length&&t.setAttribute(i,a.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",a);break;case"style":Object.assign(t.style,a);break;case"textContent":t.textContent=a;break;default:(!l||"href"!==i&&"newWindow"!==i)&&t.setAttribute(i,a)}}l&&n.addLinkAttributes(t,o.href,o.newWindow);s&&o.dataId&&this.setupStorage(t,o.dataId,i,s)}static render(e){const t=e.annotationStorage,i=e.linkService,a=e.xfaHtml,s=e.intent||"display",r=document.createElement(a.name);a.attributes&&this.setAttributes({html:r,element:a,intent:s,linkService:i});const n="richText"!==s,o=e.div;o.append(r);if(e.viewport){const t=`matrix(${e.viewport.transform.join(",")})`;o.style.transform=t}n&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===a.children.length){if(a.value){const e=document.createTextNode(a.value);r.append(e);n&&XfaText.shouldBuildText(a.name)&&l.push(e)}return{textDivs:l}}const c=[[a,-1,r]];for(;c.length>0;){const e=_slicedToArray(c.at(-1),3),a=e[0],r=e[1],o=e[2];if(r+1===a.children.length){c.pop();continue}const d=a.children[++c.at(-1)[1]];if(null===d)continue;const h=d.name;if("#text"===h){const e=document.createTextNode(d.value);l.push(e);o.append(e);continue}const u=d?.attributes?.xmlns?document.createElementNS(d.attributes.xmlns,h):document.createElement(h);o.append(u);d.attributes&&this.setAttributes({html:u,element:d,storage:t,intent:s,linkService:i});if(d.children?.length>0)c.push([d,-1,u]);else if(d.value){const e=document.createTextNode(d.value);n&&XfaText.shouldBuildText(h)&&l.push(e);u.append(e)}}for(const e of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:l}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t;e.div.hidden=!1}static getPageViewport(e,t){let i=t.scale,a=void 0===i?1:i,s=t.rotation,r=void 0===s?0:s;const n=e.attributes.style,o=n.width,l=n.height;return new PageViewport({viewBox:[0,0,parseInt(o,10),parseInt(l,10)],userUnit:1,scale:a,rotation:r})}}function _classPrivateFieldInitSpec(e,t,i){(function _checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function _classPrivateFieldGet(e,t){return e.get(display_utils_assertClassBrand(e,t))}function display_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function display_utils_slicedToArray(e,t){return function display_utils_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function display_utils_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function display_utils_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return display_utils_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?display_utils_arrayLikeToArray(e,t):void 0}}(e,t)||function display_utils_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function display_utils_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function display_utils_defineProperty(e,t,i){return(t=function display_utils_toPropertyKey(e){var t=function display_utils_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class PixelsPerInch{}K=PixelsPerInch;display_utils_defineProperty(PixelsPerInch,"CSS",96);display_utils_defineProperty(PixelsPerInch,"PDF",72);display_utils_defineProperty(PixelsPerInch,"PDF_TO_CSS_UNITS",K.CSS/K.PDF);async function fetchData(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";if(isValidFetchUrl(e,document.baseURI)){const i=await fetch(e);if(!i.ok)throw new Error(i.statusText);switch(t){case"blob":return i.blob();case"bytes":return i.bytes();case"json":return i.json()}return i.text()}return new Promise((i,a)=>{const s=new XMLHttpRequest;s.open("GET",e,!0);s.responseType="bytes"===t?"arraybuffer":t;s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE)if(200!==s.status&&0!==s.status)a(new Error(s.statusText));else{switch(t){case"bytes":i(new Uint8Array(s.response));return;case"blob":case"json":i(s.response);return}i(s.responseText)}};s.send(null)})}class RenderingCancelledException extends ${constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;super(e,"RenderingCancelledException");this.extraDelay=t}}function isDataScheme(e){const t=e.length;let i=0;for(;i<t&&""===e[i].trim();)i++;return"data:"===e.substring(i,i+5).toLowerCase()}function isPdfFile(e){return"string"==typeof e&&/\.pdf$/i.test(e)}function getPdfFilenameFromUrl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"document.pdf";if(t&&"document.pdf"!==t)return t;if("string"!=typeof e)return t;if(isDataScheme(e)){warn('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');return t}const i=(e=>{try{return new URL(e)}catch{}try{return new URL(decodeURIComponent(e))}catch{}try{return new URL(e,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(e),"https://foo.bar")}catch{}return null})(e);if(!i)return t;const decode=e=>{try{let t=decodeURIComponent(e);if(t.includes("/")){t=stripPath(t);if(4===t.length&&a.test(t))return e}return t}catch{return e}},a=/\.pdf$/i,s=stripPath(i.pathname);if(a.test(s))return decode(s);if(i.searchParams.size>0){const getLast=e=>[...e].findLast(e=>a.test(e)),e=getLast(i.searchParams.values())??getLast(i.searchParams.keys());if(e)return decode(e)}if(i.hash){const e=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(e)return decode(e[0])}return t}var Y=new WeakMap;class StatTimer{constructor(){_classPrivateFieldInitSpec(this,Y,new Map);display_utils_defineProperty(this,"times",[])}time(e){_classPrivateFieldGet(Y,this).has(e)&&warn(`Timer is already running for ${e}`);_classPrivateFieldGet(Y,this).set(e,Date.now())}timeEnd(e){_classPrivateFieldGet(Y,this).has(e)||warn(`Timer has not been started for ${e}`);this.times.push({name:e,start:_classPrivateFieldGet(Y,this).get(e),end:Date.now()});_classPrivateFieldGet(Y,this).delete(e)}toString(){const e=Math.max(...this.times.map(e=>e.name.length));return this.times.map(t=>`${t.name.padEnd(e)} ${t.end-t.start}ms\n`).join("")}}function isValidFetchUrl(e,t){const i=t?URL.parse(e,t):URL.parse(e);return/https?:|blob:|capacitor:/.test(i?.protocol??"")}function noContextMenu(e){e.preventDefault()}function stopEvent(e){e.preventDefault();e.stopPropagation()}class PDFDateString{static toDateObject(e){if(e instanceof Date)return e;if(!e||"string"!=typeof e)return null;display_utils_assertClassBrand(PDFDateString,this,Z)._||(Z._=display_utils_assertClassBrand(PDFDateString,this,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?")));const t=display_utils_assertClassBrand(PDFDateString,this,Z)._.exec(e);if(!t)return null;const i=parseInt(t[1],10);let a=parseInt(t[2],10);a=a>=1&&a<=12?a-1:0;let s=parseInt(t[3],10);s=s>=1&&s<=31?s:1;let r=parseInt(t[4],10);r=r>=0&&r<=23?r:0;let n=parseInt(t[5],10);n=n>=0&&n<=59?n:0;let o=parseInt(t[6],10);o=o>=0&&o<=59?o:0;const l=t[7]||"Z";let c=parseInt(t[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(t[9],10)||0;d=d>=0&&d<=59?d:0;if("-"===l){r+=c;n+=d}else if("+"===l){r-=c;n-=d}return new Date(Date.UTC(i,a,s,r,n,o))}}var Z={_:void 0};function getRGBA(e){if(e.startsWith("#")){const t=e.slice(1);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),t.length>=8?parseInt(t.slice(6,8),16)/255:1]}if(e.startsWith("rgb(")){const t=display_utils_slicedToArray(e.slice(4,-1).split(",").map(e=>parseInt(e,10)),3);return[t[0],t[1],t[2],1]}if(e.startsWith("rgba(")){const t=e.slice(5,-1).split(",");return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3])]}const t=e.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(255*parseFloat(t[1])),Math.round(255*parseFloat(t[2])),Math.round(255*parseFloat(t[3])),void 0!==t[4]&&"none"!==t[4]?parseFloat(t[4]):1]:null}function getRGB(e){const t=getRGBA(e);if(!t){warn(`Not a valid color format: "${e}"`);return[0,0,0]}return t.slice(0,3)}function getCurrentTransform(e){const t=e.getTransform();return[t.a,t.b,t.c,t.d,t.e,t.f]}function getCurrentTransformInverse(e){const t=e.getTransform().invertSelf();return[t.a,t.b,t.c,t.d,t.e,t.f]}function setLayerDimensions(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(t instanceof PageViewport){const a=t.rawDims,s=a.pageWidth,r=a.pageHeight,n=e.style,o=`round(down, var(--total-scale-factor) * ${s}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;if(i&&t.rotation%180!=0){n.width=l;n.height=o}else{n.width=o;n.height=l}}a&&e.setAttribute("data-main-rotation",t.rotation)}class OutputScale{constructor(){const e=OutputScale.pixelRatio;this.sx=e;this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(e,t,i,a){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,r=1/0,n=1/0,o=1/0;(i=OutputScale.capPixels(i,s))>0&&(r=Math.sqrt(i/(e*t)));if(-1!==a){n=a/e;o=a/t}const l=Math.min(r,n,o);if(this.sx>l||this.sy>l){this.sx=l;this.sy=l;return!0}return!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+t/100));return e>0?Math.min(e,i):i}return e}}const J=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class ColorScheme{static get isDarkMode(){return shadow(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class CSSConstants{static get commentForegroundColor(){const e=document.createElement("ngx-extended-pdf-viewer");e.style.display="block";const t=document.createElement("span");t.classList.add("commentPopup","comment","sidebar");const i=t.style;i.width=i.height="0";i.display="none";i.color="var(--comment-fg-color)";e.append(t);document.body.append(e);const a=window.getComputedStyle(t).color;e.remove();return shadow(this,"commentForegroundColor",getRGB(a))}}function applyOpacity(e,t){const i=255*(1-(t=MathClamp(t??1,0,1)));return e.map(e=>Math.round(e*t+i))}function RGBToHSL(e,t){const i=e[0]/255,a=e[1]/255,s=e[2]/255,r=Math.max(i,a,s),n=Math.min(i,a,s),o=(r+n)/2;if(r===n)t[0]=t[1]=0;else{const e=r-n;t[1]=o<.5?e/(r+n):e/(2-r-n);switch(r){case i:t[0]=60*((a-s)/e+(a<s?6:0));break;case a:t[0]=60*((s-i)/e+2);break;case s:t[0]=60*((i-a)/e+4)}}t[2]=o}function HSLToRGB(e,t){const i=e[0],a=e[1],s=e[2],r=(1-Math.abs(2*s-1))*a,n=r*(1-Math.abs(i/60%2-1)),o=s-r/2;switch(Math.floor(i/60)){case 0:t[0]=r+o;t[1]=n+o;t[2]=o;break;case 1:t[0]=n+o;t[1]=r+o;t[2]=o;break;case 2:t[0]=o;t[1]=r+o;t[2]=n+o;break;case 3:t[0]=o;t[1]=n+o;t[2]=r+o;break;case 4:t[0]=n+o;t[1]=o;t[2]=r+o;break;case 5:case 6:t[0]=r+o;t[1]=o;t[2]=n+o}}function computeLuminance(e){return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function contrastRatio(e,t,i){HSLToRGB(e,i);i.map(computeLuminance);const a=.2126*i[0]+.7152*i[1]+.0722*i[2];HSLToRGB(t,i);i.map(computeLuminance);const s=.2126*i[0]+.7152*i[1]+.0722*i[2];return a>s?(a+.05)/(s+.05):(s+.05)/(a+.05)}const Q=new Map;function findContrastColor(e,t){const i=e[0]+256*e[1]+65536*e[2]+16777216*t[0]+4294967296*t[1]+1099511627776*t[2];let a=Q.get(i);if(a)return a;const s=new Float32Array(9),r=s.subarray(0,3),n=s.subarray(3,6);RGBToHSL(e,n);const o=s.subarray(6,9);RGBToHSL(t,o);const l=o[2]<.5,c=l?12:4.5;n[2]=l?Math.sqrt(n[2]):1-Math.sqrt(1-n[2]);if(contrastRatio(n,o,r)<c){let e,t;if(l){e=n[2];t=1}else{e=0;t=n[2]}const i=.005;for(;t-e>i;){const i=n[2]=(e+t)/2;l===contrastRatio(n,o,r)<c?e=i:t=i}n[2]=l?t:e}HSLToRGB(n,r);a=Util.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2]));Q.set(i,a);return a}function renderRichText(e,t){let i=e.html,a=e.dir,s=e.className;const r=document.createDocumentFragment();if("string"==typeof i){const e=document.createElement("p");e.dir=a||"auto";const t=i.split(/\r\n?|\n/);for(let i=0,a=t.length;i<a;++i){const s=t[i];e.append(document.createTextNode(s));i<a-1&&e.append(document.createElement("br"))}r.append(e)}else XfaLayer.render({xfaHtml:i,div:r,intent:"richText"});r.firstElementChild.classList.add("richText",s);t.append(r)}function makePathFromDrawOPS(e){const t=new Path2D;if(!e)return t;for(let i=0,a=e.length;i<a;)switch(e[i++]){case N:t.moveTo(e[i++],e[i++]);break;case j:t.lineTo(e[i++],e[i++]);break;case W:t.bezierCurveTo(e[i++],e[i++],e[i++],e[i++],e[i++],e[i++]);break;case U:t.quadraticCurveTo(e[i++],e[i++],e[i++],e[i++]);break;case V:t.closePath();break;default:warn(`Unrecognized drawing path operator: ${e[i-1]}`)}return t}__webpack_require__(4972),__webpack_require__(4628),__webpack_require__(7642),__webpack_require__(8004),__webpack_require__(3853),__webpack_require__(5876),__webpack_require__(2475),__webpack_require__(5024),__webpack_require__(1698),__webpack_require__(4979),__webpack_require__(3579),__webpack_require__(3110),__webpack_require__(9314),__webpack_require__(1148),__webpack_require__(7588),__webpack_require__(9112),__webpack_require__(7357);function toolbar_slicedToArray(e,t){return function toolbar_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function toolbar_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function toolbar_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return toolbar_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?toolbar_arrayLikeToArray(e,t):void 0}}(e,t)||function toolbar_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function toolbar_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function _classPrivateMethodInitSpec(e,t){toolbar_checkPrivateRedeclaration(e,t),t.add(e)}function toolbar_classPrivateFieldInitSpec(e,t,i){toolbar_checkPrivateRedeclaration(e,t),t.set(e,i)}function toolbar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateGetter(e,t,i){return i(toolbar_assertClassBrand(e,t))}function toolbar_classPrivateFieldGet(e,t){return e.get(toolbar_assertClassBrand(e,t))}function _classPrivateFieldSet(e,t,i){return e.set(toolbar_assertClassBrand(e,t),i),i}function toolbar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var ee=new WeakMap,te=new WeakMap,ie=new WeakMap,ae=new WeakMap,se=new WeakMap,re=new WeakMap,ne=new WeakMap,oe=new WeakMap,le=new WeakSet;class EditorToolbar{constructor(e){_classPrivateMethodInitSpec(this,le);toolbar_classPrivateFieldInitSpec(this,ee,null);toolbar_classPrivateFieldInitSpec(this,te,null);toolbar_classPrivateFieldInitSpec(this,ie,void 0);toolbar_classPrivateFieldInitSpec(this,ae,null);toolbar_classPrivateFieldInitSpec(this,se,null);toolbar_classPrivateFieldInitSpec(this,re,null);toolbar_classPrivateFieldInitSpec(this,ne,null);toolbar_classPrivateFieldInitSpec(this,oe,null);_classPrivateFieldSet(ie,this,e);ce._||(ce._=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=_classPrivateFieldSet(ee,this,document.createElement("div"));e.classList.add("editToolbar","hidden");e.setAttribute("role","toolbar");const t=toolbar_classPrivateFieldGet(ie,this)._uiManager._signal;if(t instanceof AbortSignal&&!t.aborted){e.addEventListener("contextmenu",noContextMenu,{signal:t});e.addEventListener("pointerdown",_pointerDown,{signal:t})}const i=_classPrivateFieldSet(ae,this,document.createElement("div"));i.className="buttons";e.append(i);const a=toolbar_classPrivateFieldGet(ie,this).toolbarPosition;if(a){const t=e.style,i="ltr"===toolbar_classPrivateFieldGet(ie,this)._uiManager.direction?1-a[0]:a[0];t.insetInlineEnd=100*i+"%";t.top=`calc(${100*a[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return toolbar_classPrivateFieldGet(ee,this)}hide(){toolbar_classPrivateFieldGet(ee,this).classList.add("hidden");toolbar_classPrivateFieldGet(te,this)?.hideDropdown()}show(){toolbar_classPrivateFieldGet(ee,this).classList.remove("hidden");toolbar_classPrivateFieldGet(se,this)?.shown();toolbar_classPrivateFieldGet(re,this)?.shown()}addDeleteButton(){const e=toolbar_classPrivateFieldGet(ie,this),t=e.editorType,i=e._uiManager,a=document.createElement("button");a.classList.add("basic","deleteButton");a.tabIndex=0;a.setAttribute("data-l10n-id",ce._[t]);toolbar_assertClassBrand(le,this,_addListenersToElement).call(this,a)&&a.addEventListener("click",e=>{i.delete()},{signal:i._signal});toolbar_classPrivateFieldGet(ae,this).append(a)}async addAltText(e){const t=await e.render();toolbar_assertClassBrand(le,this,_addListenersToElement).call(this,t);toolbar_classPrivateFieldGet(ae,this).append(t,_classPrivateGetter(le,this,_get_divider));_classPrivateFieldSet(se,this,e)}addComment(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(toolbar_classPrivateFieldGet(re,this))return;const i=e.renderForToolbar();if(!i)return;toolbar_assertClassBrand(le,this,_addListenersToElement).call(this,i);const a=_classPrivateFieldSet(ne,this,_classPrivateGetter(le,this,_get_divider));if(t){toolbar_classPrivateFieldGet(ae,this).insertBefore(i,t);toolbar_classPrivateFieldGet(ae,this).insertBefore(a,t)}else toolbar_classPrivateFieldGet(ae,this).append(i,a);_classPrivateFieldSet(re,this,e);e.toolbar=this}addColorPicker(e){if(toolbar_classPrivateFieldGet(te,this))return;_classPrivateFieldSet(te,this,e);const t=e.renderButton();toolbar_assertClassBrand(le,this,_addListenersToElement).call(this,t);toolbar_classPrivateFieldGet(ae,this).append(t,_classPrivateGetter(le,this,_get_divider))}async addEditSignatureButton(e){const t=_classPrivateFieldSet(oe,this,await e.renderEditButton(toolbar_classPrivateFieldGet(ie,this)));toolbar_assertClassBrand(le,this,_addListenersToElement).call(this,t);toolbar_classPrivateFieldGet(ae,this).append(t,_classPrivateGetter(le,this,_get_divider))}removeButton(e){if("comment"===e){toolbar_classPrivateFieldGet(re,this)?.removeToolbarCommentButton();_classPrivateFieldSet(re,this,null);toolbar_classPrivateFieldGet(ne,this)?.remove();_classPrivateFieldSet(ne,this,null)}}async addButton(e,t){switch(e){case"colorPicker":t&&this.addColorPicker(t);break;case"altText":t&&await this.addAltText(t);break;case"editSignature":t&&await this.addEditSignatureButton(t);break;case"delete":this.addDeleteButton();break;case"comment":t&&this.addComment(t)}}async addButtonBefore(e,t,i){if(!t&&"comment"===e)return;const a=toolbar_classPrivateFieldGet(ae,this).querySelector(i);a&&"comment"===e&&this.addComment(t,a)}updateEditSignatureButton(e){toolbar_classPrivateFieldGet(oe,this)&&(toolbar_classPrivateFieldGet(oe,this).title=e)}remove(){toolbar_classPrivateFieldGet(ee,this).remove();toolbar_classPrivateFieldGet(te,this)?.destroy();_classPrivateFieldSet(te,this,null)}}function _pointerDown(e){e.stopPropagation()}function _focusIn(e){toolbar_classPrivateFieldGet(ie,this)._focusEventsAllowed=!1;stopEvent(e)}function _focusOut(e){toolbar_classPrivateFieldGet(ie,this)._focusEventsAllowed=!0;stopEvent(e)}function _addListenersToElement(e){const t=toolbar_classPrivateFieldGet(ie,this)._uiManager._signal;if(!(t instanceof AbortSignal)||t.aborted)return!1;e.addEventListener("focusin",toolbar_assertClassBrand(le,this,_focusIn).bind(this),{capture:!0,signal:t});e.addEventListener("focusout",toolbar_assertClassBrand(le,this,_focusOut).bind(this),{capture:!0,signal:t});e.addEventListener("contextmenu",noContextMenu,{signal:t});return!0}function _get_divider(e){const t=document.createElement("div");t.className="divider";return t}var ce={_:null},de=new WeakMap,he=new WeakMap,ue=new WeakMap,_e=new WeakSet;class FloatingToolbar{constructor(e){_classPrivateMethodInitSpec(this,_e);toolbar_classPrivateFieldInitSpec(this,de,null);toolbar_classPrivateFieldInitSpec(this,he,null);toolbar_classPrivateFieldInitSpec(this,ue,void 0);_classPrivateFieldSet(ue,this,e)}show(e,t,i){const a=toolbar_slicedToArray(toolbar_assertClassBrand(_e,this,_getLastPoint).call(this,t,i),2),s=a[0],r=a[1],n=(toolbar_classPrivateFieldGet(he,this)||_classPrivateFieldSet(he,this,toolbar_assertClassBrand(_e,this,_render).call(this))).style;e.append(toolbar_classPrivateFieldGet(he,this));n.insetInlineEnd=100*s+"%";n.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){toolbar_classPrivateFieldGet(he,this).remove()}}function _render(){const e=_classPrivateFieldSet(he,this,document.createElement("div"));e.className="editToolbar";e.setAttribute("role","toolbar");const t=toolbar_classPrivateFieldGet(ue,this)._signal;t instanceof AbortSignal&&!t.aborted&&e.addEventListener("contextmenu",noContextMenu,{signal:t});const i=_classPrivateFieldSet(de,this,document.createElement("div"));i.className="buttons";e.append(i);toolbar_classPrivateFieldGet(ue,this).hasCommentManager()&&toolbar_assertClassBrand(_e,this,_makeButton).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{toolbar_classPrivateFieldGet(ue,this).commentSelection("floating_button")});toolbar_assertClassBrand(_e,this,_makeButton).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{toolbar_classPrivateFieldGet(ue,this).highlightSelection("floating_button")});return e}function _getLastPoint(e,t){let i=0,a=0;for(const s of e){const e=s.y+s.height;if(e<i)continue;const r=s.x+(t?s.width:0);if(e>i){a=r;i=e}else t?r>a&&(a=r):r<a&&(a=r)}return[t?1-a:a,i]}function _makeButton(e,t,i,a){const s=document.createElement("button");s.classList.add("basic",e);s.tabIndex=0;s.setAttribute("data-l10n-id",t);const r=document.createElement("span");s.append(r);r.className="visuallyHidden";r.setAttribute("data-l10n-id",i);const n=toolbar_classPrivateFieldGet(ue,this)._signal;if(n instanceof AbortSignal&&!n.aborted){s.addEventListener("contextmenu",noContextMenu,{signal:n});s.addEventListener("click",a,{signal:n})}toolbar_classPrivateFieldGet(de,this).append(s)}const pe=Object.freeze({internal:"403220b8-c231-4993-9821-9c57ccbbb137"});var ge;function tools_defineProperty(e,t,i){return(t=function tools_toPropertyKey(e){var t=function tools_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function tools_slicedToArray(e,t){return function tools_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function tools_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function tools_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return tools_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?tools_arrayLikeToArray(e,t):void 0}}(e,t)||function tools_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tools_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function tools_classPrivateMethodInitSpec(e,t){tools_checkPrivateRedeclaration(e,t),t.add(e)}function tools_classPrivateFieldInitSpec(e,t,i){tools_checkPrivateRedeclaration(e,t),t.set(e,i)}function tools_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function tools_classPrivateFieldGet(e,t){return e.get(tools_assertClassBrand(e,t))}function tools_classPrivateFieldSet(e,t,i){return e.set(tools_assertClassBrand(e,t),i),i}function tools_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function bindEvents(e,t,i){for(const a of i)t.addEventListener(a,e[a].bind(e))}class CurrentPointers{static initializeAndAddPointerId(e){(me._||(me._=new Set)).add(e)}static setPointer(e,t){fe._||(fe._=t);ye._??(ye._=e)}static setTimeStamp(e){ve._=e}static isSamePointerId(e){return fe._===e}static isSamePointerIdOrRemove(e){if(fe._===e)return!0;me._?.delete(e);return!1}static isSamePointerType(e){return ye._===e}static isInitializedAndDifferentPointerType(e){return null!==ye._&&!CurrentPointers.isSamePointerType(e)}static isSameTimeStamp(e){return ve._===e}static isUsingMultiplePointers(){return me._?.size>=1}static clearPointerType(){ye._=null}static clearPointerIds(){fe._=NaN;me._=null}static clearTimeStamp(){ve._=NaN}}var fe={_:NaN},me={_:null},ve={_:NaN},ye={_:null},Pe=new WeakMap;class IdManager{constructor(){tools_classPrivateFieldInitSpec(this,Pe,0)}get id(){var e,t;return`${y}${tools_classPrivateFieldSet(Pe,this,(e=tools_classPrivateFieldGet(Pe,this),t=e++,e)),t}`}}var we=new WeakMap,be=new WeakMap,Fe=new WeakMap,Se=new WeakSet;class ImageManager{constructor(){tools_classPrivateMethodInitSpec(this,Se);tools_classPrivateFieldInitSpec(this,we,getUuid());tools_classPrivateFieldInitSpec(this,be,0);tools_classPrivateFieldInitSpec(this,Fe,null)}static get _isSVGFittingCanvas(){const e=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${l}"><rect width="1" height="1" style="fill:red;"/></svg>`,t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=e;return shadow(this,"_isSVGFittingCanvas",i.decode().then(()=>{t.drawImage(i,0,0,1,1,0,0,1,3);return 0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]}))}async getFromFile(e){const t=e.lastModified,i=e.name,a=e.size,s=e.type;return tools_assertClassBrand(Se,this,_get).call(this,`${t}_${i}_${a}_${s}`,e)}async getFromUrl(e){return tools_assertClassBrand(Se,this,_get).call(this,e,e)}async getFromBlob(e,t){const i=await t;return tools_assertClassBrand(Se,this,_get).call(this,e,i)}async getFromId(e){tools_classPrivateFieldGet(Fe,this)||tools_classPrivateFieldSet(Fe,this,new Map);const t=tools_classPrivateFieldGet(Fe,this).get(e);if(!t)return null;if(t.bitmap){t.refCounter+=1;return t}if(t.file)return this.getFromFile(t.file);if(t.blobPromise){const e=t.blobPromise;delete t.blobPromise;return this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){var i,a;tools_classPrivateFieldGet(Fe,this)||tools_classPrivateFieldSet(Fe,this,new Map);let s=tools_classPrivateFieldGet(Fe,this).get(e);if(s?.bitmap){s.refCounter+=1;return s}const r=new OffscreenCanvas(t.width,t.height);r.getContext("2d").drawImage(t,0,0);s={bitmap:r.transferToImageBitmap(),id:`image_${tools_classPrivateFieldGet(we,this)}_${tools_classPrivateFieldSet(be,this,(i=tools_classPrivateFieldGet(be,this),a=i++,i)),a}`,refCounter:1,isSvg:!1};tools_classPrivateFieldGet(Fe,this).set(e,s);tools_classPrivateFieldGet(Fe,this).set(s.id,s);return s}getSvgUrl(e){const t=tools_classPrivateFieldGet(Fe,this).get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){tools_classPrivateFieldGet(Fe,this)||tools_classPrivateFieldSet(Fe,this,new Map);const t=tools_classPrivateFieldGet(Fe,this).get(e);if(!t)return;t.refCounter-=1;if(0!==t.refCounter)return;const i=t.bitmap;if(!t.url&&!t.file){const e=new OffscreenCanvas(i.width,i.height);e.getContext("bitmaprenderer").transferFromImageBitmap(i);t.blobPromise=e.convertToBlob()}i.close?.();t.bitmap=null}isValidId(e){return e.startsWith(`image_${tools_classPrivateFieldGet(we,this)}_`)}}ge=ImageManager;async function _get(e,t){tools_classPrivateFieldGet(Fe,this)||tools_classPrivateFieldSet(Fe,this,new Map);let i=tools_classPrivateFieldGet(Fe,this).get(e);if(null===i)return null;if(i?.bitmap){i.refCounter+=1;return i}try{var a,s;i||={bitmap:null,id:`image_${tools_classPrivateFieldGet(we,this)}_${tools_classPrivateFieldSet(be,this,(a=tools_classPrivateFieldGet(be,this),s=a++,a)),s}`,refCounter:0,isSvg:!1};let e;if("string"==typeof t){i.url=t;e=await fetchData(t,"blob")}else t instanceof File?e=i.file=t:t instanceof Blob&&(e=t);if("image/svg+xml"===e.type){const t=ge._isSVGFittingCanvas,a=new FileReader,s=new Image,r=new Promise((e,r)=>{s.onload=()=>{i.bitmap=s;i.isSvg=!0;e()};a.onload=async()=>{const e=i.svgUrl=a.result;s.src=await t?`${e}#svgView(preserveAspectRatio(none))`:e};s.onerror=a.onerror=r});a.readAsDataURL(e);await r}else i.bitmap=await createImageBitmap(e);i.refCounter=1}catch(e){warn(e);i=null}tools_classPrivateFieldGet(Fe,this).set(e,i);i&&tools_classPrivateFieldGet(Fe,this).set(i.id,i);return i}var Ce=new WeakMap,Ae=new WeakMap,xe=new WeakMap,ke=new WeakMap;class CommandManager{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:128;tools_classPrivateFieldInitSpec(this,Ce,[]);tools_classPrivateFieldInitSpec(this,Ae,!1);tools_classPrivateFieldInitSpec(this,xe,void 0);tools_classPrivateFieldInitSpec(this,ke,-1);tools_classPrivateFieldSet(xe,this,e)}add(e){let t=e.cmd,i=e.undo,a=e.post,s=e.mustExec,r=e.type,n=void 0===r?NaN:r,o=e.overwriteIfSameType,l=void 0!==o&&o,c=e.keepUndo,d=void 0!==c&&c;s&&t();if(tools_classPrivateFieldGet(Ae,this))return;const h={cmd:t,undo:i,post:a,type:n};if(-1===tools_classPrivateFieldGet(ke,this)){tools_classPrivateFieldGet(Ce,this).length>0&&(tools_classPrivateFieldGet(Ce,this).length=0);tools_classPrivateFieldSet(ke,this,0);tools_classPrivateFieldGet(Ce,this).push(h);return}if(l&&tools_classPrivateFieldGet(Ce,this)[tools_classPrivateFieldGet(ke,this)].type===n){d&&(h.undo=tools_classPrivateFieldGet(Ce,this)[tools_classPrivateFieldGet(ke,this)].undo);tools_classPrivateFieldGet(Ce,this)[tools_classPrivateFieldGet(ke,this)]=h;return}const u=tools_classPrivateFieldGet(ke,this)+1;if(u===tools_classPrivateFieldGet(xe,this))tools_classPrivateFieldGet(Ce,this).splice(0,1);else{tools_classPrivateFieldSet(ke,this,u);u<tools_classPrivateFieldGet(Ce,this).length&&tools_classPrivateFieldGet(Ce,this).splice(u)}tools_classPrivateFieldGet(Ce,this).push(h)}undo(){if(-1===tools_classPrivateFieldGet(ke,this))return;tools_classPrivateFieldSet(Ae,this,!0);const e=tools_classPrivateFieldGet(Ce,this)[tools_classPrivateFieldGet(ke,this)],t=e.undo,i=e.post;t();i?.();tools_classPrivateFieldSet(Ae,this,!1);tools_classPrivateFieldSet(ke,this,tools_classPrivateFieldGet(ke,this)-1)}redo(){if(tools_classPrivateFieldGet(ke,this)<tools_classPrivateFieldGet(Ce,this).length-1){tools_classPrivateFieldSet(ke,this,tools_classPrivateFieldGet(ke,this)+1);tools_classPrivateFieldSet(Ae,this,!0);const e=tools_classPrivateFieldGet(Ce,this)[tools_classPrivateFieldGet(ke,this)],t=e.cmd,i=e.post;t();i?.();tools_classPrivateFieldSet(Ae,this,!1)}}hasSomethingToUndo(){return-1!==tools_classPrivateFieldGet(ke,this)}hasSomethingToRedo(){return tools_classPrivateFieldGet(ke,this)<tools_classPrivateFieldGet(Ce,this).length-1}cleanType(e){if(-1!==tools_classPrivateFieldGet(ke,this)){for(let t=tools_classPrivateFieldGet(ke,this);t>=0;t--)if(tools_classPrivateFieldGet(Ce,this)[t].type!==e){tools_classPrivateFieldGet(Ce,this).splice(t+1,tools_classPrivateFieldGet(ke,this)-t);tools_classPrivateFieldSet(ke,this,t);return}tools_classPrivateFieldGet(Ce,this).length=0;tools_classPrivateFieldSet(ke,this,-1)}}destroy(){tools_classPrivateFieldSet(Ce,this,null)}reset(){tools_classPrivateFieldSet(Ce,this,[]);tools_classPrivateFieldSet(ke,this,-1);tools_classPrivateFieldSet(Ae,this,!1)}}var Ee=new WeakSet;class KeyboardManager{constructor(e){tools_classPrivateMethodInitSpec(this,Ee);this.buffer=[];this.callbacks=new Map;this.allKeys=new Set;const t=FeatureTest.platform.isMac;for(const s of e){var i=tools_slicedToArray(s,3);const e=i[0],r=i[1];var a=i[2];const n=void 0===a?{}:a;for(const i of e){const e=i.startsWith("mac+");if(t&&e){this.callbacks.set(i.slice(4),{callback:r,options:n});this.allKeys.add(i.split("+").at(-1))}else if(!t&&!e){this.callbacks.set(i,{callback:r,options:n});this.allKeys.add(i.split("+").at(-1))}}}}exec(e,t){if(!this.allKeys.has(t.key))return;const i=this.callbacks.get(tools_assertClassBrand(Ee,this,_serialize).call(this,t));if(!i)return;const a=i.callback,s=i.options,r=s.bubbles,n=void 0!==r&&r,o=s.args,l=void 0===o?[]:o,c=s.checker,d=void 0===c?null:c;if(!d||d(e,t)){a.bind(e,...l,t)();n||stopEvent(t)}}}function _serialize(e){e.altKey&&this.buffer.push("alt");e.ctrlKey&&this.buffer.push("ctrl");e.metaKey&&this.buffer.push("meta");e.shiftKey&&this.buffer.push("shift");this.buffer.push(e.key);const t=this.buffer.join("+");this.buffer.length=0;return t}class ColorManager{get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);!function getColorValues(e){const t=document.createElement("span");t.style.visibility="hidden";t.style.colorScheme="only light";document.body.append(t);for(const i of e.keys()){t.style.color=i;const a=window.getComputedStyle(t).color;e.set(i,getRGB(a))}t.remove()}(e);return shadow(this,"_colors",e)}convert(e){const t=getRGB(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(const e of this._colors){var i=tools_slicedToArray(e,2);const a=i[0];if(i[1].every((e,i)=>e===t[i]))return ColorManager._colorsMapping.get(a)}return t}getHexCode(e){const t=this._colors.get(e);return t?Util.makeHexColor(...t):e}}tools_defineProperty(ColorManager,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));var Te=new WeakMap,Ie=new WeakMap,Ge=new WeakMap,Be=new WeakMap,Me=new WeakMap,De=new WeakMap,Le=new WeakMap,Oe=new WeakMap,Re=new WeakMap,Ne=new WeakMap,je=new WeakMap,We=new WeakMap,Ue=new WeakMap,Ve=new WeakMap,He=new WeakMap,ze=new WeakMap,$e=new WeakMap,qe=new WeakMap,Xe=new WeakMap,Ke=new WeakMap,Ye=new WeakMap,Ze=new WeakMap,Je=new WeakMap,Qe=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,st=new WeakMap,rt=new WeakMap,nt=new WeakMap,ot=new WeakMap,lt=new WeakMap,ct=new WeakMap,dt=new WeakMap,ht=new WeakMap,ut=new WeakMap,_t=new WeakMap,pt=new WeakMap,gt=new WeakMap,ft=new WeakMap,mt=new WeakMap,vt=new WeakMap,yt=new WeakMap,Pt=new WeakMap,wt=new WeakMap,bt=new WeakMap,Ft=new WeakMap,St=new WeakMap,Ct=new WeakMap,At=new WeakMap,xt=new WeakSet;class AnnotationEditorUIManager{static get _keyboardManager(){const e=AnnotationEditorUIManager.prototype,arrowChecker=e=>tools_classPrivateFieldGet(Ft,e).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&e.hasSomethingToControl(),textInputChecker=(e,t)=>{let i=t.target;if(i instanceof HTMLInputElement){const e=i.type;return"text"!==e&&"number"!==e}return!0},t=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return shadow(this,"_keyboardManager",new KeyboardManager([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:textInputChecker}],[["ctrl+z","mac+meta+z"],e.undo,{checker:textInputChecker}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:textInputChecker}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:textInputChecker}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(e,t)=>{let i=t.target;return!(i instanceof HTMLButtonElement)&&tools_classPrivateFieldGet(Ft,e).contains(i)&&!e.isEnterHandled}}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(e,t)=>!(t.target instanceof HTMLButtonElement)&&tools_classPrivateFieldGet(Ft,e).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-t,0],checker:arrowChecker}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:arrowChecker}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[t,0],checker:arrowChecker}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:arrowChecker}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-t],checker:arrowChecker}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:arrowChecker}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,t],checker:arrowChecker}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:arrowChecker}]]))}constructor(e,t,i,a,s,r,n,o,l,c,d,h,u,_,p,g){tools_classPrivateMethodInitSpec(this,xt);tools_classPrivateFieldInitSpec(this,Te,new AbortController);tools_classPrivateFieldInitSpec(this,Ie,null);tools_classPrivateFieldInitSpec(this,Ge,null);tools_classPrivateFieldInitSpec(this,Be,new Map);tools_classPrivateFieldInitSpec(this,Me,new Map);tools_classPrivateFieldInitSpec(this,De,null);tools_classPrivateFieldInitSpec(this,Le,null);tools_classPrivateFieldInitSpec(this,Oe,null);tools_classPrivateFieldInitSpec(this,Re,null);tools_classPrivateFieldInitSpec(this,Ne,new CommandManager);tools_classPrivateFieldInitSpec(this,je,null);tools_classPrivateFieldInitSpec(this,We,null);tools_classPrivateFieldInitSpec(this,Ue,null);tools_classPrivateFieldInitSpec(this,Ve,0);tools_classPrivateFieldInitSpec(this,He,new Set);tools_classPrivateFieldInitSpec(this,ze,null);tools_classPrivateFieldInitSpec(this,$e,null);tools_classPrivateFieldInitSpec(this,qe,new Set);tools_defineProperty(this,"_editorUndoBar",null);tools_classPrivateFieldInitSpec(this,Xe,!1);tools_classPrivateFieldInitSpec(this,Ke,!1);tools_classPrivateFieldInitSpec(this,Ye,!1);tools_classPrivateFieldInitSpec(this,Ze,null);tools_classPrivateFieldInitSpec(this,Je,null);tools_classPrivateFieldInitSpec(this,Qe,null);tools_classPrivateFieldInitSpec(this,et,null);tools_classPrivateFieldInitSpec(this,tt,!1);tools_classPrivateFieldInitSpec(this,it,null);tools_classPrivateFieldInitSpec(this,st,new IdManager);tools_classPrivateFieldInitSpec(this,rt,!1);tools_classPrivateFieldInitSpec(this,nt,!1);tools_classPrivateFieldInitSpec(this,ot,!1);tools_classPrivateFieldInitSpec(this,lt,null);tools_classPrivateFieldInitSpec(this,ct,null);tools_classPrivateFieldInitSpec(this,dt,null);tools_classPrivateFieldInitSpec(this,ht,null);tools_classPrivateFieldInitSpec(this,ut,null);tools_classPrivateFieldInitSpec(this,_t,P.NONE);tools_classPrivateFieldInitSpec(this,pt,new Set);tools_classPrivateFieldInitSpec(this,gt,null);tools_classPrivateFieldInitSpec(this,ft,null);tools_classPrivateFieldInitSpec(this,mt,null);tools_classPrivateFieldInitSpec(this,vt,null);tools_classPrivateFieldInitSpec(this,yt,null);tools_classPrivateFieldInitSpec(this,Pt,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});tools_classPrivateFieldInitSpec(this,wt,[0,0]);tools_classPrivateFieldInitSpec(this,bt,null);tools_classPrivateFieldInitSpec(this,Ft,null);tools_classPrivateFieldInitSpec(this,St,null);tools_classPrivateFieldInitSpec(this,Ct,null);tools_classPrivateFieldInitSpec(this,At,null);const f=this._signal=tools_classPrivateFieldGet(Te,this).signal;tools_classPrivateFieldSet(Ft,this,e);tools_classPrivateFieldSet(St,this,t);tools_classPrivateFieldSet(Ct,this,i);tools_classPrivateFieldSet(Le,this,a);tools_classPrivateFieldSet(je,this,s);tools_classPrivateFieldSet(ft,this,r);tools_classPrivateFieldSet(yt,this,o);this._eventBus=n;const m={signal:f,...pe};n.on("editingaction",this.onEditingAction.bind(this),m);n.on("pagechanging",this.onPageChanging.bind(this),m);n.on("scalechanging",this.onScaleChanging.bind(this),m);n.on("rotationchanging",this.onRotationChanging.bind(this),m);n.on("setpreference",this.onSetPreference.bind(this),m);n.on("switchannotationeditorparams",e=>this.updateParams(e.type,e.value),m);window.addEventListener("pointerdown",()=>{tools_classPrivateFieldSet(nt,this,!0)},{capture:!0,signal:f});window.addEventListener("pointerup",()=>{tools_classPrivateFieldSet(nt,this,!1)},{capture:!0,signal:f});window.addEventListener("beforeunload",tools_assertClassBrand(xt,this,_beforeUnload).bind(this),{capture:!0,signal:f});tools_assertClassBrand(xt,this,_addSelectionListener).call(this);tools_assertClassBrand(xt,this,_addDragAndDropListeners).call(this);tools_assertClassBrand(xt,this,_addKeyboardManager).call(this);tools_classPrivateFieldSet(Oe,this,o.annotationStorage);tools_classPrivateFieldSet(Ze,this,o.filterFactory);tools_classPrivateFieldSet(mt,this,l);tools_classPrivateFieldSet(et,this,c||null);tools_classPrivateFieldSet(Xe,this,d);tools_classPrivateFieldSet(Ke,this,h);tools_classPrivateFieldSet(Ye,this,u);tools_classPrivateFieldSet(ut,this,_||null);this.viewParameters={realScale:PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0};this.isShiftKeyDown=!1;this._editorUndoBar=p||null;this._supportsPinchToZoom=!1!==g;s?.setSidebarUiManager(this)}destroy(){tools_classPrivateFieldGet(At,this)?.resolve();tools_classPrivateFieldSet(At,this,null);tools_classPrivateFieldGet(Te,this)?.abort();tools_classPrivateFieldSet(Te,this,null);this._signal=null;for(const e of tools_classPrivateFieldGet(Me,this).values())e.destroy();tools_classPrivateFieldGet(Me,this).clear();tools_classPrivateFieldGet(Be,this).clear();tools_classPrivateFieldGet(qe,this).clear();tools_classPrivateFieldGet(ht,this)?.clear();tools_classPrivateFieldSet(Ie,this,null);tools_classPrivateFieldGet(pt,this).clear();tools_classPrivateFieldGet(Ne,this).destroy();tools_classPrivateFieldGet(Le,this)?.destroy();tools_classPrivateFieldGet(je,this)?.destroy();tools_classPrivateFieldGet(ft,this)?.destroy();tools_classPrivateFieldGet(it,this)?.hide();tools_classPrivateFieldSet(it,this,null);tools_classPrivateFieldGet(dt,this)?.destroy();tools_classPrivateFieldSet(dt,this,null);tools_classPrivateFieldSet(Ge,this,null);if(tools_classPrivateFieldGet(Je,this)){clearTimeout(tools_classPrivateFieldGet(Je,this));tools_classPrivateFieldSet(Je,this,null)}if(tools_classPrivateFieldGet(bt,this)){clearTimeout(tools_classPrivateFieldGet(bt,this));tools_classPrivateFieldSet(bt,this,null)}this._editorUndoBar?.destroy();tools_classPrivateFieldSet(yt,this,null)}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return tools_classPrivateFieldGet(ut,this)}get useNewAltTextFlow(){return tools_classPrivateFieldGet(Ke,this)}get useNewAltTextWhenAddingImage(){return tools_classPrivateFieldGet(Ye,this)}get hcmFilter(){return shadow(this,"hcmFilter",tools_classPrivateFieldGet(mt,this)?tools_classPrivateFieldGet(Ze,this).addHCMFilter(tools_classPrivateFieldGet(mt,this).foreground,tools_classPrivateFieldGet(mt,this).background):"none")}get direction(){return shadow(this,"direction",getComputedStyle(tools_classPrivateFieldGet(Ft,this)).direction)}get _highlightColors(){return shadow(this,"_highlightColors",tools_classPrivateFieldGet(et,this)?new Map(tools_classPrivateFieldGet(et,this).split(",").map(e=>{(e=e.split("=").map(e=>e.trim()))[1]=e[1].toUpperCase();return e})):null)}get highlightColors(){const e=this._highlightColors;if(!e)return shadow(this,"highlightColors",null);const t=new Map,i=!!tools_classPrivateFieldGet(mt,this);for(const s of e){var a=tools_slicedToArray(s,2);const e=a[0],r=a[1],n=e.endsWith("_HCM");i&&n?t.set(e.replace("_HCM",""),r):i||n||t.set(e,r)}return shadow(this,"highlightColors",t)}get highlightColorNames(){return shadow(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;const t=this.highlightColorNames.get(e);return this._highlightColors.get(t)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){if(e){this.unselectAll();this.disableUserSelect(!0)}else this.disableUserSelect(!1);tools_classPrivateFieldSet(Ue,this,e)}setMainHighlightColorPicker(e){tools_classPrivateFieldSet(dt,this,e)}editAltText(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];tools_classPrivateFieldGet(Le,this)?.editAltText(this,e,t)}hasCommentManager(){return!!tools_classPrivateFieldGet(je,this)}editComment(e,t,i,a){tools_classPrivateFieldGet(je,this)?.showDialog(this,e,t,i,a)}selectComment(e,t){const i=tools_classPrivateFieldGet(Me,this).get(e),a=i?.getEditorByUID(t);a?.toggleComment(!0,!0)}updateComment(e){tools_classPrivateFieldGet(je,this)?.updateComment(e.getData())}updatePopupColor(e){tools_classPrivateFieldGet(je,this)?.updatePopupColor(e)}removeComment(e){tools_classPrivateFieldGet(je,this)?.removeComments([e.uid])}deleteComment(e,t){const undo=()=>{e.comment=t};this.addCommands({cmd:()=>{this._editorUndoBar?.show(undo,"comment");this.toggleComment(null);e.comment=null},undo,mustExec:!0})}toggleComment(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;tools_classPrivateFieldGet(je,this)?.toggleCommentPopup(e,t,i)}makeCommentColor(e,t){return e&&tools_classPrivateFieldGet(je,this)?.makeCommentColor(e,t)||null}getCommentDialogElement(){return tools_classPrivateFieldGet(je,this)?.dialogElement||null}async waitForEditorsRendered(e){if(tools_classPrivateFieldGet(Me,this).has(e-1))return;const t=Promise.withResolvers(),i=t.resolve,a=t.promise,onEditorsRendered=t=>{if(t.pageNumber===e){this._eventBus.off("editorsrendered",onEditorsRendered);i()}};this._eventBus.on("editorsrendered",onEditorsRendered);await a}getSignature(e){tools_classPrivateFieldGet(ft,this)?.getSignature({uiManager:this,editor:e})}get signatureManager(){return tools_classPrivateFieldGet(ft,this)}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal});this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference(e){let t=e.name,i=e.value;if("enableNewAltTextWhenAddingImage"===t)tools_classPrivateFieldSet(Ye,this,i)}onPageChanging(e){let t=e.pageNumber;tools_classPrivateFieldSet(Ve,this,t-1)}deletePage(e){for(const t of this.getEditors(e))t.remove();tools_classPrivateFieldGet(Me,this).delete(e);tools_classPrivateFieldGet(Ve,this)===e&&tools_classPrivateFieldSet(Ve,this,0)}focusMainContainer(){tools_classPrivateFieldGet(Ft,this).focus()}findParent(e,t){for(const i of tools_classPrivateFieldGet(Me,this).values()){const a=i.div.getBoundingClientRect(),s=a.x,r=a.y,n=a.width,o=a.height;if(e>=s&&e<=s+n&&t>=r&&t<=r+o)return i}return null}disableUserSelect(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];tools_classPrivateFieldGet(St,this).classList.toggle("noUserSelect",e)}addShouldRescale(e){tools_classPrivateFieldGet(qe,this).add(e)}removeShouldRescale(e){tools_classPrivateFieldGet(qe,this).delete(e)}onScaleChanging(e){let t=e.scale;this.commitOrRemove();this.viewParameters.realScale=t*PixelsPerInch.PDF_TO_CSS_UNITS;for(const e of tools_classPrivateFieldGet(qe,this))e.onScaleChanging();tools_classPrivateFieldGet(Ue,this)?.onScaleChanging()}onRotationChanging(e){let t=e.pagesRotation;this.commitOrRemove();this.viewParameters.rotation=t}highlightSelection(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=document.getSelection();if(!i||i.isCollapsed)return;const a=i.anchorNode,s=i.anchorOffset,r=i.focusNode,n=i.focusOffset,o=i.toString(),l=tools_assertClassBrand(xt,this,_getAnchorElementForSelection).call(this,i).closest(".textLayer"),c=this.getSelectionBoxes(l);if(!c)return;i.empty();const d=tools_assertClassBrand(xt,this,_getLayerForTextLayer).call(this,l),h=tools_classPrivateFieldGet(_t,this)===P.NONE,callback=()=>{const i=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:c,anchorNode:a,anchorOffset:s,focusNode:r,focusOffset:n,text:o});h&&this.showAllEditors("highlight",!0,!0);t&&i?.editComment()};h?this.switchToMode(P.HIGHLIGHT,callback):callback()}commentSelection(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.highlightSelection(e,!0)}getAndRemoveDataFromAnnotationStorage(e){if(!tools_classPrivateFieldGet(Oe,this))return null;const t=`${y}${e}`,i=tools_classPrivateFieldGet(Oe,this).getRawValue(t);i&&tools_classPrivateFieldGet(Oe,this).remove(t);return i}addToAnnotationStorage(e){e.isEmpty()||!tools_classPrivateFieldGet(Oe,this)||tools_classPrivateFieldGet(Oe,this).has(e.id)||tools_classPrivateFieldGet(Oe,this).setValue(e.id,e)}a11yAlert(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=tools_classPrivateFieldGet(Ct,this);if(i){i.setAttribute("data-l10n-id",e);t?i.setAttribute("data-l10n-args",JSON.stringify(t)):i.removeAttribute("data-l10n-args")}}blur(){this.isShiftKeyDown=!1;if(tools_classPrivateFieldGet(tt,this)){tools_classPrivateFieldSet(tt,this,!1);tools_assertClassBrand(xt,this,_onSelectEnd).call(this,"main_toolbar")}if(!this.hasSelection)return;const e=document.activeElement;for(const t of tools_classPrivateFieldGet(pt,this))if(t.div.contains(e)){tools_classPrivateFieldSet(ct,this,[t,e]);t._focusEventsAllowed=!1;break}}focus(){if(!tools_classPrivateFieldGet(ct,this))return;const e=tools_slicedToArray(tools_classPrivateFieldGet(ct,this),2),t=e[0],i=e[1];tools_classPrivateFieldSet(ct,this,null);i.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal});i.focus()}addEditListeners(){tools_assertClassBrand(xt,this,_addKeyboardManager).call(this);this.setEditingState(!0)}removeEditListeners(){tools_assertClassBrand(xt,this,_removeKeyboardManager).call(this);this.setEditingState(!1)}dragOver(e){for(const t of e.dataTransfer.items){const i=t.type;for(const t of tools_classPrivateFieldGet($e,this))if(t.isHandlingMimeForPasting(i)){e.dataTransfer.dropEffect="copy";e.preventDefault();return}}}drop(e){for(const t of e.dataTransfer.items)for(const i of tools_classPrivateFieldGet($e,this))if(i.isHandlingMimeForPasting(t.type)){i.paste(t,this.currentLayer);e.preventDefault();return}}copy(e){e.preventDefault();tools_classPrivateFieldGet(Ie,this)?.commitOrRemove();if(!this.hasSelection)return;const t=[];for(const e of tools_classPrivateFieldGet(pt,this)){const i=e.serialize(!0);i&&t.push(i)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e);this.delete()}async paste(e){e.preventDefault();const t=e.clipboardData;for(const e of t.items)for(const t of tools_classPrivateFieldGet($e,this))if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}const i=t.getData("application/pdfjs");await this.addSerializedEditor(i)}async addSerializedEditor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!e)return;try{"string"==typeof e&&(e=JSON.parse(e))}catch(e){warn(`paste: "${e.message}".`);return}if(!Array.isArray(e))return;const s=tools_classPrivateFieldGet(_t,this);t&&s===P.NONE&&this.updateMode(P.FREETEXT);this.unselectAll();try{const t=[];for(const s of e){const e=void 0===s.pageIndex,r=a||e,n=r?this.currentLayer:this.getLayer(s.pageIndex);if(!n){warn(`addSerializedEditor: the annotation editor layer for page ${r?tools_classPrivateFieldGet(Ve,this):s.pageIndex} is not rendered yet. Wait for the "annotationeditorlayerrendered" event (not "annotationlayerrendered") before adding an annotation to that page.`);continue}const o=await n.deserialize(s);if(!o)return;o.doNotMove=i;t.push(o)}const cmd=()=>{for(const e of t)tools_assertClassBrand(xt,this,_addEditorToLayer).call(this,e);tools_assertClassBrand(xt,this,_selectEditors).call(this,t)},undo=()=>{for(const e of t)e.remove()};this.addCommands({cmd,undo,mustExec:!0})}catch(e){warn(`paste: "${e.message}".`)}t&&s!==tools_classPrivateFieldGet(_t,this)&&this.updateMode(s)}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0);tools_classPrivateFieldGet(_t,this)===P.NONE||this.isEditorHandlingKeyboard||AnnotationEditorUIManager._keyboardManager.exec(this,e)}keyup(e){if(this.isShiftKeyDown&&"Shift"===e.key){this.isShiftKeyDown=!1;if(tools_classPrivateFieldGet(tt,this)){tools_classPrivateFieldSet(tt,this,!1);tools_assertClassBrand(xt,this,_onSelectEnd).call(this,"main_toolbar")}}}onEditingAction(e){let t=e.name;switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}updatePageIndex(e,t){for(const i of this.getEditors(e))i.pageIndex=t;const i=tools_classPrivateFieldGet(De,this).get(e);if(i){i.pageIndex=t;tools_classPrivateFieldGet(Me,this).set(t,i);tools_classPrivateFieldGet(rt,this)?i.enable():i.disable()}}startUpdatePages(){tools_classPrivateFieldSet(De,this,new Map(tools_classPrivateFieldGet(Me,this)));tools_classPrivateFieldGet(Me,this).clear()}endUpdatePages(){tools_classPrivateFieldSet(De,this,null)}clonePage(e,t){for(const i of this.getEditors(e)){const e=i.serialize(i.mode!==P.HIGHLIGHT);if(e){e.pageIndex=t;e.id=this.getId();e.isClone=!0;delete e.popupRef;tools_classPrivateFieldGet(Oe,this).setValue(e.id,e)}}}findClonesForPage(e){const t=[],i=e.pageIndex;for(const s of tools_classPrivateFieldGet(Oe,this)){var a=tools_slicedToArray(s,2);const r=a[0],n=a[1];if(n.pageIndex===i&&n.isClone){tools_classPrivateFieldGet(Oe,this).remove(r);t.push(e.deserialize(n).then(t=>{if(t){t.isClone=!0;e.addOrRebuild(t)}}))}}return Promise.all(t)}setEditingState(e){if(e){tools_assertClassBrand(xt,this,_addFocusManager).call(this);tools_assertClassBrand(xt,this,_addCopyPasteListeners).call(this);tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{isEditing:tools_classPrivateFieldGet(_t,this)!==P.NONE,isEmpty:tools_assertClassBrand(xt,this,_isEmpty).call(this),hasSomethingToUndo:tools_classPrivateFieldGet(Ne,this).hasSomethingToUndo(),hasSomethingToRedo:tools_classPrivateFieldGet(Ne,this).hasSomethingToRedo(),hasSelectedEditor:!1})}else{tools_assertClassBrand(xt,this,_removeFocusManager).call(this);tools_assertClassBrand(xt,this,_removeCopyPasteListeners).call(this);tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{isEditing:!1});this.disableUserSelect(!1)}}registerEditorTypes(e){if(!tools_classPrivateFieldGet($e,this)){tools_classPrivateFieldSet($e,this,e);for(const e of tools_classPrivateFieldGet($e,this))tools_assertClassBrand(xt,this,_dispatchUpdateUI).call(this,e.defaultPropertiesToUpdate)}}getId(){return tools_classPrivateFieldGet(st,this).id}get currentLayer(){return tools_classPrivateFieldGet(Me,this).get(tools_classPrivateFieldGet(Ve,this))}getLayer(e){return tools_classPrivateFieldGet(Me,this).get(e)}get currentPageIndex(){return tools_classPrivateFieldGet(Ve,this)}addLayer(e){tools_classPrivateFieldGet(Me,this).set(e.pageIndex,e);tools_classPrivateFieldGet(rt,this)?e.enable():e.disable()}removeLayer(e){tools_classPrivateFieldGet(Me,this).delete(e.pageIndex)}async updateMode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(tools_classPrivateFieldGet(_t,this)!==e){if(tools_classPrivateFieldGet(At,this)){await tools_classPrivateFieldGet(At,this).promise;if(!tools_classPrivateFieldGet(At,this))return}tools_classPrivateFieldSet(At,this,Promise.withResolvers());tools_classPrivateFieldGet(Ue,this)?.commitOrRemove();tools_classPrivateFieldGet(_t,this)===P.POPUP&&tools_classPrivateFieldGet(je,this)?.hideSidebar();tools_classPrivateFieldGet(je,this)?.destroyPopup();tools_classPrivateFieldSet(_t,this,e);if(e!==P.NONE){for(const e of tools_classPrivateFieldGet(Be,this).values())e.addStandaloneCommentButton();e===P.SIGNATURE&&await(tools_classPrivateFieldGet(ft,this)?.loadSignatures());i&&CurrentPointers.clearPointerType();this.setEditingState(!0);await tools_assertClassBrand(xt,this,_enableAll).call(this);this.unselectAll();for(const t of tools_classPrivateFieldGet(Me,this).values())t.updateMode(e);if(e===P.POPUP){tools_classPrivateFieldGet(Ge,this)||tools_classPrivateFieldSet(Ge,this,await tools_classPrivateFieldGet(yt,this).getAnnotationsByType(new Set(tools_classPrivateFieldGet($e,this).map(e=>e._editorType))));const e=new Set,t=[];for(const i of tools_classPrivateFieldGet(Be,this).values()){const a=i.annotationElementId,s=i.hasComment,r=i.deleted;a&&e.add(a);s&&!r&&t.push(i.getData())}for(const i of tools_classPrivateFieldGet(Ge,this)){const a=i.id,s=i.popupRef,r=i.contentsObj;s&&r?.str&&!e.has(a)&&!tools_classPrivateFieldGet(He,this).has(a)&&t.push(i)}tools_classPrivateFieldGet(je,this)?.showSidebar(t)}if(t){for(const e of tools_classPrivateFieldGet(Be,this).values())if(e.uid===t){this.setSelected(e);r?e.editComment():s?e.enterInEditMode():e.focus()}else e.unselect();tools_classPrivateFieldGet(At,this).resolve()}else{a&&this.addNewEditorFromKeyboard();tools_classPrivateFieldGet(At,this).resolve()}}else{this.setEditingState(!1);tools_assertClassBrand(xt,this,_disableAll).call(this);for(const e of tools_classPrivateFieldGet(Be,this).values())e.hideStandaloneCommentButton();this._editorUndoBar?.hide();this.toggleComment(null);tools_classPrivateFieldGet(At,this).resolve()}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==tools_classPrivateFieldGet(_t,this)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,t){if(tools_classPrivateFieldGet($e,this)){switch(e){case w.CREATE:this.currentLayer.addNewEditor(t);return;case w.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}});(tools_classPrivateFieldGet(vt,this)||tools_classPrivateFieldSet(vt,this,new Map)).set(e,t);this.showAllEditors("highlight",t)}if(this.hasSelection){for(const i of tools_classPrivateFieldGet(pt,this))i.updateParams(e,t);if(e===w.HIGHLIGHT_COLOR||e===w.HIGHLIGHT_THICKNESS)for(const i of tools_classPrivateFieldGet($e,this))i.updateDefaultParams(e,t)}else for(const i of tools_classPrivateFieldGet($e,this))i.updateDefaultParams(e,t)}}showAllEditors(e,t){for(const i of tools_classPrivateFieldGet(Be,this).values())i.editorType===e&&i.show(t);(tools_classPrivateFieldGet(vt,this)?.get(w.HIGHLIGHT_SHOW_ALL)??!0)!==t&&tools_assertClassBrand(xt,this,_dispatchUpdateUI).call(this,[[w.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(tools_classPrivateFieldGet(ot,this)!==e){tools_classPrivateFieldSet(ot,this,e);for(const t of tools_classPrivateFieldGet(Me,this).values()){e?t.disableClick():t.enableClick();t.div.classList.toggle("waiting",e)}}}*getEditors(e){for(const t of tools_classPrivateFieldGet(Be,this).values())t.pageIndex===e&&(yield t)}getEditor(e){return tools_classPrivateFieldGet(Be,this).get(e)}addEditor(e){tools_classPrivateFieldGet(Be,this).set(e.id,e)}removeEditor(e){if(e.div.contains(document.activeElement)){tools_classPrivateFieldGet(Je,this)&&clearTimeout(tools_classPrivateFieldGet(Je,this));tools_classPrivateFieldSet(Je,this,setTimeout(()=>{this.focusMainContainer();tools_classPrivateFieldSet(Je,this,null)},0))}tools_classPrivateFieldGet(Be,this).delete(e.id);e.annotationElementId&&tools_classPrivateFieldGet(ht,this)?.delete(e.annotationElementId);this.unselect(e);e.annotationElementId&&tools_classPrivateFieldGet(He,this).has(e.annotationElementId)||tools_classPrivateFieldGet(Oe,this)?.remove(e.id)}addDeletedAnnotationElement(e){tools_classPrivateFieldGet(He,this).add(e.annotationElementId);this.addChangedExistingAnnotation(e);e.deleted=!0}isDeletedAnnotationElement(e){return tools_classPrivateFieldGet(He,this).has(e)}removeDeletedAnnotationElement(e){tools_classPrivateFieldGet(He,this).delete(e.annotationElementId);this.removeChangedExistingAnnotation(e);e.deleted=!1}setActiveEditor(e){if(tools_classPrivateFieldGet(Ie,this)!==e){tools_classPrivateFieldSet(Ie,this,e);e&&tools_assertClassBrand(xt,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate)}}updateUI(e){(function tools_classPrivateGetter(e,t,i){return i(tools_assertClassBrand(e,t))})(xt,this,_get_lastSelectedEditor)===e&&tools_assertClassBrand(xt,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){tools_assertClassBrand(xt,this,_dispatchUpdateUI).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(tools_classPrivateFieldGet(pt,this).has(e)){tools_classPrivateFieldGet(pt,this).delete(e);e.unselect();tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:this.hasSelection})}else{tools_classPrivateFieldGet(pt,this).add(e);e.select();tools_assertClassBrand(xt,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate);tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:!0})}}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid});tools_classPrivateFieldGet(Ue,this)?.commitOrRemove();for(const t of tools_classPrivateFieldGet(pt,this))t!==e&&t.unselect();tools_classPrivateFieldGet(je,this)?.destroyPopup();tools_classPrivateFieldGet(pt,this).clear();tools_classPrivateFieldGet(pt,this).add(e);e.select();tools_assertClassBrand(xt,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate);tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:!0})}isSelected(e){return tools_classPrivateFieldGet(pt,this).has(e)}get firstSelectedEditor(){return tools_classPrivateFieldGet(pt,this).values().next().value}unselect(e){e.unselect();tools_classPrivateFieldGet(pt,this).delete(e);tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==tools_classPrivateFieldGet(pt,this).size}get isEnterHandled(){return 1===tools_classPrivateFieldGet(pt,this).size&&this.firstSelectedEditor.isEnterHandled}undo(){tools_classPrivateFieldGet(Ne,this).undo();tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:tools_classPrivateFieldGet(Ne,this).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:tools_assertClassBrand(xt,this,_isEmpty).call(this)});this._editorUndoBar?.hide()}redo(){tools_classPrivateFieldGet(Ne,this).redo();tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:tools_classPrivateFieldGet(Ne,this).hasSomethingToRedo(),isEmpty:tools_assertClassBrand(xt,this,_isEmpty).call(this)})}addCommands(e){tools_classPrivateFieldGet(Ne,this).add(e);tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:tools_assertClassBrand(xt,this,_isEmpty).call(this)})}cleanUndoStack(e){tools_classPrivateFieldGet(Ne,this).cleanType(e)}delete(){this.commitOrRemove();const e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const t=e?[e]:[...tools_classPrivateFieldGet(pt,this)],undo=()=>{for(const e of t)tools_assertClassBrand(xt,this,_addEditorToLayer).call(this,e)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(undo,1===t.length?t[0].editorType:t.length);for(const e of t)e.remove()},undo,mustExec:!0})}commitOrRemove(){tools_classPrivateFieldGet(Ie,this)?.commitOrRemove()}hasSomethingToControl(){return tools_classPrivateFieldGet(Ie,this)||this.hasSelection}selectAll(){for(const e of tools_classPrivateFieldGet(pt,this))e.commit();tools_assertClassBrand(xt,this,_selectEditors).call(this,tools_classPrivateFieldGet(Be,this).values())}unselectAll(){if(tools_classPrivateFieldGet(Ie,this)){tools_classPrivateFieldGet(Ie,this).commitOrRemove();if(tools_classPrivateFieldGet(_t,this)!==P.NONE)return}if(!tools_classPrivateFieldGet(Ue,this)?.commitOrRemove()){tools_classPrivateFieldGet(je,this)?.destroyPopup();if(this.hasSelection){for(const e of tools_classPrivateFieldGet(pt,this))e.unselect();tools_classPrivateFieldGet(pt,this).clear();tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:!1})}}}translateSelectedEditors(e,t){arguments.length>2&&void 0!==arguments[2]&&arguments[2]||this.commitOrRemove();if(!this.hasSelection)return;tools_classPrivateFieldGet(wt,this)[0]+=e;tools_classPrivateFieldGet(wt,this)[1]+=t;const i=tools_slicedToArray(tools_classPrivateFieldGet(wt,this),2),a=i[0],s=i[1],r=[...tools_classPrivateFieldGet(pt,this)];tools_classPrivateFieldGet(bt,this)&&clearTimeout(tools_classPrivateFieldGet(bt,this));tools_classPrivateFieldSet(bt,this,setTimeout(()=>{tools_classPrivateFieldSet(bt,this,null);tools_classPrivateFieldGet(wt,this)[0]=tools_classPrivateFieldGet(wt,this)[1]=0;this.addCommands({cmd:()=>{for(const e of r)if(tools_classPrivateFieldGet(Be,this).has(e.id)){e.translateInPage(a,s);e.translationDone()}},undo:()=>{for(const e of r)if(tools_classPrivateFieldGet(Be,this).has(e.id)){e.translateInPage(-a,-s);e.translationDone()}},mustExec:!1})},1e3));for(const i of r){i.translateInPage(e,t);i.translationDone()}}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0);tools_classPrivateFieldSet(ze,this,new Map);for(const e of tools_classPrivateFieldGet(pt,this))tools_classPrivateFieldGet(ze,this).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!tools_classPrivateFieldGet(ze,this))return!1;this.disableUserSelect(!1);const e=tools_classPrivateFieldGet(ze,this);tools_classPrivateFieldSet(ze,this,null);let t=!1;for(const s of e){var i=tools_slicedToArray(s,2),a=i[0];const e=a.x,r=a.y,n=a.pageIndex,o=i[1];o.newX=e;o.newY=r;o.newPageIndex=n;t||=e!==o.savedX||r!==o.savedY||n!==o.savedPageIndex}if(!t)return!1;const move=(e,t,i,a)=>{if(tools_classPrivateFieldGet(Be,this).has(e.id)){const s=tools_classPrivateFieldGet(Me,this).get(a);if(s)e._setParentAndPosition(s,t,i);else{e.pageIndex=a;e.x=t;e.y=i}}};this.addCommands({cmd:()=>{for(const a of e){var t=tools_slicedToArray(a,2);const e=t[0];var i=t[1];const s=i.newX,r=i.newY,n=i.newPageIndex,o=i.savedX,l=i.savedY,c=i.savedPageIndex;move(e,s,r,n);this._eventBus?.dispatch("annotation-editor-event",{source:e,type:"moved",page:n+1,editorType:e.constructor.name,id:e.uid,previousValue:{x:o,y:l,page:c+1},value:{x:s,y:r,page:n+1}})}},undo:()=>{for(const a of e){var t=tools_slicedToArray(a,2);const e=t[0];var i=t[1];const s=i.savedX,r=i.savedY,n=i.savedPageIndex;move(e,s,r,n)}},mustExec:!0});return!0}dragSelectedEditors(e,t){if(tools_classPrivateFieldGet(ze,this))for(const i of tools_classPrivateFieldGet(ze,this).keys())i.drag(e,t)}rebuild(e){if(null===e.parent){const t=this.getLayer(e.pageIndex);if(t){t.changeParent(e);t.addOrRebuild(e)}else{this.addEditor(e);this.addToAnnotationStorage(e);e.rebuild()}}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===tools_classPrivateFieldGet(pt,this).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return tools_classPrivateFieldGet(Ie,this)===e}getActive(){return tools_classPrivateFieldGet(Ie,this)}getMode(){return tools_classPrivateFieldGet(_t,this)}isEditingMode(){return tools_classPrivateFieldGet(_t,this)!==P.NONE}get imageManager(){return shadow(this,"imageManager",new ImageManager)}removeEditors(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>!0,t=!1;tools_classPrivateFieldGet(Be,this).forEach(i=>{if(i?.serialize()&&e(i.serialize())){i.remove();t=!0}});if(t){tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:!1,hasSomethingToRedo:!1,isEmpty:tools_assertClassBrand(xt,this,_isEmpty).call(this)});tools_classPrivateFieldGet(Ne,this).reset()}}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let i=0,a=t.rangeCount;i<a;i++)if(!e.contains(t.getRangeAt(i).commonAncestorContainer))return null;const i=e.getBoundingClientRect(),a=i.x,s=i.y,r=i.width,n=i.height;let o;switch(e.getAttribute("data-main-rotation")){case"90":o=(e,t,i,o)=>({x:(t-s)/n,y:1-(e+i-a)/r,width:o/n,height:i/r});break;case"180":o=(e,t,i,o)=>({x:1-(e+i-a)/r,y:1-(t+o-s)/n,width:i/r,height:o/n});break;case"270":o=(e,t,i,o)=>({x:1-(t+o-s)/n,y:(e-a)/r,width:o/n,height:i/r});break;default:o=(e,t,i,o)=>({x:(e-a)/r,y:(t-s)/n,width:i/r,height:o/n})}const l=[];for(let e=0,i=t.rangeCount;e<i;e++){const i=t.getRangeAt(e);if(!i.collapsed)for(const e of i.getClientRects()){const t=e.x,i=e.y,a=e.width,s=e.height;0!==a&&0!==s&&l.push(o(t,i,a,s))}}return 0===l.length?null:l}addChangedExistingAnnotation(e){let t=e.annotationElementId,i=e.id;(tools_classPrivateFieldGet(Re,this)||tools_classPrivateFieldSet(Re,this,new Map)).set(t,i)}removeChangedExistingAnnotation(e){let t=e.annotationElementId;tools_classPrivateFieldGet(Re,this)?.delete(t)}renderAnnotationElement(e){const t=tools_classPrivateFieldGet(Re,this)?.get(e.data.id);if(!t)return;const i=tools_classPrivateFieldGet(Oe,this).getRawValue(t);i&&(tools_classPrivateFieldGet(_t,this)!==P.NONE||i.hasBeenModified)&&i.renderAnnotationElement(e)}setMissingCanvas(e,t,i){const a=tools_classPrivateFieldGet(ht,this)?.get(e);if(a){a.setCanvas(t,i);tools_classPrivateFieldGet(ht,this).delete(e)}}addMissingCanvas(e,t){(tools_classPrivateFieldGet(ht,this)||tools_classPrivateFieldSet(ht,this,new Map)).set(e,t)}}function _getAnchorElementForSelection(e){let t=e.anchorNode;return t.nodeType===Node.TEXT_NODE?t.parentElement:t}function _getLayerForTextLayer(e){const t=this.currentLayer;if(t.hasTextLayer(e))return t;for(const t of tools_classPrivateFieldGet(Me,this).values())if(t.hasTextLayer(e))return t;return null}function _beforeUnload(e){this.commitOrRemove();this.currentLayer?.endDrawingSession(!1)}function _displayFloatingToolbar(){const e=document.getSelection();if(!e||e.isCollapsed)return;const t=tools_assertClassBrand(xt,this,_getAnchorElementForSelection).call(this,e).closest(".textLayer"),i=this.getSelectionBoxes(t);if(i){tools_classPrivateFieldGet(it,this)||tools_classPrivateFieldSet(it,this,new FloatingToolbar(this));tools_classPrivateFieldGet(it,this).show(t,i,"ltr"===this.direction)}}function _selectionChange(){const e=document.getSelection();if(!e||e.isCollapsed){if(tools_classPrivateFieldGet(gt,this)){tools_classPrivateFieldGet(it,this)?.hide();tools_classPrivateFieldSet(gt,this,null);tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSelectedText:!1})}return}const t=e.anchorNode;if(t===tools_classPrivateFieldGet(gt,this))return;const i=tools_assertClassBrand(xt,this,_getAnchorElementForSelection).call(this,e).closest(".textLayer");if(i){tools_classPrivateFieldGet(it,this)?.hide();tools_classPrivateFieldSet(gt,this,t);tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSelectedText:!0});if(tools_classPrivateFieldGet(_t,this)===P.HIGHLIGHT||tools_classPrivateFieldGet(_t,this)===P.NONE){tools_classPrivateFieldGet(_t,this)===P.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0);tools_classPrivateFieldSet(tt,this,this.isShiftKeyDown);if(!this.isShiftKeyDown){const e=tools_classPrivateFieldGet(_t,this)===P.HIGHLIGHT?tools_assertClassBrand(xt,this,_getLayerForTextLayer).call(this,i):null;e?.toggleDrawing();if(tools_classPrivateFieldGet(nt,this)){const t=new AbortController,i=this.combinedSignal(t),pointerup=i=>{if("pointerup"!==i.type||0===i.button){t.abort();e?.toggleDrawing(!0);"pointerup"===i.type&&tools_assertClassBrand(xt,this,_onSelectEnd).call(this,"main_toolbar")}};window.addEventListener("pointerup",pointerup,{signal:i});window.addEventListener("blur",pointerup,{signal:i})}else{e?.toggleDrawing(!0);tools_assertClassBrand(xt,this,_onSelectEnd).call(this,"main_toolbar")}}}}else if(tools_classPrivateFieldGet(gt,this)){tools_classPrivateFieldGet(it,this)?.hide();tools_classPrivateFieldSet(gt,this,null);tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSelectedText:!1})}}function _onSelectEnd(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";tools_classPrivateFieldGet(_t,this)===P.HIGHLIGHT?this.highlightSelection(e):tools_classPrivateFieldGet(Xe,this)&&tools_assertClassBrand(xt,this,_displayFloatingToolbar).call(this)}function _addSelectionListener(){document.addEventListener("selectionchange",tools_assertClassBrand(xt,this,_selectionChange).bind(this),{signal:this._signal})}function _addFocusManager(){if(tools_classPrivateFieldGet(Qe,this))return;tools_classPrivateFieldSet(Qe,this,new AbortController);const e=this.combinedSignal(tools_classPrivateFieldGet(Qe,this));window.addEventListener("focus",this.focus.bind(this),{signal:e});window.addEventListener("blur",this.blur.bind(this),{signal:e})}function _removeFocusManager(){tools_classPrivateFieldGet(Qe,this)?.abort();tools_classPrivateFieldSet(Qe,this,null)}function _addKeyboardManager(){if(tools_classPrivateFieldGet(lt,this))return;tools_classPrivateFieldSet(lt,this,new AbortController);const e=this.combinedSignal(tools_classPrivateFieldGet(lt,this));window.addEventListener("keydown",this.keydown.bind(this),{signal:e});window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}function _removeKeyboardManager(){tools_classPrivateFieldGet(lt,this)?.abort();tools_classPrivateFieldSet(lt,this,null)}function _addCopyPasteListeners(){if(tools_classPrivateFieldGet(We,this))return;tools_classPrivateFieldSet(We,this,new AbortController);const e=this.combinedSignal(tools_classPrivateFieldGet(We,this));document.addEventListener("copy",this.copy.bind(this),{signal:e});document.addEventListener("cut",this.cut.bind(this),{signal:e});document.addEventListener("paste",this.paste.bind(this),{signal:e})}function _removeCopyPasteListeners(){tools_classPrivateFieldGet(We,this)?.abort();tools_classPrivateFieldSet(We,this,null)}function _addDragAndDropListeners(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e});document.addEventListener("drop",this.drop.bind(this),{signal:e})}function _dispatchUpdateStates(e){if(Object.entries(e).some(e=>{let t=tools_slicedToArray(e,2),i=t[0],a=t[1];return tools_classPrivateFieldGet(Pt,this)[i]!==a})){this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(tools_classPrivateFieldGet(Pt,this),e)});tools_classPrivateFieldGet(_t,this)===P.HIGHLIGHT&&!1===e.hasSelectedEditor&&tools_assertClassBrand(xt,this,_dispatchUpdateUI).call(this,[[w.HIGHLIGHT_FREE,!0]])}}function _dispatchUpdateUI(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}async function _enableAll(){if(!tools_classPrivateFieldGet(rt,this)){tools_classPrivateFieldSet(rt,this,!0);const e=[];for(const t of tools_classPrivateFieldGet(Me,this).values())e.push(t.enable());await Promise.all(e);for(const e of tools_classPrivateFieldGet(Be,this).values())e.enable()}}function _disableAll(){this.unselectAll();if(tools_classPrivateFieldGet(rt,this)){tools_classPrivateFieldSet(rt,this,!1);for(const e of tools_classPrivateFieldGet(Me,this).values())e.disable();for(const e of tools_classPrivateFieldGet(Be,this).values())e.disable()}}function _addEditorToLayer(e){const t=tools_classPrivateFieldGet(Me,this).get(e.pageIndex);if(t)t.addOrRebuild(e);else{this.addEditor(e);this.addToAnnotationStorage(e)}}function _get_lastSelectedEditor(e){let t=null;for(t of tools_classPrivateFieldGet(pt,e));return t}function _isEmpty(){if(0===tools_classPrivateFieldGet(Be,this).size)return!0;if(1===tools_classPrivateFieldGet(Be,this).size)for(const e of tools_classPrivateFieldGet(Be,this).values())return e.isEmpty();return!1}function _selectEditors(e){for(const e of tools_classPrivateFieldGet(pt,this))e.unselect();tools_classPrivateFieldGet(pt,this).clear();for(const t of e)if(!t.isEmpty()){tools_classPrivateFieldGet(pt,this).add(t);t.select()}tools_assertClassBrand(xt,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:this.hasSelection})}tools_defineProperty(AnnotationEditorUIManager,"TRANSLATE_SMALL",1);tools_defineProperty(AnnotationEditorUIManager,"TRANSLATE_BIG",10);function alt_text_classPrivateFieldInitSpec(e,t,i){alt_text_checkPrivateRedeclaration(e,t),t.set(e,i)}function alt_text_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function alt_text_classPrivateGetter(e,t,i){return i(alt_text_assertClassBrand(e,t))}function alt_text_classPrivateFieldGet(e,t){return e.get(alt_text_assertClassBrand(e,t))}function alt_text_classPrivateFieldSet(e,t,i){return e.set(alt_text_assertClassBrand(e,t),i),i}function alt_text_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var kt=new WeakMap,Et=new WeakMap,Tt=new WeakMap,It=new WeakMap,Gt=new WeakMap,Bt=new WeakMap,Mt=new WeakMap,Dt=new WeakMap,Lt=new WeakMap,Ot=new WeakMap,Rt=new WeakMap,Nt=new WeakMap,jt=new WeakSet;class AltText{constructor(e){!function alt_text_classPrivateMethodInitSpec(e,t){alt_text_checkPrivateRedeclaration(e,t),t.add(e)}(this,jt);alt_text_classPrivateFieldInitSpec(this,kt,null);alt_text_classPrivateFieldInitSpec(this,Et,!1);alt_text_classPrivateFieldInitSpec(this,Tt,null);alt_text_classPrivateFieldInitSpec(this,It,null);alt_text_classPrivateFieldInitSpec(this,Gt,null);alt_text_classPrivateFieldInitSpec(this,Bt,null);alt_text_classPrivateFieldInitSpec(this,Mt,!1);alt_text_classPrivateFieldInitSpec(this,Dt,null);alt_text_classPrivateFieldInitSpec(this,Lt,null);alt_text_classPrivateFieldInitSpec(this,Ot,null);alt_text_classPrivateFieldInitSpec(this,Rt,null);alt_text_classPrivateFieldInitSpec(this,Nt,!1);alt_text_classPrivateFieldSet(Lt,this,e);alt_text_classPrivateFieldSet(Nt,this,e._uiManager.useNewAltTextFlow);Wt._||(Wt._=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(e){AltText._l10n??=e}async render(){const e=alt_text_classPrivateFieldSet(Tt,this,document.createElement("button"));e.className="altText";e.tabIndex="0";const t=alt_text_classPrivateFieldSet(It,this,document.createElement("span"));e.append(t);if(alt_text_classPrivateFieldGet(Nt,this)){e.classList.add("new");e.setAttribute("data-l10n-id",Wt._.missing);t.setAttribute("data-l10n-id",Wt._["missing-label"])}else{e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button");t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label")}const i=alt_text_classPrivateFieldGet(Lt,this)._uiManager._signal;e.addEventListener("contextmenu",noContextMenu,{signal:i});e.addEventListener("pointerdown",e=>e.stopPropagation(),{signal:i});const onClick=e=>{e.preventDefault();alt_text_classPrivateFieldGet(Lt,this)._uiManager.editAltText(alt_text_classPrivateFieldGet(Lt,this));alt_text_classPrivateFieldGet(Nt,this)&&alt_text_classPrivateFieldGet(Lt,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:alt_text_classPrivateGetter(jt,this,_get_label)}})};e.addEventListener("click",onClick,{capture:!0,signal:i});e.addEventListener("keydown",t=>{if(t.target===e&&"Enter"===t.key){alt_text_classPrivateFieldSet(Mt,this,!0);onClick(t)}},{signal:i});await alt_text_assertClassBrand(jt,this,_setState).call(this);return e}finish(){if(alt_text_classPrivateFieldGet(Tt,this)){alt_text_classPrivateFieldGet(Tt,this).focus({focusVisible:alt_text_classPrivateFieldGet(Mt,this)});alt_text_classPrivateFieldSet(Mt,this,!1)}}isEmpty(){return alt_text_classPrivateFieldGet(Nt,this)?null===alt_text_classPrivateFieldGet(kt,this):!alt_text_classPrivateFieldGet(kt,this)&&!alt_text_classPrivateFieldGet(Et,this)}hasData(){return alt_text_classPrivateFieldGet(Nt,this)?null!==alt_text_classPrivateFieldGet(kt,this)||!!alt_text_classPrivateFieldGet(Ot,this):this.isEmpty()}get guessedText(){return alt_text_classPrivateFieldGet(Ot,this)}async setGuessedText(e){if(null===alt_text_classPrivateFieldGet(kt,this)){alt_text_classPrivateFieldSet(Ot,this,e);alt_text_classPrivateFieldSet(Rt,this,await AltText._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}));alt_text_assertClassBrand(jt,this,_setState).call(this)}}toggleAltTextBadge(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(alt_text_classPrivateFieldGet(Nt,this)&&!alt_text_classPrivateFieldGet(kt,this)){if(!alt_text_classPrivateFieldGet(Dt,this)){const e=alt_text_classPrivateFieldSet(Dt,this,document.createElement("div"));e.className="noAltTextBadge";alt_text_classPrivateFieldGet(Lt,this).div.append(e)}alt_text_classPrivateFieldGet(Dt,this).classList.toggle("hidden",!e)}else{alt_text_classPrivateFieldGet(Dt,this)?.remove();alt_text_classPrivateFieldSet(Dt,this,null)}}serialize(e){let t=alt_text_classPrivateFieldGet(kt,this);e||alt_text_classPrivateFieldGet(Ot,this)!==t||(t=alt_text_classPrivateFieldGet(Rt,this));return{altText:t,decorative:alt_text_classPrivateFieldGet(Et,this),guessedText:alt_text_classPrivateFieldGet(Ot,this),textWithDisclaimer:alt_text_classPrivateFieldGet(Rt,this)}}get data(){return{altText:alt_text_classPrivateFieldGet(kt,this),decorative:alt_text_classPrivateFieldGet(Et,this)}}set data(e){let t=e.altText,i=e.decorative,a=e.guessedText,s=e.textWithDisclaimer,r=e.cancel,n=void 0!==r&&r;if(a){alt_text_classPrivateFieldSet(Ot,this,a);alt_text_classPrivateFieldSet(Rt,this,s)}if(alt_text_classPrivateFieldGet(kt,this)!==t||alt_text_classPrivateFieldGet(Et,this)!==i){if(!n){alt_text_classPrivateFieldSet(kt,this,t);alt_text_classPrivateFieldSet(Et,this,i)}alt_text_assertClassBrand(jt,this,_setState).call(this)}}toggle(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(alt_text_classPrivateFieldGet(Tt,this)){if(!e&&alt_text_classPrivateFieldGet(Bt,this)){clearTimeout(alt_text_classPrivateFieldGet(Bt,this));alt_text_classPrivateFieldSet(Bt,this,null)}alt_text_classPrivateFieldGet(Tt,this).disabled=!e}}shown(){alt_text_classPrivateFieldGet(Lt,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:alt_text_classPrivateGetter(jt,this,_get_label)}})}destroy(){alt_text_classPrivateFieldGet(Tt,this)?.remove();alt_text_classPrivateFieldSet(Tt,this,null);alt_text_classPrivateFieldSet(It,this,null);alt_text_classPrivateFieldSet(Gt,this,null);alt_text_classPrivateFieldGet(Dt,this)?.remove();alt_text_classPrivateFieldSet(Dt,this,null)}}function _get_label(e){return(alt_text_classPrivateFieldGet(kt,e)?"added":null===alt_text_classPrivateFieldGet(kt,e)&&e.guessedText&&"review")||"missing"}async function _setState(){const e=alt_text_classPrivateFieldGet(Tt,this);if(!e)return;if(alt_text_classPrivateFieldGet(Nt,this)){e.classList.toggle("done",!!alt_text_classPrivateFieldGet(kt,this));e.setAttribute("data-l10n-id",Wt._[alt_text_classPrivateGetter(jt,this,_get_label)]);alt_text_classPrivateFieldGet(It,this)?.setAttribute("data-l10n-id",Wt._[`${alt_text_classPrivateGetter(jt,this,_get_label)}-label`]);if(!alt_text_classPrivateFieldGet(kt,this)){alt_text_classPrivateFieldGet(Gt,this)?.remove();return}}else{if(!alt_text_classPrivateFieldGet(kt,this)&&!alt_text_classPrivateFieldGet(Et,this)){e.classList.remove("done");alt_text_classPrivateFieldGet(Gt,this)?.remove();return}e.classList.add("done");e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=alt_text_classPrivateFieldGet(Gt,this);if(!t){alt_text_classPrivateFieldSet(Gt,this,t=document.createElement("span"));t.className="tooltip";t.setAttribute("role","tooltip");t.id=`alt-text-tooltip-${alt_text_classPrivateFieldGet(Lt,this).id}`;const i=100,a=alt_text_classPrivateFieldGet(Lt,this)._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(alt_text_classPrivateFieldGet(Bt,this));alt_text_classPrivateFieldSet(Bt,this,null)},{once:!0});e.addEventListener("mouseenter",()=>{alt_text_classPrivateFieldSet(Bt,this,setTimeout(()=>{alt_text_classPrivateFieldSet(Bt,this,null);alt_text_classPrivateFieldGet(Gt,this).classList.add("show");alt_text_classPrivateFieldGet(Lt,this)._reportTelemetry({action:"alt_text_tooltip"})},i))},{signal:a});e.addEventListener("mouseleave",()=>{if(alt_text_classPrivateFieldGet(Bt,this)){clearTimeout(alt_text_classPrivateFieldGet(Bt,this));alt_text_classPrivateFieldSet(Bt,this,null)}alt_text_classPrivateFieldGet(Gt,this)?.classList.remove("show")},{signal:a})}if(alt_text_classPrivateFieldGet(Et,this))t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip");else{t.removeAttribute("data-l10n-id");t.textContent=alt_text_classPrivateFieldGet(kt,this)}t.parentNode||e.append(t);const i=alt_text_classPrivateFieldGet(Lt,this).getElementForAltText();i?.setAttribute("aria-describedby",t.id)}var Wt={_:null};!function alt_text_defineProperty(e,t,i){return(t=function alt_text_toPropertyKey(e){var t=function alt_text_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(AltText,"_l10n",null);function comment_slicedToArray(e,t){return function comment_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function comment_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function comment_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return comment_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?comment_arrayLikeToArray(e,t):void 0}}(e,t)||function comment_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function comment_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function comment_classPrivateFieldInitSpec(e,t,i){comment_checkPrivateRedeclaration(e,t),t.set(e,i)}function comment_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function comment_classPrivateFieldGet(e,t){return e.get(comment_assertClassBrand(e,t))}function comment_classPrivateFieldSet(e,t,i){return e.set(comment_assertClassBrand(e,t),i),i}function comment_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Ut,Vt=new WeakMap,Ht=new WeakMap,zt=new WeakMap,$t=new WeakMap,qt=new WeakMap,Xt=new WeakMap,Kt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,Jt=new WeakMap,Qt=new WeakSet;class Comment{constructor(e){!function comment_classPrivateMethodInitSpec(e,t){comment_checkPrivateRedeclaration(e,t),t.add(e)}(this,Qt);comment_classPrivateFieldInitSpec(this,Vt,null);comment_classPrivateFieldInitSpec(this,Ht,null);comment_classPrivateFieldInitSpec(this,zt,!1);comment_classPrivateFieldInitSpec(this,$t,null);comment_classPrivateFieldInitSpec(this,qt,null);comment_classPrivateFieldInitSpec(this,Xt,null);comment_classPrivateFieldInitSpec(this,Kt,null);comment_classPrivateFieldInitSpec(this,Yt,null);comment_classPrivateFieldInitSpec(this,Zt,!1);comment_classPrivateFieldInitSpec(this,Jt,null);comment_classPrivateFieldSet($t,this,e)}renderForToolbar(){const e=comment_classPrivateFieldSet(Ht,this,document.createElement("button"));e.className="comment";return comment_assertClassBrand(Qt,this,comment_render).call(this,e,!1)}renderForStandalone(){const e=comment_classPrivateFieldSet(Vt,this,document.createElement("button"));e.className="annotationCommentButton";const t=comment_classPrivateFieldGet($t,this).commentButtonPosition;if(t){const i=e.style;i.insetInlineEnd=`calc(${100*("ltr"===comment_classPrivateFieldGet($t,this)._uiManager.direction?1-t[0]:t[0])}% - var(--comment-button-dim))`;i.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;const a=comment_classPrivateFieldGet($t,this).commentButtonColor;a&&(i.backgroundColor=a)}return comment_assertClassBrand(Qt,this,comment_render).call(this,e,!0)}focusButton(){setTimeout(()=>{(comment_classPrivateFieldGet(Vt,this)??comment_classPrivateFieldGet(Ht,this))?.focus()},0)}onUpdatedColor(){if(!comment_classPrivateFieldGet(Vt,this))return;const e=comment_classPrivateFieldGet($t,this).commentButtonColor;e&&(comment_classPrivateFieldGet(Vt,this).style.backgroundColor=e);comment_classPrivateFieldGet($t,this)._uiManager.updatePopupColor(comment_classPrivateFieldGet($t,this))}get commentButtonWidth(){return(comment_classPrivateFieldGet(Vt,this)?.getBoundingClientRect().width??0)/comment_classPrivateFieldGet($t,this).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(comment_classPrivateFieldGet(Jt,this))return comment_classPrivateFieldGet(Jt,this);if(!comment_classPrivateFieldGet(Vt,this))return null;const e=comment_classPrivateFieldGet(Vt,this).getBoundingClientRect(),t=e.x,i=e.y,a=e.height,s=comment_classPrivateFieldGet($t,this).parent.boundingClientRect,r=s.x,n=s.y;return[(t-r)/s.width,(i+a-n)/s.height]}set commentPopupPositionInLayer(e){comment_classPrivateFieldSet(Jt,this,e)}hasDefaultPopupPosition(){return null===comment_classPrivateFieldGet(Jt,this)}removeStandaloneCommentButton(){comment_classPrivateFieldGet(Vt,this)?.remove();comment_classPrivateFieldSet(Vt,this,null)}removeToolbarCommentButton(){comment_classPrivateFieldGet(Ht,this)?.remove();comment_classPrivateFieldSet(Ht,this,null)}setCommentButtonStates(e){let t=e.selected,i=e.hasPopup;if(comment_classPrivateFieldGet(Vt,this)){comment_classPrivateFieldGet(Vt,this).classList.toggle("selected",t);comment_classPrivateFieldGet(Vt,this).ariaExpanded=i}}edit(e){const t=this.commentPopupPositionInLayer;let i,a;if(t){var s=comment_slicedToArray(t,2);i=s[0];a=s[1]}else{var r=comment_slicedToArray(comment_classPrivateFieldGet($t,this).commentButtonPosition,2);i=r[0];a=r[1];const e=comment_classPrivateFieldGet($t,this),t=e.width,s=e.height;i=e.x+i*t;a=e.y+a*s}const n=comment_classPrivateFieldGet($t,this).parent.boundingClientRect,o=n.x,l=n.y,c=n.width,d=n.height;comment_classPrivateFieldGet($t,this)._uiManager.editComment(comment_classPrivateFieldGet($t,this),o+i*c,l+a*d,{...e,parentDimensions:n})}finish(){if(comment_classPrivateFieldGet(Ht,this)){comment_classPrivateFieldGet(Ht,this).focus({focusVisible:comment_classPrivateFieldGet(zt,this)});comment_classPrivateFieldSet(zt,this,!1)}}isDeleted(){return comment_classPrivateFieldGet(Zt,this)||""===comment_classPrivateFieldGet(Kt,this)}isEmpty(){return null===comment_classPrivateFieldGet(Kt,this)}hasBeenEdited(){return this.isDeleted()||comment_classPrivateFieldGet(Kt,this)!==comment_classPrivateFieldGet(qt,this)}serialize(){return this.data}get data(){return{text:comment_classPrivateFieldGet(Kt,this),richText:comment_classPrivateFieldGet(Xt,this),date:comment_classPrivateFieldGet(Yt,this),deleted:this.isDeleted()}}set data(e){e!==comment_classPrivateFieldGet(Kt,this)&&comment_classPrivateFieldSet(Xt,this,null);if(null!==e){comment_classPrivateFieldSet(Kt,this,e);comment_classPrivateFieldSet(Yt,this,new Date);comment_classPrivateFieldSet(Zt,this,!1);comment_classPrivateFieldGet($t,this).eventBus?.dispatch("annotation-editor-event",{source:comment_classPrivateFieldGet($t,this),type:"commented",page:comment_classPrivateFieldGet($t,this).pageIndex+1,editorType:comment_classPrivateFieldGet($t,this).constructor.name,id:comment_classPrivateFieldGet($t,this).uid,value:comment_classPrivateFieldGet($t,this)})}else{comment_classPrivateFieldSet(Kt,this,"");comment_classPrivateFieldSet(Zt,this,!0);comment_classPrivateFieldGet($t,this).eventBus?.dispatch("annotation-editor-event",{source:comment_classPrivateFieldGet($t,this),type:"commentRemoved",page:comment_classPrivateFieldGet($t,this).pageIndex+1,editorType:comment_classPrivateFieldGet($t,this).constructor.name,id:comment_classPrivateFieldGet($t,this).uid,value:comment_classPrivateFieldGet($t,this)})}}restoreData(e){let t=e.text,i=e.richText,a=e.date;comment_classPrivateFieldSet(Kt,this,t);comment_classPrivateFieldSet(Xt,this,i);comment_classPrivateFieldSet(Yt,this,a);comment_classPrivateFieldSet(Zt,this,!1)}setInitialText(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;comment_classPrivateFieldSet(qt,this,e);this.data=e;comment_classPrivateFieldSet(Yt,this,null);comment_classPrivateFieldSet(Xt,this,t)}setDate(e){const t=e&&new Date(e);!t||isNaN(t)?comment_classPrivateFieldSet(Yt,this,new Date):comment_classPrivateFieldSet(Yt,this,t)}shown(){}destroy(){comment_classPrivateFieldGet(Ht,this)?.remove();comment_classPrivateFieldSet(Ht,this,null);comment_classPrivateFieldGet(Vt,this)?.remove();comment_classPrivateFieldSet(Vt,this,null);comment_classPrivateFieldSet(Kt,this,"");comment_classPrivateFieldSet(Xt,this,null);comment_classPrivateFieldSet(Yt,this,null);comment_classPrivateFieldSet($t,this,null);comment_classPrivateFieldSet(zt,this,!1);comment_classPrivateFieldSet(Zt,this,!1)}}function comment_render(e,t){if(!comment_classPrivateFieldGet($t,this)._uiManager.hasCommentManager())return null;e.tabIndex="0";e.ariaHasPopup="dialog";if(t){e.ariaControls="commentPopup";e.setAttribute("data-l10n-id","pdfjs-show-comment-button")}else{e.ariaControlsElements=[comment_classPrivateFieldGet($t,this)._uiManager.getCommentDialogElement()];e.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button")}const i=comment_classPrivateFieldGet($t,this)._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return e;e.addEventListener("contextmenu",noContextMenu,{signal:i});if(t){e.addEventListener("focusin",e=>{comment_classPrivateFieldGet($t,this)._focusEventsAllowed=!1;stopEvent(e)},{capture:!0,signal:i});e.addEventListener("focusout",e=>{comment_classPrivateFieldGet($t,this)._focusEventsAllowed=!0;stopEvent(e)},{capture:!0,signal:i})}e.addEventListener("pointerdown",e=>e.stopPropagation(),{signal:i});const onClick=t=>{t.preventDefault();e===comment_classPrivateFieldGet(Ht,this)?this.edit():comment_classPrivateFieldGet($t,this).toggleComment(!0)};e.addEventListener("click",onClick,{capture:!0,signal:i});e.addEventListener("keydown",t=>{if(t.target===e&&"Enter"===t.key){comment_classPrivateFieldSet(zt,this,!0);onClick(t)}},{signal:i});e.addEventListener("pointerenter",()=>{comment_classPrivateFieldGet($t,this).toggleComment(!1,!0)},{signal:i});e.addEventListener("pointerleave",()=>{comment_classPrivateFieldGet($t,this).toggleComment(!1,!1)},{signal:i});return e}function touch_manager_slicedToArray(e,t){return function touch_manager_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function touch_manager_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function touch_manager_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return touch_manager_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?touch_manager_arrayLikeToArray(e,t):void 0}}(e,t)||function touch_manager_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function touch_manager_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function touch_manager_classPrivateFieldInitSpec(e,t,i){touch_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function touch_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function touch_manager_classPrivateFieldGet(e,t){return e.get(touch_manager_assertClassBrand(e,t))}function touch_manager_classPrivateFieldSet(e,t,i){return e.set(touch_manager_assertClassBrand(e,t),i),i}function touch_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var ei,ti=new WeakMap,ii=new WeakMap,ai=new WeakMap,si=new WeakMap,ri=new WeakMap,ni=new WeakMap,oi=new WeakMap,li=new WeakMap,ci=new WeakMap,di=new WeakMap,hi=new WeakMap,ui=new WeakMap,_i=new WeakSet;class TouchManager{constructor(e){let t=e.container,i=e.isPinchingDisabled,a=void 0===i?null:i,s=e.isPinchingStopped,r=void 0===s?null:s,n=e.onPinchStart,o=void 0===n?null:n,l=e.onPinching,c=void 0===l?null:l,d=e.onPinchEnd,h=void 0===d?null:d,u=e.signal;!function touch_manager_classPrivateMethodInitSpec(e,t){touch_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,_i);touch_manager_classPrivateFieldInitSpec(this,ti,void 0);touch_manager_classPrivateFieldInitSpec(this,ii,!1);touch_manager_classPrivateFieldInitSpec(this,ai,null);touch_manager_classPrivateFieldInitSpec(this,si,void 0);touch_manager_classPrivateFieldInitSpec(this,ri,void 0);touch_manager_classPrivateFieldInitSpec(this,ni,void 0);touch_manager_classPrivateFieldInitSpec(this,oi,void 0);touch_manager_classPrivateFieldInitSpec(this,li,null);touch_manager_classPrivateFieldInitSpec(this,ci,void 0);touch_manager_classPrivateFieldInitSpec(this,di,null);touch_manager_classPrivateFieldInitSpec(this,hi,void 0);touch_manager_classPrivateFieldInitSpec(this,ui,null);touch_manager_classPrivateFieldSet(ti,this,t);touch_manager_classPrivateFieldSet(ai,this,r);touch_manager_classPrivateFieldSet(si,this,a);touch_manager_classPrivateFieldSet(ri,this,o);touch_manager_classPrivateFieldSet(ni,this,c);touch_manager_classPrivateFieldSet(oi,this,h);touch_manager_classPrivateFieldSet(hi,this,new AbortController);touch_manager_classPrivateFieldSet(ci,this,AbortSignal.any([u,touch_manager_classPrivateFieldGet(hi,this).signal]));t.addEventListener("touchstart",touch_manager_assertClassBrand(_i,this,_onTouchStart).bind(this),{passive:!1,signal:touch_manager_classPrivateFieldGet(ci,this)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/OutputScale.pixelRatio}destroy(){touch_manager_classPrivateFieldGet(hi,this)?.abort();touch_manager_classPrivateFieldSet(hi,this,null);touch_manager_classPrivateFieldGet(li,this)?.abort();touch_manager_classPrivateFieldSet(li,this,null)}}Ut=TouchManager;function _onTouchStart(e){if(touch_manager_classPrivateFieldGet(si,this)?.call(this))return;if(1===e.touches.length){if(touch_manager_classPrivateFieldGet(li,this))return;const e=touch_manager_classPrivateFieldSet(li,this,new AbortController),t=AbortSignal.any([touch_manager_classPrivateFieldGet(ci,this),e.signal]),i=touch_manager_classPrivateFieldGet(ti,this),a={capture:!0,signal:t,passive:!1},cancelPointerDown=e=>{if("touch"===e.pointerType){touch_manager_classPrivateFieldGet(li,this)?.abort();touch_manager_classPrivateFieldSet(li,this,null)}};i.addEventListener("pointerdown",e=>{if("touch"===e.pointerType){stopEvent(e);cancelPointerDown(e)}},a);i.addEventListener("pointerup",cancelPointerDown,a);i.addEventListener("pointercancel",cancelPointerDown,a);return}if(!touch_manager_classPrivateFieldGet(ui,this)){touch_manager_classPrivateFieldSet(ui,this,new AbortController);const e=AbortSignal.any([touch_manager_classPrivateFieldGet(ci,this),touch_manager_classPrivateFieldGet(ui,this).signal]),t=touch_manager_classPrivateFieldGet(ti,this),i={signal:e,capture:!1,passive:!1};t.addEventListener("touchmove",touch_manager_assertClassBrand(_i,this,_onTouchMove).bind(this),i);const a=touch_manager_assertClassBrand(_i,this,_onTouchEnd).bind(this);t.addEventListener("touchend",a,i);t.addEventListener("touchcancel",a,i);i.capture=!0;t.addEventListener("pointerdown",stopEvent,i);t.addEventListener("pointermove",stopEvent,i);t.addEventListener("pointercancel",stopEvent,i);t.addEventListener("pointerup",stopEvent,i);touch_manager_classPrivateFieldGet(ri,this)?.call(this)}stopEvent(e);if(2!==e.touches.length||touch_manager_classPrivateFieldGet(ai,this)?.call(this)){touch_manager_classPrivateFieldSet(di,this,null);return}let t=touch_manager_slicedToArray(e.touches,2),i=t[0],a=t[1];if(i.identifier>a.identifier){var s=[a,i];i=s[0];a=s[1]}touch_manager_classPrivateFieldSet(di,this,{touch0X:i.screenX,touch0Y:i.screenY,touch1X:a.screenX,touch1Y:a.screenY})}function _onTouchMove(e){if(!touch_manager_classPrivateFieldGet(di,this)||2!==e.touches.length)return;stopEvent(e);let t=touch_manager_slicedToArray(e.touches,2),i=t[0],a=t[1];if(i.identifier>a.identifier){var s=[a,i];i=s[0];a=s[1]}const r=i,n=r.screenX,o=r.screenY,l=a,c=l.screenX,d=l.screenY,h=touch_manager_classPrivateFieldGet(di,this),u=h.touch0X,_=h.touch0Y,p=h.touch1X-u,g=h.touch1Y-_,f=c-n,m=d-o,v=Math.hypot(f,m)||1,y=Math.hypot(p,g)||1;if(!touch_manager_classPrivateFieldGet(ii,this)&&Math.abs(y-v)<=Ut.MIN_TOUCH_DISTANCE_TO_PINCH)return;h.touch0X=n;h.touch0Y=o;h.touch1X=c;h.touch1Y=d;if(!touch_manager_classPrivateFieldGet(ii,this)){touch_manager_classPrivateFieldSet(ii,this,!0);return}const P=[(i.screenX+a.screenX)/2,(i.screenY+a.screenY)/2];touch_manager_classPrivateFieldGet(ni,this)?.call(this,P,y,v)}function _onTouchEnd(e){if(!(e.touches.length>=2)){if(touch_manager_classPrivateFieldGet(ui,this)){touch_manager_classPrivateFieldGet(ui,this).abort();touch_manager_classPrivateFieldSet(ui,this,null);touch_manager_classPrivateFieldGet(oi,this)?.call(this)}if(touch_manager_classPrivateFieldGet(di,this)){stopEvent(e);touch_manager_classPrivateFieldSet(di,this,null);touch_manager_classPrivateFieldSet(ii,this,!1)}}}function editor_slicedToArray(e,t){return function editor_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function editor_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function editor_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return editor_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?editor_arrayLikeToArray(e,t):void 0}}(e,t)||function editor_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function editor_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function editor_defineProperty(e,t,i){return(t=function editor_toPropertyKey(e){var t=function editor_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function editor_classPrivateFieldInitSpec(e,t,i){editor_checkPrivateRedeclaration(e,t),t.set(e,i)}function editor_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function editor_classPrivateFieldSet(e,t,i){return e.set(editor_assertClassBrand(e,t),i),i}function editor_classPrivateFieldGet(e,t){return e.get(editor_assertClassBrand(e,t))}function editor_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var pi=new WeakMap,gi=new WeakMap,fi=new WeakMap,mi=new WeakMap,vi=new WeakMap,yi=new WeakMap,Pi=new WeakMap,wi=new WeakMap,bi=new WeakMap,Fi=new WeakMap,Si=new WeakMap,Ci=new WeakMap,Ai=new WeakMap,xi=new WeakMap,ki=new WeakMap,Ei=new WeakMap,Ti=new WeakMap,Ii=new WeakMap,Gi=new WeakMap,Bi=new WeakMap,Mi=new WeakMap,Di=new WeakMap,Li=new WeakMap,Oi=new WeakMap,Ri=new WeakMap,Ni=new WeakMap,ji=new WeakMap,Wi=new WeakSet;class AnnotationEditor{static get _resizerKeyboardManager(){const e=AnnotationEditor.prototype._resizeWithKeyboard,t=AnnotationEditorUIManager.TRANSLATE_SMALL,i=AnnotationEditorUIManager.TRANSLATE_BIG;return shadow(this,"_resizerKeyboardManager",new KeyboardManager([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,i]}],[["Escape","mac+Escape"],AnnotationEditor.prototype._stopResizingWithKeyboard]]))}constructor(e){!function editor_classPrivateMethodInitSpec(e,t){editor_checkPrivateRedeclaration(e,t),t.add(e)}(this,Wi);editor_classPrivateFieldInitSpec(this,pi,null);editor_classPrivateFieldInitSpec(this,gi,null);editor_classPrivateFieldInitSpec(this,fi,null);editor_classPrivateFieldInitSpec(this,mi,null);editor_classPrivateFieldInitSpec(this,vi,null);editor_classPrivateFieldInitSpec(this,yi,!1);editor_classPrivateFieldInitSpec(this,Pi,null);editor_classPrivateFieldInitSpec(this,wi,"");editor_classPrivateFieldInitSpec(this,bi,!1);editor_classPrivateFieldInitSpec(this,Fi,null);editor_classPrivateFieldInitSpec(this,Si,null);editor_classPrivateFieldInitSpec(this,Ci,null);editor_classPrivateFieldInitSpec(this,Ai,null);editor_classPrivateFieldInitSpec(this,xi,null);editor_classPrivateFieldInitSpec(this,ki,"");editor_classPrivateFieldInitSpec(this,Ei,!1);editor_classPrivateFieldInitSpec(this,Ti,null);editor_classPrivateFieldInitSpec(this,Ii,!1);editor_classPrivateFieldInitSpec(this,Gi,!1);editor_classPrivateFieldInitSpec(this,Bi,!1);editor_classPrivateFieldInitSpec(this,Mi,null);editor_classPrivateFieldInitSpec(this,Di,0);editor_classPrivateFieldInitSpec(this,Li,0);editor_classPrivateFieldInitSpec(this,Oi,null);editor_classPrivateFieldInitSpec(this,Ri,null);editor_defineProperty(this,"isSelected",!1);editor_defineProperty(this,"_isCopy",!1);editor_defineProperty(this,"_editToolbar",null);editor_defineProperty(this,"_initialOptions",Object.create(null));editor_defineProperty(this,"_initialData",null);editor_defineProperty(this,"_isVisible",!0);editor_defineProperty(this,"_uiManager",null);editor_defineProperty(this,"_focusEventsAllowed",!0);editor_classPrivateFieldInitSpec(this,Ni,!1);editor_classPrivateFieldInitSpec(this,ji,AnnotationEditor._zIndex++);editor_defineProperty(this,"doNotMove",!1);this.parent=e.parent;this.id=e.id;this.width=this.height=null;this.pageIndex=e.parent.pageIndex;this.name=e.name;this.div=null;this._uiManager=e.uiManager;this.annotationElementId=null;this._willKeepAspectRatio=!1;this._initialOptions.isCentered=e.isCentered;this._structTreeParentId=null;this.annotationElementId=e.annotationElementId||null;this.creationDate=e.creationDate||new Date;this.modificationDate=e.modificationDate||null;this.canAddComment=!0;const t=this.parent.viewport,i=t.rotation,a=t.rawDims,s=a.pageWidth,r=a.pageHeight,n=a.pageX,o=a.pageY;this.rotation=i;this.pageRotation=(360+i-this._uiManager.viewParameters.rotation)%360;this.pageDimensions=[s,r];this.pageTranslation=[n,o];const l=editor_slicedToArray(this.parentDimensions,2),c=l[0],d=l[1];this.x=e.x/c;this.y=e.y/d;this.isAttachedToDOM=!1;this.deleted=!1;this.eventBus=e.eventBus}updatePageIndex(e){this.pageIndex=e}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 shadow(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new FakeEditor({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId;t.deleted=!0;t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){AnnotationEditor._l10n??=e;AnnotationEditor._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"});AnnotationEditor._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"});if(-1!==AnnotationEditor._borderLineWidth)return;const i=getComputedStyle(document.documentElement);AnnotationEditor._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){unreachable("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return editor_classPrivateFieldGet(Ni,this)}set _isDraggable(e){editor_classPrivateFieldSet(Ni,this,e);this.div?.classList.toggle("draggable",e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const e=editor_slicedToArray(this.pageDimensions,2),t=e[0],i=e[1];switch(this.parentRotation){case 90:this.x-=this.height*i/(2*t);this.y+=this.width*t/(2*i);break;case 180:this.x+=this.width/2;this.y+=this.height/2;break;case 270:this.x+=this.height*i/(2*t);this.y-=this.width*t/(2*i);break;default:this.x-=this.width/2;this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=editor_classPrivateFieldGet(ji,this)}setParent(e){if(null!==e){this.pageIndex=e.pageIndex;this.pageDimensions=e.pageDimensions}else{editor_assertClassBrand(Wi,this,_stopResizing).call(this);editor_classPrivateFieldGet(Ai,this)?.remove();editor_classPrivateFieldSet(Ai,this,null)}this.parent=e}focusin(e){this._focusEventsAllowed&&(editor_classPrivateFieldGet(Ei,this)?editor_classPrivateFieldSet(Ei,this,!1):this.parent.setSelected(this))}focusout(e){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const t=e.relatedTarget;if(!t?.closest(`#${this.id}`)){e.preventDefault();this.parent?.isMultipleSelection||this.commitOrRemove()}}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){if(this.isInEditMode()){this.addToAnnotationStorage();this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"commit",page:this.pageIndex+1,editorType:this.constructor.name,value:this,id:this.uid})}}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,i,a){const s=editor_slicedToArray(this.parentDimensions,2),r=s[0],n=s[1];var o=editor_slicedToArray(this.screenToPageTranslation(i,a),2);i=o[0];a=o[1];if(this.doNotMove){i=0;a=0}this.x=(e+i)/r;this.y=(t+a)/n;this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}const i=editor_slicedToArray(this.parentDimensions,2),a=i[0],s=i[1];this.setAt(e*a,t*s,this.width*a,this.height*s);this._onTranslated()}translate(e,t){editor_assertClassBrand(Wi,this,_translate).call(this,this.parentDimensions,e,t)}translateInPage(e,t){editor_classPrivateFieldGet(Ti,this)||editor_classPrivateFieldSet(Ti,this,[this.x,this.y,this.width,this.height]);editor_assertClassBrand(Wi,this,_translate).call(this,this.pageDimensions,e,t);this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){editor_classPrivateFieldGet(Ti,this)||editor_classPrivateFieldSet(Ti,this,[this.x,this.y,this.width,this.height]);const i=this.div,a=editor_slicedToArray(this.parentDimensions,2),s=a[0],r=a[1];this.x+=e/s;this.y+=t/r;if(this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const e=this.div.getBoundingClientRect(),t=e.x,i=e.y;if(this.parent.findNewParent(this,t,i)){this.x-=Math.floor(this.x);this.y-=Math.floor(this.y)}}let n=this.x,o=this.y;const l=editor_slicedToArray(this.getBaseTranslation(),2);n+=l[0];o+=l[1];const c=i.style;c.left=`${(100*n).toFixed(2)}%`;c.top=`${(100*o).toFixed(2)}%`;this._onTranslating(n,o);i.scrollIntoView({block:"nearest"})}_onTranslating(e,t){}_onTranslated(e,t){this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"moved",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:{x:e,y:t}})}get _hasBeenMoved(){return!!editor_classPrivateFieldGet(Ti,this)&&(editor_classPrivateFieldGet(Ti,this)[0]!==this.x||editor_classPrivateFieldGet(Ti,this)[1]!==this.y)}get _hasBeenResized(){return!!editor_classPrivateFieldGet(Ti,this)&&(editor_classPrivateFieldGet(Ti,this)[2]!==this.width||editor_classPrivateFieldGet(Ti,this)[3]!==this.height)}getBaseTranslation(){const e=editor_slicedToArray(this.parentDimensions,2),t=e[0],i=e[1],a=AnnotationEditor._borderLineWidth,s=a/t,r=a/i;switch(this.rotation){case 90:return[-s,r];case 180:return[s,r];case 270:return[s,-r];default:return[-s,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.rotation;const t=this.div.style,i=editor_slicedToArray(this.pageDimensions,2),a=i[0],s=i[1];let r=this.x,n=this.y,o=this.width,l=this.height;o*=a;l*=s;r*=a;n*=s;if(this._mustFixPosition)switch(e){case 0:r=MathClamp(r,0,a-o);n=MathClamp(n,0,s-l);break;case 90:r=MathClamp(r,0,a-l);n=MathClamp(n,o,s);break;case 180:r=MathClamp(r,o,a);n=MathClamp(n,l,s);break;case 270:r=MathClamp(r,l,a);n=MathClamp(n,0,s-o)}this.x=r/=a;this.y=n/=s;const c=editor_slicedToArray(this.getBaseTranslation(),2);r+=c[0];n+=c[1];t.left=`${(100*r).toFixed(2)}%`;t.top=`${(100*n).toFixed(2)}%`;this.moveInDOM()}screenToPageTranslation(e,t){return _rotatePoint.call(AnnotationEditor,e,t,this.parentRotation)}pageTranslationToScreen(e,t){return _rotatePoint.call(AnnotationEditor,e,t,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const e=this.parentScale,t=editor_slicedToArray(this.pageDimensions,2);return[t[0]*e,t[1]*e]}setDims(){const e=this.div.style,t=this.width,i=this.height;e.width=`${(100*t).toFixed(2)}%`;e.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(1e4*e)/1e4}_onResizing(){}altTextFinish(){editor_classPrivateFieldGet(fi,this)?.finish();this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"altTextChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:editor_classPrivateFieldGet(fi,this)})}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||editor_classPrivateFieldGet(Gi,this))return this._editToolbar;this._editToolbar=new EditorToolbar(this);this.div.append(this._editToolbar.render());const e=this.toolbarButtons;if(e)for(const i of e){var t=editor_slicedToArray(i,2);const e=t[0],a=t[1];await this._editToolbar.addButton(e,a)}this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton());this._editToolbar.addButton("delete");return this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove();this._editToolbar=null;editor_classPrivateFieldGet(fi,this)?.destroy()}addContainer(e){const t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){if(!editor_classPrivateFieldGet(fi,this)){AltText.initialize(AnnotationEditor._l10n);editor_classPrivateFieldSet(fi,this,new AltText(this));if(editor_classPrivateFieldGet(pi,this)){editor_classPrivateFieldGet(fi,this).data=editor_classPrivateFieldGet(pi,this);editor_classPrivateFieldSet(pi,this,null)}}return editor_classPrivateFieldGet(fi,this)}get altTextData(){return editor_classPrivateFieldGet(fi,this)?.data}set altTextData(e){editor_classPrivateFieldGet(fi,this)&&(editor_classPrivateFieldGet(fi,this).data=e)}get guessedAltText(){return editor_classPrivateFieldGet(fi,this)?.guessedText}async setGuessedAltText(e){await(editor_classPrivateFieldGet(fi,this)?.setGuessedText(e))}serializeAltText(e){return editor_classPrivateFieldGet(fi,this)?.serialize(e)}hasAltText(){return!!editor_classPrivateFieldGet(fi,this)&&!editor_classPrivateFieldGet(fi,this).isEmpty()}hasAltTextData(){return editor_classPrivateFieldGet(fi,this)?.hasData()??!1}focusCommentButton(){editor_classPrivateFieldGet(mi,this)?.focusButton()}addCommentButton(){return this.canAddComment?editor_classPrivateFieldGet(mi,this)||editor_classPrivateFieldSet(mi,this,new Comment(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager())if(editor_classPrivateFieldGet(vi,this))this._uiManager.isEditingMode()&&editor_classPrivateFieldGet(vi,this).classList.remove("hidden");else if(this.hasComment){editor_classPrivateFieldSet(vi,this,editor_classPrivateFieldGet(mi,this).renderForStandalone());this.div.append(editor_classPrivateFieldGet(vi,this))}}removeStandaloneCommentButton(){editor_classPrivateFieldGet(mi,this).removeStandaloneCommentButton();editor_classPrivateFieldSet(vi,this,null)}hideStandaloneCommentButton(){editor_classPrivateFieldGet(vi,this)?.classList.add("hidden")}get comment(){if(!editor_classPrivateFieldGet(mi,this))return null;const e=editor_classPrivateFieldGet(mi,this).data,t=e.richText;return{text:e.text,richText:t,date:e.date,deleted:e.deleted,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){editor_classPrivateFieldGet(mi,this)||editor_classPrivateFieldSet(mi,this,new Comment(this));"object"==typeof e&&null!==e?editor_classPrivateFieldGet(mi,this).restoreData(e):editor_classPrivateFieldGet(mi,this).data=e;if(this.hasComment){this.removeCommentButtonFromToolbar();this.addStandaloneCommentButton();this._uiManager.updateComment(this)}else{this.addCommentButtonInToolbar();this.removeStandaloneCommentButton();this._uiManager.removeComment(this)}}setCommentData(e){let t=e.comment,i=e.popupRef,a=e.richText,s=e.commentDate;if(!i)return;editor_classPrivateFieldGet(mi,this)||editor_classPrivateFieldSet(mi,this,new Comment(this));editor_classPrivateFieldGet(mi,this).setInitialText(t,a);s&&editor_classPrivateFieldGet(mi,this).setDate(s);if(!this.annotationElementId)return;const r=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);r&&this.updateFromAnnotationLayer(r)}get hasEditedComment(){return editor_classPrivateFieldGet(mi,this)?.hasBeenEdited()}get hasDeletedComment(){return editor_classPrivateFieldGet(mi,this)?.isDeleted()}get hasComment(){return!!editor_classPrivateFieldGet(mi,this)&&!editor_classPrivateFieldGet(mi,this).isEmpty()&&!editor_classPrivateFieldGet(mi,this).isDeleted()}async editComment(e){editor_classPrivateFieldGet(mi,this)||editor_classPrivateFieldSet(mi,this,new Comment(this));editor_classPrivateFieldGet(mi,this).edit(e)}toggleComment(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;this.hasComment&&this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){editor_classPrivateFieldGet(mi,this).setSelectedButton(e)}addComment(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.hasEditedComment||t&&this.hasComment){const t=180,i=100,a=editor_slicedToArray(e.rect,4)[3],s=editor_slicedToArray(this.pageDimensions,1)[0],r=editor_slicedToArray(this.pageTranslation,1)[0]+s+1,n=a-i,o=r+t;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[r,n,o,a],date:this.comment.date?.toISOString()}}}updateFromAnnotationLayer(e){let t=e.popup,i=t.contents,a=t.deleted;editor_classPrivateFieldGet(mi,this).data=a?null:i}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360);e.className=this.name;e.setAttribute("id",this.id);e.tabIndex=editor_classPrivateFieldGet(yi,this)?-1:0;e.setAttribute("role","application");this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId);this._isVisible||e.classList.add("hidden");this.setInForeground();editor_assertClassBrand(Wi,this,_addFocusListeners).call(this);const t=editor_slicedToArray(this.parentDimensions,2),i=t[0],a=t[1];if(this.parentRotation%180!=0){e.style.maxWidth=`${(100*a/i).toFixed(2)}%`;e.style.maxHeight=`${(100*i/a).toFixed(2)}%`}const s=editor_slicedToArray(this.getInitialTranslation(),2),r=s[0],n=s[1];this.translate(r,n);bindEvents(this,e,["keydown","pointerdown","dblclick"]);this.isResizable&&this._uiManager._supportsPinchToZoom&&(editor_classPrivateFieldGet(Ri,this)||editor_classPrivateFieldSet(Ri,this,new TouchManager({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:editor_assertClassBrand(Wi,this,_touchPinchStartCallback).bind(this),onPinching:editor_assertClassBrand(Wi,this,_touchPinchCallback).bind(this),onPinchEnd:editor_assertClassBrand(Wi,this,_touchPinchEndCallback).bind(this),signal:this._uiManager._signal})));this.addStandaloneCommentButton();this._uiManager._editorUndoBar?.hide();return e}pointerdown(e){const t=FeatureTest.platform.isMac;if(0!==e.button||e.ctrlKey&&t)e.preventDefault();else{editor_classPrivateFieldSet(Ei,this,!0);this._isDraggable?editor_assertClassBrand(Wi,this,_setUpDragSession).call(this,e):editor_assertClassBrand(Wi,this,_selectOnPointerEvent).call(this,e)}}_onStartDragging(){}_onStopDragging(){}moveInDOM(){editor_classPrivateFieldGet(Mi,this)&&clearTimeout(editor_classPrivateFieldGet(Mi,this));editor_classPrivateFieldSet(Mi,this,setTimeout(()=>{editor_classPrivateFieldSet(Mi,this,null);this.parent?.moveEditorInDOM(this)},0))}_setParentAndPosition(e,t,i){e.changeParent(this);this.x=t;this.y=i;this.fixAndSetPosition();this._onTranslated()}getRect(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.rotation;const a=this.parentScale,s=editor_slicedToArray(this.pageDimensions,2),r=s[0],n=s[1],o=editor_slicedToArray(this.pageTranslation,2),l=o[0],c=o[1],d=e/a,h=t/a,u=this.x*r,_=this.y*n,p=this.width*r,g=this.height*n;switch(i){case 0:return[u+d+l,n-_-h-g+c,u+d+p+l,n-_-h+c];case 90:return[u+h+l,n-_+d+c,u+h+g+l,n-_+d+p+c];case 180:return[u-d-p+l,n-_+h+c,u-d+l,n-_+h+g+c];case 270:return[u-h-g+l,n-_-d-p+c,u-h+l,n-_-d+c];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const i=editor_slicedToArray(e,4),a=i[0],s=i[1],r=i[2],n=i[3],o=r-a,l=n-s;switch(this.rotation){case 0:return[a,t-n,o,l];case 90:return[a,t-s,l,o];case 180:return[r,t-s,o,l];case 270:return[r,t-n,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&AnnotationEditor._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){editor_classPrivateFieldGet(mi,this)?.onUpdatedColor()}getData(){const e=this.comment,t=e.text,i=e.color,a=e.date,s=e.opacity,r=e.deleted,n=e.richText,o=this.uid,l=this.pageIndex,c=this.creationDate,d=this.modificationDate;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:n,contentsObj:{str:t},creationDate:c,modificationDate:a||d,popupRef:!r,color:i,opacity:s}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){if(this.isInEditMode())return!1;this.parent.setEditingState(!1);editor_classPrivateFieldSet(Gi,this,!0);return!0}disableEditMode(){if(!this.isInEditMode())return!1;this.parent.setEditingState(!0);editor_classPrivateFieldSet(Gi,this,!1);return!0}isInEditMode(){return editor_classPrivateFieldGet(Gi,this)}shouldGetKeyboardEvents(){return editor_classPrivateFieldGet(Bi,this)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const e=this.getClientDimensions(),t=e.top,i=e.left,a=e.bottom,s=e.right,r=window,n=r.innerHeight;return i<r.innerWidth&&s>0&&t<n&&a>0}rebuild(){editor_assertClassBrand(Wi,this,_addFocusListeners).call(this)}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(e,t,i){const a=new this.prototype.constructor({parent:t,id:i.getId(),uiManager:i,annotationElementId:e.annotationElementId,eventBus:t.eventBus,creationDate:e.creationDate,modificationDate:e.modificationDate});a.rotation=e.rotation;editor_classPrivateFieldSet(pi,a,e.accessibilityData);a._isCopy=e.isCopy||!1;const s=editor_slicedToArray(a.pageDimensions,2),r=s[0],n=s[1],o=editor_slicedToArray(a.getRectInCurrentCoords(e.rect,n),4),l=o[0],c=o[1],d=o[2],h=o[3];a.x=l/r;a.y=c/n;a.width=d/r;a.height=h/n;return a}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){editor_classPrivateFieldGet(xi,this)?.abort();editor_classPrivateFieldSet(xi,this,null);this.isEmpty()||this.commit();this.parent?this.parent.remove(this):this._uiManager.removeEditor(this);this.hideCommentPopup();if(editor_classPrivateFieldGet(Mi,this)){clearTimeout(editor_classPrivateFieldGet(Mi,this));editor_classPrivateFieldSet(Mi,this,null)}editor_assertClassBrand(Wi,this,_stopResizing).call(this);this.removeEditToolbar();if(editor_classPrivateFieldGet(Oi,this)){for(const e of editor_classPrivateFieldGet(Oi,this).values())clearTimeout(e);editor_classPrivateFieldSet(Oi,this,null)}this.parent=null;this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"removed",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:this});editor_classPrivateFieldGet(Ri,this)?.destroy();editor_classPrivateFieldSet(Ri,this,null);editor_classPrivateFieldGet(Ai,this)?.remove();editor_classPrivateFieldSet(Ai,this,null)}get isResizable(){return!1}makeResizable(){if(this.isResizable){editor_assertClassBrand(Wi,this,_createResizers).call(this);editor_classPrivateFieldGet(Fi,this).classList.remove("hidden")}}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const e=editor_slicedToArray(this.commentButtonPosition,2),t=e[0],i=e[1],a=editor_slicedToArray(this.getPDFRect(),4),s=a[0],r=a[1],n=a[2],o=a[3];return[AnnotationEditor._round(s+(n-s)*t),AnnotationEditor._round(r+(o-r)*(1-i))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return editor_classPrivateFieldGet(mi,this).commentPopupPositionInLayer}set commentPopupPosition(e){editor_classPrivateFieldGet(mi,this).commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return editor_classPrivateFieldGet(mi,this).hasDefaultPopupPosition()}get commentButtonWidth(){return editor_classPrivateFieldGet(mi,this).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){editor_classPrivateFieldGet(mi,this)?.setCommentButtonStates(e)}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this);editor_classPrivateFieldSet(Ci,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const t=editor_classPrivateFieldGet(Fi,this).children;if(!editor_classPrivateFieldGet(gi,this)){editor_classPrivateFieldSet(gi,this,Array.from(t));const e=editor_assertClassBrand(Wi,this,_resizerKeydown).bind(this),i=editor_assertClassBrand(Wi,this,_resizerBlur).bind(this),a=this._uiManager._signal;for(const t of editor_classPrivateFieldGet(gi,this)){const s=t.getAttribute("data-resizer-name");t.setAttribute("role","spinbutton");t.addEventListener("keydown",e,{signal:a});t.addEventListener("blur",i,{signal:a});t.addEventListener("focus",editor_assertClassBrand(Wi,this,_resizerFocus).bind(this,s),{signal:a});t.setAttribute("data-l10n-id",AnnotationEditor._l10nResizer[s])}}const i=editor_classPrivateFieldGet(gi,this)[0];let a=0;for(const e of t){if(e===i)break;a++}const s=(360-this.rotation+this.parentRotation)%360/90*(editor_classPrivateFieldGet(gi,this).length/4);if(s!==a){if(s<a)for(let e=0;e<a-s;e++)editor_classPrivateFieldGet(Fi,this).append(editor_classPrivateFieldGet(Fi,this).firstElementChild);else if(s>a)for(let e=0;e<s-a;e++)editor_classPrivateFieldGet(Fi,this).firstElementChild.before(editor_classPrivateFieldGet(Fi,this).lastElementChild);let e=0;for(const i of t){const t=editor_classPrivateFieldGet(gi,this)[e++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",AnnotationEditor._l10nResizer[t])}}editor_assertClassBrand(Wi,this,_setResizerTabIndex).call(this,0);editor_classPrivateFieldSet(Bi,this,!0);editor_classPrivateFieldGet(Fi,this).firstElementChild.focus({focusVisible:!0});e.preventDefault();e.stopImmediatePropagation()}_resizeWithKeyboard(e,t){editor_classPrivateFieldGet(Bi,this)&&editor_assertClassBrand(Wi,this,_resizerPointermove).call(this,editor_classPrivateFieldGet(ki,this),{deltaX:e,deltaY:t,fromKeyboard:!0})}_stopResizingWithKeyboard(){editor_assertClassBrand(Wi,this,_stopResizing).call(this);this.div.focus()}select(){if(this.isSelected&&this._editToolbar)this._editToolbar.show();else{this.isSelected=!0;this.makeResizable();this.div?.classList.add("selectedEditor");if(this._editToolbar){this._editToolbar?.show();editor_classPrivateFieldGet(fi,this)?.toggleAltTextBadge(!1)}else 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(){if(this.isSelected){this.isSelected=!1;editor_classPrivateFieldGet(Fi,this)?.classList.add("hidden");this.div?.classList.remove("selectedEditor");this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0});this._editToolbar?.hide();editor_classPrivateFieldGet(fi,this)?.toggleAltTextBadge(!0);this.hideCommentPopup()}}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){if(this.canChangeContent){this.enableEditMode();this.div.focus()}}dblclick(e){if("BUTTON"!==e.target.nodeName){this.enterInEditMode();this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid})}}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return editor_classPrivateFieldGet(Ii,this)}set isEditing(e){editor_classPrivateFieldSet(Ii,this,e);if(this.parent)if(e){this.parent.setSelected(this);this.parent.setActiveEditor(this)}else this.parent.setActiveEditor(null)}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){editor_classPrivateFieldGet(Oi,this)||editor_classPrivateFieldSet(Oi,this,new Map);const t=e.action;let i=editor_classPrivateFieldGet(Oi,this).get(t);i&&clearTimeout(i);i=setTimeout(()=>{this._reportTelemetry(e);editor_classPrivateFieldGet(Oi,this).delete(t);0===editor_classPrivateFieldGet(Oi,this).size&&editor_classPrivateFieldSet(Oi,this,null)},AnnotationEditor._telemetryTimeout);editor_classPrivateFieldGet(Oi,this).set(t,i);return}e.type||=this.editorType;this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;this.div.classList.toggle("hidden",!e);this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0);editor_classPrivateFieldSet(yi,this,!1)}disable(){this.div&&(this.div.tabIndex=-1);editor_classPrivateFieldSet(yi,this,!0)}updateFakeAnnotationElement(e){if(editor_classPrivateFieldGet(Ai,this)||this.deleted)if(this.deleted){editor_classPrivateFieldGet(Ai,this).remove();editor_classPrivateFieldSet(Ai,this,null)}else(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&editor_classPrivateFieldGet(Ai,this).updateEdited({rect:this.getPDFRect(),popup:this.comment});else editor_classPrivateFieldSet(Ai,this,e.addFakeAnnotation(this))}renderAnnotationElement(e){if(this.deleted){e.hide();return null}let t=e.container.querySelector(".annotationContent");if(t){if("CANVAS"===t.nodeName){const e=t;t=document.createElement("div");t.classList.add("annotationContent",this.editorType);e.before(t)}}else{t=document.createElement("div");t.classList.add("annotationContent",this.editorType);e.container.prepend(t)}return t}resetAnnotationElement(e){const t=e.container.firstElementChild;"DIV"===t?.nodeName&&t.classList.contains("annotationContent")&&t.remove()}}ei=AnnotationEditor;function _translate(e,t,i){let a=editor_slicedToArray(e,2),s=a[0],r=a[1];var n=editor_slicedToArray(this.screenToPageTranslation(t,i),2);t=n[0];i=n[1];this.x+=t/s;this.y+=i/r;this._onTranslating(this.x,this.y);this.fixAndSetPosition()}function _rotatePoint(e,t,i){switch(i){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}function _getRotationMatrix(e){switch(e){case 90:{const e=editor_slicedToArray(this.pageDimensions,2),t=e[0],i=e[1];return[0,-t/i,i/t,0]}case 180:return[-1,0,0,-1];case 270:{const e=editor_slicedToArray(this.pageDimensions,2),t=e[0],i=e[1];return[0,t/i,-i/t,0]}default:return[1,0,0,1]}}function _createResizers(){if(editor_classPrivateFieldGet(Fi,this))return;editor_classPrivateFieldSet(Fi,this,document.createElement("div"));editor_classPrivateFieldGet(Fi,this).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const i of e){const e=document.createElement("div");editor_classPrivateFieldGet(Fi,this).append(e);e.classList.add("resizer",i);e.setAttribute("data-resizer-name",i);e.addEventListener("pointerdown",editor_assertClassBrand(Wi,this,_resizerPointerdown).bind(this,i),{signal:t});e.addEventListener("contextmenu",noContextMenu,{signal:t});e.tabIndex=-1}this.div.prepend(editor_classPrivateFieldGet(Fi,this))}function _resizerPointerdown(e,t){t.preventDefault();const i=FeatureTest.platform.isMac;if(0!==t.button||t.ctrlKey&&i)return;editor_classPrivateFieldGet(fi,this)?.toggle(!1);const a=this._isDraggable;this._isDraggable=!1;editor_classPrivateFieldSet(Si,this,[t.screenX,t.screenY]);const s=new AbortController,r=this._uiManager.combinedSignal(s);this.parent.togglePointerEvents(!1);window.addEventListener("pointermove",editor_assertClassBrand(Wi,this,_resizerPointermove).bind(this,e),{passive:!0,capture:!0,signal:r});window.addEventListener("touchmove",stopEvent,{passive:!1,signal:r});window.addEventListener("contextmenu",noContextMenu,{signal:r});editor_classPrivateFieldSet(Ci,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const n=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const pointerUpCallback=()=>{s.abort();this.parent.togglePointerEvents(!0);editor_classPrivateFieldGet(fi,this)?.toggle(!0);this._isDraggable=a;this.parent.div.style.cursor=n;this.div.style.cursor=o;editor_assertClassBrand(Wi,this,_addResizeToUndoStack).call(this)};window.addEventListener("pointerup",pointerUpCallback,{signal:r});window.addEventListener("blur",pointerUpCallback,{signal:r})}function _resize(e,t,i,a){this.width=i;this.height=a;this.x=e;this.y=t;this.setDims();this.fixAndSetPosition();this._onResized()}function _addResizeToUndoStack(){if(!editor_classPrivateFieldGet(Ci,this))return;const e=editor_classPrivateFieldGet(Ci,this),t=e.savedX,i=e.savedY,a=e.savedWidth,s=e.savedHeight;editor_classPrivateFieldSet(Ci,this,null);const r=this.x,n=this.y,o=this.width,l=this.height;if(r!==t||n!==i||o!==a||l!==s){this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"sizeChanged",editorType:this.constructor.name,id:this.uid,page:this.pageIndex+1,value:{x:t,y:i,width:a,height:s}});this.addCommands({cmd:editor_assertClassBrand(Wi,this,_resize).bind(this,r,n,o,l),undo:editor_assertClassBrand(Wi,this,_resize).bind(this,t,i,a,s),mustExec:!0})}}function _resizerPointermove(e,t){const i=editor_slicedToArray(this.parentDimensions,2),a=i[0],s=i[1],r=this.x,n=this.y,o=this.width,l=this.height,c=ei.MIN_SIZE/a,d=ei.MIN_SIZE/s,h=editor_assertClassBrand(Wi,this,_getRotationMatrix).call(this,this.rotation),transf=(e,t)=>[h[0]*e+h[2]*t,h[1]*e+h[3]*t],u=editor_assertClassBrand(Wi,this,_getRotationMatrix).call(this,360-this.rotation);let _,p,g=!1,f=!1;switch(e){case"topLeft":g=!0;_=(e,t)=>[0,0];p=(e,t)=>[e,t];break;case"topMiddle":_=(e,t)=>[e/2,0];p=(e,t)=>[e/2,t];break;case"topRight":g=!0;_=(e,t)=>[e,0];p=(e,t)=>[0,t];break;case"middleRight":f=!0;_=(e,t)=>[e,t/2];p=(e,t)=>[0,t/2];break;case"bottomRight":g=!0;_=(e,t)=>[e,t];p=(e,t)=>[0,0];break;case"bottomMiddle":_=(e,t)=>[e/2,t];p=(e,t)=>[e/2,0];break;case"bottomLeft":g=!0;_=(e,t)=>[0,t];p=(e,t)=>[e,0];break;case"middleLeft":f=!0;_=(e,t)=>[0,t/2];p=(e,t)=>[e,t/2]}const m=_(o,l),v=p(o,l);let y=transf(...v);const P=ei._round(r+y[0]),w=ei._round(n+y[1]);let b,S,C=1,A=1;if(t.fromKeyboard){b=t.deltaX;S=t.deltaY}else{const e=t.screenX,i=t.screenY,a=editor_slicedToArray(editor_classPrivateFieldGet(Si,this),2),s=a[0],r=a[1];var x=editor_slicedToArray(this.screenToPageTranslation(e-s,i-r),2);b=x[0];S=x[1];editor_classPrivateFieldGet(Si,this)[0]=e;editor_classPrivateFieldGet(Si,this)[1]=i}var k,E,T=editor_slicedToArray((k=b/a,E=S/s,[u[0]*k+u[2]*E,u[1]*k+u[3]*E]),2);b=T[0];S=T[1];if(g){const e=Math.hypot(o,l);C=A=Math.max(Math.min(Math.hypot(v[0]-m[0]-b,v[1]-m[1]-S)/e,1/o,1/l),c/o,d/l)}else f?C=MathClamp(Math.abs(v[0]-m[0]-b),c,1)/o:A=MathClamp(Math.abs(v[1]-m[1]-S),d,1)/l;const I=ei._round(o*C),G=ei._round(l*A);y=transf(...p(I,G));const B=P-y[0],M=w-y[1];editor_classPrivateFieldGet(Ti,this)||editor_classPrivateFieldSet(Ti,this,[this.x,this.y,this.width,this.height]);this.width=I;this.height=G;this.x=B;this.y=M;this.setDims();this.fixAndSetPosition();this._onResizing()}function _touchPinchStartCallback(){editor_classPrivateFieldSet(Ci,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});editor_classPrivateFieldGet(fi,this)?.toggle(!1);this.parent.togglePointerEvents(!1)}function _touchPinchCallback(e,t,i){let a=i/t*.7+1-.7;if(1===a)return;const s=editor_assertClassBrand(Wi,this,_getRotationMatrix).call(this,this.rotation),transf=(e,t)=>[s[0]*e+s[2]*t,s[1]*e+s[3]*t],r=editor_slicedToArray(this.parentDimensions,2),n=r[0],o=r[1],l=this.x,c=this.y,d=this.width,h=this.height,u=ei.MIN_SIZE/n,_=ei.MIN_SIZE/o;a=Math.max(Math.min(a,1/d,1/h),u/d,_/h);const p=ei._round(d*a),g=ei._round(h*a);if(p===d&&g===h)return;editor_classPrivateFieldGet(Ti,this)||editor_classPrivateFieldSet(Ti,this,[l,c,d,h]);const f=transf(d/2,h/2),m=ei._round(l+f[0]),v=ei._round(c+f[1]),y=transf(p/2,g/2);this.x=m-y[0];this.y=v-y[1];this.width=p;this.height=g;this.setDims();this.fixAndSetPosition();this._onResizing()}function _touchPinchEndCallback(){editor_classPrivateFieldGet(fi,this)?.toggle(!0);this.parent.togglePointerEvents(!0);editor_assertClassBrand(Wi,this,_addResizeToUndoStack).call(this)}function _selectOnPointerEvent(e){const t=FeatureTest.platform.isMac;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}function _setUpDragSession(e){const t=this.isSelected;this._uiManager.setUpDragSession();let i=!1;const a=new AbortController,s=this._uiManager.combinedSignal(a),r={capture:!0,passive:!1,signal:s},cancelDrag=e=>{a.abort();editor_classPrivateFieldSet(Pi,this,null);editor_classPrivateFieldSet(Ei,this,!1);this._uiManager.endDragSession()||editor_assertClassBrand(Wi,this,_selectOnPointerEvent).call(this,e);i&&this._onStopDragging()};if(t){editor_classPrivateFieldSet(Di,this,e.clientX);editor_classPrivateFieldSet(Li,this,e.clientY);editor_classPrivateFieldSet(Pi,this,e.pointerId);editor_classPrivateFieldSet(wi,this,e.pointerType);window.addEventListener("pointermove",e=>{if(!i){i=!0;this._uiManager.toggleComment(this,!0,!1);this._onStartDragging()}const t=e.clientX,a=e.clientY;if(e.pointerId!==editor_classPrivateFieldGet(Pi,this)){stopEvent(e);return}const s=editor_slicedToArray(this.screenToPageTranslation(t-editor_classPrivateFieldGet(Di,this),a-editor_classPrivateFieldGet(Li,this)),2),r=s[0],n=s[1];editor_classPrivateFieldSet(Di,this,t);editor_classPrivateFieldSet(Li,this,a);this._uiManager.dragSelectedEditors(r,n)},r);window.addEventListener("touchmove",stopEvent,r);window.addEventListener("pointerdown",e=>{e.pointerType===editor_classPrivateFieldGet(wi,this)&&(editor_classPrivateFieldGet(Ri,this)||e.isPrimary)&&cancelDrag(e);stopEvent(e)},r)}const pointerUpCallback=e=>{editor_classPrivateFieldGet(Pi,this)&&editor_classPrivateFieldGet(Pi,this)!==e.pointerId?stopEvent(e):cancelDrag(e)};window.addEventListener("pointerup",pointerUpCallback,{signal:s});window.addEventListener("blur",pointerUpCallback,{signal:s})}function _addFocusListeners(){if(editor_classPrivateFieldGet(xi,this)||!this.div)return;editor_classPrivateFieldSet(xi,this,new AbortController);const e=this._uiManager.combinedSignal(editor_classPrivateFieldGet(xi,this));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e});this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}function _resizerKeydown(e){ei._resizerKeyboardManager.exec(this,e)}function _resizerBlur(e){editor_classPrivateFieldGet(Bi,this)&&e.relatedTarget?.parentNode!==editor_classPrivateFieldGet(Fi,this)&&editor_assertClassBrand(Wi,this,_stopResizing).call(this)}function _resizerFocus(e){editor_classPrivateFieldSet(ki,this,editor_classPrivateFieldGet(Bi,this)?e:"")}function _setResizerTabIndex(e){if(editor_classPrivateFieldGet(gi,this))for(const t of editor_classPrivateFieldGet(gi,this))t.tabIndex=e}function _stopResizing(){editor_classPrivateFieldSet(Bi,this,!1);editor_assertClassBrand(Wi,this,_setResizerTabIndex).call(this,-1);editor_assertClassBrand(Wi,this,_addResizeToUndoStack).call(this)}editor_defineProperty(AnnotationEditor,"_l10n",null);editor_defineProperty(AnnotationEditor,"_l10nAlert",null);editor_defineProperty(AnnotationEditor,"_l10nResizer",null);editor_defineProperty(AnnotationEditor,"_borderLineWidth",-1);editor_defineProperty(AnnotationEditor,"_colorManager",new ColorManager);editor_defineProperty(AnnotationEditor,"_zIndex",1);editor_defineProperty(AnnotationEditor,"_telemetryTimeout",1e3);class FakeEditor extends AnnotationEditor{constructor(e){super(e);this.annotationElementId=e.annotationElementId;this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ui=3285377520,Vi=4294901760,Hi=65535;class MurmurHash3_64{constructor(e){this.h1=e?4294967295&e:Ui;this.h2=e?4294967295&e:Ui}update(e){let t,i;if("string"==typeof e){t=new Uint8Array(2*e.length);i=0;for(let a=0,s=e.length;a<s;a++){const s=e.charCodeAt(a);if(s<=255)t[i++]=s;else{t[i++]=s>>>8;t[i++]=255&s}}}else{if(!ArrayBuffer.isView(e))throw new Error("Invalid data format, must be a string or TypedArray.");t=e.slice();i=t.byteLength}const a=i>>2,s=i-4*a,r=new Uint32Array(t.buffer,0,a);let n=0,o=0,l=this.h1,c=this.h2;const d=3432918353,h=461845907,u=11601,_=13715;for(let e=0;e<a;e++)if(1&e){n=r[e];n=n*d&Vi|n*u&Hi;n=n<<15|n>>>17;n=n*h&Vi|n*_&Hi;l^=n;l=l<<13|l>>>19;l=5*l+3864292196}else{o=r[e];o=o*d&Vi|o*u&Hi;o=o<<15|o>>>17;o=o*h&Vi|o*_&Hi;c^=o;c=c<<13|c>>>19;c=5*c+3864292196}n=0;switch(s){case 3:n^=t[4*a+2]<<16;case 2:n^=t[4*a+1]<<8;case 1:n^=t[4*a];n=n*d&Vi|n*u&Hi;n=n<<15|n>>>17;n=n*h&Vi|n*_&Hi;1&a?l^=n:c^=n}this.h1=l;this.h2=c}hexdigest(){let e=this.h1,t=this.h2;e^=t>>>1;e=3981806797*e&Vi|36045*e&Hi;t=4283543511*t&Vi|(2950163797*(t<<16|e>>>16)&Vi)>>>16;e^=t>>>1;e=444984403*e&Vi|60499*e&Hi;t=3301882366*t&Vi|(3120437893*(t<<16|e>>>16)&Vi)>>>16;e^=t>>>1;return(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}function annotation_storage_slicedToArray(e,t){return function annotation_storage_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function annotation_storage_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function annotation_storage_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return annotation_storage_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?annotation_storage_arrayLikeToArray(e,t):void 0}}(e,t)||function annotation_storage_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function annotation_storage_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function annotation_storage_defineProperty(e,t,i){return(t=function annotation_storage_toPropertyKey(e){var t=function annotation_storage_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function annotation_storage_classPrivateFieldInitSpec(e,t,i){annotation_storage_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_storage_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_storage_classPrivateFieldSet(e,t,i){return e.set(annotation_storage_assertClassBrand(e,t),i),i}function annotation_storage_classPrivateFieldGet(e,t){return e.get(annotation_storage_assertClassBrand(e,t))}function annotation_storage_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const zi=Object.freeze({map:null,hash:"",transfer:void 0});var $i=new WeakMap,qi=new WeakMap,Xi=new WeakMap,Ki=new WeakMap,Yi=new WeakSet;class AnnotationStorage{constructor(){!function annotation_storage_classPrivateMethodInitSpec(e,t){annotation_storage_checkPrivateRedeclaration(e,t),t.add(e)}(this,Yi);annotation_storage_classPrivateFieldInitSpec(this,$i,!1);annotation_storage_classPrivateFieldInitSpec(this,qi,null);annotation_storage_classPrivateFieldInitSpec(this,Xi,null);annotation_storage_classPrivateFieldInitSpec(this,Ki,new Map);annotation_storage_defineProperty(this,"onSetModified",null);annotation_storage_defineProperty(this,"onResetModified",null);annotation_storage_defineProperty(this,"onAnnotationEditor",null)}getValue(e,t){const i=annotation_storage_classPrivateFieldGet(Ki,this).get(e);return void 0===i?t:Object.assign(t,i)}getRawValue(e){return annotation_storage_classPrivateFieldGet(Ki,this).get(e)}remove(e){const t=annotation_storage_classPrivateFieldGet(Ki,this).get(e);if(void 0!==t){t instanceof AnnotationEditor&&annotation_storage_classPrivateFieldGet(Xi,this).delete(t.annotationElementId);annotation_storage_classPrivateFieldGet(Ki,this).delete(e);0===annotation_storage_classPrivateFieldGet(Ki,this).size&&this.resetModified();annotation_storage_classPrivateFieldGet(Ki,this).values().some(e=>e instanceof AnnotationEditor)||this.onAnnotationEditor?.(null)}}setValue(e,t){const i=annotation_storage_classPrivateFieldGet(Ki,this).get(e);let a=!1;if(void 0!==i)for(const e of Object.entries(t)){var s=annotation_storage_slicedToArray(e,2);const t=s[0],r=s[1];if(i[t]!==r){a=!0;i[t]=r}}else{a=!0;annotation_storage_classPrivateFieldGet(Ki,this).set(e,t)}a&&annotation_storage_assertClassBrand(Yi,this,_setModified).call(this);if(t instanceof AnnotationEditor){(annotation_storage_classPrivateFieldGet(Xi,this)||annotation_storage_classPrivateFieldSet(Xi,this,new Map)).set(t.annotationElementId,t);this.onAnnotationEditor?.(t.constructor._type)}}has(e){return annotation_storage_classPrivateFieldGet(Ki,this).has(e)}get size(){return annotation_storage_classPrivateFieldGet(Ki,this).size}resetModified(){if(annotation_storage_classPrivateFieldGet($i,this)){annotation_storage_classPrivateFieldSet($i,this,!1);this.onResetModified?.()}}get print(){return new PrintAnnotationStorage(this)}get serializable(){if(0===annotation_storage_classPrivateFieldGet(Ki,this).size)return zi;const e=new Map,t=new MurmurHash3_64,i=[],a=Object.create(null);let s=!1;for(const i of annotation_storage_classPrivateFieldGet(Ki,this)){var r=annotation_storage_slicedToArray(i,2);const n=r[0],o=r[1],l=o instanceof AnnotationEditor?o.serialize(!1,a):o;if(o.page){o.pageIndex=o.page._pageIndex;delete o.page}if(l){e.set(n,l);t.update(`${n}:${JSON.stringify(l)}`);s||=!!l.bitmap}}if(s)for(const t of e.values())t.bitmap&&i.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:i}:zi}get editorStats(){let e=null;const t=new Map;let i=0,a=0;for(const r of annotation_storage_classPrivateFieldGet(Ki,this).values()){if(!(r instanceof AnnotationEditor)){r.popup&&(r.popup.deleted?a+=1:i+=1);continue}r.isCommentDeleted?a+=1:r.hasEditedComment&&(i+=1);const n=r.telemetryFinalData;if(!n)continue;const o=n.type;t.has(o)||t.set(o,Object.getPrototypeOf(r).constructor);e||=Object.create(null);const l=e[o]||=new Map;for(const e of Object.entries(n)){var s=annotation_storage_slicedToArray(e,2);const t=s[0],i=s[1];if("type"===t)continue;const a=l.getOrInsertComputed(t,makeMap);a.set(i,(a.get(i)??0)+1)}}if(a>0||i>0){e||=Object.create(null);e.comments={deleted:a,edited:i}}if(!e)return null;for(const i of t){var r=annotation_storage_slicedToArray(i,2);const t=r[0],a=r[1];e[t]=a.computeTelemetryFinalData(e[t])}return e}resetModifiedIds(){annotation_storage_classPrivateFieldSet(qi,this,null)}updateEditor(e,t){const i=annotation_storage_classPrivateFieldGet(Xi,this)?.get(e);if(i){i.updateFromAnnotationLayer(t);return!0}return!1}getEditor(e){return annotation_storage_classPrivateFieldGet(Xi,this)?.get(e)||null}get modifiedIds(){if(annotation_storage_classPrivateFieldGet(qi,this))return annotation_storage_classPrivateFieldGet(qi,this);const e=[];if(annotation_storage_classPrivateFieldGet(Xi,this))for(const t of annotation_storage_classPrivateFieldGet(Xi,this).values())t.serialize()&&e.push(t.annotationElementId);let t="";if(e.length){const i=new MurmurHash3_64;i.update(e.join(","));t=i.hexdigest()}return annotation_storage_classPrivateFieldSet(qi,this,{ids:new Set(e),hash:t})}[Symbol.iterator](){return annotation_storage_classPrivateFieldGet(Ki,this).entries()}}function _setModified(){if(!annotation_storage_classPrivateFieldGet($i,this)){annotation_storage_classPrivateFieldSet($i,this,!0);this.onSetModified?.()}}var Zi=new WeakMap;class PrintAnnotationStorage extends AnnotationStorage{constructor(e){super();annotation_storage_classPrivateFieldInitSpec(this,Zi,zi);const t=e.serializable;if(t===zi)return;const i=t.map,a=t.hash,s=t.transfer,r=structuredClone(i,s?{transfer:s}:null);annotation_storage_classPrivateFieldSet(Zi,this,{map:r,hash:a,transfer:[]})}get print(){unreachable("Should not call PrintAnnotationStorage.print")}get serializable(){return annotation_storage_classPrivateFieldGet(Zi,this)}get modifiedIds(){return shadow(this,"modifiedIds",{ids:new Set,hash:""})}}function canvas_dependency_tracker_slicedToArray(e,t){return function canvas_dependency_tracker_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function canvas_dependency_tracker_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function canvas_dependency_tracker_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return canvas_dependency_tracker_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?canvas_dependency_tracker_arrayLikeToArray(e,t):void 0}}(e,t)||function canvas_dependency_tracker_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function canvas_dependency_tracker_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function canvas_dependency_tracker_defineProperty(e,t,i){return(t=function canvas_dependency_tracker_toPropertyKey(e){var t=function canvas_dependency_tracker_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function canvas_dependency_tracker_classPrivateFieldInitSpec(e,t,i){canvas_dependency_tracker_checkPrivateRedeclaration(e,t),t.set(e,i)}function canvas_dependency_tracker_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function canvas_dependency_tracker_classPrivateFieldGet(e,t){return e.get(canvas_dependency_tracker_assertClassBrand(e,t))}function canvas_dependency_tracker_classPrivateFieldSet(e,t,i){return e.set(canvas_dependency_tracker_assertClassBrand(e,t),i),i}function canvas_dependency_tracker_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Ji="__forcedDependency",Qi=Math.floor,ea=Math.ceil;function expandBBox(e,t,i,a,s,r){e[4*t+0]=Math.min(e[4*t+0],i);e[4*t+1]=Math.min(e[4*t+1],a);e[4*t+2]=Math.max(e[4*t+2],s);e[4*t+3]=Math.max(e[4*t+3],r)}const ta=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var ia=new WeakMap,aa=new WeakMap;class BBoxReader{constructor(e,t){canvas_dependency_tracker_classPrivateFieldInitSpec(this,ia,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,aa,void 0);canvas_dependency_tracker_classPrivateFieldSet(ia,this,e);canvas_dependency_tracker_classPrivateFieldSet(aa,this,t)}get length(){return canvas_dependency_tracker_classPrivateFieldGet(ia,this).length}isEmpty(e){return canvas_dependency_tracker_classPrivateFieldGet(ia,this)[e]===ta}minX(e){return canvas_dependency_tracker_classPrivateFieldGet(aa,this)[4*e+0]/256}minY(e){return canvas_dependency_tracker_classPrivateFieldGet(aa,this)[4*e+1]/256}maxX(e){return(canvas_dependency_tracker_classPrivateFieldGet(aa,this)[4*e+2]+1)/256}maxY(e){return(canvas_dependency_tracker_classPrivateFieldGet(aa,this)[4*e+3]+1)/256}}const ensureDebugMetadata=(e,t)=>e?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var sa=new WeakMap,ra=new WeakMap,na=new WeakMap,oa=new WeakMap,la=new WeakMap,ca=new WeakMap,da=new WeakMap,ha=new WeakSet;class CanvasBBoxTracker{constructor(e,t){!function canvas_dependency_tracker_classPrivateMethodInitSpec(e,t){canvas_dependency_tracker_checkPrivateRedeclaration(e,t),t.add(e)}(this,ha);canvas_dependency_tracker_classPrivateFieldInitSpec(this,sa,[[1,0,0,1,0,0]]);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ra,[-1/0,-1/0,1/0,1/0]);canvas_dependency_tracker_classPrivateFieldInitSpec(this,na,new Float64Array(s));canvas_dependency_tracker_defineProperty(this,"_pendingBBoxIdx",-1);canvas_dependency_tracker_classPrivateFieldInitSpec(this,oa,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,la,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ca,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,da,void 0);canvas_dependency_tracker_defineProperty(this,"_savesStack",[]);canvas_dependency_tracker_defineProperty(this,"_markedContentStack",[]);canvas_dependency_tracker_classPrivateFieldSet(oa,this,e.width);canvas_dependency_tracker_classPrivateFieldSet(la,this,e.height);canvas_dependency_tracker_assertClassBrand(ha,this,_initializeBBoxes).call(this,t)}growOperationsCount(e){e>=canvas_dependency_tracker_classPrivateFieldGet(da,this).length&&canvas_dependency_tracker_assertClassBrand(ha,this,_initializeBBoxes).call(this,e,canvas_dependency_tracker_classPrivateFieldGet(da,this))}get clipBox(){return canvas_dependency_tracker_classPrivateFieldGet(ra,this)}save(e){canvas_dependency_tracker_classPrivateFieldSet(ra,this,{__proto__:canvas_dependency_tracker_classPrivateFieldGet(ra,this)});this._savesStack.push(e);return this}restore(e,t){const i=Object.getPrototypeOf(canvas_dependency_tracker_classPrivateFieldGet(ra,this));if(null===i)return this;canvas_dependency_tracker_classPrivateFieldSet(ra,this,i);const a=this._savesStack.pop();if(void 0!==a){t?.(a,e);canvas_dependency_tracker_classPrivateFieldGet(da,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(da,this)[a]}return this}recordOpenMarker(e){this._savesStack.push(e);return this}getOpenMarker(){return 0===this._savesStack.length?null:this._savesStack.at(-1)}recordCloseMarker(e,t){const i=this._savesStack.pop();if(void 0!==i){t?.(i,e);canvas_dependency_tracker_classPrivateFieldGet(da,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(da,this)[i]}return this}beginMarkedContent(e){this._markedContentStack.push(e);return this}endMarkedContent(e,t){const i=this._markedContentStack.pop();if(void 0!==i){t?.(i,e);canvas_dependency_tracker_classPrivateFieldGet(da,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(da,this)[i]}return this}pushBaseTransform(e){canvas_dependency_tracker_classPrivateFieldGet(sa,this).push(Util.multiplyByDOMMatrix(canvas_dependency_tracker_classPrivateFieldGet(sa,this).at(-1),e.getTransform()));return this}popBaseTransform(){canvas_dependency_tracker_classPrivateFieldGet(sa,this).length>1&&canvas_dependency_tracker_classPrivateFieldGet(sa,this).pop();return this}resetBBox(e){if(this._pendingBBoxIdx!==e){this._pendingBBoxIdx=e;canvas_dependency_tracker_classPrivateFieldGet(na,this).set(s,0)}return this}recordClipBox(e,t,i,a,r,n){const o=Util.multiplyByDOMMatrix(canvas_dependency_tracker_classPrivateFieldGet(sa,this).at(-1),t.getTransform()),l=s.slice();Util.axialAlignedBoundingBox([i,r,a,n],o,l);const c=Util.intersect(canvas_dependency_tracker_classPrivateFieldGet(ra,this),l);if(c){canvas_dependency_tracker_classPrivateFieldGet(ra,this)[0]=c[0];canvas_dependency_tracker_classPrivateFieldGet(ra,this)[1]=c[1];canvas_dependency_tracker_classPrivateFieldGet(ra,this)[2]=c[2];canvas_dependency_tracker_classPrivateFieldGet(ra,this)[3]=c[3]}else{canvas_dependency_tracker_classPrivateFieldGet(ra,this)[0]=canvas_dependency_tracker_classPrivateFieldGet(ra,this)[1]=1/0;canvas_dependency_tracker_classPrivateFieldGet(ra,this)[2]=canvas_dependency_tracker_classPrivateFieldGet(ra,this)[3]=-1/0}return this}recordBBox(e,t,i,a,r,n){const o=canvas_dependency_tracker_classPrivateFieldGet(ra,this);if(o[0]===1/0)return this;const l=Util.multiplyByDOMMatrix(canvas_dependency_tracker_classPrivateFieldGet(sa,this).at(-1),t.getTransform());if(o[0]===-1/0){Util.axialAlignedBoundingBox([i,r,a,n],l,canvas_dependency_tracker_classPrivateFieldGet(na,this));return this}const c=s.slice();Util.axialAlignedBoundingBox([i,r,a,n],l,c);canvas_dependency_tracker_classPrivateFieldGet(na,this)[0]=MathClamp(c[0],o[0],canvas_dependency_tracker_classPrivateFieldGet(na,this)[0]);canvas_dependency_tracker_classPrivateFieldGet(na,this)[1]=MathClamp(c[1],o[1],canvas_dependency_tracker_classPrivateFieldGet(na,this)[1]);canvas_dependency_tracker_classPrivateFieldGet(na,this)[2]=MathClamp(c[2],canvas_dependency_tracker_classPrivateFieldGet(na,this)[2],o[2]);canvas_dependency_tracker_classPrivateFieldGet(na,this)[3]=MathClamp(c[3],canvas_dependency_tracker_classPrivateFieldGet(na,this)[3],o[3]);return this}recordFullPageBBox(e){canvas_dependency_tracker_classPrivateFieldGet(na,this)[0]=Math.max(0,canvas_dependency_tracker_classPrivateFieldGet(ra,this)[0]);canvas_dependency_tracker_classPrivateFieldGet(na,this)[1]=Math.max(0,canvas_dependency_tracker_classPrivateFieldGet(ra,this)[1]);canvas_dependency_tracker_classPrivateFieldGet(na,this)[2]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(oa,this),canvas_dependency_tracker_classPrivateFieldGet(ra,this)[2]);canvas_dependency_tracker_classPrivateFieldGet(na,this)[3]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(la,this),canvas_dependency_tracker_classPrivateFieldGet(ra,this)[3]);return this}recordOperation(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2?arguments[2]:void 0;if(this._pendingBBoxIdx!==e)return this;const a=Qi(256*canvas_dependency_tracker_classPrivateFieldGet(na,this)[0]/canvas_dependency_tracker_classPrivateFieldGet(oa,this)),s=Qi(256*canvas_dependency_tracker_classPrivateFieldGet(na,this)[1]/canvas_dependency_tracker_classPrivateFieldGet(la,this)),r=ea(256*canvas_dependency_tracker_classPrivateFieldGet(na,this)[2]/canvas_dependency_tracker_classPrivateFieldGet(oa,this)),n=ea(256*canvas_dependency_tracker_classPrivateFieldGet(na,this)[3]/canvas_dependency_tracker_classPrivateFieldGet(la,this));expandBBox(canvas_dependency_tracker_classPrivateFieldGet(ca,this),e,a,s,r,n);if(i)for(const t of i)for(const i of t)i!==e&&expandBBox(canvas_dependency_tracker_classPrivateFieldGet(ca,this),i,a,s,r,n);t||(this._pendingBBoxIdx=-1);return this}bboxToClipBoxDropOperation(e){if(this._pendingBBoxIdx===e){this._pendingBBoxIdx=-1;canvas_dependency_tracker_classPrivateFieldGet(ra,this)[0]=Math.max(canvas_dependency_tracker_classPrivateFieldGet(ra,this)[0],canvas_dependency_tracker_classPrivateFieldGet(na,this)[0]);canvas_dependency_tracker_classPrivateFieldGet(ra,this)[1]=Math.max(canvas_dependency_tracker_classPrivateFieldGet(ra,this)[1],canvas_dependency_tracker_classPrivateFieldGet(na,this)[1]);canvas_dependency_tracker_classPrivateFieldGet(ra,this)[2]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(ra,this)[2],canvas_dependency_tracker_classPrivateFieldGet(na,this)[2]);canvas_dependency_tracker_classPrivateFieldGet(ra,this)[3]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(ra,this)[3],canvas_dependency_tracker_classPrivateFieldGet(na,this)[3])}return this}take(){return new BBoxReader(canvas_dependency_tracker_classPrivateFieldGet(da,this),canvas_dependency_tracker_classPrivateFieldGet(ca,this))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(e,t){return this}recordIncrementalData(e,t){return this}resetIncrementalData(e,t){return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,i){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,i){return this}getSimpleIndex(e){}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e){return this}}function _initializeBBoxes(e,t){const i=new ArrayBuffer(4*e);canvas_dependency_tracker_classPrivateFieldSet(ca,this,new Uint8ClampedArray(i));canvas_dependency_tracker_classPrivateFieldSet(da,this,new Uint32Array(i));if(t&&t.length>0){canvas_dependency_tracker_classPrivateFieldGet(da,this).set(t);canvas_dependency_tracker_classPrivateFieldGet(da,this).fill(ta,t.length)}else canvas_dependency_tracker_classPrivateFieldGet(da,this).fill(ta)}var ua=new WeakMap,_a=new WeakMap,pa=new WeakMap,ga=new WeakMap,fa=new WeakMap,ma=new WeakMap,va=new WeakMap,ya=new WeakMap;class CanvasDependencyTracker{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];canvas_dependency_tracker_classPrivateFieldInitSpec(this,ua,{__proto__:null});canvas_dependency_tracker_classPrivateFieldInitSpec(this,_a,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Ji]:[]});canvas_dependency_tracker_classPrivateFieldInitSpec(this,pa,new Map);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ga,new Set);canvas_dependency_tracker_classPrivateFieldInitSpec(this,fa,new Map);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ma,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,va,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ya,void 0);canvas_dependency_tracker_classPrivateFieldSet(ya,this,e);if(t){canvas_dependency_tracker_classPrivateFieldSet(ma,this,new Map);canvas_dependency_tracker_classPrivateFieldSet(va,this,(e,t)=>{ensureDebugMetadata(canvas_dependency_tracker_classPrivateFieldGet(ma,this),t).dependencies.add(e)})}}get clipBox(){return canvas_dependency_tracker_classPrivateFieldGet(ya,this).clipBox}growOperationsCount(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this).growOperationsCount(e)}save(e){canvas_dependency_tracker_classPrivateFieldSet(ua,this,{__proto__:canvas_dependency_tracker_classPrivateFieldGet(ua,this)});canvas_dependency_tracker_classPrivateFieldSet(_a,this,{__proto__:canvas_dependency_tracker_classPrivateFieldGet(_a,this),transform:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(_a,this).transform},moveText:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(_a,this).moveText},sameLineText:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(_a,this).sameLineText},[Ji]:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(_a,this)[Ji]}});canvas_dependency_tracker_classPrivateFieldGet(ya,this).save(e);return this}restore(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this).restore(e,canvas_dependency_tracker_classPrivateFieldGet(va,this));const t=Object.getPrototypeOf(canvas_dependency_tracker_classPrivateFieldGet(ua,this));if(null===t)return this;canvas_dependency_tracker_classPrivateFieldSet(ua,this,t);canvas_dependency_tracker_classPrivateFieldSet(_a,this,Object.getPrototypeOf(canvas_dependency_tracker_classPrivateFieldGet(_a,this)));return this}recordOpenMarker(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this).recordOpenMarker(e,canvas_dependency_tracker_classPrivateFieldGet(va,this));return this}getOpenMarker(){return canvas_dependency_tracker_classPrivateFieldGet(ya,this).getOpenMarker()}recordCloseMarker(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this).recordCloseMarker(e,canvas_dependency_tracker_classPrivateFieldGet(va,this));return this}beginMarkedContent(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this).beginMarkedContent(e);return this}endMarkedContent(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this).endMarkedContent(e,canvas_dependency_tracker_classPrivateFieldGet(va,this));return this}pushBaseTransform(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this).pushBaseTransform(e);return this}popBaseTransform(){canvas_dependency_tracker_classPrivateFieldGet(ya,this).popBaseTransform();return this}recordSimpleData(e,t){canvas_dependency_tracker_classPrivateFieldGet(ua,this)[e]=t;return this}recordIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(_a,this)[e].push(t);return this}resetIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(_a,this)[e].length=0;return this}recordNamedData(e,t){canvas_dependency_tracker_classPrivateFieldGet(pa,this).set(e,t);return this}recordSimpleDataFromNamed(e,t,i){canvas_dependency_tracker_classPrivateFieldGet(ua,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(pa,this).get(t)??i}recordFutureForcedDependency(e,t){this.recordIncrementalData(Ji,t);return this}inheritSimpleDataAsFutureForcedDependencies(e){for(const t of e)t in canvas_dependency_tracker_classPrivateFieldGet(ua,this)&&this.recordFutureForcedDependency(t,canvas_dependency_tracker_classPrivateFieldGet(ua,this)[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const e of canvas_dependency_tracker_classPrivateFieldGet(ga,this))this.recordFutureForcedDependency(Ji,e);return this}resetBBox(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this).resetBBox(e);return this}recordClipBox(e,t,i,a,s,r){canvas_dependency_tracker_classPrivateFieldGet(ya,this).recordClipBox(e,t,i,a,s,r);return this}recordBBox(e,t,i,a,s,r){canvas_dependency_tracker_classPrivateFieldGet(ya,this).recordBBox(e,t,i,a,s,r);return this}recordCharacterBBox(e,t,i){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,n=arguments.length>6?arguments[6]:void 0;const o=i.bbox;let l,c;if(o){l=o[2]!==o[0]&&o[3]!==o[1]&&canvas_dependency_tracker_classPrivateFieldGet(fa,this).get(i);if(!1!==l){c=[0,0,0,0];Util.axialAlignedBoundingBox(o,i.fontMatrix,c);1===a&&0===s&&0===r||function scaleCharBBox(e,t,i,a,s){let r;if(e){if(e<0){r=s[0];s[0]=s[2];s[2]=r}s[0]*=e;s[2]*=e;if(t<0){r=s[1];s[1]=s[3];s[3]=r}s[1]*=t;s[3]*=t}else s.fill(0);s[0]+=i;s[1]+=a;s[2]+=i;s[3]+=a}(a,-a,s,r,c);if(l)return this.recordBBox(e,t,c[0],c[2],c[1],c[3])}}if(!n)return this.recordFullPageBBox(e);const d=n();if(o&&c&&void 0===l){l=c[0]<=s-d.actualBoundingBoxLeft&&c[2]>=s+d.actualBoundingBoxRight&&c[1]<=r-d.actualBoundingBoxAscent&&c[3]>=r+d.actualBoundingBoxDescent;canvas_dependency_tracker_classPrivateFieldGet(fa,this).set(i,l);if(l)return this.recordBBox(e,t,c[0],c[2],c[1],c[3])}return this.recordBBox(e,t,s-d.actualBoundingBoxLeft,s+d.actualBoundingBoxRight,r-d.actualBoundingBoxAscent,r+d.actualBoundingBoxDescent)}recordFullPageBBox(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this).recordFullPageBBox(e);return this}getSimpleIndex(e){return canvas_dependency_tracker_classPrivateFieldGet(ua,this)[e]}recordDependencies(e,t){const i=canvas_dependency_tracker_classPrivateFieldGet(ga,this),a=canvas_dependency_tracker_classPrivateFieldGet(ua,this),s=canvas_dependency_tracker_classPrivateFieldGet(_a,this);for(const e of t)e in canvas_dependency_tracker_classPrivateFieldGet(ua,this)?i.add(a[e]):e in s&&s[e].forEach(i.add,i);return this}recordNamedDependency(e,t){canvas_dependency_tracker_classPrivateFieldGet(pa,this).has(t)&&canvas_dependency_tracker_classPrivateFieldGet(ga,this).add(canvas_dependency_tracker_classPrivateFieldGet(pa,this).get(t));return this}recordOperation(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.recordDependencies(e,[Ji]);if(canvas_dependency_tracker_classPrivateFieldGet(ma,this)){const t=ensureDebugMetadata(canvas_dependency_tracker_classPrivateFieldGet(ma,this),e),i=t.dependencies;canvas_dependency_tracker_classPrivateFieldGet(ga,this).forEach(i.add,i);canvas_dependency_tracker_classPrivateFieldGet(ya,this)._savesStack.forEach(i.add,i);canvas_dependency_tracker_classPrivateFieldGet(ya,this)._markedContentStack.forEach(i.add,i);i.delete(e);t.isRenderingOperation=!0}const i=!t&&e===canvas_dependency_tracker_classPrivateFieldGet(ya,this)._pendingBBoxIdx;canvas_dependency_tracker_classPrivateFieldGet(ya,this).recordOperation(e,t,[canvas_dependency_tracker_classPrivateFieldGet(ga,this),canvas_dependency_tracker_classPrivateFieldGet(ya,this)._savesStack,canvas_dependency_tracker_classPrivateFieldGet(ya,this)._markedContentStack]);i&&canvas_dependency_tracker_classPrivateFieldGet(ga,this).clear();return this}recordShowTextOperation(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=Array.from(canvas_dependency_tracker_classPrivateFieldGet(ga,this));this.recordOperation(e,t);this.recordIncrementalData("sameLineText",e);for(const e of i)this.recordIncrementalData("sameLineText",e);return this}bboxToClipBoxDropOperation(e){const t=!(arguments.length>1&&void 0!==arguments[1]&&arguments[1])&&e===canvas_dependency_tracker_classPrivateFieldGet(ya,this)._pendingBBoxIdx;canvas_dependency_tracker_classPrivateFieldGet(ya,this).bboxToClipBoxDropOperation(e);t&&canvas_dependency_tracker_classPrivateFieldGet(ga,this).clear();return this}take(){canvas_dependency_tracker_classPrivateFieldGet(fa,this).clear();return canvas_dependency_tracker_classPrivateFieldGet(ya,this).take()}takeDebugMetadata(){return canvas_dependency_tracker_classPrivateFieldGet(ma,this)}}var Pa=new WeakMap,wa=new WeakMap,ba=new WeakMap,Fa=new WeakMap,Sa=new WeakMap;class CanvasNestedDependencyTracker{constructor(e,t,i){canvas_dependency_tracker_classPrivateFieldInitSpec(this,Pa,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,wa,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ba,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Fa,0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Sa,0);if(e instanceof CanvasNestedDependencyTracker&&canvas_dependency_tracker_classPrivateFieldGet(ba,e)===!!i)return e;canvas_dependency_tracker_classPrivateFieldSet(Pa,this,e);canvas_dependency_tracker_classPrivateFieldSet(wa,this,t);canvas_dependency_tracker_classPrivateFieldSet(ba,this,!!i)}get clipBox(){return canvas_dependency_tracker_classPrivateFieldGet(Pa,this).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(e){var t;canvas_dependency_tracker_classPrivateFieldSet(Sa,this,(t=canvas_dependency_tracker_classPrivateFieldGet(Sa,this),t++,t));canvas_dependency_tracker_classPrivateFieldGet(Pa,this).save(canvas_dependency_tracker_classPrivateFieldGet(wa,this));return this}restore(e){if(canvas_dependency_tracker_classPrivateFieldGet(Sa,this)>0){var t;canvas_dependency_tracker_classPrivateFieldGet(Pa,this).restore(canvas_dependency_tracker_classPrivateFieldGet(wa,this));canvas_dependency_tracker_classPrivateFieldSet(Sa,this,(t=canvas_dependency_tracker_classPrivateFieldGet(Sa,this),t--,t))}return this}recordOpenMarker(e){var t;canvas_dependency_tracker_classPrivateFieldSet(Fa,this,(t=canvas_dependency_tracker_classPrivateFieldGet(Fa,this),t++,t));return this}getOpenMarker(){return canvas_dependency_tracker_classPrivateFieldGet(Fa,this)>0?canvas_dependency_tracker_classPrivateFieldGet(wa,this):canvas_dependency_tracker_classPrivateFieldGet(Pa,this).getOpenMarker()}recordCloseMarker(e){var t;canvas_dependency_tracker_classPrivateFieldSet(Fa,this,(t=canvas_dependency_tracker_classPrivateFieldGet(Fa,this),t--,t));return this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).pushBaseTransform(e);return this}popBaseTransform(){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).popBaseTransform();return this}recordSimpleData(e,t){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordSimpleData(e,canvas_dependency_tracker_classPrivateFieldGet(wa,this));return this}recordIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordIncrementalData(e,canvas_dependency_tracker_classPrivateFieldGet(wa,this));return this}resetIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).resetIncrementalData(e,canvas_dependency_tracker_classPrivateFieldGet(wa,this));return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,i){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordSimpleDataFromNamed(e,t,canvas_dependency_tracker_classPrivateFieldGet(wa,this));return this}recordFutureForcedDependency(e,t){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordFutureForcedDependency(e,canvas_dependency_tracker_classPrivateFieldGet(wa,this));return this}inheritSimpleDataAsFutureForcedDependencies(e){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).inheritSimpleDataAsFutureForcedDependencies(e);return this}inheritPendingDependenciesAsFutureForcedDependencies(){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).inheritPendingDependenciesAsFutureForcedDependencies();return this}resetBBox(e){canvas_dependency_tracker_classPrivateFieldGet(ba,this)||canvas_dependency_tracker_classPrivateFieldGet(Pa,this).resetBBox(canvas_dependency_tracker_classPrivateFieldGet(wa,this));return this}recordClipBox(e,t,i,a,s,r){canvas_dependency_tracker_classPrivateFieldGet(ba,this)||canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordClipBox(canvas_dependency_tracker_classPrivateFieldGet(wa,this),t,i,a,s,r);return this}recordBBox(e,t,i,a,s,r){canvas_dependency_tracker_classPrivateFieldGet(ba,this)||canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordBBox(canvas_dependency_tracker_classPrivateFieldGet(wa,this),t,i,a,s,r);return this}recordCharacterBBox(e,t,i,a,s,r,n){canvas_dependency_tracker_classPrivateFieldGet(ba,this)||canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordCharacterBBox(canvas_dependency_tracker_classPrivateFieldGet(wa,this),t,i,a,s,r,n);return this}recordFullPageBBox(e){canvas_dependency_tracker_classPrivateFieldGet(ba,this)||canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordFullPageBBox(canvas_dependency_tracker_classPrivateFieldGet(wa,this));return this}getSimpleIndex(e){return canvas_dependency_tracker_classPrivateFieldGet(Pa,this).getSimpleIndex(e)}recordDependencies(e,t){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordDependencies(canvas_dependency_tracker_classPrivateFieldGet(wa,this),t);return this}recordNamedDependency(e,t){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordNamedDependency(canvas_dependency_tracker_classPrivateFieldGet(wa,this),t);return this}recordOperation(e){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordOperation(canvas_dependency_tracker_classPrivateFieldGet(wa,this),!0);return this}recordShowTextOperation(e){canvas_dependency_tracker_classPrivateFieldGet(Pa,this).recordShowTextOperation(canvas_dependency_tracker_classPrivateFieldGet(wa,this),!0);return this}bboxToClipBoxDropOperation(e){canvas_dependency_tracker_classPrivateFieldGet(ba,this)||canvas_dependency_tracker_classPrivateFieldGet(Pa,this).bboxToClipBoxDropOperation(canvas_dependency_tracker_classPrivateFieldGet(wa,this),!0);return this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const Ca=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],Aa=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],xa=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],ka=["filter","fillColor","fillAlpha"],Ea=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],Ta=["transform"],Ia=["transform","fillColor"];var Ga=new WeakMap,Ba=new WeakMap,Ma=new WeakMap,Da=new WeakMap,La=new WeakMap;class CanvasImagesTracker{constructor(e){canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ga,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ba,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ma,4);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Da,0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,La,new Oa._(6*canvas_dependency_tracker_classPrivateFieldGet(Ma,this)));canvas_dependency_tracker_classPrivateFieldSet(Ga,this,e.width);canvas_dependency_tracker_classPrivateFieldSet(Ba,this,e.height)}record(e,t,i,a){var r;if(canvas_dependency_tracker_classPrivateFieldGet(Da,this)===canvas_dependency_tracker_classPrivateFieldGet(Ma,this)){canvas_dependency_tracker_classPrivateFieldSet(Ma,this,2*canvas_dependency_tracker_classPrivateFieldGet(Ma,this));const e=new Oa._(6*canvas_dependency_tracker_classPrivateFieldGet(Ma,this));e.set(canvas_dependency_tracker_classPrivateFieldGet(La,this));canvas_dependency_tracker_classPrivateFieldSet(La,this,e)}const n=getCurrentTransform(e);let o;if(a[0]!==1/0){const e=s.slice();Util.axialAlignedBoundingBox([0,-i,t,0],n,e);const r=Util.intersect(a,e);if(!r)return;const l=canvas_dependency_tracker_slicedToArray(r,4),c=l[0],d=l[1],h=l[2],u=l[3];if(c!==e[0]||d!==e[1]||h!==e[2]||u!==e[3]){const e=Math.atan2(n[1],n[0]),t=Math.abs(Math.sin(e)),i=Math.abs(Math.cos(e));if(t<1e-6||i<1e-6||Math.abs(t-i)<1e-6)o=[c,d,c,u,h,d];else{const e=h-c,a=u-d,s=t*t,r=i*i,n=i*t,l=r-s,_=(a*r-e*n)/l;o=[c+(a*n-e*s)/l,d,c,d+_,h,u-_]}}}if(!o){o=[0,-i,0,0,t,-i];Util.applyTransform(o,n,0);Util.applyTransform(o,n,2);Util.applyTransform(o,n,4)}o[0]/=canvas_dependency_tracker_classPrivateFieldGet(Ga,this);o[1]/=canvas_dependency_tracker_classPrivateFieldGet(Ba,this);o[2]/=canvas_dependency_tracker_classPrivateFieldGet(Ga,this);o[3]/=canvas_dependency_tracker_classPrivateFieldGet(Ba,this);o[4]/=canvas_dependency_tracker_classPrivateFieldGet(Ga,this);o[5]/=canvas_dependency_tracker_classPrivateFieldGet(Ba,this);canvas_dependency_tracker_classPrivateFieldGet(La,this).set(o,6*canvas_dependency_tracker_classPrivateFieldGet(Da,this));canvas_dependency_tracker_classPrivateFieldSet(Da,this,(r=canvas_dependency_tracker_classPrivateFieldGet(Da,this),r++,r))}take(){return canvas_dependency_tracker_classPrivateFieldGet(La,this).subarray(0,6*canvas_dependency_tracker_classPrivateFieldGet(Da,this))}}var Oa={_:FeatureTest.isFloat16ArraySupported?Float16Array:Float32Array};function font_loader_defineProperty(e,t,i){return(t=function font_loader_toPropertyKey(e){var t=function font_loader_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function font_loader_classPrivateFieldInitSpec(e,t,i){(function font_loader_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function font_loader_classPrivateFieldGet(e,t){return e.get(font_loader_assertClassBrand(e,t))}function font_loader_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Ra=new WeakMap;class FontLoader{constructor(e){let t=e.ownerDocument,i=void 0===t?globalThis.document:t;e.styleElement;font_loader_classPrivateFieldInitSpec(this,Ra,new Set);this._document=i;this.nativeFontFaces=new Set;this.styleElement=null;this.loadingRequests=[];this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e);this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e);this._document.fonts.delete(e)}insertRule(e){if(!this.styleElement){this.styleElement=this._document.createElement("style");this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)}const t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear();font_loader_classPrivateFieldGet(Ra,this).clear();if(this.styleElement){this.styleElement.remove();this.styleElement=null}}async loadSystemFont(e){let t=e.systemFontInfo,i=e.disableFontFace,a=e._inspectFont;if(t&&!font_loader_classPrivateFieldGet(Ra,this).has(t.loadedName)){assert(!i,"loadSystemFont shouldn't be called when `disableFontFace` is set.");if(this.isFontLoadingAPISupported){const e=t.loadedName,i=t.src,s=t.style,r=new FontFace(e,i,s);this.addNativeFontFace(r);try{await r.load();font_loader_classPrivateFieldGet(Ra,this).add(e);a?.(t)}catch{warn(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`);this.removeNativeFontFace(r)}return}unreachable("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;e.attached=!0;if(e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(i){warn(`Failed to load font '${t.family}': '${i}'.`);e.disableFontFace=!0;throw i}}return}const t=e.createFontFaceRule();if(t){this.insertRule(t);if(this.isSyncFontLoadingSupported)return;await new Promise(t=>{const i=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,i)})}}get isFontLoadingAPISupported(){return shadow(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return shadow(this,"isSyncFontLoadingSupported",a||FeatureTest.platform.isFirefox)}_queueLoadingCallback(e){const t=this.loadingRequests,i={done:!1,complete:function completeRequest(){assert(!i.done,"completeRequest() cannot be called twice.");i.done=!0;for(;t.length>0&&t[0].done;){const e=t.shift();setTimeout(e.callback,0)}},callback:e};t.push(i);return i}get _loadTestFont(){return shadow(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(e,t){function int32(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function spliceString(e,t,i,a){return e.substring(0,t)+a+e.substring(t+i)}let i,a;const s=this._document.createElement("canvas");s.width=1;s.height=1;const r=s.getContext("2d");let n=0;const o=`lt${Date.now()}${this.loadTestFontId++}`;let l=this._loadTestFont;l=spliceString(l,976,o.length,o);const c=1482184792;let d=int32(l,16);for(i=0,a=o.length-3;i<a;i+=4)d=d-c+int32(o,i)|0;i<o.length&&(d=d-c+int32(o+"XXX",i)|0);l=spliceString(l,16,4,function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}(d));const h=`@font-face {font-family:"${o}";src:${`url(data:font/opentype;base64,${btoa(l)});`}}`;this.insertRule(h);const u=this._document.createElement("div");u.style.visibility="hidden";u.style.width=u.style.height="10px";u.style.position="absolute";u.style.top=u.style.left="0px";for(const t of[e.loadedName,o]){const e=this._document.createElement("span");e.textContent="Hi";e.style.fontFamily=t;u.append(e)}this._document.body.append(u);!function isFontReady(e,t){if(++n>30){warn("Load test font never loaded.");t();return}r.font="30px "+e;r.fillText(".",0,20);r.getImageData(0,0,1,1).data[3]>0?t():setTimeout(isFontReady.bind(null,e,t))}(o,()=>{u.remove();t.complete()})}}var Na,ja=new WeakMap;class FontFaceObject{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0;font_loader_defineProperty(this,"compiledGlyphs",Object.create(null));font_loader_classPrivateFieldInitSpec(this,ja,void 0);!function font_loader_classPrivateFieldSet(e,t,i){return e.set(font_loader_assertClassBrand(e,t),i),i}(ja,this,e);this._inspectFont=t;i&&(this.charProcOperatorList=i);a&&Object.assign(this,a)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`);e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});this._inspectFont?.(this);return e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let t;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}}`;this._inspectFont?.(this,e);return t}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];const i=this.loadedName+"_path_"+t;let a;try{a=e.get(i)}catch(e){warn(`getPathGenerator - ignoring character: "${e}".`)}const s=makePathFromDrawOPS(a?.path);this.fontExtraProperties||e.delete(i);return this.compiledGlyphs[t]=s}get black(){return font_loader_classPrivateFieldGet(ja,this).black}get bold(){return font_loader_classPrivateFieldGet(ja,this).bold}get disableFontFace(){return font_loader_classPrivateFieldGet(ja,this).disableFontFace}set disableFontFace(e){shadow(this,"disableFontFace",!!e)}get fontExtraProperties(){return font_loader_classPrivateFieldGet(ja,this).fontExtraProperties}get isInvalidPDFjsFont(){return font_loader_classPrivateFieldGet(ja,this).isInvalidPDFjsFont}get isType3Font(){return font_loader_classPrivateFieldGet(ja,this).isType3Font}get italic(){return font_loader_classPrivateFieldGet(ja,this).italic}get missingFile(){return font_loader_classPrivateFieldGet(ja,this).missingFile}get remeasure(){return font_loader_classPrivateFieldGet(ja,this).remeasure}get vertical(){return font_loader_classPrivateFieldGet(ja,this).vertical}get ascent(){return font_loader_classPrivateFieldGet(ja,this).ascent}get defaultWidth(){return font_loader_classPrivateFieldGet(ja,this).defaultWidth}get descent(){return font_loader_classPrivateFieldGet(ja,this).descent}get bbox(){return font_loader_classPrivateFieldGet(ja,this).bbox}get fontMatrix(){return font_loader_classPrivateFieldGet(ja,this).fontMatrix}get fallbackName(){return font_loader_classPrivateFieldGet(ja,this).fallbackName}get loadedName(){return font_loader_classPrivateFieldGet(ja,this).loadedName}get mimetype(){return font_loader_classPrivateFieldGet(ja,this).mimetype}get name(){return font_loader_classPrivateFieldGet(ja,this).name}get data(){return font_loader_classPrivateFieldGet(ja,this).data}clearData(){font_loader_classPrivateFieldGet(ja,this).clearData()}get cssFontInfo(){return font_loader_classPrivateFieldGet(ja,this).cssFontInfo}get systemFontInfo(){return font_loader_classPrivateFieldGet(ja,this).systemFontInfo}get defaultVMetrics(){return font_loader_classPrivateFieldGet(ja,this).defaultVMetrics}}function obj_bin_transform_utils_defineProperty(e,t,i){return(t=function obj_bin_transform_utils_toPropertyKey(e){var t=function obj_bin_transform_utils_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class CSS_FONT_INFO{}obj_bin_transform_utils_defineProperty(CSS_FONT_INFO,"strings",["fontFamily","fontWeight","italicAngle"]);class SYSTEM_FONT_INFO{}obj_bin_transform_utils_defineProperty(SYSTEM_FONT_INFO,"strings",["css","loadedName","baseFontName","src"]);class FONT_INFO{}Na=FONT_INFO;obj_bin_transform_utils_defineProperty(FONT_INFO,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]);obj_bin_transform_utils_defineProperty(FONT_INFO,"numbers",["ascent","defaultWidth","descent"]);obj_bin_transform_utils_defineProperty(FONT_INFO,"strings",["fallbackName","loadedName","mimetype","name"]);obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_NUMBERS",Math.ceil(2*Na.bools.length/8));obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_BBOX",Na.OFFSET_NUMBERS+8*Na.numbers.length);obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_FONT_MATRIX",Na.OFFSET_BBOX+1+8);obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_DEFAULT_VMETRICS",Na.OFFSET_FONT_MATRIX+1+48);obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_STRINGS",Na.OFFSET_DEFAULT_VMETRICS+1+6);class PATTERN_INFO{}obj_bin_transform_utils_defineProperty(PATTERN_INFO,"KIND",0);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"HAS_BBOX",1);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"HAS_BACKGROUND",2);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"SHADING_TYPE",3);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_COORD",4);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_COLOR",8);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_STOP",12);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_FIGURES",16);function obj_bin_transform_display_classPrivateMethodInitSpec(e,t){obj_bin_transform_display_checkPrivateRedeclaration(e,t),t.add(e)}function obj_bin_transform_display_classPrivateFieldInitSpec(e,t,i){obj_bin_transform_display_checkPrivateRedeclaration(e,t),t.set(e,i)}function obj_bin_transform_display_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function obj_bin_transform_display_classPrivateFieldGet(e,t){return e.get(obj_bin_transform_display_assertClassBrand(e,t))}function obj_bin_transform_display_classPrivateFieldSet(e,t,i){return e.set(obj_bin_transform_display_assertClassBrand(e,t),i),i}function obj_bin_transform_display_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Wa=new WeakMap,Ua=new WeakMap,Va=new WeakMap,Ha=new WeakSet;class CssFontInfo{constructor(e){obj_bin_transform_display_classPrivateMethodInitSpec(this,Ha);obj_bin_transform_display_classPrivateFieldInitSpec(this,Wa,void 0);obj_bin_transform_display_classPrivateFieldInitSpec(this,Ua,new TextDecoder);obj_bin_transform_display_classPrivateFieldInitSpec(this,Va,void 0);obj_bin_transform_display_classPrivateFieldSet(Wa,this,e);obj_bin_transform_display_classPrivateFieldSet(Va,this,new DataView(e))}get fontFamily(){return obj_bin_transform_display_assertClassBrand(Ha,this,_readString).call(this,0)}get fontWeight(){return obj_bin_transform_display_assertClassBrand(Ha,this,_readString).call(this,1)}get italicAngle(){return obj_bin_transform_display_assertClassBrand(Ha,this,_readString).call(this,2)}}function _readString(e){assert(e<CSS_FONT_INFO.strings.length,"Invalid string index");let t=0;for(let i=0;i<e;i++)t+=obj_bin_transform_display_classPrivateFieldGet(Va,this).getUint32(t)+4;const i=obj_bin_transform_display_classPrivateFieldGet(Va,this).getUint32(t);return obj_bin_transform_display_classPrivateFieldGet(Ua,this).decode(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Wa,this),t+4,i))}var za=new WeakMap,$a=new WeakMap,qa=new WeakMap,Xa=new WeakSet;class SystemFontInfo{constructor(e){obj_bin_transform_display_classPrivateMethodInitSpec(this,Xa);obj_bin_transform_display_classPrivateFieldInitSpec(this,za,void 0);obj_bin_transform_display_classPrivateFieldInitSpec(this,$a,new TextDecoder);obj_bin_transform_display_classPrivateFieldInitSpec(this,qa,void 0);obj_bin_transform_display_classPrivateFieldSet(za,this,e);obj_bin_transform_display_classPrivateFieldSet(qa,this,new DataView(e))}get guessFallback(){return 0!==obj_bin_transform_display_classPrivateFieldGet(qa,this).getUint8(0)}get css(){return obj_bin_transform_display_assertClassBrand(Xa,this,_readString2).call(this,0)}get loadedName(){return obj_bin_transform_display_assertClassBrand(Xa,this,_readString2).call(this,1)}get baseFontName(){return obj_bin_transform_display_assertClassBrand(Xa,this,_readString2).call(this,2)}get src(){return obj_bin_transform_display_assertClassBrand(Xa,this,_readString2).call(this,3)}get style(){let e=1;e+=4+obj_bin_transform_display_classPrivateFieldGet(qa,this).getUint32(e);const t=obj_bin_transform_display_classPrivateFieldGet(qa,this).getUint32(e),i=obj_bin_transform_display_classPrivateFieldGet($a,this).decode(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(za,this),e+4,t));e+=4+t;const a=obj_bin_transform_display_classPrivateFieldGet(qa,this).getUint32(e);return{style:i,weight:obj_bin_transform_display_classPrivateFieldGet($a,this).decode(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(za,this),e+4,a))}}}function _readString2(e){assert(e<SYSTEM_FONT_INFO.strings.length,"Invalid string index");let t=5;for(let i=0;i<e;i++)t+=obj_bin_transform_display_classPrivateFieldGet(qa,this).getUint32(t)+4;const i=obj_bin_transform_display_classPrivateFieldGet(qa,this).getUint32(t);return obj_bin_transform_display_classPrivateFieldGet($a,this).decode(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(za,this),t+4,i))}var Ka=new WeakMap,Ya=new WeakMap,Za=new WeakMap,Ja=new WeakSet;class FontInfo{constructor(e){let t=e.buffer,i=e.extra;obj_bin_transform_display_classPrivateMethodInitSpec(this,Ja);obj_bin_transform_display_classPrivateFieldInitSpec(this,Ka,void 0);obj_bin_transform_display_classPrivateFieldInitSpec(this,Ya,new TextDecoder);obj_bin_transform_display_classPrivateFieldInitSpec(this,Za,void 0);obj_bin_transform_display_classPrivateFieldSet(Ka,this,t);obj_bin_transform_display_classPrivateFieldSet(Za,this,new DataView(t));i&&Object.assign(this,i)}get black(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readBoolean).call(this,0)}get bold(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readBoolean).call(this,1)}get disableFontFace(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readBoolean).call(this,2)}get fontExtraProperties(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readBoolean).call(this,3)}get isInvalidPDFjsFont(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readBoolean).call(this,4)}get isType3Font(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readBoolean).call(this,5)}get italic(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readBoolean).call(this,6)}get missingFile(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readBoolean).call(this,7)}get remeasure(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readBoolean).call(this,8)}get vertical(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readBoolean).call(this,9)}get ascent(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readNumber).call(this,0)}get defaultWidth(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readNumber).call(this,1)}get descent(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readNumber).call(this,2)}get bbox(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readArray).call(this,FONT_INFO.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readArray).call(this,FONT_INFO.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readArray).call(this,FONT_INFO.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}get fallbackName(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readString3).call(this,0)}get loadedName(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readString3).call(this,1)}get mimetype(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readString3).call(this,2)}get name(){return obj_bin_transform_display_assertClassBrand(Ja,this,_readString3).call(this,3)}get data(){const e=obj_bin_transform_display_assertClassBrand(Ja,this,_getDataOffsets).call(this),t=e.offset,i=e.length;return 0===i?void 0:new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Ka,this),t+4,i)}clearData(){const e=obj_bin_transform_display_assertClassBrand(Ja,this,_getDataOffsets).call(this),t=e.offset;if(0!==e.length){obj_bin_transform_display_classPrivateFieldGet(Za,this).setUint32(t,0);obj_bin_transform_display_classPrivateFieldSet(Ka,this,new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Ka,this),0,t+4).slice().buffer);obj_bin_transform_display_classPrivateFieldSet(Za,this,new DataView(obj_bin_transform_display_classPrivateFieldGet(Ka,this)))}}get cssFontInfo(){let e=FONT_INFO.OFFSET_STRINGS;e+=4+obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(e);e+=4+obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(e);const t=obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(e);if(0===t)return null;const i=new Uint8Array(t);i.set(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Ka,this),e+4,t));return new CssFontInfo(i.buffer)}get systemFontInfo(){let e=FONT_INFO.OFFSET_STRINGS;e+=4+obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(e);const t=obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(e);if(0===t)return null;const i=new Uint8Array(t);i.set(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Ka,this),e+4,t));return new SystemFontInfo(i.buffer)}}function _readBoolean(e){assert(e<FONT_INFO.bools.length,"Invalid boolean index");const t=Math.floor(e/4),i=2*e%8,a=obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint8(t)>>i&3;return 0===a?void 0:2===a}function _readNumber(e){assert(e<FONT_INFO.numbers.length,"Invalid number index");return obj_bin_transform_display_classPrivateFieldGet(Za,this).getFloat64(FONT_INFO.OFFSET_NUMBERS+8*e)}function _readArray(e,t,i,a){const s=obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint8(e);if(0===s)return;assert(s===t,"Invalid array length.");e+=1;const r=new Array(s);for(let t=0;t<s;t++){r[t]=obj_bin_transform_display_classPrivateFieldGet(Za,this)[i](e,!0);e+=a}return r}function _readString3(e){assert(e<FONT_INFO.strings.length,"Invalid string index");let t=FONT_INFO.OFFSET_STRINGS+4;for(let i=0;i<e;i++)t+=obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(t)+4;const i=obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(t);return obj_bin_transform_display_classPrivateFieldGet(Ya,this).decode(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Ka,this),t+4,i))}function _getDataOffsets(){let e=FONT_INFO.OFFSET_STRINGS;e+=4+obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(e);e+=4+obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(e);e+=4+obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(e);return{offset:e,length:obj_bin_transform_display_classPrivateFieldGet(Za,this).getUint32(e)}}class PatternInfo{constructor(e){this.buffer=e;this.view=new DataView(e);this.data=new Uint8Array(e)}getIR(){const e=this.view,t=this.data[PATTERN_INFO.KIND],i=!!this.data[PATTERN_INFO.HAS_BBOX],a=!!this.data[PATTERN_INFO.HAS_BACKGROUND],r=e.getUint32(PATTERN_INFO.N_COORD,!0),n=e.getUint32(PATTERN_INFO.N_COLOR,!0),o=e.getUint32(PATTERN_INFO.N_STOP,!0);let l=20;const c=new Float32Array(this.buffer,l,2*r);l+=8*r;const d=new Uint8Array(this.buffer,l,4*n);l+=4*n;const h=[];for(let t=0;t<o;++t){const t=e.getFloat32(l,!0);l+=4;const i=e.getUint32(l,!0);l+=4;h.push([t,`#${i.toString(16).padStart(6,"0")}`])}let u=null;if(i){u=[];for(let t=0;t<4;++t){u.push(e.getFloat32(l,!0));l+=4}}let _=null;if(a){_=new Uint8Array(this.buffer,l,3);l+=3}if(1===t)return["RadialAxial","axial",u,h,Array.from(c.slice(0,2)),Array.from(c.slice(2,4)),null,null];if(2===t)return["RadialAxial","radial",u,h,[c[0],c[1]],[c[3],c[4]],c[2],c[5]];if(3===t){const e=this.data[PATTERN_INFO.SHADING_TYPE];let t=null;if(c.length>0){t=s.slice();for(let e=0,i=c.length;e<i;e+=2)Util.pointBoundingBox(c[e],c[e+1],t)}return["Mesh",e,c,d,r,t,u,_]}throw new Error(`Unsupported pattern kind: ${t}`)}}var Qa=new WeakMap;class FontPathInfo{constructor(e){obj_bin_transform_display_classPrivateFieldInitSpec(this,Qa,void 0);obj_bin_transform_display_classPrivateFieldSet(Qa,this,e)}get path(){return FeatureTest.isFloat16ArraySupported?new Float16Array(obj_bin_transform_display_classPrivateFieldGet(Qa,this)):new Float32Array(obj_bin_transform_display_classPrivateFieldGet(Qa,this))}}function api_utils_slicedToArray(e,t){return function api_utils_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function api_utils_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function api_utils_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return api_utils_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?api_utils_arrayLikeToArray(e,t):void 0}}(e,t)||function api_utils_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function api_utils_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function api_utils_classPrivateFieldInitSpec(e,t,i){(function api_utils_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function api_utils_classPrivateFieldGet(e,t){return e.get(function api_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}function getFactoryUrlProp(e){if("string"!=typeof e)return null;if(e.endsWith("/"))return e;throw new Error(`Invalid factory url: "${e}" must include trailing slash.`)}const isRefProxy=e=>"object"==typeof e&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0,es=function _isValidExplicitDest(e,t,i){if(!Array.isArray(i)||i.length<2)return!1;const a=_toArray(i),s=a[0],r=a[1],n=_arrayLikeToArray(a).slice(2);if(!e(s)&&!Number.isInteger(s))return!1;if(!t(r))return!1;const o=n.length;let l=!0;switch(r.name){case"XYZ":if(o<2||o>3)return!1;break;case"Fit":case"FitB":return 0===o;case"FitH":case"FitBH":case"FitV":case"FitBV":if(o>1)return!1;break;case"FitR":if(4!==o)return!1;l=!1;break;default:return!1}for(const e of n)if(!("number"==typeof e||l&&null===e))return!1;return!0}.bind(null,isRefProxy,e=>"object"==typeof e&&"string"==typeof e?.name);var ts=new WeakMap,is=new WeakMap;class LoopbackPort{constructor(){api_utils_classPrivateFieldInitSpec(this,ts,new Map);api_utils_classPrivateFieldInitSpec(this,is,Promise.resolve())}postMessage(e,t){const i={data:structuredClone(e,t?{transfer:t}:null)};api_utils_classPrivateFieldGet(is,this).then(()=>{for(const e of api_utils_classPrivateFieldGet(ts,this)){api_utils_slicedToArray(e,1)[0].call(this,i)}})}addEventListener(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=null;if(i?.signal instanceof AbortSignal){const s=i.signal;if(s.aborted){warn("LoopbackPort - cannot use an `aborted` signal.");return}const onAbort=()=>this.removeEventListener(e,t);a=()=>s.removeEventListener("abort",onAbort);s.addEventListener("abort",onAbort)}api_utils_classPrivateFieldGet(ts,this).set(t,a)}removeEventListener(e,t){const i=api_utils_classPrivateFieldGet(ts,this).get(t);i?.();api_utils_classPrivateFieldGet(ts,this).delete(t)}terminate(){for(const e of api_utils_classPrivateFieldGet(ts,this)){const t=api_utils_slicedToArray(e,2)[1];t?.()}api_utils_classPrivateFieldGet(ts,this).clear()}}__webpack_require__(1689);function message_handler_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function message_handler_classPrivateFieldGet(e,t){return e.get(message_handler_assertClassBrand(e,t))}function message_handler_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const as=1,ss=2,rs=1,ns=2,os=3,ls=4,cs=5,ds=6,hs=7,us=8;function onFn(){}function wrapReason(e){if(e instanceof AbortException||e instanceof InvalidPDFException||e instanceof PasswordException||e instanceof ResponseException||e instanceof UnknownErrorException)return e;e instanceof Error||"object"==typeof e&&null!==e||unreachable('wrapReason: Expected "reason" to be a (possibly cloned) Error.');switch(e.name){case"AbortException":return new AbortException(e.message);case"InvalidPDFException":return new InvalidPDFException(e.message);case"PasswordException":return new PasswordException(e.message,e.code);case"ResponseException":return new ResponseException(e.message,e.status,e.missing);case"UnknownErrorException":return new UnknownErrorException(e.message,e.details)}return new UnknownErrorException(e.message,e.toString())}var _s=new WeakMap,ps=new WeakSet;class MessageHandler{constructor(e,t,i){!function message_handler_classPrivateMethodInitSpec(e,t){message_handler_checkPrivateRedeclaration(e,t),t.add(e)}(this,ps);!function message_handler_classPrivateFieldInitSpec(e,t,i){message_handler_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,_s,new AbortController);this.sourceName=e;this.targetName=t;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",message_handler_assertClassBrand(ps,this,_onMessage).bind(this),{signal:message_handler_classPrivateFieldGet(_s,this).signal})}on(e,t){const i=this.actionHandler;if(i[e])throw new Error(`There is already an actionName called "${e}"`);i[e]=t}send(e,t,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},i)}sendWithPromise(e,t,i){const a=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[a]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:a,data:t},i)}catch(e){s.reject(e)}return s.promise}sendWithStream(e,t,i,a){const s=this.streamId++,r=this.sourceName,n=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();this.streamControllers[s]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1};o.postMessage({sourceName:r,targetName:n,action:e,streamId:s,data:t,desiredSize:i.desiredSize},a);return l.promise},pull:e=>{const t=Promise.withResolvers();this.streamControllers[s].pullCall=t;o.postMessage({sourceName:r,targetName:n,stream:ds,streamId:s,desiredSize:e.desiredSize});return t.promise},cancel:e=>{assert(e instanceof Error,"cancel must have a valid reason");const t=Promise.withResolvers();this.streamControllers[s].cancelCall=t;this.streamControllers[s].isClosed=!0;o.postMessage({sourceName:r,targetName:n,stream:rs,streamId:s,reason:wrapReason(e)});return t.promise}},i)}destroy(){message_handler_classPrivateFieldGet(_s,this)?.abort();!function message_handler_classPrivateFieldSet(e,t,i){return e.set(message_handler_assertClassBrand(e,t),i),i}(_s,this,null)}}function _onMessage(e){let t=e.data;if(t.targetName!==this.sourceName)return;if(t.stream){message_handler_assertClassBrand(ps,this,_processStreamMessage).call(this,t);return}if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);delete this.callbackCapabilities[e];if(t.callback===as)i.resolve(t.data);else{if(t.callback!==ss)throw new Error("Unexpected callback case");i.reject(wrapReason(t.reason))}return}const i=this.actionHandler[t.action];if(!i)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const e=this.sourceName,a=t.sourceName,s=this.comObj;Promise.try(i,t.data).then(function(i){s.postMessage({sourceName:e,targetName:a,callback:as,callbackId:t.callbackId,data:i})},function(i){s.postMessage({sourceName:e,targetName:a,callback:ss,callbackId:t.callbackId,reason:wrapReason(i)})});return}t.streamId?message_handler_assertClassBrand(ps,this,_createStreamSink).call(this,t):i(t.data)}function _createStreamSink(e){const t=e.streamId,i=this.sourceName,a=e.sourceName,s=this.comObj,r=this,n=this.actionHandler[e.action],o={enqueue(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2?arguments[2]:void 0;if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=r;if(o>0&&this.desiredSize<=0){this.sinkCapability=Promise.withResolvers();this.ready=this.sinkCapability.promise}s.postMessage({sourceName:i,targetName:a,stream:ls,streamId:t,chunk:e},n)},close(){if(!this.isCancelled){this.isCancelled=!0;s.postMessage({sourceName:i,targetName:a,stream:os,streamId:t});delete r.streamSinks[t]}},error(e){assert(e instanceof Error,"error must have a valid reason");if(!this.isCancelled){this.isCancelled=!0;s.postMessage({sourceName:i,targetName:a,stream:cs,streamId:t,reason:wrapReason(e)})}},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};o.sinkCapability.resolve();o.ready=o.sinkCapability.promise;this.streamSinks[t]=o;Promise.try(n,e.data,o).then(function(){s.postMessage({sourceName:i,targetName:a,stream:us,streamId:t,success:!0})},function(e){s.postMessage({sourceName:i,targetName:a,stream:us,streamId:t,reason:wrapReason(e)})})}function _processStreamMessage(e){const t=e.streamId,i=this.sourceName,a=e.sourceName,s=this.comObj,r=this.streamControllers[t],n=this.streamSinks[t];switch(e.stream){case us:e.success?r.startCall.resolve():r.startCall.reject(wrapReason(e.reason));break;case hs:e.success?r.pullCall.resolve():r.pullCall.reject(wrapReason(e.reason));break;case ds:if(!n){s.postMessage({sourceName:i,targetName:a,stream:hs,streamId:t,success:!0});break}n.desiredSize<=0&&e.desiredSize>0&&n.sinkCapability.resolve();n.desiredSize=e.desiredSize;Promise.try(n.onPull||onFn).then(function(){s.postMessage({sourceName:i,targetName:a,stream:hs,streamId:t,success:!0})},function(e){s.postMessage({sourceName:i,targetName:a,stream:hs,streamId:t,reason:wrapReason(e)})});break;case ls:assert(r,"enqueue should have stream controller");if(r.isClosed)break;r.controller.enqueue(e.chunk);break;case os:assert(r,"close should have stream controller");if(r.isClosed)break;r.isClosed=!0;r.controller.close();message_handler_assertClassBrand(ps,this,_deleteStreamController).call(this,r,t);break;case cs:assert(r,"error should have stream controller");r.controller.error(wrapReason(e.reason));message_handler_assertClassBrand(ps,this,_deleteStreamController).call(this,r,t);break;case ns:e.success?r.cancelCall.resolve():r.cancelCall.reject(wrapReason(e.reason));message_handler_assertClassBrand(ps,this,_deleteStreamController).call(this,r,t);break;case rs:if(!n)break;const o=wrapReason(e.reason);Promise.try(n.onCancel||onFn,o).then(function(){s.postMessage({sourceName:i,targetName:a,stream:ns,streamId:t,success:!0})},function(e){s.postMessage({sourceName:i,targetName:a,stream:ns,streamId:t,reason:wrapReason(e)})});n.sinkCapability.reject(o);n.isCancelled=!0;delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}async function _deleteStreamController(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]);delete this.streamControllers[t]}function binary_data_factory_classPrivateFieldInitSpec(e,t,i){(function binary_data_factory_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function binary_data_factory_classPrivateFieldGet(e,t){return e.get(function binary_data_factory_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}var gs=new WeakMap;class BaseBinaryDataFactory{constructor(e){let t=e.cMapUrl,i=void 0===t?null:t,a=e.standardFontDataUrl,s=void 0===a?null:a,r=e.wasmUrl,n=void 0===r?null:r;binary_data_factory_classPrivateFieldInitSpec(this,gs,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));this.cMapUrl=i;this.standardFontDataUrl=s;this.wasmUrl=n}async fetch(e){let t=e.kind,i=e.filename;switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:unreachable(`Not implemented: ${t}`)}const a=this[t];if(!a)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const s=`${a}${i}`;return this._fetch(s,t).catch(e=>{throw new Error(`Unable to load ${binary_data_factory_classPrivateFieldGet(gs,this)[t]} data at: ${s}`)})}async _fetch(e,t){unreachable("Abstract method `_fetch` called.")}}class DOMBinaryDataFactory extends BaseBinaryDataFactory{async _fetch(e,t){const i="cMapUrl"!==t||e.endsWith(".bcmap")?"bytes":"text",a=await fetchData(e,i);return a instanceof Uint8Array?a:stringToBytes(a)}}function canvas_factory_classPrivateFieldInitSpec(e,t,i){(function canvas_factory_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function canvas_factory_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var fs=new WeakMap;class BaseCanvasFactory{constructor(e){let t=e.enableHWA,i=void 0!==t&&t;canvas_factory_classPrivateFieldInitSpec(this,fs,!1);!function canvas_factory_classPrivateFieldSet(e,t,i){return e.set(canvas_factory_assertClassBrand(e,t),i),i}(fs,this,i)}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(e,t);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!(a=fs,s=this,a.get(canvas_factory_assertClassBrand(a,s)))})};var a,s}reset(e,t,i){let a=e.canvas;if(!a)throw new Error("Canvas is not specified");if(t<=0||i<=0)throw new Error("Invalid canvas size");a.width=t;a.height=i}destroy(e){const t=e.canvas;if(!t)throw new Error("Canvas is not specified");t.width=t.height=0;e.canvas=null;e.context=null}_createCanvas(e,t){unreachable("Abstract method `_createCanvas` called.")}}class DOMCanvasFactory extends BaseCanvasFactory{constructor(e){let t=e.ownerDocument,i=void 0===t?globalThis.document:t,a=e.enableHWA;super({enableHWA:void 0!==a&&a});this._document=i}_createCanvas(e,t){const i=this._document.createElement("canvas");i.width=e;i.height=t;return i}}function filter_factory_slicedToArray(e,t){return function filter_factory_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function filter_factory_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function filter_factory_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return filter_factory_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?filter_factory_arrayLikeToArray(e,t):void 0}}(e,t)||function filter_factory_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function filter_factory_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function filter_factory_classPrivateFieldInitSpec(e,t,i){filter_factory_checkPrivateRedeclaration(e,t),t.set(e,i)}function filter_factory_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function filter_factory_classPrivateGetter(e,t,i){return i(filter_factory_assertClassBrand(e,t))}function filter_factory_classPrivateFieldGet(e,t){return e.get(filter_factory_assertClassBrand(e,t))}function filter_factory_classPrivateFieldSet(e,t,i){return e.set(filter_factory_assertClassBrand(e,t),i),i}function filter_factory_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class BaseFilterFactory{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addKnockoutFilter(){return"none"}addHighlightHCMFilter(e,t,i,a,s){return"none"}addSelectionHCMFilter(e,t){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(){return null}destroy(){}}var ms=new WeakMap,vs=new WeakMap,ys=new WeakMap,Ps=new WeakMap,ws=new WeakMap,bs=new WeakMap,Fs=new WeakMap,Ss=new WeakSet;class DOMFilterFactory extends BaseFilterFactory{constructor(e){let t=e.docId,i=e.ownerDocument,a=void 0===i?globalThis.document:i;super();!function filter_factory_classPrivateMethodInitSpec(e,t){filter_factory_checkPrivateRedeclaration(e,t),t.add(e)}(this,Ss);filter_factory_classPrivateFieldInitSpec(this,ms,void 0);filter_factory_classPrivateFieldInitSpec(this,vs,void 0);filter_factory_classPrivateFieldInitSpec(this,ys,void 0);filter_factory_classPrivateFieldInitSpec(this,Ps,void 0);filter_factory_classPrivateFieldInitSpec(this,ws,void 0);filter_factory_classPrivateFieldInitSpec(this,bs,void 0);filter_factory_classPrivateFieldInitSpec(this,Fs,0);filter_factory_classPrivateFieldSet(Ps,this,t);filter_factory_classPrivateFieldSet(ws,this,a)}addFilter(e){var t,i;if(!e)return"none";let a=filter_factory_classPrivateGetter(Ss,this,_get_cache).get(e);if(a)return a;const s=filter_factory_slicedToArray(filter_factory_assertClassBrand(Ss,this,_createTables).call(this,e),3),r=s[0],n=s[1],o=s[2],l=1===e.length?r:`${r}${n}${o}`;a=filter_factory_classPrivateGetter(Ss,this,_get_cache).get(l);if(a){filter_factory_classPrivateGetter(Ss,this,_get_cache).set(e,a);return a}const c=`g_${filter_factory_classPrivateFieldGet(Ps,this)}_transfer_map_${filter_factory_classPrivateFieldSet(Fs,this,(t=filter_factory_classPrivateFieldGet(Fs,this),i=t++,t)),i}`,d=filter_factory_assertClassBrand(Ss,this,_createUrl).call(this,c);filter_factory_classPrivateGetter(Ss,this,_get_cache).set(e,d);filter_factory_classPrivateGetter(Ss,this,_get_cache).set(l,d);const h=filter_factory_assertClassBrand(Ss,this,_createFilter).call(this,c);filter_factory_assertClassBrand(Ss,this,_addTransferMapConversion).call(this,r,n,o,h);return d}addHCMFilter(e,t){const i=`${e}-${t}`,a="base";let s=filter_factory_classPrivateGetter(Ss,this,_get_hcmCache).get(a);if(s?.key===i)return s.url;if(s){s.filter?.remove();s.key=i;s.url="none";s.filter=null}else{s={key:i,url:"none",filter:null};filter_factory_classPrivateGetter(Ss,this,_get_hcmCache).set(a,s)}if(!e||!t)return s.url;const r=filter_factory_assertClassBrand(Ss,this,_getRGB).call(this,e);e=Util.makeHexColor(...r);const n=filter_factory_assertClassBrand(Ss,this,_getRGB).call(this,t);t=Util.makeHexColor(...n);filter_factory_classPrivateGetter(Ss,this,_get_defs).style.color="";if("#000000"===e&&"#ffffff"===t||e===t)return s.url;const o=new Array(256);for(let e=0;e<=255;e++){const t=e/255;o[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const l=o.join(","),c=`g_${filter_factory_classPrivateFieldGet(Ps,this)}_hcm_filter`,d=s.filter=filter_factory_assertClassBrand(Ss,this,_createFilter).call(this,c);filter_factory_assertClassBrand(Ss,this,_addTransferMapConversion).call(this,l,l,l,d);filter_factory_assertClassBrand(Ss,this,_addGrayConversion).call(this,d);const getSteps=(e,t)=>{const i=r[e]/255,a=n[e]/255,s=new Array(t+1);for(let e=0;e<=t;e++)s[e]=i+e/t*(a-i);return s.join(",")};filter_factory_assertClassBrand(Ss,this,_addTransferMapConversion).call(this,getSteps(0,5),getSteps(1,5),getSteps(2,5),d);s.url=filter_factory_assertClassBrand(Ss,this,_createUrl).call(this,c);return s.url}addSelectionHCMFilter(e,t){return this.addHighlightHCMFilter("selection",e,t,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return"none"!==t&&FeatureTest.platform.isFirefox?{"backdrop-filter":t,"background-color":"transparent"}:null}addAlphaFilter(e){var t,i;let a=filter_factory_classPrivateGetter(Ss,this,_get_cache).get(e);if(a)return a;const s=filter_factory_slicedToArray(filter_factory_assertClassBrand(Ss,this,_createTables).call(this,[e]),1)[0],r=`alpha_${s}`;a=filter_factory_classPrivateGetter(Ss,this,_get_cache).get(r);if(a){filter_factory_classPrivateGetter(Ss,this,_get_cache).set(e,a);return a}const n=`g_${filter_factory_classPrivateFieldGet(Ps,this)}_alpha_map_${filter_factory_classPrivateFieldSet(Fs,this,(t=filter_factory_classPrivateFieldGet(Fs,this),i=t++,t)),i}`,o=filter_factory_assertClassBrand(Ss,this,_createUrl).call(this,n);filter_factory_classPrivateGetter(Ss,this,_get_cache).set(e,o);filter_factory_classPrivateGetter(Ss,this,_get_cache).set(r,o);const l=filter_factory_assertClassBrand(Ss,this,_createFilter).call(this,n);filter_factory_assertClassBrand(Ss,this,_addTransferMapAlphaConversion).call(this,s,l);return o}addLuminosityFilter(e){var t,i;let a,s,r=filter_factory_classPrivateGetter(Ss,this,_get_cache).get(e||"luminosity");if(r)return r;if(e){a=filter_factory_slicedToArray(filter_factory_assertClassBrand(Ss,this,_createTables).call(this,[e]),1)[0];s=`luminosity_${a}`}else s="luminosity";r=filter_factory_classPrivateGetter(Ss,this,_get_cache).get(s);if(r){filter_factory_classPrivateGetter(Ss,this,_get_cache).set(e,r);return r}const n=`g_${filter_factory_classPrivateFieldGet(Ps,this)}_luminosity_map_${filter_factory_classPrivateFieldSet(Fs,this,(t=filter_factory_classPrivateFieldGet(Fs,this),i=t++,t)),i}`,o=filter_factory_assertClassBrand(Ss,this,_createUrl).call(this,n);filter_factory_classPrivateGetter(Ss,this,_get_cache).set(e,o);filter_factory_classPrivateGetter(Ss,this,_get_cache).set(s,o);const l=filter_factory_assertClassBrand(Ss,this,_createFilter).call(this,n);filter_factory_assertClassBrand(Ss,this,_addLuminosityConversion).call(this,l);e&&filter_factory_assertClassBrand(Ss,this,_addTransferMapAlphaConversion).call(this,a,l);return o}addKnockoutFilter(){var e,t;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const a=i>0?Math.min(1/i,1e6):1e6,s=`knockout_${a}`,r=filter_factory_classPrivateGetter(Ss,this,_get_cache).get(s);if(r)return r;const n=`g_${filter_factory_classPrivateFieldGet(Ps,this)}_knockout_filter_${filter_factory_classPrivateFieldSet(Fs,this,(e=filter_factory_classPrivateFieldGet(Fs,this),t=e++,e)),t}`,o=filter_factory_assertClassBrand(Ss,this,_createUrl).call(this,n);filter_factory_classPrivateGetter(Ss,this,_get_cache).set(s,o);const c=filter_factory_assertClassBrand(Ss,this,_createFilter).call(this,n),d=filter_factory_classPrivateFieldGet(ws,this).createElementNS(l,"feComponentTransfer");c.append(d);const h=filter_factory_classPrivateFieldGet(ws,this).createElementNS(l,"feFuncA");h.setAttribute("type","linear");h.setAttribute("slope",`${a}`);h.setAttribute("intercept","0");d.append(h);return o}addHighlightHCMFilter(e,t,i,a,s){const r=`${t}-${i}-${a}-${s}`;let n=filter_factory_classPrivateGetter(Ss,this,_get_hcmCache).get(e);if(n?.key===r)return n.url;if(n){n.filter?.remove();n.key=r;n.url="none";n.filter=null}else{n={key:r,url:"none",filter:null};filter_factory_classPrivateGetter(Ss,this,_get_hcmCache).set(e,n)}if(!t||!i)return n.url;const o=filter_factory_slicedToArray([t,i].map(filter_factory_assertClassBrand(Ss,this,_getRGB).bind(this)),2),l=o[0],c=o[1];let d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),h=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),u=filter_factory_slicedToArray([a,s].map(filter_factory_assertClassBrand(Ss,this,_getOpaqueTextColor).bind(this)),2),_=u[0],p=u[1];if(h<d){var g=[h,d,p,_];d=g[0];h=g[1];_=g[2];p=g[3]}filter_factory_classPrivateGetter(Ss,this,_get_defs).style.color="";const getSteps=(e,t,i)=>{const a=new Array(256),s=(h-d)/i,r=e/255,n=(t-e)/(255*i);let o=0;for(let e=0;e<=i;e++){const t=Math.round(d+e*s),i=r+e*n;for(let e=o;e<=t;e++)a[e]=i;o=t+1}for(let e=o;e<256;e++)a[e]=a[o-1];return a.join(",")},f=`g_${filter_factory_classPrivateFieldGet(Ps,this)}_hcm_${e}_filter`,m=n.filter=filter_factory_assertClassBrand(Ss,this,_createFilter).call(this,f);filter_factory_assertClassBrand(Ss,this,_addGrayConversion).call(this,m);filter_factory_assertClassBrand(Ss,this,_addTransferMapConversion).call(this,getSteps(_[0],p[0],5),getSteps(_[1],p[1],5),getSteps(_[2],p[2],5),m);n.url=filter_factory_assertClassBrand(Ss,this,_createUrl).call(this,f);return n.url}destroy(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])||!filter_factory_classPrivateFieldGet(bs,this)?.size){filter_factory_classPrivateFieldGet(ys,this)?.parentNode.parentNode.remove();filter_factory_classPrivateFieldSet(ys,this,null);filter_factory_classPrivateFieldGet(vs,this)?.clear();filter_factory_classPrivateFieldSet(vs,this,null);filter_factory_classPrivateFieldGet(bs,this)?.clear();filter_factory_classPrivateFieldSet(bs,this,null);filter_factory_classPrivateFieldSet(Fs,this,0)}}}function _get_cache(e){return filter_factory_classPrivateFieldGet(vs,e)||filter_factory_classPrivateFieldSet(vs,e,new Map)}function _get_hcmCache(e){return filter_factory_classPrivateFieldGet(bs,e)||filter_factory_classPrivateFieldSet(bs,e,new Map)}function _get_defs(e){if(!filter_factory_classPrivateFieldGet(ys,e)){const t=filter_factory_classPrivateFieldGet(ws,e).createElement("div"),i=t.style;i.colorScheme="only light";i.visibility="hidden";i.contain="strict";i.width=i.height=0;i.position="absolute";i.top=i.left=0;i.zIndex=-1;const a=filter_factory_classPrivateFieldGet(ws,e).createElementNS(l,"svg");a.setAttribute("width",0);a.setAttribute("height",0);filter_factory_classPrivateFieldSet(ys,e,filter_factory_classPrivateFieldGet(ws,e).createElementNS(l,"defs"));t.append(a);a.append(filter_factory_classPrivateFieldGet(ys,e));filter_factory_classPrivateFieldGet(ws,e).body.append(t)}return filter_factory_classPrivateFieldGet(ys,e)}function _createTables(e){if(1===e.length){const t=e[0],i=new Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255;const a=i.join(",");return[a,a,a]}const t=filter_factory_slicedToArray(e,3),i=t[0],a=t[1],s=t[2],r=new Array(256),n=new Array(256),o=new Array(256);for(let e=0;e<256;e++){r[e]=i[e]/255;n[e]=a[e]/255;o[e]=s[e]/255}return[r.join(","),n.join(","),o.join(",")]}function _createUrl(e){if(void 0===filter_factory_classPrivateFieldGet(ms,this)){filter_factory_classPrivateFieldSet(ms,this,"");const e=filter_factory_classPrivateFieldGet(ws,this).URL;e!==filter_factory_classPrivateFieldGet(ws,this).baseURI&&(isDataScheme(e)?warn('#createUrl: ignore "data:"-URL for performance reasons.'):filter_factory_classPrivateFieldSet(ms,this,updateUrlHash(e,"")))}return`url(${filter_factory_classPrivateFieldGet(ms,this)}#${e})`}function _addLuminosityConversion(e){const t=filter_factory_classPrivateFieldGet(ws,this).createElementNS(l,"feColorMatrix");t.setAttribute("type","matrix");t.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");e.append(t)}function _addGrayConversion(e){const t=filter_factory_classPrivateFieldGet(ws,this).createElementNS(l,"feColorMatrix");t.setAttribute("type","matrix");t.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");e.append(t)}function _createFilter(e){const t=filter_factory_classPrivateFieldGet(ws,this).createElementNS(l,"filter");t.setAttribute("color-interpolation-filters","sRGB");t.setAttribute("id",e);filter_factory_classPrivateGetter(Ss,this,_get_defs).append(t);return t}function _appendFeFunc(e,t,i){const a=filter_factory_classPrivateFieldGet(ws,this).createElementNS(l,t);a.setAttribute("type","discrete");a.setAttribute("tableValues",i);e.append(a)}function _addTransferMapConversion(e,t,i,a){const s=filter_factory_classPrivateFieldGet(ws,this).createElementNS(l,"feComponentTransfer");a.append(s);filter_factory_assertClassBrand(Ss,this,_appendFeFunc).call(this,s,"feFuncR",e);filter_factory_assertClassBrand(Ss,this,_appendFeFunc).call(this,s,"feFuncG",t);filter_factory_assertClassBrand(Ss,this,_appendFeFunc).call(this,s,"feFuncB",i)}function _addTransferMapAlphaConversion(e,t){const i=filter_factory_classPrivateFieldGet(ws,this).createElementNS(l,"feComponentTransfer");t.append(i);filter_factory_assertClassBrand(Ss,this,_appendFeFunc).call(this,i,"feFuncA",e)}function _getRGB(e){filter_factory_classPrivateGetter(Ss,this,_get_defs).style.color=e;return getRGB(getComputedStyle(filter_factory_classPrivateGetter(Ss,this,_get_defs)).getPropertyValue("color"))}function _getRGBA(e){filter_factory_classPrivateGetter(Ss,this,_get_defs).style.color=e;return getRGBA(getComputedStyle(filter_factory_classPrivateGetter(Ss,this,_get_defs)).getPropertyValue("color"))}function _getOpaqueTextColor(e){const t=filter_factory_slicedToArray(filter_factory_assertClassBrand(Ss,this,_getRGBA).call(this,e),4),i=t[0],a=t[1],s=t[2],r=t[3];if(1===r)return[i,a,s];const n=filter_factory_slicedToArray(filter_factory_assertClassBrand(Ss,this,_getRGB).call(this,"Canvas"),3),o=n[0],l=n[1],c=n[2];return[blend(i,o,r),blend(a,l,r),blend(s,c,r)]}function blend(e,t,i){return Math.round(i*e+(1-i)*t)}class NodeFilterFactory extends BaseFilterFactory{}class NodeCanvasFactory extends BaseCanvasFactory{_createCanvas(e,t){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,t)}}class NodeBinaryDataFactory extends BaseBinaryDataFactory{async _fetch(e,t){return async function node_utils_fetchData(e){const t=process.getBuiltinModule("fs/promises"),i=await t.readFile(e);return new Uint8Array(i)}(e)}}function webgpu_classPrivateFieldInitSpec(e,t,i){webgpu_checkPrivateRedeclaration(e,t),t.set(e,i)}function webgpu_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function webgpu_classPrivateFieldGet(e,t){return e.get(webgpu_assertClassBrand(e,t))}function webgpu_classPrivateFieldSet(e,t,i){return e.set(webgpu_assertClassBrand(e,t),i),i}function webgpu_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Cs=new WeakMap,As=new WeakMap,xs=new WeakMap,ks=new WeakMap,Es=new WeakSet;async function _initGPU(){if(!globalThis.navigator?.gpu)return!1;try{const e=await navigator.gpu.requestAdapter();if(!e)return!1;webgpu_classPrivateFieldSet(ks,this,navigator.gpu.getPreferredCanvasFormat());webgpu_classPrivateFieldSet(As,this,await e.requestDevice());return!0}catch{return!1}}const Ts=new class WebGPU{constructor(){!function webgpu_classPrivateMethodInitSpec(e,t){webgpu_checkPrivateRedeclaration(e,t),t.add(e)}(this,Es);webgpu_classPrivateFieldInitSpec(this,Cs,null);webgpu_classPrivateFieldInitSpec(this,As,null);webgpu_classPrivateFieldInitSpec(this,xs,null);webgpu_classPrivateFieldInitSpec(this,ks,null)}init(){return webgpu_classPrivateFieldGet(Cs,this)||webgpu_classPrivateFieldSet(Cs,this,webgpu_assertClassBrand(Es,this,_initGPU).call(this))}get isReady(){return null!==webgpu_classPrivateFieldGet(As,this)}loadMeshShader(){if(!webgpu_classPrivateFieldGet(As,this)||webgpu_classPrivateFieldGet(xs,this))return;const e=webgpu_classPrivateFieldGet(As,this).createShaderModule({code:"\nstruct Uniforms {\n offsetX : f32,\n offsetY : f32,\n scaleX : f32,\n scaleY : f32,\n paddedWidth : f32,\n paddedHeight : f32,\n borderSize : f32,\n _pad : f32,\n};\n\n@group(0) @binding(0) var<uniform> u : Uniforms;\n\nstruct VertexInput {\n @location(0) position : vec2<f32>,\n @location(1) color : vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) color : vec3<f32>,\n};\n\n@vertex\nfn vs_main(in : VertexInput) -> VertexOutput {\n var out : VertexOutput;\n let cx = (in.position.x + u.offsetX) * u.scaleX;\n let cy = (in.position.y + u.offsetY) * u.scaleY;\n out.position = vec4<f32>(\n ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,\n 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,\n 0.0,\n 1.0\n );\n out.color = in.color.rgb;\n return out;\n}\n\n@fragment\nfn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {\n return vec4<f32>(in.color, 1.0);\n}\n"});webgpu_classPrivateFieldSet(xs,this,webgpu_classPrivateFieldGet(As,this).createRenderPipeline({layout:"auto",vertex:{module:e,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:e,entryPoint:"fs_main",targets:[{format:webgpu_classPrivateFieldGet(ks,this)}]},primitive:{topology:"triangle-list"}}))}draw(e,t,i,a,s,r,n,o){this.loadMeshShader();const l=webgpu_classPrivateFieldGet(As,this),c=a.offsetX,d=a.offsetY,h=a.scaleX,u=a.scaleY,_=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&l.queue.writeBuffer(_,0,e);const p=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&l.queue.writeBuffer(p,0,t);const g=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(g,0,new Float32Array([c,d,h,u,r,n,o,0]));const f=l.createBindGroup({layout:webgpu_classPrivateFieldGet(xs,this).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:g}}]}),m=new OffscreenCanvas(r,n),v=m.getContext("webgpu");v.configure({device:l,format:webgpu_classPrivateFieldGet(ks,this),alphaMode:s?"opaque":"premultiplied"});const y=s?{r:s[0]/255,g:s[1]/255,b:s[2]/255,a:1}:{r:0,g:0,b:0,a:0},P=l.createCommandEncoder(),w=P.beginRenderPass({colorAttachments:[{view:v.getCurrentTexture().createView(),clearValue:y,loadOp:"clear",storeOp:"store"}]});if(i>0){w.setPipeline(webgpu_classPrivateFieldGet(xs,this));w.setBindGroup(0,f);w.setVertexBuffer(0,_);w.setVertexBuffer(1,p);w.draw(i)}w.end();l.queue.submit([P.finish()]);_.destroy();p.destroy();g.destroy();return m.transferToImageBitmap()}};function pattern_helper_slicedToArray(e,t){return function pattern_helper_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pattern_helper_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pattern_helper_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pattern_helper_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pattern_helper_arrayLikeToArray(e,t):void 0}}(e,t)||function pattern_helper_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pattern_helper_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}const Is="Fill",Gs="Stroke",Bs="Shading";function applyBoundingBox(e,t){if(!t)return;const i=t[2]-t[0],a=t[3]-t[1],s=new Path2D;s.rect(t[0],t[1],i,a);e.clip(s)}class BaseShadingPattern{isModifyingCurrentTransform(){return!1}getPattern(){unreachable("Abstract method `getPattern` called.")}}class RadialAxialShadingPattern extends BaseShadingPattern{constructor(e){super();this._type=e[1];this._bbox=e[2];this._colorStops=e[3];this._p0=e[4];this._p1=e[5];this._r0=e[6];this._r1=e[7];this.matrix=null}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}areConic(){if(!this.isRadial())return!1;const e=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return e+this._r1>this._r0&&e+this._r0>this._r1}_createGradient(e){let t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=this._p0,s=this._p1;if(i){a=a.slice();s=s.slice();Util.applyTransform(a,i);Util.applyTransform(s,i)}if("axial"===this._type)t=e.createLinearGradient(a[0],a[1],s[0],s[1]);else if("radial"===this._type){let r=this._r0,n=this._r1;if(i){const e=new Float32Array(2);Util.singularValueDecompose2dScale(i,e);r*=e[0];n*=e[0]}t=e.createRadialGradient(a[0],a[1],r,s[0],s[1],n)}for(const e of this._colorStops)t.addColorStop(e[0],e[1]);return t}_createReversedGradient(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=this._p1,a=this._p0;if(t){i=i.slice();a=a.slice();Util.applyTransform(i,t);Util.applyTransform(a,t)}let s=this._r1,r=this._r0;if(t){const e=new Float32Array(2);Util.singularValueDecompose2dScale(t,e);s*=e[0];r*=e[0]}const n=e.createRadialGradient(i[0],i[1],s,a[0],a[1],r),o=this._colorStops.map(e=>{let t=pattern_helper_slicedToArray(e,2);return[1-t[0],t[1]]}).reverse();for(const e of o){var l=pattern_helper_slicedToArray(e,2);const t=l[0],i=l[1];n.addColorStop(t,i)}return n}getPattern(e,t,i,a){let s;if(a===Gs||a===Is){if(this.isOriginBased()){let a=Util.transform(i,t.baseTransform);this.matrix&&(a=Util.transform(a,this.matrix));const s=.001,r=Math.hypot(a[0],a[1]),n=Math.hypot(a[2],a[3]),o=(a[0]*a[2]+a[1]*a[3])/(r*n);if(Math.abs(o)<s){if(!this.isRadial())return this._createGradient(e,a);if(Math.abs(r-n)<s)return this._createGradient(e,a)}}const r=t.current.getClippedPathBoundingBox(a,getCurrentTransform(e))||[0,0,0,0],n=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=t.canvasFactory.create(n,o),c=l.context;c.clearRect(0,0,c.canvas.width,c.canvas.height);c.beginPath();c.rect(0,0,c.canvas.width,c.canvas.height);c.translate(-r[0],-r[1]);i=Util.transform(i,[1,0,0,1,r[0],r[1]]);c.transform(...t.baseTransform);this.matrix&&c.transform(...this.matrix);applyBoundingBox(c,this._bbox);if(this.areConic()){c.fillStyle=this._createReversedGradient(c);c.fill()}c.fillStyle=this._createGradient(c);c.fill();s=e.createPattern(l.canvas,"no-repeat");t.canvasFactory.destroy(l);const d=new DOMMatrix(i);s.setTransform(d)}else{if(this.areConic()){e.save();applyBoundingBox(e,this._bbox);e.fillStyle=this._createReversedGradient(e);e.fillRect(-1e10,-1e10,2e10,2e10);e.restore()}applyBoundingBox(e,this._bbox);s=this._createGradient(e)}return s}}function drawTriangle(e,t,i,a,s,r,n,o){const l=t.coords,c=t.colors,d=e.data,h=4*e.width;let u;if(l[2*i+1]>l[2*a+1]){u=i;i=a;a=u;u=r;r=n;n=u}if(l[2*a+1]>l[2*s+1]){u=a;a=s;s=u;u=n;n=o;o=u}if(l[2*i+1]>l[2*a+1]){u=i;i=a;a=u;u=r;r=n;n=u}const _=(l[2*i]+t.offsetX)*t.scaleX,p=(l[2*i+1]+t.offsetY)*t.scaleY,g=(l[2*a]+t.offsetX)*t.scaleX,f=(l[2*a+1]+t.offsetY)*t.scaleY,m=(l[2*s]+t.offsetX)*t.scaleX,v=(l[2*s+1]+t.offsetY)*t.scaleY;if(p>=v)return;const y=c[4*r],P=c[4*r+1],w=c[4*r+2],b=c[4*n],S=c[4*n+1],C=c[4*n+2],A=c[4*o],x=c[4*o+1],k=c[4*o+2],E=Math.round(p),T=Math.round(v);let I,G,B,M,D,L,O,R;for(let e=E;e<=T;e++){if(e<f){const t=e<p?0:(p-e)/(p-f);I=_-(_-g)*t;G=y-(y-b)*t;B=P-(P-S)*t;M=w-(w-C)*t}else{let t;t=e>v?1:f===v?0:(f-e)/(f-v);I=g-(g-m)*t;G=b-(b-A)*t;B=S-(S-x)*t;M=C-(C-k)*t}let t;t=e<p?0:e>v?1:(p-e)/(p-v);D=_-(_-m)*t;L=y-(y-A)*t;O=P-(P-x)*t;R=w-(w-k)*t;const i=Math.round(Math.min(I,D)),a=Math.round(Math.max(I,D));let s=h*e+4*i;for(let e=i;e<=a;e++){t=(I-e)/(I-D);t<0?t=0:t>1&&(t=1);d[s++]=G-(G-L)*t|0;d[s++]=B-(B-O)*t|0;d[s++]=M-(M-R)*t|0;d[s++]=255}}}class MeshShadingPattern extends BaseShadingPattern{constructor(e){super();this._posData=e[2];this._colData=e[3];this._vertexCount=e[4];this._bounds=e[5];this._bbox=e[6];this._background=e[7];this.matrix=null;!function loadMeshShader(){Ts.loadMeshShader()}()}_createMeshCanvas(e,t,i){const a=Math.floor(this._bounds[0]),s=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-a,n=Math.ceil(this._bounds[3])-s,o=Math.min(Math.ceil(Math.abs(r*e[0]*1.1)),3e3)||1,l=Math.min(Math.ceil(Math.abs(n*e[1]*1.1)),3e3)||1,c=r?r/o:1,d=n?n/l:1,h={coords:this._posData,colors:this._colData,offsetX:-a,offsetY:-s,scaleX:1/c,scaleY:1/d},u=o+4,_=l+4,p=i.create(u,_);if(function isGPUReady(){return Ts.isReady}()&&this._vertexCount>48)p.context.drawImage(function drawMeshWithGPU(e,t,i,a,s,r,n,o){return Ts.draw(e,t,i,a,s,r,n,o)}(this._posData,this._colData,this._vertexCount,h,t,u,_,2),0,0);else{const e=p.context.createImageData(o,l);if(t){const i=e.data;for(let e=0,a=i.length;e<a;e+=4){i[e]=t[0];i[e+1]=t[1];i[e+2]=t[2];i[e+3]=255}}for(let t=0,i=this._vertexCount;t<i;t+=3)drawTriangle(e,h,t,t+1,t+2,t,t+1,t+2);p.context.putImageData(e,2,2)}return{canvas:p.canvas,offsetX:a-2*c,offsetY:s-2*d,scaleX:c,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(e,t,i,a){applyBoundingBox(e,this._bbox);const s=new Float32Array(2);if(a===Bs)Util.singularValueDecompose2dScale(getCurrentTransform(e),s);else if(this.matrix){Util.singularValueDecompose2dScale(this.matrix,s);const e=pattern_helper_slicedToArray(s,2),i=e[0],a=e[1];Util.singularValueDecompose2dScale(t.baseTransform,s);s[0]*=i;s[1]*=a}else Util.singularValueDecompose2dScale(t.baseTransform,s);const r=this._createMeshCanvas(s,a===Bs?null:this._background,t.canvasFactory);if(a!==Bs){e.setTransform(...t.baseTransform);this.matrix&&e.transform(...this.matrix)}e.translate(r.offsetX,r.offsetY);e.scale(r.scaleX,r.scaleY);const n=e.createPattern(r.canvas,"no-repeat");t.canvasFactory.destroy(r);return n}}class DummyShadingPattern extends BaseShadingPattern{getPattern(){return"hotpink"}}const Ms=1,Ds=2;class TilingPattern{constructor(e,t,i,a){this.color=e[1];this.operatorList=e[2];this.matrix=e[3];this.bbox=e[4];this.xstep=e[5];this.ystep=e[6];this.paintType=e[7];this.tilingType=e[8];this.needsIsolation=e[9]??!0;this.ctx=t;this.canvasGraphicsFactory=i;this.baseTransform=a;this.patternBaseMatrix=this.matrix?Util.transform(a,this.matrix):a}canSkipPatternCanvas(e){let t=pattern_helper_slicedToArray(e,4),i=t[0],a=t[1],s=t[2],r=t[3];const n=pattern_helper_slicedToArray(this.bbox,4),o=n[0],l=n[1],c=n[2],d=n[3],h=Math.abs(this.xstep),u=Math.abs(this.ystep);if(i>h+1e-6||a>u+1e-6)return null;const _=Math.floor((s-c)/h)+1,p=Math.ceil((s+i-o)/h)-1,g=Math.floor((r-d)/u)+1,f=Math.ceil((r+a-l)/u)-1;return p<=_&&f<=g?[_,g]:null}updatePatternDims(e,t){const i=Util.inverseTransform(this.patternBaseMatrix),a=[e[0],e[1]],s=[e[2],e[3]];Util.applyTransform(a,i);Util.applyTransform(s,i);t[0]=Math.abs(s[0]-a[0]);t[1]=Math.abs(s[1]-a[1]);t[2]=Math.min(a[0],s[0]);t[3]=Math.min(a[1],s[1])}_renderTileCanvas(e,t,i,a){const s=pattern_helper_slicedToArray(this.bbox,4),r=s[0],n=s[1],o=s[2],l=s[3],c=e.canvasFactory.create(i.size,a.size),d=c.context,h=this.canvasGraphicsFactory.createCanvasGraphics(d,t);h.groupLevel=e.groupLevel;this.setFillAndStrokeStyleToContext(h,this.paintType,this.color);d.translate(-i.scale*r,-a.scale*n);h.transform(0,i.scale,0,0,a.scale,0,0);d.save();h.dependencyTracker?.save();this.clipBbox(h,r,n,o,l);h.baseTransform=getCurrentTransform(h.ctx);h.executeOperatorList(this.operatorList);h.endDrawing();h.dependencyTracker?.restore();d.restore();return c}_getCombinedScales(){const e=new Float32Array(2);Util.singularValueDecompose2dScale(this.matrix,e);const t=pattern_helper_slicedToArray(e,2),i=t[0],a=t[1];Util.singularValueDecompose2dScale(this.baseTransform,e);return[i*e[0],a*e[1]]}drawPattern(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=pattern_helper_slicedToArray(arguments.length>3?arguments[3]:void 0,2),s=a[0],r=a[1],n=arguments.length>4?arguments[4]:void 0;const o=pattern_helper_slicedToArray(this.bbox,4),l=o[0],c=o[1],d=o[2],h=o[3],u=e.dependencyTracker;u&&(e.dependencyTracker=new CanvasNestedDependencyTracker(u,n));e.save();i?e.ctx.clip(t,"evenodd"):e.ctx.clip(t);e.ctx.setTransform(...this.patternBaseMatrix);e.ctx.translate(s*this.xstep,r*this.ystep);if(this.needsIsolation||1!==e.ctx.globalAlpha||"source-over"!==e.ctx.globalCompositeOperation||e.inSMaskMode){const t=d-l,i=h-c,a=pattern_helper_slicedToArray(this._getCombinedScales(),2),s=a[0],r=a[1],o=this.getSizeAndScale(t,this.ctx.canvas.width,s),u=this.getSizeAndScale(i,this.ctx.canvas.height,r),_=this._renderTileCanvas(e,n,o,u);e.ctx.drawImage(_.canvas,l,c,t,i);e.canvasFactory.destroy(_)}else{this.setFillAndStrokeStyleToContext(e,this.paintType,this.color);this.clipBbox(e,l,c,d,h);e.baseTransformStack.push(e.baseTransform);e.baseTransform=getCurrentTransform(e.ctx);e.executeOperatorList(this.operatorList);e.baseTransform=e.baseTransformStack.pop()}e.restore();u&&(e.dependencyTracker=u)}createPatternCanvas(e,t){const i=pattern_helper_slicedToArray(this.bbox,4),a=i[0],s=i[1],r=i[2]-a,n=i[3]-s;let o=this.xstep,l=this.ystep;o=Math.abs(o);l=Math.abs(l);info("TilingType: "+this.tilingType);const c=pattern_helper_slicedToArray(this._getCombinedScales(),2),d=c[0],h=c[1];let u=r,_=n,p=!1,g=!1;Math.ceil(o*d)>=Math.ceil(r*d)?u=o:p=!0;Math.ceil(l*h)>=Math.ceil(n*h)?_=l:g=!0;const f=this.getSizeAndScale(u,this.ctx.canvas.width,d),m=this.getSizeAndScale(_,this.ctx.canvas.height,h),v=this._renderTileCanvas(e,t,f,m);if(p||g){const t=v.canvas;p&&(u=o);g&&(_=l);const i=this.getSizeAndScale(u,this.ctx.canvas.width,d),c=this.getSizeAndScale(_,this.ctx.canvas.height,h),f=i.size,m=c.size,y=e.canvasFactory.create(f,m),P=y.context,w=p?Math.floor(r/o):0,b=g?Math.floor(n/l):0;for(let e=0;e<=w;e++)for(let i=0;i<=b;i++)P.drawImage(t,f*e,m*i,f,m,0,0,f,m);e.canvasFactory.destroy(v);return{canvas:y.canvas,canvasEntry:y,scaleX:i.scale,scaleY:c.scale,offsetX:a,offsetY:s}}return{canvas:v.canvas,canvasEntry:v,scaleX:f.scale,scaleY:m.scale,offsetX:a,offsetY:s}}getSizeAndScale(e,t,i){const a=Math.max(TilingPattern.MAX_PATTERN_SIZE,t);let s=Math.ceil(e*i);s>=a?s=a:i=s/e;return{scale:i,size:s}}clipBbox(e,t,i,a,s){const r=a-t,n=s-i,o=new Path2D;o.rect(t,i,r,n);Util.axialAlignedBoundingBox([t,i,a,s],getCurrentTransform(e.ctx),e.current.minMax);e.ctx.clip(o);e.current.updateClipFromPath()}setFillAndStrokeStyleToContext(e,t,i){const a=e.ctx,s=e.current;s.patternFill=s.patternStroke=!1;switch(t){case Ms:const e=this.ctx,r=e.fillStyle,n=e.strokeStyle;a.fillStyle=s.fillColor=r;a.strokeStyle=s.strokeColor=n;break;case Ds:a.fillStyle=a.strokeStyle=i;s.fillColor=s.strokeColor=i;break;default:throw new FormatError(`Unsupported paint type: ${t}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,t,i,a,s){const r=a!==Bs?Util.transform(i,this.patternBaseMatrix):i,n=this.createPatternCanvas(t,s);let o=new DOMMatrix(r);o=o.translate(n.offsetX,n.offsetY);o=o.scale(1/n.scaleX,1/n.scaleY);const l=e.createPattern(n.canvas,"repeat");t.canvasFactory.destroy(n.canvasEntry);l.setTransform(o);return l}}!function pattern_helper_defineProperty(e,t,i){return(t=function pattern_helper_toPropertyKey(e){var t=function pattern_helper_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(TilingPattern,"MAX_PATTERN_SIZE",3e3);function image_utils_slicedToArray(e,t){return function image_utils_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function image_utils_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function image_utils_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return image_utils_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?image_utils_arrayLikeToArray(e,t):void 0}}(e,t)||function image_utils_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function image_utils_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function convertBlackAndWhiteToRGBA(e){let t=e.src,i=e.srcPos,a=void 0===i?0:i,s=e.dest,r=e.width,n=e.height,o=e.nonBlackColor,l=void 0===o?4294967295:o,c=e.inverseDecode;const d=FeatureTest.isLittleEndian?4278190080:255,h=image_utils_slicedToArray(void 0!==c&&c?[l,d]:[d,l],2),u=h[0],_=r>>3,p=7&r,g=u^h[1],f=t.length;s=new Uint32Array(s.buffer);let m=0;for(let e=0;e<n;++e){for(const e=a+_;a<e;++a,m+=8){const e=t[a];s[m]=u^-(e>>7&1)&g;s[m+1]=u^-(e>>6&1)&g;s[m+2]=u^-(e>>5&1)&g;s[m+3]=u^-(e>>4&1)&g;s[m+4]=u^-(e>>3&1)&g;s[m+5]=u^-(e>>2&1)&g;s[m+6]=u^-(e>>1&1)&g;s[m+7]=u^-(1&e)&g}if(0===p)continue;const e=a<f?t[a++]:255;for(let t=0;t<p;++t,++m)s[m]=u^-(e>>7-t&1)&g}return{srcPos:a,destPos:m}}function canvas_classPrivateFieldInitSpec(e,t,i){canvas_checkPrivateRedeclaration(e,t),t.set(e,i)}function canvas_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function canvas_classPrivateFieldSet(e,t,i){return e.set(canvas_assertClassBrand(e,t),i),i}function canvas_classPrivateFieldGet(e,t){return e.get(canvas_assertClassBrand(e,t))}function canvas_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function canvas_defineProperty(e,t,i){return(t=function canvas_toPropertyKey(e){var t=function canvas_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function canvas_slicedToArray(e,t){return function canvas_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function canvas_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function canvas_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return canvas_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?canvas_arrayLikeToArray(e,t):void 0}}(e,t)||function canvas_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function canvas_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}const Ls=16,Os=new DOMMatrix,Rs=new Float32Array(2);function mirrorContextOperations(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");const i=new Map;for(const a of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const s=e[a];if("function"==typeof s&&"function"==typeof t[a]){i.set(a,s);e[a]=function(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];t[a](...i);return s.apply(this,i)}}}e._removeMirroring=()=>{for(const a of i){var t=canvas_slicedToArray(a,2);const i=t[0],s=t[1];e[i]=s}delete e._removeMirroring}}function drawImageAtIntegerCoords(e,t,i,a,s,r,n,o,l,c){const d=canvas_slicedToArray(getCurrentTransform(e),6),h=d[0],u=d[1],_=d[2],p=d[3],g=d[4],f=d[5];if(0===u&&0===_){const d=n*h+g,m=Math.round(d),v=o*p+f,y=Math.round(v),P=(n+l)*h+g,w=Math.abs(Math.round(P)-m)||1,b=(o+c)*p+f,S=Math.abs(Math.round(b)-y)||1;e.setTransform(Math.sign(h),0,0,Math.sign(p),m,y);e.drawImage(t,i,a,s,r,0,0,w,S);e.setTransform(h,u,_,p,g,f);return[w,S]}if(0===h&&0===p){const d=o*_+g,m=Math.round(d),v=n*u+f,y=Math.round(v),P=(o+c)*_+g,w=Math.abs(Math.round(P)-m)||1,b=(n+l)*u+f,S=Math.abs(Math.round(b)-y)||1;e.setTransform(0,Math.sign(u),Math.sign(_),0,m,y);e.drawImage(t,i,a,s,r,0,0,S,w);e.setTransform(h,u,_,p,g,f);return[S,w]}e.drawImage(t,i,a,s,r,n,o,l,c);return[Math.hypot(h,u)*l,Math.hypot(_,p)*c]}class CanvasExtraState{constructor(e,t){canvas_defineProperty(this,"alphaIsShape",!1);canvas_defineProperty(this,"fontSize",0);canvas_defineProperty(this,"fontSizeScale",1);canvas_defineProperty(this,"textMatrix",null);canvas_defineProperty(this,"textMatrixScale",1);canvas_defineProperty(this,"fontMatrix",n);canvas_defineProperty(this,"leading",0);canvas_defineProperty(this,"x",0);canvas_defineProperty(this,"y",0);canvas_defineProperty(this,"lineX",0);canvas_defineProperty(this,"lineY",0);canvas_defineProperty(this,"charSpacing",0);canvas_defineProperty(this,"wordSpacing",0);canvas_defineProperty(this,"textHScale",1);canvas_defineProperty(this,"textRenderingMode",S);canvas_defineProperty(this,"textRise",0);canvas_defineProperty(this,"fillColor","#000000");canvas_defineProperty(this,"strokeColor","#000000");canvas_defineProperty(this,"tilingPatternDims",null);canvas_defineProperty(this,"patternFill",!1);canvas_defineProperty(this,"patternStroke",!1);canvas_defineProperty(this,"fillAlpha",1);canvas_defineProperty(this,"strokeAlpha",1);canvas_defineProperty(this,"lineWidth",1);canvas_defineProperty(this,"activeSMask",null);canvas_defineProperty(this,"transferMaps","none");canvas_defineProperty(this,"minMax",r.slice());this.clipBox=new Float32Array([0,0,e,t])}clone(){const e=Object.create(this);e.clipBox=this.clipBox.slice();e.minMax=this.minMax.slice();e.tilingPatternDims=this.tilingPatternDims?.slice();return e}getPathBoundingBox(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Is,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=this.minMax.slice();if(e===Gs){t||unreachable("Stroke bounding box must include transform.");Util.singularValueDecompose2dScale(t,Rs);const e=Rs[0]*this.lineWidth/2,a=Rs[1]*this.lineWidth/2;i[0]-=e;i[1]-=a;i[2]+=e;i[3]+=a}return i}updateClipFromPath(){const e=Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0);this.minMax.set(r,0)}getClippedPathBoundingBox(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Is,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function putBinaryImageData(e,t){if(t instanceof ImageData){e.putImageData(t,0,0);return}const i=t.height,a=t.width,s=i%Ls,r=(i-s)/Ls,n=0===s?r:r+1,o=e.createImageData(a,Ls);let l,c=0;const d=t.data,h=o.data;let u,_,p,g;if(t.kind===T.GRAYSCALE_1BPP){const t=d.byteLength,i=new Uint32Array(h.buffer,0,h.byteLength>>2),g=i.length,f=a+7>>3,m=4294967295,v=FeatureTest.isLittleEndian?4278190080:255;for(u=0;u<n;u++){p=u<r?Ls:s;l=0;for(_=0;_<p;_++){const e=t-c;let s=0;const r=e>f?a:8*e-7,n=-8&r;let o=0,h=0;for(;s<n;s+=8){h=d[c++];i[l++]=128&h?m:v;i[l++]=64&h?m:v;i[l++]=32&h?m:v;i[l++]=16&h?m:v;i[l++]=8&h?m:v;i[l++]=4&h?m:v;i[l++]=2&h?m:v;i[l++]=1&h?m:v}for(;s<r;s++){if(0===o){h=d[c++];o=128}i[l++]=h&o?m:v;o>>=1}}for(;l<g;)i[l++]=0;e.putImageData(o,0,u*Ls)}}else if(t.kind===T.RGBA_32BPP){_=0;g=a*Ls*4;for(u=0;u<r;u++){h.set(d.subarray(c,c+g));c+=g;e.putImageData(o,0,_);_+=Ls}if(u<n){g=a*s*4;h.set(d.subarray(c,c+g));e.putImageData(o,0,_)}}else{if(t.kind!==T.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);p=Ls;g=a*p;for(u=0;u<n;u++){if(u>=r){p=s;g=a*p}l=0;for(_=g;_--;){h[l++]=d[c++];h[l++]=d[c++];h[l++]=d[c++];h[l++]=255}e.putImageData(o,0,u*Ls)}}}function putBinaryImageMask(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}const i=t.height,a=t.width,s=i%Ls,r=(i-s)/Ls,n=0===s?r:r+1,o=e.createImageData(a,Ls);let l=0;const c=t.data,d=o.data;for(let t=0;t<n;t++){l=convertBlackAndWhiteToRGBA({src:c,srcPos:l,dest:d,width:a,height:t<r?Ls:s,nonBlackColor:0}).srcPos;e.putImageData(o,0,t*Ls)}}function copyCtxState(e,t){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const a of i)void 0!==e[a]&&(t[a]=e[a]);if(void 0!==e.setLineDash){t.setLineDash(e.getLineDash());t.lineDashOffset=e.lineDashOffset}}function resetCtxToDefault(e){e.strokeStyle=e.fillStyle="#000000";e.fillRule="nonzero";e.globalAlpha=1;e.lineWidth=1;e.lineCap="butt";e.lineJoin="miter";e.miterLimit=10;e.globalCompositeOperation="source-over";e.font="10px sans-serif";if(void 0!==e.setLineDash){e.setLineDash([]);e.lineDashOffset=0}const t=e.filter;"none"!==t&&""!==t&&(e.filter="none")}function getImageSmoothingEnabled(e,t){if(t)return!0;Util.singularValueDecompose2dScale(e,Rs);const i=Math.fround(OutputScale.pixelRatio*PixelsPerInch.PDF_TO_CSS_UNITS);return Rs[0]<=i&&Rs[1]<=i}const Ns=["butt","round","square"],js=["miter","round","bevel"],Ws={},Us={};var Vs=new WeakMap,Hs=new WeakMap,zs=new WeakMap,$s=new WeakMap,qs=new WeakMap,Xs=new WeakMap,Ks=new WeakMap,Ys=new WeakMap,Zs=new WeakMap,Js=new WeakMap,Qs=new WeakSet;class CanvasGraphics{constructor(e,t,i,a,s,r,n,o,l,c){let d=r.optionalContentConfig,h=r.markedContentStack,u=void 0===h?null:h;!function canvas_classPrivateMethodInitSpec(e,t){canvas_checkPrivateRedeclaration(e,t),t.add(e)}(this,Qs);canvas_classPrivateFieldInitSpec(this,Vs,0);canvas_classPrivateFieldInitSpec(this,Hs,0);canvas_classPrivateFieldInitSpec(this,zs,null);canvas_classPrivateFieldInitSpec(this,$s,null);canvas_classPrivateFieldInitSpec(this,qs,null);canvas_classPrivateFieldInitSpec(this,Xs,null);canvas_classPrivateFieldInitSpec(this,Ks,1);canvas_classPrivateFieldInitSpec(this,Ys,void 0);canvas_classPrivateFieldInitSpec(this,Zs,null);canvas_classPrivateFieldInitSpec(this,Js,[]);this.ctx=e;this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.stateStack=[];this.pendingClip=null;this.pendingEOFill=!1;this.commonObjs=t;this.objs=i;this.canvasFactory=a;this.filterFactory=s;this.groupStack=[];this.baseTransform=null;this.baseTransformStack=[];this.groupLevel=0;this.smaskStack=[];this.tempSMask=null;this.smaskGroupCanvases=[];this.smaskPreparedEntry=null;this.smaskPreparedFor=null;this.smaskPreparedOffsetX=0;this.smaskPreparedOffsetY=0;this.smaskPreparedOOBAlpha=null;this.suspendedCtx=null;this.contentVisible=!0;this.markedContentStack=u||[];this.optionalContentConfig=d;this.cachedPatterns=new Map;this.annotationCanvasMap=n;this.viewportScale=1;this.outputScaleX=1;this.outputScaleY=1;this.pageColors=o;this._cachedScaleForStroking=[-1,0];this._cachedGetSinglePixelWidth=null;this._cachedBitmapsMap=new Map;this.dependencyTracker=l??null;this.imagesTracker=c??null}getObject(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if("string"==typeof t){this.dependencyTracker?.recordNamedDependency(e,t);return t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t)}return i}beginDrawing(e){let t=e.transform,i=e.viewport,a=e.transparency,s=void 0!==a&&a,r=e.background,n=void 0===r?null:r;const o=this.ctx.canvas.width,l=this.ctx.canvas.height,c=this.ctx.fillStyle;this.ctx.fillStyle=n||"#ffffff";this.ctx.fillRect(0,0,o,l);this.ctx.fillStyle=c;if(s){const e=this.transparentCanvasEntry=this.canvasFactory.create(o,l);this.compositeCtx=this.ctx;this.transparentCanvas=e.canvas;this.ctx=e.context;this.ctx.save();this.ctx.transform(...getCurrentTransform(this.compositeCtx))}this.ctx.save();resetCtxToDefault(this.ctx);if(t){this.ctx.transform(...t);this.outputScaleX=t[0];this.outputScaleY=t[3]}this.ctx.transform(...i.transform);this.viewportScale=i.scale;this.baseTransform=getCurrentTransform(this.ctx)}executeOperatorList(e,t,i,a,s){const r=e.argsArray,n=e.fnArray;let o=t||0;const l=r.length;if(l===o)return o;const c=l-o>10&&"function"==typeof i,d=c?Date.now()+15:0;let h=0;const u=this.commonObjs,_=this.objs;let p,g;for(;;){if(void 0!==a){if(o===a.nextBreakPoint){a.breakIt(o,i);return o}if(a.shouldSkip(o)){if(++o===l)return o;continue}}if(!s||s(o)){p=n[o];g=r[o]??null;if(p!==R.dependency)null===g?this[p](o):this[p](o,...g);else for(const e of g){this.dependencyTracker?.recordNamedData(e,o);const t=e.startsWith("g_")?u:_;if(!t.has(e)){t.get(e,i);return o}}}o++;if(o===l)return o;if(c&&++h>10){if(Date.now()>d){i();return o}h=0}}}endDrawing(){canvas_assertClassBrand(Qs,this,_restoreInitialState).call(this);for(const e of this.smaskGroupCanvases)this.canvasFactory.destroy(e);this.smaskGroupCanvases.length=0;this._clearPreparedSMask();this.tempSMask=null;this.smaskStack.length=0;for(const e of canvas_classPrivateFieldGet(Js,this))canvas_assertClassBrand(Qs,this,_destroyKnockoutPools).call(this,e);canvas_classPrivateFieldGet(Js,this).length=0;canvas_classPrivateFieldSet(zs,this,null);canvas_classPrivateFieldSet($s,this,null);canvas_classPrivateFieldSet(qs,this,null);canvas_classPrivateFieldSet(Xs,this,null);canvas_classPrivateFieldSet(Ks,this,1);canvas_classPrivateFieldSet(Zs,this,null);canvas_classPrivateFieldSet(Hs,this,0);canvas_classPrivateFieldSet(Vs,this,0);this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear();canvas_assertClassBrand(Qs,this,_drawFilter).call(this)}_scaleImage(e,t){const i=e.width??e.displayWidth,a=e.height??e.displayHeight,s=[];let r=Math.max(Math.hypot(t[0],t[1]),1),n=Math.max(Math.hypot(t[2],t[3]),1),o=i,l=a;for(;r>2&&o>1||n>2&&l>1;){let e=o,t=l;if(r>2&&o>1){e=Math.ceil(o/2);r/=o/e}if(n>2&&l>1){t=Math.ceil(l/2);n/=l/t}s.push({newWidth:e,newHeight:t});o=e;l=t}if(0===s.length)return{img:e,paintWidth:i,paintHeight:a,tmpCanvas:null};if(1===s.length){const t=s[0],r=t.newWidth,n=t.newHeight,o=this.canvasFactory.create(r,n);o.context.drawImage(e,0,0,i,a,0,0,r,n);return{img:o.canvas,paintWidth:r,paintHeight:n,tmpCanvas:o}}let c=this.canvasFactory.create(1,1),d=this.canvasFactory.create(1,1),h=i,u=a,_=e;for(const e of s){const t=e.newWidth,i=e.newHeight;this.canvasFactory.reset(d,t,i);d.context.drawImage(_,0,0,h,u,0,0,t,i);var p=[d,c];c=p[0];d=p[1];_=c.canvas;h=t;u=i}this.canvasFactory.destroy(d);return{img:c.canvas,paintWidth:h,paintHeight:u,tmpCanvas:c}}_createMaskCanvas(e,t){const i=this.ctx,a=t.width,s=t.height,n=this.current.fillColor,o=this.current.patternFill,l=getCurrentTransform(i);let c,d,h,u;if((t.bitmap||t.data)&&t.count>1){const i=t.bitmap||t.data.buffer;d=JSON.stringify(o?l:[l.slice(0,4),n]);c=this._cachedBitmapsMap.getOrInsertComputed(i,makeMap);const a=c.get(d);if(a&&!o){const t=Math.round(Math.min(l[0],l[2])+l[4]),i=Math.round(Math.min(l[1],l[3])+l[5]);this.dependencyTracker?.recordDependencies(e,Ia);return{canvas:a,offsetX:t,offsetY:i}}h=a}if(!h){u=this.canvasFactory.create(a,s);putBinaryImageMask(u.context,t)}let _=Util.transform(l,[1/a,0,0,-1/s,0,0]);_=Util.transform(_,[1,0,0,1,0,-s]);const p=r.slice();Util.axialAlignedBoundingBox([0,0,a,s],_,p);const g=canvas_slicedToArray(p,4),f=g[0],m=g[1],v=g[2],y=g[3],P=Math.round(v-f)||1,w=Math.round(y-m)||1,b=this.canvasFactory.create(P,w),S=b.context,C=f,A=m;S.translate(-C,-A);S.transform(..._);let x=null;if(!h){const e=this._scaleImage(u.canvas,getCurrentTransformInverse(S));h=e.img;x=e.tmpCanvas;if(h!==u.canvas){this.canvasFactory.destroy(u);u=null}if(c&&o){c.set(d,h);x=null;u=null}}S.imageSmoothingEnabled=getImageSmoothingEnabled(getCurrentTransform(S),t.interpolate);drawImageAtIntegerCoords(S,h,0,0,h.width,h.height,0,0,a,s);x&&this.canvasFactory.destroy(x);u&&this.canvasFactory.destroy(u);S.globalCompositeOperation="source-in";const k=Util.transform(getCurrentTransformInverse(S),[1,0,0,1,-C,-A]);S.fillStyle=o?n.getPattern(i,this,k,Is,e):n;S.fillRect(0,0,a,s);c&&!o&&c.set(d,b.canvas);this.dependencyTracker?.recordDependencies(e,Ia);return{canvas:b.canvas,canvasEntry:c&&!o?null:b,offsetX:Math.round(C),offsetY:Math.round(A)}}setLineWidth(e,t){this.dependencyTracker?.recordSimpleData("lineWidth",e);t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1);this.current.lineWidth=t;this.ctx.lineWidth=t}setLineCap(e,t){this.dependencyTracker?.recordSimpleData("lineCap",e);this.ctx.lineCap=Ns[t]}setLineJoin(e,t){this.dependencyTracker?.recordSimpleData("lineJoin",e);this.ctx.lineJoin=js[t]}setMiterLimit(e,t){this.dependencyTracker?.recordSimpleData("miterLimit",e);this.ctx.miterLimit=t}setDash(e,t,i){this.dependencyTracker?.recordSimpleData("dash",e);const a=this.ctx;if(void 0!==a.setLineDash){a.setLineDash(t);a.lineDashOffset=i}}setRenderingIntent(e,t){}setFlatness(e,t){}setGState(e,t){for(const a of t){var i=canvas_slicedToArray(a,2);const t=i[0],s=i[1];switch(t){case"LW":this.setLineWidth(e,s);break;case"LC":this.setLineCap(e,s);break;case"LJ":this.setLineJoin(e,s);break;case"ML":this.setMiterLimit(e,s);break;case"D":this.setDash(e,s[0],s[1]);break;case"RI":this.setRenderingIntent(e,s);break;case"FL":this.setFlatness(e,s);break;case"Font":this.setFont(e,s[0],s[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",e);this.current.strokeAlpha=s;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",e);this.ctx.globalAlpha=this.current.fillAlpha=s;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",e);this.ctx.globalCompositeOperation=s;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",e);this.current.activeSMask=s?this.tempSMask:null;this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation);this.tempSMask=null;this.checkSMaskState(e);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",e);this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){if(this.smaskPreparedEntry){this.canvasFactory.destroy(this.smaskPreparedEntry);this.smaskPreparedEntry=null}this.smaskPreparedFor=null;this.smaskPreparedOffsetX=0;this.smaskPreparedOffsetY=0;this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(e){if(e!==this.smaskPreparedFor){this._clearPreparedSMask();this._prepareSMaskCanvas(e)}}checkSMaskState(e){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode(e):!this.current.activeSMask&&t?this.endSMaskMode():this.current.activeSMask&&t&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(e){const t=e.canvas,i=e.subtype,a=e.backdrop,s=e.transferMap,r="Luminosity"===i||"Alpha"===i&&s;if(!(r||"Luminosity"===i&&a)){this.smaskPreparedFor=e;return}let n;if("Luminosity"===i&&a){const e=canvas_slicedToArray(getRGBA(a),3),t=e[0],i=e[1],r=e[2],o=Math.round(.3*t+.59*i+.11*r);n=s?.[o]??o}else n=s?.[0]??0;const o=this.ctx.canvas,l=o.width,c=o.height,d=l*c<4*(t.width*t.height),h=r?{url:"Alpha"===i?this.filterFactory.addAlphaFilter(s):this.filterFactory.addLuminosityFilter(s),subtype:i,transferMap:s}:null,u="Luminosity"===i?a:null;let _,p,g;if(d){_=this._bakeSMaskCanvas(t,e.offsetX,e.offsetY,l,c,u,h);p=0;g=0}else{_=this._bakeSMaskCanvas(t,0,0,t.width,t.height,u,h);p=e.offsetX;g=e.offsetY}this.smaskPreparedEntry=_;this.smaskPreparedFor=e;this.smaskPreparedOffsetX=p;this.smaskPreparedOffsetY=g;this.smaskPreparedOOBAlpha=d||0===n?null:n}_bakeSMaskCanvas(e,t,i,a,s,r,n){r||n||unreachable("_bakeSMaskCanvas with neither backdrop nor filter");const o=this.canvasFactory.create(a,s),l=o.context;l.drawImage(e,t,i);if(r){l.globalCompositeOperation="destination-atop";l.fillStyle=r;l.fillRect(0,0,a,s)}if(!n)return o;const c=this.canvasFactory.create(a,s),d=c.context;d.filter=n.url;const h=FeatureTest.isCanvasFilterSupported&&"none"!==d.filter&&""!==d.filter;d.drawImage(o.canvas,0,0);FeatureTest.isCanvasFilterSupported&&(d.filter="none");if(!h){const e=d.getImageData(0,0,a,s),t=e.data,i=n.transferMap;if("Luminosity"===n.subtype)for(let e=0,a=t.length;e<a;e+=4){const a=.3*t[e]+.59*t[e+1]+.11*t[e+2]+.5|0;t[e]=t[e+1]=t[e+2]=0;t[e+3]=i?.[a]??a}else for(let e=3,a=t.length;e<a;e+=4)t[e]=i[t[e]];d.putImageData(e,0,0)}this.canvasFactory.destroy(o);return c}beginSMaskMode(e){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas,i=t.width,a=t.height,s=this.canvasFactory.create(i,a);this.smaskScratchCanvas=s;this.suspendedCtx=this.ctx;const r=this.ctx=s.context;r.setTransform(this.suspendedCtx.getTransform());copyCtxState(this.suspendedCtx,r);mirrorContextOperations(r,this.suspendedCtx);this._ensurePreparedSMask(this.current.activeSMask);this.setGState(e,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring();copyCtxState(this.ctx,this.suspendedCtx);this.ctx=this.suspendedCtx;this.suspendedCtx=null;this.canvasFactory.destroy(this.smaskScratchCanvas);this.smaskScratchCanvas=null;this._clearPreparedSMask()}compose(e){if(!this.current.activeSMask)return;e=e?[Math.floor(e[0]),Math.floor(e[1]),Math.ceil(e[2]),Math.ceil(e[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,i=this.suspendedCtx,a=canvas_classPrivateFieldGet(Hs,this)>0&&i===this.ctx;this.composeSMask(a?null:i,t,this.ctx,e);if(!a){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(e,t,i,a){const s=a[0],r=a[1],n=a[2]-s,o=a[3]-r;if(0===n||0===o)return;const l=this.smaskPreparedEntry;if(l){let e=s,a=r,c=n,d=o;const h=this.smaskPreparedOOBAlpha,u=null!==h;if(u){e=Math.max(s,t.offsetX);a=Math.max(r,t.offsetY);c=Math.min(s+n,t.offsetX+t.canvas.width)-e;d=Math.min(r+o,t.offsetY+t.canvas.height)-a}if(c>0&&d>0){const t=e-this.smaskPreparedOffsetX,s=a-this.smaskPreparedOffsetY;i.save();i.globalAlpha=1;i.setTransform(1,0,0,1,0,0);const r=new Path2D;r.rect(e,a,c,d);i.clip(r);i.globalCompositeOperation="destination-in";i.drawImage(l.canvas,t,s,c,d,e,a,c,d);i.restore()}u&&h<255&&this._applySMaskOOBAlpha(i,s,r,n,o,e,a,e+c,a+d,h)}else this.genericComposeSMask(t,i,n,o,s,r);if(e){e.save();e.globalAlpha=1;e.globalCompositeOperation=t.blendMode||"source-over";e.setTransform(1,0,0,1,0,0);e.drawImage(i.canvas,s,r,n,o,s,r,n,o);e.restore()}}_applySMaskOOBAlpha(e,t,i,a,s,r,n,o,l,c){const d=r<o&&n<l;if(d&&r===t&&n===i&&o===t+a&&l===i+s)return;const h=new Path2D;h.rect(t,i,a,s);d&&h.rect(r,n,o-r,l-n);e.save();e.globalAlpha=c/255;e.setTransform(1,0,0,1,0,0);e.clip(h,"evenodd");e.globalCompositeOperation="destination-in";e.fillStyle="#000000";e.fillRect(t,i,a,s);e.restore()}genericComposeSMask(e,t,i,a,s,r){const n=e.context,o=e.offsetX,l=e.offsetY;t.save();t.globalAlpha=1;t.setTransform(1,0,0,1,0,0);const c=new Path2D;c.rect(s,r,i,a);t.clip(c);t.globalCompositeOperation="destination-in";t.drawImage(n.canvas,s-o,r-l,i,a,s,r,i,a);t.restore()}save(e){this.inSMaskMode&©CtxState(this.ctx,this.suspendedCtx);this.ctx.save();const t=this.current;this.stateStack.push(t);this.current=t.clone();this.dependencyTracker?.save(e)}restore(e){this.dependencyTracker?.restore(e);if(0!==this.stateStack.length){this.current=this.stateStack.pop();this.ctx.restore();if(this.inSMaskMode){copyCtxState(this.suspendedCtx,this.ctx);this.ctx.setTransform(this.suspendedCtx.getTransform())}this.checkSMaskState(e);this.pendingClip=null;this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null}else this.inSMaskMode&&this.endSMaskMode()}transform(e,t,i,a,s,r,n){this.dependencyTracker?.recordIncrementalData("transform",e);this.ctx.transform(t,i,a,s,r,n);this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null}constructPath(e,t,i,a){let s=canvas_slicedToArray(i,1)[0];if(!a){s||=i[0]=new Path2D;t!==R.stroke&&t!==R.closeStroke&&(this.current.tilingPatternDims=null);this[t](e,s);return}if(null!==this.dependencyTracker){const i=t===R.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,a[0]-i,a[2]+i,a[1]-i,a[3]+i).recordDependencies(e,["transform"])}s instanceof Path2D||(s=i[0]=makePathFromDrawOPS(s));Util.axialAlignedBoundingBox(a,getCurrentTransform(this.ctx),this.current.minMax);const r=this.current.tilingPatternDims;if(r&&t!==R.stroke&&t!==R.closeStroke&&this.current.fillColor instanceof TilingPattern){const e=Util.intersect(this.current.clipBox,this.current.minMax);e?this.current.fillColor.updatePatternDims(e,r):this.current.tilingPatternDims=null}this[t](e,s);this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const a=i&&canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,this.current.strokeAlpha),s=this.ctx,r=this.current.strokeColor;s.globalAlpha=this.current.strokeAlpha;if(this.contentVisible)if("object"==typeof r&&r?.getPattern){const i=r.isModifyingCurrentTransform()?s.getTransform():null;s.save();s.strokeStyle=r.getPattern(s,this,getCurrentTransformInverse(s),Gs,e);if(i){const e=new Path2D;e.addPath(t,s.getTransform().invertSelf().multiplySelf(i));t=e}this.rescaleAndStroke(t,!1);s.restore()}else this.rescaleAndStroke(t,!0);this.dependencyTracker?.recordDependencies(e,Ca);i&&this.consumePath(e,t,this.current.getClippedPathBoundingBox(Gs,getCurrentTransform(this.ctx)));s.globalAlpha=this.current.fillAlpha;canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,a)}closeStroke(e,t){this.stroke(e,t)}fill(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const a=i&&canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx,r=this.current.fillColor,n=this.current.patternFill;let o=!1;const l=this.current.getClippedPathBoundingBox();this.dependencyTracker?.recordDependencies(e,Aa);if(n){const n=this.current.tilingPatternDims,c=n&&r.canSkipPatternCanvas(n);if(c){r.drawPattern(this,t,this.pendingEOFill,c,e);this.pendingEOFill=!1;i&&this.consumePath(e,t,l);this.current.tilingPatternDims=null;canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,a);return}const d=r.isModifyingCurrentTransform()?s.getTransform():null;this.dependencyTracker?.save(e);s.save();s.fillStyle=r.getPattern(s,this,getCurrentTransformInverse(s),Is,e);if(d){const e=new Path2D;e.addPath(t,s.getTransform().invertSelf().multiplySelf(d));t=e}o=!0}if(this.contentVisible&&null!==l)if(this.pendingEOFill){s.fill(t,"evenodd");this.pendingEOFill=!1}else s.fill(t);if(o){s.restore();this.dependencyTracker?.restore(e)}i&&this.consumePath(e,t,l);canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,a)}eoFill(e,t){this.pendingEOFill=!0;this.fill(e,t)}fillStroke(e,t){const i=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(e,t,!1);this.stroke(e,t,!1);this.consumePath(e,t);canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,i)}eoFillStroke(e,t){this.pendingEOFill=!0;this.fillStroke(e,t)}closeFillStroke(e,t){this.fillStroke(e,t)}closeEOFillStroke(e,t){this.pendingEOFill=!0;this.fillStroke(e,t)}endPath(e,t){this.consumePath(e,t)}rawFillPath(e,t){const i=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,this.current.fillAlpha);this.ctx.fill(t);this.dependencyTracker?.recordDependencies(e,ka).recordOperation(e);canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,i)}clip(e){this.dependencyTracker?.recordFutureForcedDependency("clipMode",e);this.pendingClip=Ws}eoClip(e){this.dependencyTracker?.recordFutureForcedDependency("clipMode",e);this.pendingClip=Us}beginText(e){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(e).resetIncrementalData("sameLineText").resetIncrementalData("moveText",e)}endText(e){const t=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const i=this.dependencyTracker;void 0!==t&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",e);i.recordCloseMarker(e)}if(void 0!==t){const e=new Path2D,a=i.getTransform().invertSelf();for(const i of t){const t=i.transform,s=i.x,r=i.y,n=i.fontSize,o=i.path;o&&e.addPath(o,new DOMMatrix(t).preMultiplySelf(a).translate(s,r).scale(n,-n))}i.clip(e)}delete this.pendingTextPaths}setCharSpacing(e,t){this.dependencyTracker?.recordSimpleData("charSpacing",e);this.current.charSpacing=t}setWordSpacing(e,t){this.dependencyTracker?.recordSimpleData("wordSpacing",e);this.current.wordSpacing=t}setHScale(e,t){this.dependencyTracker?.recordSimpleData("hScale",e);this.current.textHScale=t/100}setLeading(e,t){this.dependencyTracker?.recordSimpleData("leading",e);this.current.leading=-t}setFont(e,t,i){this.dependencyTracker?.recordSimpleData("font",e).recordSimpleDataFromNamed("fontObj",t,e);const a=this.commonObjs.get(t),s=this.current;if(!a)throw new Error(`Can't find font for ${t}`);s.fontMatrix=a.fontMatrix||n;0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||warn("Invalid font matrix for font "+t);if(i<0){i=-i;s.fontDirection=-1}else s.fontDirection=1;this.current.font=a;this.current.fontSize=i;if(a.isType3Font)return;const r=a.loadedName||"sans-serif",o=a.systemFontInfo?.css||`"${r}", ${a.fallbackName}`;let l="normal";a.black?l="900":a.bold&&(l="bold");const c=a.italic?"italic":"normal";let d=i;i<16?d=16:i>100&&(d=100);this.current.fontSizeScale=i/d;this.ctx.font=`${c} ${l} ${d}px ${o}`}setTextRenderingMode(e,t){this.dependencyTracker?.recordSimpleData("textRenderingMode",e);this.current.textRenderingMode=t}setTextRise(e,t){this.dependencyTracker?.recordSimpleData("textRise",e);this.current.textRise=t}moveText(e,t,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",e);this.current.x=this.current.lineX+=t;this.current.y=this.current.lineY+=i}setLeadingMoveText(e,t,i){this.setLeading(e,-i);this.moveText(e,t,i)}setTextMatrix(e,t){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",e);const i=this.current;i.textMatrix=t;i.textMatrixScale=Math.hypot(t[0],t[1]);i.x=i.lineX=0;i.y=i.lineY=0}nextLine(e){this.moveText(e,0,this.current.leading);this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??e)}paintChar(e,t,i,a,s,r){const n=this.ctx,o=this.current,l=o.font,c=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,h=c&k,u=!!(c&E),_=o.patternFill&&!l.missingFile,p=o.patternStroke&&!l.missingFile;let g;(l.disableFontFace||u||_||p)&&!l.missingFile&&(g=l.getPathGenerator(this.commonObjs,t));if(g&&(l.disableFontFace||_||p)){n.save();n.translate(i,a);n.scale(d,-d);this.dependencyTracker?.recordCharacterBBox(e,n,l);let t;if(h===S||h===A)if(s){t=n.getTransform();n.setTransform(...s);const e=canvas_assertClassBrand(Qs,this,_getScaledPath).call(this,g,t,s);n.fill(e)}else n.fill(g);if(h===C||h===A)if(r){t||=n.getTransform();n.setTransform(...r);const e=t,i=e.a,a=e.b,s=e.c,o=e.d,l=Util.inverseTransform(r),c=Util.transform([i,a,s,o,0,0],l);Util.singularValueDecompose2dScale(c,Rs);n.lineWidth*=Math.max(Rs[0],Rs[1])/d;n.stroke(canvas_assertClassBrand(Qs,this,_getScaledPath).call(this,g,t,r))}else{n.lineWidth/=d;n.stroke(g)}n.restore()}else{if(h===S||h===A){n.fillText(t,i,a);this.dependencyTracker?.recordCharacterBBox(e,n,l,d,i,a,()=>n.measureText(t))}if(h===C||h===A){this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(e,n,l,d,i,a,()=>n.measureText(t)).recordDependencies(e,Ca);n.strokeText(t,i,a)}}if(u){(this.pendingTextPaths||=[]).push({transform:getCurrentTransform(n),x:i,y:a,fontSize:d,path:g});this.dependencyTracker?.recordCharacterBBox(e,n,l,d,i,a)}}get isFontSubpixelAAEnabled(){const e=this.canvasFactory.create(10,10),t=e.context;t.scale(1.5,1);t.fillText("I",0,10);const i=t.getImageData(0,0,10,10).data;this.canvasFactory.destroy(e);let a=!1;for(let e=3;e<i.length;e+=4)if(i[e]>0&&i[e]<255){a=!0;break}return shadow(this,"isFontSubpixelAAEnabled",a)}showText(e,t){if(this.dependencyTracker){this.dependencyTracker.recordDependencies(e,Ea).resetBBox(e);this.current.textRenderingMode&E&&this.dependencyTracker.recordFutureForcedDependency("textClip",e).inheritPendingDependenciesAsFutureForcedDependencies()}const i=this.current,a=i.font;if(a.isType3Font){const a=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,i.fillAlpha);this.showType3Text(e,t);this.dependencyTracker?.recordShowTextOperation(e);canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,a);return}const s=i.fontSize;if(0===s){this.dependencyTracker?.recordOperation(e);return}const r=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,i.fillAlpha),n=this.ctx,o=i.fontSizeScale,l=i.charSpacing,c=i.wordSpacing,d=i.fontDirection,h=i.textHScale*d,u=t.length,_=a.vertical,p=_?1:-1,g=a.defaultVMetrics,f=s*i.fontMatrix[0],m=i.textRenderingMode===S&&!a.disableFontFace&&!i.patternFill;n.save();i.textMatrix&&n.transform(...i.textMatrix);n.translate(i.x,i.y+i.textRise);d>0?n.scale(h,-1):n.scale(h,1);let v,y;const P=i.textRenderingMode&k,w=P===S||P===A,b=P===C||P===A;let x=i.lineWidth;const T=i.textMatrixScale;0===T||0===x?b&&(x=this.getSinglePixelWidth()):x/=T;if(1!==o){n.scale(o,o);x/=o}n.lineWidth=x;if(w&&i.patternFill){n.save();const t=i.fillColor.getPattern(n,this,getCurrentTransformInverse(n),Is,e);v=getCurrentTransform(n);n.restore();n.fillStyle=t}if(b&&i.patternStroke){n.save();const t=i.strokeColor.getPattern(n,this,getCurrentTransformInverse(n),Gs,e);y=getCurrentTransform(n);n.restore();n.strokeStyle=t}if(a.isInvalidPDFjsFont){const a=[];let s=0;for(const e of t){a.push(e.unicode);s+=e.width}const o=a.join("");n.fillText(o,0,0);if(null!==this.dependencyTracker){const t=n.measureText(o);this.dependencyTracker.recordBBox(e,this.ctx,-t.actualBoundingBoxLeft,t.actualBoundingBoxRight,-t.actualBoundingBoxAscent,t.actualBoundingBoxDescent).recordShowTextOperation(e)}i.x+=s*f*h;n.restore();this.compose();canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,r);return}let I,G=0;for(I=0;I<u;++I){const i=t[I];if("number"==typeof i){G+=p*i*s/1e3;continue}let r=!1;const h=(i.isSpace?c:0)+l,u=i.fontChar,P=i.accent;let w,b,S,C=i.width;if(_){const e=i.vmetric||g,t=-(i.vmetric?e[1]:.5*C)*f,a=e[2]*f;C=e?-e[0]:C;w=t/o;b=(G+a)/o}else{w=G/o;b=0}if(a.remeasure&&C>0){S=n.measureText(u);const e=1e3*S.width/s*o;if(C<e&&this.isFontSubpixelAAEnabled){const t=C/e;r=!0;n.save();n.scale(t,1);w/=t}else C!==e&&(w+=(C-e)/2e3*s/o)}if(this.contentVisible&&(i.isInFont||a.missingFile))if(m&&!P){n.fillText(u,w,b);this.dependencyTracker?.recordCharacterBBox(e,n,S?{bbox:null}:a,s/o,w,b,()=>S??n.measureText(u))}else{this.paintChar(e,u,w,b,v,y);if(P){const t=w+s*P.offset.x/o,i=b-s*P.offset.y/o;this.paintChar(e,P.fontChar,t,i,v,y)}}G+=_?C*f-h*d:C*f+h*d;r&&n.restore()}_?i.y-=G:i.x+=G*h;n.restore();this.compose();this.dependencyTracker?.recordShowTextOperation(e);canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,r)}showType3Text(e,t){const i=this.ctx,a=this.current,s=a.font,r=a.fontSize,o=a.fontDirection,l=s.vertical?1:-1,c=a.charSpacing,d=a.wordSpacing,h=a.textHScale*o,u=a.fontMatrix||n,_=t.length;let p,g,f,m;if(a.textRenderingMode===x||0===r)return;this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null;i.save();a.textMatrix&&i.transform(...a.textMatrix);i.translate(a.x,a.y+a.textRise);i.scale(h,o);const v=this.dependencyTracker;this.dependencyTracker=v?new CanvasNestedDependencyTracker(v,e):null;for(p=0;p<_;++p){g=t[p];if("number"==typeof g){m=l*g*r/1e3;this.ctx.translate(m,0);a.x+=m*h;continue}const e=(g.isSpace?d:0)+c,n=s.charProcOperatorList[g.operatorListId];if(n){if(this.contentVisible){this.save();i.scale(r,r);i.transform(...u);this.executeOperatorList(n);this.restore()}}else warn(`Type3 character "${g.operatorListId}" is not available.`);const o=[g.width,0];Util.applyTransform(o,u);f=o[0]*r+e;i.translate(f,0);a.x+=f*h}i.restore();v&&(this.dependencyTracker=v)}setCharWidth(e,t,i){}setCharWidthAndBounds(e,t,i,a,s,r,n){const o=new Path2D;o.rect(a,s,r-a,n-s);this.ctx.clip(o);this.dependencyTracker?.recordBBox(e,this.ctx,a,r,s,n).recordClipBox(e,this.ctx,a,r,s,n);this.endPath(e)}getColorN_Pattern(e,t){let i;if("TilingPattern"===t[0]){const e=this.baseTransform||getCurrentTransform(this.ctx),a={createCanvasGraphics:(e,t)=>new CanvasGraphics(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new CanvasNestedDependencyTracker(this.dependencyTracker,t,!0):null)};i=new TilingPattern(t,this.ctx,a,e)}else i=this._getPattern(e,t[1],t[2]);return i}setStrokeColorN(e){this.dependencyTracker?.recordSimpleData("strokeColor",e);for(var t=arguments.length,i=new Array(t>1?t-1:0),a=1;a<t;a++)i[a-1]=arguments[a];this.current.strokeColor=this.getColorN_Pattern(e,i);this.current.patternStroke=!0}setFillColorN(e){this.dependencyTracker?.recordSimpleData("fillColor",e);for(var t=arguments.length,i=new Array(t>1?t-1:0),a=1;a<t;a++)i[a-1]=arguments[a];const s=this.current.fillColor=this.getColorN_Pattern(e,i);this.current.patternFill=!0;this.current.tilingPatternDims=s instanceof TilingPattern?[0,0,0,0]:null}setStrokeRGBColor(e,t){this.dependencyTracker?.recordSimpleData("strokeColor",e);this.ctx.strokeStyle=this.current.strokeColor=t;this.current.patternStroke=!1}setStrokeTransparent(e){this.dependencyTracker?.recordSimpleData("strokeColor",e);this.ctx.strokeStyle=this.current.strokeColor="transparent";this.current.patternStroke=!1}setFillRGBColor(e,t){this.dependencyTracker?.recordSimpleData("fillColor",e);this.ctx.fillStyle=this.current.fillColor=t;this.current.patternFill=!1;this.current.tilingPatternDims=null}setFillTransparent(e){this.dependencyTracker?.recordSimpleData("fillColor",e);this.ctx.fillStyle=this.current.fillColor="transparent";this.current.patternFill=!1;this.current.tilingPatternDims=null}_getPattern(e,t){let i,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this.cachedPatterns.has(t))i=this.cachedPatterns.get(t);else{i=function getShadingPattern(e){switch(e[0]){case"RadialAxial":return new RadialAxialShadingPattern(e);case"Mesh":return new MeshShadingPattern(e);case"Dummy":return new DummyShadingPattern}throw new Error(`Unknown IR type: ${e[0]}`)}(this.getObject(e,t));this.cachedPatterns.set(t,i)}a&&(i.matrix=a);return i}shadingFill(e,t){if(!this.contentVisible)return;const i=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),a=this.ctx;this.save(e);const s=this._getPattern(e,t);a.fillStyle=s.getPattern(a,this,getCurrentTransformInverse(a),Bs,e);const n=getCurrentTransformInverse(a);if(n){const e=a.canvas,t=e.width,i=e.height,s=r.slice();Util.axialAlignedBoundingBox([0,0,t,i],n,s);const o=canvas_slicedToArray(s,4),l=o[0],c=o[1],d=o[2],h=o[3];this.ctx.fillRect(l,c,d-l,h-c)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,Ta).recordDependencies(e,Aa).recordOperation(e);this.compose(this.current.getClippedPathBoundingBox());this.restore(e);canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,i)}beginInlineImage(){unreachable("Should not call beginInlineImage")}beginImageData(){unreachable("Should not call beginImageData")}paintFormXObjectBegin(e,t,i){if(this.contentVisible){this.save(e);this.baseTransformStack.push(this.baseTransform);t&&this.transform(e,...t);this.baseTransform=getCurrentTransform(this.ctx);if(i){Util.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const t=canvas_slicedToArray(i,4),a=t[0],s=t[1],r=t[2],n=t[3],o=new Path2D;o.rect(a,s,r-a,n-s);this.ctx.clip(o);this.dependencyTracker?.recordClipBox(e,this.ctx,a,r,s,n);this.endPath(e)}}}paintFormXObjectEnd(e){if(this.contentVisible){this.restore(e);this.baseTransform=this.baseTransformStack.pop()}}beginGroup(e,t){if(!this.contentVisible)return;this.save(e);const i=this.inSMaskMode;if(i){this.endSMaskMode();this.current.activeSMask=null}const a=this.ctx;t.isolated||t.knockout||0!==canvas_classPrivateFieldGet(Vs,this)||info("TODO: Fully support non-isolated non-knockout groups.");if(!t.needsIsolation&&!t.knockout&&0===canvas_classPrivateFieldGet(Vs,this)&&1===a.globalAlpha&&"source-over"===a.globalCompositeOperation&&!i){if(t.bbox){let e=new Path2D;const i=canvas_slicedToArray(t.bbox,4),s=i[0],r=i[1],n=i[2],o=i[3];e.rect(s,r,n-s,o-r);if(t.matrix){const i=new Path2D;i.addPath(e,new DOMMatrix(t.matrix));e=i}a.clip(e)}this.groupStack.push(null);canvas_classPrivateFieldGet(Js,this).push(null);this.groupLevel++;return}const s=getCurrentTransform(a);t.matrix&&a.transform(...t.matrix);const n=[0,0,a.canvas.width,a.canvas.height];let o;if(t.bbox){o=r.slice();Util.axialAlignedBoundingBox(t.bbox,getCurrentTransform(a),o);o=Util.intersect(o,n)||[0,0,0,0]}else o=n;const l=Math.floor(o[0]),c=Math.floor(o[1]),d=Math.max(Math.ceil(o[2])-l,1),h=Math.max(Math.ceil(o[3])-c,1);this.current.startNewPathAndClipBox([0,0,d,h]);const u=this.canvasFactory.create(d,h);t.smask&&this.smaskGroupCanvases.push(u);const _=u.context,p=t.knockout&&!t.isolated?a:null,g=!t.isolated&&!t.knockout&&!t.smask&&t.needsIsolation&&canvas_classPrivateFieldGet(Vs,this)>0,f=t.knockout?this.canvasFactory.create(d,h):null,m=canvas_classPrivateFieldGet(Vs,this);if(t.knockout){var v;canvas_classPrivateFieldSet(Vs,this,(v=canvas_classPrivateFieldGet(Vs,this),v++,v))}else canvas_classPrivateFieldSet(Vs,this,0);_.translate(-l,-c);_.transform(...s);if(!t.isolated&&!t.smask&&i&&t.needsIsolation){_.save();_.setTransform(1,0,0,1,0,0);_.drawImage(a.canvas,-l,-c);_.restore()}if(t.bbox){let e=new Path2D;const i=canvas_slicedToArray(t.bbox,4),a=i[0],s=i[1],r=i[2],n=i[3];e.rect(a,s,r-a,n-s);if(t.matrix){const i=new Path2D;i.addPath(e,new DOMMatrix(t.matrix));e=i}_.clip(e)}t.smask&&this.smaskStack.push({canvas:u.canvas,context:_,offsetX:l,offsetY:c,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null});if(!t.smask||this.dependencyTracker){a.setTransform(1,0,0,1,0,0);a.translate(l,c);a.save()}copyCtxState(a,_);this.ctx=_;this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(a);this.setGState(e,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]);this.groupStack.push(a);canvas_classPrivateFieldGet(Js,this).push({backdropCtx:p,savedKnockoutLevel:m,offsetX:l,offsetY:c,hasInnerBackdrop:g,knockoutMaskEntry:f,knockoutTempEntry:null,knockoutBackdropEntry:null});this.groupLevel++}endGroup(e,t){if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,a=this.groupStack.pop(),s=canvas_classPrivateFieldGet(Js,this).pop();s&&canvas_classPrivateFieldSet(Vs,this,s.savedKnockoutLevel);if(null!==a){this.ctx=a;this.ctx.imageSmoothingEnabled=!1;this.dependencyTracker?.popBaseTransform();if(t.smask){this.tempSMask=this.smaskStack.pop();this.restore(e);if(this.dependencyTracker){this.ctx.restore();this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())}canvas_assertClassBrand(Qs,this,_destroyKnockoutPools).call(this,s)}else{this.ctx.restore();const t=getCurrentTransform(this.ctx);this.restore(e);this.ctx.save();this.ctx.setTransform(...t);const n=r.slice();Util.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],t,n);const o=canvas_classPrivateFieldGet(Js,this).at(-1);if(canvas_classPrivateFieldGet(Vs,this)>0)if(s.hasInnerBackdrop){const e=i.canvas,r=e.width,n=e.height,o=this.canvasFactory.create(r,n),l=o.context;l.drawImage(a.canvas,s.offsetX,s.offsetY,r,n,0,0,r,n);l.globalCompositeOperation="source-over";l.drawImage(i.canvas,0,0);const c=canvas_assertClassBrand(Qs,this,_createKnockoutMaskCanvas).call(this,i.canvas);l.globalCompositeOperation="destination-in";l.drawImage(c.canvas,0,0);const d=this.ctx.globalCompositeOperation,h=this.ctx.globalAlpha,u=this.ctx.filter;this.ctx.save();this.ctx.setTransform(...t);this.ctx.globalAlpha=1;FeatureTest.isCanvasFilterSupported&&(this.ctx.filter="none");this.ctx.globalCompositeOperation="destination-out";this.ctx.drawImage(c.canvas,0,0);this.ctx.globalCompositeOperation=d;this.ctx.globalAlpha=h;FeatureTest.isCanvasFilterSupported&&(this.ctx.filter=u??"none");this.ctx.drawImage(o.canvas,0,0);this.ctx.restore();this.canvasFactory.destroy(c);this.canvasFactory.destroy(o)}else{const e=o?.backdropCtx??null;canvas_assertClassBrand(Qs,this,_compositeKnockoutSurface).call(this,this.ctx,i.canvas,{backdropCanvas:e?.canvas??null,destTransform:t,backdropOffset:e?[o.offsetX+s.offsetX,o.offsetY+s.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(i.canvas,0,0);this.ctx.restore();this.canvasFactory.destroy({canvas:i.canvas,context:i});canvas_assertClassBrand(Qs,this,_destroyKnockoutPools).call(this,s);this.compose(n)}}else this.restore(e)}beginAnnotation(e,t,i,a,s,r){canvas_assertClassBrand(Qs,this,_restoreInitialState).call(this);resetCtxToDefault(this.ctx);this.ctx.save();this.save(e);this.baseTransform&&this.ctx.setTransform(...this.baseTransform);if(i){const s=i[2]-i[0],n=i[3]-i[1];if(r&&this.annotationCanvasMap){(a=a.slice())[4]-=i[0];a[5]-=i[1];(i=i.slice())[0]=i[1]=0;i[2]=s;i[3]=n;Util.singularValueDecompose2dScale(getCurrentTransform(this.ctx),Rs);const e=this.viewportScale,r=Math.ceil(s*this.outputScaleX*e),o=Math.ceil(n*this.outputScaleY*e);this.annotationCanvas=this.canvasFactory.create(r,o);const l=this.annotationCanvas,c=l.canvas,d=l.context;this.annotationCanvasMap.set(t,c);this.annotationCanvas.savedCtx=this.ctx;this.ctx=d;this.ctx.save();this.ctx.setTransform(Rs[0],0,0,-Rs[1],0,n*Rs[1]);resetCtxToDefault(this.ctx)}else{resetCtxToDefault(this.ctx);this.endPath(e);const t=new Path2D;t.rect(i[0],i[1],s,n);this.ctx.clip(t)}}this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.baseTransformStack.push(this.baseTransform);this.transform(e,...a);this.transform(e,...s);this.baseTransform=getCurrentTransform(this.ctx)}endAnnotation(e){if(this.annotationCanvas){this.ctx.restore();canvas_assertClassBrand(Qs,this,_drawFilter).call(this);this.ctx=this.annotationCanvas.savedCtx;delete this.annotationCanvas.savedCtx;delete this.annotationCanvas}this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(e,t){if(!this.contentVisible)return;const i=t.count;(t=this.getObject(e,t.data,t)).count=i;const a=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx,r=this._createMaskCanvas(e,t),n=r.canvas;s.save();s.setTransform(1,0,0,1,0,0);s.drawImage(n,r.offsetX,r.offsetY);this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,r.offsetX,r.offsetX+n.width,r.offsetY,r.offsetY+n.height).recordOperation(e);s.restore();r.canvasEntry&&this.canvasFactory.destroy(r.canvasEntry);this.compose();canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,a)}paintImageMaskXObjectRepeat(e,t,i){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=arguments.length>5?arguments[5]:void 0,n=arguments.length>6?arguments[6]:void 0;if(!this.contentVisible)return;t=this.getObject(e,t.data,t);const o=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),l=this.ctx;l.save();const c=getCurrentTransform(l);l.transform(i,a,s,r,0,0);const d=this._createMaskCanvas(e,t);l.setTransform(1,0,0,1,d.offsetX-c[4],d.offsetY-c[5]);this.dependencyTracker?.resetBBox(e);for(let t=0,o=n.length;t<o;t+=2){const o=Util.transform(c,[i,a,s,r,n[t],n[t+1]]);l.drawImage(d.canvas,o[4],o[5]);this.dependencyTracker?.recordBBox(e,this.ctx,o[4],o[4]+d.canvas.width,o[5],o[5]+d.canvas.height)}l.restore();d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry);this.compose();this.dependencyTracker?.recordOperation(e);canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,o)}paintImageMaskXObjectGroup(e,t){if(!this.contentVisible)return;const i=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),a=this.ctx,s=this.current.fillColor,r=this.current.patternFill;this.dependencyTracker?.resetBBox(e).recordDependencies(e,Ia);for(const i of t){const t=i.data,n=i.width,o=i.height,l=i.transform,c=this.canvasFactory.create(n,o),d=c.context;d.save();putBinaryImageMask(d,this.getObject(e,t,i));d.globalCompositeOperation="source-in";d.fillStyle=r?s.getPattern(d,this,getCurrentTransformInverse(a),Is,e):s;d.fillRect(0,0,n,o);d.restore();a.save();a.transform(...l);a.scale(1,-1);drawImageAtIntegerCoords(a,c.canvas,0,0,n,o,0,-1,1,1);this.canvasFactory.destroy(c);this.dependencyTracker?.recordBBox(e,a,0,n,0,o);a.restore()}this.compose();this.dependencyTracker?.recordOperation(e);canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,i)}paintImageXObject(e,t){if(!this.contentVisible)return;const i=this.getObject(e,t);i?this.paintInlineImageXObject(e,i):warn("Dependent image isn't ready yet")}paintImageXObjectRepeat(e,t,i,a,s){if(!this.contentVisible)return;const r=this.getObject(e,t);if(!r){warn("Dependent image isn't ready yet");return}const n=r.width,o=r.height,l=[];for(let e=0,t=s.length;e<t;e+=2)l.push({transform:[i,0,0,a,s[e],s[e+1]],x:0,y:0,w:n,h:o});this.paintInlineImageXObjectGroup(e,r,l)}applyTransferMapsToCanvas(e){if("none"!==this.current.transferMaps){e.filter=this.current.transferMaps;e.drawImage(e.canvas,0,0);e.filter="none"}return e.canvas}applyTransferMapsToBitmap(e){if("none"===this.current.transferMaps)return{img:e.bitmap,canvasEntry:null};const t=e.bitmap,i=e.width,a=e.height,s=this.canvasFactory.create(i,a),r=s.context;r.filter=this.current.transferMaps;r.drawImage(t,0,0);r.filter="none";return{img:s.canvas,canvasEntry:s}}paintInlineImageXObject(e,t){if(!this.contentVisible)return;const i=t.width,a=t.height,s=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),r=this.ctx;this.save(e);const n=r.filter;"none"!==n&&""!==n&&(r.filter="none");r.scale(1/i,-1/a);let o,l=null;if(t.bitmap){const e=this.applyTransferMapsToBitmap(t);o=e.img;l=e.canvasEntry}else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)o=t;else{const e=this.canvasFactory.create(i,a);putBinaryImageData(e.context,t);o=this.applyTransferMapsToCanvas(e.context);l=e}const c=this._scaleImage(o,getCurrentTransformInverse(r));r.imageSmoothingEnabled=getImageSmoothingEnabled(getCurrentTransform(r),t.interpolate);if(this.dependencyTracker){this.dependencyTracker.resetBBox(e).recordBBox(e,r,0,i,-a,0).recordDependencies(e,xa).recordOperation(e);this.imagesTracker?.record(r,i,a,this.dependencyTracker.clipBox)}drawImageAtIntegerCoords(r,c.img,0,0,c.paintWidth,c.paintHeight,0,-a,i,a);c.tmpCanvas&&this.canvasFactory.destroy(c.tmpCanvas);l&&this.canvasFactory.destroy(l);this.compose();this.restore(e);canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,s)}paintInlineImageXObjectGroup(e,t,i){if(!this.contentVisible)return;const a=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx;let r,n=null;if(t.bitmap)r=t.bitmap;else{const e=t.width,i=t.height,a=this.canvasFactory.create(e,i);putBinaryImageData(a.context,t);r=this.applyTransferMapsToCanvas(a.context);n=a}this.dependencyTracker?.resetBBox(e);for(const t of i){s.save();s.transform(...t.transform);s.scale(1,-1);drawImageAtIntegerCoords(s,r,t.x,t.y,t.w,t.h,0,-1,1,1);this.dependencyTracker?.recordBBox(e,s,0,1,-1,0);s.restore()}n&&this.canvasFactory.destroy(n);this.dependencyTracker?.recordOperation(e);this.compose();canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,a)}paintSolidColorImageMask(e){if(!this.contentVisible)return;const t=canvas_assertClassBrand(Qs,this,_beginKnockoutElement).call(this,this.current.fillAlpha);this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,Aa).recordOperation(e);this.ctx.fillRect(0,0,1,1);this.compose();canvas_assertClassBrand(Qs,this,_endKnockoutElement).call(this,t)}markPoint(e,t){}markPointProps(e,t,i){}beginMarkedContent(e,t){this.dependencyTracker?.beginMarkedContent(e);this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t,i){this.dependencyTracker?.beginMarkedContent(e);"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(e){this.dependencyTracker?.endMarkedContent(e);this.markedContentStack.pop();this.contentVisible=this.isContentVisible()}beginCompat(e){}endCompat(e){}consumePath(e,t,i){const a=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath();this.pendingClip||this.compose(i);const s=this.ctx;if(this.pendingClip){a||(this.pendingClip===Us?s.clip(t,"evenodd"):s.clip(t));this.pendingClip=null;this.dependencyTracker?.bboxToClipBoxDropOperation(e).recordFutureForcedDependency("clipPath",e)}else this.dependencyTracker?.recordOperation(e);this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=getCurrentTransform(this.ctx);if(0===e[1]&&0===e[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const t=Math.abs(e[0]*e[3]-e[2]*e[1]),i=Math.hypot(e[0],e[2]),a=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(i,a)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const e=this.current.lineWidth,t=this.ctx.getTransform(),i=t.a,a=t.b,s=t.c,r=t.d;let n,o;if(0===a&&0===s){const t=Math.abs(i),a=Math.abs(r);if(t===a)if(0===e)n=o=1/t;else{const i=t*e;n=o=i<1?1/i:1}else if(0===e){n=1/t;o=1/a}else{const i=t*e,s=a*e;n=i<1?1/i:1;o=s<1?1/s:1}}else{const t=Math.abs(i*r-a*s),l=Math.hypot(i,a),c=Math.hypot(s,r);if(0===e){n=c/t;o=l/t}else{const i=e*t;n=c>i?c/i:1;o=l>i?l/i:1}}this._cachedScaleForStroking[0]=n;this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e,t){const i=this.ctx,a=this.current.lineWidth,s=canvas_slicedToArray(this.getScaleForStroking(),2),r=s[0],n=s[1];if(r===n){i.lineWidth=(a||1)*r;i.stroke(e);return}const o=i.getLineDash();t&&i.save();i.scale(r,n);Os.a=1/r;Os.d=1/n;const l=new Path2D;l.addPath(e,Os);if(o.length>0){const e=Math.max(r,n);i.setLineDash(o.map(t=>t/e));i.lineDashOffset/=e}i.lineWidth=a||1;i.stroke(l);t&&i.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}function _restoreInitialState(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null;this.ctx.restore();if(this.transparentCanvas){this.ctx=this.compositeCtx;this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.drawImage(this.transparentCanvas,0,0);this.ctx.restore();this.canvasFactory.destroy(this.transparentCanvasEntry);this.transparentCanvas=null;this.transparentCanvasEntry=null}}function _drawFilter(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){const t=this.ctx.filter;this.ctx.filter=e;this.ctx.drawImage(this.ctx.canvas,0,0);this.ctx.filter=t}}}function _createKnockoutMaskCanvas(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;const a=e.width,s=e.height,r=t??this.canvasFactory.create(a,s),n=r.context;i=Math.round(255*i)/255;const o=i<1;o&&void 0===canvas_classPrivateFieldGet(Ys,this)&&canvas_classPrivateFieldSet(Ys,this,FeatureTest.isCanvasFilterSupported?new Map:"none");let l="none";if(o&&canvas_classPrivateFieldGet(Ys,this)instanceof Map){l=canvas_classPrivateFieldGet(Ys,this).get(i);if(!l){l=this.filterFactory.addKnockoutFilter(i);canvas_classPrivateFieldGet(Ys,this).set(i,l)}}if(!o||"none"!==l){if(t){n.save();n.setTransform(1,0,0,1,0,0);n.clearRect(0,0,a,s);n.restore()}n.filter=l;n.drawImage(e,0,0);n.filter="none";return r}const c=e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,a,s),d=n.createImageData(a,s),h=c.data,u=d.data,_=i>0?1/i:1e6;for(let e=3,t=h.length;e<t;e+=4)u[e]=Math.min(Math.round(h[e]*_),255);n.putImageData(d,0,0);return r}function _getOrCreatePooledEntry(e,t,i,a){let s=e?.[t]??null;if(s&&(s.canvas.width!==i||s.canvas.height!==a)){this.canvasFactory.destroy(s);s=null}if(!s){s=this.canvasFactory.create(i,a);e&&(e[t]=s);return s}const r=s.context;r.save();r.setTransform(1,0,0,1,0,0);r.clearRect(0,0,i,a);r.restore();return s}function _compositeKnockoutSurface(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=i.backdropCanvas,s=void 0===a?null:a,r=i.destTransform,n=void 0===r?[1,0,0,1,0,0]:r,o=i.backdropOffset,l=void 0===o?[0,0]:o,c=i.reuseMaskEntry,d=void 0===c?null:c,h=i.poolMeta,u=void 0===h?null:h,_=i.sourceAlpha,p=void 0===_?1:_,g=i.sourceFilter,f=void 0===g?"none":g,m=i.knockoutAlpha,v=void 0===m?1:m,y=t.width,P=t.height,w=canvas_assertClassBrand(Qs,this,_createKnockoutMaskCanvas).call(this,t,d,v),b=e.globalCompositeOperation;e.save();e.setTransform(...n);e.globalAlpha=1;FeatureTest.isCanvasFilterSupported&&(e.filter="none");e.globalCompositeOperation="destination-out";e.drawImage(w.canvas,0,0);if(s){const t=canvas_slicedToArray(l,2),i=t[0],a=t[1],r=canvas_assertClassBrand(Qs,this,_getOrCreatePooledEntry).call(this,u,"knockoutBackdropEntry",y,P),n=r.context;n.drawImage(s,i,a,y,P,0,0,y,P);n.globalCompositeOperation="destination-in";n.drawImage(w.canvas,0,0);n.globalCompositeOperation="source-over";e.globalCompositeOperation="destination-over";e.drawImage(r.canvas,0,0);u||this.canvasFactory.destroy(r)}e.globalCompositeOperation=b;e.globalAlpha=p;FeatureTest.isCanvasFilterSupported&&(e.filter=f??"none");e.drawImage(t,0,0);e.restore();d||this.canvasFactory.destroy(w)}function _beginKnockoutElement(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(0===canvas_classPrivateFieldGet(Vs,this)||canvas_classPrivateFieldGet(Hs,this)>0||!this.contentVisible)return!1;canvas_classPrivateFieldSet(Hs,this,(e=canvas_classPrivateFieldGet(Hs,this),e++,e));canvas_classPrivateFieldSet(Ks,this,t);const i=canvas_classPrivateFieldGet(Js,this).at(-1),a=this.ctx.canvas,s=canvas_assertClassBrand(Qs,this,_getOrCreatePooledEntry).call(this,i,"knockoutTempEntry",a.width,a.height);canvas_classPrivateFieldSet(zs,this,s);const r=s.context;r.save();r.setTransform(this.ctx.getTransform());copyCtxState(this.ctx,r);canvas_classPrivateFieldSet(Xs,this,r.globalCompositeOperation);r.globalCompositeOperation="source-over";mirrorContextOperations(r,this.ctx);canvas_classPrivateFieldSet(Zs,this,i);canvas_classPrivateFieldSet($s,this,this.ctx);canvas_classPrivateFieldSet(qs,this,this.suspendedCtx);this.ctx=r;this.inSMaskMode&&(this.suspendedCtx=r);return!0}function _endKnockoutElement(e){if(!e)return;const t=canvas_classPrivateFieldGet(zs,this),i=canvas_classPrivateFieldGet($s,this),a=canvas_classPrivateFieldGet(qs,this),s=t.context;canvas_classPrivateFieldSet(zs,this,null);canvas_classPrivateFieldSet($s,this,null);canvas_classPrivateFieldSet(qs,this,null);this.inSMaskMode&&this.suspendedCtx===s&&this.ctx!==s&&this.endSMaskMode();this.inSMaskMode&&(this.suspendedCtx=a);this.ctx._removeMirroring();this.ctx.globalCompositeOperation=canvas_classPrivateFieldGet(Xs,this);canvas_classPrivateFieldSet(Xs,this,null);copyCtxState(this.ctx,i);this.ctx=i;const r=canvas_classPrivateFieldGet(Zs,this);canvas_classPrivateFieldSet(Zs,this,null);const n=canvas_classPrivateFieldGet(Ks,this);canvas_classPrivateFieldSet(Ks,this,1);try{canvas_assertClassBrand(Qs,this,_compositeKnockoutSurface).call(this,a??i,t.canvas,{backdropCanvas:r?.backdropCtx?.canvas??null,backdropOffset:r?.backdropCtx?[r.offsetX,r.offsetY]:[0,0],reuseMaskEntry:r?.knockoutMaskEntry??null,poolMeta:r,knockoutAlpha:n})}finally{var o;s.restore();canvas_classPrivateFieldSet(Hs,this,(o=canvas_classPrivateFieldGet(Hs,this),o--,o));r||this.canvasFactory.destroy(t)}}function _getScaledPath(e,t,i){const a=new Path2D;a.addPath(e,new DOMMatrix(i).invertSelf().multiplySelf(t));return a}function _destroyKnockoutPools(e){if(e){if(e.knockoutMaskEntry){this.canvasFactory.destroy(e.knockoutMaskEntry);e.knockoutMaskEntry=null}if(e.knockoutTempEntry){this.canvasFactory.destroy(e.knockoutTempEntry);e.knockoutTempEntry=null}if(e.knockoutBackdropEntry){this.canvasFactory.destroy(e.knockoutBackdropEntry);e.knockoutBackdropEntry=null}}}for(const e in R)void 0!==CanvasGraphics.prototype[e]&&(CanvasGraphics.prototype[R[e]]=CanvasGraphics.prototype[e]);function base_pdf_stream_defineProperty(e,t,i){return(t=function base_pdf_stream_toPropertyKey(e){var t=function base_pdf_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function base_pdf_stream_classPrivateFieldInitSpec(e,t,i){(function base_pdf_stream_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function base_pdf_stream_classPrivateFieldGet(e,t){return e.get(base_pdf_stream_assertClassBrand(e,t))}function base_pdf_stream_classPrivateFieldSet(e,t,i){return e.set(base_pdf_stream_assertClassBrand(e,t),i),i}function base_pdf_stream_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var er=new WeakMap,tr=new WeakMap;class BasePDFStream{constructor(e,t,i){base_pdf_stream_classPrivateFieldInitSpec(this,er,null);base_pdf_stream_classPrivateFieldInitSpec(this,tr,null);base_pdf_stream_defineProperty(this,"_fullReader",null);base_pdf_stream_defineProperty(this,"_rangeReaders",new Set);base_pdf_stream_defineProperty(this,"_source",null);this._source=e;base_pdf_stream_classPrivateFieldSet(er,this,t);base_pdf_stream_classPrivateFieldSet(tr,this,i)}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){assert(!this._fullReader,"BasePDFStream.getFullReader can only be called once.");return this._fullReader=new(base_pdf_stream_classPrivateFieldGet(er,this))(this)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const i=new(base_pdf_stream_classPrivateFieldGet(tr,this))(this,e,t);this._rangeReaders.add(i);return i}cancelAllRequests(e){this._fullReader?.cancel(e);for(const t of new Set(this._rangeReaders))t.cancel(e)}}class BasePDFStreamReader{constructor(e){base_pdf_stream_defineProperty(this,"onProgress",null);base_pdf_stream_defineProperty(this,"_contentLength",0);base_pdf_stream_defineProperty(this,"_filename",null);base_pdf_stream_defineProperty(this,"_headersCapability",Promise.withResolvers());base_pdf_stream_defineProperty(this,"_isRangeSupported",!1);base_pdf_stream_defineProperty(this,"_isStreamingSupported",!1);base_pdf_stream_defineProperty(this,"_loaded",0);base_pdf_stream_defineProperty(this,"_stream",null);this._stream=e}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){unreachable("Abstract method `read` called")}cancel(e){unreachable("Abstract method `cancel` called")}}class BasePDFStreamRangeReader{constructor(e,t,i){base_pdf_stream_defineProperty(this,"_stream",null);this._stream=e}async read(){unreachable("Abstract method `read` called")}cancel(e){unreachable("Abstract method `cancel` called")}}function content_disposition_slicedToArray(e,t){return function content_disposition_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function content_disposition_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function content_disposition_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return content_disposition_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?content_disposition_arrayLikeToArray(e,t):void 0}}(e,t)||function content_disposition_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function content_disposition_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function createHeaders(e,t){const i=new Headers;if(!e||!t||"object"!=typeof t)return i;for(const e in t){const a=t[e];void 0!==a&&i.append(e,a)}return i}function getResponseOrigin(e){return URL.parse(e)?.origin??null}function validateRangeRequestCapabilities(e){let t=e.responseHeaders,i=e.isHttp,a=e.rangeChunkSize,s=e.disableRange;const r={contentLength:0,isRangeSupported:!1},n=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(n))return r;r.contentLength=n;if(n<=2*a)return r;if(s||!i)return r;if("bytes"!==t.get("Accept-Ranges"))return r;"identity"===(t.get("Content-Encoding")||"identity")&&(r.isRangeSupported=!0);return r}function extractFilenameFromHeader(e){const t=e.get("Content-Disposition");if(t){let e=function getFilenameFromContentDispositionHeader(e){let t=!0,i=toParamRegExp("filename\\*","i").exec(e);if(i){i=i[1];let e=rfc2616unquote(i);e=unescape(e);e=rfc5987decode(e);e=rfc2047decode(e);return fixupEncoding(e)}i=function rfc2231getparam(e){const t=[];let i;const a=toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=a.exec(e));){let e=content_disposition_slicedToArray(i,4),a=e[1],s=e[2],r=e[3];a=parseInt(a,10);if(a in t){if(0===a)break}else t[a]=[s,r]}const s=[];for(let e=0;e<t.length&&e in t;++e){let i=content_disposition_slicedToArray(t[e],2),a=i[0],r=i[1];r=rfc2616unquote(r);if(a){r=unescape(r);0===e&&(r=rfc5987decode(r))}s.push(r)}return s.join("")}(e);if(i)return fixupEncoding(rfc2047decode(i));i=toParamRegExp("filename","i").exec(e);if(i){i=i[1];let e=rfc2616unquote(i);e=rfc2047decode(e);return fixupEncoding(e)}function toParamRegExp(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function textdecode(e,i){if(e){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const a=new TextDecoder(e,{fatal:!0}),s=stringToBytes(i);i=a.decode(s);t=!1}catch{}}return i}function fixupEncoding(e){if(t&&/[\x80-\xff]/.test(e)){e=textdecode("utf-8",e);t&&(e=textdecode("iso-8859-1",e))}return e}function rfc2616unquote(e){if(e.startsWith('"')){const t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){const i=t[e].indexOf('"');if(-1!==i){t[e]=t[e].slice(0,i);t.length=e+1}t[e]=t[e].replaceAll(/\\(.)/g,"$1")}e=t.join('"')}return e}function rfc5987decode(e){const t=e.indexOf("'");return-1===t?e:textdecode(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,""))}function rfc2047decode(e){return!e.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(e,t,i,a){if("q"===i||"Q"===i)return textdecode(t,a=(a=a.replaceAll("_"," ")).replaceAll(/=([0-9a-f]{2})/gi,function(e,t){return String.fromCharCode(parseInt(t,16))}));try{a=atob(a)}catch{}return textdecode(t,a)})}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(isPdfFile(e))return e}return null}function createResponseError(e,t){return new ResponseException(`Unexpected server response (${e}) while retrieving PDF "${t.href}".`,e,404===e||0===e&&"file:"===t.protocol)}function ensureResponseOrigin(e,t){if(e!==t)throw new Error(`Expected range response-origin "${e}" to match "${t}".`)}function fetch_stream_defineProperty(e,t,i){return(t=function fetch_stream_toPropertyKey(e){var t=function fetch_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function fetchUrl(e,t,i,a){return fetch(e,{method:"GET",headers:t,signal:a.signal,mode:"cors",credentials:i?"include":"same-origin",redirect:"follow"})}function ensureResponseStatus(e,t){if(200!==e&&206!==e)throw createResponseError(e,t)}function getArrayBuffer(e){if(e instanceof Uint8Array)return e.buffer;if(e instanceof ArrayBuffer)return e;throw new Error(`getArrayBuffer - unexpected data: ${e}`)}class PDFFetchStream extends BasePDFStream{constructor(e){super(e,PDFFetchStreamReader,PDFFetchStreamRangeReader);fetch_stream_defineProperty(this,"_responseOrigin",null);const t=e.httpHeaders,i=e.url;assert(/https?:|blob:|capacitor:/.test(i.protocol),"PDFFetchStream only supports http(s)://, blob:, and capacitor:// URLs.");this.headers=createHeaders(!0,t)}}class PDFFetchStreamReader extends BasePDFStreamReader{constructor(e){super(e);fetch_stream_defineProperty(this,"_abortController",new AbortController);fetch_stream_defineProperty(this,"_reader",null);const t=e._source,i=t.disableRange,a=t.disableStream,s=t.rangeChunkSize,r=t.url,n=t.withCredentials;this._isStreamingSupported=!a;const o=new Headers(e.headers);fetchUrl(r,o,n,this._abortController).then(t=>{e._responseOrigin=getResponseOrigin(t.url);ensureResponseStatus(t.status,r);this._reader=t.body.getReader();const a=t.headers,n=validateRangeRequestCapabilities({responseHeaders:a,isHttp:!0,rangeChunkSize:s,disableRange:i}),o=n.contentLength,l=n.isRangeSupported;this._contentLength=o;this._isRangeSupported=l;this._filename=extractFilenameFromHeader(a);!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new AbortException("Streaming is disabled."));this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const e=await this._reader.read(),t=e.value,i=e.done;if(i)return{value:t,done:i};this._loaded+=t.byteLength;this._callOnProgress();return{value:getArrayBuffer(t),done:!1}}cancel(e){this._reader?.cancel(e);this._abortController.abort()}}class PDFFetchStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);fetch_stream_defineProperty(this,"_abortController",new AbortController);fetch_stream_defineProperty(this,"_readCapability",Promise.withResolvers());fetch_stream_defineProperty(this,"_reader",null);const a=e._source,s=a.url,r=a.withCredentials,n=new Headers(e.headers);n.append("Range",`bytes=${t}-${i-1}`);fetchUrl(s,n,r,this._abortController).then(t=>{ensureResponseOrigin(getResponseOrigin(t.url),e._responseOrigin);ensureResponseStatus(t.status,s);this._reader=t.body.getReader();this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const e=await this._reader.read(),t=e.value,i=e.done;return i?{value:t,done:i}:{value:getArrayBuffer(t),done:!1}}cancel(e){this._reader?.cancel(e);this._abortController.abort()}}__webpack_require__(116);function transport_stream_classPrivateFieldInitSpec(e,t,i){transport_stream_checkPrivateRedeclaration(e,t),t.set(e,i)}function transport_stream_classPrivateFieldGet(e,t){return e.get(transport_stream_assertClassBrand(e,t))}function transport_stream_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function transport_stream_defineProperty(e,t,i){return(t=function transport_stream_toPropertyKey(e){var t=function transport_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function transport_stream_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function transport_stream_getArrayBuffer(e){return e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function endRequests(){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}var ir=new WeakSet;class PDFDataTransportStream extends BasePDFStream{constructor(e){super(e,PDFDataTransportStreamReader,PDFDataTransportStreamRangeReader);!function transport_stream_classPrivateMethodInitSpec(e,t){transport_stream_checkPrivateRedeclaration(e,t),t.add(e)}(this,ir);transport_stream_defineProperty(this,"_progressiveDone",!1);transport_stream_defineProperty(this,"_queuedChunks",[]);const t=e.pdfDataRangeTransport,i=t.initialData,a=t.progressiveDone;if(i?.length>0){const e=transport_stream_getArrayBuffer(i);this._queuedChunks.push(e)}this._progressiveDone=a;t.transportReady(e=>{switch(e.type){case"range":case"progressiveRead":transport_stream_assertClassBrand(ir,this,_onReceiveData).call(this,e.begin,e.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone();this._progressiveDone=!0}})}getFullReader(){const e=super.getFullReader();this._queuedChunks=null;return e}getRangeReader(e,t){const i=super.getRangeReader(e,t);if(i){i.onDone=()=>this._rangeReaders.delete(i);this._source.pdfDataRangeTransport.requestDataRange(e,t)}return i}cancelAllRequests(e){super.cancelAllRequests(e);this._source.pdfDataRangeTransport.abort()}}function _onReceiveData(e,t){const i=transport_stream_getArrayBuffer(t);if(void 0===e)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const t=this._rangeReaders.keys().find(t=>t._begin===e);assert(t,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");t._enqueue(i)}}var ar=new WeakMap;class PDFDataTransportStreamReader extends BasePDFStreamReader{constructor(e){super(e);transport_stream_classPrivateFieldInitSpec(this,ar,endRequests.bind(this));transport_stream_defineProperty(this,"_done",!1);transport_stream_defineProperty(this,"_queuedChunks",null);transport_stream_defineProperty(this,"_requests",[]);const t=e._source,i=t.pdfDataRangeTransport,a=t.disableRange,s=t.disableStream,r=i.length,n=i.contentDispositionFilename;this._queuedChunks=e._queuedChunks||[];for(const e of this._queuedChunks)this._loaded+=e.byteLength;this._done=e._progressiveDone;this._contentLength=r;this._isStreamingSupported=!s;this._isRangeSupported=!a;isPdfFile(n)&&(this._filename=n);this._headersCapability.resolve();const o=this._loaded;Promise.resolve().then(()=>{o>0&&this._loaded===o&&this._callOnProgress()})}_enqueue(e){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunks.push(e);this._loaded+=e.byteLength;this._callOnProgress()}}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;transport_stream_classPrivateFieldGet(ar,this).call(this)}progressiveDone(){this._done||=!0;0===this._queuedChunks.length&&transport_stream_classPrivateFieldGet(ar,this).call(this)}}var sr=new WeakMap;class PDFDataTransportStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);transport_stream_classPrivateFieldInitSpec(this,sr,endRequests.bind(this));transport_stream_defineProperty(this,"onDone",null);transport_stream_defineProperty(this,"_begin",-1);transport_stream_defineProperty(this,"_done",!1);transport_stream_defineProperty(this,"_queuedChunk",null);transport_stream_defineProperty(this,"_requests",[]);this._begin=t}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});transport_stream_classPrivateFieldGet(sr,this).call(this)}this._done=!0;this.onDone?.()}}async read(){if(this._queuedChunk){const e=this._queuedChunk;this._queuedChunk=null;return{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;transport_stream_classPrivateFieldGet(sr,this).call(this);this.onDone?.()}}function network_toArray(e){return network_arrayWithHoles(e)||function network_iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||network_unsupportedIterableToArray(e)||network_nonIterableRest()}function network_slicedToArray(e,t){return network_arrayWithHoles(e)||function network_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||network_unsupportedIterableToArray(e,t)||network_nonIterableRest()}function network_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function network_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return network_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?network_arrayLikeToArray(e,t):void 0}}function network_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function network_arrayWithHoles(e){if(Array.isArray(e))return e}function network_classPrivateMethodInitSpec(e,t){network_checkPrivateRedeclaration(e,t),t.add(e)}function network_defineProperty(e,t,i){return(t=function network_toPropertyKey(e){var t=function network_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function network_classPrivateFieldInitSpec(e,t,i){network_checkPrivateRedeclaration(e,t),t.set(e,i)}function network_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function network_classPrivateFieldGet(e,t){return e.get(network_assertClassBrand(e,t))}function network_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var rr=new WeakMap,nr=new WeakSet;class PDFNetworkStream extends BasePDFStream{constructor(e){super(e,PDFNetworkStreamReader,PDFNetworkStreamRangeReader);network_classPrivateMethodInitSpec(this,nr);network_classPrivateFieldInitSpec(this,rr,new WeakMap);network_defineProperty(this,"_responseOrigin",null);const t=e.httpHeaders,i=e.url;this.url=i;this.isHttp=/https?:/.test(i.protocol);this.headers=createHeaders(this.isHttp,t)}_request(e){const t=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};network_classPrivateFieldGet(rr,this).set(t,i);t.open("GET",this.url);t.withCredentials=this._source.withCredentials;for(const e of this.headers){var a=network_slicedToArray(e,2);const i=a[0],s=a[1];t.setRequestHeader(i,s)}if(this.isHttp&&"begin"in e&&"end"in e){t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`);i.validateStatus=e=>206===e||200===e}else i.validateStatus=e=>200===e;t.responseType="arraybuffer";assert(e.onError,"Expected `onError` callback to be provided.");t.onerror=()=>e.onError(t.status);t.onreadystatechange=network_assertClassBrand(nr,this,_onStateChange).bind(this,t);t.onprogress=network_assertClassBrand(nr,this,_onProgress).bind(this,t);t.send(null);return t}_abortRequest(e){if(network_classPrivateFieldGet(rr,this).has(e)){network_classPrivateFieldGet(rr,this).delete(e);e.abort()}}getRangeReader(e,t){const i=super.getRangeReader(e,t);i&&(i.onClosed=()=>this._rangeReaders.delete(i));return i}}function _onProgress(e,t){const i=network_classPrivateFieldGet(rr,this).get(e);i?.onProgress?.(t)}function _onStateChange(e,t){const i=network_classPrivateFieldGet(rr,this).get(e);if(!i)return;if(e.readyState>=2&&i.onHeadersReceived){i.onHeadersReceived();delete i.onHeadersReceived}if(4!==e.readyState)return;if(!network_classPrivateFieldGet(rr,this).has(e))return;network_classPrivateFieldGet(rr,this).delete(e);if(0===e.status&&this.isHttp){i.onError(e.status);return}const a=e.status||200;if(!i.validateStatus(a)){i.onError(e.status);return}const s=function network_getArrayBuffer(e){return"string"!=typeof e?e:stringToBytes(e).buffer}(e.response);if(206===a){const t=e.getResponseHeader("Content-Range");if(/bytes \d+-\d+\/\d+/.test(t))i.onDone(s);else{warn('Missing or invalid "Content-Range" header.');i.onError(0)}}else s?i.onDone(s):i.onError(e.status)}var or=new WeakMap,lr=new WeakSet;class PDFNetworkStreamReader extends BasePDFStreamReader{constructor(e){super(e);network_classPrivateMethodInitSpec(this,lr);network_classPrivateFieldInitSpec(this,or,endRequests.bind(this));network_defineProperty(this,"_cachedChunks",[]);network_defineProperty(this,"_done",!1);network_defineProperty(this,"_requests",[]);network_defineProperty(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:network_assertClassBrand(lr,this,_onHeadersReceived).bind(this),onDone:network_assertClassBrand(lr,this,_onDone).bind(this),onError:network_assertClassBrand(lr,this,_onError).bind(this),onProgress:network_assertClassBrand(lr,this,_onProgress2).bind(this)})}async read(){await this._headersCapability.promise;if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;this._headersCapability.reject(e);network_classPrivateFieldGet(or,this).call(this);this._stream._abortRequest(this._fullRequestXhr);this._fullRequestXhr=null}}function _onHeadersReceived(){const e=this._stream,t=e._source,i=t.disableRange,a=t.rangeChunkSize,s=this._fullRequestXhr;e._responseOrigin=getResponseOrigin(s.responseURL);const r=s.getAllResponseHeaders(),n=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(e=>{const t=network_toArray(e.split(": "));return[t[0],network_arrayLikeToArray(t).slice(1).join(": ")]}):[]),o=validateRangeRequestCapabilities({responseHeaders:n,isHttp:e.isHttp,rangeChunkSize:a,disableRange:i}),l=o.contentLength,c=o.isRangeSupported;this._contentLength=l;this._isRangeSupported=c;this._filename=extractFilenameFromHeader(n);this._isRangeSupported&&e._abortRequest(s);this._headersCapability.resolve()}function _onDone(e){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._cachedChunks.push(e);this._done=!0;0===this._cachedChunks.length&&network_classPrivateFieldGet(or,this).call(this)}function _onError(e){this._storedError=createResponseError(e,this._stream.url);this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0;this._cachedChunks.length=0}function _onProgress2(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}var cr=new WeakMap,dr=new WeakSet;class PDFNetworkStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);network_classPrivateMethodInitSpec(this,dr);network_classPrivateFieldInitSpec(this,cr,endRequests.bind(this));network_defineProperty(this,"onClosed",null);network_defineProperty(this,"_done",!1);network_defineProperty(this,"_queuedChunk",null);network_defineProperty(this,"_requests",[]);network_defineProperty(this,"_storedError",null);this._requestXhr=e._request({begin:t,end:i,onHeadersReceived:network_assertClassBrand(dr,this,_onHeadersReceived2).bind(this),onDone:network_assertClassBrand(dr,this,_onDone2).bind(this),onError:network_assertClassBrand(dr,this,_onError2).bind(this),onProgress:null})}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const e=this._queuedChunk;this._queuedChunk=null;return{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;network_classPrivateFieldGet(cr,this).call(this);this._stream._abortRequest(this._requestXhr);this.onClosed?.()}}function _onHeadersReceived2(){const e=getResponseOrigin(this._requestXhr?.responseURL);try{ensureResponseOrigin(e,this._stream._responseOrigin)}catch(e){this._storedError=e;network_assertClassBrand(dr,this,_onError2).call(this,0)}}function _onDone2(e){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;network_classPrivateFieldGet(cr,this).call(this);this.onClosed?.()}function _onError2(e){this._storedError??=createResponseError(e,this._stream.url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0;this._queuedChunk=null}function node_stream_defineProperty(e,t,i){return(t=function node_stream_toPropertyKey(e){var t=function node_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function getReadableStream(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=process.getBuiltinModule("fs"),a=process.getBuiltinModule("stream").Readable,s=i.createReadStream(e,t);return a.toWeb(s)}class PDFNodeStream extends BasePDFStream{constructor(e){super(e,PDFNodeStreamReader,PDFNodeStreamRangeReader);assert("file:"===e.url.protocol,"PDFNodeStream only supports file:// URLs.")}}class PDFNodeStreamReader extends BasePDFStreamReader{constructor(e){super(e);node_stream_defineProperty(this,"_reader",null);const t=e._source,i=t.disableRange,a=t.disableStream,s=t.rangeChunkSize,r=t.url;this._isStreamingSupported=!a;process.getBuiltinModule("fs/promises").lstat(r).then(e=>{const t=getReadableStream(r);this._reader=t.getReader();const a=e.size;this._contentLength=a;this._isRangeSupported=!i&&a>2*s;!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new AbortException("Streaming is disabled."));this._headersCapability.resolve()}).catch(e=>{"ENOENT"===e.code&&(e=createResponseError(0,r));this._headersCapability.reject(e)})}async read(){await this._headersCapability.promise;const e=await this._reader.read(),t=e.value,i=e.done;if(i)return{value:t,done:i};this._loaded+=t.byteLength;this._callOnProgress();return{value:getArrayBuffer(t),done:!1}}cancel(e){this._reader?.cancel(e)}}class PDFNodeStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);node_stream_defineProperty(this,"_readCapability",Promise.withResolvers());node_stream_defineProperty(this,"_reader",null);const a=e._source.url;try{const e=getReadableStream(a,{start:t,end:i-1});this._reader=e.getReader();this._readCapability.resolve()}catch(e){this._readCapability.reject(e)}}async read(){await this._readCapability.promise;const e=await this._reader.read(),t=e.value,i=e.done;return i?{value:t,done:i}:{value:getArrayBuffer(t),done:!1}}cancel(e){this._reader?.cancel(e)}}function worker_options_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class GlobalWorkerOptions{static get workerPort(){return worker_options_assertClassBrand(GlobalWorkerOptions,this,hr)._}static set workerPort(e){if(!("undefined"!=typeof Worker&&e instanceof Worker)&&null!==e)throw new Error("Invalid `workerPort` type.");hr._=worker_options_assertClassBrand(GlobalWorkerOptions,this,e)}static get workerSrc(){return worker_options_assertClassBrand(GlobalWorkerOptions,this,ur)._}static set workerSrc(e){if("string"!=typeof e)throw new Error("Invalid `workerSrc` type.");ur._=worker_options_assertClassBrand(GlobalWorkerOptions,this,e)}}var hr={_:null},ur={_:""};function metadata_classPrivateFieldInitSpec(e,t,i){(function metadata_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function metadata_classPrivateFieldGet(e,t){return e.get(metadata_assertClassBrand(e,t))}function metadata_classPrivateFieldSet(e,t,i){return e.set(metadata_assertClassBrand(e,t),i),i}function metadata_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var _r=new WeakMap,pr=new WeakMap;class Metadata{constructor(e){let t=e.parsedData,i=e.rawData;metadata_classPrivateFieldInitSpec(this,_r,void 0);metadata_classPrivateFieldInitSpec(this,pr,void 0);metadata_classPrivateFieldSet(_r,this,t);metadata_classPrivateFieldSet(pr,this,i)}getRaw(){return metadata_classPrivateFieldGet(pr,this)}get(e){return metadata_classPrivateFieldGet(_r,this).get(e)??null}[Symbol.iterator](){return metadata_classPrivateFieldGet(_r,this).entries()}}function optional_content_config_slicedToArray(e,t){return function optional_content_config_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function optional_content_config_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function optional_content_config_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return optional_content_config_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?optional_content_config_arrayLikeToArray(e,t):void 0}}(e,t)||function optional_content_config_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function optional_content_config_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function optional_content_config_classPrivateFieldInitSpec(e,t,i){optional_content_config_checkPrivateRedeclaration(e,t),t.set(e,i)}function optional_content_config_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function optional_content_config_classPrivateFieldGet(e,t){return e.get(optional_content_config_assertClassBrand(e,t))}function optional_content_config_classPrivateFieldSet(e,t,i){return e.set(optional_content_config_assertClassBrand(e,t),i),i}function optional_content_config_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const gr=Symbol("INTERNAL");var fr=new WeakMap,mr=new WeakMap,vr=new WeakMap,yr=new WeakMap;class OptionalContentGroup{constructor(e,t){let i=t.name,a=t.intent,s=t.usage,r=t.rbGroups;optional_content_config_classPrivateFieldInitSpec(this,fr,!1);optional_content_config_classPrivateFieldInitSpec(this,mr,!1);optional_content_config_classPrivateFieldInitSpec(this,vr,!1);optional_content_config_classPrivateFieldInitSpec(this,yr,!0);optional_content_config_classPrivateFieldSet(fr,this,!!(e&d));optional_content_config_classPrivateFieldSet(mr,this,!!(e&h));this.name=i;this.intent=a;this.usage=s;this.rbGroups=r}get visible(){if(optional_content_config_classPrivateFieldGet(vr,this))return optional_content_config_classPrivateFieldGet(yr,this);if(!optional_content_config_classPrivateFieldGet(yr,this))return!1;const e=this.usage,t=e.print,i=e.view;return optional_content_config_classPrivateFieldGet(fr,this)?"OFF"!==i?.viewState:!optional_content_config_classPrivateFieldGet(mr,this)||"OFF"!==t?.printState}_setVisible(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e!==gr&&unreachable("Internal method `_setVisible` called.");optional_content_config_classPrivateFieldSet(vr,this,i);optional_content_config_classPrivateFieldSet(yr,this,t)}}var Pr=new WeakMap,wr=new WeakMap,br=new WeakMap,Fr=new WeakMap,Sr=new WeakSet;class OptionalContentConfig{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;!function optional_content_config_classPrivateMethodInitSpec(e,t){optional_content_config_checkPrivateRedeclaration(e,t),t.add(e)}(this,Sr);optional_content_config_classPrivateFieldInitSpec(this,Pr,null);optional_content_config_classPrivateFieldInitSpec(this,wr,new Map);optional_content_config_classPrivateFieldInitSpec(this,br,null);optional_content_config_classPrivateFieldInitSpec(this,Fr,null);this.renderingIntent=t;this.name=null;this.creator=null;if(null!==e){this.name=e.name;this.creator=e.creator;optional_content_config_classPrivateFieldSet(Fr,this,e.order);for(const i of e.groups)optional_content_config_classPrivateFieldGet(wr,this).set(i.id,new OptionalContentGroup(t,i));if("OFF"===e.baseState)for(const e of optional_content_config_classPrivateFieldGet(wr,this).values())e._setVisible(gr,!1);for(const t of e.on)optional_content_config_classPrivateFieldGet(wr,this).get(t)._setVisible(gr,!0);for(const t of e.off)optional_content_config_classPrivateFieldGet(wr,this).get(t)._setVisible(gr,!1);optional_content_config_classPrivateFieldSet(br,this,this.getHash())}}isVisible(e){if(0===optional_content_config_classPrivateFieldGet(wr,this).size)return!0;if(!e){info("Optional content group not defined.");return!0}if("OCG"===e.type){if(!optional_content_config_classPrivateFieldGet(wr,this).has(e.id)){warn(`Optional content group not found: ${e.id}`);return!0}return optional_content_config_classPrivateFieldGet(wr,this).get(e.id).visible}if("OCMD"===e.type){if(e.expression)return optional_content_config_assertClassBrand(Sr,this,_evaluateVisibilityExpression).call(this,e.expression);if(!e.policy||"AnyOn"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(wr,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(optional_content_config_classPrivateFieldGet(wr,this).get(t).visible)return!0}return!1}if("AllOn"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(wr,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(!optional_content_config_classPrivateFieldGet(wr,this).get(t).visible)return!1}return!0}if("AnyOff"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(wr,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(!optional_content_config_classPrivateFieldGet(wr,this).get(t).visible)return!0}return!1}if("AllOff"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(wr,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(optional_content_config_classPrivateFieldGet(wr,this).get(t).visible)return!1}return!0}warn(`Unknown optional content policy ${e.policy}.`);return!0}warn(`Unknown group type ${e.type}.`);return!0}setVisibility(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const a=optional_content_config_classPrivateFieldGet(wr,this).get(e);if(a){if(i&&t&&a.rbGroups.length)for(const t of a.rbGroups)for(const i of t)i!==e&&optional_content_config_classPrivateFieldGet(wr,this).get(i)?._setVisible(gr,!1,!0);a._setVisible(gr,!!t,!0);optional_content_config_classPrivateFieldSet(Pr,this,null)}else warn(`Optional content group not found: ${e}`)}setOCGState(e){let t,i=e.state,a=e.preserveRB;for(const e of i){switch(e){case"ON":case"OFF":case"Toggle":t=e;continue}const i=optional_content_config_classPrivateFieldGet(wr,this).get(e);if(i)switch(t){case"ON":this.setVisibility(e,!0,a);break;case"OFF":this.setVisibility(e,!1,a);break;case"Toggle":this.setVisibility(e,!i.visible,a)}}optional_content_config_classPrivateFieldSet(Pr,this,null)}get hasInitialVisibility(){return null===optional_content_config_classPrivateFieldGet(br,this)||this.getHash()===optional_content_config_classPrivateFieldGet(br,this)}getOrder(){return optional_content_config_classPrivateFieldGet(wr,this).size?optional_content_config_classPrivateFieldGet(Fr,this)?optional_content_config_classPrivateFieldGet(Fr,this).slice():[...optional_content_config_classPrivateFieldGet(wr,this).keys()]:null}getGroup(e){return optional_content_config_classPrivateFieldGet(wr,this).get(e)||null}getHash(){if(null!==optional_content_config_classPrivateFieldGet(Pr,this))return optional_content_config_classPrivateFieldGet(Pr,this);const e=new MurmurHash3_64;for(const i of optional_content_config_classPrivateFieldGet(wr,this)){var t=optional_content_config_slicedToArray(i,2);const a=t[0],s=t[1];e.update(`${a}:${s.visible}`)}return optional_content_config_classPrivateFieldSet(Pr,this,e.hexdigest())}[Symbol.iterator](){return optional_content_config_classPrivateFieldGet(wr,this).entries()}}function _evaluateVisibilityExpression(e){const t=e.length;if(t<2)return!0;const i=e[0];for(let a=1;a<t;a++){const t=e[a];let s;if(Array.isArray(t))s=optional_content_config_assertClassBrand(Sr,this,_evaluateVisibilityExpression).call(this,t);else{if(!optional_content_config_classPrivateFieldGet(wr,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}s=optional_content_config_classPrivateFieldGet(wr,this).get(t).visible}switch(i){case"And":if(!s)return!1;break;case"Or":if(s)return!0;break;case"Not":return!s;default:return!0}}return"And"===i}function pages_mapper_slicedToArray(e,t){return function pages_mapper_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pages_mapper_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pages_mapper_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pages_mapper_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pages_mapper_arrayLikeToArray(e,t):void 0}}(e,t)||function pages_mapper_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pages_mapper_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pages_mapper_classPrivateFieldInitSpec(e,t,i){pages_mapper_checkPrivateRedeclaration(e,t),t.set(e,i)}function pages_mapper_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pages_mapper_classPrivateFieldSet(e,t,i){return e.set(pages_mapper_assertClassBrand(e,t),i),i}function pages_mapper_classPrivateFieldGet(e,t){return e.get(pages_mapper_assertClassBrand(e,t))}function pages_mapper_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Cr=new WeakMap,Ar=new WeakMap,xr=new WeakMap,kr=new WeakMap,Er=new WeakMap,Tr=new WeakSet;class PagesMapper{constructor(){!function pages_mapper_classPrivateMethodInitSpec(e,t){pages_mapper_checkPrivateRedeclaration(e,t),t.add(e)}(this,Tr);pages_mapper_classPrivateFieldInitSpec(this,Cr,null);pages_mapper_classPrivateFieldInitSpec(this,Ar,null);pages_mapper_classPrivateFieldInitSpec(this,xr,0);pages_mapper_classPrivateFieldInitSpec(this,kr,null);pages_mapper_classPrivateFieldInitSpec(this,Er,null)}get pagesNumber(){return pages_mapper_classPrivateFieldGet(xr,this)}set pagesNumber(e){if(pages_mapper_classPrivateFieldGet(xr,this)!==e){pages_mapper_classPrivateFieldSet(xr,this,e);pages_mapper_classPrivateFieldSet(Cr,this,null);pages_mapper_classPrivateFieldSet(Ar,this,null)}}movePages(e,t,i){pages_mapper_assertClassBrand(Tr,this,_ensureInit).call(this);const a=pages_mapper_classPrivateFieldGet(Cr,this),s=pages_mapper_assertClassBrand(Tr,this,_buildIdToPageNumber).call(this),r=t.length,n=new Uint32Array(r);let o=0;for(let e=0;e<r;e++){const s=t[e]-1;n[e]=a[s];s<i&&o++}const l=pages_mapper_classPrivateFieldGet(xr,this),c=l-r,d=MathClamp(i-o,0,c);for(let t=0,i=0;t<l;t++)e.has(t+1)||(a[i++]=a[t]);a.copyWithin(d+r,d,c);a.set(n,d);pages_mapper_assertClassBrand(Tr,this,_updatePrevPageNumbers).call(this,s);a.every((e,t)=>e===t+1)&&pages_mapper_classPrivateFieldSet(Cr,this,null)}deletePages(e){pages_mapper_assertClassBrand(Tr,this,_ensureInit).call(this);const t=pages_mapper_classPrivateFieldGet(Cr,this),i=pages_mapper_assertClassBrand(Tr,this,_buildIdToPageNumber).call(this);pages_mapper_classPrivateFieldSet(Er,this,{pageNumberToId:t.slice(),pagesNumber:pages_mapper_classPrivateFieldGet(xr,this),prevPageNumbers:pages_mapper_classPrivateFieldGet(Ar,this).slice()});const a=pages_mapper_classPrivateFieldGet(xr,this)-e.length;pages_mapper_classPrivateFieldSet(xr,this,a);const s=pages_mapper_classPrivateFieldSet(Cr,this,new Uint32Array(a));pages_mapper_classPrivateFieldSet(Ar,this,new Int32Array(a));let r=0,n=0;for(const i of e){const e=i-1;if(e!==r){s.set(t.subarray(r,e),n);n+=e-r}r=e+1}r<t.length&&s.set(t.subarray(r),n);pages_mapper_assertClassBrand(Tr,this,_updatePrevPageNumbers).call(this,i,new Set(e))}cancelDelete(){if(pages_mapper_classPrivateFieldGet(Er,this)){pages_mapper_classPrivateFieldSet(Cr,this,pages_mapper_classPrivateFieldGet(Er,this).pageNumberToId);pages_mapper_classPrivateFieldSet(xr,this,pages_mapper_classPrivateFieldGet(Er,this).pagesNumber);pages_mapper_classPrivateFieldSet(Ar,this,pages_mapper_classPrivateFieldGet(Er,this).prevPageNumbers);pages_mapper_classPrivateFieldSet(Er,this,null)}}cleanSavedData(){pages_mapper_classPrivateFieldSet(Er,this,null)}copyPages(e){pages_mapper_assertClassBrand(Tr,this,_ensureInit).call(this);pages_mapper_classPrivateFieldSet(kr,this,{pageNumbers:e,pageIds:e.map(e=>pages_mapper_classPrivateFieldGet(Cr,this)[e-1])})}cancelCopy(){pages_mapper_classPrivateFieldSet(kr,this,null)}pastePages(e){pages_mapper_assertClassBrand(Tr,this,_ensureInit).call(this);const t=pages_mapper_classPrivateFieldGet(Cr,this),i=pages_mapper_assertClassBrand(Tr,this,_buildIdToPageNumber).call(this),a=pages_mapper_classPrivateFieldGet(kr,this),s=a.pageNumbers,r=a.pageIds,n=pages_mapper_classPrivateFieldGet(xr,this)+s.length;pages_mapper_classPrivateFieldSet(xr,this,n);const o=pages_mapper_classPrivateFieldSet(Cr,this,new Uint32Array(n));pages_mapper_classPrivateFieldSet(Ar,this,new Int32Array(n));o.set(t.subarray(0,e),0);o.set(r,e);o.set(t.subarray(e),e+s.length);pages_mapper_assertClassBrand(Tr,this,_updatePrevPageNumbers).call(this,i,null,e,s);pages_mapper_classPrivateFieldSet(kr,this,null)}hasBeenAltered(){return null!==pages_mapper_classPrivateFieldGet(Cr,this)}getPageMappingForSaving(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e??=pages_mapper_assertClassBrand(Tr,this,_buildIdToPageNumber).call(this);let t=0;for(const i of e.values())t=Math.max(t,i.length);const i=new Array(t);for(let e=0;e<t;e++)i[e]={document:null,pageIndices:[],includePages:[]};for(const t of e){var a=pages_mapper_slicedToArray(t,2);const e=a[0],s=a[1];for(let t=0,a=s.length;t<a;t++)i[t].includePages.push([e-1,s[t]-1])}for(const e of i){const t=e.includePages,i=e.pageIndices;t.sort((e,t)=>e[0]-t[0]);for(let e=0,a=t.length;e<a;e++){i.push(t[e][1]);t[e]=t[e][0]}}return i}extractPages(e){e=Array.from(e).sort((e,t)=>e-t);const t=new Map;for(let i=0,a=e.length;i<a;i++){const a=this.getPageId(e[i]);t.getOrInsertComputed(a,makeArr).push(i+1)}return this.getPageMappingForSaving(t)}getPrevPageNumber(e){return pages_mapper_classPrivateFieldGet(Ar,this)?.[e-1]??0}getPageNumber(e){if(!pages_mapper_classPrivateFieldGet(Cr,this))return e;const t=pages_mapper_classPrivateFieldGet(Cr,this);for(let i=0,a=pages_mapper_classPrivateFieldGet(xr,this);i<a;i++)if(t[i]===e)return i+1;return 0}getPageId(e){return pages_mapper_classPrivateFieldGet(Cr,this)?.[e-1]??e}getMapping(){return pages_mapper_classPrivateFieldGet(Cr,this)?.subarray(0,this.pagesNumber)}}function _ensureInit(){if(pages_mapper_classPrivateFieldGet(Cr,this))return;const e=pages_mapper_classPrivateFieldGet(xr,this),t=pages_mapper_classPrivateFieldSet(Cr,this,new Uint32Array(e));for(let i=0;i<e;i++)t[i]=i+1;pages_mapper_classPrivateFieldSet(Ar,this,new Int32Array(t))}function _buildIdToPageNumber(){const e=new Map,t=pages_mapper_classPrivateFieldGet(Cr,this);for(let i=0,a=pages_mapper_classPrivateFieldGet(xr,this);i<a;i++){const a=t[i],s=e.get(a);s?s.push(i+1):e.set(a,[i+1])}return e}function _updatePrevPageNumbers(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const s=pages_mapper_classPrivateFieldGet(Ar,this),r=pages_mapper_classPrivateFieldGet(Cr,this),n=i+(a?.length??0),o=new Map;for(let l=0,c=pages_mapper_classPrivateFieldGet(xr,this);l<c;l++){if(l>=i&&l<n){s[l]=-a[l-i];continue}const c=r[l],d=e.get(c);let h=o.get(c)||0;if(t&&d)for(;h<d.length&&t.has(d[h]);)h++;s[l]=d?.[h];o.set(c,h+1)}}function pdf_objects_slicedToArray(e,t){return function pdf_objects_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_objects_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_objects_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_objects_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_objects_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_objects_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_objects_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pdf_objects_classPrivateFieldInitSpec(e,t,i){(function pdf_objects_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function pdf_objects_classPrivateFieldGet(e,t){return e.get(function pdf_objects_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}const Ir=Symbol("INITIAL_DATA"),dataObj=()=>({...Promise.withResolvers(),data:Ir});var Gr,Br=new WeakMap;class PDFObjects{constructor(){pdf_objects_classPrivateFieldInitSpec(this,Br,new Map)}get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(t){const i=pdf_objects_classPrivateFieldGet(Br,this).getOrInsertComputed(e,dataObj);i.promise.then(()=>t(i.data));return null}const i=pdf_objects_classPrivateFieldGet(Br,this).get(e);if(!i||i.data===Ir)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return i.data}has(e){const t=pdf_objects_classPrivateFieldGet(Br,this).get(e);return!!t&&t.data!==Ir}delete(e){const t=pdf_objects_classPrivateFieldGet(Br,this).get(e);if(!t||t.data===Ir)return!1;pdf_objects_classPrivateFieldGet(Br,this).delete(e);return!0}resolve(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=pdf_objects_classPrivateFieldGet(Br,this).getOrInsertComputed(e,dataObj);if(i.data!==Ir)throw new Error(`Object already resolved ${e}.`);i.data=t;i.resolve()}clear(){for(const e of pdf_objects_classPrivateFieldGet(Br,this).values()){const t=e.data;t?.bitmap?.close()}pdf_objects_classPrivateFieldGet(Br,this).clear()}*[Symbol.iterator](){for(const t of pdf_objects_classPrivateFieldGet(Br,this)){var e=pdf_objects_slicedToArray(t,2);const i=e[0],a=e[1].data;a!==Ir&&(yield[i,a])}}}function text_layer_classPrivateFieldInitSpec(e,t,i){text_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_layer_classPrivateFieldGet(e,t){return e.get(text_layer_assertClassBrand(e,t))}function text_layer_classPrivateFieldSet(e,t,i){return e.set(text_layer_assertClassBrand(e,t),i),i}function text_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Mr=new WeakMap,Dr=new WeakMap,Lr=new WeakMap,Or=new WeakMap,Rr=new WeakMap,Nr=new WeakMap,jr=new WeakMap,Wr=new WeakMap,Ur=new WeakMap,Vr=new WeakMap,Hr=new WeakMap,zr=new WeakMap,$r=new WeakMap,qr=new WeakMap,Xr=new WeakMap,Kr=new WeakMap,Yr=new WeakMap,Zr=new WeakMap,Jr=new WeakMap,Qr=new WeakSet;class TextLayer{constructor(e){let t=e.textContentSource,i=e.images,a=e.container,s=e.viewport;!function text_layer_classPrivateMethodInitSpec(e,t){text_layer_checkPrivateRedeclaration(e,t),t.add(e)}(this,Qr);text_layer_classPrivateFieldInitSpec(this,Mr,Promise.withResolvers());text_layer_classPrivateFieldInitSpec(this,Dr,null);text_layer_classPrivateFieldInitSpec(this,Lr,!1);text_layer_classPrivateFieldInitSpec(this,Or,!!globalThis.FontInspector?.enabled);text_layer_classPrivateFieldInitSpec(this,Rr,null);text_layer_classPrivateFieldInitSpec(this,Nr,null);text_layer_classPrivateFieldInitSpec(this,jr,null);text_layer_classPrivateFieldInitSpec(this,Wr,0);text_layer_classPrivateFieldInitSpec(this,Ur,0);text_layer_classPrivateFieldInitSpec(this,Vr,null);text_layer_classPrivateFieldInitSpec(this,Hr,null);text_layer_classPrivateFieldInitSpec(this,zr,0);text_layer_classPrivateFieldInitSpec(this,$r,0);text_layer_classPrivateFieldInitSpec(this,qr,Object.create(null));text_layer_classPrivateFieldInitSpec(this,Xr,[]);text_layer_classPrivateFieldInitSpec(this,Kr,null);text_layer_classPrivateFieldInitSpec(this,Yr,[]);text_layer_classPrivateFieldInitSpec(this,Zr,new WeakMap);text_layer_classPrivateFieldInitSpec(this,Jr,null);if(t instanceof ReadableStream)text_layer_classPrivateFieldSet(Kr,this,t);else{if("object"!=typeof t)throw new Error('No "textContentSource" parameter specified.');text_layer_classPrivateFieldSet(Kr,this,new ReadableStream({start(e){e.enqueue(t);e.close()}}))}text_layer_classPrivateFieldSet(Dr,this,text_layer_classPrivateFieldSet(Hr,this,a));text_layer_classPrivateFieldSet(Rr,this,i);text_layer_classPrivateFieldSet($r,this,s.scale*OutputScale.pixelRatio);text_layer_classPrivateFieldSet(zr,this,s.rotation);text_layer_classPrivateFieldSet(jr,this,{div:null,properties:null,ctx:null});const r=s.rawDims,n=r.pageWidth,o=r.pageHeight,l=r.pageX,c=r.pageY;text_layer_classPrivateFieldSet(Jr,this,[1,0,0,-1,-l,c+o]);text_layer_classPrivateFieldSet(Ur,this,n);text_layer_classPrivateFieldSet(Wr,this,o);_ensureMinFontSizeComputed.call(TextLayer);a.style.setProperty("--min-font-size",rn._);setLayerDimensions(a,s);text_layer_classPrivateFieldGet(Mr,this).promise.finally(()=>{nn._.delete(this);text_layer_classPrivateFieldSet(jr,this,null);text_layer_classPrivateFieldSet(qr,this,null)}).catch(()=>{})}static get fontFamilyMap(){const e=FeatureTest.platform,t=e.isWindows,i=e.isFirefox;return shadow(this,"fontFamilyMap",new Map([["sans-serif",(t&&i?"Calibri, ":"")+"sans-serif"],["monospace",(t&&i?"Lucida Console, ":"")+"monospace"]]))}render(){text_layer_classPrivateFieldGet(Rr,this)&&text_layer_classPrivateFieldGet(Dr,this).append(text_layer_classPrivateFieldGet(Rr,this).render());const pump=()=>{text_layer_classPrivateFieldGet(Vr,this).read().then(e=>{let t=e.value;if(e.done)text_layer_classPrivateFieldGet(Mr,this).resolve();else{text_layer_classPrivateFieldGet(Nr,this)??text_layer_classPrivateFieldSet(Nr,this,t.lang);Object.assign(text_layer_classPrivateFieldGet(qr,this),t.styles);text_layer_assertClassBrand(Qr,this,_processItems).call(this,t.items);pump()}},text_layer_classPrivateFieldGet(Mr,this).reject)};text_layer_classPrivateFieldSet(Vr,this,text_layer_classPrivateFieldGet(Kr,this).getReader());nn._.add(this);pump();return text_layer_classPrivateFieldGet(Mr,this).promise}update(e){let t=e.viewport,i=e.onBefore,a=void 0===i?null:i;const s=t.scale*OutputScale.pixelRatio,r=t.rotation;if(r!==text_layer_classPrivateFieldGet(zr,this)){a?.();text_layer_classPrivateFieldSet(zr,this,r);setLayerDimensions(text_layer_classPrivateFieldGet(Hr,this),{rotation:r})}if(s!==text_layer_classPrivateFieldGet($r,this)){a?.();text_layer_classPrivateFieldSet($r,this,s);const e={div:null,properties:null,ctx:_getCtx.call(TextLayer,text_layer_classPrivateFieldGet(Nr,this))};for(const t of text_layer_classPrivateFieldGet(Yr,this)){e.properties=text_layer_classPrivateFieldGet(Zr,this).get(t);e.div=t;text_layer_assertClassBrand(Qr,this,_layout).call(this,e)}}}cancel(){const e=new AbortException("TextLayer task cancelled.");text_layer_classPrivateFieldGet(Vr,this)?.cancel(e).catch(()=>{});text_layer_classPrivateFieldSet(Vr,this,null);text_layer_classPrivateFieldGet(Mr,this).reject(e)}get textDivs(){return text_layer_classPrivateFieldGet(Yr,this)}get textContentItemsStr(){return text_layer_classPrivateFieldGet(Xr,this)}static cleanup(){if(!(text_layer_assertClassBrand(TextLayer,this,nn)._.size>0)){text_layer_assertClassBrand(TextLayer,this,tn)._.clear();for(const e of text_layer_assertClassBrand(TextLayer,this,an)._.values()){e.canvas.remove()}text_layer_assertClassBrand(TextLayer,this,an)._.clear()}}}Gr=TextLayer;function _processItems(e){if(text_layer_classPrivateFieldGet(Lr,this))return;text_layer_classPrivateFieldGet(jr,this).ctx??=_getCtx.call(Gr,text_layer_classPrivateFieldGet(Nr,this));const t=text_layer_classPrivateFieldGet(Yr,this),i=text_layer_classPrivateFieldGet(Xr,this);for(const a of e){if(t.length>1e5){warn("Ignoring additional textDivs for performance reasons.");text_layer_classPrivateFieldSet(Lr,this,!0);return}if(void 0!==a.str){i.push(a.str);text_layer_assertClassBrand(Qr,this,_appendText).call(this,a)}else if("beginMarkedContentProps"===a.type||"beginMarkedContent"===a.type){const e=text_layer_classPrivateFieldGet(Dr,this);text_layer_classPrivateFieldSet(Dr,this,document.createElement("span"));text_layer_classPrivateFieldGet(Dr,this).classList.add("markedContent");a.id&&text_layer_classPrivateFieldGet(Dr,this).setAttribute("id",`${a.id}`);"Artifact"===a.tag&&(text_layer_classPrivateFieldGet(Dr,this).ariaHidden=!0);e.append(text_layer_classPrivateFieldGet(Dr,this))}else"endMarkedContent"===a.type&&text_layer_classPrivateFieldSet(Dr,this,text_layer_classPrivateFieldGet(Dr,this).parentNode)}}function _appendText(e){const t=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};text_layer_classPrivateFieldGet(Yr,this).push(t);const a=Util.transform(text_layer_classPrivateFieldGet(Jr,this),e.transform);let s=Math.atan2(a[1],a[0]);const r=text_layer_classPrivateFieldGet(qr,this)[e.fontName];r.vertical&&(s+=Math.PI/2);let n=text_layer_classPrivateFieldGet(Or,this)&&r.fontSubstitution||r.fontFamily;n=Gr.fontFamilyMap.get(n)||n;const o=Math.hypot(a[2],a[3]),l=o*_getAscent.call(Gr,n,r,text_layer_classPrivateFieldGet(Nr,this));let c,d;if(0===s){c=a[4];d=a[5]-l}else{c=a[4]+l*Math.sin(s);d=a[5]-l*Math.cos(s)}const h=t.style;h.left=`${(100*c/text_layer_classPrivateFieldGet(Ur,this)).toFixed(2)}%`;h.top=`${(100*d/text_layer_classPrivateFieldGet(Wr,this)).toFixed(2)}%`;h.setProperty("--font-height",`${o.toFixed(2)}px`);h.fontFamily=n;i.fontSize=o;t.setAttribute("role","presentation");t.textContent=e.str;t.dir=e.dir;text_layer_classPrivateFieldGet(Or,this)&&(t.dataset.fontName=r.fontSubstitutionLoadedName||e.fontName);0!==s&&(i.angle=s*(180/Math.PI));let u=!1;if(e.str.length>1)u=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),i=Math.abs(e.transform[3]);t!==i&&Math.max(t,i)/Math.min(t,i)>1.5&&(u=!0)}u&&(i.canvasWidth=r.vertical?e.height:e.width);text_layer_classPrivateFieldGet(Zr,this).set(t,i);text_layer_classPrivateFieldGet(jr,this).div=t;text_layer_classPrivateFieldGet(jr,this).properties=i;text_layer_assertClassBrand(Qr,this,_layout).call(this,text_layer_classPrivateFieldGet(jr,this));i.hasText&&text_layer_classPrivateFieldGet(Dr,this).append(t);if(i.hasEOL){const e=document.createElement("br");e.setAttribute("role","presentation");text_layer_classPrivateFieldGet(Dr,this).append(e)}}function _layout(e){const t=e.div,i=e.properties,a=e.ctx,s=t.style;if(0!==i.canvasWidth&&i.hasText){const e=s.fontFamily,r=i.canvasWidth,n=i.fontSize;_ensureCtxFont.call(Gr,a,n*text_layer_classPrivateFieldGet($r,this),e);try{const e=a.measureText(t.textContent).width;e>0&&(transform=`scaleX(${r*text_layer_classPrivateFieldGet($r,this)/e}) ${transform}`)}catch(e){}const o=a.measureText(t.textContent).width;o>0&&s.setProperty("--scale-x",r*text_layer_classPrivateFieldGet($r,this)/o)}0!==i.angle&&s.setProperty("--rotate",`${i.angle}deg`)}function _getCtx(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=text_layer_assertClassBrand(Gr,this,an)._.get(e||="");if(!t){const i=document.createElement("canvas");i.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal";i.lang=e;i.width=i.height=0;document.body.append(i);t=i.getContext("2d",{alpha:!1,willReadFrequently:!0});text_layer_assertClassBrand(Gr,this,an)._.set(e,t);text_layer_assertClassBrand(Gr,this,sn)._.set(t,{size:0,family:""})}return t}function _ensureCtxFont(e,t,i){const a=text_layer_assertClassBrand(Gr,this,sn)._.get(e);if(t!==a.size||i!==a.family){e.font=`${t}px ${i}`;a.size=t;a.family=i}}function _ensureMinFontSizeComputed(){if(null!==text_layer_assertClassBrand(Gr,this,rn)._)return;const e=document.createElement("div");e.style.opacity=0;e.style.lineHeight=1;e.style.fontSize="1px";e.style.position="absolute";e.textContent="X";document.body.append(e);rn._=text_layer_assertClassBrand(Gr,this,e.getBoundingClientRect().height);e.remove()}function _getAscent(e,t,i){const a=text_layer_assertClassBrand(Gr,this,tn)._.get(e);if(a)return a;const s=text_layer_assertClassBrand(Gr,this,_getCtx).call(this,i);s.canvas.width=s.canvas.height=30;text_layer_assertClassBrand(Gr,this,_ensureCtxFont).call(this,s,30,e);const r=s.measureText(""),n=r?.fontBoundingBoxAscent,o=Math.abs(r?.fontBoundingBoxDescent);s.canvas.width=s.canvas.height=0;let l=.8;if(n)l=n/(n+o);else{FeatureTest.platform.isFirefox&&warn("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering.");t.ascent?l=t.ascent:t.descent&&(l=1+t.descent)}text_layer_assertClassBrand(Gr,this,tn)._.set(e,l);return l}var en,tn={_:new Map},an={_:new Map},sn={_:new WeakMap},rn={_:null},nn={_:new Set};function app_options_slicedToArray(e,t){return function app_options_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function app_options_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function app_options_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return app_options_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?app_options_arrayLikeToArray(e,t):void 0}}(e,t)||function app_options_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function app_options_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function app_options_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}{var on=new Map;const e=navigator,t=e.maxTouchPoints,i=e.platform,a=e.userAgent,s=/Android/.test(a);(/\b(?:iPad|iPhone|iPod)(?=;)/.test(a)||"MacIntel"===i&&t>1||s)&&on.set("maxCanvasPixels",5242880);s&&on.set("useSystemFonts",!1)}const ln=1,cn=2,dn=4,hn=8,un=16,_n=128,pn={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},gn={defaultCacheSize:{value:50,kind:cn},passwordPrompt:{value:null,kind:cn},enableDragAndDrop:{value:!0,kind:cn},pageViewMode:{value:"multiple",kind:cn},findController:{value:null,kind:cn},secondaryFindController:{value:null,kind:cn},enableOpenActionJavaScript:{value:!1,kind:hn},enableCatalogAAJavaScript:{value:!1,kind:hn},allowedGlobalEvents:{value:null,kind:ln},canvasMaxAreaInBytes:{value:-1,kind:ln+dn},isInAutomation:{value:!1,kind:ln},localeProperties:{value:{lang:navigator.language||"en-US"},kind:ln},maxCanvasDim:{value:32767,kind:ln+cn},nimbusDataStr:{value:"",kind:ln},supportsCaretBrowsingMode:{value:!1,kind:ln},supportsDocumentFonts:{value:!0,kind:ln},supportsIntegratedFind:{value:!1,kind:ln},supportsMouseWheelZoomCtrlKey:{value:!0,kind:ln},supportsMouseWheelZoomMetaKey:{value:!0,kind:ln},supportsPinchToZoom:{value:!0,kind:ln},supportsPrinting:{value:!0,kind:ln},toolbarDensity:{value:0,kind:ln+un},altTextLearnMoreUrl:{value:"",kind:cn+_n},annotationEditorMode:{value:0,kind:cn+_n},annotationMode:{value:2,kind:cn+_n},capCanvasAreaFactor:{value:200,kind:cn+_n},commentLearnMoreUrl:{value:"",kind:cn+_n},cursorToolOnLoad:{value:0,kind:cn+_n},debuggerSrc:{value:"./debugger.mjs",kind:cn},defaultZoomDelay:{value:400,kind:cn+_n},defaultZoomValue:{value:"auto",kind:cn+_n},disableHistory:{value:!1,kind:cn},disablePageLabels:{value:!1,kind:cn+_n},enableAltText:{value:!1,kind:cn+_n},enableAltTextModelDownload:{value:!0,kind:cn+_n+un},enableAutoLinking:{value:!0,kind:cn+_n},enableComment:{value:!1,kind:cn+_n},enableDetailCanvas:{value:!0,kind:cn},enableGuessAltText:{value:!0,kind:cn+_n+un},enableHighlightFloatingButton:{value:!1,kind:cn+_n},enableMerge:{value:!1,kind:cn+_n},enableNewAltTextWhenAddingImage:{value:!0,kind:cn+_n},enableNewBadge:{value:!1,kind:cn+_n},enableOptimizedPartialRendering:{value:!1,kind:cn+_n},enablePermissions:{value:!1,kind:cn+_n},enablePrintAutoRotate:{value:!0,kind:cn+_n},enableScripting:{value:!1,kind:cn+_n},enableSignatureEditor:{value:!1,kind:cn+_n},enablePageReordering:{value:!0,kind:cn+_n},enableSplitMerge:{value:!1,kind:cn+_n},pdfBackgroundColor:{value:"",kind:cn+_n},enableUpdatedAddImage:{value:!1,kind:cn+_n},externalLinkRel:{value:"noopener noreferrer nofollow",kind:cn},externalLinkTarget:{value:0,kind:cn+_n},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F,yellow_HCM=#FFFFCC,green_HCM=#53FFBC,blue_HCM=#80EBFF,pink_HCM=#F6B8FF,red_HCM=#C50043",kind:cn+_n},historyUpdateUrl:{value:!1,kind:cn+_n},ignoreDestinationZoom:{value:!1,kind:cn+_n},imageResourcesPath:{value:"./images/",kind:cn},enableSelectionRendering:{value:!0,kind:cn+_n},imagesRightClickMinSize:{value:-1,kind:cn+_n},maxCanvasPixels:{value:2**25,kind:cn},minDurationToUpdateCanvas:{value:500,kind:cn},forcePageColors:{value:!1,kind:cn+_n},pageColorsBackground:{value:"Canvas",kind:cn+_n},pageColorsForeground:{value:"CanvasText",kind:cn+_n},pdfBugEnabled:{value:!1,kind:cn+_n},postMessageAfterPrintCallback:{value:!1,kind:cn+_n},printResolution:{value:150,kind:cn},removePageBorders:{value:!1,kind:cn+_n},sidebarViewOnLoad:{value:-1,kind:cn+_n},scrollModeOnLoad:{value:-1,kind:cn+_n},readingDirection:{value:"auto",kind:cn+_n},spreadModeOnLoad:{value:-1,kind:cn+_n},textLayerMode:{value:1,kind:cn+_n},viewerCssTheme:{value:0,kind:cn+_n},viewOnLoad:{value:0,kind:cn+_n},cMapPacked:{value:!0,kind:dn},cMapUrl:{value:"../web/cmaps/",kind:dn},disableAutoFetch:{value:!1,kind:dn+_n},disableFontFace:{value:!1,kind:dn+_n},disableRange:{value:!1,kind:dn+_n},disableStream:{value:!1,kind:dn+_n},docBaseUrl:{value:"",kind:dn},enableHWA:{value:!0,kind:dn+_n},enableWebGPU:{value:!0,kind:dn+_n},enableXfa:{value:!0,kind:dn+_n},fontExtraProperties:{value:!1,kind:dn},iccUrl:{value:"../web/iccs/",kind:dn},isOffscreenCanvasSupported:{value:!0,kind:dn},maxZoom:{value:10,kind:cn},minZoom:{value:.1,kind:cn},maxImageSize:{value:-1,kind:dn},pdfBug:{value:!1,kind:dn},standardFontDataUrl:{value:"../web/standard_fonts/",kind:dn},useSystemFonts:{value:void 0,kind:dn,type:pn.BOOLEAN+pn.UNDEFINED},useWasm:{value:!0,kind:dn},verbosity:{value:1,kind:dn},wasmUrl:{value:"../web/wasm/",kind:dn},workerPort:{value:null,kind:hn},workerSrc:{value:"./assets/pdf.worker.mjs",kind:hn}};gn.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:cn};gn.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:cn};gn.enableFakeMLManager={value:!0,kind:cn};gn.disablePreferences={value:!1,kind:cn};class AppOptions{static get(e){return app_options_assertClassBrand(AppOptions,this,yn)._.get(e)}static getAll(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=Object.create(null);for(const a in gn){const s=gn[a];(!e||e&s.kind)&&(i[a]=t?s.value:app_options_assertClassBrand(AppOptions,this,yn)._.get(a))}return i}static set(e,t){this.setAll({[e]:t})}static setAll(e){let t,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._hasInvokedSet||=!0;for(const a in e){if("positionPopupDialogsWithJavaScript"===a)continue;const s=gn[a];let r=e[a];if(s&&!(typeof r==typeof s.value||pn[(typeof r).toUpperCase()]&s.type)){"number"==typeof s?.value&&"string"==typeof r&&(Number.isNaN(Number(r))||(r=Number(r)));if(!(typeof r==typeof s.value||pn[(typeof r).toUpperCase()]&s.type||["maxZoom","minZoom","passwordPrompt","defaultZoomValue","findController","pdfBackgroundColor"].includes(a))){console.error("Invalid AppOptions value: "+a+" = "+r);continue}}const n=s?.kind;if(!i||n&ln||n&_n){this.eventBus&&n&un&&(t||=new Map).set(a,r);app_options_assertClassBrand(AppOptions,this,yn)._.set(a,r)}else console.error("Invalid AppOptions parameter: "+a+" = "+r)}if(t)for(const e of t){var a=app_options_slicedToArray(e,2);const t=a[0],i=a[1];this.eventBus.dispatch(t.toLowerCase(),{source:this,value:i})}}}en=AppOptions;!function app_options_defineProperty(e,t,i){return(t=function app_options_toPropertyKey(e){var t=function app_options_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(AppOptions,"eventBus",void 0);var fn,mn,vn,yn={_:new Map};(()=>{for(const e in gn)app_options_assertClassBrand(en,en,yn)._.set(e,gn[e].value);for(const t of on){var e=app_options_slicedToArray(t,2);const i=e[0],a=e[1];app_options_assertClassBrand(en,en,yn)._.set(i,a)}en._hasInvokedSet=!1;en._checkDisablePreferences=()=>{if(en.get("disablePreferences"))return!0;en._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.');return!1}})();function api_classPrivateGetter(e,t,i){return i(api_assertClassBrand(e,t))}function api_classPrivateMethodInitSpec(e,t){api_checkPrivateRedeclaration(e,t),t.add(e)}function api_classPrivateFieldInitSpec(e,t,i){api_checkPrivateRedeclaration(e,t),t.set(e,i)}function api_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function api_classPrivateFieldSet(e,t,i){return e.set(api_assertClassBrand(e,t),i),i}function api_classPrivateFieldGet(e,t){return e.get(api_assertClassBrand(e,t))}function api_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function api_defineProperty(e,t,i){return(t=function api_toPropertyKey(e){var t=function api_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function api_slicedToArray(e,t){return function api_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function api_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function api_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return api_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?api_arrayLikeToArray(e,t):void 0}}(e,t)||function api_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function api_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function getDocument(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=new PDFDocumentLoadingTask,i=t.docId,s=e.url?function getUrlProp(e,t){if(e instanceof URL)return e;if("string"==typeof e){if(a){if(/^[a-z][a-z0-9\-+.]+:/i.test(e))return new URL(e);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(e))}if(t)return new URL(e,window.location.origin+t);const i=URL.parse(e,window.location);if(i)return i}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(e.url,e.baseHref):null,r=e.data?function getDataProp(e){if(a&&"undefined"!=typeof Buffer&&e instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return stringToBytes(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||"object"==typeof e&&!isNaN(e?.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(e.data):null,n=e.httpHeaders||null,o=!0===e.withCredentials,l=e.password??null,c=e.range instanceof PDFDataRangeTransport?e.range:null,d=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:65536;let h=e.worker instanceof PDFWorker?e.worker:null;const u=e.verbosity,_="string"!=typeof e.docBaseUrl||isDataScheme(e.docBaseUrl)?null:e.docBaseUrl,p=getFactoryUrlProp("function"==typeof e.cMapUrl?e.cMapUrl():"string"==typeof e.cMapUrl?e.cMapUrl:null),g=!1!==e.cMapPacked,f=getFactoryUrlProp(e.iccUrl),m=getFactoryUrlProp("function"==typeof e.standardFontDataUrl?e.standardFontDataUrl():"string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null),v=getFactoryUrlProp(e.wasmUrl),y=!0!==e.stopAtErrors,P=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,w="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!a,b="boolean"==typeof e.isImageDecoderSupported?e.isImageDecoderSupported:!a,S=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,C="boolean"==typeof e.disableFontFace?e.disableFontFace:a,A=!0===e.fontExtraProperties,x=!0===e.enableXfa,k=e.ownerDocument||globalThis.document,E=!0===e.disableRange,T=!0===e.disableStream,I=!0===e.disableAutoFetch,G=!0===e.pdfBug,B=e.CanvasFactory||(a?NodeCanvasFactory:DOMCanvasFactory),M=e.FilterFactory||(a?NodeFilterFactory:DOMFilterFactory),D=e.BinaryDataFactory||(a?NodeBinaryDataFactory:DOMBinaryDataFactory),L=!0===e.enableHWA,O=!0===e.enableWebGPU?function initGPU(){return Ts.init()}():Promise.resolve(!1),R=!1!==e.useWasm,N=e.pagesMapper||new PagesMapper,j="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!a&&!C,W="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:!!(D===DOMBinaryDataFactory&&p&&g&&m&&v&&isValidFetchUrl(p,document.baseURI)&&isValidFetchUrl(m,document.baseURI)&&isValidFetchUrl(v,document.baseURI));setVerbosityLevel(u);const U={canvasFactory:new B({ownerDocument:k,enableHWA:L}),filterFactory:new M({docId:i,ownerDocument:k}),binaryDataFactory:W?null:new D({cMapUrl:p,standardFontDataUrl:m,wasmUrl:v})};if(!h){const i={verbosity:u,port:GlobalWorkerOptions.workerPort,cspPolicyService:e.cspPolicyService};h=PDFWorker.create(i);t._worker=h}const V={docId:i,apiVersion:"6.0.1161",data:r,password:l,disableAutoFetch:I,rangeChunkSize:d,docBaseUrl:_,enableXfa:x,enableOpenActionJavaScript:AppOptions.get("enableOpenActionJavaScript"),enableCatalogAAJavaScript:AppOptions.get("enableCatalogAAJavaScript"),evaluatorOptions:{maxImageSize:P,disableFontFace:C,ignoreErrors:y,isOffscreenCanvasSupported:w,isImageDecoderSupported:b,canvasMaxAreaInBytes:S,fontExtraProperties:A,useSystemFonts:j,useWasm:R,useWorkerFetch:W,cMapUrl:p,cMapPacked:g,iccUrl:f,standardFontDataUrl:m,wasmUrl:v,hasGPU:!1}},H={ownerDocument:k,pdfBug:G,styleElement:null,enableHWA:L,loadingParams:{disableAutoFetch:I,enableXfa:x}};Promise.all([h.promise,O]).then(function(e){let l=api_slicedToArray(e,2)[1];if(h.destroyed)throw new Error("Worker was destroyed");V.evaluatorOptions.hasGPU=l;const u=h.messageHandler.sendWithPromise("GetDocRequest",V,r?[r.buffer]:null);let _;if(r);else if(c)_=new PDFDataTransportStream({pdfDataRangeTransport:c,disableRange:E,disableStream:T});else{if(!s)throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");{const e=function getNetworkStream(e){return isValidFetchUrl(e)?PDFFetchStream:a?PDFNodeStream:PDFNetworkStream}(s);_=new e({url:s,httpHeaders:n,withCredentials:o,rangeChunkSize:d,disableRange:E,disableStream:T})}}return u.then(e=>{if(h.destroyed)throw new Error("Worker was destroyed");const a=new MessageHandler(i,e,h.port),s=new WorkerTransport(a,t,_,H,U,N);t._transport=s;if(t.destroyed)throw new Error("Loading aborted");a.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve);return t}class PDFDocumentLoadingTask{constructor(){api_defineProperty(this,"_capability",Promise.withResolvers());api_defineProperty(this,"_setupCapability",Promise.withResolvers());api_defineProperty(this,"_transport",null);api_defineProperty(this,"_worker",null);api_defineProperty(this,"docId",`d${Pn._=(fn=Pn._,mn=fn++,fn),mn}`);api_defineProperty(this,"destroyed",!1);api_defineProperty(this,"onPassword",null);api_defineProperty(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;this._capability.promise.catch(()=>{});try{this._worker?.port&&(this._worker._pendingDestroy=!0);await this._setupCapability.promise;await(this._transport?.destroy())}catch(e){this._worker?.port&&delete this._worker._pendingDestroy;throw e}this._transport=null;this._worker?.destroy();this._worker=null}async getData(){return this._transport.getData()}}var Pn={_:0},wn=new WeakMap,bn=new WeakMap;class PDFDataRangeTransport{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;api_classPrivateFieldInitSpec(this,wn,Promise.withResolvers());api_classPrivateFieldInitSpec(this,bn,null);this.length=e;this.initialData=t;this.progressiveDone=i;this.contentDispositionFilename=a}onDataRange(e,t){api_classPrivateFieldGet(bn,this).call(this,{type:"range",begin:e,chunk:t})}onDataProgressiveRead(e){api_classPrivateFieldGet(wn,this).promise.then(()=>{api_classPrivateFieldGet(bn,this).call(this,{type:"progressiveRead",chunk:e})})}onDataProgressiveDone(){api_classPrivateFieldGet(wn,this).promise.then(()=>{api_classPrivateFieldGet(bn,this).call(this,{type:"progressiveDone"})})}transportReady(e){api_classPrivateFieldSet(bn,this,e);api_classPrivateFieldGet(wn,this).resolve()}requestDataRange(e,t){unreachable("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class PDFDocumentProxy{constructor(e,t){this._pdfInfo=e;this._transport=t}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return shadow(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}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(e,t){return this._transport.getAnnotationsByType(e,t)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).intent,t=void 0===e?"display":e;const i=this._transport.getRenderingIntent(t).renderingIntent;return this._transport.getOptionalContentConfig(i)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this._transport.saveDocument(e)}extractPages(e){return this._transport.extractPages(e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(e){return this._transport.getRawData(e)}cleanup(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._transport.startCleanup(e||this.isPureXfa)}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}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()}}var Fn=new WeakMap,Sn=new WeakMap,Cn=new WeakSet;class PDFPageProxy{constructor(e,t,i,a){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];api_classPrivateMethodInitSpec(this,Cn);api_classPrivateFieldInitSpec(this,Fn,!1);api_classPrivateFieldInitSpec(this,Sn,null);this._pageIndex=e;this._pageInfo=t;this._transport=i;this._stats=s?new StatTimer:null;this._pdfBug=s;this.commonObjs=i.commonObjs;this.objs=new PDFObjects;this._intentStates=new Map;this.destroyed=!1;this.recordedBBoxes=null;api_classPrivateFieldSet(Sn,this,a);this.imageCoordinates=null}clone(e){const t=new PDFPageProxy(e,this._pageInfo,this._transport,api_classPrivateFieldGet(Sn,this),this._pdfBug);t.clonedFromIndex=this.clonedFromIndex??this._pageIndex;this._transport.updatePage(t);return t}get pageNumber(){return this._pageIndex+1}set pageNumber(e){this._pageIndex=e-1;this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.scale,i=e.rotation,a=void 0===i?this.rotate:i,s=e.offsetX,r=void 0===s?0:s,n=e.offsetY,o=void 0===n?0:n,l=e.dontFlip,c=void 0!==l&&l;return new PageViewport({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:a,offsetX:r,offsetY:o,dontFlip:c})}getAnnotations(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).intent,t=void 0===e?"display":e;const i=this._transport.getRenderingIntent(t).renderingIntent;return this._transport.getAnnotations(this._pageIndex,i)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return shadow(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render(e){let t=e.canvasContext,i=e.canvas,a=void 0===i?t.canvas:i,s=e.viewport,r=e.intent,n=void 0===r?"display":r,o=e.annotationMode,l=void 0===o?m.ENABLE:o,c=e.transform,d=void 0===c?null:c,u=e.background,_=void 0===u?null:u,p=e.optionalContentConfigPromise,g=void 0===p?null:p,f=e.annotationCanvasMap,v=void 0===f?null:f,y=e.pageColors,P=void 0===y?null:y,w=e.printAnnotationStorage,b=void 0===w?null:w,S=e.isEditing,C=void 0!==S&&S,A=e.recordImages,x=void 0!==A&&A,k=e.recordOperations,E=void 0!==k&&k,T=e.operationsFilter,I=void 0===T?null:T;this._stats?.time("Overall");const G=this._transport.getRenderingIntent(n,l,b,C),B=G.renderingIntent,M=G.cacheKey;api_classPrivateFieldSet(Fn,this,!1);g||=this._transport.getOptionalContentConfig(B);const D=this._intentStates.getOrInsertComputed(M,makeObj);if(D.streamReaderCancelTimeout){clearTimeout(D.streamReaderCancelTimeout);D.streamReaderCancelTimeout=null}const L=!!(B&h);if(!D.displayReadyCapability){D.displayReadyCapability=Promise.withResolvers();D.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(G)}const O=!(!this._pdfBug||!globalThis.StepperManager?.enabled),R=!!a&&!this.recordedBBoxes&&(E||O),N=!!a&&!this.imageCoordinates&&x,complete=e=>{D.renderTasks.delete(U);if(R){const e=U.gfx?.dependencyTracker.take();if(e){U.stepper?.setOperatorBBoxes(e,U.gfx.dependencyTracker.takeDebugMetadata());E&&(this.recordedBBoxes=e)}}N&&!e&&(this.imageCoordinates=U.gfx?.imagesTracker.take());L&&api_classPrivateFieldSet(Fn,this,!0);api_assertClassBrand(Cn,this,_tryCleanup).call(this);if(e){U.capability.reject(e);this._abortOperatorList({intentState:D,reason:e instanceof Error?e:new Error(e)})}else U.capability.resolve();if(this._stats){this._stats.timeEnd("Rendering");this._stats.timeEnd("Overall");globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats)}};let j=null,W=null;(R||N)&&(W=new CanvasBBoxTracker(a,D.operatorList.length));R&&(j=new CanvasDependencyTracker(W,O));const U=new InternalRenderTask({callback:complete,params:{canvas:a,canvasContext:t,dependencyTracker:j??W,imagesTracker:N?new CanvasImagesTracker(a):null,viewport:s,transform:d,background:_},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:v,operatorList:D.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!L,pdfBug:this._pdfBug,pageColors:P,enableHWA:this._transport.enableHWA,operationsFilter:I});(D.renderTasks||=new Set).add(U);const V=U.task;Promise.all([D.displayReadyCapability.promise,g]).then(e=>{let t=api_slicedToArray(e,2),i=t[0],a=t[1];if(this.destroyed)complete();else{this._stats?.time("Rendering");if(!(a.renderingIntent&B))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");U.initializeGraphics({transparency:i,optionalContentConfig:a});U.operatorListChanged()}}).catch(complete);return V}getOperatorList(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.intent,i=void 0===t?"display":t,a=e.annotationMode,s=void 0===a?m.ENABLE:a,r=e.printAnnotationStorage,n=void 0===r?null:r,o=e.isEditing,l=void 0!==o&&o;const c=this._transport.getRenderingIntent(i,s,n,l,!0),d=this._intentStates.getOrInsertComputed(c.cacheKey,makeObj);let h;if(!d.opListReadCapability){h=Object.create(null);h.operatorListChanged=function operatorListChanged(){if(d.operatorList.lastChunk){d.opListReadCapability.resolve(d.operatorList);d.renderTasks.delete(h)}};d.opListReadCapability=Promise.withResolvers();(d.renderTasks||=new Set).add(h);d.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(c)}return d.opListReadCapability.promise}streamTextContent(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.includeMarkedContent,i=void 0!==t&&t,a=e.disableNormalization,s=void 0!==a&&a;return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:api_classPrivateFieldGet(Sn,this).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===i,disableNormalization:!0===s},{highWaterMark:100,size:e=>e.items.length})}async getTextContent(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._transport._htmlForXfa)return this.getXfa().then(e=>XfaText.textContent(e));const t=this.streamTextContent(e),i={items:[],styles:Object.create(null),lang:null},a=t.getReader();try{for(;;){const e=await a.read(),t=e.value;if(e.done)break;i.lang??=t.lang;Object.assign(i.styles,t.styles);i.items.push(...t.items)}}finally{a.releaseLock()}return i}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values()){this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0});if(!t.opListReadCapability)for(const i of t.renderTasks){e.push(i.completed);i.cancel()}}this.objs.clear();api_classPrivateFieldSet(Fn,this,!1);return Promise.all(e)}cleanup(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];api_classPrivateFieldSet(Fn,this,!0);const t=api_assertClassBrand(Cn,this,_tryCleanup).call(this);e&&t&&(this._stats&&=new StatTimer);return t}_startRenderPage(e,t){const i=this._intentStates.get(t);if(i){this._stats?.timeEnd("Page Request");i.displayReadyCapability?.resolve(e)}}_renderPageChunk(e,t){for(let i=0,a=e.length;i<a;i++){t.operatorList.fnArray.push(e.fnArray[i]);t.operatorList.argsArray.push(e.argsArray[i])}t.operatorList.lastChunk=e.lastChunk;t.operatorList.separateAnnots=e.separateAnnots;for(const e of t.renderTasks)e.operatorListChanged();e.lastChunk&&api_assertClassBrand(Cn,this,_tryCleanup).call(this)}_pumpOperatorList(e){let t=e.renderingIntent,i=e.cacheKey,a=e.annotationStorageSerializable,s=e.modifiedIds;const r=a.map,n=a.transfer,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:api_classPrivateFieldGet(Sn,this).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:i,annotationStorage:r,modifiedIds:s},void 0,n).getReader(),l=this._intentStates.get(i);l.streamReader=o;const pump=()=>{o.read().then(e=>{let t=e.value;if(e.done)l.streamReader=null;else if(!this._transport.destroyed){this._renderPageChunk(t,l);pump()}},e=>{l.streamReader=null;if(!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(const e of l.renderTasks)e.operatorListChanged();api_assertClassBrand(Cn,this,_tryCleanup).call(this)}if(l.displayReadyCapability)l.displayReadyCapability.reject(e);else{if(!l.opListReadCapability)throw e;l.opListReadCapability.reject(e)}}})};pump()}_abortOperatorList(e){let t=e.intentState,i=e.reason,a=e.force,s=void 0!==a&&a;if(t.streamReader){if(t.streamReaderCancelTimeout){clearTimeout(t.streamReaderCancelTimeout);t.streamReaderCancelTimeout=null}if(!s){if(t.renderTasks.size>0)return;if(i instanceof RenderingCancelledException){let e=100;i.extraDelay>0&&i.extraDelay<1e3&&(e+=i.extraDelay);t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null;this._abortOperatorList({intentState:t,reason:i,force:!0})},e);return}}t.streamReader.cancel(new AbortException(i.message)).catch(()=>{});t.streamReader=null;if(!this._transport.destroyed){for(const e of this._intentStates){var r=api_slicedToArray(e,2);const i=r[0];if(r[1]===t){this._intentStates.delete(i);break}}this.cleanup()}}}get stats(){return this._stats}}function _tryCleanup(){if(!api_classPrivateFieldGet(Fn,this)||this.destroyed)return!1;for(const e of this._intentStates.values()){const t=e.renderTasks,i=e.operatorList;if(t.size>0||!i.lastChunk)return!1}this._intentStates.clear();this.objs.clear();api_classPrivateFieldSet(Fn,this,!1);return!0}var An=new WeakMap,xn=new WeakMap,kn=new WeakMap,En=new WeakMap,Tn=new WeakSet;class PDFWorker{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.name,i=void 0===t?null:t,a=e.port,s=void 0===a?null:a,r=e.verbosity,n=void 0===r?getVerbosityLevel():r,o=e.cspPolicyService;api_classPrivateMethodInitSpec(this,Tn);api_classPrivateFieldInitSpec(this,An,Promise.withResolvers());api_classPrivateFieldInitSpec(this,xn,null);api_classPrivateFieldInitSpec(this,kn,null);api_classPrivateFieldInitSpec(this,En,null);this.name=i;this.destroyed=!1;this.verbosity=n;if(s){if(Bn._.has(s))throw new Error("Cannot use more than one PDFWorker per port.");Bn._.set(s,this);api_assertClassBrand(Tn,this,_initializeFromPort).call(this,s)}else this._initialize(o)}get promise(){return api_classPrivateFieldGet(An,this).promise}get port(){return api_classPrivateFieldGet(kn,this)}get messageHandler(){return api_classPrivateFieldGet(xn,this)}_initialize(e){if(Gn._||_get_mainThreadWorkerMessageHandler(PDFWorker)){api_assertClassBrand(Tn,this,_setupFakeWorker).call(this);return}let t=PDFWorker.workerSrc;try{PDFWorker._isSameOrigin(window.location,t)||(t=PDFWorker._createCDNWrapper(new URL(t,window.location).href));const i=new Worker(e.generateTrustedURL(t),{type:"module"}),a=new MessageHandler("main","worker",i),terminateEarly=()=>{s.abort();a.destroy();i.terminate();this.destroyed?api_classPrivateFieldGet(An,this).reject(new Error("Worker was destroyed")):api_assertClassBrand(Tn,this,_setupFakeWorker).call(this)},s=new AbortController;i.addEventListener("error",()=>{api_classPrivateFieldGet(En,this)||terminateEarly()},{signal:s.signal});a.on("test",e=>{s.abort();if(!this.destroyed&&e){api_classPrivateFieldSet(xn,this,a);api_classPrivateFieldSet(kn,this,i);api_classPrivateFieldSet(En,this,i);api_assertClassBrand(Tn,this,_resolve).call(this)}else terminateEarly()});a.on("ready",e=>{s.abort();if(this.destroyed)terminateEarly();else try{sendTest()}catch{api_assertClassBrand(Tn,this,_setupFakeWorker).call(this)}});const sendTest=()=>{const e=new Uint8Array;a.send("test",e,[e.buffer])};sendTest();return}catch{info("The worker has been disabled.")}api_assertClassBrand(Tn,this,_setupFakeWorker).call(this)}destroy(){this.destroyed=!0;api_classPrivateFieldGet(En,this)?.terminate();api_classPrivateFieldSet(En,this,null);Bn._.delete(api_classPrivateFieldGet(kn,this));api_classPrivateFieldSet(kn,this,null);api_classPrivateFieldGet(xn,this)?.destroy();api_classPrivateFieldSet(xn,this,null)}static create(e){const t=api_assertClassBrand(PDFWorker,this,Bn)._.get(e?.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new PDFWorker(e)}static get workerSrc(){if(GlobalWorkerOptions.workerSrc)return GlobalWorkerOptions.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return shadow(this,"_setupFakeWorkerGlobal",(async()=>{if(api_classPrivateGetter(PDFWorker,this,_get_mainThreadWorkerMessageHandler))return api_classPrivateGetter(PDFWorker,this,_get_mainThreadWorkerMessageHandler);return(await import(
/*webpackIgnore: true*/
/*@vite-ignore*/
this.workerSrc)).WorkerMessageHandler})())}}vn=PDFWorker;function _resolve(){api_classPrivateFieldGet(An,this).resolve();api_classPrivateFieldGet(xn,this).send("configure",{verbosity:this.verbosity})}function _initializeFromPort(e){api_classPrivateFieldSet(kn,this,e);api_classPrivateFieldSet(xn,this,new MessageHandler("main","worker",e));api_classPrivateFieldGet(xn,this).on("ready",()=>{});api_assertClassBrand(Tn,this,_resolve).call(this)}function _setupFakeWorker(){if(!Gn._){warn("Setting up fake worker.");Gn._=!0}vn._setupFakeWorkerGlobal.then(e=>{var t,i;if(this.destroyed){api_classPrivateFieldGet(An,this).reject(new Error("Worker was destroyed"));return}const a=new LoopbackPort;api_classPrivateFieldSet(kn,this,a);const s=`fake${In._=(t=In._,i=t++,t),i}`,r=new MessageHandler(s+"_worker",s,a);e.setup(r,a);api_classPrivateFieldSet(xn,this,new MessageHandler(s,s+"_worker",a));api_assertClassBrand(Tn,this,_resolve).call(this)}).catch(e=>{api_classPrivateFieldGet(An,this).reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}function _get_mainThreadWorkerMessageHandler(e){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}var In={_:0},Gn={_:!1},Bn={_:new WeakMap};(()=>{if(a){Gn._=api_assertClassBrand(vn,vn,!0);GlobalWorkerOptions.workerSrc||="./pdf.worker.mjs"}vn._isSameOrigin=(e,t)=>{const i=URL.parse(e);if(!i?.origin||"null"===i.origin)return!1;const a=new URL(t,i);return i.origin===a.origin};vn._createCDNWrapper=e=>{const t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}})();var Mn=new WeakMap,Dn=new WeakMap,Ln=new WeakMap,On=new WeakMap,Rn=new WeakMap,Nn=new WeakMap,jn=new WeakMap,Wn=new WeakSet;class WorkerTransport{constructor(e,t,i,a,s,r){api_classPrivateMethodInitSpec(this,Wn);api_defineProperty(this,"downloadInfoCapability",Promise.withResolvers());api_classPrivateFieldInitSpec(this,Mn,null);api_classPrivateFieldInitSpec(this,Dn,new Map);api_classPrivateFieldInitSpec(this,Ln,null);api_classPrivateFieldInitSpec(this,On,new Map);api_classPrivateFieldInitSpec(this,Rn,new Map);api_classPrivateFieldInitSpec(this,Nn,new Map);api_classPrivateFieldInitSpec(this,jn,null);this.messageHandler=e;this.loadingTask=t;api_classPrivateFieldSet(Ln,this,i);this.commonObjs=new PDFObjects;this.fontLoader=new FontLoader({ownerDocument:a.ownerDocument,styleElement:a.styleElement});this.enableHWA=a.enableHWA;this.loadingParams=a.loadingParams;this._params=a;this.canvasFactory=s.canvasFactory;this.filterFactory=s.filterFactory;this.binaryDataFactory=s.binaryDataFactory;this.pagesMapper=r;this.destroyed=!1;this.destroyCapability=null;this.setupMessageHandler()}updatePage(e){const t=e._pageIndex;api_classPrivateFieldGet(On,this).set(t,e);api_classPrivateFieldGet(Rn,this).set(t,Promise.resolve(e))}get annotationStorage(){return shadow(this,"annotationStorage",new AnnotationStorage)}getRenderingIntent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m.ENABLE,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=d,n=zi;switch(e){case"any":r=c;break;case"display":break;case"print":r=h;break;default:warn(`getRenderingIntent - invalid intent: ${e}`)}const o=r&h&&i instanceof PrintAnnotationStorage?i:this.annotationStorage;switch(t){case m.DISABLE:r+=p;break;case m.ENABLE:break;case m.ENABLE_FORMS:r+=u;break;case m.ENABLE_STORAGE:r+=_;n=o.serializable;break;default:warn(`getRenderingIntent - invalid annotationMode: ${t}`)}a&&(r+=g);s&&(r+=f);const l=o.modifiedIds,v=l.ids,y=l.hash;return{renderingIntent:r,cacheKey:[r,n.hash,y].join("_"),annotationStorageSerializable:n,modifiedIds:v}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0;this.destroyCapability=Promise.withResolvers();api_classPrivateFieldGet(jn,this)?.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const t of api_classPrivateFieldGet(On,this).values())e.push(t._destroy());api_classPrivateFieldGet(On,this).clear();api_classPrivateFieldGet(Rn,this).clear();api_classPrivateFieldGet(Nn,this).clear();Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);e.push(t);Promise.all(e).then(()=>{this.commonObjs.clear();this.fontLoader.clear();api_classPrivateFieldGet(Dn,this).clear();this.filterFactory.destroy();TextLayer.cleanup();api_classPrivateFieldGet(Ln,this)?.cancelAllRequests(new AbortException("Worker was terminated."));this.messageHandler?.destroy();this.messageHandler=null;this.destroyCapability.resolve()},this.destroyCapability.reject);return this.destroyCapability.promise}setupMessageHandler(){const e=this.messageHandler,t=this.loadingTask;e.on("GetReader",(e,t)=>{assert(api_classPrivateFieldGet(Ln,this),"GetReader - no `BasePDFStream` instance available.");api_classPrivateFieldSet(Mn,this,api_classPrivateFieldGet(Ln,this).getFullReader());api_classPrivateFieldGet(Mn,this).onProgress=e=>api_assertClassBrand(Wn,this,api_onProgress).call(this,e);t.onPull=()=>{api_classPrivateFieldGet(Mn,this).read().then(function(e){let i=e.value;if(e.done)t.close();else{assert(i instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(i),1,[i])}}).catch(e=>{t.error(e)})};t.onCancel=e=>{api_classPrivateFieldGet(Mn,this).cancel(e);t.ready.catch(e=>{if(!this.destroyed)throw e})}});e.on("ReaderHeadersReady",async e=>{await api_classPrivateFieldGet(Mn,this).headersReady;const t=api_classPrivateFieldGet(Mn,this),i=t.isStreamingSupported,a=t.isRangeSupported,s=t.contentLength;i&&a&&(api_classPrivateFieldGet(Mn,this).onProgress=null);return{isStreamingSupported:i,isRangeSupported:a,contentLength:s}});e.on("GetRangeReader",(e,t)=>{assert(api_classPrivateFieldGet(Ln,this),"GetRangeReader - no `BasePDFStream` instance available.");const i=api_classPrivateFieldGet(Ln,this).getRangeReader(e.begin,e.end);if(i){t.onPull=()=>{i.read().then(function(e){let i=e.value;if(e.done)t.close();else{assert(i instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(i),1,[i])}}).catch(e=>{t.error(e)})};t.onCancel=e=>{i.cancel(e);t.ready.catch(e=>{if(!this.destroyed)throw e})}}else t.close()});e.on("GetDoc",e=>{let i=e.pdfInfo;this.pagesMapper.pagesNumber=i.numPages;this._numPages=i.numPages;this._htmlForXfa=i.htmlForXfa;delete i.htmlForXfa;t._capability.resolve(new PDFDocumentProxy(i,this))});e.on("DocException",e=>{t._capability.reject(wrapReason(e))});e.on("PasswordRequest",e=>{api_classPrivateFieldSet(jn,this,Promise.withResolvers());try{if(!t.onPassword)throw wrapReason(e);const updatePassword=e=>{e instanceof Error?api_classPrivateFieldGet(jn,this).reject(e):api_classPrivateFieldGet(jn,this).resolve({password:e})};t.onPassword(updatePassword,e.code)}catch(e){api_classPrivateFieldGet(jn,this).reject(e)}return api_classPrivateFieldGet(jn,this).promise});e.on("DataLoaded",e=>{api_assertClassBrand(Wn,this,api_onProgress).call(this,{loaded:e.length,total:e.length});this.downloadInfoCapability.resolve(e)});e.on("StartRenderPage",e=>{if(this.destroyed)return;api_classPrivateFieldGet(On,this).get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)});e.on("commonobj",t=>{let i=api_slicedToArray(t,3),a=i[0],s=i[1],r=i[2];if(this.destroyed)return null;if(this.commonObjs.has(a))return null;switch(s){case"Font":if("error"in r){const e=r.error;warn(`Error during font loading: ${e}`);this.commonObjs.resolve(a,e);break}const t=new FontInfo(r),i=this._params.pdfBug&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,n=new FontFaceObject(t,i,r.charProcOperatorList,r.extra);this.fontLoader.bind(n).catch(()=>e.sendWithPromise("FontFallback",{id:a})).finally(()=>{n.fontExtraProperties||n.clearData();this.commonObjs.resolve(a,n)});break;case"CopyLocalImage":const o=r.imageRef;assert(o,"The imageRef must be defined.");for(const e of api_classPrivateFieldGet(On,this).values())for(const t of e.objs){const e=api_slicedToArray(t,2)[1];if(e?.ref!==o)continue;if(!e.dataLen)return null;const i=structuredClone(e);this.commonObjs.resolve(a,i);return e.dataLen}break;case"FontPath":this.commonObjs.resolve(a,new FontPathInfo(r));break;case"Image":this.commonObjs.resolve(a,r);break;case"Pattern":const l=new PatternInfo(r);this.commonObjs.resolve(a,l.getIR());break;default:throw new Error(`Got unknown common object type ${s}`)}return null});e.on("obj",e=>{let t=api_slicedToArray(e,4),i=t[0],a=t[1],s=t[2],r=t[3];if(this.destroyed)return;const n=api_classPrivateFieldGet(On,this).get(a);if(!n.objs.has(i))if(0!==n._intentStates.size)switch(s){case"Image":case"Pattern":n.objs.resolve(i,r);break;default:throw new Error(`Got unknown object type ${s}`)}else r?.bitmap?.close()});e.on("DocProgress",e=>{this.destroyed||api_assertClassBrand(Wn,this,api_onProgress).call(this,e)});e.on("FetchBinaryData",async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(e)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.annotationStorage.size<=0&&warn("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const t=this.annotationStorage.serializable,i=t.map,a=t.transfer;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:i,filename:api_classPrivateFieldGet(Mn,this)?.filename??null,pageOrder:e},a).finally(()=>{this.annotationStorage.resetModified()})}extractPages(e){const t={pageInfos:e};let i;const a=globalThis.ImageBitmap;if("function"==typeof a){const t=Array.isArray(e)?e:[e];for(const e of t)e?.image instanceof a&&(i||=[]).push(e.image)}if(this.annotationStorage.size>0){const e=this.annotationStorage.serializable;let a=e.map;e.transfer?.length&&(i?i.push(...e.transfer):i=e.transfer);const r=this.pagesMapper.getMapping();if(r){const e=new Map;for(const t of a){var s=api_slicedToArray(t,2);const i=s[0],a=s[1];if(void 0!==a?.pageIndex&&a.pageIndex>=0&&a.pageIndex<r.length){const t=r[a.pageIndex]-1;if(t!==a.pageIndex){e.set(i,{...a,pageIndex:t});continue}}e.set(i,a)}a=e}t.annotationStorage=a}return this.messageHandler.sendWithPromise("ExtractPages",t,i).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const t=e-1,i=this.pagesMapper.getPageId(e)-1,a=api_classPrivateFieldGet(Rn,this).get(t);if(a)return a;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then(e=>{if(this.destroyed)throw new Error("Transport destroyed");e.refStr&&api_classPrivateFieldGet(Nn,this).set(e.refStr,i);const a=new PDFPageProxy(t,e,this,this.pagesMapper,this._params.pdfBug);api_classPrivateFieldGet(On,this).set(t,a);return a});api_classPrivateFieldGet(Rn,this).set(t,s);return s}async getPageIndex(e){if(!isRefProxy(e))throw new Error("Invalid pageIndex request.");const t=await this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}),i=this.pagesMapper.getPageNumber(t+1);if(0===i)throw new Error("GetPageIndex: page has been removed.");return i-1}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(e+1)-1,intent:t})}getFieldObjects(){return api_assertClassBrand(Wn,this,_cacheSimpleMethod).call(this,"GetFieldObjects")}hasJSActions(){return api_assertClassBrand(Wn,this,_cacheSimpleMethod).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}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(e,t){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:e,pageIndexesToSkip:t})}getDocJSActions(){return api_assertClassBrand(Wn,this,_cacheSimpleMethod).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return api_assertClassBrand(Wn,this,_cacheSimpleMethod).call(this,"GetOptionalContentConfig").then(t=>new OptionalContentConfig(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata";return api_classPrivateFieldGet(Dn,this).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,null).then(e=>({info:e[0],metadata:e[1]?new Metadata(e[1]):null,contentDispositionFilename:api_classPrivateFieldGet(Mn,this)?.filename??null,contentLength:api_classPrivateFieldGet(Mn,this)?.contentLength??null,hasStructTree:e[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(e){return this.messageHandler.sendWithPromise("GetRawData",e)}async startCleanup(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of api_classPrivateFieldGet(On,this).values()){if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`)}this.commonObjs.clear();e||this.fontLoader.clear();api_classPrivateFieldGet(Dn,this).clear();this.filterFactory.destroy(!0);TextLayer.cleanup()}}cachedPageNumber(e){if(!isRefProxy(e))return null;const t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`,i=api_classPrivateFieldGet(Nn,this).get(t);if(i>=0){const e=this.pagesMapper.getPageNumber(i+1);if(0!==e)return e}return null}}function _cacheSimpleMethod(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return api_classPrivateFieldGet(Dn,this).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,t))}function api_onProgress(e){let t=e.loaded,i=e.total;this.loadingTask.onProgress?.({loaded:t,total:i,percent:i?MathClamp(Math.round(t/i*100),0,100):NaN})}class RenderTask{constructor(e){api_defineProperty(this,"_internalRenderTask",null);api_defineProperty(this,"onContinue",null);api_defineProperty(this,"onError",null);this._internalRenderTask=e}get promise(){return this._internalRenderTask.capability.promise}cancel(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._internalRenderTask.cancel(null,e)}get separateAnnots(){const e=this._internalRenderTask.operatorList.separateAnnots;if(!e)return!1;const t=this._internalRenderTask.annotationCanvasMap;return e.form||e.canvas&&t?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}var Un=new WeakMap;class InternalRenderTask{constructor(e){let t=e.callback,i=e.params,a=e.objs,s=e.commonObjs,r=e.annotationCanvasMap,n=e.operatorList,o=e.pageIndex,l=e.canvasFactory,c=e.filterFactory,d=e.useRequestAnimationFrame,h=void 0!==d&&d,u=e.pdfBug,_=void 0!==u&&u,p=e.pageColors,g=void 0===p?null:p,f=e.enableHWA,m=void 0!==f&&f,v=e.operationsFilter,y=void 0===v?null:v;api_classPrivateFieldInitSpec(this,Un,null);this.callback=t;this.params=i;this.objs=a;this.commonObjs=s;this.annotationCanvasMap=r;this.operatorListIdx=null;this.operatorList=n;this._pageIndex=o;this.canvasFactory=l;this.filterFactory=c;this._pdfBug=_;this.pageColors=g;this.running=!1;this.graphicsReadyCallback=null;this.graphicsReady=!1;this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window;this.cancelled=!1;this.capability=Promise.withResolvers();this.task=new RenderTask(this);this._cancelBound=this.cancel.bind(this);this._continueBound=this._continue.bind(this);this._scheduleNextBound=this._scheduleNext.bind(this);this._nextBound=this._next.bind(this);this._canvas=i.canvas;this._canvasContext=i.canvas?null:i.canvasContext;this._enableHWA=m;this._dependencyTracker=i.dependencyTracker;this._imagesTracker=i.imagesTracker;this._operationsFilter=y}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics(e){let t=e.transparency,i=void 0!==t&&t,a=e.optionalContentConfig;if(this.cancelled)return;if(this._canvas){if(Vn._.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");Vn._.add(this._canvas)}if(this._pdfBug&&globalThis.StepperManager?.enabled){this.stepper=globalThis.StepperManager.create(this._pageIndex);this.stepper.init(this.operatorList);this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint()}const s=this.params,r=s.viewport,n=s.transform,o=s.background,l=s.dependencyTracker,c=s.imagesTracker,d=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new CanvasGraphics(d,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:a},this.annotationCanvasMap,this.pageColors,l,c);this.gfx.beginDrawing({transform:n,viewport:r,transparency:i,background:o});this.operatorListIdx=0;this.graphicsReady=!0;this.graphicsReadyCallback?.()}cancel(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.running=!1;this.cancelled=!0;this.gfx?.endDrawing();if(api_classPrivateFieldGet(Un,this)){window.cancelAnimationFrame(api_classPrivateFieldGet(Un,this));api_classPrivateFieldSet(Un,this,null)}Vn._.delete(this._canvas);e||=new RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,t);this.callback(e);this.task.onError?.(e)}operatorListChanged(){if(this.graphicsReady){this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length);this.stepper?.updateOperatorList(this.operatorList);this.running||this._continue()}else this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0;this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?api_classPrivateFieldSet(Un,this,window.requestAnimationFrame(()=>{api_classPrivateFieldSet(Un,this,null);this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(!this.cancelled){this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter);if(this.operatorListIdx===this.operatorList.argsArray.length){this.running=!1;if(this.operatorList.lastChunk){this.gfx.endDrawing();Vn._.delete(this._canvas);this.callback()}}}}}var Vn={_:new WeakSet};const Hn="6.0.1161",zn="2d346053b";var $n;__webpack_require__(3068);function color_picker_slicedToArray(e,t){return function color_picker_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function color_picker_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function color_picker_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return color_picker_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?color_picker_arrayLikeToArray(e,t):void 0}}(e,t)||function color_picker_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function color_picker_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function color_picker_classPrivateFieldInitSpec(e,t,i){color_picker_checkPrivateRedeclaration(e,t),t.set(e,i)}function color_picker_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function color_picker_classPrivateGetter(e,t,i){return i(color_picker_assertClassBrand(e,t))}function color_picker_classPrivateFieldGet(e,t){return e.get(color_picker_assertClassBrand(e,t))}function color_picker_classPrivateFieldSet(e,t,i){return e.set(color_picker_assertClassBrand(e,t),i),i}function color_picker_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var qn=new WeakMap,Xn=new WeakMap,Kn=new WeakMap,Yn=new WeakMap,Zn=new WeakMap,Jn=new WeakMap,Qn=new WeakMap,eo=new WeakMap,to=new WeakMap,io=new WeakMap,ao=new WeakSet;class ColorPicker{static get _keyboardManager(){return shadow(this,"_keyboardManager",new KeyboardManager([[["Escape","mac+Escape"],ColorPicker.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ColorPicker.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ColorPicker.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ColorPicker.prototype._moveToPrevious],[["Home","mac+Home"],ColorPicker.prototype._moveToBeginning],[["End","mac+End"],ColorPicker.prototype._moveToEnd]]))}constructor(e){let t=e.editor,i=void 0===t?null:t,a=e.uiManager,s=void 0===a?null:a;!function color_picker_classPrivateMethodInitSpec(e,t){color_picker_checkPrivateRedeclaration(e,t),t.add(e)}(this,ao);color_picker_classPrivateFieldInitSpec(this,qn,null);color_picker_classPrivateFieldInitSpec(this,Xn,null);color_picker_classPrivateFieldInitSpec(this,Kn,void 0);color_picker_classPrivateFieldInitSpec(this,Yn,null);color_picker_classPrivateFieldInitSpec(this,Zn,!1);color_picker_classPrivateFieldInitSpec(this,Jn,!1);color_picker_classPrivateFieldInitSpec(this,Qn,null);color_picker_classPrivateFieldInitSpec(this,eo,void 0);color_picker_classPrivateFieldInitSpec(this,to,null);color_picker_classPrivateFieldInitSpec(this,io,null);if(i){color_picker_classPrivateFieldSet(Jn,this,!1);color_picker_classPrivateFieldSet(Qn,this,i)}else color_picker_classPrivateFieldSet(Jn,this,!0);color_picker_classPrivateFieldSet(io,this,i?._uiManager||s);color_picker_classPrivateFieldSet(eo,this,color_picker_classPrivateFieldGet(io,this)._eventBus);color_picker_classPrivateFieldSet(Kn,this,i?.color?.toUpperCase()||color_picker_classPrivateFieldGet(io,this)?.highlightColors.values().next().value||"#FFFF98");so._||(so._=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}renderButton(){const e=color_picker_classPrivateFieldSet(qn,this,document.createElement("button"));e.className="colorPicker";e.tabIndex="0";e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button");e.ariaHasPopup="true";color_picker_classPrivateFieldGet(Qn,this)&&(e.ariaControls=`${color_picker_classPrivateFieldGet(Qn,this).id}_colorpicker_dropdown`);const t=color_picker_classPrivateFieldGet(io,this)._signal;e.addEventListener("click",color_picker_assertClassBrand(ao,this,_openDropdown).bind(this),{signal:t});e.addEventListener("keydown",color_picker_assertClassBrand(ao,this,_keyDown).bind(this),{signal:t});const i=color_picker_classPrivateFieldSet(Xn,this,document.createElement("span"));i.className="swatch";i.ariaHidden="true";i.style.backgroundColor=color_picker_classPrivateFieldGet(Kn,this);e.append(i);return e}renderMainDropdown(){const e=color_picker_classPrivateFieldSet(Yn,this,color_picker_assertClassBrand(ao,this,_getDropdownRoot).call(this));e.ariaOrientation="horizontal";e.ariaLabelledBy="highlightColorPickerLabel";return e}_colorSelectFromKeyboard(e){if(e.target===color_picker_classPrivateFieldGet(qn,this)){color_picker_assertClassBrand(ao,this,_openDropdown).call(this,e);return}const t=e.target.getAttribute("data-color");t&&color_picker_assertClassBrand(ao,this,_colorSelect).call(this,t,e)}_moveToNext(e){color_picker_classPrivateGetter(ao,this,_get_isDropdownVisible)?e.target!==color_picker_classPrivateFieldGet(qn,this)?e.target.nextSibling?.focus():color_picker_classPrivateFieldGet(Yn,this).firstElementChild?.focus():color_picker_assertClassBrand(ao,this,_openDropdown).call(this,e)}_moveToPrevious(e){if(e.target!==color_picker_classPrivateFieldGet(Yn,this)?.firstElementChild&&e.target!==color_picker_classPrivateFieldGet(qn,this)){color_picker_classPrivateGetter(ao,this,_get_isDropdownVisible)||color_picker_assertClassBrand(ao,this,_openDropdown).call(this,e);e.target.previousSibling?.focus()}else color_picker_classPrivateGetter(ao,this,_get_isDropdownVisible)&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){color_picker_classPrivateGetter(ao,this,_get_isDropdownVisible)?color_picker_classPrivateFieldGet(Yn,this).firstElementChild?.focus():color_picker_assertClassBrand(ao,this,_openDropdown).call(this,e)}_moveToEnd(e){color_picker_classPrivateGetter(ao,this,_get_isDropdownVisible)?color_picker_classPrivateFieldGet(Yn,this).lastElementChild?.focus():color_picker_assertClassBrand(ao,this,_openDropdown).call(this,e)}hideDropdown(){color_picker_classPrivateFieldGet(Yn,this)?.classList.add("hidden");color_picker_classPrivateFieldGet(qn,this).ariaExpanded="false";color_picker_classPrivateFieldGet(to,this)?.abort();color_picker_classPrivateFieldSet(to,this,null)}_hideDropdownFromKeyboard(){if(!color_picker_classPrivateFieldGet(Jn,this))if(color_picker_classPrivateGetter(ao,this,_get_isDropdownVisible)){this.hideDropdown();color_picker_classPrivateFieldGet(qn,this).focus({preventScroll:!0,focusVisible:color_picker_classPrivateFieldGet(Zn,this)})}else color_picker_classPrivateFieldGet(Qn,this)?.unselect()}updateColor(e){color_picker_classPrivateFieldGet(Xn,this)&&(color_picker_classPrivateFieldGet(Xn,this).style.backgroundColor=e);if(!color_picker_classPrivateFieldGet(Yn,this))return;const t=color_picker_classPrivateFieldGet(io,this).highlightColors.values();for(const i of color_picker_classPrivateFieldGet(Yn,this).children)i.ariaSelected=t.next().value===e.toUpperCase()}destroy(){color_picker_classPrivateFieldGet(qn,this)?.remove();color_picker_classPrivateFieldSet(qn,this,null);color_picker_classPrivateFieldSet(Xn,this,null);color_picker_classPrivateFieldGet(Yn,this)?.remove();color_picker_classPrivateFieldSet(Yn,this,null)}}$n=ColorPicker;function _getDropdownRoot(){const e=document.createElement("div"),t=color_picker_classPrivateFieldGet(io,this)._signal;e.addEventListener("contextmenu",noContextMenu,{signal:t});e.className="dropdown";e.role="listbox";e.ariaMultiSelectable="false";e.ariaOrientation="vertical";e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");color_picker_classPrivateFieldGet(Qn,this)&&(e.id=`${color_picker_classPrivateFieldGet(Qn,this).id}_colorpicker_dropdown`);for(const a of color_picker_classPrivateFieldGet(io,this).highlightColors){var i=color_picker_slicedToArray(a,2);const s=i[0],r=i[1],n=document.createElement("button");n.tabIndex="0";n.role="option";n.setAttribute("data-color",r);n.title=s;n.setAttribute("data-l10n-id",so._[s]);const o=document.createElement("span");n.append(o);o.className="swatch";o.style.backgroundColor=r;n.ariaSelected=r===color_picker_classPrivateFieldGet(Kn,this);n.addEventListener("click",color_picker_assertClassBrand(ao,this,_colorSelect).bind(this,r),{signal:t});e.append(n)}e.addEventListener("keydown",color_picker_assertClassBrand(ao,this,_keyDown).bind(this),{signal:t});return e}function _colorSelect(e,t){t.stopPropagation();color_picker_classPrivateFieldGet(eo,this).dispatch("switchannotationeditorparams",{source:this,type:w.HIGHLIGHT_COLOR,value:e});this.updateColor(e)}function _keyDown(e){$n._keyboardManager.exec(this,e)}function _openDropdown(e){if(color_picker_classPrivateGetter(ao,this,_get_isDropdownVisible)){this.hideDropdown();return}color_picker_classPrivateFieldSet(Zn,this,0===e.detail);if(!color_picker_classPrivateFieldGet(to,this)){color_picker_classPrivateFieldSet(to,this,new AbortController);window.addEventListener("pointerdown",color_picker_assertClassBrand(ao,this,color_picker_pointerDown).bind(this),{signal:color_picker_classPrivateFieldGet(io,this).combinedSignal(color_picker_classPrivateFieldGet(to,this))})}color_picker_classPrivateFieldGet(qn,this).ariaExpanded="true";if(color_picker_classPrivateFieldGet(Yn,this)){color_picker_classPrivateFieldGet(Yn,this).classList.remove("hidden");return}const t=color_picker_classPrivateFieldSet(Yn,this,color_picker_assertClassBrand(ao,this,_getDropdownRoot).call(this));color_picker_classPrivateFieldGet(qn,this).append(t)}function color_picker_pointerDown(e){color_picker_classPrivateFieldGet(Yn,this)?.contains(e.target)||this.hideDropdown()}function _get_isDropdownVisible(e){return color_picker_classPrivateFieldGet(Yn,e)&&!color_picker_classPrivateFieldGet(Yn,e).classList.contains("hidden")}var so={_:null},ro=new WeakMap,no=new WeakMap,oo=new WeakMap,lo=new WeakMap;class BasicColorPicker{constructor(e){color_picker_classPrivateFieldInitSpec(this,ro,null);color_picker_classPrivateFieldInitSpec(this,no,!1);color_picker_classPrivateFieldInitSpec(this,oo,null);color_picker_classPrivateFieldInitSpec(this,lo,null);color_picker_classPrivateFieldSet(oo,this,e);color_picker_classPrivateFieldSet(lo,this,e._uiManager);co._||(co._=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(color_picker_classPrivateFieldGet(ro,this))return color_picker_classPrivateFieldGet(ro,this);const e=color_picker_classPrivateFieldGet(oo,this),t=e.editorType,i=e.colorType,a=e.colorAndOpacityType,s=e.opacityType,r=e.color,n=e.opacity,o=color_picker_classPrivateFieldSet(no,this,FeatureTest.isAlphaColorInputSupported&&void 0!==s),l=color_picker_classPrivateFieldSet(ro,this,document.createElement("input"));l.type="color";if(o){l.setAttribute("alpha","");const e=Util.hexNums[Math.round(255*(n??1))];l.value=(r||"#000000")+e}else l.value=r||"#000000";l.className="basicColorPicker";l.tabIndex=0;l.setAttribute("data-l10n-id",co._[t]);l.addEventListener("input",()=>{if(o){const e=getRGBA(l.value);if(!e)return;const t=color_picker_slicedToArray(e,4),r=t[0],n=t[1],o=t[2],c=t[3],d=Util.makeHexColor(r,n,o);if(void 0!==a)color_picker_classPrivateFieldGet(lo,this).updateParams(a,{color:d,opacity:c});else{color_picker_classPrivateFieldGet(lo,this).updateParams(i,d);color_picker_classPrivateFieldGet(lo,this).updateParams(s,c)}}else color_picker_classPrivateFieldGet(lo,this).updateParams(i,l.value)},{signal:color_picker_classPrivateFieldGet(lo,this)._signal});return l}update(e){if(color_picker_classPrivateFieldGet(ro,this))if(color_picker_classPrivateFieldGet(no,this)){const t=Util.hexNums[Math.round(255*color_picker_classPrivateFieldGet(oo,this).opacity)];color_picker_classPrivateFieldGet(ro,this).value=e+t}else color_picker_classPrivateFieldGet(ro,this).value=e}updateOpacity(e){if(!color_picker_classPrivateFieldGet(ro,this)||!color_picker_classPrivateFieldGet(no,this))return;const t=Util.hexNums[Math.round(255*e)];color_picker_classPrivateFieldGet(ro,this).value=color_picker_classPrivateFieldGet(oo,this).color+t}destroy(){color_picker_classPrivateFieldGet(ro,this)?.remove();color_picker_classPrivateFieldSet(ro,this,null)}hideDropdown(){}}var co={_:null};__webpack_require__(531);function scripting_utils_slicedToArray(e,t){return function scripting_utils_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function scripting_utils_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function scripting_utils_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return scripting_utils_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?scripting_utils_arrayLikeToArray(e,t):void 0}}(e,t)||function scripting_utils_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function scripting_utils_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function makeColorComp(e){return Math.floor(255*MathClamp(e,0,1)).toString(16).padStart(2,"0")}function scaleAndClamp(e){return 255*MathClamp(e,0,1)}class ColorConverters{static CMYK_G(e){let t=scripting_utils_slicedToArray(e,4),i=t[0],a=t[1],s=t[2],r=t[3];return["G",1-Math.min(1,.3*i+.59*s+.11*a+r)]}static G_CMYK(e){return["CMYK",0,0,0,1-scripting_utils_slicedToArray(e,1)[0]]}static G_RGB(e){let t=scripting_utils_slicedToArray(e,1)[0];return["RGB",t,t,t]}static G_rgb(e){let t=scripting_utils_slicedToArray(e,1)[0];t=scaleAndClamp(t);return[t,t,t]}static G_HTML(e){const t=makeColorComp(scripting_utils_slicedToArray(e,1)[0]);return`#${t}${t}${t}`}static RGB_G(e){let t=scripting_utils_slicedToArray(e,3);return["G",.3*t[0]+.59*t[1]+.11*t[2]]}static RGB_rgb(e){return e.map(scaleAndClamp)}static RGB_HTML(e){return`#${e.map(makeColorComp).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB(e){let t=scripting_utils_slicedToArray(e,4),i=t[0],a=t[1],s=t[2],r=t[3];return["RGB",1-Math.min(1,i+r),1-Math.min(1,s+r),1-Math.min(1,a+r)]}static CMYK_rgb(e){let t=scripting_utils_slicedToArray(e,4),i=t[0],a=t[1],s=t[2],r=t[3];return[scaleAndClamp(1-Math.min(1,i+r)),scaleAndClamp(1-Math.min(1,s+r)),scaleAndClamp(1-Math.min(1,a+r))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK(e){let t=scripting_utils_slicedToArray(e,3);const i=1-t[0],a=1-t[1],s=1-t[2];return["CMYK",i,a,s,Math.min(i,a,s)]}}class BaseSVGFactory{create(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const a=this._createSVG("svg:svg");a.setAttribute("version","1.1");if(!i){a.setAttribute("width",`${e}px`);a.setAttribute("height",`${t}px`)}a.setAttribute("preserveAspectRatio","none");a.setAttribute("viewBox",`0 0 ${e} ${t}`);return a}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){unreachable("Abstract method `_createSVG` called.")}}class DOMSVGFactory extends BaseSVGFactory{_createSVG(e){return document.createElementNS(l,e)}}function annotation_layer_defineProperty(e,t,i){return(t=function annotation_layer_toPropertyKey(e){var t=function annotation_layer_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function annotation_layer_classPrivateGetter(e,t,i){return i(annotation_layer_assertClassBrand(e,t))}function annotation_layer_slicedToArray(e,t){return function annotation_layer_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function annotation_layer_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function annotation_layer_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return annotation_layer_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?annotation_layer_arrayLikeToArray(e,t):void 0}}(e,t)||function annotation_layer_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function annotation_layer_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function annotation_layer_classPrivateMethodInitSpec(e,t){annotation_layer_checkPrivateRedeclaration(e,t),t.add(e)}function annotation_layer_classPrivateFieldInitSpec(e,t,i){annotation_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_layer_classPrivateFieldSet(e,t,i){return e.set(annotation_layer_assertClassBrand(e,t),i),i}function annotation_layer_classPrivateFieldGet(e,t){return e.get(annotation_layer_assertClassBrand(e,t))}function annotation_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const ho=new WeakSet,uo=60*(new Date).getTimezoneOffset()*1e3;class AnnotationElementFactory{static create(e){switch(e.data.annotationType){case I.LINK:return new LinkAnnotationElement(e);case I.TEXT:return new TextAnnotationElement(e);case I.WIDGET:switch(e.data.fieldType){case"Tx":return new TextWidgetAnnotationElement(e);case"Btn":return e.data.radioButton?new RadioButtonWidgetAnnotationElement(e):e.data.checkBox?new CheckboxWidgetAnnotationElement(e):new PushButtonWidgetAnnotationElement(e);case"Ch":return new ChoiceWidgetAnnotationElement(e);case"Sig":return new SignatureWidgetAnnotationElement(e)}return new WidgetAnnotationElement(e);case I.POPUP:return new PopupAnnotationElement(e);case I.FREETEXT:return new FreeTextAnnotationElement(e);case I.LINE:return new LineAnnotationElement(e);case I.SQUARE:return new SquareAnnotationElement(e);case I.CIRCLE:return new CircleAnnotationElement(e);case I.POLYLINE:return new PolylineAnnotationElement(e);case I.CARET:return new CaretAnnotationElement(e);case I.INK:return new InkAnnotationElement(e);case I.POLYGON:return new PolygonAnnotationElement(e);case I.HIGHLIGHT:return new HighlightAnnotationElement(e);case I.UNDERLINE:return new UnderlineAnnotationElement(e);case I.SQUIGGLY:return new SquigglyAnnotationElement(e);case I.STRIKEOUT:return new StrikeOutAnnotationElement(e);case I.STAMP:return new StampAnnotationElement(e);case I.FILEATTACHMENT:return new FileAttachmentAnnotationElement(e);default:return new AnnotationElement(e)}}}var _o=new WeakMap,po=new WeakMap,go=new WeakMap,fo=new WeakSet;class AnnotationElement{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.isRenderable,a=void 0!==i&&i,s=t.ignoreBorder,r=void 0!==s&&s,n=t.createQuadrilaterals,o=void 0!==n&&n;annotation_layer_classPrivateMethodInitSpec(this,fo);annotation_layer_classPrivateFieldInitSpec(this,_o,null);annotation_layer_classPrivateFieldInitSpec(this,po,!1);annotation_layer_classPrivateFieldInitSpec(this,go,null);this.isRenderable=a;this.data=e.data;this.layer=e.layer;this.linkService=e.linkService;this.downloadManager=e.downloadManager;this.imageResourcesPath=e.imageResourcesPath;this.renderForms=e.renderForms;this.svgFactory=e.svgFactory;this.annotationStorage=e.annotationStorage;this.enableComment=e.enableComment;this.enableScripting=e.enableScripting;this.hasJSActions=e.hasJSActions;this._fieldObjects=e.fieldObjects;this.parent=e.parent;this.hasOwnCommentButton=!1;a&&(this.contentElement=this.container=this._createContainer(r));o&&this._createQuadrilaterals()}static _hasPopupData(e){let t=e.contentsObj,i=e.richText;return!(!t?.str&&!i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return AnnotationElement._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const e=this.data,t=this.annotationStorage?.getEditor(e.id);return t?t.getData():e}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const e=this.annotationStorage?.getEditor(this.data.id);if(e)return e.commentButtonPositionInPage;const t=this.data,i=t.quadPoints,a=t.inkLists,s=t.rect;let r=-1/0,n=-1/0;if(i?.length>=8){for(let e=0;e<i.length;e+=8)if(i[e+1]>n){n=i[e+1];r=i[e+2]}else i[e+1]===n&&(r=Math.max(r,i[e+2]));return[r,n]}if(a?.length>=1){for(const e of a)for(let t=0,i=e.length;t<i;t+=2)if(e[t+1]>n){n=e[t+1];r=e[t]}else e[t+1]===n&&(r=Math.max(r,e[t]));if(r!==1/0)return[r,n]}return s?[s[2],s[3]]:null}_normalizePoint(e){const t=this.parent,i=t.page.view,a=t.viewport.rawDims,s=a.pageWidth,r=a.pageHeight,n=a.pageX,o=a.pageY;e[1]=i[3]-e[1]+i[1];e[0]=100*(e[0]-n)/s;e[1]=100*(e[1]-o)/r;return e}get commentText(){const e=this.data;return this.annotationStorage.getRawValue(`${y}${e.id}`)?.popup?.contents||e.contentsObj?.str||""}set commentText(e){const t=this.data,i={deleted:!e,contents:e||""};this.annotationStorage.updateEditor(t.id,{popup:i})||this.annotationStorage.setValue(`${y}${t.id}`,{id:t.id,annotationType:t.annotationType,page:this.parent.page,popup:i,popupRef:t.popupRef,modificationDate:new Date});e||this.removePopup()}removePopup(){(annotation_layer_classPrivateFieldGet(go,this)?.popup||this.popup)?.remove();annotation_layer_classPrivateFieldSet(go,this,this.popup=null)}updateEdited(e){if(!this.container)return;e.rect&&(annotation_layer_classPrivateFieldGet(_o,this)||annotation_layer_classPrivateFieldSet(_o,this,{rect:this.data.rect.slice(0)}));const t=e.rect,i=e.popup;t&&annotation_layer_assertClassBrand(fo,this,_setRectEdited).call(this,t);let a=annotation_layer_classPrivateFieldGet(go,this)?.popup||this.popup;if(!a&&i?.text){this._createPopup(i);a=annotation_layer_classPrivateFieldGet(go,this).popup}if(a){a.updateEdited(e);if(i?.deleted){a.remove();annotation_layer_classPrivateFieldSet(go,this,null);this.popup=null}}}resetEdited(){if(annotation_layer_classPrivateFieldGet(_o,this)){annotation_layer_assertClassBrand(fo,this,_setRectEdited).call(this,annotation_layer_classPrivateFieldGet(_o,this).rect);annotation_layer_classPrivateFieldGet(go,this)?.popup.resetEdited();annotation_layer_classPrivateFieldSet(_o,this,null)}}_createContainer(e){const t=this.data,i=this.parent,a=i.page,s=i.viewport,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id);this instanceof WidgetAnnotationElement||this instanceof LinkAnnotationElement||(r.tabIndex=0);const n=r.style;n.zIndex=this.parent.zIndex;this.parent.zIndex+=2;t.alternativeText&&(r.title=t.alternativeText);t.noRotate&&r.classList.add("norotate");if(!t.rect||this instanceof PopupAnnotationElement){const e=t.rotation;t.hasOwnCanvas||0===e||this.setRotation(e,r);return r}const o=this.width,l=this.height;if(!e&&t.borderStyle.width>0){n.borderWidth=`${t.borderStyle.width}px`;const e=t.borderStyle.horizontalCornerRadius,i=t.borderStyle.verticalCornerRadius;if(e>0||i>0){const t=`calc(${e}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;n.borderRadius=t}else if(this instanceof RadioButtonWidgetAnnotationElement){const e=`calc(${o}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;n.borderRadius=e}switch(t.borderStyle.style){case G:n.borderStyle="solid";break;case B:n.borderStyle="dashed";break;case M:warn("Unimplemented border style: beveled");break;case D:warn("Unimplemented border style: inset");break;case L:n.borderBottomStyle="solid"}const a=t.borderColor||null;if(a){annotation_layer_classPrivateFieldSet(po,this,!0);n.borderColor=Util.makeHexColor(...a)}else n.borderWidth=0}const c=Util.normalizeRect([t.rect[0],a.view[3]-t.rect[1]+a.view[1],t.rect[2],a.view[3]-t.rect[3]+a.view[1]]),d=s.rawDims,h=d.pageWidth,u=d.pageHeight,_=d.pageX,p=d.pageY;n.left=100*(c[0]-_)/h+"%";n.top=100*(c[1]-p)/u+"%";const g=t.rotation;if(t.hasOwnCanvas||0===g){n.width=100*o/h+"%";n.height=100*l/u+"%"}else this.setRotation(g,r);return r}setRotation(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.container;if(!this.data.rect)return;const i=this.parent.viewport.rawDims,a=i.pageWidth,s=i.pageHeight;let r=this.width,n=this.height;if(e%180!=0){var o=[n,r];r=o[0];n=o[1]}t.style.width=100*r/a+"%";t.style.height=100*n/s+"%";t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const setColor=(e,t,i)=>{const a=i.detail[e],s=a[0],r=a.slice(1);i.target.style[t]=ColorConverters[`${s}_HTML`](r);this.annotationStorage.setValue(this.data.id,{[t]:ColorConverters[`${s}_rgb`](r)})};return shadow(this,"_commonActions",{display:e=>{const t=e.detail.display,i=t%2==1;this.container.style.visibility=i?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===t||2===t})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const t=e.detail.hidden;this.container.style.visibility=t?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{setColor("bgColor","backgroundColor",e)},fillColor:e=>{setColor("fillColor","backgroundColor",e)},fgColor:e=>{setColor("fgColor","color",e)},textColor:e=>{setColor("textColor","color",e)},borderColor:e=>{setColor("borderColor","borderColor",e)},strokeColor:e=>{setColor("strokeColor","borderColor",e)},rotation:e=>{const t=e.detail.rotation;this.setRotation(t);this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){const i=this._commonActions;for(const a of Object.keys(t.detail)){const s=e[a]||i[a];s?.(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const i=this._commonActions;for(const s of Object.entries(t)){var a=annotation_layer_slicedToArray(s,2);const r=a[0],n=a[1],o=i[r];if(o){o({detail:{[r]:n},target:e});delete t[r]}}}_createQuadrilaterals(){if(!this.container)return;const e=this.data.quadPoints;if(!e)return;const t=annotation_layer_slicedToArray(this.data.rect.map(e=>Math.fround(e)),4),i=t[0],a=t[1],s=t[2],r=t[3];if(8===e.length){const t=annotation_layer_slicedToArray(e.subarray(2,6),4),n=t[0],o=t[1],l=t[2],c=t[3];if(s===n&&r===o&&i===l&&a===c)return}const n=this.container.style;let o;if(annotation_layer_classPrivateFieldGet(po,this)){const e=n.borderColor,t=n.borderWidth;n.borderWidth=0;o=["url('data:image/svg+xml;utf8,",`<svg xmlns="${l}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${t}">`];this.container.classList.add("hasBorder")}const c=s-i,d=r-a,h=this.svgFactory,u=h.createElement("svg");u.classList.add("quadrilateralsContainer");u.setAttribute("width",0);u.setAttribute("height",0);u.role="none";const _=h.createElement("defs");u.append(_);const p=h.createElement("clipPath"),g=`clippath_${this.data.id}`;p.setAttribute("id",g);p.setAttribute("clipPathUnits","objectBoundingBox");_.append(p);for(let t=2,a=e.length;t<a;t+=8){const a=e[t],s=e[t+1],n=e[t+2],l=e[t+3],u=h.createElement("rect"),_=(n-i)/c,g=(r-s)/d,f=(a-n)/c,m=(s-l)/d;u.setAttribute("x",_);u.setAttribute("y",g);u.setAttribute("width",f);u.setAttribute("height",m);p.append(u);o?.push(`<rect vector-effect="non-scaling-stroke" x="${_}" y="${g}" width="${f}" height="${m}"/>`)}if(annotation_layer_classPrivateFieldGet(po,this)){o.push("</g></svg>')");n.backgroundImage=o.join("")}this.container.append(u);this.container.style.clipPath=`url(#${g})`}_createPopup(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=this.data;let i,a;if(e){i={str:e.text};a=e.date}else{i=t.contentsObj;a=t.modificationDate}annotation_layer_classPrivateFieldSet(go,this,new PopupAnnotationElement({data:{color:t.color,titleObj:t.titleObj,modificationDate:a,contentsObj:i,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(annotation_layer_classPrivateFieldGet(go,this)||this.popup||this.data.popupRef)}get extraPopupElement(){return annotation_layer_classPrivateFieldGet(go,this)}render(){unreachable("Abstract method `AnnotationElement.render` called")}_getElementsByName(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=[];if(this._fieldObjects){const a=this._fieldObjects[e];if(a)for(const e of a){const a=e.page,s=e.id,r=e.exportValues;if(-1===a)continue;if(s===t)continue;const n="string"==typeof r?r:null,o=document.querySelector(`[data-element-id="${s}"]`);!o||ho.has(o)?i.push({id:s,exportValue:n,domElement:o}):warn(`_getElementsByName - element not allowed: ${s}`)}return i}for(const a of document.getElementsByName(e)){const e=a.exportValue,s=a.getAttribute("data-element-id");s!==t&&(ho.has(a)&&i.push({id:s,exportValue:e,domElement:a}))}return i}show(){this.container&&(this.container.hidden=!1);this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0);this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const e=this.annotationEditorType,t=this.data.id;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t,mustEnterInEditMode:!0})})}updateOC(e){if(!this.data.oc||!e)return;e.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}function _setRectEdited(e){const t=this.container.style,i=this.data,a=i.rect,s=i.rotation,r=this.parent.viewport.rawDims,n=r.pageWidth,o=r.pageHeight,l=r.pageX,c=r.pageY;a?.splice(0,4,...e);t.left=100*(e[0]-l)/n+"%";t.top=100*(o-e[3]+c)/o+"%";if(0===s){t.width=100*(e[2]-e[0])/n+"%";t.height=100*(e[3]-e[1])/o+"%"}else this.setRotation(s)}class EditorAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.editor=e.editor}render(){this.container.className="editorAnnotation";return this.container}createOrUpdatePopup(){const e=this.editor;e.hasComment&&this._createPopup(e.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(e){this.editor.comment=e;e||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id);this.container.remove();this.container=null;this.removePopup()}}var mo=new WeakSet;class LinkAnnotationElement extends AnnotationElement{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0});annotation_layer_classPrivateMethodInitSpec(this,mo);this.isTooltipOnly=e.data.isTooltipOnly}render(){const e=this.data,t=this.linkService,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let a=!1;if(e.url){t.addLinkAttributes(i,e.url,e.newWindow);a=!0}else if(e.action){this._bindNamedAction(i,e.action,e.overlaidText);a=!0}else if(e.attachment){annotation_layer_assertClassBrand(mo,this,_bindAttachment).call(this,i,e.attachment,e.overlaidText,e.attachmentDest);a=!0}else if(e.setOCGState){annotation_layer_assertClassBrand(mo,this,_bindSetOCGState).call(this,i,e.setOCGState,e.overlaidText);a=!0}else if(e.dest){this._bindLink(i,e.dest,e.overlaidText);a=!0}else{if(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions){this._bindJSAction(i,e);a=!0}if(e.resetForm){this._bindResetFormAction(i,e.resetForm);a=!0}else if(this.isTooltipOnly&&!a){this._bindLink(i,"");a=!0}}this.container.classList.add("linkAnnotation");if(a){this.contentElement=i;this.container.append(i)}return this.container}_bindLink(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";e.href=this.linkService.getDestinationHash(t);e.onclick=()=>{t&&this.linkService.goToDestination(t);return!1};(t||""===t)&&annotation_layer_assertClassBrand(mo,this,_setInternalLink).call(this);i&&(e.title=i)}_bindNamedAction(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";e.href=this.linkService.getAnchorUrl("");e.onclick=()=>{this.linkService.executeNamedAction(t);return!1};i&&(e.title=i);annotation_layer_assertClassBrand(mo,this,_setInternalLink).call(this)}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const a of Object.keys(t.actions)){const s=i.get(a);s&&(e[s]=()=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:a}});return!1})}t.overlaidText&&(e.title=t.overlaidText);e.onclick||(e.onclick=()=>!1);annotation_layer_assertClassBrand(mo,this,_setInternalLink).call(this)}_bindResetFormAction(e,t){const i=e.onclick;i||(e.href=this.linkService.getAnchorUrl(""));annotation_layer_assertClassBrand(mo,this,_setInternalLink).call(this);if(this._fieldObjects)e.onclick=()=>{i?.();const e=t.fields,a=t.refs,s=t.include,r=[];if(0!==e.length||0!==a.length){const t=new Set(a);for(const i of e){const e=this._fieldObjects[i]||[];for(const i of e){const e=i.id;t.add(e)}}for(const e of Object.values(this._fieldObjects))for(const i of e)t.has(i.id)===s&&r.push(i)}else for(const e of Object.values(this._fieldObjects))r.push(...e);const n=this.annotationStorage,o=[];for(const e of r){const t=e.id;o.push(t);switch(e.type){case"text":{const i=e.defaultValue||"";n.setValue(t,{value:i});window.updateAngularFormValue(t,{value:i});break}case"checkbox":case"radiobutton":{const i=e.defaultValue===e.exportValues;n.setValue(t,{value:i});window.updateAngularFormValue(t,{value:i});break}case"combobox":case"listbox":{const i=e.defaultValue||"";n.setValue(t,{value:i});window.updateAngularFormValue(t,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${t}"]`);i&&(ho.has(i)?i.dispatchEvent(new Event("resetform")):warn(`_bindResetFormAction - element not allowed: ${t}`))}this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}});return!1};else{warn('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.');i||(e.onclick=()=>!1)}}}function _setInternalLink(){this.container.setAttribute("data-internal-link","")}function _bindAttachment(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;e.href=this.linkService.getAnchorUrl("");t.description?e.title=t.description:i&&(e.title=i);e.onclick=()=>{this.downloadManager?.openOrDownloadData(t.content,t.filename,a);return!1};annotation_layer_assertClassBrand(mo,this,_setInternalLink).call(this)}function _bindSetOCGState(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";e.href=this.linkService.getAnchorUrl("");e.onclick=()=>{this.linkService.executeSetOCGState(t);return!1};i&&(e.title=i);annotation_layer_assertClassBrand(mo,this,_setInternalLink).call(this)}class TextAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg";e.setAttribute("data-l10n-id","pdfjs-text-annotation-type");e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name}));if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.append(e);return this.container}}class WidgetAnnotationElement extends AnnotationElement{render(){return this.container}showElementAndHideCanvas(e){if(this.data.hasOwnCanvas){"CANVAS"===e.previousSibling?.nodeName&&(e.previousSibling.hidden=!0);e.hidden=!1}}_getKeyModifier(e){return FeatureTest.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,i,a,s){i.includes("mouse")?e.addEventListener(i,e=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:s(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(i,e=>{if("blur"===i){if(!t.focused)return;t.focused=!1}else if("focus"===i){if(t.focused)return;t.focused=!0}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:s(e)}})})}_setEventListeners(e,t,i,a){for(const r of i){var s=annotation_layer_slicedToArray(r,2);const i=s[0],n=s[1];if("Action"===n||this.data.actions?.[n]){"Focus"!==n&&"Blur"!==n||(t||={focused:!1});this._setEventListener(e,t,i,n,a);"Focus"!==n||this.data.actions?.Blur?"Blur"!==n||this.data.actions?.Focus||this._setEventListener(e,t,"focus","Focus",null):this._setEventListener(e,t,"blur","Blur",null)}}}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":Util.makeHexColor(...t)}_setTextStyle(e){const t=["left","center","right"],i=this.data.defaultAppearanceData.fontColor,a=this.data.defaultAppearanceData.fontSize||9,s=e.style;let r;const roundToOneDecimal=e=>Math.round(10*e)/10;if(this.data.multiLine){const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(o*a))||1);r=Math.min(a,roundToOneDecimal(t/o))}else{const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(a,roundToOneDecimal(e/o))}s.fontSize=`calc(${r}px * var(--total-scale-factor))`;s.color=Util.makeHexColor(...i);null!==this.data.textAlignment&&(s.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required");e.setAttribute("aria-required",t)}}class TextWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,i,a){const s=this.annotationStorage;for(const r of this._getElementsByName(e.name,e.id)){r.domElement&&(r.domElement[t]=i);s.setValue(r.id,{[a]:i})}}render(){const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const a=window.getFormValueFromAngular(this.data.fieldName),s=e.getValue(t,{value:this.data.fieldValue}),r=a.value?a:s;if(a!==s){e.setValue(t,{value:a.value});r.formattedValue=a.value}let n=r.value||"";const o=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&n.length>o&&(n=n.slice(0,o));let l=r.formattedValue||this.data.textContent?.join("\n")||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));const c={userValue:n,formattedValue:l,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){i=document.createElement("textarea");i.textContent=l??n;this.data.doNotScroll&&(i.style.overflowY="hidden")}else{i=document.createElement("input");i.type=this.data.password?"password":"text";i.setAttribute("value",l??n);this.data.doNotScroll&&(i.style.overflowX="hidden")}this.data.hasOwnCanvas&&(i.hidden=!0);ho.add(i);this.contentElement=i;i.setAttribute("data-element-id",t);i.disabled=this.data.readOnly;i.name=this.data.fieldName;i.tabIndex=0;const d=this.data,h=d.datetimeFormat,u=d.datetimeType,_=d.timeStep,p=!!u&&this.enableScripting;h&&(i.title=h);this._setRequired(i,this.data.required);o&&(i.maxLength=o);i.addEventListener("input",a=>{e.setValue(t,{value:a.target.value});window.updateAngularFormValue(t,{value:a.target.value});this.setPropertyOnSiblings(i,"value",a.target.value,"value");c.formattedValue=null});i.addEventListener("resetform",e=>{const t=this.data.defaultFieldValue??"";i.value=c.userValue=t;c.formattedValue=null});let blurListener=e=>{const t=c.formattedValue;null!=t&&(e.target.value=t);e.target.scrollLeft=0};window.registerAcroformField(t,i,r.value,void 0,this.data.fieldValue);i.addEventListener("updateFromAngular",i=>{c.formattedValue=null;e.setValue(t,{value:i.detail})});if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",e=>{if(c.focused)return;const t=e.target;if(p){t.type=u;_&&(t.step=_)}if(c.userValue){const e=c.userValue;if(p)if("time"===u){const i=new Date(e),a=[i.getHours(),i.getMinutes(),i.getSeconds()];t.value=a.map(e=>e.toString().padStart(2,"0")).join(":")}else t.value=new Date(e-uo).toISOString().split("date"===u?"T":".",1)[0];else t.value=e}c.lastCommittedValue=t.value;c.commitKey=1;this.data.actions?.Focus||(c.focused=!0)});i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target);const a={value(i){c.userValue=i.detail.value??"";if(!p){e.setValue(t,{value:c.userValue.toString()});window.updateAngularFormValue(t,{value:c.userValue.toString()})}i.target.value=c.userValue},formattedValue(i){const a=i.detail.formattedValue;c.formattedValue=a;null!=a&&i.target!==document.activeElement&&(i.target.value=a);const s={formattedValue:a};p&&(s.value=a);e.setValue(t,s);window.updateAngularFormValue(t,{formattedValue:a})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:i=>{const a=i.detail.charLimit,s=i.target;if(0===a){s.removeAttribute("maxLength");return}s.setAttribute("maxLength",a);let r=c.userValue;if(r&&!(r.length<=a)){r=r.slice(0,a);s.value=c.userValue=r;e.setValue(t,{value:r});window.updateAngularFormValue(t,{value:r});this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:s.selectionStart,selEnd:s.selectionEnd}})}}};this._dispatchEventFromSandbox(a,i)});i.addEventListener("keydown",e=>{c.commitKey=1;let i=-1;"Escape"===e.key?i=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(c.commitKey=3):i=2;if(-1===i)return;const a=e.target.value;if(c.lastCommittedValue!==a){c.lastCommittedValue=a;c.userValue=a;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:a,willCommit:!0,commitKey:i,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})}});const a=blurListener;blurListener=null;i.addEventListener("blur",e=>{if(!c.focused)return;this.data.actions?.Blur||(c.focused=!1);const i=e.target;let s=i.value;if(p){if(s&&"time"===u){const e=s.split(":").map(e=>parseInt(e,10));s=new Date(2e3,0,1,e[0],e[1],e[2]||0).valueOf();i.step=""}else{s.includes("T")||(s=`${s}T00:00`);s=new Date(s).valueOf()}i.type="text"}c.userValue=s;c.lastCommittedValue!==s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:s,willCommit:!0,commitKey:c.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}});a(e)});this.data.actions?.Keystroke&&i.addEventListener("beforeinput",e=>{c.lastCommittedValue=null;const i=e.data,a=e.target,s=a.value,r=a.selectionStart,n=a.selectionEnd;let o=r,l=n;switch(e.inputType){case"deleteWordBackward":{const e=s.substring(0,r).match(/\w*\W*$/);e&&(o-=e[0].length);break}case"deleteWordForward":{const e=s.substring(r).match(/^\W*\w*/);e&&(l+=e[0].length);break}case"deleteContentBackward":r===n&&(o-=1);break;case"deleteContentForward":r===n&&(l+=1)}e.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:s,change:i||"",willCommit:!1,selStart:o,selEnd:l}})});this._setEventListeners(i,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.value)}blurListener&&i.addEventListener("blur",blurListener);if(this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/o;i.classList.add("comb");i.style.letterSpacing=`calc(${e}px * var(--total-scale-factor) - 1ch)`}}else{i=document.createElement("div");i.textContent=this.data.fieldValue;i.style.verticalAlign="middle";i.style.display="table-cell";this.data.hasOwnCanvas&&(i.hidden=!0)}this._setTextStyle(i);this._setBackgroundColor(i);this._setDefaultPropertiesFromJS(i);this.container.append(i);return this.container}}class SignatureWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,i=t.id,a=window.getFormValueFromAngular(this.data.fieldName),s=e.getValue(i,{value:t.exportValue===t.fieldValue}).value;let r;a.value&&(r=!0===a.value||a.value===t.exportValue);let n=void 0!==r?r:s,o=!1;if("string"==typeof n){n=n===t.exportValue;e.setValue(i,{value:n});o=!0}else if(void 0!==a?.value&&a.value!==s){n=!0===a.value||a.value===t.exportValue?t.exportValue:void 0;e.setValue(i,{value:n})}this.container.classList.add("buttonWidgetAnnotation","checkBox");const l=document.createElement("input");ho.add(l);l.setAttribute("data-element-id",i);l.disabled=t.readOnly;this._setRequired(l,this.data.required);l.type="checkbox";l.name=t.fieldName;n&&l.setAttribute("checked",!0);l.setAttribute("exportValue",t.exportValue);l.tabIndex=0;l.addEventListener("change",a=>{const s=a.target,r=s.name,n=s.checked;for(const a of this._getElementsByName(r,i)){const s=n&&a.exportValue===t.exportValue;a.domElement&&(a.domElement.checked=s);e.setValue(a.id,{value:s});window.updateAngularFormValue(i,{value:s})}e.setValue(i,{value:n});window.updateAngularFormValue(i,{value:n})});l.addEventListener("resetform",e=>{const i=t.defaultFieldValue||"Off";e.target.checked=i===t.exportValue});window.registerAcroformField(i,l,n?t.exportValue:void 0,void 0,this.data.fieldValue);l.addEventListener("updateFromAngular",t=>e.setValue(i,{value:t.detail}));o&&window.updateAngularFormValue(i,{value:n});if(this.enableScripting&&this.hasJSActions){l.addEventListener("updatefromsandbox",t=>{const a={value(t){t.target.checked="Off"!==t.detail.value;e.setValue(i,{value:t.target.checked});window.updateAngularFormValue(i,{value:t.target.value})}};this._dispatchEventFromSandbox(a,t)});this._setEventListeners(l,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.checked)}this._setBackgroundColor(l);this._setDefaultPropertiesFromJS(l);this.container.append(l);return this.container}}class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,i=t.id,a=window.getFormValueFromAngular(this.data.fieldName),s=t.fieldValue===t.buttonValue?t.buttonValue:void 0,r=e.getValue(i,{value:s}).value;let n=a.value??r;if("string"==typeof n||a!==r){n=n===t.buttonValue;e.setValue(i,{value:n})}else n&&window.updateAngularFormValue(i,{value:t.buttonValue});if(n)for(const a of this._getElementsByName(t.fieldName,i))e.setValue(a.id,{value:!1});const o=document.createElement("input");ho.add(o);o.setAttribute("data-element-id",i);o.disabled=t.readOnly;this._setRequired(o,this.data.required);o.type="radio";o.name=t.fieldName;n&&o.setAttribute("checked",!0);o.tabIndex=0;o.addEventListener("change",t=>{const a=t.target,s=a.name,r=a.checked;for(const t of this._getElementsByName(s,i)){e.setValue(t.id,{value:!1});window.updateAngularFormValue(t.id,{value:!1})}e.setValue(i,{value:r});window.updateAngularFormValue(i,{value:r})});o.addEventListener("resetform",e=>{const i=t.defaultFieldValue;e.target.checked=null!=i&&i===t.buttonValue});window.registerAcroformField(i,o,n?t.buttonValue:void 0,t.buttonValue,this.data.fieldValue);o.addEventListener("updateFromAngular",t=>e.setValue(i,{value:t.detail}));if(this.enableScripting&&this.hasJSActions){const a=t.buttonValue;o.addEventListener("updatefromsandbox",t=>{const s={value:t=>{const s=a===t.detail.value;for(const a of this._getElementsByName(t.target.name)){const t=s&&a.id===i;a.domElement&&(a.domElement.checked=t);e.setValue(a.id,{value:t});window.updateAngularFormValue(i,{value:t})}}};this._dispatchEventFromSandbox(s,t)});this._setEventListeners(o,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.checked)}this._setBackgroundColor(o);this._setDefaultPropertiesFromJS(o);this.container.append(o);return this.container}}class PushButtonWidgetAnnotationElement extends LinkAnnotationElement{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;if(this.enableScripting&&this.hasJSActions&&t){this._setDefaultPropertiesFromJS(t);t.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({},e)})}return e}}class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,i=window.getFormValueFromAngular(this.data.fieldName),a=e.getValue(t,{value:this.data.fieldValue}),s=i.value?i:a;i!==a&&e.setValue(t,{value:i.value});const r=document.createElement("select");ho.add(r);r.setAttribute("data-element-id",t);r.disabled=this.data.readOnly;this._setRequired(r,this.data.required);r.name=this.data.fieldName;r.tabIndex=0;let n=this.data.combo&&this.data.options.length>0;if(!this.data.combo){r.size=this.data.options.length;this.data.multiSelect&&(r.multiple=!0)}r.addEventListener("resetform",e=>{const t=this.data.defaultFieldValue;for(const e of r.options)e.selected=e.value===t});const fixDisplayValue=(e,t)=>{const i=t.replaceAll(" "," ");e.textContent=i;i!==t&&e.setAttribute("display-value",t)};for(const e of this.data.options){const t=document.createElement("option");fixDisplayValue(t,e.displayValue);t.value=e.exportValue;if(s.value.includes(e.exportValue)){t.setAttribute("selected",!0);n=!1}r.append(t)}let o=null;if(n){const e=document.createElement("option");e.value=" ";e.setAttribute("hidden",!0);e.setAttribute("selected",!0);r.prepend(e);o=()=>{e.remove();r.removeEventListener("input",o);o=null};r.addEventListener("input",o)}const getValue=e=>{const t=e?"value":"textContent",i=r.options;return r.multiple?Array.prototype.filter.call(i,e=>e.selected).map(e=>e[t]):-1===i.selectedIndex?null:i[i.selectedIndex][t]};let l=getValue(!1);const getItems=e=>{const t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.getAttribute("display-value")||e.textContent,exportValue:e.value}))};window.registerAcroformField(t,r,l,void 0,this.data.fieldValue);r.addEventListener("updateFromAngular",i=>e.setValue(t,{value:i.detail}));if(this.enableScripting&&this.hasJSActions){r.addEventListener("updatefromsandbox",i=>{const a={value(i){o?.();const a=i.detail.value,s=new Set(Array.isArray(a)?a:[a]);for(const e of r.options)e.selected=s.has(e.value);e.setValue(t,{value:getValue(!0)});l=getValue(!1);window.updateAngularFormValue(t,{value:l})},multipleSelection(e){r.multiple=!0},remove(i){const a=r.options,s=i.detail.remove;a[s].selected=!1;r.remove(s);if(a.length>0){-1===Array.prototype.findIndex.call(a,e=>e.selected)&&(a[0].selected=!0)}e.setValue(t,{value:getValue(!0),items:getItems(i)});l=getValue(!1)},clear(i){for(;0!==r.length;)r.remove(0);e.setValue(t,{value:null,items:[]});l=getValue(!1);window.updateAngularFormValue(t,{value:l})},insert(i){const a=i.detail.insert,s=a.index,n=a.displayValue,o=a.exportValue,c=r.children[s],d=document.createElement("option");fixDisplayValue(d,n);d.value=o;c?c.before(d):r.append(d);e.setValue(t,{value:getValue(!0),items:getItems(i)});l=getValue(!1);window.updateAngularFormValue(t,{value:l})},items(i){const a=i.detail.items;for(;0!==r.length;)r.remove(0);for(const e of a){const t=e.displayValue,i=e.exportValue,a=document.createElement("option");fixDisplayValue(a,t);a.value=i;r.append(a)}r.options.length>0&&(r.options[0].selected=!0);e.setValue(t,{value:getValue(!0),items:getItems(i)});l=getValue(!1);window.updateAngularFormValue(t,{value:l})},indices(i){const a=new Set(i.detail.indices);for(const e of i.target.options)e.selected=a.has(e.index);e.setValue(t,{value:getValue(!0)});l=getValue(!1);window.updateAngularFormValue(t,{value:l})},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(a,i)});r.addEventListener("input",i=>{const a=getValue(!0),s=getValue(!1);e.setValue(t,{value:a});window.updateAngularFormValue(t,{value:a});i.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:l,change:s,changeEx:a,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"]],e=>e.target.value)}else r.addEventListener("input",function(i){e.setValue(t,{value:getValue(!0)});window.updateAngularFormValue(t,{value:getValue(!0)})});this.data.combo&&this._setTextStyle(r);this._setBackgroundColor(r);this._setDefaultPropertiesFromJS(r);this.container.append(r);return this.container}}var vo=new WeakSet;class PopupAnnotationElement extends AnnotationElement{constructor(e){const t=e.data,i=e.elements,a=!!e.parent._commentManager;super(e,{isRenderable:!a&&AnnotationElement._hasPopupData(t)});annotation_layer_classPrivateMethodInitSpec(this,vo);this.elements=i;if(a&&AnnotationElement._hasPopupData(t)){const e=this.popup=annotation_layer_assertClassBrand(vo,this,_createPopup).call(this);for(const t of i)t.popup=e}else this.popup=null}render(){const e=this.container;e.classList.add("popupAnnotation");e.role="comment";const t=this.popup=annotation_layer_assertClassBrand(vo,this,_createPopup).call(this),i=[];for(const e of this.elements){e.popup=t;e.container.ariaHasPopup="dialog";i.push(e.data.id);e.addHighlightArea()}this.container.setAttribute("aria-controls",i.map(e=>`${v}${e}`).join(","));return this.container}}function _createPopup(){return new PopupElement({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}var yo=new WeakMap,Po=new WeakMap,wo=new WeakMap,bo=new WeakMap,Fo=new WeakMap,So=new WeakMap,Co=new WeakMap,Ao=new WeakMap,xo=new WeakMap,ko=new WeakMap,Eo=new WeakMap,To=new WeakMap,Io=new WeakMap,Go=new WeakMap,Bo=new WeakMap,Mo=new WeakMap,Do=new WeakMap,Lo=new WeakMap,Oo=new WeakMap,Ro=new WeakMap,No=new WeakMap,jo=new WeakMap,Wo=new WeakMap,Uo=new WeakMap,Vo=new WeakMap,Ho=new WeakMap,zo=new WeakSet;class PopupElement{constructor(e){let t=e.container,i=e.color,a=e.elements,s=e.titleObj,r=e.modificationDate,n=e.contentsObj,o=e.richText,l=e.parent,c=e.rect,d=e.parentRect,h=e.open,u=e.commentManager,_=void 0===u?null:u;annotation_layer_classPrivateMethodInitSpec(this,zo);annotation_layer_classPrivateFieldInitSpec(this,yo,null);annotation_layer_classPrivateFieldInitSpec(this,Po,annotation_layer_assertClassBrand(zo,this,annotation_layer_keyDown).bind(this));annotation_layer_classPrivateFieldInitSpec(this,wo,annotation_layer_assertClassBrand(zo,this,_hide).bind(this));annotation_layer_classPrivateFieldInitSpec(this,bo,annotation_layer_assertClassBrand(zo,this,_show).bind(this));annotation_layer_classPrivateFieldInitSpec(this,Fo,annotation_layer_assertClassBrand(zo,this,_toggle).bind(this));annotation_layer_classPrivateFieldInitSpec(this,So,null);annotation_layer_classPrivateFieldInitSpec(this,Co,null);annotation_layer_classPrivateFieldInitSpec(this,Ao,null);annotation_layer_classPrivateFieldInitSpec(this,xo,null);annotation_layer_classPrivateFieldInitSpec(this,ko,null);annotation_layer_classPrivateFieldInitSpec(this,Eo,null);annotation_layer_classPrivateFieldInitSpec(this,To,null);annotation_layer_classPrivateFieldInitSpec(this,Io,!1);annotation_layer_classPrivateFieldInitSpec(this,Go,null);annotation_layer_classPrivateFieldInitSpec(this,Bo,null);annotation_layer_classPrivateFieldInitSpec(this,Mo,null);annotation_layer_classPrivateFieldInitSpec(this,Do,null);annotation_layer_classPrivateFieldInitSpec(this,Lo,null);annotation_layer_classPrivateFieldInitSpec(this,Oo,null);annotation_layer_classPrivateFieldInitSpec(this,Ro,null);annotation_layer_classPrivateFieldInitSpec(this,No,null);annotation_layer_classPrivateFieldInitSpec(this,jo,null);annotation_layer_classPrivateFieldInitSpec(this,Wo,null);annotation_layer_classPrivateFieldInitSpec(this,Uo,!1);annotation_layer_classPrivateFieldInitSpec(this,Vo,null);annotation_layer_classPrivateFieldInitSpec(this,Ho,null);annotation_layer_classPrivateFieldSet(Co,this,t);annotation_layer_classPrivateFieldSet(jo,this,s);annotation_layer_classPrivateFieldSet(Ao,this,n);annotation_layer_classPrivateFieldSet(No,this,o);annotation_layer_classPrivateFieldSet(Eo,this,l);annotation_layer_classPrivateFieldSet(So,this,i);annotation_layer_classPrivateFieldSet(Ro,this,c);annotation_layer_classPrivateFieldSet(To,this,d);annotation_layer_classPrivateFieldSet(ko,this,a);annotation_layer_classPrivateFieldSet(yo,this,_);annotation_layer_classPrivateFieldSet(Vo,this,a[0]);annotation_layer_classPrivateFieldSet(xo,this,PDFDateString.toDateObject(r));this.trigger=a.flatMap(e=>e.getElementsToTriggerPopup());if(!_){annotation_layer_assertClassBrand(zo,this,_addEventListeners).call(this);annotation_layer_classPrivateFieldGet(Co,this).hidden=!0;h&&annotation_layer_assertClassBrand(zo,this,_toggle).call(this)}}renderCommentButton(){if(annotation_layer_classPrivateFieldGet(Do,this)){annotation_layer_classPrivateFieldGet(Do,this).parentNode||annotation_layer_classPrivateFieldGet(Vo,this).container.after(annotation_layer_classPrivateFieldGet(Do,this));return}annotation_layer_classPrivateFieldGet(Lo,this)||annotation_layer_assertClassBrand(zo,this,_setCommentButtonPosition).call(this);if(!annotation_layer_classPrivateFieldGet(Lo,this))return;const e=annotation_layer_classPrivateFieldSet(Bo,this,new AbortController).signal,t=annotation_layer_classPrivateFieldGet(Vo,this).hasOwnCommentButton,togglePopup=()=>{annotation_layer_classPrivateFieldGet(yo,this).toggleCommentPopup(this,!0,void 0,!t)},showPopup=()=>{annotation_layer_classPrivateFieldGet(yo,this).toggleCommentPopup(this,!1,!0,!t)},hidePopup=()=>{annotation_layer_classPrivateFieldGet(yo,this).toggleCommentPopup(this,!1,!1)};if(t){annotation_layer_classPrivateFieldSet(Do,this,annotation_layer_classPrivateFieldGet(Vo,this).container);for(const t of this.trigger){t.ariaHasPopup="dialog";t.ariaControls="commentPopup";t.addEventListener("keydown",annotation_layer_classPrivateFieldGet(Po,this),{signal:e});t.addEventListener("click",togglePopup,{signal:e});t.addEventListener("pointerenter",showPopup,{signal:e});t.addEventListener("pointerleave",hidePopup,{signal:e});t.classList.add("popupTriggerArea")}}else{const t=annotation_layer_classPrivateFieldSet(Do,this,document.createElement("button"));t.className="annotationCommentButton";const i=annotation_layer_classPrivateFieldGet(Vo,this).container;t.style.zIndex=parseInt(i.style.zIndex,10)+1;t.tabIndex=0;t.ariaHasPopup="dialog";t.ariaControls="commentPopup";t.setAttribute("data-l10n-id","pdfjs-show-comment-button");annotation_layer_assertClassBrand(zo,this,_updateColor).call(this);annotation_layer_assertClassBrand(zo,this,_updateCommentButtonPosition).call(this);t.addEventListener("keydown",annotation_layer_classPrivateFieldGet(Po,this),{signal:e});t.addEventListener("click",togglePopup,{signal:e});t.addEventListener("pointerenter",showPopup,{signal:e});t.addEventListener("pointerleave",hidePopup,{signal:e});i.after(t)}}get commentButtonColor(){const e=annotation_layer_classPrivateFieldGet(Vo,this).commentData,t=e.color,i=e.opacity;return t?annotation_layer_classPrivateFieldGet(Eo,this)._commentManager.makeCommentColor(t,i):null}focusCommentButton(){setTimeout(()=>{annotation_layer_classPrivateFieldGet(Do,this)?.focus()},0)}getData(){const e=annotation_layer_classPrivateFieldGet(Vo,this).commentData,t=e.richText,i=e.color,a=e.opacity,s=e.creationDate,r=e.modificationDate;return{contentsObj:{str:this.comment},richText:t,color:i,opacity:a,creationDate:s,modificationDate:r}}get elementBeforePopup(){return annotation_layer_classPrivateFieldGet(Do,this)}get comment(){annotation_layer_classPrivateFieldGet(Ho,this)||annotation_layer_classPrivateFieldSet(Ho,this,annotation_layer_classPrivateFieldGet(Vo,this).commentText);return annotation_layer_classPrivateFieldGet(Ho,this)}set comment(e){e!==this.comment&&(annotation_layer_classPrivateFieldGet(Vo,this).commentText=annotation_layer_classPrivateFieldSet(Ho,this,e))}focus(){annotation_layer_classPrivateFieldGet(Vo,this).container?.focus()}get parentBoundingClientRect(){return annotation_layer_classPrivateFieldGet(Vo,this).layer.getBoundingClientRect()}setCommentButtonStates(e){let t=e.selected,i=e.hasPopup;if(annotation_layer_classPrivateFieldGet(Do,this)){annotation_layer_classPrivateFieldGet(Do,this).classList.toggle("selected",t);annotation_layer_classPrivateFieldGet(Do,this).ariaExpanded=i}}setSelectedCommentButton(e){annotation_layer_classPrivateFieldGet(Do,this).classList.toggle("selected",e)}get commentPopupPosition(){if(annotation_layer_classPrivateFieldGet(Oo,this))return annotation_layer_classPrivateFieldGet(Oo,this);const e=annotation_layer_classPrivateFieldGet(Do,this).getBoundingClientRect(),t=e.x,i=e.y,a=e.height,s=annotation_layer_classPrivateFieldGet(Vo,this).layer.getBoundingClientRect(),r=s.x,n=s.y;return[(t-r)/s.width,(i+a-n)/s.height]}set commentPopupPosition(e){annotation_layer_classPrivateFieldSet(Oo,this,e)}hasDefaultPopupPosition(){return null===annotation_layer_classPrivateFieldGet(Oo,this)}get commentButtonPosition(){return annotation_layer_classPrivateFieldGet(Lo,this)}get commentButtonWidth(){return annotation_layer_classPrivateFieldGet(Do,this).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(e){const t=annotation_layer_slicedToArray(annotation_layer_classPrivateFieldGet(Oo,this)||this.commentButtonPosition.map(e=>e/100),2),i=t[0],a=t[1],s=this.parentBoundingClientRect,r=s.x,n=s.y,o=s.width,l=s.height;annotation_layer_classPrivateFieldGet(yo,this).showDialog(null,this,r+i*o,n+a*l,{...e,parentDimensions:s})}render(){if(annotation_layer_classPrivateFieldGet(Go,this))return;const e=annotation_layer_classPrivateFieldSet(Go,this,document.createElement("div"));e.className="popup";if(annotation_layer_classPrivateFieldGet(So,this)){const t=e.style.outlineColor=Util.makeHexColor(...annotation_layer_classPrivateFieldGet(So,this));e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}const t=document.createElement("span");t.className="header";if(annotation_layer_classPrivateFieldGet(jo,this)?.str){const e=document.createElement("span");e.className="title";t.append(e);var i=annotation_layer_classPrivateFieldGet(jo,this);e.dir=i.dir;e.textContent=i.str}e.append(t);if(annotation_layer_classPrivateFieldGet(xo,this)){const e=document.createElement("time");e.className="popupDate";e.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string");e.setAttribute("data-l10n-args",JSON.stringify({dateObj:annotation_layer_classPrivateFieldGet(xo,this).valueOf()}));e.dateTime=annotation_layer_classPrivateFieldGet(xo,this).toISOString();t.append(e)}renderRichText({html:annotation_layer_classPrivateGetter(zo,this,_get_html)||annotation_layer_classPrivateFieldGet(Ao,this).str,dir:annotation_layer_classPrivateFieldGet(Ao,this)?.dir,className:"popupContent"},e);annotation_layer_classPrivateFieldGet(Co,this).append(e)}updateEdited(e){let t=e.rect,i=e.popup,a=e.deleted;if(annotation_layer_classPrivateFieldGet(yo,this)){if(a){this.remove();annotation_layer_classPrivateFieldSet(Ho,this,null)}else if(i)if(i.deleted)this.remove();else{annotation_layer_assertClassBrand(zo,this,_updateColor).call(this);annotation_layer_classPrivateFieldSet(Ho,this,i.text)}if(t){annotation_layer_classPrivateFieldSet(Lo,this,null);annotation_layer_assertClassBrand(zo,this,_setCommentButtonPosition).call(this);annotation_layer_assertClassBrand(zo,this,_updateCommentButtonPosition).call(this)}}else if(a||i?.deleted)this.remove();else{annotation_layer_assertClassBrand(zo,this,_addEventListeners).call(this);annotation_layer_classPrivateFieldGet(Wo,this)||annotation_layer_classPrivateFieldSet(Wo,this,{contentsObj:annotation_layer_classPrivateFieldGet(Ao,this),richText:annotation_layer_classPrivateFieldGet(No,this)});t&&annotation_layer_classPrivateFieldSet(Mo,this,null);if(i&&i.text){annotation_layer_classPrivateFieldSet(No,this,annotation_layer_assertClassBrand(zo,this,_makePopupContent).call(this,i.text));annotation_layer_classPrivateFieldSet(xo,this,PDFDateString.toDateObject(i.date));annotation_layer_classPrivateFieldSet(Ao,this,null)}annotation_layer_classPrivateFieldGet(Go,this)?.remove();annotation_layer_classPrivateFieldSet(Go,this,null)}}resetEdited(){if(annotation_layer_classPrivateFieldGet(Wo,this)){var e=annotation_layer_classPrivateFieldGet(Wo,this);_toSetter(annotation_layer_classPrivateFieldSet,[Ao,this])._=e.contentsObj;_toSetter(annotation_layer_classPrivateFieldSet,[No,this])._=e.richText;annotation_layer_classPrivateFieldSet(Wo,this,null);annotation_layer_classPrivateFieldGet(Go,this)?.remove();annotation_layer_classPrivateFieldSet(Go,this,null);annotation_layer_classPrivateFieldSet(Mo,this,null)}}remove(){annotation_layer_classPrivateFieldGet(Bo,this)?.abort();annotation_layer_classPrivateFieldSet(Bo,this,null);annotation_layer_classPrivateFieldGet(Go,this)?.remove();annotation_layer_classPrivateFieldSet(Go,this,null);annotation_layer_classPrivateFieldSet(Uo,this,!1);annotation_layer_classPrivateFieldSet(Io,this,!1);annotation_layer_classPrivateFieldGet(Do,this)?.remove();annotation_layer_classPrivateFieldSet(Do,this,null);if(this.trigger)for(const e of this.trigger)e.classList.remove("popupTriggerArea")}forceHide(){annotation_layer_classPrivateFieldSet(Uo,this,this.isVisible);annotation_layer_classPrivateFieldGet(Uo,this)&&(annotation_layer_classPrivateFieldGet(Co,this).hidden=!0)}maybeShow(){if(!annotation_layer_classPrivateFieldGet(yo,this)){annotation_layer_assertClassBrand(zo,this,_addEventListeners).call(this);if(annotation_layer_classPrivateFieldGet(Uo,this)){annotation_layer_classPrivateFieldGet(Go,this)||annotation_layer_assertClassBrand(zo,this,_show).call(this);annotation_layer_classPrivateFieldSet(Uo,this,!1);annotation_layer_classPrivateFieldGet(Co,this).hidden=!1}}}get isVisible(){return!annotation_layer_classPrivateFieldGet(yo,this)&&!1===annotation_layer_classPrivateFieldGet(Co,this).hidden}}function _addEventListeners(){if(annotation_layer_classPrivateFieldGet(Bo,this))return;annotation_layer_classPrivateFieldSet(Bo,this,new AbortController);const e=annotation_layer_classPrivateFieldGet(Bo,this).signal;for(const t of this.trigger){t.addEventListener("click",annotation_layer_classPrivateFieldGet(Fo,this),{signal:e});t.addEventListener("pointerenter",annotation_layer_classPrivateFieldGet(bo,this),{signal:e});t.addEventListener("pointerleave",annotation_layer_classPrivateFieldGet(wo,this),{signal:e});t.classList.add("popupTriggerArea")}for(const t of annotation_layer_classPrivateFieldGet(ko,this))t.container?.addEventListener("keydown",annotation_layer_classPrivateFieldGet(Po,this),{signal:e})}function _setCommentButtonPosition(){const e=annotation_layer_classPrivateFieldGet(ko,this).find(e=>e.hasCommentButton);e&&annotation_layer_classPrivateFieldSet(Lo,this,e._normalizePoint(e.commentButtonPosition))}function _updateCommentButtonPosition(){if(annotation_layer_classPrivateFieldGet(Vo,this).extraPopupElement&&!annotation_layer_classPrivateFieldGet(Vo,this).editor)return;annotation_layer_classPrivateFieldGet(Do,this)||this.renderCommentButton();const e=annotation_layer_slicedToArray(annotation_layer_classPrivateFieldGet(Lo,this),2),t=e[0],i=e[1],a=annotation_layer_classPrivateFieldGet(Do,this).style;a.left=`calc(${t}%)`;a.top=`calc(${i}% - var(--comment-button-dim))`}function _updateColor(){if(!annotation_layer_classPrivateFieldGet(Vo,this).extraPopupElement){annotation_layer_classPrivateFieldGet(Do,this)||this.renderCommentButton();annotation_layer_classPrivateFieldGet(Do,this).style.backgroundColor=this.commentButtonColor||""}}function _get_html(e){const t=annotation_layer_classPrivateFieldGet(No,e),i=annotation_layer_classPrivateFieldGet(Ao,e);return!t?.str||i?.str&&i.str!==t.str?null:annotation_layer_classPrivateFieldGet(No,e).html||null}function _get_fontSize(e){return annotation_layer_classPrivateGetter(zo,e,_get_html)?.attributes?.style?.fontSize||0}function _get_fontColor(e){return annotation_layer_classPrivateGetter(zo,e,_get_html)?.attributes?.style?.color||null}function _makePopupContent(e){const t=[],i={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},a={style:{color:annotation_layer_classPrivateGetter(zo,this,_get_fontColor),fontSize:annotation_layer_classPrivateGetter(zo,this,_get_fontSize)?`calc(${annotation_layer_classPrivateGetter(zo,this,_get_fontSize)}px * var(--total-scale-factor))`:""}};for(const i of e.split("\n"))t.push({name:"span",value:i,attributes:a});return i}function annotation_layer_keyDown(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||("Enter"===e.key||"Escape"===e.key&&annotation_layer_classPrivateFieldGet(Io,this))&&annotation_layer_assertClassBrand(zo,this,_toggle).call(this)}function _setPosition(){if(null!==annotation_layer_classPrivateFieldGet(Mo,this))return;const e=annotation_layer_classPrivateFieldGet(Eo,this),t=e.page.view,i=e.viewport.rawDims,a=i.pageWidth,s=i.pageHeight,r=i.pageX,n=i.pageY;let o=!!annotation_layer_classPrivateFieldGet(To,this),l=annotation_layer_classPrivateFieldGet(o?To:Ro,this);for(const e of annotation_layer_classPrivateFieldGet(ko,this))if(!l||null!==Util.intersect(e.data.rect,l)){l=e.data.rect;o=!0;break}const c=Util.normalizeRect([l[0],t[3]-l[1]+t[1],l[2],t[3]-l[3]+t[1]]),d=o?l[2]-l[0]+5:0,h=c[0]+d,u=c[1];annotation_layer_classPrivateFieldSet(Mo,this,[100*(h-r)/a,100*(u-n)/s]);const _=annotation_layer_classPrivateFieldGet(Co,this).style;_.left=`${annotation_layer_classPrivateFieldGet(Mo,this)[0]}%`;_.top=`${annotation_layer_classPrivateFieldGet(Mo,this)[1]}%`}function _toggle(){if(annotation_layer_classPrivateFieldGet(yo,this))annotation_layer_classPrivateFieldGet(yo,this).toggleCommentPopup(this,!1);else{annotation_layer_classPrivateFieldSet(Io,this,!annotation_layer_classPrivateFieldGet(Io,this));if(annotation_layer_classPrivateFieldGet(Io,this)){annotation_layer_assertClassBrand(zo,this,_show).call(this);annotation_layer_classPrivateFieldGet(Co,this).addEventListener("click",annotation_layer_classPrivateFieldGet(Fo,this));annotation_layer_classPrivateFieldGet(Co,this).addEventListener("keydown",annotation_layer_classPrivateFieldGet(Po,this))}else{annotation_layer_assertClassBrand(zo,this,_hide).call(this);annotation_layer_classPrivateFieldGet(Co,this).removeEventListener("click",annotation_layer_classPrivateFieldGet(Fo,this));annotation_layer_classPrivateFieldGet(Co,this).removeEventListener("keydown",annotation_layer_classPrivateFieldGet(Po,this))}}}function _show(){annotation_layer_classPrivateFieldGet(Go,this)||this.render();if(this.isVisible)annotation_layer_classPrivateFieldGet(Io,this)&&annotation_layer_classPrivateFieldGet(Co,this).classList.add("focused");else{annotation_layer_assertClassBrand(zo,this,_setPosition).call(this);annotation_layer_classPrivateFieldGet(Co,this).hidden=!1;annotation_layer_classPrivateFieldGet(Co,this).style.zIndex=parseInt(annotation_layer_classPrivateFieldGet(Co,this).style.zIndex,10)+1e3;const e=annotation_layer_classPrivateFieldGet(Co,this).closest(".page");e&&(e.style.overflow="visible")}}function _hide(){annotation_layer_classPrivateFieldGet(Co,this).classList.remove("focused");if(annotation_layer_classPrivateFieldGet(Io,this)||!this.isVisible)return;annotation_layer_classPrivateFieldGet(Co,this).hidden=!0;annotation_layer_classPrivateFieldGet(Co,this).style.zIndex=parseInt(annotation_layer_classPrivateFieldGet(Co,this).style.zIndex,10)-1e3;const e=annotation_layer_classPrivateFieldGet(Co,this).closest(".page");e&&(e.style.overflow="")}class FreeTextAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.textContent=e.data.textContent;this.textPosition=e.data.textPosition;this.annotationEditorType=P.FREETEXT}render(){this.container.classList.add("freeTextAnnotation");if(this.textContent){const e=this.contentElement=document.createElement("div");e.classList.add("annotationTextContent");e.setAttribute("role","comment");for(const t of this.textContent){const i=document.createElement("span");i.textContent=t;e.append(i)}this.container.append(e)}if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this._editOnDoubleClick();return this.container}}var $o=new WeakMap;class LineAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,$o,null)}render(){this.container.classList.add("lineAnnotation");const e=this.data,t=this.width,i=this.height,a=this.svgFactory.create(t,i,!0),s=annotation_layer_classPrivateFieldSet($o,this,this.svgFactory.createElement("svg:line"));s.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]);s.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]);s.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]);s.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]);s.setAttribute("stroke-width",e.borderStyle.width||1);s.setAttribute("stroke","transparent");s.setAttribute("fill","transparent");a.append(s);this.container.append(a);if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet($o,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var qo=new WeakMap;class SquareAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,qo,null)}render(){this.container.classList.add("squareAnnotation");const e=this.data,t=this.width,i=this.height,a=this.svgFactory.create(t,i,!0),s=e.borderStyle.width,r=annotation_layer_classPrivateFieldSet(qo,this,this.svgFactory.createElement("svg:rect"));r.setAttribute("x",s/2);r.setAttribute("y",s/2);r.setAttribute("width",t-s);r.setAttribute("height",i-s);r.setAttribute("stroke-width",s||1);r.setAttribute("stroke","transparent");r.setAttribute("fill","transparent");a.append(r);this.container.append(a);if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(qo,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var Xo=new WeakMap;class CircleAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,Xo,null)}render(){this.container.classList.add("circleAnnotation");const e=this.data,t=this.width,i=this.height,a=this.svgFactory.create(t,i,!0),s=e.borderStyle.width,r=annotation_layer_classPrivateFieldSet(Xo,this,this.svgFactory.createElement("svg:ellipse"));r.setAttribute("cx",t/2);r.setAttribute("cy",i/2);r.setAttribute("rx",t/2-s/2);r.setAttribute("ry",i/2-s/2);r.setAttribute("stroke-width",s||1);r.setAttribute("stroke","transparent");r.setAttribute("fill","transparent");a.append(r);this.container.append(a);if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(Xo,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var Ko=new WeakMap;class PolylineAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,Ko,null);this.containerClassName="polylineAnnotation";this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const e=this.data,t=e.rect,i=e.vertices,a=e.borderStyle,s=e.popupRef,r=this.width,n=this.height;if(!i)return this.container;const o=this.svgFactory.create(r,n,!0);let l=[];for(let e=0,a=i.length;e<a;e+=2){const a=i[e]-t[0],s=t[3]-i[e+1];l.push(`${a},${s}`)}l=l.join(" ");const c=annotation_layer_classPrivateFieldSet(Ko,this,this.svgFactory.createElement(this.svgElementName));c.setAttribute("points",l);c.setAttribute("stroke-width",a.width||1);c.setAttribute("stroke","transparent");c.setAttribute("fill","transparent");o.append(c);this.container.append(o);if(!s&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(Ko,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}class PolygonAnnotationElement extends PolylineAnnotationElement{constructor(e){super(e);this.containerClassName="polygonAnnotation";this.svgElementName="svg:polygon"}}class CaretAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("caretAnnotation");if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}}var Yo=new WeakMap,Zo=new WeakMap,Jo=new WeakSet;class InkAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateMethodInitSpec(this,Jo);annotation_layer_classPrivateFieldInitSpec(this,Yo,null);annotation_layer_classPrivateFieldInitSpec(this,Zo,[]);this.containerClassName="inkAnnotation";this.svgElementName="svg:polyline";this.annotationEditorType="InkHighlight"===this.data.it?P.HIGHLIGHT:P.INK}render(){this.container.classList.add(this.containerClassName);const e=this.data,t=e.rect,i=e.rotation,a=e.inkLists,s=e.borderStyle,r=e.popupRef,n=annotation_layer_assertClassBrand(Jo,this,_getTransform).call(this,i,t),o=n.transform,l=n.width,c=n.height,d=this.svgFactory.create(l,c,!0),h=annotation_layer_classPrivateFieldSet(Yo,this,this.svgFactory.createElement("svg:g"));d.append(h);h.setAttribute("stroke-width",s.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",o);for(let e=0,t=a.length;e<t;e++){const t=this.svgFactory.createElement(this.svgElementName);annotation_layer_classPrivateFieldGet(Zo,this).push(t);t.setAttribute("points",a[e].join(","));h.append(t)}if(!r&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.append(d);this._editOnDoubleClick();return this.container}updateEdited(e){super.updateEdited(e);const t=e.thickness,i=e.points,a=e.rect,s=annotation_layer_classPrivateFieldGet(Yo,this);t>=0&&s.setAttribute("stroke-width",t||1);if(i)for(let e=0,t=annotation_layer_classPrivateFieldGet(Zo,this).length;e<t;e++)annotation_layer_classPrivateFieldGet(Zo,this)[e].setAttribute("points",i[e].join(","));if(a){const e=annotation_layer_assertClassBrand(Jo,this,_getTransform).call(this,this.data.rotation,a),t=e.transform,i=e.width,r=e.height;s.parentElement.setAttribute("viewBox",`0 0 ${i} ${r}`);s.setAttribute("transform",t)}}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(Zo,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function _getTransform(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}class HighlightAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0});this.annotationEditorType=P.HIGHLIGHT}render(){const e=this.data,t=e.overlaidText;if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("highlightAnnotation");this._editOnDoubleClick();if(t){const e=document.createElement("mark");e.classList.add("overlaidText");e.textContent=t;this.container.append(e)}return this.container}}class UnderlineAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const e=this.data,t=e.overlaidText;if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("underlineAnnotation");if(t){const e=document.createElement("u");e.classList.add("overlaidText");e.textContent=t;this.container.append(e)}return this.container}}class SquigglyAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const e=this.data,t=e.overlaidText;if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("squigglyAnnotation");if(t){const e=document.createElement("u");e.classList.add("overlaidText");e.textContent=t;this.container.append(e)}return this.container}}class StrikeOutAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const e=this.data,t=e.overlaidText;if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("strikeoutAnnotation");if(t){const e=document.createElement("s");e.classList.add("overlaidText");e.textContent=t;this.container.append(e)}return this.container}}class StampAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.annotationEditorType=P.STAMP}render(){this.container.classList.add("stampAnnotation");this.container.setAttribute("role","img");if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this._editOnDoubleClick();return this.container}}var Qo=new WeakMap,el=new WeakSet;class FileAttachmentAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0});annotation_layer_classPrivateMethodInitSpec(this,el);annotation_layer_classPrivateFieldInitSpec(this,Qo,null);const t=this.data.file;this.filename=t.filename;this.content=t.content;this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...t})}render(){this.container.classList.add("fileAttachmentAnnotation");const e=this.container,t=this.data;let i;if(t.hasAppearance||0===t.fillAlpha)i=document.createElement("div");else{i=document.createElement("img");i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`;t.fillAlpha&&t.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*t.fillAlpha)}%);`)}i.addEventListener("dblclick",annotation_layer_assertClassBrand(el,this,_download).bind(this));annotation_layer_classPrivateFieldSet(Qo,this,i);const a=FeatureTest.platform.isMac;e.addEventListener("keydown",e=>{"Enter"===e.key&&(a?e.metaKey:e.ctrlKey)&&annotation_layer_assertClassBrand(el,this,_download).call(this)});if(!t.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}else i.classList.add("popupTriggerArea");e.append(i);return e}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(Qo,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function _download(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}var tl,il=new WeakMap,al=new WeakMap,sl=new WeakMap,rl=new WeakMap,nl=new WeakMap,ol=new WeakMap,ll=new WeakMap,cl=new WeakMap,dl=new WeakSet;class AnnotationLayer{constructor(e){let t=e.div,i=e.accessibilityManager,a=e.annotationCanvasMap,s=e.annotationEditorUIManager,r=e.page,n=e.viewport,o=e.structTreeLayer,l=e.commentManager,c=e.linkService,d=e.annotationStorage;annotation_layer_classPrivateMethodInitSpec(this,dl);annotation_layer_classPrivateFieldInitSpec(this,il,null);annotation_layer_classPrivateFieldInitSpec(this,al,null);annotation_layer_classPrivateFieldInitSpec(this,sl,null);annotation_layer_classPrivateFieldInitSpec(this,rl,new Map);annotation_layer_classPrivateFieldInitSpec(this,nl,null);annotation_layer_classPrivateFieldInitSpec(this,ol,null);annotation_layer_classPrivateFieldInitSpec(this,ll,[]);annotation_layer_classPrivateFieldInitSpec(this,cl,!1);annotation_layer_defineProperty(this,"zIndex",0);this.div=t;annotation_layer_classPrivateFieldSet(il,this,i);annotation_layer_classPrivateFieldSet(al,this,a);annotation_layer_classPrivateFieldSet(nl,this,o||null);annotation_layer_classPrivateFieldSet(ol,this,c||null);annotation_layer_classPrivateFieldSet(sl,this,d||new AnnotationStorage);this.page=r;this.viewport=n;this._annotationEditorUIManager=s;this._commentManager=l||null}hasEditableAnnotations(){return annotation_layer_classPrivateFieldGet(rl,this).size>0}async render(e){const t=e.annotations,i=e.optionalContentConfig,a=this.div;setLayerDimensions(a,this.viewport);const s=new Map,r=[],n={data:null,layer:a,linkService:annotation_layer_classPrivateFieldGet(ol,this),downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,svgFactory:new DOMSVGFactory,annotationStorage:annotation_layer_classPrivateFieldGet(sl,this),enableComment:!0===e.enableComment,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const e of t){if(e.noHTML)continue;const t=e.annotationType===I.POPUP;if(t){const t=s.get(e.id);if(!t)continue;if(!this._commentManager){r.push(e);continue}n.elements=t}else if(e.rect[2]===e.rect[0]||e.rect[3]===e.rect[1])continue;n.data=e;const a=AnnotationElementFactory.create(n);if(!a.isRenderable)continue;if(!t){annotation_layer_classPrivateFieldGet(ll,this).push(a);e.popupRef&&s.getOrInsertComputed(e.popupRef,makeArr).push(a)}const o=a.render();e.hidden&&(o.style.visibility="hidden");a.updateOC(i);if(a._isEditable){annotation_layer_classPrivateFieldGet(rl,this).set(a.data.id,a);this._annotationEditorUIManager?.renderAnnotationElement(a)}}await annotation_layer_assertClassBrand(dl,this,_addElementsToDOM).call(this);for(const e of r){const t=n.elements=s.get(e.id);n.data=e;const i=AnnotationElementFactory.create(n);if(!i.isRenderable)continue;const a=i.render();i.contentElement.id=`${v}${e.id}`;e.hidden&&(a.style.visibility="hidden");t.at(-1).container.after(a)}annotation_layer_assertClassBrand(dl,this,_setAnnotationCanvasMap).call(this)}async addLinkAnnotations(e){const t={data:null,layer:this.div,linkService:annotation_layer_classPrivateFieldGet(ol,this),svgFactory:new DOMSVGFactory,parent:this};for(const i of e){i.borderStyle||=AnnotationLayer._defaultBorderStyle;t.data=i;const e=AnnotationElementFactory.create(t);if(e.isRenderable){e.render();e.contentElement.id=`${v}${i.id}`;annotation_layer_classPrivateFieldGet(ll,this).push(e)}}await annotation_layer_assertClassBrand(dl,this,_addElementsToDOM).call(this)}update(e){let t=e.viewport,i=e.optionalContentConfig;const a=this.div;this.viewport=t;setLayerDimensions(a,{rotation:t.rotation});for(const e of annotation_layer_classPrivateFieldGet(ll,this))e.updateOC(i);annotation_layer_assertClassBrand(dl,this,_setAnnotationCanvasMap).call(this);a.hidden=!1}getEditableAnnotations(){return annotation_layer_classPrivateFieldGet(rl,this).values()}getEditableAnnotation(e){return annotation_layer_classPrivateFieldGet(rl,this).get(e)}addFakeAnnotation(e){const t=this.div,i=e.id,a=e.rotation,s=new EditorAnnotationElement({data:{id:i,rect:e.getPDFRect(),rotation:a},editor:e,layer:t,parent:this,enableComment:!!this._commentManager,linkService:annotation_layer_classPrivateFieldGet(ol,this),annotationStorage:annotation_layer_classPrivateFieldGet(sl,this)});s.render();s.contentElement.id=`${v}${i}`;s.createOrUpdatePopup();annotation_layer_classPrivateFieldGet(ll,this).push(s);return s}removeAnnotation(e){const t=annotation_layer_classPrivateFieldGet(ll,this).findIndex(t=>t.data.id===e);if(t<0)return;const i=annotation_layer_slicedToArray(annotation_layer_classPrivateFieldGet(ll,this).splice(t,1),1)[0];annotation_layer_classPrivateFieldGet(il,this)?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(e){if(0!==e.length){for(const t of e)t.updateFakeAnnotationElement(this);annotation_layer_assertClassBrand(dl,this,_addElementsToDOM).call(this)}}togglePointerEvents(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("disabled",!e)}static get _defaultBorderStyle(){return shadow(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:G,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}async function _addElementsToDOM(){if(0===annotation_layer_classPrivateFieldGet(ll,this).length)return;this.div.replaceChildren();const e=[];if(!annotation_layer_classPrivateFieldGet(cl,this)){annotation_layer_classPrivateFieldSet(cl,this,!0);for(const t of annotation_layer_classPrivateFieldGet(ll,this)){const i=t.contentElement,a=t.data.id,s=i.id=`${v}${a}`;e.push(annotation_layer_classPrivateFieldGet(nl,this)?.getAriaAttributes(s).then(e=>{if(e)for(const a of e){var t=annotation_layer_slicedToArray(a,2);const e=t[0],s=t[1];i.setAttribute(e,s)}}))}}annotation_layer_classPrivateFieldGet(ll,this).sort((e,t)=>{let i=annotation_layer_slicedToArray(e.data.rect,4),a=i[0],s=i[1],r=i[2],n=i[3],o=annotation_layer_slicedToArray(t.data.rect,4),l=o[0],c=o[1],d=o[2],h=o[3];if(a===r&&s===n)return 1;if(l===d&&c===h)return-1;const u=(s+n)/2,_=(c+h)/2;if(u>=h&&_<=s)return-1;if(_>=n&&u<=c)return 1;return(a+r)/2-(l+d)/2});const t=document.createDocumentFragment();for(const e of annotation_layer_classPrivateFieldGet(ll,this)){t.append(e.container);this._commentManager?(e.extraPopupElement?.popup||e.popup)?.renderCommentButton():e.extraPopupElement&&t.append(e.extraPopupElement.render())}this.div.append(t);await Promise.all(e);if(annotation_layer_classPrivateFieldGet(il,this))for(const e of annotation_layer_classPrivateFieldGet(ll,this))annotation_layer_classPrivateFieldGet(il,this).addPointerInTextLayer(e.contentElement,!1)}function _setAnnotationCanvasMap(){if(!annotation_layer_classPrivateFieldGet(al,this))return;const e=this.div;for(const i of annotation_layer_classPrivateFieldGet(al,this)){var t=annotation_layer_slicedToArray(i,2);const a=t[0],s=t[1],r=e.querySelector(`[data-annotation-id="${a}"]`);if(!r)continue;s.className="annotationContent";const n=r.firstChild;n?"CANVAS"===n.nodeName?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):r.append(s);const o=annotation_layer_classPrivateFieldGet(rl,this).get(a);if(o)if(o._hasNoCanvas){this._annotationEditorUIManager?.setMissingCanvas(a,r.id,s);o._hasNoCanvas=!1}else o.canvas=s}annotation_layer_classPrivateFieldGet(al,this).clear()}function freetext_slicedToArray(e,t){return function freetext_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function freetext_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function freetext_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return freetext_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?freetext_arrayLikeToArray(e,t):void 0}}(e,t)||function freetext_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function freetext_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function freetext_defineProperty(e,t,i){return(t=function freetext_toPropertyKey(e){var t=function freetext_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function freetext_classPrivateFieldInitSpec(e,t,i){freetext_checkPrivateRedeclaration(e,t),t.set(e,i)}function freetext_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function freetext_classPrivateFieldGet(e,t){return e.get(freetext_assertClassBrand(e,t))}function freetext_classPrivateFieldSet(e,t,i){return e.set(freetext_assertClassBrand(e,t),i),i}function freetext_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const hl=/\r\n?|\n/g;var ul=new WeakMap,_l=new WeakMap,pl=new WeakMap,gl=new WeakMap,fl=new WeakSet;class FreeTextEditor extends AnnotationEditor{static get _keyboardManager(){const e=FreeTextEditor.prototype,arrowChecker=e=>e.isEmpty(),t=AnnotationEditorUIManager.TRANSLATE_SMALL,i=AnnotationEditorUIManager.TRANSLATE_BIG;return shadow(this,"_keyboardManager",new KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-t,0],checker:arrowChecker}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:arrowChecker}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[t,0],checker:arrowChecker}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[i,0],checker:arrowChecker}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-t],checker:arrowChecker}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:arrowChecker}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,t],checker:arrowChecker}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,i],checker:arrowChecker}]]))}constructor(e){super({...e,name:"freeTextEditor"});!function freetext_classPrivateMethodInitSpec(e,t){freetext_checkPrivateRedeclaration(e,t),t.add(e)}(this,fl);freetext_classPrivateFieldInitSpec(this,ul,"");freetext_classPrivateFieldInitSpec(this,_l,`${this.id}-editor`);freetext_classPrivateFieldInitSpec(this,pl,null);freetext_classPrivateFieldInitSpec(this,gl,void 0);freetext_defineProperty(this,"_colorPicker",null);this.color=e.color||FreeTextEditor._defaultColor||AnnotationEditor._defaultLineColor;freetext_classPrivateFieldSet(gl,this,e.fontSize||FreeTextEditor._defaultFontSize);this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.freetext);this.canAddComment=!1}static initialize(e,t){AnnotationEditor.initialize(e,t);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case w.FREETEXT_SIZE:FreeTextEditor._defaultFontSize=t;break;case w.FREETEXT_COLOR:FreeTextEditor._defaultColor=t}}updateParams(e,t){switch(e){case w.FREETEXT_SIZE:freetext_assertClassBrand(fl,this,_updateFontSize).call(this,t);break;case w.FREETEXT_COLOR:freetext_assertClassBrand(fl,this,freetext_updateColor).call(this,t)}}static get defaultPropertiesToUpdate(){return[[w.FREETEXT_SIZE,FreeTextEditor._defaultFontSize],[w.FREETEXT_COLOR,FreeTextEditor._defaultColor||AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[w.FREETEXT_SIZE,freetext_classPrivateFieldGet(gl,this)],[w.FREETEXT_COLOR,this.color]]}get toolbarButtons(){this._colorPicker||=new BasicColorPicker(this);return[["colorPicker",this._colorPicker]]}get colorType(){return w.FREETEXT_COLOR}onUpdatedColor(){this.editorDiv.style.color=this.color;this._colorPicker?.update(this.color);super.onUpdatedColor()}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){const e=this.parentScale;return[-FreeTextEditor._internalPadding*e,-(FreeTextEditor._internalPadding+freetext_classPrivateFieldGet(gl,this))*e]}rebuild(){if(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");freetext_classPrivateFieldSet(pl,this,new AbortController);const e=this._uiManager.combinedSignal(freetext_classPrivateFieldGet(pl,this));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e});this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e});this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e});this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e});this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e});return!0}disableEditMode(){if(!super.disableEditMode())return!1;this.overlayDiv.classList.add("enabled");this.editorDiv.contentEditable=!1;this.div.setAttribute("aria-activedescendant",freetext_classPrivateFieldGet(_l,this));this._isDraggable=!0;freetext_classPrivateFieldGet(pl,this)?.abort();freetext_classPrivateFieldSet(pl,this,null);this.div.focus({preventScroll:!0});this.isEditing=!1;this.parent.div.classList.add("freetextEditing");return!0}focusin(e){if(this._focusEventsAllowed){super.focusin(e);e.target!==this.editorDiv&&this.editorDiv.focus()}}onceAdded(e){if(!this.width){this.enableEditMode();e&&this.editorDiv.focus();this._initialOptions?.isCentered&&this.center();this._initialOptions=null}}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1;if(this.parent){this.parent.setEditingState(!0);this.parent.div.classList.add("freetextEditing")}super.remove()}commit(){if(!this.isInEditMode())return;super.commit();this.disableEditMode();const e=freetext_classPrivateFieldGet(ul,this),t=freetext_classPrivateFieldSet(ul,this,freetext_assertClassBrand(fl,this,_extractText).call(this).trimEnd());if(e===t)return;const setText=e=>{freetext_classPrivateFieldSet(ul,this,e);if(e){freetext_assertClassBrand(fl,this,_setContent).call(this);this._uiManager.rebuild(this);freetext_assertClassBrand(fl,this,_setEditorDimensions).call(this)}else this.remove()};this.addCommands({cmd:()=>{setText(t)},undo:()=>{setText(e)},mustExec:!1});freetext_assertClassBrand(fl,this,_setEditorDimensions).call(this);this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"commit",page:this.pageIndex+1,id:this.uid,value:t,previousValue:e})}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode();this.editorDiv.focus()}keydown(e){if(e.target===this.div&&"Enter"===e.key){this.enterInEditMode();e.preventDefault()}}editorDivKeydown(e){FreeTextEditor._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment");this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox");this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy||this.annotationElementId){e=this.x;t=this.y}super.render();this.editorDiv=document.createElement("div");this.editorDiv.className="internal";this.editorDiv.setAttribute("id",freetext_classPrivateFieldGet(_l,this));this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2");this.editorDiv.setAttribute("data-l10n-attrs","default-content");this.enableEditing();this.editorDiv.contentEditable=!0;const i=this.editorDiv.style;i.fontSize=`calc(${freetext_classPrivateFieldGet(gl,this)}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);if(this._isCopy||this.annotationElementId){const i=freetext_slicedToArray(this.parentDimensions,2),o=i[0],l=i[1];if(this.annotationElementId){const i=this._initialData.position;let c=freetext_slicedToArray(this.getInitialTranslation(),2),d=c[0],h=c[1];var a=freetext_slicedToArray(this.pageTranslationToScreen(d,h),2);d=a[0];h=a[1];const u=freetext_slicedToArray(this.pageDimensions,2),_=u[0],p=u[1],g=freetext_slicedToArray(this.pageTranslation,2),f=g[0],m=g[1];let v,y;switch(this.rotation){case 0:v=e+(i[0]-f)/_;y=t+this.height-(i[1]-m)/p;break;case 90:v=e+(i[0]-f)/_;y=t-(i[1]-m)/p;var s=[h,-d];d=s[0];h=s[1];break;case 180:v=e-this.width+(i[0]-f)/_;y=t-(i[1]-m)/p;var r=[-d,-h];d=r[0];h=r[1];break;case 270:v=e+(i[0]-f-this.height*p)/_;y=t+(i[1]-m-this.width*_)/p;var n=[-h,d];d=n[0];h=n[1]}this.setAt(v*o,y*l,d,h)}else this._moveAfterPaste(e,t);freetext_assertClassBrand(fl,this,_setContent).call(this);this._isDraggable=!0;this.editorDiv.contentEditable=!1}else{this._isDraggable=!1;this.editorDiv.contentEditable=!0}return this.div}editorDivPaste(e){const t=e.clipboardData||window.clipboardData,i=t.types;if(1===i.length&&"text/plain"===i[0])return;e.preventDefault();const a=_deserializeContent.call(FreeTextEditor,t.getData("text")||"").replaceAll(hl,"\n");if(!a)return;const s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize();s.deleteFromDocument();const r=s.getRangeAt(0);if(!a.includes("\n")){r.insertNode(document.createTextNode(a));this.editorDiv.normalize();s.collapseToStart();return}const n=r.startContainer,o=r.startOffset,l=[],c=[];if(n.nodeType===Node.TEXT_NODE){const e=n.parentElement;c.push(n.nodeValue.slice(o).replaceAll(hl,""));if(e!==this.editorDiv){let t=l;for(const i of this.editorDiv.childNodes)i!==e?t.push(_getNodeContent.call(FreeTextEditor,i)):t=c}l.push(n.nodeValue.slice(0,o).replaceAll(hl,""))}else if(n===this.editorDiv){let e=l,t=0;for(const i of this.editorDiv.childNodes){t++===o&&(e=c);e.push(_getNodeContent.call(FreeTextEditor,i))}}freetext_classPrivateFieldSet(ul,this,`${l.join("\n")}${a}${c.join("\n")}`);freetext_assertClassBrand(fl,this,_setContent).call(this);const d=new Range;let h=Math.sumPrecise(l.map(e=>e.length));for(const e of this.editorDiv.childNodes){const t=e.firstChild;if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(h<=e){d.setStart(t,h);d.setEnd(t,h);break}h-=e}}s.removeAllRanges();s.addRange(d)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=FreeTextEditor._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,t,i){let a=null;if(e instanceof FreeTextAnnotationElement){const t=e,i=t.data,s=i.defaultAppearanceData,r=s.fontSize,n=s.fontColor,o=i.rect,l=i.rotation,c=i.id,d=i.popupRef,h=i.richText,u=i.contentsObj,_=i.creationDate,p=i.modificationDate,g=t.textContent,f=t.textPosition,m=t.parent.page.pageNumber;if(!g||0===g.length)return null;a=e={annotationType:P.FREETEXT,color:Array.from(n),fontSize:r,value:g.join("\n"),position:f,pageIndex:m-1,rect:o.slice(0),rotation:l,annotationElementId:c,id:c,deleted:!1,popupRef:d,comment:u?.str||null,richText:h,creationDate:_,modificationDate:p}}const s=await super.deserialize(e,t,i);freetext_classPrivateFieldSet(gl,s,e.fontSize);s.color=Util.makeHexColor(...e.color);freetext_classPrivateFieldSet(ul,s,_deserializeContent.call(FreeTextEditor,e.value));s._initialData=a;e.comment&&s.setCommentData(e);return s}serialize(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const a=AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(e,t),{color:a,fontSize:freetext_classPrivateFieldGet(gl,this),value:freetext_assertClassBrand(fl,this,_serializeContent).call(this)});this.addComment(s,this._isCopy);if(e){i&&(s.id=this.uid);s.isCopy=!0;return s}if(this.annotationElementId&&!freetext_assertClassBrand(fl,this,_hasElementChanged).call(this,s))return null;s.id=this.uid;return s}renderAnnotationElement(e){const t=super.renderAnnotationElement(e);if(!t)return null;const i=t.style;i.fontSize=`calc(${freetext_classPrivateFieldGet(gl,this)}px * var(--total-scale-factor))`;i.color=this.color;t.replaceChildren();for(const e of freetext_classPrivateFieldGet(ul,this).split("\n")){const i=document.createElement("div");i.append(e?document.createTextNode(e):document.createElement("br"));t.append(i)}e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:freetext_classPrivateFieldGet(ul,this)}});return t}resetAnnotationElement(e){super.resetAnnotationElement(e);e.resetEdited()}}tl=FreeTextEditor;function _updateFontSize(e){const setFontsize=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--total-scale-factor))`;this.translate(0,-(e-freetext_classPrivateFieldGet(gl,this))*this.parentScale);freetext_classPrivateFieldSet(gl,this,e);freetext_assertClassBrand(fl,this,_setEditorDimensions).call(this)},t=freetext_classPrivateFieldGet(gl,this);this.addCommands({cmd:setFontsize.bind(this,e),undo:setFontsize.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:w.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0});this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"fontSizeChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:e,previousValue:freetext_classPrivateFieldGet(gl,this)})}function freetext_updateColor(e){const setColor=e=>{this.color=e;this.onUpdatedColor()},t=this.color;this.addCommands({cmd:setColor.bind(this,e),undo:setColor.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:w.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0});this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"colorChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:e,previousValue:t})}function _extractText(){const e=[];this.editorDiv.normalize();let t=null;for(const i of this.editorDiv.childNodes)if(t?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName){e.push(_getNodeContent.call(tl,i));t=i}return e.join("\n")}function _setEditorDimensions(){const e=freetext_slicedToArray(this.parentDimensions,2),t=e[0],i=e[1];let a;if(this.isAttachedToDOM)a=this.div.getBoundingClientRect();else{const e=this.currentLayer,t=this.div,i=t.style.display,s=t.classList.contains("hidden");t.classList.remove("hidden");t.style.display="hidden";e.div.append(this.div);a=t.getBoundingClientRect();t.remove();t.style.display=i;t.classList.toggle("hidden",s)}if(this.rotation%180==this.parentRotation%180){this.width=a.width/t;this.height=a.height/i}else{this.width=a.height/t;this.height=a.width/i}this.fixAndSetPosition()}function _getNodeContent(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(hl,"")}function _setContent(){this.editorDiv.replaceChildren();if(freetext_classPrivateFieldGet(ul,this))for(const e of freetext_classPrivateFieldGet(ul,this).split("\n")){const t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br"));this.editorDiv.append(t)}}function _serializeContent(){return freetext_classPrivateFieldGet(ul,this).replaceAll(" "," ")}function _deserializeContent(e){return e.replaceAll(" "," ")}function _hasElementChanged(e){const t=this._initialData,i=t.value,a=t.fontSize,s=t.color,r=t.pageIndex;return this.hasEditedComment||this._hasBeenMoved||e.value!==i||e.fontSize!==a||e.color.some((e,t)=>e!==s[t])||e.pageIndex!==r}freetext_defineProperty(FreeTextEditor,"_freeTextDefaultContent","");freetext_defineProperty(FreeTextEditor,"_internalPadding",0);freetext_defineProperty(FreeTextEditor,"_defaultColor",null);freetext_defineProperty(FreeTextEditor,"_defaultFontSize",10);freetext_defineProperty(FreeTextEditor,"_type","freetext");freetext_defineProperty(FreeTextEditor,"_editorType",P.FREETEXT);class Outline{toSVGPath(){unreachable("Abstract method `toSVGPath` must be implemented.")}get box(){unreachable("Abstract getter `box` must be implemented.")}serialize(e,t){unreachable("Abstract method `serialize` must be implemented.")}static _rescale(e,t,i,a,s,r){r||=new Float32Array(e.length);for(let n=0,o=e.length;n<o;n+=2){r[n]=t+e[n]*a;r[n+1]=i+e[n+1]*s}return r}static _rescaleAndSwap(e,t,i,a,s,r){r||=new Float32Array(e.length);for(let n=0,o=e.length;n<o;n+=2){r[n]=t+e[n+1]*a;r[n+1]=i+e[n]*s}return r}static _translate(e,t,i,a){a||=new Float32Array(e.length);for(let s=0,r=e.length;s<r;s+=2){a[s]=t+e[s];a[s+1]=i+e[s+1]}return a}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,i,a,s){switch(s){case 90:return[1-t/i,e/a];case 180:return[1-e/i,1-t/a];case 270:return[t/i,1-e/a];default:return[e/i,t/a]}}static createBezierPoints(e,t,i,a,s,r){return[(e+5*i)/6,(t+5*a)/6,(5*i+s)/6,(5*a+r)/6,(i+s)/2,(a+r)/2]}}!function outline_defineProperty(e,t,i){return(t=function outline_toPropertyKey(e){var t=function outline_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(Outline,"PRECISION",1e-4);function freedraw_slicedToArray(e,t){return function freedraw_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function freedraw_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function freedraw_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return freedraw_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?freedraw_arrayLikeToArray(e,t):void 0}}(e,t)||function freedraw_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function freedraw_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function freedraw_classPrivateMethodInitSpec(e,t){freedraw_checkPrivateRedeclaration(e,t),t.add(e)}function freedraw_classPrivateFieldInitSpec(e,t,i){freedraw_checkPrivateRedeclaration(e,t),t.set(e,i)}function freedraw_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function freedraw_classPrivateFieldGet(e,t){return e.get(freedraw_assertClassBrand(e,t))}function freedraw_classPrivateFieldSet(e,t,i){return e.set(freedraw_assertClassBrand(e,t),i),i}function freedraw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var ml=new WeakMap,vl=new WeakMap,yl=new WeakMap,Pl=new WeakMap,wl=new WeakMap,bl=new WeakMap,Fl=new WeakMap,Sl=new WeakMap,Cl=new WeakMap,Al=new WeakMap,xl=new WeakMap,kl=new WeakMap,El=new WeakMap,Tl=new WeakSet;class FreeDrawOutliner{constructor(e,t,i,a,s){let r=e.x,n=e.y,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;freedraw_classPrivateMethodInitSpec(this,Tl);freedraw_classPrivateFieldInitSpec(this,ml,void 0);freedraw_classPrivateFieldInitSpec(this,vl,[]);freedraw_classPrivateFieldInitSpec(this,yl,void 0);freedraw_classPrivateFieldInitSpec(this,Pl,void 0);freedraw_classPrivateFieldInitSpec(this,wl,[]);freedraw_classPrivateFieldInitSpec(this,bl,new Float32Array(18));freedraw_classPrivateFieldInitSpec(this,Fl,void 0);freedraw_classPrivateFieldInitSpec(this,Sl,void 0);freedraw_classPrivateFieldInitSpec(this,Cl,void 0);freedraw_classPrivateFieldInitSpec(this,Al,void 0);freedraw_classPrivateFieldInitSpec(this,xl,void 0);freedraw_classPrivateFieldInitSpec(this,kl,void 0);freedraw_classPrivateFieldInitSpec(this,El,[]);freedraw_classPrivateFieldSet(ml,this,t);freedraw_classPrivateFieldSet(kl,this,a*i);freedraw_classPrivateFieldSet(Pl,this,s);freedraw_classPrivateFieldGet(bl,this).set([NaN,NaN,NaN,NaN,r,n],6);freedraw_classPrivateFieldSet(yl,this,o);freedraw_classPrivateFieldSet(Al,this,Il._*i);freedraw_classPrivateFieldSet(Cl,this,Gl._*i);freedraw_classPrivateFieldSet(xl,this,i);freedraw_classPrivateFieldGet(El,this).push(r,n)}isEmpty(){return isNaN(freedraw_classPrivateFieldGet(bl,this)[8])}add(e){let t=e.x,i=e.y;freedraw_classPrivateFieldSet(Fl,this,t);freedraw_classPrivateFieldSet(Sl,this,i);const a=freedraw_slicedToArray(freedraw_classPrivateFieldGet(ml,this),4),s=a[0],r=a[1],n=a[2],o=a[3];let l=freedraw_slicedToArray(freedraw_classPrivateFieldGet(bl,this).subarray(8,12),4),c=l[0],d=l[1],h=l[2],u=l[3];const _=t-h,p=i-u,g=Math.hypot(_,p);if(g<freedraw_classPrivateFieldGet(Cl,this))return!1;const f=g-freedraw_classPrivateFieldGet(Al,this),m=f/g,v=m*_,y=m*p;let P=c,w=d;c=h;d=u;h+=v;u+=y;freedraw_classPrivateFieldGet(El,this)?.push(t,i);const b=v/f,S=-y/f*freedraw_classPrivateFieldGet(kl,this),C=b*freedraw_classPrivateFieldGet(kl,this);freedraw_classPrivateFieldGet(bl,this).set(freedraw_classPrivateFieldGet(bl,this).subarray(2,8),0);freedraw_classPrivateFieldGet(bl,this).set([h+S,u+C],4);freedraw_classPrivateFieldGet(bl,this).set(freedraw_classPrivateFieldGet(bl,this).subarray(14,18),12);freedraw_classPrivateFieldGet(bl,this).set([h-S,u-C],16);if(isNaN(freedraw_classPrivateFieldGet(bl,this)[6])){if(0===freedraw_classPrivateFieldGet(wl,this).length){freedraw_classPrivateFieldGet(bl,this).set([c+S,d+C],2);freedraw_classPrivateFieldGet(wl,this).push(NaN,NaN,NaN,NaN,(c+S-s)/n,(d+C-r)/o);freedraw_classPrivateFieldGet(bl,this).set([c-S,d-C],14);freedraw_classPrivateFieldGet(vl,this).push(NaN,NaN,NaN,NaN,(c-S-s)/n,(d-C-r)/o)}freedraw_classPrivateFieldGet(bl,this).set([P,w,c,d,h,u],6);return!this.isEmpty()}freedraw_classPrivateFieldGet(bl,this).set([P,w,c,d,h,u],6);if(Math.abs(Math.atan2(w-d,P-c)-Math.atan2(y,v))<Math.PI/2){var A=freedraw_slicedToArray(freedraw_classPrivateFieldGet(bl,this).subarray(2,6),4);c=A[0];d=A[1];h=A[2];u=A[3];freedraw_classPrivateFieldGet(wl,this).push(NaN,NaN,NaN,NaN,((c+h)/2-s)/n,((d+u)/2-r)/o);var x=freedraw_slicedToArray(freedraw_classPrivateFieldGet(bl,this).subarray(14,18),4);c=x[0];d=x[1];P=x[2];w=x[3];freedraw_classPrivateFieldGet(vl,this).push(NaN,NaN,NaN,NaN,((P+c)/2-s)/n,((w+d)/2-r)/o);return!0}var k=freedraw_slicedToArray(freedraw_classPrivateFieldGet(bl,this).subarray(0,6),6);P=k[0];w=k[1];c=k[2];d=k[3];h=k[4];u=k[5];freedraw_classPrivateFieldGet(wl,this).push(((P+5*c)/6-s)/n,((w+5*d)/6-r)/o,((5*c+h)/6-s)/n,((5*d+u)/6-r)/o,((c+h)/2-s)/n,((d+u)/2-r)/o);var E=freedraw_slicedToArray(freedraw_classPrivateFieldGet(bl,this).subarray(12,18),6);h=E[0];u=E[1];c=E[2];d=E[3];P=E[4];w=E[5];freedraw_classPrivateFieldGet(vl,this).push(((P+5*c)/6-s)/n,((w+5*d)/6-r)/o,((5*c+h)/6-s)/n,((5*d+u)/6-r)/o,((c+h)/2-s)/n,((d+u)/2-r)/o);return!0}toSVGPath(){if(this.isEmpty())return"";const e=freedraw_classPrivateFieldGet(wl,this),t=freedraw_classPrivateFieldGet(vl,this);if(isNaN(freedraw_classPrivateFieldGet(bl,this)[6])&&!this.isEmpty())return freedraw_assertClassBrand(Tl,this,_toSVGPathTwoPoints).call(this);const i=[];i.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;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]}`);freedraw_assertClassBrand(Tl,this,_toSVGPathEnd).call(this,i);for(let e=t.length-6;e>=6;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]}`);freedraw_assertClassBrand(Tl,this,_toSVGPathStart).call(this,i);return i.join(" ")}newFreeDrawOutline(e,t,i,a,s,r){return new FreeDrawOutline(e,t,i,a,s,r)}getOutlines(){const e=freedraw_classPrivateFieldGet(wl,this),t=freedraw_classPrivateFieldGet(vl,this),i=freedraw_classPrivateFieldGet(bl,this),a=freedraw_slicedToArray(freedraw_classPrivateFieldGet(ml,this),4),s=a[0],r=a[1],n=a[2],o=a[3],l=new Float32Array((freedraw_classPrivateFieldGet(El,this)?.length??0)+2);for(let e=0,t=l.length-2;e<t;e+=2){l[e]=(freedraw_classPrivateFieldGet(El,this)[e]-s)/n;l[e+1]=(freedraw_classPrivateFieldGet(El,this)[e+1]-r)/o}l[l.length-2]=(freedraw_classPrivateFieldGet(Fl,this)-s)/n;l[l.length-1]=(freedraw_classPrivateFieldGet(Sl,this)-r)/o;if(isNaN(i[6])&&!this.isEmpty())return freedraw_assertClassBrand(Tl,this,_getOutlineTwoPoints).call(this,l);const c=new Float32Array(freedraw_classPrivateFieldGet(wl,this).length+24+freedraw_classPrivateFieldGet(vl,this).length);let d=e.length;for(let t=0;t<d;t+=2)if(isNaN(e[t]))c[t]=c[t+1]=NaN;else{c[t]=e[t];c[t+1]=e[t+1]}d=freedraw_assertClassBrand(Tl,this,_getOutlineEnd).call(this,c,d);for(let e=t.length-6;e>=6;e-=6)for(let i=0;i<6;i+=2)if(isNaN(t[e+i])){c[d]=c[d+1]=NaN;d+=2}else{c[d]=t[e+i];c[d+1]=t[e+i+1];d+=2}freedraw_assertClassBrand(Tl,this,_getOutlineStart).call(this,c,d);return this.newFreeDrawOutline(c,l,freedraw_classPrivateFieldGet(ml,this),freedraw_classPrivateFieldGet(xl,this),freedraw_classPrivateFieldGet(yl,this),freedraw_classPrivateFieldGet(Pl,this))}}function _getLastCoords(){const e=freedraw_classPrivateFieldGet(bl,this).subarray(4,6),t=freedraw_classPrivateFieldGet(bl,this).subarray(16,18),i=freedraw_slicedToArray(freedraw_classPrivateFieldGet(ml,this),4),a=i[0],s=i[1],r=i[2],n=i[3];return[(freedraw_classPrivateFieldGet(Fl,this)+(e[0]-t[0])/2-a)/r,(freedraw_classPrivateFieldGet(Sl,this)+(e[1]-t[1])/2-s)/n,(freedraw_classPrivateFieldGet(Fl,this)+(t[0]-e[0])/2-a)/r,(freedraw_classPrivateFieldGet(Sl,this)+(t[1]-e[1])/2-s)/n]}function _toSVGPathTwoPoints(){const e=freedraw_slicedToArray(freedraw_classPrivateFieldGet(ml,this),4),t=e[0],i=e[1],a=e[2],s=e[3],r=freedraw_slicedToArray(freedraw_assertClassBrand(Tl,this,_getLastCoords).call(this),4),n=r[0],o=r[1],l=r[2],c=r[3];return`M${(freedraw_classPrivateFieldGet(bl,this)[2]-t)/a} ${(freedraw_classPrivateFieldGet(bl,this)[3]-i)/s} L${(freedraw_classPrivateFieldGet(bl,this)[4]-t)/a} ${(freedraw_classPrivateFieldGet(bl,this)[5]-i)/s} L${n} ${o} L${l} ${c} L${(freedraw_classPrivateFieldGet(bl,this)[16]-t)/a} ${(freedraw_classPrivateFieldGet(bl,this)[17]-i)/s} L${(freedraw_classPrivateFieldGet(bl,this)[14]-t)/a} ${(freedraw_classPrivateFieldGet(bl,this)[15]-i)/s} Z`}function _toSVGPathStart(e){const t=freedraw_classPrivateFieldGet(vl,this);e.push(`L${t[4]} ${t[5]} Z`)}function _toSVGPathEnd(e){const t=freedraw_slicedToArray(freedraw_classPrivateFieldGet(ml,this),4),i=t[0],a=t[1],s=t[2],r=t[3],n=freedraw_classPrivateFieldGet(bl,this).subarray(4,6),o=freedraw_classPrivateFieldGet(bl,this).subarray(16,18),l=freedraw_slicedToArray(freedraw_assertClassBrand(Tl,this,_getLastCoords).call(this),4),c=l[0],d=l[1],h=l[2],u=l[3];e.push(`L${(n[0]-i)/s} ${(n[1]-a)/r} L${c} ${d} L${h} ${u} L${(o[0]-i)/s} ${(o[1]-a)/r}`)}function _getOutlineTwoPoints(e){const t=freedraw_classPrivateFieldGet(bl,this),i=freedraw_slicedToArray(freedraw_classPrivateFieldGet(ml,this),4),a=i[0],s=i[1],r=i[2],n=i[3],o=freedraw_slicedToArray(freedraw_assertClassBrand(Tl,this,_getLastCoords).call(this),4),l=o[0],c=o[1],d=o[2],h=o[3],u=new Float32Array(36);u.set([NaN,NaN,NaN,NaN,(t[2]-a)/r,(t[3]-s)/n,NaN,NaN,NaN,NaN,(t[4]-a)/r,(t[5]-s)/n,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,d,h,NaN,NaN,NaN,NaN,(t[16]-a)/r,(t[17]-s)/n,NaN,NaN,NaN,NaN,(t[14]-a)/r,(t[15]-s)/n],0);return this.newFreeDrawOutline(u,e,freedraw_classPrivateFieldGet(ml,this),freedraw_classPrivateFieldGet(xl,this),freedraw_classPrivateFieldGet(yl,this),freedraw_classPrivateFieldGet(Pl,this))}function _getOutlineStart(e,t){const i=freedraw_classPrivateFieldGet(vl,this);e.set([NaN,NaN,NaN,NaN,i[4],i[5]],t);return t+6}function _getOutlineEnd(e,t){const i=freedraw_classPrivateFieldGet(bl,this).subarray(4,6),a=freedraw_classPrivateFieldGet(bl,this).subarray(16,18),s=freedraw_slicedToArray(freedraw_classPrivateFieldGet(ml,this),4),r=s[0],n=s[1],o=s[2],l=s[3],c=freedraw_slicedToArray(freedraw_assertClassBrand(Tl,this,_getLastCoords).call(this),4),d=c[0],h=c[1],u=c[2],_=c[3];e.set([NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-n)/l,NaN,NaN,NaN,NaN,d,h,NaN,NaN,NaN,NaN,u,_,NaN,NaN,NaN,NaN,(a[0]-r)/o,(a[1]-n)/l],t);return t+24}var Il={_:8},Gl={_:Il._+2},Bl=new WeakMap,Ml=new WeakMap,Dl=new WeakMap,Ll=new WeakMap,Ol=new WeakMap,Rl=new WeakMap,Nl=new WeakMap,jl=new WeakSet;class FreeDrawOutline extends Outline{constructor(e,t,i,a,s,r){super();freedraw_classPrivateMethodInitSpec(this,jl);freedraw_classPrivateFieldInitSpec(this,Bl,void 0);freedraw_classPrivateFieldInitSpec(this,Ml,new Float32Array(4));freedraw_classPrivateFieldInitSpec(this,Dl,void 0);freedraw_classPrivateFieldInitSpec(this,Ll,void 0);freedraw_classPrivateFieldInitSpec(this,Ol,void 0);freedraw_classPrivateFieldInitSpec(this,Rl,void 0);freedraw_classPrivateFieldInitSpec(this,Nl,void 0);freedraw_classPrivateFieldSet(Nl,this,e);freedraw_classPrivateFieldSet(Ol,this,t);freedraw_classPrivateFieldSet(Bl,this,i);freedraw_classPrivateFieldSet(Rl,this,a);freedraw_classPrivateFieldSet(Dl,this,s);freedraw_classPrivateFieldSet(Ll,this,r);this.firstPoint=[NaN,NaN];this.lastPoint=[NaN,NaN];freedraw_assertClassBrand(jl,this,_computeMinMax).call(this,r);const n=freedraw_slicedToArray(freedraw_classPrivateFieldGet(Ml,this),4),o=n[0],l=n[1],c=n[2],d=n[3];for(let t=0,i=e.length;t<i;t+=2){e[t]=(e[t]-o)/c;e[t+1]=(e[t+1]-l)/d}for(let e=0,i=t.length;e<i;e+=2){t[e]=(t[e]-o)/c;t[e+1]=(t[e+1]-l)/d}}toSVGPath(){const e=[`M${freedraw_classPrivateFieldGet(Nl,this)[4]} ${freedraw_classPrivateFieldGet(Nl,this)[5]}`];for(let t=6,i=freedraw_classPrivateFieldGet(Nl,this).length;t<i;t+=6)isNaN(freedraw_classPrivateFieldGet(Nl,this)[t])?e.push(`L${freedraw_classPrivateFieldGet(Nl,this)[t+4]} ${freedraw_classPrivateFieldGet(Nl,this)[t+5]}`):e.push(`C${freedraw_classPrivateFieldGet(Nl,this)[t]} ${freedraw_classPrivateFieldGet(Nl,this)[t+1]} ${freedraw_classPrivateFieldGet(Nl,this)[t+2]} ${freedraw_classPrivateFieldGet(Nl,this)[t+3]} ${freedraw_classPrivateFieldGet(Nl,this)[t+4]} ${freedraw_classPrivateFieldGet(Nl,this)[t+5]}`);e.push("Z");return e.join(" ")}serialize(e,t){let i=freedraw_slicedToArray(e,4),a=i[0],s=i[1],r=i[2],n=i[3];const o=r-a,l=n-s;let c,d;switch(t){case 0:c=Outline._rescale(freedraw_classPrivateFieldGet(Nl,this),a,n,o,-l);d=Outline._rescale(freedraw_classPrivateFieldGet(Ol,this),a,n,o,-l);break;case 90:c=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(Nl,this),a,s,o,l);d=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(Ol,this),a,s,o,l);break;case 180:c=Outline._rescale(freedraw_classPrivateFieldGet(Nl,this),r,s,-o,l);d=Outline._rescale(freedraw_classPrivateFieldGet(Ol,this),r,s,-o,l);break;case 270:c=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(Nl,this),r,n,-o,-l);d=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(Ol,this),r,n,-o,-l)}return{outline:Array.from(c),points:[Array.from(d)]}}get box(){return freedraw_classPrivateFieldGet(Ml,this)}newOutliner(e,t,i,a,s){return new FreeDrawOutliner(e,t,i,a,s,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}getNewOutline(e,t){const i=freedraw_slicedToArray(freedraw_classPrivateFieldGet(Ml,this),4),a=i[0],s=i[1],r=i[2],n=i[3],o=freedraw_slicedToArray(freedraw_classPrivateFieldGet(Bl,this),4),l=o[0],c=o[1],d=o[2],h=o[3],u=r*d,_=n*h,p=a*d+l,g=s*h+c,f=this.newOutliner({x:freedraw_classPrivateFieldGet(Ol,this)[0]*u+p,y:freedraw_classPrivateFieldGet(Ol,this)[1]*_+g},freedraw_classPrivateFieldGet(Bl,this),freedraw_classPrivateFieldGet(Rl,this),e,freedraw_classPrivateFieldGet(Ll,this),t??freedraw_classPrivateFieldGet(Dl,this));for(let e=2;e<freedraw_classPrivateFieldGet(Ol,this).length;e+=2)f.add({x:freedraw_classPrivateFieldGet(Ol,this)[e]*u+p,y:freedraw_classPrivateFieldGet(Ol,this)[e+1]*_+g});return f.getOutlines()}}function _computeMinMax(e){const t=freedraw_classPrivateFieldGet(Nl,this);let i=t[4],a=t[5];const r=[i,a,i,a];let n=i,o=a,l=i,c=a;const d=e?Math.max:Math.min,h=new Float32Array(4);for(let e=6,u=t.length;e<u;e+=6){const u=t[e+4],_=t[e+5];if(isNaN(t[e])){Util.pointBoundingBox(u,_,r);if(o>_){n=u;o=_}else o===_&&(n=d(n,u));if(c<_){l=u;c=_}else c===_&&(l=d(l,u))}else{h.set(s,0);Util.bezierBoundingBox(i,a,...t.slice(e,e+6),h);Util.rectBoundingBox(...h,r);if(o>h[1]){n=h[0];o=h[1]}else o===h[1]&&(n=d(n,h[0]));if(c<h[3]){l=h[2];c=h[3]}else c===h[3]&&(l=d(l,h[2]))}i=u;a=_}const u=freedraw_classPrivateFieldGet(Ml,this);u[0]=r[0]-freedraw_classPrivateFieldGet(Dl,this);u[1]=r[1]-freedraw_classPrivateFieldGet(Dl,this);u[2]=r[2]-r[0]+2*freedraw_classPrivateFieldGet(Dl,this);u[3]=r[3]-r[1]+2*freedraw_classPrivateFieldGet(Dl,this);this.firstPoint=[n,o];this.lastPoint=[l,c]}function highlight_slicedToArray(e,t){return function highlight_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function highlight_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function highlight_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return highlight_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?highlight_arrayLikeToArray(e,t):void 0}}(e,t)||function highlight_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function highlight_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function highlight_classPrivateFieldInitSpec(e,t,i){highlight_checkPrivateRedeclaration(e,t),t.set(e,i)}function highlight_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function highlight_classPrivateFieldSet(e,t,i){return e.set(highlight_assertClassBrand(e,t),i),i}function highlight_classPrivateFieldGet(e,t){return e.get(highlight_assertClassBrand(e,t))}function highlight_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Wl=new WeakMap,Ul=new WeakMap,Vl=new WeakMap,Hl=new WeakMap,zl=new WeakMap,$l=new WeakSet;class HighlightOutliner{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];!function highlight_classPrivateMethodInitSpec(e,t){highlight_checkPrivateRedeclaration(e,t),t.add(e)}(this,$l);highlight_classPrivateFieldInitSpec(this,Wl,void 0);highlight_classPrivateFieldInitSpec(this,Ul,void 0);highlight_classPrivateFieldInitSpec(this,Vl,void 0);highlight_classPrivateFieldInitSpec(this,Hl,[]);highlight_classPrivateFieldInitSpec(this,zl,[]);const r=s.slice(),n=10**-4;for(const i of e){const e=i.x,a=i.y,s=i.width,o=i.height,l=Math.floor((e-t)/n)*n,c=Math.ceil((e+s+t)/n)*n,d=Math.floor((a-t)/n)*n,h=Math.ceil((a+o+t)/n)*n,u=[l,d,h,!0],_=[c,d,h,!1];highlight_classPrivateFieldGet(Hl,this).push(u,_);Util.rectBoundingBox(l,d,c,h,r)}const o=r[2]-r[0]+2*i,l=r[3]-r[1]+2*i,c=r[0]-i,d=r[1]-i;let h=a?-1/0:1/0,u=1/0;const _=highlight_classPrivateFieldGet(Hl,this).at(a?-1:-2),p=[_[0],_[2]];for(const e of highlight_classPrivateFieldGet(Hl,this)){const t=highlight_slicedToArray(e,4),i=t[0],s=t[1],r=t[2],n=t[3];if(!n&&a)if(s<u){u=s;h=i}else s===u&&(h=Math.max(h,i));else if(n&&!a)if(s<u){u=s;h=i}else s===u&&(h=Math.min(h,i));e[0]=(i-c)/o;e[1]=(s-d)/l;e[2]=(r-d)/l}highlight_classPrivateFieldSet(Wl,this,new Float32Array([c,d,o,l]));highlight_classPrivateFieldSet(Ul,this,[h,u]);highlight_classPrivateFieldSet(Vl,this,p)}getOutlines(){highlight_classPrivateFieldGet(Hl,this).sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);const e=[];for(const t of highlight_classPrivateFieldGet(Hl,this))if(t[3]){e.push(...highlight_assertClassBrand($l,this,_breakEdge).call(this,t));highlight_assertClassBrand($l,this,_insert).call(this,t)}else{highlight_assertClassBrand($l,this,_remove).call(this,t);e.push(...highlight_assertClassBrand($l,this,_breakEdge).call(this,t))}return highlight_assertClassBrand($l,this,_getOutlines).call(this,e)}}function _getOutlines(e){const t=[],i=new Set;for(const i of e){const e=highlight_slicedToArray(i,3),a=e[0],s=e[1],r=e[2];t.push([a,s,i],[a,r,i])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,a=t.length;e<a;e+=2){const a=t[e][2],s=t[e+1][2];a.push(s);s.push(a);i.add(a);i.add(s)}const a=[];let s;for(;i.size>0;){const e=i.values().next().value;let t=highlight_slicedToArray(e,5),n=t[0],o=t[1],l=t[2],c=t[3],d=t[4];i.delete(e);let h=n,u=o;s=[n,l];a.push(s);for(;;){let e;if(i.has(c))e=c;else{if(!i.has(d))break;e=d}i.delete(e);var r=highlight_slicedToArray(e,5);n=r[0];o=r[1];l=r[2];c=r[3];d=r[4];if(h!==n){s.push(h,u,n,u===o?o:l);h=n}u=u===o?l:o}s.push(h,u)}return new HighlightOutline(a,highlight_classPrivateFieldGet(Wl,this),highlight_classPrivateFieldGet(Ul,this),highlight_classPrivateFieldGet(Vl,this))}function _binarySearch(e){const t=highlight_classPrivateFieldGet(zl,this);let i=0,a=t.length-1;for(;i<=a;){const s=i+a>>1,r=t[s][0];if(r===e)return s;r<e?i=s+1:a=s-1}return a+1}function _insert(e){let t=highlight_slicedToArray(e,3),i=t[1],a=t[2];const s=highlight_assertClassBrand($l,this,_binarySearch).call(this,i);highlight_classPrivateFieldGet(zl,this).splice(s,0,[i,a])}function _remove(e){let t=highlight_slicedToArray(e,3),i=t[1],a=t[2];const s=highlight_assertClassBrand($l,this,_binarySearch).call(this,i);for(let e=s;e<highlight_classPrivateFieldGet(zl,this).length;e++){const t=highlight_slicedToArray(highlight_classPrivateFieldGet(zl,this)[e],2),s=t[0],r=t[1];if(s!==i)break;if(s===i&&r===a){highlight_classPrivateFieldGet(zl,this).splice(e,1);return}}for(let e=s-1;e>=0;e--){const t=highlight_slicedToArray(highlight_classPrivateFieldGet(zl,this)[e],2),s=t[0],r=t[1];if(s!==i)break;if(s===i&&r===a){highlight_classPrivateFieldGet(zl,this).splice(e,1);return}}}function _breakEdge(e){const t=highlight_slicedToArray(e,3),i=t[0],a=t[1],s=t[2],r=[[i,a,s]],n=highlight_assertClassBrand($l,this,_binarySearch).call(this,s);for(let e=0;e<n;e++){const t=highlight_slicedToArray(highlight_classPrivateFieldGet(zl,this)[e],2),a=t[0],s=t[1];for(let e=0,t=r.length;e<t;e++){const n=highlight_slicedToArray(r[e],3),o=n[1],l=n[2];if(!(s<=o||l<=a))if(o>=a)if(l>s)r[e][1]=s;else{if(1===t)return[];r.splice(e,1);e--;t--}else{r[e][2]=a;l>s&&r.push([i,s,l])}}}return r}var ql,Xl=new WeakMap,Kl=new WeakMap;class HighlightOutline extends Outline{constructor(e,t,i,a){super();highlight_classPrivateFieldInitSpec(this,Xl,void 0);highlight_classPrivateFieldInitSpec(this,Kl,void 0);highlight_classPrivateFieldSet(Kl,this,e);highlight_classPrivateFieldSet(Xl,this,t);this.firstPoint=i;this.lastPoint=a}toSVGPath(){const e=[];for(const t of highlight_classPrivateFieldGet(Kl,this)){let i=highlight_slicedToArray(t,2),a=i[0],s=i[1];e.push(`M${a} ${s}`);for(let i=2;i<t.length;i+=2){const r=t[i],n=t[i+1];if(r===a){e.push(`V${n}`);s=n}else if(n===s){e.push(`H${r}`);a=r}}e.push("Z")}return e.join(" ")}serialize(e,t){let i=highlight_slicedToArray(e,4),a=i[0],s=i[1],r=i[2],n=i[3];const o=[],l=r-a,c=n-s;for(const e of highlight_classPrivateFieldGet(Kl,this)){const t=new Array(e.length);for(let i=0;i<e.length;i+=2){t[i]=a+e[i]*l;t[i+1]=n-e[i+1]*c}o.push(t)}return o}get box(){return highlight_classPrivateFieldGet(Xl,this)}get classNamesForOutlining(){return["highlightOutline"]}}class FreeHighlightOutliner extends FreeDrawOutliner{newFreeDrawOutline(e,t,i,a,s,r){return new FreeHighlightOutline(e,t,i,a,s,r)}}class FreeHighlightOutline extends FreeDrawOutline{newOutliner(e,t,i,a,s){return new FreeHighlightOutliner(e,t,i,a,s,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}}function editor_highlight_slicedToArray(e,t){return function editor_highlight_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function editor_highlight_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function editor_highlight_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return editor_highlight_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?editor_highlight_arrayLikeToArray(e,t):void 0}}(e,t)||function editor_highlight_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function editor_highlight_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function highlight_defineProperty(e,t,i){return(t=function highlight_toPropertyKey(e){var t=function highlight_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function editor_highlight_classPrivateFieldInitSpec(e,t,i){editor_highlight_checkPrivateRedeclaration(e,t),t.set(e,i)}function editor_highlight_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function highlight_toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function editor_highlight_classPrivateFieldGet(e,t){return e.get(editor_highlight_assertClassBrand(e,t))}function editor_highlight_classPrivateFieldSet(e,t,i){return e.set(editor_highlight_assertClassBrand(e,t),i),i}function editor_highlight_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Yl,Zl=new WeakMap,Jl=new WeakMap,Ql=new WeakMap,ec=new WeakMap,tc=new WeakMap,ic=new WeakMap,ac=new WeakMap,sc=new WeakMap,rc=new WeakMap,nc=new WeakMap,oc=new WeakMap,lc=new WeakMap,cc=new WeakMap,dc=new WeakMap,hc=new WeakMap,uc=new WeakMap,_c=new WeakMap,pc=new WeakMap,gc=new WeakSet;class HighlightEditor extends AnnotationEditor{static get _keyboardManager(){const e=HighlightEditor.prototype;return shadow(this,"_keyboardManager",new KeyboardManager([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:"highlightEditor"});!function editor_highlight_classPrivateMethodInitSpec(e,t){editor_highlight_checkPrivateRedeclaration(e,t),t.add(e)}(this,gc);editor_highlight_classPrivateFieldInitSpec(this,Zl,null);editor_highlight_classPrivateFieldInitSpec(this,Jl,0);editor_highlight_classPrivateFieldInitSpec(this,Ql,void 0);editor_highlight_classPrivateFieldInitSpec(this,ec,null);editor_highlight_classPrivateFieldInitSpec(this,tc,null);editor_highlight_classPrivateFieldInitSpec(this,ic,null);editor_highlight_classPrivateFieldInitSpec(this,ac,null);editor_highlight_classPrivateFieldInitSpec(this,sc,0);editor_highlight_classPrivateFieldInitSpec(this,rc,null);editor_highlight_classPrivateFieldInitSpec(this,nc,null);editor_highlight_classPrivateFieldInitSpec(this,oc,null);editor_highlight_classPrivateFieldInitSpec(this,lc,!1);editor_highlight_classPrivateFieldInitSpec(this,cc,null);editor_highlight_classPrivateFieldInitSpec(this,dc,null);editor_highlight_classPrivateFieldInitSpec(this,hc,null);editor_highlight_classPrivateFieldInitSpec(this,uc,"");editor_highlight_classPrivateFieldInitSpec(this,_c,void 0);editor_highlight_classPrivateFieldInitSpec(this,pc,"");this.color=e.color||HighlightEditor._defaultColor;editor_highlight_classPrivateFieldSet(_c,this,e.thickness||HighlightEditor._defaultThickness);this.opacity=e.opacity||HighlightEditor._defaultOpacity;editor_highlight_classPrivateFieldSet(Ql,this,e.boxes||null);editor_highlight_classPrivateFieldSet(pc,this,e.methodOfCreation||"");editor_highlight_classPrivateFieldSet(uc,this,e.text||"");this._isDraggable=!1;this.defaultL10nId="pdfjs-editor-highlight-editor";if(e.highlightId>-1){editor_highlight_classPrivateFieldSet(lc,this,!0);editor_highlight_assertClassBrand(gc,this,_createFreeOutlines).call(this,e);editor_highlight_assertClassBrand(gc,this,_addToDrawLayer).call(this)}else if(editor_highlight_classPrivateFieldGet(Ql,this)){editor_highlight_classPrivateFieldSet(Zl,this,e.anchorNode);editor_highlight_classPrivateFieldSet(Jl,this,e.anchorOffset);editor_highlight_classPrivateFieldSet(ac,this,e.focusNode);editor_highlight_classPrivateFieldSet(sc,this,e.focusOffset);editor_highlight_assertClassBrand(gc,this,_createOutlines).call(this);editor_highlight_assertClassBrand(gc,this,_addToDrawLayer).call(this);this.rotate(this.rotation)}this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"added",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:{color:this.color,thickness:editor_highlight_classPrivateFieldGet(_c,this),isFreeHighlight:editor_highlight_classPrivateFieldGet(lc,this),text:editor_highlight_classPrivateFieldGet(uc,this)}});this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.highlight)}get telemetryInitialData(){return{action:"added",type:editor_highlight_classPrivateFieldGet(lc,this)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:editor_highlight_classPrivateFieldGet(_c,this),methodOfCreation:editor_highlight_classPrivateFieldGet(pc,this)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,t){AnnotationEditor.initialize(e,t);HighlightEditor._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case w.HIGHLIGHT_COLOR:HighlightEditor._defaultColor=t;break;case w.HIGHLIGHT_THICKNESS:HighlightEditor._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return editor_highlight_classPrivateFieldGet(dc,this)}get commentButtonPosition(){return editor_highlight_classPrivateFieldGet(cc,this)}updateParams(e,t){switch(e){case w.HIGHLIGHT_COLOR:editor_highlight_assertClassBrand(gc,this,highlight_updateColor).call(this,t);break;case w.HIGHLIGHT_THICKNESS:editor_highlight_assertClassBrand(gc,this,_updateThickness).call(this,t)}}static get defaultPropertiesToUpdate(){return[[w.HIGHLIGHT_COLOR,HighlightEditor._defaultColor],[w.HIGHLIGHT_THICKNESS,HighlightEditor._defaultThickness]]}get propertiesToUpdate(){return[[w.HIGHLIGHT_COLOR,this.color||HighlightEditor._defaultColor],[w.HIGHLIGHT_THICKNESS,editor_highlight_classPrivateFieldGet(_c,this)||HighlightEditor._defaultThickness],[w.HIGHLIGHT_FREE,editor_highlight_classPrivateFieldGet(lc,this)]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(oc,this),{root:{fill:this.color,"fill-opacity":this.opacity}});editor_highlight_classPrivateFieldGet(tc,this)?.updateColor(this.color);super.onUpdatedColor()}get toolbarButtons(){if(this._uiManager.highlightColors){return[["colorPicker",editor_highlight_classPrivateFieldSet(tc,this,new ColorPicker({editor:this}))]]}return super.toolbarButtons}disableEditing(){super.disableEditing();this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing();this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(editor_highlight_assertClassBrand(gc,this,_getRotation).call(this))}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,editor_highlight_assertClassBrand(gc,this,_getRotation).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);e&&this.div.focus()}remove(){editor_highlight_assertClassBrand(gc,this,_cleanDrawLayer).call(this);this._reportTelemetry({action:"deleted"});super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){editor_highlight_assertClassBrand(gc,this,_addToDrawLayer).call(this);this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e)editor_highlight_assertClassBrand(gc,this,_cleanDrawLayer).call(this);else if(e){editor_highlight_assertClassBrand(gc,this,_addToDrawLayer).call(this,e);t=!this.parent&&this.div?.classList.contains("selectedEditor")}super.setParent(e);this.show(this._isVisible);t&&this.select()}rotate(e){const t=this.parent.drawLayer;let i;if(editor_highlight_classPrivateFieldGet(lc,this)){e=(e-this.rotation+360)%360;i=_rotateBbox.call(HighlightEditor,editor_highlight_classPrivateFieldGet(nc,this).box,e)}else i=_rotateBbox.call(HighlightEditor,[this.x,this.y,this.width,this.height],e);t.updateProperties(editor_highlight_classPrivateFieldGet(oc,this),{bbox:i,root:{"data-main-rotation":e}});t.updateProperties(editor_highlight_classPrivateFieldGet(hc,this),{bbox:_rotateBbox.call(HighlightEditor,editor_highlight_classPrivateFieldGet(ic,this).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();if(editor_highlight_classPrivateFieldGet(uc,this)){e.setAttribute("aria-label",editor_highlight_classPrivateFieldGet(uc,this));e.setAttribute("role","mark")}editor_highlight_classPrivateFieldGet(lc,this)?e.classList.add("free"):this.div.addEventListener("keydown",editor_highlight_assertClassBrand(gc,this,_keydown).bind(this),{signal:this._uiManager._signal});const t=editor_highlight_classPrivateFieldSet(rc,this,document.createElement("div"));e.append(t);t.setAttribute("aria-hidden","true");t.className="internal";t.style.clipPath=editor_highlight_classPrivateFieldGet(ec,this);this.setDims();bindEvents(this,editor_highlight_classPrivateFieldGet(rc,this),["pointerover","pointerleave"]);this.enableEditing();return e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(hc,this),{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(hc,this),{rootClass:{hovered:!1}})}_moveCaret(e){this.parent.unselect(this);switch(e){case 0:case 2:editor_highlight_assertClassBrand(gc,this,_setCaret).call(this,!0);break;case 1:case 3:editor_highlight_assertClassBrand(gc,this,_setCaret).call(this,!1)}}select(){super.select();editor_highlight_classPrivateFieldGet(hc,this)&&this.parent?.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(hc,this),{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect();if(editor_highlight_classPrivateFieldGet(hc,this)){this.parent?.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(hc,this),{rootClass:{selected:!1}});editor_highlight_classPrivateFieldGet(lc,this)||editor_highlight_assertClassBrand(gc,this,_setCaret).call(this,!1)}}get _mustFixPosition(){return!editor_highlight_classPrivateFieldGet(lc,this)}show(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;super.show(e);if(this.parent){this.parent.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(oc,this),{rootClass:{hidden:!e}});this.parent.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(hc,this),{rootClass:{hidden:!e}})}}static startHighlighting(e,t,i){let a=i.target,s=i.x,r=i.y;const n=a.getBoundingClientRect(),o=n.x,l=n.y,c=n.width,d=n.height,h=new AbortController,u=e.combinedSignal(h),pointerUpCallback=t=>{h.abort();editor_highlight_assertClassBrand(HighlightEditor,this,_endHighlight).call(this,e,t)};window.addEventListener("blur",pointerUpCallback,{signal:u});window.addEventListener("pointerup",pointerUpCallback,{signal:u});window.addEventListener("pointerdown",stopEvent,{capture:!0,passive:!1,signal:u});window.addEventListener("contextmenu",noContextMenu,{signal:u});a.addEventListener("pointermove",editor_highlight_assertClassBrand(HighlightEditor,this,_highlightMove).bind(this,e),{signal:u});this._freeHighlight=new FreeHighlightOutliner({x:s,y:r},[o,l,c,d],e.scale,this._defaultThickness/2,t,.001);var _=e.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);this._freeHighlightId=_.id;this._freeHighlightClipId=_.clipPathId}static async deserialize(e,t,i){let a=null;if(e instanceof HighlightAnnotationElement){const t=e,i=t.data,s=i.quadPoints,r=i.rect,n=i.rotation,o=i.id,l=i.color,c=i.opacity,d=i.popupRef,h=i.richText,u=i.contentsObj,_=i.creationDate,p=i.modificationDate,g=t.parent.page.pageNumber;a=e={annotationType:P.HIGHLIGHT,color:Array.from(l),opacity:c,quadPoints:s,boxes:null,pageIndex:g-1,rect:r.slice(0),rotation:n,annotationElementId:o,id:o,deleted:!1,popupRef:d,richText:h,comment:u?.str||null,creationDate:_,modificationDate:p}}else if(e.annotationType&&e.annotationType===P.HIGHLIGHT){let t,i=e,s=i.quadPoints,r=i.outlines,n=i.rect,o=i.rotation,l=i.id,c=i.color,d=i.opacity,h=i.popup,u=i.popupRef,_=i.pageIndex,p=i.thickness;s&&(Array.isArray(s)||(s=Object.values(s)));if(!s&&r){if(Array.isArray(r))t=r.map(e=>e);else{if("object"!=typeof r||!r.points){console.error("Unexpected outlines format");return null}t=[r.points.flat()]}p=p||e.thickness||1}a=e={annotationType:P.HIGHLIGHT,color:Array.from(c),opacity:d,quadPoints:s,inkLists:t,thickness:p,boxes:null,pageIndex:_,rect:n.slice(0),rotation:o,id:l,deleted:!1,popupRef:u||!(!h||!h.contents||h.deleted)||null,comment:!h?.deleted&&h?.contents||null,commentDate:!h?.deleted&&h?.date||null}}else if(e instanceof InkAnnotationElement){const t=e,i=t.data,s=i.inkLists,r=i.rect,n=i.rotation,o=i.id,l=i.color,c=i.borderStyle.rawWidth,d=i.popupRef,h=i.richText,u=i.contentsObj,_=i.creationDate,p=i.modificationDate,g=t.parent.page.pageNumber;a=e={annotationType:P.HIGHLIGHT,color:Array.from(l),thickness:c,inkLists:s,boxes:null,pageIndex:g-1,rect:r.slice(0),rotation:n,annotationElementId:o,id:o,deleted:!1,popupRef:d,richText:h,comment:u?.str||null,creationDate:_,modificationDate:p}}const s=e,r=s.color,n=s.quadPoints,o=s.inkLists,l=s.outlines,c=s.opacity,d=await super.deserialize(e,t,i);d.color=Util.makeHexColor(...r);d.opacity=c||1;o&&editor_highlight_classPrivateFieldSet(_c,d,e.thickness);d._initialData=a;e.comment&&d.setCommentData(e);const h=editor_highlight_slicedToArray(d.pageDimensions,2),u=h[0],_=h[1],p=editor_highlight_slicedToArray(d.pageTranslation,2),g=p[0],f=p[1];if(n){const e=editor_highlight_classPrivateFieldSet(Ql,d,[]);for(let t=0;t<n.length;t+=8)e.push({x:(n[t]-g)/u,y:1-(n[t+1]-f)/_,width:(n[t+2]-n[t])/u,height:(n[t+1]-n[t+5])/_});editor_highlight_assertClassBrand(gc,d,_createOutlines).call(d);editor_highlight_assertClassBrand(gc,d,_addToDrawLayer).call(d);d.rotate(d.rotation)}else if(o||l){editor_highlight_classPrivateFieldSet(lc,d,!0);const e=(o||l.points)[0],i={x:e[0]-g,y:_-(e[1]-f)},a=new FreeHighlightOutliner(i,[0,0,u,_],1,editor_highlight_classPrivateFieldGet(_c,d)/2,!0,.001);for(let t=0,s=e.length;t<s;t+=2){i.x=e[t]-g;i.y=_-(e[t+1]-f);a.add(i)}const s=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:a.toSVGPath()}},!0,!0),r=s.id,n=s.clipPathId;editor_highlight_assertClassBrand(gc,d,_createFreeOutlines).call(d,{highlightOutlines:a.getOutlines(),highlightId:r,clipPathId:n});editor_highlight_assertClassBrand(gc,d,_addToDrawLayer).call(d);d.rotate(d.parentRotation)}return d}serialize(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.isEmpty()||e&&!i)return null;if(this.deleted)return this.serializeDeleted();const a=AnnotationEditor._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),s=super.serialize(e,t);Object.assign(s,{color:a,opacity:this.opacity,thickness:editor_highlight_classPrivateFieldGet(_c,this),quadPoints:editor_highlight_assertClassBrand(gc,this,_serializeBoxes).call(this),outlines:editor_highlight_assertClassBrand(gc,this,_serializeOutlines).call(this,s.rect)});this.addComment(s,this._isCopy);if(e&&i){s.id=this.uid;s.isCopy=!0;return s}if(this.annotationElementId&&!editor_highlight_assertClassBrand(gc,this,highlight_hasElementChanged).call(this,s))return null;s.id=this.uid;return s}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}static canCreateNewEmptyEditor(){return!1}}ql=HighlightEditor;function _createOutlines(){const e=new HighlightOutliner(editor_highlight_classPrivateFieldGet(Ql,this),.001);editor_highlight_classPrivateFieldSet(nc,this,e.getOutlines());var t=editor_highlight_slicedToArray(editor_highlight_classPrivateFieldGet(nc,this).box,4);this.x=t[0];this.y=t[1];this.width=t[2];this.height=t[3];const i=new HighlightOutliner(editor_highlight_classPrivateFieldGet(Ql,this),.0025,.001,"ltr"===this._uiManager.direction);editor_highlight_classPrivateFieldSet(ic,this,i.getOutlines());const a=editor_highlight_classPrivateFieldGet(nc,this).firstPoint;editor_highlight_classPrivateFieldSet(cc,this,[(a[0]-this.x)/this.width,(a[1]-this.y)/this.height]);const s=editor_highlight_classPrivateFieldGet(ic,this).lastPoint;editor_highlight_classPrivateFieldSet(dc,this,[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height])}function _createFreeOutlines(e){let t=e.highlightOutlines,i=e.highlightId,a=e.clipPathId;editor_highlight_classPrivateFieldSet(nc,this,t);editor_highlight_classPrivateFieldSet(ic,this,t.getNewOutline(editor_highlight_classPrivateFieldGet(_c,this)/2+1.5,.0025));if(i>=0){editor_highlight_classPrivateFieldSet(oc,this,i);editor_highlight_classPrivateFieldSet(ec,this,a);this.parent.drawLayer.finalizeDraw(i,{bbox:t.box,path:{d:t.toSVGPath()}});editor_highlight_classPrivateFieldSet(hc,this,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:editor_highlight_classPrivateFieldGet(ic,this).box,path:{d:editor_highlight_classPrivateFieldGet(ic,this).toSVGPath()}},!0))}else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(oc,this),{bbox:_rotateBbox.call(ql,editor_highlight_classPrivateFieldGet(nc,this).box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}});this.parent.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(hc,this),{bbox:_rotateBbox.call(ql,editor_highlight_classPrivateFieldGet(ic,this).box,e),path:{d:editor_highlight_classPrivateFieldGet(ic,this).toSVGPath()}})}const s=editor_highlight_slicedToArray(t.box,4),r=s[0],n=s[1],o=s[2],l=s[3];switch(this.rotation){case 0:this.x=r;this.y=n;this.width=o;this.height=l;break;case 90:{const e=editor_highlight_slicedToArray(this.parentDimensions,2),t=e[0],i=e[1];this.x=n;this.y=1-r;this.width=o*i/t;this.height=l*t/i;break}case 180:this.x=1-r;this.y=1-n;this.width=o;this.height=l;break;case 270:{const e=editor_highlight_slicedToArray(this.parentDimensions,2),t=e[0],i=e[1];this.x=1-n;this.y=r;this.width=o*i/t;this.height=l*t/i;break}}const c=t.firstPoint;editor_highlight_classPrivateFieldSet(cc,this,[(c[0]-r)/o,(c[1]-n)/l]);const d=editor_highlight_classPrivateFieldGet(ic,this).lastPoint;editor_highlight_classPrivateFieldSet(dc,this,[(d[0]-r)/o,(d[1]-n)/l])}function highlight_updateColor(e){const setColorAndOpacity=(e,t)=>{this.color=e;this.opacity=t;this.onUpdatedColor()},t=this.color,i=this.opacity;this.addCommands({cmd:setColorAndOpacity.bind(this,e,ql._defaultOpacity),undo:setColorAndOpacity.bind(this,t,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:w.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0);this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"colorChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:e,previousValue:t})}function _updateThickness(e){const t=editor_highlight_classPrivateFieldGet(_c,this),setThickness=e=>{editor_highlight_classPrivateFieldSet(_c,this,e);editor_highlight_assertClassBrand(gc,this,_changeThickness).call(this,e)};this.addCommands({cmd:setThickness.bind(this,e),undo:setThickness.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:w.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:"thickness_changed",thickness:e},!0);this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"thicknessChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:e,previousValue:t})}function _changeThickness(e){if(editor_highlight_classPrivateFieldGet(lc,this)){editor_highlight_assertClassBrand(gc,this,_createFreeOutlines).call(this,{highlightOutlines:editor_highlight_classPrivateFieldGet(nc,this).getNewOutline(e/2)});this.fixAndSetPosition();this.setDims()}}function _cleanDrawLayer(){if(null!==editor_highlight_classPrivateFieldGet(oc,this)&&this.parent){this.parent.drawLayer.remove(editor_highlight_classPrivateFieldGet(oc,this));editor_highlight_classPrivateFieldSet(oc,this,null);this.parent.drawLayer.remove(editor_highlight_classPrivateFieldGet(hc,this));editor_highlight_classPrivateFieldSet(hc,this,null)}}function _addToDrawLayer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;if(null===editor_highlight_classPrivateFieldGet(oc,this)){var t=e.drawLayer.draw({bbox:editor_highlight_classPrivateFieldGet(nc,this).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:editor_highlight_classPrivateFieldGet(lc,this)},path:{d:editor_highlight_classPrivateFieldGet(nc,this).toSVGPath()}},!1,!0);highlight_toSetter(editor_highlight_classPrivateFieldSet,[oc,this])._=t.id;highlight_toSetter(editor_highlight_classPrivateFieldSet,[ec,this])._=t.clipPathId;editor_highlight_classPrivateFieldSet(hc,this,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:editor_highlight_classPrivateFieldGet(lc,this)},bbox:editor_highlight_classPrivateFieldGet(ic,this).box,path:{d:editor_highlight_classPrivateFieldGet(ic,this).toSVGPath()}},editor_highlight_classPrivateFieldGet(lc,this)));editor_highlight_classPrivateFieldGet(rc,this)&&(editor_highlight_classPrivateFieldGet(rc,this).style.clipPath=editor_highlight_classPrivateFieldGet(ec,this))}}function _rotateBbox(e,t){let i=editor_highlight_slicedToArray(e,4),a=i[0],s=i[1],r=i[2],n=i[3];switch(t){case 90:return[1-s-n,a,n,r];case 180:return[1-a-r,1-s-n,r,n];case 270:return[s,1-a-r,n,r]}return[a,s,r,n]}function _keydown(e){ql._keyboardManager.exec(this,e)}function _setCaret(e){if(!editor_highlight_classPrivateFieldGet(Zl,this))return;const t=window.getSelection();e?t.setPosition(editor_highlight_classPrivateFieldGet(Zl,this),editor_highlight_classPrivateFieldGet(Jl,this)):t.setPosition(editor_highlight_classPrivateFieldGet(ac,this),editor_highlight_classPrivateFieldGet(sc,this))}function _getRotation(){return editor_highlight_classPrivateFieldGet(lc,this)?this.rotation:0}function _serializeBoxes(){if(editor_highlight_classPrivateFieldGet(lc,this))return null;const e=editor_highlight_slicedToArray(this.pageDimensions,2),t=e[0],i=e[1],a=editor_highlight_slicedToArray(this.pageTranslation,2),s=a[0],r=a[1],n=editor_highlight_classPrivateFieldGet(Ql,this),o=new Float32Array(8*n.length);let l=0;for(const e of n){const a=e.x,n=e.y,c=e.width,d=e.height,h=a*t+s,u=(1-n)*i+r;o[l]=o[l+4]=h;o[l+1]=o[l+3]=u;o[l+2]=o[l+6]=h+c*t;o[l+5]=o[l+7]=u-d*i;l+=8}return o}function _serializeOutlines(e){return editor_highlight_classPrivateFieldGet(nc,this).serialize(e,editor_highlight_assertClassBrand(gc,this,_getRotation).call(this))}function _highlightMove(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}function _endHighlight(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"});this._freeHighlightId=-1;this._freeHighlight=null;this._freeHighlightClipId=""}function highlight_hasElementChanged(e){const t=this._initialData.color;return this.hasEditedComment||e.color.some((e,i)=>e!==t[i])}highlight_defineProperty(HighlightEditor,"_defaultColor",null);highlight_defineProperty(HighlightEditor,"_defaultOpacity",1);highlight_defineProperty(HighlightEditor,"_defaultThickness",12);highlight_defineProperty(HighlightEditor,"_type","highlight");highlight_defineProperty(HighlightEditor,"_editorType",P.HIGHLIGHT);highlight_defineProperty(HighlightEditor,"_freeHighlightId",-1);highlight_defineProperty(HighlightEditor,"_freeHighlight",null);highlight_defineProperty(HighlightEditor,"_freeHighlightClipId","");function draw_defineProperty(e,t,i){return(t=function draw_toPropertyKey(e){var t=function draw_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function draw_slicedToArray(e,t){return function draw_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function draw_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function draw_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return draw_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?draw_arrayLikeToArray(e,t):void 0}}(e,t)||function draw_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function draw_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function draw_classPrivateFieldInitSpec(e,t,i){draw_checkPrivateRedeclaration(e,t),t.set(e,i)}function draw_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function draw_classPrivateFieldSet(e,t,i){return e.set(draw_assertClassBrand(e,t),i),i}function draw_classPrivateFieldGet(e,t){return e.get(draw_assertClassBrand(e,t))}function draw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var fc=new WeakMap;class DrawingOptions{constructor(){draw_classPrivateFieldInitSpec(this,fc,Object.create(null))}updateProperty(e,t){this[e]=t;this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(const i of Object.entries(e)){var t=draw_slicedToArray(i,2);const e=t[0],a=t[1];e.startsWith("_")||this.updateProperty(e,a)}}updateSVGProperty(e,t){draw_classPrivateFieldGet(fc,this)[e]=t}toSVGProperties(){const e=draw_classPrivateFieldGet(fc,this);draw_classPrivateFieldSet(fc,this,Object.create(null));return{root:e}}reset(){draw_classPrivateFieldSet(fc,this,Object.create(null))}updateAll(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this;this.updateProperties(e)}clone(){unreachable("Not implemented")}}var mc=new WeakMap,vc=new WeakMap,yc=new WeakSet;class DrawingEditor extends AnnotationEditor{constructor(e){super(e);!function draw_classPrivateMethodInitSpec(e,t){draw_checkPrivateRedeclaration(e,t),t.add(e)}(this,yc);draw_classPrivateFieldInitSpec(this,mc,null);draw_classPrivateFieldInitSpec(this,vc,void 0);draw_defineProperty(this,"_colorPicker",null);draw_defineProperty(this,"_drawId",null);draw_classPrivateFieldSet(vc,this,e.mustBeCommitted||!1);this._addOutlines(e)}onUpdatedColor(){this._colorPicker?.update(this.color);super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(e){if(e.drawOutlines){draw_assertClassBrand(yc,this,_createDrawOutlines).call(this,e);draw_assertClassBrand(yc,this,draw_addToDrawLayer).call(this)}}static _mergeSVGProperties(e,t){const i=new Set(Object.keys(e));for(const s of Object.entries(t)){var a=draw_slicedToArray(s,2);const t=a[0],r=a[1];i.has(t)?Object.assign(e[t],r):e[t]=r}return e}static getDefaultDrawingOptions(e){unreachable("Not implemented")}static get typesMap(){unreachable("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,t);if(this._currentParent){Pc._.updateProperty(i,t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}updateParams(e,t){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,t)}static get defaultPropertiesToUpdate(){const e=[],t=this._defaultDrawingOptions;for(const a of this.typesMap){var i=draw_slicedToArray(a,2);const s=i[0],r=i[1];e.push([s,t[r]])}return e}get propertiesToUpdate(){const e=[],t=this._drawingOptions;for(const a of this.constructor.typesMap){var i=draw_slicedToArray(a,2);const s=i[0],r=i[1];e.push([s,t[r]])}return e}_updateProperty(e,t,i){const a=this._drawingOptions,s=a[t],setter=s=>{a.updateProperty(t,s);const r=draw_classPrivateFieldGet(mc,this).updateProperty(t,s);r&&draw_assertClassBrand(yc,this,_updateBbox).call(this,r);this.parent?.drawLayer.updateProperties(this._drawId,a.toSVGProperties());"stroke"===t?this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"colorChanged",page:this.pageIndex+1,editorType:this.constructor.name,value:i,id:this.uid}):"stroke-width"===t?this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"thicknessChanged",page:this.pageIndex+1,editorType:this.constructor.name,value:i,id:this.uid}):"stroke-opacity"===t&&this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"opacityChanged",page:this.pageIndex+1,editorType:this.constructor.name,value:i,id:this.uid});e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:setter.bind(this,i),undo:setter.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t){const i=this.constructor.typesMap.get(this.colorType),a=this.constructor.typesMap.get(this.opacityType),s=this._drawingOptions,r=s[i],n=s[a],setter=(e,t)=>{s.updateProperty(i,e);s.updateProperty(a,t);draw_classPrivateFieldGet(mc,this).updateProperty(i,e);draw_classPrivateFieldGet(mc,this).updateProperty(a,t);this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties());this.onUpdatedColor();this.onUpdatedOpacity()};this.addCommands({cmd:setter.bind(this,e,t),undo:setter.bind(this,r,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:w.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties(draw_classPrivateFieldGet(mc,this).getPathResizingSVGProperties(draw_assertClassBrand(yc,this,_convertToDrawSpace).call(this)),{bbox:draw_assertClassBrand(yc,this,_rotateBox).call(this)}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties(draw_classPrivateFieldGet(mc,this).getPathResizedSVGProperties(draw_assertClassBrand(yc,this,_convertToDrawSpace).call(this)),{bbox:draw_assertClassBrand(yc,this,_rotateBox).call(this)}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:draw_assertClassBrand(yc,this,_rotateBox).call(this)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties(draw_classPrivateFieldGet(mc,this).getPathTranslatedSVGProperties(draw_assertClassBrand(yc,this,_convertToDrawSpace).call(this),this.parentDimensions),{bbox:draw_assertClassBrand(yc,this,_rotateBox).call(this)}))}_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(e){this.annotationElementId||this.parent.addUndoableEditor(this);this._isDraggable=!0;if(draw_classPrivateFieldGet(vc,this)){draw_classPrivateFieldSet(vc,this,!1);this.commit();this.parent.setSelected(this);e&&this.isOnScreen&&this.div.focus()}}remove(){draw_assertClassBrand(yc,this,draw_cleanDrawLayer).call(this);super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){draw_assertClassBrand(yc,this,draw_addToDrawLayer).call(this);draw_assertClassBrand(yc,this,_updateBbox).call(this,draw_classPrivateFieldGet(mc,this).box);this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e){this._uiManager.removeShouldRescale(this);draw_assertClassBrand(yc,this,draw_cleanDrawLayer).call(this)}else if(e){this._uiManager.addShouldRescale(this);draw_assertClassBrand(yc,this,draw_addToDrawLayer).call(this,e);t=!this.parent&&this.div?.classList.contains("selectedEditor")}super.setParent(e);t&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties({bbox:draw_assertClassBrand(yc,this,_rotateBox).call(this)},draw_classPrivateFieldGet(mc,this).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&draw_assertClassBrand(yc,this,_updateBbox).call(this,draw_classPrivateFieldGet(mc,this).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}const i=super.render();i.classList.add("draw");const a=document.createElement("div");i.append(a);a.setAttribute("aria-hidden","true");a.className="internal";this.setDims();this._uiManager.addShouldRescale(this);this.disableEditing();this._isCopy&&this._moveAfterPaste(e,t);return i}static createDrawerInstance(e,t,i,a,s){unreachable("Not implemented")}static startDrawing(e,t,i,a){const s=a.target,r=a.offsetX,n=a.offsetY,o=a.pointerId,l=a.pointerType;if(CurrentPointers.isInitializedAndDifferentPointerType(l))return;const c=e.viewport.rotation,d=s.getBoundingClientRect(),h=d.width,u=d.height,_=wc._=new AbortController,p=e.combinedSignal(_);CurrentPointers.setPointer(l,o);window.addEventListener("pointerup",e=>{CurrentPointers.isSamePointerIdOrRemove(e.pointerId)&&this._endDraw(e)},{signal:p});window.addEventListener("pointercancel",e=>{CurrentPointers.isSamePointerIdOrRemove(e.pointerId)&&this._currentParent.endDrawingSession()},{signal:p});window.addEventListener("pointerdown",e=>{if(CurrentPointers.isSamePointerType(e.pointerType)){CurrentPointers.initializeAndAddPointerId(e.pointerId);if(Pc._.isCancellable()){Pc._.removeLastElement();Pc._.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)}}},{capture:!0,passive:!1,signal:p});window.addEventListener("contextmenu",noContextMenu,{signal:p});s.addEventListener("pointermove",this._drawMove.bind(this),{signal:p});s.addEventListener("touchmove",e=>{CurrentPointers.isSameTimeStamp(e.timeStamp)&&stopEvent(e)},{signal:p});e.toggleDrawing();this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"drawingStarted",editorType:this.name});t._editorUndoBar?.hide();if(Pc._)e.drawLayer.updateProperties(this._currentDrawId,Pc._.startNew(r,n,h,u,c));else{t.updateUIForDefaultProperties(this);Pc._=this.createDrawerInstance(r,n,h,u,c);bc._=this.getDefaultDrawingOptions();this._currentParent=e;var g=e.drawLayer.draw(this._mergeSVGProperties(bc._.toSVGProperties(),Pc._.defaultSVGProperties),!0,!1);this._currentDrawId=g.id}}static _drawMove(e){CurrentPointers.isSameTimeStamp(e.timeStamp);if(!Pc._)return;const t=e.offsetX,i=e.offsetY,a=e.pointerId;if(CurrentPointers.isSamePointerId(a))if(CurrentPointers.isUsingMultiplePointers())this._endDraw(e);else{this._currentParent.drawLayer.updateProperties(this._currentDrawId,Pc._.add(t,i));CurrentPointers.setTimeStamp(e.timeStamp);stopEvent(e)}}static _cleanup(e){if(e){this._currentDrawId=-1;this._currentParent=null;Pc._=null;bc._=null;CurrentPointers.clearTimeStamp()}if(wc._){wc._.abort();wc._=null;CurrentPointers.clearPointerIds()}}static _endDraw(e){const t=this._currentParent;if(t){t.toggleDrawing(!0);this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"drawingStopped",editorType:this.name});this._cleanup(!1);e?.target===t.div&&t.drawLayer.updateProperties(this._currentDrawId,Pc._.end(e.offsetX,e.offsetY));this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"bezierPathChanged",page:this._currentParent?this._currentParent.pageIndex+1:NaN,editorType:this.name,id:this.uid});if(this.supportMultipleDrawings){const e=Pc._,i=this._currentDrawId,a=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(i,e.setLastElement(a))},undo:()=>{t.drawLayer.updateProperties(i,e.removeLastElement())},mustExec:!1,type:w.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const t=this._currentParent;if(!t)return null;t.toggleDrawing(!0);t.cleanUndoStack(w.DRAW_STEP);if(!Pc._.isEmpty()){const i=draw_slicedToArray(t.pageDimensions,2),a=i[0],s=i[1],r=t.scale,n=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Pc._.getOutlines(a*r,s*r,r,this._INNER_MARGIN),drawingOptions:bc._,mustBeCommitted:!e});this._cleanup(!0);return n}t.drawLayer.remove(this._currentDrawId);this._cleanup(!0);return null}createDrawingOptions(e){}static deserializeDraw(e,t,i,a,s,r){unreachable("Not implemented")}static async deserialize(e,t,i){const a=t.viewport.rawDims,s=a.pageWidth,r=a.pageHeight,n=a.pageX,o=a.pageY,l=this.deserializeDraw(n,o,s,r,this._INNER_MARGIN,e),c=await super.deserialize(e,t,i);c.createDrawingOptions(e);draw_assertClassBrand(yc,c,_createDrawOutlines).call(c,{drawOutlines:l});draw_assertClassBrand(yc,c,draw_addToDrawLayer).call(c);c.onScaleChanging();c.rotate();return c}serializeDraw(e){const t=draw_slicedToArray(this.pageTranslation,2),i=t[0],a=t[1],s=draw_slicedToArray(this.pageDimensions,2),r=s[0],n=s[1];return draw_classPrivateFieldGet(mc,this).serialize([i,a,r,n],e)}renderAnnotationElement(e){e.updateEdited({rect:this.getPDFRect()});return null}static canCreateNewEmptyEditor(){return!1}}Yl=DrawingEditor;function _createDrawOutlines(e){let t=e.drawOutlines,i=e.drawId,a=e.drawingOptions;draw_classPrivateFieldSet(mc,this,t);this._drawingOptions||=a;this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert[this.editorType]);if(i>=0){this._drawId=i;this.parent.drawLayer.finalizeDraw(i,t.defaultProperties)}else this._drawId=draw_assertClassBrand(yc,this,_createDrawing).call(this,t,this.parent);draw_assertClassBrand(yc,this,_updateBbox).call(this,t.box)}function _createDrawing(e,t){return t.drawLayer.draw(Yl._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1).id}function draw_cleanDrawLayer(){if(null!==this._drawId&&this.parent){this.parent.drawLayer.remove(this._drawId);this._drawId=null;this._drawingOptions.reset()}}function draw_addToDrawLayer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;if(null===this._drawId||this.parent!==e)if(null===this._drawId){this._drawingOptions.updateAll();this._drawId=draw_assertClassBrand(yc,this,_createDrawing).call(this,draw_classPrivateFieldGet(mc,this),e)}else this.parent.drawLayer.updateParent(this._drawId,e.drawLayer)}function _convertToParentSpace(e){let t=draw_slicedToArray(e,4),i=t[0],a=t[1],s=t[2],r=t[3];const n=draw_slicedToArray(this.parentDimensions,2),o=n[0],l=n[1];switch(this.rotation){case 90:return[a,1-i,s*(l/o),r*(o/l)];case 180:return[1-i,1-a,s,r];case 270:return[1-a,i,s*(l/o),r*(o/l)];default:return[i,a,s,r]}}function _convertToDrawSpace(){const e=this.x,t=this.y,i=this.width,a=this.height,s=draw_slicedToArray(this.parentDimensions,2),r=s[0],n=s[1];switch(this.rotation){case 90:return[1-t,e,i*(r/n),a*(n/r)];case 180:return[1-e,1-t,i,a];case 270:return[t,1-e,i*(r/n),a*(n/r)];default:return[e,t,i,a]}}function _updateBbox(e){var t=draw_slicedToArray(draw_assertClassBrand(yc,this,_convertToParentSpace).call(this,e),4);this.x=t[0];this.y=t[1];this.width=t[2];this.height=t[3];if(this.div){this.fixAndSetPosition();this.setDims()}this._onResized()}function _rotateBox(){const e=this.x,t=this.y,i=this.width,a=this.height,s=this.rotation,r=this.parentRotation,n=draw_slicedToArray(this.parentDimensions,2),o=n[0],l=n[1];switch((4*s+r)/90){case 1:return[1-t-a,e,a,i];case 2:return[1-e-i,1-t-a,i,a];case 3:return[t,1-e-i,a,i];case 4:return[e,t-i*(o/l),a*(l/o),i*(o/l)];case 5:return[1-t,e,i*(o/l),a*(l/o)];case 6:return[1-e-a*(l/o),1-t,a*(l/o),i*(o/l)];case 7:return[t-i*(o/l),1-e-a*(l/o),i*(o/l),a*(l/o)];case 8:return[e-i,t-a,i,a];case 9:return[1-t,e-i,a,i];case 10:return[1-e,1-t,i,a];case 11:return[t-a,1-e,a,i];case 12:return[e-a*(l/o),t,a*(l/o),i*(o/l)];case 13:return[1-t-i*(o/l),e-a*(l/o),i*(o/l),a*(l/o)];case 14:return[1-e,1-t-i*(o/l),a*(l/o),i*(o/l)];case 15:return[t,1-e,i*(o/l),a*(l/o)];default:return[e,t,i,a]}}draw_defineProperty(DrawingEditor,"_currentDrawId",-1);draw_defineProperty(DrawingEditor,"_currentParent",null);var Pc={_:null},wc={_:null},bc={_:null};draw_defineProperty(DrawingEditor,"_INNER_MARGIN",3);function inkdraw_slicedToArray(e,t){return function inkdraw_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function inkdraw_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function inkdraw_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return inkdraw_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?inkdraw_arrayLikeToArray(e,t):void 0}}(e,t)||function inkdraw_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function inkdraw_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function inkdraw_classPrivateMethodInitSpec(e,t){inkdraw_checkPrivateRedeclaration(e,t),t.add(e)}function inkdraw_classPrivateFieldInitSpec(e,t,i){inkdraw_checkPrivateRedeclaration(e,t),t.set(e,i)}function inkdraw_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function inkdraw_classPrivateFieldGet(e,t){return e.get(inkdraw_assertClassBrand(e,t))}function inkdraw_classPrivateFieldSet(e,t,i){return e.set(inkdraw_assertClassBrand(e,t),i),i}function inkdraw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Fc=new WeakMap,Sc=new WeakMap,Cc=new WeakMap,Ac=new WeakMap,xc=new WeakMap,kc=new WeakMap,Ec=new WeakMap,Tc=new WeakMap,Ic=new WeakMap,Gc=new WeakMap,Bc=new WeakMap,Mc=new WeakSet;class InkDrawOutliner{constructor(e,t,i,a,s,r){inkdraw_classPrivateMethodInitSpec(this,Mc);inkdraw_classPrivateFieldInitSpec(this,Fc,new Float64Array(6));inkdraw_classPrivateFieldInitSpec(this,Sc,void 0);inkdraw_classPrivateFieldInitSpec(this,Cc,void 0);inkdraw_classPrivateFieldInitSpec(this,Ac,void 0);inkdraw_classPrivateFieldInitSpec(this,xc,void 0);inkdraw_classPrivateFieldInitSpec(this,kc,void 0);inkdraw_classPrivateFieldInitSpec(this,Ec,"");inkdraw_classPrivateFieldInitSpec(this,Tc,0);inkdraw_classPrivateFieldInitSpec(this,Ic,new InkDrawOutline);inkdraw_classPrivateFieldInitSpec(this,Gc,void 0);inkdraw_classPrivateFieldInitSpec(this,Bc,void 0);inkdraw_classPrivateFieldSet(Gc,this,i);inkdraw_classPrivateFieldSet(Bc,this,a);inkdraw_classPrivateFieldSet(Ac,this,s);inkdraw_classPrivateFieldSet(xc,this,r);var n=inkdraw_slicedToArray(inkdraw_assertClassBrand(Mc,this,_normalizePoint).call(this,e,t),2);e=n[0];t=n[1];const o=inkdraw_classPrivateFieldSet(Sc,this,[NaN,NaN,NaN,NaN,e,t]);inkdraw_classPrivateFieldSet(kc,this,[e,t]);inkdraw_classPrivateFieldSet(Cc,this,[{line:o,points:inkdraw_classPrivateFieldGet(kc,this)}]);inkdraw_classPrivateFieldGet(Fc,this).set(o,0)}updateProperty(e,t){"stroke-width"===e&&inkdraw_classPrivateFieldSet(xc,this,t)}isEmpty(){return!inkdraw_classPrivateFieldGet(Cc,this)||0===inkdraw_classPrivateFieldGet(Cc,this).length}isCancellable(){return inkdraw_classPrivateFieldGet(kc,this).length<=10}add(e,t){var i=inkdraw_slicedToArray(inkdraw_assertClassBrand(Mc,this,_normalizePoint).call(this,e,t),2);e=i[0];t=i[1];const a=inkdraw_slicedToArray(inkdraw_classPrivateFieldGet(Fc,this).subarray(2,6),4),s=a[0],r=a[1],n=a[2],o=a[3],l=e-n,c=t-o;if(Math.hypot(inkdraw_classPrivateFieldGet(Gc,this)*l,inkdraw_classPrivateFieldGet(Bc,this)*c)<=2)return null;inkdraw_classPrivateFieldGet(kc,this).push(e,t);if(isNaN(s)){inkdraw_classPrivateFieldGet(Fc,this).set([n,o,e,t],2);inkdraw_classPrivateFieldGet(Sc,this).push(NaN,NaN,NaN,NaN,e,t);return{path:{d:this.toSVGPath()}}}isNaN(inkdraw_classPrivateFieldGet(Fc,this)[0])&&inkdraw_classPrivateFieldGet(Sc,this).splice(6,6);inkdraw_classPrivateFieldGet(Fc,this).set([s,r,n,o,e,t],0);inkdraw_classPrivateFieldGet(Sc,this).push(...Outline.createBezierPoints(s,r,n,o,e,t));return{path:{d:this.toSVGPath()}}}end(e,t){const i=this.add(e,t);return i||(2===inkdraw_classPrivateFieldGet(kc,this).length?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,i,a,s){inkdraw_classPrivateFieldSet(Gc,this,i);inkdraw_classPrivateFieldSet(Bc,this,a);inkdraw_classPrivateFieldSet(Ac,this,s);var r=inkdraw_slicedToArray(inkdraw_assertClassBrand(Mc,this,_normalizePoint).call(this,e,t),2);e=r[0];t=r[1];const n=inkdraw_classPrivateFieldSet(Sc,this,[NaN,NaN,NaN,NaN,e,t]);inkdraw_classPrivateFieldSet(kc,this,[e,t]);const o=inkdraw_classPrivateFieldGet(Cc,this).at(-1);if(o){o.line=new Float32Array(o.line);o.points=new Float32Array(o.points)}inkdraw_classPrivateFieldGet(Cc,this).push({line:n,points:inkdraw_classPrivateFieldGet(kc,this)});inkdraw_classPrivateFieldGet(Fc,this).set(n,0);inkdraw_classPrivateFieldSet(Tc,this,0);this.toSVGPath();return null}getLastElement(){return inkdraw_classPrivateFieldGet(Cc,this).at(-1)}setLastElement(e){if(!inkdraw_classPrivateFieldGet(Cc,this))return inkdraw_classPrivateFieldGet(Ic,this).setLastElement(e);inkdraw_classPrivateFieldGet(Cc,this).push(e);inkdraw_classPrivateFieldSet(Sc,this,e.line);inkdraw_classPrivateFieldSet(kc,this,e.points);inkdraw_classPrivateFieldSet(Tc,this,0);return{path:{d:this.toSVGPath()}}}removeLastElement(){if(!inkdraw_classPrivateFieldGet(Cc,this))return inkdraw_classPrivateFieldGet(Ic,this).removeLastElement();inkdraw_classPrivateFieldGet(Cc,this).pop();inkdraw_classPrivateFieldSet(Ec,this,"");for(let e=0,t=inkdraw_classPrivateFieldGet(Cc,this).length;e<t;e++){const t=inkdraw_classPrivateFieldGet(Cc,this)[e],i=t.line,a=t.points;inkdraw_classPrivateFieldSet(Sc,this,i);inkdraw_classPrivateFieldSet(kc,this,a);inkdraw_classPrivateFieldSet(Tc,this,0);this.toSVGPath()}return{path:{d:inkdraw_classPrivateFieldGet(Ec,this)}}}toSVGPath(){const e=Outline.svgRound(inkdraw_classPrivateFieldGet(Sc,this)[4]),t=Outline.svgRound(inkdraw_classPrivateFieldGet(Sc,this)[5]);if(2===inkdraw_classPrivateFieldGet(kc,this).length){inkdraw_classPrivateFieldSet(Ec,this,`${inkdraw_classPrivateFieldGet(Ec,this)} M ${e} ${t} Z`);return inkdraw_classPrivateFieldGet(Ec,this)}if(inkdraw_classPrivateFieldGet(kc,this).length<=6){const i=inkdraw_classPrivateFieldGet(Ec,this).lastIndexOf("M");inkdraw_classPrivateFieldSet(Ec,this,`${inkdraw_classPrivateFieldGet(Ec,this).slice(0,i)} M ${e} ${t}`);inkdraw_classPrivateFieldSet(Tc,this,6)}if(4===inkdraw_classPrivateFieldGet(kc,this).length){const e=Outline.svgRound(inkdraw_classPrivateFieldGet(Sc,this)[10]),t=Outline.svgRound(inkdraw_classPrivateFieldGet(Sc,this)[11]);inkdraw_classPrivateFieldSet(Ec,this,`${inkdraw_classPrivateFieldGet(Ec,this)} L ${e} ${t}`);inkdraw_classPrivateFieldSet(Tc,this,12);return inkdraw_classPrivateFieldGet(Ec,this)}const i=[];if(0===inkdraw_classPrivateFieldGet(Tc,this)){i.push(`M ${e} ${t}`);inkdraw_classPrivateFieldSet(Tc,this,6)}for(let e=inkdraw_classPrivateFieldGet(Tc,this),t=inkdraw_classPrivateFieldGet(Sc,this).length;e<t;e+=6){const t=inkdraw_slicedToArray(inkdraw_classPrivateFieldGet(Sc,this).slice(e,e+6).map(Outline.svgRound),6),a=t[0],s=t[1],r=t[2],n=t[3],o=t[4],l=t[5];i.push(`C${a} ${s} ${r} ${n} ${o} ${l}`)}inkdraw_classPrivateFieldSet(Ec,this,inkdraw_classPrivateFieldGet(Ec,this)+i.join(" "));inkdraw_classPrivateFieldSet(Tc,this,inkdraw_classPrivateFieldGet(Sc,this).length);return inkdraw_classPrivateFieldGet(Ec,this)}getOutlines(e,t,i,a){const s=inkdraw_classPrivateFieldGet(Cc,this).at(-1);s.line=new Float32Array(s.line);s.points=new Float32Array(s.points);inkdraw_classPrivateFieldGet(Ic,this).build(inkdraw_classPrivateFieldGet(Cc,this),e,t,i,inkdraw_classPrivateFieldGet(Ac,this),inkdraw_classPrivateFieldGet(xc,this),a);inkdraw_classPrivateFieldSet(Fc,this,null);inkdraw_classPrivateFieldSet(Sc,this,null);inkdraw_classPrivateFieldSet(Cc,this,null);inkdraw_classPrivateFieldSet(Ec,this,null);return inkdraw_classPrivateFieldGet(Ic,this)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}function _normalizePoint(e,t){return Outline._normalizePoint(e,t,inkdraw_classPrivateFieldGet(Gc,this),inkdraw_classPrivateFieldGet(Bc,this),inkdraw_classPrivateFieldGet(Ac,this))}var Dc=new WeakMap,Lc=new WeakMap,Oc=new WeakMap,Rc=new WeakMap,Nc=new WeakMap,jc=new WeakMap,Wc=new WeakMap,Uc=new WeakMap,Vc=new WeakMap,Hc=new WeakSet;class InkDrawOutline extends Outline{constructor(){super(...arguments);inkdraw_classPrivateMethodInitSpec(this,Hc);inkdraw_classPrivateFieldInitSpec(this,Dc,void 0);inkdraw_classPrivateFieldInitSpec(this,Lc,0);inkdraw_classPrivateFieldInitSpec(this,Oc,void 0);inkdraw_classPrivateFieldInitSpec(this,Rc,void 0);inkdraw_classPrivateFieldInitSpec(this,Nc,void 0);inkdraw_classPrivateFieldInitSpec(this,jc,void 0);inkdraw_classPrivateFieldInitSpec(this,Wc,void 0);inkdraw_classPrivateFieldInitSpec(this,Uc,void 0);inkdraw_classPrivateFieldInitSpec(this,Vc,void 0)}build(e,t,i,a,s,r,n){inkdraw_classPrivateFieldSet(Nc,this,t);inkdraw_classPrivateFieldSet(jc,this,i);inkdraw_classPrivateFieldSet(Wc,this,a);inkdraw_classPrivateFieldSet(Uc,this,s);inkdraw_classPrivateFieldSet(Vc,this,r);inkdraw_classPrivateFieldSet(Oc,this,n??0);inkdraw_classPrivateFieldSet(Rc,this,e);inkdraw_assertClassBrand(Hc,this,_computeBbox).call(this)}get thickness(){return inkdraw_classPrivateFieldGet(Vc,this)}setLastElement(e){inkdraw_classPrivateFieldGet(Rc,this).push(e);return{path:{d:this.toSVGPath()}}}removeLastElement(){inkdraw_classPrivateFieldGet(Rc,this).pop();return{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const t of inkdraw_classPrivateFieldGet(Rc,this)){const i=t.line;e.push(`M${Outline.svgRound(i[4])} ${Outline.svgRound(i[5])}`);if(6!==i.length)if(12===i.length&&isNaN(i[6]))e.push(`L${Outline.svgRound(i[10])} ${Outline.svgRound(i[11])}`);else for(let t=6,a=i.length;t<a;t+=6){const a=inkdraw_slicedToArray(i.subarray(t,t+6).map(Outline.svgRound),6),s=a[0],r=a[1],n=a[2],o=a[3],l=a[4],c=a[5];e.push(`C${s} ${r} ${n} ${o} ${l} ${c}`)}else e.push("Z")}return e.join("")}serialize(e,t){let i=inkdraw_slicedToArray(e,4),a=i[0],s=i[1],r=i[2],n=i[3];const o=[],l=[],c=inkdraw_slicedToArray(inkdraw_assertClassBrand(Hc,this,_getBBoxWithNoMargin).call(this),4),d=c[0],h=c[1],u=c[2],_=c[3];let p,g,f,m,v,y,P,w,b;switch(inkdraw_classPrivateFieldGet(Uc,this)){case 0:b=Outline._rescale;p=a;g=s+n;f=r;m=-n;v=a+d*r;y=s+(1-h-_)*n;P=a+(d+u)*r;w=s+(1-h)*n;break;case 90:b=Outline._rescaleAndSwap;p=a;g=s;f=r;m=n;v=a+h*r;y=s+d*n;P=a+(h+_)*r;w=s+(d+u)*n;break;case 180:b=Outline._rescale;p=a+r;g=s;f=-r;m=n;v=a+(1-d-u)*r;y=s+h*n;P=a+(1-d)*r;w=s+(h+_)*n;break;case 270:b=Outline._rescaleAndSwap;p=a+r;g=s+n;f=-r;m=-n;v=a+(1-h-_)*r;y=s+(1-d-u)*n;P=a+(1-h)*r;w=s+(1-d)*n}for(const e of inkdraw_classPrivateFieldGet(Rc,this)){const i=e.line,a=e.points;o.push(b(i,p,g,f,m,t?new Array(i.length):null));l.push(b(a,p,g,f,m,t?new Array(a.length):null))}return{lines:o,points:l,rect:[v,y,P,w]}}static deserialize(e,t,i,a,s,r){let n=r.paths,o=n.lines,l=n.points,c=r.rotation,d=r.thickness;const h=[];let u,_,p,g,f;switch(c){case 0:f=Outline._rescale;u=-e/i;_=t/a+1;p=1/i;g=-1/a;break;case 90:f=Outline._rescaleAndSwap;u=-t/a;_=-e/i;p=1/a;g=1/i;break;case 180:f=Outline._rescale;u=e/i+1;_=-t/a;p=-1/i;g=1/a;break;case 270:f=Outline._rescaleAndSwap;u=t/a+1;_=e/i+1;p=-1/a;g=-1/i}if(!o){o=[];for(const e of l){const t=e.length;if(2===t){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(4===t){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}const i=new Float32Array(3*(t-2));o.push(i);let a=inkdraw_slicedToArray(e.subarray(0,4),4),s=a[0],r=a[1],n=a[2],l=a[3];i.set([NaN,NaN,NaN,NaN,s,r],0);for(let a=4;a<t;a+=2){const t=e[a],o=e[a+1];i.set(Outline.createBezierPoints(s,r,n,l,t,o),3*(a-2));var m=[n,l,t,o];s=m[0];r=m[1];n=m[2];l=m[3]}}}for(let e=0,t=o.length;e<t;e++)h.push({line:f(o[e].map(e=>e??NaN),u,_,p,g),points:f(l[e].map(e=>e??NaN),u,_,p,g)});const v=new this.prototype.constructor;v.build(h,i,a,1,c,d,s);return v}get box(){return inkdraw_classPrivateFieldGet(Dc,this)}updateProperty(e,t){return"stroke-width"===e?inkdraw_assertClassBrand(Hc,this,inkdraw_updateThickness).call(this,t):null}updateParentDimensions(e,t){let i=inkdraw_slicedToArray(e,2),a=i[0],s=i[1];const r=inkdraw_slicedToArray(inkdraw_assertClassBrand(Hc,this,_getMarginComponents).call(this),2),n=r[0],o=r[1];inkdraw_classPrivateFieldSet(Nc,this,a);inkdraw_classPrivateFieldSet(jc,this,s);inkdraw_classPrivateFieldSet(Wc,this,t);const l=inkdraw_slicedToArray(inkdraw_assertClassBrand(Hc,this,_getMarginComponents).call(this),2),c=l[0]-n,d=l[1]-o,h=inkdraw_classPrivateFieldGet(Dc,this);h[0]-=c;h[1]-=d;h[2]+=2*c;h[3]+=2*d;return h}updateRotation(e){inkdraw_classPrivateFieldSet(Lc,this,e);return{path:{transform:this.rotationTransform}}}get viewBox(){return inkdraw_classPrivateFieldGet(Dc,this).map(Outline.svgRound).join(" ")}get defaultProperties(){const e=inkdraw_slicedToArray(inkdraw_classPrivateFieldGet(Dc,this),2),t=e[0],i=e[1];return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Outline.svgRound(t)} ${Outline.svgRound(i)}`}}}get rotationTransform(){const e=inkdraw_slicedToArray(inkdraw_classPrivateFieldGet(Dc,this),4),t=e[2],i=e[3];let a=0,s=0,r=0,n=0,o=0,l=0;switch(inkdraw_classPrivateFieldGet(Lc,this)){case 90:s=i/t;r=-t/i;o=t;break;case 180:a=-1;n=-1;o=t;l=i;break;case 270:s=-i/t;r=t/i;l=i;break;default:return""}return`matrix(${a} ${s} ${r} ${n} ${Outline.svgRound(o)} ${Outline.svgRound(l)})`}getPathResizingSVGProperties(e){let t=inkdraw_slicedToArray(e,4),i=t[0],a=t[1],s=t[2],r=t[3];const n=inkdraw_slicedToArray(inkdraw_assertClassBrand(Hc,this,_getMarginComponents).call(this),2),o=n[0],l=n[1],c=inkdraw_slicedToArray(inkdraw_classPrivateFieldGet(Dc,this),4),d=c[0],h=c[1],u=c[2],_=c[3];if(Math.abs(u-o)<=Outline.PRECISION||Math.abs(_-l)<=Outline.PRECISION){const e=i+s/2-(d+u/2),t=a+r/2-(h+_/2);return{path:{"transform-origin":`${Outline.svgRound(i)} ${Outline.svgRound(a)}`,transform:`${this.rotationTransform} translate(${e} ${t})`}}}const p=(s-2*o)/(u-2*o),g=(r-2*l)/(_-2*l),f=u/s,m=_/r;return{path:{"transform-origin":`${Outline.svgRound(d)} ${Outline.svgRound(h)}`,transform:`${this.rotationTransform} scale(${f} ${m}) translate(${Outline.svgRound(o)} ${Outline.svgRound(l)}) scale(${p} ${g}) translate(${Outline.svgRound(-o)} ${Outline.svgRound(-l)})`}}}getPathResizedSVGProperties(e){let t=inkdraw_slicedToArray(e,4),i=t[0],a=t[1],s=t[2],r=t[3];const n=inkdraw_slicedToArray(inkdraw_assertClassBrand(Hc,this,_getMarginComponents).call(this),2),o=n[0],l=n[1],c=inkdraw_classPrivateFieldGet(Dc,this),d=inkdraw_slicedToArray(c,4),h=d[0],u=d[1],_=d[2],p=d[3];c[0]=i;c[1]=a;c[2]=s;c[3]=r;if(Math.abs(_-o)<=Outline.PRECISION||Math.abs(p-l)<=Outline.PRECISION){const e=i+s/2-(h+_/2),t=a+r/2-(u+p/2);for(const i of inkdraw_classPrivateFieldGet(Rc,this)){const a=i.line,s=i.points;Outline._translate(a,e,t,a);Outline._translate(s,e,t,s)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Outline.svgRound(i)} ${Outline.svgRound(a)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(s-2*o)/(_-2*o),f=(r-2*l)/(p-2*l),m=-g*(h+o)+i+o,v=-f*(u+l)+a+l;if(1!==g||1!==f||0!==m||0!==v)for(const e of inkdraw_classPrivateFieldGet(Rc,this)){const t=e.line,i=e.points;Outline._rescale(t,m,v,g,f,t);Outline._rescale(i,m,v,g,f,i)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Outline.svgRound(i)} ${Outline.svgRound(a)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties(e,t){let i=inkdraw_slicedToArray(e,2),a=i[0],s=i[1];const r=inkdraw_slicedToArray(t,2),n=r[0],o=r[1],l=inkdraw_classPrivateFieldGet(Dc,this),c=a-l[0],d=s-l[1];if(inkdraw_classPrivateFieldGet(Nc,this)===n&&inkdraw_classPrivateFieldGet(jc,this)===o)for(const e of inkdraw_classPrivateFieldGet(Rc,this)){const t=e.line,i=e.points;Outline._translate(t,c,d,t);Outline._translate(i,c,d,i)}else{const e=inkdraw_classPrivateFieldGet(Nc,this)/n,t=inkdraw_classPrivateFieldGet(jc,this)/o;inkdraw_classPrivateFieldSet(Nc,this,n);inkdraw_classPrivateFieldSet(jc,this,o);for(const i of inkdraw_classPrivateFieldGet(Rc,this)){const a=i.line,s=i.points;Outline._rescale(a,c,d,e,t,a);Outline._rescale(s,c,d,e,t,s)}l[2]*=e;l[3]*=t}l[0]=a;l[1]=s;return{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Outline.svgRound(a)} ${Outline.svgRound(s)}`}}}get defaultSVGProperties(){const e=inkdraw_classPrivateFieldGet(Dc,this);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Outline.svgRound(e[0])} ${Outline.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}function _getMarginComponents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:inkdraw_classPrivateFieldGet(Vc,this);const t=inkdraw_classPrivateFieldGet(Oc,this)+e/2*inkdraw_classPrivateFieldGet(Wc,this);return inkdraw_classPrivateFieldGet(Uc,this)%180==0?[t/inkdraw_classPrivateFieldGet(Nc,this),t/inkdraw_classPrivateFieldGet(jc,this)]:[t/inkdraw_classPrivateFieldGet(jc,this),t/inkdraw_classPrivateFieldGet(Nc,this)]}function _getBBoxWithNoMargin(){const e=inkdraw_slicedToArray(inkdraw_classPrivateFieldGet(Dc,this),4),t=e[0],i=e[1],a=e[2],s=e[3],r=inkdraw_slicedToArray(inkdraw_assertClassBrand(Hc,this,_getMarginComponents).call(this,0),2),n=r[0],o=r[1];return[t+n,i+o,a-2*n,s-2*o]}function _computeBbox(){const e=inkdraw_classPrivateFieldSet(Dc,this,r.slice());for(const t of inkdraw_classPrivateFieldGet(Rc,this)){const i=t.line;if(i.length<=12){for(let t=4,a=i.length;t<a;t+=6)Util.pointBoundingBox(i[t],i[t+1],e);continue}let a=i[4],s=i[5];for(let t=6,r=i.length;t<r;t+=6){const r=inkdraw_slicedToArray(i.subarray(t,t+6),6),n=r[0],o=r[1],l=r[2],c=r[3],d=r[4],h=r[5];Util.bezierBoundingBox(a,s,n,o,l,c,d,h,e);a=d;s=h}}const t=inkdraw_slicedToArray(inkdraw_assertClassBrand(Hc,this,_getMarginComponents).call(this),2),i=t[0],a=t[1];e[0]=MathClamp(e[0]-i,0,1);e[1]=MathClamp(e[1]-a,0,1);e[2]=MathClamp(e[2]+i,0,1);e[3]=MathClamp(e[3]+a,0,1);e[2]-=e[0];e[3]-=e[1]}function inkdraw_updateThickness(e){const t=inkdraw_slicedToArray(inkdraw_assertClassBrand(Hc,this,_getMarginComponents).call(this),2),i=t[0],a=t[1];inkdraw_classPrivateFieldSet(Vc,this,e);const s=inkdraw_slicedToArray(inkdraw_assertClassBrand(Hc,this,_getMarginComponents).call(this),2),r=s[0]-i,n=s[1]-a,o=inkdraw_classPrivateFieldGet(Dc,this);o[0]-=r;o[1]-=n;o[2]+=2*r;o[3]+=2*n;return o}function ink_classPrivateMethodInitSpec(e,t){(function ink_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function ink_defineProperty(e,t,i){return(t=function ink_toPropertyKey(e){var t=function ink_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class InkDrawingOptions extends DrawingOptions{constructor(e){super();this._viewParameters=e;super.updateProperties({fill:"none",stroke:AnnotationEditor._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){if("stroke-width"===e){t??=this["stroke-width"];t*=this._viewParameters.realScale}super.updateSVGProperty(e,t)}clone(){const e=new InkDrawingOptions(this._viewParameters);e.updateAll(this);return e}}var zc=new WeakSet;class InkEditor extends DrawingEditor{constructor(e){super({...e,name:"inkEditor"});ink_classPrivateMethodInitSpec(this,zc);this._willKeepAspectRatio=!0;this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,t){AnnotationEditor.initialize(e,t);this._defaultDrawingOptions=new InkDrawingOptions(t.viewParameters)}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!0}static get typesMap(){return shadow(this,"typesMap",new Map([[w.INK_THICKNESS,"stroke-width"],[w.INK_COLOR,"stroke"],[w.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,t,i,a,s){return new InkDrawOutliner(e,t,i,a,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,t,i,a,s,r){return InkDrawOutline.deserialize(e,t,i,a,s,r)}static async deserialize(e,t,i){let a=null;if(e instanceof InkAnnotationElement){const t=e,i=t.data,s=i.inkLists,r=i.rect,n=i.rotation,o=i.id,l=i.color,c=i.opacity,d=i.borderStyle.rawWidth,h=i.popupRef,u=i.richText,_=i.contentsObj,p=i.creationDate,g=i.modificationDate,f=t.parent.page.pageNumber;a=e={annotationType:P.INK,color:Array.from(l),thickness:d,opacity:c,paths:{points:s},boxes:null,pageIndex:f-1,rect:r.slice(0),rotation:n,annotationElementId:o,id:o,deleted:!1,popupRef:h,richText:u,comment:_?.str||null,creationDate:p,modificationDate:g}}else{const t=e,i=t.popup,s=t.popupRef;a=e={...e,popupRef:s||!(!i||!i.contents||i.deleted)||null,comment:!i?.deleted&&i?.contents||null,commentDate:!i?.deleted&&i?.date||null}}const s=await super.deserialize(e,t,i);s._initialData=a;e.comment&&s.setCommentData(e);return s}get toolbarButtons(){this._colorPicker||=new BasicColorPicker(this);return[["colorPicker",this._colorPicker]]}get colorType(){return w.INK_COLOR}get colorAndOpacityType(){return w.INK_COLOR_AND_OPACITY}get opacityType(){return w.INK_OPACITY}updateParams(e,t){e!==w.INK_COLOR_AND_OPACITY?super.updateParams(e,t):this._updateColorAndOpacity(t.color,t.opacity)}static updateDefaultParams(e,t){if(e!==w.INK_COLOR_AND_OPACITY)super.updateDefaultParams(e,t);else{super.updateDefaultParams(w.INK_COLOR,t.color);super.updateDefaultParams(w.INK_OPACITY,t.opacity)}}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const e=this._drawId,t=this._drawingOptions,i=this.parent;t.updateSVGProperty("stroke-width");i.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;if(e){super.onScaleChangingWhenDrawing();this._defaultDrawingOptions.updateSVGProperty("stroke-width");e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}createDrawingOptions(e){let t=e.color,i=e.thickness,a=e.opacity;this._drawingOptions=InkEditor.getDefaultDrawingOptions({stroke:Util.makeHexColor(...t),"stroke-width":i,"stroke-opacity":a})}serialize(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const a=this.serializeDraw(e),s=a.lines,r=a.points,n=this._drawingOptions,o=n.stroke,l=n["stroke-opacity"],c=n["stroke-width"],d=Object.assign(super.serialize(e,t),{color:AnnotationEditor._colorManager.convert(o),opacity:l,thickness:c,paths:{lines:s,points:r}});this.addComment(d,this._isCopy);if(e){i&&(d.id=this.uid);d.isCopy=!0;return d}if(this.annotationElementId&&!function ink_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(zc,this,ink_hasElementChanged).call(this,d))return null;d.id=this.uid;return d}renderAnnotationElement(e){if(this.deleted){e.hide();return null}const t=this.serializeDraw(!1),i=t.points,a=t.rect;e.updateEdited({rect:a,thickness:this._drawingOptions["stroke-width"],points:i,popup:this.comment});return null}}function ink_hasElementChanged(e){const t=this._initialData,i=t.color,a=t.thickness,s=t.opacity,r=t.pageIndex;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((e,t)=>e!==i[t])||e.thickness!==a||e.opacity!==s||e.pageIndex!==r}ink_defineProperty(InkEditor,"_type","ink");ink_defineProperty(InkEditor,"_editorType",P.INK);ink_defineProperty(InkEditor,"_defaultDrawingOptions",null);class ContourDrawOutline extends InkDrawOutline{toSVGPath(){let e=super.toSVGPath();e.endsWith("Z")||(e+="Z");return e}}var $c;__webpack_require__(5213);function signaturedraw_slicedToArray(e,t){return function signaturedraw_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function signaturedraw_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function signaturedraw_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return signaturedraw_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?signaturedraw_arrayLikeToArray(e,t):void 0}}(e,t)||function signaturedraw_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function signaturedraw_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function signaturedraw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class SignatureExtractor{static extractContoursFromText(e,t,i,a,s,r){let n=t.fontFamily,o=t.fontStyle,l=t.fontWeight,c=new OffscreenCanvas(1,1),d=c.getContext("2d",{alpha:!1});const h=d.font=`${o} ${l} 200px ${n}`,u=d.measureText(e),_=u.actualBoundingBoxLeft,p=u.actualBoundingBoxRight,g=u.actualBoundingBoxAscent,f=u.actualBoundingBoxDescent,m=u.fontBoundingBoxAscent,v=u.fontBoundingBoxDescent,y=u.width,P=1.5,w=Math.ceil(Math.max(Math.abs(_)+Math.abs(p)||0,y)*P),b=Math.ceil(Math.max(Math.abs(g)+Math.abs(f)||200,Math.abs(m)+Math.abs(v)||200)*P);c=new OffscreenCanvas(w,b);d=c.getContext("2d",{alpha:!0,willReadFrequently:!0});d.font=h;d.filter="grayscale(1)";d.fillStyle="white";d.fillRect(0,0,w,b);d.fillStyle="black";d.fillText(e,.5*w/2,1.5*b/2);const S=signaturedraw_assertClassBrand(SignatureExtractor,this,_toUint).call(this,d.getImageData(0,0,w,b).data),C=signaturedraw_assertClassBrand(SignatureExtractor,this,_getHistogram).call(this,S),A=signaturedraw_assertClassBrand(SignatureExtractor,this,_guessThreshold).call(this,C),x=signaturedraw_assertClassBrand(SignatureExtractor,this,_findContours).call(this,S,w,b,A);return this.processDrawnLines({lines:{curves:x,width:w,height:b},pageWidth:i,pageHeight:a,rotation:s,innerMargin:r,mustSmooth:!0,areContours:!0})}static process(e,t,i,a,s){const r=signaturedraw_slicedToArray(signaturedraw_assertClassBrand(SignatureExtractor,this,_getGrayPixels).call(this,e),3),n=r[0],o=r[1],l=r[2],c=signaturedraw_slicedToArray(signaturedraw_assertClassBrand(SignatureExtractor,this,_bilateralFilter).call(this,n,o,l,Math.hypot(o,l)*signaturedraw_assertClassBrand(SignatureExtractor,this,qc)._.sigmaSFactor,signaturedraw_assertClassBrand(SignatureExtractor,this,qc)._.sigmaR,signaturedraw_assertClassBrand(SignatureExtractor,this,qc)._.kernelSize),2),d=c[0],h=c[1],u=signaturedraw_assertClassBrand(SignatureExtractor,this,_guessThreshold).call(this,h),_=signaturedraw_assertClassBrand(SignatureExtractor,this,_findContours).call(this,d,o,l,u);return this.processDrawnLines({lines:{curves:_,width:o,height:l},pageWidth:t,pageHeight:i,rotation:a,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines(e){let t=e.lines,i=e.pageWidth,a=e.pageHeight,s=e.rotation,r=e.innerMargin,n=e.mustSmooth,o=e.areContours;if(s%180!=0){var l=[a,i];i=l[0];a=l[1]}const c=t.curves,d=t.width,h=t.height,u=t.thickness??0,_=[],p=Math.min(i/d,a/h),g=p/i,f=p/a,m=[];for(const e of c){const t=e.points,i=n?signaturedraw_assertClassBrand(SignatureExtractor,this,_douglasPeucker).call(this,t):t;if(!i)continue;m.push(i);const a=i.length,s=new Float32Array(a),r=new Float32Array(3*(2===a?2:a-2));_.push({line:r,points:s});if(2===a){s[0]=i[0]*g;s[1]=i[1]*f;r.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let o=signaturedraw_slicedToArray(i,4),l=o[0],c=o[1],d=o[2],h=o[3];l*=g;c*=f;d*=g;h*=f;s.set([l,c,d,h],0);r.set([NaN,NaN,NaN,NaN,l,c],0);for(let e=4;e<a;e+=2){const t=s[e]=i[e]*g,a=s[e+1]=i[e+1]*f;r.set(Outline.createBezierPoints(l,c,d,h,t,a),3*(e-2));var v=[d,h,t,a];l=v[0];c=v[1];d=v[2];h=v[3]}}if(0===_.length)return null;const y=o?new ContourDrawOutline:new InkDrawOutline;y.build(_,i,a,1,s,o?0:u,r);return{outline:y,newCurves:m,areContours:o,thickness:u,width:d,height:h}}static async compressSignature(e){let t,i=e.outlines,a=e.areContours,s=e.thickness,r=e.width,n=e.height,o=1/0,l=-1/0,c=0;for(const e of i){c+=e.length;for(let t=2,i=e.length;t<i;t++){const i=e[t]-e[t-2];o=Math.min(o,i);l=Math.max(l,i)}}t=o>=-128&&l<=127?Int8Array:o>=-32768&&l<=32767?Int16Array:Int32Array;const d=i.length,h=8+3*d,u=new Uint32Array(h);let _=0;u[_++]=h*Uint32Array.BYTES_PER_ELEMENT+(c-2*d)*t.BYTES_PER_ELEMENT;u[_++]=0;u[_++]=r;u[_++]=n;u[_++]=a?0:1;u[_++]=Math.max(0,Math.floor(s??0));u[_++]=d;u[_++]=t.BYTES_PER_ELEMENT;for(const e of i){u[_++]=e.length-2;u[_++]=e[0];u[_++]=e[1]}const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready;g.write(u);const f=t.prototype.constructor;for(const e of i){const t=new f(e.length-2);for(let i=2,a=e.length;i<a;i++)t[i-2]=e[i]-e[i-2];g.write(t)}g.close();return(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(e){try{const t=Uint8Array.fromBase64(e),i=new DecompressionStream("deflate-raw"),a=i.readable,s=i.writable.getWriter();await s.ready;s.write(t).then(async()=>{await s.ready;await s.close()}).catch(()=>{});let r=null,n=0;for await(const e of a){r||=new Uint8Array(new Uint32Array(e.buffer,0,4)[0]);r.set(e,n);n+=e.length}const o=new Uint32Array(r.buffer,0,r.length>>2),l=o[1];if(0!==l)throw new Error(`Invalid version: ${l}`);const c=o[2],d=o[3],h=0===o[4],u=o[5],_=o[6],p=o[7],g=[],f=(8+3*_)*Uint32Array.BYTES_PER_ELEMENT;let m;switch(p){case Int8Array.BYTES_PER_ELEMENT:m=new Int8Array(r.buffer,f);break;case Int16Array.BYTES_PER_ELEMENT:m=new Int16Array(r.buffer,f);break;case Int32Array.BYTES_PER_ELEMENT:m=new Int32Array(r.buffer,f)}n=0;for(let e=0;e<_;e++){const t=o[3*e+8],i=new Float32Array(t+2);g.push(i);for(let t=0;t<2;t++)i[t]=o[3*e+8+t+1];for(let e=0;e<t;e++)i[e+2]=i[e]+m[n++]}return{areContours:h,thickness:u,outlines:g,width:c,height:d}}catch(e){warn(`decompressSignature: ${e}`);return null}}}$c=SignatureExtractor;function _neighborIndexToId(e,t,i,a){a-=t;return 0===(i-=e)?a>0?0:4:1===i?a+6:2-a}function _clockwiseNonZero(e,t,i,a,s,r,n){const o=signaturedraw_assertClassBrand($c,this,_neighborIndexToId).call(this,i,a,s,r);for(let s=0;s<8;s++){const r=(-s+o-n+16)%8;if(0!==e[(i+signaturedraw_assertClassBrand($c,this,Xc)._[2*r])*t+(a+signaturedraw_assertClassBrand($c,this,Xc)._[2*r+1])])return r}return-1}function _counterClockwiseNonZero(e,t,i,a,s,r,n){const o=signaturedraw_assertClassBrand($c,this,_neighborIndexToId).call(this,i,a,s,r);for(let s=0;s<8;s++){const r=(s+o+n+16)%8;if(0!==e[(i+signaturedraw_assertClassBrand($c,this,Xc)._[2*r])*t+(a+signaturedraw_assertClassBrand($c,this,Xc)._[2*r+1])])return r}return-1}function _findContours(e,t,i,a){const s=e.length,r=new Int32Array(s);for(let t=0;t<s;t++)r[t]=e[t]<=a?1:0;for(let e=1;e<i-1;e++)r[e*t]=r[e*t+t-1]=0;for(let e=0;e<t;e++)r[e]=r[t*i-1-e]=0;let n,o=1;const l=[];for(let e=1;e<i-1;e++){n=1;for(let i=1;i<t-1;i++){const a=e*t+i,s=r[a];if(0===s)continue;let c=e,d=i;if(1===s&&0===r[a-1]){o+=1;d-=1}else{if(!(s>=1&&0===r[a+1])){1!==s&&(n=Math.abs(s));continue}o+=1;d+=1;s>1&&(n=s)}const h=[i,e],u=d===i+1,_={isHole:u,points:h,id:o,parent:0};l.push(_);let p;for(const e of l)if(e.id===n){p=e;break}p?p.isHole?_.parent=u?p.parent:n:_.parent=u?n:p.parent:_.parent=u?n:0;const g=signaturedraw_assertClassBrand($c,this,_clockwiseNonZero).call(this,r,t,e,i,c,d,0);if(-1===g){r[a]=-o;1!==r[a]&&(n=Math.abs(r[a]));continue}let f=signaturedraw_assertClassBrand($c,this,Xc)._[2*g],m=signaturedraw_assertClassBrand($c,this,Xc)._[2*g+1];const v=e+f,y=i+m;c=v;d=y;let P=e,w=i;for(;;){const s=signaturedraw_assertClassBrand($c,this,_counterClockwiseNonZero).call(this,r,t,P,w,c,d,1);f=signaturedraw_assertClassBrand($c,this,Xc)._[2*s];m=signaturedraw_assertClassBrand($c,this,Xc)._[2*s+1];const l=P+f,u=w+m;h.push(u,l);const _=P*t+w;0===r[_+1]?r[_]=-o:1===r[_]&&(r[_]=o);if(l===e&&u===i&&P===v&&w===y){1!==r[a]&&(n=Math.abs(r[a]));break}c=P;d=w;P=l;w=u}}}return l}function _douglasPeuckerHelper(e,t,i,a){if(i-t<=4){for(let s=t;s<i-2;s+=2)a.push(e[s],e[s+1]);return}const s=e[t],r=e[t+1],n=e[i-4]-s,o=e[i-3]-r,l=Math.hypot(n,o),c=n/l,d=o/l,h=c*r-d*s,u=o/n,_=1/l,p=Math.atan(u),g=Math.cos(p),f=Math.sin(p),m=_*(Math.abs(g)+Math.abs(f)),v=_*(1-m+m**2),y=Math.max(Math.atan(Math.abs(f+g)*v),Math.atan(Math.abs(f-g)*v));let P=0,w=t;for(let a=t+2;a<i-2;a+=2){const t=Math.abs(h-c*e[a+1]+d*e[a]);if(t>P){w=a;P=t}}if(P>(l*y)**2){signaturedraw_assertClassBrand($c,this,_douglasPeuckerHelper).call(this,e,t,w+2,a);signaturedraw_assertClassBrand($c,this,_douglasPeuckerHelper).call(this,e,w,i,a)}else a.push(s,r)}function _douglasPeucker(e){const t=[],i=e.length;signaturedraw_assertClassBrand($c,this,_douglasPeuckerHelper).call(this,e,0,i,t);t.push(e[i-2],e[i-1]);return t.length<=4?null:t}function _bilateralFilter(e,t,i,a,s,r){const n=new Float32Array(r**2),o=-2*a**2,l=r>>1;for(let e=0;e<r;e++){const t=(e-l)**2;for(let i=0;i<r;i++)n[e*r+i]=Math.exp((t+(i-l)**2)/o)}const c=new Float32Array(256),d=-2*s**2;for(let e=0;e<256;e++)c[e]=Math.exp(e**2/d);const h=e.length,u=new Uint8Array(h),_=new Uint32Array(256);for(let a=0;a<i;a++)for(let s=0;s<t;s++){const o=a*t+s,d=e[o];let h=0,p=0;for(let o=0;o<r;o++){const u=a+o-l;if(!(u<0||u>=i))for(let i=0;i<r;i++){const a=s+i-l;if(a<0||a>=t)continue;const _=e[u*t+a],g=n[o*r+i]*c[Math.abs(_-d)];h+=_*g;p+=g}}_[u[o]=Math.round(h/p)]++}return[u,_]}function _getHistogram(e){const t=new Uint32Array(256);for(const i of e)t[i]++;return t}function _toUint(e){const t=e.length,i=new Uint8ClampedArray(t>>2);let a=-1/0,s=1/0;for(let t=0,r=i.length;t<r;t++){const r=i[t]=e[t<<2];a=Math.max(a,r);s=Math.min(s,r)}const r=255/(a-s);for(let e=0,t=i.length;e<t;e++)i[e]=(i[e]-s)*r;return i}function _guessThreshold(e){let t,i=-1/0,a=-1/0;const s=e.findIndex(e=>0!==e);let r=s,n=s;for(t=s;t<256;t++){const s=e[t];if(s>i){if(t-r>a){a=t-r;n=t-1}i=s;r=t}}for(t=n-1;t>=0&&!(e[t]>e[t+1]);t--);return t}function _getGrayPixels(e){const t=e,i=e,a=i.width,s=i.height,r=signaturedraw_assertClassBrand($c,this,qc)._.maxDim;let n=a,o=s;if(a>r||s>r){let i=a,l=s,c=Math.log2(Math.max(a,s)/r);const d=Math.floor(c);c=c===d?d-1:d;for(let a=0;a<c;a++){n=Math.ceil(i/2);o=Math.ceil(l/2);const a=new OffscreenCanvas(n,o);a.getContext("2d").drawImage(e,0,0,i,l,0,0,n,o);i=n;l=o;e!==t&&e.close();e=a.transferToImageBitmap()}const h=Math.min(r/n,r/o);n=Math.round(n*h);o=Math.round(o*h)}const l=new OffscreenCanvas(n,o).getContext("2d",{willReadFrequently:!0});l.fillStyle="white";l.fillRect(0,0,n,o);l.filter="grayscale(1)";l.drawImage(e,0,0,e.width,e.height,0,0,n,o);const c=l.getImageData(0,0,n,o).data;return[signaturedraw_assertClassBrand($c,this,_toUint).call(this,c),n,o]}var qc={_:{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}},Xc={_:new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1])};function signature_slicedToArray(e,t){return function signature_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function signature_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function signature_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return signature_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?signature_arrayLikeToArray(e,t):void 0}}(e,t)||function signature_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function signature_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function signature_defineProperty(e,t,i){return(t=function signature_toPropertyKey(e){var t=function signature_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function signature_classPrivateFieldInitSpec(e,t,i){(function signature_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function signature_classPrivateFieldGet(e,t){return e.get(signature_assertClassBrand(e,t))}function signature_classPrivateFieldSet(e,t,i){return e.set(signature_assertClassBrand(e,t),i),i}function signature_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class SignatureOptions extends DrawingOptions{constructor(){super();super.updateProperties({fill:AnnotationEditor._defaultLineColor,"stroke-width":0})}clone(){const e=new SignatureOptions;e.updateAll(this);return e}}class DrawnSignatureOptions extends InkDrawingOptions{constructor(e){super(e);super.updateProperties({stroke:AnnotationEditor._defaultLineColor,"stroke-width":1})}clone(){const e=new DrawnSignatureOptions(this._viewParameters);e.updateAll(this);return e}}var Kc=new WeakMap,Yc=new WeakMap,Zc=new WeakMap,Jc=new WeakMap;class SignatureEditor extends DrawingEditor{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});signature_classPrivateFieldInitSpec(this,Kc,!1);signature_classPrivateFieldInitSpec(this,Yc,null);signature_classPrivateFieldInitSpec(this,Zc,null);signature_classPrivateFieldInitSpec(this,Jc,null);this._willKeepAspectRatio=!0;signature_classPrivateFieldSet(Zc,this,e.signatureData||null);signature_classPrivateFieldSet(Yc,this,null);this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,t){AnnotationEditor.initialize(e,t);this._defaultDrawingOptions=new SignatureOptions;this._defaultDrawnSignatureOptions=new DrawnSignatureOptions(t.viewParameters)}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!1}static get typesMap(){return shadow(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!signature_classPrivateFieldGet(Yc,this)}}static computeTelemetryFinalData(e){const t=e.get("hasDescription");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,t;const i=this._isCopy;if(i){this._isCopy=!1;e=this.x;t=this.y}super.render();if(null===this._drawId)if(signature_classPrivateFieldGet(Zc,this)){const e=signature_classPrivateFieldGet(Zc,this),t=e.lines,i=e.mustSmooth,a=e.areContours,s=e.description,r=e.uuid,n=e.heightInPage,o=this.parent.viewport,l=o.rawDims,c=l.pageWidth,d=l.pageHeight,h=o.rotation,u=SignatureExtractor.processDrawnLines({lines:t,pageWidth:c,pageHeight:d,rotation:h,innerMargin:SignatureEditor._INNER_MARGIN,mustSmooth:i,areContours:a});this.addSignature(u,n,s,r)}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:signature_classPrivateFieldGet(Yc,this)||""}));if(i){this._isCopy=!0;this._moveAfterPaste(e,t)}return this.div}setUuid(e){signature_classPrivateFieldSet(Jc,this,e);this.addEditToolbar()}getUuid(){return signature_classPrivateFieldGet(Jc,this)}get description(){return signature_classPrivateFieldGet(Yc,this)}set description(e){signature_classPrivateFieldSet(Yc,this,e);if(this.div){this.div.setAttribute("data-l10n-args",JSON.stringify({description:e}));super.addEditToolbar().then(t=>{t?.updateEditSignatureButton(e)})}}getSignaturePreview(){const e=signature_classPrivateFieldGet(Zc,this),t=e.newCurves,i=e.areContours,a=e.thickness,s=e.width,r=e.height,n=Math.max(s,r);return{areContours:i,outline:SignatureExtractor.processDrawnLines({lines:{curves:t.map(e=>({points:e})),thickness:a,width:s,height:r},pageWidth:n,pageHeight:n,rotation:0,innerMargin:0,mustSmooth:!1,areContours:i}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,t,i,a){const s=this.x,r=this.y,n=signature_classPrivateFieldSet(Zc,this,e).outline;signature_classPrivateFieldSet(Kc,this,n instanceof ContourDrawOutline);this.description=i;let o;if(signature_classPrivateFieldGet(Kc,this))o=SignatureEditor.getDefaultDrawingOptions();else{o=SignatureEditor._defaultDrawnSignatureOptions.clone();o.updateProperties({"stroke-width":n.thickness})}this._addOutlines({drawOutlines:n,drawingOptions:o});let l=t/signature_slicedToArray(this.pageDimensions,2)[1];l=l>=1?.5:l;this.width*=l/this.height;if(this.width>=1){l*=.9/this.width;this.width=.9}this.height=l;this.setDims();this.x=s;this.y=r;this.center();this._onResized();this.onScaleChanging();this.rotate();this._uiManager.addToAnnotationStorage(this);this.setUuid(a);this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!a,hasDescription:!!i}});this.div.hidden=!1;this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"signatureAdded",page:this.pageIndex+1,editorType:this.constructor.name,id:this.uid,value:this,description:i})}getFromImage(e){const t=this.parent.viewport,i=t.rawDims,a=i.pageWidth,s=i.pageHeight,r=t.rotation;return SignatureExtractor.process(e,a,s,r,SignatureEditor._INNER_MARGIN)}getFromText(e,t){const i=this.parent.viewport,a=i.rawDims,s=a.pageWidth,r=a.pageHeight,n=i.rotation;return SignatureExtractor.extractContoursFromText(e,t,s,r,n,SignatureEditor._INNER_MARGIN)}getDrawnSignature(e){const t=this.parent.viewport,i=t.rawDims,a=i.pageWidth,s=i.pageHeight,r=t.rotation;return SignatureExtractor.processDrawnLines({lines:e,pageWidth:a,pageHeight:s,rotation:r,innerMargin:SignatureEditor._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions(e){let t=e.areContours,i=e.thickness;if(t)this._drawingOptions=SignatureEditor.getDefaultDrawingOptions();else{this._drawingOptions=SignatureEditor._defaultDrawnSignatureOptions.clone();this._drawingOptions.updateProperties({"stroke-width":i})}}serialize(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.isEmpty())return null;const a=this.serializeDraw(e),s=a.lines,r=a.points,n=this._drawingOptions["stroke-width"],o=Object.assign(super.serialize(e,t),{isSignature:!0,areContours:signature_classPrivateFieldGet(Kc,this),color:[0,0,0],thickness:signature_classPrivateFieldGet(Kc,this)?0:n});this.addComment(o,this._isCopy);if(e){o.paths={lines:s,points:r};o.uuid=signature_classPrivateFieldGet(Jc,this);o.isCopy=!0}else{o.lines=s;i&&(o.id=this.uid)}signature_classPrivateFieldGet(Yc,this)&&(o.accessibilityData={type:"Figure",alt:signature_classPrivateFieldGet(Yc,this)});return o}static deserializeDraw(e,t,i,a,s,r){return r.areContours?ContourDrawOutline.deserialize(e,t,i,a,s,r):InkDrawOutline.deserialize(e,t,i,a,s,r)}static async deserialize(e,t,i){const a=await super.deserialize(e,t,i);signature_classPrivateFieldSet(Kc,a,e.areContours);a.description=e.accessibilityData?.alt||"";signature_classPrivateFieldSet(Jc,a,e.uuid);return a}}signature_defineProperty(SignatureEditor,"_type","signature");signature_defineProperty(SignatureEditor,"_editorType",P.SIGNATURE);signature_defineProperty(SignatureEditor,"_defaultDrawingOptions",null);function stamp_slicedToArray(e,t){return function stamp_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function stamp_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function stamp_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return stamp_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?stamp_arrayLikeToArray(e,t):void 0}}(e,t)||function stamp_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function stamp_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function stamp_defineProperty(e,t,i){return(t=function stamp_toPropertyKey(e){var t=function stamp_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function stamp_classPrivateFieldInitSpec(e,t,i){stamp_checkPrivateRedeclaration(e,t),t.set(e,i)}function stamp_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function stamp_classPrivateFieldGet(e,t){return e.get(stamp_assertClassBrand(e,t))}function stamp_classPrivateFieldSet(e,t,i){return e.set(stamp_assertClassBrand(e,t),i),i}function stamp_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Qc=new WeakMap,ed=new WeakMap,td=new WeakMap,id=new WeakMap,ad=new WeakMap,sd=new WeakMap,rd=new WeakMap,nd=new WeakMap,od=new WeakMap,ld=new WeakMap,cd=new WeakMap,dd=new WeakSet;class StampEditor extends AnnotationEditor{constructor(e){super({...e,name:"stampEditor"});!function stamp_classPrivateMethodInitSpec(e,t){stamp_checkPrivateRedeclaration(e,t),t.add(e)}(this,dd);stamp_classPrivateFieldInitSpec(this,Qc,null);stamp_classPrivateFieldInitSpec(this,ed,null);stamp_classPrivateFieldInitSpec(this,td,null);stamp_classPrivateFieldInitSpec(this,id,null);stamp_classPrivateFieldInitSpec(this,ad,null);stamp_classPrivateFieldInitSpec(this,sd,"");stamp_classPrivateFieldInitSpec(this,rd,null);stamp_classPrivateFieldInitSpec(this,nd,!1);stamp_classPrivateFieldInitSpec(this,od,null);stamp_classPrivateFieldInitSpec(this,ld,!1);stamp_classPrivateFieldInitSpec(this,cd,!1);stamp_classPrivateFieldSet(id,this,e.bitmapUrl);stamp_classPrivateFieldSet(ad,this,e.bitmapFile);this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,t){AnnotationEditor.initialize(e,t)}static isHandlingMimeForPasting(e){return J.includes(e)}static paste(e,t){t.pasteEditor({mode:P.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1);super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){const t=e.get("hasAltText");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}async mlGuessAltText(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.hasAltTextData())return null;const i=this._uiManager.mlManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const a=e||this.copyCanvas(null,null,!0).imageData,s=a.data,r=a.width,n=a.height,o=await i.guess({name:"altText",request:{data:s,width:r,height:n,channels:s.length/(r*n)}});if(!o)throw new Error("No response from the AI service.");if(o.error)throw new Error("Error from the AI service.");if(o.cancel)return null;if(!o.output)throw new Error("No valid response from the AI service.");const l=o.output;await this.setGuessedAltText(l);t&&!this.hasAltTextData()&&(this.altTextData={alt:l,decorative:!1});return l}remove(){if(stamp_classPrivateFieldGet(ed,this)){stamp_classPrivateFieldSet(Qc,this,null);this._uiManager.imageManager.deleteId(stamp_classPrivateFieldGet(ed,this));stamp_classPrivateFieldGet(rd,this)?.remove();stamp_classPrivateFieldSet(rd,this,null);if(stamp_classPrivateFieldGet(od,this)){clearTimeout(stamp_classPrivateFieldGet(od,this));stamp_classPrivateFieldSet(od,this,null)}}super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){stamp_classPrivateFieldGet(ed,this)&&null===stamp_classPrivateFieldGet(rd,this)&&stamp_assertClassBrand(dd,this,_getBitmap).call(this);this.isAttachedToDOM||this.parent.add(this)}}else stamp_classPrivateFieldGet(ed,this)&&stamp_assertClassBrand(dd,this,_getBitmap).call(this)}onceAdded(e){this._isDraggable=!0;e&&this.div.focus()}isEmpty(){return!(stamp_classPrivateFieldGet(td,this)||stamp_classPrivateFieldGet(Qc,this)||stamp_classPrivateFieldGet(id,this)||stamp_classPrivateFieldGet(ad,this)||stamp_classPrivateFieldGet(ed,this)||stamp_classPrivateFieldGet(nd,this))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}super.render();this.div.hidden=!0;this.createAltText();stamp_classPrivateFieldGet(nd,this)||(stamp_classPrivateFieldGet(Qc,this)?stamp_assertClassBrand(dd,this,_createCanvas).call(this):stamp_assertClassBrand(dd,this,_getBitmap).call(this));this._isCopy&&this._moveAfterPaste(e,t);this._uiManager.addShouldRescale(this);return this.div}setCanvas(e,t){const i=this._uiManager.imageManager.getFromCanvas(e,t),a=i.id,s=i.bitmap;t.remove();if(a&&this._uiManager.imageManager.isValidId(a)){stamp_classPrivateFieldSet(ed,this,a);s&&stamp_classPrivateFieldSet(Qc,this,s);stamp_classPrivateFieldSet(nd,this,!1);stamp_assertClassBrand(dd,this,_createCanvas).call(this)}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==stamp_classPrivateFieldGet(od,this)&&clearTimeout(stamp_classPrivateFieldGet(od,this));stamp_classPrivateFieldSet(od,this,setTimeout(()=>{stamp_classPrivateFieldSet(od,this,null);stamp_assertClassBrand(dd,this,_drawBitmap).call(this)},200))}copyCanvas(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e||(e=224);const a=stamp_classPrivateFieldGet(Qc,this),s=a.width,r=a.height,n=new OutputScale;let o=stamp_classPrivateFieldGet(Qc,this),l=s,c=r,d=null;if(t){if(s>t||r>t){const e=Math.min(t/s,t/r);l=Math.floor(s*e);c=Math.floor(r*e)}d=document.createElement("canvas");const e=d.width=Math.ceil(l*n.sx),i=d.height=Math.ceil(c*n.sy);stamp_classPrivateFieldGet(ld,this)||(o=stamp_assertClassBrand(dd,this,_scaleBitmap).call(this,e,i));const a=d.getContext("2d");a.filter=this._uiManager.hcmFilter;let h="white",u="#cfcfd8";if("none"!==this._uiManager.hcmFilter)u="black";else if(ColorScheme.isDarkMode){h="#8f8f9d";u="#42414d"}const _=15,p=_*n.sx,g=_*n.sy,f=new OffscreenCanvas(2*p,2*g),m=f.getContext("2d");m.fillStyle=h;m.fillRect(0,0,2*p,2*g);m.fillStyle=u;m.fillRect(0,0,p,g);m.fillRect(p,g,p,g);a.fillStyle=a.createPattern(f,"repeat");a.fillRect(0,0,e,i);a.drawImage(o,0,0,o.width,o.height,0,0,e,i)}let h=null;if(i){let t,i;if(n.symmetric&&o.width<e&&o.height<e){t=o.width;i=o.height}else{o=stamp_classPrivateFieldGet(Qc,this);if(s>e||r>e){const a=Math.min(e/s,e/r);t=Math.floor(s*a);i=Math.floor(r*a);stamp_classPrivateFieldGet(ld,this)||(o=stamp_assertClassBrand(dd,this,_scaleBitmap).call(this,t,i))}}const a=new OffscreenCanvas(t,i).getContext("2d",{willReadFrequently:!0});a.drawImage(o,0,0,o.width,o.height,0,0,t,i);h={width:t,height:i,data:a.getImageData(0,0,t,i).data}}return{canvas:d,width:l,height:c,imageData:h}}static async deserialize(e,t,i){let a=null,s=!1;if(e instanceof StampAnnotationElement){const n=e,o=n.data,l=o.rect,c=o.rotation,d=o.id,h=o.structParent,u=o.popupRef,_=o.richText,p=o.contentsObj,g=o.creationDate,f=o.modificationDate,m=n.container,y=n.parent.page.pageNumber,w=n.canvas;let b,S;if(w){delete e.canvas;var r=i.imageManager.getFromCanvas(m.id,w);b=r.id;S=r.bitmap;w.remove()}else{s=!0;e._hasNoCanvas=!0}const C=(await t._structTree.getAriaAttributes(`${v}${d}`))?.get("aria-label")||"";a=e={annotationType:P.STAMP,bitmapId:b,bitmap:S,pageIndex:y-1,rect:l.slice(0),rotation:c,annotationElementId:d,id:d,deleted:!1,accessibilityData:{decorative:!1,altText:C},isSvg:!1,structParent:h,popupRef:u,richText:_,comment:p?.str||null,creationDate:g,modificationDate:f}}else{const t=e,i=t.popup,s=t.popupRef;a=e={...e,popupRef:s||!(!i||!i.contents||i.deleted)||null,comment:!i?.deleted&&i?.contents||null,commentDate:!i?.deleted&&i?.date||null}}const n=await super.deserialize(e,t,i),o=e,l=o.rect,c=o.bitmap,d=o.bitmapUrl,h=o.bitmapId,u=o.isSvg,_=o.accessibilityData;if(s){i.addMissingCanvas(e.id,n);stamp_classPrivateFieldSet(nd,n,!0)}else if(h&&i.imageManager.isValidId(h)){stamp_classPrivateFieldSet(ed,n,h);c&&stamp_classPrivateFieldSet(Qc,n,c)}else stamp_classPrivateFieldSet(id,n,d);stamp_classPrivateFieldSet(ld,n,u);const p=stamp_slicedToArray(n.pageDimensions,2),g=p[0],f=p[1];n.width=(l[2]-l[0])/g;n.height=(l[3]-l[1])/f;_&&(n.altTextData=_);n._initialData=a;e.comment&&n.setCommentData(e);stamp_classPrivateFieldSet(cd,n,!!a);return n}serialize(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const a=Object.assign(super.serialize(e,t),{bitmapId:stamp_classPrivateFieldGet(ed,this),isSvg:stamp_classPrivateFieldGet(ld,this)});this.addComment(a,this._isCopy);if(e){a.bitmapUrl=stamp_assertClassBrand(dd,this,_serializeBitmap).call(this,!0);a.accessibilityData=this.serializeAltText(!0);i&&(a.id=this.uid);a.isCopy=!0;return a}const s=this.serializeAltText(!1),r=s.decorative,n=s.altText;!r&&n&&(a.accessibilityData={type:"Figure",alt:n});if(this.annotationElementId){const e=stamp_assertClassBrand(dd,this,stamp_hasElementChanged).call(this,a);if(e.isSame)return null;e.isSameAltText?delete a.accessibilityData:a.accessibilityData.structParent=this._initialData.structParent??-1;a.id=this.uid;delete a.bitmapId;return a}if(null===t)return a;t.stamps||=new Map;const o=stamp_classPrivateFieldGet(ld,this)?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(t.stamps.has(stamp_classPrivateFieldGet(ed,this))){if(stamp_classPrivateFieldGet(ld,this)){const e=t.stamps.get(stamp_classPrivateFieldGet(ed,this));if(o>e.area){e.area=o;e.serialized.bitmap.close();e.serialized.bitmap=stamp_assertClassBrand(dd,this,_serializeBitmap).call(this,!1)}}}else{t.stamps.set(stamp_classPrivateFieldGet(ed,this),{area:o,serialized:a});a.bitmap=stamp_assertClassBrand(dd,this,_serializeBitmap).call(this,!1)}return a}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}}function _getBitmapFetched(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e){stamp_classPrivateFieldSet(Qc,this,e.bitmap);if(!t){stamp_classPrivateFieldSet(ed,this,e.id);stamp_classPrivateFieldSet(ld,this,e.isSvg)}e.file&&stamp_classPrivateFieldSet(sd,this,e.file.name);stamp_assertClassBrand(dd,this,_createCanvas).call(this)}else this.remove()}function _getBitmapDone(){stamp_classPrivateFieldSet(td,this,null);this._uiManager.enableWaiting(!1);if(stamp_classPrivateFieldGet(rd,this))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&stamp_classPrivateFieldGet(Qc,this))this.addEditToolbar().then(()=>{this._editToolbar.hide();this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&stamp_classPrivateFieldGet(Qc,this)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}function _getBitmap(){if(stamp_classPrivateFieldGet(ed,this)){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(stamp_classPrivateFieldGet(ed,this)).then(e=>stamp_assertClassBrand(dd,this,_getBitmapFetched).call(this,e,!0)).finally(()=>stamp_assertClassBrand(dd,this,_getBitmapDone).call(this));return}if(stamp_classPrivateFieldGet(id,this)){const e=stamp_classPrivateFieldGet(id,this);stamp_classPrivateFieldSet(id,this,null);this._uiManager.enableWaiting(!0);stamp_classPrivateFieldSet(td,this,this._uiManager.imageManager.getFromUrl(e).then(e=>stamp_assertClassBrand(dd,this,_getBitmapFetched).call(this,e)).finally(()=>stamp_assertClassBrand(dd,this,_getBitmapDone).call(this)));return}if(stamp_classPrivateFieldGet(ad,this)){const e=stamp_classPrivateFieldGet(ad,this);stamp_classPrivateFieldSet(ad,this,null);this._uiManager.enableWaiting(!0);stamp_classPrivateFieldSet(td,this,this._uiManager.imageManager.getFromFile(e).then(e=>stamp_assertClassBrand(dd,this,_getBitmapFetched).call(this,e)).finally(()=>stamp_assertClassBrand(dd,this,_getBitmapDone).call(this)));return}const e=document.createElement("input");e.type="file";e.accept=J.join(",");const t=this._uiManager._signal;stamp_classPrivateFieldSet(td,this,new Promise(i=>{e.addEventListener("change",async()=>{if(e.files&&0!==e.files.length){this._uiManager.enableWaiting(!0);const t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}});stamp_assertClassBrand(dd,this,_getBitmapFetched).call(this,t)}else this.remove();i()},{signal:t});e.addEventListener("cancel",()=>{this.remove();i()},{signal:t})}).finally(()=>stamp_assertClassBrand(dd,this,_getBitmapDone).call(this)));e.click()}function _createCanvas(){const e=this.div;let t=stamp_classPrivateFieldGet(Qc,this),i=t.width,a=t.height;const s=stamp_slicedToArray(this.pageDimensions,2),r=s[0],n=s[1],o=.75;if(this.width){i=this.width*r;a=this.height*n}else if(i>o*r||a>o*n){const e=Math.min(o*r/i,o*n/a);i*=e;a*=e}this._uiManager.enableWaiting(!1);const l=stamp_classPrivateFieldSet(rd,this,document.createElement("canvas"));l.setAttribute("role","img");this.addContainer(l);this.width=i/r;this.height=a/n;this.setDims();this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1);stamp_assertClassBrand(dd,this,_drawBitmap).call(this);if(!stamp_classPrivateFieldGet(cd,this)){this.parent.addUndoableEditor(this);stamp_classPrivateFieldSet(cd,this,!0)}this._reportTelemetry({action:"inserted_image"});this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"imageAdded",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:l,width:i,height:a,fileName:stamp_classPrivateFieldGet(sd,this)});stamp_classPrivateFieldGet(sd,this)&&this.div.setAttribute("aria-description",stamp_classPrivateFieldGet(sd,this));this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.stamp)}function _scaleBitmap(e,t){const i=stamp_classPrivateFieldGet(Qc,this);let a=i.width,s=i.height,r=stamp_classPrivateFieldGet(Qc,this);for(;a>2*e||s>2*t;){const i=a,n=s;a>2*e&&(a=Math.ceil(a/2));s>2*t&&(s=Math.ceil(s/2));const o=new OffscreenCanvas(a,s);o.getContext("2d").drawImage(r,0,0,i,n,0,0,a,s);r=o.transferToImageBitmap()}return r}function _drawBitmap(){const e=stamp_slicedToArray(this.parentDimensions,2),t=e[0],i=e[1],a=this.width,s=this.height,r=new OutputScale,n=Math.ceil(a*t*r.sx),o=Math.ceil(s*i*r.sy),l=stamp_classPrivateFieldGet(rd,this);if(!l||l.width===n&&l.height===o)return;l.width=n;l.height=o;const c=stamp_classPrivateFieldGet(ld,this)?stamp_classPrivateFieldGet(Qc,this):stamp_assertClassBrand(dd,this,_scaleBitmap).call(this,n,o),d=l.getContext("2d");d.filter=this._uiManager.hcmFilter;d.drawImage(c,0,0,c.width,c.height,0,0,n,o)}function _serializeBitmap(e){if(e){if(stamp_classPrivateFieldGet(ld,this)){const e=this._uiManager.imageManager.getSvgUrl(stamp_classPrivateFieldGet(ed,this));if(e)return e}const e=document.createElement("canvas");var t=stamp_classPrivateFieldGet(Qc,this);e.width=t.width;e.height=t.height;e.getContext("2d").drawImage(stamp_classPrivateFieldGet(Qc,this),0,0);return e.toDataURL()}if(stamp_classPrivateFieldGet(ld,this)){const e=stamp_slicedToArray(this.pageDimensions,2),t=e[0],i=e[1],a=Math.round(this.width*t*PixelsPerInch.PDF_TO_CSS_UNITS),s=Math.round(this.height*i*PixelsPerInch.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(a,s);r.getContext("2d").drawImage(stamp_classPrivateFieldGet(Qc,this),0,0,stamp_classPrivateFieldGet(Qc,this).width,stamp_classPrivateFieldGet(Qc,this).height,0,0,a,s);return r.transferToImageBitmap()}return structuredClone(stamp_classPrivateFieldGet(Qc,this))}function stamp_hasElementChanged(e){const t=this._initialData,i=t.pageIndex,a=t.accessibilityData.altText,s=e.pageIndex===i,r=(e.accessibilityData?.alt||"")===a;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&s&&r,isSameAltText:r}}stamp_defineProperty(StampEditor,"_type","stamp");stamp_defineProperty(StampEditor,"_editorType",P.STAMP);function annotation_editor_layer_slicedToArray(e,t){return function annotation_editor_layer_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function annotation_editor_layer_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function annotation_editor_layer_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return annotation_editor_layer_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?annotation_editor_layer_arrayLikeToArray(e,t):void 0}}(e,t)||function annotation_editor_layer_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function annotation_editor_layer_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function annotation_editor_layer_classPrivateFieldInitSpec(e,t,i){annotation_editor_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_editor_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_editor_layer_classPrivateGetter(e,t,i){return i(annotation_editor_layer_assertClassBrand(e,t))}function annotation_editor_layer_classPrivateFieldGet(e,t){return e.get(annotation_editor_layer_assertClassBrand(e,t))}function annotation_editor_layer_classPrivateFieldSet(e,t,i){return e.set(annotation_editor_layer_assertClassBrand(e,t),i),i}function annotation_editor_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function annotation_editor_layer_defineProperty(e,t,i){return(t=function annotation_editor_layer_toPropertyKey(e){var t=function annotation_editor_layer_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class PointerType{constructor(e){if(null===PointerType.current){PointerType.current="";window.addEventListener("pointerdown",this.windowPointerDown,!0)}}destroy(){if(null!==PointerType.current){window.removeEventListener("pointerdown",this.windowPointerDown,!0);PointerType.current=null}}windowPointerDown(e){PointerType.current=e.pointerType;return!0}static initializeEditor(){setTimeout(()=>PointerType.editor=PointerType.current)}static sameAsEditor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;return e?PointerType.editor==e:PointerType.editor==PointerType.current}}annotation_editor_layer_defineProperty(PointerType,"current",null);annotation_editor_layer_defineProperty(PointerType,"editor",null);new PointerType;var hd=new WeakMap,ud=new WeakMap,_d=new WeakMap,pd=new WeakMap,gd=new WeakMap,fd=new WeakMap,md=new WeakMap,vd=new WeakMap,yd=new WeakMap,Pd=new WeakMap,wd=new WeakMap,bd=new WeakMap,Fd=new WeakMap,Sd=new WeakMap,Cd=new WeakMap,Ad=new WeakMap,xd=new WeakSet;class AnnotationEditorLayer{constructor(e){let t=e.uiManager,i=e.pageIndex,a=e.div,s=e.structTreeLayer,r=e.accessibilityManager,n=e.annotationLayer,o=e.drawLayer,l=e.textLayer,c=e.viewport,d=e.l10n,h=e.eventBus;!function annotation_editor_layer_classPrivateMethodInitSpec(e,t){annotation_editor_layer_checkPrivateRedeclaration(e,t),t.add(e)}(this,xd);annotation_editor_layer_classPrivateFieldInitSpec(this,hd,void 0);annotation_editor_layer_classPrivateFieldInitSpec(this,ud,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,_d,null);annotation_editor_layer_classPrivateFieldInitSpec(this,pd,null);annotation_editor_layer_classPrivateFieldInitSpec(this,gd,null);annotation_editor_layer_classPrivateFieldInitSpec(this,fd,new Map);annotation_editor_layer_classPrivateFieldInitSpec(this,md,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,vd,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,yd,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,Pd,null);annotation_editor_layer_classPrivateFieldInitSpec(this,wd,null);annotation_editor_layer_classPrivateFieldInitSpec(this,bd,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Fd,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Sd,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Cd,-1);annotation_editor_layer_classPrivateFieldInitSpec(this,Ad,void 0);const u=[...Ed._.values()];if(!AnnotationEditorLayer._initialized){AnnotationEditorLayer._initialized=!0;for(const e of u){e.eventBus=h;e.initialize(d,t)}}t.registerEditorTypes(u);annotation_editor_layer_classPrivateFieldSet(Ad,this,t);this.pageIndex=i;this.div=a;annotation_editor_layer_classPrivateFieldSet(hd,this,r);annotation_editor_layer_classPrivateFieldSet(_d,this,n);this.viewport=c;annotation_editor_layer_classPrivateFieldSet(bd,this,l);this.drawLayer=o;this._structTree=s;annotation_editor_layer_classPrivateFieldGet(Ad,this).addLayer(this);this.eventBus=h}get isEmpty(){return 0===annotation_editor_layer_classPrivateFieldGet(fd,this).size}get isInvisible(){return this.isEmpty&&annotation_editor_layer_classPrivateFieldGet(Ad,this).getMode()===P.NONE}updateToolbar(e){annotation_editor_layer_classPrivateFieldGet(Ad,this).updateToolbar(e)}updateMode(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:annotation_editor_layer_classPrivateFieldGet(Ad,this).getMode();annotation_editor_layer_assertClassBrand(xd,this,_cleanup).call(this);switch(e){case P.NONE:this.div.classList.toggle("nonEditing",!0);this.disableTextSelection();this.togglePointerEvents(!1);this.toggleAnnotationLayerPointerEvents(!0);this.disableClick();return;case P.INK:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick();break;case P.HIGHLIGHT:this.enableTextSelection();this.togglePointerEvents(!1);this.disableClick();break;default:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick()}PointerType.initializeEditor();this.toggleAnnotationLayerPointerEvents(!1);const t=this.div.classList;t.toggle("nonEditing",!1);if(e===P.POPUP)t.toggle("commentEditing",!0);else{t.toggle("commentEditing",!1);for(const i of Ed._.values())t.toggle(`${i._type}Editing`,e===i._editorType)}this.div.hidden=!1}hasTextLayer(e){return e===annotation_editor_layer_classPrivateFieldGet(bd,this)?.div}setEditingState(e){annotation_editor_layer_classPrivateFieldGet(Ad,this).setEditingState(e)}addCommands(e){annotation_editor_layer_classPrivateFieldGet(Ad,this).addCommands(e)}cleanUndoStack(e){annotation_editor_layer_classPrivateFieldGet(Ad,this).cleanUndoStack(e)}toggleDrawing(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("drawing",!e)}togglePointerEvents(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];annotation_editor_layer_classPrivateFieldGet(_d,this)?.togglePointerEvents(e)}async enable(){annotation_editor_layer_classPrivateFieldSet(yd,this,!0);this.div.tabIndex=0;this.togglePointerEvents(!0);this.div.classList.toggle("nonEditing",!1);annotation_editor_layer_classPrivateFieldGet(Sd,this)?.abort();annotation_editor_layer_classPrivateFieldSet(Sd,this,null);const e=new Set;for(const t of annotation_editor_layer_classPrivateGetter(xd,this,_get_allEditorsIterator)){t.enableEditing();t.show(!0);if(t.annotationElementId){annotation_editor_layer_classPrivateFieldGet(Ad,this).removeChangedExistingAnnotation(t);e.add(t.annotationElementId)}}const t=annotation_editor_layer_classPrivateFieldGet(_d,this);if(t)for(const i of t.getEditableAnnotations()){i.hide();if(annotation_editor_layer_classPrivateFieldGet(Ad,this).isDeletedAnnotationElement(i.data.id))continue;if(e.has(i.data.id))continue;const t=await this.deserialize(i);if(t){this.addOrRebuild(t);t.enableEditing()}}annotation_editor_layer_classPrivateFieldSet(yd,this,!1);annotation_editor_layer_classPrivateFieldGet(Ad,this)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){annotation_editor_layer_classPrivateFieldSet(vd,this,!0);this.div.tabIndex=-1;this.togglePointerEvents(!1);this.div.classList.toggle("nonEditing",!0);if(annotation_editor_layer_classPrivateFieldGet(bd,this)&&!annotation_editor_layer_classPrivateFieldGet(Sd,this)){annotation_editor_layer_classPrivateFieldSet(Sd,this,new AbortController);const e=annotation_editor_layer_classPrivateFieldGet(Ad,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(Sd,this));annotation_editor_layer_classPrivateFieldGet(bd,this).div.addEventListener("pointerdown",e=>{const t=e.clientX,i=e.clientY,a=e.timeStamp;if(a-annotation_editor_layer_classPrivateFieldGet(Cd,this)>500){annotation_editor_layer_classPrivateFieldSet(Cd,this,a);return}annotation_editor_layer_classPrivateFieldSet(Cd,this,-1);const s=this.div.classList;s.toggle("getElements",!0);const r=document.elementsFromPoint(t,i);s.toggle("getElements",!1);if(!this.div.contains(r[0]))return;let n;const o=new RegExp(`^${y}[0-9]+$`);for(const e of r)if(o.test(e.id)){n=e.id;break}if(!n)return;const l=annotation_editor_layer_classPrivateFieldGet(fd,this).get(n);if(null===l?.annotationElementId){stopEvent(e);l.dblclick(e)}},{signal:e,capture:!0})}const e=annotation_editor_layer_classPrivateFieldGet(_d,this),t=[];if(e){const i=new Map,a=new Map;for(const e of annotation_editor_layer_classPrivateGetter(xd,this,_get_allEditorsIterator)){e.disableEditing();if(e.annotationElementId)if(null===e.serialize()){a.set(e.annotationElementId,e);this.getEditableAnnotation(e.annotationElementId)?.show();e.remove()}else i.set(e.annotationElementId,e);else t.push(e)}for(const t of e.getEditableAnnotations()){const e=t.data.id;if(annotation_editor_layer_classPrivateFieldGet(Ad,this).isDeletedAnnotationElement(e)){t.updateEdited({deleted:!0});continue}let s=a.get(e);if(s){s.resetAnnotationElement(t);s.show(!1);t.show()}else{s=i.get(e);if(s){annotation_editor_layer_classPrivateFieldGet(Ad,this).addChangedExistingAnnotation(s);s.renderAnnotationElement(t)&&s.show(!1)}t.show()}}}annotation_editor_layer_assertClassBrand(xd,this,_cleanup).call(this);this.isEmpty&&(this.div.hidden=!0);const i=this.div.classList;for(const e of Ed._.values())i.remove(`${e._type}Editing`);this.disableTextSelection();this.toggleAnnotationLayerPointerEvents(!0);e?.updateFakeAnnotations(t);annotation_editor_layer_classPrivateFieldSet(vd,this,!1)}getEditableAnnotation(e){return annotation_editor_layer_classPrivateFieldGet(_d,this)?.getEditableAnnotation(e)||null}setActiveEditor(e){annotation_editor_layer_classPrivateFieldGet(Ad,this).getActive()!==e&&annotation_editor_layer_classPrivateFieldGet(Ad,this).setActiveEditor(e)}enableTextSelection(){this.div.tabIndex=-1;if(annotation_editor_layer_classPrivateFieldGet(bd,this)?.div&&!annotation_editor_layer_classPrivateFieldGet(Fd,this)){annotation_editor_layer_classPrivateFieldSet(Fd,this,new AbortController);const e=annotation_editor_layer_classPrivateFieldGet(Ad,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(Fd,this));annotation_editor_layer_classPrivateFieldGet(bd,this).div.addEventListener("pointerdown",annotation_editor_layer_assertClassBrand(xd,this,_textLayerPointerDown).bind(this),{signal:e});annotation_editor_layer_classPrivateFieldGet(bd,this).div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0;if(annotation_editor_layer_classPrivateFieldGet(bd,this)?.div&&annotation_editor_layer_classPrivateFieldGet(Fd,this)){annotation_editor_layer_classPrivateFieldGet(Fd,this).abort();annotation_editor_layer_classPrivateFieldSet(Fd,this,null);annotation_editor_layer_classPrivateFieldGet(bd,this).div.classList.remove("highlighting")}}enableClick(){if(annotation_editor_layer_classPrivateFieldGet(pd,this))return;annotation_editor_layer_classPrivateFieldSet(pd,this,new AbortController);const e=annotation_editor_layer_classPrivateFieldGet(Ad,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(pd,this));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e});this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){annotation_editor_layer_classPrivateFieldGet(pd,this)?.abort();annotation_editor_layer_classPrivateFieldSet(pd,this,null)}attach(e){annotation_editor_layer_classPrivateFieldGet(fd,this).set(e.id,e);const t=e.annotationElementId;t&&annotation_editor_layer_classPrivateFieldGet(Ad,this).isDeletedAnnotationElement(t)&&annotation_editor_layer_classPrivateFieldGet(Ad,this).removeDeletedAnnotationElement(e)}detach(e){annotation_editor_layer_classPrivateFieldGet(fd,this).delete(e.id);annotation_editor_layer_classPrivateFieldGet(hd,this)?.removePointerInTextLayer(e.contentDiv);!annotation_editor_layer_classPrivateFieldGet(vd,this)&&e.annotationElementId&&annotation_editor_layer_classPrivateFieldGet(Ad,this).addDeletedAnnotationElement(e)}remove(e){this.detach(e);annotation_editor_layer_classPrivateFieldGet(Ad,this).removeEditor(e);e.div.remove();e.isAttachedToDOM=!1}changeParent(e){if(e.parent!==this){if(e.parent&&e.annotationElementId){annotation_editor_layer_classPrivateFieldGet(Ad,this).addDeletedAnnotationElement(e);AnnotationEditor.deleteAnnotationElement(e);e.annotationElementId=null}this.attach(e);e.parent?.detach(e);e.setParent(this);if(e.div&&e.isAttachedToDOM){e.div.remove();this.div.append(e.div)}}}add(e){if(e.parent!==this||!e.isAttachedToDOM){this.changeParent(e);annotation_editor_layer_classPrivateFieldGet(Ad,this).addEditor(e);this.attach(e);if(!e.isAttachedToDOM){const t=e.render();this.div.append(t);e.isAttachedToDOM=!0}e.fixAndSetPosition();e.onceAdded(!annotation_editor_layer_classPrivateFieldGet(yd,this));annotation_editor_layer_classPrivateFieldGet(Ad,this).addToAnnotationStorage(e);e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;const t=document.activeElement;if(e.div.contains(t)&&!annotation_editor_layer_classPrivateFieldGet(gd,this)){e._focusEventsAllowed=!1;annotation_editor_layer_classPrivateFieldSet(gd,this,setTimeout(()=>{annotation_editor_layer_classPrivateFieldSet(gd,this,null);if(e.div.contains(document.activeElement))e._focusEventsAllowed=!0;else{e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:annotation_editor_layer_classPrivateFieldGet(Ad,this)._signal});t.focus()}},0))}e._structTreeParentId=annotation_editor_layer_classPrivateFieldGet(hd,this)?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){if(e.needsToBeRebuilt()){e.parent||=this;e.rebuild();e.show()}else this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getEditorByUID(e){for(const t of annotation_editor_layer_classPrivateFieldGet(fd,this).values())if(t.uid===e)return t;return null}combinedSignal(e){return annotation_editor_layer_classPrivateFieldGet(Ad,this).combinedSignal(e)}canCreateNewEmptyEditor(){return annotation_editor_layer_classPrivateGetter(xd,this,_get_currentEditorType)?.canCreateNewEmptyEditor()}async pasteEditor(e,t){this.updateToolbar(e);await annotation_editor_layer_classPrivateFieldGet(Ad,this).updateMode(e.mode);const i=annotation_editor_layer_assertClassBrand(xd,this,_getCenterPoint).call(this),a=i.offsetX,s=i.offsetY,r=annotation_editor_layer_classPrivateFieldGet(Ad,this).getId(),n=annotation_editor_layer_assertClassBrand(xd,this,_createNewEditor).call(this,{parent:this,id:r,x:a,y:s,uiManager:annotation_editor_layer_classPrivateFieldGet(Ad,this),isCentered:!0,...t});n&&this.add(n)}async deserialize(e){return await(Ed._.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,annotation_editor_layer_classPrivateFieldGet(Ad,this)))||null}createAndAddNewEditor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=annotation_editor_layer_classPrivateFieldGet(Ad,this).getId(),s=annotation_editor_layer_assertClassBrand(xd,this,_createNewEditor).call(this,{parent:this,id:a,x:e.offsetX,y:e.offsetY,uiManager:annotation_editor_layer_classPrivateFieldGet(Ad,this),isCentered:t,eventBus:this.eventBus,...i});s&&this.add(s);return s}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.createAndAddNewEditor(annotation_editor_layer_assertClassBrand(xd,this,_getCenterPoint).call(this),!0,e)}setSelected(e){annotation_editor_layer_classPrivateFieldGet(Ad,this).setSelected(e)}toggleSelected(e){annotation_editor_layer_classPrivateFieldGet(Ad,this).toggleSelected(e)}unselect(e){annotation_editor_layer_classPrivateFieldGet(Ad,this).unselect(e)}pointerup(e){const t=FeatureTest.platform.isMac;if(0!==e.button||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(!annotation_editor_layer_classPrivateFieldGet(md,this))return;annotation_editor_layer_classPrivateFieldSet(md,this,!1);if(annotation_editor_layer_classPrivateGetter(xd,this,_get_currentEditorType)?.isDrawer&&annotation_editor_layer_classPrivateGetter(xd,this,_get_currentEditorType).supportMultipleDrawings)return;if(!annotation_editor_layer_classPrivateFieldGet(ud,this)){annotation_editor_layer_classPrivateFieldSet(ud,this,!0);return}const i=annotation_editor_layer_classPrivateFieldGet(Ad,this).getMode();i!==P.STAMP&&i!==P.POPUP&&i!==P.SIGNATURE?this.createAndAddNewEditor(e,!1):annotation_editor_layer_classPrivateFieldGet(Ad,this).unselectAll()}pointerdown(e){if(annotation_editor_layer_classPrivateFieldGet(Ad,this).getMode()===P.HIGHLIGHT){if(!PointerType.sameAsEditor(e.pointerType))return;this.enableTextSelection()}else if(annotation_editor_layer_classPrivateFieldGet(Ad,this).getMode()===P.INK&&!PointerType.sameAsEditor(e.pointerType))return;if(annotation_editor_layer_classPrivateFieldGet(md,this)){annotation_editor_layer_classPrivateFieldSet(md,this,!1);return}const t=FeatureTest.platform.isMac;if(0!==e.button||e.ctrlKey&&t)return;if(e.target!==this.div)return;annotation_editor_layer_classPrivateFieldSet(md,this,!0);if(annotation_editor_layer_classPrivateGetter(xd,this,_get_currentEditorType)?.isDrawer){this.startDrawingSession(e);return}const i=annotation_editor_layer_classPrivateFieldGet(Ad,this).getActive();annotation_editor_layer_classPrivateFieldSet(ud,this,!i||i.isEmpty())}startDrawingSession(e){this.div.focus({preventScroll:!0});if(annotation_editor_layer_classPrivateFieldGet(Pd,this)){annotation_editor_layer_classPrivateGetter(xd,this,_get_currentEditorType).startDrawing(this,annotation_editor_layer_classPrivateFieldGet(Ad,this),!1,e);return}annotation_editor_layer_classPrivateFieldGet(Ad,this).setCurrentDrawingSession(this);annotation_editor_layer_classPrivateFieldSet(Pd,this,new AbortController);const t=annotation_editor_layer_classPrivateFieldGet(Ad,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(Pd,this));this.div.addEventListener("blur",e=>{let t=e.relatedTarget;if(t&&!this.div.contains(t)){annotation_editor_layer_classPrivateFieldSet(wd,this,null);this.commitOrRemove()}},{signal:t});annotation_editor_layer_classPrivateGetter(xd,this,_get_currentEditorType).startDrawing(this,annotation_editor_layer_classPrivateFieldGet(Ad,this),!1,e)}pause(e){if(e){const e=document.activeElement;this.div.contains(e)&&annotation_editor_layer_classPrivateFieldSet(wd,this,e);return}annotation_editor_layer_classPrivateFieldGet(wd,this)&&setTimeout(()=>{annotation_editor_layer_classPrivateFieldGet(wd,this)?.focus();annotation_editor_layer_classPrivateFieldSet(wd,this,null)},0)}endDrawingSession(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!annotation_editor_layer_classPrivateFieldGet(Pd,this))return null;annotation_editor_layer_classPrivateFieldGet(Ad,this).setCurrentDrawingSession(null);annotation_editor_layer_classPrivateFieldGet(Pd,this).abort();annotation_editor_layer_classPrivateFieldSet(Pd,this,null);annotation_editor_layer_classPrivateFieldSet(wd,this,null);return annotation_editor_layer_classPrivateGetter(xd,this,_get_currentEditorType).endDrawing(e)}findNewParent(e,t,i){const a=annotation_editor_layer_classPrivateFieldGet(Ad,this).findParent(t,i);if(null===a||a===this)return!1;a.changeParent(e);return!0}commitOrRemove(){if(annotation_editor_layer_classPrivateFieldGet(Pd,this)){this.endDrawingSession();return!0}return!1}onScaleChanging(){annotation_editor_layer_classPrivateFieldGet(Pd,this)&&annotation_editor_layer_classPrivateGetter(xd,this,_get_currentEditorType).onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove();if(annotation_editor_layer_classPrivateFieldGet(Ad,this).getActive()?.parent===this){annotation_editor_layer_classPrivateFieldGet(Ad,this).commitOrRemove();annotation_editor_layer_classPrivateFieldGet(Ad,this).setActiveEditor(null)}if(annotation_editor_layer_classPrivateFieldGet(gd,this)){clearTimeout(annotation_editor_layer_classPrivateFieldGet(gd,this));annotation_editor_layer_classPrivateFieldSet(gd,this,null)}for(const e of annotation_editor_layer_classPrivateFieldGet(fd,this).values()){annotation_editor_layer_classPrivateFieldGet(hd,this)?.removePointerInTextLayer(e.contentDiv);e.setParent(null);e.isAttachedToDOM=!1;e.div.remove()}this.div=null;annotation_editor_layer_classPrivateFieldGet(fd,this).clear();annotation_editor_layer_classPrivateFieldGet(Ad,this).removeLayer(this)}async render(e){let t=e.viewport;this.viewport=t;setLayerDimensions(this.div,t);for(const e of annotation_editor_layer_classPrivateFieldGet(Ad,this).getEditors(this.pageIndex)){this.add(e);e.rebuild()}await annotation_editor_layer_classPrivateFieldGet(Ad,this).findClonesForPage(this);this.div.hidden=this.isEmpty;this.updateMode()}update(e){let t=e.viewport;annotation_editor_layer_classPrivateFieldGet(Ad,this).commitOrRemove();annotation_editor_layer_assertClassBrand(xd,this,_cleanup).call(this);const i=this.viewport.rotation,a=t.rotation;this.viewport=t;setLayerDimensions(this.div,{rotation:a});if(i!==a)for(const e of annotation_editor_layer_classPrivateFieldGet(fd,this).values())e.rotate(a)}get pageDimensions(){const e=this.viewport.rawDims;return[e.pageWidth,e.pageHeight]}get scale(){return annotation_editor_layer_classPrivateFieldGet(Ad,this).viewParameters.realScale}}function _get_allEditorsIterator(e){return 0!==annotation_editor_layer_classPrivateFieldGet(fd,e).size?annotation_editor_layer_classPrivateFieldGet(fd,e).values():annotation_editor_layer_classPrivateFieldGet(Ad,e).getEditors(e.pageIndex)}function _textLayerPointerDown(e){annotation_editor_layer_classPrivateFieldGet(Ad,this).unselectAll();const t=e.target;if(t===annotation_editor_layer_classPrivateFieldGet(bd,this).div||("img"===t.getAttribute("role")||t.classList.contains("endOfContent")||t.classList.contains("textLayerImages")||t.classList.contains("textLayerImagePlaceholder"))&&annotation_editor_layer_classPrivateFieldGet(bd,this).div.contains(t)){const t=FeatureTest.platform.isMac;if(0!==e.button||e.ctrlKey&&t)return;annotation_editor_layer_classPrivateFieldGet(Ad,this).showAllEditors("highlight",!0,!0);annotation_editor_layer_classPrivateFieldGet(bd,this).div.classList.add("free");this.toggleDrawing();this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"drawingStarted",editorType:"HighlightEditor"});HighlightEditor.startHighlighting(this,"ltr"===annotation_editor_layer_classPrivateFieldGet(Ad,this).direction,{target:annotation_editor_layer_classPrivateFieldGet(bd,this).div,x:e.x,y:e.y});annotation_editor_layer_classPrivateFieldGet(bd,this).div.addEventListener("pointerup",()=>{annotation_editor_layer_classPrivateFieldGet(bd,this).div.classList.remove("free");this.toggleDrawing(!0);this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"drawingStopped",editorType:"HighlightEditor"})},{once:!0,signal:annotation_editor_layer_classPrivateFieldGet(Ad,this)._signal});e.preventDefault()}}function _get_currentEditorType(e){return Ed._.get(annotation_editor_layer_classPrivateFieldGet(Ad,e).getMode())}function _createNewEditor(e){const t=annotation_editor_layer_classPrivateGetter(xd,this,_get_currentEditorType);return t?new t.prototype.constructor(e):null}function _getCenterPoint(){const e=this.boundingClientRect,t=e.x,i=e.y,a=e.width,s=e.height,r=Math.max(0,t),n=Math.max(0,i),o=(r+Math.min(window.innerWidth,t+a))/2-t,l=(n+Math.min(window.innerHeight,i+s))/2-i,c=annotation_editor_layer_slicedToArray(this.viewport.rotation%180==0?[o,l]:[l,o],2);return{offsetX:c[0],offsetY:c[1]}}function _cleanup(){for(const e of annotation_editor_layer_classPrivateFieldGet(fd,this).values())e.isEmpty()&&e.remove()}annotation_editor_layer_defineProperty(AnnotationEditorLayer,"_initialized",!1);var kd,Ed={_:new Map([FreeTextEditor,InkEditor,StampEditor,HighlightEditor,SignatureEditor].map(e=>[e._editorType,e]))};function draw_layer_slicedToArray(e,t){return function draw_layer_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function draw_layer_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function draw_layer_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return draw_layer_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?draw_layer_arrayLikeToArray(e,t):void 0}}(e,t)||function draw_layer_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function draw_layer_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function draw_layer_classPrivateFieldInitSpec(e,t,i){draw_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function draw_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function draw_layer_classPrivateFieldGet(e,t){return e.get(draw_layer_assertClassBrand(e,t))}function draw_layer_classPrivateFieldSet(e,t,i){return e.set(draw_layer_assertClassBrand(e,t),i),i}function draw_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function compareTextLayers(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function getTextLayer(e){return e?e.nodeType===Node.ELEMENT_NODE?e.closest(".textLayer"):e.parentElement?.closest(".textLayer")||null:null}function isPointBefore(e,t,i,a){if(e===i)return t<=a;const s=e.compareDocumentPosition(i);return!!(s&Node.DOCUMENT_POSITION_FOLLOWING)||!(s&Node.DOCUMENT_POSITION_PRECEDING)&&null}function normalizeEdgeBoundary(e,t,i){if(e.nodeType!==Node.ELEMENT_NODE||!e.classList.contains("textLayer")||t!==e.childNodes.length)return{container:e,offset:t};let a=e.lastChild;a?.nodeType===Node.ELEMENT_NODE&&a.classList.contains("endOfContent")&&(a=a.previousSibling);return a&&i.contains(a)?a.nodeType===Node.TEXT_NODE?{container:a,offset:a.textContent.length}:{container:a,offset:a.childNodes.length}:null}var Td=new WeakMap,Id=new WeakMap,Gd=new WeakMap,Bd=new WeakMap,Md=new WeakMap,Dd=new WeakMap,Ld=new WeakMap,Od=new WeakSet;class DrawLayer{constructor(e){let t=e.filterFactory,i=void 0===t?null:t,a=e.pageColors,s=void 0===a?null:a,r=e.pageIndex,n=e.textLayer,o=void 0===n?null:n;!function draw_layer_classPrivateMethodInitSpec(e,t){draw_layer_checkPrivateRedeclaration(e,t),t.add(e)}(this,Od);draw_layer_classPrivateFieldInitSpec(this,Td,null);draw_layer_classPrivateFieldInitSpec(this,Id,new Map);draw_layer_classPrivateFieldInitSpec(this,Gd,null);draw_layer_classPrivateFieldInitSpec(this,Bd,null);draw_layer_classPrivateFieldInitSpec(this,Md,null);draw_layer_classPrivateFieldInitSpec(this,Dd,null);draw_layer_classPrivateFieldInitSpec(this,Ld,new Map);this.pageIndex=r;draw_layer_classPrivateFieldSet(Bd,this,i);draw_layer_classPrivateFieldSet(Md,this,s);if(o){const e=Hd._.get(o);if(e?.selectionDiv){e.selectionDiv.remove();Wd._.delete(e.selectionDiv)}Hd._.set(o,{drawLayer:this});Vd._.add(o);draw_layer_classPrivateFieldSet(Gd,this,o);draw_layer_classPrivateFieldSet(Dd,this,new MutationObserver(e=>{if(draw_layer_classPrivateFieldGet(Td,this)&&draw_layer_classPrivateFieldGet(Gd,this)?.isConnected&&_hasSelection.call(DrawLayer))for(const t of e){const e=t.addedNodes;for(const t of e)if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains("endOfContent")){draw_layer_selectionChange.call(DrawLayer);return}}}));draw_layer_classPrivateFieldGet(Dd,this).observe(o,{childList:!0});if(null===jd._){jd._=new AbortController;const e=jd._.signal;document.addEventListener("selectionchange",draw_layer_selectionChange.bind(DrawLayer),{signal:e});document.addEventListener("pointerdown",()=>{Ud._=!0},{signal:e});document.addEventListener("pointerup",()=>{Ud._=!1},{signal:e});window.addEventListener("blur",()=>{Ud._=!1},{signal:e})}}}setParent(e){if(draw_layer_classPrivateFieldGet(Td,this)){if(draw_layer_classPrivateFieldGet(Td,this)!==e){if(draw_layer_classPrivateFieldGet(Id,this).size>0)for(const t of draw_layer_classPrivateFieldGet(Id,this).values()){t.remove();e.append(t)}draw_layer_classPrivateFieldSet(Td,this,e)}}else{draw_layer_classPrivateFieldSet(Td,this,e);draw_layer_classPrivateFieldGet(Gd,this)?.isConnected&&_hasSelection.call(DrawLayer)&&draw_layer_selectionChange.call(DrawLayer)}}static get _svgFactory(){return shadow(this,"_svgFactory",new DOMSVGFactory)}draw(e){var t,i;let a=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=(Rd._=(t=Rd._,i=t++,t),i),n=draw_layer_assertClassBrand(Od,this,_createSVG).call(this),o=DrawLayer._svgFactory.createElement("defs");n.append(o);const l=DrawLayer._svgFactory.createElement("path");o.append(l);const c=`path_${r}`;l.setAttribute("id",c);l.setAttribute("vector-effect","non-scaling-stroke");a&&draw_layer_classPrivateFieldGet(Ld,this).set(r,l);const d=s?draw_layer_assertClassBrand(Od,this,_createClipPath).call(this,o,c):null,h=DrawLayer._svgFactory.createElement("use");n.append(h);h.setAttribute("href",`#${c}`);this.updateProperties(n,e);draw_layer_classPrivateFieldGet(Id,this).set(r,n);return{id:r,clipPathId:`url(#${d})`}}drawOutline(e,t){var i,a;const s=(Rd._=(i=Rd._,a=i++,i),a),r=draw_layer_assertClassBrand(Od,this,_createSVG).call(this),n=DrawLayer._svgFactory.createElement("defs");r.append(n);const o=DrawLayer._svgFactory.createElement("path");n.append(o);const l=`path_${s}`;o.setAttribute("id",l);o.setAttribute("vector-effect","non-scaling-stroke");let c;if(t){const e=DrawLayer._svgFactory.createElement("mask");n.append(e);c=`mask_${s}`;e.setAttribute("id",c);e.setAttribute("maskUnits","objectBoundingBox");const t=DrawLayer._svgFactory.createElement("rect");e.append(t);t.setAttribute("width","1");t.setAttribute("height","1");t.setAttribute("fill","white");const i=DrawLayer._svgFactory.createElement("use");e.append(i);i.setAttribute("href",`#${l}`);i.setAttribute("stroke","none");i.setAttribute("fill","black");i.setAttribute("fill-rule","nonzero");i.classList.add("mask")}const d=DrawLayer._svgFactory.createElement("use");r.append(d);d.setAttribute("href",`#${l}`);c&&d.setAttribute("mask",`url(#${c})`);const h=d.cloneNode();r.append(h);d.classList.add("mainOutline");h.classList.add("secondaryOutline");this.updateProperties(r,e);draw_layer_classPrivateFieldGet(Id,this).set(s,r);return s}finalizeDraw(e,t){draw_layer_classPrivateFieldGet(Ld,this).delete(e);this.updateProperties(e,t)}updateProperties(e,t){if(!t)return;const i=t.root,a=t.bbox,s=t.rootClass,r=t.path,n="number"==typeof e?draw_layer_classPrivateFieldGet(Id,this).get(e):e;if(n){i&&draw_layer_assertClassBrand(Od,this,_updateProperties).call(this,n,i);a&&_setBox.call(DrawLayer,n,a);if(s){const e=n.classList;for(const t of Object.entries(s)){var o=draw_layer_slicedToArray(t,2);const i=o[0],a=o[1];e.toggle(i,a)}}if(r){const e=n.firstElementChild.firstElementChild;draw_layer_assertClassBrand(Od,this,_updateProperties).call(this,e,r)}}}updateParent(e,t){if(t===this)return;const i=draw_layer_classPrivateFieldGet(Id,this).get(e);if(i){draw_layer_classPrivateFieldGet(Td,t).append(i);draw_layer_classPrivateFieldGet(Id,this).delete(e);draw_layer_classPrivateFieldGet(Id,t).set(e,i)}}remove(e){draw_layer_classPrivateFieldGet(Ld,this).delete(e);if(null!==draw_layer_classPrivateFieldGet(Td,this)){draw_layer_classPrivateFieldGet(Id,this).get(e).remove();draw_layer_classPrivateFieldGet(Id,this).delete(e)}}destroy(){draw_layer_classPrivateFieldSet(Td,this,null);for(const e of draw_layer_classPrivateFieldGet(Id,this).values())e.remove();draw_layer_classPrivateFieldGet(Id,this).clear();draw_layer_classPrivateFieldGet(Ld,this).clear();draw_layer_classPrivateFieldGet(Dd,this)?.disconnect();draw_layer_classPrivateFieldSet(Dd,this,null);if(draw_layer_classPrivateFieldGet(Gd,this)){const e=Hd._.get(draw_layer_classPrivateFieldGet(Gd,this));if(e?.drawLayer===this){_cleanupTextLayerSelection.call(DrawLayer,draw_layer_classPrivateFieldGet(Gd,this));Hd._.delete(draw_layer_classPrivateFieldGet(Gd,this));Vd._.delete(draw_layer_classPrivateFieldGet(Gd,this));if(0===Vd._.size){jd._?.abort();jd._=null;Ud._=!1}}draw_layer_classPrivateFieldSet(Gd,this,null)}}}kd=DrawLayer;function _cleanupTextLayerSelection(e){const t=draw_layer_assertClassBrand(kd,this,Hd)._.get(e);if(t?.selectionDiv){t.selectionDiv.remove();draw_layer_assertClassBrand(kd,this,Wd)._.delete(t.selectionDiv);t.selectionDiv=null;t.path=null}}function _hasSelection(){const e=document.getSelection();return!!e&&!e.isCollapsed}function _getOrderedTextLayers(){return[...draw_layer_assertClassBrand(kd,this,Vd)._].filter(e=>e.isConnected).sort(compareTextLayers)}function draw_layer_selectionChange(){const e=document.getSelection();if(!e||e.isCollapsed){for(const e of draw_layer_assertClassBrand(kd,this,Wd)._)e.remove();draw_layer_assertClassBrand(kd,this,Wd)._.clear();return}const t=new WeakMap,i=draw_layer_assertClassBrand(kd,this,_getOrderedTextLayers).call(this),a=[];for(let t=0,s=e.rangeCount;t<s;t++){const s=e.getRangeAt(t);if(s.collapsed)continue;let r=s.startContainer,n=s.startOffset,o=s.endContainer,l=s.endOffset,c=getTextLayer(r),d=getTextLayer(o);const h=null===c,u=null===d;if(draw_layer_assertClassBrand(kd,this,Ud)._&&h!==u)return;if(1===e.rangeCount){const t=e.anchorNode,i=e.anchorOffset,a=e.focusNode,s=e.focusOffset,h=getTextLayer(t),u=getTextLayer(a),_=isPointBefore(t,i,a,s);if(h&&u&&null!==_)if(_){r=t;n=i;c=h;o=a;l=s;d=u}else{r=a;n=s;c=u;o=t;l=i;d=h}}const _=i.filter(e=>s.intersectsNode(e));if(0===_.length)continue;let p=!1;if(!c){c=_[0];r=c;n=0;p=!0}if(!d){d=_.at(-1);o=d;l=d.childNodes.length;p=!0}if(o.nodeType===Node.ELEMENT_NODE)if(o.classList.contains("endOfContent")){const e=o.previousSibling;if(!e)continue;o=e;l=e.nodeType===Node.TEXT_NODE?e.textContent.length:e.childNodes.length}else if(o.classList.contains("textLayer")&&o.childNodes.length===l){const e=normalizeEdgeBoundary(o,l,d);if(!e)continue;o=e.container;l=e.offset}if(r.nodeType===Node.ELEMENT_NODE){const e=normalizeEdgeBoundary(r,n,c);if(!e)continue;r=e.container;n=e.offset}if(c!==d||p||!_.includes(c))for(const e of _){const t=e.firstChild;if(!t)continue;const i=document.createRange();e===c?i.setStart(r,n):i.setStartBefore(t);if(e===d)i.setEnd(o,l);else{const t=e.lastChild;if(!t)continue;if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains("endOfContent")){const e=t.previousSibling;if(!e)continue;i.setEndAfter(e)}else i.setEndAfter(t)}i.collapsed||a.push([i,e])}else a.push([s,c])}const s=new Set(a.map(e=>e[1]));for(const e of draw_layer_assertClassBrand(kd,this,Vd)._)s.has(e)||draw_layer_assertClassBrand(kd,this,_cleanupTextLayerSelection).call(this,e);for(const e of a){var r=draw_layer_slicedToArray(e,2);const i=r[0],a=r[1],s=Hd._.get(a);if(!s)continue;let d=t.get(a);if(!d){const e=a.getBoundingClientRect();d=(t,i,a,s)=>({x:(t-e.x)/e.width,y:(i-e.y)/e.height,width:a/e.width,height:s/e.height});t.set(a,d)}const h=[];for(let e of i.getClientRects()){let t=e.x,i=e.y,a=e.width,s=e.height;if(0!==a&&0!==s){var n=d(t,i,a,s);t=n.x;i=n.y;a=n.width;s=n.height;1===a&&1===s||h.push(`M${t} ${i} h${a} v${s} h-${a} Z`)}}if(0===h.length)continue;const u=s.drawLayer;let _=s.selectionDiv,p=s.path;if(!_){var o,l;const e=`clip_selection_${Nd._=(o=Nd._,l=o++,o),l}`;_=document.createElement("div");_.className="selection";_.style.clipPath=`url(#${e})`;const t=draw_layer_classPrivateFieldGet(Bd,u)?.createSelectionStyle(draw_layer_classPrivateFieldGet(Md,u));if(t)for(const e of Object.entries(t)){var c=draw_layer_slicedToArray(e,2);const t=c[0],i=c[1];_.style.setProperty(t,i)}const i=kd._svgFactory.create(1,1,!0);i.setAttribute("aria-hidden","true");i.setAttribute("width","100%");i.setAttribute("height","100%");const a=kd._svgFactory.createElement("clipPath");a.setAttribute("id",e);a.setAttribute("clipPathUnits","objectBoundingBox");p=kd._svgFactory.createElement("path");a.append(p);i.append(a);_.append(i);s.path=p;s.selectionDiv=_}if(!_.parentNode&&draw_layer_classPrivateFieldGet(Td,u)){draw_layer_classPrivateFieldGet(Td,u).append(_);draw_layer_assertClassBrand(kd,this,Wd)._.add(_)}p.setAttribute("d",h.join(" "))}}function _setBox(e,t){let i=draw_layer_slicedToArray(t,4),a=i[0],s=i[1],r=i[2],n=i[3];const o=e.style;o.top=100*s+"%";o.left=100*a+"%";o.width=100*r+"%";o.height=100*n+"%"}function _createSVG(){const e=kd._svgFactory.create(1,1,!0);draw_layer_classPrivateFieldGet(Td,this).append(e);e.setAttribute("aria-hidden","true");return e}function _createClipPath(e,t){const i=kd._svgFactory.createElement("clipPath");e.append(i);const a=`clip_${t}`;i.setAttribute("id",a);i.setAttribute("clipPathUnits","objectBoundingBox");const s=kd._svgFactory.createElement("use");i.append(s);s.setAttribute("href",`#${t}`);s.classList.add("clip");return a}function _updateProperties(e,t){for(const a of Object.entries(t)){var i=draw_layer_slicedToArray(a,2);const t=i[0],s=i[1];null===s?e.removeAttribute(t):e.setAttribute(t,s)}}var Rd={_:0},Nd={_:0},jd={_:null},Wd={_:new Set},Ud={_:!1},Vd={_:new Set},Hd={_:new WeakMap};function text_layer_images_slicedToArray(e,t){return function text_layer_images_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function text_layer_images_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function text_layer_images_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return text_layer_images_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?text_layer_images_arrayLikeToArray(e,t):void 0}}(e,t)||function text_layer_images_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function text_layer_images_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function text_layer_images_classPrivateFieldInitSpec(e,t,i){text_layer_images_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_layer_images_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_layer_images_classPrivateFieldGet(e,t){return e.get(text_layer_images_assertClassBrand(e,t))}function text_layer_images_classPrivateFieldSet(e,t,i){return e.set(text_layer_images_assertClassBrand(e,t),i),i}function text_layer_images_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function percentage(e){return`${(100*e).toFixed(2)}%`}var zd=new WeakMap,$d=new WeakMap,qd=new WeakMap,Xd=new WeakMap,Kd=new WeakMap,Yd=new WeakMap,Zd=new WeakSet;class TextLayerImages{constructor(e,t,i,a){!function text_layer_images_classPrivateMethodInitSpec(e,t){text_layer_images_checkPrivateRedeclaration(e,t),t.add(e)}(this,Zd);text_layer_images_classPrivateFieldInitSpec(this,zd,[]);text_layer_images_classPrivateFieldInitSpec(this,$d,new Map);text_layer_images_classPrivateFieldInitSpec(this,qd,null);text_layer_images_classPrivateFieldInitSpec(this,Xd,0);text_layer_images_classPrivateFieldInitSpec(this,Kd,0);text_layer_images_classPrivateFieldInitSpec(this,Yd,0);text_layer_images_classPrivateFieldSet(Xd,this,e);text_layer_images_classPrivateFieldSet(zd,this,t);text_layer_images_classPrivateFieldSet(Kd,this,i.rawDims.pageWidth);text_layer_images_classPrivateFieldSet(Yd,this,i.rawDims.pageHeight);text_layer_images_classPrivateFieldSet(qd,this,a)}render(){const e=document.createElement("div");e.className="textLayerImages";for(let t=0;t<text_layer_images_classPrivateFieldGet(zd,this).length;t+=6){const i=text_layer_images_assertClassBrand(Zd,this,_createImagePlaceholder).call(this,text_layer_images_classPrivateFieldGet(zd,this).subarray(t,t+6));i&&e.append(i)}e.addEventListener("contextmenu",e=>{if(!(e.target instanceof HTMLCanvasElement))return;const t=e.target,i=text_layer_images_classPrivateFieldGet($d,this).get(t);if(!i)return;const a=Jd._?.deref();if(a===t)return;if(a){a.width=0;a.height=0}Jd._=new WeakRef(t);const s=i.inverseTransform,r=i.x1,n=i.y1,o=i.width,l=i.height,c=text_layer_images_classPrivateFieldGet(qd,this).call(this),d=Math.ceil(r*c.width),h=Math.ceil(n*c.height),u=Math.floor((r+o/text_layer_images_classPrivateFieldGet(Kd,this))*c.width),_=Math.floor((n+l/text_layer_images_classPrivateFieldGet(Yd,this))*c.height);t.width=u-d;t.height=_-h;const p=t.getContext("2d");p.setTransform(...s);p.translate(-d,-h);p.drawImage(c,0,0)});return e}}function _createImagePlaceholder(e){let t=text_layer_images_slicedToArray(e,6),i=t[0],a=t[1],s=t[2],r=t[3],n=t[4],o=t[5];const l=Math.hypot((n-i)*text_layer_images_classPrivateFieldGet(Kd,this),(o-a)*text_layer_images_classPrivateFieldGet(Yd,this)),c=Math.hypot((s-i)*text_layer_images_classPrivateFieldGet(Kd,this),(r-a)*text_layer_images_classPrivateFieldGet(Yd,this));if(l<text_layer_images_classPrivateFieldGet(Xd,this)||c<text_layer_images_classPrivateFieldGet(Xd,this))return null;const d=[(n-i)*text_layer_images_classPrivateFieldGet(Kd,this)/l,(o-a)*text_layer_images_classPrivateFieldGet(Yd,this)/l,(s-i)*text_layer_images_classPrivateFieldGet(Kd,this)/c,(r-a)*text_layer_images_classPrivateFieldGet(Yd,this)/c,0,0],h=Util.inverseTransform(d),u=document.createElement("canvas");u.className="textLayerImagePlaceholder";u.width=0;u.height=0;Object.assign(u.style,{opacity:0,position:"absolute",left:percentage(i),top:percentage(a),width:percentage(l/text_layer_images_classPrivateFieldGet(Kd,this)),height:percentage(c/text_layer_images_classPrivateFieldGet(Yd,this)),transformOrigin:"0% 0%",transform:`matrix(${d.join(",")})`});text_layer_images_classPrivateFieldGet($d,this).set(u,{inverseTransform:h,width:l,height:c,x1:i,y1:a});return u}var Jd={_:null};globalThis._pdfjsTestingUtils={HighlightOutliner};globalThis.pdfjsLib={AbortException,AnnotationEditorLayer,AnnotationEditorParamsType:w,AnnotationEditorType:P,AnnotationEditorUIManager,AnnotationLayer,AnnotationMode:m,AnnotationType:I,applyOpacity,build:zn,ColorPicker,createValidAbsoluteUrl,CSSConstants,DOMSVGFactory,DrawLayer,FeatureTest,fetchData,findContrastColor,getDocument,getFilenameFromUrl:function getFilenameFromUrl(e){var t=e.split(/[#?]/,1);return stripPath(e=display_utils_slicedToArray(t,1)[0])},getPdfFilenameFromUrl,getRGB,getRGBA,getUuid,GlobalWorkerOptions,ImageKind:T,InvalidPDFException,isDataScheme,isPdfFile,isValidExplicitDest:es,makeArr,makeMap,makeObj,MathClamp,noContextMenu,normalizeUnicode,OPS:R,OutputScale,PasswordResponses:H,PDFDataRangeTransport,PDFDateString,PDFWorker,PermissionFlag:b,PixelsPerInch,RenderingCancelledException,renderRichText,ResponseException,setLayerDimensions,shadow,SignatureExtractor,stopEvent,SupportedImageMimeTypes:J,TextLayer,TextLayerImages,TouchManager,updateUrlHash,Util,VerbosityLevel:O,version:Hn,XfaLayer};function ui_utils_classPrivateFieldInitSpec(e,t,i){(function ui_utils_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function ui_utils_classPrivateFieldGet(e,t){return e.get(ui_utils_assertClassBrand(e,t))}function ui_utils_classPrivateFieldSet(e,t,i){return e.set(ui_utils_assertClassBrand(e,t),i),i}function ui_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function ui_utils_slicedToArray(e,t){return function ui_utils_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function ui_utils_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function ui_utils_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return ui_utils_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?ui_utils_arrayLikeToArray(e,t):void 0}}(e,t)||function ui_utils_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ui_utils_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}const Qd="auto",eh=.1,th=0,ih=1,ah=2,sh=3,rh=-1,nh=0,oh=1,lh=2,ch=3,dh=4,hh=0,uh=1,_h=2,ph={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},gh={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2},fh=0,mh=1,vh=-3,yh=/\bprint\s*\(/;let Ph=null;function cancelPendingHiddenScroll(){if(Ph){for(const e of Ph.observers)e.disconnect();clearInterval(Ph.pollInterval);clearTimeout(Ph.watchdog);Ph=null}}function scrollIntoView(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(e.classList.contains("stf__item")||e.parentElement?.classList.contains("stf__item")||e.parentElement?.parentElement?.classList.contains("stf__item"))return;if(a){setTimeout(()=>{let i=e.parentElement;for(;i&&i!==document.body&&i!==document.documentElement;){const a=getComputedStyle(i).overflowY;if(("auto"===a||"scroll"===a)&&i.scrollHeight>i.clientHeight){const a=e.getBoundingClientRect(),s=i.getBoundingClientRect();let r=i.scrollTop+(a.top-s.top),n=i.scrollLeft+(a.left-s.left);if(t){void 0!==t.top&&(r+=t.top);void 0!==t.left&&(n+=t.left)}i.scrollTop=r;void 0!==t?.left&&(i.scrollLeft=n);return}i=i.parentElement}const a=e.getBoundingClientRect();let s=window.scrollY+a.top;void 0!==t?.top&&(s+=t.top);window.scrollTo(window.scrollX,s)},0);return}let s=e.offsetParent;if(!s){cancelPendingHiddenScroll();if(!e.isConnected){ngx_console_NgxConsole.warn("offsetParent is not set -- cannot scroll viewer (element is not attached)");return}ngx_console_NgxConsole.warn("offsetParent is not set -- scroll deferred until viewer becomes visible");let s=t,r=i,n=a;const tryReplay=()=>{if(!e.isConnected){cancelPendingHiddenScroll();return}if(!e.offsetParent)return;const t=s,i=r,a=n;s=null;r=null;n=null;cancelPendingHiddenScroll();requestAnimationFrame(()=>{requestAnimationFrame(()=>{scrollIntoView(e,t,i,a)})})},o=[];if("undefined"!=typeof ResizeObserver){const t=new ResizeObserver(tryReplay);t.observe(e);o.push(t)}if("undefined"!=typeof IntersectionObserver){const t=new IntersectionObserver(tryReplay,{rootMargin:"99999px"});t.observe(e);o.push(t)}const l=setInterval(tryReplay,250),c=setTimeout(()=>{s=null;r=null;n=null;cancelPendingHiddenScroll()},1e4);Ph={observers:o,pollInterval:l,watchdog:c};return}let r=e.offsetTop+e.clientTop,n=e.offsetLeft+e.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth;){r+=s.offsetTop;n+=s.offsetLeft;s=s.offsetParent;if(!s)return}if("viewer"===s.id&&s.offsetParent){const e=s.offsetParent,t=getComputedStyle(e);if("auto"===t.overflow||"scroll"===t.overflow||"auto"===t.overflowX||"scroll"===t.overflowX){r+=s.offsetTop;n+=s.offsetLeft;s=e}}if(t){void 0!==t.top&&(r+=t.top);if(void 0!==t.left){n+=t.left;s.scrollLeft=n}}else if(function isDivInViewport(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}(e))return;s.scrollTop=r}function watchScroll(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;const debounceScroll=function(i){s||(s=window.requestAnimationFrame(function viewAreaElementScrolled(){s=null;const i=e.scrollLeft,r=a.lastX;i!==r&&(a.right=i>r);a.lastX=i;const n=e.scrollTop,o=a.lastY;n!==o&&(a.down=n>o);a.lastY=n;t(a)}))},a={right:!0,down:!0,lastX:e.scrollLeft,lastY:e.scrollTop,_eventHandler:debounceScroll};let s=null;e.addEventListener("scroll",debounceScroll,{useCapture:!0,signal:i});i?.addEventListener("abort",()=>window.cancelAnimationFrame(s),{once:!0});return a}function parseQueryString(e){const t=new Map;for(const a of new URLSearchParams(e)){var i=ui_utils_slicedToArray(a,2);const e=i[0],s=i[1];t.set(e.toLowerCase(),s)}return t}const wh=/[\x00-\x1F]/g;function removeNullCharacters(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return wh.test(e)?t?e.replaceAll(wh,e=>"\0"===e?"":" "):e.replaceAll("\0",""):e}function binarySearchFirstItem(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=e.length-1;if(a<0||!t(e[a]))return e.length;if(t(e[i]))return i;for(;i<a;){const s=i+a>>1;t(e[s])?a=s:i=s+1}return i}function approximateFraction(e){if(Math.floor(e)===e)return[e,1];const t=1/e;if(t>8)return[1,8];if(Math.floor(t)===t)return[1,t];const i=e>1?t:e;let a=0,s=1,r=1,n=1;for(;;){const e=a+r,t=s+n;if(t>8)break;if(i<=e/t){r=e;n=t}else{a=e;s=t}}return i-a/s<r/n-i?i===e?[a,s]:[s,a]:i===e?[r,n]:[n,r]}function floorToDivide(e,t){return e-e%t}function getVisibleElements(e){let t=e.scrollEl,i=e.views,a=e.sortByVisibility,s=void 0!==a&&a,r=e.horizontal,n=void 0!==r&&r,o=e.rtl,l=void 0!==o&&o;const c=t.scrollTop,d=c+t.clientHeight,h=t.scrollLeft,u=h+t.clientWidth;const _=[],p=new Set,g=i.length;let f=binarySearchFirstItem(i,n?function isElementNextAfterViewHorizontally(e){const t=e.div,i=t.offsetLeft+t.clientLeft,a=i+t.clientWidth;return l?i<u:a>h}:function isElementBottomAfterViewTop(e){const t=e.div;return t.offsetTop+t.clientTop+t.clientHeight>c});f>0&&f<g&&!n&&(f=function backtrackBeforeAllVisibleElements(e,t,i){if(e<2)return e;let a=t[e].div,s=a.offsetTop+a.clientTop;if(s>=i){a=t[e-1].div;s=a.offsetTop+a.clientTop}for(let i=e-2;i>=0;--i){a=t[i].div;if(a.offsetTop+a.clientTop+a.clientHeight<=s)break;e=i}return e}(f,i,c));let m=n?u:-1;for(let e=f;e<g;e++){const t=i[e],a=t.div,s=a.offsetLeft+a.clientLeft,r=a.offsetTop+a.clientTop,o=a.clientWidth,l=a.clientHeight,g=s+o,f=r+l;if(-1===m)f>=d&&(m=f);else if((n?s:r)>m)break;if(f<=c||r>=d||g<=h||s>=u)continue;const v=Math.max(0,c-r),y=Math.max(0,h-s),P=v+Math.max(0,f-d),w=(o-(y+Math.max(0,g-u)))/o,b=(l-P)/l*w*100|0;_.push({id:t.id,x:s,y:r,visibleArea:100===b?null:{minX:y,minY:v,maxX:Math.min(g,u)-s,maxY:Math.min(f,d)-r},view:t,percent:b,widthPercent:100*w|0});p.add(t.id)}const v=_[0],y=_.at(-1);s&&_.sort(function(e,t){const i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id});return{first:v,last:y,views:_,ids:p}}function normalizeWheelEventDirection(e){let t=Math.hypot(e.deltaX,e.deltaY);const i=Math.atan2(e.deltaY,e.deltaX);-.25*Math.PI<i&&i<.75*Math.PI&&(t=-t);return t}function isValidRotation(e){return Number.isInteger(e)&&e%90==0}function isValidScrollMode(e){return Number.isInteger(e)&&Object.values(ph).includes(e)&&e!==ph.UNKNOWN}function isValidSpreadMode(e){return Number.isInteger(e)&&Object.values(gh).includes(e)&&e!==gh.UNKNOWN}function isPortraitOrientation(e){return e.width<=e.height}const bh=new Promise(function(e){window.requestAnimationFrame(e)}),Fh=document.documentElement.style;var Sh=new WeakMap,Ch=new WeakMap,Ah=new WeakMap,xh=new WeakMap,kh=new WeakMap;class ProgressBar{constructor(e){ui_utils_classPrivateFieldInitSpec(this,Sh,null);ui_utils_classPrivateFieldInitSpec(this,Ch,null);ui_utils_classPrivateFieldInitSpec(this,Ah,0);ui_utils_classPrivateFieldInitSpec(this,xh,null);ui_utils_classPrivateFieldInitSpec(this,kh,!0);ui_utils_classPrivateFieldSet(Sh,this,e.classList);ui_utils_classPrivateFieldSet(xh,this,e.style)}get percent(){return ui_utils_classPrivateFieldGet(Ah,this)}set percent(e){ui_utils_classPrivateFieldSet(Ah,this,e);if(isNaN(e))ui_utils_classPrivateFieldGet(Sh,this).add("indeterminate");else{ui_utils_classPrivateFieldGet(Sh,this).remove("indeterminate");ui_utils_classPrivateFieldGet(xh,this).setProperty("--progressBar-percent",`${ui_utils_classPrivateFieldGet(Ah,this)}%`)}}setWidth(e){if(!e)return;const t=e.parentNode.offsetWidth-e.offsetWidth;t>0&&ui_utils_classPrivateFieldGet(xh,this).setProperty("--progressBar-end-offset",`${t}px`)}setDisableAutoFetch(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;if(100!==ui_utils_classPrivateFieldGet(Ah,this)&&!isNaN(ui_utils_classPrivateFieldGet(Ah,this))){ui_utils_classPrivateFieldGet(Ch,this)&&clearTimeout(ui_utils_classPrivateFieldGet(Ch,this));this.show();ui_utils_classPrivateFieldSet(Ch,this,setTimeout(()=>{ui_utils_classPrivateFieldSet(Ch,this,null);this.hide()},e))}}hide(){if(ui_utils_classPrivateFieldGet(kh,this)){ui_utils_classPrivateFieldSet(kh,this,!1);ui_utils_classPrivateFieldGet(Sh,this).add("hidden")}}show(){if(!ui_utils_classPrivateFieldGet(kh,this)){ui_utils_classPrivateFieldSet(kh,this,!0);ui_utils_classPrivateFieldGet(Sh,this).remove("hidden")}}}function getActiveOrFocusedElement(){let e=document,t=e.activeElement||e.querySelector(":focus");for(;t?.shadowRoot;){e=t.shadowRoot;t=e.activeElement||e.querySelector(":focus")}return t}function apiPageLayoutToViewerModes(e){let t=ph.VERTICAL,i=gh.NONE;switch(e){case"SinglePage":t=ph.PAGE;break;case"OneColumn":break;case"TwoPageLeft":t=ph.PAGE;case"TwoColumnLeft":i=gh.ODD;break;case"TwoPageRight":t=ph.PAGE;case"TwoColumnRight":i=gh.EVEN}return{scrollMode:t,spreadMode:i}}function toggleCheckedBtn(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;e.classList.toggle("toggled",t);e.setAttribute("aria-checked",t);i?.classList.toggle("hidden",!t)}function toggleSelectedBtn(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;e.classList.toggle("selected",t);e.setAttribute("aria-selected",t);i?.classList.toggle("hidden",!t)}function toggleExpandedBtn(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;e?.classList.toggle("toggled",t);e?.setAttribute("aria-expanded",t);i?.classList.toggle("hidden",!t);if(i&&!i.classList.contains("hidden")){const t=e.getBoundingClientRect(),a=e.closest("#toolbarViewer");if(a){const e=a.getBoundingClientRect().right-t.right;i.style.removeProperty("inset-inline-end");i.style.setProperty("inset-inline-end",e+"px")}}}const Eh=function(){const e=document.createElement("div");e.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)";return"calc(1320px)"===e.style.width?Math.fround:e=>e}();const Th="403220b8-c231-4993-9821-9c57ccbbb137",Ih=Object.freeze({internal:Th});function pdf_link_service_slicedToArray(e,t){return function pdf_link_service_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_link_service_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_link_service_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_link_service_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_link_service_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_link_service_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_link_service_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pdf_link_service_defineProperty(e,t,i){return(t=function pdf_link_service_toPropertyKey(e){var t=function pdf_link_service_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const Gh={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class PDFLinkService{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.eventBus,i=e.externalLinkTarget,a=void 0===i?null:i,s=e.externalLinkRel,r=void 0===s?null:s,n=e.ignoreDestinationZoom,o=void 0!==n&&n;pdf_link_service_defineProperty(this,"externalLinkEnabled",!0);this.eventBus=t;this.externalLinkTarget=a;this.externalLinkRel=r;this._ignoreDestinationZoom=o;this.baseUrl=null;this.pdfDocument=null;this.pdfViewer=null;this.pdfHistory=null}setDocument(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.baseUrl=t;this.pdfDocument=e}setViewer(e){this.pdfViewer=e}setHistory(e){this.pdfHistory=e}get pagesCount(){return this.pdfDocument?.pagesMapper.pagesNumber||0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(e){this.pdfDocument&&(this.pdfViewer.currentPageNumber=e)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(e){this.pdfDocument&&(this.pdfViewer.pagesRotation=e)}get isInPresentationMode(){return!!this.pdfDocument&&this.pdfViewer.isInPresentationMode}async goToDestination(e){if(!this.pdfDocument)return;let t,i,a;if("string"==typeof e){t=e;i=await this.pdfDocument.getDestination(e)}else{t=null;i=await e}if(!Array.isArray(i)){console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${e}".`);return}const s=pdf_link_service_slicedToArray(i,1)[0];if(s&&"object"==typeof s){a=this.pdfDocument.cachedPageNumber(s);if(!a)try{a=await this.pdfDocument.getPageIndex(s)+1}catch{ngx_console_NgxConsole.error(`goToDestination: "${s}" is not a valid page reference, for dest="${e}".`);return}}else Number.isInteger(s)&&(a=s+1);if(!a||a<1||a>this.pagesCount){ngx_console_NgxConsole.error(`goToDestination: "${a}" is not a valid page number, for dest="${e}".`);return}if(this.pdfHistory){this.pdfHistory.pushCurrentPosition();this.pdfHistory.push({namedDest:t,explicitDest:i,pageNumber:a})}if("book"===this.pdfViewer.pageViewMode&&this.pdfViewer.pageFlip){this.pdfViewer.ensureAdjacentPagesAreLoaded();this.pdfViewer.pageFlip.flip(a-1)}else this.pdfViewer.scrollPageIntoView({pageNumber:a,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom});const r=new AbortController;this.eventBus.on("textlayerrendered",e=>{if(e.pageNumber===a){e.source.textLayer.div.focus();r.abort()}},{signal:r.signal,...Ih})}goToPage(e){if(!this.pdfDocument)return;const t="string"==typeof e&&this.pdfViewer.pageLabelToPageNumber(e)||0|e;if(Number.isInteger(t)&&t>0&&t<=this.pagesCount){if(this.pdfHistory){this.pdfHistory.pushCurrentPosition();this.pdfHistory.pushPage(t)}this.pdfViewer.scrollPageIntoView({pageNumber:t})}else ngx_console_NgxConsole.error(`PDFLinkService.goToPage: "${e}" is not a valid page.`)}goToXY(e,t,i){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};this.pdfViewer.scrollPageIntoView({pageNumber:e,destArray:[null,{name:"XYZ"},t,i],ignoreDestinationZoom:!0,...a})}addLinkAttributes(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!t||"string"!=typeof t)throw new Error('A valid "url" parameter must provided.');const a=i?Gh.BLANK:this.externalLinkTarget,s=this.externalLinkRel;let r=t;const n=URL.parse(t);if(n?.username||n?.password){n.username=n.password="";r=n.href}if(this.externalLinkEnabled){e.href=t;e.title=r}else{e.href="";e.title=`Disabled: ${r}`;e.onclick=()=>!1}let o="";switch(a){case Gh.NONE:break;case Gh.SELF:o="_self";break;case Gh.BLANK:o="_blank";break;case Gh.PARENT:o="_parent";break;case Gh.TOP:o="_top"}e.target=o;e.rel="string"==typeof s?s:"noopener noreferrer nofollow"}getDestinationHash(e){if("string"==typeof e){if(e.length>0)return this.getAnchorUrl("#"+escape(e))}else if(Array.isArray(e)){const t=JSON.stringify(e);if(t.length>0)return this.getAnchorUrl("#"+escape(t))}return this.getAnchorUrl("")}getAnchorUrl(e){return this.baseUrl?this.baseUrl+e:e}setHash(e){if(!this.pdfDocument)return;let t,i;if(e.includes("=")){const a=parseQueryString(e);if(a.has("search")){const e=a.get("search").replaceAll('"',""),t="true"===a.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:t?e:e.match(/\S+/g)})}a.has("page")&&(t=0|a.get("page")||1);if(a.has("zoom")){const e=a.get("zoom").split(","),t=e[0],s=parseFloat(t);t.includes("Fit")?"Fit"===t||"FitB"===t?i=[null,{name:t}]:"FitH"===t||"FitBH"===t||"FitV"===t||"FitBV"===t?i=[null,{name:t},e.length>1?0|e[1]:null]:"FitR"===t?5!==e.length?ngx_console_NgxConsole.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:t},0|e[1],0|e[2],0|e[3],0|e[4]]:ngx_console_NgxConsole.error(`PDFLinkService.setHash: "${t}" is not a valid zoom value.`):i=[null,{name:"XYZ"},e.length>1?0|e[1]:null,e.length>2?0|e[2]:null,s?s/100:t]}i?this.pdfViewer.scrollPageIntoView({pageNumber:t||this.page,destArray:i,allowNegativeOffset:!0}):t&&(this.page=t);a.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:a.get("pagemode")});a.has("nameddest")&&this.goToDestination(a.get("nameddest"));return}i=unescape(e);try{i=JSON.parse(i);Array.isArray(i)||(i=i.toString())}catch{}"string"==typeof i||es(i)?this.goToDestination(i):console.error(`PDFLinkService.setHash: "${unescape(e)}" is not a valid destination.`)}executeNamedAction(e){if(this.pdfDocument){switch(e){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1}this.eventBus.dispatch("namedaction",{source:this,action:e})}}async executeSetOCGState(e){if(!this.pdfDocument)return;const t=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;if(t===this.pdfDocument){i.setOCGState(e);this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i)}}}class SimpleLinkService extends PDFLinkService{setDocument(e){}}function event_utils_classPrivateFieldInitSpec(e,t,i){(function event_utils_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function event_utils_classPrivateFieldGet(e,t){return e.get(event_utils_assertClassBrand(e,t))}function event_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Bh="event",Mh="timeout";async function waitOnEventOrTimeout(e){let t=e.target,i=e.name,a=e.delay,s=void 0===a?0:a;if("object"!=typeof t||!i||"string"!=typeof i||!(Number.isInteger(s)&&s>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const r=Promise.withResolvers(),n=r.promise,o=r.resolve,l=new AbortController;function handler(e){l.abort();clearTimeout(h);o(e)}const c=t instanceof EventBus?"on":"addEventListener",d=t instanceof EventBus?{signal:l.signal,...Ih}:{signal:l.signal};t[c](i,handler.bind(null,Bh),d);const h=setTimeout(handler.bind(null,Mh),s);return n}var Dh=new WeakMap;class EventBus{constructor(){event_utils_classPrivateFieldInitSpec(this,Dh,Object.create(null));Object.seal(this)}_on(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.on(e,t,{...i||{},internal:Th})}_off(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.off(e,t,i)}on(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=null;if(i?.signal instanceof AbortSignal){const s=i.signal;if(s.aborted){console.error("Cannot use an `aborted` signal.");return}const onAbort=()=>this.off(e,t);a=()=>s.removeEventListener("abort",onAbort);s.addEventListener("abort",onAbort)}(event_utils_classPrivateFieldGet(Dh,this)[e]??=[]).push({listener:t,internal:i?.internal===Th,once:!0===i?.once,rmAbort:a})}off(e,t){const i=event_utils_classPrivateFieldGet(Dh,this)[e];if(i)for(let e=0,a=i.length;e<a;e++){const a=i[e];if(a.listener===t){a.rmAbort?.();i.splice(e,1);return}}}dispatch(e,t){const i=event_utils_classPrivateFieldGet(Dh,this)[e];if(!i?.length)return;let a;for(const s of i.slice(0)){const i=s.listener,r=s.internal;s.once&&this.off(e,i);r?i(t):(a??=[]).push(i)}if(a)for(const e of a)e(t)}destroy(){let e;for(e in event_utils_classPrivateFieldGet(Dh,this))event_utils_classPrivateFieldGet(Dh,this)[e].length=0}}class BaseExternalServices{updateFindControlState(e){}updateFindMatchesCount(e){}initPassiveLoading(){}reportTelemetry(e){}reportText(e){}async createL10n(){throw new Error("Not implemented: createL10n")}createScripting(){throw new Error("Not implemented: createScripting")}createSignatureStorage(){throw new Error("Not implemented: createSignatureStorage")}updateEditorStates(e){throw new Error("Not implemented: updateEditorStates")}dispatchGlobalEvent(e){}}function preferences_classPrivateFieldInitSpec(e,t,i){(function preferences_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function preferences_classPrivateFieldGet(e,t){return e.get(preferences_assertClassBrand(e,t))}function preferences_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Lh=new WeakMap,Oh=new WeakMap;class BasePreferences{constructor(){preferences_classPrivateFieldInitSpec(this,Lh,Object.freeze(AppOptions.getAll(_n,!0)));preferences_classPrivateFieldInitSpec(this,Oh,null);!function preferences_classPrivateFieldSet(e,t,i){return e.set(preferences_assertClassBrand(e,t),i),i}(Oh,this,this._readFromStorage(preferences_classPrivateFieldGet(Lh,this)).then(e=>{let t=e.browserPrefs,i=e.prefs;AppOptions._checkDisablePreferences()||AppOptions.setAll({...t,...i},!0)}))}async _writeToStorage(e){throw new Error("Not implemented: _writeToStorage")}async _readFromStorage(e){throw new Error("Not implemented: _readFromStorage")}async reset(){await preferences_classPrivateFieldGet(Oh,this);AppOptions.setAll(preferences_classPrivateFieldGet(Lh,this),!0);await this._writeToStorage(preferences_classPrivateFieldGet(Lh,this))}async set(e,t){await preferences_classPrivateFieldGet(Oh,this);AppOptions.setAll({[e]:t},!0);await this._writeToStorage(AppOptions.getAll(_n))}async get(e){await preferences_classPrivateFieldGet(Oh,this);return AppOptions.get(e)}get defaults(){return preferences_classPrivateFieldGet(Lh,this)}get initializedPromise(){return preferences_classPrivateFieldGet(Oh,this)}}class FluentType{constructor(e){this.value=e}valueOf(){return this.value}}class FluentNone extends FluentType{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"???")}toString(e){return`{${this.value}}`}}class FluentNumber extends FluentType{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e);this.opts=t}toString(e){if(e)try{return e.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(t){e.reportError(t)}return this.value.toString(10)}}class FluentDateTime extends FluentType{static supportsValue(e){if("number"==typeof e)return!0;if(e instanceof Date)return!0;if(e instanceof FluentType)return FluentDateTime.supportsValue(e.valueOf());if("Temporal"in globalThis){const t=globalThis.Temporal;if(e instanceof t.Instant||e instanceof t.PlainDateTime||e instanceof t.PlainDate||e instanceof t.PlainMonthDay||e instanceof t.PlainTime||e instanceof t.PlainYearMonth)return!0}return!1}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e instanceof FluentDateTime){t={...e.opts,...t};e=e.value}else e instanceof FluentType&&(e=e.valueOf());"object"==typeof e&&"calendarId"in e&&void 0===t.calendar&&(t={...t,calendar:e.calendarId});super(e);this.opts=t}[Symbol.toPrimitive](e){return"string"===e?this.toString():this.toNumber()}toNumber(){const e=this.value;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();if("epochMilliseconds"in e)return e.epochMilliseconds;if("toZonedDateTime"in e)return e.toZonedDateTime("UTC").epochMilliseconds;throw new TypeError("Unwrapping a non-number value as a number")}toString(e){if(e)try{return e.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(t){e.reportError(t)}return"number"==typeof this.value||this.value instanceof Date?new Date(this.value).toISOString():this.value.toString()}}function match(e,t,i){if(i===t)return!0;if(i instanceof FluentNumber&&t instanceof FluentNumber&&i.value===t.value)return!0;if(t instanceof FluentNumber&&"string"==typeof i){if(i===e.memoizeIntlObject(Intl.PluralRules,t.opts).select(t.value))return!0}return!1}function getDefault(e,t,i){if(t[i])return resolvePattern(e,t[i].value);e.reportError(new RangeError("No default"));return new FluentNone}function getArguments(e,t){const i=[],a=Object.create(null);for(const s of t)"narg"===s.type?a[s.name]=resolveExpression(e,s.value):i.push(resolveExpression(e,s));return{positional:i,named:a}}function resolveExpression(e,t){switch(t.type){case"str":return t.value;case"num":return new FluentNumber(t.value,{minimumFractionDigits:t.precision});case"var":return function resolveVariableReference(e,t){let i,a=t.name;if(e.params){if(!Object.prototype.hasOwnProperty.call(e.params,a))return new FluentNone(`$${a}`);i=e.params[a]}else{if(!e.args||!Object.prototype.hasOwnProperty.call(e.args,a)){e.reportError(new ReferenceError(`Unknown variable: $${a}`));return new FluentNone(`$${a}`)}i=e.args[a]}if(i instanceof FluentType)return i;switch(typeof i){case"string":return i;case"number":return new FluentNumber(i);case"object":if(FluentDateTime.supportsValue(i))return new FluentDateTime(i);default:e.reportError(new TypeError(`Variable type not supported: $${a}, ${typeof i}`));return new FluentNone(`$${a}`)}}(e,t);case"mesg":return function resolveMessageReference(e,t){let i=t.name,a=t.attr;const s=e.bundle._messages.get(i);if(!s){e.reportError(new ReferenceError(`Unknown message: ${i}`));return new FluentNone(i)}if(a){const t=s.attributes[a];if(t)return resolvePattern(e,t);e.reportError(new ReferenceError(`Unknown attribute: ${a}`));return new FluentNone(`${i}.${a}`)}if(s.value)return resolvePattern(e,s.value);e.reportError(new ReferenceError(`No value: ${i}`));return new FluentNone(i)}(e,t);case"term":return function resolveTermReference(e,t){let i=t.name,a=t.attr,s=t.args;const r=`-${i}`,n=e.bundle._terms.get(r);if(!n){e.reportError(new ReferenceError(`Unknown term: ${r}`));return new FluentNone(r)}if(a){const t=n.attributes[a];if(t){e.params=getArguments(e,s).named;const i=resolvePattern(e,t);e.params=null;return i}e.reportError(new ReferenceError(`Unknown attribute: ${a}`));return new FluentNone(`${r}.${a}`)}e.params=getArguments(e,s).named;const o=resolvePattern(e,n.value);e.params=null;return o}(e,t);case"func":return function resolveFunctionReference(e,t){let i=t.name,a=t.args,s=e.bundle._functions[i];if(!s){e.reportError(new ReferenceError(`Unknown function: ${i}()`));return new FluentNone(`${i}()`)}if("function"!=typeof s){e.reportError(new TypeError(`Function ${i}() is not callable`));return new FluentNone(`${i}()`)}try{let t=getArguments(e,a);return s(t.positional,t.named)}catch(t){e.reportError(t);return new FluentNone(`${i}()`)}}(e,t);case"select":return function resolveSelectExpression(e,t){let i=t.selector,a=t.variants,s=t.star,r=resolveExpression(e,i);if(r instanceof FluentNone)return getDefault(e,a,s);for(const t of a){if(match(e,r,resolveExpression(e,t.key)))return resolvePattern(e,t.value)}return getDefault(e,a,s)}(e,t);default:return new FluentNone}}function resolveComplexPattern(e,t){if(e.dirty.has(t)){e.reportError(new RangeError("Cyclic reference"));return new FluentNone}e.dirty.add(t);const i=[],a=e.bundle._useIsolating&&t.length>1;for(const s of t)if("string"!=typeof s){e.placeables++;if(e.placeables>100){e.dirty.delete(t);throw new RangeError(`Too many placeables expanded: ${e.placeables}, max allowed is 100`)}a&&i.push("");i.push(resolveExpression(e,s).toString(e));a&&i.push("")}else i.push(e.bundle._transform(s));e.dirty.delete(t);return i.join("")}function resolvePattern(e,t){return"string"==typeof t?e.bundle._transform(t):resolveComplexPattern(e,t)}class Scope{constructor(e,t,i){this.dirty=new WeakSet;this.params=null;this.placeables=0;this.bundle=e;this.errors=t;this.args=i}reportError(e){if(!(this.errors&&e instanceof Error))throw e;this.errors.push(e)}memoizeIntlObject(e,t){let i=this.bundle._intls.get(e);if(!i){i={};this.bundle._intls.set(e,i)}let a=JSON.stringify(t);i[a]||(i[a]=new e(this.bundle.locales,t));return i[a]}}function builtins_slicedToArray(e,t){return function builtins_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function builtins_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function builtins_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return builtins_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?builtins_arrayLikeToArray(e,t):void 0}}(e,t)||function builtins_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function builtins_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function values(e,t){const i=Object.create(null);for(const s of Object.entries(e)){var a=builtins_slicedToArray(s,2);const e=a[0],r=a[1];t.includes(e)&&(i[e]=r.valueOf())}return i}const Rh=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function NUMBER(e,t){let i=e[0];if(i instanceof FluentNone)return new FluentNone(`NUMBER(${i.valueOf()})`);if(i instanceof FluentNumber)return new FluentNumber(i.valueOf(),{...i.opts,...values(t,Rh)});if(i instanceof FluentDateTime)return new FluentNumber(i.toNumber(),{...values(t,Rh)});throw new TypeError("Invalid argument to NUMBER")}const Nh=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function DATETIME(e,t){let i=e[0];if(i instanceof FluentNone)return new FluentNone(`DATETIME(${i.valueOf()})`);if(i instanceof FluentDateTime||i instanceof FluentNumber)return new FluentDateTime(i,values(t,Nh));throw new TypeError("Invalid argument to DATETIME")}const jh=new Map;class FluentBundle{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.functions,a=t.useIsolating,s=void 0===a||a,r=t.transform,n=void 0===r?e=>e:r;this._terms=new Map;this._messages=new Map;this.locales=Array.isArray(e)?e:[e];this._functions={NUMBER,DATETIME,...i};this._useIsolating=s;this._transform=n;this._intls=function getMemoizerForLocale(e){const t=Array.isArray(e)?e.join(" "):e;let i=jh.get(t);if(void 0===i){i=new Map;jh.set(t,i)}return i}(e)}hasMessage(e){return this._messages.has(e)}getMessage(e){return this._messages.get(e)}addResource(e){let t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).allowOverrides,i=void 0!==t&&t;const a=[];for(let t=0;t<e.body.length;t++){let s=e.body[t];if(s.id.startsWith("-")){if(!1===i&&this._terms.has(s.id)){a.push(new Error(`Attempt to override an existing term: "${s.id}"`));continue}this._terms.set(s.id,s)}else{if(!1===i&&this._messages.has(s.id)){a.push(new Error(`Attempt to override an existing message: "${s.id}"`));continue}this._messages.set(s.id,s)}}return a}formatPattern(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if("string"==typeof e)return this._transform(e);let a=new Scope(this,i,t);try{return resolveComplexPattern(a,e).toString(a)}catch(e){if(a.errors&&e instanceof Error){a.errors.push(e);return(new FluentNone).toString(a)}throw e}}}function resource_slicedToArray(e,t){return function resource_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function resource_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function resource_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return resource_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?resource_arrayLikeToArray(e,t):void 0}}(e,t)||function resource_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function resource_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}const Wh=/^(-?[a-zA-Z][\w-]*) *= */gm,Uh=/\.([a-zA-Z][\w-]*) *= */y,Vh=/\*?\[/y,Hh=/(-?[0-9]+(?:\.([0-9]+))?)/y,zh=/([a-zA-Z][\w-]*)/y,$h=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,qh=/^[A-Z][A-Z0-9_-]*$/,Xh=/([^{}\n\r]+)/y,Kh=/([^\\"\n\r]*)/y,Yh=/\\([\\"])/y,Zh=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,Jh=/^\n+/,Qh=/ +$/,eu=/ *\r?\n/g,tu=/( *)$/,iu=/{\s*/y,au=/\s*}/y,su=/\[\s*/y,ru=/\s*] */y,nu=/\s*\(\s*/y,ou=/\s*->\s*/y,lu=/\s*:\s*/y,cu=/\s*,?\s*/y,du=/\s+/y;class FluentResource{constructor(e){this.body=[];Wh.lastIndex=0;let t=0;for(;;){let i=Wh.exec(e);if(null===i)break;t=Wh.lastIndex;try{this.body.push(parseMessage(i[1]))}catch(e){if(e instanceof SyntaxError)continue;throw e}}function test(i){i.lastIndex=t;return i.test(e)}function consumeChar(i,a){if(e[t]===i){t++;return!0}if(a)throw new a(`Expected ${i}`);return!1}function consumeToken(e,i){if(test(e)){t=e.lastIndex;return!0}if(i)throw new i(`Expected ${e.toString()}`);return!1}function match(i){i.lastIndex=t;let a=i.exec(e);if(null===a)throw new SyntaxError(`Expected ${i.toString()}`);t=i.lastIndex;return a}function match1(e){return match(e)[1]}function parseMessage(e){let t=parsePattern(),i=function parseAttributes(){let e=Object.create(null);for(;test(Uh);){let t=match1(Uh),i=parsePattern();if(null===i)throw new SyntaxError("Expected attribute value");e[t]=i}return e}();if(null===t&&0===Object.keys(i).length)throw new SyntaxError("Expected message value or attributes");return{id:e,value:t,attributes:i}}function parsePattern(){let i;test(Xh)&&(i=match1(Xh));if("{"===e[t]||"}"===e[t])return parsePatternElements(i?[i]:[],1/0);let a=parseIndent();if(a){if(i)return parsePatternElements([i,a],a.length);a.value=trim(a.value,Jh);return parsePatternElements([a],a.length)}return i?trim(i,Qh):null}function parsePatternElements(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=arguments.length>1?arguments[1]:void 0;for(;;){if(test(Xh)){i.push(match1(Xh));continue}if("{"===e[t]){i.push(parsePlaceable());continue}if("}"===e[t])throw new SyntaxError("Unbalanced closing brace");let s=parseIndent();if(!s)break;i.push(s);a=Math.min(a,s.length)}let s=i.length-1,r=i[s];"string"==typeof r&&(i[s]=trim(r,Qh));let n=[];for(let e of i){e instanceof Indent&&(e=e.value.slice(0,e.value.length-a));e&&n.push(e)}return n}function parsePlaceable(){consumeToken(iu,SyntaxError);let e=parseInlineExpression();if(consumeToken(au))return e;if(consumeToken(ou)){let t=function parseVariants(){let e,t=[],i=0;for(;test(Vh);){consumeChar("*")&&(e=i);let a=parseVariantKey(),s=parsePattern();if(null===s)throw new SyntaxError("Expected variant value");t[i++]={key:a,value:s}}if(0===i)return null;if(void 0===e)throw new SyntaxError("Expected default variant");return{variants:t,star:e}}();consumeToken(au,SyntaxError);return{type:"select",selector:e,...t}}throw new SyntaxError("Unclosed placeable")}function parseInlineExpression(){if("{"===e[t])return parsePlaceable();if(test($h)){let i=resource_slicedToArray(match($h),4),a=i[1],s=i[2],r=i[3],n=void 0===r?null:r;if("$"===a)return{type:"var",name:s};if(consumeToken(nu)){let i=function parseArguments(){let i=[];for(;;){switch(e[t]){case")":t++;return i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(parseArgument());consumeToken(cu)}}();if("-"===a)return{type:"term",name:s,attr:n,args:i};if(qh.test(s))return{type:"func",name:s,args:i};throw new SyntaxError("Function names must be all upper-case")}return"-"===a?{type:"term",name:s,attr:n,args:[]}:{type:"mesg",name:s,attr:n}}return parseLiteral()}function parseArgument(){let e=parseInlineExpression();return"mesg"!==e.type?e:consumeToken(lu)?{type:"narg",name:e.name,value:parseLiteral()}:e}function parseVariantKey(){consumeToken(su,SyntaxError);let e;e=test(Hh)?parseNumberLiteral():{type:"str",value:match1(zh)};consumeToken(ru,SyntaxError);return e}function parseLiteral(){if(test(Hh))return parseNumberLiteral();if('"'===e[t])return function parseStringLiteral(){consumeChar('"',SyntaxError);let i="";for(;;){i+=match1(Kh);if("\\"!==e[t]){if(consumeChar('"'))return{type:"str",value:i};throw new SyntaxError("Unclosed string literal")}i+=parseEscapeSequence()}}();throw new SyntaxError("Invalid expression")}function parseNumberLiteral(){let e=resource_slicedToArray(match(Hh),3),t=e[1],i=e[2],a=(void 0===i?"":i).length;return{type:"num",value:parseFloat(t),precision:a}}function parseEscapeSequence(){if(test(Yh))return match1(Yh);if(test(Zh)){let e=resource_slicedToArray(match(Zh),3),t=e[1],i=e[2],a=parseInt(t||i,16);return a<=55295||57344<=a?String.fromCodePoint(a):"�"}throw new SyntaxError("Unknown escape sequence")}function parseIndent(){let i=t;consumeToken(du);switch(e[t]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return makeIndent(e.slice(i,t))}return" "===e[t-1]&&makeIndent(e.slice(i,t))}function trim(e,t){return e.replace(t,"")}function makeIndent(e){let t=e.replace(eu,"\n"),i=tu.exec(e)[1].length;return new Indent(t,i)}}}class Indent{constructor(e,t){this.value=e;this.length=t}}const hu=/<|&#?\w+;/,uu={"http://www.w3.org/1999/xhtml":["em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","bdi","bdo","span","br","wbr"]},_u={"http://www.w3.org/1999/xhtml":{global:["title","aria-description","aria-label","aria-valuetext"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]},"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul":{global:["accesskey","aria-label","aria-valuetext","label","title","tooltiptext"],description:["value"],key:["key","keycode"],label:["value"],textbox:["placeholder","value"]}};function translateElement(e,t){const i=t.value;if("string"==typeof i)if("title"===e.localName&&"http://www.w3.org/1999/xhtml"===e.namespaceURI)e.textContent=i;else if(hu.test(i)){const t=e.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");t.innerHTML=i;!function overlayChildNodes(e,t){for(const i of e.childNodes)if(i.nodeType!==i.TEXT_NODE){if(i.hasAttribute("data-l10n-name")){const a=getNodeForNamedElement(t,i);e.replaceChild(a,i);continue}if(isElementAllowed(i)){const t=createSanitizedElement(i);e.replaceChild(t,i);continue}console.warn(`An element of forbidden type "${i.localName}" was found in the translation. Only safe text-level elements and elements with data-l10n-name are allowed.`);e.replaceChild(createTextNodeFromTextContent(i),i)}t.textContent="";t.appendChild(e)}(t.content,e)}else e.textContent=i;overlayAttributes(t,e)}function hasAttribute(e,t){if(!e)return!1;for(let i of e)if(i.name===t)return!0;return!1}function overlayAttributes(e,t){const i=t.hasAttribute("data-l10n-attrs")?t.getAttribute("data-l10n-attrs").split(",").map(e=>e.trim()):null;for(const a of Array.from(t.attributes))isAttrNameLocalizable(a.name,t,i)&&!hasAttribute(e.attributes,a.name)&&t.removeAttribute(a.name);if(e.attributes)for(const a of Array.from(e.attributes))isAttrNameLocalizable(a.name,t,i)&&t.getAttribute(a.name)!==a.value&&t.setAttribute(a.name,a.value)}function getNodeForNamedElement(e,t){const i=t.getAttribute("data-l10n-name"),a=e.querySelector(`[data-l10n-name="${i}"]`);if(!a){console.warn(`An element named "${i}" wasn't found in the source.`);return createTextNodeFromTextContent(t)}if(a.localName!==t.localName){console.warn(`An element named "${i}" was found in the translation but its type ${t.localName} didn't match the element found in the source (${a.localName}).`);return createTextNodeFromTextContent(t)}e.removeChild(a);return shallowPopulateUsing(t,a.cloneNode(!1))}function createSanitizedElement(e){const t=e.ownerDocument.createElement(e.localName);return shallowPopulateUsing(e,t)}function createTextNodeFromTextContent(e){return e.ownerDocument.createTextNode(e.textContent)}function isElementAllowed(e){const t=uu[e.namespaceURI];return t&&t.includes(e.localName)}function isAttrNameLocalizable(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(i&&i.includes(e))return!0;const a=_u[t.namespaceURI];if(!a)return!1;const s=e.toLowerCase(),r=t.localName;if(a.global.includes(s))return!0;if(!a[r])return!1;if(a[r].includes(s))return!0;if("http://www.w3.org/1999/xhtml"===t.namespaceURI&&"input"===r&&"value"===s){const e=t.type.toLowerCase();if("submit"===e||"button"===e||"reset"===e)return!0}return!1}function shallowPopulateUsing(e,t){t.textContent=e.textContent;overlayAttributes(e,t);return t}class CachedIterable extends Array{static from(e){return e instanceof this?e:new this(e)}}Symbol.iterator;class CachedAsyncIterable extends CachedIterable{constructor(e){super();if(Symbol.asyncIterator in Object(e))this.iterator=e[Symbol.asyncIterator]();else{if(!(Symbol.iterator in Object(e)))throw new TypeError("Argument must implement the iteration protocol.");this.iterator=e[Symbol.iterator]()}}[Symbol.asyncIterator](){const e=this;let t=0;return{async next(){e.length<=t&&e.push(e.iterator.next());return e[t++]}}}async touchNext(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=0;for(;t++<e;){const e=this[this.length-1];if(e&&(await e).done)break;this.push(this.iterator.next())}return this[this.length-1]}}function localization_slicedToArray(e,t){return function localization_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function localization_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function localization_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return localization_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?localization_arrayLikeToArray(e,t):void 0}}(e,t)||function localization_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function localization_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}class Localization{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0;this.resourceIds=e;this.generateBundles=t;this.onChange(!0)}addResourceIds(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.resourceIds.push(...e);this.onChange(t);return this.resourceIds.length}removeResourceIds(e){this.resourceIds=this.resourceIds.filter(t=>!e.includes(t));this.onChange();return this.resourceIds.length}async formatWithFallback(e,t){const i=[];let a=!1;for await(const s of this.bundles){a=!0;const r=keysFromBundle(t,s,e,i);if(0===r.size)break;if("undefined"!=typeof console){const e=s.locales[0],t=Array.from(r).join(", ");console.warn(`[fluent] Missing translations in ${e}: ${t}`)}}a||"undefined"==typeof console||console.warn(`[fluent] Request for keys failed because no resource bundles got generated.\n keys: ${JSON.stringify(e)}.\n resourceIds: ${JSON.stringify(this.resourceIds)}.`);return i}formatMessages(e){return this.formatWithFallback(e,messageFromBundle)}formatValues(e){return this.formatWithFallback(e,valueFromBundle)}async formatValue(e,t){return localization_slicedToArray(await this.formatValues([{id:e,args:t}]),1)[0]}handleEvent(){this.onChange()}onChange(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.bundles=CachedAsyncIterable.from(this.generateBundles(this.resourceIds));e&&this.bundles.touchNext(2)}}function valueFromBundle(e,t,i,a){return i.value?e.formatPattern(i.value,a,t):null}function messageFromBundle(e,t,i,a){const s={value:null,attributes:null};i.value&&(s.value=e.formatPattern(i.value,a,t));let r=Object.keys(i.attributes);if(r.length>0){s.attributes=new Array(r.length);for(let o of r.entries()){var n=localization_slicedToArray(o,2);let r=n[0],l=n[1],c=e.formatPattern(i.attributes[l],a,t);s.attributes[r]={name:l,value:c}}}return s}function keysFromBundle(e,t,i,a){const s=[],r=new Set;i.forEach((i,n)=>{let o=i.id,l=i.args;if(void 0!==a[n])return;let c=t.getMessage(o);if(c){s.length=0;a[n]=e(t,s,c,l);if(s.length>0&&"undefined"!=typeof console){const e=t.locales[0],i=s.join(", ");console.warn(`[fluent][resolver] errors in ${e}/${o}: ${i}.`)}}else r.add(o)});return r}const pu="data-l10n-id",gu="data-l10n-args",fu=`[${pu}]`;class DOMLocalization extends Localization{constructor(e,t){super(e,t);this.roots=new Set;this.pendingrAF=null;this.pendingElements=new Set;this.windowElement=null;this.mutationObserver=null;this.observerConfig={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:[pu,gu]}}onChange(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];super.onChange(e);this.roots&&this.translateRoots()}setAttributes(e,t,i){e.setAttribute(pu,t);i?e.setAttribute(gu,JSON.stringify(i)):e.removeAttribute(gu);return e}getAttributes(e){return{id:e.getAttribute(pu),args:JSON.parse(e.getAttribute(gu)||null)}}connectRoot(e){for(const t of this.roots)if(t===e||t.contains(e)||e.contains(t))throw new Error("Cannot add a root that overlaps with existing root.");if(this.windowElement){if(this.windowElement!==e.ownerDocument.defaultView)throw new Error("Cannot connect a root:\n DOMLocalization already has a root from a different window.")}else{this.windowElement=e.ownerDocument.defaultView;this.mutationObserver=new this.windowElement.MutationObserver(e=>this.translateMutations(e))}this.roots.add(e);this.mutationObserver.observe(e,this.observerConfig)}disconnectRoot(e){this.roots.delete(e);this.pauseObserving();if(0===this.roots.size){this.mutationObserver=null;this.windowElement&&this.pendingrAF&&this.windowElement.cancelAnimationFrame(this.pendingrAF);this.windowElement=null;this.pendingrAF=null;this.pendingElements.clear();return!0}this.resumeObserving();return!1}translateRoots(){const e=Array.from(this.roots);return Promise.all(e.map(e=>this.translateFragment(e)))}pauseObserving(){if(this.mutationObserver){this.translateMutations(this.mutationObserver.takeRecords());this.mutationObserver.disconnect()}}resumeObserving(){if(this.mutationObserver)for(const e of this.roots)this.mutationObserver.observe(e,this.observerConfig)}translateMutations(e){for(const t of e)switch(t.type){case"attributes":t.target.hasAttribute("data-l10n-id")&&this.pendingElements.add(t.target);break;case"childList":for(const e of t.addedNodes)if(e.nodeType===e.ELEMENT_NODE)if(e.childElementCount)for(const t of this.getTranslatables(e))this.pendingElements.add(t);else e.hasAttribute(pu)&&this.pendingElements.add(e)}this.pendingElements.size>0&&null===this.pendingrAF&&(this.pendingrAF=this.windowElement.requestAnimationFrame(()=>{this.translateElements(Array.from(this.pendingElements));this.pendingElements.clear();this.pendingrAF=null}))}translateFragment(e){return this.translateElements(this.getTranslatables(e))}async translateElements(e){if(!e.length)return;const t=e.map(this.getKeysForElement),i=await this.formatMessages(t);return this.applyTranslations(e,i)}applyTranslations(e,t){this.pauseObserving();for(let i=0;i<e.length;i++)void 0!==t[i]&&translateElement(e[i],t[i]);this.resumeObserving()}getTranslatables(e){const t=Array.from(e.querySelectorAll(fu));"function"==typeof e.hasAttribute&&e.hasAttribute(pu)&&t.push(e);return t}getKeysForElement(e){return{id:e.getAttribute(pu),args:JSON.parse(e.getAttribute(gu)||null)}}}function l10n_classPrivateFieldInitSpec(e,t,i){(function l10n_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function l10n_classPrivateFieldGet(e,t){return e.get(l10n_assertClassBrand(e,t))}function l10n_classPrivateFieldSet(e,t,i){return e.set(l10n_assertClassBrand(e,t),i),i}function l10n_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var mu=new WeakMap,vu=new WeakMap,yu=new WeakMap,Pu=new WeakMap;class L10n{constructor(e){let t=e.lang,i=e.isRTL,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;l10n_classPrivateFieldInitSpec(this,mu,void 0);l10n_classPrivateFieldInitSpec(this,vu,void 0);l10n_classPrivateFieldInitSpec(this,yu,void 0);l10n_classPrivateFieldInitSpec(this,Pu,void 0);l10n_classPrivateFieldSet(yu,this,_fixupLangCode.call(L10n,t));l10n_classPrivateFieldSet(Pu,this,a);l10n_classPrivateFieldSet(mu,this,i??_isRTL.call(L10n,l10n_classPrivateFieldGet(yu,this))?"rtl":"ltr")}_setL10n(e){l10n_classPrivateFieldSet(Pu,this,e)}getLanguage(){return l10n_classPrivateFieldGet(yu,this)}getDirection(){return l10n_classPrivateFieldGet(mu,this)}async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2?arguments[2]:void 0;if(Array.isArray(e)){e=e.map(e=>({id:e}));return(await l10n_classPrivateFieldGet(Pu,this).formatMessages(e)).map(e=>e.value)}const a=await l10n_classPrivateFieldGet(Pu,this).formatMessages([{id:e,args:t}]);return a[0]?.value||i}async translate(e){(l10n_classPrivateFieldGet(vu,this)||l10n_classPrivateFieldSet(vu,this,new Set)).add(e);try{l10n_classPrivateFieldGet(Pu,this).connectRoot(e)}catch{}await l10n_classPrivateFieldGet(Pu,this).translateRoots()}async translateOnce(e){try{await l10n_classPrivateFieldGet(Pu,this).translateElements([e])}catch(e){console.error("translateOnce:",e)}}async destroy(){if(l10n_classPrivateFieldGet(vu,this)){for(const e of l10n_classPrivateFieldGet(vu,this))l10n_classPrivateFieldGet(Pu,this).disconnectRoot(e);l10n_classPrivateFieldGet(vu,this).clear();l10n_classPrivateFieldSet(vu,this,null)}l10n_classPrivateFieldGet(Pu,this).pauseObserving()}pause(){l10n_classPrivateFieldGet(Pu,this).pauseObserving()}resume(){l10n_classPrivateFieldGet(Pu,this).resumeObserving()}}function _fixupLangCode(e){return{en:"en-us",es:"es-es",fy:"fy-nl",ga:"ga-ie",gu:"gu-in",hi:"hi-in",hy:"hy-am",nb:"nb-no",ne:"ne-np",nn:"nn-no",pa:"pa-in",pt:"pt-pt",sv:"sv-se",zh:"zh-cn"}[e=e?.toLowerCase()||"en-us"]||e}function _isRTL(e){const t=e.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(t)}var wu;function genericl10n_slicedToArray(e,t){return function genericl10n_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function genericl10n_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function genericl10n_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return genericl10n_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?genericl10n_arrayLikeToArray(e,t):void 0}}(e,t)||function genericl10n_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function genericl10n_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function genericl10n_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function PLATFORM(){const e=FeatureTest.platform,t=e.isAndroid,i=e.isLinux,a=e.isMac,s=e.isWindows;return i?"linux":s?"windows":a?"macos":t?"android":"other"}function createBundle(e,t){const i=new FluentResource(t),a=new FluentBundle(e,{functions:{PLATFORM}}),s=a.addResource(i);s.length&&console.error("L10n errors",s);return a}class genericl10n_GenericL10n extends L10n{constructor(e){super({lang:e});const t=e?_generateBundles.bind(genericl10n_GenericL10n,"en-us",this.getLanguage()):_generateBundlesFallback.bind(genericl10n_GenericL10n,this.getLanguage());this._setL10n(new DOMLocalization([],t))}}wu=genericl10n_GenericL10n;async function*_generateBundles(e,t){const i=await genericl10n_assertClassBrand(wu,this,_getPaths).call(this),a=i.baseURL,s=i.paths,r=[t];if(e!==t){const i=t.split("-",1)[0];i!==t&&r.push(i);r.push(e)}const n=r.map(e=>[e,genericl10n_assertClassBrand(wu,this,_createBundle).call(this,e,a,s)]);for(const e of n){var o=genericl10n_slicedToArray(e,2);const t=o[0],i=o[1],a=await i;a?yield a:"en-us"===t&&(yield genericl10n_assertClassBrand(wu,this,_createBundleFallback).call(this,t))}}async function _createBundle(e,t,i){const a=i[e];if(!a)return null;const s=new URL(a,t);return createBundle(e,await fetchData(s,"text"))}async function _getPaths(){try{const e=document.querySelector('link[type="application/l10n"]').href,t=await fetchData(e,"json");return{baseURL:e.substring(0,e.lastIndexOf("/")+1)||"./",paths:t}}catch{}return{baseURL:"./",paths:Object.create(null)}}async function*_generateBundlesFallback(e){yield genericl10n_assertClassBrand(wu,this,_createBundleFallback).call(this,e)}async function _createBundleFallback(e){return createBundle(e,'pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties…\npdfjs-document-properties-button-label = Document Properties…\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } × { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } × { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing…\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title1 =\n .title = Page { $page } of { $total }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-thumb-page-checkbox1 =\n .title = Select page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document…\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-color-picker-free-text-input =\n .title = Change text color\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-color-picker-ink-input =\n .title = Change drawing color\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-comment-floating-button =\n .title = Comment\n .aria-label = Comment\npdfjs-comment-floating-button-label = Comment\npdfjs-editor-comment-button =\n .title = Comment\n .aria-label = Comment\npdfjs-editor-comment-button-label = Comment\npdfjs-editor-signature-button =\n .title = Add signature\npdfjs-editor-signature-button-label = Add signature\npdfjs-editor-highlight-editor =\n .aria-label = Highlight editor\npdfjs-editor-ink-editor =\n .aria-label = Drawing editor\npdfjs-editor-signature-editor1 =\n .aria-description = Signature editor: { $description }\npdfjs-editor-stamp-editor =\n .aria-label = Image editor\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-remove-signature-button =\n .title = Remove signature\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-editor-add-signature-container =\n .aria-label = Signature controls and saved signatures\npdfjs-editor-signature-add-signature-button =\n .title = Add new signature\npdfjs-editor-signature-add-signature-button-label = Add new signature\npdfjs-editor-add-saved-signature-button =\n .title = Saved signature: { $description }\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\npdfjs-editor-comments-sidebar-title =\n { $count ->\n [one] Comment\n *[other] Comments\n }\npdfjs-editor-comments-sidebar-close-button =\n .title = Close the sidebar\n .aria-label = Close the sidebar\npdfjs-editor-comments-sidebar-close-button-label = Close the sidebar\npdfjs-editor-comments-sidebar-no-comments1 = See something noteworthy? Highlight it and leave a comment.\npdfjs-editor-comments-sidebar-no-comments-link = Learn more\npdfjs-editor-alt-text-button =\n .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n .aria-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, “A young man sits down at a table to eat a meal”\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner — resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle — resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner — resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right — resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner — resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle — resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner — resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left — resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here…\npdfjs-editor-new-alt-text-description = Short description for people who can’t see the image or when the image doesn’t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn’t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can’t see the image or when the image doesn’t load.\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-highlight-added-alert = Highlight added\npdfjs-editor-freetext-added-alert = Text added\npdfjs-editor-ink-added-alert = Drawing added\npdfjs-editor-stamp-added-alert = Image added\npdfjs-editor-signature-added-alert = Signature added\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-signature = Signature removed\npdfjs-editor-undo-bar-message-comment = Comment removed\npdfjs-editor-undo-bar-message-multiple =\n { $count ->\n [one] { $count } annotation removed\n *[other] { $count } annotations removed\n }\npdfjs-editor-undo-bar-undo-button =\n .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n .title = Close\npdfjs-editor-undo-bar-close-button-label = Close\npdfjs-editor-add-signature-dialog-label = This modal allows the user to create a signature to add to a PDF document. The user can edit the name (which also serves as the alt text), and optionally save the signature for repeated use.\npdfjs-editor-add-signature-dialog-title = Add a signature\npdfjs-editor-add-signature-type-button = Type\n .title = Type\npdfjs-editor-add-signature-draw-button = Draw\n .title = Draw\npdfjs-editor-add-signature-image-button = Image\n .title = Image\npdfjs-editor-add-signature-type-input =\n .aria-label = Type your signature\n .placeholder = Type your signature\npdfjs-editor-add-signature-draw-placeholder = Draw your signature\npdfjs-editor-add-signature-draw-thickness-range-label = Thickness\npdfjs-editor-add-signature-draw-thickness-range =\n .title = Drawing thickness: { $thickness }\npdfjs-editor-add-signature-image-placeholder = Drag a file here to upload\npdfjs-editor-add-signature-image-browse-link =\n { PLATFORM() ->\n [macos] Or choose image files\n *[other] Or browse image files\n }\npdfjs-editor-add-signature-description-label = Description (alt text)\npdfjs-editor-add-signature-description-input =\n .title = Description (alt text)\npdfjs-editor-add-signature-description-default-when-drawing = Signature\npdfjs-editor-add-signature-clear-button-label = Clear signature\npdfjs-editor-add-signature-clear-button =\n .title = Clear signature\npdfjs-editor-add-signature-save-checkbox = Save signature\npdfjs-editor-add-signature-save-warning-message = You’ve reached the limit of 5 saved signatures. Remove one to save more.\npdfjs-editor-add-signature-image-upload-error-title = Couldn’t upload image\npdfjs-editor-add-signature-image-upload-error-description = Check your network connection or try another image.\npdfjs-editor-add-signature-image-no-data-error-title = Can’t convert this image into a signature\npdfjs-editor-add-signature-image-no-data-error-description = Please try uploading a different image.\npdfjs-editor-add-signature-error-close-button = Close\npdfjs-editor-add-signature-cancel-button = Cancel\npdfjs-editor-add-signature-add-button = Add\npdfjs-editor-delete-signature-button1 =\n .title = Remove saved signature\npdfjs-editor-delete-signature-button-label1 = Remove saved signature\npdfjs-editor-add-signature-edit-button-label = Edit description\npdfjs-editor-edit-signature-dialog-title = Edit description\npdfjs-editor-edit-signature-update-button = Update\npdfjs-show-comment-button =\n .title = Show comment\npdfjs-editor-edit-comment-popup-button-label = Edit comment\npdfjs-editor-edit-comment-popup-button =\n .title = Edit comment\npdfjs-editor-delete-comment-popup-button-label = Remove comment\npdfjs-editor-delete-comment-popup-button =\n .title = Remove comment\npdfjs-editor-edit-comment-dialog-title-when-editing = Edit comment\npdfjs-editor-edit-comment-dialog-save-button-when-editing = Update\npdfjs-editor-edit-comment-dialog-title-when-adding = Add comment\npdfjs-editor-edit-comment-dialog-save-button-when-adding = Add\npdfjs-editor-edit-comment-dialog-text-input =\n .placeholder = Start typing…\npdfjs-editor-edit-comment-dialog-cancel-button = Cancel\npdfjs-editor-add-comment-button =\n .title = Add comment\npdfjs-toggle-views-manager-button1 =\n .title = Manage pages\npdfjs-toggle-views-manager-notification-button =\n .title = Toggle Sidebar (document contains thumbnails/outline/attachments/layers)\npdfjs-toggle-views-manager-button1-label = Manage pages\npdfjs-views-manager-sidebar =\n .aria-label = Sidebar\npdfjs-views-manager-sidebar-resizer =\n .aria-label = Sidebar resizer\npdfjs-views-manager-view-selector-button =\n .title = Views\npdfjs-views-manager-view-selector-button-label = Views\npdfjs-views-manager-pages-title = Pages\npdfjs-views-manager-outlines-title1 = Document outline\n .title = Document outline (double-click to expand/collapse all items)\npdfjs-views-manager-attachments-title = Attachments\npdfjs-views-manager-layers-title1 = Layers\n .title = Layers (double-click to reset all layers to the default state)\npdfjs-views-manager-pages-option-label = Pages\npdfjs-views-manager-outlines-option-label = Document outline\npdfjs-views-manager-attachments-option-label = Attachments\npdfjs-views-manager-layers-option-label = Layers\npdfjs-views-manager-add-file-button =\n .title = Add file\npdfjs-views-manager-add-file-button-label = Add file\npdfjs-views-manager-pages-status-action-label =\n { $count ->\n [one] { $count } selected\n *[other] { $count } selected\n }\npdfjs-views-manager-pages-status-none-action-label = Select pages\npdfjs-views-manager-pages-status-action-button-label = Manage\npdfjs-views-manager-pages-status-copy-button-label = Copy\npdfjs-views-manager-pages-status-cut-button-label = Cut\npdfjs-views-manager-pages-status-delete-button-label = Delete\npdfjs-views-manager-pages-status-export-selected-button-label = Export selected…\npdfjs-views-manager-status-undo-cut-label =\n { $count ->\n [one] 1 page cut\n *[other] { $count } pages cut\n }\npdfjs-views-manager-pages-status-undo-copy-label =\n { $count ->\n [one] 1 page copied\n *[other] { $count } pages copied\n }\npdfjs-views-manager-pages-status-undo-delete-label =\n { $count ->\n [one] 1 page deleted\n *[other] { $count } pages deleted\n }\npdfjs-views-manager-pages-status-waiting-ready-label = Getting your file ready…\npdfjs-views-manager-pages-status-waiting-uploading-label = Uploading file…\npdfjs-views-manager-status-warning-cut-label = Couldn’t cut. Refresh page and try again.\npdfjs-views-manager-status-warning-copy-label = Couldn’t copy. Refresh page and try again.\npdfjs-views-manager-status-warning-delete-label = Couldn’t delete. Refresh page and try again.\npdfjs-views-manager-status-warning-save-label = Couldn’t save. Refresh page and try again.\npdfjs-views-manager-status-undo-button-label = Undo\npdfjs-views-manager-status-done-button-label = Done\npdfjs-views-manager-status-close-button =\n .title = Close\npdfjs-views-manager-status-close-button-label = Close\npdfjs-views-manager-paste-button-label = Paste\npdfjs-views-manager-paste-button-before =\n .title = Paste before the first page\npdfjs-views-manager-paste-button-after =\n .title = Paste after page { $page }\npdfjs-new-badge-content = NEW\npdfjs-views-manager-waiting-for-file = Uploading file…')}class GenericScripting{constructor(e,t){"Function"===e?.constructor?.name&&(e=e());this._ready=new Promise((i,a)=>{import(
/*webpackIgnore: true*/
/*@vite-ignore*/
e).then(e=>{i(e.QuickJSSandbox(new URL(t,location.href).href))}).catch(a)})}async createSandbox(e){(await this._ready).create(e)}async dispatchEventInSandbox(e){const t=await this._ready;setTimeout(()=>t.dispatchEvent(e),0)}async destroySandbox(){(await this._ready).nukeSandbox()}}function generic_signature_storage_slicedToArray(e,t){return function generic_signature_storage_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function generic_signature_storage_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function generic_signature_storage_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return generic_signature_storage_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?generic_signature_storage_arrayLikeToArray(e,t):void 0}}(e,t)||function generic_signature_storage_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function generic_signature_storage_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function generic_signature_storage_classPrivateFieldInitSpec(e,t,i){generic_signature_storage_checkPrivateRedeclaration(e,t),t.set(e,i)}function generic_signature_storage_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function generic_signature_storage_classPrivateFieldGet(e,t){return e.get(generic_signature_storage_assertClassBrand(e,t))}function generic_signature_storage_classPrivateFieldSet(e,t,i){return e.set(generic_signature_storage_assertClassBrand(e,t),i),i}function generic_signature_storage_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const bu="pdfjs.signature";var Fu=new WeakMap,Su=new WeakMap,Cu=new WeakMap,Au=new WeakSet;class SignatureStorage{constructor(e,t){!function generic_signature_storage_classPrivateMethodInitSpec(e,t){generic_signature_storage_checkPrivateRedeclaration(e,t),t.add(e)}(this,Au);generic_signature_storage_classPrivateFieldInitSpec(this,Fu,void 0);generic_signature_storage_classPrivateFieldInitSpec(this,Su,null);generic_signature_storage_classPrivateFieldInitSpec(this,Cu,null);generic_signature_storage_classPrivateFieldSet(Fu,this,e);generic_signature_storage_classPrivateFieldSet(Cu,this,t)}async getAll(){if(generic_signature_storage_classPrivateFieldGet(Cu,this)){window.addEventListener("storage",e=>{if(e.key===bu){generic_signature_storage_classPrivateFieldSet(Su,this,null);generic_signature_storage_classPrivateFieldGet(Fu,this)?.dispatch("storedsignatureschanged",{source:this})}},{signal:generic_signature_storage_classPrivateFieldGet(Cu,this)});generic_signature_storage_classPrivateFieldSet(Cu,this,null)}if(!generic_signature_storage_classPrivateFieldGet(Su,this)){generic_signature_storage_classPrivateFieldSet(Su,this,new Map);const t=localStorage.getItem(bu);if(t)for(const i of Object.entries(JSON.parse(t))){var e=generic_signature_storage_slicedToArray(i,2);const t=e[0],a=e[1];generic_signature_storage_classPrivateFieldGet(Su,this).set(t,a)}}return generic_signature_storage_classPrivateFieldGet(Su,this)}async isFull(){return 5===await this.size()}async size(){return(await this.getAll()).size}async create(e){if(await this.isFull())return null;const t=getUuid();generic_signature_storage_classPrivateFieldGet(Su,this).set(t,e);generic_signature_storage_assertClassBrand(Au,this,_save).call(this);return t}async delete(e){const t=await this.getAll();if(!t.has(e))return!1;t.delete(e);generic_signature_storage_assertClassBrand(Au,this,_save).call(this);return!0}}function _save(){localStorage.setItem(bu,JSON.stringify(Object.fromEntries(generic_signature_storage_classPrivateFieldGet(Su,this))))}class ExternalServices extends BaseExternalServices{constructor(){super()}async createL10n(){return new genericl10n_GenericL10n(AppOptions.get("localeProperties")?.lang)}createScripting(){return new GenericScripting(AppOptions.get("sandboxBundleSrc"),AppOptions.get("wasmUrl"))}createSignatureStorage(e,t){return new SignatureStorage(e,t)}}0;function new_alt_text_manager_classPrivateMethodInitSpec(e,t){new_alt_text_manager_checkPrivateRedeclaration(e,t),t.add(e)}function new_alt_text_manager_classPrivateFieldInitSpec(e,t,i){new_alt_text_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function new_alt_text_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function new_alt_text_manager_toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function new_alt_text_manager_classPrivateFieldGet(e,t){return e.get(new_alt_text_manager_assertClassBrand(e,t))}function new_alt_text_manager_classPrivateFieldSet(e,t,i){return e.set(new_alt_text_manager_assertClassBrand(e,t),i),i}function new_alt_text_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var xu=new WeakMap,ku=new WeakMap,Eu=new WeakMap,Tu=new WeakMap,Iu=new WeakMap,Gu=new WeakMap,Bu=new WeakMap,Mu=new WeakMap,Du=new WeakMap,Lu=new WeakMap,Ou=new WeakMap,Ru=new WeakMap,Nu=new WeakMap,ju=new WeakMap,Wu=new WeakMap,Uu=new WeakMap,Vu=new WeakMap,Hu=new WeakMap,zu=new WeakMap,$u=new WeakMap,qu=new WeakMap,Xu=new WeakMap,Ku=new WeakMap,Yu=new WeakMap,Zu=new WeakMap,Ju=new WeakSet;class NewAltTextManager{constructor(e,t,i){let a=e.descriptionContainer,s=e.dialog,r=e.imagePreview,n=e.cancelButton,o=e.disclaimer,l=e.notNowButton,c=e.saveButton,d=e.textarea,h=e.learnMore,u=e.errorCloseButton,_=e.createAutomaticallyButton,p=e.downloadModel,g=e.downloadModelDescription,f=e.title;new_alt_text_manager_classPrivateMethodInitSpec(this,Ju);new_alt_text_manager_classPrivateFieldInitSpec(this,xu,new_alt_text_manager_assertClassBrand(Ju,this,_cancel).bind(this));new_alt_text_manager_classPrivateFieldInitSpec(this,ku,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Eu,null);new_alt_text_manager_classPrivateFieldInitSpec(this,Tu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Iu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Gu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Bu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Mu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Du,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Lu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Ou,!1);new_alt_text_manager_classPrivateFieldInitSpec(this,Ru,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Nu,null);new_alt_text_manager_classPrivateFieldInitSpec(this,ju,null);new_alt_text_manager_classPrivateFieldInitSpec(this,Wu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Uu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Vu,!1);new_alt_text_manager_classPrivateFieldInitSpec(this,Hu,!1);new_alt_text_manager_classPrivateFieldInitSpec(this,zu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,$u,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,qu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Xu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Ku,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Yu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Zu,null);new_alt_text_manager_classPrivateFieldSet(Tu,this,n);new_alt_text_manager_classPrivateFieldSet(ku,this,_);new_alt_text_manager_classPrivateFieldSet(Iu,this,a);new_alt_text_manager_classPrivateFieldSet(Gu,this,s);new_alt_text_manager_classPrivateFieldSet(Bu,this,o);new_alt_text_manager_classPrivateFieldSet($u,this,l);new_alt_text_manager_classPrivateFieldSet(Wu,this,r);new_alt_text_manager_classPrivateFieldSet(Xu,this,d);new_alt_text_manager_classPrivateFieldSet(zu,this,h);new_alt_text_manager_classPrivateFieldSet(Ku,this,f);new_alt_text_manager_classPrivateFieldSet(Mu,this,p);new_alt_text_manager_classPrivateFieldSet(Du,this,g);new_alt_text_manager_classPrivateFieldSet(qu,this,t);new_alt_text_manager_classPrivateFieldSet(Lu,this,i);s.addEventListener("close",new_alt_text_manager_assertClassBrand(Ju,this,_close).bind(this));s.addEventListener("contextmenu",e=>{e.target!==new_alt_text_manager_classPrivateFieldGet(Xu,this)&&e.preventDefault()});n.addEventListener("click",new_alt_text_manager_classPrivateFieldGet(xu,this));l.addEventListener("click",new_alt_text_manager_classPrivateFieldGet(xu,this));c.addEventListener("click",new_alt_text_manager_assertClassBrand(Ju,this,new_alt_text_manager_save).bind(this));u.addEventListener("click",()=>{new_alt_text_manager_assertClassBrand(Ju,this,_toggleError).call(this,!1)});_.addEventListener("click",async()=>{const e="true"!==_.getAttribute("aria-pressed");new_alt_text_manager_classPrivateFieldGet(Eu,this)._reportTelemetry({action:"pdfjs.image.alt_text.ai_generation_check",data:{status:e}});if(new_alt_text_manager_classPrivateFieldGet(Yu,this)){const t=await new_alt_text_manager_classPrivateFieldGet(Yu,this).mlManager.isEnabledFor("altText");new_alt_text_manager_classPrivateFieldGet(ku,this).disabled=!0;if(e&&!t){new_alt_text_manager_classPrivateFieldGet(Xu,this).value="";new_alt_text_manager_assertClassBrand(Ju,this,_setProgress).call(this);new_alt_text_manager_classPrivateFieldGet(Yu,this).setPreference("enableGuessAltText",!0);await new_alt_text_manager_classPrivateFieldGet(Yu,this).mlManager.downloadModel("altText");new_alt_text_manager_assertClassBrand(Ju,this,_setPref).call(this,"enableAltTextModelDownload",!0)}else if(!e&&t){new_alt_text_manager_classPrivateFieldGet(Yu,this).setPreference("enableGuessAltText",!1);await new_alt_text_manager_classPrivateFieldGet(Yu,this).mlManager.deleteModel("altText");new_alt_text_manager_assertClassBrand(Ju,this,_setPref).call(this,"enableAltTextModelDownload",!1)}new_alt_text_manager_classPrivateFieldGet(ku,this).disabled=!1;await new_alt_text_manager_classPrivateFieldGet(Yu,this).mlManager.toggleService("altText",e)}new_alt_text_manager_assertClassBrand(Ju,this,_toggleGuessAltText).call(this,e,!1)});d.addEventListener("focus",()=>{new_alt_text_manager_classPrivateFieldSet(Hu,this,new_alt_text_manager_classPrivateFieldGet(Vu,this));new_alt_text_manager_assertClassBrand(Ju,this,_toggleLoading).call(this,!1);new_alt_text_manager_assertClassBrand(Ju,this,_toggleTitleAndDisclaimer).call(this)});d.addEventListener("blur",()=>{d.value||new_alt_text_manager_assertClassBrand(Ju,this,_toggleLoading).call(this,new_alt_text_manager_classPrivateFieldGet(Hu,this));new_alt_text_manager_assertClassBrand(Ju,this,_toggleTitleAndDisclaimer).call(this)});d.addEventListener("input",()=>{new_alt_text_manager_assertClassBrand(Ju,this,_toggleTitleAndDisclaimer).call(this)});d.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||c.disabled||new_alt_text_manager_assertClassBrand(Ju,this,new_alt_text_manager_save).call(this)});i.on("enableguessalttext",e=>{let t=e.value;new_alt_text_manager_assertClassBrand(Ju,this,_toggleGuessAltText).call(this,t,!1)},Ih);new_alt_text_manager_classPrivateFieldGet(qu,this).register(s);new_alt_text_manager_classPrivateFieldGet(zu,this).addEventListener("click",()=>{new_alt_text_manager_classPrivateFieldGet(Eu,this)._reportTelemetry({action:"pdfjs.image.alt_text.info",data:{topic:"alt_text"}})})}async editAltText(e,t,i){if(new_alt_text_manager_classPrivateFieldGet(Eu,this)||!t)return;if(i&&t.hasAltTextData()){t.altTextFinish();return}new_alt_text_manager_classPrivateFieldSet(Ou,this,i);const a=e.mlManager,s=!!a;new_alt_text_manager_assertClassBrand(Ju,this,_toggleTitleAndDisclaimer).call(this);a&&!a.isReady("altText")?a.hasProgress?new_alt_text_manager_assertClassBrand(Ju,this,_setProgress).call(this):new_alt_text_manager_classPrivateFieldGet(ku,this).setAttribute("aria-pressed",!1):new_alt_text_manager_classPrivateFieldGet(Mu,this).classList.toggle("hidden",!0);const r=a?.isEnabledFor("altText");new_alt_text_manager_classPrivateFieldSet(Eu,this,t);new_alt_text_manager_classPrivateFieldSet(Yu,this,e);new_alt_text_manager_classPrivateFieldGet(Yu,this).removeEditListeners();new_alt_text_manager_toSetter(new_alt_text_manager_classPrivateFieldSet,[Zu,this])._=t.altTextData.altText;new_alt_text_manager_classPrivateFieldGet(Xu,this).value=new_alt_text_manager_classPrivateFieldGet(Zu,this)??"";let n,o,l;if(a){var c=t.copyCanvas(224,180,!0);n=c.canvas;o=c.width;l=c.height;new_alt_text_manager_toSetter(new_alt_text_manager_classPrivateFieldSet,[Uu,this])._=c.imageData;s&&new_alt_text_manager_assertClassBrand(Ju,this,_toggleGuessAltText).call(this,await r,!0)}else{var d=t.copyCanvas(224,180,!1);n=d.canvas;o=d.width;l=d.height}n.setAttribute("role","presentation");const h=n.style;h.width=`${o}px`;h.height=`${l}px`;new_alt_text_manager_classPrivateFieldGet(Wu,this).append(n);new_alt_text_manager_assertClassBrand(Ju,this,_toggleNotNow).call(this);new_alt_text_manager_assertClassBrand(Ju,this,_toggleAI).call(this,s);new_alt_text_manager_assertClassBrand(Ju,this,_toggleError).call(this,!1);try{await new_alt_text_manager_classPrivateFieldGet(qu,this).open(new_alt_text_manager_classPrivateFieldGet(Gu,this))}catch(e){new_alt_text_manager_assertClassBrand(Ju,this,_close).call(this);throw e}}destroy(){new_alt_text_manager_classPrivateFieldSet(Yu,this,null);new_alt_text_manager_assertClassBrand(Ju,this,_finish).call(this)}}function _setPref(e,t){new_alt_text_manager_classPrivateFieldGet(Lu,this).dispatch("setpreference",{source:this,name:e,value:t})}function _toggleLoading(e){if(new_alt_text_manager_classPrivateFieldGet(Yu,this)&&new_alt_text_manager_classPrivateFieldGet(Vu,this)!==e){new_alt_text_manager_classPrivateFieldSet(Vu,this,e);new_alt_text_manager_classPrivateFieldGet(Iu,this).classList.toggle("loading",e)}}function _toggleError(e){new_alt_text_manager_classPrivateFieldGet(Yu,this)&&new_alt_text_manager_classPrivateFieldGet(Gu,this).classList.toggle("error",e)}async function _toggleGuessAltText(e,t){if(new_alt_text_manager_classPrivateFieldGet(Yu,this)){new_alt_text_manager_classPrivateFieldGet(Gu,this).classList.toggle("aiDisabled",!e);new_alt_text_manager_classPrivateFieldGet(ku,this).setAttribute("aria-pressed",e);if(e){const e=new_alt_text_manager_classPrivateFieldGet(Yu,this).mlManager.altTextLearnMoreUrl;e&&(new_alt_text_manager_classPrivateFieldGet(zu,this).href=e);new_alt_text_manager_assertClassBrand(Ju,this,_mlGuessAltText).call(this,t)}else{new_alt_text_manager_assertClassBrand(Ju,this,_toggleLoading).call(this,!1);new_alt_text_manager_classPrivateFieldSet(Vu,this,!1);new_alt_text_manager_assertClassBrand(Ju,this,_toggleTitleAndDisclaimer).call(this)}}}function _toggleNotNow(){new_alt_text_manager_classPrivateFieldGet($u,this).classList.toggle("hidden",!new_alt_text_manager_classPrivateFieldGet(Ou,this));new_alt_text_manager_classPrivateFieldGet(Tu,this).classList.toggle("hidden",new_alt_text_manager_classPrivateFieldGet(Ou,this))}function _toggleAI(e){if(new_alt_text_manager_classPrivateFieldGet(Yu,this)&&new_alt_text_manager_classPrivateFieldGet(Nu,this)!==e){new_alt_text_manager_classPrivateFieldSet(Nu,this,e);new_alt_text_manager_classPrivateFieldGet(Gu,this).classList.toggle("noAi",!e);new_alt_text_manager_assertClassBrand(Ju,this,_toggleTitleAndDisclaimer).call(this)}}function _toggleTitleAndDisclaimer(){const e=new_alt_text_manager_classPrivateFieldGet(Vu,this)||new_alt_text_manager_classPrivateFieldGet(Ru,this)&&new_alt_text_manager_classPrivateFieldGet(Ru,this)===new_alt_text_manager_classPrivateFieldGet(Xu,this).value;new_alt_text_manager_classPrivateFieldGet(Bu,this).hidden=!e;const t=new_alt_text_manager_classPrivateFieldGet(Vu,this)||!!new_alt_text_manager_classPrivateFieldGet(Xu,this).value;if(new_alt_text_manager_classPrivateFieldGet(ju,this)!==t){new_alt_text_manager_classPrivateFieldSet(ju,this,t);new_alt_text_manager_classPrivateFieldGet(Ku,this).setAttribute("data-l10n-id",t?"pdfjs-editor-new-alt-text-dialog-edit-label":"pdfjs-editor-new-alt-text-dialog-add-label")}}async function _mlGuessAltText(e){if(new_alt_text_manager_classPrivateFieldGet(Vu,this))return;if(new_alt_text_manager_classPrivateFieldGet(Xu,this).value)return;if(e&&null!==new_alt_text_manager_classPrivateFieldGet(Zu,this))return;new_alt_text_manager_classPrivateFieldSet(Ru,this,new_alt_text_manager_classPrivateFieldGet(Eu,this).guessedAltText);if(null===new_alt_text_manager_classPrivateFieldGet(Zu,this)&&new_alt_text_manager_classPrivateFieldGet(Ru,this)){new_alt_text_manager_assertClassBrand(Ju,this,_addAltText).call(this,new_alt_text_manager_classPrivateFieldGet(Ru,this));return}new_alt_text_manager_assertClassBrand(Ju,this,_toggleLoading).call(this,!0);new_alt_text_manager_assertClassBrand(Ju,this,_toggleTitleAndDisclaimer).call(this);let t=!1;try{const e=await new_alt_text_manager_classPrivateFieldGet(Eu,this).mlGuessAltText(new_alt_text_manager_classPrivateFieldGet(Uu,this),!1);if(e){new_alt_text_manager_classPrivateFieldSet(Ru,this,e);new_alt_text_manager_classPrivateFieldSet(Hu,this,new_alt_text_manager_classPrivateFieldGet(Vu,this));new_alt_text_manager_classPrivateFieldGet(Vu,this)&&new_alt_text_manager_assertClassBrand(Ju,this,_addAltText).call(this,e)}}catch(e){console.error(e);t=!0}new_alt_text_manager_assertClassBrand(Ju,this,_toggleLoading).call(this,!1);new_alt_text_manager_assertClassBrand(Ju,this,_toggleTitleAndDisclaimer).call(this);t&&new_alt_text_manager_classPrivateFieldGet(Yu,this)&&new_alt_text_manager_assertClassBrand(Ju,this,_toggleError).call(this,!0)}function _addAltText(e){if(new_alt_text_manager_classPrivateFieldGet(Yu,this)&&!new_alt_text_manager_classPrivateFieldGet(Xu,this).value){new_alt_text_manager_classPrivateFieldGet(Xu,this).value=e;new_alt_text_manager_assertClassBrand(Ju,this,_toggleTitleAndDisclaimer).call(this)}}function _setProgress(){new_alt_text_manager_classPrivateFieldGet(Mu,this).classList.toggle("hidden",!1);const callback=async e=>{let t=e.detail,i=t.finished,a=t.total,s=t.totalLoaded;const r=1e6;s=Math.min(.99*a,s);const n=new_alt_text_manager_classPrivateFieldGet(Du,this).ariaValueMax=Math.round(a/r),o=new_alt_text_manager_classPrivateFieldGet(Du,this).ariaValueNow=Math.round(s/r);new_alt_text_manager_classPrivateFieldGet(Du,this).setAttribute("data-l10n-args",JSON.stringify({totalSize:n,downloadedSize:o}));if(!i)return;new_alt_text_manager_classPrivateFieldGet(Lu,this).off("loadaiengineprogress",callback);new_alt_text_manager_classPrivateFieldGet(Mu,this).classList.toggle("hidden",!0);new_alt_text_manager_assertClassBrand(Ju,this,_toggleAI).call(this,!0);if(!new_alt_text_manager_classPrivateFieldGet(Yu,this))return;const l=new_alt_text_manager_classPrivateFieldGet(Yu,this).mlManager;l.toggleService("altText",!0);new_alt_text_manager_assertClassBrand(Ju,this,_toggleGuessAltText).call(this,await l.isEnabledFor("altText"),!0)};new_alt_text_manager_classPrivateFieldGet(Lu,this).on("loadaiengineprogress",callback,Ih)}function _cancel(){new_alt_text_manager_classPrivateFieldGet(Eu,this).altTextData={cancel:!0};const e=new_alt_text_manager_classPrivateFieldGet(Xu,this).value.trim();new_alt_text_manager_classPrivateFieldGet(Eu,this)._reportTelemetry({action:"pdfjs.image.alt_text.dismiss",data:{alt_text_type:e?"present":"empty",flow:new_alt_text_manager_classPrivateFieldGet(Ou,this)?"image_add":"alt_text_edit"}});new_alt_text_manager_classPrivateFieldGet(Eu,this)._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!0,alt_text_type:"skipped"}});new_alt_text_manager_assertClassBrand(Ju,this,_finish).call(this)}function _finish(){new_alt_text_manager_classPrivateFieldGet(qu,this).closeIfActive(new_alt_text_manager_classPrivateFieldGet(Gu,this))}function _close(){const e=new_alt_text_manager_classPrivateFieldGet(Wu,this).firstElementChild;e.remove();e.width=e.height=0;new_alt_text_manager_classPrivateFieldSet(Uu,this,null);new_alt_text_manager_assertClassBrand(Ju,this,_toggleLoading).call(this,!1);new_alt_text_manager_classPrivateFieldGet(Yu,this)?.addEditListeners();new_alt_text_manager_classPrivateFieldGet(Eu,this).altTextFinish();new_alt_text_manager_classPrivateFieldGet(Yu,this)?.setSelected(new_alt_text_manager_classPrivateFieldGet(Eu,this));new_alt_text_manager_classPrivateFieldSet(Eu,this,null);new_alt_text_manager_classPrivateFieldSet(Yu,this,null)}function _extractWords(e){return new Set(e.toLowerCase().split(/[^\p{L}\p{N}]+/gu).filter(e=>!!e))}function new_alt_text_manager_save(){const e=new_alt_text_manager_classPrivateFieldGet(Xu,this).value.trim();new_alt_text_manager_classPrivateFieldGet(Eu,this).altTextData={altText:e,decorative:!1};new_alt_text_manager_classPrivateFieldGet(Eu,this).altTextData.guessedAltText=new_alt_text_manager_classPrivateFieldGet(Ru,this);if(new_alt_text_manager_classPrivateFieldGet(Ru,this)&&new_alt_text_manager_classPrivateFieldGet(Ru,this)!==e){const t=new_alt_text_manager_assertClassBrand(Ju,this,_extractWords).call(this,new_alt_text_manager_classPrivateFieldGet(Ru,this)),i=new_alt_text_manager_assertClassBrand(Ju,this,_extractWords).call(this,e);new_alt_text_manager_classPrivateFieldGet(Eu,this)._reportTelemetry({action:"pdfjs.image.alt_text.user_edit",data:{total_words:t.size,words_removed:t.difference(i).size,words_added:i.difference(t).size}})}new_alt_text_manager_classPrivateFieldGet(Eu,this)._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!0,alt_text_type:e?"present":"empty"}});new_alt_text_manager_classPrivateFieldGet(Eu,this)._reportTelemetry({action:"pdfjs.image.alt_text.save",data:{alt_text_type:e?"present":"empty",flow:new_alt_text_manager_classPrivateFieldGet(Ou,this)?"image_add":"alt_text_edit"}});new_alt_text_manager_assertClassBrand(Ju,this,_finish).call(this)}var Qu=new WeakMap,e_=new WeakMap,t_=new WeakMap,i_=new WeakMap,a_=new WeakMap,s_=new WeakMap,r_=new WeakSet;class ImageAltTextSettings{constructor(e,t,i,a){let s=e.dialog,r=e.createModelButton,n=e.learnMore,o=e.closeButton,l=e.showAltTextDialogButton;new_alt_text_manager_classPrivateMethodInitSpec(this,r_);new_alt_text_manager_classPrivateFieldInitSpec(this,Qu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,e_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,t_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,i_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,a_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,s_,void 0);new_alt_text_manager_classPrivateFieldSet(e_,this,s);new_alt_text_manager_classPrivateFieldSet(Qu,this,r);new_alt_text_manager_classPrivateFieldSet(s_,this,l);new_alt_text_manager_classPrivateFieldSet(a_,this,t);new_alt_text_manager_classPrivateFieldSet(t_,this,i);new_alt_text_manager_classPrivateFieldSet(i_,this,a);const c=a.altTextLearnMoreUrl;c&&(n.href=c);s.addEventListener("contextmenu",noContextMenu);r.addEventListener("click",async e=>{const t=new_alt_text_manager_assertClassBrand(r_,this,_togglePref).call(this,"enableGuessAltText",e);await(t?new_alt_text_manager_assertClassBrand(r_,this,new_alt_text_manager_download).call(this,!0):new_alt_text_manager_assertClassBrand(r_,this,_delete).call(this,!0));await a.toggleService("altText",t);new_alt_text_manager_assertClassBrand(r_,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.settings_ai_generation_check",data:{status:t}})});l.addEventListener("click",e=>{const t=new_alt_text_manager_assertClassBrand(r_,this,_togglePref).call(this,"enableNewAltTextWhenAddingImage",e);new_alt_text_manager_assertClassBrand(r_,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.settings_edit_alt_text_check",data:{status:t}})});o.addEventListener("click",new_alt_text_manager_assertClassBrand(r_,this,_finish2).bind(this));n.addEventListener("click",()=>{new_alt_text_manager_assertClassBrand(r_,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.info",data:{topic:"ai_generation"}})});i.on("enablealttextmodeldownload",e=>{e.value?new_alt_text_manager_assertClassBrand(r_,this,new_alt_text_manager_download).call(this,!1):new_alt_text_manager_assertClassBrand(r_,this,_delete).call(this,!1)},Ih);new_alt_text_manager_classPrivateFieldGet(a_,this).register(s)}async open(e){let t=e.enableGuessAltText,i=e.enableNewAltTextWhenAddingImage;const a=new_alt_text_manager_classPrivateFieldGet(i_,this).enableAltTextModelDownload;new_alt_text_manager_classPrivateFieldGet(Qu,this).setAttribute("aria-pressed",a&&t);new_alt_text_manager_classPrivateFieldGet(s_,this).setAttribute("aria-pressed",i);await new_alt_text_manager_classPrivateFieldGet(a_,this).open(new_alt_text_manager_classPrivateFieldGet(e_,this));new_alt_text_manager_assertClassBrand(r_,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.settings_displayed"})}}function _reportTelemetry(e){new_alt_text_manager_classPrivateFieldGet(t_,this).dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}async function new_alt_text_manager_download(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0]){await new_alt_text_manager_classPrivateFieldGet(i_,this).downloadModel("altText");new_alt_text_manager_assertClassBrand(r_,this,_setPref2).call(this,"enableGuessAltText",!0);new_alt_text_manager_classPrivateFieldGet(i_,this).toggleService("altText",!0);new_alt_text_manager_assertClassBrand(r_,this,_setPref2).call(this,"enableAltTextModelDownload",!0)}}async function _delete(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0]){await new_alt_text_manager_classPrivateFieldGet(i_,this).deleteModel("altText");new_alt_text_manager_assertClassBrand(r_,this,_setPref2).call(this,"enableGuessAltText",!1);new_alt_text_manager_assertClassBrand(r_,this,_setPref2).call(this,"enableAltTextModelDownload",!1)}new_alt_text_manager_classPrivateFieldGet(Qu,this).setAttribute("aria-pressed",!1)}function _togglePref(e,t){let i=t.target;const a="true"!==i.getAttribute("aria-pressed");new_alt_text_manager_assertClassBrand(r_,this,_setPref2).call(this,e,a);i.setAttribute("aria-pressed",a);return a}function _setPref2(e,t){new_alt_text_manager_classPrivateFieldGet(t_,this).dispatch("setpreference",{source:this,name:e,value:t})}function _finish2(){new_alt_text_manager_classPrivateFieldGet(a_,this).closeIfActive(new_alt_text_manager_classPrivateFieldGet(e_,this))}function alt_text_manager_classPrivateFieldInitSpec(e,t,i){alt_text_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function alt_text_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function alt_text_manager_classPrivateFieldGet(e,t){return e.get(alt_text_manager_assertClassBrand(e,t))}function alt_text_manager_classPrivateFieldSet(e,t,i){return e.set(alt_text_manager_assertClassBrand(e,t),i),i}function alt_text_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var n_=new WeakMap,o_=new WeakMap,l_=new WeakMap,c_=new WeakMap,d_=new WeakMap,h_=new WeakMap,u_=new WeakMap,__=new WeakMap,p_=new WeakMap,g_=new WeakMap,f_=new WeakMap,m_=new WeakMap,v_=new WeakMap,y_=new WeakMap,P_=new WeakMap,w_=new WeakMap,b_=new WeakMap,F_=new WeakMap,S_=new WeakSet;class AltTextManager{constructor(e,t,i,a){let s=e.dialog,r=e.optionDescription,n=e.optionDecorative,o=e.textarea,l=e.cancelButton,c=e.saveButton;!function alt_text_manager_classPrivateMethodInitSpec(e,t){alt_text_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,S_);alt_text_manager_classPrivateFieldInitSpec(this,n_,null);alt_text_manager_classPrivateFieldInitSpec(this,o_,null);alt_text_manager_classPrivateFieldInitSpec(this,l_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,c_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,d_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,h_,!1);alt_text_manager_classPrivateFieldInitSpec(this,u_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,__,void 0);alt_text_manager_classPrivateFieldInitSpec(this,p_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,g_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,f_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,m_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,v_,null);alt_text_manager_classPrivateFieldInitSpec(this,y_,null);alt_text_manager_classPrivateFieldInitSpec(this,P_,null);alt_text_manager_classPrivateFieldInitSpec(this,w_,null);alt_text_manager_classPrivateFieldInitSpec(this,b_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,F_,null);alt_text_manager_classPrivateFieldSet(c_,this,s);alt_text_manager_classPrivateFieldSet(u_,this,r);alt_text_manager_classPrivateFieldSet(__,this,n);alt_text_manager_classPrivateFieldSet(f_,this,o);alt_text_manager_classPrivateFieldSet(l_,this,l);alt_text_manager_classPrivateFieldSet(g_,this,c);alt_text_manager_classPrivateFieldSet(p_,this,i);alt_text_manager_classPrivateFieldSet(d_,this,a);alt_text_manager_classPrivateFieldSet(b_,this,t);const d=alt_text_manager_assertClassBrand(S_,this,_updateUIState).bind(this);s.addEventListener("close",alt_text_manager_assertClassBrand(S_,this,alt_text_manager_close).bind(this));s.addEventListener("contextmenu",e=>{e.target!==alt_text_manager_classPrivateFieldGet(f_,this)&&e.preventDefault()});l.addEventListener("click",alt_text_manager_assertClassBrand(S_,this,alt_text_manager_finish).bind(this));c.addEventListener("click",alt_text_manager_assertClassBrand(S_,this,alt_text_manager_save).bind(this));r.addEventListener("change",d);n.addEventListener("change",d);o.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||c.disabled||alt_text_manager_assertClassBrand(S_,this,alt_text_manager_save).call(this)});alt_text_manager_classPrivateFieldGet(p_,this).register(s)}async editAltText(e,t){if(alt_text_manager_classPrivateFieldGet(o_,this)||!t)return;alt_text_manager_assertClassBrand(S_,this,_createSVGElement).call(this);alt_text_manager_classPrivateFieldSet(h_,this,!1);alt_text_manager_classPrivateFieldSet(n_,this,new AbortController);const i={signal:alt_text_manager_classPrivateFieldGet(n_,this).signal},a=alt_text_manager_assertClassBrand(S_,this,_onClick).bind(this);for(const e of[alt_text_manager_classPrivateFieldGet(u_,this),alt_text_manager_classPrivateFieldGet(__,this),alt_text_manager_classPrivateFieldGet(f_,this),alt_text_manager_classPrivateFieldGet(g_,this),alt_text_manager_classPrivateFieldGet(l_,this)])e.addEventListener("click",a,i);const s=t.altTextData,r=s.altText;if(!0===s.decorative){alt_text_manager_classPrivateFieldGet(__,this).checked=!0;alt_text_manager_classPrivateFieldGet(u_,this).checked=!1}else{alt_text_manager_classPrivateFieldGet(__,this).checked=!1;alt_text_manager_classPrivateFieldGet(u_,this).checked=!0}alt_text_manager_classPrivateFieldSet(v_,this,alt_text_manager_classPrivateFieldGet(f_,this).value=r?.trim()||"");alt_text_manager_assertClassBrand(S_,this,_updateUIState).call(this);alt_text_manager_classPrivateFieldSet(o_,this,t);alt_text_manager_classPrivateFieldSet(m_,this,e);alt_text_manager_classPrivateFieldGet(m_,this).removeEditListeners();alt_text_manager_classPrivateFieldSet(y_,this,new AbortController);alt_text_manager_classPrivateFieldGet(d_,this).on("resize",alt_text_manager_assertClassBrand(S_,this,alt_text_manager_setPosition).bind(this),{signal:alt_text_manager_classPrivateFieldGet(y_,this).signal,...Ih});try{await alt_text_manager_classPrivateFieldGet(p_,this).open(alt_text_manager_classPrivateFieldGet(c_,this));alt_text_manager_assertClassBrand(S_,this,alt_text_manager_setPosition).call(this)}catch(e){alt_text_manager_assertClassBrand(S_,this,alt_text_manager_close).call(this);throw e}}destroy(){alt_text_manager_classPrivateFieldSet(m_,this,null);alt_text_manager_assertClassBrand(S_,this,alt_text_manager_finish).call(this);alt_text_manager_classPrivateFieldGet(P_,this)?.remove();alt_text_manager_classPrivateFieldSet(P_,this,alt_text_manager_classPrivateFieldSet(w_,this,null))}}function _createSVGElement(){if(alt_text_manager_classPrivateFieldGet(P_,this))return;const e=new DOMSVGFactory,t=alt_text_manager_classPrivateFieldSet(P_,this,e.createElement("svg"));t.setAttribute("width","0");t.setAttribute("height","0");const i=e.createElement("defs");t.append(i);const a=e.createElement("mask");i.append(a);a.setAttribute("id","alttext-manager-mask");a.setAttribute("maskContentUnits","objectBoundingBox");let s=e.createElement("rect");a.append(s);s.setAttribute("fill","white");s.setAttribute("width","1");s.setAttribute("height","1");s.setAttribute("x","0");s.setAttribute("y","0");s=alt_text_manager_classPrivateFieldSet(w_,this,e.createElement("rect"));a.append(s);s.setAttribute("fill","black");alt_text_manager_classPrivateFieldGet(c_,this).append(t)}function alt_text_manager_setPosition(){if(!alt_text_manager_classPrivateFieldGet(o_,this))return;const e=alt_text_manager_classPrivateFieldGet(c_,this),t=e.style,i=alt_text_manager_classPrivateFieldGet(b_,this).getBoundingClientRect(),a=i.x,s=i.y,r=i.width,n=i.height,o=window,l=o.innerWidth,c=o.innerHeight,d=e.getBoundingClientRect(),h=d.width,u=d.height,_=alt_text_manager_classPrivateFieldGet(o_,this).getClientDimensions(),p=_.x,g=_.y,f=_.width,m=_.height,v=10,y="ltr"===alt_text_manager_classPrivateFieldGet(m_,this).direction,P=Math.max(p,a),w=Math.min(p+f,a+r),b=Math.max(g,s),S=Math.min(g+m,s+n);alt_text_manager_classPrivateFieldGet(w_,this).setAttribute("width",""+(w-P)/l);alt_text_manager_classPrivateFieldGet(w_,this).setAttribute("height",""+(S-b)/c);alt_text_manager_classPrivateFieldGet(w_,this).setAttribute("x",""+P/l);alt_text_manager_classPrivateFieldGet(w_,this).setAttribute("y",""+b/c);let C=null,A=Math.max(g,0);A+=Math.min(c-(A+u),0);y?p+f+v+h<l?C=p+f+v:p>h+v&&(C=p-h-v):p>h+v?C=p-h-v:p+f+v+h<l&&(C=p+f+v);if(null===C){A=null;C=Math.max(p,0);C+=Math.min(l-(C+h),0);g>u+v?A=g-u-v:g+m+v+u<c&&(A=g+m+v)}if(null!==A){e.classList.add("positioned");y?t.left=`${C}px`:t.right=l-C-h+"px";t.top=`${A}px`}else{e.classList.remove("positioned");t.left="";t.top=""}}function alt_text_manager_finish(){alt_text_manager_classPrivateFieldGet(p_,this).closeIfActive(alt_text_manager_classPrivateFieldGet(c_,this))}function alt_text_manager_close(){alt_text_manager_classPrivateFieldGet(o_,this)._reportTelemetry(alt_text_manager_classPrivateFieldGet(F_,this)||{action:"alt_text_cancel",alt_text_keyboard:!alt_text_manager_classPrivateFieldGet(h_,this)});alt_text_manager_classPrivateFieldSet(F_,this,null);alt_text_manager_assertClassBrand(S_,this,_removeOnClickListeners).call(this);alt_text_manager_classPrivateFieldGet(m_,this)?.addEditListeners();alt_text_manager_classPrivateFieldGet(y_,this)?.abort();alt_text_manager_classPrivateFieldSet(y_,this,null);alt_text_manager_classPrivateFieldGet(o_,this).altTextFinish();alt_text_manager_classPrivateFieldSet(o_,this,null);alt_text_manager_classPrivateFieldSet(m_,this,null)}function _updateUIState(){alt_text_manager_classPrivateFieldGet(f_,this).disabled=alt_text_manager_classPrivateFieldGet(__,this).checked}function alt_text_manager_save(){const e=alt_text_manager_classPrivateFieldGet(f_,this).value.trim(),t=alt_text_manager_classPrivateFieldGet(__,this).checked;alt_text_manager_classPrivateFieldGet(o_,this).altTextData={altText:e,decorative:t};alt_text_manager_classPrivateFieldSet(F_,this,{action:"alt_text_save",alt_text_description:!!e,alt_text_edit:!!alt_text_manager_classPrivateFieldGet(v_,this)&&alt_text_manager_classPrivateFieldGet(v_,this)!==e,alt_text_decorative:t,alt_text_keyboard:!alt_text_manager_classPrivateFieldGet(h_,this)});alt_text_manager_assertClassBrand(S_,this,alt_text_manager_finish).call(this)}function _onClick(e){if(0!==e.detail){alt_text_manager_classPrivateFieldSet(h_,this,!0);alt_text_manager_assertClassBrand(S_,this,_removeOnClickListeners).call(this)}}function _removeOnClickListeners(){alt_text_manager_classPrivateFieldGet(n_,this)?.abort();alt_text_manager_classPrivateFieldSet(n_,this,null)}function annotation_editor_params_slicedToArray(e,t){return function annotation_editor_params_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function annotation_editor_params_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function annotation_editor_params_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return annotation_editor_params_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?annotation_editor_params_arrayLikeToArray(e,t):void 0}}(e,t)||function annotation_editor_params_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function annotation_editor_params_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function annotation_editor_params_classPrivateMethodInitSpec(e,t){(function annotation_editor_params_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}var C_,A_=new WeakSet;class AnnotationEditorParams{constructor(e,t){annotation_editor_params_classPrivateMethodInitSpec(this,A_);this.eventBus=t;(function annotation_editor_params_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")})(A_,this,_bindListeners).call(this,e)}}function _bindListeners(e){let t=e.editorFreeTextFontSize,i=e.editorFreeTextColor,a=e.editorInkColor,s=e.editorInkThickness,r=e.editorInkOpacity,n=e.editorStampAddImage,o=e.editorFreeHighlightThickness,l=e.editorHighlightShowAll,c=e.editorSignatureAddSignature;const d=this.eventBus,dispatchEvent=(e,t)=>{d.dispatch("switchannotationeditorparams",{source:this,type:w[e],value:t})};t.addEventListener("input",function(){dispatchEvent("FREETEXT_SIZE",this.valueAsNumber)});i.addEventListener("input",function(){dispatchEvent("FREETEXT_COLOR",this.value)});let h,u;if(FeatureTest.isAlphaColorInputSupported){a.setAttribute("alpha","");r.closest(".editorParamsSetter")?.remove();let e="#000000",t=1;a.addEventListener("input",function(){const i=getRGBA(this.value);if(!i)return;const a=annotation_editor_params_slicedToArray(i,4),s=a[0],r=a[1],n=a[2],o=a[3],l=Util.makeHexColor(s,r,n);e=l;t=o;dispatchEvent("INK_COLOR_AND_OPACITY",{color:l,opacity:o})});h=i=>{e=i;const s=Util.hexNums[Math.round(255*t)];a.value=e+s};u=i=>{t=i;const s=Util.hexNums[Math.round(255*t)];a.value=e+s}}else{a.addEventListener("input",function(){dispatchEvent("INK_COLOR",this.value)});r.addEventListener("input",function(){dispatchEvent("INK_OPACITY",this.valueAsNumber)});h=e=>{a.value=e};u=e=>{r.value=e}}s.addEventListener("input",function(){dispatchEvent("INK_THICKNESS",this.valueAsNumber)});n.addEventListener("click",()=>{d.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{action:"pdfjs.image.add_image_click"}}});dispatchEvent("CREATE")});o.addEventListener("input",function(){dispatchEvent("HIGHLIGHT_THICKNESS",this.valueAsNumber)});l.addEventListener("click",function(){const e="true"===this.getAttribute("aria-pressed");this.setAttribute("aria-pressed",!e);dispatchEvent("HIGHLIGHT_SHOW_ALL",!e)});c?.addEventListener("click",()=>{dispatchEvent("CREATE")});d.on("annotationeditorparamschanged",e=>{for(const r of e.details){var a=annotation_editor_params_slicedToArray(r,2);const e=a[0],n=a[1];switch(e){case w.FREETEXT_SIZE:t.value=n;break;case w.FREETEXT_COLOR:i.value=n;break;case w.INK_COLOR:h(n);break;case w.INK_THICKNESS:s.value=n;break;case w.INK_OPACITY:u(n);break;case w.HIGHLIGHT_COLOR:d.dispatch("mainhighlightcolorpickerupdatecolor",{source:this,value:n});break;case w.HIGHLIGHT_THICKNESS:o.value=n;break;case w.HIGHLIGHT_FREE:o.disabled=!n;break;case w.HIGHLIGHT_SHOW_ALL:l.setAttribute("aria-pressed",n)}}},Ih)}function caret_browsing_slicedToArray(e,t){return function caret_browsing_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function caret_browsing_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function caret_browsing_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return caret_browsing_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?caret_browsing_arrayLikeToArray(e,t):void 0}}(e,t)||function caret_browsing_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function caret_browsing_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function caret_browsing_classPrivateFieldInitSpec(e,t,i){caret_browsing_checkPrivateRedeclaration(e,t),t.set(e,i)}function caret_browsing_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function caret_browsing_classPrivateFieldGet(e,t){return e.get(caret_browsing_assertClassBrand(e,t))}function caret_browsing_classPrivateFieldSet(e,t,i){return e.set(caret_browsing_assertClassBrand(e,t),i),i}function caret_browsing_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const x_=.1;var k_=new WeakMap,E_=new WeakMap,T_=new WeakMap,I_=new WeakSet;class CaretBrowsingMode{constructor(e,t,i,a){!function caret_browsing_classPrivateMethodInitSpec(e,t){caret_browsing_checkPrivateRedeclaration(e,t),t.add(e)}(this,I_);caret_browsing_classPrivateFieldInitSpec(this,k_,void 0);caret_browsing_classPrivateFieldInitSpec(this,E_,0);caret_browsing_classPrivateFieldInitSpec(this,T_,void 0);caret_browsing_classPrivateFieldSet(k_,this,t);caret_browsing_classPrivateFieldSet(T_,this,i);if(!a)return;caret_browsing_classPrivateFieldSet(E_,this,a.getBoundingClientRect().height);const s=new ResizeObserver(e=>{for(const t of e)if(t.target===a){caret_browsing_classPrivateFieldSet(E_,this,Math.floor(t.borderBoxSize[0].blockSize));break}});s.observe(a);e.addEventListener("abort",()=>s.disconnect(),{once:!0})}moveCaret(e,t){const i=document.getSelection();if(0===i.rangeCount)return;const a=i.focusNode,s=a.nodeType!==Node.ELEMENT_NODE?a.parentElement:a,r=s.closest(".textLayer");if(!r)return;const n=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);n.currentNode=a;const o=s.getBoundingClientRect();let l=null;const c=(e?n.previousSibling:n.nextSibling).bind(n);for(;c();){const e=n.currentNode.parentElement;if(!caret_browsing_assertClassBrand(I_,this,_isOnSameLine).call(this,o,e.getBoundingClientRect())){l=e;break}}if(!l){const s=caret_browsing_assertClassBrand(I_,this,_getNodeOnNextPage).call(this,r,e);if(!s)return;if(t){const t=(e?n.firstChild():n.lastChild())||a;i.extend(t,e?0:t.length);const r=document.createRange();r.setStart(s,e?s.length:0);r.setEnd(s,e?s.length:0);i.addRange(r);return}const o=caret_browsing_slicedToArray(caret_browsing_assertClassBrand(I_,this,_getCaretPosition).call(this,i,e),1)[0],l=s.parentElement;caret_browsing_assertClassBrand(I_,this,_setCaretPosition).call(this,t,i,l,l.getBoundingClientRect(),o);return}const d=caret_browsing_slicedToArray(caret_browsing_assertClassBrand(I_,this,_getCaretPosition).call(this,i,e),2),h=d[0],u=d[1],_=l.getBoundingClientRect();if(caret_browsing_assertClassBrand(I_,this,_isUnderOver).call(this,_,h,u,e))caret_browsing_assertClassBrand(I_,this,_setCaretPosition).call(this,t,i,l,_,h);else{for(;c();){const a=n.currentNode.parentElement,s=a.getBoundingClientRect();if(!caret_browsing_assertClassBrand(I_,this,_isOnSameLine).call(this,_,s))break;if(caret_browsing_assertClassBrand(I_,this,_isUnderOver).call(this,s,h,u,e)){caret_browsing_assertClassBrand(I_,this,_setCaretPosition).call(this,t,i,a,s,h);return}}caret_browsing_assertClassBrand(I_,this,_setCaretPosition).call(this,t,i,l,_,h)}}}C_=CaretBrowsingMode;function _isOnSameLine(e,t){const i=e.y,a=e.bottom,s=e.y+e.height/2,r=t.y,n=t.bottom,o=t.y+t.height/2;return i<=o&&o<=a||r<=s&&s<=n}function _isUnderOver(e,t,i,a){const s=e.y+e.height/2;return(a?i>=s:i<=s)&&e.x-x_<=t&&t<=e.right+x_}function _isVisible(e){return e.top>=caret_browsing_classPrivateFieldGet(E_,this)&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function _getCaretPosition(e,t){const i=e.focusNode,a=e.focusOffset,s=document.createRange();s.setStart(i,a);s.setEnd(i,a);const r=s.getBoundingClientRect();return[r.x,t?r.top:r.bottom]}function _caretPositionFromPoint(e,t){if(!document.caretPositionFromPoint){const i=document.caretRangeFromPoint(e,t);return{offsetNode:i.startContainer,offset:i.startOffset}}return document.caretPositionFromPoint(e,t)}function _setCaretPositionHelper(e,t,i,a,s){s||=a.getBoundingClientRect();if(t<=s.x+x_){i?e.extend(a.firstChild,0):e.setPosition(a.firstChild,0);return}if(s.right-x_<=t){const t=a.lastChild;i?e.extend(t,t.length):e.setPosition(t,t.length);return}const r=s.y+s.height/2;let n=_caretPositionFromPoint.call(C_,t,r),o=n.offsetNode?.parentElement;if(o&&o!==a){const e=document.elementsFromPoint(t,r),i=[];for(const t of e){if(t===a)break;const e=t.style;i.push([t,e.visibility]);e.visibility="hidden"}n=_caretPositionFromPoint.call(C_,t,r);o=n.offsetNode?.parentElement;for(const e of i){var l=caret_browsing_slicedToArray(e,2);const t=l[0],i=l[1];t.style.visibility=i}}o===a?i?e.extend(n.offsetNode,n.offset):e.setPosition(n.offsetNode,n.offset):i?e.extend(a.firstChild,0):e.setPosition(a.firstChild,0)}function _setCaretPosition(e,t,i,a,s){if(caret_browsing_assertClassBrand(I_,this,_isVisible).call(this,a))caret_browsing_assertClassBrand(I_,this,_setCaretPositionHelper).call(this,t,s,e,i,a);else{caret_browsing_classPrivateFieldGet(k_,this).addEventListener("scrollend",caret_browsing_assertClassBrand(I_,this,_setCaretPositionHelper).bind(this,t,s,e,i,null),{once:!0});i.scrollIntoView()}}function _getNodeOnNextPage(e,t){for(;;){const i=e.closest(".page"),a=parseInt(i.getAttribute("data-page-number"),10),s=t?a-1:a+1;if(!(e=caret_browsing_classPrivateFieldGet(T_,this).querySelector(`.page[data-page-number="${s}"] .textLayer`)))return null;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=t?r.lastChild():r.firstChild();if(n)return n}}function sidebar_slicedToArray(e,t){return function sidebar_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function sidebar_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function sidebar_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return sidebar_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?sidebar_arrayLikeToArray(e,t):void 0}}(e,t)||function sidebar_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function sidebar_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function sidebar_classPrivateFieldInitSpec(e,t,i){sidebar_checkPrivateRedeclaration(e,t),t.set(e,i)}function sidebar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function sidebar_classPrivateFieldGet(e,t){return e.get(sidebar_assertClassBrand(e,t))}function sidebar_classPrivateFieldSet(e,t,i){return e.set(sidebar_assertClassBrand(e,t),i),i}function sidebar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var G_=new WeakMap,B_=new WeakMap,M_=new WeakMap,D_=new WeakMap,L_=new WeakMap,O_=new WeakMap,R_=new WeakMap,N_=new WeakMap,j_=new WeakMap,W_=new WeakSet;class Sidebar{constructor(e,t,i,a){let s=e.sidebar,r=e.resizer;e.toggleButton;!function sidebar_classPrivateMethodInitSpec(e,t){sidebar_checkPrivateRedeclaration(e,t),t.add(e)}(this,W_);sidebar_classPrivateFieldInitSpec(this,G_,0);sidebar_classPrivateFieldInitSpec(this,B_,0);sidebar_classPrivateFieldInitSpec(this,M_,void 0);sidebar_classPrivateFieldInitSpec(this,D_,null);sidebar_classPrivateFieldInitSpec(this,L_,void 0);sidebar_classPrivateFieldInitSpec(this,O_,void 0);sidebar_classPrivateFieldInitSpec(this,R_,!1);sidebar_classPrivateFieldInitSpec(this,N_,void 0);sidebar_classPrivateFieldInitSpec(this,j_,0);if(!s){console.warn("[Sidebar] sidebar element is null, skipping initialization");this._sidebar=null;return}this._sidebar=s;sidebar_classPrivateFieldSet(M_,this,t===i?-1:1);sidebar_classPrivateFieldSet(L_,this,r);sidebar_classPrivateFieldSet(O_,this,i);const n=window.getComputedStyle(s);sidebar_classPrivateFieldSet(G_,this,sidebar_classPrivateFieldSet(B_,this,parseFloat(n.getPropertyValue("--sidebar-width"))));r.ariaValueMin=parseFloat(n.getPropertyValue("--sidebar-min-width"))||0;r.ariaValueMax=parseFloat(n.getPropertyValue("--sidebar-max-width"))||1/0;r.ariaValueNow=sidebar_classPrivateFieldGet(B_,this);sidebar_assertClassBrand(W_,this,_makeSidebarResizable).call(this);this._isOpen=!1;s.hidden=!0;a?.addEventListener("abort",this.destroy.bind(this),{once:!0});sidebar_classPrivateFieldSet(N_,this,new ResizeObserver(e=>{let t=sidebar_slicedToArray(e,1),i=sidebar_slicedToArray(t[0].borderBoxSize,1)[0].inlineSize;isNaN(sidebar_classPrivateFieldGet(j_,this))||sidebar_classPrivateFieldSet(j_,this,sidebar_classPrivateFieldGet(j_,this)+sidebar_classPrivateFieldGet(M_,this)*(i-sidebar_classPrivateFieldGet(B_,this)));sidebar_assertClassBrand(W_,this,_setWidth).call(this,i)}));sidebar_classPrivateFieldGet(N_,this).observe(s)}get width(){return sidebar_classPrivateFieldGet(B_,this)}set width(e){this._sidebar&&(this._sidebar.style.width=`${e}px`)}onStartResizing(){}onStopResizing(){}onResizing(e){}toggle(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!this._isOpen;this._sidebar&&(this._sidebar.hidden=!(this._isOpen=e))}destroy(){sidebar_classPrivateFieldGet(N_,this)?.disconnect();sidebar_classPrivateFieldSet(N_,this,null)}}function _makeSidebarResizable(){if(!this._sidebar)return;const e=this._sidebar.style;let t;const cancelResize=()=>{sidebar_classPrivateFieldSet(D_,this,null);this._sidebar.classList.remove("resizing");t?.abort();t=null;sidebar_classPrivateFieldSet(R_,this,!1);this.onStopResizing();sidebar_classPrivateFieldSet(j_,this,NaN)};sidebar_classPrivateFieldGet(L_,this).addEventListener("pointerdown",i=>{if(t){cancelResize();return}this.onStartResizing();const a=i.clientX;stopEvent(i);sidebar_classPrivateFieldSet(j_,this,a);t=new AbortController;const s=t.signal,r=this._sidebar;r.classList.add("resizing");r.parentElement.style.minWidth=0;window.addEventListener("contextmenu",noContextMenu,{signal:s});window.addEventListener("pointermove",i=>{if(t&&!(Math.abs(i.clientX-sidebar_classPrivateFieldGet(j_,this))<1)){stopEvent(i);e.width=`${Math.round(sidebar_classPrivateFieldGet(B_,this)+sidebar_classPrivateFieldGet(M_,this)*(i.clientX-sidebar_classPrivateFieldGet(j_,this)))}px`}},{signal:s,capture:!0});window.addEventListener("blur",cancelResize,{signal:s});window.addEventListener("pointerup",e=>{if(t){cancelResize();stopEvent(e)}},{signal:s})});sidebar_classPrivateFieldGet(L_,this).addEventListener("keydown",t=>{const i=t.key,a="ArrowLeft"===i;if(a||"ArrowRight"===i){if(!sidebar_classPrivateFieldGet(R_,this)){this._sidebar.classList.add("resizing");sidebar_classPrivateFieldSet(R_,this,!0);this.onStartResizing()}const i=(t.ctrlKey||t.metaKey?10:1)*(a?-1:1);clearTimeout(sidebar_classPrivateFieldGet(D_,this));sidebar_classPrivateFieldSet(D_,this,setTimeout(cancelResize,400));e.width=`${Math.round(sidebar_classPrivateFieldGet(B_,this)+sidebar_classPrivateFieldGet(M_,this)*i)}px`;stopEvent(t)}})}function _setWidth(e){sidebar_classPrivateFieldSet(B_,this,e);sidebar_classPrivateFieldGet(L_,this).ariaValueNow=Math.round(e);sidebar_classPrivateFieldGet(O_,this)&&this._sidebar?.parentElement&&(this._sidebar.parentElement.style.insetInlineStart=`${(sidebar_classPrivateFieldGet(G_,this)-e).toFixed(3)}px`);this.onResizing(e)}function comment_manager_classPrivateMethodInitSpec(e,t){comment_manager_checkPrivateRedeclaration(e,t),t.add(e)}function comment_manager_classPrivateFieldInitSpec(e,t,i){comment_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function comment_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function comment_manager_classPrivateFieldGet(e,t){return e.get(comment_manager_assertClassBrand(e,t))}function comment_manager_classPrivateFieldSet(e,t,i){return e.set(comment_manager_assertClassBrand(e,t),i),i}function comment_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var U_=new WeakMap,V_=new WeakMap,H_=new WeakMap;class CommentManager{constructor(e,t,i,a,s,r,n,o){comment_manager_classPrivateFieldInitSpec(this,U_,void 0);comment_manager_classPrivateFieldInitSpec(this,V_,void 0);comment_manager_classPrivateFieldInitSpec(this,H_,void 0);const l=new Intl.DateTimeFormat(void 0,{dateStyle:"long"});this.dialogElement=e.dialog;comment_manager_classPrivateFieldSet(U_,this,new CommentDialog(e,s,i,r));comment_manager_classPrivateFieldSet(V_,this,new CommentPopup(i,l,r,this.dialogElement));comment_manager_classPrivateFieldSet(H_,this,new CommentSidebar(t,i,a,comment_manager_classPrivateFieldGet(V_,this),l,r,o));comment_manager_classPrivateFieldGet(V_,this).sidebar=comment_manager_classPrivateFieldGet(H_,this);z_._=n}setSidebarUiManager(e){comment_manager_classPrivateFieldGet(H_,this).setUIManager(e)}showSidebar(e){comment_manager_classPrivateFieldGet(H_,this).show(e)}hideSidebar(){comment_manager_classPrivateFieldGet(H_,this).hide()}removeComments(e){comment_manager_classPrivateFieldGet(H_,this).removeComments(e)}selectComment(e){comment_manager_classPrivateFieldGet(H_,this).selectComment(null,e)}addComment(e){comment_manager_classPrivateFieldGet(H_,this).addComment(e)}updateComment(e){comment_manager_classPrivateFieldGet(H_,this).updateComment(e)}toggleCommentPopup(e,t,i,a){t&&this.selectComment(e.uid);comment_manager_classPrivateFieldGet(V_,this).toggle(e,t,i,a)}destroyPopup(){comment_manager_classPrivateFieldGet(V_,this).destroy()}updatePopupColor(e){comment_manager_classPrivateFieldGet(V_,this).updateColor(e)}showDialog(e,t,i,a,s){return comment_manager_classPrivateFieldGet(U_,this).open(e,t,i,a,s)}makeCommentColor(e,t){return CommentManager._makeCommentColor(e,t)}static _makeCommentColor(e,t){return comment_manager_assertClassBrand(CommentManager,this,z_)._?null:findContrastColor(applyOpacity(e,t??1),CSSConstants.commentForegroundColor)}destroy(){comment_manager_classPrivateFieldGet(U_,this).destroy();comment_manager_classPrivateFieldGet(H_,this).hide();comment_manager_classPrivateFieldGet(V_,this).destroy()}}var z_={_:null},$_=new WeakMap,q_=new WeakMap,X_=new WeakMap,K_=new WeakMap,Y_=new WeakMap,Z_=new WeakMap,J_=new WeakMap,Q_=new WeakMap,ep=new WeakMap,tp=new WeakMap,ip=new WeakMap,ap=new WeakMap,sp=new WeakMap,rp=new WeakMap,np=new WeakMap,op=new WeakSet;class CommentSidebar extends Sidebar{constructor(e,t,i,a,s,r,n){let o=e.learnMoreUrl,l=e.sidebar,c=e.sidebarResizer,d=e.commentsList,h=e.commentCount,u=e.sidebarTitle,_=e.closeButton,p=e.commentToolbarButton;super({sidebar:l,resizer:c,toggleButton:p},r,!0,n);comment_manager_classPrivateMethodInitSpec(this,op);comment_manager_classPrivateFieldInitSpec(this,$_,null);comment_manager_classPrivateFieldInitSpec(this,q_,void 0);comment_manager_classPrivateFieldInitSpec(this,X_,comment_manager_assertClassBrand(op,this,_commentClick).bind(this));comment_manager_classPrivateFieldInitSpec(this,K_,comment_manager_assertClassBrand(op,this,_commentKeydown).bind(this));comment_manager_classPrivateFieldInitSpec(this,Y_,void 0);comment_manager_classPrivateFieldInitSpec(this,Z_,void 0);comment_manager_classPrivateFieldInitSpec(this,J_,void 0);comment_manager_classPrivateFieldInitSpec(this,Q_,void 0);comment_manager_classPrivateFieldInitSpec(this,ep,void 0);comment_manager_classPrivateFieldInitSpec(this,tp,void 0);comment_manager_classPrivateFieldInitSpec(this,ip,void 0);comment_manager_classPrivateFieldInitSpec(this,ap,void 0);comment_manager_classPrivateFieldInitSpec(this,sp,null);comment_manager_classPrivateFieldInitSpec(this,rp,null);comment_manager_classPrivateFieldInitSpec(this,np,null);if(!l)return;comment_manager_classPrivateFieldSet(ep,this,u);comment_manager_classPrivateFieldSet(Z_,this,d);comment_manager_classPrivateFieldSet(J_,this,h);comment_manager_classPrivateFieldSet(tp,this,o);comment_manager_classPrivateFieldSet(ip,this,i);comment_manager_classPrivateFieldSet(Y_,this,_);comment_manager_classPrivateFieldSet(ap,this,a);comment_manager_classPrivateFieldSet(Q_,this,s);comment_manager_classPrivateFieldSet(q_,this,t);_.addEventListener("click",()=>{t.dispatch("switchannotationeditormode",{source:this,mode:P.NONE})});const keyDownCallback=e=>{if("ArrowDown"===e.key||"Home"===e.key||"F6"===e.key){comment_manager_classPrivateFieldGet(Z_,this).firstElementChild.focus();stopEvent(e)}else if("ArrowUp"===e.key||"End"===e.key){comment_manager_classPrivateFieldGet(Z_,this).lastElementChild.focus();stopEvent(e)}};p?.addEventListener("keydown",keyDownCallback);l.addEventListener("keydown",keyDownCallback)}setUIManager(e){comment_manager_classPrivateFieldSet(np,this,e)}show(e){comment_manager_classPrivateFieldSet(sp,this,new WeakMap);comment_manager_classPrivateFieldSet(rp,this,new Map);comment_manager_classPrivateFieldSet($_,this,e);e.sort(comment_manager_assertClassBrand(op,this,_sortComments).bind(this));if(0!==e.length){const t=document.createDocumentFragment();for(const i of e)t.append(comment_manager_assertClassBrand(op,this,_createCommentElement).call(this,i));comment_manager_assertClassBrand(op,this,_setCommentsCount).call(this,t);comment_manager_classPrivateFieldGet(Z_,this).append(t)}else comment_manager_assertClassBrand(op,this,_setCommentsCount).call(this);this._sidebar.hidden=!1;comment_manager_classPrivateFieldGet(q_,this).dispatch("reporttelemetry",{source:this,details:{type:"commentSidebar",data:{numberOfAnnotations:e.length}}})}hide(){this._sidebar.hidden=!0;comment_manager_classPrivateFieldGet(Z_,this).replaceChildren();comment_manager_classPrivateFieldSet(sp,this,null);comment_manager_classPrivateFieldSet(rp,this,null);comment_manager_classPrivateFieldSet($_,this,null)}removeComments(e){if(0!==e.length&&comment_manager_classPrivateFieldGet(rp,this))if(0!==new Set(comment_manager_classPrivateFieldGet(rp,this).keys()).difference(new Set(e)).size)for(const t of e)comment_manager_assertClassBrand(op,this,_removeComment).call(this,t);else comment_manager_assertClassBrand(op,this,_removeAll).call(this)}focusComment(e){const t=comment_manager_classPrivateFieldGet(rp,this).get(e);if(t){this._sidebar.scrollTop=t.offsetTop-this._sidebar.offsetTop;for(const e of comment_manager_classPrivateFieldGet(Z_,this).children)e.classList.toggle("selected",e===t)}}updateComment(e){if(!comment_manager_classPrivateFieldGet(rp,this))return;const t=e.id,i=e.creationDate,a=e.modificationDate,s=e.richText,r=e.contentsObj;e.popupRef&&(s||r?.str)||comment_manager_assertClassBrand(op,this,_removeComment).call(this,t);const n=comment_manager_classPrivateFieldGet(rp,this).get(t);if(!n)return;const o=comment_manager_classPrivateFieldGet(sp,this).get(n);let l=binarySearchFirstItem(comment_manager_classPrivateFieldGet($_,this),e=>comment_manager_assertClassBrand(op,this,_sortComments).call(this,e,o)>=0);if(!(l>=comment_manager_classPrivateFieldGet($_,this).length)){comment_manager_assertClassBrand(op,this,_setDate).call(this,n.firstElementChild,a||i);comment_manager_assertClassBrand(op,this,_setText).call(this,n.lastElementChild,s,r);comment_manager_classPrivateFieldGet($_,this).splice(l,1);l=binarySearchFirstItem(comment_manager_classPrivateFieldGet($_,this),t=>comment_manager_assertClassBrand(op,this,_sortComments).call(this,t,e)>=0);comment_manager_classPrivateFieldGet($_,this).splice(l,0,e);l>=comment_manager_classPrivateFieldGet(Z_,this).children.length?comment_manager_classPrivateFieldGet(Z_,this).append(n):comment_manager_classPrivateFieldGet(Z_,this).insertBefore(n,comment_manager_classPrivateFieldGet(Z_,this).children[l])}}selectComment(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!comment_manager_classPrivateFieldGet(rp,this))return;const i=!e;e||=comment_manager_classPrivateFieldGet(rp,this).get(t);for(const t of comment_manager_classPrivateFieldGet(Z_,this).children)t.classList.toggle("selected",t===e);i&&e?.scrollIntoView({behavior:"instant",block:"center"})}addComment(e){if(comment_manager_classPrivateFieldGet(rp,this)?.has(e.id))return;const t=e.popupRef,i=e.contentsObj;if(!t||!i?.str)return;const a=comment_manager_assertClassBrand(op,this,_createCommentElement).call(this,e);if(0===comment_manager_classPrivateFieldGet($_,this).length){comment_manager_classPrivateFieldGet(Z_,this).replaceChildren(a);comment_manager_classPrivateFieldGet($_,this).push(e);comment_manager_assertClassBrand(op,this,_setCommentsCount).call(this);return}const s=binarySearchFirstItem(comment_manager_classPrivateFieldGet($_,this),t=>comment_manager_assertClassBrand(op,this,_sortComments).call(this,t,e)>=0);comment_manager_classPrivateFieldGet($_,this).splice(s,0,e);s>=comment_manager_classPrivateFieldGet(Z_,this).children.length?comment_manager_classPrivateFieldGet(Z_,this).append(a):comment_manager_classPrivateFieldGet(Z_,this).insertBefore(a,comment_manager_classPrivateFieldGet(Z_,this).children[s]);comment_manager_assertClassBrand(op,this,_setCommentsCount).call(this)}}function _removeComment(e){const t=comment_manager_classPrivateFieldGet(rp,this)?.get(e);if(!t)return;const i=comment_manager_classPrivateFieldGet(sp,this).get(t),a=binarySearchFirstItem(comment_manager_classPrivateFieldGet($_,this),e=>comment_manager_assertClassBrand(op,this,_sortComments).call(this,e,i)>=0);if(!(a>=comment_manager_classPrivateFieldGet($_,this).length)){comment_manager_classPrivateFieldGet($_,this).splice(a,1);t.remove();comment_manager_classPrivateFieldGet(rp,this).delete(e);comment_manager_assertClassBrand(op,this,_setCommentsCount).call(this)}}function _removeAll(){comment_manager_classPrivateFieldGet(Z_,this).replaceChildren();comment_manager_classPrivateFieldSet(sp,this,new WeakMap);comment_manager_classPrivateFieldGet(rp,this).clear();comment_manager_classPrivateFieldGet($_,this).length=0;comment_manager_assertClassBrand(op,this,_setCommentsCount).call(this)}function _setCommentsCount(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:comment_manager_classPrivateFieldGet(Z_,this);const t=comment_manager_classPrivateFieldGet(rp,this).size;comment_manager_classPrivateFieldGet(ep,this).setAttribute("data-l10n-args",JSON.stringify({count:t}));comment_manager_classPrivateFieldGet(J_,this).textContent=t;0===t&&e.append(comment_manager_assertClassBrand(op,this,_createZeroCommentElement).call(this))}function _createZeroCommentElement(){const e=document.createElement("li");e.classList.add("sidebarComment","noComments");const t=document.createElement("div");t.className="sidebarCommentText";t.setAttribute("data-l10n-id","pdfjs-editor-comments-sidebar-no-comments1");e.append(t);if(comment_manager_classPrivateFieldGet(tp,this)){const t=document.createElement("a");t.setAttribute("data-l10n-id","pdfjs-editor-comments-sidebar-no-comments-link");t.href=comment_manager_classPrivateFieldGet(tp,this);t.target="_blank";t.rel="noopener noreferrer";e.append(t)}return e}function _setDate(e,t){t=PDFDateString.toDateObject(t);e.dateTime=t.toISOString();e.textContent=comment_manager_classPrivateFieldGet(Q_,this).format(t)}function _setText(e,t,i){e.replaceChildren();renderRichText({html:!t?.str||i?.str&&t.str!==i.str?i?.str:t.html,dir:i?.dir||"auto",className:"richText"},e)}function _createCommentElement(e){const t=e.id,i=e.creationDate,a=e.modificationDate,s=e.richText,r=e.contentsObj,n=e.color,o=e.opacity,l=document.createElement("li");l.role="button";l.className="sidebarComment";l.tabIndex=-1;l.style.backgroundColor=n&&CommentManager._makeCommentColor(n,o)||"";const c=document.createElement("time");comment_manager_assertClassBrand(op,this,_setDate).call(this,c,a||i);const d=document.createElement("div");d.className="sidebarCommentText";comment_manager_assertClassBrand(op,this,_setText).call(this,d,s,r);l.append(c,d);l.addEventListener("click",comment_manager_classPrivateFieldGet(X_,this));l.addEventListener("keydown",comment_manager_classPrivateFieldGet(K_,this));comment_manager_classPrivateFieldGet(sp,this).set(l,e);comment_manager_classPrivateFieldGet(rp,this).set(t,l);return l}async function _commentClick(e){let t=e.currentTarget;if(t.classList.contains("selected")){t.classList.remove("selected");comment_manager_classPrivateFieldGet(ap,this)._hide();return}const i=comment_manager_classPrivateFieldGet(sp,this).get(t);if(!i)return;comment_manager_classPrivateFieldGet(ap,this)._hide();const a=i.id,s=i.pageIndex,r=i.rect,n=s+1,o=comment_manager_classPrivateFieldGet(np,this)?.waitForEditorsRendered(n);comment_manager_classPrivateFieldGet(ip,this)?.goToXY(n,r[0],r[3],{center:"both"});this.selectComment(t);await o;comment_manager_classPrivateFieldGet(np,this)?.selectComment(s,a)}function _commentKeydown(e){const t=e.key,i=e.currentTarget;switch(t){case"ArrowDown":(i.nextElementSibling||comment_manager_classPrivateFieldGet(Z_,this).firstElementChild).focus();stopEvent(e);break;case"ArrowUp":(i.previousElementSibling||comment_manager_classPrivateFieldGet(Z_,this).lastElementChild).focus();stopEvent(e);break;case"Home":comment_manager_classPrivateFieldGet(Z_,this).firstElementChild.focus();stopEvent(e);break;case"End":comment_manager_classPrivateFieldGet(Z_,this).lastElementChild.focus();stopEvent(e);break;case"Enter":case" ":comment_manager_assertClassBrand(op,this,_commentClick).call(this,e);stopEvent(e);break;case"ShiftTab":comment_manager_classPrivateFieldGet(Y_,this).focus();stopEvent(e)}}function _sortComments(e,t){const i=PDFDateString.toDateObject(e.modificationDate||e.creationDate),a=PDFDateString.toDateObject(t.modificationDate||t.creationDate);return i!==a?null!==i&&null!==a?a-i:null!==i?-1:1:e.pageIndex!==t.pageIndex?e.pageIndex-t.pageIndex:e.rect[3]!==t.rect[3]?t.rect[3]-e.rect[3]:e.rect[0]!==t.rect[0]?e.rect[0]-t.rect[0]:e.rect[1]!==t.rect[1]?t.rect[1]-e.rect[1]:e.rect[2]!==t.rect[2]?e.rect[2]-t.rect[2]:e.id.localeCompare(t.id)}var lp=new WeakMap,cp=new WeakMap,dp=new WeakMap,hp=new WeakMap,up=new WeakMap,_p=new WeakMap,pp=new WeakMap,gp=new WeakMap,fp=new WeakMap,mp=new WeakMap,vp=new WeakMap,yp=new WeakMap,Pp=new WeakMap,wp=new WeakMap,bp=new WeakMap,Fp=new WeakSet;class CommentDialog{constructor(e,t,i,a){let s=e.dialog,r=e.toolbar,n=e.title,o=e.textInput,l=e.cancelButton,c=e.saveButton;comment_manager_classPrivateMethodInitSpec(this,Fp);comment_manager_classPrivateFieldInitSpec(this,lp,void 0);comment_manager_classPrivateFieldInitSpec(this,cp,void 0);comment_manager_classPrivateFieldInitSpec(this,dp,void 0);comment_manager_classPrivateFieldInitSpec(this,hp,"");comment_manager_classPrivateFieldInitSpec(this,up,"");comment_manager_classPrivateFieldInitSpec(this,_p,void 0);comment_manager_classPrivateFieldInitSpec(this,pp,void 0);comment_manager_classPrivateFieldInitSpec(this,gp,void 0);comment_manager_classPrivateFieldInitSpec(this,fp,void 0);comment_manager_classPrivateFieldInitSpec(this,mp,0);comment_manager_classPrivateFieldInitSpec(this,vp,0);comment_manager_classPrivateFieldInitSpec(this,yp,0);comment_manager_classPrivateFieldInitSpec(this,Pp,0);comment_manager_classPrivateFieldInitSpec(this,wp,void 0);comment_manager_classPrivateFieldInitSpec(this,bp,void 0);comment_manager_classPrivateFieldSet(lp,this,s);comment_manager_classPrivateFieldSet(_p,this,o);comment_manager_classPrivateFieldSet(dp,this,t);comment_manager_classPrivateFieldSet(bp,this,i);comment_manager_classPrivateFieldSet(gp,this,c);comment_manager_classPrivateFieldSet(pp,this,n);comment_manager_classPrivateFieldSet(wp,this,a);const d=comment_manager_assertClassBrand(Fp,this,comment_manager_finish).bind(this);s.addEventListener("close",d);s.addEventListener("contextmenu",e=>{e.target!==comment_manager_classPrivateFieldGet(_p,this)&&e.preventDefault()});l.addEventListener("click",d);c.addEventListener("click",comment_manager_assertClassBrand(Fp,this,comment_manager_save).bind(this));o.addEventListener("input",()=>{c.disabled=o.value===comment_manager_classPrivateFieldGet(hp,this)});o.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||c.disabled||comment_manager_assertClassBrand(Fp,this,comment_manager_save).call(this)});let h;const cancelDrag=()=>{s.classList.remove("dragging");h?.abort();h=null};r.addEventListener("pointerdown",e=>{if(h){cancelDrag();return}const t=e.clientX,i=e.clientY;stopEvent(e);comment_manager_classPrivateFieldSet(mp,this,t);comment_manager_classPrivateFieldSet(vp,this,i);h=new AbortController;const a=h.signal,r=window,n=r.innerHeight,o=r.innerWidth;s.classList.add("dragging");window.addEventListener("pointermove",e=>{if(!h)return;const t=e.clientX,i=e.clientY;comment_manager_assertClassBrand(Fp,this,comment_manager_setPosition).call(this,comment_manager_classPrivateFieldGet(yp,this)+(t-comment_manager_classPrivateFieldGet(mp,this))/o,comment_manager_classPrivateFieldGet(Pp,this)+(i-comment_manager_classPrivateFieldGet(vp,this))/n);comment_manager_classPrivateFieldSet(mp,this,t);comment_manager_classPrivateFieldSet(vp,this,i);stopEvent(e)},{signal:a});window.addEventListener("blur",cancelDrag,{signal:a});window.addEventListener("pointerup",e=>{if(h){cancelDrag();stopEvent(e)}},{signal:a})});t.register(s)}async open(e,t,i,a,s){if(t){comment_manager_classPrivateFieldSet(fp,this,e);comment_manager_classPrivateFieldSet(cp,this,t)}const r=t.getData(),n=r.contentsObj.str,o=r.color,l=r.opacity,c=comment_manager_classPrivateFieldGet(lp,this).style;if(o){c.backgroundColor=CommentManager._makeCommentColor(o,l);c.borderColor=Util.makeHexColor(...o)}else c.backgroundColor=c.borderColor="";comment_manager_classPrivateFieldSet(up,this,n||"");const d=comment_manager_classPrivateFieldGet(_p,this);d.value=comment_manager_classPrivateFieldSet(hp,this,comment_manager_classPrivateFieldGet(up,this));if(n){comment_manager_classPrivateFieldGet(pp,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-title-when-editing");comment_manager_classPrivateFieldGet(gp,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-save-button-when-editing")}else{comment_manager_classPrivateFieldGet(pp,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-title-when-adding");comment_manager_classPrivateFieldGet(gp,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-save-button-when-adding")}s?.height&&(d.style.height=`${s.height}px`);comment_manager_classPrivateFieldGet(fp,this)?.removeEditListeners();comment_manager_classPrivateFieldGet(gp,this).disabled=!0;const h=s?.parentDimensions,u=window,_=u.innerHeight,p=u.innerWidth;if(t.hasDefaultPopupPosition()){const e=this._dialogDimensions,t=e.dialogWidth,r=e.dialogHeight;if(h)if(comment_manager_classPrivateFieldGet(wp,this)&&i+t>Math.min(h.x+h.width,p)){i-=t-comment_manager_classPrivateFieldGet(cp,this).commentButtonWidth*h.width}else if(!comment_manager_classPrivateFieldGet(wp,this)){const e=comment_manager_classPrivateFieldGet(cp,this).commentButtonWidth*h.width;i-t<Math.max(0,h.x)?i=Math.max(0,i):i-=t-e}const n=Math.max(r,s?.height||0);a+n>_&&(a=_-n);a<0&&(a=0)}i=MathClamp(i/p,0,1);a=MathClamp(a/_,0,1);comment_manager_assertClassBrand(Fp,this,comment_manager_setPosition).call(this,i,a);await comment_manager_classPrivateFieldGet(dp,this).open(comment_manager_classPrivateFieldGet(lp,this));d.focus()}get _dialogDimensions(){const e=comment_manager_classPrivateFieldGet(lp,this),t=e.style;t.opacity="0";t.display="block";const i=e.getBoundingClientRect(),a=i.width,s=i.height;t.opacity=t.display="";return shadow(this,"_dialogDimensions",{dialogWidth:a,dialogHeight:s})}destroy(){comment_manager_classPrivateFieldSet(fp,this,null);comment_manager_classPrivateFieldSet(cp,this,null);comment_manager_assertClassBrand(Fp,this,comment_manager_finish).call(this)}}async function comment_manager_save(){comment_manager_classPrivateFieldGet(cp,this).comment=comment_manager_classPrivateFieldGet(_p,this).value;comment_manager_assertClassBrand(Fp,this,comment_manager_finish).call(this)}function comment_manager_setPosition(e,t){comment_manager_classPrivateFieldSet(yp,this,e);comment_manager_classPrivateFieldSet(Pp,this,t);const i=comment_manager_classPrivateFieldGet(lp,this).style;i.left=100*e+"%";i.top=100*t+"%"}function comment_manager_finish(){if(!comment_manager_classPrivateFieldGet(cp,this))return;const e=comment_manager_classPrivateFieldGet(_p,this).value!==comment_manager_classPrivateFieldGet(up,this);comment_manager_classPrivateFieldGet(bp,this).dispatch("reporttelemetry",{source:this,details:{type:"comment",data:{edited:e}}});e&&comment_manager_classPrivateFieldGet(bp,this)?.dispatch("annotation-editor-event",{source:this,type:comment_manager_classPrivateFieldGet(_p,this).value?"commented":"commentRemoved",page:comment_manager_classPrivateFieldGet(cp,this).pageIndex+1,id:comment_manager_classPrivateFieldGet(cp,this).uid,editorType:comment_manager_classPrivateFieldGet(cp,this).constructor.name,value:comment_manager_classPrivateFieldGet(cp,this)});comment_manager_classPrivateFieldGet(cp,this)?.focusCommentButton();comment_manager_classPrivateFieldSet(cp,this,null);comment_manager_classPrivateFieldGet(_p,this).value=comment_manager_classPrivateFieldSet(hp,this,comment_manager_classPrivateFieldSet(up,this,""));comment_manager_classPrivateFieldGet(dp,this).closeIfActive(comment_manager_classPrivateFieldGet(lp,this));comment_manager_classPrivateFieldGet(_p,this).style.height="";comment_manager_classPrivateFieldGet(fp,this)?.addEditListeners();comment_manager_classPrivateFieldSet(fp,this,null)}var Sp=new WeakMap,Cp=new WeakMap,Ap=new WeakMap,xp=new WeakMap,kp=new WeakMap,Ep=new WeakMap,Tp=new WeakMap,Ip=new WeakMap,Gp=new WeakMap,Bp=new WeakMap,Mp=new WeakMap,Dp=new WeakMap,Lp=new WeakMap,Op=new WeakMap,Rp=new WeakMap,Np=new WeakMap,jp=new WeakSet;class CommentPopup{constructor(e,t,i,a){comment_manager_classPrivateMethodInitSpec(this,jp);comment_manager_classPrivateFieldInitSpec(this,Sp,null);comment_manager_classPrivateFieldInitSpec(this,Cp,void 0);comment_manager_classPrivateFieldInitSpec(this,Ap,void 0);comment_manager_classPrivateFieldInitSpec(this,xp,void 0);comment_manager_classPrivateFieldInitSpec(this,kp,null);comment_manager_classPrivateFieldInitSpec(this,Ep,void 0);comment_manager_classPrivateFieldInitSpec(this,Tp,null);comment_manager_classPrivateFieldInitSpec(this,Ip,null);comment_manager_classPrivateFieldInitSpec(this,Gp,null);comment_manager_classPrivateFieldInitSpec(this,Bp,0);comment_manager_classPrivateFieldInitSpec(this,Mp,0);comment_manager_classPrivateFieldInitSpec(this,Dp,0);comment_manager_classPrivateFieldInitSpec(this,Lp,0);comment_manager_classPrivateFieldInitSpec(this,Op,null);comment_manager_classPrivateFieldInitSpec(this,Rp,!1);comment_manager_classPrivateFieldInitSpec(this,Np,!1);comment_manager_classPrivateFieldSet(Cp,this,e);comment_manager_classPrivateFieldSet(xp,this,t);comment_manager_classPrivateFieldSet(Ep,this,i);comment_manager_classPrivateFieldSet(Ap,this,a);this.sidebar=null}get _popupWidth(){const e=document.createElement("ngx-extended-pdf-viewer");e.style.opacity="0";e.style.display="block";const t=document.createElement("div");t.classList.add("zoom");e.append(t);const i=comment_manager_assertClassBrand(jp,this,comment_manager_createPopup).call(this);i.style.display="block";t.append(i);document.body.append(e);const a=i.getBoundingClientRect().width;i.remove();e.remove();i.style.display="";return shadow(this,"_popupWidth",a)}updateColor(e){if(comment_manager_classPrivateFieldGet(kp,this)!==e||!comment_manager_classPrivateFieldGet(Np,this))return;const t=e.getData(),i=t.color,a=t.opacity;comment_manager_classPrivateFieldGet(Tp,this).style.backgroundColor=i&&CommentManager._makeCommentColor(i,a)||""}_hide(e){const t=comment_manager_assertClassBrand(jp,this,comment_manager_createPopup).call(this);t.classList.toggle("hidden",!0);t.classList.toggle("selected",!1);(e||comment_manager_classPrivateFieldGet(kp,this))?.setCommentButtonStates({selected:!1,hasPopup:!1});comment_manager_classPrivateFieldSet(kp,this,null);comment_manager_classPrivateFieldSet(Rp,this,!1);comment_manager_classPrivateFieldSet(Np,this,!1);comment_manager_classPrivateFieldGet(Ip,this).replaceChildren();this.sidebar.selectComment(null)}toggle(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!e){this.destroy();return}if(t)i??=comment_manager_classPrivateFieldGet(kp,this)!==e||(!comment_manager_classPrivateFieldGet(Rp,this)||!comment_manager_classPrivateFieldGet(Np,this));else{if(comment_manager_classPrivateFieldGet(Rp,this))return;i??=!comment_manager_classPrivateFieldGet(Np,this)}if(!i){this._hide(e);return}comment_manager_classPrivateFieldSet(Np,this,!0);comment_manager_classPrivateFieldGet(kp,this)!==e&&comment_manager_classPrivateFieldGet(kp,this)?.setCommentButtonStates({selected:!1,hasPopup:!1});const s=comment_manager_assertClassBrand(jp,this,comment_manager_createPopup).call(this);comment_manager_classPrivateFieldGet(Sp,this).classList.toggle("hidden",!a);s.classList.toggle("hidden",!1);s.classList.toggle("selected",t);comment_manager_classPrivateFieldSet(Rp,this,t);comment_manager_classPrivateFieldSet(kp,this,e);e.setCommentButtonStates({selected:t,hasPopup:!0});const r=e.getData(),n=r.contentsObj,o=r.richText,l=r.creationDate,c=r.modificationDate,d=r.color,h=r.opacity;s.style.backgroundColor=d&&CommentManager._makeCommentColor(d,h)||"";comment_manager_classPrivateFieldGet(Ip,this).replaceChildren();const u=!o?.str||n?.str&&o.str!==n.str?n?.str:o.html;u&&renderRichText({html:u,dir:n?.dir||"auto",className:"richText"},comment_manager_classPrivateFieldGet(Ip,this));comment_manager_classPrivateFieldGet(Gp,this).textContent=comment_manager_classPrivateFieldGet(xp,this).format(PDFDateString.toDateObject(c||l));comment_manager_assertClassBrand(jp,this,_setPosition2).call(this,...e.commentPopupPosition,e.hasDefaultPopupPosition());e.elementBeforePopup.after(s);s.addEventListener("focus",e=>{let t=e.relatedTarget;comment_manager_classPrivateFieldSet(Op,this,t)},{once:!0});t&&setTimeout(()=>s.focus(),0)}destroy(){this._hide();comment_manager_classPrivateFieldGet(Tp,this)?.remove();comment_manager_classPrivateFieldSet(Tp,this,comment_manager_classPrivateFieldSet(Ip,this,comment_manager_classPrivateFieldSet(Gp,this,null)));comment_manager_classPrivateFieldSet(Bp,this,comment_manager_classPrivateFieldSet(Mp,this,1/0));comment_manager_classPrivateFieldSet(Dp,this,comment_manager_classPrivateFieldSet(Lp,this,0));comment_manager_classPrivateFieldSet(Op,this,null)}}function comment_manager_createPopup(){if(comment_manager_classPrivateFieldGet(Tp,this))return comment_manager_classPrivateFieldGet(Tp,this);const e=comment_manager_classPrivateFieldSet(Tp,this,document.createElement("div"));e.className="commentPopup";e.id="commentPopup";e.tabIndex=-1;e.role="dialog";e.ariaModal="false";e.addEventListener("contextmenu",noContextMenu);e.addEventListener("keydown",e=>{if("Escape"===e.key){this.toggle(comment_manager_classPrivateFieldGet(kp,this),!0,!1);comment_manager_classPrivateFieldGet(Op,this)?.focus();stopEvent(e)}});e.addEventListener("click",()=>{e.focus()});const t=document.createElement("div");t.className="commentPopupTop";const i=comment_manager_classPrivateFieldSet(Gp,this,document.createElement("time"));i.className="commentPopupTime";const a=comment_manager_classPrivateFieldSet(Sp,this,document.createElement("div"));a.className="commentPopupButtons";const s=document.createElement("button");s.classList.add("commentPopupEdit","toolbarButton");s.tabIndex=0;s.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-popup-button");s.ariaHasPopup="dialog";s.ariaControlsElements=[comment_manager_classPrivateFieldGet(Ap,this)];const r=document.createElement("span");r.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-popup-button-label");s.append(r);s.addEventListener("click",()=>{const e=comment_manager_classPrivateFieldGet(kp,this),t=parseFloat(getComputedStyle(comment_manager_classPrivateFieldGet(Ip,this)).height);this.toggle(e,!0,!1);e.editComment({height:t})});s.addEventListener("contextmenu",noContextMenu);const n=document.createElement("button");n.classList.add("commentPopupDelete","toolbarButton");n.tabIndex=0;n.setAttribute("data-l10n-id","pdfjs-editor-delete-comment-popup-button");const o=document.createElement("span");o.setAttribute("data-l10n-id","pdfjs-editor-delete-comment-popup-button-label");n.append(o);n.addEventListener("click",()=>{comment_manager_classPrivateFieldGet(Cp,this).dispatch("reporttelemetry",{source:this,details:{type:"comment",data:{deleted:!0}}});const e=comment_manager_classPrivateFieldGet(kp,this),t=e.comment;comment_manager_classPrivateFieldGet(Cp,this)?.dispatch("annotation-editor-event",{source:this,type:"commentRemoved",page:e.pageIndex+1,id:e.uid,editorType:e.constructor.name,value:e});this.destroy();t?.text?e._uiManager.deleteComment(e,t):e.comment=null;e.focus()});n.addEventListener("contextmenu",noContextMenu);a.append(s,n);t.append(i,a);const l=document.createElement("hr"),c=comment_manager_classPrivateFieldSet(Ip,this,document.createElement("div"));c.className="commentPopupText";e.append(t,l,c);let d;const cancelDrag=()=>{e.classList.remove("dragging");d?.abort();d=null};t.addEventListener("pointerdown",t=>{if(d){cancelDrag();return}const i=t.target,s=t.clientX,r=t.clientY;if(a.contains(i))return;stopEvent(t);const n=comment_manager_classPrivateFieldGet(kp,this).parentBoundingClientRect,o=n.width,l=n.height;comment_manager_classPrivateFieldSet(Bp,this,s);comment_manager_classPrivateFieldSet(Mp,this,r);d=new AbortController;const c=d.signal;e.classList.add("dragging");window.addEventListener("pointermove",e=>{if(!d)return;const t=e.clientX,i=e.clientY;comment_manager_assertClassBrand(jp,this,_setPosition2).call(this,comment_manager_classPrivateFieldGet(Dp,this)+(t-comment_manager_classPrivateFieldGet(Bp,this))/o,comment_manager_classPrivateFieldGet(Lp,this)+(i-comment_manager_classPrivateFieldGet(Mp,this))/l,!1);comment_manager_classPrivateFieldSet(Bp,this,t);comment_manager_classPrivateFieldSet(Mp,this,i);stopEvent(e)},{signal:c});window.addEventListener("blur",cancelDrag,{signal:c});window.addEventListener("pointerup",e=>{if(d){cancelDrag();stopEvent(e)}},{signal:c})});return e}function _setPosition2(e,t,i){if(i){const t=comment_manager_classPrivateFieldGet(kp,this).parentBoundingClientRect,i=this._popupWidth/t.width;if(comment_manager_classPrivateFieldGet(Ep,this)&&e+i>1||!comment_manager_classPrivateFieldGet(Ep,this)&&e-i>=0){e-=i-comment_manager_classPrivateFieldGet(kp,this).commentButtonWidth}const a=.02;e=comment_manager_classPrivateFieldGet(Ep,this)?Math.max(e,-t.x/t.width+a):Math.min(e,(window.innerWidth-t.x)/t.width-i-a)}else comment_manager_classPrivateFieldGet(kp,this).commentPopupPosition=[e,t];comment_manager_classPrivateFieldSet(Dp,this,e);comment_manager_classPrivateFieldSet(Lp,this,t);const a=comment_manager_classPrivateFieldGet(Tp,this).style;a.left=100*e+"%";a.top=100*t+"%"}function base_download_manager_classPrivateFieldInitSpec(e,t,i){(function base_download_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function base_download_manager_classPrivateFieldGet(e,t){return e.get(function base_download_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}var Wp=new WeakMap;class BaseDownloadManager{constructor(){base_download_manager_classPrivateFieldInitSpec(this,Wp,new WeakMap)}_triggerDownload(e,t,i){throw new Error("Not implemented: _triggerDownload")}_getOpenDataUrl(e,t){throw new Error("Not implemented: _getOpenDataUrl")}downloadData(e,t,i){const a=URL.createObjectURL(new Blob([e],{type:i}));this._triggerDownload(a,a,t,!0)}openOrDownloadData(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const a=isPdfFile(t),s=a?"application/pdf":"";if(a){const a=base_download_manager_classPrivateFieldGet(Wp,this).getOrInsertComputed(e,()=>URL.createObjectURL(new Blob([e],{type:s})));try{const e=this._getOpenDataUrl(a,t,i);window.open(e);return!0}catch(t){console.error("openOrDownloadData:",t);URL.revokeObjectURL(a);base_download_manager_classPrivateFieldGet(Wp,this).delete(e)}}this.downloadData(e,t,s);return!1}download(e,t,i){const a=e?URL.createObjectURL(new Blob([e],{type:"application/pdf"})):null;this._triggerDownload(a,t,i)}}class DownloadManager extends BaseDownloadManager{_triggerDownload(e,t,i){if(!e&&!(arguments.length>3&&void 0!==arguments[3]&&arguments[3])){if(!createValidAbsoluteUrl(t,"http://example.com"))throw new Error(`_triggerDownload - not a valid URL: ${t}`);e=t+"#pdfjs.action=download"}const a=document.createElement("a");a.href=e;a.target="_parent";"download"in a&&(a.download=i);(document.body||document.documentElement).append(a);a.click();a.remove()}_getOpenDataUrl(e,t){return e}}function editor_undo_bar_defineProperty(e,t,i){return(t=function editor_undo_bar_toPropertyKey(e){var t=function editor_undo_bar_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function editor_undo_bar_classPrivateFieldInitSpec(e,t,i){(function editor_undo_bar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function editor_undo_bar_classPrivateFieldGet(e,t){return e.get(editor_undo_bar_assertClassBrand(e,t))}function editor_undo_bar_classPrivateFieldSet(e,t,i){return e.set(editor_undo_bar_assertClassBrand(e,t),i),i}function editor_undo_bar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Up=new WeakMap,Vp=new WeakMap,Hp=new WeakMap,zp=new WeakMap,$p=new WeakMap,qp=new WeakMap,Xp=new WeakMap,Kp=new WeakMap;class EditorUndoBar{constructor(e,t){let i=e.container,a=e.message,s=e.undoButton,r=e.closeButton;editor_undo_bar_classPrivateFieldInitSpec(this,Up,null);editor_undo_bar_classPrivateFieldInitSpec(this,Vp,void 0);editor_undo_bar_classPrivateFieldInitSpec(this,Hp,null);editor_undo_bar_classPrivateFieldInitSpec(this,zp,null);editor_undo_bar_classPrivateFieldInitSpec(this,$p,null);editor_undo_bar_defineProperty(this,"isOpen",!1);editor_undo_bar_classPrivateFieldInitSpec(this,qp,void 0);editor_undo_bar_classPrivateFieldInitSpec(this,Xp,null);editor_undo_bar_classPrivateFieldInitSpec(this,Kp,void 0);editor_undo_bar_classPrivateFieldSet(Vp,this,i);editor_undo_bar_classPrivateFieldSet(qp,this,a);editor_undo_bar_classPrivateFieldSet(Kp,this,s);editor_undo_bar_classPrivateFieldSet(Up,this,r);editor_undo_bar_classPrivateFieldSet(Hp,this,t)}destroy(){editor_undo_bar_classPrivateFieldGet($p,this)?.abort();editor_undo_bar_classPrivateFieldSet($p,this,null);this.hide()}show(e,t){if(!editor_undo_bar_classPrivateFieldGet($p,this)){editor_undo_bar_classPrivateFieldSet($p,this,new AbortController);const e={signal:editor_undo_bar_classPrivateFieldGet($p,this).signal},t={signal:editor_undo_bar_classPrivateFieldGet($p,this).signal,...Ih},i=this.hide.bind(this);editor_undo_bar_classPrivateFieldGet(Vp,this).addEventListener("contextmenu",noContextMenu,e);editor_undo_bar_classPrivateFieldGet(Up,this).addEventListener("click",i,e);editor_undo_bar_classPrivateFieldGet(Hp,this).on("beforeprint",i,t);editor_undo_bar_classPrivateFieldGet(Hp,this).on("download",i,t)}this.hide();if("string"==typeof t)editor_undo_bar_classPrivateFieldGet(qp,this).setAttribute("data-l10n-id",Yp._[t]);else{editor_undo_bar_classPrivateFieldGet(qp,this).setAttribute("data-l10n-id",Yp._._multiple);editor_undo_bar_classPrivateFieldGet(qp,this).setAttribute("data-l10n-args",JSON.stringify({count:t}))}this.isOpen=!0;editor_undo_bar_classPrivateFieldGet(Vp,this).hidden=!1;editor_undo_bar_classPrivateFieldSet(Xp,this,new AbortController);editor_undo_bar_classPrivateFieldGet(Kp,this).addEventListener("click",()=>{e();this.hide()},{signal:editor_undo_bar_classPrivateFieldGet(Xp,this).signal});editor_undo_bar_classPrivateFieldSet(zp,this,setTimeout(()=>{editor_undo_bar_classPrivateFieldGet(Vp,this).contains(document.activeElement)||editor_undo_bar_classPrivateFieldGet(Vp,this).focus();editor_undo_bar_classPrivateFieldSet(zp,this,null)},100))}hide(){if(this.isOpen){this.isOpen=!1;editor_undo_bar_classPrivateFieldGet(Vp,this).hidden=!0;editor_undo_bar_classPrivateFieldGet(Xp,this)?.abort();editor_undo_bar_classPrivateFieldSet(Xp,this,null);if(editor_undo_bar_classPrivateFieldGet(zp,this)){clearTimeout(editor_undo_bar_classPrivateFieldGet(zp,this));editor_undo_bar_classPrivateFieldSet(zp,this,null)}}}}var Yp={_:Object.freeze({highlight:"pdfjs-editor-undo-bar-message-highlight",freetext:"pdfjs-editor-undo-bar-message-freetext",stamp:"pdfjs-editor-undo-bar-message-stamp",ink:"pdfjs-editor-undo-bar-message-ink",signature:"pdfjs-editor-undo-bar-message-signature",comment:"pdfjs-editor-undo-bar-message-comment",_multiple:"pdfjs-editor-undo-bar-message-multiple"})};function overlay_manager_classPrivateFieldInitSpec(e,t,i){(function overlay_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function overlay_manager_classPrivateFieldSet(e,t,i){return e.set(overlay_manager_assertClassBrand(e,t),i),i}function overlay_manager_classPrivateFieldGet(e,t){return e.get(overlay_manager_assertClassBrand(e,t))}function overlay_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Zp=new WeakMap,Jp=new WeakMap;class OverlayManager{constructor(){overlay_manager_classPrivateFieldInitSpec(this,Zp,new WeakMap);overlay_manager_classPrivateFieldInitSpec(this,Jp,null)}get active(){return overlay_manager_classPrivateFieldGet(Jp,this)}async register(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("object"!=typeof e)throw new Error("Not enough parameters.");if(overlay_manager_classPrivateFieldGet(Zp,this).has(e))throw new Error("The overlay is already registered.");overlay_manager_classPrivateFieldGet(Zp,this).set(e,{canForceClose:t});e.addEventListener("cancel",e=>{let t=e.target;overlay_manager_classPrivateFieldGet(Jp,this)===t&&overlay_manager_classPrivateFieldSet(Jp,this,null)})}unregister(e){if(!overlay_manager_classPrivateFieldGet(Zp,this).has(e))throw new Error("The overlay does not exist.");overlay_manager_classPrivateFieldGet(Zp,this).delete(e)}async open(e){if(!overlay_manager_classPrivateFieldGet(Zp,this).has(e))throw new Error("The overlay does not exist.");if(overlay_manager_classPrivateFieldGet(Jp,this)){if(overlay_manager_classPrivateFieldGet(Jp,this)===e)throw new Error("The overlay is already active.");if(!overlay_manager_classPrivateFieldGet(Zp,this).get(e).canForceClose)throw new Error("Another overlay is currently active.");await this.close()}overlay_manager_classPrivateFieldSet(Jp,this,e);e.showModal();e.classList.remove("hidden")}async close(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:overlay_manager_classPrivateFieldGet(Jp,this),t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!overlay_manager_classPrivateFieldGet(Zp,this).has(e)){if(t)return;throw new Error("The overlay does not exist.")}if(!overlay_manager_classPrivateFieldGet(Jp,this)){if(t)return;throw new Error("The overlay is currently not active.")}if(overlay_manager_classPrivateFieldGet(Jp,this)!==e){if(t)return;throw new Error("Another overlay is currently active.")}e.close();overlay_manager_classPrivateFieldSet(Jp,this,null)}async closeIfActive(e){overlay_manager_classPrivateFieldGet(Jp,this)===e&&await this.close(e)}}function password_prompt_classPrivateFieldInitSpec(e,t,i){password_prompt_checkPrivateRedeclaration(e,t),t.set(e,i)}function password_prompt_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function password_prompt_classPrivateFieldSet(e,t,i){return e.set(password_prompt_assertClassBrand(e,t),i),i}function password_prompt_classPrivateFieldGet(e,t){return e.get(password_prompt_assertClassBrand(e,t))}function password_prompt_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Qp=new WeakMap,eg=new WeakMap,tg=new WeakMap,ig=new WeakSet;class PasswordPrompt{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];!function password_prompt_classPrivateMethodInitSpec(e,t){password_prompt_checkPrivateRedeclaration(e,t),t.add(e)}(this,ig);password_prompt_classPrivateFieldInitSpec(this,Qp,null);password_prompt_classPrivateFieldInitSpec(this,eg,null);password_prompt_classPrivateFieldInitSpec(this,tg,null);this.dialog=e.dialog;this.label=e.label;this.input=e.input;this.submitButton=e.submitButton;this.cancelButton=e.cancelButton;this.overlayManager=t;this._isViewerEmbedded=i;this.submitButton.addEventListener("click",password_prompt_assertClassBrand(ig,this,_verify).bind(this));this.cancelButton.addEventListener("click",this.close.bind(this));this.input.addEventListener("keydown",e=>{13===e.keyCode&&password_prompt_assertClassBrand(ig,this,_verify).call(this)});this.overlayManager.register(this.dialog,!0);this.dialog.addEventListener("close",password_prompt_assertClassBrand(ig,this,password_prompt_cancel).bind(this))}async open(){await(password_prompt_classPrivateFieldGet(Qp,this)?.promise);password_prompt_classPrivateFieldSet(Qp,this,Promise.withResolvers());try{await this.overlayManager.open(this.dialog);this.input.type="password";this.input.focus()}catch(e){password_prompt_classPrivateFieldGet(Qp,this).resolve();throw e}const e=password_prompt_classPrivateFieldGet(tg,this)===H.INCORRECT_PASSWORD;this._isViewerEmbedded&&!e||this.input.focus();this.label.setAttribute("data-l10n-id",e?"pdfjs-password-invalid":"pdfjs-password-label")}async close(){this.overlayManager.closeIfActive(this.dialog);this.input.value="";this.input.type="text"}async setUpdateCallback(e,t){password_prompt_classPrivateFieldGet(Qp,this)&&await password_prompt_classPrivateFieldGet(Qp,this).promise;password_prompt_classPrivateFieldSet(eg,this,e);password_prompt_classPrivateFieldSet(tg,this,t)}}function _verify(){const e=this.input.value;e?.length>0&&password_prompt_assertClassBrand(ig,this,_invokeCallback).call(this,e)}function password_prompt_cancel(){password_prompt_assertClassBrand(ig,this,_invokeCallback).call(this,new Error("PasswordPrompt cancelled."));password_prompt_classPrivateFieldGet(Qp,this).resolve()}function _invokeCallback(e){if(password_prompt_classPrivateFieldGet(eg,this)){this.close();this.input.value="";password_prompt_classPrivateFieldGet(eg,this).call(this,e);password_prompt_classPrivateFieldSet(eg,this,null)}}const ag="selected";class BaseTreeViewer{constructor(e){this.container=e.container;this.eventBus=e.eventBus;this._l10n=e.l10n;this.reset()}reset(){this._pdfDocument=null;this._lastToggleIsShow=!0;this._currentTreeItem=null;this.container.replaceChildren();this.container.classList.remove("withNesting")}_dispatchEvent(e){throw new Error("Not implemented: _dispatchEvent")}_bindLink(e,t){throw new Error("Not implemented: _bindLink")}_normalizeTextContent(e){return removeNullCharacters(e,!0)||"–"}_addToggleButton(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=document.createElement("div");i.className="treeItemToggler";t&&i.classList.add("treeItemsHidden");e.prepend(i)}_toggleTreeItem(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._l10n.pause();this._lastToggleIsShow=t;for(const i of e.querySelectorAll(".treeItemToggler"))i.classList.toggle("treeItemsHidden",!t);this._l10n.resume()}_toggleAllTreeItems(){this._toggleTreeItem(this.container,!this._lastToggleIsShow)}_finishRendering(e,t){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]){this.container.classList.add("withNesting");this._lastToggleIsShow=!e.querySelector(".treeItemsHidden");this.container.addEventListener("click",e=>{const t=e.target;if(t.classList.contains("treeItemToggler")){stopEvent(e);t.classList.toggle("treeItemsHidden");if(e.shiftKey){const e=!t.classList.contains("treeItemsHidden");this._toggleTreeItem(t.parentNode,e)}}})}this._l10n.pause();this.container.append(e);this._l10n.resume();this._dispatchEvent(t)}render(e){throw new Error("Not implemented: render")}_updateCurrentTreeItem(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(this._currentTreeItem){this._currentTreeItem.classList.remove(ag);this._currentTreeItem=null}if(e){e.classList.add(ag);this._currentTreeItem=e}}_scrollToCurrentTreeItem(e){if(!e)return;this._l10n.pause();let t=e.parentNode;for(;t&&t!==this.container;){if(t.classList.contains("treeItem")){const e=t.firstElementChild;e?.classList.remove("treeItemsHidden")}t=t.parentNode}this._l10n.resume();this._updateCurrentTreeItem(e);e.scrollIntoView({behavior:"instant",block:"center",inline:"center",container:"nearest"})}}function pdf_attachment_viewer_classPrivateMethodInitSpec(e,t){(function pdf_attachment_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}var sg=new WeakSet;class PDFAttachmentViewer extends BaseTreeViewer{constructor(e){super(e);pdf_attachment_viewer_classPrivateMethodInitSpec(this,sg);this.downloadManager=e.downloadManager;this.eventBus.on("fileattachmentannotation",function pdf_attachment_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(sg,this,_appendAttachment).bind(this),Ih)}reset(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];super.reset();this._attachments=null;e||(this._renderedCapability=Promise.withResolvers());this._pendingDispatchEvent=!1}async _dispatchEvent(e){this._renderedCapability.resolve();if(0===e&&!this._pendingDispatchEvent){this._pendingDispatchEvent=!0;await waitOnEventOrTimeout({target:this.eventBus,name:"annotationlayerrendered",delay:1e3});if(!this._pendingDispatchEvent)return}this._pendingDispatchEvent=!1;this.eventBus.dispatch("attachmentsloaded",{source:this,attachmentsCount:e})}_bindLink(e,t){let i=t.content,a=t.description,s=t.filename;a&&(e.title=a);e.onclick=()=>{this.downloadManager.openOrDownloadData(i,s);return!1}}render(e){let t=e.attachments,i=e.keepRenderedCapability,a=void 0!==i&&i;this._attachments&&this.reset(a);this._attachments=t||null;if(!t){this._dispatchEvent(0);return}const s=document.createDocumentFragment(),r=document.createElement("ul");s.append(r);let n=0;for(const e in t){const i=t[e],a=document.createElement("li");r.append(a);const s=document.createElement("a");a.append(s);this._bindLink(s,i);s.textContent=this._normalizeTextContent(i.filename);n++}this._finishRendering(s,n)}}function _appendAttachment(e){const t=this._renderedCapability.promise;t.then(()=>{if(t!==this._renderedCapability.promise)return;const i=this._attachments||Object.create(null);for(const t in i)if(e.filename===t)return;i[e.filename]=e;this.render({attachments:i,keepRenderedCapability:!0})})}function grab_to_pan_classPrivateFieldInitSpec(e,t,i){grab_to_pan_checkPrivateRedeclaration(e,t),t.set(e,i)}function grab_to_pan_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function grab_to_pan_classPrivateFieldSet(e,t,i){return e.set(grab_to_pan_assertClassBrand(e,t),i),i}function grab_to_pan_classPrivateFieldGet(e,t){return e.get(grab_to_pan_assertClassBrand(e,t))}function grab_to_pan_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const rg="grab-to-pan-grab";var ng=new WeakMap,og=new WeakMap,lg=new WeakMap,cg=new WeakSet;class GrabToPan{constructor(e){let t=e.element;!function grab_to_pan_classPrivateMethodInitSpec(e,t){grab_to_pan_checkPrivateRedeclaration(e,t),t.add(e)}(this,cg);grab_to_pan_classPrivateFieldInitSpec(this,ng,null);grab_to_pan_classPrivateFieldInitSpec(this,og,null);grab_to_pan_classPrivateFieldInitSpec(this,lg,null);this.element=t;this.document=t.ownerDocument;(this.overlay=document.createElement("div")).className="grab-to-pan-grabbing"}activate(){if(!grab_to_pan_classPrivateFieldGet(ng,this)){grab_to_pan_classPrivateFieldSet(ng,this,new AbortController);this.element.addEventListener("mousedown",grab_to_pan_assertClassBrand(cg,this,_onMouseDown).bind(this),{capture:!0,signal:grab_to_pan_classPrivateFieldGet(ng,this).signal});this.element.classList.add(rg)}}deactivate(){if(grab_to_pan_classPrivateFieldGet(ng,this)){grab_to_pan_classPrivateFieldGet(ng,this).abort();grab_to_pan_classPrivateFieldSet(ng,this,null);grab_to_pan_assertClassBrand(cg,this,_endPan).call(this);this.element.classList.remove(rg)}}toggle(){grab_to_pan_classPrivateFieldGet(ng,this)?this.deactivate():this.activate()}ignoreTarget(e){return e.matches("a[href], a[href] *, input, textarea, button, button *, select, option")}}function _onMouseDown(e){if(0!==e.button||this.ignoreTarget(e.target))return;if(e.originalTarget)try{e.originalTarget.tagName}catch{return}this.scrollLeftStart=this.element.scrollLeft;this.scrollTopStart=this.element.scrollTop;this.clientXStart=e.clientX;this.clientYStart=e.clientY;if(isOverPerfectScrollbar(this.clientXStart,this.clientYStart,"ps__rail-x"))return;if(isOverPerfectScrollbar(this.clientXStart,this.clientYStart,"ps__rail-y"))return;grab_to_pan_classPrivateFieldSet(og,this,new AbortController);const t=grab_to_pan_assertClassBrand(cg,this,_endPan).bind(this),i={capture:!0,signal:grab_to_pan_classPrivateFieldGet(og,this).signal};this.document.addEventListener("mousemove",grab_to_pan_assertClassBrand(cg,this,_onMouseMove).bind(this),i);this.document.addEventListener("mouseup",t,i);grab_to_pan_classPrivateFieldSet(lg,this,new AbortController);this.element.addEventListener("scroll",t,{capture:!0,signal:grab_to_pan_classPrivateFieldGet(lg,this).signal});stopEvent(e);const a=document.activeElement;a&&!a.contains(e.target)&&a.blur()}function _onMouseMove(e){grab_to_pan_classPrivateFieldGet(lg,this)?.abort();grab_to_pan_classPrivateFieldSet(lg,this,null);if(!(1&e.buttons)){grab_to_pan_assertClassBrand(cg,this,_endPan).call(this);return}const t=e.clientX-this.clientXStart,i=e.clientY-this.clientYStart;this.element.scrollTo({top:this.scrollTopStart-i,left:this.scrollLeftStart-t,behavior:"instant"});this.overlay.parentNode||document.body.append(this.overlay)}function _endPan(){grab_to_pan_classPrivateFieldGet(og,this)?.abort();grab_to_pan_classPrivateFieldSet(og,this,null);grab_to_pan_classPrivateFieldGet(lg,this)?.abort();grab_to_pan_classPrivateFieldSet(lg,this,null);this.overlay.remove()}function isOverPerfectScrollbar(e,t,i){const a=document.getElementsByClassName(i);if(a&&1===a.length){var s=a[0].getBoundingClientRect(),r=s.top,n=s.right,o=s.bottom,l=s.left;if(t>=r&&t<=o&&e<=n&&e>=l)return!0}return!1}function pdf_cursor_tools_classPrivateFieldInitSpec(e,t,i){pdf_cursor_tools_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_cursor_tools_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_cursor_tools_classPrivateFieldSet(e,t,i){return e.set(pdf_cursor_tools_assertClassBrand(e,t),i),i}function pdf_cursor_tools_classPrivateFieldGet(e,t){return e.get(pdf_cursor_tools_assertClassBrand(e,t))}function pdf_cursor_tools_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var dg=new WeakMap,hg=new WeakMap,ug=new WeakSet;class PDFCursorTools{constructor(e){let t=e.container,i=e.eventBus,a=e.cursorToolOnLoad,s=void 0===a?fh:a;!function pdf_cursor_tools_classPrivateMethodInitSpec(e,t){pdf_cursor_tools_checkPrivateRedeclaration(e,t),t.add(e)}(this,ug);pdf_cursor_tools_classPrivateFieldInitSpec(this,dg,fh);pdf_cursor_tools_classPrivateFieldInitSpec(this,hg,null);this.container=t;this.eventBus=i;pdf_cursor_tools_assertClassBrand(ug,this,pdf_cursor_tools_addEventListeners).call(this);Promise.resolve().then(()=>{this.switchTool(s)})}get activeTool(){return pdf_cursor_tools_classPrivateFieldGet(dg,this)}switchTool(e){null===pdf_cursor_tools_classPrivateFieldGet(hg,this)&&pdf_cursor_tools_assertClassBrand(ug,this,_switchTool).call(this,e)}get _handTool(){return shadow(this,"_handTool",new GrabToPan({element:this.container}))}}function _switchTool(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e===pdf_cursor_tools_classPrivateFieldGet(dg,this)){null!==pdf_cursor_tools_classPrivateFieldGet(hg,this)&&this.eventBus.dispatch("cursortoolchanged",{source:this,tool:e,disabled:t});return}const disableActiveTool=()=>{switch(pdf_cursor_tools_classPrivateFieldGet(dg,this)){case fh:break;case mh:this._handTool.deactivate()}};switch(e){case fh:disableActiveTool();break;case mh:disableActiveTool();this._handTool.activate();break;case vh:disableActiveTool();break;default:ngx_console_NgxConsole.error(`switchTool: "${e}" is an unsupported value.`);return}pdf_cursor_tools_classPrivateFieldSet(dg,this,e);this.eventBus.dispatch("cursortoolchanged",{source:this,tool:e,disabled:t})}function pdf_cursor_tools_addEventListeners(){const e=this.eventBus;e.on("switchcursortool",e=>{if(e.reset){if(null!==pdf_cursor_tools_classPrivateFieldGet(hg,this)){t=P.NONE;i=ih;enableActive()}}else this.switchTool(e.tool)},Ih);let t=P.NONE,i=ih;const disableActive=()=>{pdf_cursor_tools_classPrivateFieldGet(hg,this)??pdf_cursor_tools_classPrivateFieldSet(hg,this,pdf_cursor_tools_classPrivateFieldGet(dg,this));pdf_cursor_tools_assertClassBrand(ug,this,_switchTool).call(this,fh,!0)},enableActive=()=>{if(null!==pdf_cursor_tools_classPrivateFieldGet(hg,this)&&t===P.NONE&&i===ih){pdf_cursor_tools_assertClassBrand(ug,this,_switchTool).call(this,pdf_cursor_tools_classPrivateFieldGet(hg,this));pdf_cursor_tools_classPrivateFieldSet(hg,this,null)}};e.on("annotationeditormodechanged",e=>{let i=e.mode;t=i;i===P.NONE?enableActive():disableActive()},Ih);e.on("presentationmodechanged",e=>{let t=e.state;i=t;t===ih?enableActive():t===sh&&disableActive()},Ih)}function pdf_document_properties_slicedToArray(e,t){return function pdf_document_properties_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_document_properties_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_document_properties_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_document_properties_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_document_properties_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_document_properties_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_document_properties_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pdf_document_properties_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_document_properties_classPrivateFieldSet(e,t,i){return e.set(pdf_document_properties_assertClassBrand(e,t),i),i}function pdf_document_properties_classPrivateFieldGet(e,t){return e.get(pdf_document_properties_assertClassBrand(e,t))}function pdf_document_properties_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const _g=["en-us","en-lr","my"],pg={"8.5x11":"pdfjs-document-properties-page-size-name-letter","8.5x14":"pdfjs-document-properties-page-size-name-legal"},gg={"297x420":"pdfjs-document-properties-page-size-name-a-three","210x297":"pdfjs-document-properties-page-size-name-a-four"};function getPageName(e,t,i){return i[`${t?e.width:e.height}x${t?e.height:e.width}`]}var fg=new WeakMap,mg=new WeakSet;class PDFDocumentProperties{constructor(e,t,i,a,s,r){let n=e.dialog,o=e.fields,l=e.closeButton;!function pdf_document_properties_classPrivateMethodInitSpec(e,t){pdf_document_properties_checkPrivateRedeclaration(e,t),t.add(e)}(this,mg);!function pdf_document_properties_classPrivateFieldInitSpec(e,t,i){pdf_document_properties_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,fg,null);this.dialog=n;this.fields=o;this.overlayManager=t;this.l10n=a;this._fileNameLookup=s;this.eventBus=i;this._titleLookup=r;pdf_document_properties_assertClassBrand(mg,this,_reset).call(this);l.addEventListener("click",this.close.bind(this));this.overlayManager.register(this.dialog);i.on("pagechanging",e=>{this._currentPageNumber=e.pageNumber},Ih);i.on("rotationchanging",e=>{this._pagesRotation=e.pagesRotation},Ih)}async open(){await Promise.all([this.overlayManager.open(this.dialog),this._dataAvailableCapability.promise]);this.eventBus.dispatch("propertiesdialogopen",this);const e=this._currentPageNumber,t=this._pagesRotation;if(pdf_document_properties_classPrivateFieldGet(fg,this)&&e===pdf_document_properties_classPrivateFieldGet(fg,this)._currentPageNumber&&t===pdf_document_properties_classPrivateFieldGet(fg,this)._pagesRotation){pdf_document_properties_assertClassBrand(mg,this,_updateUI).call(this);return}const i=pdf_document_properties_slicedToArray(await Promise.all([this.pdfDocument.getMetadata(),this.pdfDocument.getPage(e).catch(t=>{console.error(`PDFDocumentProperties - unable to get page ${e}.`,t);return null})]),2),a=i[0],s=a.info,r=a.metadata,n=a.contentLength,o=i[1],l=pdf_document_properties_slicedToArray(await Promise.all([this._fileNameLookup(),pdf_document_properties_assertClassBrand(mg,this,_parseFileSize).call(this,n),this._titleLookup(),pdf_document_properties_assertClassBrand(mg,this,_parseDate).call(this,r?.get("xmp:createdate"),s.CreationDate),pdf_document_properties_assertClassBrand(mg,this,_parseDate).call(this,r?.get("xmp:modifydate"),s.ModDate),pdf_document_properties_assertClassBrand(mg,this,_parsePageSize).call(this,o,t),pdf_document_properties_assertClassBrand(mg,this,_parseLinearization).call(this,s.IsLinearized)]),7),c=l[0],d=l[1],h=l[2],u=l[3],_=l[4],p=l[5],g=l[6];pdf_document_properties_classPrivateFieldSet(fg,this,Object.freeze({fileName:c,fileSize:d,title:h,author:r?.get("dc:creator")?.join("\n")||s.Author,subject:r?.get("dc:subject")?.join("\n")||s.Subject,keywords:r?.get("pdf:keywords")||s.Keywords,creationDate:u,modificationDate:_,creator:r?.get("xmp:creatortool")||s.Creator,producer:r?.get("pdf:producer")||s.Producer,version:s.PDFFormatVersion,pageCount:this.pdfDocument.numPages,pageSize:p,linearized:g,_currentPageNumber:e,_pagesRotation:t}));pdf_document_properties_assertClassBrand(mg,this,_updateUI).call(this);const f=(await this.pdfDocument.getDownloadInfo()).length;if(n===f)return;const m=Object.assign(Object.create(null),pdf_document_properties_classPrivateFieldGet(fg,this));m.fileSize=await pdf_document_properties_assertClassBrand(mg,this,_parseFileSize).call(this,f);pdf_document_properties_classPrivateFieldSet(fg,this,Object.freeze(m));pdf_document_properties_assertClassBrand(mg,this,_updateUI).call(this)}async close(){this.overlayManager.close(this.dialog,!0);this.eventBus.dispatch("propertiesdialogclose",this)}setDocument(e){if(this.pdfDocument){pdf_document_properties_assertClassBrand(mg,this,_reset).call(this);pdf_document_properties_assertClassBrand(mg,this,_updateUI).call(this)}if(e){this.pdfDocument=e;this._dataAvailableCapability.resolve()}}}function _reset(){this.pdfDocument=null;pdf_document_properties_classPrivateFieldSet(fg,this,null);this._dataAvailableCapability=Promise.withResolvers();this._currentPageNumber=1;this._pagesRotation=0}function _updateUI(){if(!pdf_document_properties_classPrivateFieldGet(fg,this)||this.overlayManager.active===this.dialog)for(const e in this.fields){const t=pdf_document_properties_classPrivateFieldGet(fg,this)?.[e];this.fields[e].textContent=t||0===t?t:"-"}}async function _parseFileSize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const t=e/1024,i=t/1024;return t?this.l10n.get(i>=1?"pdfjs-document-properties-size-mb":"pdfjs-document-properties-size-kb",{mb:i,kb:t,b:e}):void 0}async function _parsePageSize(e,t){if(!e)return;let i=function getPageSizeInches(e){let t=e.view,i=e.userUnit,a=e.rotate;const s=ui_utils_slicedToArray(t,4),r=s[0],n=s[1],o=a%180!=0,l=(s[2]-r)/72*i,c=(s[3]-n)/72*i;return{width:o?c:l,height:o?l:c}}(e);t%180!=0&&(i={width:i.height,height:i.width});const a=isPortraitOrientation(i),s=_g.includes(this.l10n.getLanguage());let r={width:Math.round(100*i.width)/100,height:Math.round(100*i.height)/100},n={width:Math.round(25.4*i.width*10)/10,height:Math.round(25.4*i.height*10)/10},o=getPageName(r,a,pg)||getPageName(n,a,gg);if(!(o||Number.isInteger(n.width)&&Number.isInteger(n.height))){const e={width:25.4*i.width,height:25.4*i.height},t={width:Math.round(n.width),height:Math.round(n.height)};if(Math.abs(e.width-t.width)<.1&&Math.abs(e.height-t.height)<.1){o=getPageName(t,a,gg);if(o){r={width:Math.round(t.width/25.4*100)/100,height:Math.round(t.height/25.4*100)/100};n=t}}}const l=pdf_document_properties_slicedToArray(await Promise.all([s?r:n,this.l10n.get(s?"pdfjs-document-properties-page-size-unit-inches":"pdfjs-document-properties-page-size-unit-millimeters"),o&&this.l10n.get(o),this.l10n.get(a?"pdfjs-document-properties-page-size-orientation-portrait":"pdfjs-document-properties-page-size-orientation-landscape")]),4),c=l[0],d=c.width,h=c.height,u=l[1],_=l[2],p=l[3];return this.l10n.get(_?"pdfjs-document-properties-page-size-dimension-name-string":"pdfjs-document-properties-page-size-dimension-string",{width:d,height:h,unit:u,name:_,orientation:p})}async function _parseDate(e,t){const i=Date.parse(e)||PDFDateString.toDateObject(t);return i?this.l10n.get("pdfjs-document-properties-date-time-string",{dateObj:i.valueOf()}):void 0}function _parseLinearization(e){return this.l10n.get(e?"pdfjs-document-properties-linearized-yes":"pdfjs-document-properties-linearized-no")}__webpack_require__(6069);const vg=0,yg=1,Pg=2,wg=3,bg=4,Fg=5,Sg=6,Cg=7;function getCharacterType(e){return function isAlphabeticalScript(e){return e<11904}(e)?function isAscii(e){return!(65408&e)}(e)?function isAsciiSpace(e){return 32===e||9===e||13===e||10===e}(e)?vg:function isAsciiAlpha(e){return e>=97&&e<=122||e>=65&&e<=90}(e)||function isAsciiDigit(e){return e>=48&&e<=57}(e)||95===e?yg:Pg:function isThai(e){return 3584==(65408&e)}(e)?Cg:160===e?vg:yg:function isHan(e){return e>=13312&&e<=40959||e>=63744&&e<=64255}(e)?wg:function isKatakana(e){return e>=12448&&e<=12543}(e)?bg:function isHiragana(e){return e>=12352&&e<=12447}(e)?Fg:function isHalfwidthKatakana(e){return e>=65376&&e<=65439}(e)?Sg:yg}let Ag;function pdf_find_controller_classPrivateFieldInitSpec(e,t,i){pdf_find_controller_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_find_controller_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_find_controller_classPrivateGetter(e,t,i){return i(pdf_find_controller_assertClassBrand(e,t))}function pdf_find_controller_classPrivateFieldGet(e,t){return e.get(pdf_find_controller_assertClassBrand(e,t))}function pdf_find_controller_classPrivateFieldSet(e,t,i){return e.set(pdf_find_controller_assertClassBrand(e,t),i),i}function pdf_find_controller_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function pdf_find_controller_slicedToArray(e,t){return function pdf_find_controller_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_find_controller_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_find_controller_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_find_controller_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_find_controller_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_find_controller_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_find_controller_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}const xg=0,kg=1,Eg=2,Tg=3,Ig={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},Gg=new Set([12441,12442,2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,3642,3770,3972,4153,4154,5908,5940,6098,6752,6980,7082,7083,7154,7155,11647,43014,43052,43204,43347,43456,43766,44013,3158,3953,3954,3962,3963,3964,3965,3968,3956]);let Bg;const Mg=/\p{M}+/gu,Dg=/([+^$|])|(\p{P}+)|(\s+)|(\p{M})|(\p{L})/gu,Lg=/(\P{M})\p{M}*$/u,Og=/^\p{M}*(\P{M})/u,Rg=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,Ng=new Map,jg=new Map;let Wg=null,Ug=null;function normalize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=[];let a;for(;null!==(a=Rg.exec(e));){let e=a.index;for(const t of a[0]){let a=Ng.get(t);if(!a){a=t.normalize("NFD").length;Ng.set(t,a)}i.push([a,e++])}}const s=i.length>0,r=t.ignoreDashEOL??!1;let n;if(!s&&Wg)n=Wg;else if(s&&Ug)n=Ug;else{const e=Object.keys(Ig).join(""),t=function getNormalizeWithNFKC(){if(!Ag){const e=[],t=[],i=/^\p{M}$/u;for(let a=0;a<65536;a++){if(a>=55296&&a<=57343)continue;const s=String.fromCharCode(a);if(s.normalize("NFKC")!==s&&!i.test(s)){if(2!==t.length){t[0]=t[1]=a;continue}if(t[1]+1!==a){t[0]===t[1]?e.push(String.fromCharCode(t[0])):e.push(`${String.fromCharCode(t[0])}-${String.fromCharCode(t[1])}`);t[0]=t[1]=a}else t[1]=a}}const a=e.join("");if(Ag){if(a!==Ag){for(let e=1;e<a.length;e++)if(a[e]!==Ag[e]){console.log(`Difference at index ${e}: U+${a.charCodeAt(e).toString(16).toUpperCase().padStart(4,"0")}!== U+${Ag.charCodeAt(e).toString(16).toUpperCase().padStart(4,"0")}`);break}throw new Error("getNormalizeWithNFKC - update the `NormalizeWithNFKC` string.")}}else Ag=a}return Ag}();n=new RegExp([`[${e}]`,`[${t}]`,`${"(?:゙|゚)"}\\n`,"\\p{M}+(?:-\\n)?",`${"\\p{Ll}-\\n(?=\\p{Ll})|\\p{Lu}-\\n(?=\\p{L})"}`,"\\S-\\n",`${"(?:\\p{Ideographic}|[-ヿ])"}\\n`,"\\n",s?"[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]":"\\u0000"].map(e=>`(${e})`).join("|"),"gmu");s?Ug=n:Wg=n}const o=[];for(;null!==(a=Mg.exec(e));)o.push([a[0].length,a.index]);let l=e.normalize("NFD");const c=[0,0];let d=0,h=0,u=0,_=0,p=0,g=!1;l=l.replace(n,(e,t,a,s,n,l,f,m,v,y,P)=>{P-=_;if(t){const e=Ig[t],i=e.length;for(let e=1;e<i;e++)c.push(P-u+e,u-e);u-=i-1;return e}if(a){let e=jg.get(a);if(!e){e=a.normalize("NFKC");jg.set(a,e)}const t=e.length;for(let e=1;e<t;e++)c.push(P-u+e,u-e);u-=t-1;return e}if(s){g=!0;if(P+p===o[d]?.[1])++d;else{c.push(P-1-u+1,u-1);u-=1;_+=1}c.push(P-u+1,u);_+=1;p+=1;return s.charAt(0)}if(n){const e=n.endsWith("\n"),t=e?n.length-2:n.length;g=!0;let i=t;if(P+p===o[d]?.[1]){i-=o[d][0];++d}for(let e=1;e<=i;e++)c.push(P-1-u+e,u-e);u-=i;_+=i;if(e){P+=t-1;c.push(P-u+1,1+u);u+=1;_+=1;p+=1;return n.slice(0,t)}return n}if(l){if(r){_+=1;p+=1;return l.slice(0,-1)}const e=l.length-2;c.push(P-u+e,1+u);u+=1;_+=1;p+=1;return l.slice(0,-2)}if(f){_+=1;p+=1;return f.slice(0,-1)}if(m){const e=m.length-1;c.push(P-u+e,u);_+=1;p+=1;return m.slice(0,-1)}if(v){c.push(P-u+1,u-1);u-=1;_+=1;p+=1;return" "}if(P+p===i[h]?.[1]){const e=i[h][0]-1;++h;for(let t=1;t<=e;t++)c.push(P-(u-t),u-t);u-=e;_+=e}return y});c.push(l.length,u);const f=new Uint32Array(c.length>>1),m=new Int32Array(c.length>>1);for(let e=0,t=c.length;e<t;e+=2){f[e>>1]=c[e];m[e>>1]=c[e+1]}return[l,[f,m],g]}function getOriginalIndex(e,t,i){if(!e)return[t,i];const a=pdf_find_controller_slicedToArray(e,2),s=a[0],r=a[1],n=t,o=t+i-1;let l=binarySearchFirstItem(s,e=>e>=n);s[l]>n&&--l;let c=binarySearchFirstItem(s,e=>e>=o,l);s[c]>o&&--c;const d=n+r[l];return[d,o+r[c]+1-d]}var Vg=new WeakMap,Hg=new WeakMap,zg=new WeakMap,$g=new WeakMap,qg=new WeakMap,Xg=new WeakMap,Kg=new WeakSet;class PDFFindController{constructor(e){let t=e.linkService,i=e.eventBus,a=e.delay,s=void 0===a?250:a,r=e.updateMatchesCountOnProgress,n=void 0===r||r,o=e.pageViewMode,l=e.listenToEventBus;!function pdf_find_controller_classPrivateMethodInitSpec(e,t){pdf_find_controller_checkPrivateRedeclaration(e,t),t.add(e)}(this,Kg);pdf_find_controller_classPrivateFieldInitSpec(this,Vg,null);pdf_find_controller_classPrivateFieldInitSpec(this,Hg,!0);pdf_find_controller_classPrivateFieldInitSpec(this,zg,0);pdf_find_controller_classPrivateFieldInitSpec(this,$g,0);pdf_find_controller_classPrivateFieldInitSpec(this,qg,null);pdf_find_controller_classPrivateFieldInitSpec(this,Xg,null);this._linkService=t;this._eventBus=i;pdf_find_controller_classPrivateFieldSet(Hg,this,n);this._pageViewMode=o;pdf_find_controller_classPrivateFieldSet(zg,this,s);this.onIsPageVisible=null;pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_reset).call(this);this._eventBus.on("pageviewmodechanged",e=>{let t=e.pageViewMode;this._pageViewMode=t});if(l){i.on("find",pdf_find_controller_assertClassBrand(Kg,this,_onFind).bind(this),Ih);i.on("findbarclose",pdf_find_controller_assertClassBrand(Kg,this,_onFindBarClose).bind(this),Ih);i.on("pagesedited",pdf_find_controller_assertClassBrand(Kg,this,_onPagesEdited).bind(this),Ih)}}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get pageMatchesColor(){return this._pageMatchesColor}get selected(){return this._selected}get state(){return pdf_find_controller_classPrivateFieldGet(Vg,this)}setDocument(e){this._pdfDocument&&pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_reset).call(this);if(e){this._pdfDocument=e;this._firstPageCapability.resolve()}}ngxFind(e){const t=[];this._findResultResolvers=[];for(let e=0,i=this._linkService.pagesCount;e<i;e++){const i=Promise.withResolvers(),a=i.promise,s=i.resolve;t[e]=a;this._findResultResolvers[e]=s}pdf_find_controller_assertClassBrand(Kg,this,_onFind).call(this,e);return t}ngxFindNext(){const e={...pdf_find_controller_classPrivateFieldGet(Vg,this),type:"again",findPrevious:!1};pdf_find_controller_assertClassBrand(Kg,this,_onFind).call(this,e)}ngxFindPrevious(){const e={...pdf_find_controller_classPrivateFieldGet(Vg,this),type:"again",findPrevious:!0};pdf_find_controller_assertClassBrand(Kg,this,_onFind).call(this,e)}scrollMatchIntoView(e){let t=e.element,i=void 0===t?null:t;e.pageIndex,e.matchIndex;if(!pdf_find_controller_classPrivateFieldGet(Vg,this)?.dontScrollIntoView&&this._scrollMatches&&i){this._scrollMatches=!1;"infinite-scroll"===this._pageViewMode?scrollIntoView(i,{top:-50,left:0},!0,!0):i.scrollIntoView({block:"start",inline:"center"})}}_convertToRegExpString(e,t){const i=pdf_find_controller_classPrivateFieldGet(Vg,this).matchDiacritics;let a=!1;const addExtraWhitespaces=(t,i)=>t===e?i:e.startsWith(t)?`${i}[ ]*`:e.endsWith(t)?`[ ]*${i}`:`[ ]*${i}[ ]*`,s="[ ]*";(e=e.replaceAll(Dg,(e,s,r,n,o,l)=>{if(s)return addExtraWhitespaces(s,RegExp.escape(s));if(r)return addExtraWhitespaces(r,RegExp.escape(r));if(n)return"[ ]+";if(i)return o||l;if(o)return Gg.has(o.charCodeAt(0))?o:"";if(t){a=!0;return`${l}\\p{M}*`}return l})).endsWith(s)&&(e=e.slice(0,e.length-4));if(i&&t){Bg||=String.fromCharCode(...Gg);a=!0;e=`${e}(?=[${Bg}]|[^\\p{M}]|$)`}return[a,e]}_calculateMatch(e){var t;if(!pdf_find_controller_classPrivateFieldGet(Vg,this))return;const i=pdf_find_controller_classPrivateGetter(Kg,this,_get_query);if(0===i.length)return;const a=this._pageContents[e],s=this.match(i,a,e),r=this._pageMatches[e]=[],n=this._pageMatchesLength[e]=[],o=this._pageMatchesColor[e]=[],l=this._pageDiffs[e];s?.forEach(e=>{let t=e.index,i=e.length,a=e.color;const s=pdf_find_controller_slicedToArray(getOriginalIndex(l,t,i),2),c=s[0],d=s[1];if(d){r.push(c);n.push(d);o.push(a||0)}});pdf_find_controller_classPrivateFieldGet(Vg,this).highlightAll&&pdf_find_controller_assertClassBrand(Kg,this,_updatePage).call(this,e);if(this._resumePageIdx===e){this._resumePageIdx=null;pdf_find_controller_assertClassBrand(Kg,this,_nextPageMatch).call(this)}const c=r.length;this._matchesCountTotal+=c;pdf_find_controller_classPrivateFieldGet(Hg,this)?c>0&&pdf_find_controller_assertClassBrand(Kg,this,_updateUIResultsCount).call(this,e):pdf_find_controller_classPrivateFieldSet($g,this,(t=pdf_find_controller_classPrivateFieldGet($g,this),++t))===this._linkService.pagesCount&&pdf_find_controller_assertClassBrand(Kg,this,_updateUIResultsCount).call(this,e)}match(e,t,i){const a=this._hasDiacritics[i];let s=!1;const r=pdf_find_controller_classPrivateFieldGet(Vg,this),n=r.caseSensitive,o=r.findMultiple,l=r.matchRegExp;o&&"string"==typeof e&&(e=e.trim().split(/\s+/));let c=null;if(l&&"string"==typeof e){e=new RegExp(e,n?"g":"gi");s=a}else if("string"==typeof e){var d=pdf_find_controller_slicedToArray(this._convertToRegExpString(e,a),2);s=d[0];e=d[1]}else{const t=[...e];e=e.sort().reverse().map(e=>{const t=pdf_find_controller_slicedToArray(this._convertToRegExpString(e,a),2),i=t[0],r=t[1];s||=i;return`(${r})`}).join("|");c=[...t].sort().reverse().map(e=>t.indexOf(e))}if(!e)return;const h=pdf_find_controller_classPrivateFieldGet(Vg,this).entireWord;e=new RegExp(e,`g${s?"u":""}${n?"":"i"}`);const u=[];let _;for(;null!==(_=e.exec(t));){if(h&&!pdf_find_controller_assertClassBrand(Kg,this,_isEntireWord).call(this,t,_.index,_[0].length))continue;let e=0;if(c)for(let t=1;t<_.length;t++)if(void 0!==_[t]){e=c[t-1]%5;break}u.push({index:_.index,length:_[0].length,color:e})}return u}}function _onFind(e){if(!e)return;const t=this._pdfDocument,i=e.type;(null===pdf_find_controller_classPrivateFieldGet(Vg,this)||pdf_find_controller_assertClassBrand(Kg,this,_shouldDirtyMatch).call(this,e))&&(this._dirtyMatch=!0);pdf_find_controller_classPrivateFieldSet(Vg,this,e);if("highlightallchange"!==i)pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_updateUIState).call(this,Tg);else{const e=this._pageMatches.some(e=>e.length>0),t=!this.state?.query||e;pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_updateUIState).call(this,t?xg:kg)}this._firstPageCapability.promise.then(()=>{if(!this._pdfDocument||t&&this._pdfDocument!==t)return;pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_extractText).call(this);const e=!this._highlightMatches,a=!!this._findTimeout;if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}if(i)if(this._dirtyMatch)pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this);else if("again"===i){pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this);e&&pdf_find_controller_classPrivateFieldGet(Vg,this).highlightAll&&pdf_find_controller_assertClassBrand(Kg,this,_updateAllPages).call(this)}else if("highlightallchange"===i){a?pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this):this._highlightMatches=!0;pdf_find_controller_assertClassBrand(Kg,this,_updateAllPages).call(this)}else pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this);else this._findTimeout=setTimeout(()=>{pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this);this._findTimeout=null},pdf_find_controller_classPrivateFieldGet(zg,this))})}function pdf_find_controller_reset(){this._highlightMatches=!1;this._scrollMatches=!1;this._pdfDocument=null;this._pageMatches=[];this._pageMatchesLength=[];this._pageMatchesColor=[];pdf_find_controller_classPrivateFieldSet($g,this,0);pdf_find_controller_classPrivateFieldSet(Vg,this,null);this._selected={pageIdx:-1,matchIdx:-1};this._offset={pageIdx:null,matchIdx:null,wrapped:!1};this._extractTextPromises=[];this._findResultResolvers=[];this._pageContents=[];this._pageDiffs=[];this._hasDiacritics=[];this._matchesCountTotal=0;this._pagesToSearch=null;this._pendingFindMatches=new Set;this._resumePageIdx=null;this._dirtyMatch=!1;clearTimeout(this._findTimeout);this._findTimeout=null;pdf_find_controller_classPrivateFieldSet(qg,this,null);this._firstPageCapability=Promise.withResolvers()}function _get_query(e){const t=pdf_find_controller_classPrivateFieldGet(Vg,e).query;if("string"==typeof t){if(t!==e._rawQuery){e._rawQuery=t;var i=pdf_find_controller_slicedToArray(normalize(t),1);e._normalizedQuery=i[0]}return e._normalizedQuery}return(t||[]).filter(e=>!!e).map(e=>normalize(e)[0])}function _shouldDirtyMatch(e){const t=e.query,i=pdf_find_controller_classPrivateFieldGet(Vg,this).query,a=typeof t;if(a!==typeof i)return!0;if("string"===a){if(t!==i)return!0}else if(JSON.stringify(t)!==JSON.stringify(i))return!0;switch(e.type){case"again":const e=this._selected.pageIdx+1,t=this._linkService;return e>=1&&e<=t.pagesCount&&e!==t.page&&!(this.onIsPageVisible?.(e)??1);case"highlightallchange":return!1}return!0}function _isEntireWord(e,t,i){let a=e.slice(0,t).match(Lg);if(a){const i=e.charCodeAt(t),s=a[1].charCodeAt(0);if(getCharacterType(i)===getCharacterType(s))return!1}a=e.slice(t+i).match(Og);if(a){const s=e.charCodeAt(t+i-1),r=a[1].charCodeAt(0);if(getCharacterType(s)===getCharacterType(r))return!1}return!0}function pdf_find_controller_extractText(){if(this._extractTextPromises.length>0)return;let e=Promise.resolve();const t={disableNormalization:!0},i=this._pdfDocument;for(let a=0,s=this._linkService.pagesCount;a<s;a++){const s=Promise.withResolvers(),r=s.promise,n=s.resolve;this._extractTextPromises[a]=r;e=e.then(async()=>{if(i===this._pdfDocument){try{const s=await i.getPage(a+1),r=await s.getTextContent(t);if(i!==this._pdfDocument){n();return}const o=[];for(const e of r.items){o.push(e.str);e.hasEOL&&o.push("\n")}var e=pdf_find_controller_slicedToArray(normalize(o.join("")),3);this._pageContents[a]=e[0];this._pageDiffs[a]=e[1];this._hasDiacritics[a]=e[2]}catch(e){if(i!==this._pdfDocument){n();return}ngx_console_NgxConsole.error(`Unable to get text content for page ${a+1}`,e);var s=["",null,!1];this._pageContents[a]=s[0];this._pageDiffs[a]=s[1];this._hasDiacritics[a]=s[2]}n()}else n()})}}function _updatePage(e){this._scrollMatches&&this._selected.pageIdx===e&&(this.state.dontScrollIntoView||(this._linkService.page=e+1));this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:e})}function _updateAllPages(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}function _nextMatch(){const e=pdf_find_controller_classPrivateFieldGet(Vg,this).findPrevious,t=this._linkService.page-1,i=this._linkService.pagesCount;this._highlightMatches=!0;if(this._dirtyMatch){this._dirtyMatch=!1;this._selected.pageIdx=this._selected.matchIdx=-1;this._offset.pageIdx=t;this._offset.matchIdx=null;this._offset.wrapped=!1;this._resumePageIdx=null;this._pageMatches.length=0;this._pageMatchesLength.length=0;pdf_find_controller_classPrivateFieldSet($g,this,0);this._matchesCountTotal=0;pdf_find_controller_assertClassBrand(Kg,this,_updateAllPages).call(this);for(let e=0;e<i;e++)if(!this._pendingFindMatches.has(e)){this._pendingFindMatches.add(e);this._extractTextPromises[e].then(()=>{this._pendingFindMatches.delete(e);this._calculateMatch(e)})}}if(0===pdf_find_controller_classPrivateGetter(Kg,this,_get_query).length){pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_updateUIState).call(this,xg);return}if(this._resumePageIdx)return;const a=this._offset;this._pagesToSearch=i;if(null!==a.matchIdx){const t=this._pageMatches[a.pageIdx].length;if(!e&&a.matchIdx+1<t||e&&a.matchIdx>0){a.matchIdx=e?a.matchIdx-1:a.matchIdx+1;pdf_find_controller_assertClassBrand(Kg,this,_updateMatch).call(this,!0);return}pdf_find_controller_assertClassBrand(Kg,this,_advanceOffsetPage).call(this,e)}pdf_find_controller_assertClassBrand(Kg,this,_nextPageMatch).call(this)}function _matchesReady(e){const t=this._offset,i=e.length,a=pdf_find_controller_classPrivateFieldGet(Vg,this).findPrevious;if(i){t.matchIdx=a?i-1:0;pdf_find_controller_assertClassBrand(Kg,this,_updateMatch).call(this,!0);return!0}pdf_find_controller_assertClassBrand(Kg,this,_advanceOffsetPage).call(this,a);if(t.wrapped){t.matchIdx=null;if(this._pagesToSearch<0){pdf_find_controller_assertClassBrand(Kg,this,_updateMatch).call(this,!1);return!0}}return!1}function _nextPageMatch(){null!==this._resumePageIdx&&ngx_console_NgxConsole.error("There can only be one pending page.");let e=null;do{const t=this._offset.pageIdx;e=this._pageMatches[t];if(!e){this._resumePageIdx=t;break}}while(!pdf_find_controller_assertClassBrand(Kg,this,_matchesReady).call(this,e))}function _advanceOffsetPage(e){const t=this._offset,i=this._linkService.pagesCount;t.pageIdx=e?t.pageIdx-1:t.pageIdx+1;t.matchIdx=null;this._pagesToSearch--;if(t.pageIdx>=i||t.pageIdx<0){t.pageIdx=e?i-1:0;t.wrapped=!0}}function _updateMatch(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=kg;const i=this._offset.wrapped;this._offset.wrapped=!1;if(e){const e=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx;this._selected.matchIdx=this._offset.matchIdx;t=i?Eg:xg;-1!==e&&e!==this._selected.pageIdx&&pdf_find_controller_assertClassBrand(Kg,this,_updatePage).call(this,e)}pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_updateUIState).call(this,t,pdf_find_controller_classPrivateFieldGet(Vg,this).findPrevious);if(-1!==this._selected.pageIdx){this._scrollMatches=!0;pdf_find_controller_assertClassBrand(Kg,this,_updatePage).call(this,this._selected.pageIdx)}}function _onPagesEdited(e){let t=e.pagesMapper,i=e.type,a=e.pageNumbers;if(0===this._extractTextPromises.length)return;if("copy"===i){const e=new Map,t=new Map,i=new Map,s=new Map;for(const r of a){e.set(r,this._extractTextPromises[r-1]);t.set(r,this._pageContents[r-1]);i.set(r,this._pageDiffs[r-1]);s.set(r,this._hasDiacritics[r-1])}pdf_find_controller_classPrivateFieldSet(qg,this,{promises:e,contents:t,diffs:i,diacritics:s});return}if("cancelCopy"===i){pdf_find_controller_classPrivateFieldSet(qg,this,null);return}"delete"===i&&pdf_find_controller_classPrivateFieldSet(Xg,this,{promises:this._extractTextPromises,contents:this._pageContents,diffs:this._pageDiffs,diacritics:this._hasDiacritics});if("cancelDelete"===i){this._extractTextPromises=pdf_find_controller_classPrivateFieldGet(Xg,this).promises;this._pageContents=pdf_find_controller_classPrivateFieldGet(Xg,this).contents;this._pageDiffs=pdf_find_controller_classPrivateFieldGet(Xg,this).diffs;this._hasDiacritics=pdf_find_controller_classPrivateFieldGet(Xg,this).diacritics;return}if("cleanSavedData"===i){pdf_find_controller_classPrivateFieldSet(Xg,this,null);return}if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}this._resumePageIdx=null;this._dirtyMatch=!0;const s=this._extractTextPromises,r=this._pageContents,n=this._pageDiffs,o=this._hasDiacritics,l=this._extractTextPromises=[],c=this._pageContents=[],d=this._pageDiffs=[],h=this._hasDiacritics=[];for(let e=1,i=t.pagesNumber;e<=i;e++){const i=t.getPrevPageNumber(e);if(i<0){const e=-i;l.push(pdf_find_controller_classPrivateFieldGet(qg,this)?.promises.get(e)||Promise.resolve());c.push(pdf_find_controller_classPrivateFieldGet(qg,this)?.contents.get(e)??"");d.push(pdf_find_controller_classPrivateFieldGet(qg,this)?.diffs.get(e)??null);h.push(pdf_find_controller_classPrivateFieldGet(qg,this)?.diacritics.get(e)??!1);continue}l.push(s[i-1]||Promise.resolve());c.push(r[i-1]??"");d.push(n[i-1]??null);h.push(o[i-1]??!1)}pdf_find_controller_classPrivateFieldGet(Vg,this)&&pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this)}function _onFindBarClose(e){const t=this._pdfDocument;this._firstPageCapability.promise.then(()=>{if(this._pdfDocument&&(!t||this._pdfDocument===t)){if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}if(this._resumePageIdx){this._resumePageIdx=null;this._dirtyMatch=!0}pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_updateUIState).call(this,xg);this._highlightMatches=!1;pdf_find_controller_assertClassBrand(Kg,this,_updateAllPages).call(this)}})}function _requestMatchesCount(){const e=this._selected,t=e.pageIdx,i=e.matchIdx;let a=0,s=this._matchesCountTotal;if(-1!==i){for(let e=0;e<t;e++)a+=this._pageMatches[e]?.length||0;a+=i+1}(a<1||a>s)&&(a=s=0);return{current:a,total:s}}function _updateUIResultsCount(e){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:pdf_find_controller_assertClassBrand(Kg,this,_requestMatchesCount).call(this)});const t=this._pageMatches[e].length;if(this._findResultResolvers&&this._findResultResolvers[e]){this._findResultResolvers[e](t);this._findResultResolvers[e]=null}}function pdf_find_controller_updateUIState(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(pdf_find_controller_classPrivateFieldGet(Hg,this)||pdf_find_controller_classPrivateFieldGet($g,this)===this._linkService.pagesCount&&e!==Tg)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:e,previous:t,entireWord:pdf_find_controller_classPrivateFieldGet(Vg,this)?.entireWord??null,matchesCount:pdf_find_controller_assertClassBrand(Kg,this,_requestMatchesCount).call(this),rawQuery:pdf_find_controller_classPrivateFieldGet(Vg,this)?.query??null})}function pdf_find_bar_slicedToArray(e,t){return function pdf_find_bar_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_find_bar_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_find_bar_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_find_bar_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_find_bar_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_find_bar_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_find_bar_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pdf_find_bar_defineProperty(e,t,i){return(t=function pdf_find_bar_toPropertyKey(e){var t=function pdf_find_bar_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function pdf_find_bar_classPrivateFieldInitSpec(e,t,i){pdf_find_bar_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_find_bar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_find_bar_classPrivateFieldGet(e,t){return e.get(pdf_find_bar_assertClassBrand(e,t))}function pdf_find_bar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Yg=new WeakMap,Zg=new WeakMap,Jg=new WeakSet;class PDFFindBar{constructor(e,t,i){!function pdf_find_bar_classPrivateMethodInitSpec(e,t){pdf_find_bar_checkPrivateRedeclaration(e,t),t.add(e)}(this,Jg);pdf_find_bar_classPrivateFieldInitSpec(this,Yg,void 0);pdf_find_bar_classPrivateFieldInitSpec(this,Zg,new ResizeObserver(pdf_find_bar_assertClassBrand(Jg,this,_resizeObserverCallback).bind(this)));pdf_find_bar_defineProperty(this,"opened",!1);this.bar=e.bar;this.toggleButton=e.toggleButton;this.findField=e.findField;this.highlightAll=e.highlightAllCheckbox;this.currentPage=e.findCurrentPageCheckbox;this.pageRange=e.findPageRangeField;this.caseSensitive=e.caseSensitiveCheckbox;this.findMultipleCheckbox=e.findMultipleCheckbox;this.matchRegExpCheckbox=e.matchRegExpCheckbox;this.matchDiacritics=e.matchDiacriticsCheckbox;this.entireWord=e.entireWordCheckbox;this.findMsg=e.findMsg;this.findResultsCount=e.findResultsCount;this.findPreviousButton=e.findPreviousButton;this.findNextButton=e.findNextButton;this.eventBus=i;!function pdf_find_bar_classPrivateFieldSet(e,t,i){return e.set(pdf_find_bar_assertClassBrand(e,t),i),i}(Yg,this,t);i._on("closeopenpopovers",e=>{e.source!==this&&this.close()});const a=new Map(Array.from([[this.highlightAll,"highlightallchange"],[this.caseSensitive,"casesensitivitychange"],[this.entireWord,"entirewordchange"],[this.matchDiacritics,"diacriticmatchingchange"],[this.findMultipleCheckbox,"findmultiplechange"]]).filter(e=>{let t=pdf_find_bar_slicedToArray(e,1)[0];return t&&t instanceof Element}));this.toggleButton&&(function isInsideNgxExtendedPdfViewer(e){let t=e;for(;t;){if("ngx-extended-pdf-viewer"===t.tagName.toLowerCase())return!0;t=t.parentElement}return!1}(this.toggleButton)||this.toggleButton.addEventListener("click",()=>{this.toggle()}));this.findField.addEventListener("input",()=>{this.dispatchEvent("")});this.findField.parentElement.addEventListener("keydown",e=>{const t=e.keyCode;13!==t&&27!==t&&e.stopPropagation();e.metaKey&&"ArrowDown"===e.key&&e.preventDefault();e.metaKey&&"ArrowUp"===e.key&&e.preventDefault()});this.bar.addEventListener("keydown",e=>{const t=e.keyCode,i=e.shiftKey,s=e.target;switch(t){case 13:if(s===this.findField)this.dispatchEvent("again",i);else if(a.has(s)){s.checked=!s.checked;this.dispatchEvent(a.get(s))}break;case 27:this.close();e.stopPropagation()}});this.findPreviousButton.addEventListener("click",()=>{this.dispatchEvent("again",!0)});this.findNextButton.addEventListener("click",()=>{this.dispatchEvent("again",!1)});for(const e of a){var s=pdf_find_bar_slicedToArray(e,2);const t=s[0],i=s[1];t.addEventListener("click",()=>{this.dispatchEvent(i)})}this.matchRegExpCheckbox?.addEventListener("click",()=>{if(this.matchRegExpCheckbox.checked){this.findMultipleCheckbox.checked=!1;this.findMultipleCheckbox.disabled=!0;this.matchDiacritics.checked=!1;this.matchDiacritics.disabled=!0;this.entireWord.checked=!1;this.entireWord.disabled=!0}else{this.findMultipleCheckbox.disabled=!1;this.matchDiacritics.disabled=!1;this.entireWord.disabled=!1}this.dispatchEvent("findregexpchange")})}reset(){this.updateUIState()}dispatchEvent(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.eventBus.dispatch("find",{source:this,type:e,query:this.findField.value,caseSensitive:this.caseSensitive.checked,findMultiple:this.findMultipleCheckbox?.checked,matchRegExp:this.matchRegExpCheckbox?.checked,entireWord:this.entireWord.checked,highlightAll:this.highlightAll.checked,findPrevious:t,matchDiacritics:this.matchDiacritics.checked})}updateUIState(e,t,i){const a=this.findField,s=this.findMsg;let r="",n="";switch(e){case xg:break;case Tg:n="pending";break;case kg:r="pdfjs-find-not-found";n="notFound";break;case Eg:r=t?"pdfjs-find-reached-top":"pdfjs-find-reached-bottom"}a.setAttribute("data-status",n);a.setAttribute("aria-invalid",e===kg);s.setAttribute("data-status",n);if(r)s.setAttribute("data-l10n-id",r);else{s.removeAttribute("data-l10n-id");s.textContent=""}this.updateResultsCount(i)}updateResultsCount(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.current,i=void 0===t?0:t,a=e.total,s=void 0===a?0:a;const r=this.findResultsCount;if(s>0){const e=1e3;r.setAttribute("data-l10n-id",s>e?"pdfjs-find-match-count-limit":"pdfjs-find-match-count");r.setAttribute("data-l10n-args",JSON.stringify({limit:e,current:i,total:s}))}else{r.removeAttribute("data-l10n-id");r.textContent=""}}open(){this.eventBus.dispatch("closeopenpopovers",{source:this});if(!this.opened){pdf_find_bar_classPrivateFieldGet(Zg,this).observe(pdf_find_bar_classPrivateFieldGet(Yg,this));pdf_find_bar_classPrivateFieldGet(Zg,this).observe(this.bar);this.opened=!0;toggleExpandedBtn(this.toggleButton,!0,this.bar)}if(this.findField){"function"==typeof this.findField.select&&this.findField.select();"function"==typeof this.findField.focus&&this.findField.focus()}this.dispatchEvent("");this.eventBus.dispatch("findbaropen",{source:this})}close(){if(this.opened){pdf_find_bar_classPrivateFieldGet(Zg,this).disconnect();this.opened=!1;toggleExpandedBtn(this.toggleButton,!1,this.bar);this.eventBus.dispatch("findbarclose",{source:this})}}toggle(){this.opened?this.close():this.open()}}function _resizeObserverCallback(){const e=this.bar;e.classList.remove("wrapContainers");e.clientHeight>e.firstElementChild.clientHeight&&e.classList.add("wrapContainers")}function pdf_history_slicedToArray(e,t){return function pdf_history_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_history_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_history_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_history_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_history_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_history_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_history_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pdf_history_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_history_classPrivateFieldSet(e,t,i){return e.set(pdf_history_assertClassBrand(e,t),i),i}function pdf_history_classPrivateFieldGet(e,t){return e.get(pdf_history_assertClassBrand(e,t))}function pdf_history_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function getCurrentHash(){return document.location.hash}var Qg=new WeakMap,ef=new WeakSet;class PDFHistory{constructor(e){let t=e.linkService,i=e.eventBus;!function pdf_history_classPrivateMethodInitSpec(e,t){pdf_history_checkPrivateRedeclaration(e,t),t.add(e)}(this,ef);!function pdf_history_classPrivateFieldInitSpec(e,t,i){pdf_history_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,Qg,null);this.linkService=t;this.eventBus=i;this._initialized=!1;this._fingerprint="";this.reset();this.eventBus.on("pagesinit",()=>{this._isPagesLoaded=!1;this.eventBus.on("pagesloaded",e=>{this._isPagesLoaded=!!e.pagesCount},{once:!0,...Ih})},Ih)}initialize(e){let t=e.fingerprint,i=e.resetHistory,a=void 0!==i&&i,s=e.updateUrl,r=void 0!==s&&s;if(!t||"string"!=typeof t){ngx_console_NgxConsole.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');return}this._initialized&&this.reset();const n=""!==this._fingerprint&&this._fingerprint!==t;this._fingerprint=t;this._updateUrl=!0===r;this._initialized=!0;pdf_history_assertClassBrand(ef,this,_bindEvents).call(this);const o=window.history.state;this._popStateInProgress=!1;this._blockHashChange=0;this._currentHash=getCurrentHash();this._numPositionUpdates=0;this._uid=this._maxUid=0;this._destination=null;this._position=null;if(!pdf_history_assertClassBrand(ef,this,_isValidState).call(this,o,!0)||a){const e=pdf_history_assertClassBrand(ef,this,_parseCurrentHash).call(this,!0),t=e.hash,i=e.page,s=e.rotation;if(!t||n||a){pdf_history_assertClassBrand(ef,this,_pushOrReplaceState).call(this,null,!0);return}pdf_history_assertClassBrand(ef,this,_pushOrReplaceState).call(this,{hash:t,page:i,rotation:s},!0);return}const l=o.destination;pdf_history_assertClassBrand(ef,this,_updateInternalState).call(this,l,o.uid,!0);void 0!==l.rotation&&(this._initialRotation=l.rotation);if(l.dest){this._initialBookmark=JSON.stringify(l.dest);this._destination.page=null}else l.hash?this._initialBookmark=l.hash:l.page&&(this._initialBookmark=`page=${l.page}`)}reset(){if(this._initialized){pdf_history_assertClassBrand(ef,this,_pageHide).call(this);this._initialized=!1;pdf_history_assertClassBrand(ef,this,_unbindEvents).call(this)}if(this._updateViewareaTimeout){clearTimeout(this._updateViewareaTimeout);this._updateViewareaTimeout=null}this._initialBookmark=null;this._initialRotation=null}push(e){let t=e.namedDest,i=void 0===t?null:t,a=e.explicitDest,s=e.pageNumber;if(!this._initialized)return;if(i&&"string"!=typeof i){ngx_console_NgxConsole.error(`PDFHistory.push: "${i}" is not a valid namedDest parameter.`);return}if(!Array.isArray(a)){ngx_console_NgxConsole.error(`PDFHistory.push: "${a}" is not a valid explicitDest parameter.`);return}if(!pdf_history_assertClassBrand(ef,this,_isValidPage).call(this,s)&&(null!==s||this._destination)){ngx_console_NgxConsole.error(`PDFHistory.push: "${s}" is not a valid pageNumber parameter.`);return}const r=i||JSON.stringify(a);if(!r)return;let n=!1;if(this._destination&&(function isDestHashesEqual(e,t){if("string"!=typeof e||"string"!=typeof t)return!1;if(e===t)return!0;if(parseQueryString(e).get("nameddest")===t)return!0;return!1}(this._destination.hash,r)||function isDestArraysEqual(e,t){function isEntryEqual(e,t){if(typeof e!=typeof t)return!1;if(Array.isArray(e)||Array.isArray(t))return!1;if(null!==e&&"object"==typeof e&&null!==t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!isEntryEqual(e[i],t[i]))return!1;return!0}return e===t||Number.isNaN(e)&&Number.isNaN(t)}if(!Array.isArray(e)||!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(let i=0,a=e.length;i<a;i++)if(!isEntryEqual(e[i],t[i]))return!1;return!0}(this._destination.dest,a))){if(this._destination.page)return;n=!0}if(!this._popStateInProgress||n){pdf_history_assertClassBrand(ef,this,_pushOrReplaceState).call(this,{dest:a,hash:r,page:s,rotation:this.linkService.rotation},n);if(!this._popStateInProgress){this._popStateInProgress=!0;Promise.resolve().then(()=>{this._popStateInProgress=!1})}}}pushPage(e){if(this._initialized)if(pdf_history_assertClassBrand(ef,this,_isValidPage).call(this,e)){if(this._destination?.page!==e&&!this._popStateInProgress){pdf_history_assertClassBrand(ef,this,_pushOrReplaceState).call(this,{dest:null,hash:`page=${e}`,page:e,rotation:this.linkService.rotation});if(!this._popStateInProgress){this._popStateInProgress=!0;Promise.resolve().then(()=>{this._popStateInProgress=!1})}}}else ngx_console_NgxConsole.error(`PDFHistory.pushPage: "${e}" is not a valid page number.`)}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&pdf_history_assertClassBrand(ef,this,_tryPushCurrentPosition).call(this)}back(){if(!this._initialized||this._popStateInProgress)return;const e=window.history.state;pdf_history_assertClassBrand(ef,this,_isValidState).call(this,e)&&e.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const e=window.history.state;pdf_history_assertClassBrand(ef,this,_isValidState).call(this,e)&&e.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}}function _pushOrReplaceState(e){const t=arguments.length>1&&void 0!==arguments[1]&&arguments[1]||!this._destination,i={fingerprint:this._fingerprint,uid:t?this._uid:this._uid+1,destination:e};pdf_history_assertClassBrand(ef,this,_updateInternalState).call(this,e,i.uid);let a;if(this._updateUrl&&e?.hash){const t=document.location,i=t.href;"file:"!==t.protocol&&(a=updateUrlHash(i,e.hash))}t?window.history.replaceState(i,"",a):window.history.pushState(i,"",a)}function _tryPushCurrentPosition(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this._position)return;let t=this._position;if(e){t=Object.assign(Object.create(null),this._position);t.temporary=!0}if(!this._destination){pdf_history_assertClassBrand(ef,this,_pushOrReplaceState).call(this,t);return}if(this._destination.temporary){pdf_history_assertClassBrand(ef,this,_pushOrReplaceState).call(this,t,!0);return}if(this._destination.hash===t.hash)return;if(!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=t.first&&this._destination.page<=t.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}pdf_history_assertClassBrand(ef,this,_pushOrReplaceState).call(this,t,i)}function _isValidPage(e){return Number.isInteger(e)&&e>0&&e<=this.linkService.pagesCount}function _isValidState(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return!1;if(e.fingerprint!==this._fingerprint){if(!t)return!1;{if("string"!=typeof e.fingerprint||e.fingerprint.length!==this._fingerprint.length)return!1;const t=pdf_history_slicedToArray(performance.getEntriesByType("navigation"),1)[0];if("reload"!==t?.type)return!1}}return!(!Number.isInteger(e.uid)||e.uid<0)&&(null!==e.destination&&"object"==typeof e.destination)}function _updateInternalState(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this._updateViewareaTimeout){clearTimeout(this._updateViewareaTimeout);this._updateViewareaTimeout=null}i&&e?.temporary&&delete e.temporary;this._destination=e;this._uid=t;this._maxUid=Math.max(this._maxUid,t);this._numPositionUpdates=0}function _parseCurrentHash(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=unescape(getCurrentHash()).substring(1),i=parseQueryString(t),a=i.get("nameddest")||"";let s=0|i.get("page");(!pdf_history_assertClassBrand(ef,this,_isValidPage).call(this,s)||e&&a.length>0)&&(s=null);return{hash:t,page:s,rotation:this.linkService.rotation}}function _updateViewarea(e){let t=e.location;if(this._updateViewareaTimeout){clearTimeout(this._updateViewareaTimeout);this._updateViewareaTimeout=null}this._position={hash:t.pdfOpenParams.substring(1),page:this.linkService.page,first:t.pageNumber,rotation:t.rotation};if(!this._popStateInProgress){this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++;this._updateViewareaTimeout=setTimeout(()=>{this._popStateInProgress||pdf_history_assertClassBrand(ef,this,_tryPushCurrentPosition).call(this,!0);this._updateViewareaTimeout=null},1e3)}}function _popState(e){let t=e.state;const i=getCurrentHash(),a=this._currentHash!==i;this._currentHash=i;if(!t){this._uid++;const e=pdf_history_assertClassBrand(ef,this,_parseCurrentHash).call(this),t=e.hash,i=e.page,a=e.rotation;pdf_history_assertClassBrand(ef,this,_pushOrReplaceState).call(this,{hash:t,page:i,rotation:a},!0);return}if(!pdf_history_assertClassBrand(ef,this,_isValidState).call(this,t))return;this._popStateInProgress=!0;if(a){this._blockHashChange++;waitOnEventOrTimeout({target:window,name:"hashchange",delay:1e3}).then(()=>{this._blockHashChange--})}const s=t.destination;pdf_history_assertClassBrand(ef,this,_updateInternalState).call(this,s,t.uid,!0);isValidRotation(s.rotation)&&(this.linkService.rotation=s.rotation);s.dest?this.linkService.goToDestination(s.dest):s.hash?this.linkService.setHash&&this.linkService.setHash(s.hash):s.page&&(this.linkService.page=s.page);Promise.resolve().then(()=>{this._popStateInProgress=!1})}function _pageHide(){this._destination&&!this._destination.temporary||pdf_history_assertClassBrand(ef,this,_tryPushCurrentPosition).call(this)}function _bindEvents(){if(pdf_history_classPrivateFieldGet(Qg,this))return;pdf_history_classPrivateFieldSet(Qg,this,new AbortController);const e=pdf_history_classPrivateFieldGet(Qg,this).signal;this.eventBus.on("updateviewarea",pdf_history_assertClassBrand(ef,this,_updateViewarea).bind(this),{signal:e,...Ih});window.addEventListener("popstate",pdf_history_assertClassBrand(ef,this,_popState).bind(this),{signal:e});window.addEventListener("pagehide",pdf_history_assertClassBrand(ef,this,_pageHide).bind(this),{signal:e})}function _unbindEvents(){pdf_history_classPrivateFieldGet(Qg,this)?.abort();pdf_history_classPrivateFieldSet(Qg,this,null)}function pdf_layer_viewer_slicedToArray(e,t){return function pdf_layer_viewer_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_layer_viewer_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_layer_viewer_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_layer_viewer_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_layer_viewer_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_layer_viewer_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_layer_viewer_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pdf_layer_viewer_classPrivateMethodInitSpec(e,t){(function pdf_layer_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function pdf_layer_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var tf=new WeakSet;class PDFLayerViewer extends BaseTreeViewer{constructor(e){super(e);pdf_layer_viewer_classPrivateMethodInitSpec(this,tf);const t=this.eventBus;t.on("optionalcontentconfigchanged",e=>{pdf_layer_viewer_assertClassBrand(tf,this,_updateLayers).call(this,e.promise)},Ih);t.on("resetlayers",()=>{pdf_layer_viewer_assertClassBrand(tf,this,_updateLayers).call(this)},Ih);t.on("togglelayerstree",this._toggleAllTreeItems.bind(this),Ih)}reset(){super.reset();this._optionalContentConfig=null;this._optionalContentVisibility?.clear();this._optionalContentVisibility=null}_dispatchEvent(e){this.eventBus.dispatch("layersloaded",{source:this,layersCount:e})}_bindLink(e,t){let i=t.groupId,a=t.input;const setVisibility=()=>{const e=a.checked;this._optionalContentConfig.setVisibility(i,e);const t=this._optionalContentVisibility.get(i);t&&(t.visible=e);this.eventBus.dispatch("optionalcontentconfig",{source:this,promise:Promise.resolve(this._optionalContentConfig)})};e.onclick=t=>{if(t.target===a){setVisibility();return!0}if(t.target!==e)return!0;a.checked=!a.checked;setVisibility();return!1}}_setNestedName(e,t){let i=t.name,a=void 0===i?null:i;if("string"!=typeof a){e.setAttribute("data-l10n-id","pdfjs-additional-layers");e.style.fontStyle="italic";this._l10n.translateOnce(e)}else e.textContent=this._normalizeTextContent(a)}_addToggleButton(e,t){let i=t.name,a=void 0===i?null:i;super._addToggleButton(e,null===a)}_toggleAllTreeItems(){this._optionalContentConfig&&super._toggleAllTreeItems()}render(e){let t=e.optionalContentConfig,i=e.pdfDocument;this._optionalContentConfig&&this.reset();this._optionalContentConfig=t||null;this._pdfDocument=i||null;const a=t?.getOrder();if(!a){this._dispatchEvent(0);return}this._optionalContentVisibility=new Map;const s=document.createDocumentFragment(),r=[{parent:s,groups:a}];let n=0,o=!1;for(;r.length>0;){const e=r.shift();for(const i of e.groups){const a=document.createElement("div");a.className="treeItem";const s=document.createElement("a");a.append(s);if("object"==typeof i){o=!0;this._addToggleButton(a,i);this._setNestedName(s,i);const e=document.createElement("div");e.className="treeItems";a.append(e);r.push({parent:e,groups:i.order})}else{const e=t.getGroup(i),a=document.createElement("label"),r=document.createElement("input");a.append(r,document.createTextNode(this._normalizeTextContent(e.name)));this._bindLink(s,{groupId:i,input:r});r.type="checkbox";r.checked=e.visible;this._optionalContentVisibility.set(i,{input:r,visible:r.checked});s.append(a);n++}e.parent.append(a)}}this._finishRendering(s,n,o)}}async function _updateLayers(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!this._optionalContentConfig)return;const t=this._pdfDocument,i=await(e||t.getOptionalContentConfig({intent:"display"}));if(t===this._pdfDocument)if(e)for(const e of this._optionalContentVisibility){var a=pdf_layer_viewer_slicedToArray(e,2);const t=a[0],s=a[1],r=i.getGroup(t);r&&s.visible!==r.visible&&(s.input.checked=s.visible=!s.visible)}else{this.eventBus.dispatch("optionalcontentconfig",{source:this,promise:Promise.resolve(i)});this.render({optionalContentConfig:i,pdfDocument:this._pdfDocument})}}function pdf_outline_viewer_slicedToArray(e,t){return function pdf_outline_viewer_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_outline_viewer_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_outline_viewer_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_outline_viewer_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_outline_viewer_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_outline_viewer_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_outline_viewer_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}class PDFOutlineViewer extends BaseTreeViewer{constructor(e){super(e);this.linkService=e.linkService;this.downloadManager=e.downloadManager;const t=this.eventBus;t.on("toggleoutlinetree",this._toggleAllTreeItems.bind(this),Ih);t.on("currentoutlineitem",this._currentOutlineItem.bind(this),Ih);t.on("pagechanging",e=>{this._currentPageNumber=e.pageNumber},Ih);t.on("pagesloaded",e=>{this._isPagesLoaded=!!e.pagesCount;this._currentOutlineItemCapability?.resolve(this._isPagesLoaded)},Ih);t.on("sidebarviewchanged",e=>{this._sidebarView=e.view},Ih)}reset(){super.reset();this._outline=null;this._pageNumberToDestHashCapability=null;this._currentPageNumber=1;this._isPagesLoaded=null;this._currentOutlineItemCapability?.resolve(!1);this._currentOutlineItemCapability=null}_dispatchEvent(e){this._currentOutlineItemCapability=Promise.withResolvers();0===e||this._pdfDocument?.loadingParams.disableAutoFetch?this._currentOutlineItemCapability.resolve(!1):null!==this._isPagesLoaded&&this._currentOutlineItemCapability.resolve(this._isPagesLoaded);this.eventBus.dispatch("outlineloaded",{source:this,outlineCount:e,currentOutlineItemPromise:this._currentOutlineItemCapability.promise})}_bindLink(e,t){let i=t.url,a=t.newWindow,s=t.action,r=t.attachment,n=t.dest,o=t.setOCGState;const l=this.linkService;if(i)l.addLinkAttributes(e,i,a);else if(s){e.href=l.getAnchorUrl("");e.onclick=()=>{l.executeNamedAction(s);return!1}}else if(r){e.href=l.getAnchorUrl("");e.onclick=()=>{this.downloadManager.openOrDownloadData(r.content,r.filename);return!1}}else if(o){e.href=l.getAnchorUrl("");e.onclick=()=>{l.executeSetOCGState(o);return!1}}else{e.href=l.getDestinationHash(n);e.onclick=e=>{this._updateCurrentTreeItem(e.target.parentNode);n&&l.goToDestination(n);return!1}}}_setStyles(e,t){let i=t.bold,a=t.italic;i&&(e.style.fontWeight="bold");a&&(e.style.fontStyle="italic")}_addToggleButton(e,t){let i=t.count,a=t.items,s=!1;if(i<0){let e=a.length;if(e>0){const t=[...a];for(;t.length>0;){const i=t.shift(),a=i.count,s=i.items;if(a>0&&s.length>0){e+=s.length;t.push(...s)}}}Math.abs(i)===e&&(s=!0)}super._addToggleButton(e,s)}_toggleAllTreeItems(){this._outline&&super._toggleAllTreeItems()}render(e){let t=e.outline,i=e.pdfDocument;this._outline&&this.reset();this._outline=t||null;this._pdfDocument=i||null;if(!t){this._dispatchEvent(0);return}const a=document.createDocumentFragment(),s=[{parent:a,items:t}];let r=0,n=!1;for(;s.length>0;){const e=s.shift();for(const t of e.items){const i=document.createElement("div");i.className="treeItem";const a=document.createElement("a");this._bindLink(a,t);this._setStyles(a,t);a.textContent=this._normalizeTextContent(t.title);i.append(a);if(t.items.length>0){n=!0;this._addToggleButton(i,t);const e=document.createElement("div");e.className="treeItems";i.append(e);s.push({parent:e,items:t.items})}e.parent.append(i);r++}}this._finishRendering(a,r,n)}async _currentOutlineItem(){if(!this._isPagesLoaded)throw new Error("_currentOutlineItem: All pages have not been loaded.");if(!this._outline||!this._pdfDocument)return;const e=await this._getPageNumberToDestHash(this._pdfDocument);if(e){this._updateCurrentTreeItem(null);if(this._sidebarView===lh)for(let t=this._currentPageNumber;t>0;t--){const i=e.get(t);if(!i)continue;const a=this.container.querySelector(`a[href="${i}"]`);if(a){this._scrollToCurrentTreeItem(a.parentNode);break}}}}async _getPageNumberToDestHash(e){if(this._pageNumberToDestHashCapability)return this._pageNumberToDestHashCapability.promise;this._pageNumberToDestHashCapability=Promise.withResolvers();const t=new Map,i=new Map,a=[{nesting:0,items:this._outline}];for(;a.length>0;){const s=a.shift(),r=s.nesting;for(const n of s.items){const s=n.dest,o=n.items;let l,c;if("string"==typeof s){l=await e.getDestination(s);if(e!==this._pdfDocument)return null}else l=s;if(Array.isArray(l)){const a=pdf_outline_viewer_slicedToArray(l,1)[0];a&&"object"==typeof a?c=e.cachedPageNumber(a):Number.isInteger(a)&&(c=a+1);if(Number.isInteger(c)&&(!t.has(c)||r>i.get(c))){const e=this.linkService.getDestinationHash(s);t.set(c,e);i.set(c,r)}}o.length>0&&a.push({nesting:r+1,items:o})}}this._pageNumberToDestHashCapability.resolve(t.size>0?t:null);return this._pageNumberToDestHashCapability.promise}}function pdf_presentation_mode_classPrivateFieldInitSpec(e,t,i){pdf_presentation_mode_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_presentation_mode_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_presentation_mode_classPrivateFieldGet(e,t){return e.get(pdf_presentation_mode_assertClassBrand(e,t))}function pdf_presentation_mode_classPrivateFieldSet(e,t,i){return e.set(pdf_presentation_mode_assertClassBrand(e,t),i),i}function pdf_presentation_mode_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const af="pdfPresentationMode",sf="pdfPresentationModeControls",rf=Math.PI/6;var nf=new WeakMap,of=new WeakMap,lf=new WeakMap,cf=new WeakMap,df=new WeakSet;class PDFPresentationMode{constructor(e){let t=e.container,i=e.pdfViewer,a=e.eventBus;!function pdf_presentation_mode_classPrivateMethodInitSpec(e,t){pdf_presentation_mode_checkPrivateRedeclaration(e,t),t.add(e)}(this,df);pdf_presentation_mode_classPrivateFieldInitSpec(this,nf,th);pdf_presentation_mode_classPrivateFieldInitSpec(this,of,null);pdf_presentation_mode_classPrivateFieldInitSpec(this,lf,null);pdf_presentation_mode_classPrivateFieldInitSpec(this,cf,null);this.container=t;this.pdfViewer=i;this.eventBus=a;this.contextMenuOpen=!1;this.mouseScrollTimeStamp=0;this.mouseScrollDelta=0;this.touchSwipeState=null}async request(){const e=this.container,t=this.pdfViewer;if(this.active||!t.pagesCount||!e.requestFullscreen)return!1;pdf_presentation_mode_assertClassBrand(df,this,_addFullscreenChangeListeners).call(this);pdf_presentation_mode_assertClassBrand(df,this,_notifyStateChange).call(this,ah);const i=e.requestFullscreen();pdf_presentation_mode_classPrivateFieldSet(of,this,{pageNumber:t.currentPageNumber,scaleValue:t.currentScaleValue,scrollMode:t.scrollMode,spreadMode:null,annotationEditorMode:null});if(!(t.spreadMode===gh.NONE||t.pageViewsReady&&t.hasEqualPageSizes)){ngx_console_NgxConsole.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes.");pdf_presentation_mode_classPrivateFieldGet(of,this).spreadMode=t.spreadMode}t.annotationEditorMode!==P.DISABLE&&(pdf_presentation_mode_classPrivateFieldGet(of,this).annotationEditorMode=t.annotationEditorMode);try{await i;t.focus();return!0}catch{pdf_presentation_mode_assertClassBrand(df,this,_removeFullscreenChangeListeners).call(this);pdf_presentation_mode_assertClassBrand(df,this,_notifyStateChange).call(this,ih)}return!1}get active(){return pdf_presentation_mode_classPrivateFieldGet(nf,this)===ah||pdf_presentation_mode_classPrivateFieldGet(nf,this)===sh}_prepareFullscreenMode(){const e=document.getElementsByClassName("zoom")[0].parentElement,t=e.parentElement;this.ngxContainer=t;for(let i=0;i<t.childElementCount;i++)t.children.item(i)===e&&(this.ngxContainerIndex=i);t.removeChild(e);document.body.append(e);const i=document.body.children;for(let t=0;t<i.length;t++){const a=i.item(t);a!==e&&a instanceof HTMLElement&&a.classList.add("hidden-by-fullscreen")}document.getElementById("sidebarContainer").classList.add("hidden-by-fullscreen");document.getElementsByClassName("toolbar")[0].classList.add("hidden-by-fullscreen")}_tidyUpFullscreenMode(){if(this.ngxContainer){const e=document.getElementsByClassName("zoom")[0].parentElement;document.body.removeChild(e);this.ngxContainerIndex>=this.ngxContainer.childElementCount?this.ngxContainer.append(e):this.ngxContainer.insertBefore(e,this.ngxContainer.children.item(this.ngxContainerIndex));this.ngxContainer=void 0;const t=document.body.children;for(let i=0;i<t.length;i++){const a=t.item(i);a!==e&&a instanceof HTMLElement&&a.classList.contains("hidden-by-fullscreen")&&a.classList.remove("hidden-by-fullscreen")}document.getElementById("sidebarContainer").classList.remove("hidden-by-fullscreen");document.getElementsByClassName("toolbar")[0].classList.remove("hidden-by-fullscreen")}}}function _mouseWheel(e){if(!this.active)return;e.preventDefault();const t=function normalizeWheelEventDelta(e){const t=e.deltaMode;let i=normalizeWheelEventDirection(e);t===WheelEvent.DOM_DELTA_PIXEL?i/=900:t===WheelEvent.DOM_DELTA_LINE&&(i/=30);return i}(e),i=Date.now(),a=this.mouseScrollTimeStamp;if(!(i>a&&i-a<50)){(this.mouseScrollDelta>0&&t<0||this.mouseScrollDelta<0&&t>0)&&pdf_presentation_mode_assertClassBrand(df,this,_resetMouseScrollState).call(this);this.mouseScrollDelta+=t;if(Math.abs(this.mouseScrollDelta)>=.1){const e=this.mouseScrollDelta;pdf_presentation_mode_assertClassBrand(df,this,_resetMouseScrollState).call(this);(e>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}}}function _notifyStateChange(e){pdf_presentation_mode_classPrivateFieldSet(nf,this,e);this.eventBus.dispatch("presentationmodechanged",{source:this,state:e})}function _enter(){pdf_presentation_mode_assertClassBrand(df,this,_notifyStateChange).call(this,sh);this.container.classList.add(af);setTimeout(()=>{this.pdfViewer.scrollMode=ph.PAGE;null!==pdf_presentation_mode_classPrivateFieldGet(of,this).spreadMode&&(this.pdfViewer.spreadMode=gh.NONE);this.pdfViewer.currentPageNumber=pdf_presentation_mode_classPrivateFieldGet(of,this).pageNumber;this.pdfViewer.currentScaleValue="page-fit";null!==pdf_presentation_mode_classPrivateFieldGet(of,this).annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:P.NONE})},0);pdf_presentation_mode_assertClassBrand(df,this,_addWindowListeners).call(this);pdf_presentation_mode_assertClassBrand(df,this,_showControls).call(this);this.contextMenuOpen=!1;document.getSelection().empty()}function _exit(){const e=this.pdfViewer.currentPageNumber;this.container.classList.remove(af);setTimeout(()=>{pdf_presentation_mode_assertClassBrand(df,this,_removeFullscreenChangeListeners).call(this);pdf_presentation_mode_assertClassBrand(df,this,_notifyStateChange).call(this,ih);this.pdfViewer.scrollMode=pdf_presentation_mode_classPrivateFieldGet(of,this).scrollMode;null!==pdf_presentation_mode_classPrivateFieldGet(of,this).spreadMode&&(this.pdfViewer.spreadMode=pdf_presentation_mode_classPrivateFieldGet(of,this).spreadMode);this.pdfViewer.currentScaleValue=pdf_presentation_mode_classPrivateFieldGet(of,this).scaleValue;this.pdfViewer.currentPageNumber=e;null!==pdf_presentation_mode_classPrivateFieldGet(of,this).annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:pdf_presentation_mode_classPrivateFieldGet(of,this).annotationEditorMode});pdf_presentation_mode_classPrivateFieldSet(of,this,null)},0);pdf_presentation_mode_assertClassBrand(df,this,_removeWindowListeners).call(this);pdf_presentation_mode_assertClassBrand(df,this,_hideControls).call(this);pdf_presentation_mode_assertClassBrand(df,this,_resetMouseScrollState).call(this);this.contextMenuOpen=!1}function _mouseDown(e){if(this.contextMenuOpen){this.contextMenuOpen=!1;e.preventDefault()}else if(!(0!==e.button||e.target.href&&e.target.parentNode?.hasAttribute("data-internal-link"))){e.preventDefault();e.shiftKey?this.pdfViewer.previousPage():this.pdfViewer.nextPage()}}function _contextMenu(){this.contextMenuOpen=!0}function _showControls(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(sf);this.controlsTimeout=setTimeout(()=>{this.container.classList.remove(sf);delete this.controlsTimeout},3e3)}function _hideControls(){if(this.controlsTimeout){clearTimeout(this.controlsTimeout);this.container.classList.remove(sf);delete this.controlsTimeout}}function _resetMouseScrollState(){this.mouseScrollTimeStamp=0;this.mouseScrollDelta=0}function _touchSwipe(e){if(this.active)if(e.touches.length>1)this.touchSwipeState=null;else switch(e.type){case"touchstart":this.touchSwipeState={startX:e.touches[0].pageX,startY:e.touches[0].pageY,endX:e.touches[0].pageX,endY:e.touches[0].pageY};break;case"touchmove":if(null===this.touchSwipeState)return;this.touchSwipeState.endX=e.touches[0].pageX;this.touchSwipeState.endY=e.touches[0].pageY;e.preventDefault();break;case"touchend":if(null===this.touchSwipeState)return;let t=0;const i=this.touchSwipeState.endX-this.touchSwipeState.startX,a=this.touchSwipeState.endY-this.touchSwipeState.startY,s=Math.abs(Math.atan2(a,i));Math.abs(i)>50&&(s<=rf||s>=Math.PI-rf)?t=i:Math.abs(a)>50&&Math.abs(s-Math.PI/2)<=rf&&(t=a);t>0?this.pdfViewer.previousPage():t<0&&this.pdfViewer.nextPage()}}function _addWindowListeners(){if(pdf_presentation_mode_classPrivateFieldGet(cf,this))return;pdf_presentation_mode_classPrivateFieldSet(cf,this,new AbortController);const e=pdf_presentation_mode_classPrivateFieldGet(cf,this).signal,t=pdf_presentation_mode_assertClassBrand(df,this,_touchSwipe).bind(this);window.addEventListener("mousemove",pdf_presentation_mode_assertClassBrand(df,this,_showControls).bind(this),{signal:e});window.addEventListener("mousedown",pdf_presentation_mode_assertClassBrand(df,this,_mouseDown).bind(this),{signal:e});window.addEventListener("wheel",pdf_presentation_mode_assertClassBrand(df,this,_mouseWheel).bind(this),{passive:!1,signal:e});window.addEventListener("keydown",pdf_presentation_mode_assertClassBrand(df,this,_resetMouseScrollState).bind(this),{signal:e});window.addEventListener("contextmenu",pdf_presentation_mode_assertClassBrand(df,this,_contextMenu).bind(this),{signal:e});window.addEventListener("touchstart",t,{signal:e});window.addEventListener("touchmove",t,{signal:e});window.addEventListener("touchend",t,{signal:e})}function _removeWindowListeners(){pdf_presentation_mode_classPrivateFieldGet(cf,this)?.abort();pdf_presentation_mode_classPrivateFieldSet(cf,this,null)}function _addFullscreenChangeListeners(){if(!pdf_presentation_mode_classPrivateFieldGet(lf,this)){pdf_presentation_mode_classPrivateFieldSet(lf,this,new AbortController);window.addEventListener("fullscreenchange",()=>{document.fullscreenElement?pdf_presentation_mode_assertClassBrand(df,this,_enter).call(this):pdf_presentation_mode_assertClassBrand(df,this,_exit).call(this)},{signal:pdf_presentation_mode_classPrivateFieldGet(lf,this).signal})}}function _removeFullscreenChangeListeners(){pdf_presentation_mode_classPrivateFieldGet(lf,this)?.abort();pdf_presentation_mode_classPrivateFieldSet(lf,this,null)}function xfa_layer_builder_defineProperty(e,t,i){return(t=function xfa_layer_builder_toPropertyKey(e){var t=function xfa_layer_builder_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function xfa_layer_builder_classPrivateFieldInitSpec(e,t,i){(function xfa_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function xfa_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var hf=new WeakMap;class XfaLayerBuilder{constructor(e){let t=e.pdfPage,i=e.annotationStorage,a=void 0===i?null:i,s=e.linkService,r=e.xfaHtml,n=void 0===r?null:r;xfa_layer_builder_classPrivateFieldInitSpec(this,hf,!1);xfa_layer_builder_defineProperty(this,"div",null);this.pdfPage=t;this.annotationStorage=a;this.linkService=s;this.xfaHtml=n}async render(e){let t,i=e.viewport,a=e.intent,s=void 0===a?"display":a;if("print"===s)t=this.xfaHtml;else{t=await this.pdfPage.getXfa();if(function xfa_layer_builder_classPrivateFieldGet(e,t){return e.get(xfa_layer_builder_assertClassBrand(e,t))}(hf,this)||!t)return{textDivs:[]}}const r=!!this.div,n={viewport:i.clone({dontFlip:!0}),div:this.div??=document.createElement("div"),xfaHtml:t,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:s};return r?XfaLayer.update(n):XfaLayer.render(n)}cancel(){!function xfa_layer_builder_classPrivateFieldSet(e,t,i){return e.set(xfa_layer_builder_assertClassBrand(e,t),i),i}(hf,this,!0)}hide(){this.div&&(this.div.hidden=!0)}}class BasePrintServiceFactory{static initGlobals(e){}static get supportsPrinting(){throw new Error("Not implemented: supportsPrinting")}static createPrintService(e){throw new Error("Not implemented: createPrintService")}}const uf=["onError","onSuccess"];function canvas_size_esm_slicedToArray(e,t){return function canvas_size_esm_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function canvas_size_esm_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function canvas_size_esm_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return canvas_size_esm_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?canvas_size_esm_arrayLikeToArray(e,t):void 0}}(e,t)||function canvas_size_esm_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function canvas_size_esm_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function canvasTest(e){const t=e.sizes.shift(),i=Math.max(Math.ceil(t[0]),1),a=Math.max(Math.ceil(t[1]),1),s=[i-1,a-1,1,1],r=performance.now(),n="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let o,l;if(n){o=new OffscreenCanvas(1,1);l=new OffscreenCanvas(i,a)}else{o=document.createElement("canvas");o.width=1;o.height=1;l=document.createElement("canvas");l.width=i;l.height=a}const c=o.getContext("2d"),d=l.getContext("2d");if(d){d.fillRect.apply(d,s);c.drawImage(l,i-1,a-1,1,1,0,0,1,1)}const h=c&&0!==c.getImageData(0,0,1,1).data[3],u=parseInt(performance.now()-r);[o,l].forEach(e=>{e.height=0;e.width=0});if(n){postMessage({width:i,height:a,testTime:u,isTestPass:h});!h&&e.sizes.length&&setTimeout(()=>{canvasTest(e)},0)}else if(h)e.onSuccess({width:i,height:a,testTime:u});else{e.onError({width:i,height:a,testTime:u});e.sizes.length&&setTimeout(()=>{canvasTest(e)},0)}return h}const _f={area:[16384,14188,11402,11180,10836,8192,4096,1],height:[8388607,65535,32767,16384,8192,4096,1],width:[4194303,65535,32767,16384,8192,4096,1]},pf={max:null,min:1,sizes:[],step:1024,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},gf={};function createSizesArray(e){const t=e.width===e.height,i=1===e.height,a=1===e.width,s=[];if(e.width&&e.height){const r=e.min||pf.min,n=e.step||pf.step;let o=Math.max(e.width,e.height);for(;o>=r;){const e=t||i?o:1,r=t||a?o:1;s.push([e,r]);o-=n}}else e.sizes.forEach(e=>{const r=t||i?e:1,n=t||a?e:1;s.push([r,n])});return s}function handleMethod(e){const t="undefined"!=typeof window,i=t&&"Promise"in window,a=t&&"HTMLCanvasElement"in window,s=t&&"OffscreenCanvas"in window,r=URL.createObjectURL(new Blob([])).slice(-36),n=performance.now(),o=e.onError,l=e.onSuccess,c=function _objectWithoutProperties(e,t){if(null==e)return{};var i,a,s=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var i={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(-1!==t.indexOf(a))continue;i[a]=e[a]}return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)i=r[a],-1===t.indexOf(i)&&{}.propertyIsEnumerable.call(e,i)&&(s[i]=e[i])}return s}(e,uf),getTotalTime=()=>parseInt(performance.now()-n);let d=null;if(!a)return!1;if(e.useWorker&&s){const e=`\n var canvasTest = ${canvasTest.toString()};\n onmessage = function(e) {\n canvasTest(e.data);\n };\n `,t=new Blob([e],{type:"application/javascript"}),i=URL.createObjectURL(t);d=new Worker(i);URL.revokeObjectURL(i);d.onmessage=function(e){const t=e.data,i=t.width,a=t.height,s=t.testTime,n=t.isTestPass,o={width:i,height:a,testTime:s,totalTime:getTotalTime()};if(n){gf[r].onSuccess(o);delete gf[r]}else gf[r].onError(o)}}if(i)return new Promise(t=>{const i={...e,onError(i){let a=i.width,s=i.height;const r={width:a,height:s,testTime:i.testTime,totalTime:getTotalTime()};let n;if(0===e.sizes.length)n=!0;else{const t=canvas_size_esm_slicedToArray(e.sizes.slice(-1),1),i=canvas_size_esm_slicedToArray(t[0],2),r=i[0],o=i[1];n=a===r&&s===o}o(r);n&&t({...r,success:!1})},onSuccess(e){const i={width:e.width,height:e.height,testTime:e.testTime,totalTime:getTotalTime()};l(i);t({...i,success:!0})}};if(d){const e=i.onError,t=i.onSuccess;gf[r]={onError:e,onSuccess:t};d.postMessage(c)}else canvasTest(i)});if(!d)return canvasTest(e);gf[r]={onError:o,onSuccess:l};d.postMessage(c)}const ff={maxArea(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=createSizesArray({width:e.max,height:e.max,min:e.min,step:e.step,sizes:[..._f.area]});return handleMethod({...pf,...e,sizes:t})},maxHeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=createSizesArray({width:1,height:e.max,min:e.min,step:e.step,sizes:[..._f.height]});return handleMethod({...pf,...e,sizes:t})},maxWidth(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=createSizesArray({width:e.max,height:1,min:e.min,step:e.step,sizes:[..._f.width]});return handleMethod({...pf,...e,sizes:t})},test(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={...pf,...e};t.sizes=[...t.sizes];t.width&&t.height&&(t.sizes=[[t.width,t.height]]);return handleMethod(t)}};function max_canvas_size_defineProperty(e,t,i){return(t=function max_canvas_size_toPropertyKey(e){var t=function max_canvas_size_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class MaxCanvasSize{static async determineMaxArea(){const e=await ff.maxArea({useWorker:!0}),t=e.success,i=e.width,a=e.height;if(!t){MaxCanvasSize.maxWidth=4096;MaxCanvasSize.maxArea=16777216;return 4096}MaxCanvasSize.maxArea=i*a;return MaxCanvasSize.maxArea}static async determineMaxWidth(){const e=(await ff.maxWidth({useWorker:!0})).width;MaxCanvasSize.maxWidth=e;return MaxCanvasSize.maxWidth}static async determineMaxHeight(){const e=(await ff.maxHeight({useWorker:!0})).height;MaxCanvasSize.maxHeight=e;return MaxCanvasSize.maxHeight}static async determineMaxDimensions(){if(MaxCanvasSize.maxWidth)return MaxCanvasSize.maxWidth;await this.determineMaxArea();await this.determineMaxHeight();await this.determineMaxWidth();return MaxCanvasSize.maxWidth}static async reduceToMaxCanvasSize(e,t){let i=1;if(e>=4096||t>=4096){await this.determineMaxDimensions();i=Math.max(e/MaxCanvasSize.maxWidth,t/MaxCanvasSize.maxHeight,Math.sqrt(e*t/MaxCanvasSize.maxArea));i>1&&(i=Math.ceil(1+100*i)/100)}return i}}max_canvas_size_defineProperty(MaxCanvasSize,"maxWidth",null);max_canvas_size_defineProperty(MaxCanvasSize,"maxHeight",null);max_canvas_size_defineProperty(MaxCanvasSize,"maxArea",null);function pdf_print_service_slicedToArray(e,t){return function pdf_print_service_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_print_service_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_print_service_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_print_service_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_print_service_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_print_service_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_print_service_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}let mf=null,vf=null,yf=null,Pf={initialized:!1};class PDFPrintService{constructor(e,t,i){let a=e.pdfDocument,s=e.pagesOverview,r=e.printResolution,n=e.printAnnotationStoragePromise,o=void 0===n?null:n,l=e.eventBus,c=e.cspPolicyService,d=e.pageOrder,h=void 0===d?null:d;this.pdfDocument=a;this.pagesOverview=s;this._printResolution=r||150;this.pageOrder=h||Array.from({length:a.numPages},(e,t)=>t+1);this._optionalContentConfigPromise=a.getOptionalContentConfig({intent:"print"});this._printAnnotationStoragePromise=o||Promise.resolve();this.currentPage=-1;this.scratchCanvas=document.createElement("canvas");this.eventBus=l;this.filteredPageCount=i;this.isInPDFPrintRange=t;this.cspPolicyService=c;this._blobUrls=[]}layout(){this.throwIfInactive();const e=document.querySelector("body");e.setAttribute("data-pdfjsprinting",!0);document.querySelector("html").setAttribute("data-pdfjsprinting",!0);const t=this.pagesOverview[0],i=t.width,a=t.height;this.pagesOverview.every(e=>e.width===i&&e.height===a)||ngx_console_NgxConsole.warn("Not all pages have the same size. The printed result may be incorrect!");this.pageStyleSheet=document.createElement("style");const s=`@page { size: ${i}pt ${a}pt;}`;this.cspPolicyService?this.cspPolicyService.addTrustedCSS(this.pageStyleSheet,s):this.pageStyleSheet.textContent=s;e.append(this.pageStyleSheet)}destroy(){if(mf!==this)return;this.printContainer.remove();this.printContainer=null;document.querySelector("body").removeAttribute("data-pdfjsprinting");document.querySelector("html").removeAttribute("data-pdfjsprinting");if(this.pageStyleSheet){this.pageStyleSheet.remove();this.pageStyleSheet=null}if(this._blobURLs){for(const e of this._blobURLs)URL.revokeObjectURL(e);this._blobURLs=null}this.scratchCanvas.width=this.scratchCanvas.height=0;this.scratchCanvas=null;for(const e of this._blobUrls)URL.revokeObjectURL(e);this._blobUrls=[];mf=null;ensureOverlay().then(function(){yf.closeIfActive(vf);yf.unregister(vf);bf=void 0})}renderPages(){if(this.pdfDocument.isPureXfa){!function getXfaHtmlForPrinting(e,t){const i=t.allXfaHtml,a=new SimpleLinkService,s=Math.round(100*PixelsPerInch.PDF_TO_CSS_UNITS)/100;for(const r of i.children){const i=document.createElement("div");i.className="xfaPrintedPage";e.append(i);const n=new XfaLayerBuilder({pdfPage:null,annotationStorage:t.annotationStorage,linkService:a,xfaHtml:r}),o=XfaLayer.getPageViewport(r,{scale:s});n.render({viewport:o,intent:"print"});i.append(n.div)}}(this.printContainer,this.pdfDocument);return Promise.resolve()}const e=this.pagesOverview.length,renderNextPage=(t,i)=>{this.throwIfInactive();for(;;){++this.currentPage;if(this.currentPage>=e)break;if(!this.isInPDFPrintRange||this.isInPDFPrintRange(this.currentPage))break}if(this.currentPage>=e){renderProgress(this.filteredPageCount??e,this.filteredPageCount??e,this.eventBus);t();return}const a=this.currentPage;renderProgress(a,this.filteredPageCount??e,this.eventBus);(async function renderPage(e,t,i,a,s,r,n){const o=mf.scratchCanvas;let l=s/PixelsPerInch.PDF;const c=Math.floor(a.width*l),d=Math.floor(a.height*l),h=await MaxCanvasSize.reduceToMaxCanvasSize(c,d);if(h>1){const e=Math.round(100*(h-1));l=Math.ceil(.95*l/h);warn(`Page ${i}: Reduced the maximum resolution by ${e}% because the browser can't render larger canvases. The resolution is now ${l*PixelsPerInch.PDF} DPI.`)}o.width=Math.floor(a.width*l);o.height=Math.floor(a.height*l);const u=o.getContext("2d");u.save();u.fillStyle="rgb(255, 255, 255)";u.fillRect(0,0,o.width,o.height);u.restore();return Promise.all([t.getPage(i),n]).then(function(e){let t=pdf_print_service_slicedToArray(e,2),i=t[0],s=t[1];const n={canvas:o,transform:[l,0,0,l,0,0],viewport:i.getViewport({scale:1,rotation:a.rotation}),intent:"print",annotationMode:m.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:s};return i.render(n).promise.catch(e=>{e instanceof RenderingCancelledException||ngx_console_NgxConsole.error(e);throw e})})})(0,this.pdfDocument,this.pageOrder[a],this.pagesOverview[a],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function(){renderNextPage(t,i)},i)};return new Promise(renderNextPage)}useRenderedPage(){this.throwIfInactive();const e=document.createElement("img"),t=Promise.withResolvers(),i=t.promise,a=t.resolve,s=t.reject;e.onload=a;e.onerror=()=>{ngx_console_NgxConsole.error("Failed to load printed page image via blob URL, falling back to data URL.");try{e.onerror=()=>{ngx_console_NgxConsole.error("Print failed: could not load page image even with data URL fallback.");s(new Error("Failed to load printed page image."))};e.src=this.scratchCanvas.toDataURL()}catch(e){ngx_console_NgxConsole.error("Print failed: toDataURL fallback also failed.",e);s(e)}};try{this.scratchCanvas.toBlob(t=>{if(!t){ngx_console_NgxConsole.warn("Print: toBlob returned null, falling back to data URL.");try{e.src=this.scratchCanvas.toDataURL()}catch(e){ngx_console_NgxConsole.error("Print failed: both toBlob and toDataURL failed.",e);s(e)}return}const i=URL.createObjectURL(t);this._blobUrls.push(i);e.src=i})}catch(t){ngx_console_NgxConsole.warn("Print: toBlob threw, falling back to data URL.",t);try{e.src=this.scratchCanvas.toDataURL()}catch(e){ngx_console_NgxConsole.error("Print failed: both toBlob and toDataURL failed.",e);s(e)}}const r=document.createElement("div");r.className="printedPage";r.append(e);this.printContainer.append(r);i.catch(()=>{});return i}performPrint(){this.throwIfInactive();return new Promise(e=>{setTimeout(()=>{if(!this.active){e();return}wf.call(window);const t=navigator.platform&&["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,i=/Android/i.test(navigator.userAgent);setTimeout(e,t||i?1500:100)},0)})}get active(){return this===mf}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const wf=window.print;function dispatchEvent(e){const t=new CustomEvent(e,{bubbles:!1,cancelable:!1,detail:"custom"});window.dispatchEvent(t)}function abort(){if(mf){mf.destroy();dispatchEvent("afterprint")}}function renderProgress(e,t,i){vf=document.getElementById("printServiceDialog");const a=Math.round(100*e/t),s=vf.querySelector("progress"),r=vf.querySelector(".relative-progress");s.value=a;r.setAttribute("data-l10n-args",JSON.stringify({progress:a}));i.dispatch("progress",{source:this,type:"print",total:t,page:e,percent:100*e/t})}window.addEventListener("keydown",function(e){if(80===e.keyCode&&(e.ctrlKey||e.metaKey)&&!e.altKey&&(!e.shiftKey||window.chrome||window.opera)){window.print();e.preventDefault();e.stopImmediatePropagation()}},!0);if("onbeforeprint"in window){const stopPropagationIfNeeded=function(e){"custom"!==e.detail&&e.stopImmediatePropagation()};window.addEventListener("beforeprint",stopPropagationIfNeeded);window.addEventListener("afterprint",stopPropagationIfNeeded)}let bf;function ensureOverlay(){if(!bf){yf=Pf.overlayManager;if(!yf)throw new Error("The overlay manager has not yet been initialized.");vf=document.getElementById("printServiceDialog");bf=yf.register(vf,!0);document.getElementById("printCancel").onclick=abort;vf.addEventListener("close",abort)}return bf}class PDFPrintServiceFactory extends BasePrintServiceFactory{static initGlobals(e){Pf=e}static get supportsPrinting(){return shadow(this,"supportsPrinting",!0)}static createPrintService(e){if(mf)throw new Error("The print service is created and active.");PDFPrintServiceFactory.enablePrint||ngx_console_NgxConsole.debug("The print service is disabled.");return mf=new PDFPrintService(e,PDFPrintServiceFactory.isInPDFPrintRange,PDFPrintServiceFactory.filteredPageCount)}}function renderable_view_defineProperty(e,t,i){return(t=function renderable_view_toPropertyKey(e){var t=function renderable_view_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const Ff={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3};class RenderableView{constructor(){renderable_view_defineProperty(this,"renderingId","");renderable_view_defineProperty(this,"renderTask",null);renderable_view_defineProperty(this,"resume",null)}get renderingState(){throw new Error("Abstract getter `renderingState` accessed")}set renderingState(e){throw new Error("Abstract setter `renderingState` accessed")}async draw(){throw new Error("Not implemented: draw")}}function pdf_rendering_queue_defineProperty(e,t,i){return(t=function pdf_rendering_queue_toPropertyKey(e){var t=function pdf_rendering_queue_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function pdf_rendering_queue_classPrivateFieldInitSpec(e,t,i){(function pdf_rendering_queue_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function pdf_rendering_queue_classPrivateFieldSet(e,t,i){return e.set(pdf_rendering_queue_assertClassBrand(e,t),i),i}function pdf_rendering_queue_classPrivateFieldGet(e,t){return e.get(pdf_rendering_queue_assertClassBrand(e,t))}function pdf_rendering_queue_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Sf=new WeakMap,Cf=new WeakMap,Af=new WeakMap,xf=new WeakMap;class PDFRenderingQueue{constructor(){pdf_rendering_queue_classPrivateFieldInitSpec(this,Sf,null);pdf_rendering_queue_classPrivateFieldInitSpec(this,Cf,null);pdf_rendering_queue_classPrivateFieldInitSpec(this,Af,null);pdf_rendering_queue_classPrivateFieldInitSpec(this,xf,null);pdf_rendering_queue_defineProperty(this,"isThumbnailViewEnabled",!1);pdf_rendering_queue_defineProperty(this,"onIdle",null);pdf_rendering_queue_defineProperty(this,"printing",!1);Object.defineProperty(this,"hasViewer",{value:()=>!!pdf_rendering_queue_classPrivateFieldGet(xf,this)})}setViewer(e){pdf_rendering_queue_classPrivateFieldSet(xf,this,e)}setThumbnailViewer(e){pdf_rendering_queue_classPrivateFieldSet(Af,this,e)}isHighestPriority(e){return pdf_rendering_queue_classPrivateFieldGet(Sf,this)===e.renderingId}renderHighestPriority(e){if(pdf_rendering_queue_classPrivateFieldGet(Cf,this)){clearTimeout(pdf_rendering_queue_classPrivateFieldGet(Cf,this));pdf_rendering_queue_classPrivateFieldSet(Cf,this,null)}pdf_rendering_queue_classPrivateFieldGet(xf,this).forceRendering(e)||this.isThumbnailViewEnabled&&pdf_rendering_queue_classPrivateFieldGet(Af,this)?.forceRendering()||this.printing||this.onIdle&&pdf_rendering_queue_classPrivateFieldSet(Cf,this,setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(e,t,i){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const r=e.views,n=r.length;if(0===n)return null;for(let e=0;e<n;e++){const t=r[e].view;if(!this.isViewFinished(t))return t}if(!s)for(let e=0;e<n;e++){const t=r[e].view.detailView;if(t&&!this.isViewFinished(t))return t}const o=e.first.id,l=e.last.id;if(l-o+1>n){const a=e.ids;for(let e=1,s=l-o;e<s;e++){const s=i?o+e:l-e;if(a.has(s))continue;const r=t[s-1];if(!this.isViewFinished(r))return r}}let c=i?l:o-2,d=t[c];if(d&&!this.isViewFinished(d))return d;if(a){c+=i?1:-1;d=t[c];if(d&&!this.isViewFinished(d))return d}return null}isViewFinished(e){return e.renderingState===Ff.FINISHED}renderView(e){switch(e.renderingState){case Ff.FINISHED:return!1;case Ff.PAUSED:pdf_rendering_queue_classPrivateFieldSet(Sf,this,e.renderingId);e.resume();break;case Ff.RUNNING:pdf_rendering_queue_classPrivateFieldSet(Sf,this,e.renderingId);break;case Ff.INITIAL:pdf_rendering_queue_classPrivateFieldSet(Sf,this,e.renderingId);e.draw().finally(()=>{this.renderHighestPriority()}).catch(e=>{e instanceof RenderingCancelledException||ngx_console_NgxConsole.error("renderView:",e)})}return!0}}function pdf_scripting_manager_slicedToArray(e,t){return function pdf_scripting_manager_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_scripting_manager_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_scripting_manager_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_scripting_manager_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_scripting_manager_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_scripting_manager_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_scripting_manager_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pdf_scripting_manager_classPrivateFieldInitSpec(e,t,i){pdf_scripting_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_scripting_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_scripting_manager_classPrivateFieldGet(e,t){return e.get(pdf_scripting_manager_assertClassBrand(e,t))}function pdf_scripting_manager_classPrivateFieldSet(e,t,i){return e.set(pdf_scripting_manager_assertClassBrand(e,t),i),i}function pdf_scripting_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var kf=new WeakMap,Ef=new WeakMap,Tf=new WeakMap,If=new WeakMap,Gf=new WeakMap,Bf=new WeakMap,Mf=new WeakMap,Df=new WeakMap,Lf=new WeakMap,Of=new WeakMap,Rf=new WeakMap,Nf=new WeakSet;class PDFScriptingManager{constructor(e){let t=e.eventBus,i=e.externalServices,a=void 0===i?null:i,s=e.docProperties,r=void 0===s?null:s;!function pdf_scripting_manager_classPrivateMethodInitSpec(e,t){pdf_scripting_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,Nf);pdf_scripting_manager_classPrivateFieldInitSpec(this,kf,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Ef,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Tf,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,If,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Gf,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Bf,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Mf,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Df,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Lf,!1);pdf_scripting_manager_classPrivateFieldInitSpec(this,Of,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Rf,null);pdf_scripting_manager_classPrivateFieldSet(Gf,this,t);pdf_scripting_manager_classPrivateFieldSet(Bf,this,a);pdf_scripting_manager_classPrivateFieldSet(Tf,this,r)}setViewer(e){pdf_scripting_manager_classPrivateFieldSet(Df,this,e)}async setDocument(e){pdf_scripting_manager_classPrivateFieldGet(Mf,this)&&await pdf_scripting_manager_assertClassBrand(Nf,this,_destroyScripting).call(this);pdf_scripting_manager_classPrivateFieldSet(Mf,this,e);if(!e)return;const t=pdf_scripting_manager_slicedToArray(await Promise.all([e.getFieldObjects(),e.getCalculationOrderIds(),e.getJSActions()]),3),i=t[0],a=t[1],s=t[2];if(!i&&!s){await pdf_scripting_manager_assertClassBrand(Nf,this,_destroyScripting).call(this);return}if(e!==pdf_scripting_manager_classPrivateFieldGet(Mf,this))return;try{pdf_scripting_manager_classPrivateFieldSet(Of,this,pdf_scripting_manager_assertClassBrand(Nf,this,_initScripting).call(this))}catch(e){ngx_console_NgxConsole.error("setDocument:",e);await pdf_scripting_manager_assertClassBrand(Nf,this,_destroyScripting).call(this);return}const r=pdf_scripting_manager_classPrivateFieldGet(Gf,this);pdf_scripting_manager_classPrivateFieldSet(If,this,new AbortController);const n={signal:pdf_scripting_manager_classPrivateFieldGet(If,this).signal,...Ih};r.on("updatefromsandbox",e=>{e?.source===window&&pdf_scripting_manager_assertClassBrand(Nf,this,_updateFromSandbox).call(this,e.detail)},n);r.on("dispatcheventinsandbox",e=>{pdf_scripting_manager_classPrivateFieldGet(Of,this)?.dispatchEventInSandbox(e.detail)},n);r.on("pagechanging",e=>{let t=e.pageNumber,i=e.previous;if(t!==i){pdf_scripting_manager_assertClassBrand(Nf,this,_dispatchPageClose).call(this,i);pdf_scripting_manager_assertClassBrand(Nf,this,_dispatchPageOpen).call(this,t)}},n);r.on("pagerendered",e=>{let t=e.pageNumber;this._pageOpenPending.has(t)&&t===pdf_scripting_manager_classPrivateFieldGet(Df,this).currentPageNumber&&pdf_scripting_manager_assertClassBrand(Nf,this,_dispatchPageOpen).call(this,t)},n);r.on("pagesdestroy",async()=>{await pdf_scripting_manager_assertClassBrand(Nf,this,_dispatchPageClose).call(this,pdf_scripting_manager_classPrivateFieldGet(Df,this).currentPageNumber);await(pdf_scripting_manager_classPrivateFieldGet(Of,this)?.dispatchEventInSandbox({id:"doc",name:"WillClose"}));pdf_scripting_manager_classPrivateFieldGet(kf,this)?.resolve()},n);try{const t=await pdf_scripting_manager_classPrivateFieldGet(Tf,this).call(this,e);if(e!==pdf_scripting_manager_classPrivateFieldGet(Mf,this))return;await pdf_scripting_manager_classPrivateFieldGet(Of,this).createSandbox({objects:i,calculationOrder:a,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...t,actions:s}});r.dispatch("sandboxcreated",{source:this})}catch(e){ngx_console_NgxConsole.error("setDocument:",e);await pdf_scripting_manager_assertClassBrand(Nf,this,_destroyScripting).call(this);return}await(pdf_scripting_manager_classPrivateFieldGet(Of,this)?.dispatchEventInSandbox({id:"doc",name:"Open"}));await pdf_scripting_manager_assertClassBrand(Nf,this,_dispatchPageOpen).call(this,pdf_scripting_manager_classPrivateFieldGet(Df,this).currentPageNumber,!0);Promise.resolve().then(()=>{e===pdf_scripting_manager_classPrivateFieldGet(Mf,this)&&pdf_scripting_manager_classPrivateFieldSet(Lf,this,!0)})}async dispatchWillSave(){return pdf_scripting_manager_classPrivateFieldGet(Of,this)?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return pdf_scripting_manager_classPrivateFieldGet(Of,this)?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(pdf_scripting_manager_classPrivateFieldGet(Of,this)){await(pdf_scripting_manager_classPrivateFieldGet(Rf,this)?.promise);pdf_scripting_manager_classPrivateFieldSet(Rf,this,Promise.withResolvers());try{await pdf_scripting_manager_classPrivateFieldGet(Of,this).dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(e){pdf_scripting_manager_classPrivateFieldGet(Rf,this).resolve();pdf_scripting_manager_classPrivateFieldSet(Rf,this,null);throw e}await pdf_scripting_manager_classPrivateFieldGet(Rf,this).promise}}async dispatchDidPrint(){return pdf_scripting_manager_classPrivateFieldGet(Of,this)?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return pdf_scripting_manager_classPrivateFieldGet(Ef,this)?.promise||null}get ready(){return pdf_scripting_manager_classPrivateFieldGet(Lf,this)}get _pageOpenPending(){return shadow(this,"_pageOpenPending",new Set)}get _visitedPages(){return shadow(this,"_visitedPages",new Map)}}async function _updateFromSandbox(e){const t=pdf_scripting_manager_classPrivateFieldGet(Df,this),i=t.isInPresentationMode||t.isChangingPresentationMode,a=e.id,s=e.siblings,r=e.command,n=e.value;if(!a){switch(r){case"clear":ngx_console_NgxConsole.clear();break;case"error":ngx_console_NgxConsole.error(n);break;case"layout":if(!i){const e=apiPageLayoutToViewerModes(n);t.spreadMode=e.spreadMode}break;case"page-num":t.currentPageNumber=n+1;break;case"print":await t.pagesPromise;pdf_scripting_manager_classPrivateFieldGet(Gf,this).dispatch("print",{source:this});break;case"println":ngx_console_NgxConsole.log(n);break;case"zoom":i||(t.currentScaleValue=n);break;case"SaveAs":pdf_scripting_manager_classPrivateFieldGet(Gf,this).dispatch("download",{source:this});break;case"FirstPage":t.currentPageNumber=1;break;case"LastPage":t.currentPageNumber=t.pagesCount;break;case"NextPage":t.nextPage();break;case"PrevPage":t.previousPage();break;case"ZoomViewIn":i||t.increaseScale();break;case"ZoomViewOut":i||t.decreaseScale();break;case"WillPrintFinished":pdf_scripting_manager_classPrivateFieldGet(Rf,this)?.resolve();pdf_scripting_manager_classPrivateFieldSet(Rf,this,null)}return}if(i&&e.focus)return;delete e.id;delete e.siblings;const o=s?[a,...s]:[a];for(const t of o){const i=document.querySelector(`[data-element-id="${t}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:e})):pdf_scripting_manager_classPrivateFieldGet(Mf,this)?.annotationStorage.setValue(t,e)}}async function _dispatchPageOpen(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=pdf_scripting_manager_classPrivateFieldGet(Mf,this),a=this._visitedPages;t&&pdf_scripting_manager_classPrivateFieldSet(kf,this,Promise.withResolvers());if(!pdf_scripting_manager_classPrivateFieldGet(kf,this))return;const s=pdf_scripting_manager_classPrivateFieldGet(Df,this).getPageView(e-1);if(s?.renderingState!==Ff.FINISHED){this._pageOpenPending.add(e);return}this._pageOpenPending.delete(e);const r=(async()=>{const t=await(a.has(e)?null:s.pdfPage?.getJSActions());i===pdf_scripting_manager_classPrivateFieldGet(Mf,this)&&await(pdf_scripting_manager_classPrivateFieldGet(Of,this)?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:e,actions:t}))})();a.set(e,r)}async function _dispatchPageClose(e){const t=pdf_scripting_manager_classPrivateFieldGet(Mf,this),i=this._visitedPages;if(!pdf_scripting_manager_classPrivateFieldGet(kf,this))return;if(this._pageOpenPending.has(e))return;const a=i.get(e);if(a){i.set(e,null);await a;t===pdf_scripting_manager_classPrivateFieldGet(Mf,this)&&await(pdf_scripting_manager_classPrivateFieldGet(Of,this)?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:e}))}}function _initScripting(){pdf_scripting_manager_classPrivateFieldSet(Ef,this,Promise.withResolvers());if(pdf_scripting_manager_classPrivateFieldGet(Of,this))throw new Error("#initScripting: Scripting already exists.");return pdf_scripting_manager_classPrivateFieldGet(Bf,this).createScripting()}async function _destroyScripting(){if(pdf_scripting_manager_classPrivateFieldGet(Of,this)){if(pdf_scripting_manager_classPrivateFieldGet(kf,this)){await Promise.race([pdf_scripting_manager_classPrivateFieldGet(kf,this).promise,new Promise(e=>{setTimeout(e,1e3)})]).catch(()=>{});pdf_scripting_manager_classPrivateFieldSet(kf,this,null)}pdf_scripting_manager_classPrivateFieldSet(Mf,this,null);try{await pdf_scripting_manager_classPrivateFieldGet(Of,this).destroySandbox()}catch{}pdf_scripting_manager_classPrivateFieldGet(Rf,this)?.reject(new Error("Scripting destroyed."));pdf_scripting_manager_classPrivateFieldSet(Rf,this,null);pdf_scripting_manager_classPrivateFieldGet(If,this)?.abort();pdf_scripting_manager_classPrivateFieldSet(If,this,null);this._pageOpenPending.clear();this._visitedPages.clear();pdf_scripting_manager_classPrivateFieldSet(Of,this,null);pdf_scripting_manager_classPrivateFieldSet(Lf,this,!1);pdf_scripting_manager_classPrivateFieldGet(Ef,this)?.resolve()}else{pdf_scripting_manager_classPrivateFieldSet(Mf,this,null);pdf_scripting_manager_classPrivateFieldGet(Ef,this)?.resolve()}}function menu_classPrivateFieldInitSpec(e,t,i){menu_checkPrivateRedeclaration(e,t),t.set(e,i)}function menu_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function menu_classPrivateFieldGet(e,t){return e.get(menu_assertClassBrand(e,t))}function menu_classPrivateFieldSet(e,t,i){return e.set(menu_assertClassBrand(e,t),i),i}function menu_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var jf=new WeakMap,Wf=new WeakMap,Uf=new WeakMap,Vf=new WeakMap,Hf=new WeakMap,zf=new WeakMap,$f=new WeakMap,qf=new WeakSet;class Menu{constructor(e,t,i){!function menu_classPrivateMethodInitSpec(e,t){menu_checkPrivateRedeclaration(e,t),t.add(e)}(this,qf);menu_classPrivateFieldInitSpec(this,jf,void 0);menu_classPrivateFieldInitSpec(this,Wf,void 0);menu_classPrivateFieldInitSpec(this,Uf,void 0);menu_classPrivateFieldInitSpec(this,Vf,null);menu_classPrivateFieldInitSpec(this,Hf,new AbortController);menu_classPrivateFieldInitSpec(this,zf,-1);menu_classPrivateFieldInitSpec(this,$f,menu_assertClassBrand(qf,this,_onFocusOut).bind(this));menu_classPrivateFieldSet(Wf,this,e);menu_classPrivateFieldSet(jf,this,t);if(Array.isArray(i))menu_classPrivateFieldSet(Uf,this,i);else{menu_classPrivateFieldSet(Uf,this,[]);for(const e of menu_classPrivateFieldGet(Wf,this).querySelectorAll("button"))menu_classPrivateFieldGet(Uf,this).push(e)}menu_assertClassBrand(qf,this,_setUpMenu).call(this)}destroy(){menu_assertClassBrand(qf,this,_closeMenu).call(this);menu_classPrivateFieldGet(Hf,this)?.abort();menu_classPrivateFieldSet(Hf,this,null)}}function _closeMenu(){if(!menu_classPrivateFieldGet(Vf,this))return;const e=menu_classPrivateFieldGet(Wf,this);menu_classPrivateFieldGet(jf,this).ariaExpanded="false";menu_classPrivateFieldGet(Vf,this).abort();menu_classPrivateFieldSet(Vf,this,null);e.contains(document.activeElement)&&setTimeout(()=>{e.contains(document.activeElement)||menu_classPrivateFieldGet(jf,this).focus()},0);menu_classPrivateFieldSet(zf,this,-1)}function _openMenu(){if(menu_classPrivateFieldGet(Vf,this))return;const e=menu_classPrivateFieldGet(Wf,this);menu_classPrivateFieldGet(jf,this).ariaExpanded="true";menu_classPrivateFieldSet(Vf,this,new AbortController);const t=AbortSignal.any([menu_classPrivateFieldGet(Hf,this).signal,menu_classPrivateFieldGet(Vf,this).signal]);window.addEventListener("pointerdown",t=>{let i=t.target;menu_classPrivateFieldGet(jf,this).contains(i)||e.contains(i)||menu_assertClassBrand(qf,this,_closeMenu).call(this)},{signal:t});const i=menu_assertClassBrand(qf,this,_closeMenu).bind(this);window.addEventListener("blur",i,{signal:t});e.addEventListener("focusout",menu_classPrivateFieldGet($f,this),{signal:t})}function _onFocusOut(e){let t=e.relatedTarget;menu_classPrivateFieldGet(jf,this).contains(t)||menu_classPrivateFieldGet(Wf,this).contains(t)||menu_assertClassBrand(qf,this,_closeMenu).call(this)}function _setUpMenu(){menu_classPrivateFieldGet(jf,this).addEventListener("click",e=>{menu_classPrivateFieldGet(Vf,this)?menu_assertClassBrand(qf,this,_closeMenu).call(this):menu_assertClassBrand(qf,this,_openMenu).call(this)});menu_classPrivateFieldGet(jf,this).addEventListener("focusout",menu_classPrivateFieldGet($f,this));const e=menu_classPrivateFieldGet(Hf,this).signal;menu_classPrivateFieldGet(Wf,this).addEventListener("keydown",e=>{switch(e.key){case"Escape":menu_assertClassBrand(qf,this,_closeMenu).call(this);stopEvent(e);break;case"ArrowDown":menu_assertClassBrand(qf,this,_goToNextItem).call(this,e.target,!0);stopEvent(e);break;case"ArrowUp":menu_assertClassBrand(qf,this,_goToNextItem).call(this,e.target,!1);stopEvent(e);break;case"Home":menu_classPrivateFieldGet(Uf,this).find(e=>!e.disabled&&!e.classList.contains("hidden"))?.focus();stopEvent(e);break;case"End":menu_classPrivateFieldGet(Uf,this).findLast(e=>!e.disabled&&!e.classList.contains("hidden"))?.focus();stopEvent(e);break;default:const t=e.key;if(!/^\p{L}$/u.test(t))break;const i=t.toLocaleLowerCase();menu_assertClassBrand(qf,this,_goToNextItem).call(this,e.target,!0,e=>e.textContent.trim().toLowerCase().startsWith(i));stopEvent(e)}},{signal:e,capture:!0});menu_classPrivateFieldGet(Wf,this).addEventListener("contextmenu",noContextMenu,{signal:e});menu_classPrivateFieldGet(Wf,this).addEventListener("click",menu_assertClassBrand(qf,this,_closeMenu).bind(this),{signal:e,capture:!0});menu_classPrivateFieldGet(jf,this).addEventListener("keydown",e=>{switch(e.key){case" ":case"Enter":case"ArrowDown":case"Home":stopEvent(e);menu_classPrivateFieldGet(Vf,this)||menu_assertClassBrand(qf,this,_openMenu).call(this);menu_classPrivateFieldGet(Uf,this).find(e=>!e.disabled&&!e.classList.contains("hidden"))?.focus();break;case"ArrowUp":case"End":stopEvent(e);menu_classPrivateFieldGet(Vf,this)||menu_assertClassBrand(qf,this,_openMenu).call(this);menu_classPrivateFieldGet(Uf,this).findLast(e=>!e.disabled&&!e.classList.contains("hidden"))?.focus();break;case"Escape":menu_assertClassBrand(qf,this,_closeMenu).call(this);stopEvent(e)}},{signal:e})}function _goToNextItem(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>!0;const a=-1===menu_classPrivateFieldGet(zf,this)?menu_classPrivateFieldGet(Uf,this).indexOf(e):menu_classPrivateFieldGet(zf,this),s=menu_classPrivateFieldGet(Uf,this).length,r=t?1:s-1;for(let e=(a+r)%s;e!==a;e=(e+r)%s){const t=menu_classPrivateFieldGet(Uf,this)[e];if(!t.disabled&&!t.classList.contains("hidden")&&i(t)){t.focus();menu_classPrivateFieldSet(zf,this,e);break}}}function pdf_thumbnail_view_slicedToArray(e,t){return function pdf_thumbnail_view_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_thumbnail_view_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_thumbnail_view_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_thumbnail_view_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_thumbnail_view_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_thumbnail_view_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_thumbnail_view_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pdf_thumbnail_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_thumbnail_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}let Xf=0;var Kf,Yf=new WeakMap,Zf=new WeakSet;class PDFThumbnailView extends RenderableView{constructor(e){let t=e.container,i=e.eventBus,a=e.id,s=e.defaultViewport,r=e.optionalContentConfigPromise,n=e.linkService,o=e.renderingQueue,l=e.maxCanvasPixels,c=e.maxCanvasDim,d=e.pageColors,h=e.enableSplitMerge,u=void 0!==h&&h,_=e.enablePageReordering,p=void 0!==_&&_;super();!function pdf_thumbnail_view_classPrivateMethodInitSpec(e,t){pdf_thumbnail_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,Zf);!function pdf_thumbnail_view_classPrivateFieldInitSpec(e,t,i){pdf_thumbnail_view_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,Yf,Ff.INITIAL);this.id=a;this.renderingId=`thumbnail${a}`;this.pageLabel=null;this.pdfPage=null;this.rotation=0;this.viewport=s;this.pdfPageRotate=s.rotation;this._optionalContentConfigPromise=r||null;this.maxCanvasPixels=l??AppOptions.get("maxCanvasPixels");this.maxCanvasDim=c||AppOptions.get("maxCanvasDim");this.pageColors=d||null;this.eventBus=i;this.linkService=n;this.renderingQueue=o;this.placeholder=null;i.dispatch("rendercustomthumbnail",{pdfThumbnailView:this,linkService:n,id:a,container:t,thumbPageTitlePromiseOrPageL10nArgs:pdf_thumbnail_view_assertClassBrand(Zf,this,_getPageL10nArgs).call(this)});const g=t.querySelector(`.${this.renderingId}`);if(g){this.div=g;this.imageContainer=this.div.querySelector(".thumbnailImageContainer")||this.div;this.image=this.div.querySelector(".thumbnailImage")||this.imageContainer.querySelector("img");this.checkbox=this.div.querySelector("input[type='checkbox']");if(this.image){if(u&&!this.checkbox){const e=this.checkbox=document.createElement("input");e.type="checkbox";e.tabIndex=-1;e.setAttribute("data-l10n-id","pdfjs-thumb-page-checkbox1");e.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Zf,this,_getPageL10nArgs).call(this));this.div.append(e);this.pasteButton=null}}else pdf_thumbnail_view_assertClassBrand(Zf,this,_createStandardThumbnail).call(this,t,a,u,p)}else pdf_thumbnail_view_assertClassBrand(Zf,this,_createStandardThumbnail).call(this,t,a,u);g&&pdf_thumbnail_view_assertClassBrand(Zf,this,_updateDims).call(this);if(p&&this.div){this.div.addEventListener("dragstart",this._dragStartHandler.bind(this));this.div.addEventListener("dragover",this._dragOverHandler.bind(this));this.div.addEventListener("drop",this._dropHandler.bind(this));this.div.addEventListener("mousedown",this._mouseDownHandler.bind(this))}}clone(e,t){const i=new PDFThumbnailView({container:e,id:t,eventBus:this.eventBus,defaultViewport:this.viewport,optionalContentConfigPromise:this._optionalContentConfigPromise,linkService:this.linkService,renderingQueue:this.renderingQueue,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,enableSplitMerge:!!this.checkbox});if(!this.imageContainer.classList.contains("missingThumbnailImage")){i.image.replaceWith(this.image.cloneNode(!0));i.imageContainer.classList.remove("missingThumbnailImage")}return i}addPasteButton(e){if(this.pasteButton)return;const t=this.pasteButton=document.createElement("button");t.classList.add("thumbnailPasteButton","viewsManagerButton");t.tabIndex=0;t.setAttribute("data-l10n-id","pdfjs-views-manager-paste-button-after");t.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id}));const i=document.createElement("span");i.setAttribute("data-l10n-id","pdfjs-views-manager-paste-button-label");t.append(i);t.addEventListener("click",()=>{e(this.id)});if(1===this.id){const i=this.prevPasteButton=t.cloneNode(!0);i.setAttribute("data-l10n-id","pdfjs-views-manager-paste-button-before");i.addEventListener("click",()=>{e(0)});this.imageContainer.before(i)}this.imageContainer.after(t)}removePasteButton(){this.pasteButton?.remove();this.pasteButton=null;this.prevPasteButton?.remove();this.prevPasteButton=null}toggleSelected(e){this.checkbox&&(this.checkbox.checked=e)}_dragStartHandler(e){e.dataTransfer.setData("text/plain",this.id.toString())}_dragOverHandler(e){e.preventDefault();e.dataTransfer.dropEffect="move";const t=e.currentTarget,i=t.getBoundingClientRect();this._removeDottedLine();i.top<Xf&&i.bottom>Xf||this._showDottedLine(t,i.height,Xf>e.clientY)}_dropHandler(e){e.preventDefault();e.stopPropagation();const t=parseInt(e.dataTransfer.getData("text/plain"),10),i=this.id;this._removeDottedLine();t!==i&&this._movePage(t,i)}_mouseDownHandler(e){Xf=e.clientY}_showDottedLine(e,t,i){const a=document.createElement("div");a.className="dotted-line";i?a.style.setProperty("--dotted-line-margin-x",-t+"px"):a.style.setProperty("--dotted-line-margin-x","6px");e.appendChild(a)}_removeDottedLine(){const e=document.querySelector(".dotted-line");e&&e.parentNode.removeChild(e)}_movePage(e,t){const i=this.div.parentNode,a=i.children[e-1],s=i.children[t-1];a&&s&&vw.movePage(e,t)}updateId(e){this.id=e;this.renderingId=`thumbnail${e}`;this.div.setAttribute("page-number",e);this.imageContainer.setAttribute("page-number",e);this.setPageLabel(this.pageLabel)}get renderingState(){return function pdf_thumbnail_view_classPrivateFieldGet(e,t){return e.get(pdf_thumbnail_view_assertClassBrand(e,t))}(Yf,this)}set renderingState(e){!function pdf_thumbnail_view_classPrivateFieldSet(e,t,i){return e.set(pdf_thumbnail_view_assertClassBrand(e,t),i),i}(Yf,this,e)}setPdfPage(e){if(!e)return;this.pdfPage=e;this.pdfPageRotate=e.rotate;const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=e.getViewport({scale:1,rotation:t});this.reset()}reset(){this.cancelRendering();this.renderingState=Ff.INITIAL;pdf_thumbnail_view_assertClassBrand(Zf,this,_updateDims).call(this);const e=this.image,t=this.imageContainer,i=e.src;if(i){URL.revokeObjectURL(i);e.src="";t.removeAttribute("data-l10n-id");t.removeAttribute("data-l10n-args");t.classList.add("missingThumbnailImage")}}destroy(){this.reset();this.toggleCurrent(!1);this.div.remove()}update(e){let t=e.rotation,i=void 0===t?null:t;"number"==typeof i&&(this.rotation=i);const a=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:1,rotation:a});this.reset()}toggleCurrent(e){const t=this.imageContainer;if(e){t.ariaCurrent="page";t.tabIndex=0;this.checkbox&&(this.checkbox.tabIndex=0)}else{t.ariaCurrent=!1;t.tabIndex=-1;this.checkbox&&(this.checkbox.tabIndex=-1)}}cancelRendering(){if(this.renderTask){this.renderTask.cancel();this.renderTask=null}this.resume=null}async draw(){if(this.renderingState!==Ff.INITIAL){ngx_console_NgxConsole.error("Must be in new state before drawing");return}const e=this.pageColors,t=this.pdfPage;if(!t){this.renderingState=Ff.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=Ff.RUNNING;const i=pdf_thumbnail_view_assertClassBrand(Zf,this,_getPageDrawContext).call(this,2),a=i.canvas,s={canvas:a,transform:i.transform,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:e},r=this.renderTask=t.render(s);r.onContinue=e=>{if(this.renderingQueue.isHighestPriority(this))e();else{this.renderingState=Ff.PAUSED;this.resume=()=>{this.renderingState=Ff.RUNNING;e()}}};let n=null;try{await r.promise}catch(e){if(e instanceof RenderingCancelledException)return;n=e}finally{r===this.renderTask&&(this.renderTask=null)}this.renderingState=Ff.FINISHED;await pdf_thumbnail_view_assertClassBrand(Zf,this,_convertCanvasToImage).call(this,a);this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:t});if(n)throw n}setImage(e){if(this.renderingState!==Ff.INITIAL)return;const t=e.thumbnailCanvas,i=e.pdfPage,a=e.scale;if(t){this.pdfPage||this.setPdfPage(i);if(!(a<this.scale)){this.renderingState=Ff.FINISHED;pdf_thumbnail_view_assertClassBrand(Zf,this,_convertCanvasToImage).call(this,t)}}}setPageLabel(e){this.pageLabel="string"==typeof e?e:null;this.imageContainer.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Zf,this,_getPageL10nArgs).call(this,!0));this.image.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Zf,this,_getPageL10nArgs).call(this));this.checkbox?.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Zf,this,_getPageL10nArgs).call(this))}}function _createStandardThumbnail(e,t,i){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const s=this.div=document.createElement("div");s.className="thumbnail";s.setAttribute("page-number",t);const r=this.imageContainer=document.createElement("div");s.append(r);r.classList.add("thumbnailImageContainer","missingThumbnailImage");r.role="button";r.tabIndex=-1;r.draggable=!1;r.setAttribute("page-number",t);r.setAttribute("data-l10n-id","pdfjs-thumb-page-title1");r.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Zf,this,_getPageL10nArgs).call(this,!0));const n=this.image=document.createElement("img");r.append(n);a&&(r.draggable=!0);if(i){const e=this.checkbox=document.createElement("input");e.type="checkbox";e.tabIndex=-1;e.setAttribute("data-l10n-id","pdfjs-thumb-page-checkbox1");e.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Zf,this,_getPageL10nArgs).call(this));s.append(e);this.pasteButton=null}pdf_thumbnail_view_assertClassBrand(Zf,this,_updateDims).call(this);e.append(s)}function _updateDims(){const e=this.viewport,t=e.width,i=t/e.height,a=this.canvasWidth=126,s=this.canvasHeight=a/i|0;this.scale=a/t;this.imageContainer.style.height=`${s}px`}function _getPageDrawContext(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;const t=new OutputScale,i=e*this.canvasWidth,a=e*this.canvasHeight;t.limitCanvas(i,a,this.maxCanvasPixels,this.maxCanvasDim);const s=document.createElement("canvas");s.width=i*t.sx|0;s.height=a*t.sy|0;return{canvas:s,transform:t.scaled?[t.sx,0,0,t.sy,0,0]:null}}async function _convertCanvasToImage(e){if(this.renderingState!==Ff.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const t=pdf_thumbnail_view_assertClassBrand(Zf,this,_reduceImage).call(this,e),i=this.imageContainer,a=this.image,s=Promise.withResolvers(),r=s.promise,n=s.resolve;t.toBlob(n);const o=await r;a.src=URL.createObjectURL(o);a.setAttribute("data-l10n-id","pdfjs-thumb-page-canvas");a.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Zf,this,_getPageL10nArgs).call(this));i.classList.remove("missingThumbnailImage")}function _getReducedImageDims(e){const t=e.width<<3,i=e.height<<3,a=new OutputScale;a.sx=a.sy=1;a.limitCanvas(t,i,this.maxCanvasPixels,this.maxCanvasDim);return[t*a.sx|0,i*a.sy|0]}function _reduceImage(e){const t=pdf_thumbnail_view_assertClassBrand(Zf,this,_getPageDrawContext).call(this,1).canvas,i=t.getContext("2d",{alpha:!1,willReadFrequently:!1});if(e.width<=2*t.width){i.drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height);return t}let a=pdf_thumbnail_view_slicedToArray(pdf_thumbnail_view_assertClassBrand(Zf,this,_getReducedImageDims).call(this,t),2),s=a[0],r=a[1];const n=function getTempCanvas(e,t){const i=new OffscreenCanvas(e,t),a=i.getContext("2d",{alpha:!1});a.save();a.fillStyle="rgb(255, 255, 255)";a.fillRect(0,0,e,t);a.restore();return[i,a]}(s,r),o=pdf_thumbnail_view_slicedToArray(n,2),l=o[0],c=o[1];for(;s>e.width||r>e.height;){s>>=1;r>>=1}c.drawImage(e,0,0,e.width,e.height,0,0,s,r);for(;s>2*t.width;){c.drawImage(l,0,0,s,r,0,0,s>>1,r>>1);s>>=1;r>>=1}i.drawImage(l,0,0,s,r,0,0,t.width,t.height);return t}function _getPageL10nArgs(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return JSON.stringify({page:this.pageLabel??this.id,total:e?this.linkService.pagesCount:void 0})}function pdf_thumbnail_viewer_slicedToArray(e,t){return function pdf_thumbnail_viewer_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_thumbnail_viewer_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_thumbnail_viewer_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_thumbnail_viewer_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_thumbnail_viewer_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_thumbnail_viewer_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_thumbnail_viewer_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pdf_thumbnail_viewer_classPrivateFieldInitSpec(e,t,i){pdf_thumbnail_viewer_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_thumbnail_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_thumbnail_viewer_toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function pdf_thumbnail_viewer_classPrivateFieldGet(e,t){return e.get(pdf_thumbnail_viewer_assertClassBrand(e,t))}function pdf_thumbnail_viewer_classPrivateFieldSet(e,t,i){return e.set(pdf_thumbnail_viewer_assertClassBrand(e,t),i),i}function pdf_thumbnail_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Jf={behavior:"instant",block:"nearest",inline:"nearest",container:"nearest"};var Qf=new WeakMap,em=new WeakMap,tm=new WeakMap,im=new WeakMap,am=new WeakMap,sm=new WeakMap,rm=new WeakMap,nm=new WeakMap,om=new WeakMap,lm=new WeakMap,cm=new WeakMap,dm=new WeakMap,hm=new WeakMap,um=new WeakMap,_m=new WeakMap,pm=new WeakMap,gm=new WeakMap,fm=new WeakMap,mm=new WeakMap,vm=new WeakMap,ym=new WeakMap,Pm=new WeakMap,wm=new WeakMap,bm=new WeakMap,Fm=new WeakMap,Sm=new WeakMap,Cm=new WeakMap,Am=new WeakMap,xm=new WeakMap,km=new WeakMap,Em=new WeakMap,Tm=new WeakMap,Im=new WeakMap,Gm=new WeakMap,Bm=new WeakMap,Mm=new WeakMap,Dm=new WeakMap,Lm=new WeakMap,Om=new WeakMap,Rm=new WeakMap,Nm=new WeakMap,jm=new WeakMap,Wm=new WeakMap,Um=new WeakMap,Vm=new WeakMap,Hm=new WeakSet;class PDFThumbnailViewer{constructor(e){let t=e.container,i=e.eventBus,a=e.linkService,s=e.renderingQueue,r=e.maxCanvasPixels,n=e.maxCanvasDim,o=e.pageColors,l=e.abortSignal,c=e.enableMerge,d=e.enableSplitMerge,h=e.enablePageReordering,u=e.enableNewBadge,_=e.statusBar,p=e.undoBar,g=e.waitingBar,f=e.manageMenu,m=e.addFileComponent;!function pdf_thumbnail_viewer_classPrivateMethodInitSpec(e,t){pdf_thumbnail_viewer_checkPrivateRedeclaration(e,t),t.add(e)}(this,Hm);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Qf,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,em,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,tm,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,im,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,am,void 0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,sm,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,rm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,nm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,om,NaN);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,lm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,cm,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,dm,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,hm,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,um,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,_m,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,pm,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,gm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,fm,NaN);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,mm,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,vm,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,ym,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Pm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,wm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,bm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Fm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Sm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Cm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Am,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,xm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,km,pdf_thumbnail_viewer_assertClassBrand(Hm,this,_pastePages).bind(this));pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Em,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Tm,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Im,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Gm,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Bm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Mm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Dm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Lm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Om,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Rm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Nm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,jm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Wm,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Um,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Vm,null);this.scrollableContainer=t.parentElement;this.container=t;this.eventBus=i;this.linkService=a;this.renderingQueue=s;this.maxCanvasPixels=r;this.maxCanvasDim=n;this.pageColors=o||null;pdf_thumbnail_viewer_classPrivateFieldSet(am,this,l);pdf_thumbnail_viewer_classPrivateFieldSet(Qf,this,c||!1);pdf_thumbnail_viewer_classPrivateFieldSet(em,this,d||!1);pdf_thumbnail_viewer_classPrivateFieldSet(tm,this,h||!1);pdf_thumbnail_viewer_classPrivateFieldSet(Bm,this,_?.viewsManagerStatusActionLabel||null);pdf_thumbnail_viewer_classPrivateFieldSet(Dm,this,_?.viewsManagerStatusActionDeselectButton||null);pdf_thumbnail_viewer_classPrivateFieldSet(Mm,this,_?.viewsManagerStatusAction||null);pdf_thumbnail_viewer_classPrivateFieldSet(Lm,this,p?.viewsManagerStatusUndo||null);pdf_thumbnail_viewer_classPrivateFieldSet(Om,this,p?.viewsManagerStatusUndoLabel||null);pdf_thumbnail_viewer_classPrivateFieldSet(Rm,this,p?.viewsManagerStatusUndoButton||null);pdf_thumbnail_viewer_classPrivateFieldSet(Nm,this,p?.viewsManagerStatusUndoCloseButton||null);pdf_thumbnail_viewer_classPrivateFieldSet(jm,this,g||null);if(pdf_thumbnail_viewer_classPrivateFieldGet(em,this)&&f){const e=f.button,t=f.menu,i=f.copy,a=f.cut,s=f.delete,r=f.exportSelected;if(u){const t=document.createElement("span");t.setAttribute("data-l10n-id","pdfjs-new-badge-content");t.classList.add("newBadge");e.parentElement.before(t);pdf_thumbnail_viewer_classPrivateFieldSet(Vm,this,t)}this.eventBus.on("pagesloaded",()=>{e.disabled=!1},{once:!0});this._manageMenu=new Menu(t,e,[i,a,s,r]);pdf_thumbnail_viewer_classPrivateFieldSet(Pm,this,r);r.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Hm,this,_saveExtractedPages).bind(this));pdf_thumbnail_viewer_classPrivateFieldSet(wm,this,s);s.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Hm,this,_deletePages).bind(this,"delete"));pdf_thumbnail_viewer_classPrivateFieldSet(bm,this,i);i.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Hm,this,_copyPages).bind(this));pdf_thumbnail_viewer_classPrivateFieldSet(Fm,this,a);a.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Hm,this,_cutPages).bind(this));pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleMenuEntries).call(this,!1);e.disabled=!0;this.eventBus.on("editingaction",e=>{switch(e.name){case"copyPage":pdf_thumbnail_viewer_assertClassBrand(Hm,this,_copyPages).call(this);break;case"cutPage":pdf_thumbnail_viewer_assertClassBrand(Hm,this,_cutPages).call(this);break;case"deletePage":pdf_thumbnail_viewer_assertClassBrand(Hm,this,_deletePages).call(this,"delete");break;case"savePage":pdf_thumbnail_viewer_assertClassBrand(Hm,this,_saveExtractedPages).call(this)}});this.container.addEventListener("contextmenu",e=>{this.eventBus.dispatch("editingstateschanged",{source:this,details:{thumbnailId:parseInt(e.target.closest(".thumbnailImageContainer")?.parentElement.getAttribute("page-number"),10)??-1,hasSelectedPages:!!pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)?.size,canDeletePages:pdf_thumbnail_viewer_assertClassBrand(Hm,this,_canDelete).call(this)}})},{signal:l,passive:!0});pdf_thumbnail_viewer_classPrivateFieldGet(Rm,this)?.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Hm,this,_undo).bind(this));pdf_thumbnail_viewer_classPrivateFieldGet(Nm,this)?.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Hm,this,_dismissUndo).bind(this,!0));pdf_thumbnail_viewer_classPrivateFieldGet(Dm,this)?.addEventListener("click",()=>{pdf_thumbnail_viewer_assertClassBrand(Hm,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateStatus).call(this,"select")});pdf_thumbnail_viewer_classPrivateFieldGet(Dm,this).classList.toggle("hidden",!0)}else f&&(f.button.hidden=!0);if(pdf_thumbnail_viewer_classPrivateFieldGet(Qf,this)&&m?.button&&m.picker){const e=m.picker,t=m.button;e.addEventListener("change",()=>{const t=Array.from(e.files??[]);t.length&&pdf_thumbnail_viewer_assertClassBrand(Hm,this,_mergeFiles).call(this,t,this._currentPageNumber-1)});t.addEventListener("click",()=>{e.click()});pdf_thumbnail_viewer_classPrivateFieldGet(jm,this)?.closeButton?.addEventListener("click",()=>{pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleBar).call(this,"status");e.value=""})}this.scroll=watchScroll(this.scrollableContainer,pdf_thumbnail_viewer_assertClassBrand(Hm,this,_scrollUpdated).bind(this),l);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_resetView).call(this);pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_addEventListeners).call(this)}getThumbnail(e){return this._thumbnails[e]}scrollThumbnailIntoView(e){if(!this.pdfDocument)return;const t=this._thumbnails[e-1];if(!t){ngx_console_NgxConsole.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');return}if(e!==this._currentPageNumber){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_resetCurrentThumbnail).call(this,e);t.toggleCurrent(!0)}const i=pdf_thumbnail_viewer_assertClassBrand(Hm,this,_getVisibleThumbs).call(this),a=i.first,s=i.last,r=i.views;if(r.length>0){let i=!1;if(e<=a.id||e>=s.id)i=!0;else for(const t of r){const a=t.id,s=t.percent;if(a===e){i=s<100;break}}i&&t.div.scrollIntoView(Jf)}this._currentPageNumber=e}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!isValidRotation(e))throw new Error("Invalid thumbnails rotation angle.");if(!this.pdfDocument)return;if(this._pagesRotation===e)return;this._pagesRotation=e;const t={rotation:e};for(const e of this._thumbnails)e.update(t)}swapThumbnails(e,t){let i=this._thumbnails[e].pdfPage;this._thumbnails[e].setPdfPage(this._thumbnails[t].pdfPage);this._thumbnails[t].setPdfPage(i)}cleanup(){for(const e of this._thumbnails)e.renderingState!==Ff.FINISHED&&e.reset()}setDocument(e){this.initialized=!1;if(this.pdfDocument){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_cancelRendering).call(this);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_resetView).call(this)}this.pdfDocument=e;if(!e)return;pdf_thumbnail_viewer_classPrivateFieldSet(ym,this,e.pagesMapper);const t=e.getPage(1),i=e.getOptionalContentConfig({intent:"display"});t.then(t=>{const a=e.numPages,s=t.getViewport({scale:1}),r=document.createDocumentFragment();for(let e=1;e<=a;++e){const t=new PDFThumbnailView({container:r,eventBus:this.eventBus,id:e,defaultViewport:s.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,eventBus:this.eventBus,enableSplitMerge:pdf_thumbnail_viewer_classPrivateFieldGet(em,this),enablePageReordering:pdf_thumbnail_viewer_classPrivateFieldGet(tm,this)});this._thumbnails.push(t)}this._thumbnails[0]?.setPdfPage(t);this._thumbnails[this._currentPageNumber-1].toggleCurrent(!0);this.container.append(r);this.eventBus.dispatch("thumbnailsloaded",{source:this})}).catch(e=>{ngx_console_NgxConsole.error("Unable to initialize thumbnail viewer",e)})}setPageLabels(e){if(this.pdfDocument){if(e)if(Array.isArray(e)&&this.pdfDocument.numPages===e.length)this._pageLabels=e;else{this._pageLabels=null;ngx_console_NgxConsole.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")}else this._pageLabels=null;for(let e=0,t=this._thumbnails.length;e<t;e++)this._thumbnails[e].setPageLabel(this._pageLabels?.[e]??null)}}forceRendering(){const e=pdf_thumbnail_viewer_assertClassBrand(Hm,this,_getVisibleThumbs).call(this),t=pdf_thumbnail_viewer_assertClassBrand(Hm,this,_getScrollAhead).call(this,e),i=this.renderingQueue.getHighestPriority(e,this._thumbnails,t,!1,!0);if(i){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_ensurePdfPageLoaded).call(this,i).then(()=>{this.renderingQueue.renderView(i)});return!0}return!1}hasStructuralChanges(){return pdf_thumbnail_viewer_classPrivateFieldGet(ym,this)?.hasBeenAltered()||!1}getStructuralChanges(){return pdf_thumbnail_viewer_classPrivateFieldGet(ym,this)?.getPageMappingForSaving()||null}stopRendering(){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_cancelRendering).call(this)}}Kf=PDFThumbnailViewer;function _scrollUpdated(){this.renderingQueue.renderHighestPriority()}async function _mergeFiles(e,t){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleBar).call(this,"waiting","pdfjs-views-manager-waiting-for-file");const i=[];for(const a of e){const e=a.type?.startsWith("image/");if(!e&&"application/pdf"!==a.type){if("%PDF-"!==await a.slice(0,5).text())continue}if(e){let e;try{e=await _fileToImageBitmap.call(Kf,a)}catch{continue}i.push({image:e,insertAfter:t})}else i.push({document:await a.bytes(),insertAfter:t})}if(0===i.length){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleBar).call(this,"status");return}const a=pdf_thumbnail_viewer_classPrivateFieldGet(ym,this).pagesNumber,s=this.hasStructuralChanges()?this.getStructuralChanges():[{document:null}];s.push(...i);this.eventBus.on("pagesloaded",()=>{pdf_thumbnail_viewer_classPrivateFieldSet(lm,this,null);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateMenuEntries).call(this);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleBar).call(this,"status");const e=pdf_thumbnail_viewer_classPrivateFieldGet(ym,this).pagesNumber-a;for(let i=t+1,a=t+1+e;i<a;i++){this._thumbnails[i].checkbox&&(this._thumbnails[i].checkbox.checked=!0);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_selectPage).call(this,i+1,!0)}e&&pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateCurrentPage).call(this,t+2,!0)},{once:!0,...Ih});pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"merge"});this.eventBus.dispatch("saveandload",{source:this,data:s})}function _getVisibleThumbs(){return getVisibleElements({scrollEl:this.scrollableContainer,views:this._thumbnails})}function _resetCurrentThumbnail(e){if(!this.pdfDocument)return;const t=this._thumbnails[this._currentPageNumber-1];t?.toggleCurrent(!1);this._currentPageNumber=e}function _resetView(){this._thumbnails=[];this._currentPageNumber=1;this._pageLabels=null;this._pagesRotation=0;this.container.textContent=""}function _cancelRendering(){for(const e of this._thumbnails)e.cancelRendering()}async function _ensurePdfPageLoaded(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);e.pdfPage||e.setPdfPage(t);return t}catch(e){ngx_console_NgxConsole.error("Unable to get page for thumb view",e);return null}}function _getScrollAhead(e){return 1===e.first?.id||e.last?.id!==this._thumbnails.length&&this.scroll.down}function _getScaleFactor(e){return zm._||(zm._=parseFloat(getComputedStyle(e).getPropertyValue("--thumbnail-dragging-scale")))}function _fitImageDimensions(e,t,i){let a=i.minSide,s=void 0===a?0:a,r=i.maxSide;const n=Math.max(e,t);let o=1;s>0&&n<s?o=s/n:n>r&&(o=r/n);return 1===o?{width:e,height:t}:{width:Math.max(1,Math.round(e*o)),height:Math.max(1,Math.round(t*o))}}async function _fileToImageBitmap(e){const t=1024;if("image/svg+xml"!==e.type){const t=await createImageBitmap(e),i=_fitImageDimensions.call(Kf,t.width,t.height,{maxSide:4096}),a=i.width,s=i.height;if(a===t.width&&s===t.height)return t;const r=new OffscreenCanvas(a,s);r.getContext("2d").drawImage(t,0,0,a,s);t.close();return r.transferToImageBitmap()}const i=URL.createObjectURL(e);try{const e=new Image;e.src=i;await e.decode();const a=_fitImageDimensions.call(Kf,e.naturalWidth||t,e.naturalHeight||t,{minSide:t,maxSide:4096}),s=a.width,r=a.height,n=new OffscreenCanvas(s,r);n.getContext("2d").drawImage(e,0,0,s,r);return n.transferToImageBitmap()}finally{URL.revokeObjectURL(i)}}function _updateThumbnails(e){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_resetCurrentThumbnail).call(this,0);let t=0;const i=pdf_thumbnail_viewer_classPrivateFieldGet(ym,this),a=pdf_thumbnail_viewer_classPrivateFieldSet(Cm,this,this._thumbnails),s=this._thumbnails=[],r=document.createDocumentFragment(),n=pdf_thumbnail_viewer_classPrivateFieldGet(Em,this);for(let o=1,l=i.pagesNumber;o<=l;o++){const l=i.getPrevPageNumber(o);if(l<0){let e=pdf_thumbnail_viewer_classPrivateFieldGet(Sm,this).get(-l);e.checkbox&&(e.checkbox.checked=!1);if(n){e.updateId(o);r.append(e.div)}else e=e.clone(r,o);s.push(e);continue}l===e&&(t=o);const c=a[l-1];s.push(c);c.updateId(o);c.checkbox&&(c.checkbox.checked=!1);r.append(c.div)}this.container.replaceChildren(r);return t}function _onStartDragging(e){pdf_thumbnail_viewer_classPrivateFieldSet(vm,this,this.scrollableContainer.scrollTop);pdf_thumbnail_viewer_classPrivateFieldSet(mm,this,pdf_thumbnail_viewer_classPrivateFieldGet(vm,this)+this.scrollableContainer.clientHeight);pdf_thumbnail_viewer_classPrivateFieldSet(im,this,new AbortController);this.container.classList.add("isDragging");pdf_thumbnail_viewer_classPrivateFieldGet(Vm,this)?.classList.add("hidden");const t=parseInt(e.getAttribute("page-number"),10);pdf_thumbnail_viewer_classPrivateFieldSet(om,this,t-1);if(!pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)?.has(t)){pdf_thumbnail_viewer_classPrivateFieldSet(fm,this,t);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_selectPage).call(this,t,!0)}for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)){const i=this._thumbnails[e-1],a=i.placeholder=document.createElement("div");a.classList.add("thumbnailImageContainer","placeholder");const s=i.div,r=i.imageContainer;s.classList.add("isDragging");a.style.height=getComputedStyle(r).height;r.after(a);if(e!==t){r.classList.add("hidden");continue}if(1===pdf_thumbnail_viewer_classPrivateFieldGet(lm,this).size){r.classList.add("draggingThumbnail");pdf_thumbnail_viewer_classPrivateFieldSet(rm,this,r);continue}const n=pdf_thumbnail_viewer_classPrivateFieldSet(rm,this,document.createElement("div"));n.classList.add("draggingThumbnail","thumbnailImageContainer","multiple");n.style.height=getComputedStyle(r).height;r.replaceWith(n);r.classList.remove("thumbnailImageContainer");n.append(r);n.setAttribute("data-multiple-count",pdf_thumbnail_viewer_classPrivateFieldGet(lm,this).size)}}function _onStopDragging(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=pdf_thumbnail_viewer_classPrivateFieldGet(rm,this);pdf_thumbnail_viewer_classPrivateFieldSet(rm,this,null);const i=pdf_thumbnail_viewer_classPrivateFieldGet(om,this);pdf_thumbnail_viewer_classPrivateFieldSet(om,this,NaN);pdf_thumbnail_viewer_classPrivateFieldGet(gm,this)?.remove();pdf_thumbnail_viewer_classPrivateFieldSet(gm,this,null);pdf_thumbnail_viewer_classPrivateFieldGet(im,this).abort();pdf_thumbnail_viewer_classPrivateFieldSet(im,this,null);pdf_thumbnail_viewer_classPrivateFieldGet(Vm,this)?.classList.remove("hidden");this.container.classList.remove("isDragging");for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)){const t=this._thumbnails[e-1],i=t.div,a=t.placeholder,s=t.imageContainer;a.remove();s.classList.remove("draggingThumbnail","hidden");i.classList.remove("isDragging")}if(t.classList.contains("multiple")){const e=t.firstElementChild;t.replaceWith(e);e.classList.add("thumbnailImageContainer")}else t.style.translate="";const a=pdf_thumbnail_viewer_classPrivateFieldGet(lm,this);if(!isNaN(i)&&e&&(1!==a.size||!a.has(i+1)&&!a.has(i+2))){this._thumbnails[this._currentPageNumber-1]?.toggleCurrent(!1);this._currentPageNumber=-1;const e=i+1,t=Array.from(a).sort((e,t)=>e-t),s=pdf_thumbnail_viewer_classPrivateFieldGet(ym,this),r=isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(fm,this))?t[0]:pdf_thumbnail_viewer_classPrivateFieldGet(fm,this);s.movePages(a,t,e);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateCurrentPage).call(this,pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateThumbnails).call(this,r));pdf_thumbnail_viewer_classPrivateFieldSet(nm,this,null);a.clear();pdf_thumbnail_viewer_classPrivateFieldSet(fm,this,NaN);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateStatus).call(this,"select");pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"move"});this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:s,type:"move"})}if(!isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(fm,this))){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_selectPage).call(this,pdf_thumbnail_viewer_classPrivateFieldGet(fm,this),!1);pdf_thumbnail_viewer_classPrivateFieldSet(fm,this,NaN)}}function _clearSelection(){for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(lm,this))this._thumbnails[e-1].toggleSelected(!1);pdf_thumbnail_viewer_classPrivateFieldGet(lm,this).clear()}function _updateCurrentPage(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];setTimeout(()=>{this.forceRendering();const i=e||1;this.linkService.goToPage(i);const a=this._thumbnails[i-1];!t&&this.container.contains(document.activeElement)||a.imageContainer.focus()},0)}function _undo(){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateStatus).call(this,"select");if(pdf_thumbnail_viewer_classPrivateFieldGet(Sm,this)){pdf_thumbnail_viewer_classPrivateFieldSet(Sm,this,null);pdf_thumbnail_viewer_classPrivateFieldGet(ym,this).cancelCopy();pdf_thumbnail_viewer_assertClassBrand(Hm,this,_togglePasteMode).call(this,!1);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:pdf_thumbnail_viewer_classPrivateFieldGet(ym,this),type:"cancelCopy"})}pdf_thumbnail_viewer_classPrivateFieldSet(Em,this,!1);if(pdf_thumbnail_viewer_classPrivateFieldGet(Cm,this)){const e=this._thumbnails[this._currentPageNumber-1];e?.toggleCurrent(!1);const t=document.createDocumentFragment();for(let e=1,i=pdf_thumbnail_viewer_classPrivateFieldGet(Cm,this).length;e<=i;e++){const i=pdf_thumbnail_viewer_classPrivateFieldGet(Cm,this)[e-1];i.updateId(e);i.checkbox&&(i.checkbox.checked=!1);t.append(i.div)}this.container.replaceChildren(t);this._thumbnails=pdf_thumbnail_viewer_classPrivateFieldGet(Cm,this);pdf_thumbnail_viewer_classPrivateFieldSet(Cm,this,null);const i=e?this._thumbnails.indexOf(e):-1;this._currentPageNumber=i+1;e?.toggleCurrent(-1!==i);pdf_thumbnail_viewer_classPrivateFieldGet(ym,this).cancelDelete();this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:pdf_thumbnail_viewer_classPrivateFieldGet(ym,this),type:"cancelDelete"})}}function _dismissUndo(e){pdf_thumbnail_viewer_classPrivateFieldSet(Sm,this,null);if(pdf_thumbnail_viewer_classPrivateFieldGet(Am,this)){if(pdf_thumbnail_viewer_classPrivateFieldGet(Cm,this)){for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(Am,this))pdf_thumbnail_viewer_classPrivateFieldGet(Cm,this)[e-1].destroy();pdf_thumbnail_viewer_classPrivateFieldSet(Cm,this,null)}pdf_thumbnail_viewer_classPrivateFieldSet(Am,this,null)}pdf_thumbnail_viewer_classPrivateFieldSet(Em,this,!1);e&&pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateStatus).call(this,"select");pdf_thumbnail_viewer_assertClassBrand(Hm,this,_togglePasteMode).call(this,!1);pdf_thumbnail_viewer_classPrivateFieldGet(ym,this).cleanSavedData();this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:pdf_thumbnail_viewer_classPrivateFieldGet(ym,this),type:"cleanSavedData"})}function _canDelete(){const e=pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)?.size||0;return e>0&&e<this._thumbnails.length}function _toggleBar(e,t,i){pdf_thumbnail_viewer_classPrivateFieldGet(Mm,this).classList.toggle("hidden","status"!==e);pdf_thumbnail_viewer_classPrivateFieldGet(jm,this).container.classList.toggle("hidden","waiting"!==e);pdf_thumbnail_viewer_classPrivateFieldGet(Lm,this).classList.toggle("hidden","undo"!==e);pdf_thumbnail_viewer_classPrivateFieldSet(Um,this,"undo"===e);switch(e){case"waiting":pdf_thumbnail_viewer_classPrivateFieldGet(jm,this).label.setAttribute("data-l10n-id",t);break;case"undo":pdf_thumbnail_viewer_classPrivateFieldGet(Om,this).setAttribute("data-l10n-id",t);i&&pdf_thumbnail_viewer_classPrivateFieldGet(Om,this).setAttribute("data-l10n-args",JSON.stringify(i));break;case"status":i?pdf_thumbnail_viewer_classPrivateFieldGet(Bm,this).setAttribute("data-l10n-args",JSON.stringify(i)):pdf_thumbnail_viewer_classPrivateFieldGet(Bm,this).removeAttribute("data-l10n-args");pdf_thumbnail_viewer_classPrivateFieldGet(Vm,this)?.classList.toggle("hidden",!!i);pdf_thumbnail_viewer_classPrivateFieldGet(Dm,this).classList.toggle("hidden",!i)}}function _togglePasteMode(e){pdf_thumbnail_viewer_classPrivateFieldSet(Wm,this,e);if(e){this.container.classList.add("pasteMode");for(const e of this._thumbnails)e.addPasteButton(pdf_thumbnail_viewer_classPrivateFieldGet(km,this))}else{this.container.classList.remove("pasteMode");for(const e of this._thumbnails)e.removePasteButton()}}function pdf_thumbnail_viewer_reportTelemetry(e){this.eventBus.dispatch("reporttelemetry",{source:this,details:{type:"pageOrganization",data:e}})}function _saveExtractedPages(){pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"exportSelected"});this.eventBus.dispatch("saveextractedpages",{source:this,data:pdf_thumbnail_viewer_classPrivateFieldGet(ym,this).extractPages(pdf_thumbnail_viewer_classPrivateFieldGet(lm,this))});pdf_thumbnail_viewer_assertClassBrand(Hm,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateStatus).call(this,"select")}function _copyPages(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(!pdf_thumbnail_viewer_classPrivateFieldGet(Em,this)){pdf_thumbnail_viewer_classPrivateFieldSet(Cm,this,null);pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"copy"})}pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateStatus).call(this,pdf_thumbnail_viewer_classPrivateFieldGet(Em,this)?"cut":"copy");const t=pdf_thumbnail_viewer_classPrivateFieldSet(xm,this,Uint32Array.from(pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)).sort((e,t)=>e-t)),i=pdf_thumbnail_viewer_classPrivateFieldGet(ym,this);i.copyPages(t);pdf_thumbnail_viewer_classPrivateFieldSet(Sm,this,new Map);for(const e of t)pdf_thumbnail_viewer_classPrivateFieldGet(Sm,this).set(e,this._thumbnails[e-1]);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:i,pageNumbers:t,type:"copy"});e&&pdf_thumbnail_viewer_assertClassBrand(Hm,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_togglePasteMode).call(this,!0);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleMenuEntries).call(this,!1)}function _cutPages(){if(pdf_thumbnail_viewer_assertClassBrand(Hm,this,_canDelete).call(this)){pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"cut"});pdf_thumbnail_viewer_classPrivateFieldSet(Em,this,!0);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_copyPages).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_deletePages).call(this,"cut")}}function _pastePages(e){pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"paste"});const t=pdf_thumbnail_viewer_classPrivateFieldGet(ym,this),i=pdf_thumbnail_viewer_classPrivateFieldGet(xm,this).includes(this._currentPageNumber)?0:this._currentPageNumber;t.pastePages(e);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateThumbnails).call(this,i);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateCurrentPage).call(this,e+1,!0);pdf_thumbnail_viewer_classPrivateFieldSet(nm,this,null);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:t,hasBeenCut:pdf_thumbnail_viewer_classPrivateFieldGet(Em,this),type:"paste"});pdf_thumbnail_viewer_classPrivateFieldSet(Sm,this,null);pdf_thumbnail_viewer_classPrivateFieldSet(Em,this,!1);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_togglePasteMode).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateStatus).call(this,"select")}function _deletePages(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"delete";if(!pdf_thumbnail_viewer_assertClassBrand(Hm,this,_canDelete).call(this))return;const t=pdf_thumbnail_viewer_classPrivateFieldGet(lm,this);if("delete"===e){pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"delete"});pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateStatus).call(this,"delete")}const i=pdf_thumbnail_viewer_classPrivateFieldGet(ym,this),a=t.has(this._currentPageNumber)?0:this._currentPageNumber,s=pdf_thumbnail_viewer_classPrivateFieldSet(Am,this,Uint32Array.from(t).sort((e,t)=>e-t));i.deletePages(s);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateCurrentPage).call(this,pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateThumbnails).call(this,a));pdf_thumbnail_viewer_classPrivateFieldSet(nm,this,null);t.clear();pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateMenuEntries).call(this);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:i,pageNumbers:s,type:e})}function _updateMenuEntries(){if(!pdf_thumbnail_viewer_classPrivateFieldGet(Pm,this))return;const e=pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)?.size||0;pdf_thumbnail_viewer_classPrivateFieldGet(Pm,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(bm,this).disabled=!e;pdf_thumbnail_viewer_classPrivateFieldGet(wm,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(Fm,this).disabled=!pdf_thumbnail_viewer_assertClassBrand(Hm,this,_canDelete).call(this)}function _toggleMenuEntries(e){pdf_thumbnail_viewer_classPrivateFieldGet(Pm,this)&&(pdf_thumbnail_viewer_classPrivateFieldGet(Pm,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(wm,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(bm,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(Fm,this).disabled=!e)}function _updateStatus(e){if(!pdf_thumbnail_viewer_classPrivateFieldGet(Mm,this)||!pdf_thumbnail_viewer_classPrivateFieldGet(Lm,this))return;const t=pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)?.size||0;if("select"===e){pdf_thumbnail_viewer_classPrivateFieldGet(Bm,this).setAttribute("data-l10n-id",t?"pdfjs-views-manager-pages-status-action-label":"pdfjs-views-manager-pages-status-none-action-label");pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleBar).call(this,"status","",t?{count:t}:null);return}let i;switch(e){case"copy":i="pdfjs-views-manager-pages-status-undo-copy-label";break;case"cut":i="pdfjs-views-manager-status-undo-cut-label";break;case"delete":i="pdfjs-views-manager-pages-status-undo-delete-label"}pdf_thumbnail_viewer_assertClassBrand(Hm,this,_toggleBar).call(this,"undo",i,{count:t});if("copy"===e){pdf_thumbnail_viewer_classPrivateFieldGet(Rm,this).firstElementChild.setAttribute("data-l10n-id","pdfjs-views-manager-status-done-button-label");pdf_thumbnail_viewer_classPrivateFieldGet(Nm,this).classList.toggle("hidden",!0)}else{pdf_thumbnail_viewer_classPrivateFieldGet(Rm,this).firstElementChild.setAttribute("data-l10n-id","pdfjs-views-manager-status-undo-button-label");pdf_thumbnail_viewer_classPrivateFieldGet(Nm,this).classList.toggle("hidden",!1)}}function _moveDraggedContainer(e,t){pdf_thumbnail_viewer_classPrivateFieldGet(Tm,this)&&(e=0);(pdf_thumbnail_viewer_classPrivateFieldGet(cm,this)+e<0||pdf_thumbnail_viewer_classPrivateFieldGet(cm,this)+pdf_thumbnail_viewer_classPrivateFieldGet(hm,this)+e>pdf_thumbnail_viewer_classPrivateFieldGet(Im,this))&&(e=0);(pdf_thumbnail_viewer_classPrivateFieldGet(dm,this)+t<0||pdf_thumbnail_viewer_classPrivateFieldGet(dm,this)+pdf_thumbnail_viewer_classPrivateFieldGet(um,this)+t>pdf_thumbnail_viewer_classPrivateFieldGet(Gm,this))&&(t=0);pdf_thumbnail_viewer_classPrivateFieldSet(cm,this,pdf_thumbnail_viewer_classPrivateFieldGet(cm,this)+e);pdf_thumbnail_viewer_classPrivateFieldSet(dm,this,pdf_thumbnail_viewer_classPrivateFieldGet(dm,this)+t);pdf_thumbnail_viewer_classPrivateFieldSet(_m,this,pdf_thumbnail_viewer_classPrivateFieldGet(_m,this)+e);pdf_thumbnail_viewer_classPrivateFieldSet(pm,this,pdf_thumbnail_viewer_classPrivateFieldGet(pm,this)+t);pdf_thumbnail_viewer_classPrivateFieldGet(rm,this).style.translate=`${pdf_thumbnail_viewer_classPrivateFieldGet(_m,this)}px ${pdf_thumbnail_viewer_classPrivateFieldGet(pm,this)}px`;pdf_thumbnail_viewer_classPrivateFieldGet(dm,this)+pdf_thumbnail_viewer_classPrivateFieldGet(um,this)>pdf_thumbnail_viewer_classPrivateFieldGet(mm,this)?this.scrollableContainer.scrollTop=Math.min(this.scrollableContainer.scrollTop+20,pdf_thumbnail_viewer_classPrivateFieldGet(Gm,this)):pdf_thumbnail_viewer_classPrivateFieldGet(dm,this)<pdf_thumbnail_viewer_classPrivateFieldGet(vm,this)&&(this.scrollableContainer.scrollTop=Math.max(this.scrollableContainer.scrollTop-20,0));const i=pdf_thumbnail_viewer_assertClassBrand(Hm,this,_findClosestThumbnail).call(this,pdf_thumbnail_viewer_classPrivateFieldGet(cm,this)+pdf_thumbnail_viewer_classPrivateFieldGet(hm,this)/2,pdf_thumbnail_viewer_classPrivateFieldGet(dm,this)+pdf_thumbnail_viewer_classPrivateFieldGet(um,this)/2);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_positionDragMarker).call(this,i)}function _positionDragMarker(e){if(!e)return;let t=pdf_thumbnail_viewer_classPrivateFieldGet(gm,this);if(!t){t=pdf_thumbnail_viewer_classPrivateFieldSet(gm,this,document.createElement("div"));t.className="dragMarker";this.container.firstChild.before(t)}const i=pdf_thumbnail_viewer_slicedToArray(e,2),a=i[0],s=i[1],r=t.style,n=pdf_thumbnail_viewer_classPrivateFieldGet(nm,this),o=n.bbox,l=n.x;let c,d,h,u;if(a<0)if(1===l.length){d=o[1]-15;c=o[0];h=o[2]}else{d=o[1];c=o[0]-15;u=o[3]}else if(1===l.length){d=o[4*a+1]+o[4*a+3]+s;c=o[4*a];h=o[4*a+2]}else{d=o[4*a+1];c=o[4*a]+o[4*a+2]+s;u=o[4*a+3]}r.translate=`${c}px ${d}px`;r.width=h?`${h}px`:"";r.height=u?`${u}px`:""}function _computeThumbnailsPosition(){const e=[],t=[],i=[],a=new Float32Array(4*this._thumbnails.length);let s,r,n,o,l=-1/0,c=-1/0,d=-1;for(let o=0,h=this._thumbnails.length;o<h;o++){const u=this._thumbnails[o].div,_=u.offsetTop,p=u.offsetLeft,g=u.offsetWidth,f=u.offsetHeight;if(0===g)return;a[4*o]=p;a[4*o+1]=_;a[4*o+2]=g;a[4*o+3]=f;if(p>l){l=p+g/2;s??=l+g;e.push(l)}if(_>c){-1===d&&e.length>1&&(d=h%e.length);c=_+f/2;n??=c+f;t.push(c)}if(d>0&&o>=h-d){const e=p+g/2;i.push(e);r??=e+g}}o=e.length>1?(e[1]-s)/2:t.length>1?(t[1]-n)/2:15;pdf_thumbnail_viewer_classPrivateFieldSet(nm,this,{x:e,y:t,lastX:i,space:o,lastSpace:i.length?(i.at(-1)-r)/2:o,bbox:a});pdf_thumbnail_viewer_classPrivateFieldSet(Tm,this,1===e.length);var h=this.scrollableContainer;pdf_thumbnail_viewer_toSetter(pdf_thumbnail_viewer_classPrivateFieldSet,[Im,this])._=h.clientWidth;pdf_thumbnail_viewer_toSetter(pdf_thumbnail_viewer_classPrivateFieldSet,[Gm,this])._=h.scrollHeight}function pdf_thumbnail_viewer_addEventListeners(){this.eventBus.on("resize",e=>{e.source.thumbnailsView===this.container&&pdf_thumbnail_viewer_assertClassBrand(Hm,this,_computeThumbnailsPosition).call(this)});this.container.addEventListener("keydown",e=>{const t=e.target,i=t instanceof HTMLInputElement&&"checkbox"===t.type;switch(e.key){case"ArrowLeft":pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!1,!0,i);stopEvent(e);break;case"ArrowRight":pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!0,!0,i);stopEvent(e);break;case"ArrowDown":pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!0,!1,i);stopEvent(e);break;case"ArrowUp":pdf_thumbnail_viewer_assertClassBrand(Hm,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!1,!1,i);stopEvent(e);break;case"Home":pdf_thumbnail_viewer_assertClassBrand(Hm,this,_focusThumbnailElement).call(this,this._thumbnails[0],i);stopEvent(e);break;case"End":pdf_thumbnail_viewer_assertClassBrand(Hm,this,_focusThumbnailElement).call(this,this._thumbnails.at(-1),i);stopEvent(e);break;case"Enter":case" ":i||pdf_thumbnail_viewer_assertClassBrand(Hm,this,_goToPage).call(this,e);break;case"c":if(pdf_thumbnail_viewer_classPrivateFieldGet(em,this)&&(e.ctrlKey||e.metaKey)&&pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)?.size){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_copyPages).call(this);stopEvent(e)}break;case"x":if(pdf_thumbnail_viewer_classPrivateFieldGet(em,this)&&(e.ctrlKey||e.metaKey)&&pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)?.size){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_cutPages).call(this);stopEvent(e)}break;case"Delete":case"Backspace":if(pdf_thumbnail_viewer_classPrivateFieldGet(em,this)&&!pdf_thumbnail_viewer_classPrivateFieldGet(Wm,this)&&pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)?.size){pdf_thumbnail_viewer_assertClassBrand(Hm,this,_deletePages).call(this);stopEvent(e)}}});this.container.addEventListener("click",e=>{const t=e.target;if(t instanceof HTMLInputElement){const e=parseInt(t.parentElement.getAttribute("page-number"),10);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_selectPage).call(this,e,t.checked);return}pdf_thumbnail_viewer_assertClassBrand(Hm,this,_goToPage).call(this,e)});pdf_thumbnail_viewer_assertClassBrand(Hm,this,_addDragListeners).call(this);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_addExternalFileDropListeners).call(this)}function _selectPage(e,t){pdf_thumbnail_viewer_classPrivateFieldGet(Um,this)&&pdf_thumbnail_viewer_assertClassBrand(Hm,this,_dismissUndo).call(this,!1);const i=pdf_thumbnail_viewer_classPrivateFieldGet(lm,this)??pdf_thumbnail_viewer_classPrivateFieldSet(lm,this,new Set);t?i.add(e):i.delete(e);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateMenuEntries).call(this);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_updateStatus).call(this,"select")}function _addDragListeners(){var e=this;(pdf_thumbnail_viewer_classPrivateFieldGet(em,this)||pdf_thumbnail_viewer_classPrivateFieldGet(tm,this))&&this.container.addEventListener("pointerdown",t=>{const i=t.target,a=t.clientX,s=t.clientY,r=t.pointerId;if(0!==t.button||pdf_thumbnail_viewer_classPrivateFieldGet(Wm,this)||1===this._thumbnails.length||!isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(om,this))||!i.classList.contains("thumbnailImageContainer"))return;const n=i.parentElement,o=new AbortController,l=o.signal;let c=a,d=s,h=this.scrollableContainer.scrollTop;const u=_getScaleFactor.call(Kf,i);pdf_thumbnail_viewer_classPrivateFieldSet(pm,this,((u-1)*t.layerY+i.offsetTop)/u);pdf_thumbnail_viewer_classPrivateFieldGet(Tm,this)?pdf_thumbnail_viewer_classPrivateFieldSet(_m,this,i.offsetLeft+.5*(u-1)*i.offsetWidth/u):pdf_thumbnail_viewer_classPrivateFieldSet(_m,this,((u-1)*t.layerX+i.offsetLeft)/u);pdf_thumbnail_viewer_classPrivateFieldSet(cm,this,n.offsetLeft+pdf_thumbnail_viewer_classPrivateFieldGet(_m,this));pdf_thumbnail_viewer_classPrivateFieldSet(dm,this,n.offsetTop+pdf_thumbnail_viewer_classPrivateFieldGet(pm,this));pdf_thumbnail_viewer_classPrivateFieldSet(hm,this,i.offsetWidth/u);pdf_thumbnail_viewer_classPrivateFieldSet(um,this,i.offsetHeight/u);this.container.addEventListener("pointermove",t=>{const i=t.clientX,l=t.clientY,u=t.pointerId;if(isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(om,this))){if(u!==r||Math.abs(i-a)<=5&&Math.abs(l-s)<=5)return;pdf_thumbnail_viewer_assertClassBrand(Hm,this,_onStartDragging).call(this,n);const stopDragging=function(t){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];pdf_thumbnail_viewer_assertClassBrand(Hm,e,_onStopDragging).call(e,i);o.abort()},t=pdf_thumbnail_viewer_classPrivateFieldGet(im,this).signal;window.addEventListener("touchmove",stopEvent,{passive:!1,signal:t});window.addEventListener("contextmenu",noContextMenu,{signal:t});this.scrollableContainer.addEventListener("scrollend",()=>{const e=this.scrollableContainer,t=e.clientHeight,i=e.scrollTop;pdf_thumbnail_viewer_classPrivateFieldSet(vm,this,i);pdf_thumbnail_viewer_classPrivateFieldSet(mm,this,i+t);const a=i-h;h=i;pdf_thumbnail_viewer_assertClassBrand(Hm,this,_moveDraggedContainer).call(this,0,a)},{passive:!0,signal:t});window.addEventListener("pointerup",e=>{if(e.pointerId===r){window.addEventListener("click",stopEvent,{capture:!0,once:!0,signal:t});stopEvent(e);stopDragging(e,!0)}},{signal:t});window.addEventListener("blur",stopDragging,{signal:t});window.addEventListener("pointercancel",stopDragging,{signal:t});window.addEventListener("wheel",stopEvent,{passive:!1,signal:t});window.addEventListener("keydown",e=>{"Escape"!==e.key||isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(om,this))||stopDragging(e)},{signal:t})}const _=i-c,p=l-d;c=i;d=l;pdf_thumbnail_viewer_assertClassBrand(Hm,this,_moveDraggedContainer).call(this,_,p)},{passive:!0,signal:l});window.addEventListener("pointerup",e=>{e.pointerId===r&&o.abort()},{signal:l});window.addEventListener("dragstart",stopEvent,{capture:!0,signal:l})})}function _addExternalFileDropListeners(){if(!pdf_thumbnail_viewer_classPrivateFieldGet(Qf,this))return;const e=this.container,t=pdf_thumbnail_viewer_classPrivateFieldGet(am,this);e.addEventListener("dragenter",e=>{if(!pdf_thumbnail_viewer_classPrivateFieldGet(sm,this)&&isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(om,this))&&this._thumbnails.length&&(e=>{if(!e)return!1;for(const t of e.items)if("file"===t.kind&&("application/pdf"===t.type||t.type.startsWith("image/")))return!0;return!1})(e.dataTransfer)){e.preventDefault();e.stopPropagation();e.dataTransfer.dropEffect="copy";pdf_thumbnail_viewer_classPrivateFieldSet(sm,this,!0);this.container.classList.add("isDraggingFile");pdf_thumbnail_viewer_classPrivateFieldSet(nm,this,null);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_computeThumbnailsPosition).call(this);pdf_thumbnail_viewer_classPrivateFieldSet(om,this,NaN)}},{signal:t});e.addEventListener("dragover",t=>{if(!pdf_thumbnail_viewer_classPrivateFieldGet(sm,this))return;t.preventDefault();t.stopPropagation();t.dataTransfer.dropEffect="copy";if(!pdf_thumbnail_viewer_classPrivateFieldGet(nm,this))return;const i=e.getBoundingClientRect(),a=t.clientX-i.left,s=t.clientY-i.top,r=pdf_thumbnail_viewer_assertClassBrand(Hm,this,_findClosestThumbnail).call(this,a,s);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_positionDragMarker).call(this,r)},{signal:t});e.addEventListener("dragleave",t=>{pdf_thumbnail_viewer_classPrivateFieldGet(sm,this)&&(t.relatedTarget&&e.contains(t.relatedTarget)||(t=>{let i=t.clientX,a=t.clientY;const s=e.getBoundingClientRect(),r=s.left,n=s.right,o=s.top,l=s.bottom;return i>=r&&i<n&&a>=o&&a<l})(t)||pdf_thumbnail_viewer_assertClassBrand(Hm,this,_endExternalFileDrag).call(this))},{signal:t});e.addEventListener("drop",t=>{if(!pdf_thumbnail_viewer_classPrivateFieldGet(sm,this))return;t.preventDefault();t.stopPropagation();const i=Array.from(t.dataTransfer.files??[]);if(isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(om,this))&&pdf_thumbnail_viewer_classPrivateFieldGet(nm,this)){const i=e.getBoundingClientRect();pdf_thumbnail_viewer_assertClassBrand(Hm,this,_findClosestThumbnail).call(this,t.clientX-i.left,t.clientY-i.top)}const a=isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(om,this))?-1:pdf_thumbnail_viewer_classPrivateFieldGet(om,this);pdf_thumbnail_viewer_assertClassBrand(Hm,this,_endExternalFileDrag).call(this);i.length&&pdf_thumbnail_viewer_assertClassBrand(Hm,this,_mergeFiles).call(this,i,a)},{signal:t})}function _endExternalFileDrag(){pdf_thumbnail_viewer_classPrivateFieldSet(sm,this,!1);this.container.classList.remove("isDraggingFile");pdf_thumbnail_viewer_classPrivateFieldGet(gm,this)?.remove();pdf_thumbnail_viewer_classPrivateFieldSet(gm,this,null);pdf_thumbnail_viewer_classPrivateFieldSet(om,this,NaN)}function _goToPage(e){const t=e.target.closest(".thumbnailImageContainer");if(t){const i=parseInt(t.getAttribute("page-number"),10);this.linkService.goToPage(i);stopEvent(e)}}function _focusThumbnailElement(e,t){t&&e.checkbox?e.checkbox.focus():e.imageContainer.focus()}function pdf_thumbnail_viewer_goToNextItem(e,t,i){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=parseInt(e.parentElement.getAttribute("page-number"),10);isNaN(s)&&(s=this._currentPageNumber);const r=t?1:-1;let n;if(i){const e=MathClamp(s+r,1,this._thumbnails.length+1);n=this._thumbnails[e-1]}else{const e=this._thumbnails[s-1].div.getBoundingClientRect(),t=e.x,i=e.y;let a;for(let e=s-1+r;e>=0&&e<this._thumbnails.length;e+=r){const s=this._thumbnails[e],r=s.div.getBoundingClientRect(),o=r.x,l=r.y;a||l===i||(a=s);if(o===t){n=s;break}}n||(n=a)}n&&pdf_thumbnail_viewer_assertClassBrand(Hm,this,_focusThumbnailElement).call(this,n,a)}function _findClosestThumbnail(e,t){pdf_thumbnail_viewer_classPrivateFieldGet(nm,this)||pdf_thumbnail_viewer_assertClassBrand(Hm,this,_computeThumbnailsPosition).call(this);const i=pdf_thumbnail_viewer_classPrivateFieldGet(nm,this),a=i.x,s=i.y,r=i.lastX,n=i.space,o=i.lastSpace,l=pdf_thumbnail_viewer_classPrivateFieldGet(om,this);let c,d=l%a.length,h=Math.floor(l/a.length),u=h===s.length-1?r:a;if(s[h]<=t&&t<(s[h+1]??1/0)&&u[d]<=e&&e<(u[d+1]??1/0))return null;h=binarySearchFirstItem(s,e=>t<e);if(pdf_thumbnail_viewer_classPrivateFieldGet(Tm,this))c=h-1;else{if(h===s.length)h=s.length-1;else{h=Math.abs(s[h-1]-t)<Math.abs(s[h]-t)?h-1:h}u=h===s.length-1&&r.length>0?r:a;d=binarySearchFirstItem(u,t=>e<t)-1;if(h<0){d<=0&&(d=-1);h=0}c=MathClamp(h*a.length+d,-1,this._thumbnails.length-1)}if(c===l)return null;pdf_thumbnail_viewer_classPrivateFieldSet(om,this,c);return[c,h===s.length-1&&r.length>0&&d>=0?o:n]}var zm={_:0};class Page{constructor(e,t){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0};this.createdDensity=t;this.nowDrawingDensity=this.createdDensity;this.render=e}setDensity(e){this.createdDensity=e;this.nowDrawingDensity=e}setDrawingDensity(e){this.nowDrawingDensity=e}setPosition(e){this.state.position=e}setAngle(e){this.state.angle=e}setArea(e){this.state.area=e}setHardDrawingAngle(e){this.state.hardDrawingAngle=e}setHardAngle(e){this.state.hardAngle=e;this.state.hardDrawingAngle=e}setOrientation(e){this.orientation=e}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class PageCollection{constructor(e,t){this.pages=[];this.currentPageIndex=0;this.currentSpreadIndex=0;this.landscapeSpread=[];this.portraitSpread=[];this.render=t;this.app=e;this.currentPageIndex=0;this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[];this.portraitSpread=[];for(let e=0;e<this.pages.length;e++)this.portraitSpread.push([e]);let e=0;if(this.isShowCover){this.pages[0].setDensity("hard");this.landscapeSpread.push([e]);e++}for(let t=e;t<this.pages.length;t+=2)if(t<this.pages.length-1)this.landscapeSpread.push([t,t+1]);else{this.landscapeSpread.push([t]);this.pages[t].setDensity("hard")}}getSpread(){return"landscape"===this.render.getOrientation()?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(e){const t=this.getSpread();for(let i=0;i<t.length;i++)if(e===t[i][0]||e===t[i][1])return i;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(e){if(e>=0&&e<this.pages.length)return this.pages[e];throw new Error("Invalid page number")}nextBy(e){const t=this.pages.indexOf(e);return t<this.pages.length-1?this.pages[t+1]:null}prevBy(e){const t=this.pages.indexOf(e);return t>0?this.pages[t-1]:null}getFlippingPage(e){const t=this.currentSpreadIndex;if("portrait"===this.render.getOrientation())return 0===e?this.pages[t].newTemporaryCopy():this.pages[t-1];{const i=0===e?this.getSpread()[t+1]:this.getSpread()[t-1];return 1===i.length||0===e?this.pages[i[0]]:this.pages[i[1]]}}getBottomPage(e){const t=this.currentSpreadIndex;if("portrait"===this.render.getOrientation())return 0===e?this.pages[t+1]:this.pages[t-1];{const i=0===e?this.getSpread()[t+1]:this.getSpread()[t-1];return 1===i.length?this.pages[i[0]]:0===e?this.pages[i[1]]:this.pages[i[0]]}}showNext(){if(this.currentSpreadIndex<this.getSpread().length){this.currentSpreadIndex++;this.showSpread()}}showPrev(){if(this.currentSpreadIndex>0){this.currentSpreadIndex--;this.showSpread()}}getCurrentPageIndex(){return this.currentPageIndex}show(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;null===e&&(e=this.currentPageIndex);if(e<0||e>=this.pages.length)return;const t=this.getSpreadIndexByPage(e);if(null!==t){this.currentSpreadIndex=t;this.showSpread()}}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(e){if(!(e>=0&&e<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=e}showSpread(){const e=this.getSpread()[this.currentSpreadIndex];if(2===e.length){this.render.setLeftPage(this.pages[e[0]]);this.render.setRightPage(this.pages[e[1]])}else if("landscape"===this.render.getOrientation())if(e[0]===this.pages.length-1){this.render.setLeftPage(this.pages[e[0]]);this.render.setRightPage(null)}else{this.render.setLeftPage(null);this.render.setRightPage(this.pages[e[0]])}else{this.render.setLeftPage(null);this.render.setRightPage(this.pages[e[0]])}this.currentPageIndex=e[0];this.app.updatePageIndex(this.currentPageIndex)}}class Helper{static GetDistanceBetweenTwoPoint(e,t){return null===e||null===t?1/0:Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static GetSegmentLength(e){return Helper.GetDistanceBetweenTwoPoint(e[0],e[1])}static GetAngleBetweenTwoLine(e,t){const i=e[0].y-e[1].y,a=t[0].y-t[1].y,s=e[1].x-e[0].x,r=t[1].x-t[0].x;return Math.acos((i*a+s*r)/(Math.sqrt(i*i+s*s)*Math.sqrt(a*a+r*r)))}static PointInRect(e,t){return null===t?null:t.x>=e.left&&t.x<=e.width+e.left&&t.y>=e.top&&t.y<=e.top+e.height?t:null}static GetRotatedPoint(e,t,i){return{x:e.x*Math.cos(i)+e.y*Math.sin(i)+t.x,y:e.y*Math.cos(i)-e.x*Math.sin(i)+t.y}}static LimitPointToCircle(e,t,i){if(Helper.GetDistanceBetweenTwoPoint(e,i)<=t)return i;const a=e.x,s=e.y,r=i.x,n=i.y;let o=Math.sqrt(Math.pow(t,2)*Math.pow(a-r,2)/(Math.pow(a-r,2)+Math.pow(s-n,2)))+a;i.x<0&&(o*=-1);let l=(o-a)*(s-n)/(a-r)+s;a-r+s===0&&(l=t);return{x:o,y:l}}static GetIntersectBetweenTwoSegment(e,t,i){return Helper.PointInRect(e,Helper.GetIntersectBeetwenTwoLine(t,i))}static GetIntersectBeetwenTwoLine(e,t){const i=e[0].y-e[1].y,a=t[0].y-t[1].y,s=e[1].x-e[0].x,r=t[1].x-t[0].x,n=e[0].x*e[1].y-e[1].x*e[0].y,o=t[0].x*t[1].y-t[1].x*t[0].y,l=i*o-a*n,c=s*o-r*n,d=-(n*r-o*s)/(i*r-a*s),h=-(i*o-a*n)/(i*r-a*s);if(isFinite(d)&&isFinite(h))return{x:d,y:h};if(Math.abs(l-c)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(e,t){const i=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y),s=Math.max(i,a),r=[e];function getCord(e,t,i,a,s){return t>e?e+s*(i/a):t<e?e-s*(i/a):e}for(let n=1;n<=s;n+=1)r.push({x:getCord(e.x,t.x,i,s,n),y:getCord(e.y,t.y,a,s,n)});return r}}class HTMLPage extends Page{constructor(e,t,i){super(e,i);this.copiedElement=null;this.temporaryCopy=null;this.isLoad=!1;this.element=t;this.element.classList.add("stf__item");this.element.classList.add("--"+i)}newTemporaryCopy(){if("hard"===this.nowDrawingDensity)return this;if(null===this.temporaryCopy){this.copiedElement=this.element.cloneNode(!0);this.element.parentElement.appendChild(this.copiedElement);this.temporaryCopy=new HTMLPage(this.render,this.copiedElement,this.nowDrawingDensity)}return this.getTemporaryCopy()}getTemporaryCopy(){return this.temporaryCopy}hideTemporaryCopy(){if(null!==this.temporaryCopy){this.copiedElement.remove();this.copiedElement=null;this.temporaryCopy=null}}draw(e){const t=e||this.nowDrawingDensity,i=this.render.convertToGlobal(this.state.position),a=this.render.getRect().pageWidth,s=this.render.getRect().height;this.element.classList.remove("--simple");const r=`\n position: absolute;\n display: block;\n z-index: ${this.element.style.zIndex};\n left: 0;\n top: 0;\n width: ${a}px;\n height: ${s}px;\n `;"hard"===t?this.drawHard(r):this.drawSoft(i,r)}drawHard(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const t=this.render.getRect().left+this.render.getRect().width/2,i=this.state.hardDrawingAngle,a=e+"\n backface-visibility: hidden;\n -webkit-backface-visibility: hidden;\n clip-path: none;\n -webkit-clip-path: none;\n "+(0===this.orientation?`transform-origin: ${this.render.getRect().pageWidth}px 0;\n transform: translate3d(0, 0, 0) rotateY(${i}deg);`:`transform-origin: 0 0;\n transform: translate3d(${t}px, 0, 0) rotateY(${i}deg);`);this.element.style.cssText=a}drawSoft(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i="polygon( ";for(const e of this.state.area)if(null!==e){let t=1===this.render.getDirection()?{x:-e.x+this.state.position.x,y:e.y-this.state.position.y}:{x:e.x-this.state.position.x,y:e.y-this.state.position.y};t=Helper.GetRotatedPoint(t,{x:0,y:0},this.state.angle);i+=t.x+"px "+t.y+"px, "}i=i.slice(0,-2);i+=")";const a=t+`transform-origin: 0 0; clip-path: ${i}; -webkit-clip-path: ${i};`+(this.render.isSafari()&&0===this.state.angle?`transform: translate(${e.x}px, ${e.y}px);`:`transform: translate3d(${e.x}px, ${e.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=a}simpleDraw(e){const t=this.render.getRect(),i=t.pageWidth,a=t.height,s=1===e?t.left+t.pageWidth:t.left,r=t.top;this.element.classList.add("--simple");this.element.style.cssText=`\n position: absolute;\n display: block;\n height: ${a}px;\n left: ${s}px;\n top: ${r}px;\n width: ${i}px;\n z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(e){super.setOrientation(e);this.element.classList.remove("--left","--right");this.element.classList.add(1===e?"--right":"--left")}setDrawingDensity(e){this.element.classList.remove("--soft","--hard");this.element.classList.add("--"+e);super.setDrawingDensity(e)}}class HTMLPageCollection extends PageCollection{constructor(e,t,i,a){super(e,t);this.element=i;this.pagesElement=a}load(){for(const e of this.pagesElement){const t=new HTMLPage(this.render,e,"hard"===e.dataset.density?"hard":"soft");t.load();this.pages.push(t)}this.createSpread()}}class FlipCalculation{constructor(e,t,i,a){this.direction=e;this.corner=t;this.topIntersectPoint=null;this.sideIntersectPoint=null;this.bottomIntersectPoint=null;this.pageWidth=parseInt(i,10);this.pageHeight=parseInt(a,10)}calc(e){try{this.position=this.calcAngleAndPosition(e);this.calculateIntersectPoint(this.position);return!0}catch(e){return!1}}getFlippingClipArea(){const e=[];let t=!1;e.push(this.rect.topLeft);e.push(this.topIntersectPoint);if(null===this.sideIntersectPoint)t=!0;else{e.push(this.sideIntersectPoint);null===this.bottomIntersectPoint&&(t=!1)}e.push(this.bottomIntersectPoint);(t||"bottom"===this.corner)&&e.push(this.rect.bottomLeft);return e}getBottomClipArea(){const e=[];e.push(this.topIntersectPoint);if("top"===this.corner)e.push({x:this.pageWidth,y:0});else{null!==this.topIntersectPoint&&e.push({x:this.pageWidth,y:0});e.push({x:this.pageWidth,y:this.pageHeight})}null!==this.sideIntersectPoint?Helper.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&e.push(this.sideIntersectPoint):"top"===this.corner&&e.push({x:this.pageWidth,y:this.pageHeight});e.push(this.bottomIntersectPoint);e.push(this.topIntersectPoint);return e}getAngle(){return 0===this.direction?-this.angle:this.angle}getRect(){return this.rect}getPosition(){return this.position}getActiveCorner(){return 0===this.direction?this.rect.topLeft:this.rect.topRight}getDirection(){return this.direction}getFlippingProgress(){return Math.abs((this.position.x-this.pageWidth)/(2*this.pageWidth)*100)}getCorner(){return this.corner}getBottomPagePosition(){return 1===this.direction?{x:this.pageWidth,y:0}:{x:0,y:0}}getShadowStartPoint(){return"top"===this.corner?this.topIntersectPoint:null!==this.sideIntersectPoint?this.sideIntersectPoint:this.topIntersectPoint}getShadowAngle(){const e=Helper.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return 0===this.direction?e:Math.PI-e}calcAngleAndPosition(e){let t=e;this.updateAngleAndGeometry(t);t="top"===this.corner?this.checkPositionAtCenterLine(t,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(t,{x:0,y:this.pageHeight},{x:0,y:0});if(Math.abs(t.x-this.pageWidth)<1&&Math.abs(t.y)<1)throw new Error("Point is too small");return t}updateAngleAndGeometry(e){this.angle=this.calculateAngle(e);this.rect=this.getPageRect(e)}calculateAngle(e){const t=this.pageWidth-e.x+1,i="bottom"===this.corner?this.pageHeight-e.y:e.y;let a=2*Math.acos(t/Math.sqrt(i*i+t*t));i<0&&(a=-a);const s=Math.PI-a;if(!isFinite(a)||s>=0&&s<.003)throw new Error("The G point is too small");"bottom"===this.corner&&(a=-a);return a}getPageRect(e){return"top"===this.corner?this.getRectFromBasePoint([{x:0,y:0},{x:this.pageWidth,y:0},{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}],e):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],e)}getRectFromBasePoint(e,t){return{topLeft:this.getRotatedPoint(e[0],t),topRight:this.getRotatedPoint(e[1],t),bottomLeft:this.getRotatedPoint(e[2],t),bottomRight:this.getRotatedPoint(e[3],t)}}getRotatedPoint(e,t){return{x:e.x*Math.cos(this.angle)+e.y*Math.sin(this.angle)+t.x,y:e.y*Math.cos(this.angle)-e.x*Math.sin(this.angle)+t.y}}calculateIntersectPoint(e){const t={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};if("top"===this.corner){this.topIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[e,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]);this.sideIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[e,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]);this.bottomIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])}else{this.topIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]);this.sideIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[e,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]);this.bottomIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])}}checkPositionAtCenterLine(e,t,i){let a=e;const s=Helper.LimitPointToCircle(t,this.pageWidth,a);if(a!==s){a=s;this.updateAngleAndGeometry(a)}const r=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let n=this.rect.bottomRight,o=this.rect.topLeft;if("bottom"===this.corner){n=this.rect.topRight;o=this.rect.bottomLeft}if(n.x<=0){const e=Helper.LimitPointToCircle(i,r,o);if(e!==a){a=e;this.updateAngleAndGeometry(a)}}return a}getSegmentToShadowLine(){const e=this.getShadowStartPoint();return[e,e!==this.sideIntersectPoint&&null!==this.sideIntersectPoint?this.sideIntersectPoint:this.bottomIntersectPoint]}}class Flip{constructor(e,t){this.flippingPage=null;this.bottomPage=null;this.calc=null;this.state="read";this.render=e;this.app=t}fold(e){this.setState("user_fold");null===this.calc&&this.start(e);this.do(this.render.convertToPage(e))}flip(e){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(e))return;null!==this.calc&&this.render.finishAnimation();if(!this.start(e))return;const t=this.getBoundsRect();this.setState("flipping");const i=t.height/10,a="bottom"===this.calc.getCorner()?t.height-i:i,s="bottom"===this.calc.getCorner()?t.height:0;this.calc.calc({x:t.pageWidth-i,y:a});this.animateFlippingTo({x:t.pageWidth-i,y:a},{x:-t.pageWidth,y:s},!0)}start(e){this.reset();const t=this.render.convertToBook(e),i=this.getBoundsRect(),a=this.getDirectionByPoint(t),s=t.y>=i.height/2?"bottom":"top";if(!this.checkDirection(a))return!1;try{this.flippingPage=this.app.getPageCollection().getFlippingPage(a);this.bottomPage=this.app.getPageCollection().getBottomPage(a);if("landscape"===this.render.getOrientation())if(1===a){const e=this.app.getPageCollection().nextBy(this.flippingPage);if(null!==e&&this.flippingPage.getDensity()!==e.getDensity()){this.flippingPage.setDrawingDensity("hard");e.setDrawingDensity("hard")}}else{const e=this.app.getPageCollection().prevBy(this.flippingPage);if(null!==e&&this.flippingPage.getDensity()!==e.getDensity()){this.flippingPage.setDrawingDensity("hard");e.setDrawingDensity("hard")}}this.render.setDirection(a);this.calc=new FlipCalculation(a,s,i.pageWidth.toString(10),i.height.toString(10));return!0}catch(e){return!1}}do(e){if(null!==this.calc&&this.calc.calc(e)){const e=this.calc.getFlippingProgress();this.bottomPage.setArea(this.calc.getBottomClipArea());this.bottomPage.setPosition(this.calc.getBottomPagePosition());this.bottomPage.setAngle(0);this.bottomPage.setHardAngle(0);this.flippingPage.setArea(this.calc.getFlippingClipArea());this.flippingPage.setPosition(this.calc.getActiveCorner());this.flippingPage.setAngle(this.calc.getAngle());0===this.calc.getDirection()?this.flippingPage.setHardAngle(90*(200-2*e)/100):this.flippingPage.setHardAngle(-90*(200-2*e)/100);this.render.setPageRect(this.calc.getRect());this.render.setBottomPage(this.bottomPage);this.render.setFlippingPage(this.flippingPage);this.render.setShadowData(this.calc.getShadowStartPoint(),this.calc.getShadowAngle(),e,this.calc.getDirection())}}flipToPage(e,t){const i=this.app.getPageCollection().getCurrentSpreadIndex(),a=this.app.getPageCollection().getSpreadIndexByPage(e);try{if(a>i){this.app.getPageCollection().setCurrentSpreadIndex(a-1);this.flipNext(t)}if(a<i){this.app.getPageCollection().setCurrentSpreadIndex(a+1);this.flipPrev(t)}}catch(e){}}flipNext(e){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:"top"===e?1:this.render.getRect().height-2})}flipPrev(e){this.flip({x:10,y:"top"===e?1:this.render.getRect().height-2})}stopMove(){if(null===this.calc)return;const e=this.calc.getPosition(),t=this.getBoundsRect(),i="bottom"===this.calc.getCorner()?t.height:0;e.x<=0?this.animateFlippingTo(e,{x:-t.pageWidth,y:i},!0):this.animateFlippingTo(e,{x:t.pageWidth,y:i},!1)}showCorner(e){if(!this.checkState("read","fold_corner"))return;const t=this.getBoundsRect(),i=t.pageWidth;if(this.isPointOnCorners(e))if(null===this.calc){if(!this.start(e))return;this.setState("fold_corner");this.calc.calc({x:i-1,y:1});const a=50,s="bottom"===this.calc.getCorner()?t.height-1:1,r="bottom"===this.calc.getCorner()?t.height-a:a;this.animateFlippingTo({x:i-1,y:s},{x:i-a,y:r},!1,!1)}else this.do(this.render.convertToPage(e));else{this.setState("read");this.render.finishAnimation();this.stopMove()}}animateFlippingTo(e,t,i){let a=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const s=Helper.GetCordsFromTwoPoint(e,t),r=[];for(const e of s)r.push(()=>this.do(e));const n=this.getAnimationDuration(s.length);this.render.startAnimation(r,n,()=>{if(this.calc){i&&(1===this.calc.getDirection()?this.app.turnToPrevPage():this.app.turnToNextPage());if(a){this.render.setBottomPage(null);this.render.setFlippingPage(null);this.render.clearShadow();this.setState("read");this.reset()}}})}getCalculation(){return this.calc}getState(){return this.state}setState(e){if(this.state!==e){this.app.updateState(e);this.state=e}}getDirectionByPoint(e){const t=this.getBoundsRect();if("portrait"===this.render.getOrientation()){if(e.x-t.pageWidth<=t.width/5)return 1}else if(e.x<t.width/2)return 1;return 0}getAnimationDuration(e){const t=this.app.getSettings().flippingTime;return e>=1e3?t:e/1e3*t}checkDirection(e){return 0===e?this.app.getCurrentPageIndex()<this.app.getPageCount()-1:this.app.getCurrentPageIndex()>=1}reset(){this.calc=null;this.flippingPage=null;this.bottomPage=null}getBoundsRect(){return this.render.getRect()}checkState(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];for(const e of t)if(this.state===e)return!0;return!1}isPointOnCorners(e){const t=this.getBoundsRect(),i=t.pageWidth,a=Math.sqrt(Math.pow(i,2)+Math.pow(t.height,2))/5,s=this.render.convertToBook(e);return s.x>0&&s.y>0&&s.x<t.width&&s.y<t.height&&(s.x<a||s.x>t.width-a)&&(s.y<a||s.y>t.height-a)}}class Render{constructor(e,t){this.leftPage=null;this.rightPage=null;this.flippingPage=null;this.bottomPage=null;this.direction=null;this.orientation=null;this.shadow=null;this.animation=null;this.pageRect=null;this.boundsRect=null;this.timer=0;this.safari=!1;this.setting=t;this.app=e;const i=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=null!==i.exec(window.navigator.userAgent)}render(e){if(null!==this.animation){const t=Math.round((e-this.animation.startedAt)/this.animation.durationFrame);if(t<this.animation.frames.length)this.animation.frames[t]();else{this.animation.onAnimateEnd();this.animation=null}}this.timer=e;this.drawFrame()}start(){this.update();const loop=e=>{this.render(e);requestAnimationFrame(loop)};requestAnimationFrame(loop)}startAnimation(e,t,i){this.finishAnimation();this.animation={frames:e,duration:t,durationFrame:t/e.length,onAnimateEnd:i,startedAt:this.timer}}finishAnimation(){if(null!==this.animation){this.animation.frames[this.animation.frames.length-1]();null!==this.animation.onAnimateEnd&&this.animation.onAnimateEnd()}this.animation=null}update(){this.boundsRect=null;const e=this.calculateBoundsRect();if(this.orientation!==e){this.orientation=e;this.app.updateOrientation(e)}}calculateBoundsRect(){let e="landscape";const t=this.getBlockWidth(),i=t/2,a=this.getBlockHeight()/2,s=this.setting.width/this.setting.height;let r=this.setting.width,n=this.setting.height,o=i-r;if("stretch"===this.setting.size){t<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(e="portrait");r="portrait"===e?this.getBlockWidth():this.getBlockWidth()/2;r>this.setting.maxWidth&&(r=this.setting.maxWidth);n=r/s;if(n>this.getBlockHeight()){n=this.getBlockHeight();r=n*s}o="portrait"===e?i-r/2-r:i-r}else if(t<2*r&&this.app.getSettings().usePortrait){e="portrait";o=i-r/2-r}this.boundsRect={left:o,top:a-n/2,width:2*r,height:n,pageWidth:r};return e}setShadowData(e,t,i,a){if(!this.app.getSettings().drawShadow)return;const s=100*this.getSettings().maxShadowOpacity;this.shadow={pos:e,angle:t,width:3*this.getRect().pageWidth/4*i/100,opacity:(100-i)*s/100/100,direction:a,progress:2*i}}clearShadow(){this.shadow=null}getBlockWidth(){return this.app.getUI().getDistElement().offsetWidth}getBlockHeight(){return this.app.getUI().getDistElement().offsetHeight}getDirection(){return this.direction}getRect(){null===this.boundsRect&&this.calculateBoundsRect();return this.boundsRect}getSettings(){return this.app.getSettings()}getOrientation(){return this.orientation}setPageRect(e){this.pageRect=e}setDirection(e){this.direction=e}setRightPage(e){null!==e&&e.setOrientation(1);this.rightPage=e}setLeftPage(e){null!==e&&e.setOrientation(0);this.leftPage=e}setBottomPage(e){null!==e&&e.setOrientation(1===this.direction?0:1);this.bottomPage=e}setFlippingPage(e){null!==e&&e.setOrientation(0===this.direction&&"portrait"!==this.orientation?0:1);this.flippingPage=e}convertToBook(e){const t=this.getRect();return{x:e.x-t.left,y:e.y-t.top}}isSafari(){return this.safari}convertToPage(e,t){t||(t=this.direction);const i=this.getRect();return{x:0===t?e.x-i.left-i.width/2:i.width/2-e.x+i.left,y:e.y-i.top}}convertToGlobal(e,t){t||(t=this.direction);if(null==e)return null;const i=this.getRect();return{x:0===t?e.x+i.left+i.width/2:i.width/2-e.x+i.left,y:e.y+i.top}}convertRectToGlobal(e,t){t||(t=this.direction);return{topLeft:this.convertToGlobal(e.topLeft,t),topRight:this.convertToGlobal(e.topRight,t),bottomLeft:this.convertToGlobal(e.bottomLeft,t),bottomRight:this.convertToGlobal(e.bottomRight,t)}}}class UI{constructor(e,t,i){this.cspPolicyService=t.cspPolicyService;this.touchPoint=null;this.swipeTimeout=250;this.onResize=()=>{this.update()};this.onMouseDown=e=>{if(this.checkTarget(e.target)){if(!this.app.getSettings().enableFlipByDrag){this._clickStartPos=this.getMousePos(e.clientX,e.clientY);this._clickStartClientX=e.clientX;this._clickStartClientY=e.clientY;return}const t=this.getMousePos(e.clientX,e.clientY);this.app.startUserTouch(t);e.preventDefault()}};this.onTouchStart=e=>{if(this.checkTarget(e.target)){if(!this.app.getSettings().enableFlipByDrag)return;if(e.changedTouches.length>0){const t=e.changedTouches[0],i=this.getMousePos(t.clientX,t.clientY);this.touchPoint={point:i,time:Date.now()};setTimeout(()=>{null!==this.touchPoint&&this.app.startUserTouch(i)},this.swipeTimeout);this.app.getSettings().mobileScrollSupport||e.preventDefault()}}};this.onMouseUp=e=>{if(this._clickStartPos){const t=e.clientX-this._clickStartClientX,i=e.clientY-this._clickStartClientY;if(t*t+i*i<25){const e=this._clickStartPos;this.app.startUserTouch(e);this.app.userStop(e)}this._clickStartPos=null;return}const t=this.getMousePos(e.clientX,e.clientY);this.app.userStop(t)};this.onMouseMove=e=>{if(!this.app.getSettings().enableFlipByDrag)return;const t=this.getMousePos(e.clientX,e.clientY);this.app.userMove(t,!1)};this.onTouchMove=e=>{if(e.changedTouches.length>0){const t=e.changedTouches[0],i=this.getMousePos(t.clientX,t.clientY);if(this.app.getSettings().mobileScrollSupport){null!==this.touchPoint&&(Math.abs(this.touchPoint.point.x-i.x)>10||"read"!==this.app.getState())&&e.cancelable&&this.app.userMove(i,!0);"read"!==this.app.getState()&&e.preventDefault()}else this.app.userMove(i,!0)}};this.onTouchEnd=e=>{if(e.changedTouches.length>0){const t=e.changedTouches[0],i=this.getMousePos(t.clientX,t.clientY);let a=!1;if(null!==this.touchPoint){const e=i.x-this.touchPoint.point.x,t=Math.abs(i.y-this.touchPoint.point.y);if(Math.abs(e)>this.swipeDistance&&t<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout){e>0?this.app.flipPrev(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"):this.app.flipNext(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom");a=!0}this.touchPoint=null}this.app.userStop(i,a)}};this.parentElement=e;e.classList.add("stf__parent");const a=this.cspPolicyService.createTrustedHTML('<div class="stf__wrapper"></div>');e.insertAdjacentHTML("afterbegin",a);this.wrapper=e.querySelector(".stf__wrapper");this.app=t;const s=this.app.getSettings().usePortrait?1:2;e.style.minWidth=i.minWidth*s+"px";e.style.minHeight=i.minHeight+"px";if("fixed"===i.size){e.style.minWidth=i.width*s+"px";e.style.minHeight=i.height+"px"}if(i.autoSize){e.style.width="100%";e.style.maxWidth=2*i.maxWidth+"px"}e.style.display="block";window.addEventListener("resize",this.onResize,!1);this.swipeDistance=i.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers();this.distElement.remove();this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(e){this.wrapper.classList.remove("--portrait","--landscape");if("portrait"===e){this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/this.app.getSettings().width*100+"%");this.wrapper.classList.add("--portrait")}else{this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/(2*this.app.getSettings().width)*100+"%");this.wrapper.classList.add("--landscape")}this.update()}removeHandlers(){window.removeEventListener("resize",this.onResize);this.distElement.removeEventListener("mousedown",this.onMouseDown);this.distElement.removeEventListener("touchstart",this.onTouchStart);window.removeEventListener("mousemove",this.onMouseMove);window.removeEventListener("touchmove",this.onTouchMove);window.removeEventListener("mouseup",this.onMouseUp);window.removeEventListener("touchend",this.onTouchEnd)}setHandlers(){window.addEventListener("resize",this.onResize,!1);if(this.app.getSettings().useMouseEvents){this.distElement.addEventListener("mousedown",this.onMouseDown);this.distElement.addEventListener("touchstart",this.onTouchStart);window.addEventListener("mousemove",this.onMouseMove);window.addEventListener("touchmove",this.onTouchMove,{passive:!this.app.getSettings().mobileScrollSupport});window.addEventListener("mouseup",this.onMouseUp);window.addEventListener("touchend",this.onTouchEnd)}}getMousePos(e,t){const i=this.distElement.getBoundingClientRect();return{x:e-i.left,y:t-i.top}}checkTarget(e){return!this.app.getSettings().clickEventForward||!["a","button"].includes(e.tagName.toLowerCase())}}class HTMLUI extends UI{constructor(e,t,i,a,s){super(e,t,i);this.cspPolicyService=s;const r=this.cspPolicyService.createTrustedHTML('<div class="stf__block"></div>');this.wrapper.insertAdjacentHTML("afterbegin",r);this.distElement=e.querySelector(".stf__block");this.items=a;for(const e of a)this.distElement.appendChild(e);this.setHandlers()}clear(){for(const e of this.items)this.parentElement.appendChild(e)}updateItems(e){this.removeHandlers();this.distElement.innerHTML="";for(const t of e)this.distElement.appendChild(t);this.items=e;this.setHandlers()}update(){this.app.getRender().update()}}class EventObject{constructor(){this.events=new Map}on(e,t){this.events.has(e)?this.events.get(e).push(t):this.events.set(e,[t]);return this}off(e){this.events.delete(e)}trigger(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this.events.has(e))for(const a of this.events.get(e))a({data:i,object:t})}}class HTMLRender extends Render{constructor(e,t,i){super(e,t);this.outerShadow=null;this.innerShadow=null;this.hardShadow=null;this.hardInnerShadow=null;this.element=i;this.createShadows()}createShadows(){const e=this.app.cspPolicyService.createTrustedHTML('<div class="stf__outerShadow"></div>\n <div class="stf__innerShadow"></div>\n <div class="stf__hardShadow"></div>\n <div class="stf__hardInnerShadow"></div>');this.element.insertAdjacentHTML("beforeend",e);this.outerShadow=this.element.querySelector(".stf__outerShadow");this.innerShadow=this.element.querySelector(".stf__innerShadow");this.hardShadow=this.element.querySelector(".stf__hardShadow");this.hardInnerShadow=this.element.querySelector(".stf__hardInnerShadow")}clearShadow(){super.clearShadow();this.outerShadow.style.cssText="display: none";this.innerShadow.style.cssText="display: none";this.hardShadow.style.cssText="display: none";this.hardInnerShadow.style.cssText="display: none"}reload(){this.element.querySelector(".stf__outerShadow")||this.createShadows()}drawHardInnerShadow(){const e=this.getRect(),t=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let i=(100-t)*(2.5*e.pageWidth)/100+20;i>e.pageWidth&&(i=e.pageWidth);let a=`\n display: block;\n z-index: ${(this.getSettings().startZIndex+5).toString(10)};\n width: ${i}px;\n height: ${e.height}px;\n background: linear-gradient(to right,\n rgba(0, 0, 0, ${this.shadow.opacity*t/100}) 5%,\n rgba(0, 0, 0, 0) 100%);\n left: ${e.left+e.width/2}px;\n transform-origin: 0 0;\n `;a+=0===this.getDirection()&&this.shadow.progress>100||1===this.getDirection()&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0);":"transform: translate3d(0, 0, 0) rotateY(180deg);";this.hardInnerShadow.style.cssText=a}drawHardOuterShadow(){const e=this.getRect();let t=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*e.pageWidth)/100+20;t>e.pageWidth&&(t=e.pageWidth);let i=`\n display: block;\n z-index: ${(this.getSettings().startZIndex+4).toString(10)};\n width: ${t}px;\n height: ${e.height}px;\n background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);\n left: ${e.left+e.width/2}px;\n transform-origin: 0 0;\n `;i+=0===this.getDirection()&&this.shadow.progress>100||1===this.getDirection()&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0) rotateY(180deg);":"transform: translate3d(0, 0, 0);";this.hardShadow.style.cssText=i}drawInnerShadow(){const e=this.getRect(),t=3*this.shadow.width/4,i=0===this.getDirection()?t:0,a=0===this.getDirection()?"to left":"to right",s=this.convertToGlobal(this.shadow.pos),r=this.shadow.angle+3*Math.PI/2,n=[this.pageRect.topLeft,this.pageRect.topRight,this.pageRect.bottomRight,this.pageRect.bottomLeft];let o="polygon( ";for(const e of n){let t=1===this.getDirection()?{x:-e.x+this.shadow.pos.x,y:e.y-this.shadow.pos.y}:{x:e.x-this.shadow.pos.x,y:e.y-this.shadow.pos.y};t=Helper.GetRotatedPoint(t,{x:i,y:100},r);o+=t.x+"px "+t.y+"px, "}o=o.slice(0,-2);o+=")";const l=`\n display: block;\n z-index: ${(this.getSettings().startZIndex+10).toString(10)};\n width: ${t}px;\n height: ${2*e.height}px;\n background: linear-gradient(${a},\n rgba(0, 0, 0, ${this.shadow.opacity}) 5%,\n rgba(0, 0, 0, 0.05) 15%,\n rgba(0, 0, 0, ${this.shadow.opacity}) 35%,\n rgba(0, 0, 0, 0) 100%);\n transform-origin: ${i}px 100px;\n transform: translate3d(${s.x-i}px, ${s.y-100}px, 0) rotate(${r}rad);\n clip-path: ${o};\n -webkit-clip-path: ${o};\n `;this.innerShadow.style.cssText=l}drawOuterShadow(){const e=this.getRect(),t=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),i=this.shadow.angle+3*Math.PI/2,a=1===this.getDirection()?this.shadow.width:0,s=0===this.getDirection()?"to right":"to left",r=[{x:0,y:0},{x:e.pageWidth,y:0},{x:e.pageWidth,y:e.height},{x:0,y:e.height}];let n="polygon( ";for(const e of r)if(null!==e){let t=1===this.getDirection()?{x:-e.x+this.shadow.pos.x,y:e.y-this.shadow.pos.y}:{x:e.x-this.shadow.pos.x,y:e.y-this.shadow.pos.y};t=Helper.GetRotatedPoint(t,{x:a,y:100},i);n+=t.x+"px "+t.y+"px, "}n=n.slice(0,-2);n+=")";const o=`\n display: block;\n z-index: ${(this.getSettings().startZIndex+10).toString(10)};\n width: ${this.shadow.width}px;\n height: ${2*e.height}px;\n background: linear-gradient(${s}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));\n transform-origin: ${a}px 100px;\n transform: translate3d(${t.x-a}px, ${t.y-100}px, 0) rotate(${i}rad);\n clip-path: ${n};\n -webkit-clip-path: ${n};\n `;this.outerShadow.style.cssText=o}drawLeftPage(){if("portrait"!==this.orientation&&null!==this.leftPage)if(1===this.direction&&null!==this.flippingPage&&"hard"===this.flippingPage.getDrawingDensity()){if(this.flippingPage.getHardAngle()<-90){this.leftPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10);this.leftPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle());this.leftPage.draw(this.flippingPage.getDrawingDensity())}else this.leftPage.getElement().style.display="none"}else this.leftPage.simpleDraw(0)}drawRightPage(){if(null!==this.rightPage)if(0===this.direction&&null!==this.flippingPage&&"hard"===this.flippingPage.getDrawingDensity()){if(this.flippingPage.getHardAngle()>90){this.rightPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10);this.rightPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle());this.rightPage.draw(this.flippingPage.getDrawingDensity())}else this.rightPage.getElement().style.display="none"}else this.rightPage.simpleDraw(1)}drawBottomPage(){if(null===this.bottomPage)return;const e=null!=this.flippingPage?this.flippingPage.getDrawingDensity():null;if("portrait"!==this.orientation||1!==this.direction){this.bottomPage.getElement().style.zIndex=(this.getSettings().startZIndex+3).toString(10);this.bottomPage.draw(e)}}drawFrame(){if(null!==this.flippingPage){if(this.flippingPage.getHardAngle()===this.lastAngle)return;this.lastAngle=this.flippingPage.getHardAngle()}else this.lastAngle=-1234;this.clear();this.drawLeftPage();this.drawRightPage();this.drawBottomPage();if(null!=this.flippingPage){if(this.flippingPage.state.hardDrawingAngle<=90){this.flippingPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10);this.flippingPage.draw()}else this.flippingPage.getElement().style.display="none"}if(null!=this.shadow&&null!==this.flippingPage)if("soft"===this.flippingPage.getDrawingDensity()){this.drawOuterShadow();this.drawInnerShadow()}else{this.drawHardOuterShadow();this.drawHardInnerShadow()}}clear(){for(const e of this.app.getPageCollection().getPages()){if(e!==this.leftPage&&e!==this.rightPage&&e!==this.flippingPage&&e!==this.bottomPage){const t=e.getElement().style;"none"!==t.display&&(t.cssText="display: none")}e.getTemporaryCopy()!==this.flippingPage&&e.hideTemporaryCopy()}}update(){super.update();null!==this.rightPage&&this.rightPage.setOrientation(1);null!==this.leftPage&&this.leftPage.setOrientation(0)}}class Settings{constructor(){this._default={startPage:0,size:"fixed",width:0,height:0,minWidth:0,maxWidth:0,minHeight:0,maxHeight:0,drawShadow:!0,flippingTime:1e3,usePortrait:!0,startZIndex:0,autoSize:!0,maxShadowOpacity:1,showCover:!1,mobileScrollSupport:!0,swipeDistance:30,clickEventForward:!0,useMouseEvents:!0,showPageCorners:!0,disableFlipByClick:!1,enableFlipByDrag:!0}}getSettings(e){const t=this._default;Object.assign(t,e);if("stretch"!==t.size&&"fixed"!==t.size)throw new Error('Invalid size type. Available only "fixed" and "stretch" value');if(t.width<=0||t.height<=0)throw new Error("Invalid width or height");if(t.flippingTime<=0)throw new Error("Invalid flipping time");if("stretch"===t.size){t.minWidth<=0&&(t.minWidth=100);t.maxWidth<t.minWidth&&(t.maxWidth=2e3);t.minHeight<=0&&(t.minHeight=100);t.maxHeight<t.minHeight&&(t.maxHeight=2e3)}else{t.minWidth=t.width;t.maxWidth=t.width;t.minHeight=t.height;t.maxHeight=t.height}return t}}class PageFlip extends EventObject{constructor(e,t,i){super();this.isUserTouch=!1;this.isUserMove=!1;this.setting=null;this.pages=null;this.setting=(new Settings).getSettings(t);this.block=e;this.cspPolicyService=i}destroy(){this.ui.destroy();this.render=void 0}update(){this.render.update();this.pages.show()}loadFromHTML(e){this.ui=new HTMLUI(this.block,this,this.setting,e,this.cspPolicyService);this.render=new HTMLRender(this,this.setting,this.ui.getDistElement());this.flipController=new Flip(this.render,this);this.pages=new HTMLPageCollection(this,this.render,this.ui.getDistElement(),e);this.pages.load();this.render.start();this.pages.show(this.setting.startPage);setTimeout(()=>{this.ui.update();this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}updateFromHtml(e){const t=this.pages.getCurrentPageIndex();this.pages.destroy();this.pages=new HTMLPageCollection(this,this.render,this.ui.getDistElement(),e);this.pages.load();this.ui.updateItems(e);this.render.reload();this.pages.show(t);this.trigger("update",this,{page:t,mode:this.render.getOrientation()})}clear(){this.pages.destroy();this.ui.clear()}turnToPrevPage(){this.pages.showPrev()}turnToNextPage(){this.pages.showNext()}turnToPage(e){this.pages.show(e)}flipNext(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"top";this.flipController.flipNext(e)}flipPrev(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"top";this.flipController.flipPrev(e)}flip(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top";this.flipController.flipToPage(e,t)}updateState(e){this.trigger("changeState",this,e)}updatePageIndex(e){this.trigger("flip",this,e)}updateOrientation(e){this.ui.setOrientationStyle(e);this.update();this.trigger("changeOrientation",this,e)}getPageCount(){return this.pages.getPageCount()}getCurrentPageIndex(){return this.pages.getCurrentPageIndex()}getPage(e){return this.pages.getPage(e)}getRender(){return this.render}getFlipController(){return this.flipController}getOrientation(){return this.render.getOrientation()}getBoundsRect(){return this.render.getRect()}getSettings(){return this.setting}getUI(){return this.ui}getState(){return this.flipController.getState()}getPageCollection(){return this.pages}startUserTouch(e){this.mousePosition=e;this.isUserTouch=!0;this.isUserMove=!1}userMove(e,t){if(this.isUserTouch||t||!this.setting.showPageCorners){if(this.isUserTouch&&Helper.GetDistanceBetweenTwoPoint(this.mousePosition,e)>5){this.isUserMove=!0;this.flipController.fold(e)}}else this.flipController.showCorner(e)}userStop(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.isUserTouch){this.isUserTouch=!1;t||(this.isUserMove?this.flipController.stopMove():this.flipController.flip(e))}}}function annotation_editor_layer_builder_classPrivateFieldInitSpec(e,t,i){(function annotation_editor_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function annotation_editor_layer_builder_classPrivateFieldGet(e,t){return e.get(annotation_editor_layer_builder_assertClassBrand(e,t))}function annotation_editor_layer_builder_classPrivateFieldSet(e,t,i){return e.set(annotation_editor_layer_builder_assertClassBrand(e,t),i),i}function annotation_editor_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var $m=new WeakMap,qm=new WeakMap,Xm=new WeakMap,Km=new WeakMap,Ym=new WeakMap,Zm=new WeakMap;class AnnotationEditorLayerBuilder{constructor(e){annotation_editor_layer_builder_classPrivateFieldInitSpec(this,$m,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,qm,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,Xm,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,Km,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,Ym,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,Zm,void 0);this.pageIndex=e.pageIndex;this.accessibilityManager=e.accessibilityManager;this.l10n=e.l10n;this.l10n||=new genericl10n_GenericL10n;this.annotationEditorLayer=null;this.div=null;this._cancelled=!1;annotation_editor_layer_builder_classPrivateFieldSet(Zm,this,e.uiManager);annotation_editor_layer_builder_classPrivateFieldSet($m,this,e.annotationLayer||null);annotation_editor_layer_builder_classPrivateFieldSet(Ym,this,e.textLayer||null);annotation_editor_layer_builder_classPrivateFieldSet(qm,this,e.drawLayer||null);annotation_editor_layer_builder_classPrivateFieldSet(Xm,this,e.onAppend||null);this.eventBus=e.eventBus;annotation_editor_layer_builder_classPrivateFieldSet(Km,this,e.structTreeLayer||null)}updatePageIndex(e){this.pageIndex=e;this.annotationEditorLayer?.updatePageIndex(e)}async render(e){let t=e.viewport,i=e.intent,a=void 0===i?"display":i;if("display"!==a)return;if(this._cancelled)return;const s=t.clone({dontFlip:!0});if(this.div){this.annotationEditorLayer.update({viewport:s});this.show();return}const r=this.div=document.createElement("div");r.className="annotationEditorLayer";r.hidden=!0;r.dir=annotation_editor_layer_builder_classPrivateFieldGet(Zm,this).direction;annotation_editor_layer_builder_classPrivateFieldGet(Xm,this)?.call(this,r);this.annotationEditorLayer=new AnnotationEditorLayer({uiManager:annotation_editor_layer_builder_classPrivateFieldGet(Zm,this),div:r,structTreeLayer:annotation_editor_layer_builder_classPrivateFieldGet(Km,this),accessibilityManager:this.accessibilityManager,pageIndex:this.pageIndex,l10n:this.l10n,viewport:s,annotationLayer:annotation_editor_layer_builder_classPrivateFieldGet($m,this),textLayer:annotation_editor_layer_builder_classPrivateFieldGet(Ym,this),drawLayer:annotation_editor_layer_builder_classPrivateFieldGet(qm,this),eventBus:this.eventBus});const n={viewport:s,div:r,annotations:null,intent:a};await this.annotationEditorLayer.render(n);this.show()}cancel(){this._cancelled=!0;this.div&&this.annotationEditorLayer.destroy()}hide(){if(this.div){this.annotationEditorLayer.pause(!0);this.div.hidden=!0}}show(){if(this.div&&!this.annotationEditorLayer.isInvisible){this.div.hidden=!1;this.annotationEditorLayer.pause(!1)}}}function annotation_layer_builder_slicedToArray(e,t){return function annotation_layer_builder_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function annotation_layer_builder_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function annotation_layer_builder_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return annotation_layer_builder_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?annotation_layer_builder_arrayLikeToArray(e,t):void 0}}(e,t)||function annotation_layer_builder_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function annotation_layer_builder_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function annotation_layer_builder_classPrivateFieldInitSpec(e,t,i){annotation_layer_builder_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_layer_builder_classPrivateFieldGet(e,t){return e.get(annotation_layer_builder_assertClassBrand(e,t))}function annotation_layer_builder_classPrivateFieldSet(e,t,i){return e.set(annotation_layer_builder_assertClassBrand(e,t),i),i}function annotation_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Jm=new WeakMap,Qm=new WeakMap,ev=new WeakMap,tv=new WeakMap,iv=new WeakMap,av=new WeakMap,sv=new WeakSet;class AnnotationLayerBuilder{constructor(e){let t=e.pdfPage,i=e.linkService,a=e.downloadManager,s=e.annotationStorage,r=void 0===s?null:s,n=e.imageResourcesPath,o=void 0===n?"":n,l=e.renderForms,c=void 0===l||l,d=e.enableComment,h=void 0!==d&&d,u=e.commentManager,_=void 0===u?null:u,p=e.enableScripting,g=void 0!==p&&p,f=e.hasJSActionsPromise,m=void 0===f?null:f,v=e.fieldObjectsPromise,y=void 0===v?null:v,P=e.annotationCanvasMap,w=void 0===P?null:P,b=e.accessibilityManager,S=void 0===b?null:b,C=e.annotationEditorUIManager,A=void 0===C?null:C,x=e.onAppend,k=void 0===x?null:x;!function annotation_layer_builder_classPrivateMethodInitSpec(e,t){annotation_layer_builder_checkPrivateRedeclaration(e,t),t.add(e)}(this,sv);annotation_layer_builder_classPrivateFieldInitSpec(this,Jm,null);annotation_layer_builder_classPrivateFieldInitSpec(this,Qm,null);annotation_layer_builder_classPrivateFieldInitSpec(this,ev,!1);annotation_layer_builder_classPrivateFieldInitSpec(this,tv,null);annotation_layer_builder_classPrivateFieldInitSpec(this,iv,null);annotation_layer_builder_classPrivateFieldInitSpec(this,av,!1);this.pdfPage=t;this.linkService=i;this.downloadManager=a;this.imageResourcesPath=o;this.renderForms=c;this.annotationStorage=r;this.enableComment=h;annotation_layer_builder_classPrivateFieldSet(Qm,this,_);this.enableScripting=g;this._hasJSActionsPromise=m||Promise.resolve(!1);this._fieldObjectsPromise=y||Promise.resolve(null);this._annotationCanvasMap=w;this._accessibilityManager=S;this._annotationEditorUIManager=A;annotation_layer_builder_classPrivateFieldSet(tv,this,k);this.annotationLayer=null;this.div=null;this._cancelled=!1;this._eventBus=i.eventBus}async render(e){let t=e.viewport,i=e.intent,a=void 0===i?"display":i,s=e.structTreeLayer,r=void 0===s?null:s,n=e.optionalContentConfigPromise,o=void 0===n?null:n;if(this.div){const e=await o;if(this._cancelled||!this.annotationLayer)return;this.annotationLayer.update({viewport:t.clone({dontFlip:!0}),optionalContentConfig:e});return}const l=annotation_layer_builder_slicedToArray(await Promise.all([this.pdfPage.getAnnotations({intent:a}),this._hasJSActionsPromise,this._fieldObjectsPromise,o]),4),c=l[0],d=l[1],h=l[2],u=l[3];if(this._cancelled)return;const _=this.div=document.createElement("div");_.className="annotationLayer";annotation_layer_builder_classPrivateFieldGet(tv,this)?.call(this,_);annotation_layer_builder_assertClassBrand(sv,this,_initAnnotationLayer).call(this,t,r);if(0!==c.length){await this.annotationLayer.render({annotations:c,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,downloadManager:this.downloadManager,enableComment:this.enableComment,enableScripting:this.enableScripting,hasJSActions:d,fieldObjects:h,optionalContentConfig:u});annotation_layer_builder_classPrivateFieldSet(Jm,this,c);this.linkService.isInPresentationMode&&annotation_layer_builder_assertClassBrand(sv,this,_updatePresentationModeState).call(this,sh);if(!annotation_layer_builder_classPrivateFieldGet(iv,this)){annotation_layer_builder_classPrivateFieldSet(iv,this,new AbortController);this._eventBus?.on("presentationmodechanged",e=>{annotation_layer_builder_assertClassBrand(sv,this,_updatePresentationModeState).call(this,e.state)},{signal:annotation_layer_builder_classPrivateFieldGet(iv,this).signal,...Ih})}}else{annotation_layer_builder_classPrivateFieldSet(Jm,this,c);setLayerDimensions(this.div,t)}}cancel(){this._cancelled=!0;annotation_layer_builder_classPrivateFieldGet(iv,this)?.abort();annotation_layer_builder_classPrivateFieldSet(iv,this,null)}hide(){annotation_layer_builder_classPrivateFieldSet(ev,this,!(arguments.length>0&&void 0!==arguments[0]&&arguments[0]));this.div&&(document.querySelector("[data-pdfjsprinting=true]")||(this.div.hidden=!0))}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}async injectLinkAnnotations(e){if(null===annotation_layer_builder_classPrivateFieldGet(Jm,this)||this._cancelled||annotation_layer_builder_classPrivateFieldGet(av,this))return;annotation_layer_builder_classPrivateFieldSet(av,this,!0);const t=annotation_layer_builder_classPrivateFieldGet(Jm,this).length?annotation_layer_builder_assertClassBrand(sv,this,_checkInferredLinks).call(this,e):e;if(t.length){await this.annotationLayer.addLinkAnnotations(t);annotation_layer_builder_classPrivateFieldGet(ev,this)||(this.div.hidden=!1)}}}function _initAnnotationLayer(e,t){this.annotationLayer=new AnnotationLayer({div:this.div,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,annotationStorage:this.annotationStorage,page:this.pdfPage,viewport:e.clone({dontFlip:!0}),structTreeLayer:t,commentManager:annotation_layer_builder_classPrivateFieldGet(Qm,this),linkService:this.linkService})}function _updatePresentationModeState(e){if(!this.div)return;let t=!1;switch(e){case sh:t=!0;break;case ih:break;default:return}for(const e of this.div.childNodes)e.hasAttribute("data-internal-link")||(e.inert=t)}function _checkInferredLinks(e){function annotationRects(e){if(!e.quadPoints)return[e.rect];const t=[];for(let i=2,a=e.quadPoints.length;i<a;i+=8){const a=e.quadPoints[i],s=e.quadPoints[i+1],r=e.quadPoints[i+2],n=e.quadPoints[i+3];t.push([r,n,a,s])}return t}function intersectAnnotations(e,t){const i=[],a=annotationRects(e),s=annotationRects(t);for(const e of a)for(const t of s){const a=Util.intersect(e,t);a&&i.push(a)}return i}function areaRects(e){let t=0;for(const i of e)t+=Math.abs((i[2]-i[0])*(i[3]-i[1]));return t}return e.filter(e=>{let t;for(const i of annotation_layer_builder_classPrivateFieldGet(Jm,this)){if(i.annotationType!==I.LINK||!i.url)continue;const a=intersectAnnotations(i,e);if(0!==a.length){t??=areaRects(annotationRects(e));if(areaRects(a)/t>.5)return!1}}return!0})}function autolinker_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function autolinker_slicedToArray(e,t){return function autolinker_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function autolinker_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function autolinker_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return autolinker_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?autolinker_arrayLikeToArray(e,t):void 0}}(e,t)||function autolinker_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function autolinker_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function DOMRectToPDF(e,t){let i=e.width,a=e.height,s=e.left,r=e.top;if(0===i||0===a)return null;const n=t.textLayer.div.getBoundingClientRect(),o=t.getPagePoint(s-n.left,r-n.top),l=t.getPagePoint(s-n.left+i,r-n.top+a);return Util.normalizeRect([o[0],o[1],l[0],l[1]])}function calculateLinkPosition(e,t){const i=e.getClientRects();if(1===i.length)return{rect:DOMRectToPDF(i[0],t)};const a=[1/0,1/0,-1/0,-1/0],s=[];let r=0;for(const e of i){const i=DOMRectToPDF(e,t);if(null!==i){s[r]=s[r+4]=i[0];s[r+1]=s[r+3]=i[3];s[r+2]=s[r+6]=i[2];s[r+5]=s[r+7]=i[1];Util.rectBoundingBox(...i,a);r+=8}}return{quadPoints:s,rect:a}}function textPosition(e,t){let i=e;do{if(i.nodeType===Node.TEXT_NODE){const e=i.textContent.length;if(t<=e)return[i,t];t-=e}else if(i.firstChild){i=i.firstChild;continue}for(;!i.nextSibling&&i!==e;)i=i.parentNode;i!==e&&(i=i.nextSibling)}while(i!==e);throw new Error("Offset is bigger than container's contents length.")}class Autolinker{static findLinks(e){autolinker_assertClassBrand(Autolinker,this,nv)._??(nv._=autolinker_assertClassBrand(Autolinker,this,/\b(?:https?:\/\/|mailto:|www\.)(?:[\0-\x08\x0E-\x1F\$\+0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]|\/|[\0-\x08\x0E-\x1F!-Z\\\^-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uFEFE\uFF00-\u{10FFFF}]+[\0-\x08\x0E-\x1F\$\+0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}])+|(?=\p{L})[\0-\x08\x0E-\x1F!-'\*-;=\?A-Z\\\^-z\|~-\x9F\xA1-\u0F39\u0F3E-\u167F\u1681-\u169A\u169D-\u1FFF\u200B-\u2019\u201B-\u201D\u201F-\u2027\u202A-\u202E\u2030-\u2044\u2047-\u205E\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2E21\u2E2A-\u2E41\u2E43-\u2E54\u2E5D-\u2FFF\u3001-\u3007\u3012\u3013\u301C\u3020-\uFD3D\uFD40-\uFE16\uFE19-\uFE34\uFE45\uFE46\uFE49-\uFE58\uFE5F-\uFEFE\uFF00-\uFF07\uFF0A-\uFF3A\uFF3C\uFF3E-\uFF5A\uFF5C\uFF5E\uFF61\uFF64-\u{10FFFF}]+@([\0-\x08\x0E-\x1F\$\+\x2D0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]+(?:\.[\0-\x08\x0E-\x1F\$\+\x2D0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]+)+)/gu));const t=autolinker_slicedToArray(normalize(e,{ignoreDashEOL:!0}),2),i=t[0],a=t[1],s=i.matchAll(autolinker_assertClassBrand(Autolinker,this,nv)._),r=[];for(const e of s){const t=autolinker_slicedToArray(e,2),i=t[0],s=t[1];let n;if(i.startsWith("www.")||i.startsWith("http://")||i.startsWith("https://"))n=i;else if(s){const e=URL.parse(`http://${s}`)?.hostname;if(!e)continue;autolinker_assertClassBrand(Autolinker,this,ov)._??(ov._=autolinker_assertClassBrand(Autolinker,this,/\.\d+$/));if(autolinker_assertClassBrand(Autolinker,this,ov)._.test(e))continue}n??=i.startsWith("mailto:")?i:`mailto:${i}`;const o=createValidAbsoluteUrl(n,null,{addDefaultProtocol:!0});if(o){const t=autolinker_slicedToArray(getOriginalIndex(a,e.index,i.length),2),s=t[0],n=t[1];r.push({url:o.href,index:s,length:n})}}return r}static processLinks(e){return this.findLinks(e._textHighlighter.textContentItemsStr.join("\n")).map(t=>{var i,a;return function createLinkAnnotation(e,t,i){let a=e.url,s=e.index,r=e.length;const n=t._textHighlighter,o=autolinker_slicedToArray(n._convertMatches([s],[r]),1)[0],l=o.begin,c=o.end,d=new Range;d.setStart(...textPosition(n.textDivs[l.divIdx],l.offset));d.setEnd(...textPosition(n.textDivs[c.divIdx],c.offset));return{id:`inferred_link_${i}`,unsafeUrl:a,url:a,annotationType:I.LINK,rotation:0,...calculateLinkPosition(d,t),borderStyle:null}}(t,e,(rv._=autolinker_assertClassBrand(Autolinker,this,(i=autolinker_assertClassBrand(Autolinker,this,rv)._,a=i++,i)),a))})}}var rv={_:0},nv={_:void 0},ov={_:void 0};function base_pdf_page_view_defineProperty(e,t,i){return(t=function base_pdf_page_view_toPropertyKey(e){var t=function base_pdf_page_view_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function base_pdf_page_view_classPrivateFieldInitSpec(e,t,i){base_pdf_page_view_checkPrivateRedeclaration(e,t),t.set(e,i)}function base_pdf_page_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function base_pdf_page_view_classPrivateFieldSet(e,t,i){return e.set(base_pdf_page_view_assertClassBrand(e,t),i),i}function base_pdf_page_view_classPrivateFieldGet(e,t){return e.get(base_pdf_page_view_assertClassBrand(e,t))}function base_pdf_page_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var lv=new WeakMap,cv=new WeakMap,dv=new WeakMap,hv=new WeakMap,uv=new WeakMap,_v=new WeakMap,pv=new WeakMap,gv=new WeakSet;class BasePDFPageView extends RenderableView{constructor(e){super();!function base_pdf_page_view_classPrivateMethodInitSpec(e,t){base_pdf_page_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,gv);base_pdf_page_view_classPrivateFieldInitSpec(this,lv,null);base_pdf_page_view_classPrivateFieldInitSpec(this,cv,null);base_pdf_page_view_classPrivateFieldInitSpec(this,dv,Ff.INITIAL);base_pdf_page_view_classPrivateFieldInitSpec(this,hv,null);base_pdf_page_view_classPrivateFieldInitSpec(this,uv,0);base_pdf_page_view_classPrivateFieldInitSpec(this,_v,null);base_pdf_page_view_defineProperty(this,"canvas",null);base_pdf_page_view_defineProperty(this,"div",null);base_pdf_page_view_defineProperty(this,"enableOptimizedPartialRendering",!1);base_pdf_page_view_defineProperty(this,"enableSelectionRendering",!0);base_pdf_page_view_defineProperty(this,"imagesRightClickMinSize",-1);base_pdf_page_view_defineProperty(this,"eventBus",null);base_pdf_page_view_defineProperty(this,"id",null);base_pdf_page_view_defineProperty(this,"imageCoordinates",null);base_pdf_page_view_defineProperty(this,"pageColors",null);base_pdf_page_view_defineProperty(this,"recordedBBoxes",null);base_pdf_page_view_defineProperty(this,"renderingQueue",null);base_pdf_page_view_classPrivateFieldInitSpec(this,pv,e=>{base_pdf_page_view_classPrivateFieldGet(hv,this)?.call(this,!1);if(!this.renderingQueue||this.renderingQueue.isHighestPriority(this))e();else{this.renderingState=Ff.PAUSED;this.resume=()=>{this.renderingState=Ff.RUNNING;e()}}});this.eventBus=e.eventBus;this.id=e.id;this.pageColors=e.pageColors||null;this.renderingQueue=e.renderingQueue;this.enableOptimizedPartialRendering=e.enableOptimizedPartialRendering??!1;this.enableSelectionRendering=!1!==e.enableSelectionRendering;this.imagesRightClickMinSize=e.imagesRightClickMinSize??-1;this.minDurationToUpdateCanvas=e.minDurationToUpdateCanvas??500}get renderingState(){return base_pdf_page_view_classPrivateFieldGet(dv,this)}set renderingState(e){if(e!==base_pdf_page_view_classPrivateFieldGet(dv,this)){base_pdf_page_view_classPrivateFieldSet(dv,this,e);if(base_pdf_page_view_classPrivateFieldGet(lv,this)){clearTimeout(base_pdf_page_view_classPrivateFieldGet(lv,this));base_pdf_page_view_classPrivateFieldSet(lv,this,null)}switch(e){case Ff.PAUSED:this.div.classList.remove("loading");base_pdf_page_view_classPrivateFieldSet(uv,this,0);base_pdf_page_view_classPrivateFieldGet(hv,this)?.call(this,!1);break;case Ff.RUNNING:this.div.classList.add("loadingIcon");base_pdf_page_view_classPrivateFieldSet(lv,this,setTimeout(()=>{this.div.classList.add("loading");base_pdf_page_view_classPrivateFieldSet(lv,this,null)},0));base_pdf_page_view_classPrivateFieldSet(uv,this,Date.now());break;case Ff.INITIAL:case Ff.FINISHED:this.div.classList.remove("loadingIcon","loading");base_pdf_page_view_classPrivateFieldSet(uv,this,0)}}}_createCanvas(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=this.pageColors,a=!(!i?.background||!i?.foreground),s=this.canvas,r=!s&&!a&&!t;let n=this.canvas=document.createElement("canvas");base_pdf_page_view_classPrivateFieldSet(hv,this,t=>{if(r){let i=base_pdf_page_view_classPrivateFieldGet(_v,this);if(!t&&this.minDurationToUpdateCanvas>0){if(Date.now()-base_pdf_page_view_classPrivateFieldGet(uv,this)<this.minDurationToUpdateCanvas)return;if(!i){i=base_pdf_page_view_classPrivateFieldSet(_v,this,n);n=this.canvas=n.cloneNode(!1);e(n)}}if(i){n.getContext("2d",{alpha:!1}).drawImage(i,0,0);t?base_pdf_page_view_assertClassBrand(gv,this,_resetTempCanvas).call(this):base_pdf_page_view_classPrivateFieldSet(uv,this,Date.now());return}e(n);base_pdf_page_view_classPrivateFieldSet(hv,this,null);return}if(t)if(s){s.parentNode?s.replaceWith(n):e(n);s.width=s.height=0}else e(n)});return{canvas:n,prevCanvas:s}}_resetCanvas(){const e=this.canvas;if(e){e.remove();e.width=e.height=0;this.canvas=null;base_pdf_page_view_assertClassBrand(gv,this,_resetTempCanvas).call(this)}}async _drawCanvas(e,t,i){const a=this.renderTask=this.pdfPage.render(e);a.onContinue=base_pdf_page_view_classPrivateFieldGet(pv,this);a.onError=e=>{if(e instanceof RenderingCancelledException){t();base_pdf_page_view_classPrivateFieldSet(cv,this,null)}};let s=null;try{await a.promise;base_pdf_page_view_classPrivateFieldGet(hv,this)?.call(this,!0)}catch(e){if(e instanceof RenderingCancelledException)return;s=e;base_pdf_page_view_classPrivateFieldGet(hv,this)?.call(this,!0)}finally{base_pdf_page_view_classPrivateFieldSet(cv,this,s);if(a===this.renderTask){this.renderTask=null;this.enableOptimizedPartialRendering&&(this.recordedBBoxes??=a.recordedBBoxes);-1!==this.imagesRightClickMinSize&&(this.imageCoordinates??=this.pdfPage.imageCoordinates)}}this.renderingState=Ff.FINISHED;i(a);if(s)throw s}cancelRendering(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).cancelExtraDelay,t=void 0===e?0:e;if(this.renderTask){this.renderTask.cancel(t);this.renderTask=null}this.resume=null}dispatchPageRender(){this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id})}dispatchPageRendered(e,t){this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:e,isDetailView:t,timestamp:performance.now(),error:base_pdf_page_view_classPrivateFieldGet(cv,this)})}}function _resetTempCanvas(){if(base_pdf_page_view_classPrivateFieldGet(_v,this)){base_pdf_page_view_classPrivateFieldGet(_v,this).width=base_pdf_page_view_classPrivateFieldGet(_v,this).height=0;base_pdf_page_view_classPrivateFieldSet(_v,this,null)}}function draw_layer_builder_classPrivateFieldInitSpec(e,t,i){(function draw_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function draw_layer_builder_classPrivateFieldSet(e,t,i){return e.set(draw_layer_builder_assertClassBrand(e,t),i),i}function draw_layer_builder_classPrivateFieldGet(e,t){return e.get(draw_layer_builder_assertClassBrand(e,t))}function draw_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var fv=new WeakMap;class DrawLayerBuilder{constructor(e){draw_layer_builder_classPrivateFieldInitSpec(this,fv,null);this.pageIndex=e.pageIndex;this.textLayer=e.textLayer||null;this.filterFactory=e.filterFactory||null;this.pageColors=e.pageColors||null}async render(e){let t=e.intent;"display"!==(void 0===t?"display":t)||draw_layer_builder_classPrivateFieldGet(fv,this)||this._cancelled||draw_layer_builder_classPrivateFieldSet(fv,this,new DrawLayer({pageIndex:this.pageIndex,textLayer:this.textLayer,filterFactory:this.filterFactory,pageColors:this.pageColors}))}cancel(){this._cancelled=!0;if(draw_layer_builder_classPrivateFieldGet(fv,this)){draw_layer_builder_classPrivateFieldGet(fv,this).destroy();draw_layer_builder_classPrivateFieldSet(fv,this,null)}}setParent(e){draw_layer_builder_classPrivateFieldGet(fv,this)?.setParent(e)}getDrawLayer(){return draw_layer_builder_classPrivateFieldGet(fv,this)}}function pdf_page_detail_view_defineProperty(e,t,i){return(t=function pdf_page_detail_view_toPropertyKey(e){var t=function pdf_page_detail_view_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function pdf_page_detail_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_page_detail_view_classPrivateFieldGet(e,t){return e.get(pdf_page_detail_view_assertClassBrand(e,t))}function pdf_page_detail_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var mv=new WeakMap,vv=new WeakSet;class PDFPageDetailView extends BasePDFPageView{constructor(e){let t=e.pageView;super(t);!function pdf_page_detail_view_classPrivateMethodInitSpec(e,t){pdf_page_detail_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,vv);!function pdf_page_detail_view_classPrivateFieldInitSpec(e,t,i){pdf_page_detail_view_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,mv,null);pdf_page_detail_view_defineProperty(this,"renderingCancelled",!1);this.pageView=t;this.renderingId="detail"+this.id;this.div=t.div}setPdfPage(e){this.pageView.setPdfPage(e)}get pdfPage(){return this.pageView.pdfPage}get renderingState(){return super.renderingState}set renderingState(e){this.renderingCancelled=!1;super.renderingState=e}reset(){let e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).keepCanvas,t=void 0!==e&&e;const i=this.renderingCancelled||this.renderingState===Ff.RUNNING||this.renderingState===Ff.PAUSED;this.cancelRendering();this.renderingState=Ff.INITIAL;this.renderingCancelled=i;t||this._resetCanvas()}update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.visibleArea,i=void 0===t?null:t,a=e.underlyingViewUpdated;if(void 0!==a&&a){this.cancelRendering();this.renderingState=Ff.INITIAL;return}if(!pdf_page_detail_view_assertClassBrand(vv,this,_shouldRenderDifferentArea).call(this,i))return;const s=this.pageView,r=s.viewport,n=s.maxCanvasPixels,o=s.capCanvasAreaFactor,l=i.maxX-i.minX,c=i.maxY-i.minY,d=l*c*OutputScale.pixelRatio**2,h=(Math.sqrt(OutputScale.capPixels(n,o)/d)-1)/2;let u=Math.min(1,h);u<0&&(u=0);const _=l*u,p=c*u,g=Math.max(0,i.minX-_),f=Math.min(r.width,i.maxX+_),m=Math.max(0,i.minY-p),v=Math.min(r.height,i.maxY+p);!function pdf_page_detail_view_classPrivateFieldSet(e,t,i){return e.set(pdf_page_detail_view_assertClassBrand(e,t),i),i}(mv,this,{minX:g,minY:m,width:f-g,height:v-m,scale:r.scale});this.reset({keepCanvas:!0})}_getRenderingContext(e,t){const i=this.pageView._getRenderingContext(e,t,!1),a=this.pdfPage.recordedBBoxes;if(!a||!this.enableOptimizedPartialRendering)return i;const s=this.pageView.viewport,r=s.width,n=s.height,o=pdf_page_detail_view_classPrivateFieldGet(mv,this),l=o.width,c=o.height,d=o.minX,h=o.minY,u=d/r,_=h/n,p=(d+l)/r,g=(h+c)/n;return{...i,operationsFilter:e=>!a.isEmpty(e)&&(a.minX(e)<=p&&a.maxX(e)>=u&&a.minY(e)<=g&&a.maxY(e)>=_)}}async draw(){if(this.pageView.detailView!==this)return;const e=this.pageView.renderingState===Ff.FINISHED||this.renderingState===Ff.FINISHED;if(this.renderingState!==Ff.INITIAL){NgxConsole.error("Must be in new state before drawing");this.reset()}const t=this.pageView,i=t.div,a=t.pdfPage,s=t.viewport;if(!a){this.renderingState=Ff.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=Ff.RUNNING;const r=this.pageView._ensureCanvasWrapper(),n=this._createCanvas(e=>{"CANVAS"===r.firstElementChild?.tagName?r.firstElementChild.after(e):r.prepend(e)},e),o=n.canvas,l=n.prevCanvas;o.ariaHidden=!0;this.enableOptimizedPartialRendering&&(o.className="detailView");const c=s.width,d=s.height,h=pdf_page_detail_view_classPrivateFieldGet(mv,this),u=OutputScale.pixelRatio,_=[u,0,0,u,-h.minX*u,-h.minY*u];o.width=h.width*u;o.height=h.height*u;const p=o.style;p.width=100*h.width/c+"%";p.height=100*h.height/d+"%";p.top=100*h.minY/d+"%";p.left=100*h.minX/c+"%";const g=this._drawCanvas(this._getRenderingContext(o,_),()=>{this.canvas?.remove();this.canvas=l},()=>{this.dispatchPageRendered(!1,!0)});i.setAttribute("data-loaded",!0);this.dispatchPageRender();return g}}function _shouldRenderDifferentArea(e){if(!pdf_page_detail_view_classPrivateFieldGet(mv,this))return!0;const t=pdf_page_detail_view_classPrivateFieldGet(mv,this).minX,i=pdf_page_detail_view_classPrivateFieldGet(mv,this).minY,a=pdf_page_detail_view_classPrivateFieldGet(mv,this).width+t,s=pdf_page_detail_view_classPrivateFieldGet(mv,this).height+i;if(e.minX<t||e.minY<i||e.maxX>a||e.maxY>s)return!0;const r=this.pageView.viewport,n=r.width,o=r.height,l=r.scale;if(pdf_page_detail_view_classPrivateFieldGet(mv,this).scale!==l)return!0;const c=e.minX-t,d=a-e.maxX,h=e.minY-i,u=s-e.maxY;return t>0&&d/c>3||a<n&&c/d>3||i>0&&u/h>3||s<o&&h/u>3}function struct_tree_layer_builder_slicedToArray(e,t){return function struct_tree_layer_builder_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function struct_tree_layer_builder_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function struct_tree_layer_builder_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return struct_tree_layer_builder_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?struct_tree_layer_builder_arrayLikeToArray(e,t):void 0}}(e,t)||function struct_tree_layer_builder_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function struct_tree_layer_builder_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function struct_tree_layer_builder_classPrivateFieldInitSpec(e,t,i){struct_tree_layer_builder_checkPrivateRedeclaration(e,t),t.set(e,i)}function struct_tree_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function struct_tree_layer_builder_classPrivateFieldGet(e,t){return e.get(struct_tree_layer_builder_assertClassBrand(e,t))}function struct_tree_layer_builder_classPrivateFieldSet(e,t,i){return e.set(struct_tree_layer_builder_assertClassBrand(e,t),i),i}function struct_tree_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const yv={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P: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:"rowgroup",TBody:"rowgroup",TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},Pv=new Set(["math","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics"]),wv="http://www.w3.org/1998/Math/MathML";class MathMLSanitizer{static get sanitizer(){return shadow(this,"sanitizer",FeatureTest.isSanitizerSupported?new Sanitizer({elements:[...Pv].map(e=>({name:e,namespace:wv})),replaceWithChildrenElements:[{name:"maction",namespace:wv}],attributes:["dir","displaystyle","mathbackground","mathcolor","mathsize","scriptlevel","encoding","display","linethickness","intent","arg","form","fence","separator","lspace","rspace","stretchy","symmetric","maxsize","minsize","largeop","movablelimits","width","height","depth","voffset","accent","accentunder","columnspan","rowspan"],comments:!1}):null)}}const bv=/^H(\d+)$/;var Fv=new WeakMap,Sv=new WeakMap,Cv=new WeakMap,Av=new WeakMap,xv=new WeakMap,kv=new WeakMap,Ev=new WeakMap,Tv=new WeakMap,Iv=new WeakSet;class StructTreeLayerBuilder{constructor(e,t){!function struct_tree_layer_builder_classPrivateMethodInitSpec(e,t){struct_tree_layer_builder_checkPrivateRedeclaration(e,t),t.add(e)}(this,Iv);struct_tree_layer_builder_classPrivateFieldInitSpec(this,Fv,void 0);struct_tree_layer_builder_classPrivateFieldInitSpec(this,Sv,null);struct_tree_layer_builder_classPrivateFieldInitSpec(this,Cv,void 0);struct_tree_layer_builder_classPrivateFieldInitSpec(this,Av,new Map);struct_tree_layer_builder_classPrivateFieldInitSpec(this,xv,void 0);struct_tree_layer_builder_classPrivateFieldInitSpec(this,kv,null);struct_tree_layer_builder_classPrivateFieldInitSpec(this,Ev,null);struct_tree_layer_builder_classPrivateFieldInitSpec(this,Tv,null);struct_tree_layer_builder_classPrivateFieldSet(Fv,this,e.getStructTree());struct_tree_layer_builder_classPrivateFieldSet(xv,this,t)}async render(){if(struct_tree_layer_builder_classPrivateFieldGet(Cv,this))return struct_tree_layer_builder_classPrivateFieldGet(Cv,this);const e=Promise.withResolvers(),t=e.promise,i=e.resolve,a=e.reject;struct_tree_layer_builder_classPrivateFieldSet(Cv,this,t);try{struct_tree_layer_builder_classPrivateFieldSet(Sv,this,struct_tree_layer_builder_assertClassBrand(Iv,this,_walk).call(this,await struct_tree_layer_builder_classPrivateFieldGet(Fv,this)))}catch(e){a(e)}struct_tree_layer_builder_classPrivateFieldSet(Fv,this,null);struct_tree_layer_builder_classPrivateFieldGet(Sv,this)?.classList.add("structTree");i(struct_tree_layer_builder_classPrivateFieldGet(Sv,this));return t}async getAriaAttributes(e){try{await this.render();return struct_tree_layer_builder_classPrivateFieldGet(Av,this).get(e)}catch{}return null}hide(){struct_tree_layer_builder_classPrivateFieldGet(Sv,this)&&!struct_tree_layer_builder_classPrivateFieldGet(Sv,this).hidden&&(struct_tree_layer_builder_classPrivateFieldGet(Sv,this).hidden=!0)}show(){struct_tree_layer_builder_classPrivateFieldGet(Sv,this)?.hidden&&(struct_tree_layer_builder_classPrivateFieldGet(Sv,this).hidden=!1)}updateTextLayer(){if(struct_tree_layer_builder_classPrivateFieldGet(kv,this)){for(const t of struct_tree_layer_builder_classPrivateFieldGet(kv,this)){var e=struct_tree_layer_builder_slicedToArray(t,2);const i=e[0],a=e[1];document.getElementById(i)?.append(a)}struct_tree_layer_builder_classPrivateFieldGet(kv,this).clear();struct_tree_layer_builder_classPrivateFieldSet(kv,this,null)}if(struct_tree_layer_builder_classPrivateFieldGet(Ev,this)){for(const e of struct_tree_layer_builder_classPrivateFieldGet(Ev,this)){const t=document.getElementById(e);t&&(t.ariaHidden=!0)}struct_tree_layer_builder_classPrivateFieldGet(Ev,this).length=0;struct_tree_layer_builder_classPrivateFieldSet(Ev,this,null)}if(struct_tree_layer_builder_classPrivateFieldGet(Tv,this)){for(let e=0,t=struct_tree_layer_builder_classPrivateFieldGet(Tv,this).length;e<t;e+=2){const t=struct_tree_layer_builder_classPrivateFieldGet(Tv,this)[e],i=struct_tree_layer_builder_classPrivateFieldGet(Tv,this)[e+1];let a="";for(const e of i){const t=document.getElementById(e);if(t){a+=t.textContent.trim()||"";t.ariaHidden="true"}}a&&(t.textContent=a)}struct_tree_layer_builder_classPrivateFieldGet(Tv,this).length=0;struct_tree_layer_builder_classPrivateFieldSet(Tv,this,null)}}}function _setAttributes(e,t){const i=e.alt,a=e.id,s=e.lang;if(void 0!==i){let a=!1;const s=removeNullCharacters(i);for(const t of e.children)if("annotation"===t.type){struct_tree_layer_builder_classPrivateFieldGet(Av,this).getOrInsertComputed(t.id,makeMap).set("aria-label",s);a=!0}a||t.setAttribute("aria-label",s)}void 0!==a&&t.setAttribute("aria-owns",a);void 0!==s&&t.setAttribute("lang",removeNullCharacters(s,!0))}function _addImageInTextLayer(e,t){const i=e.alt,a=e.bbox,s=e.children,r=s?.[0];if(!struct_tree_layer_builder_classPrivateFieldGet(xv,this)||!i||!a||"content"!==r?.type)return!1;const n=r.id;if(!n)return!1;t.setAttribute("aria-owns",n);const o=document.createElement("span");(struct_tree_layer_builder_classPrivateFieldGet(kv,this)||struct_tree_layer_builder_classPrivateFieldSet(kv,this,new Map)).set(n,o);o.setAttribute("role","img");o.setAttribute("aria-label",removeNullCharacters(i));const l=struct_tree_layer_builder_classPrivateFieldGet(xv,this),c=l.pageHeight,d=l.pageX,h=l.pageY,u="calc(var(--total-scale-factor) *",_=o.style;_.width=`${u}${a[2]-a[0]}px)`;_.height=`${u}${a[3]-a[1]}px)`;_.left=`${u}${a[0]-d}px)`;_.top=`${u}${c-a[3]+h}px)`;return!0}function _collectIds(e,t){if(e){"id"in e&&t.push(e.id);for(const i of e.children||[])struct_tree_layer_builder_assertClassBrand(Iv,this,_collectIds).call(this,i,t)}}function _walk(e){let t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e)return null;let a=!0;if("role"in e){const s=e.role;if(Pv.has(s)){t=document.createElementNS(wv,s);const i=[];(struct_tree_layer_builder_classPrivateFieldGet(Tv,this)||struct_tree_layer_builder_classPrivateFieldSet(Tv,this,[])).push(t,i);for(const t of e.children||[]){const e=t.type,a=t.id;"content"===e&&a&&i.push(a)}}else t=document.createElement("span");const r=s.match(bv);if(r){t.setAttribute("role","heading");t.setAttribute("aria-level",r[1])}else yv[s]&&t.setAttribute("role","TH"===s&&"TR"===i.at(-1)?.role&&"TBody"===i.at(-2)?.role?"rowheader":yv[s]);if("Figure"===s&&struct_tree_layer_builder_assertClassBrand(Iv,this,_addImageInTextLayer).call(this,e,t))return t;if("Formula"===s){if(e.mathML&&MathMLSanitizer.sanitizer){a=!1;t.setHTML(e.mathML,{sanitizer:MathMLSanitizer.sanitizer});struct_tree_layer_builder_assertClassBrand(Iv,this,_collectIds).call(this,e,struct_tree_layer_builder_classPrivateFieldGet(Ev,this)||struct_tree_layer_builder_classPrivateFieldSet(Ev,this,[]));delete e.alt}if(!e.mathML&&1===e.children.length&&"math"!==e.children[0].role){t=document.createElementNS(wv,"math");delete e.alt}}}t||=document.createElement("span");struct_tree_layer_builder_assertClassBrand(Iv,this,_setAttributes).call(this,e,t);if(e.children)if(1===e.children.length&&"id"in e.children[0])struct_tree_layer_builder_assertClassBrand(Iv,this,_setAttributes).call(this,e.children[0],t);else if(a){i.push(e);for(const a of e.children)t.append(struct_tree_layer_builder_assertClassBrand(Iv,this,_walk).call(this,a,i));i.pop()}return t}function text_accessibility_slicedToArray(e,t){return function text_accessibility_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function text_accessibility_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function text_accessibility_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return text_accessibility_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?text_accessibility_arrayLikeToArray(e,t):void 0}}(e,t)||function text_accessibility_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function text_accessibility_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function text_accessibility_classPrivateFieldInitSpec(e,t,i){text_accessibility_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_accessibility_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_accessibility_classPrivateFieldGet(e,t){return e.get(text_accessibility_assertClassBrand(e,t))}function text_accessibility_classPrivateFieldSet(e,t,i){return e.set(text_accessibility_assertClassBrand(e,t),i),i}function text_accessibility_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Gv=new WeakMap,Bv=new WeakMap,Mv=new WeakMap,Dv=new WeakMap,Lv=new WeakSet;class TextAccessibilityManager{constructor(){!function text_accessibility_classPrivateMethodInitSpec(e,t){text_accessibility_checkPrivateRedeclaration(e,t),t.add(e)}(this,Lv);text_accessibility_classPrivateFieldInitSpec(this,Gv,!1);text_accessibility_classPrivateFieldInitSpec(this,Bv,null);text_accessibility_classPrivateFieldInitSpec(this,Mv,new Map);text_accessibility_classPrivateFieldInitSpec(this,Dv,new Map)}setTextMapping(e){text_accessibility_classPrivateFieldSet(Bv,this,e)}enable(){if(text_accessibility_classPrivateFieldGet(Gv,this))throw new Error("TextAccessibilityManager is already enabled.");if(!text_accessibility_classPrivateFieldGet(Bv,this))throw new Error("Text divs and strings have not been set.");text_accessibility_classPrivateFieldSet(Gv,this,!0);text_accessibility_classPrivateFieldSet(Bv,this,text_accessibility_classPrivateFieldGet(Bv,this).slice());text_accessibility_classPrivateFieldGet(Bv,this).sort(_compareElementPositions);if(text_accessibility_classPrivateFieldGet(Mv,this).size>0){const t=text_accessibility_classPrivateFieldGet(Bv,this);for(const i of text_accessibility_classPrivateFieldGet(Mv,this)){var e=text_accessibility_slicedToArray(i,2);const a=e[0],s=e[1];document.getElementById(a)?text_accessibility_assertClassBrand(Lv,this,_addIdToAriaOwns).call(this,a,t[s]):text_accessibility_classPrivateFieldGet(Mv,this).delete(a)}}for(const e of text_accessibility_classPrivateFieldGet(Dv,this)){var t=text_accessibility_slicedToArray(e,2);const i=t[0],a=t[1];this.addPointerInTextLayer(i,a)}text_accessibility_classPrivateFieldGet(Dv,this).clear()}disable(){if(text_accessibility_classPrivateFieldGet(Gv,this)){text_accessibility_classPrivateFieldGet(Dv,this).clear();text_accessibility_classPrivateFieldSet(Bv,this,null);text_accessibility_classPrivateFieldSet(Gv,this,!1)}}removePointerInTextLayer(e){if(!text_accessibility_classPrivateFieldGet(Gv,this)){text_accessibility_classPrivateFieldGet(Dv,this).delete(e);return}const t=text_accessibility_classPrivateFieldGet(Bv,this);if(!t||0===t.length)return;const i=e.id,a=text_accessibility_classPrivateFieldGet(Mv,this).get(i);if(void 0===a)return;const s=t[a];text_accessibility_classPrivateFieldGet(Mv,this).delete(i);let r=s.getAttribute("aria-owns");if(r?.includes(i)){r=r.split(" ").filter(e=>e!==i).join(" ");if(r)s.setAttribute("aria-owns",r);else{s.removeAttribute("aria-owns");s.setAttribute("role","presentation")}}}addPointerInTextLayer(e,t){const i=e.id;if(!i)return null;if(!text_accessibility_classPrivateFieldGet(Gv,this)){text_accessibility_classPrivateFieldGet(Dv,this).set(e,t);return null}t&&this.removePointerInTextLayer(e);const a=text_accessibility_classPrivateFieldGet(Bv,this);if(!a||0===a.length)return null;const s=binarySearchFirstItem(a,t=>_compareElementPositions.call(TextAccessibilityManager,e,t)<0),r=Math.max(0,s-1),n=a[r];text_accessibility_assertClassBrand(Lv,this,_addIdToAriaOwns).call(this,i,n);text_accessibility_classPrivateFieldGet(Mv,this).set(i,r);const o=n.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(e,t,i,a){const s=this.addPointerInTextLayer(i,a);if(!e.hasChildNodes()){e.append(t);return s}const r=Array.from(e.childNodes).filter(e=>e!==t);if(0===r.length)return s;const n=binarySearchFirstItem(r,e=>_compareElementPositions.call(TextAccessibilityManager,t,e)<0);0===n?r[0].before(t):r[n-1].after(t);return s}}function _compareElementPositions(e,t){const i=e.getBoundingClientRect(),a=t.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===a.width&&0===a.height)return-1;const s=i.y,r=i.y+i.height,n=i.y+i.height/2,o=a.y,l=a.y+a.height,c=a.y+a.height/2;if(n<=o&&c>=r)return-1;if(c<=s&&n>=l)return 1;return i.x+i.width/2-(a.x+a.width/2)}function _addIdToAriaOwns(e,t){const i=t.getAttribute("aria-owns");i?.includes(e)||t.setAttribute("aria-owns",i?`${i} ${e}`:e);t.removeAttribute("role")}function text_highlighter_classPrivateFieldInitSpec(e,t,i){(function text_highlighter_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function text_highlighter_classPrivateFieldSet(e,t,i){return e.set(text_highlighter_assertClassBrand(e,t),i),i}function text_highlighter_classPrivateFieldGet(e,t){return e.get(text_highlighter_assertClassBrand(e,t))}function text_highlighter_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Ov,Rv=new WeakMap;class TextHighlighter{constructor(e){let t=e.findController,i=e.customFindController,a=e.eventBus,s=e.pageIndex;text_highlighter_classPrivateFieldInitSpec(this,Rv,null);this.findController=t;this.customFindController=i;this.matches=[];this.eventBus=a;this.pageIdx=s;this.textDivs=null;this.textContentItemsStr=null;this.enabled=!1}setTextMapping(e,t){this.textDivs=e;this.textContentItemsStr=t}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(!this.enabled){this.enabled=!0;if(!text_highlighter_classPrivateFieldGet(Rv,this)){text_highlighter_classPrivateFieldSet(Rv,this,new AbortController);this.eventBus.on("updatetextlayermatches",e=>{e.pageIndex!==this.pageIdx&&-1!==e.pageIndex||this._updateMatches()},{signal:text_highlighter_classPrivateFieldGet(Rv,this).signal,...Ih})}this._updateMatches()}}disable(){if(this.enabled){this.enabled=!1;text_highlighter_classPrivateFieldGet(Rv,this)?.abort();text_highlighter_classPrivateFieldSet(Rv,this,null);this._updateMatches(!0)}}_convertMatches(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"highlight",a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:-1,n=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null;if(!e)return[];const o=this.textContentItemsStr;let l=0,c=0;const d=o.length-1,h=[];for(let u=0,_=e.length;u<_;u++){let _=e[u];for(;l!==d&&_>=c+o[l].length;){c+=o[l].length;l++}l===o.length&&ngx_console_NgxConsole.error("Could not find a matching mapping");const p={begin:{divIdx:l,offset:_-c},cssClass:i+(n?` color${n[u]}`:""),highlightAll:a,selected:s&&u===r};_+=t[u];for(;l!==d&&_>c+o[l].length;){c+=o[l].length;l++}p.end={divIdx:l,offset:_-c};h.push(p)}return h}_renderMatches(e,t){if(0===e.length)return;const i=this.pageIdx,a=this.textContentItemsStr,s=this.textDivs;let r=null;const n={divIdx:-1,offset:void 0};function beginText(e,t){const i=e.divIdx;s[i].textContent="";return appendTextToDiv(i,0,e.offset,t)}function appendTextToDiv(e,t,i,r){let n=s[e];if(n.nodeType===Node.TEXT_NODE){const t=document.createElement("span");n.before(t);t.append(n);s[e]=t;n=t}const o=a[e].substring(t,i),l=document.createTextNode(o);if(r){const e=document.createElement("span");e.className=`${r} appended`;e.append(l);n.append(e);return r.includes("selected")?e:null}n.append(l);return 0}let o=-1,l=-1;for(let a=0;a<e.length;a++){const c=e[a];if(!c.selected&&!c.highlightAll)continue;const d=c.begin;if(d.divIdx===o&&d.offset===l)continue;o=d.divIdx;l=d.offset;const h=c.end,u=c.selected?" selected":"";let _=null;if(r&&d.divIdx===r.divIdx)appendTextToDiv(r.divIdx,r.offset,d.offset);else{null!==r&&appendTextToDiv(r.divIdx,r.offset,n.offset);beginText(d)}if(d.divIdx===h.divIdx)_=appendTextToDiv(d.divIdx,d.offset,h.offset,c.cssClass+u);else{_=appendTextToDiv(d.divIdx,d.offset,n.offset,c.cssClass+" begin"+u);for(let e=d.divIdx+1,t=h.divIdx;e<t;e++)s[e].className=c.cssClass+" middle"+u;beginText(h,c.cssClass+" end"+u)}r=h;c.selected&&t.scrollMatchIntoView({element:_,pageIndex:i,matchIndex:a});if(this.textDivs.length>0){const e=this.textDivs[0].closest(".textLayer").querySelectorAll(`.${c.cssClass}`);this.eventBus.dispatch("renderedtextlayerhighlights",{pageIndex:i,highlights:e})}}r&&appendTextToDiv(r.divIdx,r.offset,n.offset)}_updateMatches(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this.enabled&&!e)return;const t=this.findController,i=this.customFindController,a=this.matches,s=this.pageIdx,r=this.textContentItemsStr,n=this.textDivs;let o=-1;for(const e of a){for(let t=Math.max(o,e.begin.divIdx),i=e.end.divIdx;t<=i;t++){const e=n[t];e.textContent=r[t];e.className=""}o=e.end.divIdx+1}if(e)return;const l=i.pageMatches[s]||null,c=i.pageMatchesLength[s]||null,d=i.pageMatchesColor?.[s]||null,h=t.pageMatches[s]||null,u=this._convertMatches(l,c,"customHighlight",i.state?.highlightAll,s===i.selected.pageIdx,i.selected.matchIdx,d);this.matches=[...u];t?.highlightMatches&&!e||e||this._renderMatches(this.matches,this.customFindController);const _=t.pageMatchesLength[s]||null,p=t.pageMatchesColor?.[s]||null,g=this._convertMatches(h,_,"highlight",t.state?.highlightAll,s===t.selected.pageIdx,t.selected.matchIdx,p);this.matches.push(...g);this.matches.sort((e,t)=>{const i=e.begin.divIdx-t.begin.divIdx;return 0===i?e.begin.offset-t.begin.offset:i});this._renderMatches(this.matches,this.findController)}}function text_layer_builder_slicedToArray(e,t){return function text_layer_builder_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function text_layer_builder_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function text_layer_builder_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return text_layer_builder_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?text_layer_builder_arrayLikeToArray(e,t):void 0}}(e,t)||function text_layer_builder_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function text_layer_builder_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function text_layer_builder_classPrivateFieldInitSpec(e,t,i){text_layer_builder_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_layer_builder_classPrivateFieldGet(e,t){return e.get(text_layer_builder_assertClassBrand(e,t))}function text_layer_builder_classPrivateFieldSet(e,t,i){return e.set(text_layer_builder_assertClassBrand(e,t),i),i}function text_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Nv=new WeakMap,jv=new WeakMap,Wv=new WeakMap,Uv=new WeakMap,Vv=new WeakMap,Hv=new WeakSet;class TextLayerBuilder{constructor(e){let t=e.pdfPage,i=e.highlighter,a=void 0===i?null:i,s=e.accessibilityManager,r=void 0===s?null:s,n=e.enablePermissions,o=void 0!==n&&n,l=e.onAppend,c=void 0===l?null:l,d=e.abortSignal,h=void 0===d?null:d;!function text_layer_builder_classPrivateMethodInitSpec(e,t){text_layer_builder_checkPrivateRedeclaration(e,t),t.add(e)}(this,Hv);text_layer_builder_classPrivateFieldInitSpec(this,Nv,null);text_layer_builder_classPrivateFieldInitSpec(this,jv,!1);text_layer_builder_classPrivateFieldInitSpec(this,Wv,null);text_layer_builder_classPrivateFieldInitSpec(this,Uv,!1);text_layer_builder_classPrivateFieldInitSpec(this,Vv,null);this.pdfPage=t;this.highlighter=a;this.accessibilityManager=r;text_layer_builder_classPrivateFieldSet(jv,this,!0===o);text_layer_builder_classPrivateFieldSet(Wv,this,c);text_layer_builder_classPrivateFieldSet(Nv,this,h);this.div=document.createElement("div");this.div.tabIndex=0;this.div.className="textLayer"}async render(e){let t=e.viewport,i=e.images,a=e.textContentParams,s=void 0===a?null:a;if(text_layer_builder_classPrivateFieldGet(Uv,this)&&text_layer_builder_classPrivateFieldGet(Vv,this)){text_layer_builder_classPrivateFieldGet(Vv,this).update({viewport:t,onBefore:this.hide.bind(this)});this.show();return}this.cancel();text_layer_builder_classPrivateFieldSet(Vv,this,new TextLayer({textContentSource:this.pdfPage.streamTextContent(s||{includeMarkedContent:!0,disableNormalization:!0}),images:i,container:this.div,viewport:t}));const r=text_layer_builder_classPrivateFieldGet(Vv,this),n=r.textDivs,o=r.textContentItemsStr;this.highlighter?.setTextMapping(n,o);this.accessibilityManager?.setTextMapping(n);await text_layer_builder_classPrivateFieldGet(Vv,this).render();text_layer_builder_classPrivateFieldSet(Uv,this,!0);const l=document.createElement("div");l.className="endOfContent";this.div.append(l);text_layer_builder_assertClassBrand(Hv,this,_bindMouse).call(this,l);text_layer_builder_classPrivateFieldGet(Wv,this)?.call(this,this.div);this.highlighter?.enable();this.accessibilityManager?.enable()}hide(){if(!this.div.hidden&&text_layer_builder_classPrivateFieldGet(Uv,this)){this.highlighter?.disable();this.div.hidden=!0}}show(){if(this.div.hidden&&text_layer_builder_classPrivateFieldGet(Uv,this)){this.div.hidden=!1;this.highlighter?.enable()}}cancel(){text_layer_builder_classPrivateFieldGet(Vv,this)?.cancel();text_layer_builder_classPrivateFieldSet(Vv,this,null);text_layer_builder_classPrivateFieldSet(Uv,this,!1);this.div.replaceChildren();this.highlighter?.disable();this.accessibilityManager?.disable();_removeGlobalSelectionListener.call(TextLayerBuilder,this.div)}}Ov=TextLayerBuilder;function _bindMouse(e){const t=this.div,i=text_layer_builder_classPrivateFieldGet(Nv,this),a=i?{signal:i}:null;t.addEventListener("mousedown",()=>{t.classList.add("selecting")},a);t.addEventListener("copy",e=>{if(!text_layer_builder_classPrivateFieldGet(jv,this)){const t=document.getSelection();e.clipboardData.setData("text/plain",removeNullCharacters(normalizeUnicode(t.toString())))}stopEvent(e)},a);zv._.set(t,e);_enableGlobalSelectionListener.call(Ov,i)}function _removeGlobalSelectionListener(e){text_layer_builder_assertClassBrand(Ov,this,zv)._.delete(e);if(0===text_layer_builder_assertClassBrand(Ov,this,zv)._.size){text_layer_builder_assertClassBrand(Ov,this,$v)._?.abort();$v._=text_layer_builder_assertClassBrand(Ov,this,null)}}function _enableGlobalSelectionListener(e){if(text_layer_builder_assertClassBrand(Ov,this,$v)._)return;$v._=text_layer_builder_assertClassBrand(Ov,this,new AbortController);const t=e?AbortSignal.any([text_layer_builder_assertClassBrand(Ov,this,$v)._.signal,e]):text_layer_builder_assertClassBrand(Ov,this,$v)._.signal,reset=(e,t)=>{t.append(e);e.style.width="";e.style.height="";t.classList.remove("selecting")};let i=!1;document.addEventListener("pointerdown",()=>{i=!0},{signal:t});document.addEventListener("pointerup",()=>{i=!1;text_layer_builder_assertClassBrand(Ov,this,zv)._.forEach(reset)},{signal:t});window.addEventListener("blur",()=>{i=!1;text_layer_builder_assertClassBrand(Ov,this,zv)._.forEach(reset)},{signal:t});document.addEventListener("keyup",()=>{i||text_layer_builder_assertClassBrand(Ov,this,zv)._.forEach(reset)},{signal:t});var a,s;document.addEventListener("selectionchange",()=>{const e=document.getSelection();if(0===e.rangeCount){text_layer_builder_assertClassBrand(Ov,this,zv)._.forEach(reset);return}if(0===text_layer_builder_assertClassBrand(Ov,this,zv)._.size)return;const t=new Set;for(let i=0;i<e.rangeCount;i++){const a=e.getRangeAt(i);for(const e of text_layer_builder_assertClassBrand(Ov,this,zv)._.keys())!t.has(e)&&a.intersectsNode(e)&&t.add(e)}for(const e of text_layer_builder_assertClassBrand(Ov,this,zv)._){var i=text_layer_builder_slicedToArray(e,2);const a=i[0],s=i[1];t.has(a)?a.classList.add("selecting"):reset(s,a)}a??="none"===getComputedStyle(text_layer_builder_assertClassBrand(Ov,this,zv)._.values().next().value).getPropertyValue("-moz-user-select");if(a)return;const r=e.getRangeAt(0),n=s&&(0===r.compareBoundaryPoints(Range.END_TO_END,s)||0===r.compareBoundaryPoints(Range.START_TO_END,s));let o=n?r.startContainer:r.endContainer;o.nodeType===Node.TEXT_NODE&&(o=o.parentNode);o.classList?.contains("highlight")&&(o=o.parentNode);if(!n&&0===r.endOffset)do{for(;!o.previousSibling;)o=o.parentNode;o=o.previousSibling}while(!o.childNodes.length);const l=o.parentElement?.closest(".textLayer"),c=text_layer_builder_assertClassBrand(Ov,this,zv)._.get(l);if(c){c.style.width=l.style.width;c.style.height=l.style.height;c.style.userSelect="text";o.parentElement.insertBefore(c,n?o:o.nextSibling)}s=r.cloneRange()},{signal:t})}var zv={_:new Map},$v={_:null};function pdf_page_view_classPrivateFieldInitSpec(e,t,i){pdf_page_view_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_page_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_page_view_classPrivateFieldGet(e,t){return e.get(pdf_page_view_assertClassBrand(e,t))}function pdf_page_view_classPrivateFieldSet(e,t,i){return e.set(pdf_page_view_assertClassBrand(e,t),i),i}function pdf_page_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const qv=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);var Xv=new WeakMap,Kv=new WeakMap,Yv=new WeakMap,Zv=new WeakMap,Jv=new WeakMap,Qv=new WeakMap,ey=new WeakMap,ty=new WeakMap,iy=new WeakMap,ay=new WeakMap,sy=new WeakMap,ry=new WeakMap,ny=new WeakMap,oy=new WeakMap,ly=new WeakMap,cy=new WeakMap,dy=new WeakMap,hy=new WeakSet;class PDFPageView extends BasePDFPageView{constructor(e){super(e);!function pdf_page_view_classPrivateMethodInitSpec(e,t){pdf_page_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,hy);pdf_page_view_classPrivateFieldInitSpec(this,Xv,null);pdf_page_view_classPrivateFieldInitSpec(this,Kv,m.ENABLE_FORMS);pdf_page_view_classPrivateFieldInitSpec(this,Yv,null);pdf_page_view_classPrivateFieldInitSpec(this,Zv,null);pdf_page_view_classPrivateFieldInitSpec(this,Jv,!0);pdf_page_view_classPrivateFieldInitSpec(this,Qv,!1);pdf_page_view_classPrivateFieldInitSpec(this,ey,!1);pdf_page_view_classPrivateFieldInitSpec(this,ty,null);pdf_page_view_classPrivateFieldInitSpec(this,iy,!1);pdf_page_view_classPrivateFieldInitSpec(this,ay,null);pdf_page_view_classPrivateFieldInitSpec(this,sy,null);pdf_page_view_classPrivateFieldInitSpec(this,ry,1);pdf_page_view_classPrivateFieldInitSpec(this,ny,1);pdf_page_view_classPrivateFieldInitSpec(this,oy,uh);pdf_page_view_classPrivateFieldInitSpec(this,ly,1);pdf_page_view_classPrivateFieldInitSpec(this,cy,{directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0});pdf_page_view_classPrivateFieldInitSpec(this,dy,[null,null,null,null]);const t=e.container,i=e.defaultViewport;this.renderingId="page"+this.id;pdf_page_view_classPrivateFieldSet(ty,this,e.layerProperties||null);pdf_page_view_classPrivateFieldSet(Xv,this,e.abortSignal||null);this.pdfPage=null;this.pageLabel=null;this.rotation=0;this.scale=e.scale||1;this.viewport=i;this.pdfPageRotate=i.rotation;this._optionalContentConfigPromise=e.optionalContentConfigPromise||null;pdf_page_view_classPrivateFieldSet(oy,this,e.textLayerMode??uh);pdf_page_view_classPrivateFieldSet(Kv,this,e.annotationMode??m.ENABLE_FORMS);this.imageResourcesPath=e.imageResourcesPath||"";this.enableDetailCanvas=e.enableDetailCanvas??!0;this.maxCanvasPixels=e.maxCanvasPixels??AppOptions.get("maxCanvasPixels");this.maxCanvasDim=e.maxCanvasDim||AppOptions.get("maxCanvasDim");this.capCanvasAreaFactor=e.capCanvasAreaFactor??AppOptions.get("capCanvasAreaFactor");pdf_page_view_classPrivateFieldSet(Jv,this,!1!==e.enableAutoLinking);pdf_page_view_classPrivateFieldSet(Zv,this,e.commentManager||null);this.l10n=e.l10n;this.l10n||=new genericl10n_GenericL10n;this._isStandalone=!this.renderingQueue?.hasViewer();this._container=t;this._annotationCanvasMap=null;this.annotationLayer=null;this.annotationEditorLayer=null;this.textLayer=null;this.xfaLayer=null;this.structTreeLayer=null;this.drawLayer=null;this.detailView=null;const a=document.createElement("div");a.className="page";a.setAttribute("data-page-number",this.id);a.setAttribute("role","region");a.setAttribute("data-l10n-id","pdfjs-page-landmark");a.setAttribute("data-l10n-args",JSON.stringify({page:this.id}));this.div=a;pdf_page_view_assertClassBrand(hy,this,_setDimensions).call(this);t?.append(a);if(this._isStandalone){t?.style.setProperty("--scale-factor",this.scale*PixelsPerInch.PDF_TO_CSS_UNITS);this.pageColors?.background&&t?.style.setProperty("--page-bg-color",this.pageColors.background);const i=e.optionalContentConfigPromise;i&&i.then(e=>{i===this._optionalContentConfigPromise&&(pdf_page_view_classPrivateFieldGet(cy,this).initialOptionalContent=e.hasInitialVisibility)});e.l10n||this.l10n.translate(this.div)}}clone(e){const t=new PDFPageView({container:null,eventBus:this.eventBus,pagesColors:this.pageColors,renderingQueue:this.renderingQueue,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,minDurationToUpdateCanvas:this.minDurationToUpdateCanvas,defaultViewport:this.viewport,id:e,layerProperties:pdf_page_view_classPrivateFieldGet(ty,this),abortSignal:pdf_page_view_classPrivateFieldGet(Xv,this),scale:this.scale,optionalContentConfigPromise:this._optionalContentConfigPromise,textLayerMode:pdf_page_view_classPrivateFieldGet(oy,this),annotationMode:pdf_page_view_classPrivateFieldGet(Kv,this),imageResourcesPath:this.imageResourcesPath,enableDetailCanvas:this.enableDetailCanvas,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableAutoLinking:pdf_page_view_classPrivateFieldGet(Jv,this),commentManager:pdf_page_view_classPrivateFieldGet(Zv,this),l10n:this.l10n});t.setPdfPage(this.pdfPage.clone(e-1));return t}updatePageNumber(e){if(this.id===e)return;const t=this.id;this.id=e;this.renderingId=`page${e}`;this.pdfPage&&(this.pdfPage.pageNumber=e);this.setPageLabel(this.pageLabel);const i=this.div;i.setAttribute("data-page-number",e);i.setAttribute("data-l10n-args",JSON.stringify({page:e}));this._textHighlighter.pageIdx=e-1;pdf_page_view_classPrivateFieldGet(ty,this).annotationEditorUIManager?.updatePageIndex(t-1,e-1)}setPdfPage(e){if(this._isStandalone&&("CanvasText"===this.pageColors?.foreground||"Canvas"===this.pageColors?.background)){this._container?.style.setProperty("--hcm-highlight-filter",e.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight"));this._container?.style.setProperty("--hcm-highlight-selected-filter",e.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))}this.pdfPage=e;this.pdfPageRotate=e.rotate;const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=e.getViewport({scale:this.scale*PixelsPerInch.PDF_TO_CSS_UNITS,rotation:t});pdf_page_view_assertClassBrand(hy,this,_setDimensions).call(this);this.reset()}destroy(){this.reset();this.pdfPage?.cleanup()}deleteMe(e){if(e)this.div.remove();else{this.destroy();pdf_page_view_classPrivateFieldGet(ty,this).annotationEditorUIManager?.deletePage(this.id)}}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return shadow(this,"_textHighlighter",new TextHighlighter({pageIndex:this.id-1,eventBus:this.eventBus,findController:pdf_page_view_classPrivateFieldGet(ty,this).findController,customFindController:pdf_page_view_classPrivateFieldGet(ty,this).customFindController}))}_resetCanvas(){super._resetCanvas();pdf_page_view_classPrivateFieldSet(ay,this,null)}reset(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.keepAnnotationLayer,i=void 0!==t&&t,a=e.keepAnnotationEditorLayer,s=void 0!==a&&a,r=e.keepXfaLayer,n=void 0!==r&&r,o=e.keepTextLayer,l=void 0!==o&&o,c=e.keepCanvasWrapper,d=void 0!==c&&c,h=e.preserveDetailViewState,u=void 0!==h&&h;const _=this.pdfPage?._pdfBug??!1;this.cancelRendering({keepAnnotationLayer:i,keepAnnotationEditorLayer:s,keepXfaLayer:n,keepTextLayer:l});this.renderingState=Ff.INITIAL;const p=this.div,g=p.childNodes,f=i&&this.annotationLayer?.div||null,m=s&&this.annotationEditorLayer?.div||null,v=n&&this.xfaLayer?.div||null,y=l&&this.textLayer?.div||null,P=d&&pdf_page_view_classPrivateFieldGet(Yv,this)||null;for(let e=g.length-1;e>=0;e--){const t=g[e];switch(t){case f:case m:case v:case y:case P:continue}if(_&&t.classList.contains("pdfBugGroupsLayer"))continue;t.remove();const i=pdf_page_view_classPrivateFieldGet(dy,this).indexOf(t);i>=0&&(pdf_page_view_classPrivateFieldGet(dy,this)[i]=null)}p.removeAttribute("data-loaded");f&&this.annotationLayer.hide();m&&this.annotationEditorLayer.hide();v&&this.xfaLayer.hide();y&&this.textLayer.hide();this.structTreeLayer?.hide();if(!d&&pdf_page_view_classPrivateFieldGet(Yv,this)){pdf_page_view_classPrivateFieldSet(Yv,this,null);this._resetCanvas()}if(!u){this.detailView?.reset({keepCanvas:d});d||(this.detailView=null)}}toggleEditingMode(e){pdf_page_view_classPrivateFieldSet(ey,this,e);this.hasEditableAnnotations()&&this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}updateVisibleArea(e){if(this.enableDetailCanvas)if(pdf_page_view_classPrivateFieldGet(iy,this)&&this.maxCanvasPixels>0&&e){this.detailView??=new PDFPageDetailView({pageView:this,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,imagesRightClickMinSize:-1});this.detailView.update({visibleArea:e})}else if(this.detailView){this.detailView.reset();this.detailView=null}}update(e){let t=e.scale,i=void 0===t?0:t,a=e.rotation,s=void 0===a?null:a,r=e.optionalContentConfigPromise,n=void 0===r?null:r,o=e.drawingDelay,l=void 0===o?-1:o;this.scale=i||this.scale;"number"==typeof s&&(this.rotation=s);const c=l>=0&&l<1e3;if(c&&!this.canvas)return;if(n instanceof Promise){this._optionalContentConfigPromise=n;n.then(e=>{n===this._optionalContentConfigPromise&&(pdf_page_view_classPrivateFieldGet(cy,this).initialOptionalContent=e.hasInitialVisibility)})}pdf_page_view_classPrivateFieldGet(cy,this).directDrawing=!0;const d=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:this.scale*PixelsPerInch.PDF_TO_CSS_UNITS,rotation:d});pdf_page_view_assertClassBrand(hy,this,_setDimensions).call(this);this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale);pdf_page_view_assertClassBrand(hy,this,_computeScale).call(this);if(this.canvas){const e=pdf_page_view_classPrivateFieldGet(Qv,this)&&pdf_page_view_classPrivateFieldGet(iy,this);if(c||e){if(c&&!e&&this.renderingState!==Ff.FINISHED){this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:l});this.renderingState=Ff.FINISHED;pdf_page_view_classPrivateFieldGet(cy,this).directDrawing=!1}this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!c,hideTextLayer:c});if(!c){this.detailView?.update({underlyingViewUpdated:!0});this.dispatchPageRendered(!0,!1)}return}}this.cssTransform({});this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0,preserveDetailViewState:!0});this.detailView?.update({underlyingViewUpdated:!0})}cancelRendering(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.keepAnnotationLayer,i=void 0!==t&&t,a=e.keepAnnotationEditorLayer,s=void 0!==a&&a,r=e.keepXfaLayer,n=void 0!==r&&r,o=e.keepTextLayer,l=void 0!==o&&o,c=e.cancelExtraDelay,d=void 0===c?0:c;super.cancelRendering({cancelExtraDelay:d});if(this.textLayer&&(!l||!this.textLayer.div)){this.textLayer.cancel();this.textLayer=null}if(this.annotationLayer&&(!i||!this.annotationLayer.div)){this.annotationLayer.cancel();this.annotationLayer=null;this._annotationCanvasMap=null}this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null);if(this.annotationEditorLayer&&(!s||!this.annotationEditorLayer.div)){if(this.drawLayer){this.drawLayer.cancel();this.drawLayer=null}this.annotationEditorLayer.cancel();this.annotationEditorLayer=null}if(this.xfaLayer&&(!n||!this.xfaLayer.div)){this.xfaLayer.cancel();this.xfaLayer=null;this._textHighlighter?.disable()}}cssTransform(e){let t=e.redrawAnnotationLayer,i=void 0!==t&&t,a=e.redrawAnnotationEditorLayer,s=void 0!==a&&a,r=e.redrawXfaLayer,n=void 0!==r&&r,o=e.redrawTextLayer,l=void 0!==o&&o,c=e.hideTextLayer,d=void 0!==c&&c;const h=this.canvas;if(!h)return;const u=pdf_page_view_classPrivateFieldGet(ay,this);if(this.viewport!==u){const e=(360+this.viewport.rotation-u.rotation)%360;if(90===e||270===e){const t=this.viewport,i=t.width,a=t.height,s=a/i,r=i/a;h.style.transform=`rotate(${e}deg) scale(${s},${r})`}else h.style.transform=0===e?"":`rotate(${e}deg)`}i&&this.annotationLayer&&pdf_page_view_assertClassBrand(hy,this,_renderAnnotationLayer).call(this);if(s&&this.annotationEditorLayer){this.drawLayer&&pdf_page_view_assertClassBrand(hy,this,_renderDrawLayer).call(this);pdf_page_view_assertClassBrand(hy,this,_renderAnnotationEditorLayer).call(this)}n&&this.xfaLayer&&pdf_page_view_assertClassBrand(hy,this,_renderXfaLayer).call(this);if(this.textLayer)if(d){this.textLayer.hide();this.structTreeLayer?.hide()}else l&&pdf_page_view_assertClassBrand(hy,this,_renderTextLayer).call(this)}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(e,t){return this.viewport.convertToPdfPoint(e,t)}_ensureCanvasWrapper(){let e=pdf_page_view_classPrivateFieldGet(Yv,this);if(!e){e=pdf_page_view_classPrivateFieldSet(Yv,this,document.createElement("div"));e.classList.add("canvasWrapper");pdf_page_view_assertClassBrand(hy,this,_addLayer).call(this,e,"canvasWrapper")}return e}_getRenderingContext(e,t,i,a){const s=AppOptions.get("pdfBackgroundColor");return{canvas:e,transform:t,viewport:this.viewport,annotationMode:pdf_page_view_classPrivateFieldGet(Kv,this),optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:this.pageColors,isEditing:pdf_page_view_classPrivateFieldGet(ey,this),background:s||null,recordOperations:i,recordImages:a}}async draw(){if(this.renderingState!==Ff.INITIAL){ngx_console_NgxConsole.error("Must be in new state before drawing");this.reset()}const e=this.div,t=this.l10n,i=this.pdfPage,a=this.viewport;if(!i){this.renderingState=Ff.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=Ff.RUNNING;const s=this._ensureCanvasWrapper();if(!this.textLayer&&pdf_page_view_classPrivateFieldGet(oy,this)!==hh&&!i.isPureXfa){this._accessibilityManager||=new TextAccessibilityManager;this.textLayer=new TextLayerBuilder({pdfPage:i,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:pdf_page_view_classPrivateFieldGet(oy,this)===_h,onAppend:e=>{this.l10n.pause();pdf_page_view_assertClassBrand(hy,this,_addLayer).call(this,e,"textLayer");this.l10n.resume()},abortSignal:pdf_page_view_classPrivateFieldGet(Xv,this)})}if(!this.annotationLayer&&pdf_page_view_classPrivateFieldGet(Kv,this)!==m.DISABLE){const e=pdf_page_view_classPrivateFieldGet(ty,this),t=e.annotationStorage,a=e.annotationEditorUIManager,s=e.downloadManager,r=e.enableComment,n=e.enableScripting,o=e.fieldObjectsPromise,l=e.hasJSActionsPromise,c=e.linkService;this._annotationCanvasMap||=new Map;this.annotationLayer=new AnnotationLayerBuilder({pdfPage:i,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:pdf_page_view_classPrivateFieldGet(Kv,this)===m.ENABLE_FORMS,linkService:c,downloadManager:s,enableComment:r,enableScripting:n,hasJSActionsPromise:l,fieldObjectsPromise:o,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:a,commentManager:pdf_page_view_classPrivateFieldGet(Zv,this),onAppend:e=>{pdf_page_view_assertClassBrand(hy,this,_addLayer).call(this,e,"annotationLayer")}})}const r=a.width,n=a.height;pdf_page_view_classPrivateFieldSet(ay,this,a);const o=this._createCanvas(e=>{s.prepend(e)}),l=o.canvas,c=o.prevCanvas;l.setAttribute("role","presentation");this.outputScale||pdf_page_view_assertClassBrand(hy,this,_computeScale).call(this);const d=this.outputScale;pdf_page_view_classPrivateFieldSet(Qv,this,pdf_page_view_classPrivateFieldGet(iy,this));const h=approximateFraction(d.sx),u=approximateFraction(d.sy);let _=floorToDivide(r*d.sx,h[0]),p=floorToDivide(n*d.sy,u[0]);const g=await MaxCanvasSize.reduceToMaxCanvasSize(_,p);if(g>1){_/=g;_*=.95;p/=g;p*=.95;const e=Math.round(100*(g/.95-1));warn(`Page ${this.id}: Reduced the maximum resolution by ${e}% because the browser can't render larger canvases.`)}l.width=_;l.height=p;const f=floorToDivide(Eh(r),h[1]),v=floorToDivide(Eh(n),u[1]);d.sx=_/f;d.sy=p/v;if(pdf_page_view_classPrivateFieldGet(ry,this)!==h[1]){e.style.setProperty("--scale-round-x",`${h[1]}px`);pdf_page_view_classPrivateFieldSet(ry,this,h[1])}if(pdf_page_view_classPrivateFieldGet(ny,this)!==u[1]){e.style.setProperty("--scale-round-y",`${u[1]}px`);pdf_page_view_classPrivateFieldSet(ny,this,u[1])}const y=this.enableOptimizedPartialRendering&&pdf_page_view_classPrivateFieldGet(Qv,this)&&!this.recordedBBoxes,P=-1!==this.imagesRightClickMinSize&&!this.imageCoordinates,w=d.scaled?[d.sx,0,0,d.sy,0,0]:null,b=l,S=this._drawCanvas(this._getRenderingContext(l,w,y,P),()=>{c?.remove();this.canvas===b&&this._resetCanvas()},e=>{pdf_page_view_classPrivateFieldGet(cy,this).regularAnnotations=!e.separateAnnots;this.dispatchPageRendered(!1,!1)}).then(async()=>{if(this.renderingState!==Ff.FINISHED)return;this.structTreeLayer||=new StructTreeLayerBuilder(i,a.rawDims);const e=pdf_page_view_assertClassBrand(hy,this,_renderTextLayer).call(this);if(this.annotationLayer){await pdf_page_view_assertClassBrand(hy,this,_renderAnnotationLayer).call(this);pdf_page_view_classPrivateFieldGet(Jv,this)&&this.annotationLayer&&this.textLayer&&await pdf_page_view_assertClassBrand(hy,this,_injectLinkAnnotations).call(this,e)}this.drawLayer||=new DrawLayerBuilder({pageIndex:this.id,textLayer:this.enableSelectionRendering?this.textLayer?.div:null,filterFactory:this.pdfPage?.filterFactory,pageColors:this.pageColors});await pdf_page_view_assertClassBrand(hy,this,_renderDrawLayer).call(this);this.drawLayer.setParent(s);const r=pdf_page_view_classPrivateFieldGet(ty,this).annotationEditorUIManager;if(r&&(this.annotationLayer||pdf_page_view_classPrivateFieldGet(Kv,this)===m.DISABLE)){this.annotationEditorLayer||=new AnnotationEditorLayerBuilder({uiManager:r,pageIndex:this.id-1,l10n:t,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:e=>{pdf_page_view_assertClassBrand(hy,this,_addLayer).call(this,e,"annotationEditorLayer")},eventBus:this.eventBus});pdf_page_view_assertClassBrand(hy,this,_renderAnnotationEditorLayer).call(this)}});if(i.isPureXfa){if(!this.xfaLayer){const e=pdf_page_view_classPrivateFieldGet(ty,this),t=e.annotationStorage,a=e.linkService;this.xfaLayer=new XfaLayerBuilder({pdfPage:i,annotationStorage:t,linkService:a})}pdf_page_view_assertClassBrand(hy,this,_renderXfaLayer).call(this)}e.setAttribute("data-loaded",!0);this.dispatchPageRender();return S}setPageLabel(e){this.pageLabel="string"==typeof e?e:null;this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id}));null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const e=pdf_page_view_classPrivateFieldGet(cy,this),t=e.directDrawing,i=e.initialOptionalContent,a=e.regularAnnotations;return t&&i&&a?this.canvas:null}}function _addLayer(e,t){const i=qv.get(t),a=pdf_page_view_classPrivateFieldGet(dy,this)[i];pdf_page_view_classPrivateFieldGet(dy,this)[i]=e;if(a)a.replaceWith(e);else{for(let t=i-1;t>=0;t--){const i=pdf_page_view_classPrivateFieldGet(dy,this)[t];if(i){i.after(e);return}}this.div.prepend(e)}}function _setDimensions(){const e=this.div,t=this.viewport;if(t.userUnit!==pdf_page_view_classPrivateFieldGet(ly,this)){1!==t.userUnit?e.style.setProperty("--user-unit",t.userUnit):e.style.removeProperty("--user-unit");pdf_page_view_classPrivateFieldSet(ly,this,t.userUnit)}if(this.pdfPage){if(pdf_page_view_classPrivateFieldGet(sy,this)===t.rotation)return;pdf_page_view_classPrivateFieldSet(sy,this,t.rotation)}setLayerDimensions(e,t,!0,!1)}function _dispatchLayerRendered(e,t,i){this.eventBus.dispatch(e,{source:this,pageNumber:this.id,error:t,layer:i})}async function _renderAnnotationLayer(){let e=null;try{await this.annotationLayer.render({viewport:this.viewport,intent:"display",structTreeLayer:this.structTreeLayer,optionalContentConfigPromise:this._optionalContentConfigPromise})}catch(t){ngx_console_NgxConsole.error("#renderAnnotationLayer:",t);e=t}finally{pdf_page_view_assertClassBrand(hy,this,_dispatchLayerRendered).call(this,"annotationlayerrendered",e,this.annotationLayer)}}async function _renderAnnotationEditorLayer(){let e=null;try{await this.annotationEditorLayer.render({viewport:this.viewport,intent:"display"})}catch(t){ngx_console_NgxConsole.error("#renderAnnotationEditorLayer:",t);e=t}finally{pdf_page_view_assertClassBrand(hy,this,_dispatchLayerRendered).call(this,"annotationeditorlayerrendered",e,this.annotationEditorLayer)}}async function _renderDrawLayer(){try{await this.drawLayer.render({intent:"display"})}catch(e){ngx_console_NgxConsole.error("#renderDrawLayer:",e)}}async function _renderXfaLayer(){let e=null;try{const e=await this.xfaLayer.render({viewport:this.viewport,intent:"display"});e?.textDivs&&this._textHighlighter&&pdf_page_view_assertClassBrand(hy,this,_buildXfaTextContentItems).call(this,e.textDivs)}catch(t){ngx_console_NgxConsole.error("#renderXfaLayer:",t);e=t}finally{if(this.xfaLayer?.div){this.l10n.pause();pdf_page_view_assertClassBrand(hy,this,_addLayer).call(this,this.xfaLayer.div,"xfaLayer");this.l10n.resume()}pdf_page_view_assertClassBrand(hy,this,_dispatchLayerRendered).call(this,"xfalayerrendered",e,this.xfaLayer)}}async function _renderTextLayer(){if(!this.textLayer)return;let e=null;try{await this.textLayer.render({viewport:this.viewport,images:this.imageCoordinates?new TextLayerImages(this.imagesRightClickMinSize,this.imageCoordinates,this.viewport,()=>this.canvas):null})}catch(t){if(t instanceof AbortException)return;ngx_console_NgxConsole.error("#renderTextLayer:",t);e=t}pdf_page_view_assertClassBrand(hy,this,_dispatchLayerRendered).call(this,"textlayerrendered",e,this.textLayer);pdf_page_view_assertClassBrand(hy,this,_renderStructTreeLayer).call(this)}async function _renderStructTreeLayer(){if(!this.textLayer)return;const e=await(this.structTreeLayer?.render());if(e){this.l10n.pause();this.structTreeLayer?.updateTextLayer();this.canvas&&e.parentNode!==this.canvas&&this.canvas.append(e);this.l10n.resume()}this.structTreeLayer?.show()}async function _buildXfaTextContentItems(e){const t=await this.pdfPage.getTextContent(),i=[];for(const e of t.items)i.push(e.str);this._textHighlighter.setTextMapping(e,i);this._textHighlighter.enable()}async function _injectLinkAnnotations(e){let t=null;try{await e;if(!this.annotationLayer)return;await this.annotationLayer.injectLinkAnnotations(Autolinker.processLinks(this))}catch(e){ngx_console_NgxConsole.error("#injectLinkAnnotations:",e);t=e}pdf_page_view_assertClassBrand(hy,this,_dispatchLayerRendered).call(this,"linkannotationsadded",t)}function _computeScale(){const e=this.viewport,t=e.width,i=e.height,a=this.outputScale=new OutputScale;if(0===this.maxCanvasPixels){const e=1/this.scale;a.sx*=e;a.sy*=e;pdf_page_view_classPrivateFieldSet(iy,this,!0)}else{pdf_page_view_classPrivateFieldSet(iy,this,a.limitCanvas(t,i,this.maxCanvasPixels,this.maxCanvasDim,this.capCanvasAreaFactor));if(pdf_page_view_classPrivateFieldGet(iy,this)&&this.enableDetailCanvas){const e=this.enableOptimizedPartialRendering?4:2;a.sx/=e;a.sy/=e}}}function pdf_viewer_slicedToArray(e,t){return function pdf_viewer_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function pdf_viewer_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function pdf_viewer_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return pdf_viewer_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pdf_viewer_arrayLikeToArray(e,t):void 0}}(e,t)||function pdf_viewer_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pdf_viewer_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function pdf_viewer_classPrivateMethodInitSpec(e,t){pdf_viewer_checkPrivateRedeclaration(e,t),t.add(e)}function pdf_viewer_classPrivateFieldInitSpec(e,t,i){pdf_viewer_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_viewer_classPrivateFieldGet(e,t){return e.get(pdf_viewer_assertClassBrand(e,t))}function pdf_viewer_classPrivateFieldSet(e,t,i){return e.set(pdf_viewer_assertClassBrand(e,t),i),i}function pdf_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const uy=1e4,_y=5e3,py=250;function isValidAnnotationEditorMode(e){return Object.values(P).includes(e)&&e!==P.DISABLE}var gy=new WeakMap,fy=new WeakMap,my=new WeakSet;class PDFPageViewBuffer{constructor(e){pdf_viewer_classPrivateMethodInitSpec(this,my);pdf_viewer_classPrivateFieldInitSpec(this,gy,new Set);pdf_viewer_classPrivateFieldInitSpec(this,fy,0);pdf_viewer_classPrivateFieldSet(fy,this,e)}push(e){const t=pdf_viewer_classPrivateFieldGet(gy,this);t.has(e)&&t.delete(e);t.add(e);t.size>pdf_viewer_classPrivateFieldGet(fy,this)&&pdf_viewer_assertClassBrand(my,this,_destroyFirstView).call(this)}resize(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;pdf_viewer_classPrivateFieldSet(fy,this,e);const i=pdf_viewer_classPrivateFieldGet(gy,this);if(t){const e=i.size;let a=1;for(const s of i){if(t.has(s.id)){i.delete(s);i.add(s)}if(++a>e)break}}for(;i.size>pdf_viewer_classPrivateFieldGet(fy,this);)pdf_viewer_assertClassBrand(my,this,_destroyFirstView).call(this)}has(e){return pdf_viewer_classPrivateFieldGet(gy,this).has(e)}[Symbol.iterator](){return pdf_viewer_classPrivateFieldGet(gy,this).keys()}}function _destroyFirstView(){const e=pdf_viewer_classPrivateFieldGet(gy,this).keys().next().value;e?.destroy();pdf_viewer_classPrivateFieldGet(gy,this).delete(e)}var vy=new WeakMap,yy=new WeakMap,Py=new WeakMap,wy=new WeakMap,by=new WeakMap,Fy=new WeakMap,Sy=new WeakMap,Cy=new WeakMap,Ay=new WeakMap,xy=new WeakMap,ky=new WeakMap,Ey=new WeakMap,Ty=new WeakMap,Iy=new WeakMap,Gy=new WeakMap,By=new WeakMap,My=new WeakMap,Dy=new WeakMap,Ly=new WeakMap,Oy=new WeakMap,Ry=new WeakMap,Ny=new WeakMap,jy=new WeakMap,Wy=new WeakMap,Uy=new WeakMap,Vy=new WeakMap,Hy=new WeakMap,zy=new WeakMap,$y=new WeakMap,qy=new WeakMap,Xy=new WeakMap,Ky=new WeakMap,Yy=new WeakMap,Zy=new WeakMap,Jy=new WeakMap,Qy=new WeakMap,eP=new WeakMap,tP=new WeakMap,iP=new WeakMap,aP=new WeakMap,sP=new WeakMap,rP=new WeakMap,nP=new WeakSet,oP=new WeakMap;class PDFViewer{constructor(e){pdf_viewer_classPrivateMethodInitSpec(this,nP);pdf_viewer_classPrivateFieldInitSpec(this,vy,null);pdf_viewer_classPrivateFieldInitSpec(this,yy,null);pdf_viewer_classPrivateFieldInitSpec(this,Py,null);pdf_viewer_classPrivateFieldInitSpec(this,wy,P.NONE);pdf_viewer_classPrivateFieldInitSpec(this,by,null);pdf_viewer_classPrivateFieldInitSpec(this,Fy,m.ENABLE_FORMS);pdf_viewer_classPrivateFieldInitSpec(this,Sy,null);pdf_viewer_classPrivateFieldInitSpec(this,Cy,null);pdf_viewer_classPrivateFieldInitSpec(this,Ay,null);pdf_viewer_classPrivateFieldInitSpec(this,xy,!1);pdf_viewer_classPrivateFieldInitSpec(this,ky,!1);pdf_viewer_classPrivateFieldInitSpec(this,Ey,!1);pdf_viewer_classPrivateFieldInitSpec(this,Ty,!1);pdf_viewer_classPrivateFieldInitSpec(this,Iy,!0);pdf_viewer_classPrivateFieldInitSpec(this,Gy,null);pdf_viewer_classPrivateFieldInitSpec(this,By,null);pdf_viewer_classPrivateFieldInitSpec(this,My,0);pdf_viewer_classPrivateFieldInitSpec(this,Dy,null);pdf_viewer_classPrivateFieldInitSpec(this,Ly,!0);pdf_viewer_classPrivateFieldInitSpec(this,Oy,null);pdf_viewer_classPrivateFieldInitSpec(this,Ry,null);pdf_viewer_classPrivateFieldInitSpec(this,Ny,null);pdf_viewer_classPrivateFieldInitSpec(this,jy,!1);pdf_viewer_classPrivateFieldInitSpec(this,Wy,null);pdf_viewer_classPrivateFieldInitSpec(this,Uy,0);pdf_viewer_classPrivateFieldInitSpec(this,Vy,new ResizeObserver(pdf_viewer_assertClassBrand(nP,this,pdf_viewer_resizeObserverCallback).bind(this)));pdf_viewer_classPrivateFieldInitSpec(this,Hy,null);pdf_viewer_classPrivateFieldInitSpec(this,zy,null);pdf_viewer_classPrivateFieldInitSpec(this,$y,null);pdf_viewer_classPrivateFieldInitSpec(this,qy,null);pdf_viewer_classPrivateFieldInitSpec(this,Xy,null);pdf_viewer_classPrivateFieldInitSpec(this,Ky,!0);pdf_viewer_classPrivateFieldInitSpec(this,Yy,uh);pdf_viewer_classPrivateFieldInitSpec(this,Zy,void 0);pdf_viewer_classPrivateFieldInitSpec(this,Jy,0);pdf_viewer_classPrivateFieldInitSpec(this,Qy,"multiple");pdf_viewer_classPrivateFieldInitSpec(this,eP,25);pdf_viewer_classPrivateFieldInitSpec(this,tP,eh);pdf_viewer_classPrivateFieldInitSpec(this,iP,null);pdf_viewer_classPrivateFieldInitSpec(this,aP,null);pdf_viewer_classPrivateFieldInitSpec(this,sP,null);pdf_viewer_classPrivateFieldInitSpec(this,rP,null);pdf_viewer_classPrivateFieldInitSpec(this,oP,!1);0;this.container=e.container;this.viewer=e.viewer||e.container.firstElementChild;pdf_viewer_classPrivateFieldSet(iP,this,e.viewerAlert||null);this.eventBus=e.eventBus;this.pageViewMode=e.pageViewMode||"multiple";this.defaultCacheSize=e.defaultCacheSize;pdf_viewer_classPrivateFieldSet(eP,this,e.maxZoom);pdf_viewer_classPrivateFieldSet(tP,this,e.minZoom);if("DIV"!==this.container?.tagName||"DIV"!==this.viewer?.tagName)throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&"absolute"!==getComputedStyle(this.container).position)throw new Error("The `container` must be absolutely positioned.");pdf_viewer_classPrivateFieldGet(Vy,this).observe(this.container);this.linkService=e.linkService||new SimpleLinkService;this.downloadManager=e.downloadManager||null;this.findController=e.findController||null;this.customFindController=e.customFindController||null;pdf_viewer_classPrivateFieldSet(yy,this,e.altTextManager||null);pdf_viewer_classPrivateFieldSet(Sy,this,e.commentManager||null);pdf_viewer_classPrivateFieldSet(Xy,this,e.signatureManager||null);pdf_viewer_classPrivateFieldSet(Ay,this,e.editorUndoBar||null);this.findController&&(this.findController.onIsPageVisible=e=>this._getVisiblePages().ids.has(e));this._scriptingManager=e.scriptingManager||null;pdf_viewer_classPrivateFieldSet(Yy,this,e.textLayerMode??uh);pdf_viewer_classPrivateFieldSet(Fy,this,e.annotationMode??m.ENABLE_FORMS);pdf_viewer_classPrivateFieldSet(wy,this,e.annotationEditorMode??P.NONE);pdf_viewer_classPrivateFieldSet(Py,this,e.annotationEditorHighlightColors||null);pdf_viewer_classPrivateFieldSet(xy,this,!0===e.enableHighlightFloatingButton);pdf_viewer_classPrivateFieldSet(Ey,this,!0===e.enableUpdatedAddImage);pdf_viewer_classPrivateFieldSet(Ty,this,!0===e.enableNewAltTextWhenAddingImage);this.imageResourcesPath=e.imageResourcesPath||"";this.enablePrintAutoRotate=e.enablePrintAutoRotate||!1;this.removePageBorders=e.removePageBorders||!1;this.maxCanvasPixels=e.maxCanvasPixels;this.maxCanvasDim=e.maxCanvasDim;this.capCanvasAreaFactor=e.capCanvasAreaFactor;this.enableDetailCanvas=e.enableDetailCanvas??!0;this.enableOptimizedPartialRendering=e.enableOptimizedPartialRendering??!1;this.enableSelectionRendering=!1!==e.enableSelectionRendering;this.imagesRightClickMinSize=e.imagesRightClickMinSize??-1;this.l10n=e.l10n;this.l10n||=new genericl10n_GenericL10n;pdf_viewer_classPrivateFieldSet(ky,this,e.enablePermissions||!1);this.pageColors=e.pageColors||null;pdf_viewer_classPrivateFieldSet(Dy,this,e.mlManager||null);pdf_viewer_classPrivateFieldSet(Ky,this,!1!==e.supportsPinchToZoom);pdf_viewer_classPrivateFieldSet(Iy,this,!1!==e.enableAutoLinking);pdf_viewer_classPrivateFieldSet(My,this,e.minDurationToUpdateCanvas??500);this._enableFlipByDrag=!0;this.defaultRenderingQueue=!e.renderingQueue;if(this.defaultRenderingQueue){this.renderingQueue=new PDFRenderingQueue;this.renderingQueue.setViewer(this)}else this.renderingQueue=e.renderingQueue;const t=e.abortSignal;pdf_viewer_classPrivateFieldSet(Gy,this,t||null);t?.addEventListener("abort",()=>{pdf_viewer_classPrivateFieldGet(Vy,this).disconnect();pdf_viewer_classPrivateFieldSet(Vy,this,null)},{once:!0});this.scroll=watchScroll(this.container,this._scrollUpdate.bind(this),t);this.presentationModeState=th;this._resetView();this.removePageBorders&&this.viewer.classList.add("removePageBorders");pdf_viewer_assertClassBrand(nP,this,_updateContainerHeightCss).call(this);this.eventBus.on("thumbnailrendered",e=>{let t=e.pageNumber,i=e.pdfPage;const a=this._pages[t-1];pdf_viewer_classPrivateFieldGet(vy,this).has(a)||i?.cleanup()},Ih);e.l10n||this.l10n.translate(this.container);this.cspPolicyService=e.cspPolicyService}get maxZoom(){return pdf_viewer_classPrivateFieldGet(eP,this)}set maxZoom(e){pdf_viewer_classPrivateFieldSet(eP,this,e)}get minZoom(){return pdf_viewer_classPrivateFieldGet(tP,this)}set minZoom(e){pdf_viewer_classPrivateFieldSet(tP,this,e)}setTextLayerMode(e){pdf_viewer_classPrivateFieldSet(Yy,this,e)}get pageViewMode(){return pdf_viewer_classPrivateFieldGet(Qy,this)}set pageViewMode(e){if(pdf_viewer_classPrivateFieldGet(Qy,this)!==e){const t=this._currentPageNumber;pdf_viewer_classPrivateFieldSet(Qy,this,e);pdf_viewer_classPrivateFieldSet(Zy,this,void 0);"infinite-scroll"===e&&pdf_viewer_assertClassBrand(nP,this,_initOuterScrollListener).call(this);this.eventBus.dispatch("pageviewmodechanged",{source:this,pageViewMode:e});if("infinite-scroll"===e&&t>1){pdf_viewer_classPrivateFieldSet(Jy,this,Date.now());setTimeout(()=>{pdf_viewer_classPrivateFieldSet(Jy,this,Date.now());pdf_viewer_assertClassBrand(nP,this,_scrollIntoView).call(this,this._pages[t-1])},200)}}}get printingAllowed(){return pdf_viewer_classPrivateFieldGet(Ly,this)}get pagesCount(){return this._pages.length}getPageView(e){return this._pages[e]}swapPages(e,t){const i=this._pages[e].pdfPage,a=this._pages[t].pdfPage;this._pages[e].setPdfPage(a);this._pages[t].setPdfPage(i);this.refresh()}getCachedPageViews(){return new Set(pdf_viewer_classPrivateFieldGet(vy,this))}get pageViewsReady(){return this._pages.every(e=>e?.pdfPage)}clearSelection(){const e=document.getSelection();if(e&&!e.isCollapsed)for(let t=0,i=e.rangeCount;t<i;t++)if(e.getRangeAt(t).intersectsNode(this.viewer)){e.removeAllRanges?.();e.empty?.();return}}get renderForms(){return pdf_viewer_classPrivateFieldGet(Fy,this)===m.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(e){if(!Number.isInteger(e))throw new Error("Invalid page number.");if(!this.pdfDocument)return;const t=this._currentPageNumber!==e,i=t&&Math.abs(this._currentPageNumber-e)<=2;this._currentPageNumber!==e&&this.clearSelection();this._setCurrentPageNumber(e,!0)||ngx_console_NgxConsole.error(`currentPageNumber: "${e}" is not a valid page.`);if(this.pageFlip&&t){i?this.pageFlip.flip(e-1):this.pageFlip.turnToPage(e-1);this.ensureAdjacentPagesAreLoaded()}}hidePagesDependingOnpageViewMode(){"book"===this.pageViewMode&&(this.pageFlip||setTimeout(()=>{if(!this.pageFlip){const e=this._pages[0].div,t=e.parentElement,i=t.parentElement;i.style.width=2*e.clientWidth+"px";i.style.overflow="hidden";i.style.marginLeft="auto";i.style.marginRight="auto";this.pageFlip=new PageFlip(t,{width:e.clientWidth,height:e.clientHeight,showCover:!0,size:"fixed",enableFlipByDrag:this._enableFlipByDrag},this.cspPolicyService);this.pageFlip.loadFromHTML(this.container.querySelectorAll(".page"));this.pageFlip.on("flip",e=>{this._currentPageNumber!==e.data+1&&this._setCurrentPageNumber(e.data+1,!1)})}},100))}async _setCurrentPageNumber(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this._currentPageNumber===e){t&&pdf_viewer_assertClassBrand(nP,this,_resetCurrentPageView).call(this);return!0}if(!(0<e&&e<=this.pagesCount))return!1;const i=this._currentPageNumber;this._currentPageNumber=e;this.hidePagesDependingOnpageViewMode();if("book"===this.pageViewMode||"infinite-scroll"===this.pageViewMode){const e=this._pages[this.currentPageNumber-1];if(e.div.parentElement.classList.contains("spread"))e.div.parentElement.childNodes.forEach(async e=>{const t=Number(e.getAttribute("data-page-number")),i=this._pages[t-1];await pdf_viewer_assertClassBrand(nP,this,pdf_viewer_ensurePdfPageLoaded).call(this,i);this.renderingQueue.renderView(i);e.style.display="inline-block"});else{await pdf_viewer_assertClassBrand(nP,this,pdf_viewer_ensurePdfPageLoaded).call(this,e);this.renderingQueue.renderView(e);"book"===pdf_viewer_classPrivateFieldGet(Qy,this)&&this.ensureAdjacentPagesAreLoaded()}}this.eventBus.dispatch("pagechanging",{source:this,pageNumber:e,pageLabel:this._pageLabels?.[e-1]??null,previous:i});t&&pdf_viewer_assertClassBrand(nP,this,_resetCurrentPageView).call(this);return!0}addPageToRenderQueue(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(e>=0&&e<=this._pages.length-1){const t=this._pages[e];if(t.renderingState===Ff.INITIAL){pdf_viewer_assertClassBrand(nP,this,pdf_viewer_ensurePdfPageLoaded).call(this,t).then(()=>{this.renderingQueue.renderView(t)});return!0}}return!1}async ensureAdjacentPagesAreLoaded(){const e=[0,1,-1,2,-2,-3];let t=0;this.currentPageNumber%2==1&&(t=-1);let i=!1;for(const a of e){const e=this.currentPageNumber+a+t;if(e>=0&&e<this._pages.length)try{const t=this._pages[e];await pdf_viewer_assertClassBrand(nP,this,pdf_viewer_ensurePdfPageLoaded).call(this,t);if(this._pages.some(e=>e.renderingState===Ff.RUNNING||e.renderingState===Ff.PAUSED)||i){const loader=()=>this.adjacentPagesRenderer(loader,e);this.eventBus._on("pagerendered",loader);this.eventBus._on("thumbnailRendered",loader)}else i=this.adjacentPagesRenderer(null,e)}catch(t){ngx_console_NgxConsole.log("Exception during pre-rendering page %s",e,t)}}}adjacentPagesRenderer(e,t){if(this._pages.find(e=>e.renderingState===Ff.RUNNING))return!0;const i=this._pages.find(e=>e.renderingState===Ff.PAUSED);if(i){this.renderingQueue.renderView(i);return!0}if(e){this.eventBus._off("pagerendered",e);this.eventBus._off("thumbnailRendered",e)}if(t>=0&&t<this._pages.length){const e=this._pages[t];if(e.renderingState===Ff.INITIAL){this.renderingQueue.renderView(e);return!0}}return!1}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(e){if(!this.pdfDocument)return;let t=0|e;if(this._pageLabels){const i=this._pageLabels.indexOf(e);i>=0&&(t=i+1)}this._currentPageNumber!==t&&this.clearSelection();this._setCurrentPageNumber(t,!0)||ngx_console_NgxConsole.error(`currentPageLabel: "${e}" is not a valid page.`)}get currentScale(){return 0!==this._currentScale?this._currentScale:1}set currentScale(e){if(isNaN(e))throw new Error("Invalid numeric scale.");this.pdfDocument&&pdf_viewer_assertClassBrand(nP,this,_setScale).call(this,e,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(e){this.pdfDocument&&pdf_viewer_assertClassBrand(nP,this,_setScale).call(this,e,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!isValidRotation(e))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;(e%=360)<0&&(e+=360);if(this._pagesRotation===e)return;this.clearSelection();this._pagesRotation=e;const t=this._currentPageNumber;this.refresh(!0,{rotation:e});this._currentScaleValue&&pdf_viewer_assertClassBrand(nP,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:e,pageNumber:t});this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _layerProperties(){const e=this;return shadow(this,"_layerProperties",{get annotationEditorUIManager(){return pdf_viewer_classPrivateFieldGet(by,e)},get annotationStorage(){return e.pdfDocument?.annotationStorage},get downloadManager(){return e.downloadManager},get enableComment(){return!!pdf_viewer_classPrivateFieldGet(Sy,e)},get enableScripting(){return!!e._scriptingManager},get fieldObjectsPromise(){return e.pdfDocument?.getFieldObjects()},get findController(){return e.findController},get customFindController(){return e.customFindController},get hasJSActionsPromise(){return e.pdfDocument?.hasJSActions()},get linkService(){return e.linkService}})}async getAllText(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=[],i=[];for(let a=1,s=this.pdfDocument.numPages;a<=s;++a){if(e?.aborted)return null;i.length=0;const s=await this.pdfDocument.getPage(a),r=(await s.getTextContent()).items;for(const e of r){e.str&&i.push(e.str);e.hasEOL&&i.push("\n")}t.push(removeNullCharacters(i.join("")))}return t.join("\n")}setDocument(e){if(this.pdfDocument){this.eventBus.dispatch("pagesdestroy",{source:this});this._cancelRendering();this._resetView();this.findController?.setDocument(null);this.customFindController?.setDocument(null);this._scriptingManager?.setDocument(null);pdf_viewer_classPrivateFieldGet(by,this)?.destroy();pdf_viewer_classPrivateFieldSet(by,this,null);pdf_viewer_classPrivateFieldSet(wy,this,P.NONE);pdf_viewer_classPrivateFieldSet(Ly,this,!0)}this.pdfDocument=e;if(!e)return;const t=e.numPages,i=e.getPage(1),a=e.getOptionalContentConfig({intent:"display"}),s=pdf_viewer_classPrivateFieldGet(ky,this)?e.getPermissions():Promise.resolve(),r=this.eventBus,n=this.pageColors,o=this.viewer;pdf_viewer_classPrivateFieldSet(By,this,new AbortController);const l=pdf_viewer_classPrivateFieldGet(By,this).signal,c={signal:l,...Ih};if(t>uy){ngx_console_NgxConsole.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const e=this._scrollMode=ph.PAGE;r.dispatch("scrollmodechanged",{source:this,mode:e})}this._pagesCapability.promise.then(()=>{r.dispatch("pagesloaded",{source:this,pagesCount:t})},()=>{});r.on("pagerender",e=>{const t=this._pages[e.pageNumber-1];t&&pdf_viewer_classPrivateFieldGet(vy,this).push(t)},c);const onAfterDraw=e=>{if(!e.cssTransform&&!e.isDetailView){this._onePageRenderedCapability.resolve({timestamp:e.timestamp});r.off("pagerendered",onAfterDraw)}};r.on("pagerendered",onAfterDraw,c);Promise.all([i,s]).then(i=>{let s=pdf_viewer_slicedToArray(i,2),c=s[0],d=s[1];if(e!==this.pdfDocument)return;this._firstPageCapability.resolve(c);this._optionalContentConfigPromise=a;const h=pdf_viewer_assertClassBrand(nP,this,_initializePermissions).call(this,d),u=h.annotationEditorMode,_=h.annotationMode,p=h.textLayerMode;if(p!==hh){const e=pdf_viewer_classPrivateFieldSet(Wy,this,document.createElement("div"));e.id="hiddenCopyElement";e.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none";o.before(e)}if(u!==P.DISABLE){const t=u;if(e.isPureXfa)ngx_console_NgxConsole.warn("Warning: XFA-editing is not implemented.");else if(isValidAnnotationEditorMode(t)){pdf_viewer_classPrivateFieldSet(by,this,new AnnotationEditorUIManager(this.container,o,pdf_viewer_classPrivateFieldGet(iP,this),pdf_viewer_classPrivateFieldGet(yy,this),pdf_viewer_classPrivateFieldGet(Sy,this),pdf_viewer_classPrivateFieldGet(Xy,this),r,e,n,pdf_viewer_classPrivateFieldGet(Py,this),pdf_viewer_classPrivateFieldGet(xy,this),pdf_viewer_classPrivateFieldGet(Ey,this),pdf_viewer_classPrivateFieldGet(Ty,this),pdf_viewer_classPrivateFieldGet(Dy,this),pdf_viewer_classPrivateFieldGet(Ay,this),pdf_viewer_classPrivateFieldGet(Ky,this)));r.dispatch("annotationeditoruimanager",{source:this,uiManager:pdf_viewer_classPrivateFieldGet(by,this)});if(t!==P.NONE){pdf_viewer_assertClassBrand(nP,this,_preloadEditingData).call(this,t);pdf_viewer_classPrivateFieldGet(by,this).updateMode(t)}}else ngx_console_NgxConsole.error(`Invalid AnnotationEditor mode: ${t}`)}const g=this._scrollMode===ph.PAGE?null:o,f=this.currentScale,m=c.getViewport({scale:f*PixelsPerInch.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",m.scale);n?.background&&o.style.setProperty("--page-bg-color",n.background);if("CanvasText"===n?.foreground||"Canvas"===n?.background){o.style.setProperty("--hcm-highlight-filter",e.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight"));o.style.setProperty("--hcm-highlight-selected-filter",e.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText"))}for(let e=1;e<=t;++e){const t=new PDFPageView({container:g,eventBus:r,id:e,scale:f,defaultViewport:m.clone(),optionalContentConfigPromise:a,renderingQueue:this.renderingQueue,textLayerMode:p,annotationMode:_,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,enableSelectionRendering:this.enableSelectionRendering,imagesRightClickMinSize:this.imagesRightClickMinSize,pageColors:n,l10n:this.l10n,layerProperties:this._layerProperties,enableAutoLinking:pdf_viewer_classPrivateFieldGet(Iy,this),minDurationToUpdateCanvas:pdf_viewer_classPrivateFieldGet(My,this),commentManager:pdf_viewer_classPrivateFieldGet(Sy,this),abortSignal:pdf_viewer_classPrivateFieldGet(Gy,this)});this._pages.push(t)}this._pages[0]?.setPdfPage(c);this._scrollMode===ph.PAGE?pdf_viewer_assertClassBrand(nP,this,_ensurePageViewVisible).call(this):this._spreadMode!==gh.NONE&&this._updateSpreadMode();r.on("annotationeditorlayerrendered",e=>{pdf_viewer_classPrivateFieldGet(by,this)&&r.dispatch("annotationeditormodechanged",{source:this,mode:pdf_viewer_classPrivateFieldGet(wy,this)})},{once:!0,signal:l,...Ih});pdf_viewer_assertClassBrand(nP,this,_onePageRenderedOrForceFetch).call(this,l).then(async()=>{if(e!==this.pdfDocument)return;this.findController?.setDocument(e);this.customFindController?.setDocument(e);this._scriptingManager?.setDocument(e);pdf_viewer_classPrivateFieldGet(Wy,this)&&document.addEventListener("copy",pdf_viewer_assertClassBrand(nP,this,_copyCallback).bind(this,p),{signal:l});if(e.loadingParams.disableAutoFetch||t>_y){this._pagesCapability.resolve();return}let i=t-1;if(i<=0)this._pagesCapability.resolve();else{"book"===pdf_viewer_classPrivateFieldGet(Qy,this)&&await this.ensureAdjacentPagesAreLoaded();for(let a=2;a<=t;++a){const t=e.getPage(a).then(e=>{const t=this._pages[a-1];t.pdfPage||t.setPdfPage(e);0===--i&&this._pagesCapability.resolve()},e=>{ngx_console_NgxConsole.error(`Unable to get page ${a} to initialize viewer`,e);0===--i&&this._pagesCapability.resolve()});a%py===0&&await t}}});this.hidePagesDependingOnpageViewMode();r.dispatch("pagesinit",{source:this});e.getMetadata().then(t=>{let i=t.info;e===this.pdfDocument&&i.Language&&(o.lang=i.Language)});this.defaultRenderingQueue&&this.update()}).catch(e=>{ngx_console_NgxConsole.error("Unable to initialize viewer",e);this._pagesCapability.reject(e)})}onPagesEdited(e){let t=e.pagesMapper,i=e.type,a=e.hasBeenCut,s=e.pageNumbers;if("copy"===i){pdf_viewer_classPrivateFieldSet(aP,this,new Map);for(const e of s)pdf_viewer_classPrivateFieldGet(aP,this).set(e,this._pages[e-1]);return}if("cancelCopy"===i){pdf_viewer_classPrivateFieldSet(aP,this,null);return}if("cut"===i||"delete"===i){pdf_viewer_classPrivateFieldSet(sP,this,this._pages);pdf_viewer_classPrivateFieldSet(rP,this,s)}if("cancelDelete"===i){pdf_viewer_classPrivateFieldSet(rP,this,null);if(!pdf_viewer_classPrivateFieldGet(sP,this))return;const e=this._scrollMode===ph.PAGE?null:this.viewer;if(e){pdf_viewer_classPrivateFieldGet(by,this)?.startUpdatePages();const t=document.createDocumentFragment();for(let e=0,i=pdf_viewer_classPrivateFieldGet(sP,this).length;e<i;e++){const i=pdf_viewer_classPrivateFieldGet(sP,this)[e];i.updatePageNumber(e+1);t.append(i.div)}e.replaceChildren(t);pdf_viewer_classPrivateFieldGet(by,this)?.endUpdatePages()}this._pages=pdf_viewer_classPrivateFieldGet(sP,this);pdf_viewer_classPrivateFieldSet(sP,this,null);return}if("cleanSavedData"===i){if(pdf_viewer_classPrivateFieldGet(rP,this)){if(pdf_viewer_classPrivateFieldGet(sP,this)){for(const e of pdf_viewer_classPrivateFieldGet(rP,this))pdf_viewer_classPrivateFieldGet(sP,this)[e-1].deleteMe();pdf_viewer_classPrivateFieldSet(sP,this,null)}pdf_viewer_classPrivateFieldSet(rP,this,null)}return}this._currentPageNumber=0;const r=this._pages,n=this._pages=[];pdf_viewer_classPrivateFieldGet(by,this)?.startUpdatePages();for(let e=1,i=t.pagesNumber;e<=i;e++){const i=t.getPrevPageNumber(e);if(i<0){let t=pdf_viewer_classPrivateFieldGet(aP,this).get(-i);if(a)t.updatePageNumber(e);else{pdf_viewer_classPrivateFieldGet(by,this)?.clonePage(-i-1,e-1);t=t.clone(e)}n.push(t);continue}const s=r[i-1];n.push(s);s.updatePageNumber(e)}pdf_viewer_classPrivateFieldGet(by,this)?.endUpdatePages();"paste"===i&&pdf_viewer_classPrivateFieldSet(aP,this,null);const o=this._scrollMode===ph.PAGE?null:this.viewer;if(o){const e=document.createDocumentFragment();for(const t of n){const i=t.div;e.append(i)}o.replaceChildren(e)}setTimeout(()=>{this.forceRendering()})}setPageLabels(e){if(this.pdfDocument){if(e)if(Array.isArray(e)&&this.pdfDocument.numPages===e.length)this._pageLabels=e;else{this._pageLabels=null;ngx_console_NgxConsole.error("setPageLabels: Invalid page labels.")}else this._pageLabels=null;for(let e=0,t=this._pages.length;e<t;e++)this._pages[e].setPageLabel(this._pageLabels?.[e]??null)}}_resetView(){this._pages=[];this._currentPageNumber=1;this._currentScale=0;this._currentScaleValue=null;this._pageLabels=null;const e=this.defaultCacheSize||10;pdf_viewer_classPrivateFieldSet(vy,this,new PDFPageViewBuffer(e));this._location=null;this._pagesRotation=0;this._optionalContentConfigPromise=null;this._firstPageCapability=Promise.withResolvers();this._onePageRenderedCapability=Promise.withResolvers();this._pagesCapability=Promise.withResolvers();this._scrollMode=ph.VERTICAL;this._previousScrollMode=ph.UNKNOWN;this._spreadMode=gh.NONE;pdf_viewer_classPrivateFieldSet(Hy,this,{previousPageNumber:1,scrollDown:!0,pages:[]});pdf_viewer_classPrivateFieldGet(By,this)?.abort();pdf_viewer_classPrivateFieldSet(By,this,null);this.viewer.textContent="";this._updateScrollMode();this.viewer.removeAttribute("lang");pdf_viewer_classPrivateFieldGet(Wy,this)?.remove();pdf_viewer_classPrivateFieldSet(Wy,this,null);pdf_viewer_assertClassBrand(nP,this,_cleanupTimeouts).call(this);pdf_viewer_assertClassBrand(nP,this,_cleanupSwitchAnnotationEditorMode).call(this)}_scrollUpdate(){if(0!==this.pagesCount){pdf_viewer_classPrivateFieldGet(Oy,this)&&clearTimeout(pdf_viewer_classPrivateFieldGet(Oy,this));pdf_viewer_classPrivateFieldSet(Oy,this,setTimeout(()=>{pdf_viewer_classPrivateFieldSet(Oy,this,null);this.update()},100));"infinite-scroll"===this.pageViewMode?this.update(!0):this.update()}}scrollPagePosIntoView(e,t){const i=this._pages[e-1].div;if(t){const a={...t};if("string"==typeof a.top&&a.top.endsWith("%")){const e=Number(a.top.replace("%","")),t=this.viewer.querySelector(".page")?.clientHeight;let s=i.clientHeight??t;const r=this.viewer.parentElement.clientHeight;s=Math.max(0,s-r);a.top=e*s/100}if("string"==typeof a.left&&a.left.endsWith("%")){const e=Number(a.left.replace("%","")),t=this.viewer.querySelector(".page")?.clientWidth,s=i.clientWidth??t;a.left=e*s/100}pdf_viewer_assertClassBrand(nP,this,_scrollIntoView).call(this,{div:i,id:e},a)}else pdf_viewer_assertClassBrand(nP,this,_scrollIntoView).call(this,{div:i,id:e})}pageLabelToPageNumber(e){if(!this._pageLabels)return null;const t=this._pageLabels.indexOf(e);return t<0?null:t+1}scrollPageIntoView(e){let t=e.pageNumber,i=e.destArray,a=void 0===i?null:i,s=e.allowNegativeOffset,r=void 0!==s&&s,n=e.ignoreDestinationZoom,o=void 0!==n&&n,l=e.center,c=void 0===l?null:l;if(!this.pdfDocument)return;const d=Number.isInteger(t)&&this._pages[t-1];if(!d){ngx_console_NgxConsole.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);return}if(this.isInPresentationMode||!a){this._setCurrentPageNumber(t,!0);return}let h,u,_=0,p=0,g=0,f=0;const m=d.rotation%180!=0,v=(m?d.height:d.width)/d.scale/PixelsPerInch.PDF_TO_CSS_UNITS,y=(m?d.width:d.height)/d.scale/PixelsPerInch.PDF_TO_CSS_UNITS;let P=0;switch(a[1].name){case"XYZ":_=a[2];p=a[3];P=a[4];_=null!==_?_:0;p=null!==p?p:y;break;case"Fit":case"FitB":P="page-fit";break;case"FitH":case"FitBH":p=a[2];P="page-width";if(null===p&&this._location){_=this._location.left;p=this._location.top}else("number"!=typeof p||p<0)&&(p=y);break;case"FitV":case"FitBV":_=a[2];g=v;f=y;P="page-height";break;case"FitR":_=a[2];p=a[3];g=a[4]-_;f=a[5]-p;let e=40,t=5;this.removePageBorders&&(e=t=0);h=(this.container.clientWidth-e)/g/PixelsPerInch.PDF_TO_CSS_UNITS;u=(this.container.clientHeight-t)/f/PixelsPerInch.PDF_TO_CSS_UNITS;P=Math.min(Math.abs(h),Math.abs(u));break;default:ngx_console_NgxConsole.error(`scrollPageIntoView: "${a[1].name}" is not a valid destination type.`);return}o||(P&&P!==this._currentScale?this.currentScaleValue=P:0===this._currentScale&&(this.currentScaleValue=Qd));pdf_viewer_assertClassBrand(nP,this,pdf_viewer_ensurePdfPageLoaded).call(this,d).then(()=>{this.renderingQueue.renderView(d);"single"===this.pageViewMode&&this.currentPageNumber!==t&&(this.currentPageNumber=t)});if("page-fit"===P&&!a[4]){pdf_viewer_assertClassBrand(nP,this,_scrollIntoView).call(this,d);return}const w=[d.viewport.convertToViewportPoint(_,p),d.viewport.convertToViewportPoint(_+g,p+f)];let b=Math.min(w[0][0],w[1][0]),S=Math.min(w[0][1],w[1][1]);if(c){"both"!==c&&"vertical"!==c||(S-=(this.container.clientHeight-Math.abs(w[1][1]-w[0][1]))/2);"both"!==c&&"horizontal"!==c||(b-=(this.container.clientWidth-Math.abs(w[1][0]-w[0][0]))/2)}else if(!r){b=Math.max(b,0);S=Math.max(S,0)}pdf_viewer_assertClassBrand(nP,this,_scrollIntoView).call(this,d,{left:b,top:S})}_updateLocation(e){const t=this._currentScale,i=this._currentScaleValue,a=parseFloat(i)===t?Math.round(1e4*t)/100:i,s=e.id,r=this._pages[s-1],n=this.container;let o,l;if("infinite-scroll"===this.pageViewMode){const e=n.getBoundingClientRect();pdf_viewer_classPrivateFieldGet(Zy,this)||pdf_viewer_classPrivateFieldSet(Zy,this,pdf_viewer_assertClassBrand(nP,this,_findAncestorWithScrollbar).call(this,this.container));const t=pdf_viewer_classPrivateFieldGet(Zy,this);if(t){const i=t.getBoundingClientRect();o=i.left-e.left;l=i.top-e.top}else{o=-e.left;l=-e.top}}else{o=n.scrollLeft;l=n.scrollTop}const c=r.getPagePoint(o-e.x,l-e.y),d=Math.round(c[0]),h=Math.round(c[1]);let u=`#page=${s}`;this.isInPresentationMode||(u+=`&zoom=${a},${d},${h}`);this._location={pageNumber:s,scale:a,top:h,left:d,rotation:this._pagesRotation,pdfOpenParams:u}}update(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.scrollMode===ph.PAGE?this.viewer.classList.add("singlePageView"):this.viewer.classList.remove("singlePageView");const t=this._getVisiblePages(),i=t.views,a=i.length;if(0===a)return;const s=this.defaultCacheSize||10,r=Math.max(s,2*a+1);pdf_viewer_classPrivateFieldGet(vy,this).resize(r,t.ids);for(const e of i){const t=e.view,i=e.visibleArea;t.updateVisibleArea(i)}for(const e of pdf_viewer_classPrivateFieldGet(vy,this))t.ids.has(e.id)||e.updateVisibleArea(null);this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===gh.NONE&&(this._scrollMode===ph.PAGE||this._scrollMode===ph.VERTICAL),o=this._currentPageNumber;let l=!1;for(const e of i){if(e.percent<100)break;if(e.id===o&&n){l=!0;break}}const c="infinite-scroll"===this.pageViewMode&&Date.now()-pdf_viewer_classPrivateFieldGet(Jy,this)<500;this.scrollMode===ph.PAGE||e||c||this._setCurrentPageNumber(l?this._currentPageNumber:i[0].id);this._updateLocation(t.first);this.eventBus.dispatch("updateviewarea",{source:this,location:this._location});this.hidePagesDependingOnpageViewMode()}async updateBookModeScale(e){if("book"===this.pageViewMode&&this.pageFlip&&e.scale&&e.scale!==e.previousScale){const t=this._pages[0];if(t.pdfPage){const e=t.width,i=t.height,a=t.div.parentElement,s=this.removePageBorders?1:40;a.style.width=`${2*e+s}px`;a.style.height=`${i}px`;this.pageFlip.render.setting.width=e;this.pageFlip.render.setting.height=i;this.pageFlip.render.update()}if(this._enableFlipByDrag){let i=40,a=5;this.removePageBorders&&(i=a=0);const s=(this.container.clientWidth-i)/t.width*t.scale/2,r=(this.container.clientHeight-a)/t.height*t.scale,n=Math.min(s,r),o=e.scale>n+.01;this.pageFlip.setting.enableFlipByDrag=!o}}}set enableFlipByDrag(e){this._enableFlipByDrag=e;this.pageFlip&&(this.pageFlip.setting.enableFlipByDrag=e)}get enableFlipByDrag(){return this._enableFlipByDrag}containsElement(e){return this.container.contains(e)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===sh}get isChangingPresentationMode(){return this.presentationModeState===ah}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){const e=this._scrollMode===ph.PAGE?pdf_viewer_classPrivateFieldGet(Hy,this).pages:this._pages,t=this._scrollMode===ph.HORIZONTAL,i=t&&this._isContainerRtl;return this._isContainerRtl&&(t||this._scrollMode===ph.WRAPPED)?this._getVisiblePagesRtl(e):"infinite-scroll"===this.pageViewMode?pdf_viewer_assertClassBrand(nP,this,_getVisiblePagesInfiniteScroll).call(this,e):getVisibleElements({scrollEl:this.container,views:e,sortByVisibility:!0,horizontal:t,rtl:i})}_getVisiblePagesRtl(e){const t=this.container.getBoundingClientRect(),i=[],a=new Set;for(const s of e){const e=s.div.getBoundingClientRect(),r=Math.max(e.left,t.left),n=Math.min(e.right,t.right),o=Math.max(e.top,t.top),l=Math.min(e.bottom,t.bottom),c=Math.max(0,n-r),d=Math.max(0,l-o);if(0===c||0===d)continue;const h=c/e.width,u=h*(d/e.height)*100|0;i.push({id:s.id,x:e.left-t.left,y:e.top-t.top,view:s,percent:u,widthPercent:100*h|0});a.add(s.id)}i.sort((e,t)=>t.x-e.x);return{first:i[0],last:i.at(-1),views:i,ids:a}}cleanup(){for(const e of this._pages)e.renderingState!==Ff.FINISHED&&e.reset()}_cancelRendering(){for(const e of this._pages)e.cancelRendering()}forceRendering(e){const t=e||this._getVisiblePages(),i=pdf_viewer_assertClassBrand(nP,this,pdf_viewer_getScrollAhead).call(this,t),a=this._spreadMode!==gh.NONE&&this._scrollMode!==ph.HORIZONTAL,s=null!==pdf_viewer_classPrivateFieldGet(zy,this)||null!==pdf_viewer_classPrivateFieldGet(Oy,this)&&t.views.some(e=>e.detailView?.renderingCancelled),r=this.renderingQueue.getHighestPriority(t,this._pages,i,a,s);if(r){pdf_viewer_assertClassBrand(nP,this,pdf_viewer_ensurePdfPageLoaded).call(this,r).then(()=>{this.renderingQueue.renderView(r)});return!0}return!1}get hasEqualPageSizes(){const e=this._pages[0];for(let t=1,i=this._pages.length;t<i;++t){const i=this._pages[t];if(i.width!==e.width||i.height!==e.height)return!1}return!0}getPagesOverview(){let e;return this._pages.map(t=>{const i=t.pdfPage.getViewport({scale:1}),a=isPortraitOrientation(i);if(void 0===e)e=a;else if(this.enablePrintAutoRotate&&a!==e)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}})}get optionalContentConfigPromise(){if(!this.pdfDocument)return Promise.resolve(null);if(!this._optionalContentConfigPromise){ngx_console_NgxConsole.error("optionalContentConfigPromise: Not initialized yet.");return this.pdfDocument.getOptionalContentConfig({intent:"display"})}return this._optionalContentConfigPromise}set optionalContentConfigPromise(e){if(!(e instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${e}`);if(this.pdfDocument&&this._optionalContentConfigPromise){this._optionalContentConfigPromise=e;this.refresh(!1,{optionalContentConfigPromise:e});this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:e})}}get scrollMode(){return this._scrollMode}set scrollMode(e){if(this._scrollMode!==e){if(!isValidScrollMode(e))throw new Error(`Invalid scroll mode: ${e}`);if(!(this.pagesCount>uy)){this._previousScrollMode=this._scrollMode;this.clearSelection();this._scrollMode=e;this.eventBus.dispatch("scrollmodechanged",{source:this,mode:e});if(e===ph.PAGE&&"infinite-scroll"===pdf_viewer_classPrivateFieldGet(Qy,this)){pdf_viewer_classPrivateFieldSet(Qy,this,"single");this.hidePagesDependingOnpageViewMode();queueMicrotask(()=>{this.eventBus.dispatch("pageviewmodechanged",{source:this,mode:pdf_viewer_classPrivateFieldGet(Qy,this)})})}this._updateScrollMode(this._currentPageNumber)}}}_updateScrollMode(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",t===ph.HORIZONTAL);i.classList.toggle("scrollWrapped",t===ph.WRAPPED);if(this.pdfDocument&&e){t===ph.PAGE?pdf_viewer_assertClassBrand(nP,this,_ensurePageViewVisible).call(this):this._previousScrollMode===ph.PAGE&&this._updateSpreadMode();this._currentScaleValue&&isNaN(this._currentScaleValue)&&pdf_viewer_assertClassBrand(nP,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});this._setCurrentPageNumber(e,!0);this.update()}}get spreadMode(){return this._spreadMode}set spreadMode(e){if(this._spreadMode!==e){if(!isValidSpreadMode(e))throw new Error(`Invalid spread mode: ${e}`);this.clearSelection();this._spreadMode=e;this.eventBus.dispatch("spreadmodechanged",{source:this,mode:e});this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!this.pdfDocument)return;const t=this.viewer,i=this._pages;if(this._scrollMode===ph.PAGE)pdf_viewer_assertClassBrand(nP,this,_ensurePageViewVisible).call(this);else{t.textContent="";if(this._spreadMode===gh.NONE)for(const e of this._pages)t.append(e.div);else{const e=this._spreadMode-1;let a=null;for(let s=0,r=i.length;s<r;++s){if(null===a){a=document.createElement("div");a.className="spread";t.append(a)}else if(s%2===e){a=a.cloneNode(!1);t.append(a)}a.append(i[s].div)}}}this.hidePagesDependingOnpageViewMode();if(e){this._currentScaleValue&&isNaN(this._currentScaleValue)&&pdf_viewer_assertClassBrand(nP,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});this._setCurrentPageNumber(e,!0);this.update()}}nextPage(){const e=this._currentPageNumber,t=this.pagesCount;if(e>=t)return!1;const i=pdf_viewer_assertClassBrand(nP,this,_getPageAdvance).call(this,e,!1)||1;this.currentPageNumber=Math.min(e+i,t);return!0}previousPage(){const e=this._currentPageNumber;if(e<=1)return!1;const t=pdf_viewer_assertClassBrand(nP,this,_getPageAdvance).call(this,e,!0)||1;this.currentPageNumber=Math.max(e-t,1);return!0}updateScale(e){let t=e.drawingDelay,i=e.scaleFactor,a=void 0===i?null:i,s=e.steps,r=void 0===s?null:s,n=e.origin;if(null===r&&null===a)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let o=this._currentScale;if(a>0&&1!==a)o=Math.round(o*a*1e3)/1e3;else if(r){const e=r>0?1.1:1/1.1,t=r>0?Math.ceil:Math.floor;r=Math.abs(r);do{o=t(10*(o*e).toFixed(2))/10}while(--r>0)}o=MathClamp(o,Number(this.minZoom)??eh,Number(this.maxZoom)??25);pdf_viewer_assertClassBrand(nP,this,_setScale).call(this,o,{noScroll:!1,drawingDelay:t,origin:n})}increaseScale(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.updateScale({...e,steps:e.steps??1})}decreaseScale(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.updateScale({...e,steps:-(e.steps??1)})}get containerTopLeft(){return pdf_viewer_classPrivateFieldGet(Cy,this)||pdf_viewer_classPrivateFieldSet(Cy,this,[this.container.offsetTop,this.container.offsetLeft])}get annotationEditorMode(){return pdf_viewer_classPrivateFieldGet(by,this)?pdf_viewer_classPrivateFieldGet(wy,this):P.DISABLE}set annotationEditorMode(e){let t=e.mode,i=e.editId,a=void 0===i?null:i,s=e.isFromKeyboard,r=void 0!==s&&s,n=e.mustEnterInEditMode,o=void 0!==n&&n,l=e.editComment,c=void 0!==l&&l;if(!pdf_viewer_classPrivateFieldGet(by,this))throw new Error("The AnnotationEditor is not enabled.");if(pdf_viewer_classPrivateFieldGet(wy,this)===t)return;if(!isValidAnnotationEditorMode(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;pdf_viewer_assertClassBrand(nP,this,_preloadEditingData).call(this,t);const d=this.eventBus,h=this.pdfDocument,updater=async()=>{pdf_viewer_assertClassBrand(nP,this,_cleanupSwitchAnnotationEditorMode).call(this);pdf_viewer_classPrivateFieldSet(wy,this,t);await pdf_viewer_classPrivateFieldGet(by,this).updateMode(t,a,!0,r,o,c);t===pdf_viewer_classPrivateFieldGet(wy,this)&&h===this.pdfDocument&&d.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===P.NONE||pdf_viewer_classPrivateFieldGet(wy,this)===P.NONE){const e=t!==P.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds();this.cleanup();for(const t of this._pages)t.toggleEditingMode(e);const i=pdf_viewer_assertClassBrand(nP,this,_switchToEditAnnotationMode).call(this);if(e&&i){pdf_viewer_assertClassBrand(nP,this,_cleanupSwitchAnnotationEditorMode).call(this);pdf_viewer_classPrivateFieldSet(Ry,this,new AbortController);const e=AbortSignal.any([pdf_viewer_classPrivateFieldGet(By,this).signal,pdf_viewer_classPrivateFieldGet(Ry,this).signal]);d.on("pagerendered",e=>{let t=e.pageNumber;i.delete(t);0===i.size&&pdf_viewer_classPrivateFieldSet(Ny,this,setTimeout(updater,0))},{signal:e,...Ih});return}}updater()}refresh(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Object.create(null);if(this.pdfDocument){for(const e of this._pages)e.update(t);pdf_viewer_assertClassBrand(nP,this,_cleanupTimeouts).call(this);e||this.update()}}getSerializedAnnotations(){const e=this.pdfDocument.annotationStorage;if(0===e.size)return null;const t=[];for(const a of e){var i=pdf_viewer_slicedToArray(a,2);i[0];const e=i[1];if(e&&"function"==typeof e.serialize){const i=e.serialize(!0,null,!0);i&&void 0!==i.annotationType&&t.push(i)}}return t.length>0?t:null}async addEditorAnnotation(e){try{"string"==typeof e&&(e=JSON.parse(e))}catch(e){ngx_console_NgxConsole.error(`Please pass a JSON string or an Array of JSON objects to addEditorAnnotation: "${e.message}".`);return}Array.isArray(e)||(e=[e]);const convertArrayLikeObjectToArray=e=>{if(!e||"object"!=typeof e||Array.isArray(e))return e;const t=Object.keys(e);if(t.length>0&&t.every(e=>/^\d+$/.test(e))){const i=[];for(let a=0;a<t.length;a++)i[a]=e[a];return i}return e};let t=!1;e?.forEach(e=>{e.isCopy=!0;if(15===e.annotationType&&e.paths){if(e.paths.lines){const i=e.paths.lines.map(convertArrayLikeObjectToArray);if(i.some((t,i)=>t!==e.paths.lines[i])){t=!0;e.paths.lines=i}}if(e.paths.points){const i=e.paths.points.map(convertArrayLikeObjectToArray);if(i.some((t,i)=>t!==e.paths.points[i])){t=!0;e.paths.points=i}}}});t&&ngx_console_NgxConsole.warn("Detected and converted legacy ink annotation format (object-with-numeric-keys) to arrays. This format was used in ngx-extended-pdf-viewer versions 22.x - 25.5.x. Please re-export or convert your annotations to use the correct format. The objects with numeric keys were always meant to be arrays.");await pdf_viewer_classPrivateFieldGet(by,this).addSerializedEditor(e,!0,!0,!1)}removeEditorAnnotations(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:()=>!0;pdf_viewer_classPrivateFieldGet(by,this).removeEditors(e)}destroyBookMode(){if(this.pageFlip){this.pageFlip.destroy();this.pageFlip=null}}stopRendering(){this._cancelRendering()}}function _findAncestorWithScrollbar(e){let t=e?.parentElement;for(;t;){if(t===document.body||t===document.documentElement)return null;const e=getComputedStyle(t).overflowY;if(("auto"===e||"scroll"===e)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function _initOuterScrollListener(){if(!pdf_viewer_classPrivateFieldGet(oP,this)){pdf_viewer_classPrivateFieldSet(oP,this,!0);document.addEventListener("scroll",e=>{const t=e.target;(t===document||t===document.documentElement||t===document.body||t?.contains?.(this.container))&&this._scrollUpdate()},{capture:!0});window.addEventListener("scroll",()=>this._scrollUpdate())}}function _initializePermissions(e){const t={annotationEditorMode:pdf_viewer_classPrivateFieldGet(wy,this),annotationMode:pdf_viewer_classPrivateFieldGet(Fy,this),textLayerMode:pdf_viewer_classPrivateFieldGet(Yy,this)};if(!e){pdf_viewer_classPrivateFieldSet(Ly,this,!0);this.eventBus.dispatch("printingallowed",{source:this,isAllowed:pdf_viewer_classPrivateFieldGet(Ly,this)});return t}pdf_viewer_classPrivateFieldSet(Ly,this,e.includes(b.PRINT_HIGH_QUALITY)||e.includes(b.PRINT));this.eventBus.dispatch("printingallowed",{source:this,isAllowed:pdf_viewer_classPrivateFieldGet(Ly,this)});e.includes(b.COPY)||pdf_viewer_classPrivateFieldGet(Yy,this)!==uh||(t.textLayerMode=_h);e.includes(b.MODIFY_CONTENTS)||(t.annotationEditorMode=P.DISABLE);e.includes(b.MODIFY_ANNOTATIONS)||e.includes(b.FILL_INTERACTIVE_FORMS)||pdf_viewer_classPrivateFieldGet(Fy,this)!==m.ENABLE_FORMS||(t.annotationMode=m.ENABLE);return t}async function _onePageRenderedOrForceFetch(e){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return;const t=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&t.resolve()},{signal:AbortSignal.any([e,i.signal])});await Promise.race([this._onePageRenderedCapability.promise,t.promise]);i.abort()}function _copyCallback(e,t){const i=document.getSelection(),a=i.focusNode;if(i.anchorNode&&a&&i.containsNode(pdf_viewer_classPrivateFieldGet(Wy,this))){if(pdf_viewer_classPrivateFieldGet(jy,this)||e===_h){stopEvent(t);return}pdf_viewer_classPrivateFieldSet(jy,this,!0);const i=this.viewer.classList;i.add("copyAll");const a=new AbortController,s=new AbortController;window.addEventListener("keydown",e=>{"Escape"===e.key&&s.abort()},{signal:a.signal});this.getAllText(s.signal).then(async e=>{null!==e&&await navigator.clipboard.writeText(e)}).catch(e=>{ngx_console_NgxConsole.warn(`Something goes wrong when extracting the text: ${e.message}`)}).finally(()=>{pdf_viewer_classPrivateFieldSet(jy,this,!1);a.abort();i.remove("copyAll")});stopEvent(t)}}function _ensurePageViewVisible(){if(this._scrollMode!==ph.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const e=this._currentPageNumber,t=pdf_viewer_classPrivateFieldGet(Hy,this),i=this.viewer;i.textContent="";t.pages.length=0;if(this._spreadMode!==gh.NONE||this.isInPresentationMode){const a=new Set,s=this._spreadMode-1;if(-1===s)a.add(e-1);else if(e%2!==s){a.add(e-1);a.add(e)}else{a.add(e-2);a.add(e-1)}const r=document.createElement("div");r.className="spread";if(this.isInPresentationMode){const e=document.createElement("div");e.className="dummyPage";r.append(e)}for(const e of a){const i=this._pages[e];if(i){r.append(i.div);t.pages.push(i)}}i.append(r)}else{const a=this._pages[e-1];i.append(a.div);t.pages.push(a)}t.scrollDown=e>=t.previousPageNumber;t.previousPageNumber=e}function _scrollIntoView(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e)return;"infinite-scroll"===this.pageViewMode&&pdf_viewer_classPrivateFieldSet(Jy,this,Date.now());const i=e.div,a=e.id;this._currentPageNumber!==a&&this._setCurrentPageNumber(a);if(this._scrollMode===ph.PAGE){pdf_viewer_assertClassBrand(nP,this,_ensurePageViewVisible).call(this);this.update()}if(!t&&!this.isInPresentationMode){const e=i.offsetLeft+i.clientLeft,a=e+i.clientWidth,s=this.container,r=s.scrollLeft,n=s.clientWidth;(this._scrollMode===ph.HORIZONTAL||e<r||a>r+n)&&(t={left:0,top:0})}!this._isContainerRtl||this._scrollMode!==ph.HORIZONTAL&&this._scrollMode!==ph.WRAPPED?scrollIntoView(i,t,!1,"infinite-scroll"===this.pageViewMode):i.scrollIntoView({block:"nearest",inline:"end"});!this._currentScaleValue&&this._location&&(this._location=null)}function _isSameScale(e){return e===this._currentScale||Math.abs(e-this._currentScale)<1e-15}function _setScaleUpdatePages(e,t,i){let a=i.noScroll,s=void 0!==a&&a,r=i.preset,n=void 0!==r&&r,o=i.drawingDelay,l=void 0===o?-1:o,c=i.origin,d=void 0===c?null:c;const h=isNaN(Number(this.currentScale))?void 0:Number(this.currentScale),u=this.currentScaleValue;this.clearSelection();this._currentScaleValue=t.toString();if(pdf_viewer_assertClassBrand(nP,this,_isSameScale).call(this,e)){n&&this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:t,previousScale:h,previousPresetValue:u,noScroll:s});return}const _=l>=0&&l<1e3;this.viewer.style.setProperty("--scale-factor",e*PixelsPerInch.PDF_TO_CSS_UNITS);this.refresh(!0,{scale:e,drawingDelay:_?l:-1});if(_){if(!pdf_viewer_classPrivateFieldGet($y,this)&&this._location){pdf_viewer_classPrivateFieldSet($y,this,{...this._location});pdf_viewer_classPrivateFieldSet(qy,this,h)}null!==pdf_viewer_classPrivateFieldGet(zy,this)&&clearTimeout(pdf_viewer_classPrivateFieldGet(zy,this));pdf_viewer_classPrivateFieldSet(zy,this,setTimeout(()=>{pdf_viewer_classPrivateFieldSet(zy,this,null);pdf_viewer_classPrivateFieldSet($y,this,null);pdf_viewer_classPrivateFieldSet(qy,this,null);const e=Math.round(100*this._currentScale)/100;e===this._currentScale?this.refresh():pdf_viewer_assertClassBrand(nP,this,_setScale).call(this,e,{noScroll:!0,drawingDelay:-1})},l))}this._currentScale=e;if(!s)if("infinite-scroll"===this.pageViewMode){pdf_viewer_classPrivateFieldGet(Zy,this)||pdf_viewer_classPrivateFieldSet(Zy,this,pdf_viewer_assertClassBrand(nP,this,_findAncestorWithScrollbar).call(this,this.container));const t=pdf_viewer_classPrivateFieldGet(Zy,this),i=e/h;if(t){const e=this.container.getBoundingClientRect();if(Array.isArray(d)){t.scrollTop+=(i-1)*(d[1]-e.top);t.scrollLeft+=(i-1)*(d[0]-e.left)}else{const a=t.getBoundingClientRect();t.scrollTop+=(i-1)*(a.top-e.top);t.scrollLeft+=(i-1)*(a.left-e.left)}}else{const e=this.container.getBoundingClientRect();if(Array.isArray(d)){const t=i-1;window.scrollBy(t*(d[0]-e.left),t*(d[1]-e.top))}else{const t=i-1;window.scrollBy(t*(0-e.left),t*(0-e.top))}}}else{const t=this.container,i=pdf_viewer_classPrivateFieldGet($y,this)||this._location;let a,s=this._currentPageNumber;if(i&&!this.isInPresentationMode&&!this.isChangingPresentationMode){s=i.pageNumber;a=[null,{name:"XYZ"},i.left,i.top,null]}this.scrollPageIntoView({pageNumber:s,destArray:a,allowNegativeOffset:!0});if(Array.isArray(d)){const i=e/(pdf_viewer_classPrivateFieldGet(qy,this)||h)-1,a=t.getBoundingClientRect();t.scrollLeft+=(d[0]-a.left)*i;t.scrollTop+=(d[1]-a.top)*i}}this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:n?t:void 0,previousScale:h,previousPresetValue:u,noScroll:s});this.defaultRenderingQueue&&this.update()}function _get_pageWidthScaleFactor(e){return e._spreadMode!==gh.NONE&&e._scrollMode!==ph.HORIZONTAL?2:1}function _setScale(e,t){e||(e="auto");this.maxZoom&&this.maxZoom===this.minZoom&&(e=this.maxZoom);let i=parseFloat(e);if(this._currentScale!==i)if(i>0){t.preset=!1;pdf_viewer_assertClassBrand(nP,this,_setScaleUpdatePages).call(this,i,e,t)}else{const s=this._pages[this._currentPageNumber-1];if(!s)return;let r=40,n=5;if(this.isInPresentationMode){r=n=4;this._spreadMode!==gh.NONE&&(r*=2)}else if(this.removePageBorders)r=n=0;else if(this._scrollMode===ph.HORIZONTAL){var a=[n,r];r=a[0];n=a[1]}let o=(this.container.clientWidth-r)/s.width*s.scale/function pdf_viewer_classPrivateGetter(e,t,i){return i(pdf_viewer_assertClassBrand(e,t))}(nP,this,_get_pageWidthScaleFactor);"book"===this.pageViewMode&&(o/=2);const l=(this.container.clientHeight-n)/s.height*s.scale;switch(e){case"page-actual":i=1;break;case"page-width":i=o;break;case"page-height":i=l;break;case"page-fit":i=Math.min(o,l);break;case"auto":const t=isPortraitOrientation(s)?o:Math.min(l,o);i=Math.min(1.25,t);break;default:ngx_console_NgxConsole.error(`#setScale: "${e}" is an unknown zoom value.`);return}t.preset=!0;pdf_viewer_assertClassBrand(nP,this,_setScaleUpdatePages).call(this,i,e,t)}}function _resetCurrentPageView(){const e=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&pdf_viewer_assertClassBrand(nP,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});pdf_viewer_assertClassBrand(nP,this,_scrollIntoView).call(this,e)}function _switchToEditAnnotationMode(){const e=this._getVisiblePages(),t=[],i=e.ids,a=e.views;for(const e of a){const a=e.view;a.hasEditableAnnotations()?t.push(e):i.delete(a.id)}if(0===t.length)return null;this.renderingQueue.renderHighestPriority({first:t[0],last:t.at(-1),views:t,ids:i});return i}function _getVisiblePagesInfiniteScroll(e){pdf_viewer_classPrivateFieldGet(Zy,this)||pdf_viewer_classPrivateFieldSet(Zy,this,pdf_viewer_assertClassBrand(nP,this,_findAncestorWithScrollbar).call(this,this.container));const t=pdf_viewer_classPrivateFieldGet(Zy,this);let i;i=t?t.getBoundingClientRect():{top:0,left:0,bottom:window.innerHeight,right:window.innerWidth};const a=[],s=new Set;for(const t of e){const e=t.div,r=e.getBoundingClientRect(),n=Math.max(r.left,i.left),o=Math.min(r.right,i.right),l=Math.max(r.top,i.top),c=Math.min(r.bottom,i.bottom),d=Math.max(0,o-n),h=Math.max(0,c-l);if(0===d||0===h)continue;const u=d/r.width,_=u*(h/r.height)*100|0,p=Math.max(0,i.left-r.left),g=Math.max(0,i.top-r.top),f=Math.min(r.width,i.right-r.left),m=Math.min(r.height,i.bottom-r.top);a.push({id:t.id,x:e.offsetLeft+e.clientLeft,y:e.offsetTop+e.clientTop,visibleArea:100===_?null:{minX:p,minY:g,maxX:f,maxY:m},view:t,percent:_,widthPercent:100*u|0});s.add(t.id)}a.sort((e,t)=>{const i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id});return{first:a[0],last:a.at(-1),views:a,ids:s}}async function pdf_viewer_ensurePdfPageLoaded(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);e.pdfPage||e.setPdfPage(t);return t}catch(e){ngx_console_NgxConsole.error("Unable to get page for page view",e);return null}}function pdf_viewer_getScrollAhead(e){if(1===e.first?.id)return!0;if(e.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case ph.PAGE:return pdf_viewer_classPrivateFieldGet(Hy,this).scrollDown;case ph.HORIZONTAL:return this.scroll.right}return this.scroll.down}function _getPageAdvance(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("book"===this.pageViewMode)return 2;switch(this._scrollMode){case ph.WRAPPED:{const i=this._getVisiblePages().views,a=new Map;for(const e of i){const t=e.id,i=e.y,s=e.percent,r=e.widthPercent;0===s||r<100||a.getOrInsertComputed(i,makeArr).push(t)}for(const i of a.values()){const a=i.indexOf(e);if(-1===a)continue;const s=i.length;if(1===s)break;if(t)for(let t=a-1,s=0;t>=s;t--){const a=i[t],s=i[t+1]-1;if(a<s)return e-s}else for(let t=a+1,r=s;t<r;t++){const a=i[t],s=i[t-1]+1;if(a>s)return s-e}if(t){const t=i[0];if(t<e)return e-t+1}else{const t=i[s-1];if(t>e)return t-e+1}break}break}case ph.HORIZONTAL:break;case ph.PAGE:case ph.VERTICAL:{if(this._spreadMode===gh.NONE)break;const i=this._spreadMode-1;if(t&&e%2!==i)break;if(!t&&e%2===i)break;const a=this._getVisiblePages().views,s=t?e-1:e+1;for(const e of a){const t=e.id,i=e.percent,a=e.widthPercent;if(t===s){if(i>0&&100===a)return 2;break}}break}}return 1}function _updateContainerHeightCss(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.container.clientHeight;if(e!==pdf_viewer_classPrivateFieldGet(Uy,this)){pdf_viewer_classPrivateFieldSet(Uy,this,e);Fh.setProperty("--viewer-container-height",`${e}px`)}}function pdf_viewer_resizeObserverCallback(e){for(const t of e)if(t.target===this.container){pdf_viewer_assertClassBrand(nP,this,_updateContainerHeightCss).call(this,Math.floor(t.borderBoxSize[0].blockSize));pdf_viewer_classPrivateFieldSet(Cy,this,null);break}}function _cleanupTimeouts(){if(null!==pdf_viewer_classPrivateFieldGet(zy,this)){clearTimeout(pdf_viewer_classPrivateFieldGet(zy,this));pdf_viewer_classPrivateFieldSet(zy,this,null)}if(null!==pdf_viewer_classPrivateFieldGet(Oy,this)){clearTimeout(pdf_viewer_classPrivateFieldGet(Oy,this));pdf_viewer_classPrivateFieldSet(Oy,this,null)}}function _cleanupSwitchAnnotationEditorMode(){pdf_viewer_classPrivateFieldGet(Ry,this)?.abort();pdf_viewer_classPrivateFieldSet(Ry,this,null);if(null!==pdf_viewer_classPrivateFieldGet(Ny,this)){clearTimeout(pdf_viewer_classPrivateFieldGet(Ny,this));pdf_viewer_classPrivateFieldSet(Ny,this,null)}}function _preloadEditingData(e){switch(e){case P.STAMP:pdf_viewer_classPrivateFieldGet(Dy,this)?.loadModel("altText");break;case P.SIGNATURE:pdf_viewer_classPrivateFieldGet(Xy,this)?.loadSignatures()}}function secondary_toolbar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function secondary_toolbar_classPrivateFieldGet(e,t){return e.get(secondary_toolbar_assertClassBrand(e,t))}function secondary_toolbar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var lP=new WeakMap,cP=new WeakSet;class SecondaryToolbar{constructor(e,t){!function secondary_toolbar_classPrivateMethodInitSpec(e,t){secondary_toolbar_checkPrivateRedeclaration(e,t),t.add(e)}(this,cP);!function secondary_toolbar_classPrivateFieldInitSpec(e,t,i){secondary_toolbar_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,lP,void 0);!function secondary_toolbar_classPrivateFieldSet(e,t,i){return e.set(secondary_toolbar_assertClassBrand(e,t),i),i}(lP,this,e);const i=[{element:e.presentationModeButton,eventName:"presentationmode",close:!0},{element:e.printButton,eventName:"print",close:!0},{element:e.downloadButton,eventName:"download",close:!0},{element:e.viewBookmarkButton,eventName:null,close:!0},{element:e.firstPageButton,eventName:"firstpage",close:!0},{element:e.lastPageButton,eventName:"lastpage",close:!0},{element:e.pageRotateCwButton,eventName:"rotatecw",close:!1},{element:e.pageRotateCcwButton,eventName:"rotateccw",close:!1},{element:e.cursorSelectToolButton,eventName:"switchcursortool",eventDetails:{tool:fh},close:!0},{element:e.cursorHandToolButton,eventName:"switchcursortool",eventDetails:{tool:mh},close:!0},{element:e.scrollPageButton,eventName:"switchscrollmode",eventDetails:{mode:ph.PAGE},close:!0},{element:e.scrollVerticalButton,eventName:"switchscrollmode",eventDetails:{mode:ph.VERTICAL},close:!0},{element:e.scrollHorizontalButton,eventName:"switchscrollmode",eventDetails:{mode:ph.HORIZONTAL},close:!0},{element:e.scrollWrappedButton,eventName:"switchscrollmode",eventDetails:{mode:ph.WRAPPED},close:!0},{element:e.spreadNoneButton,eventName:"switchspreadmode",eventDetails:{mode:gh.NONE},close:!0},{element:e.spreadOddButton,eventName:"switchspreadmode",eventDetails:{mode:gh.ODD},close:!0},{element:e.spreadEvenButton,eventName:"switchspreadmode",eventDetails:{mode:gh.EVEN},close:!0},{element:e.imageAltTextSettingsButton,eventName:"imagealttextsettings",close:!0},{element:e.documentPropertiesButton,eventName:"documentproperties",close:!0}];i.push({element:e.openFileButton,eventName:"openfile",close:!0});this.eventBus=t;this.opened=!1;secondary_toolbar_assertClassBrand(cP,this,secondary_toolbar_bindListeners).call(this,i);this.reset()}get isOpen(){return this.opened}setPageNumber(e){this.pageNumber=e;secondary_toolbar_assertClassBrand(cP,this,secondary_toolbar_updateUIState).call(this)}setPagesCount(e){this.pagesCount=e;secondary_toolbar_assertClassBrand(cP,this,secondary_toolbar_updateUIState).call(this)}reset(){this.pageNumber=0;this.pagesCount=0;secondary_toolbar_assertClassBrand(cP,this,secondary_toolbar_updateUIState).call(this);this.eventBus.dispatch("switchcursortool",{source:this,reset:!0});secondary_toolbar_assertClassBrand(cP,this,_scrollModeChanged).call(this,{mode:ph.VERTICAL});secondary_toolbar_assertClassBrand(cP,this,_spreadModeChanged).call(this,{mode:gh.NONE})}open(){if(this.opened)return;this.eventBus.dispatch("closeopenpopovers",{source:this});this.opened=!0;const e=secondary_toolbar_classPrivateFieldGet(lP,this);toggleExpandedBtn(e.toggleButton,!0,e.toolbar)}close(){if(!this.opened)return;this.opened=!1;const e=secondary_toolbar_classPrivateFieldGet(lP,this);toggleExpandedBtn(e.toggleButton,!1,e.toolbar)}toggle(){this.opened?this.close():this.open()}}function secondary_toolbar_updateUIState(){const e=secondary_toolbar_classPrivateFieldGet(lP,this),t=e.firstPageButton,i=e.lastPageButton,a=e.pageRotateCwButton,s=e.pageRotateCcwButton;t.disabled=this.pageNumber<=1;i.disabled=this.pageNumber>=this.pagesCount;a.disabled=0===this.pagesCount;s.disabled=0===this.pagesCount}function secondary_toolbar_bindListeners(e){const t=this.eventBus;secondary_toolbar_classPrivateFieldGet(lP,this).toggleButton.addEventListener("click",this.toggle.bind(this));for(const i of e){const e=i.element,a=i.eventName,s=i.close,r=i.eventDetails;e&&e.addEventListener("click",i=>{null!==a&&t.dispatch(a,{source:this,...r});s&&this.close();t.dispatch("reporttelemetry",{source:this,details:{type:"buttons",data:{id:e.id}}})})}t._on("cursortoolchanged",secondary_toolbar_assertClassBrand(cP,this,_cursorToolChanged).bind(this));t._on("scrollmodechanged",secondary_toolbar_assertClassBrand(cP,this,_scrollModeChanged).bind(this));t._on("spreadmodechanged",secondary_toolbar_assertClassBrand(cP,this,_spreadModeChanged).bind(this));t._on("closeopenpopovers",e=>{e.source!==this&&this.close()})}function _cursorToolChanged(e){let t=e.tool,i=e.disabled;const a=secondary_toolbar_classPrivateFieldGet(lP,this),s=a.cursorSelectToolButton,r=a.cursorHandToolButton;toggleCheckedBtn(s,t===fh);toggleCheckedBtn(r,t===mh);s.disabled=i;r.disabled=i}function _scrollModeChanged(e){let t=e.mode;const i=secondary_toolbar_classPrivateFieldGet(lP,this),a=i.scrollPageButton,s=i.scrollVerticalButton,r=i.scrollHorizontalButton,n=i.scrollWrappedButton,o=i.spreadNoneButton,l=i.spreadOddButton,c=i.spreadEvenButton;toggleCheckedBtn(a,t===ph.PAGE);toggleCheckedBtn(s,t===ph.VERTICAL);toggleCheckedBtn(r,t===ph.HORIZONTAL);toggleCheckedBtn(n,t===ph.WRAPPED);const d=this.pagesCount>uy;a.disabled=d;s.disabled=d;r.disabled=d;n.disabled=d;const h=t===ph.HORIZONTAL;o.disabled=h;l.disabled=h;c.disabled=h}function _spreadModeChanged(e){let t=e.mode;const i=secondary_toolbar_classPrivateFieldGet(lP,this),a=i.spreadNoneButton,s=i.spreadOddButton,r=i.spreadEvenButton;toggleCheckedBtn(a,t===gh.NONE);toggleCheckedBtn(s,t===gh.ODD);toggleCheckedBtn(r,t===gh.EVEN)}function signature_manager_slicedToArray(e,t){return function signature_manager_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function signature_manager_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function signature_manager_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return signature_manager_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?signature_manager_arrayLikeToArray(e,t):void 0}}(e,t)||function signature_manager_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function signature_manager_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}function signature_manager_classPrivateMethodInitSpec(e,t){signature_manager_checkPrivateRedeclaration(e,t),t.add(e)}function signature_manager_classPrivateFieldInitSpec(e,t,i){signature_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function signature_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function signature_manager_classPrivateFieldGet(e,t){return e.get(signature_manager_assertClassBrand(e,t))}function signature_manager_classPrivateFieldSet(e,t,i){return e.set(signature_manager_assertClassBrand(e,t),i),i}function signature_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var dP=new WeakMap,hP=new WeakMap,uP=new WeakMap,_P=new WeakMap,pP=new WeakMap,gP=new WeakMap,fP=new WeakMap,mP=new WeakMap,vP=new WeakMap,yP=new WeakMap,PP=new WeakMap,wP=new WeakMap,bP=new WeakMap,FP=new WeakMap,SP=new WeakMap,CP=new WeakMap,AP=new WeakMap,xP=new WeakMap,kP=new WeakMap,EP=new WeakMap,TP=new WeakMap,IP=new WeakMap,GP=new WeakMap,BP=new WeakMap,MP=new WeakMap,DP=new WeakMap,LP=new WeakMap,OP=new WeakMap,RP=new WeakMap,NP=new WeakMap,jP=new WeakMap,WP=new WeakMap,UP=new WeakMap,VP=new WeakMap,HP=new WeakMap,zP=new WeakMap,$P=new WeakMap,qP=new WeakMap,XP=new WeakMap,KP=new WeakSet;class SignatureManager{constructor(e,t,i,a,s,r,n){let o=e.dialog,l=e.panels,c=e.typeButton,d=e.typeInput,h=e.drawButton,u=e.drawPlaceholder,_=e.drawSVG,p=e.drawThickness,g=e.imageButton,f=e.imageSVG,m=e.imagePlaceholder,v=e.imagePicker,y=e.imagePickerLink,P=e.description,w=e.clearButton,b=e.cancelButton,S=e.addButton,C=e.errorCloseButton,A=e.errorBar,x=e.errorTitle,k=e.errorDescription,E=e.saveCheckbox,T=e.saveContainer;signature_manager_classPrivateMethodInitSpec(this,KP);signature_manager_classPrivateFieldInitSpec(this,dP,void 0);signature_manager_classPrivateFieldInitSpec(this,hP,null);signature_manager_classPrivateFieldInitSpec(this,uP,void 0);signature_manager_classPrivateFieldInitSpec(this,_P,void 0);signature_manager_classPrivateFieldInitSpec(this,pP,void 0);signature_manager_classPrivateFieldInitSpec(this,gP,void 0);signature_manager_classPrivateFieldInitSpec(this,fP,void 0);signature_manager_classPrivateFieldInitSpec(this,mP,null);signature_manager_classPrivateFieldInitSpec(this,vP,void 0);signature_manager_classPrivateFieldInitSpec(this,yP,null);signature_manager_classPrivateFieldInitSpec(this,PP,"");signature_manager_classPrivateFieldInitSpec(this,wP,null);signature_manager_classPrivateFieldInitSpec(this,bP,void 0);signature_manager_classPrivateFieldInitSpec(this,FP,void 0);signature_manager_classPrivateFieldInitSpec(this,SP,void 0);signature_manager_classPrivateFieldInitSpec(this,CP,void 0);signature_manager_classPrivateFieldInitSpec(this,AP,void 0);signature_manager_classPrivateFieldInitSpec(this,xP,null);signature_manager_classPrivateFieldInitSpec(this,kP,null);signature_manager_classPrivateFieldInitSpec(this,EP,void 0);signature_manager_classPrivateFieldInitSpec(this,TP,void 0);signature_manager_classPrivateFieldInitSpec(this,IP,void 0);signature_manager_classPrivateFieldInitSpec(this,GP,void 0);signature_manager_classPrivateFieldInitSpec(this,BP,void 0);signature_manager_classPrivateFieldInitSpec(this,MP,void 0);signature_manager_classPrivateFieldInitSpec(this,DP,void 0);signature_manager_classPrivateFieldInitSpec(this,LP,void 0);signature_manager_classPrivateFieldInitSpec(this,OP,null);signature_manager_classPrivateFieldInitSpec(this,RP,void 0);signature_manager_classPrivateFieldInitSpec(this,NP,null);signature_manager_classPrivateFieldInitSpec(this,jP,null);signature_manager_classPrivateFieldInitSpec(this,WP,!1);signature_manager_classPrivateFieldInitSpec(this,UP,void 0);signature_manager_classPrivateFieldInitSpec(this,VP,!1);signature_manager_classPrivateFieldInitSpec(this,HP,void 0);signature_manager_classPrivateFieldInitSpec(this,zP,void 0);signature_manager_classPrivateFieldInitSpec(this,$P,void 0);signature_manager_classPrivateFieldInitSpec(this,qP,void 0);signature_manager_classPrivateFieldInitSpec(this,XP,null);signature_manager_classPrivateFieldSet(dP,this,S);signature_manager_classPrivateFieldSet(uP,this,w);signature_manager_classPrivateFieldSet(_P,this,P.lastElementChild);signature_manager_classPrivateFieldSet(gP,this,P.firstElementChild);signature_manager_classPrivateFieldSet(fP,this,o);signature_manager_classPrivateFieldSet(bP,this,_);signature_manager_classPrivateFieldSet(vP,this,u);signature_manager_classPrivateFieldSet(FP,this,p);signature_manager_classPrivateFieldSet(SP,this,A);signature_manager_classPrivateFieldSet(AP,this,x);signature_manager_classPrivateFieldSet(CP,this,k);signature_manager_classPrivateFieldSet(GP,this,f);signature_manager_classPrivateFieldSet(IP,this,m);signature_manager_classPrivateFieldSet(EP,this,v);signature_manager_classPrivateFieldSet(TP,this,y);signature_manager_classPrivateFieldSet(zP,this,a);signature_manager_classPrivateFieldSet(BP,this,E);signature_manager_classPrivateFieldSet(MP,this,T);signature_manager_classPrivateFieldSet(LP,this,i);signature_manager_classPrivateFieldSet(RP,this,d);signature_manager_classPrivateFieldSet(HP,this,s);signature_manager_classPrivateFieldSet(qP,this,r);signature_manager_classPrivateFieldSet(UP,this,n);signature_manager_classPrivateFieldSet($P,this,new EditDescriptionDialog(t,a));YP._||(YP._=Object.freeze({signature:"pdfjs-editor-add-signature-description-default-when-drawing",errorUploadTitle:"pdfjs-editor-add-signature-image-upload-error-title",errorUploadDescription:"pdfjs-editor-add-signature-image-upload-error-description",errorNoDataTitle:"pdfjs-editor-add-signature-image-no-data-error-title",errorNoDataDescription:"pdfjs-editor-add-signature-image-no-data-error-description"}));o.addEventListener("close",signature_manager_assertClassBrand(KP,this,signature_manager_close).bind(this));o.addEventListener("contextmenu",e=>{const t=e.target;t!==signature_manager_classPrivateFieldGet(RP,this)&&t!==signature_manager_classPrivateFieldGet(gP,this)&&e.preventDefault()});o.addEventListener("drop",e=>{stopEvent(e)});b.addEventListener("click",signature_manager_assertClassBrand(KP,this,signature_manager_cancel).bind(this));S.addEventListener("click",signature_manager_assertClassBrand(KP,this,_add).bind(this));w.addEventListener("click",()=>{signature_manager_assertClassBrand(KP,this,signature_manager_reportTelemetry).call(this,{type:"signature",action:"pdfjs.signature.clear",data:{type:signature_manager_classPrivateFieldGet(NP,this)}});signature_manager_assertClassBrand(KP,this,_initTab).call(this,null)},{passive:!0});signature_manager_classPrivateFieldGet(gP,this).addEventListener("input",()=>{signature_manager_classPrivateFieldGet(_P,this).disabled=""===signature_manager_classPrivateFieldGet(gP,this).value},{passive:!0});signature_manager_classPrivateFieldGet(_P,this).addEventListener("click",()=>{signature_manager_classPrivateFieldGet(gP,this).value="";signature_manager_classPrivateFieldGet(_P,this).disabled=!0},{passive:!0});C.addEventListener("click",()=>{A.hidden=!0},{passive:!0});signature_manager_assertClassBrand(KP,this,_initTabButtons).call(this,c,h,g,l);v.accept=J.join(",");n.on("storedsignatureschanged",signature_manager_assertClassBrand(KP,this,_signaturesChanged).bind(this),Ih);a.register(o)}getSignature(e){return this.open(e)}async loadSignatures(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!signature_manager_classPrivateFieldGet(LP,this)||!e&&signature_manager_classPrivateFieldGet(LP,this).previousElementSibling||!signature_manager_classPrivateFieldGet(qP,this))return;if(!signature_manager_classPrivateFieldGet(OP,this)){signature_manager_classPrivateFieldSet(OP,this,signature_manager_classPrivateFieldGet(qP,this).getAll().then(async e=>[e,await Promise.all(Array.from(e.values(),e=>{let t=e.signatureData;return SignatureExtractor.decompressSignature(t)}))]));if(!e)return}const t=signature_manager_slicedToArray(await signature_manager_classPrivateFieldGet(OP,this),2),i=t[0],a=t[1];signature_manager_classPrivateFieldSet(OP,this,null);let s=0;for(const e of i){var r=signature_manager_slicedToArray(e,2);const t=r[0],i=r[1].description,n=a[s++];if(n){n.curves=n.outlines.map(e=>({points:e}));delete n.outlines;signature_manager_assertClassBrand(KP,this,_addToolbarButton).call(this,n,t,i)}}}async renderEditButton(e){const t=document.createElement("button");t.classList.add("altText","editDescription");t.tabIndex=0;e.description&&(t.title=e.description);const i=document.createElement("span");t.append(i);i.setAttribute("data-l10n-id","pdfjs-editor-add-signature-edit-button-label");t.addEventListener("click",()=>{signature_manager_classPrivateFieldGet($P,this).open(e)},{passive:!0});return t}async open(e){let t=e.uiManager,i=e.editor;signature_manager_classPrivateFieldGet(hP,this)||signature_manager_classPrivateFieldSet(hP,this,new Map(signature_manager_classPrivateFieldGet(DP,this).keys().map(e=>[e,{value:"",default:""}])));signature_manager_classPrivateFieldSet(XP,this,t);signature_manager_classPrivateFieldSet(pP,this,i);signature_manager_classPrivateFieldGet(XP,this).removeEditListeners();const a=signature_manager_classPrivateFieldSet(VP,this,await signature_manager_classPrivateFieldGet(qP,this).isFull());signature_manager_classPrivateFieldGet(MP,this).classList.toggle("fullStorage",a);signature_manager_classPrivateFieldGet(BP,this).checked=!a;await signature_manager_classPrivateFieldGet(zP,this).open(signature_manager_classPrivateFieldGet(fP,this));const s=signature_manager_classPrivateFieldGet(DP,this).get("type");s.focus();s.click()}destroy(){signature_manager_classPrivateFieldSet(XP,this,null);signature_manager_assertClassBrand(KP,this,signature_manager_finish).call(this)}}function _initTabButtons(e,t,i,a){const s=signature_manager_classPrivateFieldSet(DP,this,new Map([["type",e],["draw",t],["image",i]])),tabCallback=e=>{for(const i of s){var t=signature_manager_slicedToArray(i,2);const s=t[0],r=t[1];if(r===e.target){r.setAttribute("aria-selected",!0);r.setAttribute("tabindex",0);a.setAttribute("data-selected",s);signature_manager_assertClassBrand(KP,this,_initTab).call(this,s)}else{r.setAttribute("aria-selected",!1);r.setAttribute("tabindex",-1)}}},r=Array.from(s.values());for(let e=0,t=r.length;e<t;e++){const t=r[e];t.addEventListener("click",tabCallback,{passive:!0});t.addEventListener("keydown",t=>{let i=t.key;"ArrowLeft"!==i&&"ArrowRight"!==i||r[e+("ArrowLeft"===i?-1:1)]?.focus()},{passive:!0})}}function _resetCommon(){signature_manager_classPrivateFieldSet(WP,this,!1);signature_manager_classPrivateFieldGet(gP,this).value="";signature_manager_classPrivateFieldGet(NP,this)&&(signature_manager_classPrivateFieldGet(hP,this).get(signature_manager_classPrivateFieldGet(NP,this)).value="")}function _resetTab(e){switch(e){case"type":signature_manager_classPrivateFieldGet(RP,this).value="";break;case"draw":signature_manager_classPrivateFieldSet(mP,this,null);signature_manager_classPrivateFieldSet(wP,this,null);signature_manager_classPrivateFieldSet(PP,this,"");signature_manager_classPrivateFieldGet(yP,this)?.remove();signature_manager_classPrivateFieldSet(yP,this,null);signature_manager_classPrivateFieldGet(vP,this).hidden=!1;signature_manager_classPrivateFieldGet(FP,this).value=1;break;case"image":signature_manager_classPrivateFieldGet(IP,this).hidden=!1;signature_manager_classPrivateFieldGet(kP,this)?.remove();signature_manager_classPrivateFieldSet(kP,this,null)}}function _initTab(e){if(e&&signature_manager_classPrivateFieldGet(NP,this)===e)return;signature_manager_classPrivateFieldGet(NP,this)&&(signature_manager_classPrivateFieldGet(hP,this).get(signature_manager_classPrivateFieldGet(NP,this)).value=signature_manager_classPrivateFieldGet(gP,this).value);e&&signature_manager_classPrivateFieldSet(NP,this,e);signature_manager_classPrivateFieldGet(SP,this).hidden=!0;const t=!e;t?signature_manager_assertClassBrand(KP,this,_resetCommon).call(this):signature_manager_classPrivateFieldGet(gP,this).value=signature_manager_classPrivateFieldGet(hP,this).get(signature_manager_classPrivateFieldGet(NP,this)).value;signature_manager_classPrivateFieldGet(_P,this).disabled=""===signature_manager_classPrivateFieldGet(gP,this).value;signature_manager_classPrivateFieldGet(jP,this)?.abort();signature_manager_classPrivateFieldSet(jP,this,new AbortController);switch(signature_manager_classPrivateFieldGet(NP,this)){case"type":signature_manager_assertClassBrand(KP,this,_initTypeTab).call(this,t);break;case"draw":signature_manager_assertClassBrand(KP,this,_initDrawTab).call(this,t);break;case"image":signature_manager_assertClassBrand(KP,this,_initImageTab).call(this,t)}}function _disableButtons(e){e&&signature_manager_classPrivateFieldGet(VP,this)||(signature_manager_classPrivateFieldGet(BP,this).disabled=!e);signature_manager_classPrivateFieldGet(uP,this).disabled=signature_manager_classPrivateFieldGet(dP,this).disabled=signature_manager_classPrivateFieldGet(gP,this).disabled=!e}function _initTypeTab(e){e&&signature_manager_assertClassBrand(KP,this,_resetTab).call(this,"type");signature_manager_assertClassBrand(KP,this,_disableButtons).call(this,signature_manager_classPrivateFieldGet(RP,this).value);const t={passive:!0,signal:signature_manager_classPrivateFieldGet(jP,this).signal};signature_manager_classPrivateFieldGet(RP,this).addEventListener("input",()=>{const e=signature_manager_classPrivateFieldGet(RP,this).value;if(!signature_manager_classPrivateFieldGet(WP,this)){signature_manager_classPrivateFieldGet(hP,this).get("type").default=signature_manager_classPrivateFieldGet(gP,this).value=e;signature_manager_classPrivateFieldGet(_P,this).disabled=""===e}signature_manager_assertClassBrand(KP,this,_disableButtons).call(this,e)},t);signature_manager_classPrivateFieldGet(gP,this).addEventListener("input",()=>{signature_manager_classPrivateFieldSet(WP,this,signature_manager_classPrivateFieldGet(RP,this).value!==signature_manager_classPrivateFieldGet(gP,this).value)},t)}function _initDrawTab(e){e&&signature_manager_assertClassBrand(KP,this,_resetTab).call(this,"draw");signature_manager_assertClassBrand(KP,this,_disableButtons).call(this,signature_manager_classPrivateFieldGet(yP,this));const t=signature_manager_classPrivateFieldGet(jP,this).signal,i={signal:t};let a=NaN;const drawCallback=e=>{const s=e.pointerId;if(!isNaN(a)&&a!==s)return;a=s;e.preventDefault();signature_manager_classPrivateFieldGet(bP,this).setPointerCapture(s);const r=signature_manager_classPrivateFieldGet(bP,this).getBoundingClientRect(),n=r.width,o=r.height;let l=e.offsetX,c=e.offsetY;l=Math.round(l);c=Math.round(c);e.target===signature_manager_classPrivateFieldGet(vP,this)&&(signature_manager_classPrivateFieldGet(vP,this).hidden=!0);if(!signature_manager_classPrivateFieldGet(mP,this)){signature_manager_classPrivateFieldSet(mP,this,{width:n,height:o,thickness:parseInt(signature_manager_classPrivateFieldGet(FP,this).value,10),curves:[]});signature_manager_assertClassBrand(KP,this,_disableButtons).call(this,!0);const e=new DOMSVGFactory,t=signature_manager_classPrivateFieldSet(yP,this,e.createElement("path"));t.setAttribute("stroke-width",signature_manager_classPrivateFieldGet(FP,this).value);signature_manager_classPrivateFieldGet(bP,this).append(t);signature_manager_classPrivateFieldGet(bP,this).addEventListener("pointerdown",drawCallback,i);signature_manager_classPrivateFieldGet(vP,this).removeEventListener("pointerdown",drawCallback);""===signature_manager_classPrivateFieldGet(gP,this).value&&signature_manager_classPrivateFieldGet(HP,this).get(YP._.signature).then(e=>{signature_manager_classPrivateFieldGet(hP,this).get("draw").default=e;signature_manager_classPrivateFieldGet(gP,this).value||=e;signature_manager_classPrivateFieldGet(_P,this).disabled=""===signature_manager_classPrivateFieldGet(gP,this).value})}signature_manager_classPrivateFieldSet(wP,this,[l,c]);signature_manager_classPrivateFieldGet(mP,this).curves.push({points:signature_manager_classPrivateFieldGet(wP,this)});signature_manager_classPrivateFieldSet(PP,this,signature_manager_classPrivateFieldGet(PP,this)+`M ${l} ${c}`);signature_manager_classPrivateFieldGet(yP,this).setAttribute("d",signature_manager_classPrivateFieldGet(PP,this));const d=new AbortController,h={signal:AbortSignal.any([t,d.signal])};signature_manager_classPrivateFieldGet(bP,this).addEventListener("contextmenu",noContextMenu,h);signature_manager_classPrivateFieldGet(bP,this).addEventListener("pointermove",e=>{e.preventDefault();let t=e.offsetX,i=e.offsetY;t=Math.round(t);i=Math.round(i);const a=signature_manager_classPrivateFieldGet(wP,this);if(!(t<0||i<0||t>n||i>o||t===a.at(-2)&&i===a.at(-1))){if(a.length>=4){const e=signature_manager_slicedToArray(a.slice(-4),4),s=e[0],r=e[1],n=e[2],o=e[3];signature_manager_classPrivateFieldSet(PP,this,signature_manager_classPrivateFieldGet(PP,this)+`C${(s+5*n)/6} ${(r+5*o)/6} ${(5*n+t)/6} ${(5*o+i)/6} ${(n+t)/2} ${(o+i)/2}`)}else signature_manager_classPrivateFieldSet(PP,this,signature_manager_classPrivateFieldGet(PP,this)+`L${t} ${i}`);a.push(t,i);signature_manager_classPrivateFieldGet(yP,this).setAttribute("d",signature_manager_classPrivateFieldGet(PP,this))}},h);signature_manager_classPrivateFieldGet(bP,this).addEventListener("pointerup",e=>{const t=e.pointerId;if(isNaN(a)||a===t){a=NaN;e.preventDefault();signature_manager_classPrivateFieldGet(bP,this).releasePointerCapture(t);d.abort();if(2===signature_manager_classPrivateFieldGet(wP,this).length){signature_manager_classPrivateFieldSet(PP,this,signature_manager_classPrivateFieldGet(PP,this)+`L${signature_manager_classPrivateFieldGet(wP,this)[0]} ${signature_manager_classPrivateFieldGet(wP,this)[1]}`);signature_manager_classPrivateFieldGet(yP,this).setAttribute("d",signature_manager_classPrivateFieldGet(PP,this))}}},h)};signature_manager_classPrivateFieldGet(mP,this)?signature_manager_classPrivateFieldGet(bP,this).addEventListener("pointerdown",drawCallback,i):signature_manager_classPrivateFieldGet(vP,this).addEventListener("pointerdown",drawCallback,i);signature_manager_classPrivateFieldGet(FP,this).addEventListener("input",()=>{const e=signature_manager_classPrivateFieldGet(FP,this).value;signature_manager_classPrivateFieldGet(FP,this).setAttribute("data-l10n-args",JSON.stringify({thickness:e}));if(signature_manager_classPrivateFieldGet(mP,this)){signature_manager_classPrivateFieldGet(yP,this).setAttribute("stroke-width",e);signature_manager_classPrivateFieldGet(mP,this).thickness=e}},i)}function _showError(e){signature_manager_classPrivateFieldGet(AP,this).setAttribute("data-l10n-id",YP._[`error${e}Title`]);signature_manager_classPrivateFieldGet(CP,this).setAttribute("data-l10n-id",YP._[`error${e}Description`]);signature_manager_classPrivateFieldGet(SP,this).hidden=!1}function _initImageTab(e){e&&signature_manager_assertClassBrand(KP,this,_resetTab).call(this,"image");signature_manager_assertClassBrand(KP,this,_disableButtons).call(this,signature_manager_classPrivateFieldGet(kP,this));const t=signature_manager_classPrivateFieldGet(jP,this).signal,i={signal:t},a={passive:!0,signal:t};signature_manager_classPrivateFieldGet(TP,this).addEventListener("keydown",e=>{const t=e.key;if("Enter"===t||" "===t){stopEvent(e);signature_manager_classPrivateFieldGet(EP,this).click()}},i);signature_manager_classPrivateFieldGet(EP,this).addEventListener("click",()=>{signature_manager_classPrivateFieldGet(fP,this).classList.toggle("waiting",!0)},a);signature_manager_classPrivateFieldGet(EP,this).addEventListener("change",async()=>{const e=signature_manager_classPrivateFieldGet(EP,this).files?.[0];if(e&&J.includes(e.type))await signature_manager_assertClassBrand(KP,this,_extractSignature).call(this,e);else{signature_manager_assertClassBrand(KP,this,_showError).call(this,"Upload");signature_manager_classPrivateFieldGet(fP,this).classList.toggle("waiting",!1)}},a);signature_manager_classPrivateFieldGet(EP,this).addEventListener("cancel",()=>{signature_manager_classPrivateFieldGet(fP,this).classList.toggle("waiting",!1)},a);signature_manager_classPrivateFieldGet(IP,this).addEventListener("dragover",e=>{const t=e.dataTransfer;for(const i of t.items){const a=i.type;if(J.includes(a)){t.dropEffect="copy"===t.effectAllowed?"copy":"move";stopEvent(e);return}}t.dropEffect="none"},i);signature_manager_classPrivateFieldGet(IP,this).addEventListener("drop",e=>{const t=e.dataTransfer.files;if(t?.length){for(const e of t)if(J.includes(e.type)){signature_manager_assertClassBrand(KP,this,_extractSignature).call(this,e);break}stopEvent(e);signature_manager_classPrivateFieldGet(fP,this).classList.toggle("waiting",!0)}},i)}async function _extractSignature(e){let t;try{t=await signature_manager_classPrivateFieldGet(XP,this).imageManager.getFromFile(e)}catch(e){ngx_console_NgxConsole.error("SignatureManager.#extractSignature.",e)}if(!t){signature_manager_assertClassBrand(KP,this,_showError).call(this,"Upload");signature_manager_classPrivateFieldGet(fP,this).classList.toggle("waiting",!1);return}const i=signature_manager_classPrivateFieldSet(xP,this,signature_manager_classPrivateFieldGet(pP,this).getFromImage(t.bitmap));if(!i){signature_manager_assertClassBrand(KP,this,_showError).call(this,"NoData");signature_manager_classPrivateFieldGet(fP,this).classList.toggle("waiting",!1);return}const a=i.outline;signature_manager_classPrivateFieldGet(IP,this).hidden=!0;signature_manager_assertClassBrand(KP,this,_disableButtons).call(this,!0);const s=new DOMSVGFactory,r=signature_manager_classPrivateFieldSet(kP,this,s.createElement("path"));signature_manager_classPrivateFieldGet(GP,this).setAttribute("viewBox",a.viewBox);signature_manager_classPrivateFieldGet(GP,this).setAttribute("preserveAspectRatio","xMidYMid meet");signature_manager_classPrivateFieldGet(GP,this).append(r);r.setAttribute("d",a.toSVGPath());signature_manager_classPrivateFieldGet(hP,this).get("image").default=e.name;if(""===signature_manager_classPrivateFieldGet(gP,this).value){signature_manager_classPrivateFieldGet(gP,this).value=e.name||"";signature_manager_classPrivateFieldGet(_P,this).disabled=""===signature_manager_classPrivateFieldGet(gP,this).value}signature_manager_classPrivateFieldGet(fP,this).classList.toggle("waiting",!1)}function _getOutlineForType(){return signature_manager_classPrivateFieldGet(pP,this).getFromText(signature_manager_classPrivateFieldGet(RP,this).value,window.getComputedStyle(signature_manager_classPrivateFieldGet(RP,this)))}function _getOutlineForDraw(){const e=signature_manager_classPrivateFieldGet(bP,this).getBoundingClientRect(),t=e.width,i=e.height;return signature_manager_classPrivateFieldGet(pP,this).getDrawnSignature(signature_manager_classPrivateFieldGet(mP,this),t,i)}function signature_manager_reportTelemetry(e){signature_manager_classPrivateFieldGet(UP,this).dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}function _addToolbarButton(e,t,i){const a=e.curves,s=e.areContours,r=e.thickness,n=e.width,o=e.height,l=Math.max(n,o),c=SignatureExtractor.processDrawnLines({lines:{curves:a,thickness:r,width:n,height:o},pageWidth:l,pageHeight:l,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});if(!c)return;const d=c.outline,h=new DOMSVGFactory,u=document.createElement("div"),_=document.createElement("button");_.addEventListener("click",()=>{signature_manager_classPrivateFieldGet(UP,this).dispatch("switchannotationeditorparams",{source:this,type:w.CREATE,value:{signatureData:{lines:{curves:a,thickness:r,width:n,height:o},mustSmooth:!1,areContours:s,description:i,uuid:t,heightInPage:40}}})});u.append(_);u.classList.add("toolbarAddSignatureButtonContainer");const p=h.create(1,1,!0);_.append(p);const g=document.createElement("span");g.ariaHidden=!0;_.append(g);_.classList.add("toolbarAddSignatureButton");_.type="button";g.textContent=i;_.setAttribute("data-l10n-id","pdfjs-editor-add-saved-signature-button");_.setAttribute("data-l10n-args",JSON.stringify({description:i}));_.tabIndex=0;const f=h.createElement("path");p.append(f);p.setAttribute("viewBox",d.viewBox);p.setAttribute("preserveAspectRatio","xMidYMid meet");s&&f.classList.add("contours");f.setAttribute("d",d.toSVGPath());const m=document.createElement("button");u.append(m);m.classList.add("toolbarButton","deleteButton");m.setAttribute("data-l10n-id","pdfjs-editor-delete-signature-button1");m.type="button";m.tabIndex=0;m.addEventListener("click",async()=>{if(await signature_manager_classPrivateFieldGet(qP,this).delete(t)){u.remove();signature_manager_assertClassBrand(KP,this,signature_manager_reportTelemetry).call(this,{type:"signature",action:"pdfjs.signature.delete_saved",data:{savedCount:await signature_manager_classPrivateFieldGet(qP,this).size()}})}});const v=document.createElement("span");m.append(v);v.setAttribute("data-l10n-id","pdfjs-editor-delete-signature-button-label1");signature_manager_classPrivateFieldGet(LP,this).before(u)}async function _signaturesChanged(){const e=signature_manager_classPrivateFieldGet(LP,this).parentElement;for(;e.firstElementChild!==signature_manager_classPrivateFieldGet(LP,this);)e.firstElementChild.remove();signature_manager_classPrivateFieldSet(OP,this,null);await this.loadSignatures(!0)}function signature_manager_cancel(){signature_manager_assertClassBrand(KP,this,signature_manager_finish).call(this)}function signature_manager_finish(){signature_manager_classPrivateFieldGet(zP,this).closeIfActive(signature_manager_classPrivateFieldGet(fP,this))}function signature_manager_close(){null===signature_manager_classPrivateFieldGet(pP,this)._drawId&&signature_manager_classPrivateFieldGet(pP,this).remove();signature_manager_classPrivateFieldGet(XP,this)?.addEditListeners();signature_manager_classPrivateFieldGet(jP,this)?.abort();signature_manager_classPrivateFieldSet(jP,this,null);signature_manager_classPrivateFieldSet(XP,this,null);signature_manager_classPrivateFieldSet(pP,this,null);signature_manager_assertClassBrand(KP,this,_resetCommon).call(this);for(const e of signature_manager_classPrivateFieldGet(DP,this)){const t=signature_manager_slicedToArray(e,1)[0];signature_manager_assertClassBrand(KP,this,_resetTab).call(this,t)}signature_manager_assertClassBrand(KP,this,_disableButtons).call(this,!1);signature_manager_classPrivateFieldSet(NP,this,null);signature_manager_classPrivateFieldSet(hP,this,null)}async function _add(){let e;const t=signature_manager_classPrivateFieldGet(NP,this);switch(t){case"type":e=signature_manager_assertClassBrand(KP,this,_getOutlineForType).call(this);break;case"draw":e=signature_manager_assertClassBrand(KP,this,_getOutlineForDraw).call(this);break;case"image":e=signature_manager_classPrivateFieldGet(xP,this)}let i=null;const a=signature_manager_classPrivateFieldGet(gP,this).value;if(signature_manager_classPrivateFieldGet(BP,this).checked){const t=e,s=t.newCurves,r=t.areContours,n=t.thickness,o=t.width,l=t.height,c=await SignatureExtractor.compressSignature({outlines:s,areContours:r,thickness:n,width:o,height:l});i=await signature_manager_classPrivateFieldGet(qP,this).create({description:a,signatureData:c});i?signature_manager_assertClassBrand(KP,this,_addToolbarButton).call(this,{curves:s.map(e=>({points:e})),areContours:r,thickness:n,width:o,height:l},i,a):ngx_console_NgxConsole.warn("SignatureManager.add: cannot save the signature.")}const s=signature_manager_classPrivateFieldGet(hP,this).get(t);signature_manager_assertClassBrand(KP,this,signature_manager_reportTelemetry).call(this,{type:"signature",action:"pdfjs.signature.created",data:{type:t,saved:!!i,savedCount:await signature_manager_classPrivateFieldGet(qP,this).size(),descriptionChanged:a!==s.default}});signature_manager_classPrivateFieldGet(pP,this).addSignature(e,40,signature_manager_classPrivateFieldGet(gP,this).value,i);signature_manager_assertClassBrand(KP,this,signature_manager_finish).call(this)}var YP={_:null},ZP=new WeakMap,JP=new WeakMap,QP=new WeakMap,ew=new WeakMap,tw=new WeakMap,iw=new WeakMap,aw=new WeakMap,sw=new WeakSet;class EditDescriptionDialog{constructor(e,t){let i=e.dialog,a=e.description,s=e.cancelButton,r=e.updateButton,n=e.editSignatureView;signature_manager_classPrivateMethodInitSpec(this,sw);signature_manager_classPrivateFieldInitSpec(this,ZP,void 0);signature_manager_classPrivateFieldInitSpec(this,JP,void 0);signature_manager_classPrivateFieldInitSpec(this,QP,void 0);signature_manager_classPrivateFieldInitSpec(this,ew,void 0);signature_manager_classPrivateFieldInitSpec(this,tw,void 0);signature_manager_classPrivateFieldInitSpec(this,iw,void 0);signature_manager_classPrivateFieldInitSpec(this,aw,void 0);const o=signature_manager_classPrivateFieldSet(QP,this,a.firstElementChild);signature_manager_classPrivateFieldSet(iw,this,n);signature_manager_classPrivateFieldSet(ew,this,i);signature_manager_classPrivateFieldSet(tw,this,t);i.addEventListener("close",signature_manager_assertClassBrand(sw,this,_close2).bind(this));i.addEventListener("contextmenu",e=>{e.target!==signature_manager_classPrivateFieldGet(QP,this)&&e.preventDefault()});s.addEventListener("click",signature_manager_assertClassBrand(sw,this,_cancel2).bind(this));r.addEventListener("click",signature_manager_assertClassBrand(sw,this,_update).bind(this));const l=a.lastElementChild;l.addEventListener("click",()=>{o.value="";l.disabled=!0;r.disabled=""===signature_manager_classPrivateFieldGet(JP,this)});o.addEventListener("input",()=>{const e=o.value;l.disabled=""===e;r.disabled=e===signature_manager_classPrivateFieldGet(JP,this);n.setAttribute("aria-label",e)},{passive:!0});t.register(i)}async open(e){signature_manager_classPrivateFieldSet(aw,this,e._uiManager);signature_manager_classPrivateFieldSet(ZP,this,e);signature_manager_classPrivateFieldSet(JP,this,signature_manager_classPrivateFieldGet(QP,this).value=e.description);signature_manager_classPrivateFieldGet(QP,this).dispatchEvent(new Event("input"));signature_manager_classPrivateFieldGet(aw,this).removeEditListeners();const t=e.getSignaturePreview(),i=t.areContours,a=t.outline,s=(new DOMSVGFactory).createElement("path");signature_manager_classPrivateFieldGet(iw,this).append(s);signature_manager_classPrivateFieldGet(iw,this).setAttribute("viewBox",a.viewBox);s.setAttribute("d",a.toSVGPath());i&&s.classList.add("contours");await signature_manager_classPrivateFieldGet(tw,this).open(signature_manager_classPrivateFieldGet(ew,this))}}async function _update(){signature_manager_classPrivateFieldGet(ZP,this)._reportTelemetry({action:"pdfjs.signature.edit_description",data:{hasBeenChanged:!0}});signature_manager_classPrivateFieldGet(ZP,this).description=signature_manager_classPrivateFieldGet(QP,this).value;signature_manager_assertClassBrand(sw,this,signature_manager_finish2).call(this)}function _cancel2(){signature_manager_classPrivateFieldGet(ZP,this)._reportTelemetry({action:"pdfjs.signature.edit_description",data:{hasBeenChanged:!1}});signature_manager_assertClassBrand(sw,this,signature_manager_finish2).call(this)}function signature_manager_finish2(){signature_manager_classPrivateFieldGet(tw,this).closeIfActive(signature_manager_classPrivateFieldGet(ew,this))}function _close2(){signature_manager_classPrivateFieldGet(aw,this)?.addEditListeners();signature_manager_classPrivateFieldSet(aw,this,null);signature_manager_classPrivateFieldSet(ZP,this,null);signature_manager_classPrivateFieldGet(iw,this).firstElementChild.remove()}function web_toolbar_classPrivateFieldInitSpec(e,t,i){web_toolbar_checkPrivateRedeclaration(e,t),t.set(e,i)}function web_toolbar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function web_toolbar_classPrivateFieldGet(e,t){return e.get(web_toolbar_assertClassBrand(e,t))}function toolbar_classPrivateFieldSet(e,t,i){return e.set(web_toolbar_assertClassBrand(e,t),i),i}function web_toolbar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var rw=new WeakMap,nw=new WeakMap,ow=new WeakMap,lw=new WeakMap,cw=new WeakMap,dw=new WeakSet;class Toolbar{constructor(e,t,i,a,s){let r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;!function toolbar_classPrivateMethodInitSpec(e,t){web_toolbar_checkPrivateRedeclaration(e,t),t.add(e)}(this,dw);web_toolbar_classPrivateFieldInitSpec(this,rw,null);web_toolbar_classPrivateFieldInitSpec(this,nw,void 0);web_toolbar_classPrivateFieldInitSpec(this,ow,Qd);web_toolbar_classPrivateFieldInitSpec(this,lw,25);web_toolbar_classPrivateFieldInitSpec(this,cw,eh);toolbar_classPrivateFieldSet(nw,this,e);toolbar_classPrivateFieldSet(ow,this,i);toolbar_classPrivateFieldSet(lw,this,s);toolbar_classPrivateFieldSet(cw,this,a);this.eventBus=t;const n=[{element:e.previous,eventName:"previouspage"},{element:e.next,eventName:"nextpage"},{element:e.print,eventName:"print"},{element:e.presentationModeButton,eventName:"presentationmode"},{element:e.download,eventName:"download"},{element:e.movePageUp,eventName:"movePageUp"},{element:e.movePageDown,eventName:"movePageDown"}];web_toolbar_assertClassBrand(dw,this,toolbar_bindListeners).call(this,n);web_toolbar_assertClassBrand(dw,this,_updateToolbarDensity).call(this,{value:r});this.reset()}get maxZoom(){return web_toolbar_classPrivateFieldGet(lw,this)}set maxZoom(e){toolbar_classPrivateFieldSet(lw,this,e)}get minZoom(){return web_toolbar_classPrivateFieldGet(cw,this)}set minZoom(e){toolbar_classPrivateFieldSet(cw,this,e)}setPageNumber(e,t){this.pageNumber=e;this.pageLabel=t;web_toolbar_assertClassBrand(dw,this,toolbar_updateUIState).call(this,!1)}setPagesCount(e,t){this.pagesCount=e;this.hasPageLabels=t;web_toolbar_assertClassBrand(dw,this,toolbar_updateUIState).call(this,!0)}setPageScale(e,t){this.pageScaleValue=(e||t).toString();this.pageScale=t;web_toolbar_assertClassBrand(dw,this,toolbar_updateUIState).call(this,!1)}reset(){toolbar_classPrivateFieldSet(rw,this,null);this.pageNumber=0;this.pageLabel=null;this.hasPageLabels=!1;this.pagesCount=0;const e=web_toolbar_classPrivateFieldGet(ow,this)||Qd;this.pageScaleValue=e;Number(e)&&(this.pageScale=Number(e));web_toolbar_assertClassBrand(dw,this,toolbar_updateUIState).call(this,!0);this.updateLoadingIndicatorState();web_toolbar_assertClassBrand(dw,this,_editorModeChanged).call(this,{mode:P.DISABLE})}updateLoadingIndicatorState(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];web_toolbar_classPrivateFieldGet(nw,this).pageNumber.classList.toggle("loading",e)}}function _updateToolbarDensity(e){let t="normal";switch(e.value){case 1:t="compact";break;case 2:t="touch"}document.documentElement.setAttribute("data-toolbar-density",t)}function toolbar_bindListeners(e){const t=this.eventBus,i=web_toolbar_classPrivateFieldGet(nw,this),a=i.editorHighlightColorPicker,s=i.editorHighlightButton,r=i.pageNumber,n=i.scaleSelect,o=this;for(const i of e){const e=i.element,a=i.eventName,s=i.eventDetails,r=i.telemetry;e&&e.addEventListener("click",e=>{null!==a&&t.dispatch(a,{source:this,...s,isFromKeyboard:0===e.detail});r&&t.dispatch("reporttelemetry",{source:this,details:r})})}r.addEventListener("click",function(){this.select()});r.addEventListener("change",function(){t.dispatch("pagenumberchanged",{source:o,value:this.value})});t.on("pagesedited",e=>{const t=e.pagesMapper.pagesNumber;t!==this.pagesCount&&this.setPagesCount(t,this.hasPageLabels)},Ih);n.addEventListener("change",function(){"custom"!==this.value&&t.dispatch("scalechanged",{source:o,value:this.value})});n.addEventListener("click",function(e){let t=e.target;this.value===o.pageScaleValue&&"OPTION"===t.tagName.toUpperCase()&&this.blur()});n.oncontextmenu=noContextMenu;t.on("annotationeditormodechanged",web_toolbar_assertClassBrand(dw,this,_editorModeChanged).bind(this),Ih);t.on("showannotationeditorui",e=>{if(e.mode===P.HIGHLIGHT)s.click()},Ih);t.on("toolbardensity",web_toolbar_assertClassBrand(dw,this,_updateToolbarDensity).bind(this),Ih);t._on("closeopenpopovers",e=>{e.source!==this&&t.dispatch("switchannotationeditormode",{source:this,mode:P.NONE})});t._on("showannotationeditorui",e=>{if(e.mode===P.HIGHLIGHT)s.click()});t._on("spreadmodechanged",()=>{web_toolbar_assertClassBrand(dw,this,toolbar_updateUIState).call(this,!1)});t._on("scrollmodechanged",()=>{web_toolbar_assertClassBrand(dw,this,toolbar_updateUIState).call(this,!1)});if(a){t.on("annotationeditoruimanager",e=>{let t=e.uiManager;const i=toolbar_classPrivateFieldSet(rw,this,new ColorPicker({uiManager:t}));t.setMainHighlightColorPicker(i);a.append(i.renderMainDropdown())},Ih);t.on("mainhighlightcolorpickerupdatecolor",e=>{let t=e.value;web_toolbar_classPrivateFieldGet(rw,this)?.updateColor(t)},Ih)}}function _editorModeChanged(e){let t=e.mode;t!==P.NONE&&t!==P.DISABLE&&this.eventBus.dispatch("closeopenpopovers",{source:this});const i=web_toolbar_classPrivateFieldGet(nw,this),a=i.editorCommentButton,s=i.editorCommentParamsToolbar,r=i.editorFreeTextButton,n=i.editorFreeTextParamsToolbar,o=i.editorHighlightButton,l=i.editorHighlightParamsToolbar,c=i.editorInkButton,d=i.editorInkParamsToolbar,h=i.editorStampButton,u=i.editorStampParamsToolbar,_=i.editorSignatureButton,p=i.editorSignatureParamsToolbar;toggleExpandedBtn(a,t===P.POPUP,s);toggleExpandedBtn(r,t===P.FREETEXT,n);toggleExpandedBtn(o,t===P.HIGHLIGHT,l);toggleExpandedBtn(c,t===P.INK,d);toggleExpandedBtn(h,t===P.STAMP,u);toggleExpandedBtn(_,t===P.SIGNATURE,p);const g=t===P.DISABLE;a&&(a.disabled=g);r&&(r.disabled=g);o&&(o.disabled=g);c&&(c.disabled=g);h&&(h.disabled=g);_&&(_.disabled=g)}function toolbar_updateUIState(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=this.pageNumber,i=this.pagesCount,a=this.pageScaleValue,s=this.pageScale,r=web_toolbar_classPrivateFieldGet(nw,this);if(e){if(this.hasPageLabels){r.pageNumber.type="text";r.numPages.setAttribute("data-l10n-id","pdfjs-page-of-pages")}else{r.pageNumber.type="number";r.numPages.setAttribute("data-l10n-id","pdfjs-of-pages");r.numPages.setAttribute("data-l10n-args",JSON.stringify({pagesCount:i}))}r.pageNumber.max=i}if(this.hasPageLabels){r.pageNumber.value=this.pageLabel;r.numPages.setAttribute("data-l10n-args",JSON.stringify({pageNumber:t,pagesCount:i}))}else r.pageNumber.value=t;r.previous.disabled=t<=1;r.next.disabled=t>=i;const n=Number(this.minZoom)??eh,o=Number(this.maxZoom)??25;r.zoomOut&&(r.zoomOut.disabled=s<=n);r.zoomIn&&(r.zoomIn.disabled=s>=o);let l=!1;if(r.scaleSelect.options)for(const e of r.scaleSelect.options){const t=parseFloat(e.value),i=parseFloat(a);if(!isNaN(t)&&!isNaN(i)&&Math.abs(t-i)<1e-4||e.value===a){e.selected=!0;l=!0}else e.selected=!1}l||(r.customScaleOption.selected=!0);const c="number"!=typeof s||Number.isNaN(s)?0:Math.round(1e4*s)/100;r.customScaleOption.setAttribute("data-l10n-args",JSON.stringify({scale:c}));this.eventBus.dispatch("updateuistate",{source:this,widget:"Toolbar",pageNumber:t,pagesCount:i,pageScaleValue:a,pageScale:s})}class ViewHistory{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;this.fingerprint=e;this.cacheSize=t;this._initializedPromise=this._readFromStorage().then(e=>{const t=JSON.parse(e||"{}");let i=-1;if(Array.isArray(t.files)){for(;t.files.length>=this.cacheSize;)t.files.shift();for(let e=0,a=t.files.length;e<a;e++){if(t.files[e].fingerprint===this.fingerprint){i=e;break}}}else t.files=[];-1===i&&(i=t.files.push({fingerprint:this.fingerprint})-1);this.file=t.files[i];this.database=t})}async _writeToStorage(){if(AppOptions.get("disableHistory"))return;const e=JSON.stringify(this.database);try{localStorage.setItem("pdfjs.history",e)}catch(e){}}async _readFromStorage(){if(!AppOptions.get("disableHistory"))try{return localStorage.getItem("pdfjs.history")}catch(e){return}}async set(e,t){await this._initializedPromise;this.file[e]=t;return this._writeToStorage()}async setMultiple(e){await this._initializedPromise;for(const t in e)this.file[t]=e[t];return this._writeToStorage()}async get(e,t){await this._initializedPromise;const i=this.file[e];return void 0!==i?i:t}async getMultiple(e){await this._initializedPromise;const t=Object.create(null);for(const i in e){const a=this.file[i];t[i]=void 0!==a?a:e[i]}return t}}function views_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function views_manager_classPrivateFieldGet(e,t){return e.get(views_manager_assertClassBrand(e,t))}function views_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const hw="viewsManagerResizing",uw="pdfSidebarNotification";var _w=new WeakMap,pw=new WeakSet;class ViewsManager extends Sidebar{constructor(e){let t=e.elements,i=t.outerContainer,a=t.sidebarContainer,s=t.toggleButton,r=t.resizer,n=t.thumbnailButton,o=t.outlineButton,l=t.attachmentsButton,c=t.layersButton,d=t.thumbnailsView,h=t.outlinesView,u=t.attachmentsView,_=t.layersView,p=t.viewsManagerAddFile.button,g=t.viewsManagerCurrentOutlineButton,f=t.viewsManagerSelectorButton,m=t.viewsManagerSelectorOptions,v=t.viewsManagerHeaderLabel,y=t.viewsManagerStatus,P=e.eventBus,w=e.l10n,b=e.enableMerge,S=void 0!==b&&b,C=e.enableSplitMerge,A=void 0!==C&&C,x=e.globalAbortSignal;super({sidebar:a,resizer:r,toggleButton:s},"ltr"===w.getDirection(),!1,x);!function views_manager_classPrivateMethodInitSpec(e,t){views_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,pw);!function views_manager_classPrivateFieldInitSpec(e,t,i){views_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,_w,!window.matchMedia("(prefers-reduced-motion: reduce)").matches);this.isOpen=!1;this.active=oh;this.isInitialViewSet=!1;this.isInitialEventDispatched=!1;this.onToggled=null;this.onUpdateThumbnails=null;this.outerContainer=i;this.sidebarContainer=a;this.toggleButton=s;this.resizer=r;this.thumbnailButton=n;this.outlineButton=o;this.attachmentsButton=l;this.layersButton=c;this.thumbnailsView=d;this.outlinesView=h;this.attachmentsView=u;this.layersView=_;this.viewsManagerAddFileButton=p;this.viewsManagerCurrentOutlineButton=g;this.viewsManagerHeaderLabel=v;this.viewsManagerStatus=y;this.eventBus=P;!A&&y&&(y.hidden=!0);this._enableSplitMerge=A;this._enableMerge=S;S||(p.hidden=!0);this.menu=m&&f?new Menu(m,f,[n,o,l,c]):null;gw._||(gw._=Object.freeze({pagesTitle:"pdfjs-views-manager-pages-title",outlinesTitle:"pdfjs-views-manager-outlines-title1",attachmentsTitle:"pdfjs-views-manager-attachments-title",layersTitle:"pdfjs-views-manager-layers-title1",notificationButton:"pdfjs-toggle-views-manager-notification-button",toggleButton:"pdfjs-toggle-views-manager-button1"}));views_manager_assertClassBrand(pw,this,views_manager_addEventListeners).call(this)}reset(){this.isInitialViewSet=!1;this.isInitialEventDispatched=!1;views_manager_assertClassBrand(pw,this,_hideUINotification).call(this,!0);this.switchView(oh);this.outlineButton.disabled=this.attachmentsButton.disabled=this.layersButton.disabled=!1;this.outlineButton.hidden=!1;this.attachmentsButton.hidden=!1;this.layersButton.hidden=!1;this.viewsManagerCurrentOutlineButton&&(this.viewsManagerCurrentOutlineButton.disabled=!0)}get visibleView(){return this.isOpen?this.active:nh}setInitialView(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nh;if(!this.isInitialViewSet){this.isInitialViewSet=!0;if(e!==nh&&e!==rh){this.switchView(e,!0);this.isInitialEventDispatched||views_manager_assertClassBrand(pw,this,_dispatchEvent).call(this)}else views_manager_assertClassBrand(pw,this,_dispatchEvent).call(this)}}switchView(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const i=e!==this.active;let a=!1,s=null;switch(e){case nh:this.isOpen&&this.close();return;case oh:s="pagesTitle";this.isOpen&&i&&(a=!0);break;case lh:s="outlinesTitle";if(this.outlineButton.disabled)return;break;case ch:s="attachmentsTitle";if(this.attachmentsButton.disabled)return;break;case dh:s="layersTitle";if(this.layersButton.disabled)return;break;default:ngx_console_NgxConsole.error(`PDFSidebar.switchView: "${e}" is not a valid view.`);return}this._enableSplitMerge&&this.viewsManagerStatus&&(this.viewsManagerStatus.hidden=e!==oh);this.viewsManagerAddFileButton&&(this.viewsManagerAddFileButton.hidden=!this._enableMerge||e!==oh);this.viewsManagerCurrentOutlineButton&&(this.viewsManagerCurrentOutlineButton.hidden=e!==lh);this.viewsManagerHeaderLabel&&this.viewsManagerHeaderLabel.setAttribute("data-l10n-id",gw._[s]||"");this.active=e;toggleSelectedBtn(this.thumbnailButton,e===oh,this.thumbnailsView);toggleSelectedBtn(this.outlineButton,e===lh,this.outlinesView);toggleSelectedBtn(this.attachmentsButton,e===ch,this.attachmentsView);toggleSelectedBtn(this.layersButton,e===dh,this.layersView);if(!t||this.isOpen){if(a){this.onUpdateThumbnails();this.onToggled()}i&&views_manager_assertClassBrand(pw,this,_dispatchEvent).call(this)}else this.open()}open(){if(!this.isOpen&&this._sidebar){this.isOpen=!0;this.onResizing(this.width);this._sidebar.hidden=!1;toggleExpandedBtn(this.toggleButton,!0);this.switchView(this.active);if(views_manager_classPrivateFieldGet(_w,this))queueMicrotask(()=>{this.outerContainer.classList.add("viewsManagerMoving","viewsManagerOpen")});else{this.outerContainer.classList.add("viewsManagerOpen");this.eventBus.dispatch("resize",{source:this,sidebarToggle:!0})}this.active===oh&&this.onUpdateThumbnails();this.onToggled();views_manager_assertClassBrand(pw,this,_dispatchEvent).call(this);views_manager_assertClassBrand(pw,this,_hideUINotification).call(this)}}close(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(this.isOpen&&this._sidebar){this.isOpen=!1;this._sidebar.hidden=!0;toggleExpandedBtn(this.toggleButton,!1);this.outerContainer.classList.add("viewsManagerMoving");this.outerContainer.classList.remove("viewsManagerOpen");this.onToggled();views_manager_assertClassBrand(pw,this,_dispatchEvent).call(this);this.eventBus.dispatch("resize",{source:this,sidebarToggle:!0});e?.detail>0&&this.toggleButton.blur()}}toggle(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;super.toggle();this.isOpen?this.close(e):this.open()}onStartResizing(){this.outerContainer.classList.add(hw)}onStopResizing(){this.eventBus.dispatch("resize",{source:this});this.outerContainer.classList.remove(hw)}onResizing(e){Fh.setProperty("--viewsManager-width",`${e}px`)}}function _dispatchEvent(){this.isInitialViewSet&&(this.isInitialEventDispatched||=!0);this.eventBus.dispatch("sidebarviewchanged",{source:this,view:this.visibleView})}function _showUINotification(){this.toggleButton.setAttribute("data-l10n-id",gw._.notificationButton);this.isOpen||this.toggleButton.classList.add(uw)}function _hideUINotification(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(this.isOpen||e)&&this.toggleButton.classList.remove(uw);e&&this.toggleButton.setAttribute("data-l10n-id",gw._.toggleButton)}function views_manager_addEventListeners(){const e=this.eventBus,t=this.outerContainer;views_manager_classPrivateFieldGet(_w,this)&&this.sidebarContainer&&this.sidebarContainer.addEventListener("transitionend",i=>{if(i.target===this.sidebarContainer){t.classList.remove("viewsManagerMoving");e.dispatch("resize",{source:this,sidebarToggle:!0})}});this.viewsManagerHeaderLabel?.addEventListener("dblclick",t=>{this.active!==lh?this.active===dh&&e.dispatch("resetlayers",{source:this}):e.dispatch("toggleoutlinetree",{source:this})});this.thumbnailButton?.addEventListener("click",()=>{this.switchView(oh)});this.outlineButton?.addEventListener("click",()=>{this.switchView(lh)});this.attachmentsButton?.addEventListener("click",()=>{this.switchView(ch)});this.layersButton?.addEventListener("click",()=>{this.switchView(dh)});this.viewsManagerCurrentOutlineButton?.addEventListener("click",()=>{e.dispatch("currentoutlineitem",{source:this})});const onTreeLoaded=(e,t,i)=>{t.disabled=!e;t.hidden=!e;e?views_manager_assertClassBrand(pw,this,_showUINotification).call(this):this.active===i&&this.switchView(oh)};e.on("outlineloaded",e=>{onTreeLoaded(e.outlineCount,this.outlineButton,lh);e.currentOutlineItemPromise.then(e=>{this.isInitialViewSet&&this.viewsManagerCurrentOutlineButton&&(this.viewsManagerCurrentOutlineButton.disabled=!e)})},Ih);e.on("attachmentsloaded",e=>{onTreeLoaded(e.attachmentsCount,this.attachmentsButton,ch)},Ih);e.on("layersloaded",e=>{onTreeLoaded(e.layersCount,this.layersButton,dh)},Ih);e.on("presentationmodechanged",e=>{e.state===ih&&this.visibleView===oh&&this.onUpdateThumbnails()},Ih)}var gw={_:null};function app_slicedToArray(e,t){return function app_arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function app_iterableToArrayLimit(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var a,s,r,n,o=[],l=!0,c=!1;try{if(r=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;l=!1}else for(;!(l=(a=r.call(i)).done)&&(o.push(a.value),o.length!==t);l=!0);}catch(e){c=!0,s=e}finally{try{if(!l&&null!=i.return&&(n=i.return(),Object(n)!==n))return}finally{if(c)throw s}}return o}}(e,t)||function app_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return app_arrayLikeToArray(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?app_arrayLikeToArray(e,t):void 0}}(e,t)||function app_nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function app_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,a=Array(t);i<t;i++)a[i]=e[i];return a}const fw=-1,mw=1,vw={initialBookmark:document.location.hash.substring(1),_initializedCapability:{...Promise.withResolvers(),settled:!1},appConfig:null,pdfDocument:null,pdfLoadingTask:null,printService:null,pdfViewer:null,pdfThumbnailViewer:null,pdfRenderingQueue:null,pdfPresentationMode:null,pdfDocumentProperties:null,pdfLinkService:null,pdfTextExtractor:null,pdfHistory:null,viewsManager:null,pdfOutlineViewer:null,pdfAttachmentViewer:null,pdfLayerViewer:null,pdfCursorTools:null,pdfScriptingManager:null,pdfWorker:null,store:null,downloadManager:null,overlayManager:null,preferences:new class Preferences extends BasePreferences{async _writeToStorage(e){try{localStorage.setItem("pdfjs.preferences",JSON.stringify(e))}catch(e){}}async _readFromStorage(e){try{return{prefs:JSON.parse(localStorage.getItem("pdfjs.preferences"))}}catch(e){return{}}}},toolbar:null,secondaryToolbar:null,eventBus:null,l10n:null,annotationEditorParams:null,imageAltTextSettings:null,isInitialViewSet:!1,isViewerEmbedded:window.parent!==window,url:"",baseUrl:"",mlManager:null,_downloadUrl:"",_eventBusAC:null,_windowAC:null,_globalAbortController:new AbortController,documentInfo:null,metadata:null,_contentDispositionFilename:null,_contentLength:null,_saveInProgress:!1,_wheelUnusedTicks:0,_wheelUnusedFactor:1,_touchManager:null,_touchUnusedTicks:0,_touchUnusedFactor:1,_PDFBug:null,_hasAnnotationEditors:!1,_title:document.title,_printAnnotationStoragePromise:null,_isCtrlKeyDown:!1,_caretBrowsing:null,_isScrolling:!1,editorUndoBar:null,pageOrder:null,_printPermissionPromise:null,async initialize(e){this.appConfig=e;this.cspPolicyService=e.cspPolicyService;try{await this.preferences.initializedPromise}catch(e){ngx_console_NgxConsole.error("initialize:",e)}AppOptions.get("pdfBugEnabled")&&await this._parseHashParams();let t;switch(AppOptions.get("viewerCssTheme")){case 1:t="light";break;case 2:t="dark"}t&&Fh.setProperty("color-scheme",t);this.l10n=await this.externalServices.createL10n();document.getElementsByTagName("html")[0].dir=this.l10n.getDirection();this.l10n.translate(e.appContainer||document.documentElement);this.isViewerEmbedded&&AppOptions.get("externalLinkTarget")===Gh.NONE&&AppOptions.set("externalLinkTarget",Gh.TOP);await this._initializeViewerComponents();this.bindEvents();this.bindWindowEvents();this._initializedCapability.settled=!0;this._initializedCapability.resolve();this.initializeLoadingBar()},async _parseHashParams(){const e=document.location.hash.substring(1);if(!e)return;const t=this.appConfig,i=t.mainContainer,a=t.viewerContainer,s=parseQueryString(e),loadPDFBug=async()=>{if(this._PDFBug)return;const e=(await import(
/*webpackIgnore: true*/
/*@vite-ignore*/
AppOptions.get("debuggerSrc"))).PDFBug;this._PDFBug=e};if("true"===s.get("disableworker"))try{GlobalWorkerOptions.workerSrc||=AppOptions.get("workerSrc");await import(
/*webpackIgnore: true*/
/*@vite-ignore*/
PDFWorker.workerSrc);AppOptions.set("workerPort",null)}catch(e){ngx_console_NgxConsole.error("_parseHashParams:",e)}if(s.has("textlayer"))switch(s.get("textlayer")){case"off":AppOptions.set("textLayerMode",hh);break;case"visible":case"shadow":case"hover":a.classList.add(`textLayer-${s.get("textlayer")}`);try{await loadPDFBug();this._PDFBug.loadCSS()}catch(e){ngx_console_NgxConsole.error("_parseHashParams:",e)}}if(s.has("pdfbug")){const e=s.get("pdfbug").split(",");try{await loadPDFBug();this._PDFBug.init(i,e)}catch(e){ngx_console_NgxConsole.error("_parseHashParams:",e)}const t={pdfBug:!0,fontExtraProperties:!0};globalThis.StepperManager?.enabled&&(t.minDurationToUpdateCanvas=0);AppOptions.setAll(t)}s.has("locale")&&AppOptions.set("localeProperties",{lang:s.get("locale")});const r={disableAutoFetch:e=>"true"===e,disableFontFace:e=>"true"===e,disableHistory:e=>"true"===e,disableRange:e=>"true"===e,disableStream:e=>"true"===e,verbosity:e=>0|e};for(const e in r){const t=r[e],i=e.toLowerCase();s.has(i)&&AppOptions.set(e,t(s.get(i)))}},async _initializeViewerComponents(){const e=this.appConfig,t=this.externalServices,i=this.l10n,a=this.mlManager,s=this._globalAbortController.signal,r=new EventBus;this.eventBus=AppOptions.eventBus=r;a?.setEventBus(r,s);const n=this.overlayManager=new OverlayManager,o=this.pdfRenderingQueue=new PDFRenderingQueue;o.onIdle=this._cleanup.bind(this);const l=this.pdfLinkService=new PDFLinkService({eventBus:r,externalLinkTarget:AppOptions.get("externalLinkTarget"),externalLinkRel:AppOptions.get("externalLinkRel"),ignoreDestinationZoom:AppOptions.get("ignoreDestinationZoom")}),c=this.downloadManager=new DownloadManager;let d=PDFFindController;AppOptions.get("findController")&&(d=AppOptions.get("findController"));const h=new d({linkService:l,eventBus:r,pageViewMode:AppOptions.get("pageViewMode"),updateMatchesCountOnProgress:!0,listenToEventBus:!1});this.customFindController=h;const u=new d({linkService:l,eventBus:r,pageViewMode:AppOptions.get("pageViewMode"),updateMatchesCountOnProgress:!0,listenToEventBus:!0});this.findController=u;const _=this.pdfScriptingManager=new PDFScriptingManager({eventBus:r,externalServices:t,docProperties:this._scriptingDocProperties.bind(this)}),p=e.mainContainer,g=e.viewerContainer,f=AppOptions.get("annotationEditorMode"),m=AppOptions.get("forcePageColors")||window.matchMedia("(forced-colors: active)").matches,v=m?{background:AppOptions.get("pageColorsBackground"),foreground:AppOptions.get("pageColorsForeground")}:null,y=AppOptions.get("enableMerge"),w=AppOptions.get("enableSplitMerge");let b;b=AppOptions.get("enableUpdatedAddImage")?e.newAltTextDialog?new NewAltTextManager(e.newAltTextDialog,n,r):null:e.altTextDialog?new AltTextManager(e.altTextDialog,p,n,r):null;e.editorUndoBar&&(this.editorUndoBar=new EditorUndoBar(e.editorUndoBar,r));const S=AppOptions.get("enableSignatureEditor")&&e.addSignatureDialog?new SignatureManager(e.addSignatureDialog,e.editSignatureDialog,e.annotationEditorParams?.editorSignatureAddSignature||null,n,i,t.createSignatureStorage(r,s),r):null,C=AppOptions.get("enableComment")&&e.editCommentDialog?new CommentManager(e.editCommentDialog,{learnMoreUrl:AppOptions.get("commentLearnMoreUrl"),sidebar:e.annotationEditorParams?.editorCommentsSidebar||null,sidebarResizer:e.annotationEditorParams?.editorCommentsSidebarResizer||null,commentsList:e.annotationEditorParams?.editorCommentsSidebarList||null,commentCount:e.annotationEditorParams?.editorCommentsSidebarCount||null,sidebarTitle:e.annotationEditorParams?.editorCommentsSidebarTitle||null,closeButton:e.annotationEditorParams?.editorCommentsSidebarCloseButton||null,commentToolbarButton:e.toolbar?.editorCommentButton||null},r,l,n,"ltr"===i.getDirection(),m,s):null,A=AppOptions.get("maxCanvasPixels"),x=AppOptions.get("maxCanvasDim"),k=AppOptions.get("capCanvasAreaFactor"),E=this.pdfViewer=new PDFViewer({container:p,viewer:g,viewerAlert:e.viewerAlert,eventBus:r,renderingQueue:o,linkService:l,downloadManager:c,altTextManager:b,commentManager:C,signatureManager:S,editorUndoBar:this.editorUndoBar,findController:u,customFindController:h,scriptingManager:AppOptions.get("enableScripting")&&_,l10n:i,textLayerMode:AppOptions.get("textLayerMode"),annotationMode:AppOptions.get("annotationMode"),annotationEditorMode:f,annotationEditorHighlightColors:AppOptions.get("highlightEditorColors"),enableHighlightFloatingButton:AppOptions.get("enableHighlightFloatingButton"),enableUpdatedAddImage:AppOptions.get("enableUpdatedAddImage"),enableNewAltTextWhenAddingImage:AppOptions.get("enableNewAltTextWhenAddingImage"),imageResourcesPath:AppOptions.get("imageResourcesPath"),removePageBorders:AppOptions.get("removePageBorders"),enablePrintAutoRotate:AppOptions.get("enablePrintAutoRotate"),maxCanvasPixels:A,maxCanvasDim:x,capCanvasAreaFactor:k,enableDetailCanvas:AppOptions.get("enableDetailCanvas"),pageViewMode:AppOptions.get("pageViewMode"),enablePermissions:AppOptions.get("enablePermissions"),enableOptimizedPartialRendering:AppOptions.get("enableOptimizedPartialRendering"),enableSelectionRendering:AppOptions.get("enableSelectionRendering"),imagesRightClickMinSize:AppOptions.get("imagesRightClickMinSize"),pageColors:v,mlManager:a,abortSignal:s,defaultCacheSize:AppOptions.get("defaultCacheSize"),minZoom:AppOptions.get("minZoom"),maxZoom:AppOptions.get("maxZoom"),cspPolicyService:this.cspPolicyService,supportsPinchToZoom:this.supportsPinchToZoom,enableAutoLinking:AppOptions.get("enableAutoLinking"),minDurationToUpdateCanvas:AppOptions.get("minDurationToUpdateCanvas")});o.setViewer(E);l.setViewer(E);_.setViewer(E);if(e.viewsManager?.thumbnailsView){const t=e.viewsManager;this.pdfThumbnailViewer=new PDFThumbnailViewer({container:t.thumbnailsView,eventBus:r,renderingQueue:o,linkService:l,maxCanvasPixels:A,maxCanvasDim:x,pageColors:v,abortSignal:s,enableSplitMerge:w,enableMerge:y,enablePageReordering:AppOptions.get("enablePageReordering"),enableNewBadge:AppOptions.get("enableNewBadge"),statusBar:t.viewsManagerStatusBar,undoBar:t.viewsManagerUndoBar,manageMenu:t.manageMenu,waitingBar:t.viewsManagerWaitingBar,addFileComponent:t.viewsManagerAddFile});o.setThumbnailViewer(this.pdfThumbnailViewer)}if(!this.isViewerEmbedded&&!AppOptions.get("disableHistory")){this.pdfHistory=new PDFHistory({linkService:l,eventBus:r});l.setHistory(this.pdfHistory)}!this.supportsIntegratedFind&&e.findBar&&(this.findBar=new PDFFindBar(e.findBar,e.principalContainer,r));if(e.annotationEditorParams)if(f!==P.DISABLE){const t=e.toolbar?.editorSignatureButton;t&&AppOptions.get("enableSignatureEditor")&&(t.parentElement.hidden=!1);const i=document.getElementById("movePageUp"),a=document.getElementById("movePageDown");if(i&&a)if(AppOptions.get("enablePageReordering")){i.hidden=!1;a.hidden=!1}else{i.hidden=!0;a.hidden=!0}const s=e.toolbar?.editorCommentButton;s&&AppOptions.get("enableComment")&&(s.parentElement.hidden=!1);this.annotationEditorParams=new AnnotationEditorParams(e.annotationEditorParams,r)}else for(const e of["editorModeButtons","editorModeSeparator"])document.getElementById(e)?.classList.add("hidden");a&&e.secondaryToolbar?.imageAltTextSettingsButton&&(this.imageAltTextSettings=new ImageAltTextSettings(e.altTextSettingsDialog,n,r,a));e.documentProperties&&(this.pdfDocumentProperties=new PDFDocumentProperties(e.documentProperties,n,r,i,()=>this._docFilename,()=>this._docTitle));e.secondaryToolbar?.cursorHandToolButton&&(this.pdfCursorTools=new PDFCursorTools({container:p,eventBus:r,cursorToolOnLoad:AppOptions.get("cursorToolOnLoad")}));e.toolbar&&(this.toolbar=new Toolbar(e.toolbar,r,AppOptions.get("defaultZoomValue"),AppOptions.get("minZoom"),AppOptions.get("maxZoom"),AppOptions.get("toolbarDensity")));if(e.secondaryToolbar){if(AppOptions.get("enableAltText")){e.secondaryToolbar.imageAltTextSettingsButton?.classList.remove("hidden");e.secondaryToolbar.imageAltTextSettingsSeparator?.classList.remove("hidden")}this.secondaryToolbar=new SecondaryToolbar(e.secondaryToolbar,r)}this.supportsFullscreen&&(e.toolbar?.presentationModeButton||e.secondaryToolbar?.presentationModeButton)&&(this.pdfPresentationMode=new PDFPresentationMode({container:p,pdfViewer:E,eventBus:r}));const T=AppOptions.get("passwordPrompt");T?this.passwordPrompt=T:e.passwordOverlay&&(this.passwordPrompt=new PasswordPrompt(e.passwordOverlay,n,this.isViewerEmbedded));e.viewsManager?.outlinesView&&(this.pdfOutlineViewer=new PDFOutlineViewer({container:e.viewsManager.outlinesView,eventBus:r,l10n:i,linkService:l,downloadManager:c}));e.viewsManager?.attachmentsView&&(this.pdfAttachmentViewer=new PDFAttachmentViewer({container:e.viewsManager.attachmentsView,eventBus:r,l10n:i,downloadManager:c}));e.viewsManager?.layersView&&(this.pdfLayerViewer=new PDFLayerViewer({container:e.viewsManager.layersView,eventBus:r,l10n:i}));if(e.viewsManager){this.viewsManager=new ViewsManager({elements:e.viewsManager,eventBus:r,l10n:i,enableMerge:y,enableSplitMerge:w,globalAbortSignal:s});this.viewsManager.onToggled=this.forceRendering.bind(this);this.viewsManager.onUpdateThumbnails=()=>{for(const e of E.getCachedPageViews())e.renderingState===Ff.FINISHED&&this.pdfThumbnailViewer.getThumbnail(e.id-1)?.setImage(e);this.pdfThumbnailViewer.scrollThumbnailIntoView(E.currentPageNumber)}}},async run(e){await this.initialize(e);const t=this.appConfig,i=this.eventBus;let a;a=parseQueryString(document.location.search.substring(1)).get("file")??AppOptions.get("defaultUrl");try{a=new URL(a).href}catch{a=encodeURIComponent(a).replaceAll("%2F","/")}validateFileURL(a);const s=this._openFileInput=document.createElement("input");s.id="fileInput";s.className="ngx-extended-pdf-viewer-file-input";s.hidden=!0;s.type="file";s.value=null;s.accept=".pdf,application/pdf";document.body.append(s);s.addEventListener("change",function(e){const t=e.target.files;t&&0!==t.length&&i.dispatch("fileinputchange",{source:this,fileInput:e.target})});t.mainContainer.addEventListener("dragover",function(e){if(AppOptions.get("enableDragAndDrop")){if(!e.dataTransfer?.items)return;for(const t of e.dataTransfer.items)if("application/pdf"===t.type){e.dataTransfer.dropEffect="copy"===e.dataTransfer.effectAllowed?"copy":"move";stopEvent(e);return}}});t.mainContainer.addEventListener("drop",function(e){if(AppOptions.get("enableDragAndDrop")){const t=e.dataTransfer?.files;if(!t||0===t.length||"application/pdf"!==t[0].type)return;stopEvent(e);i.dispatch("fileinputchange",{source:this,fileInput:e.dataTransfer,dropEvent:e})}});if(!AppOptions.get("supportsDocumentFonts")){AppOptions.set("disableFontFace",!0);this.l10n.get("pdfjs-web-fonts-disabled").then(e=>{ngx_console_NgxConsole.warn(e)})}const togglePrintingButtons=e=>{t.toolbar?.print?.classList.toggle("hidden",!e);t.secondaryToolbar?.printButton?.classList.toggle("hidden",!e)};this.supportsPrinting?i.on("printingallowed",e=>{let t=e.isAllowed;return togglePrintingButtons(t)}):togglePrintingButtons(!1);if(!this.supportsFullscreen){t.toolbar.presentationModeButton.classList.add("hidden");t.secondaryToolbar?.presentationModeButton?.classList.add("hidden")}this.supportsIntegratedFind&&t.findBar?.toggleButton?.classList.add("hidden");a?this.open({url:a}):this._hideViewBookmark();const r=new CustomEvent("webviewerinitialized",{bubbles:!0,cancelable:!0,detail:{source:window}});document.dispatchEvent(r)},get externalServices(){return shadow(this,"externalServices",new ExternalServices)},get initialized(){return this._initializedCapability.settled},get initializedPromise(){return this._initializedCapability.promise},updateZoom(e,t,i){this.pdfViewer.isInPresentationMode||this.pdfViewer.updateScale({drawingDelay:AppOptions.get("defaultZoomDelay"),steps:e,scaleFactor:t,origin:i})},zoomIn(){this.updateZoom(1)},zoomOut(){this.updateZoom(-1)},zoomReset(){this.pdfViewer.isInPresentationMode||(this.pdfViewer.currentScaleValue=Qd)},touchPinchCallback(e,t,i){if(this.supportsPinchToZoom){const a=this._accumulateFactor(this.pdfViewer.currentScale,i/t,"_touchUnusedFactor");this.updateZoom(null,a,e)}else{const a=30,s=this._accumulateTicks((i-t)/a,"_touchUnusedTicks");this.updateZoom(s,null,e)}},touchPinchEndCallback(){this._touchUnusedTicks=0;this._touchUnusedFactor=1},get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0},get page(){return this.pdfViewer.currentPageNumber},set page(e){this.pdfViewer.currentPageNumber=e},get supportsPrinting(){return shadow(this,"supportsPrinting",AppOptions.get("supportsPrinting")&&PDFPrintServiceFactory.supportsPrinting)},get supportsFullscreen(){return shadow(this,"supportsFullscreen",document.fullscreenEnabled)},get supportsPinchToZoom(){return shadow(this,"supportsPinchToZoom",AppOptions.get("supportsPinchToZoom"))},get supportsIntegratedFind(){return shadow(this,"supportsIntegratedFind",AppOptions.get("supportsIntegratedFind"))},initializeLoadingBar(){const e=document.getElementById("loadingBar"),t=e?new ProgressBar(e):null;t?.hide();return shadow(this,"loadingBar",t)},get supportsMouseWheelZoomCtrlKey(){return shadow(this,"supportsMouseWheelZoomCtrlKey",AppOptions.get("supportsMouseWheelZoomCtrlKey"))},get supportsMouseWheelZoomMetaKey(){return shadow(this,"supportsMouseWheelZoomMetaKey",AppOptions.get("supportsMouseWheelZoomMetaKey"))},get supportsCaretBrowsingMode(){return AppOptions.get("supportsCaretBrowsingMode")},moveCaret(e,t){this._caretBrowsing||=new CaretBrowsingMode(this._globalAbortController.signal,this.appConfig.mainContainer,this.appConfig.viewerContainer,this.appConfig.toolbar?.container);this._caretBrowsing.moveCaret(e,t)},setTitleUsingUrl(){},setTitle(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._title;this._title=e;if(this.isViewerEmbedded)return;const t=this._hasChanges()&&!this.pdfRenderingQueue.printing;document.title=`${t?"* ":""}${e}`},get _docFilename(){return this._contentDispositionFilename||getPdfFilenameFromUrl(this.url,vw.appConfig.filenameForDownload)},get _docTitle(){const e=this.documentInfo,t=this.metadata,i=t?.get("dc:title");return i&&"Untitled"!==i&&!/[\uFFF0-\uFFFF]/.test(i)?i:e.Title},_hideViewBookmark(){if(!this.appConfig)return;const e=this.appConfig.secondaryToolbar;e?.viewBookmarkButton.classList.add("hidden");e?.presentationModeButton?.classList.contains("hidden")&&document.getElementById("viewBookmarkSeparator")?.classList.add("hidden")},async close(){this._unblockDocumentLoadEvent();this._hideViewBookmark();if(!this.pdfLoadingTask)return;if(this._hasChanges()&&this._hasRealAnnotationChanges())try{await this.downloadOrSave()}catch{}const e=[];e.push(this.pdfLoadingTask.destroy());this.pdfLoadingTask=null;if(this.pdfDocument){this.pdfDocument=null;this.pdfThumbnailViewer?.setDocument(null);this.pdfViewer.setDocument(null);this.pdfLinkService.setDocument(null);this.pdfDocumentProperties?.setDocument(null)}this.pdfLinkService.externalLinkEnabled=!0;this.store=null;this.isInitialViewSet=!1;this.url="";this.baseUrl="";this._downloadUrl="";this.documentInfo=null;this.metadata=null;this._contentDispositionFilename=null;this._contentLength=null;this._saveInProgress=!1;this._hasAnnotationEditors=!1;e.push(this.pdfScriptingManager.destroyPromise,this.passwordPrompt.close());this.setTitle();this.viewsManager?.reset();this.pdfOutlineViewer?.reset();this.pdfAttachmentViewer?.reset();this.pdfLayerViewer?.reset();this.pdfHistory?.reset();this.findBar?.reset();this.toolbar?.reset();this.secondaryToolbar?.reset();this._PDFBug?.cleanup();await Promise.all(e)},async open(e){this.pdfViewer?.destroyBookMode();this.pdfLoadingTask&&await this.close();const t=AppOptions.getAll(hn);t.cspPolicyService=e.cspPolicyService;if(e.workerSrc&&e.workerSrc!==t.workerSrc){t.workerSrc=e.workerSrc;this.pdfWorker=null}Object.assign(GlobalWorkerOptions,t);t.port=t.port??GlobalWorkerOptions.workerPort;t.cspPolicyService=this.cspPolicyService;null===this.pdfWorker&&(this.pdfWorker=t.port?PDFWorker.fromPort(t):new PDFWorker(t));e.data&&isPdfFile(e.filename)?this._contentDispositionFilename=e.filename:e.url&&this.setTitleUsingUrl(e.originalUrl||e.url,e.url);const i=getDocument({...AppOptions.getAll(dn),...e,worker:this.pdfWorker,cspPolicyService:e.cspPolicyService});this.pdfLoadingTask=i;i.onPassword=(e,t)=>{this.isViewerEmbedded&&this._unblockDocumentLoadEvent();this.pdfLinkService.externalLinkEnabled=!1;this.passwordPrompt.setUpdateCallback(e,t);this.passwordPrompt.open()};i.onProgress=e=>{this.progress(e.percent);this.eventBus?.dispatch("progress",{source:this,type:"load",total:e.total,loaded:e.loaded,percent:e.percent})};const a=this.serviceWorkerOptions.showUnverifiedSignatures;return i.promise.then(e=>{e._transport.messageHandler.send("showUnverifiedSignatures",a);this.load(e)},e=>{if(i!==this.pdfLoadingTask)return;this.loadingBar&&(this.loadingBar.percent||=0);let t="pdfjs-loading-error";e instanceof InvalidPDFException?t="pdfjs-invalid-file-error":e instanceof ResponseException&&(t=e.missing?"pdfjs-missing-file-error":"pdfjs-unexpected-response-error");vw.onError&&vw.onError(e);return this._documentError(t,{message:e.message}).then(()=>{throw e})})},async download(){let e;try{e=await(this.pdfDocument?this.pdfDocument.getData():this.pdfLoadingTask.getData())}catch{}this.downloadManager.download(e,this._downloadUrl,this._docFilename)},async save(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(this._saveInProgress)return;this._saveInProgress=!0;await this.pdfScriptingManager.dispatchWillSave();try{const t=await this.pdfDocument.saveDocument(e);this.downloadManager.download(t,this._downloadUrl,this._docFilename)}catch(e){ngx_console_NgxConsole.error("Error when saving the document:",e);await this.download()}finally{await this.pdfScriptingManager.dispatchDidSave();this._saveInProgress=!1}const t=this.pdfDocument?.annotationStorage.editorStats;t&&this.externalServices.reportTelemetry({type:"editing",data:{type:"save",stats:t}})},async downloadOrSave(){const e=this.appConfig.appContainer.classList;e.add("wait");if(this.pdfThumbnailViewer?.hasStructuralChanges()){this.externalServices.reportTelemetry({type:"pageOrganization",data:{action:"save"}});await this.onSavePages({data:this.pdfThumbnailViewer.getStructuralChanges()})}else{const e=this.pdfDocument?.annotationStorage.size>0||!this.pageOrder.every((e,t,i)=>0===t||e>=i[t-1]);await(e?this.save(this.pageOrder):this.download())}delete this._mergedDocumentNeedsSaving;this.setTitle();e.remove("wait")},movePageUp(e){if(!(e.source.pageNumber<=1)){this.pdfViewer.swapPages(e.source.pageNumber-1,e.source.pageNumber-2);this.pdfThumbnailViewer.swapThumbnails(e.source.pageNumber-1,e.source.pageNumber-2);this.page=e.source.pageNumber-1;var t=[this.pageOrder[e.source.pageNumber-1],this.pageOrder[e.source.pageNumber-2]];this.pageOrder[e.source.pageNumber-2]=t[0];this.pageOrder[e.source.pageNumber-1]=t[1]}},movePageDown(e){if(e.source.pageNumber!==this.pdfDocument.numPages){this.pdfViewer.swapPages(e.source.pageNumber-1,e.source.pageNumber);this.pdfThumbnailViewer.swapThumbnails(e.source.pageNumber-1,e.source.pageNumber);this.page=e.source.pageNumber+1;var t=[this.pageOrder[e.source.pageNumber],this.pageOrder[e.source.pageNumber-1]];this.pageOrder[e.source.pageNumber-1]=t[0];this.pageOrder[e.source.pageNumber]=t[1]}},movePage(e,t){if(e<1||e>this.pdfDocument.numPages||t<1||t>this.pdfDocument.numPages)return;const i=e-1,a=t-1;if(i<a)for(let e=i;e<a;e++){this.pdfViewer.swapPages(e,e+1);this.pdfThumbnailViewer.swapThumbnails(e,e+1);var s=[this.pageOrder[e+1],this.pageOrder[e]];this.pageOrder[e]=s[0];this.pageOrder[e+1]=s[1]}else if(i>a)for(let e=i;e>a;e--){this.pdfViewer.swapPages(e,e-1);this.pdfThumbnailViewer.swapThumbnails(e,e-1);var r=[this.pageOrder[e-1],this.pageOrder[e]];this.pageOrder[e]=r[0];this.pageOrder[e-1]=r[1]}this.page=t},async _exportWithAnnotations(){if(this._saveInProgress)throw new Error("Already downloading");this._saveInProgress=!0;await this.pdfScriptingManager.dispatchWillSave();try{this._ensureDownloadComplete();const e=await this.pdfDocument.saveDocument();return new Blob([e],{type:"application/pdf"})}catch(e){throw new Error(`Error when saving the document: ${e.message}`)}finally{await this.pdfScriptingManager.dispatchDidSave();this._saveInProgress=!1}},_ensureDownloadComplete(){if(!this.pdfDocument)throw new Error("PDF document not downloaded.")},async _exportWithoutAnnotations(){try{this._ensureDownloadComplete();const e=await this.pdfDocument.getData();return new Blob([e],{type:"application/pdf"})}catch(e){throw new Error(`Error when saving the document: ${e.message}`)}},async export(){return this.pdfDocument?.annotationStorage.size>0?this._exportWithAnnotations():this._exportWithoutAnnotations()},openInExternalApp(){this.downloadOrSave({openInExternalApp:!0})},async _documentError(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._unblockDocumentLoadEvent();const i=await this._otherError(e||"pdfjs-loading-error",t);this.eventBus.dispatch("documenterror",{source:this,message:i,reason:t?.message??null})},async _otherError(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=await this.l10n.get(e),a=[`PDF.js v${Hn||"?"} (build: ${zn||"?"})`];if(t){a.push(`Message: ${t.message}`);if(t.stack)a.push(`Stack: ${t.stack}`);else{t.filename&&a.push(`File: ${t.filename}`);t.lineNumber&&a.push(`Line: ${t.lineNumber}`)}}ngx_console_NgxConsole.error(`${i}\n\n${a.join("\n")}`);return i},progress(e){if(this.loadingBar&&!(e<=this.loadingBar.percent)){this.loadingBar.percent=e;(this.pdfDocument?.loadingParams.disableAutoFetch??AppOptions.get("disableAutoFetch"))&&this.loadingBar.setDisableAutoFetch()}},load(e){this.pdfDocument=e;this._printPermissionPromise=new Promise(e=>{this.eventBus.on("printingallowed",t=>{let i=t.isAllowed;e(i)},{once:!0})});e.getDownloadInfo().then(e=>{let t=e.length;this._contentLength=t;this.loadingBar?.hide();r.then(()=>{this.eventBus?.dispatch("documentloaded",{source:this})})});const t=e.getPageLayout().catch(()=>{}),i=e.getPageMode().catch(()=>{}),a=e.getOpenAction().catch(()=>{});this.toolbar?.setPagesCount(e.numPages,!1);this.secondaryToolbar?.setPagesCount(e.numPages);this.pdfLinkService.setDocument(e);this.pdfDocumentProperties?.setDocument(e);const s=this.pdfViewer;s.setDocument(e);const r=s.firstPagePromise,n=s.onePageRendered,o=s.pagesPromise;this.pdfThumbnailViewer?.setDocument(e);const l=(this.store=new ViewHistory(e.fingerprints[0])).getMultiple({page:null,zoom:Qd,scrollLeft:"0",scrollTop:"0",rotation:null,sidebarView:rh,scrollMode:ph.UNKNOWN,spreadMode:gh.UNKNOWN}).catch(()=>{});r.then(r=>{this.loadingBar?.setWidth(this.appConfig.viewerContainer);this._initializeAnnotationStorageCallbacks(e);Promise.all([bh,l,t,i,a]).then(async t=>{let i=app_slicedToArray(t,5),a=(i[0],i[1]),r=i[2],n=i[3],l=i[4];const c=AppOptions.get("viewOnLoad");this._initializePdfHistory({fingerprint:e.fingerprints[0],viewOnLoad:c,initialDest:l?.dest});const d=this.initialBookmark;let h=AppOptions.get("defaultZoomValue");if(!h||""===h)try{h=await this.store.get("zoom");"string"==typeof h&&(h=h?.replace("%",""));isNaN(Number(h))||(h=Number(h)/100)}catch(e){}!s.currentScaleValue&&h&&""!==h&&(s.currentScaleValue=h);let u=h?`zoom=${h}`:null,_=null,p=AppOptions.get("sidebarViewOnLoad"),g=AppOptions.get("scrollModeOnLoad"),f=AppOptions.get("spreadModeOnLoad");this.eventBus&&this.eventBus.dispatch("storedvaluesavailable",{source:this,fingerprint:e.fingerprints[0],storedZoom:a?.zoom,storedPage:a?.page,defaultZoom:AppOptions.get("defaultZoomValue")});if(a?.page&&c!==mw){u=`page=${a.page}&zoom=${h||a.zoom},${a.scrollLeft},${a.scrollTop}`;_=parseInt(a.rotation,10);p===rh&&(p=0|a.sidebarView);g===ph.UNKNOWN&&(g=0|a.scrollMode);f===gh.UNKNOWN&&(f=0|a.spreadMode)}n&&p===rh&&(p=function apiPageModeToSidebarView(e){switch(e){case"UseNone":return nh;case"UseThumbs":return oh;case"UseOutlines":return lh;case"UseAttachments":return ch;case"UseOC":return dh}return nh}(n));if(r&&g===ph.UNKNOWN&&f===gh.UNKNOWN){f=apiPageLayoutToViewerModes(r).spreadMode}this.setInitialView(u,{rotation:_,sidebarView:p,scrollMode:g,spreadMode:f});this.eventBus.dispatch("documentinit",{source:this});await Promise.race([o,new Promise(e=>{setTimeout(e,10)})]);if((d||u)&&!s.hasEqualPageSizes){this.initialBookmark=d;s.currentScaleValue=s.currentScaleValue;this.setInitialView(u)}}).catch(()=>{this.setInitialView()}).then(function(){s.update()})});o.then(()=>{this._unblockDocumentLoadEvent();this._initializeAutoPrint(e,a)},e=>{vw.onError&&vw.onError(e);this._documentError("pdfjs-loading-error",{message:e.message})});n.then(t=>{this.externalServices.reportTelemetry({type:"pageInfo",timestamp:t.timestamp});this.pdfOutlineViewer&&e.getOutline().then(t=>{e===this.pdfDocument&&this.pdfOutlineViewer.render({outline:t,pdfDocument:e})});this.pdfAttachmentViewer&&e.getAttachments().then(t=>{e===this.pdfDocument&&this.pdfAttachmentViewer.render({attachments:t})});this.pdfLayerViewer&&s.optionalContentConfigPromise.then(t=>{e===this.pdfDocument&&this.pdfLayerViewer.render({optionalContentConfig:t,pdfDocument:e})})});this._initializePageLabels(e);this._initializeMetadata(e);this._initializePageOrder(e)},async _scriptingDocProperties(e){if(!this.documentInfo){await new Promise(e=>{this.eventBus.on("metadataloaded",e,{once:!0,...Ih})});if(e!==this.pdfDocument)return null}if(!this._contentLength){await new Promise(e=>{this.eventBus.on("documentloaded",e,{once:!0,...Ih})});if(e!==this.pdfDocument)return null}return{...this.documentInfo,baseURL:this.baseUrl,filesize:this._contentLength,filename:this._docFilename,metadata:this.metadata?.getRaw(),authors:this.metadata?.get("dc:creator"),numPages:this.pagesCount,URL:this.url}},async _initializeAutoPrint(e,t){const i=app_slicedToArray(await Promise.all([t,this.pdfViewer.enableScripting?null:e.getJSActions()]),2),a=i[0],s=i[1];if(e!==this.pdfDocument)return;let r="Print"===a?.action;if(s){ngx_console_NgxConsole.warn("Warning: JavaScript support is not enabled");for(const e in s){if(r)break;switch(e){case"WillClose":case"WillSave":case"DidSave":case"WillPrint":case"DidPrint":continue}r=s[e].some(e=>yh.test(e))}}r&&this.triggerPrinting()},async _initializeMetadata(e){const t=await e.getMetadata(),i=t.info,a=t.metadata,s=t.contentDispositionFilename,r=t.contentLength,n=t.hasStructTree;if(e!==this.pdfDocument)return;this.externalServices.reportTelemetry({type:"taggedPDF",data:n});this.documentInfo=i;this.metadata=a;this._contentDispositionFilename??=s;this._contentLength??=r;AppOptions?.get("verbosity")>0&&ngx_console_NgxConsole.log(`PDF ${e.fingerprints[0]} [${i.PDFFormatVersion} ${(a?.get("pdf:producer")||i.Producer||"-").trim()} / ${(a?.get("xmp:creatortool")||i.Creator||"-").trim()}] (PDF.js: ${Hn||"?"} [${zn||"?"}]) modified by ngx-extended-pdf-viewer 28.0.0`);const o=this._docTitle;o?this.setTitle(`${o} - ${this._contentDispositionFilename||this._title}`):this._contentDispositionFilename&&this.setTitle(this._contentDispositionFilename);!i.IsXFAPresent||i.IsAcroFormPresent||e.isPureXfa?!i.IsAcroFormPresent&&!i.IsXFAPresent||this.pdfViewer.renderForms||ngx_console_NgxConsole.warn("Warning: Interactive form support is not enabled"):e.loadingParams.enableXfa?ngx_console_NgxConsole.warn("Warning: XFA Foreground documents are not supported"):ngx_console_NgxConsole.warn("Warning: XFA support is not enabled");i.IsSignaturesPresent&&ngx_console_NgxConsole.warn("Warning: Digital signatures validation is not supported");this.eventBus.dispatch("metadataloaded",{source:this})},async _initializePageOrder(e){e===this.pdfDocument&&(this.pageOrder=Array.from({length:this.pdfDocument.numPages},(e,t)=>t+1))},async _initializePageLabels(e){const t=await e.getPageLabels();if(e!==this.pdfDocument)return;if(!t||AppOptions.get("disablePageLabels"))return;const i=t.length;let a=0,s=0;for(let e=0;e<i;e++){const i=t[e];if(i===(e+1).toString())a++;else{if(""!==i)break;s++}}if(a>=i||s>=i)return;const r=this.pdfViewer,n=this.pdfThumbnailViewer,o=this.toolbar;r.setPageLabels(t);n?.setPageLabels(t);o?.setPagesCount(i,!0);o?.setPageNumber(r.currentPageNumber,r.currentPageLabel)},_initializePdfHistory(e){let t=e.fingerprint,i=e.viewOnLoad,a=e.initialDest,s=void 0===a?null:a;if(this.pdfHistory){this.pdfHistory.initialize({fingerprint:t,resetHistory:i===mw||!!this._mergedDocumentNeedsSaving,updateUrl:AppOptions.get("historyUpdateUrl")});if(this.pdfHistory.initialBookmark){this.initialBookmark=this.pdfHistory.initialBookmark;this.initialRotation=this.pdfHistory.initialRotation}if(s&&!this.initialBookmark&&i===fw){this.initialBookmark=JSON.stringify(s);this.pdfHistory.push({explicitDest:s,pageNumber:null})}}},_hasChanges(){return this.pdfDocument?.annotationStorage.size>0||this.pdfThumbnailViewer?.hasStructuralChanges()||!0===this._mergedDocumentNeedsSaving},_initialAnnotationValues:null,_initializeAnnotationStorageCallbacks(e){if(e!==this.pdfDocument)return;const t=e.annotationStorage;t.onSetModified=()=>{this._annotationStorageModified=!0};t.onResetModified=()=>{delete this._annotationStorageModified;this._initialAnnotationValues=null};t.onAnnotationEditor=e=>{this._hasAnnotationEditors=!!e;this.setTitle()};this.eventBus._on("pagesloaded",()=>{setTimeout(()=>{this._captureInitialAnnotationValues()},200)})},_captureInitialAnnotationValues(){if(!this.pdfDocument?.annotationStorage)return;const e=this.pdfDocument.annotationStorage;this._initialAnnotationValues=new Map;for(const i of e){var t=app_slicedToArray(i,2);const e=t[0],a=t[1];this._initialAnnotationValues.set(e,JSON.parse(JSON.stringify(a)))}},setInitialAnnotationValues(){if(!this.pdfDocument?.annotationStorage)return;this._initialAnnotationValues=new Map;const e=this.pdfDocument.annotationStorage;for(const i of e){var t=app_slicedToArray(i,2);const e=t[0],a=t[1];this._initialAnnotationValues.set(e,JSON.parse(JSON.stringify(a)))}},_hasRealAnnotationChanges(){if(!this.pdfDocument?.annotationStorage||!this._initialAnnotationValues)return this._annotationStorageModified;const e=this.pdfDocument.annotationStorage,t=new Map;for(const a of e){var i=app_slicedToArray(a,2);const e=i[0],s=i[1];t.set(e,s)}if(t.size!==this._initialAnnotationValues.size)return!0;for(const e of t){var a=app_slicedToArray(e,2);const t=a[0],i=a[1],s=this._initialAnnotationValues.get(t);if(!s)return!0;if(JSON.stringify(i)!==JSON.stringify(s))return!0}for(const e of this._initialAnnotationValues.keys())if(!t.has(e))return!0;return!1},setInitialView(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.rotation,a=t.sidebarView,s=t.scrollMode,r=t.spreadMode;const setRotation=e=>{isValidRotation(e)&&(this.pdfViewer.pagesRotation=e)};this.isInitialViewSet=!0;this.viewsManager?.setInitialView(a);((e,t)=>{isValidScrollMode(e)&&(this.pdfViewer.scrollMode=e);isValidSpreadMode(t)&&(this.pdfViewer.spreadMode=t)})(s,r);if(this.initialBookmark){setRotation(this.initialRotation);delete this.initialRotation;this.pdfLinkService.setHash&&this.pdfLinkService.setHash(this.initialBookmark);this.initialBookmark=null}else if(e){setRotation(i);this.pdfLinkService.setHash&&this.pdfLinkService.setHash(e)}this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber,this.pdfViewer.currentPageLabel);this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);if(!this.pdfViewer.currentScaleValue){const e=AppOptions?.get("defaultZoomValue");e&&(this.pdfViewer.currentScaleValue=e)}},_cleanup(){if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null}if(this.pdfDocument){this.pdfViewer.cleanup();this.pdfThumbnailViewer?.cleanup();this.pdfDocument.cleanup(AppOptions.get("fontExtraProperties"))}},forceRendering(){this.pdfRenderingQueue.printing=!!this.printService;this.pdfRenderingQueue.isThumbnailViewEnabled=this.viewsManager?.visibleView===oh;this.pdfRenderingQueue.renderHighestPriority()},beforePrint(){this._printAnnotationStoragePromise=this.pdfScriptingManager.dispatchWillPrint().catch(()=>{}).then(()=>this.pdfDocument?.annotationStorage.print);if(!this.printService)if(this.supportsPrinting&&this.pdfViewer.printingAllowed)if(this.pdfViewer.pageViewsReady){this.printService=PDFPrintServiceFactory.createPrintService({pdfDocument:this.pdfDocument,pagesOverview:this.pdfViewer.getPagesOverview(),printResolution:AppOptions.get("printResolution"),printAnnotationStoragePromise:this._printAnnotationStoragePromise,pageOrder:this.pageOrder,eventBus:this.pdfViewer.eventBus,cspPolicyService:this.cspPolicyService});this.forceRendering();this.setTitle();this.printService.layout();this._hasAnnotationEditors&&this.externalServices.reportTelemetry({type:"editing",data:{type:"print",stats:this.pdfDocument?.annotationStorage.editorStats}})}else this.l10n.get("pdfjs-printing-not-ready").then(e=>{window.alert(e)});else this._otherError("pdfjs-printing-not-supported")},afterPrint(){if(this._printAnnotationStoragePromise){this._printAnnotationStoragePromise.then(()=>{this.pdfScriptingManager.dispatchDidPrint()});this._printAnnotationStoragePromise=null}if(this.printService){this.printService.destroy();this.printService=null;this.pdfDocument?.annotationStorage.resetModified()}this.forceRendering();this.setTitle()},rotatePages(e){this.pdfViewer.pagesRotation+=e},requestPresentationMode(){this.pdfPresentationMode?.request()},async triggerPrinting(){this.supportsPrinting&&await this._printPermissionPromise&&this.printPdf()},bindEvents(){if(this._eventBusAC)return;const e={signal:(this._eventBusAC=new AbortController).signal,...Ih},t=this.eventBus,i=(this.externalServices,this.pdfDocumentProperties),a=this.pdfViewer;this.preferences;t.on("resize",onResize.bind(this),e);t.on("hashchange",onHashchange.bind(this),e);t.on("beforeprint",this.beforePrint.bind(this),e);t.on("afterprint",this.afterPrint.bind(this),e);t.on("pagerender",onPageRender.bind(this),e);t.on("pagerendered",onPageRendered.bind(this),e);t.on("updateviewarea",onUpdateViewarea.bind(this),e);t.on("pagechanging",onPageChanging.bind(this),e);t.on("scalechanging",onScaleChanging.bind(this),e);t.on("rotationchanging",onRotationChanging.bind(this),e);t.on("sidebarviewchanged",onSidebarViewChanged.bind(this),e);t.on("pagemode",onPageMode.bind(this),e);t.on("namedaction",onNamedAction.bind(this),e);t.on("toggleSidebar",function(e){let t=e.visible;this.viewsManager&&(t?this.viewsManager.open():this.viewsManager.close())}.bind(this),e);t.on("presentationmodechanged",e=>a.presentationModeState=e.state,e);t.on("presentationmode",this.requestPresentationMode.bind(this),e);t.on("switchannotationeditormode",e=>a.annotationEditorMode=e,e);t.on("print",this.triggerPrinting.bind(this),e);t.on("download",this.downloadOrSave.bind(this),e);t.on("movePageUp",this.movePageUp.bind(this),e);t.on("movePageDown",this.movePageDown.bind(this),e);t.on("firstpage",()=>this.page=1,e);t.on("lastpage",()=>this.page=this.pagesCount,e);t.on("nextpage",()=>a.nextPage(),e);t.on("previouspage",()=>a.previousPage(),e);t.on("zoomin",this.zoomIn.bind(this),e);t.on("zoomout",this.zoomOut.bind(this),e);t.on("zoomreset",this.zoomReset.bind(this),e);t.on("pagenumberchanged",onPageNumberChanged.bind(this),e);t.on("scalechanged",e=>a.currentScaleValue=e.value,e);t.on("rotatecw",this.rotatePages.bind(this,90),e);t.on("rotateccw",this.rotatePages.bind(this,-90),e);t.on("optionalcontentconfig",e=>a.optionalContentConfigPromise=e.promise,e);t.on("switchscrollmode",e=>a.scrollMode=e.mode,e);t.on("scrollmodechanged",onViewerModesChanged.bind(this,"scrollMode"),e);t.on("switchspreadmode",e=>a.spreadMode=e.mode,e);t.on("spreadmodechanged",onViewerModesChanged.bind(this,"spreadMode"),e);t.on("imagealttextsettings",onImageAltTextSettings.bind(this),e);t.on("documentproperties",()=>i?.open(),e);t.on("findfromurlhash",onFindFromUrlHash.bind(this),e);t.on("updatefindmatchescount",onUpdateFindMatchesCount.bind(this),e);t.on("updatefindcontrolstate",onUpdateFindControlState.bind(this),e);t.on("fileinputchange",onFileInputChange.bind(this),e);t.on("openfile",onOpenFile.bind(this),e);t.on("pagesedited",this.onPagesEdited.bind(this),e);t.on("saveextractedpages",this.onSavePages.bind(this),e);t.on("saveandload",this.onSaveAndLoad.bind(this),e)},bindWindowEvents(){if(this._windowAC)return;this._windowAC=new AbortController;const e=this.eventBus,t=this.appConfig.mainContainer,i=this.pdfViewer,a=this._windowAC.signal;this._touchManager=new TouchManager({container:window,isPinchingDisabled:()=>i.isInPresentationMode,isPinchingStopped:()=>this.overlayManager?.active,onPinching:this.touchPinchCallback.bind(this),onPinchEnd:this.touchPinchEndCallback.bind(this),signal:a});!function addWindowResolutionChange(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)&&i.refresh();window.matchMedia(`(resolution: ${OutputScale.pixelRatio}dppx)`).addEventListener("change",addWindowResolutionChange,{once:!0,signal:a})}();const s=document.getElementById("viewerContainer");s?.addEventListener("wheel",onWheel.bind(this),{passive:!1,signal:a});window.addEventListener("wheel",onWheel.bind(this),{passive:!1,signal:a});window.addEventListener("click",onClick.bind(this),{signal:a});window.addEventListener("keydown",onKeyDown.bind(this),{signal:a});window.addEventListener("keyup",onKeyUp.bind(this),{signal:a});if(s){let i,a=t.clientWidth,s=t.clientHeight;this.resizeObserver=new ResizeObserver(r=>{const n=t.clientWidth,o=t.clientHeight;if(n!==a||o!==s){clearTimeout(i);i=setTimeout(()=>{t.offsetParent&&e.dispatch("resize",{source:t})},50);a=n;s=o}});this.resizeObserver.observe(t)}else window.addEventListener("resize",()=>e.dispatch("resize",{source:window}),{signal:a});window.addEventListener("hashchange",()=>{e.dispatch("hashchange",{source:window,hash:document.location.hash.substring(1)})},{signal:a});window.addEventListener("beforeprint",()=>e.dispatch("beforeprint",{source:window}),{signal:a});window.addEventListener("afterprint",()=>e.dispatch("afterprint",{source:window}),{signal:a});window.addEventListener("updatefromsandbox",t=>{e.dispatch("updatefromsandbox",{source:window,detail:t.detail})},{signal:a});window.addEventListener("beforeunload",onBeforeUnload.bind(this),{signal:a});if(!("onscrollend"in document.documentElement))return;this._lastScrollTop=t.scrollTop;this._lastScrollLeft=t.scrollLeft;let r,n;const scrollend=()=>{this._lastScrollTop=t.scrollTop;this._lastScrollLeft=t.scrollLeft;clearTimeout(r);if(this._isScrolling){n.abort();n=null;this._isScrolling=!1}};t.addEventListener("scroll",()=>{if(!this._isCtrlKeyDown&&(this._lastScrollTop!==t.scrollTop||this._lastScrollLeft!==t.scrollLeft)){if(!this._isScrolling){n=new AbortController;const e=AbortSignal.any([n.signal,a]);t.addEventListener("scrollend",scrollend,{signal:e});t.addEventListener("blur",scrollend,{signal:e});this._isScrolling=!0}clearTimeout(r);r=setTimeout(scrollend,100)}},{passive:!0,signal:a})},unbindEvents(){this._eventBusAC?.abort();this._eventBusAC=null},unbindWindowEvents(){this._windowAC?.abort();this._windowAC=null;this._touchManager=null},async testingClose(){this.unbindEvents();this.unbindWindowEvents();this._globalAbortController?.abort();this._globalAbortController=null;this.findBar?.close();await Promise.all([this.l10n?.destroy(),this.close()])},onPagesEdited(e){this.pdfViewer.onPagesEdited(e)},async onSavePages(e){let t=e.data;if(!this.pdfDocument)return;const i=await this.pdfDocument.extractPages(t);i?this.downloadManager.download(i,this._downloadUrl,this._docFilename):console.error("Something wrong happened when saving the edited PDF.\nPlease file a bug.")},async onSaveAndLoad(e){let t=e.data;if(!this.pdfDocument)return;const i=await this.pdfDocument.extractPages(t);if(i){this._mergedDocumentNeedsSaving=!0;this.open({data:i,filename:this._docFilename})}else console.error("Something wrong happened when saving the edited PDF.\nPlease file a bug.")},_accumulateTicks(e,t){(this[t]>0&&e<0||this[t]<0&&e>0)&&(this[t]=0);this[t]+=e;const i=Math.trunc(this[t]);this[t]-=i;return i},_accumulateFactor(e,t,i){if(1===t)return 1;(this[i]>1&&t<1||this[i]<1&&t>1)&&(this[i]=1);const a=Math.floor(e*t*this[i]*1e3)/(1e3*e);this[i]=t/a;return a},_unblockDocumentLoadEvent(){document.blockUnblockOnload?.(!1);this._unblockDocumentLoadEvent=()=>{}},get scriptingReady(){return this.pdfScriptingManager.ready}};PDFPrintServiceFactory.initGlobals(vw);{const e=new Set(["null","http://mozilla.github.io","https://mozilla.github.io"]);var validateFileURL=function(t){if(!t)return;const i=URL.parse(window.location)?.origin||"null";if(e.has(i))return;const a=URL.parse(t,window.location)?.origin;if(a===i)return;const s=new Error("file origin does not match viewer's");vw._documentError("pdfjs-loading-error",{message:s.message});vw.onError&&vw.onError(s);throw s},onFileInputChange=function(e){if(this.pdfViewer?.isInPresentationMode)return;const t=e.fileInput.files[0];this.open({url:URL.createObjectURL(t),originalUrl:encodeURIComponent(t.name)})},onOpenFile=function(e){this._openFileInput?.click()}}function onPageRender(e){e.pageNumber===this.page&&this.toolbar?.updateLoadingIndicatorState(!0)}function onPageRendered(e){let t=e.pageNumber,i=e.isDetailView,a=e.error;t===this.page&&this.toolbar?.updateLoadingIndicatorState(!1);if(!i&&this.viewsManager?.visibleView===oh){const e=this.pdfViewer.getPageView(t-1),i=this.pdfThumbnailViewer?.getThumbnail(t-1);e&&i?.setImage(e)}a&&this._otherError("pdfjs-rendering-error",a)}function onPageMode(e){let t,i=e.mode;switch(i){case"thumbs":t=oh;break;case"bookmarks":case"outline":t=lh;break;case"attachments":t=ch;break;case"layers":t=dh;break;case"none":t=nh;break;default:ngx_console_NgxConsole.error('Invalid "pagemode" hash parameter: '+i);return}this.viewsManager?.switchView(t,!0)}function onNamedAction(e){switch(e.action){case"GoToPage":this.appConfig.toolbar?.pageNumber.select();break;case"Find":this.supportsIntegratedFind||this.findBar?.toggle();break;case"Print":this.triggerPrinting();break;case"SaveAs":this.downloadOrSave()}}function onSidebarViewChanged(e){let t=e.view;this.pdfRenderingQueue.isThumbnailViewEnabled=t===oh;this.isInitialViewSet&&this.store?.set("sidebarView",t).catch(()=>{})}function onUpdateViewarea(e){let t=e.location;if(this.isInitialViewSet){const e={};void 0===t.pageNumber&&null===t.pageNumber||(e.page=t.pageNumber);t.scale&&(e.zoom=t.scale);t.left&&(e.scrollLeft=t.left);t.top&&(e.scrollTop=t.top);void 0===t.rotation&&null===t.rotation||(e.rotation=t.rotation);vw.store?.setMultiple(e).catch(()=>{})}this.appConfig.secondaryToolbar&&(this.appConfig.secondaryToolbar.viewBookmarkButton.href=this.pdfLinkService.getAnchorUrl(t.pdfOpenParams))}function onViewerModesChanged(e,t){this.isInitialViewSet&&!this.pdfViewer.isInPresentationMode&&this.store?.set(e,t.mode).catch(()=>{})}function onResize(e){const t=this.pdfDocument,i=this.pdfViewer;if(this.pdfRenderingQueue.printing&&window.matchMedia("print").matches)return;if(!t)return;const a=e?.sidebarToggle?i.currentPageNumber:0,s=i.currentScaleValue;"auto"!==s&&"page-fit"!==s&&"page-width"!==s||(i.currentScaleValue=s);i.update();a&&i.currentPageNumber!==a&&(i.currentPageNumber=a)}function onHashchange(e){const t=e.hash;t&&(this.isInitialViewSet?this.pdfHistory?.popStateInProgress||this.pdfLinkService.setHash&&this.pdfLinkService.setHash(t):this.initialBookmark=t)}function onPageNumberChanged(e){const t=this.pdfViewer;""!==e.value&&this.pdfLinkService.goToPage(e.value);e.value!==t.currentPageNumber.toString()&&e.value!==t.currentPageLabel&&this.toolbar?.setPageNumber(t.currentPageNumber,t.currentPageLabel)}function onImageAltTextSettings(){this.imageAltTextSettings?.open({enableGuessAltText:AppOptions.get("enableGuessAltText"),enableNewAltTextWhenAddingImage:AppOptions.get("enableNewAltTextWhenAddingImage")})}function onFindFromUrlHash(e){this.eventBus.dispatch("find",{source:e.source,type:"",query:e.query,caseSensitive:!1,entireWord:!1,highlightAll:!0,findPrevious:!1,matchDiacritics:!0})}function onUpdateFindMatchesCount(e){let t=e.matchesCount;this.supportsIntegratedFind?this.externalServices.updateFindMatchesCount(t):this.findBar?.updateResultsCount(t)}function onUpdateFindControlState(e){let t=e.state,i=e.previous,a=e.entireWord,s=e.matchesCount,r=e.rawQuery;this.supportsIntegratedFind?this.externalServices.updateFindControlState({result:t,findPrevious:i,entireWord:a,matchesCount:s,rawQuery:r}):this.findBar?.updateUIState(t,i,s)}function onScaleChanging(e){this.toolbar?.setPageScale(e.presetValue,e.scale);this.pdfViewer.update(e.noScroll);this.pdfViewer.updateBookModeScale(e)}function onRotationChanging(e){this.pdfThumbnailViewer&&(this.pdfThumbnailViewer.pagesRotation=e.pagesRotation);this.forceRendering();this.pdfViewer.currentPageNumber=e.pageNumber}function onPageChanging(e){let t=e.pageNumber,i=e.pageLabel;this.toolbar?.setPageNumber(t,i);this.secondaryToolbar?.setPageNumber(t);this.viewsManager?.visibleView===oh&&this.pdfThumbnailViewer?.scrollThumbnailIntoView(t);const a=this.pdfViewer.getPageView(t-1);this.toolbar?.updateLoadingIndicatorState(a?.renderingState===Ff.RUNNING);const s=document.getElementById("pageNumber");if(s){const e=new CustomEvent("page-change");s.dispatchEvent(e)}}function onWheel(e){const t=document.getElementById("viewerContainer");if(t.parentNode.querySelector(":hover")!==t)return;const i=this.pdfViewer,a=this.supportsMouseWheelZoomCtrlKey,s=this.supportsMouseWheelZoomMetaKey,r=this.supportsPinchToZoom;if(i.isInPresentationMode)return;const n=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(vw?.isKeyIgnored&&vw.isKeyIgnored(n,"WHEEL"))return;const o=e.deltaMode;let l=Math.exp(-e.deltaY/100);const c=e.ctrlKey&&!this._isCtrlKeyDown&&o===WheelEvent.DOM_DELTA_PIXEL&&0===e.deltaX&&(Math.abs(l-1)<.05||!1)&&0===e.deltaZ,d=[e.clientX,e.clientY];if(c||e.ctrlKey&&a||e.metaKey&&s){e.preventDefault();if(this._isScrolling||"hidden"===document.visibilityState||this.overlayManager.active)return;if(c&&r){l=this._accumulateFactor(i.currentScale,l,"_wheelUnusedFactor");this.updateZoom(null,l,d)}else{const t=normalizeWheelEventDirection(e);let i=0;if(o===WheelEvent.DOM_DELTA_LINE||o===WheelEvent.DOM_DELTA_PAGE)i=Math.abs(t)>=1?Math.sign(t):this._accumulateTicks(t,"_wheelUnusedTicks");else{const e=30;i=this._accumulateTicks(t/e,"_wheelUnusedTicks")}this.updateZoom(i,null,d)}}}function closeSecondaryToolbar(e){let t=e.target;if(!this.secondaryToolbar?.isOpen)return;const i=this.appConfig,a=i.toolbar,s=i.secondaryToolbar;if(this.pdfViewer.containsElement(t)||a?.container.contains(t)&&!s?.toolbar.contains(t)&&!s?.toggleButton.contains(t)){if(t&&t.parentElement===s.toggleButton)return;if(t&&t.parentElement&&t.parentElement.parentElement===s.toggleButton)return;this.secondaryToolbar.close()}}function closeEditorUndoBar(e){this.editorUndoBar?.isOpen&&this.appConfig.secondaryToolbar?.toolbar.contains(e.target)&&this.editorUndoBar.hide()}function onBeforeUnload(e){if(this._hasChanges()){e.preventDefault();e.returnValue="";return!1}return!0}function onClick(e){closeSecondaryToolbar.call(this,e);closeEditorUndoBar.call(this,e)}function onKeyUp(e){"Control"===e.key&&(this._isCtrlKeyDown=!1)}function onKeyDown(e){this._isCtrlKeyDown="Control"===e.key;this.editorUndoBar?.isOpen&&9!==e.keyCode&&16!==e.keyCode&&(13!==e.keyCode&&32!==e.keyCode||getActiveOrFocusedElement()!==this.appConfig.editorUndoBar.undoButton)&&this.editorUndoBar.hide();if(this.overlayManager.active)return;const t=this.eventBus,i=this.pdfViewer,a=i.isInPresentationMode;let s=!1,r=!1;const n=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(vw.ngxKeyboardManager&&vw.ngxKeyboardManager.isKeyIgnored.bind(vw.ngxKeyboardManager)(n,e.keyCode))return;if(1===n||8===n||5===n||12===n)switch(e.keyCode){case 70:if(!this.supportsIntegratedFind&&!e.shiftKey){if(AppOptions.get("textLayerMode")!==hh){let e=!1;const t=this.pdfViewer.viewer.closest("#outerContainer")?.querySelector("#primaryViewFind");t&&(e||=!t?.classList.contains("dummy-component"));const i=this.pdfViewer.viewer.closest("#outerContainer")?.querySelector("#secondaryToolbarToggle");if(!i.hidden){const t=this.pdfViewer.viewer.closest("#outerContainer")?.querySelector("#secondaryViewFind");t&&(e||=!t?.classList.contains("dummy-component"))}e&&this.findBar?.open()}s=!0}break;case 71:if(!this.supportsIntegratedFind){const e=this.findController.state;if(e){const i={source:window,type:"again",findPrevious:5===n||12===n};t.dispatch("find",{...e,...i})}s=!0}break;case 61:case 107:case 187:case 171:this.zoomIn();s=!0;break;case 173:case 109:case 189:this.zoomOut();s=!0;break;case 48:case 96:if(!a){setTimeout(()=>{this.zoomReset()});s=!1}break;case 38:if(a||this.page>1){this.page=1;s=!0;r=!0}break;case 40:if(a||this.page<this.pagesCount){this.page=this.pagesCount;s=!0;r=!0}}if(1===n||8===n)switch(e.keyCode){case 83:t.dispatch("download",{source:window});s=!0;break;case 79:t.dispatch("openfile",{source:window});s=!0}if(3===n||10===n)switch(e.keyCode){case 80:this.requestPresentationMode();s=!0;this.externalServices.reportTelemetry({type:"buttons",data:{id:"presentationModeKeyboard"}});break;case 71:if(this.appConfig.toolbar){this.appConfig.toolbar.pageNumber.select();s=!0}}if(s){r&&!a&&i.focus();e.preventDefault();return}const o=getActiveOrFocusedElement(),l=o?.tagName.toUpperCase();if(!("INPUT"===l||"TEXTAREA"===l||"SELECT"===l||"BUTTON"===l&&32===e.keyCode||o?.isContentEditable)||27===e.keyCode){if(0===n){let t=0,n=!1;switch(e.keyCode){case 38:if(this.supportsCaretBrowsingMode){this.moveCaret(!0,!1);s=!0;break}case 33:i.isVerticalScrollbarEnabled&&(n=!0);t=-1;break;case 8:a||(n=!0);t=-1;break;case 37:if(this.supportsCaretBrowsingMode)return;i.isHorizontalScrollbarEnabled&&(n=!0);case 75:case 80:t=-1;break;case 27:if(this.secondaryToolbar?.isOpen){this.secondaryToolbar.close();s=!0}if(!this.supportsIntegratedFind&&this.findBar?.opened){this.findBar.close();s=!0}if(!s){if([document.getElementById("editorHighlightParamsToolbar"),document.getElementById("editorFreeTextParamsToolbar"),document.getElementById("editorInkParamsToolbar"),document.getElementById("editorStampParamsToolbar"),document.getElementById("editorCommentParamsToolbar"),document.getElementById("editorSignatureParamsToolbar")].find(e=>e&&!e.classList.contains("hidden"))){this.eventBus.dispatch("switchannotationeditormode",{source:this,mode:P.NONE});s=!0}}break;case 40:if(this.supportsCaretBrowsingMode){this.moveCaret(!1,!1);s=!0;break}case 34:i.isVerticalScrollbarEnabled&&(n=!0);t=1;break;case 32:a||(n=!0);t=1;break;case 39:if(this.supportsCaretBrowsingMode)return;i.isHorizontalScrollbarEnabled&&(n=!0);case 74:case 78:t=1;break;case 36:if(a||this.page>1){this.page=1;s=!0;r=!0}break;case 35:if(a||this.page<this.pagesCount){this.page=this.pagesCount;s=!0;r=!0}break;case 83:this.pdfCursorTools?.switchTool(fh);break;case 72:this.pdfCursorTools?.switchTool(mh);break;case 82:this.rotatePages(90);break;case 115:this.viewsManager?.toggle()}0!==t&&"rtl"===AppOptions.get("readingDirection")&&(t=-t);if(0!==t&&(!n||"page-fit"===i.currentScaleValue)){(function viewerIsAllowedToCaptureKeyEvent(e){let t=document.activeElement;const i=e.closest("ngx-extended-pdf-viewer");for(;t&&t!==document.body;){if(t===i)return!0;if(-1!==t.tabIndex)return!1;t=t.parentElement}return!0})(this.appConfig.mainContainer)&&(t>0?i.nextPage():i.previousPage());s=!0}}if(4===n)switch(e.keyCode){case 32:if(!a&&"page-fit"!==i.currentScaleValue)break;i.previousPage();s=!0;break;case 38:this.moveCaret(!0,!0);s=!0;break;case 40:this.moveCaret(!1,!0);s=!0;break;case 82:this.rotatePages(-90)}r&&!i.containsElement(o)&&i.focus();s&&e.preventDefault()}}vw.printPdf=function printPdf(){if(this.enablePrint)if(mf)ngx_console_NgxConsole.warn("Ignored this.printPDF() because of a pending print job.");else{ensureOverlay().then(function(){mf&&yf.open(vf)});try{dispatchEvent("beforeprint")}finally{if(mf){const e=mf,t=document.createElement("div");t.id="printContainer";document.body.append(t);e.printContainer=t;mf.renderPages().then(function(){const t=document.getElementById("printServiceDialog");t&&t.classList.add("hidden");return e.performPrint()}).catch(()=>{}).then(()=>{e.active&&abort()})}else{ngx_console_NgxConsole.error("Expected print service to be initialized.");ensureOverlay().then(function(){yf.closeIfActive(vf)})}}}};vw.PDFPrintServiceFactory=PDFPrintServiceFactory;vw.ngxConsole=new ngx_console_NgxConsole;vw.serviceWorkerOptions={showUnverifiedSignatures:!1};const yw={LinkTarget:Gh,RenderingStates:Ff,ScrollMode:ph,SpreadMode:gh};HTMLCollection.prototype[Symbol.iterator]||(HTMLCollection.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator]);"function"!=typeof window.CustomEvent&&(window.CustomEvent=function CustomEvent(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};const i=document.createEvent("CustomEvent");i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail);return i});function webViewerLoad(e){const t=function getViewerConfiguration(){return{appContainer:document.getElementsByClassName("body")[0]??document.body,principalContainer:document.getElementById("mainContainer"),mainContainer:document.getElementById("viewerContainer"),viewerContainer:document.getElementById("viewer"),viewerAlert:document.getElementById("viewer-alert"),toolbar:{container:document.getElementById("toolbarContainer"),numPages:document.getElementById("numPages"),pageNumber:document.getElementById("pageNumber"),scaleSelect:document.getElementById("scaleSelect"),customScaleOption:document.getElementById("customScaleOption"),previous:document.getElementById("previous"),next:document.getElementById("next"),zoomIn:document.getElementById("primaryZoomIn")??document.getElementById("zoomInButton"),zoomOut:document.getElementById("primaryZoomOut")??document.getElementById("zoomOutButton"),print:document.getElementById("printButton"),editorCommentButton:document.getElementById("editorCommentButton"),editorCommentParamsToolbar:document.getElementById("editorCommentParamsToolbar"),editorFreeTextButton:document.getElementById("primaryEditorFreeText")??document.getElementById("editorFreeTextButton"),editorFreeTextParamsToolbar:document.getElementById("editorFreeTextParamsToolbar"),editorHighlightButton:document.getElementById("primaryEditorHighlight")??document.getElementById("editorHighlightButton"),editorHighlightParamsToolbar:document.getElementById("editorHighlightParamsToolbar"),editorHighlightColorPicker:document.getElementById("editorHighlightColorPicker"),editorInkButton:document.getElementById("primaryEditorInk")??document.getElementById("editorInkButton"),editorInkParamsToolbar:document.getElementById("editorInkParamsToolbar"),editorStampButton:document.getElementById("primaryEditorStamp")??document.getElementById("editorStampButton"),presentationModeButton:document.getElementById("presentationMode"),editorStampParamsToolbar:document.getElementById("editorStampParamsToolbar"),editorSignatureButton:document.getElementById("primaryEditorSignatureButton")??document.getElementById("editorSignatureButton"),editorSignatureParamsToolbar:document.getElementById("editorSignatureParamsToolbar"),download:document.getElementById("downloadButton"),movePageUp:document.getElementById("movePageUpButton"),movePageDown:document.getElementById("movePageDownButton")},secondaryToolbar:{toolbar:document.getElementById("secondaryToolbar"),toggleButton:document.getElementById("secondaryToolbarToggle"),presentationModeButton:document.getElementById("secondaryPresentationMode"),openFileButton:document.getElementById("secondaryOpenFile"),printButton:document.getElementById("secondaryPrintButton"),downloadButton:document.getElementById("secondaryDownload"),viewBookmarkButton:document.getElementById("viewBookmark"),firstPageButton:document.getElementById("firstPage"),lastPageButton:document.getElementById("lastPage"),pageRotateCwButton:document.getElementById("pageRotateCw"),pageRotateCcwButton:document.getElementById("pageRotateCcw"),cursorSelectToolButton:document.getElementById("cursorSelectTool"),cursorHandToolButton:document.getElementById("cursorHandTool"),scrollPageButton:document.getElementById("scrollPage"),scrollVerticalButton:document.getElementById("scrollVertical"),scrollHorizontalButton:document.getElementById("scrollHorizontal"),scrollWrappedButton:document.getElementById("scrollWrapped"),spreadNoneButton:document.getElementById("spreadNone"),spreadOddButton:document.getElementById("spreadOdd"),spreadEvenButton:document.getElementById("spreadEven"),imageAltTextSettingsButton:document.getElementById("imageAltTextSettings"),imageAltTextSettingsSeparator:document.getElementById("imageAltTextSettingsSeparator"),documentPropertiesButton:document.getElementById("documentProperties")},viewsManager:{outerContainer:document.getElementById("outerContainer"),toggleButton:document.getElementById("viewsManagerToggleButton")??document.getElementById("primarySidebarToggle")??document.getElementById("sidebarToggleButton"),sidebarContainer:document.getElementById("viewsManager")??document.getElementById("sidebarContainer"),resizer:document.getElementById("viewsManagerResizer")??document.getElementById("sidebarResizer"),thumbnailButton:document.getElementById("thumbnailsViewMenu")??document.getElementById("viewThumbnail"),outlineButton:document.getElementById("outlinesViewMenu")??document.getElementById("viewOutline"),attachmentsButton:document.getElementById("attachmentsViewMenu")??document.getElementById("viewAttachments"),layersButton:document.getElementById("layersViewMenu")??document.getElementById("viewLayers"),viewsManagerSelectorButton:document.getElementById("viewsManagerSelectorButton"),viewsManagerSelectorOptions:document.getElementById("viewsManagerSelectorOptions"),thumbnailsView:document.getElementById("thumbnailsView")??document.getElementById("thumbnailView"),outlinesView:document.getElementById("outlinesView")??document.getElementById("outlineView"),attachmentsView:document.getElementById("attachmentsView"),layersView:document.getElementById("layersView"),viewsManagerAddFile:{button:document.getElementById("viewsManagerAddFileButton"),picker:document.getElementById("viewsManagerAddFilePicker")},viewsManagerCurrentOutlineButton:document.getElementById("viewsManagerCurrentOutlineButton")??document.getElementById("currentOutlineItem"),viewsManagerHeaderLabel:document.getElementById("viewsManagerHeaderLabel"),viewsManagerStatus:document.getElementById("viewsManagerStatus"),viewsManagerStatusBar:{viewsManagerStatusAction:document.getElementById("viewsManagerStatusAction"),viewsManagerStatusActionDeselectButton:document.getElementById("viewsManagerStatusActionDeselectButton"),viewsManagerStatusActionLabel:document.getElementById("viewsManagerStatusActionLabel")},viewsManagerUndoBar:{viewsManagerStatusUndo:document.getElementById("viewsManagerStatusUndo"),viewsManagerStatusUndoLabel:document.getElementById("viewsManagerStatusUndoLabel"),viewsManagerStatusUndoButton:document.getElementById("viewsManagerStatusUndoButton"),viewsManagerStatusUndoCloseButton:document.getElementById("viewsManagerStatusUndoCloseButton")},viewsManagerWaitingBar:{container:document.getElementById("viewsManagerStatusWaiting"),closeButton:document.getElementById("viewsManagerStatusWaitingCloseButton"),label:document.getElementById("viewsManagerStatusWaitingLabel")},manageMenu:{button:document.getElementById("viewsManagerStatusActionButton"),menu:document.getElementById("viewsManagerStatusActionOptions"),copy:document.getElementById("viewsManagerStatusActionCopy"),cut:document.getElementById("viewsManagerStatusActionCut"),delete:document.getElementById("viewsManagerStatusActionDelete"),exportSelected:document.getElementById("viewsManagerStatusActionExport")}},findBar:{bar:document.getElementById("findbar"),toggleButton:document.getElementById("primaryViewFind")??document.getElementById("viewFindButton"),findField:document.getElementById("findInput"),highlightAllCheckbox:document.getElementById("findHighlightAll"),caseSensitiveCheckbox:document.getElementById("findMatchCase"),findMultipleCheckbox:document.getElementById("findMultiple"),matchRegExpCheckbox:document.getElementById("matchRegExp"),matchDiacriticsCheckbox:document.getElementById("findMatchDiacritics"),entireWordCheckbox:document.getElementById("findEntireWord"),findMsg:document.getElementById("findMsg"),findResultsCount:document.getElementById("findResultsCount"),findPreviousButton:document.getElementById("findPreviousButton")??document.getElementById("findPrevious"),findNextButton:document.getElementById("findNextButton")??document.getElementById("findNext")},passwordOverlay:{dialog:document.getElementById("passwordDialog"),label:document.getElementById("passwordText"),input:document.getElementById("password"),submitButton:document.getElementById("passwordSubmit"),cancelButton:document.getElementById("passwordCancel")},documentProperties:{dialog:document.getElementById("documentPropertiesDialog"),closeButton:document.getElementById("documentPropertiesClose"),fields:{fileName:document.getElementById("fileNameField"),fileSize:document.getElementById("fileSizeField"),title:document.getElementById("titleField"),author:document.getElementById("authorField"),subject:document.getElementById("subjectField"),keywords:document.getElementById("keywordsField"),creationDate:document.getElementById("creationDateField"),modificationDate:document.getElementById("modificationDateField"),creator:document.getElementById("creatorField"),producer:document.getElementById("producerField"),version:document.getElementById("versionField"),pageCount:document.getElementById("pageCountField"),pageSize:document.getElementById("pageSizeField"),linearized:document.getElementById("linearizedField")}},altTextDialog:{dialog:document.getElementById("altTextDialog"),optionDescription:document.getElementById("descriptionButton"),optionDecorative:document.getElementById("decorativeButton"),textarea:document.getElementById("descriptionTextarea"),cancelButton:document.getElementById("altTextCancel"),saveButton:document.getElementById("altTextSave")},newAltTextDialog:{dialog:document.getElementById("newAltTextDialog"),title:document.getElementById("newAltTextTitle"),descriptionContainer:document.getElementById("newAltTextDescriptionContainer"),textarea:document.getElementById("newAltTextDescriptionTextarea"),disclaimer:document.getElementById("newAltTextDisclaimer"),learnMore:document.getElementById("newAltTextLearnMore"),imagePreview:document.getElementById("newAltTextImagePreview"),createAutomatically:document.getElementById("newAltTextCreateAutomatically"),createAutomaticallyButton:document.getElementById("newAltTextCreateAutomaticallyButton"),downloadModel:document.getElementById("newAltTextDownloadModel"),downloadModelDescription:document.getElementById("newAltTextDownloadModelDescription"),error:document.getElementById("newAltTextError"),errorCloseButton:document.getElementById("newAltTextCloseButton"),cancelButton:document.getElementById("newAltTextCancel"),notNowButton:document.getElementById("newAltTextNotNow"),saveButton:document.getElementById("newAltTextSave")},altTextSettingsDialog:{dialog:document.getElementById("altTextSettingsDialog"),createModelButton:document.getElementById("createModelButton"),learnMore:document.getElementById("altTextSettingsLearnMore"),showAltTextDialogButton:document.getElementById("showAltTextDialogButton"),altTextSettingsCloseButton:document.getElementById("altTextSettingsCloseButton"),closeButton:document.getElementById("altTextSettingsCloseButton")},addSignatureDialog:{dialog:document.getElementById("addSignatureDialog"),panels:document.getElementById("addSignatureActionContainer"),typeButton:document.getElementById("addSignatureTypeButton"),typeInput:document.getElementById("addSignatureTypeInput"),drawButton:document.getElementById("addSignatureDrawButton"),drawSVG:document.getElementById("addSignatureDraw"),drawPlaceholder:document.getElementById("addSignatureDrawPlaceholder"),drawThickness:document.getElementById("addSignatureDrawThickness"),imageButton:document.getElementById("addSignatureImageButton"),imageSVG:document.getElementById("addSignatureImage"),imagePlaceholder:document.getElementById("addSignatureImagePlaceholder"),imagePicker:document.getElementById("addSignatureFilePicker"),imagePickerLink:document.getElementById("addSignatureImageBrowse"),description:document.getElementById("addSignatureDescription"),clearButton:document.getElementById("clearSignatureButton"),saveContainer:document.getElementById("addSignatureSaveContainer"),saveCheckbox:document.getElementById("addSignatureSaveCheckbox"),errorBar:document.getElementById("addSignatureError"),errorTitle:document.getElementById("addSignatureErrorTitle"),errorDescription:document.getElementById("addSignatureErrorDescription"),errorCloseButton:document.getElementById("addSignatureErrorCloseButton"),cancelButton:document.getElementById("addSignatureCancelButton"),addButton:document.getElementById("addSignatureAddButton")},editSignatureDialog:{dialog:document.getElementById("editSignatureDescriptionDialog"),description:document.getElementById("editSignatureDescription"),editSignatureView:document.getElementById("editSignatureView"),cancelButton:document.getElementById("editSignatureCancelButton"),updateButton:document.getElementById("editSignatureUpdateButton")},annotationEditorParams:{editorCommentsSidebar:document.getElementById("editorCommentsSidebar"),editorCommentsSidebarCount:document.getElementById("editorCommentsSidebarCount"),editorCommentsSidebarTitle:document.getElementById("editorCommentsSidebarTitle"),editorCommentsSidebarCloseButton:document.getElementById("editorCommentsSidebarCloseButton"),editorCommentsSidebarList:document.getElementById("editorCommentsSidebarList"),editorCommentsSidebarResizer:document.getElementById("editorCommentsSidebarResizer"),editorFreeTextFontSize:document.getElementById("editorFreeTextFontSize"),editorFreeTextColor:document.getElementById("editorFreeTextColor"),editorInkColor:document.getElementById("editorInkColor"),editorInkThickness:document.getElementById("editorInkThickness"),editorInkOpacity:document.getElementById("editorInkOpacity"),editorStampAddImage:document.getElementById("editorStampAddImage"),editorSignatureAddSignature:document.getElementById("editorSignatureAddSignature"),editorFreeHighlightThickness:document.getElementById("editorFreeHighlightThickness"),editorHighlightShowAll:document.getElementById("editorHighlightShowAll")},editorUndoBar:{container:document.getElementById("editorUndoBar"),message:document.getElementById("editorUndoBarMessage"),undoButton:document.getElementById("editorUndoBarUndoButton"),closeButton:document.getElementById("editorUndoBarCloseButton")},editCommentDialog:{dialog:document.getElementById("commentManagerDialog"),toolbar:document.getElementById("commentManagerToolbar"),title:document.getElementById("commentManagerTitle"),textInput:document.getElementById("commentManagerTextInput"),cancelButton:document.getElementById("commentManagerCancelButton"),saveButton:document.getElementById("commentManagerSaveButton")}}}(),i=new CustomEvent("webviewerloaded",{bubbles:!0,cancelable:!0,detail:{source:window}});document.dispatchEvent(i);t.cspPolicyService=e;vw.run(t)}document.blockUnblockOnload?.(!0);globalThis.STANDALONE_VIEWER&&("interactive"===document.readyState||"complete"===document.readyState?webViewerLoad():document.addEventListener("DOMContentLoaded",webViewerLoad,!0));const Pw=new CustomEvent("ngxViewerFileHasBeenLoaded",{detail:{PDFViewerApplication:vw,PDFViewerApplicationConstants:yw,PDFViewerApplicationOptions:AppOptions,webViewerLoad}});document.dispatchEvent(Pw);export{vw as PDFViewerApplication,yw as PDFViewerApplicationConstants,AppOptions as PDFViewerApplicationOptions,webViewerLoad};