@pdfme/ui 5.3.17-dev.1 → 5.3.17-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +139 -171
- package/dist/index.umd.js +12 -13
- package/dist/types/src/class.d.ts +2 -2
- package/dist/types/src/components/AppContextProvider.d.ts +2 -2
- package/dist/types/src/contexts.d.ts +2 -2
- package/dist/types/src/helper.d.ts +2 -2
- package/package.json +1 -1
- package/src/class.ts +4 -3
- package/src/components/AppContextProvider.tsx +2 -2
- package/src/components/Designer/Canvas/index.tsx +2 -11
- package/src/components/Designer/LeftSidebar.tsx +1 -1
- package/src/components/Designer/PluginIcon.tsx +2 -11
- package/src/components/Designer/RightSidebar/DetailView/index.tsx +9 -64
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableContainer.tsx +1 -20
- package/src/components/Designer/RightSidebar/ListView/SelectableSortableItem.tsx +1 -20
- package/src/components/Renderer.tsx +2 -9
- package/src/contexts.ts +2 -2
- package/src/helper.ts +9 -88
package/dist/index.umd.js
CHANGED
@@ -39,15 +39,15 @@ Add a <Suspense fallback=...> component higher in the tree to provide a loading
|
|
39
39
|
*
|
40
40
|
* @author Feross Aboukhadijeh <https://feross.org>
|
41
41
|
* @license MIT
|
42
|
-
*/var hasRequiredBuffer;function requireBuffer(){return hasRequiredBuffer||(hasRequiredBuffer=1,function(a){const s=requireBase64Js(),c=requireIeee754(),u=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;a.Buffer=A,a.SlowBuffer=I,a.INSPECT_MAX_BYTES=50;const d=2147483647;a.kMaxLength=d,A.TYPED_ARRAY_SUPPORT=p(),!A.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{const Ae=new Uint8Array(1),pe={foo:function(){return 42}};return Object.setPrototypeOf(pe,Uint8Array.prototype),Object.setPrototypeOf(Ae,pe),Ae.foo()===42}catch{return!1}}Object.defineProperty(A.prototype,"parent",{enumerable:!0,get:function(){if(A.isBuffer(this))return this.buffer}}),Object.defineProperty(A.prototype,"offset",{enumerable:!0,get:function(){if(A.isBuffer(this))return this.byteOffset}});function v(Ae){if(Ae>d)throw new RangeError('The value "'+Ae+'" is invalid for option "size"');const pe=new Uint8Array(Ae);return Object.setPrototypeOf(pe,A.prototype),pe}function A(Ae,pe,he){if(typeof Ae=="number"){if(typeof pe=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return y(Ae)}return b(Ae,pe,he)}A.poolSize=8192;function b(Ae,pe,he){if(typeof Ae=="string")return f(Ae,pe);if(ArrayBuffer.isView(Ae))return C(Ae);if(Ae==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Ae);if(xe(Ae,ArrayBuffer)||Ae&&xe(Ae.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(xe(Ae,SharedArrayBuffer)||Ae&&xe(Ae.buffer,SharedArrayBuffer)))return S(Ae,pe,he);if(typeof Ae=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const Ie=Ae.valueOf&&Ae.valueOf();if(Ie!=null&&Ie!==Ae)return A.from(Ie,pe,he);const ye=w(Ae);if(ye)return ye;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof Ae[Symbol.toPrimitive]=="function")return A.from(Ae[Symbol.toPrimitive]("string"),pe,he);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Ae)}A.from=function(Ae,pe,he){return b(Ae,pe,he)},Object.setPrototypeOf(A.prototype,Uint8Array.prototype),Object.setPrototypeOf(A,Uint8Array);function g(Ae){if(typeof Ae!="number")throw new TypeError('"size" argument must be of type number');if(Ae<0)throw new RangeError('The value "'+Ae+'" is invalid for option "size"')}function x(Ae,pe,he){return g(Ae),Ae<=0?v(Ae):pe!==void 0?typeof he=="string"?v(Ae).fill(pe,he):v(Ae).fill(pe):v(Ae)}A.alloc=function(Ae,pe,he){return x(Ae,pe,he)};function y(Ae){return g(Ae),v(Ae<0?0:_(Ae)|0)}A.allocUnsafe=function(Ae){return y(Ae)},A.allocUnsafeSlow=function(Ae){return y(Ae)};function f(Ae,pe){if((typeof pe!="string"||pe==="")&&(pe="utf8"),!A.isEncoding(pe))throw new TypeError("Unknown encoding: "+pe);const he=$(Ae,pe)|0;let Ie=v(he);const ye=Ie.write(Ae,pe);return ye!==he&&(Ie=Ie.slice(0,ye)),Ie}function m(Ae){const pe=Ae.length<0?0:_(Ae.length)|0,he=v(pe);for(let Ie=0;Ie<pe;Ie+=1)he[Ie]=Ae[Ie]&255;return he}function C(Ae){if(xe(Ae,Uint8Array)){const pe=new Uint8Array(Ae);return S(pe.buffer,pe.byteOffset,pe.byteLength)}return m(Ae)}function S(Ae,pe,he){if(pe<0||Ae.byteLength<pe)throw new RangeError('"offset" is outside of buffer bounds');if(Ae.byteLength<pe+(he||0))throw new RangeError('"length" is outside of buffer bounds');let Ie;return pe===void 0&&he===void 0?Ie=new Uint8Array(Ae):he===void 0?Ie=new Uint8Array(Ae,pe):Ie=new Uint8Array(Ae,pe,he),Object.setPrototypeOf(Ie,A.prototype),Ie}function w(Ae){if(A.isBuffer(Ae)){const pe=_(Ae.length)|0,he=v(pe);return he.length===0||Ae.copy(he,0,0,pe),he}if(Ae.length!==void 0)return typeof Ae.length!="number"||Ce(Ae.length)?v(0):m(Ae);if(Ae.type==="Buffer"&&Array.isArray(Ae.data))return m(Ae.data)}function _(Ae){if(Ae>=d)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+d.toString(16)+" bytes");return Ae|0}function I(Ae){return+Ae!=Ae&&(Ae=0),A.alloc(+Ae)}A.isBuffer=function(pe){return pe!=null&&pe._isBuffer===!0&&pe!==A.prototype},A.compare=function(pe,he){if(xe(pe,Uint8Array)&&(pe=A.from(pe,pe.offset,pe.byteLength)),xe(he,Uint8Array)&&(he=A.from(he,he.offset,he.byteLength)),!A.isBuffer(pe)||!A.isBuffer(he))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(pe===he)return 0;let Ie=pe.length,ye=he.length;for(let Pe=0,Ne=Math.min(Ie,ye);Pe<Ne;++Pe)if(pe[Pe]!==he[Pe]){Ie=pe[Pe],ye=he[Pe];break}return Ie<ye?-1:ye<Ie?1:0},A.isEncoding=function(pe){switch(String(pe).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},A.concat=function(pe,he){if(!Array.isArray(pe))throw new TypeError('"list" argument must be an Array of Buffers');if(pe.length===0)return A.alloc(0);let Ie;if(he===void 0)for(he=0,Ie=0;Ie<pe.length;++Ie)he+=pe[Ie].length;const ye=A.allocUnsafe(he);let Pe=0;for(Ie=0;Ie<pe.length;++Ie){let Ne=pe[Ie];if(xe(Ne,Uint8Array))Pe+Ne.length>ye.length?(A.isBuffer(Ne)||(Ne=A.from(Ne)),Ne.copy(ye,Pe)):Uint8Array.prototype.set.call(ye,Ne,Pe);else if(A.isBuffer(Ne))Ne.copy(ye,Pe);else throw new TypeError('"list" argument must be an Array of Buffers');Pe+=Ne.length}return ye};function $(Ae,pe){if(A.isBuffer(Ae))return Ae.length;if(ArrayBuffer.isView(Ae)||xe(Ae,ArrayBuffer))return Ae.byteLength;if(typeof Ae!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof Ae);const he=Ae.length,Ie=arguments.length>2&&arguments[2]===!0;if(!Ie&&he===0)return 0;let ye=!1;for(;;)switch(pe){case"ascii":case"latin1":case"binary":return he;case"utf8":case"utf-8":return ue(Ae).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he*2;case"hex":return he>>>1;case"base64":return de(Ae).length;default:if(ye)return Ie?-1:ue(Ae).length;pe=(""+pe).toLowerCase(),ye=!0}}A.byteLength=$;function P(Ae,pe,he){let Ie=!1;if((pe===void 0||pe<0)&&(pe=0),pe>this.length||((he===void 0||he>this.length)&&(he=this.length),he<=0)||(he>>>=0,pe>>>=0,he<=pe))return"";for(Ae||(Ae="utf8");;)switch(Ae){case"hex":return D(this,pe,he);case"utf8":case"utf-8":return q(this,pe,he);case"ascii":return U(this,pe,he);case"latin1":case"binary":return N(this,pe,he);case"base64":return j(this,pe,he);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return W(this,pe,he);default:if(Ie)throw new TypeError("Unknown encoding: "+Ae);Ae=(Ae+"").toLowerCase(),Ie=!0}}A.prototype._isBuffer=!0;function E(Ae,pe,he){const Ie=Ae[pe];Ae[pe]=Ae[he],Ae[he]=Ie}A.prototype.swap16=function(){const pe=this.length;if(pe%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let he=0;he<pe;he+=2)E(this,he,he+1);return this},A.prototype.swap32=function(){const pe=this.length;if(pe%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let he=0;he<pe;he+=4)E(this,he,he+3),E(this,he+1,he+2);return this},A.prototype.swap64=function(){const pe=this.length;if(pe%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let he=0;he<pe;he+=8)E(this,he,he+7),E(this,he+1,he+6),E(this,he+2,he+5),E(this,he+3,he+4);return this},A.prototype.toString=function(){const pe=this.length;return pe===0?"":arguments.length===0?q(this,0,pe):P.apply(this,arguments)},A.prototype.toLocaleString=A.prototype.toString,A.prototype.equals=function(pe){if(!A.isBuffer(pe))throw new TypeError("Argument must be a Buffer");return this===pe?!0:A.compare(this,pe)===0},A.prototype.inspect=function(){let pe="";const he=a.INSPECT_MAX_BYTES;return pe=this.toString("hex",0,he).replace(/(.{2})/g,"$1 ").trim(),this.length>he&&(pe+=" ... "),"<Buffer "+pe+">"},u&&(A.prototype[u]=A.prototype.inspect),A.prototype.compare=function(pe,he,Ie,ye,Pe){if(xe(pe,Uint8Array)&&(pe=A.from(pe,pe.offset,pe.byteLength)),!A.isBuffer(pe))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof pe);if(he===void 0&&(he=0),Ie===void 0&&(Ie=pe?pe.length:0),ye===void 0&&(ye=0),Pe===void 0&&(Pe=this.length),he<0||Ie>pe.length||ye<0||Pe>this.length)throw new RangeError("out of range index");if(ye>=Pe&&he>=Ie)return 0;if(ye>=Pe)return-1;if(he>=Ie)return 1;if(he>>>=0,Ie>>>=0,ye>>>=0,Pe>>>=0,this===pe)return 0;let Ne=Pe-ye,Le=Ie-he;const Oe=Math.min(Ne,Le),Fe=this.slice(ye,Pe),_e=pe.slice(he,Ie);for(let je=0;je<Oe;++je)if(Fe[je]!==_e[je]){Ne=Fe[je],Le=_e[je];break}return Ne<Le?-1:Le<Ne?1:0};function R(Ae,pe,he,Ie,ye){if(Ae.length===0)return-1;if(typeof he=="string"?(Ie=he,he=0):he>2147483647?he=2147483647:he<-2147483648&&(he=-2147483648),he=+he,Ce(he)&&(he=ye?0:Ae.length-1),he<0&&(he=Ae.length+he),he>=Ae.length){if(ye)return-1;he=Ae.length-1}else if(he<0)if(ye)he=0;else return-1;if(typeof pe=="string"&&(pe=A.from(pe,Ie)),A.isBuffer(pe))return pe.length===0?-1:T(Ae,pe,he,Ie,ye);if(typeof pe=="number")return pe=pe&255,typeof Uint8Array.prototype.indexOf=="function"?ye?Uint8Array.prototype.indexOf.call(Ae,pe,he):Uint8Array.prototype.lastIndexOf.call(Ae,pe,he):T(Ae,[pe],he,Ie,ye);throw new TypeError("val must be string, number or Buffer")}function T(Ae,pe,he,Ie,ye){let Pe=1,Ne=Ae.length,Le=pe.length;if(Ie!==void 0&&(Ie=String(Ie).toLowerCase(),Ie==="ucs2"||Ie==="ucs-2"||Ie==="utf16le"||Ie==="utf-16le")){if(Ae.length<2||pe.length<2)return-1;Pe=2,Ne/=2,Le/=2,he/=2}function Oe(_e,je){return Pe===1?_e[je]:_e.readUInt16BE(je*Pe)}let Fe;if(ye){let _e=-1;for(Fe=he;Fe<Ne;Fe++)if(Oe(Ae,Fe)===Oe(pe,_e===-1?0:Fe-_e)){if(_e===-1&&(_e=Fe),Fe-_e+1===Le)return _e*Pe}else _e!==-1&&(Fe-=Fe-_e),_e=-1}else for(he+Le>Ne&&(he=Ne-Le),Fe=he;Fe>=0;Fe--){let _e=!0;for(let je=0;je<Le;je++)if(Oe(Ae,Fe+je)!==Oe(pe,je)){_e=!1;break}if(_e)return Fe}return-1}A.prototype.includes=function(pe,he,Ie){return this.indexOf(pe,he,Ie)!==-1},A.prototype.indexOf=function(pe,he,Ie){return R(this,pe,he,Ie,!0)},A.prototype.lastIndexOf=function(pe,he,Ie){return R(this,pe,he,Ie,!1)};function B(Ae,pe,he,Ie){he=Number(he)||0;const ye=Ae.length-he;Ie?(Ie=Number(Ie),Ie>ye&&(Ie=ye)):Ie=ye;const Pe=pe.length;Ie>Pe/2&&(Ie=Pe/2);let Ne;for(Ne=0;Ne<Ie;++Ne){const Le=parseInt(pe.substr(Ne*2,2),16);if(Ce(Le))return Ne;Ae[he+Ne]=Le}return Ne}function M(Ae,pe,he,Ie){return le(ue(pe,Ae.length-he),Ae,he,Ie)}function k(Ae,pe,he,Ie){return le(se(pe),Ae,he,Ie)}function O(Ae,pe,he,Ie){return le(de(pe),Ae,he,Ie)}function H(Ae,pe,he,Ie){return le(oe(pe,Ae.length-he),Ae,he,Ie)}A.prototype.write=function(pe,he,Ie,ye){if(he===void 0)ye="utf8",Ie=this.length,he=0;else if(Ie===void 0&&typeof he=="string")ye=he,Ie=this.length,he=0;else if(isFinite(he))he=he>>>0,isFinite(Ie)?(Ie=Ie>>>0,ye===void 0&&(ye="utf8")):(ye=Ie,Ie=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Pe=this.length-he;if((Ie===void 0||Ie>Pe)&&(Ie=Pe),pe.length>0&&(Ie<0||he<0)||he>this.length)throw new RangeError("Attempt to write outside buffer bounds");ye||(ye="utf8");let Ne=!1;for(;;)switch(ye){case"hex":return B(this,pe,he,Ie);case"utf8":case"utf-8":return M(this,pe,he,Ie);case"ascii":case"latin1":case"binary":return k(this,pe,he,Ie);case"base64":return O(this,pe,he,Ie);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H(this,pe,he,Ie);default:if(Ne)throw new TypeError("Unknown encoding: "+ye);ye=(""+ye).toLowerCase(),Ne=!0}},A.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function j(Ae,pe,he){return pe===0&&he===Ae.length?s.fromByteArray(Ae):s.fromByteArray(Ae.slice(pe,he))}function q(Ae,pe,he){he=Math.min(Ae.length,he);const Ie=[];let ye=pe;for(;ye<he;){const Pe=Ae[ye];let Ne=null,Le=Pe>239?4:Pe>223?3:Pe>191?2:1;if(ye+Le<=he){let Oe,Fe,_e,je;switch(Le){case 1:Pe<128&&(Ne=Pe);break;case 2:Oe=Ae[ye+1],(Oe&192)===128&&(je=(Pe&31)<<6|Oe&63,je>127&&(Ne=je));break;case 3:Oe=Ae[ye+1],Fe=Ae[ye+2],(Oe&192)===128&&(Fe&192)===128&&(je=(Pe&15)<<12|(Oe&63)<<6|Fe&63,je>2047&&(je<55296||je>57343)&&(Ne=je));break;case 4:Oe=Ae[ye+1],Fe=Ae[ye+2],_e=Ae[ye+3],(Oe&192)===128&&(Fe&192)===128&&(_e&192)===128&&(je=(Pe&15)<<18|(Oe&63)<<12|(Fe&63)<<6|_e&63,je>65535&&je<1114112&&(Ne=je))}}Ne===null?(Ne=65533,Le=1):Ne>65535&&(Ne-=65536,Ie.push(Ne>>>10&1023|55296),Ne=56320|Ne&1023),Ie.push(Ne),ye+=Le}return F(Ie)}const L=4096;function F(Ae){const pe=Ae.length;if(pe<=L)return String.fromCharCode.apply(String,Ae);let he="",Ie=0;for(;Ie<pe;)he+=String.fromCharCode.apply(String,Ae.slice(Ie,Ie+=L));return he}function U(Ae,pe,he){let Ie="";he=Math.min(Ae.length,he);for(let ye=pe;ye<he;++ye)Ie+=String.fromCharCode(Ae[ye]&127);return Ie}function N(Ae,pe,he){let Ie="";he=Math.min(Ae.length,he);for(let ye=pe;ye<he;++ye)Ie+=String.fromCharCode(Ae[ye]);return Ie}function D(Ae,pe,he){const Ie=Ae.length;(!pe||pe<0)&&(pe=0),(!he||he<0||he>Ie)&&(he=Ie);let ye="";for(let Pe=pe;Pe<he;++Pe)ye+=$e[Ae[Pe]];return ye}function W(Ae,pe,he){const Ie=Ae.slice(pe,he);let ye="";for(let Pe=0;Pe<Ie.length-1;Pe+=2)ye+=String.fromCharCode(Ie[Pe]+Ie[Pe+1]*256);return ye}A.prototype.slice=function(pe,he){const Ie=this.length;pe=~~pe,he=he===void 0?Ie:~~he,pe<0?(pe+=Ie,pe<0&&(pe=0)):pe>Ie&&(pe=Ie),he<0?(he+=Ie,he<0&&(he=0)):he>Ie&&(he=Ie),he<pe&&(he=pe);const ye=this.subarray(pe,he);return Object.setPrototypeOf(ye,A.prototype),ye};function Z(Ae,pe,he){if(Ae%1!==0||Ae<0)throw new RangeError("offset is not uint");if(Ae+pe>he)throw new RangeError("Trying to access beyond buffer length")}A.prototype.readUintLE=A.prototype.readUIntLE=function(pe,he,Ie){pe=pe>>>0,he=he>>>0,Ie||Z(pe,he,this.length);let ye=this[pe],Pe=1,Ne=0;for(;++Ne<he&&(Pe*=256);)ye+=this[pe+Ne]*Pe;return ye},A.prototype.readUintBE=A.prototype.readUIntBE=function(pe,he,Ie){pe=pe>>>0,he=he>>>0,Ie||Z(pe,he,this.length);let ye=this[pe+--he],Pe=1;for(;he>0&&(Pe*=256);)ye+=this[pe+--he]*Pe;return ye},A.prototype.readUint8=A.prototype.readUInt8=function(pe,he){return pe=pe>>>0,he||Z(pe,1,this.length),this[pe]},A.prototype.readUint16LE=A.prototype.readUInt16LE=function(pe,he){return pe=pe>>>0,he||Z(pe,2,this.length),this[pe]|this[pe+1]<<8},A.prototype.readUint16BE=A.prototype.readUInt16BE=function(pe,he){return pe=pe>>>0,he||Z(pe,2,this.length),this[pe]<<8|this[pe+1]},A.prototype.readUint32LE=A.prototype.readUInt32LE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),(this[pe]|this[pe+1]<<8|this[pe+2]<<16)+this[pe+3]*16777216},A.prototype.readUint32BE=A.prototype.readUInt32BE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),this[pe]*16777216+(this[pe+1]<<16|this[pe+2]<<8|this[pe+3])},A.prototype.readBigUInt64LE=Se(function(pe){pe=pe>>>0,me(pe,"offset");const he=this[pe],Ie=this[pe+7];(he===void 0||Ie===void 0)&&we(pe,this.length-8);const ye=he+this[++pe]*2**8+this[++pe]*2**16+this[++pe]*2**24,Pe=this[++pe]+this[++pe]*2**8+this[++pe]*2**16+Ie*2**24;return BigInt(ye)+(BigInt(Pe)<<BigInt(32))}),A.prototype.readBigUInt64BE=Se(function(pe){pe=pe>>>0,me(pe,"offset");const he=this[pe],Ie=this[pe+7];(he===void 0||Ie===void 0)&&we(pe,this.length-8);const ye=he*2**24+this[++pe]*2**16+this[++pe]*2**8+this[++pe],Pe=this[++pe]*2**24+this[++pe]*2**16+this[++pe]*2**8+Ie;return(BigInt(ye)<<BigInt(32))+BigInt(Pe)}),A.prototype.readIntLE=function(pe,he,Ie){pe=pe>>>0,he=he>>>0,Ie||Z(pe,he,this.length);let ye=this[pe],Pe=1,Ne=0;for(;++Ne<he&&(Pe*=256);)ye+=this[pe+Ne]*Pe;return Pe*=128,ye>=Pe&&(ye-=Math.pow(2,8*he)),ye},A.prototype.readIntBE=function(pe,he,Ie){pe=pe>>>0,he=he>>>0,Ie||Z(pe,he,this.length);let ye=he,Pe=1,Ne=this[pe+--ye];for(;ye>0&&(Pe*=256);)Ne+=this[pe+--ye]*Pe;return Pe*=128,Ne>=Pe&&(Ne-=Math.pow(2,8*he)),Ne},A.prototype.readInt8=function(pe,he){return pe=pe>>>0,he||Z(pe,1,this.length),this[pe]&128?(255-this[pe]+1)*-1:this[pe]},A.prototype.readInt16LE=function(pe,he){pe=pe>>>0,he||Z(pe,2,this.length);const Ie=this[pe]|this[pe+1]<<8;return Ie&32768?Ie|4294901760:Ie},A.prototype.readInt16BE=function(pe,he){pe=pe>>>0,he||Z(pe,2,this.length);const Ie=this[pe+1]|this[pe]<<8;return Ie&32768?Ie|4294901760:Ie},A.prototype.readInt32LE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),this[pe]|this[pe+1]<<8|this[pe+2]<<16|this[pe+3]<<24},A.prototype.readInt32BE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),this[pe]<<24|this[pe+1]<<16|this[pe+2]<<8|this[pe+3]},A.prototype.readBigInt64LE=Se(function(pe){pe=pe>>>0,me(pe,"offset");const he=this[pe],Ie=this[pe+7];(he===void 0||Ie===void 0)&&we(pe,this.length-8);const ye=this[pe+4]+this[pe+5]*2**8+this[pe+6]*2**16+(Ie<<24);return(BigInt(ye)<<BigInt(32))+BigInt(he+this[++pe]*2**8+this[++pe]*2**16+this[++pe]*2**24)}),A.prototype.readBigInt64BE=Se(function(pe){pe=pe>>>0,me(pe,"offset");const he=this[pe],Ie=this[pe+7];(he===void 0||Ie===void 0)&&we(pe,this.length-8);const ye=(he<<24)+this[++pe]*2**16+this[++pe]*2**8+this[++pe];return(BigInt(ye)<<BigInt(32))+BigInt(this[++pe]*2**24+this[++pe]*2**16+this[++pe]*2**8+Ie)}),A.prototype.readFloatLE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),c.read(this,pe,!0,23,4)},A.prototype.readFloatBE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),c.read(this,pe,!1,23,4)},A.prototype.readDoubleLE=function(pe,he){return pe=pe>>>0,he||Z(pe,8,this.length),c.read(this,pe,!0,52,8)},A.prototype.readDoubleBE=function(pe,he){return pe=pe>>>0,he||Z(pe,8,this.length),c.read(this,pe,!1,52,8)};function Q(Ae,pe,he,Ie,ye,Pe){if(!A.isBuffer(Ae))throw new TypeError('"buffer" argument must be a Buffer instance');if(pe>ye||pe<Pe)throw new RangeError('"value" argument is out of bounds');if(he+Ie>Ae.length)throw new RangeError("Index out of range")}A.prototype.writeUintLE=A.prototype.writeUIntLE=function(pe,he,Ie,ye){if(pe=+pe,he=he>>>0,Ie=Ie>>>0,!ye){const Le=Math.pow(2,8*Ie)-1;Q(this,pe,he,Ie,Le,0)}let Pe=1,Ne=0;for(this[he]=pe&255;++Ne<Ie&&(Pe*=256);)this[he+Ne]=pe/Pe&255;return he+Ie},A.prototype.writeUintBE=A.prototype.writeUIntBE=function(pe,he,Ie,ye){if(pe=+pe,he=he>>>0,Ie=Ie>>>0,!ye){const Le=Math.pow(2,8*Ie)-1;Q(this,pe,he,Ie,Le,0)}let Pe=Ie-1,Ne=1;for(this[he+Pe]=pe&255;--Pe>=0&&(Ne*=256);)this[he+Pe]=pe/Ne&255;return he+Ie},A.prototype.writeUint8=A.prototype.writeUInt8=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,1,255,0),this[he]=pe&255,he+1},A.prototype.writeUint16LE=A.prototype.writeUInt16LE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,2,65535,0),this[he]=pe&255,this[he+1]=pe>>>8,he+2},A.prototype.writeUint16BE=A.prototype.writeUInt16BE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,2,65535,0),this[he]=pe>>>8,this[he+1]=pe&255,he+2},A.prototype.writeUint32LE=A.prototype.writeUInt32LE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,4,4294967295,0),this[he+3]=pe>>>24,this[he+2]=pe>>>16,this[he+1]=pe>>>8,this[he]=pe&255,he+4},A.prototype.writeUint32BE=A.prototype.writeUInt32BE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,4,4294967295,0),this[he]=pe>>>24,this[he+1]=pe>>>16,this[he+2]=pe>>>8,this[he+3]=pe&255,he+4};function Y(Ae,pe,he,Ie,ye){ce(pe,Ie,ye,Ae,he,7);let Pe=Number(pe&BigInt(4294967295));Ae[he++]=Pe,Pe=Pe>>8,Ae[he++]=Pe,Pe=Pe>>8,Ae[he++]=Pe,Pe=Pe>>8,Ae[he++]=Pe;let Ne=Number(pe>>BigInt(32)&BigInt(4294967295));return Ae[he++]=Ne,Ne=Ne>>8,Ae[he++]=Ne,Ne=Ne>>8,Ae[he++]=Ne,Ne=Ne>>8,Ae[he++]=Ne,he}function J(Ae,pe,he,Ie,ye){ce(pe,Ie,ye,Ae,he,7);let Pe=Number(pe&BigInt(4294967295));Ae[he+7]=Pe,Pe=Pe>>8,Ae[he+6]=Pe,Pe=Pe>>8,Ae[he+5]=Pe,Pe=Pe>>8,Ae[he+4]=Pe;let Ne=Number(pe>>BigInt(32)&BigInt(4294967295));return Ae[he+3]=Ne,Ne=Ne>>8,Ae[he+2]=Ne,Ne=Ne>>8,Ae[he+1]=Ne,Ne=Ne>>8,Ae[he]=Ne,he+8}A.prototype.writeBigUInt64LE=Se(function(pe,he=0){return Y(this,pe,he,BigInt(0),BigInt("0xffffffffffffffff"))}),A.prototype.writeBigUInt64BE=Se(function(pe,he=0){return J(this,pe,he,BigInt(0),BigInt("0xffffffffffffffff"))}),A.prototype.writeIntLE=function(pe,he,Ie,ye){if(pe=+pe,he=he>>>0,!ye){const Oe=Math.pow(2,8*Ie-1);Q(this,pe,he,Ie,Oe-1,-Oe)}let Pe=0,Ne=1,Le=0;for(this[he]=pe&255;++Pe<Ie&&(Ne*=256);)pe<0&&Le===0&&this[he+Pe-1]!==0&&(Le=1),this[he+Pe]=(pe/Ne>>0)-Le&255;return he+Ie},A.prototype.writeIntBE=function(pe,he,Ie,ye){if(pe=+pe,he=he>>>0,!ye){const Oe=Math.pow(2,8*Ie-1);Q(this,pe,he,Ie,Oe-1,-Oe)}let Pe=Ie-1,Ne=1,Le=0;for(this[he+Pe]=pe&255;--Pe>=0&&(Ne*=256);)pe<0&&Le===0&&this[he+Pe+1]!==0&&(Le=1),this[he+Pe]=(pe/Ne>>0)-Le&255;return he+Ie},A.prototype.writeInt8=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,1,127,-128),pe<0&&(pe=255+pe+1),this[he]=pe&255,he+1},A.prototype.writeInt16LE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,2,32767,-32768),this[he]=pe&255,this[he+1]=pe>>>8,he+2},A.prototype.writeInt16BE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,2,32767,-32768),this[he]=pe>>>8,this[he+1]=pe&255,he+2},A.prototype.writeInt32LE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,4,2147483647,-2147483648),this[he]=pe&255,this[he+1]=pe>>>8,this[he+2]=pe>>>16,this[he+3]=pe>>>24,he+4},A.prototype.writeInt32BE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,4,2147483647,-2147483648),pe<0&&(pe=4294967295+pe+1),this[he]=pe>>>24,this[he+1]=pe>>>16,this[he+2]=pe>>>8,this[he+3]=pe&255,he+4},A.prototype.writeBigInt64LE=Se(function(pe,he=0){return Y(this,pe,he,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),A.prototype.writeBigInt64BE=Se(function(pe,he=0){return J(this,pe,he,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ee(Ae,pe,he,Ie,ye,Pe){if(he+Ie>Ae.length)throw new RangeError("Index out of range");if(he<0)throw new RangeError("Index out of range")}function re(Ae,pe,he,Ie,ye){return pe=+pe,he=he>>>0,ye||ee(Ae,pe,he,4),c.write(Ae,pe,he,Ie,23,4),he+4}A.prototype.writeFloatLE=function(pe,he,Ie){return re(this,pe,he,!0,Ie)},A.prototype.writeFloatBE=function(pe,he,Ie){return re(this,pe,he,!1,Ie)};function ae(Ae,pe,he,Ie,ye){return pe=+pe,he=he>>>0,ye||ee(Ae,pe,he,8),c.write(Ae,pe,he,Ie,52,8),he+8}A.prototype.writeDoubleLE=function(pe,he,Ie){return ae(this,pe,he,!0,Ie)},A.prototype.writeDoubleBE=function(pe,he,Ie){return ae(this,pe,he,!1,Ie)},A.prototype.copy=function(pe,he,Ie,ye){if(!A.isBuffer(pe))throw new TypeError("argument should be a Buffer");if(Ie||(Ie=0),!ye&&ye!==0&&(ye=this.length),he>=pe.length&&(he=pe.length),he||(he=0),ye>0&&ye<Ie&&(ye=Ie),ye===Ie||pe.length===0||this.length===0)return 0;if(he<0)throw new RangeError("targetStart out of bounds");if(Ie<0||Ie>=this.length)throw new RangeError("Index out of range");if(ye<0)throw new RangeError("sourceEnd out of bounds");ye>this.length&&(ye=this.length),pe.length-he<ye-Ie&&(ye=pe.length-he+Ie);const Pe=ye-Ie;return this===pe&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(he,Ie,ye):Uint8Array.prototype.set.call(pe,this.subarray(Ie,ye),he),Pe},A.prototype.fill=function(pe,he,Ie,ye){if(typeof pe=="string"){if(typeof he=="string"?(ye=he,he=0,Ie=this.length):typeof Ie=="string"&&(ye=Ie,Ie=this.length),ye!==void 0&&typeof ye!="string")throw new TypeError("encoding must be a string");if(typeof ye=="string"&&!A.isEncoding(ye))throw new TypeError("Unknown encoding: "+ye);if(pe.length===1){const Ne=pe.charCodeAt(0);(ye==="utf8"&&Ne<128||ye==="latin1")&&(pe=Ne)}}else typeof pe=="number"?pe=pe&255:typeof pe=="boolean"&&(pe=Number(pe));if(he<0||this.length<he||this.length<Ie)throw new RangeError("Out of range index");if(Ie<=he)return this;he=he>>>0,Ie=Ie===void 0?this.length:Ie>>>0,pe||(pe=0);let Pe;if(typeof pe=="number")for(Pe=he;Pe<Ie;++Pe)this[Pe]=pe;else{const Ne=A.isBuffer(pe)?pe:A.from(pe,ye),Le=Ne.length;if(Le===0)throw new TypeError('The value "'+pe+'" is invalid for argument "value"');for(Pe=0;Pe<Ie-he;++Pe)this[Pe+he]=Ne[Pe%Le]}return this};const V={};function K(Ae,pe,he){V[Ae]=class extends he{constructor(){super(),Object.defineProperty(this,"message",{value:pe.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${Ae}]`,this.stack,delete this.name}get code(){return Ae}set code(ye){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:ye,writable:!0})}toString(){return`${this.name} [${Ae}]: ${this.message}`}}}K("ERR_BUFFER_OUT_OF_BOUNDS",function(Ae){return Ae?`${Ae} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),K("ERR_INVALID_ARG_TYPE",function(Ae,pe){return`The "${Ae}" argument must be of type number. Received type ${typeof pe}`},TypeError),K("ERR_OUT_OF_RANGE",function(Ae,pe,he){let Ie=`The value of "${Ae}" is out of range.`,ye=he;return Number.isInteger(he)&&Math.abs(he)>2**32?ye=te(String(he)):typeof he=="bigint"&&(ye=String(he),(he>BigInt(2)**BigInt(32)||he<-(BigInt(2)**BigInt(32)))&&(ye=te(ye)),ye+="n"),Ie+=` It must be ${pe}. Received ${ye}`,Ie},RangeError);function te(Ae){let pe="",he=Ae.length;const Ie=Ae[0]==="-"?1:0;for(;he>=Ie+4;he-=3)pe=`_${Ae.slice(he-3,he)}${pe}`;return`${Ae.slice(0,he)}${pe}`}function ie(Ae,pe,he){me(pe,"offset"),(Ae[pe]===void 0||Ae[pe+he]===void 0)&&we(pe,Ae.length-(he+1))}function ce(Ae,pe,he,Ie,ye,Pe){if(Ae>he||Ae<pe){const Ne=typeof pe=="bigint"?"n":"";let Le;throw pe===0||pe===BigInt(0)?Le=`>= 0${Ne} and < 2${Ne} ** ${(Pe+1)*8}${Ne}`:Le=`>= -(2${Ne} ** ${(Pe+1)*8-1}${Ne}) and < 2 ** ${(Pe+1)*8-1}${Ne}`,new V.ERR_OUT_OF_RANGE("value",Le,Ae)}ie(Ie,ye,Pe)}function me(Ae,pe){if(typeof Ae!="number")throw new V.ERR_INVALID_ARG_TYPE(pe,"number",Ae)}function we(Ae,pe,he){throw Math.floor(Ae)!==Ae?(me(Ae,he),new V.ERR_OUT_OF_RANGE("offset","an integer",Ae)):pe<0?new V.ERR_BUFFER_OUT_OF_BOUNDS:new V.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${pe}`,Ae)}const ve=/[^+/0-9A-Za-z-_]/g;function ge(Ae){if(Ae=Ae.split("=")[0],Ae=Ae.trim().replace(ve,""),Ae.length<2)return"";for(;Ae.length%4!==0;)Ae=Ae+"=";return Ae}function ue(Ae,pe){pe=pe||1/0;let he;const Ie=Ae.length;let ye=null;const Pe=[];for(let Ne=0;Ne<Ie;++Ne){if(he=Ae.charCodeAt(Ne),he>55295&&he<57344){if(!ye){if(he>56319){(pe-=3)>-1&&Pe.push(239,191,189);continue}else if(Ne+1===Ie){(pe-=3)>-1&&Pe.push(239,191,189);continue}ye=he;continue}if(he<56320){(pe-=3)>-1&&Pe.push(239,191,189),ye=he;continue}he=(ye-55296<<10|he-56320)+65536}else ye&&(pe-=3)>-1&&Pe.push(239,191,189);if(ye=null,he<128){if((pe-=1)<0)break;Pe.push(he)}else if(he<2048){if((pe-=2)<0)break;Pe.push(he>>6|192,he&63|128)}else if(he<65536){if((pe-=3)<0)break;Pe.push(he>>12|224,he>>6&63|128,he&63|128)}else if(he<1114112){if((pe-=4)<0)break;Pe.push(he>>18|240,he>>12&63|128,he>>6&63|128,he&63|128)}else throw new Error("Invalid code point")}return Pe}function se(Ae){const pe=[];for(let he=0;he<Ae.length;++he)pe.push(Ae.charCodeAt(he)&255);return pe}function oe(Ae,pe){let he,Ie,ye;const Pe=[];for(let Ne=0;Ne<Ae.length&&!((pe-=2)<0);++Ne)he=Ae.charCodeAt(Ne),Ie=he>>8,ye=he%256,Pe.push(ye),Pe.push(Ie);return Pe}function de(Ae){return s.toByteArray(ge(Ae))}function le(Ae,pe,he,Ie){let ye;for(ye=0;ye<Ie&&!(ye+he>=pe.length||ye>=Ae.length);++ye)pe[ye+he]=Ae[ye];return ye}function xe(Ae,pe){return Ae instanceof pe||Ae!=null&&Ae.constructor!=null&&Ae.constructor.name!=null&&Ae.constructor.name===pe.name}function Ce(Ae){return Ae!==Ae}const $e=function(){const Ae="0123456789abcdef",pe=new Array(256);for(let he=0;he<16;++he){const Ie=he*16;for(let ye=0;ye<16;++ye)pe[Ie+ye]=Ae[he]+Ae[ye]}return pe}();function Se(Ae){return typeof BigInt>"u"?Ee:Ae}function Ee(){throw new Error("BigInt not supported")}}(buffer$1)),buffer$1}var bufferExports=requireBuffer();const langs=["en","zh","ja","ko","ar","th","pl","it","de","es","fr"],Lang=z.enum(langs);z.object({cancel:z.string(),close:z.string(),set:z.string(),clear:z.string(),field:z.string(),fieldName:z.string(),align:z.string(),width:z.string(),opacity:z.string(),height:z.string(),rotate:z.string(),edit:z.string(),required:z.string(),editable:z.string(),plsInputName:z.string(),fieldMustUniq:z.string(),notUniq:z.string(),noKeyName:z.string(),fieldsList:z.string(),editField:z.string(),type:z.string(),errorOccurred:z.string(),errorBulkUpdateFieldName:z.string(),commitBulkUpdateFieldName:z.string(),bulkUpdateFieldName:z.string(),addPageAfter:z.string(),removePage:z.string(),removePageConfirm:z.string(),"validation.uniqueName":z.string(),"validation.hexColor":z.string(),"validation.dateTimeFormat":z.string(),"schemas.color":z.string(),"schemas.borderWidth":z.string(),"schemas.borderColor":z.string(),"schemas.backgroundColor":z.string(),"schemas.textColor":z.string(),"schemas.bgColor":z.string(),"schemas.horizontal":z.string(),"schemas.vertical":z.string(),"schemas.left":z.string(),"schemas.center":z.string(),"schemas.right":z.string(),"schemas.top":z.string(),"schemas.middle":z.string(),"schemas.bottom":z.string(),"schemas.padding":z.string(),"schemas.text.fontName":z.string(),"schemas.text.size":z.string(),"schemas.text.spacing":z.string(),"schemas.text.textAlign":z.string(),"schemas.text.verticalAlign":z.string(),"schemas.text.lineHeight":z.string(),"schemas.text.min":z.string(),"schemas.text.max":z.string(),"schemas.text.fit":z.string(),"schemas.text.dynamicFontSize":z.string(),"schemas.text.format":z.string(),"schemas.radius":z.string(),"schemas.mvt.typingInstructions":z.string(),"schemas.mvt.sampleField":z.string(),"schemas.mvt.variablesSampleData":z.string(),"schemas.barcodes.barColor":z.string(),"schemas.barcodes.includetext":z.string(),"schemas.table.alternateBackgroundColor":z.string(),"schemas.table.tableStyle":z.string(),"schemas.table.showHead":z.string(),"schemas.table.headStyle":z.string(),"schemas.table.bodyStyle":z.string(),"schemas.table.columnStyle":z.string(),"schemas.date.format":z.string(),"schemas.date.locale":z.string(),"schemas.select.options":z.string(),"schemas.select.optionPlaceholder":z.string(),"schemas.radioGroup.groupName":z.string()}),z.enum(["viewer","form","designer"]);const ColorType=z.enum(["rgb","cmyk"]).optional();z.object({height:z.number(),width:z.number()});const Schema$1=z.object({name:z.string(),type:z.string(),content:z.string().optional(),position:z.object({x:z.number(),y:z.number()}),width:z.number(),height:z.number(),rotate:z.number().optional(),opacity:z.number().optional(),readOnly:z.boolean().optional(),required:z.boolean().optional(),__bodyRange:z.object({start:z.number(),end:z.number().optional()}).optional(),__isSplit:z.boolean().optional()}).passthrough(),SchemaForUIAdditionalInfo=z.object({id:z.string()});Schema$1.merge(SchemaForUIAdditionalInfo);const ArrayBufferSchema=z.any().refine(a=>a instanceof ArrayBuffer),Uint8ArraySchema=z.any().refine(a=>a instanceof Uint8Array),BlankPdf=z.object({width:z.number(),height:z.number(),padding:z.tuple([z.number(),z.number(),z.number(),z.number()]),staticSchema:z.array(Schema$1).optional()}),CustomPdf=z.union([z.string(),ArrayBufferSchema,Uint8ArraySchema]),BasePdf=z.union([CustomPdf,BlankPdf]);z.array(z.record(Schema$1));const SchemaPageArray=z.array(z.array(Schema$1)),Template=z.object({schemas:SchemaPageArray,basePdf:BasePdf,pdfmeVersion:z.string().optional()}).passthrough(),Inputs=z.array(z.record(z.any())).min(1),Font=z.record(z.object({data:z.union([z.string(),ArrayBufferSchema,Uint8ArraySchema]),fallback:z.boolean().optional(),subset:z.boolean().optional()})),CommonOptions=z.object({font:Font.optional()}).passthrough(),CommonProps=z.object({template:Template,options:CommonOptions.optional(),plugins:z.record(z.object({ui:z.any(),pdf:z.any(),propPanel:z.any()})).optional()}),GeneratorOptions=CommonOptions.extend({colorType:ColorType,author:z.string().optional(),creationDate:z.date().optional(),creator:z.string().optional(),keywords:z.array(z.string()).optional(),lang:Lang.optional(),modificationDate:z.date().optional(),producer:z.string().optional(),subject:z.string().optional(),title:z.string().optional()});CommonProps.extend({inputs:Inputs,options:GeneratorOptions.optional()}).strict();const UIOptions=CommonOptions.extend({lang:Lang.optional(),labels:z.record(z.string(),z.string()).optional(),theme:z.record(z.string(),z.unknown()).optional(),icons:z.record(z.string(),z.string()).optional(),requiredByDefault:z.boolean().optional(),maxZoom:z.number().optional()}),HTMLElementSchema=z.any().refine(a=>a instanceof HTMLElement),UIProps=CommonProps.extend({domContainer:HTMLElementSchema,options:UIOptions.optional()}),PreviewProps=UIProps.extend({inputs:Inputs}).strict(),DesignerProps=UIProps.extend({}).strict(),cloneDeep$1=structuredClone,uniq=a=>Array.from(new Set(a)),getFallbackFontName=a=>{const s="",c=Object.entries(a).reduce((u,d)=>{const[p,v]=d;return!u&&v.fallback?p:u},s);if(c===s)throw Error("[@pdfme/common] fallback flag is not found in font. true fallback flag must be only one.");return c},getDefaultFont=()=>({[DEFAULT_FONT_NAME]:{data:b64toUint8Array(DEFAULT_FONT_VALUE),fallback:!0}}),mm2pt=a=>parseFloat(String(a))*MM_TO_PT_RATIO,pt2mm=a=>a*PT_TO_MM_RATIO,pt2px=a=>a*PT_TO_PX_RATIO,px2mm=a=>parseFloat(String(a))*.26458333333333,blob2Base64Pdf=a=>new Promise((s,c)=>{const u=new FileReader;u.onloadend=()=>{u.result.startsWith("data:application/pdf;")?s(u.result):c(Error("[@pdfme/common] template.basePdf must be pdf data."))},u.readAsDataURL(a)}),isHexValid=a=>/^#(?:[A-Fa-f0-9]{3,4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/i.test(a),migrateTemplate=a=>{a.schemas&&Array.isArray(a.schemas)&&a.schemas.length>0&&!Array.isArray(a.schemas[0])&&(a.schemas=a.schemas.map(s=>Object.entries(s).map(([c,u])=>({...u,name:c}))))},getB64BasePdf=async a=>{if(typeof a=="string"&&!a.startsWith("data:application/pdf;")&&typeof window<"u"){const u=await(await fetch(a)).blob();return blob2Base64Pdf(u)}if(typeof a=="string")return a;const s=a instanceof Uint8Array?a:new Uint8Array(a);return"data:application/pdf;base64,"+bufferExports.Buffer.from(s).toString("base64")},isBlankPdf=a=>BlankPdf.safeParse(a).success,getByteString=a=>bufferExports.Buffer.from(a,"base64").toString("binary"),b64toUint8Array=a=>{const s=a.split(";base64,")[1]?a.split(";base64,")[1]:a,c=getByteString(s),u=new Uint8Array(c.length);for(let d=0;d<c.length;d+=1)u[d]=c.charCodeAt(d);return u},getFontNamesInSchemas=a=>uniq(a.map(s=>s.map(c=>c.fontName??"")).reduce((s,c)=>s.concat(c),[]).filter(Boolean)),checkFont=a=>{const{font:s,template:{schemas:c}}=a,d=Object.values(s).reduce((A,b)=>b.fallback?A+1:A,0);if(d===0)throw Error(`[@pdfme/common] fallback flag is not found in font. true fallback flag must be only one.
|
42
|
+
*/var hasRequiredBuffer;function requireBuffer(){return hasRequiredBuffer||(hasRequiredBuffer=1,function(a){const s=requireBase64Js(),c=requireIeee754(),u=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;a.Buffer=A,a.SlowBuffer=I,a.INSPECT_MAX_BYTES=50;const d=2147483647;a.kMaxLength=d,A.TYPED_ARRAY_SUPPORT=p(),!A.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{const Ae=new Uint8Array(1),pe={foo:function(){return 42}};return Object.setPrototypeOf(pe,Uint8Array.prototype),Object.setPrototypeOf(Ae,pe),Ae.foo()===42}catch{return!1}}Object.defineProperty(A.prototype,"parent",{enumerable:!0,get:function(){if(A.isBuffer(this))return this.buffer}}),Object.defineProperty(A.prototype,"offset",{enumerable:!0,get:function(){if(A.isBuffer(this))return this.byteOffset}});function v(Ae){if(Ae>d)throw new RangeError('The value "'+Ae+'" is invalid for option "size"');const pe=new Uint8Array(Ae);return Object.setPrototypeOf(pe,A.prototype),pe}function A(Ae,pe,he){if(typeof Ae=="number"){if(typeof pe=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return y(Ae)}return b(Ae,pe,he)}A.poolSize=8192;function b(Ae,pe,he){if(typeof Ae=="string")return f(Ae,pe);if(ArrayBuffer.isView(Ae))return C(Ae);if(Ae==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Ae);if(xe(Ae,ArrayBuffer)||Ae&&xe(Ae.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(xe(Ae,SharedArrayBuffer)||Ae&&xe(Ae.buffer,SharedArrayBuffer)))return S(Ae,pe,he);if(typeof Ae=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const Ie=Ae.valueOf&&Ae.valueOf();if(Ie!=null&&Ie!==Ae)return A.from(Ie,pe,he);const ye=w(Ae);if(ye)return ye;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof Ae[Symbol.toPrimitive]=="function")return A.from(Ae[Symbol.toPrimitive]("string"),pe,he);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Ae)}A.from=function(Ae,pe,he){return b(Ae,pe,he)},Object.setPrototypeOf(A.prototype,Uint8Array.prototype),Object.setPrototypeOf(A,Uint8Array);function g(Ae){if(typeof Ae!="number")throw new TypeError('"size" argument must be of type number');if(Ae<0)throw new RangeError('The value "'+Ae+'" is invalid for option "size"')}function x(Ae,pe,he){return g(Ae),Ae<=0?v(Ae):pe!==void 0?typeof he=="string"?v(Ae).fill(pe,he):v(Ae).fill(pe):v(Ae)}A.alloc=function(Ae,pe,he){return x(Ae,pe,he)};function y(Ae){return g(Ae),v(Ae<0?0:_(Ae)|0)}A.allocUnsafe=function(Ae){return y(Ae)},A.allocUnsafeSlow=function(Ae){return y(Ae)};function f(Ae,pe){if((typeof pe!="string"||pe==="")&&(pe="utf8"),!A.isEncoding(pe))throw new TypeError("Unknown encoding: "+pe);const he=$(Ae,pe)|0;let Ie=v(he);const ye=Ie.write(Ae,pe);return ye!==he&&(Ie=Ie.slice(0,ye)),Ie}function m(Ae){const pe=Ae.length<0?0:_(Ae.length)|0,he=v(pe);for(let Ie=0;Ie<pe;Ie+=1)he[Ie]=Ae[Ie]&255;return he}function C(Ae){if(xe(Ae,Uint8Array)){const pe=new Uint8Array(Ae);return S(pe.buffer,pe.byteOffset,pe.byteLength)}return m(Ae)}function S(Ae,pe,he){if(pe<0||Ae.byteLength<pe)throw new RangeError('"offset" is outside of buffer bounds');if(Ae.byteLength<pe+(he||0))throw new RangeError('"length" is outside of buffer bounds');let Ie;return pe===void 0&&he===void 0?Ie=new Uint8Array(Ae):he===void 0?Ie=new Uint8Array(Ae,pe):Ie=new Uint8Array(Ae,pe,he),Object.setPrototypeOf(Ie,A.prototype),Ie}function w(Ae){if(A.isBuffer(Ae)){const pe=_(Ae.length)|0,he=v(pe);return he.length===0||Ae.copy(he,0,0,pe),he}if(Ae.length!==void 0)return typeof Ae.length!="number"||Ce(Ae.length)?v(0):m(Ae);if(Ae.type==="Buffer"&&Array.isArray(Ae.data))return m(Ae.data)}function _(Ae){if(Ae>=d)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+d.toString(16)+" bytes");return Ae|0}function I(Ae){return+Ae!=Ae&&(Ae=0),A.alloc(+Ae)}A.isBuffer=function(pe){return pe!=null&&pe._isBuffer===!0&&pe!==A.prototype},A.compare=function(pe,he){if(xe(pe,Uint8Array)&&(pe=A.from(pe,pe.offset,pe.byteLength)),xe(he,Uint8Array)&&(he=A.from(he,he.offset,he.byteLength)),!A.isBuffer(pe)||!A.isBuffer(he))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(pe===he)return 0;let Ie=pe.length,ye=he.length;for(let Pe=0,Ne=Math.min(Ie,ye);Pe<Ne;++Pe)if(pe[Pe]!==he[Pe]){Ie=pe[Pe],ye=he[Pe];break}return Ie<ye?-1:ye<Ie?1:0},A.isEncoding=function(pe){switch(String(pe).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},A.concat=function(pe,he){if(!Array.isArray(pe))throw new TypeError('"list" argument must be an Array of Buffers');if(pe.length===0)return A.alloc(0);let Ie;if(he===void 0)for(he=0,Ie=0;Ie<pe.length;++Ie)he+=pe[Ie].length;const ye=A.allocUnsafe(he);let Pe=0;for(Ie=0;Ie<pe.length;++Ie){let Ne=pe[Ie];if(xe(Ne,Uint8Array))Pe+Ne.length>ye.length?(A.isBuffer(Ne)||(Ne=A.from(Ne)),Ne.copy(ye,Pe)):Uint8Array.prototype.set.call(ye,Ne,Pe);else if(A.isBuffer(Ne))Ne.copy(ye,Pe);else throw new TypeError('"list" argument must be an Array of Buffers');Pe+=Ne.length}return ye};function $(Ae,pe){if(A.isBuffer(Ae))return Ae.length;if(ArrayBuffer.isView(Ae)||xe(Ae,ArrayBuffer))return Ae.byteLength;if(typeof Ae!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof Ae);const he=Ae.length,Ie=arguments.length>2&&arguments[2]===!0;if(!Ie&&he===0)return 0;let ye=!1;for(;;)switch(pe){case"ascii":case"latin1":case"binary":return he;case"utf8":case"utf-8":return ue(Ae).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return he*2;case"hex":return he>>>1;case"base64":return de(Ae).length;default:if(ye)return Ie?-1:ue(Ae).length;pe=(""+pe).toLowerCase(),ye=!0}}A.byteLength=$;function P(Ae,pe,he){let Ie=!1;if((pe===void 0||pe<0)&&(pe=0),pe>this.length||((he===void 0||he>this.length)&&(he=this.length),he<=0)||(he>>>=0,pe>>>=0,he<=pe))return"";for(Ae||(Ae="utf8");;)switch(Ae){case"hex":return D(this,pe,he);case"utf8":case"utf-8":return q(this,pe,he);case"ascii":return U(this,pe,he);case"latin1":case"binary":return N(this,pe,he);case"base64":return j(this,pe,he);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return W(this,pe,he);default:if(Ie)throw new TypeError("Unknown encoding: "+Ae);Ae=(Ae+"").toLowerCase(),Ie=!0}}A.prototype._isBuffer=!0;function E(Ae,pe,he){const Ie=Ae[pe];Ae[pe]=Ae[he],Ae[he]=Ie}A.prototype.swap16=function(){const pe=this.length;if(pe%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let he=0;he<pe;he+=2)E(this,he,he+1);return this},A.prototype.swap32=function(){const pe=this.length;if(pe%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let he=0;he<pe;he+=4)E(this,he,he+3),E(this,he+1,he+2);return this},A.prototype.swap64=function(){const pe=this.length;if(pe%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let he=0;he<pe;he+=8)E(this,he,he+7),E(this,he+1,he+6),E(this,he+2,he+5),E(this,he+3,he+4);return this},A.prototype.toString=function(){const pe=this.length;return pe===0?"":arguments.length===0?q(this,0,pe):P.apply(this,arguments)},A.prototype.toLocaleString=A.prototype.toString,A.prototype.equals=function(pe){if(!A.isBuffer(pe))throw new TypeError("Argument must be a Buffer");return this===pe?!0:A.compare(this,pe)===0},A.prototype.inspect=function(){let pe="";const he=a.INSPECT_MAX_BYTES;return pe=this.toString("hex",0,he).replace(/(.{2})/g,"$1 ").trim(),this.length>he&&(pe+=" ... "),"<Buffer "+pe+">"},u&&(A.prototype[u]=A.prototype.inspect),A.prototype.compare=function(pe,he,Ie,ye,Pe){if(xe(pe,Uint8Array)&&(pe=A.from(pe,pe.offset,pe.byteLength)),!A.isBuffer(pe))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof pe);if(he===void 0&&(he=0),Ie===void 0&&(Ie=pe?pe.length:0),ye===void 0&&(ye=0),Pe===void 0&&(Pe=this.length),he<0||Ie>pe.length||ye<0||Pe>this.length)throw new RangeError("out of range index");if(ye>=Pe&&he>=Ie)return 0;if(ye>=Pe)return-1;if(he>=Ie)return 1;if(he>>>=0,Ie>>>=0,ye>>>=0,Pe>>>=0,this===pe)return 0;let Ne=Pe-ye,Le=Ie-he;const Oe=Math.min(Ne,Le),Fe=this.slice(ye,Pe),_e=pe.slice(he,Ie);for(let je=0;je<Oe;++je)if(Fe[je]!==_e[je]){Ne=Fe[je],Le=_e[je];break}return Ne<Le?-1:Le<Ne?1:0};function R(Ae,pe,he,Ie,ye){if(Ae.length===0)return-1;if(typeof he=="string"?(Ie=he,he=0):he>2147483647?he=2147483647:he<-2147483648&&(he=-2147483648),he=+he,Ce(he)&&(he=ye?0:Ae.length-1),he<0&&(he=Ae.length+he),he>=Ae.length){if(ye)return-1;he=Ae.length-1}else if(he<0)if(ye)he=0;else return-1;if(typeof pe=="string"&&(pe=A.from(pe,Ie)),A.isBuffer(pe))return pe.length===0?-1:T(Ae,pe,he,Ie,ye);if(typeof pe=="number")return pe=pe&255,typeof Uint8Array.prototype.indexOf=="function"?ye?Uint8Array.prototype.indexOf.call(Ae,pe,he):Uint8Array.prototype.lastIndexOf.call(Ae,pe,he):T(Ae,[pe],he,Ie,ye);throw new TypeError("val must be string, number or Buffer")}function T(Ae,pe,he,Ie,ye){let Pe=1,Ne=Ae.length,Le=pe.length;if(Ie!==void 0&&(Ie=String(Ie).toLowerCase(),Ie==="ucs2"||Ie==="ucs-2"||Ie==="utf16le"||Ie==="utf-16le")){if(Ae.length<2||pe.length<2)return-1;Pe=2,Ne/=2,Le/=2,he/=2}function Oe(_e,je){return Pe===1?_e[je]:_e.readUInt16BE(je*Pe)}let Fe;if(ye){let _e=-1;for(Fe=he;Fe<Ne;Fe++)if(Oe(Ae,Fe)===Oe(pe,_e===-1?0:Fe-_e)){if(_e===-1&&(_e=Fe),Fe-_e+1===Le)return _e*Pe}else _e!==-1&&(Fe-=Fe-_e),_e=-1}else for(he+Le>Ne&&(he=Ne-Le),Fe=he;Fe>=0;Fe--){let _e=!0;for(let je=0;je<Le;je++)if(Oe(Ae,Fe+je)!==Oe(pe,je)){_e=!1;break}if(_e)return Fe}return-1}A.prototype.includes=function(pe,he,Ie){return this.indexOf(pe,he,Ie)!==-1},A.prototype.indexOf=function(pe,he,Ie){return R(this,pe,he,Ie,!0)},A.prototype.lastIndexOf=function(pe,he,Ie){return R(this,pe,he,Ie,!1)};function B(Ae,pe,he,Ie){he=Number(he)||0;const ye=Ae.length-he;Ie?(Ie=Number(Ie),Ie>ye&&(Ie=ye)):Ie=ye;const Pe=pe.length;Ie>Pe/2&&(Ie=Pe/2);let Ne;for(Ne=0;Ne<Ie;++Ne){const Le=parseInt(pe.substr(Ne*2,2),16);if(Ce(Le))return Ne;Ae[he+Ne]=Le}return Ne}function M(Ae,pe,he,Ie){return le(ue(pe,Ae.length-he),Ae,he,Ie)}function k(Ae,pe,he,Ie){return le(se(pe),Ae,he,Ie)}function O(Ae,pe,he,Ie){return le(de(pe),Ae,he,Ie)}function H(Ae,pe,he,Ie){return le(oe(pe,Ae.length-he),Ae,he,Ie)}A.prototype.write=function(pe,he,Ie,ye){if(he===void 0)ye="utf8",Ie=this.length,he=0;else if(Ie===void 0&&typeof he=="string")ye=he,Ie=this.length,he=0;else if(isFinite(he))he=he>>>0,isFinite(Ie)?(Ie=Ie>>>0,ye===void 0&&(ye="utf8")):(ye=Ie,Ie=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const Pe=this.length-he;if((Ie===void 0||Ie>Pe)&&(Ie=Pe),pe.length>0&&(Ie<0||he<0)||he>this.length)throw new RangeError("Attempt to write outside buffer bounds");ye||(ye="utf8");let Ne=!1;for(;;)switch(ye){case"hex":return B(this,pe,he,Ie);case"utf8":case"utf-8":return M(this,pe,he,Ie);case"ascii":case"latin1":case"binary":return k(this,pe,he,Ie);case"base64":return O(this,pe,he,Ie);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H(this,pe,he,Ie);default:if(Ne)throw new TypeError("Unknown encoding: "+ye);ye=(""+ye).toLowerCase(),Ne=!0}},A.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function j(Ae,pe,he){return pe===0&&he===Ae.length?s.fromByteArray(Ae):s.fromByteArray(Ae.slice(pe,he))}function q(Ae,pe,he){he=Math.min(Ae.length,he);const Ie=[];let ye=pe;for(;ye<he;){const Pe=Ae[ye];let Ne=null,Le=Pe>239?4:Pe>223?3:Pe>191?2:1;if(ye+Le<=he){let Oe,Fe,_e,je;switch(Le){case 1:Pe<128&&(Ne=Pe);break;case 2:Oe=Ae[ye+1],(Oe&192)===128&&(je=(Pe&31)<<6|Oe&63,je>127&&(Ne=je));break;case 3:Oe=Ae[ye+1],Fe=Ae[ye+2],(Oe&192)===128&&(Fe&192)===128&&(je=(Pe&15)<<12|(Oe&63)<<6|Fe&63,je>2047&&(je<55296||je>57343)&&(Ne=je));break;case 4:Oe=Ae[ye+1],Fe=Ae[ye+2],_e=Ae[ye+3],(Oe&192)===128&&(Fe&192)===128&&(_e&192)===128&&(je=(Pe&15)<<18|(Oe&63)<<12|(Fe&63)<<6|_e&63,je>65535&&je<1114112&&(Ne=je))}}Ne===null?(Ne=65533,Le=1):Ne>65535&&(Ne-=65536,Ie.push(Ne>>>10&1023|55296),Ne=56320|Ne&1023),Ie.push(Ne),ye+=Le}return F(Ie)}const L=4096;function F(Ae){const pe=Ae.length;if(pe<=L)return String.fromCharCode.apply(String,Ae);let he="",Ie=0;for(;Ie<pe;)he+=String.fromCharCode.apply(String,Ae.slice(Ie,Ie+=L));return he}function U(Ae,pe,he){let Ie="";he=Math.min(Ae.length,he);for(let ye=pe;ye<he;++ye)Ie+=String.fromCharCode(Ae[ye]&127);return Ie}function N(Ae,pe,he){let Ie="";he=Math.min(Ae.length,he);for(let ye=pe;ye<he;++ye)Ie+=String.fromCharCode(Ae[ye]);return Ie}function D(Ae,pe,he){const Ie=Ae.length;(!pe||pe<0)&&(pe=0),(!he||he<0||he>Ie)&&(he=Ie);let ye="";for(let Pe=pe;Pe<he;++Pe)ye+=$e[Ae[Pe]];return ye}function W(Ae,pe,he){const Ie=Ae.slice(pe,he);let ye="";for(let Pe=0;Pe<Ie.length-1;Pe+=2)ye+=String.fromCharCode(Ie[Pe]+Ie[Pe+1]*256);return ye}A.prototype.slice=function(pe,he){const Ie=this.length;pe=~~pe,he=he===void 0?Ie:~~he,pe<0?(pe+=Ie,pe<0&&(pe=0)):pe>Ie&&(pe=Ie),he<0?(he+=Ie,he<0&&(he=0)):he>Ie&&(he=Ie),he<pe&&(he=pe);const ye=this.subarray(pe,he);return Object.setPrototypeOf(ye,A.prototype),ye};function Z(Ae,pe,he){if(Ae%1!==0||Ae<0)throw new RangeError("offset is not uint");if(Ae+pe>he)throw new RangeError("Trying to access beyond buffer length")}A.prototype.readUintLE=A.prototype.readUIntLE=function(pe,he,Ie){pe=pe>>>0,he=he>>>0,Ie||Z(pe,he,this.length);let ye=this[pe],Pe=1,Ne=0;for(;++Ne<he&&(Pe*=256);)ye+=this[pe+Ne]*Pe;return ye},A.prototype.readUintBE=A.prototype.readUIntBE=function(pe,he,Ie){pe=pe>>>0,he=he>>>0,Ie||Z(pe,he,this.length);let ye=this[pe+--he],Pe=1;for(;he>0&&(Pe*=256);)ye+=this[pe+--he]*Pe;return ye},A.prototype.readUint8=A.prototype.readUInt8=function(pe,he){return pe=pe>>>0,he||Z(pe,1,this.length),this[pe]},A.prototype.readUint16LE=A.prototype.readUInt16LE=function(pe,he){return pe=pe>>>0,he||Z(pe,2,this.length),this[pe]|this[pe+1]<<8},A.prototype.readUint16BE=A.prototype.readUInt16BE=function(pe,he){return pe=pe>>>0,he||Z(pe,2,this.length),this[pe]<<8|this[pe+1]},A.prototype.readUint32LE=A.prototype.readUInt32LE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),(this[pe]|this[pe+1]<<8|this[pe+2]<<16)+this[pe+3]*16777216},A.prototype.readUint32BE=A.prototype.readUInt32BE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),this[pe]*16777216+(this[pe+1]<<16|this[pe+2]<<8|this[pe+3])},A.prototype.readBigUInt64LE=Se(function(pe){pe=pe>>>0,me(pe,"offset");const he=this[pe],Ie=this[pe+7];(he===void 0||Ie===void 0)&&we(pe,this.length-8);const ye=he+this[++pe]*2**8+this[++pe]*2**16+this[++pe]*2**24,Pe=this[++pe]+this[++pe]*2**8+this[++pe]*2**16+Ie*2**24;return BigInt(ye)+(BigInt(Pe)<<BigInt(32))}),A.prototype.readBigUInt64BE=Se(function(pe){pe=pe>>>0,me(pe,"offset");const he=this[pe],Ie=this[pe+7];(he===void 0||Ie===void 0)&&we(pe,this.length-8);const ye=he*2**24+this[++pe]*2**16+this[++pe]*2**8+this[++pe],Pe=this[++pe]*2**24+this[++pe]*2**16+this[++pe]*2**8+Ie;return(BigInt(ye)<<BigInt(32))+BigInt(Pe)}),A.prototype.readIntLE=function(pe,he,Ie){pe=pe>>>0,he=he>>>0,Ie||Z(pe,he,this.length);let ye=this[pe],Pe=1,Ne=0;for(;++Ne<he&&(Pe*=256);)ye+=this[pe+Ne]*Pe;return Pe*=128,ye>=Pe&&(ye-=Math.pow(2,8*he)),ye},A.prototype.readIntBE=function(pe,he,Ie){pe=pe>>>0,he=he>>>0,Ie||Z(pe,he,this.length);let ye=he,Pe=1,Ne=this[pe+--ye];for(;ye>0&&(Pe*=256);)Ne+=this[pe+--ye]*Pe;return Pe*=128,Ne>=Pe&&(Ne-=Math.pow(2,8*he)),Ne},A.prototype.readInt8=function(pe,he){return pe=pe>>>0,he||Z(pe,1,this.length),this[pe]&128?(255-this[pe]+1)*-1:this[pe]},A.prototype.readInt16LE=function(pe,he){pe=pe>>>0,he||Z(pe,2,this.length);const Ie=this[pe]|this[pe+1]<<8;return Ie&32768?Ie|4294901760:Ie},A.prototype.readInt16BE=function(pe,he){pe=pe>>>0,he||Z(pe,2,this.length);const Ie=this[pe+1]|this[pe]<<8;return Ie&32768?Ie|4294901760:Ie},A.prototype.readInt32LE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),this[pe]|this[pe+1]<<8|this[pe+2]<<16|this[pe+3]<<24},A.prototype.readInt32BE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),this[pe]<<24|this[pe+1]<<16|this[pe+2]<<8|this[pe+3]},A.prototype.readBigInt64LE=Se(function(pe){pe=pe>>>0,me(pe,"offset");const he=this[pe],Ie=this[pe+7];(he===void 0||Ie===void 0)&&we(pe,this.length-8);const ye=this[pe+4]+this[pe+5]*2**8+this[pe+6]*2**16+(Ie<<24);return(BigInt(ye)<<BigInt(32))+BigInt(he+this[++pe]*2**8+this[++pe]*2**16+this[++pe]*2**24)}),A.prototype.readBigInt64BE=Se(function(pe){pe=pe>>>0,me(pe,"offset");const he=this[pe],Ie=this[pe+7];(he===void 0||Ie===void 0)&&we(pe,this.length-8);const ye=(he<<24)+this[++pe]*2**16+this[++pe]*2**8+this[++pe];return(BigInt(ye)<<BigInt(32))+BigInt(this[++pe]*2**24+this[++pe]*2**16+this[++pe]*2**8+Ie)}),A.prototype.readFloatLE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),c.read(this,pe,!0,23,4)},A.prototype.readFloatBE=function(pe,he){return pe=pe>>>0,he||Z(pe,4,this.length),c.read(this,pe,!1,23,4)},A.prototype.readDoubleLE=function(pe,he){return pe=pe>>>0,he||Z(pe,8,this.length),c.read(this,pe,!0,52,8)},A.prototype.readDoubleBE=function(pe,he){return pe=pe>>>0,he||Z(pe,8,this.length),c.read(this,pe,!1,52,8)};function Q(Ae,pe,he,Ie,ye,Pe){if(!A.isBuffer(Ae))throw new TypeError('"buffer" argument must be a Buffer instance');if(pe>ye||pe<Pe)throw new RangeError('"value" argument is out of bounds');if(he+Ie>Ae.length)throw new RangeError("Index out of range")}A.prototype.writeUintLE=A.prototype.writeUIntLE=function(pe,he,Ie,ye){if(pe=+pe,he=he>>>0,Ie=Ie>>>0,!ye){const Le=Math.pow(2,8*Ie)-1;Q(this,pe,he,Ie,Le,0)}let Pe=1,Ne=0;for(this[he]=pe&255;++Ne<Ie&&(Pe*=256);)this[he+Ne]=pe/Pe&255;return he+Ie},A.prototype.writeUintBE=A.prototype.writeUIntBE=function(pe,he,Ie,ye){if(pe=+pe,he=he>>>0,Ie=Ie>>>0,!ye){const Le=Math.pow(2,8*Ie)-1;Q(this,pe,he,Ie,Le,0)}let Pe=Ie-1,Ne=1;for(this[he+Pe]=pe&255;--Pe>=0&&(Ne*=256);)this[he+Pe]=pe/Ne&255;return he+Ie},A.prototype.writeUint8=A.prototype.writeUInt8=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,1,255,0),this[he]=pe&255,he+1},A.prototype.writeUint16LE=A.prototype.writeUInt16LE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,2,65535,0),this[he]=pe&255,this[he+1]=pe>>>8,he+2},A.prototype.writeUint16BE=A.prototype.writeUInt16BE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,2,65535,0),this[he]=pe>>>8,this[he+1]=pe&255,he+2},A.prototype.writeUint32LE=A.prototype.writeUInt32LE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,4,4294967295,0),this[he+3]=pe>>>24,this[he+2]=pe>>>16,this[he+1]=pe>>>8,this[he]=pe&255,he+4},A.prototype.writeUint32BE=A.prototype.writeUInt32BE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,4,4294967295,0),this[he]=pe>>>24,this[he+1]=pe>>>16,this[he+2]=pe>>>8,this[he+3]=pe&255,he+4};function Y(Ae,pe,he,Ie,ye){ce(pe,Ie,ye,Ae,he,7);let Pe=Number(pe&BigInt(4294967295));Ae[he++]=Pe,Pe=Pe>>8,Ae[he++]=Pe,Pe=Pe>>8,Ae[he++]=Pe,Pe=Pe>>8,Ae[he++]=Pe;let Ne=Number(pe>>BigInt(32)&BigInt(4294967295));return Ae[he++]=Ne,Ne=Ne>>8,Ae[he++]=Ne,Ne=Ne>>8,Ae[he++]=Ne,Ne=Ne>>8,Ae[he++]=Ne,he}function J(Ae,pe,he,Ie,ye){ce(pe,Ie,ye,Ae,he,7);let Pe=Number(pe&BigInt(4294967295));Ae[he+7]=Pe,Pe=Pe>>8,Ae[he+6]=Pe,Pe=Pe>>8,Ae[he+5]=Pe,Pe=Pe>>8,Ae[he+4]=Pe;let Ne=Number(pe>>BigInt(32)&BigInt(4294967295));return Ae[he+3]=Ne,Ne=Ne>>8,Ae[he+2]=Ne,Ne=Ne>>8,Ae[he+1]=Ne,Ne=Ne>>8,Ae[he]=Ne,he+8}A.prototype.writeBigUInt64LE=Se(function(pe,he=0){return Y(this,pe,he,BigInt(0),BigInt("0xffffffffffffffff"))}),A.prototype.writeBigUInt64BE=Se(function(pe,he=0){return J(this,pe,he,BigInt(0),BigInt("0xffffffffffffffff"))}),A.prototype.writeIntLE=function(pe,he,Ie,ye){if(pe=+pe,he=he>>>0,!ye){const Oe=Math.pow(2,8*Ie-1);Q(this,pe,he,Ie,Oe-1,-Oe)}let Pe=0,Ne=1,Le=0;for(this[he]=pe&255;++Pe<Ie&&(Ne*=256);)pe<0&&Le===0&&this[he+Pe-1]!==0&&(Le=1),this[he+Pe]=(pe/Ne>>0)-Le&255;return he+Ie},A.prototype.writeIntBE=function(pe,he,Ie,ye){if(pe=+pe,he=he>>>0,!ye){const Oe=Math.pow(2,8*Ie-1);Q(this,pe,he,Ie,Oe-1,-Oe)}let Pe=Ie-1,Ne=1,Le=0;for(this[he+Pe]=pe&255;--Pe>=0&&(Ne*=256);)pe<0&&Le===0&&this[he+Pe+1]!==0&&(Le=1),this[he+Pe]=(pe/Ne>>0)-Le&255;return he+Ie},A.prototype.writeInt8=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,1,127,-128),pe<0&&(pe=255+pe+1),this[he]=pe&255,he+1},A.prototype.writeInt16LE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,2,32767,-32768),this[he]=pe&255,this[he+1]=pe>>>8,he+2},A.prototype.writeInt16BE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,2,32767,-32768),this[he]=pe>>>8,this[he+1]=pe&255,he+2},A.prototype.writeInt32LE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,4,2147483647,-2147483648),this[he]=pe&255,this[he+1]=pe>>>8,this[he+2]=pe>>>16,this[he+3]=pe>>>24,he+4},A.prototype.writeInt32BE=function(pe,he,Ie){return pe=+pe,he=he>>>0,Ie||Q(this,pe,he,4,2147483647,-2147483648),pe<0&&(pe=4294967295+pe+1),this[he]=pe>>>24,this[he+1]=pe>>>16,this[he+2]=pe>>>8,this[he+3]=pe&255,he+4},A.prototype.writeBigInt64LE=Se(function(pe,he=0){return Y(this,pe,he,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),A.prototype.writeBigInt64BE=Se(function(pe,he=0){return J(this,pe,he,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ee(Ae,pe,he,Ie,ye,Pe){if(he+Ie>Ae.length)throw new RangeError("Index out of range");if(he<0)throw new RangeError("Index out of range")}function re(Ae,pe,he,Ie,ye){return pe=+pe,he=he>>>0,ye||ee(Ae,pe,he,4),c.write(Ae,pe,he,Ie,23,4),he+4}A.prototype.writeFloatLE=function(pe,he,Ie){return re(this,pe,he,!0,Ie)},A.prototype.writeFloatBE=function(pe,he,Ie){return re(this,pe,he,!1,Ie)};function ae(Ae,pe,he,Ie,ye){return pe=+pe,he=he>>>0,ye||ee(Ae,pe,he,8),c.write(Ae,pe,he,Ie,52,8),he+8}A.prototype.writeDoubleLE=function(pe,he,Ie){return ae(this,pe,he,!0,Ie)},A.prototype.writeDoubleBE=function(pe,he,Ie){return ae(this,pe,he,!1,Ie)},A.prototype.copy=function(pe,he,Ie,ye){if(!A.isBuffer(pe))throw new TypeError("argument should be a Buffer");if(Ie||(Ie=0),!ye&&ye!==0&&(ye=this.length),he>=pe.length&&(he=pe.length),he||(he=0),ye>0&&ye<Ie&&(ye=Ie),ye===Ie||pe.length===0||this.length===0)return 0;if(he<0)throw new RangeError("targetStart out of bounds");if(Ie<0||Ie>=this.length)throw new RangeError("Index out of range");if(ye<0)throw new RangeError("sourceEnd out of bounds");ye>this.length&&(ye=this.length),pe.length-he<ye-Ie&&(ye=pe.length-he+Ie);const Pe=ye-Ie;return this===pe&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(he,Ie,ye):Uint8Array.prototype.set.call(pe,this.subarray(Ie,ye),he),Pe},A.prototype.fill=function(pe,he,Ie,ye){if(typeof pe=="string"){if(typeof he=="string"?(ye=he,he=0,Ie=this.length):typeof Ie=="string"&&(ye=Ie,Ie=this.length),ye!==void 0&&typeof ye!="string")throw new TypeError("encoding must be a string");if(typeof ye=="string"&&!A.isEncoding(ye))throw new TypeError("Unknown encoding: "+ye);if(pe.length===1){const Ne=pe.charCodeAt(0);(ye==="utf8"&&Ne<128||ye==="latin1")&&(pe=Ne)}}else typeof pe=="number"?pe=pe&255:typeof pe=="boolean"&&(pe=Number(pe));if(he<0||this.length<he||this.length<Ie)throw new RangeError("Out of range index");if(Ie<=he)return this;he=he>>>0,Ie=Ie===void 0?this.length:Ie>>>0,pe||(pe=0);let Pe;if(typeof pe=="number")for(Pe=he;Pe<Ie;++Pe)this[Pe]=pe;else{const Ne=A.isBuffer(pe)?pe:A.from(pe,ye),Le=Ne.length;if(Le===0)throw new TypeError('The value "'+pe+'" is invalid for argument "value"');for(Pe=0;Pe<Ie-he;++Pe)this[Pe+he]=Ne[Pe%Le]}return this};const V={};function K(Ae,pe,he){V[Ae]=class extends he{constructor(){super(),Object.defineProperty(this,"message",{value:pe.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${Ae}]`,this.stack,delete this.name}get code(){return Ae}set code(ye){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:ye,writable:!0})}toString(){return`${this.name} [${Ae}]: ${this.message}`}}}K("ERR_BUFFER_OUT_OF_BOUNDS",function(Ae){return Ae?`${Ae} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),K("ERR_INVALID_ARG_TYPE",function(Ae,pe){return`The "${Ae}" argument must be of type number. Received type ${typeof pe}`},TypeError),K("ERR_OUT_OF_RANGE",function(Ae,pe,he){let Ie=`The value of "${Ae}" is out of range.`,ye=he;return Number.isInteger(he)&&Math.abs(he)>2**32?ye=te(String(he)):typeof he=="bigint"&&(ye=String(he),(he>BigInt(2)**BigInt(32)||he<-(BigInt(2)**BigInt(32)))&&(ye=te(ye)),ye+="n"),Ie+=` It must be ${pe}. Received ${ye}`,Ie},RangeError);function te(Ae){let pe="",he=Ae.length;const Ie=Ae[0]==="-"?1:0;for(;he>=Ie+4;he-=3)pe=`_${Ae.slice(he-3,he)}${pe}`;return`${Ae.slice(0,he)}${pe}`}function ie(Ae,pe,he){me(pe,"offset"),(Ae[pe]===void 0||Ae[pe+he]===void 0)&&we(pe,Ae.length-(he+1))}function ce(Ae,pe,he,Ie,ye,Pe){if(Ae>he||Ae<pe){const Ne=typeof pe=="bigint"?"n":"";let Le;throw pe===0||pe===BigInt(0)?Le=`>= 0${Ne} and < 2${Ne} ** ${(Pe+1)*8}${Ne}`:Le=`>= -(2${Ne} ** ${(Pe+1)*8-1}${Ne}) and < 2 ** ${(Pe+1)*8-1}${Ne}`,new V.ERR_OUT_OF_RANGE("value",Le,Ae)}ie(Ie,ye,Pe)}function me(Ae,pe){if(typeof Ae!="number")throw new V.ERR_INVALID_ARG_TYPE(pe,"number",Ae)}function we(Ae,pe,he){throw Math.floor(Ae)!==Ae?(me(Ae,he),new V.ERR_OUT_OF_RANGE("offset","an integer",Ae)):pe<0?new V.ERR_BUFFER_OUT_OF_BOUNDS:new V.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${pe}`,Ae)}const ve=/[^+/0-9A-Za-z-_]/g;function ge(Ae){if(Ae=Ae.split("=")[0],Ae=Ae.trim().replace(ve,""),Ae.length<2)return"";for(;Ae.length%4!==0;)Ae=Ae+"=";return Ae}function ue(Ae,pe){pe=pe||1/0;let he;const Ie=Ae.length;let ye=null;const Pe=[];for(let Ne=0;Ne<Ie;++Ne){if(he=Ae.charCodeAt(Ne),he>55295&&he<57344){if(!ye){if(he>56319){(pe-=3)>-1&&Pe.push(239,191,189);continue}else if(Ne+1===Ie){(pe-=3)>-1&&Pe.push(239,191,189);continue}ye=he;continue}if(he<56320){(pe-=3)>-1&&Pe.push(239,191,189),ye=he;continue}he=(ye-55296<<10|he-56320)+65536}else ye&&(pe-=3)>-1&&Pe.push(239,191,189);if(ye=null,he<128){if((pe-=1)<0)break;Pe.push(he)}else if(he<2048){if((pe-=2)<0)break;Pe.push(he>>6|192,he&63|128)}else if(he<65536){if((pe-=3)<0)break;Pe.push(he>>12|224,he>>6&63|128,he&63|128)}else if(he<1114112){if((pe-=4)<0)break;Pe.push(he>>18|240,he>>12&63|128,he>>6&63|128,he&63|128)}else throw new Error("Invalid code point")}return Pe}function se(Ae){const pe=[];for(let he=0;he<Ae.length;++he)pe.push(Ae.charCodeAt(he)&255);return pe}function oe(Ae,pe){let he,Ie,ye;const Pe=[];for(let Ne=0;Ne<Ae.length&&!((pe-=2)<0);++Ne)he=Ae.charCodeAt(Ne),Ie=he>>8,ye=he%256,Pe.push(ye),Pe.push(Ie);return Pe}function de(Ae){return s.toByteArray(ge(Ae))}function le(Ae,pe,he,Ie){let ye;for(ye=0;ye<Ie&&!(ye+he>=pe.length||ye>=Ae.length);++ye)pe[ye+he]=Ae[ye];return ye}function xe(Ae,pe){return Ae instanceof pe||Ae!=null&&Ae.constructor!=null&&Ae.constructor.name!=null&&Ae.constructor.name===pe.name}function Ce(Ae){return Ae!==Ae}const $e=function(){const Ae="0123456789abcdef",pe=new Array(256);for(let he=0;he<16;++he){const Ie=he*16;for(let ye=0;ye<16;++ye)pe[Ie+ye]=Ae[he]+Ae[ye]}return pe}();function Se(Ae){return typeof BigInt>"u"?Ee:Ae}function Ee(){throw new Error("BigInt not supported")}}(buffer$1)),buffer$1}var bufferExports=requireBuffer();const langs=["en","zh","ja","ko","ar","th","pl","it","de","es","fr"],Lang=z.enum(langs);z.object({cancel:z.string(),close:z.string(),set:z.string(),clear:z.string(),field:z.string(),fieldName:z.string(),align:z.string(),width:z.string(),opacity:z.string(),height:z.string(),rotate:z.string(),edit:z.string(),required:z.string(),editable:z.string(),plsInputName:z.string(),fieldMustUniq:z.string(),notUniq:z.string(),noKeyName:z.string(),fieldsList:z.string(),editField:z.string(),type:z.string(),errorOccurred:z.string(),errorBulkUpdateFieldName:z.string(),commitBulkUpdateFieldName:z.string(),bulkUpdateFieldName:z.string(),addPageAfter:z.string(),removePage:z.string(),removePageConfirm:z.string(),"validation.uniqueName":z.string(),"validation.hexColor":z.string(),"validation.dateTimeFormat":z.string(),"schemas.color":z.string(),"schemas.borderWidth":z.string(),"schemas.borderColor":z.string(),"schemas.backgroundColor":z.string(),"schemas.textColor":z.string(),"schemas.bgColor":z.string(),"schemas.horizontal":z.string(),"schemas.vertical":z.string(),"schemas.left":z.string(),"schemas.center":z.string(),"schemas.right":z.string(),"schemas.top":z.string(),"schemas.middle":z.string(),"schemas.bottom":z.string(),"schemas.padding":z.string(),"schemas.text.fontName":z.string(),"schemas.text.size":z.string(),"schemas.text.spacing":z.string(),"schemas.text.textAlign":z.string(),"schemas.text.verticalAlign":z.string(),"schemas.text.lineHeight":z.string(),"schemas.text.min":z.string(),"schemas.text.max":z.string(),"schemas.text.fit":z.string(),"schemas.text.dynamicFontSize":z.string(),"schemas.text.format":z.string(),"schemas.radius":z.string(),"schemas.mvt.typingInstructions":z.string(),"schemas.mvt.sampleField":z.string(),"schemas.mvt.variablesSampleData":z.string(),"schemas.barcodes.barColor":z.string(),"schemas.barcodes.includetext":z.string(),"schemas.table.alternateBackgroundColor":z.string(),"schemas.table.tableStyle":z.string(),"schemas.table.showHead":z.string(),"schemas.table.headStyle":z.string(),"schemas.table.bodyStyle":z.string(),"schemas.table.columnStyle":z.string(),"schemas.date.format":z.string(),"schemas.date.locale":z.string(),"schemas.select.options":z.string(),"schemas.select.optionPlaceholder":z.string(),"schemas.radioGroup.groupName":z.string()}),z.enum(["viewer","form","designer"]);const ColorType=z.enum(["rgb","cmyk"]).optional();z.object({height:z.number(),width:z.number()});const Schema$1=z.object({name:z.string(),type:z.string(),content:z.string().optional(),position:z.object({x:z.number(),y:z.number()}),width:z.number(),height:z.number(),rotate:z.number().optional(),opacity:z.number().optional(),readOnly:z.boolean().optional(),required:z.boolean().optional(),__bodyRange:z.object({start:z.number(),end:z.number().optional()}).optional(),__isSplit:z.boolean().optional()}).passthrough(),SchemaForUIAdditionalInfo=z.object({id:z.string()});Schema$1.merge(SchemaForUIAdditionalInfo);const ArrayBufferSchema=z.any().refine(a=>a instanceof ArrayBuffer),Uint8ArraySchema=z.any().refine(a=>a instanceof Uint8Array),BlankPdf=z.object({width:z.number(),height:z.number(),padding:z.tuple([z.number(),z.number(),z.number(),z.number()]),staticSchema:z.array(Schema$1).optional()}),CustomPdf=z.union([z.string(),ArrayBufferSchema,Uint8ArraySchema]),BasePdf=z.union([CustomPdf,BlankPdf]);z.array(z.record(Schema$1));const SchemaPageArray=z.array(z.array(Schema$1)),Template=z.object({schemas:SchemaPageArray,basePdf:BasePdf,pdfmeVersion:z.string().optional()}).passthrough(),Inputs=z.array(z.record(z.any())).min(1),Font=z.record(z.object({data:z.union([z.string(),ArrayBufferSchema,Uint8ArraySchema]),fallback:z.boolean().optional(),subset:z.boolean().optional()})),Plugin=z.object({ui:z.function().args(z.any()).returns(z.any()),pdf:z.function().args(z.any()).returns(z.any()),propPanel:z.object({schema:z.unknown(),widgets:z.record(z.any()).optional(),defaultSchema:Schema$1}),icon:z.string().optional()}).passthrough(),CommonOptions=z.object({font:Font.optional()}).passthrough(),CommonProps=z.object({template:Template,options:CommonOptions.optional(),plugins:z.record(Plugin).optional()}),GeneratorOptions=CommonOptions.extend({colorType:ColorType,author:z.string().optional(),creationDate:z.date().optional(),creator:z.string().optional(),keywords:z.array(z.string()).optional(),lang:Lang.optional(),modificationDate:z.date().optional(),producer:z.string().optional(),subject:z.string().optional(),title:z.string().optional()});CommonProps.extend({inputs:Inputs,options:GeneratorOptions.optional()}).strict();const UIOptions=CommonOptions.extend({lang:Lang.optional(),labels:z.record(z.string(),z.string()).optional(),theme:z.record(z.string(),z.unknown()).optional(),icons:z.record(z.string(),z.string()).optional(),requiredByDefault:z.boolean().optional(),maxZoom:z.number().optional()}),HTMLElementSchema=z.any().refine(a=>a instanceof HTMLElement),UIProps=CommonProps.extend({domContainer:HTMLElementSchema,options:UIOptions.optional()}),PreviewProps=UIProps.extend({inputs:Inputs}).strict(),DesignerProps=UIProps.extend({}).strict(),cloneDeep$1=structuredClone,uniq=a=>Array.from(new Set(a)),getFallbackFontName=a=>{const s="",c=Object.entries(a).reduce((u,d)=>{const[p,v]=d;return!u&&v.fallback?p:u},s);if(c===s)throw Error("[@pdfme/common] fallback flag is not found in font. true fallback flag must be only one.");return c},getDefaultFont=()=>({[DEFAULT_FONT_NAME]:{data:b64toUint8Array(DEFAULT_FONT_VALUE),fallback:!0}}),mm2pt=a=>parseFloat(String(a))*MM_TO_PT_RATIO,pt2mm=a=>a*PT_TO_MM_RATIO,pt2px=a=>a*PT_TO_PX_RATIO,px2mm=a=>parseFloat(String(a))*.26458333333333,blob2Base64Pdf=a=>new Promise((s,c)=>{const u=new FileReader;u.onloadend=()=>{u.result.startsWith("data:application/pdf;")?s(u.result):c(Error("[@pdfme/common] template.basePdf must be pdf data."))},u.readAsDataURL(a)}),isHexValid=a=>/^#(?:[A-Fa-f0-9]{3,4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/i.test(a),migrateTemplate=a=>{a.schemas&&Array.isArray(a.schemas)&&a.schemas.length>0&&!Array.isArray(a.schemas[0])&&(a.schemas=a.schemas.map(s=>Object.entries(s).map(([c,u])=>({...u,name:c}))))},getB64BasePdf=async a=>{if(typeof a=="string"&&!a.startsWith("data:application/pdf;")&&typeof window<"u"){const u=await(await fetch(a)).blob();return blob2Base64Pdf(u)}if(typeof a=="string")return a;const s=a instanceof Uint8Array?a:new Uint8Array(a);return"data:application/pdf;base64,"+bufferExports.Buffer.from(s).toString("base64")},isBlankPdf=a=>BlankPdf.safeParse(a).success,getByteString=a=>bufferExports.Buffer.from(a,"base64").toString("binary"),b64toUint8Array=a=>{const s=a.split(";base64,")[1]?a.split(";base64,")[1]:a,c=getByteString(s),u=new Uint8Array(c.length);for(let d=0;d<c.length;d+=1)u[d]=c.charCodeAt(d);return u},getFontNamesInSchemas=a=>uniq(a.map(s=>s.map(c=>c.fontName??"")).reduce((s,c)=>s.concat(c),[]).filter(Boolean)),checkFont=a=>{const{font:s,template:{schemas:c}}=a,d=Object.values(s).reduce((A,b)=>b.fallback?A+1:A,0);if(d===0)throw Error(`[@pdfme/common] fallback flag is not found in font. true fallback flag must be only one.
|
43
43
|
Check this document: https://pdfme.com/docs/custom-fonts#about-font-type`);if(d>1)throw Error(`[@pdfme/common] ${d} fallback flags found in font. true fallback flag must be only one.
|
44
44
|
Check this document: https://pdfme.com/docs/custom-fonts#about-font-type`);const p=getFontNamesInSchemas(c),v=Object.keys(s);if(p.some(A=>!v.includes(A)))throw Error(`[@pdfme/common] ${p.filter(A=>!v.includes(A)).join()} of template.schemas is not found in font.
|
45
|
-
Check this document: https://pdfme.com/docs/custom-fonts`)},checkPlugins=a=>{const{plugins:s,template:{schemas:c}}=a,u=uniq(c.map(p=>p.map(v=>v.type)).flat()),d=Object.values(s).map(p=>p?p.propPanel.defaultSchema.type:void 0);if(u.some(p=>!d.includes(p)))throw Error(`[@pdfme/common] ${u.filter(p=>!d.includes(p)).join()} of template.schemas is not found in plugins.`)},checkProps=(a,s)=>{try{s.parse(a)}catch(c){if(c instanceof z.ZodError){const
|
46
|
-
ERROR MESSAGE: ${
|
47
|
-
--------------------------`)
|
48
|
-
`);throw Error(`[@pdfme/common] Invalid argument:
|
45
|
+
Check this document: https://pdfme.com/docs/custom-fonts`)},checkPlugins=a=>{const{plugins:s,template:{schemas:c}}=a,u=uniq(c.map(p=>p.map(v=>v.type)).flat()),d=Object.values(s).map(p=>p?p.propPanel.defaultSchema.type:void 0);if(u.some(p=>!d.includes(p)))throw Error(`[@pdfme/common] ${u.filter(p=>!d.includes(p)).join()} of template.schemas is not found in plugins.`)},checkProps=(a,s)=>{try{s.parse(a)}catch(c){if(c instanceof z.ZodError){const u=c.issues.map(d=>`ERROR POSITION: ${d.path.join(".")}
|
46
|
+
ERROR MESSAGE: ${d.message}
|
47
|
+
--------------------------`);throw Error(`[@pdfme/common] Invalid argument:
|
49
48
|
--------------------------
|
50
|
-
${d}`)}}if(a&&typeof a=="object"&&"template"in a&&"options"in a){const{template:c,options:u}=a;u&&u.font&&checkFont({font:u.font,template:c})}if(a&&typeof a=="object"&&"template"in a&&"plugins"in a){const{template:c,plugins:u}=a;u&&checkPlugins({plugins:u,template:c})}},checkInputs=a=>checkProps(a,Inputs),checkUIOptions=a=>checkProps(a,UIOptions),checkPreviewProps=a=>checkProps(a,PreviewProps),checkDesignerProps=a=>checkProps(a,DesignerProps),checkUIProps=a=>{typeof a=="object"&&a!==null&&"template"in a&&migrateTemplate(a.template),checkProps(a,UIProps)},checkTemplate=a=>{migrateTemplate(a),checkProps(a,Template)};class LayoutNode{constructor({width:s=0,height:c=0}={}){Object.defineProperty(this,"index",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"children",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"padding",{enumerable:!0,configurable:!0,writable:!0,value:[0,0,0,0]}),Object.defineProperty(this,"position",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0}}),this.width=s,this.height=c}setIndex(s){this.index=s}setSchema(s){this.schema=s}setWidth(s){this.width=s}setHeight(s){this.height=s}setPadding(s){this.padding=s}setPosition(s){this.position=s}insertChild(s){const c=this.getChildCount();s.setIndex(c),this.children.splice(c,0,s)}getChildCount(){return this.children.length}getChild(s){return this.children[s]}}function createPage(a){const s=new LayoutNode({...a});return s.setPadding(a.padding),s}function createNode(a){const{position:s,width:c,height:u,schema:d}=a,p=new LayoutNode({width:c,height:u});return p.setPosition(s),p.setSchema(d),p}function resortChildren(a,s){a.children=a.children.sort((c,u)=>{var v,A;const d=s.get(((v=c.schema)==null?void 0:v.name)??""),p=s.get(((A=u.schema)==null?void 0:A.name)??"");if(d===void 0||p===void 0)throw new Error("[@pdfme/common] order is not defined");return d-p}).map((c,u)=>(c.setIndex(u),c))}async function createOnePage(a){const{basePdf:s,schemaPage:c,orderMap:u,input:d,options:p,_cache:v,getDynamicHeights:A}=a,b=createPage(s),g=[],x=cloneDeep$1(c).sort((m,C)=>m.position.y-C.position.y),y=new Map;for(const m of x){const{position:C,width:S}=m,w={schema:m,basePdf:s,options:p,_cache:v},_=(m.readOnly?m.content:d==null?void 0:d[m.name])||"",I=await A(_,w),$=I.reduce((E,R)=>E+R,0),P=m.height;$!==P&&y.set(C.y+P,$-P),I.forEach((E,R)=>{let T=m.position.y+I.reduce((M,k,O)=>O<R?M+k:M,0);for(const[M,k]of y.entries())M<=m.position.y&&(T+=k);const B=createNode({schema:m,position:{...C,y:T},width:S,height:E});g.push(T+E+s.padding[2]),b.insertChild(B)})}const f=Math.max(...g,s.height-s.padding[2]);return b.setHeight(f),resortChildren(b,u),b}function breakIntoPages(a){const{longPage:s,orderMap:c,basePdf:u}=a,d=[createPage(u)],[p,,v]=u.padding,A=[],b=y=>u.height-v-(y>0?p:0),g=(y,f)=>{var C;const m=y-f*(u.height-p-v);for(;d.length<=f;)d[f]||(d.push(createPage(u)),A.push({page:f,value:(m-p)*-1}));return m+(((C=A.find(S=>S.page===f))==null?void 0:C.value)||0)},x=s.children.sort((y,f)=>y.position.y-f.position.y);for(let y=0;y<x.length;y++){const{schema:f,position:m,height:C,width:S}=x[y],{y:w,x:_}=m;let I=Math.floor(w/b(d.length-1)),$=g(w,I);if($+C>u.height-v&&(I++,$=g(w,I)),!f)throw new Error("[@pdfme/common] schema is undefined");const P=createNode({schema:f,position:{x:_,y:$},width:S,height:C});d[I].insertChild(P)}return d.forEach(y=>resortChildren(y,c)),d}function createNewTemplate(a,s){const c={schemas:Array.from({length:a.length},()=>[]),basePdf:s},u=new Map;return cloneDeep$1(a).forEach((d,p)=>{d.children.forEach(v=>{const{schema:A}=v;if(!A)throw new Error("[@pdfme/common] schema is undefined");const b=A.name;u.has(b)||u.set(b,[]),u.get(b).push(v);const g=d.children.filter(y=>{var f;return((f=y.schema)==null?void 0:f.name)===b}),x=u.get(b).length-g.length;if(g.length>0){if(!g[0].schema)throw new Error("[@pdfme/common] schema is undefined");const y=g[0].schema,f=g.reduce((w,_)=>w+_.height,0),m=g[0].position;y.__bodyRange={start:Math.max(x-1,0),end:x+g.length-1},y.__isSplit=x>0;const C=Object.assign({},y,{position:m,height:f}),S=c.schemas[p].findIndex(w=>w.name===b);S!==-1?c.schemas[p][S]=C:c.schemas[p].push(C)}})}),c}const getDynamicTemplate=async a=>{const{template:s}=a;if(!isBlankPdf(s.basePdf))return s;const c=s.basePdf,u=[];for(const d of s.schemas){const p=new Map(d.map((b,g)=>[b.name,g])),v=await createOnePage({basePdf:c,schemaPage:d,orderMap:p,...a}),A=breakIntoPages({longPage:v,basePdf:c,orderMap:p});u.push(...A)}return createNewTemplate(u,s.basePdf)};var astralIdentifierCodes=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],astralIdentifierStartCodes=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],nonASCIIidentifierChars="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",nonASCIIidentifierStartChars="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",reservedWords={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},ecma5AndLessKeywords="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",keywords$1={5:ecma5AndLessKeywords,"5module":ecma5AndLessKeywords+" export import",6:ecma5AndLessKeywords+" const class extends export import super"},keywordRelationalOperator=/^in(stanceof)?$/,nonASCIIidentifierStart=new RegExp("["+nonASCIIidentifierStartChars+"]"),nonASCIIidentifier=new RegExp("["+nonASCIIidentifierStartChars+nonASCIIidentifierChars+"]");function isInAstralSet(a,s){for(var c=65536,u=0;u<s.length;u+=2){if(c+=s[u],c>a)return!1;if(c+=s[u+1],c>=a)return!0}return!1}function isIdentifierStart(a,s){return a<65?a===36:a<91?!0:a<97?a===95:a<123?!0:a<=65535?a>=170&&nonASCIIidentifierStart.test(String.fromCharCode(a)):s===!1?!1:isInAstralSet(a,astralIdentifierStartCodes)}function isIdentifierChar(a,s){return a<48?a===36:a<58?!0:a<65?!1:a<91?!0:a<97?a===95:a<123?!0:a<=65535?a>=170&&nonASCIIidentifier.test(String.fromCharCode(a)):s===!1?!1:isInAstralSet(a,astralIdentifierStartCodes)||isInAstralSet(a,astralIdentifierCodes)}var TokenType=function(s,c){c===void 0&&(c={}),this.label=s,this.keyword=c.keyword,this.beforeExpr=!!c.beforeExpr,this.startsExpr=!!c.startsExpr,this.isLoop=!!c.isLoop,this.isAssign=!!c.isAssign,this.prefix=!!c.prefix,this.postfix=!!c.postfix,this.binop=c.binop||null,this.updateContext=null};function binop(a,s){return new TokenType(a,{beforeExpr:!0,binop:s})}var beforeExpr={beforeExpr:!0},startsExpr={startsExpr:!0},keywords={};function kw(a,s){return s===void 0&&(s={}),s.keyword=a,keywords[a]=new TokenType(a,s)}var types$1={num:new TokenType("num",startsExpr),regexp:new TokenType("regexp",startsExpr),string:new TokenType("string",startsExpr),name:new TokenType("name",startsExpr),privateId:new TokenType("privateId",startsExpr),eof:new TokenType("eof"),bracketL:new TokenType("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new TokenType("]"),braceL:new TokenType("{",{beforeExpr:!0,startsExpr:!0}),braceR:new TokenType("}"),parenL:new TokenType("(",{beforeExpr:!0,startsExpr:!0}),parenR:new TokenType(")"),comma:new TokenType(",",beforeExpr),semi:new TokenType(";",beforeExpr),colon:new TokenType(":",beforeExpr),dot:new TokenType("."),question:new TokenType("?",beforeExpr),questionDot:new TokenType("?."),arrow:new TokenType("=>",beforeExpr),template:new TokenType("template"),invalidTemplate:new TokenType("invalidTemplate"),ellipsis:new TokenType("...",beforeExpr),backQuote:new TokenType("`",startsExpr),dollarBraceL:new TokenType("${",{beforeExpr:!0,startsExpr:!0}),eq:new TokenType("=",{beforeExpr:!0,isAssign:!0}),assign:new TokenType("_=",{beforeExpr:!0,isAssign:!0}),incDec:new TokenType("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new TokenType("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:binop("||",1),logicalAND:binop("&&",2),bitwiseOR:binop("|",3),bitwiseXOR:binop("^",4),bitwiseAND:binop("&",5),equality:binop("==/!=/===/!==",6),relational:binop("</>/<=/>=",7),bitShift:binop("<</>>/>>>",8),plusMin:new TokenType("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:binop("%",10),star:binop("*",10),slash:binop("/",10),starstar:new TokenType("**",{beforeExpr:!0}),coalesce:binop("??",1),_break:kw("break"),_case:kw("case",beforeExpr),_catch:kw("catch"),_continue:kw("continue"),_debugger:kw("debugger"),_default:kw("default",beforeExpr),_do:kw("do",{isLoop:!0,beforeExpr:!0}),_else:kw("else",beforeExpr),_finally:kw("finally"),_for:kw("for",{isLoop:!0}),_function:kw("function",startsExpr),_if:kw("if"),_return:kw("return",beforeExpr),_switch:kw("switch"),_throw:kw("throw",beforeExpr),_try:kw("try"),_var:kw("var"),_const:kw("const"),_while:kw("while",{isLoop:!0}),_with:kw("with"),_new:kw("new",{beforeExpr:!0,startsExpr:!0}),_this:kw("this",startsExpr),_super:kw("super",startsExpr),_class:kw("class",startsExpr),_extends:kw("extends",beforeExpr),_export:kw("export"),_import:kw("import",startsExpr),_null:kw("null",startsExpr),_true:kw("true",startsExpr),_false:kw("false",startsExpr),_in:kw("in",{beforeExpr:!0,binop:7}),_instanceof:kw("instanceof",{beforeExpr:!0,binop:7}),_typeof:kw("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:kw("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:kw("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},lineBreak=/\r\n?|\n|\u2028|\u2029/,lineBreakG=new RegExp(lineBreak.source,"g");function isNewLine(a){return a===10||a===13||a===8232||a===8233}function nextLineBreak(a,s,c){c===void 0&&(c=a.length);for(var u=s;u<c;u++){var d=a.charCodeAt(u);if(isNewLine(d))return u<c-1&&d===13&&a.charCodeAt(u+1)===10?u+2:u+1}return-1}var nonASCIIwhitespace=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,skipWhiteSpace=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ref$1=Object.prototype,hasOwnProperty$e=ref$1.hasOwnProperty,toString$1=ref$1.toString,hasOwn=Object.hasOwn||function(a,s){return hasOwnProperty$e.call(a,s)},isArray$3=Array.isArray||function(a){return toString$1.call(a)==="[object Array]"},regexpCache=Object.create(null);function wordsRegexp(a){return regexpCache[a]||(regexpCache[a]=new RegExp("^(?:"+a.replace(/ /g,"|")+")$"))}function codePointToString(a){return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode((a>>10)+55296,(a&1023)+56320))}var loneSurrogate=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Position=function(s,c){this.line=s,this.column=c};Position.prototype.offset=function(s){return new Position(this.line,this.column+s)};var SourceLocation=function(s,c,u){this.start=c,this.end=u,s.sourceFile!==null&&(this.source=s.sourceFile)};function getLineInfo(a,s){for(var c=1,u=0;;){var d=nextLineBreak(a,u,s);if(d<0)return new Position(c,s-u);++c,u=d}}var defaultOptions$1={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},warnedAboutEcmaVersion=!1;function getOptions(a){var s={};for(var c in defaultOptions$1)s[c]=a&&hasOwn(a,c)?a[c]:defaultOptions$1[c];if(s.ecmaVersion==="latest"?s.ecmaVersion=1e8:s.ecmaVersion==null?(!warnedAboutEcmaVersion&&typeof console=="object"&&console.warn&&(warnedAboutEcmaVersion=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
49
|
+
${u.join(`
|
50
|
+
`)}`)}else throw Error(`[@pdfme/common] Unexpected parsing error: ${c instanceof Error?c.message:String(c)}`)}if(a&&typeof a=="object"&&"template"in a&&"options"in a){const{template:c,options:u}=a;u&&u.font&&checkFont({font:u.font,template:c})}if(a&&typeof a=="object"&&"template"in a&&"plugins"in a){const{template:c,plugins:u}=a;u&&checkPlugins({plugins:u,template:c})}},checkInputs=a=>checkProps(a,Inputs),checkUIOptions=a=>checkProps(a,UIOptions),checkPreviewProps=a=>checkProps(a,PreviewProps),checkDesignerProps=a=>checkProps(a,DesignerProps),checkUIProps=a=>{typeof a=="object"&&a!==null&&"template"in a&&migrateTemplate(a.template),checkProps(a,UIProps)},checkTemplate=a=>{migrateTemplate(a),checkProps(a,Template)};class LayoutNode{constructor({width:s=0,height:c=0}={}){Object.defineProperty(this,"index",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"children",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"padding",{enumerable:!0,configurable:!0,writable:!0,value:[0,0,0,0]}),Object.defineProperty(this,"position",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0}}),this.width=s,this.height=c}setIndex(s){this.index=s}setSchema(s){this.schema=s}setWidth(s){this.width=s}setHeight(s){this.height=s}setPadding(s){this.padding=s}setPosition(s){this.position=s}insertChild(s){const c=this.getChildCount();s.setIndex(c),this.children.splice(c,0,s)}getChildCount(){return this.children.length}getChild(s){return this.children[s]}}function createPage(a){const s=new LayoutNode({...a});return s.setPadding(a.padding),s}function createNode(a){const{position:s,width:c,height:u,schema:d}=a,p=new LayoutNode({width:c,height:u});return p.setPosition(s),p.setSchema(d),p}function resortChildren(a,s){a.children=a.children.sort((c,u)=>{var v,A;const d=s.get(((v=c.schema)==null?void 0:v.name)??""),p=s.get(((A=u.schema)==null?void 0:A.name)??"");if(d===void 0||p===void 0)throw new Error("[@pdfme/common] order is not defined");return d-p}).map((c,u)=>(c.setIndex(u),c))}async function createOnePage(a){const{basePdf:s,schemaPage:c,orderMap:u,input:d,options:p,_cache:v,getDynamicHeights:A}=a,b=createPage(s),g=[],x=cloneDeep$1(c).sort((m,C)=>m.position.y-C.position.y),y=new Map;for(const m of x){const{position:C,width:S}=m,w={schema:m,basePdf:s,options:p,_cache:v},_=(m.readOnly?m.content:d==null?void 0:d[m.name])||"",I=await A(_,w),$=I.reduce((E,R)=>E+R,0),P=m.height;$!==P&&y.set(C.y+P,$-P),I.forEach((E,R)=>{let T=m.position.y+I.reduce((M,k,O)=>O<R?M+k:M,0);for(const[M,k]of y.entries())M<=m.position.y&&(T+=k);const B=createNode({schema:m,position:{...C,y:T},width:S,height:E});g.push(T+E+s.padding[2]),b.insertChild(B)})}const f=Math.max(...g,s.height-s.padding[2]);return b.setHeight(f),resortChildren(b,u),b}function breakIntoPages(a){const{longPage:s,orderMap:c,basePdf:u}=a,d=[createPage(u)],[p,,v]=u.padding,A=[],b=y=>u.height-v-(y>0?p:0),g=(y,f)=>{var C;const m=y-f*(u.height-p-v);for(;d.length<=f;)d[f]||(d.push(createPage(u)),A.push({page:f,value:(m-p)*-1}));return m+(((C=A.find(S=>S.page===f))==null?void 0:C.value)||0)},x=s.children.sort((y,f)=>y.position.y-f.position.y);for(let y=0;y<x.length;y++){const{schema:f,position:m,height:C,width:S}=x[y],{y:w,x:_}=m;let I=Math.floor(w/b(d.length-1)),$=g(w,I);if($+C>u.height-v&&(I++,$=g(w,I)),!f)throw new Error("[@pdfme/common] schema is undefined");const P=createNode({schema:f,position:{x:_,y:$},width:S,height:C});d[I].insertChild(P)}return d.forEach(y=>resortChildren(y,c)),d}function createNewTemplate(a,s){const c={schemas:Array.from({length:a.length},()=>[]),basePdf:s},u=new Map;return cloneDeep$1(a).forEach((d,p)=>{d.children.forEach(v=>{const{schema:A}=v;if(!A)throw new Error("[@pdfme/common] schema is undefined");const b=A.name;u.has(b)||u.set(b,[]),u.get(b).push(v);const g=d.children.filter(y=>{var f;return((f=y.schema)==null?void 0:f.name)===b}),x=u.get(b).length-g.length;if(g.length>0){if(!g[0].schema)throw new Error("[@pdfme/common] schema is undefined");const y=g[0].schema,f=g.reduce((w,_)=>w+_.height,0),m=g[0].position;y.__bodyRange={start:Math.max(x-1,0),end:x+g.length-1},y.__isSplit=x>0;const C=Object.assign({},y,{position:m,height:f}),S=c.schemas[p].findIndex(w=>w.name===b);S!==-1?c.schemas[p][S]=C:c.schemas[p].push(C)}})}),c}const getDynamicTemplate=async a=>{const{template:s}=a;if(!isBlankPdf(s.basePdf))return s;const c=s.basePdf,u=[];for(const d of s.schemas){const p=new Map(d.map((b,g)=>[b.name,g])),v=await createOnePage({basePdf:c,schemaPage:d,orderMap:p,...a}),A=breakIntoPages({longPage:v,basePdf:c,orderMap:p});u.push(...A)}return createNewTemplate(u,s.basePdf)};var astralIdentifierCodes=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],astralIdentifierStartCodes=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],nonASCIIidentifierChars="·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・",nonASCIIidentifierStartChars="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-Ꟑꟑꟓꟕ-ꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",reservedWords={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},ecma5AndLessKeywords="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",keywords$1={5:ecma5AndLessKeywords,"5module":ecma5AndLessKeywords+" export import",6:ecma5AndLessKeywords+" const class extends export import super"},keywordRelationalOperator=/^in(stanceof)?$/,nonASCIIidentifierStart=new RegExp("["+nonASCIIidentifierStartChars+"]"),nonASCIIidentifier=new RegExp("["+nonASCIIidentifierStartChars+nonASCIIidentifierChars+"]");function isInAstralSet(a,s){for(var c=65536,u=0;u<s.length;u+=2){if(c+=s[u],c>a)return!1;if(c+=s[u+1],c>=a)return!0}return!1}function isIdentifierStart(a,s){return a<65?a===36:a<91?!0:a<97?a===95:a<123?!0:a<=65535?a>=170&&nonASCIIidentifierStart.test(String.fromCharCode(a)):s===!1?!1:isInAstralSet(a,astralIdentifierStartCodes)}function isIdentifierChar(a,s){return a<48?a===36:a<58?!0:a<65?!1:a<91?!0:a<97?a===95:a<123?!0:a<=65535?a>=170&&nonASCIIidentifier.test(String.fromCharCode(a)):s===!1?!1:isInAstralSet(a,astralIdentifierStartCodes)||isInAstralSet(a,astralIdentifierCodes)}var TokenType=function(s,c){c===void 0&&(c={}),this.label=s,this.keyword=c.keyword,this.beforeExpr=!!c.beforeExpr,this.startsExpr=!!c.startsExpr,this.isLoop=!!c.isLoop,this.isAssign=!!c.isAssign,this.prefix=!!c.prefix,this.postfix=!!c.postfix,this.binop=c.binop||null,this.updateContext=null};function binop(a,s){return new TokenType(a,{beforeExpr:!0,binop:s})}var beforeExpr={beforeExpr:!0},startsExpr={startsExpr:!0},keywords={};function kw(a,s){return s===void 0&&(s={}),s.keyword=a,keywords[a]=new TokenType(a,s)}var types$1={num:new TokenType("num",startsExpr),regexp:new TokenType("regexp",startsExpr),string:new TokenType("string",startsExpr),name:new TokenType("name",startsExpr),privateId:new TokenType("privateId",startsExpr),eof:new TokenType("eof"),bracketL:new TokenType("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new TokenType("]"),braceL:new TokenType("{",{beforeExpr:!0,startsExpr:!0}),braceR:new TokenType("}"),parenL:new TokenType("(",{beforeExpr:!0,startsExpr:!0}),parenR:new TokenType(")"),comma:new TokenType(",",beforeExpr),semi:new TokenType(";",beforeExpr),colon:new TokenType(":",beforeExpr),dot:new TokenType("."),question:new TokenType("?",beforeExpr),questionDot:new TokenType("?."),arrow:new TokenType("=>",beforeExpr),template:new TokenType("template"),invalidTemplate:new TokenType("invalidTemplate"),ellipsis:new TokenType("...",beforeExpr),backQuote:new TokenType("`",startsExpr),dollarBraceL:new TokenType("${",{beforeExpr:!0,startsExpr:!0}),eq:new TokenType("=",{beforeExpr:!0,isAssign:!0}),assign:new TokenType("_=",{beforeExpr:!0,isAssign:!0}),incDec:new TokenType("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new TokenType("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:binop("||",1),logicalAND:binop("&&",2),bitwiseOR:binop("|",3),bitwiseXOR:binop("^",4),bitwiseAND:binop("&",5),equality:binop("==/!=/===/!==",6),relational:binop("</>/<=/>=",7),bitShift:binop("<</>>/>>>",8),plusMin:new TokenType("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:binop("%",10),star:binop("*",10),slash:binop("/",10),starstar:new TokenType("**",{beforeExpr:!0}),coalesce:binop("??",1),_break:kw("break"),_case:kw("case",beforeExpr),_catch:kw("catch"),_continue:kw("continue"),_debugger:kw("debugger"),_default:kw("default",beforeExpr),_do:kw("do",{isLoop:!0,beforeExpr:!0}),_else:kw("else",beforeExpr),_finally:kw("finally"),_for:kw("for",{isLoop:!0}),_function:kw("function",startsExpr),_if:kw("if"),_return:kw("return",beforeExpr),_switch:kw("switch"),_throw:kw("throw",beforeExpr),_try:kw("try"),_var:kw("var"),_const:kw("const"),_while:kw("while",{isLoop:!0}),_with:kw("with"),_new:kw("new",{beforeExpr:!0,startsExpr:!0}),_this:kw("this",startsExpr),_super:kw("super",startsExpr),_class:kw("class",startsExpr),_extends:kw("extends",beforeExpr),_export:kw("export"),_import:kw("import",startsExpr),_null:kw("null",startsExpr),_true:kw("true",startsExpr),_false:kw("false",startsExpr),_in:kw("in",{beforeExpr:!0,binop:7}),_instanceof:kw("instanceof",{beforeExpr:!0,binop:7}),_typeof:kw("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:kw("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:kw("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},lineBreak=/\r\n?|\n|\u2028|\u2029/,lineBreakG=new RegExp(lineBreak.source,"g");function isNewLine(a){return a===10||a===13||a===8232||a===8233}function nextLineBreak(a,s,c){c===void 0&&(c=a.length);for(var u=s;u<c;u++){var d=a.charCodeAt(u);if(isNewLine(d))return u<c-1&&d===13&&a.charCodeAt(u+1)===10?u+2:u+1}return-1}var nonASCIIwhitespace=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,skipWhiteSpace=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,ref$1=Object.prototype,hasOwnProperty$e=ref$1.hasOwnProperty,toString$1=ref$1.toString,hasOwn=Object.hasOwn||function(a,s){return hasOwnProperty$e.call(a,s)},isArray$3=Array.isArray||function(a){return toString$1.call(a)==="[object Array]"},regexpCache=Object.create(null);function wordsRegexp(a){return regexpCache[a]||(regexpCache[a]=new RegExp("^(?:"+a.replace(/ /g,"|")+")$"))}function codePointToString(a){return a<=65535?String.fromCharCode(a):(a-=65536,String.fromCharCode((a>>10)+55296,(a&1023)+56320))}var loneSurrogate=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Position=function(s,c){this.line=s,this.column=c};Position.prototype.offset=function(s){return new Position(this.line,this.column+s)};var SourceLocation=function(s,c,u){this.start=c,this.end=u,s.sourceFile!==null&&(this.source=s.sourceFile)};function getLineInfo(a,s){for(var c=1,u=0;;){var d=nextLineBreak(a,u,s);if(d<0)return new Position(c,s-u);++c,u=d}}var defaultOptions$1={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},warnedAboutEcmaVersion=!1;function getOptions(a){var s={};for(var c in defaultOptions$1)s[c]=a&&hasOwn(a,c)?a[c]:defaultOptions$1[c];if(s.ecmaVersion==="latest"?s.ecmaVersion=1e8:s.ecmaVersion==null?(!warnedAboutEcmaVersion&&typeof console=="object"&&console.warn&&(warnedAboutEcmaVersion=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
51
51
|
Defaulting to 2020, but this will stop working in the future.`)),s.ecmaVersion=11):s.ecmaVersion>=2015&&(s.ecmaVersion-=2009),s.allowReserved==null&&(s.allowReserved=s.ecmaVersion<5),(!a||a.allowHashBang==null)&&(s.allowHashBang=s.ecmaVersion>=14),isArray$3(s.onToken)){var u=s.onToken;s.onToken=function(d){return u.push(d)}}return isArray$3(s.onComment)&&(s.onComment=pushComment(s,s.onComment)),s}function pushComment(a,s){return function(c,u,d,p,v,A){var b={type:c?"Block":"Line",value:u,start:d,end:p};a.locations&&(b.loc=new SourceLocation(this,v,A)),a.ranges&&(b.range=[d,p]),s.push(b)}}var SCOPE_TOP=1,SCOPE_FUNCTION=2,SCOPE_ASYNC=4,SCOPE_GENERATOR=8,SCOPE_ARROW=16,SCOPE_SIMPLE_CATCH=32,SCOPE_SUPER=64,SCOPE_DIRECT_SUPER=128,SCOPE_CLASS_STATIC_BLOCK=256,SCOPE_CLASS_FIELD_INIT=512,SCOPE_VAR=SCOPE_TOP|SCOPE_FUNCTION|SCOPE_CLASS_STATIC_BLOCK;function functionFlags(a,s){return SCOPE_FUNCTION|(a?SCOPE_ASYNC:0)|(s?SCOPE_GENERATOR:0)}var BIND_NONE=0,BIND_VAR=1,BIND_LEXICAL=2,BIND_FUNCTION=3,BIND_SIMPLE_CATCH=4,BIND_OUTSIDE=5,Parser=function(s,c,u){this.options=s=getOptions(s),this.sourceFile=s.sourceFile,this.keywords=wordsRegexp(keywords$1[s.ecmaVersion>=6?6:s.sourceType==="module"?"5module":5]);var d="";s.allowReserved!==!0&&(d=reservedWords[s.ecmaVersion>=6?6:s.ecmaVersion===5?5:3],s.sourceType==="module"&&(d+=" await")),this.reservedWords=wordsRegexp(d);var p=(d?d+" ":"")+reservedWords.strict;this.reservedWordsStrict=wordsRegexp(p),this.reservedWordsStrictBind=wordsRegexp(p+" "+reservedWords.strictBind),this.input=String(c),this.containsEsc=!1,u?(this.pos=u,this.lineStart=this.input.lastIndexOf(`
|
52
52
|
`,u-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(lineBreak).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=types$1.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=s.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&s.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(SCOPE_TOP),this.regexpState=null,this.privateNameStack=[]},prototypeAccessors={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};Parser.prototype.parse=function(){var s=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(s)},prototypeAccessors.inFunction.get=function(){return(this.currentVarScope().flags&SCOPE_FUNCTION)>0},prototypeAccessors.inGenerator.get=function(){return(this.currentVarScope().flags&SCOPE_GENERATOR)>0},prototypeAccessors.inAsync.get=function(){return(this.currentVarScope().flags&SCOPE_ASYNC)>0},prototypeAccessors.canAwait.get=function(){for(var a=this.scopeStack.length-1;a>=0;a--){var s=this.scopeStack[a],c=s.flags;if(c&(SCOPE_CLASS_STATIC_BLOCK|SCOPE_CLASS_FIELD_INIT))return!1;if(c&SCOPE_FUNCTION)return(c&SCOPE_ASYNC)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},prototypeAccessors.allowSuper.get=function(){var a=this.currentThisScope(),s=a.flags;return(s&SCOPE_SUPER)>0||this.options.allowSuperOutsideMethod},prototypeAccessors.allowDirectSuper.get=function(){return(this.currentThisScope().flags&SCOPE_DIRECT_SUPER)>0},prototypeAccessors.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},prototypeAccessors.allowNewDotTarget.get=function(){for(var a=this.scopeStack.length-1;a>=0;a--){var s=this.scopeStack[a],c=s.flags;if(c&(SCOPE_CLASS_STATIC_BLOCK|SCOPE_CLASS_FIELD_INIT)||c&SCOPE_FUNCTION&&!(c&SCOPE_ARROW))return!0}return!1},prototypeAccessors.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&SCOPE_CLASS_STATIC_BLOCK)>0},Parser.extend=function(){for(var s=[],c=arguments.length;c--;)s[c]=arguments[c];for(var u=this,d=0;d<s.length;d++)u=s[d](u);return u},Parser.parse=function(s,c){return new this(c,s).parse()},Parser.parseExpressionAt=function(s,c,u){var d=new this(u,s,c);return d.nextToken(),d.parseExpression()},Parser.tokenizer=function(s,c){return new this(c,s)},Object.defineProperties(Parser.prototype,prototypeAccessors);var pp$9=Parser.prototype,literal=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;pp$9.strictDirective=function(a){if(this.options.ecmaVersion<5)return!1;for(;;){skipWhiteSpace.lastIndex=a,a+=skipWhiteSpace.exec(this.input)[0].length;var s=literal.exec(this.input.slice(a));if(!s)return!1;if((s[1]||s[2])==="use strict"){skipWhiteSpace.lastIndex=a+s[0].length;var c=skipWhiteSpace.exec(this.input),u=c.index+c[0].length,d=this.input.charAt(u);return d===";"||d==="}"||lineBreak.test(c[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(d)||d==="!"&&this.input.charAt(u+1)==="=")}a+=s[0].length,skipWhiteSpace.lastIndex=a,a+=skipWhiteSpace.exec(this.input)[0].length,this.input[a]===";"&&a++}},pp$9.eat=function(a){return this.type===a?(this.next(),!0):!1},pp$9.isContextual=function(a){return this.type===types$1.name&&this.value===a&&!this.containsEsc},pp$9.eatContextual=function(a){return this.isContextual(a)?(this.next(),!0):!1},pp$9.expectContextual=function(a){this.eatContextual(a)||this.unexpected()},pp$9.canInsertSemicolon=function(){return this.type===types$1.eof||this.type===types$1.braceR||lineBreak.test(this.input.slice(this.lastTokEnd,this.start))},pp$9.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},pp$9.semicolon=function(){!this.eat(types$1.semi)&&!this.insertSemicolon()&&this.unexpected()},pp$9.afterTrailingComma=function(a,s){if(this.type===a)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),s||this.next(),!0},pp$9.expect=function(a){this.eat(a)||this.unexpected()},pp$9.unexpected=function(a){this.raise(a??this.start,"Unexpected token")};var DestructuringErrors=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};pp$9.checkPatternErrors=function(a,s){if(a){a.trailingComma>-1&&this.raiseRecoverable(a.trailingComma,"Comma is not permitted after the rest element");var c=s?a.parenthesizedAssign:a.parenthesizedBind;c>-1&&this.raiseRecoverable(c,s?"Assigning to rvalue":"Parenthesized pattern")}},pp$9.checkExpressionErrors=function(a,s){if(!a)return!1;var c=a.shorthandAssign,u=a.doubleProto;if(!s)return c>=0||u>=0;c>=0&&this.raise(c,"Shorthand property assignments are valid only in destructuring patterns"),u>=0&&this.raiseRecoverable(u,"Redefinition of __proto__ property")},pp$9.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")},pp$9.isSimpleAssignTarget=function(a){return a.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(a.expression):a.type==="Identifier"||a.type==="MemberExpression"};var pp$8=Parser.prototype;pp$8.parseTopLevel=function(a){var s=Object.create(null);for(a.body||(a.body=[]);this.type!==types$1.eof;){var c=this.parseStatement(null,!0,s);a.body.push(c)}if(this.inModule)for(var u=0,d=Object.keys(this.undefinedExports);u<d.length;u+=1){var p=d[u];this.raiseRecoverable(this.undefinedExports[p].start,"Export '"+p+"' is not defined")}return this.adaptDirectivePrologue(a.body),this.next(),a.sourceType=this.options.sourceType,this.finishNode(a,"Program")};var loopLabel={kind:"loop"},switchLabel={kind:"switch"};pp$8.isLet=function(a){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;skipWhiteSpace.lastIndex=this.pos;var s=skipWhiteSpace.exec(this.input),c=this.pos+s[0].length,u=this.input.charCodeAt(c);if(u===91||u===92)return!0;if(a)return!1;if(u===123||u>55295&&u<56320)return!0;if(isIdentifierStart(u,!0)){for(var d=c+1;isIdentifierChar(u=this.input.charCodeAt(d),!0);)++d;if(u===92||u>55295&&u<56320)return!0;var p=this.input.slice(c,d);if(!keywordRelationalOperator.test(p))return!0}return!1},pp$8.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;skipWhiteSpace.lastIndex=this.pos;var a=skipWhiteSpace.exec(this.input),s=this.pos+a[0].length,c;return!lineBreak.test(this.input.slice(this.pos,s))&&this.input.slice(s,s+8)==="function"&&(s+8===this.input.length||!(isIdentifierChar(c=this.input.charCodeAt(s+8))||c>55295&&c<56320))},pp$8.parseStatement=function(a,s,c){var u=this.type,d=this.startNode(),p;switch(this.isLet(a)&&(u=types$1._var,p="let"),u){case types$1._break:case types$1._continue:return this.parseBreakContinueStatement(d,u.keyword);case types$1._debugger:return this.parseDebuggerStatement(d);case types$1._do:return this.parseDoStatement(d);case types$1._for:return this.parseForStatement(d);case types$1._function:return a&&(this.strict||a!=="if"&&a!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(d,!1,!a);case types$1._class:return a&&this.unexpected(),this.parseClass(d,!0);case types$1._if:return this.parseIfStatement(d);case types$1._return:return this.parseReturnStatement(d);case types$1._switch:return this.parseSwitchStatement(d);case types$1._throw:return this.parseThrowStatement(d);case types$1._try:return this.parseTryStatement(d);case types$1._const:case types$1._var:return p=p||this.value,a&&p!=="var"&&this.unexpected(),this.parseVarStatement(d,p);case types$1._while:return this.parseWhileStatement(d);case types$1._with:return this.parseWithStatement(d);case types$1.braceL:return this.parseBlock(!0,d);case types$1.semi:return this.parseEmptyStatement(d);case types$1._export:case types$1._import:if(this.options.ecmaVersion>10&&u===types$1._import){skipWhiteSpace.lastIndex=this.pos;var v=skipWhiteSpace.exec(this.input),A=this.pos+v[0].length,b=this.input.charCodeAt(A);if(b===40||b===46)return this.parseExpressionStatement(d,this.parseExpression())}return this.options.allowImportExportEverywhere||(s||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),u===types$1._import?this.parseImport(d):this.parseExport(d,c);default:if(this.isAsyncFunction())return a&&this.unexpected(),this.next(),this.parseFunctionStatement(d,!0,!a);var g=this.value,x=this.parseExpression();return u===types$1.name&&x.type==="Identifier"&&this.eat(types$1.colon)?this.parseLabeledStatement(d,g,x,a):this.parseExpressionStatement(d,x)}},pp$8.parseBreakContinueStatement=function(a,s){var c=s==="break";this.next(),this.eat(types$1.semi)||this.insertSemicolon()?a.label=null:this.type!==types$1.name?this.unexpected():(a.label=this.parseIdent(),this.semicolon());for(var u=0;u<this.labels.length;++u){var d=this.labels[u];if((a.label==null||d.name===a.label.name)&&(d.kind!=null&&(c||d.kind==="loop")||a.label&&c))break}return u===this.labels.length&&this.raise(a.start,"Unsyntactic "+s),this.finishNode(a,c?"BreakStatement":"ContinueStatement")},pp$8.parseDebuggerStatement=function(a){return this.next(),this.semicolon(),this.finishNode(a,"DebuggerStatement")},pp$8.parseDoStatement=function(a){return this.next(),this.labels.push(loopLabel),a.body=this.parseStatement("do"),this.labels.pop(),this.expect(types$1._while),a.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(types$1.semi):this.semicolon(),this.finishNode(a,"DoWhileStatement")},pp$8.parseForStatement=function(a){this.next();var s=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(loopLabel),this.enterScope(0),this.expect(types$1.parenL),this.type===types$1.semi)return s>-1&&this.unexpected(s),this.parseFor(a,null);var c=this.isLet();if(this.type===types$1._var||this.type===types$1._const||c){var u=this.startNode(),d=c?"let":this.value;return this.next(),this.parseVar(u,!0,d),this.finishNode(u,"VariableDeclaration"),(this.type===types$1._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&u.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===types$1._in?s>-1&&this.unexpected(s):a.await=s>-1),this.parseForIn(a,u)):(s>-1&&this.unexpected(s),this.parseFor(a,u))}var p=this.isContextual("let"),v=!1,A=this.containsEsc,b=new DestructuringErrors,g=this.start,x=s>-1?this.parseExprSubscripts(b,"await"):this.parseExpression(!0,b);return this.type===types$1._in||(v=this.options.ecmaVersion>=6&&this.isContextual("of"))?(s>-1?(this.type===types$1._in&&this.unexpected(s),a.await=!0):v&&this.options.ecmaVersion>=8&&(x.start===g&&!A&&x.type==="Identifier"&&x.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(a.await=!1)),p&&v&&this.raise(x.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(x,!1,b),this.checkLValPattern(x),this.parseForIn(a,x)):(this.checkExpressionErrors(b,!0),s>-1&&this.unexpected(s),this.parseFor(a,x))},pp$8.parseFunctionStatement=function(a,s,c){return this.next(),this.parseFunction(a,FUNC_STATEMENT|(c?0:FUNC_HANGING_STATEMENT),!1,s)},pp$8.parseIfStatement=function(a){return this.next(),a.test=this.parseParenExpression(),a.consequent=this.parseStatement("if"),a.alternate=this.eat(types$1._else)?this.parseStatement("if"):null,this.finishNode(a,"IfStatement")},pp$8.parseReturnStatement=function(a){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(types$1.semi)||this.insertSemicolon()?a.argument=null:(a.argument=this.parseExpression(),this.semicolon()),this.finishNode(a,"ReturnStatement")},pp$8.parseSwitchStatement=function(a){this.next(),a.discriminant=this.parseParenExpression(),a.cases=[],this.expect(types$1.braceL),this.labels.push(switchLabel),this.enterScope(0);for(var s,c=!1;this.type!==types$1.braceR;)if(this.type===types$1._case||this.type===types$1._default){var u=this.type===types$1._case;s&&this.finishNode(s,"SwitchCase"),a.cases.push(s=this.startNode()),s.consequent=[],this.next(),u?s.test=this.parseExpression():(c&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),c=!0,s.test=null),this.expect(types$1.colon)}else s||this.unexpected(),s.consequent.push(this.parseStatement(null));return this.exitScope(),s&&this.finishNode(s,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(a,"SwitchStatement")},pp$8.parseThrowStatement=function(a){return this.next(),lineBreak.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),a.argument=this.parseExpression(),this.semicolon(),this.finishNode(a,"ThrowStatement")};var empty$1=[];pp$8.parseCatchClauseParam=function(){var a=this.parseBindingAtom(),s=a.type==="Identifier";return this.enterScope(s?SCOPE_SIMPLE_CATCH:0),this.checkLValPattern(a,s?BIND_SIMPLE_CATCH:BIND_LEXICAL),this.expect(types$1.parenR),a},pp$8.parseTryStatement=function(a){if(this.next(),a.block=this.parseBlock(),a.handler=null,this.type===types$1._catch){var s=this.startNode();this.next(),this.eat(types$1.parenL)?s.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),s.param=null,this.enterScope(0)),s.body=this.parseBlock(!1),this.exitScope(),a.handler=this.finishNode(s,"CatchClause")}return a.finalizer=this.eat(types$1._finally)?this.parseBlock():null,!a.handler&&!a.finalizer&&this.raise(a.start,"Missing catch or finally clause"),this.finishNode(a,"TryStatement")},pp$8.parseVarStatement=function(a,s,c){return this.next(),this.parseVar(a,!1,s,c),this.semicolon(),this.finishNode(a,"VariableDeclaration")},pp$8.parseWhileStatement=function(a){return this.next(),a.test=this.parseParenExpression(),this.labels.push(loopLabel),a.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(a,"WhileStatement")},pp$8.parseWithStatement=function(a){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),a.object=this.parseParenExpression(),a.body=this.parseStatement("with"),this.finishNode(a,"WithStatement")},pp$8.parseEmptyStatement=function(a){return this.next(),this.finishNode(a,"EmptyStatement")},pp$8.parseLabeledStatement=function(a,s,c,u){for(var d=0,p=this.labels;d<p.length;d+=1){var v=p[d];v.name===s&&this.raise(c.start,"Label '"+s+"' is already declared")}for(var A=this.type.isLoop?"loop":this.type===types$1._switch?"switch":null,b=this.labels.length-1;b>=0;b--){var g=this.labels[b];if(g.statementStart===a.start)g.statementStart=this.start,g.kind=A;else break}return this.labels.push({name:s,kind:A,statementStart:this.start}),a.body=this.parseStatement(u?u.indexOf("label")===-1?u+"label":u:"label"),this.labels.pop(),a.label=c,this.finishNode(a,"LabeledStatement")},pp$8.parseExpressionStatement=function(a,s){return a.expression=s,this.semicolon(),this.finishNode(a,"ExpressionStatement")},pp$8.parseBlock=function(a,s,c){for(a===void 0&&(a=!0),s===void 0&&(s=this.startNode()),s.body=[],this.expect(types$1.braceL),a&&this.enterScope(0);this.type!==types$1.braceR;){var u=this.parseStatement(null);s.body.push(u)}return c&&(this.strict=!1),this.next(),a&&this.exitScope(),this.finishNode(s,"BlockStatement")},pp$8.parseFor=function(a,s){return a.init=s,this.expect(types$1.semi),a.test=this.type===types$1.semi?null:this.parseExpression(),this.expect(types$1.semi),a.update=this.type===types$1.parenR?null:this.parseExpression(),this.expect(types$1.parenR),a.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(a,"ForStatement")},pp$8.parseForIn=function(a,s){var c=this.type===types$1._in;return this.next(),s.type==="VariableDeclaration"&&s.declarations[0].init!=null&&(!c||this.options.ecmaVersion<8||this.strict||s.kind!=="var"||s.declarations[0].id.type!=="Identifier")&&this.raise(s.start,(c?"for-in":"for-of")+" loop variable declaration may not have an initializer"),a.left=s,a.right=c?this.parseExpression():this.parseMaybeAssign(),this.expect(types$1.parenR),a.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(a,c?"ForInStatement":"ForOfStatement")},pp$8.parseVar=function(a,s,c,u){for(a.declarations=[],a.kind=c;;){var d=this.startNode();if(this.parseVarId(d,c),this.eat(types$1.eq)?d.init=this.parseMaybeAssign(s):!u&&c==="const"&&!(this.type===types$1._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!u&&d.id.type!=="Identifier"&&!(s&&(this.type===types$1._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):d.init=null,a.declarations.push(this.finishNode(d,"VariableDeclarator")),!this.eat(types$1.comma))break}return a},pp$8.parseVarId=function(a,s){a.id=this.parseBindingAtom(),this.checkLValPattern(a.id,s==="var"?BIND_VAR:BIND_LEXICAL,!1)};var FUNC_STATEMENT=1,FUNC_HANGING_STATEMENT=2,FUNC_NULLABLE_ID=4;pp$8.parseFunction=function(a,s,c,u,d){this.initFunction(a),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!u)&&(this.type===types$1.star&&s&FUNC_HANGING_STATEMENT&&this.unexpected(),a.generator=this.eat(types$1.star)),this.options.ecmaVersion>=8&&(a.async=!!u),s&FUNC_STATEMENT&&(a.id=s&FUNC_NULLABLE_ID&&this.type!==types$1.name?null:this.parseIdent(),a.id&&!(s&FUNC_HANGING_STATEMENT)&&this.checkLValSimple(a.id,this.strict||a.generator||a.async?this.treatFunctionsAsVar?BIND_VAR:BIND_LEXICAL:BIND_FUNCTION));var p=this.yieldPos,v=this.awaitPos,A=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(functionFlags(a.async,a.generator)),s&FUNC_STATEMENT||(a.id=this.type===types$1.name?this.parseIdent():null),this.parseFunctionParams(a),this.parseFunctionBody(a,c,!1,d),this.yieldPos=p,this.awaitPos=v,this.awaitIdentPos=A,this.finishNode(a,s&FUNC_STATEMENT?"FunctionDeclaration":"FunctionExpression")},pp$8.parseFunctionParams=function(a){this.expect(types$1.parenL),a.params=this.parseBindingList(types$1.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},pp$8.parseClass=function(a,s){this.next();var c=this.strict;this.strict=!0,this.parseClassId(a,s),this.parseClassSuper(a);var u=this.enterClassBody(),d=this.startNode(),p=!1;for(d.body=[],this.expect(types$1.braceL);this.type!==types$1.braceR;){var v=this.parseClassElement(a.superClass!==null);v&&(d.body.push(v),v.type==="MethodDefinition"&&v.kind==="constructor"?(p&&this.raiseRecoverable(v.start,"Duplicate constructor in the same class"),p=!0):v.key&&v.key.type==="PrivateIdentifier"&&isPrivateNameConflicted(u,v)&&this.raiseRecoverable(v.key.start,"Identifier '#"+v.key.name+"' has already been declared"))}return this.strict=c,this.next(),a.body=this.finishNode(d,"ClassBody"),this.exitClassBody(),this.finishNode(a,s?"ClassDeclaration":"ClassExpression")},pp$8.parseClassElement=function(a){if(this.eat(types$1.semi))return null;var s=this.options.ecmaVersion,c=this.startNode(),u="",d=!1,p=!1,v="method",A=!1;if(this.eatContextual("static")){if(s>=13&&this.eat(types$1.braceL))return this.parseClassStaticBlock(c),c;this.isClassElementNameStart()||this.type===types$1.star?A=!0:u="static"}if(c.static=A,!u&&s>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===types$1.star)&&!this.canInsertSemicolon()?p=!0:u="async"),!u&&(s>=9||!p)&&this.eat(types$1.star)&&(d=!0),!u&&!p&&!d){var b=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?v=b:u=b)}if(u?(c.computed=!1,c.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),c.key.name=u,this.finishNode(c.key,"Identifier")):this.parseClassElementName(c),s<13||this.type===types$1.parenL||v!=="method"||d||p){var g=!c.static&&checkKeyName(c,"constructor"),x=g&&a;g&&v!=="method"&&this.raise(c.key.start,"Constructor can't have get/set modifier"),c.kind=g?"constructor":v,this.parseClassMethod(c,d,p,x)}else this.parseClassField(c);return c},pp$8.isClassElementNameStart=function(){return this.type===types$1.name||this.type===types$1.privateId||this.type===types$1.num||this.type===types$1.string||this.type===types$1.bracketL||this.type.keyword},pp$8.parseClassElementName=function(a){this.type===types$1.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),a.computed=!1,a.key=this.parsePrivateIdent()):this.parsePropertyName(a)},pp$8.parseClassMethod=function(a,s,c,u){var d=a.key;a.kind==="constructor"?(s&&this.raise(d.start,"Constructor can't be a generator"),c&&this.raise(d.start,"Constructor can't be an async method")):a.static&&checkKeyName(a,"prototype")&&this.raise(d.start,"Classes may not have a static property named prototype");var p=a.value=this.parseMethod(s,c,u);return a.kind==="get"&&p.params.length!==0&&this.raiseRecoverable(p.start,"getter should have no params"),a.kind==="set"&&p.params.length!==1&&this.raiseRecoverable(p.start,"setter should have exactly one param"),a.kind==="set"&&p.params[0].type==="RestElement"&&this.raiseRecoverable(p.params[0].start,"Setter cannot use rest params"),this.finishNode(a,"MethodDefinition")},pp$8.parseClassField=function(a){return checkKeyName(a,"constructor")?this.raise(a.key.start,"Classes can't have a field named 'constructor'"):a.static&&checkKeyName(a,"prototype")&&this.raise(a.key.start,"Classes can't have a static field named 'prototype'"),this.eat(types$1.eq)?(this.enterScope(SCOPE_CLASS_FIELD_INIT|SCOPE_SUPER),a.value=this.parseMaybeAssign(),this.exitScope()):a.value=null,this.semicolon(),this.finishNode(a,"PropertyDefinition")},pp$8.parseClassStaticBlock=function(a){a.body=[];var s=this.labels;for(this.labels=[],this.enterScope(SCOPE_CLASS_STATIC_BLOCK|SCOPE_SUPER);this.type!==types$1.braceR;){var c=this.parseStatement(null);a.body.push(c)}return this.next(),this.exitScope(),this.labels=s,this.finishNode(a,"StaticBlock")},pp$8.parseClassId=function(a,s){this.type===types$1.name?(a.id=this.parseIdent(),s&&this.checkLValSimple(a.id,BIND_LEXICAL,!1)):(s===!0&&this.unexpected(),a.id=null)},pp$8.parseClassSuper=function(a){a.superClass=this.eat(types$1._extends)?this.parseExprSubscripts(null,!1):null},pp$8.enterClassBody=function(){var a={declared:Object.create(null),used:[]};return this.privateNameStack.push(a),a.declared},pp$8.exitClassBody=function(){var a=this.privateNameStack.pop(),s=a.declared,c=a.used;if(this.options.checkPrivateFields)for(var u=this.privateNameStack.length,d=u===0?null:this.privateNameStack[u-1],p=0;p<c.length;++p){var v=c[p];hasOwn(s,v.name)||(d?d.used.push(v):this.raiseRecoverable(v.start,"Private field '#"+v.name+"' must be declared in an enclosing class"))}};function isPrivateNameConflicted(a,s){var c=s.key.name,u=a[c],d="true";return s.type==="MethodDefinition"&&(s.kind==="get"||s.kind==="set")&&(d=(s.static?"s":"i")+s.kind),u==="iget"&&d==="iset"||u==="iset"&&d==="iget"||u==="sget"&&d==="sset"||u==="sset"&&d==="sget"?(a[c]="true",!1):u?!0:(a[c]=d,!1)}function checkKeyName(a,s){var c=a.computed,u=a.key;return!c&&(u.type==="Identifier"&&u.name===s||u.type==="Literal"&&u.value===s)}pp$8.parseExportAllDeclaration=function(a,s){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(a.exported=this.parseModuleExportName(),this.checkExport(s,a.exported,this.lastTokStart)):a.exported=null),this.expectContextual("from"),this.type!==types$1.string&&this.unexpected(),a.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(a.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(a,"ExportAllDeclaration")},pp$8.parseExport=function(a,s){if(this.next(),this.eat(types$1.star))return this.parseExportAllDeclaration(a,s);if(this.eat(types$1._default))return this.checkExport(s,"default",this.lastTokStart),a.declaration=this.parseExportDefaultDeclaration(),this.finishNode(a,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())a.declaration=this.parseExportDeclaration(a),a.declaration.type==="VariableDeclaration"?this.checkVariableExport(s,a.declaration.declarations):this.checkExport(s,a.declaration.id,a.declaration.id.start),a.specifiers=[],a.source=null,this.options.ecmaVersion>=16&&(a.attributes=[]);else{if(a.declaration=null,a.specifiers=this.parseExportSpecifiers(s),this.eatContextual("from"))this.type!==types$1.string&&this.unexpected(),a.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(a.attributes=this.parseWithClause());else{for(var c=0,u=a.specifiers;c<u.length;c+=1){var d=u[c];this.checkUnreserved(d.local),this.checkLocalExport(d.local),d.local.type==="Literal"&&this.raise(d.local.start,"A string literal cannot be used as an exported binding without `from`.")}a.source=null,this.options.ecmaVersion>=16&&(a.attributes=[])}this.semicolon()}return this.finishNode(a,"ExportNamedDeclaration")},pp$8.parseExportDeclaration=function(a){return this.parseStatement(null)},pp$8.parseExportDefaultDeclaration=function(){var a;if(this.type===types$1._function||(a=this.isAsyncFunction())){var s=this.startNode();return this.next(),a&&this.next(),this.parseFunction(s,FUNC_STATEMENT|FUNC_NULLABLE_ID,!1,a)}else if(this.type===types$1._class){var c=this.startNode();return this.parseClass(c,"nullableID")}else{var u=this.parseMaybeAssign();return this.semicolon(),u}},pp$8.checkExport=function(a,s,c){a&&(typeof s!="string"&&(s=s.type==="Identifier"?s.name:s.value),hasOwn(a,s)&&this.raiseRecoverable(c,"Duplicate export '"+s+"'"),a[s]=!0)},pp$8.checkPatternExport=function(a,s){var c=s.type;if(c==="Identifier")this.checkExport(a,s,s.start);else if(c==="ObjectPattern")for(var u=0,d=s.properties;u<d.length;u+=1){var p=d[u];this.checkPatternExport(a,p)}else if(c==="ArrayPattern")for(var v=0,A=s.elements;v<A.length;v+=1){var b=A[v];b&&this.checkPatternExport(a,b)}else c==="Property"?this.checkPatternExport(a,s.value):c==="AssignmentPattern"?this.checkPatternExport(a,s.left):c==="RestElement"&&this.checkPatternExport(a,s.argument)},pp$8.checkVariableExport=function(a,s){if(a)for(var c=0,u=s;c<u.length;c+=1){var d=u[c];this.checkPatternExport(a,d.id)}},pp$8.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()},pp$8.parseExportSpecifier=function(a){var s=this.startNode();return s.local=this.parseModuleExportName(),s.exported=this.eatContextual("as")?this.parseModuleExportName():s.local,this.checkExport(a,s.exported,s.exported.start),this.finishNode(s,"ExportSpecifier")},pp$8.parseExportSpecifiers=function(a){var s=[],c=!0;for(this.expect(types$1.braceL);!this.eat(types$1.braceR);){if(c)c=!1;else if(this.expect(types$1.comma),this.afterTrailingComma(types$1.braceR))break;s.push(this.parseExportSpecifier(a))}return s},pp$8.parseImport=function(a){return this.next(),this.type===types$1.string?(a.specifiers=empty$1,a.source=this.parseExprAtom()):(a.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),a.source=this.type===types$1.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(a.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(a,"ImportDeclaration")},pp$8.parseImportSpecifier=function(){var a=this.startNode();return a.imported=this.parseModuleExportName(),this.eatContextual("as")?a.local=this.parseIdent():(this.checkUnreserved(a.imported),a.local=a.imported),this.checkLValSimple(a.local,BIND_LEXICAL),this.finishNode(a,"ImportSpecifier")},pp$8.parseImportDefaultSpecifier=function(){var a=this.startNode();return a.local=this.parseIdent(),this.checkLValSimple(a.local,BIND_LEXICAL),this.finishNode(a,"ImportDefaultSpecifier")},pp$8.parseImportNamespaceSpecifier=function(){var a=this.startNode();return this.next(),this.expectContextual("as"),a.local=this.parseIdent(),this.checkLValSimple(a.local,BIND_LEXICAL),this.finishNode(a,"ImportNamespaceSpecifier")},pp$8.parseImportSpecifiers=function(){var a=[],s=!0;if(this.type===types$1.name&&(a.push(this.parseImportDefaultSpecifier()),!this.eat(types$1.comma)))return a;if(this.type===types$1.star)return a.push(this.parseImportNamespaceSpecifier()),a;for(this.expect(types$1.braceL);!this.eat(types$1.braceR);){if(s)s=!1;else if(this.expect(types$1.comma),this.afterTrailingComma(types$1.braceR))break;a.push(this.parseImportSpecifier())}return a},pp$8.parseWithClause=function(){var a=[];if(!this.eat(types$1._with))return a;this.expect(types$1.braceL);for(var s={},c=!0;!this.eat(types$1.braceR);){if(c)c=!1;else if(this.expect(types$1.comma),this.afterTrailingComma(types$1.braceR))break;var u=this.parseImportAttribute(),d=u.key.type==="Identifier"?u.key.name:u.key.value;hasOwn(s,d)&&this.raiseRecoverable(u.key.start,"Duplicate attribute key '"+d+"'"),s[d]=!0,a.push(u)}return a},pp$8.parseImportAttribute=function(){var a=this.startNode();return a.key=this.type===types$1.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(types$1.colon),this.type!==types$1.string&&this.unexpected(),a.value=this.parseExprAtom(),this.finishNode(a,"ImportAttribute")},pp$8.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===types$1.string){var a=this.parseLiteral(this.value);return loneSurrogate.test(a.value)&&this.raise(a.start,"An export name cannot include a lone surrogate."),a}return this.parseIdent(!0)},pp$8.adaptDirectivePrologue=function(a){for(var s=0;s<a.length&&this.isDirectiveCandidate(a[s]);++s)a[s].directive=a[s].expression.raw.slice(1,-1)},pp$8.isDirectiveCandidate=function(a){return this.options.ecmaVersion>=5&&a.type==="ExpressionStatement"&&a.expression.type==="Literal"&&typeof a.expression.value=="string"&&(this.input[a.start]==='"'||this.input[a.start]==="'")};var pp$7=Parser.prototype;pp$7.toAssignable=function(a,s,c){if(this.options.ecmaVersion>=6&&a)switch(a.type){case"Identifier":this.inAsync&&a.name==="await"&&this.raise(a.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":a.type="ObjectPattern",c&&this.checkPatternErrors(c,!0);for(var u=0,d=a.properties;u<d.length;u+=1){var p=d[u];this.toAssignable(p,s),p.type==="RestElement"&&(p.argument.type==="ArrayPattern"||p.argument.type==="ObjectPattern")&&this.raise(p.argument.start,"Unexpected token")}break;case"Property":a.kind!=="init"&&this.raise(a.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(a.value,s);break;case"ArrayExpression":a.type="ArrayPattern",c&&this.checkPatternErrors(c,!0),this.toAssignableList(a.elements,s);break;case"SpreadElement":a.type="RestElement",this.toAssignable(a.argument,s),a.argument.type==="AssignmentPattern"&&this.raise(a.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":a.operator!=="="&&this.raise(a.left.end,"Only '=' operator can be used for specifying default value."),a.type="AssignmentPattern",delete a.operator,this.toAssignable(a.left,s);break;case"ParenthesizedExpression":this.toAssignable(a.expression,s,c);break;case"ChainExpression":this.raiseRecoverable(a.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!s)break;default:this.raise(a.start,"Assigning to rvalue")}else c&&this.checkPatternErrors(c,!0);return a},pp$7.toAssignableList=function(a,s){for(var c=a.length,u=0;u<c;u++){var d=a[u];d&&this.toAssignable(d,s)}if(c){var p=a[c-1];this.options.ecmaVersion===6&&s&&p&&p.type==="RestElement"&&p.argument.type!=="Identifier"&&this.unexpected(p.argument.start)}return a},pp$7.parseSpread=function(a){var s=this.startNode();return this.next(),s.argument=this.parseMaybeAssign(!1,a),this.finishNode(s,"SpreadElement")},pp$7.parseRestBinding=function(){var a=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==types$1.name&&this.unexpected(),a.argument=this.parseBindingAtom(),this.finishNode(a,"RestElement")},pp$7.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case types$1.bracketL:var a=this.startNode();return this.next(),a.elements=this.parseBindingList(types$1.bracketR,!0,!0),this.finishNode(a,"ArrayPattern");case types$1.braceL:return this.parseObj(!0)}return this.parseIdent()},pp$7.parseBindingList=function(a,s,c,u){for(var d=[],p=!0;!this.eat(a);)if(p?p=!1:this.expect(types$1.comma),s&&this.type===types$1.comma)d.push(null);else{if(c&&this.afterTrailingComma(a))break;if(this.type===types$1.ellipsis){var v=this.parseRestBinding();this.parseBindingListItem(v),d.push(v),this.type===types$1.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(a);break}else d.push(this.parseAssignableListItem(u))}return d},pp$7.parseAssignableListItem=function(a){var s=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(s),s},pp$7.parseBindingListItem=function(a){return a},pp$7.parseMaybeDefault=function(a,s,c){if(c=c||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(types$1.eq))return c;var u=this.startNodeAt(a,s);return u.left=c,u.right=this.parseMaybeAssign(),this.finishNode(u,"AssignmentPattern")},pp$7.checkLValSimple=function(a,s,c){s===void 0&&(s=BIND_NONE);var u=s!==BIND_NONE;switch(a.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(a.name)&&this.raiseRecoverable(a.start,(u?"Binding ":"Assigning to ")+a.name+" in strict mode"),u&&(s===BIND_LEXICAL&&a.name==="let"&&this.raiseRecoverable(a.start,"let is disallowed as a lexically bound name"),c&&(hasOwn(c,a.name)&&this.raiseRecoverable(a.start,"Argument name clash"),c[a.name]=!0),s!==BIND_OUTSIDE&&this.declareName(a.name,s,a.start));break;case"ChainExpression":this.raiseRecoverable(a.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":u&&this.raiseRecoverable(a.start,"Binding member expression");break;case"ParenthesizedExpression":return u&&this.raiseRecoverable(a.start,"Binding parenthesized expression"),this.checkLValSimple(a.expression,s,c);default:this.raise(a.start,(u?"Binding":"Assigning to")+" rvalue")}},pp$7.checkLValPattern=function(a,s,c){switch(s===void 0&&(s=BIND_NONE),a.type){case"ObjectPattern":for(var u=0,d=a.properties;u<d.length;u+=1){var p=d[u];this.checkLValInnerPattern(p,s,c)}break;case"ArrayPattern":for(var v=0,A=a.elements;v<A.length;v+=1){var b=A[v];b&&this.checkLValInnerPattern(b,s,c)}break;default:this.checkLValSimple(a,s,c)}},pp$7.checkLValInnerPattern=function(a,s,c){switch(s===void 0&&(s=BIND_NONE),a.type){case"Property":this.checkLValInnerPattern(a.value,s,c);break;case"AssignmentPattern":this.checkLValPattern(a.left,s,c);break;case"RestElement":this.checkLValPattern(a.argument,s,c);break;default:this.checkLValPattern(a,s,c)}};var TokContext=function(s,c,u,d,p){this.token=s,this.isExpr=!!c,this.preserveSpace=!!u,this.override=d,this.generator=!!p},types$2={b_stat:new TokContext("{",!1),b_expr:new TokContext("{",!0),b_tmpl:new TokContext("${",!1),p_stat:new TokContext("(",!1),p_expr:new TokContext("(",!0),q_tmpl:new TokContext("`",!0,!0,function(a){return a.tryReadTemplateToken()}),f_stat:new TokContext("function",!1),f_expr:new TokContext("function",!0),f_expr_gen:new TokContext("function",!0,!1,null,!0),f_gen:new TokContext("function",!1,!1,null,!0)},pp$6=Parser.prototype;pp$6.initialContext=function(){return[types$2.b_stat]},pp$6.curContext=function(){return this.context[this.context.length-1]},pp$6.braceIsBlock=function(a){var s=this.curContext();return s===types$2.f_expr||s===types$2.f_stat?!0:a===types$1.colon&&(s===types$2.b_stat||s===types$2.b_expr)?!s.isExpr:a===types$1._return||a===types$1.name&&this.exprAllowed?lineBreak.test(this.input.slice(this.lastTokEnd,this.start)):a===types$1._else||a===types$1.semi||a===types$1.eof||a===types$1.parenR||a===types$1.arrow?!0:a===types$1.braceL?s===types$2.b_stat:a===types$1._var||a===types$1._const||a===types$1.name?!1:!this.exprAllowed},pp$6.inGeneratorContext=function(){for(var a=this.context.length-1;a>=1;a--){var s=this.context[a];if(s.token==="function")return s.generator}return!1},pp$6.updateContext=function(a){var s,c=this.type;c.keyword&&a===types$1.dot?this.exprAllowed=!1:(s=c.updateContext)?s.call(this,a):this.exprAllowed=c.beforeExpr},pp$6.overrideContext=function(a){this.curContext()!==a&&(this.context[this.context.length-1]=a)},types$1.parenR.updateContext=types$1.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var a=this.context.pop();a===types$2.b_stat&&this.curContext().token==="function"&&(a=this.context.pop()),this.exprAllowed=!a.isExpr},types$1.braceL.updateContext=function(a){this.context.push(this.braceIsBlock(a)?types$2.b_stat:types$2.b_expr),this.exprAllowed=!0},types$1.dollarBraceL.updateContext=function(){this.context.push(types$2.b_tmpl),this.exprAllowed=!0},types$1.parenL.updateContext=function(a){var s=a===types$1._if||a===types$1._for||a===types$1._with||a===types$1._while;this.context.push(s?types$2.p_stat:types$2.p_expr),this.exprAllowed=!0},types$1.incDec.updateContext=function(){},types$1._function.updateContext=types$1._class.updateContext=function(a){a.beforeExpr&&a!==types$1._else&&!(a===types$1.semi&&this.curContext()!==types$2.p_stat)&&!(a===types$1._return&&lineBreak.test(this.input.slice(this.lastTokEnd,this.start)))&&!((a===types$1.colon||a===types$1.braceL)&&this.curContext()===types$2.b_stat)?this.context.push(types$2.f_expr):this.context.push(types$2.f_stat),this.exprAllowed=!1},types$1.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0},types$1.backQuote.updateContext=function(){this.curContext()===types$2.q_tmpl?this.context.pop():this.context.push(types$2.q_tmpl),this.exprAllowed=!1},types$1.star.updateContext=function(a){if(a===types$1._function){var s=this.context.length-1;this.context[s]===types$2.f_expr?this.context[s]=types$2.f_expr_gen:this.context[s]=types$2.f_gen}this.exprAllowed=!0},types$1.name.updateContext=function(a){var s=!1;this.options.ecmaVersion>=6&&a!==types$1.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(s=!0),this.exprAllowed=s};var pp$5=Parser.prototype;pp$5.checkPropClash=function(a,s,c){if(!(this.options.ecmaVersion>=9&&a.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(a.computed||a.method||a.shorthand))){var u=a.key,d;switch(u.type){case"Identifier":d=u.name;break;case"Literal":d=String(u.value);break;default:return}var p=a.kind;if(this.options.ecmaVersion>=6){d==="__proto__"&&p==="init"&&(s.proto&&(c?c.doubleProto<0&&(c.doubleProto=u.start):this.raiseRecoverable(u.start,"Redefinition of __proto__ property")),s.proto=!0);return}d="$"+d;var v=s[d];if(v){var A;p==="init"?A=this.strict&&v.init||v.get||v.set:A=v.init||v[p],A&&this.raiseRecoverable(u.start,"Redefinition of property")}else v=s[d]={init:!1,get:!1,set:!1};v[p]=!0}},pp$5.parseExpression=function(a,s){var c=this.start,u=this.startLoc,d=this.parseMaybeAssign(a,s);if(this.type===types$1.comma){var p=this.startNodeAt(c,u);for(p.expressions=[d];this.eat(types$1.comma);)p.expressions.push(this.parseMaybeAssign(a,s));return this.finishNode(p,"SequenceExpression")}return d},pp$5.parseMaybeAssign=function(a,s,c){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(a);this.exprAllowed=!1}var u=!1,d=-1,p=-1,v=-1;s?(d=s.parenthesizedAssign,p=s.trailingComma,v=s.doubleProto,s.parenthesizedAssign=s.trailingComma=-1):(s=new DestructuringErrors,u=!0);var A=this.start,b=this.startLoc;(this.type===types$1.parenL||this.type===types$1.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=a==="await");var g=this.parseMaybeConditional(a,s);if(c&&(g=c.call(this,g,A,b)),this.type.isAssign){var x=this.startNodeAt(A,b);return x.operator=this.value,this.type===types$1.eq&&(g=this.toAssignable(g,!1,s)),u||(s.parenthesizedAssign=s.trailingComma=s.doubleProto=-1),s.shorthandAssign>=g.start&&(s.shorthandAssign=-1),this.type===types$1.eq?this.checkLValPattern(g):this.checkLValSimple(g),x.left=g,this.next(),x.right=this.parseMaybeAssign(a),v>-1&&(s.doubleProto=v),this.finishNode(x,"AssignmentExpression")}else u&&this.checkExpressionErrors(s,!0);return d>-1&&(s.parenthesizedAssign=d),p>-1&&(s.trailingComma=p),g},pp$5.parseMaybeConditional=function(a,s){var c=this.start,u=this.startLoc,d=this.parseExprOps(a,s);if(this.checkExpressionErrors(s))return d;if(this.eat(types$1.question)){var p=this.startNodeAt(c,u);return p.test=d,p.consequent=this.parseMaybeAssign(),this.expect(types$1.colon),p.alternate=this.parseMaybeAssign(a),this.finishNode(p,"ConditionalExpression")}return d},pp$5.parseExprOps=function(a,s){var c=this.start,u=this.startLoc,d=this.parseMaybeUnary(s,!1,!1,a);return this.checkExpressionErrors(s)||d.start===c&&d.type==="ArrowFunctionExpression"?d:this.parseExprOp(d,c,u,-1,a)},pp$5.parseExprOp=function(a,s,c,u,d){var p=this.type.binop;if(p!=null&&(!d||this.type!==types$1._in)&&p>u){var v=this.type===types$1.logicalOR||this.type===types$1.logicalAND,A=this.type===types$1.coalesce;A&&(p=types$1.logicalAND.binop);var b=this.value;this.next();var g=this.start,x=this.startLoc,y=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,d),g,x,p,d),f=this.buildBinary(s,c,a,y,b,v||A);return(v&&this.type===types$1.coalesce||A&&(this.type===types$1.logicalOR||this.type===types$1.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(f,s,c,u,d)}return a},pp$5.buildBinary=function(a,s,c,u,d,p){u.type==="PrivateIdentifier"&&this.raise(u.start,"Private identifier can only be left side of binary expression");var v=this.startNodeAt(a,s);return v.left=c,v.operator=d,v.right=u,this.finishNode(v,p?"LogicalExpression":"BinaryExpression")},pp$5.parseMaybeUnary=function(a,s,c,u){var d=this.start,p=this.startLoc,v;if(this.isContextual("await")&&this.canAwait)v=this.parseAwait(u),s=!0;else if(this.type.prefix){var A=this.startNode(),b=this.type===types$1.incDec;A.operator=this.value,A.prefix=!0,this.next(),A.argument=this.parseMaybeUnary(null,!0,b,u),this.checkExpressionErrors(a,!0),b?this.checkLValSimple(A.argument):this.strict&&A.operator==="delete"&&isLocalVariableAccess(A.argument)?this.raiseRecoverable(A.start,"Deleting local variable in strict mode"):A.operator==="delete"&&isPrivateFieldAccess(A.argument)?this.raiseRecoverable(A.start,"Private fields can not be deleted"):s=!0,v=this.finishNode(A,b?"UpdateExpression":"UnaryExpression")}else if(!s&&this.type===types$1.privateId)(u||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),v=this.parsePrivateIdent(),this.type!==types$1._in&&this.unexpected();else{if(v=this.parseExprSubscripts(a,u),this.checkExpressionErrors(a))return v;for(;this.type.postfix&&!this.canInsertSemicolon();){var g=this.startNodeAt(d,p);g.operator=this.value,g.prefix=!1,g.argument=v,this.checkLValSimple(v),this.next(),v=this.finishNode(g,"UpdateExpression")}}if(!c&&this.eat(types$1.starstar))if(s)this.unexpected(this.lastTokStart);else return this.buildBinary(d,p,v,this.parseMaybeUnary(null,!1,!1,u),"**",!1);else return v};function isLocalVariableAccess(a){return a.type==="Identifier"||a.type==="ParenthesizedExpression"&&isLocalVariableAccess(a.expression)}function isPrivateFieldAccess(a){return a.type==="MemberExpression"&&a.property.type==="PrivateIdentifier"||a.type==="ChainExpression"&&isPrivateFieldAccess(a.expression)||a.type==="ParenthesizedExpression"&&isPrivateFieldAccess(a.expression)}pp$5.parseExprSubscripts=function(a,s){var c=this.start,u=this.startLoc,d=this.parseExprAtom(a,s);if(d.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return d;var p=this.parseSubscripts(d,c,u,!1,s);return a&&p.type==="MemberExpression"&&(a.parenthesizedAssign>=p.start&&(a.parenthesizedAssign=-1),a.parenthesizedBind>=p.start&&(a.parenthesizedBind=-1),a.trailingComma>=p.start&&(a.trailingComma=-1)),p},pp$5.parseSubscripts=function(a,s,c,u,d){for(var p=this.options.ecmaVersion>=8&&a.type==="Identifier"&&a.name==="async"&&this.lastTokEnd===a.end&&!this.canInsertSemicolon()&&a.end-a.start===5&&this.potentialArrowAt===a.start,v=!1;;){var A=this.parseSubscript(a,s,c,u,p,v,d);if(A.optional&&(v=!0),A===a||A.type==="ArrowFunctionExpression"){if(v){var b=this.startNodeAt(s,c);b.expression=A,A=this.finishNode(b,"ChainExpression")}return A}a=A}},pp$5.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(types$1.arrow)},pp$5.parseSubscriptAsyncArrow=function(a,s,c,u){return this.parseArrowExpression(this.startNodeAt(a,s),c,!0,u)},pp$5.parseSubscript=function(a,s,c,u,d,p,v){var A=this.options.ecmaVersion>=11,b=A&&this.eat(types$1.questionDot);u&&b&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var g=this.eat(types$1.bracketL);if(g||b&&this.type!==types$1.parenL&&this.type!==types$1.backQuote||this.eat(types$1.dot)){var x=this.startNodeAt(s,c);x.object=a,g?(x.property=this.parseExpression(),this.expect(types$1.bracketR)):this.type===types$1.privateId&&a.type!=="Super"?x.property=this.parsePrivateIdent():x.property=this.parseIdent(this.options.allowReserved!=="never"),x.computed=!!g,A&&(x.optional=b),a=this.finishNode(x,"MemberExpression")}else if(!u&&this.eat(types$1.parenL)){var y=new DestructuringErrors,f=this.yieldPos,m=this.awaitPos,C=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var S=this.parseExprList(types$1.parenR,this.options.ecmaVersion>=8,!1,y);if(d&&!b&&this.shouldParseAsyncArrow())return this.checkPatternErrors(y,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=f,this.awaitPos=m,this.awaitIdentPos=C,this.parseSubscriptAsyncArrow(s,c,S,v);this.checkExpressionErrors(y,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,this.awaitIdentPos=C||this.awaitIdentPos;var w=this.startNodeAt(s,c);w.callee=a,w.arguments=S,A&&(w.optional=b),a=this.finishNode(w,"CallExpression")}else if(this.type===types$1.backQuote){(b||p)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var _=this.startNodeAt(s,c);_.tag=a,_.quasi=this.parseTemplate({isTagged:!0}),a=this.finishNode(_,"TaggedTemplateExpression")}return a},pp$5.parseExprAtom=function(a,s,c){this.type===types$1.slash&&this.readRegexp();var u,d=this.potentialArrowAt===this.start;switch(this.type){case types$1._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),u=this.startNode(),this.next(),this.type===types$1.parenL&&!this.allowDirectSuper&&this.raise(u.start,"super() call outside constructor of a subclass"),this.type!==types$1.dot&&this.type!==types$1.bracketL&&this.type!==types$1.parenL&&this.unexpected(),this.finishNode(u,"Super");case types$1._this:return u=this.startNode(),this.next(),this.finishNode(u,"ThisExpression");case types$1.name:var p=this.start,v=this.startLoc,A=this.containsEsc,b=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!A&&b.name==="async"&&!this.canInsertSemicolon()&&this.eat(types$1._function))return this.overrideContext(types$2.f_expr),this.parseFunction(this.startNodeAt(p,v),0,!1,!0,s);if(d&&!this.canInsertSemicolon()){if(this.eat(types$1.arrow))return this.parseArrowExpression(this.startNodeAt(p,v),[b],!1,s);if(this.options.ecmaVersion>=8&&b.name==="async"&&this.type===types$1.name&&!A&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return b=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(types$1.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(p,v),[b],!0,s)}return b;case types$1.regexp:var g=this.value;return u=this.parseLiteral(g.value),u.regex={pattern:g.pattern,flags:g.flags},u;case types$1.num:case types$1.string:return this.parseLiteral(this.value);case types$1._null:case types$1._true:case types$1._false:return u=this.startNode(),u.value=this.type===types$1._null?null:this.type===types$1._true,u.raw=this.type.keyword,this.next(),this.finishNode(u,"Literal");case types$1.parenL:var x=this.start,y=this.parseParenAndDistinguishExpression(d,s);return a&&(a.parenthesizedAssign<0&&!this.isSimpleAssignTarget(y)&&(a.parenthesizedAssign=x),a.parenthesizedBind<0&&(a.parenthesizedBind=x)),y;case types$1.bracketL:return u=this.startNode(),this.next(),u.elements=this.parseExprList(types$1.bracketR,!0,!0,a),this.finishNode(u,"ArrayExpression");case types$1.braceL:return this.overrideContext(types$2.b_expr),this.parseObj(!1,a);case types$1._function:return u=this.startNode(),this.next(),this.parseFunction(u,0);case types$1._class:return this.parseClass(this.startNode(),!1);case types$1._new:return this.parseNew();case types$1.backQuote:return this.parseTemplate();case types$1._import:return this.options.ecmaVersion>=11?this.parseExprImport(c):this.unexpected();default:return this.parseExprAtomDefault()}},pp$5.parseExprAtomDefault=function(){this.unexpected()},pp$5.parseExprImport=function(a){var s=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===types$1.parenL&&!a)return this.parseDynamicImport(s);if(this.type===types$1.dot){var c=this.startNodeAt(s.start,s.loc&&s.loc.start);return c.name="import",s.meta=this.finishNode(c,"Identifier"),this.parseImportMeta(s)}else this.unexpected()},pp$5.parseDynamicImport=function(a){if(this.next(),a.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(types$1.parenR)?a.options=null:(this.expect(types$1.comma),this.afterTrailingComma(types$1.parenR)?a.options=null:(a.options=this.parseMaybeAssign(),this.eat(types$1.parenR)||(this.expect(types$1.comma),this.afterTrailingComma(types$1.parenR)||this.unexpected())));else if(!this.eat(types$1.parenR)){var s=this.start;this.eat(types$1.comma)&&this.eat(types$1.parenR)?this.raiseRecoverable(s,"Trailing comma is not allowed in import()"):this.unexpected(s)}return this.finishNode(a,"ImportExpression")},pp$5.parseImportMeta=function(a){this.next();var s=this.containsEsc;return a.property=this.parseIdent(!0),a.property.name!=="meta"&&this.raiseRecoverable(a.property.start,"The only valid meta property for import is 'import.meta'"),s&&this.raiseRecoverable(a.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(a.start,"Cannot use 'import.meta' outside a module"),this.finishNode(a,"MetaProperty")},pp$5.parseLiteral=function(a){var s=this.startNode();return s.value=a,s.raw=this.input.slice(this.start,this.end),s.raw.charCodeAt(s.raw.length-1)===110&&(s.bigint=s.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(s,"Literal")},pp$5.parseParenExpression=function(){this.expect(types$1.parenL);var a=this.parseExpression();return this.expect(types$1.parenR),a},pp$5.shouldParseArrow=function(a){return!this.canInsertSemicolon()},pp$5.parseParenAndDistinguishExpression=function(a,s){var c=this.start,u=this.startLoc,d,p=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var v=this.start,A=this.startLoc,b=[],g=!0,x=!1,y=new DestructuringErrors,f=this.yieldPos,m=this.awaitPos,C;for(this.yieldPos=0,this.awaitPos=0;this.type!==types$1.parenR;)if(g?g=!1:this.expect(types$1.comma),p&&this.afterTrailingComma(types$1.parenR,!0)){x=!0;break}else if(this.type===types$1.ellipsis){C=this.start,b.push(this.parseParenItem(this.parseRestBinding())),this.type===types$1.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else b.push(this.parseMaybeAssign(!1,y,this.parseParenItem));var S=this.lastTokEnd,w=this.lastTokEndLoc;if(this.expect(types$1.parenR),a&&this.shouldParseArrow(b)&&this.eat(types$1.arrow))return this.checkPatternErrors(y,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=f,this.awaitPos=m,this.parseParenArrowList(c,u,b,s);(!b.length||x)&&this.unexpected(this.lastTokStart),C&&this.unexpected(C),this.checkExpressionErrors(y,!0),this.yieldPos=f||this.yieldPos,this.awaitPos=m||this.awaitPos,b.length>1?(d=this.startNodeAt(v,A),d.expressions=b,this.finishNodeAt(d,"SequenceExpression",S,w)):d=b[0]}else d=this.parseParenExpression();if(this.options.preserveParens){var _=this.startNodeAt(c,u);return _.expression=d,this.finishNode(_,"ParenthesizedExpression")}else return d},pp$5.parseParenItem=function(a){return a},pp$5.parseParenArrowList=function(a,s,c,u){return this.parseArrowExpression(this.startNodeAt(a,s),c,!1,u)};var empty$2=[];pp$5.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var a=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===types$1.dot){var s=this.startNodeAt(a.start,a.loc&&a.loc.start);s.name="new",a.meta=this.finishNode(s,"Identifier"),this.next();var c=this.containsEsc;return a.property=this.parseIdent(!0),a.property.name!=="target"&&this.raiseRecoverable(a.property.start,"The only valid meta property for new is 'new.target'"),c&&this.raiseRecoverable(a.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(a.start,"'new.target' can only be used in functions and class static block"),this.finishNode(a,"MetaProperty")}var u=this.start,d=this.startLoc;return a.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),u,d,!0,!1),this.eat(types$1.parenL)?a.arguments=this.parseExprList(types$1.parenR,this.options.ecmaVersion>=8,!1):a.arguments=empty$2,this.finishNode(a,"NewExpression")},pp$5.parseTemplateElement=function(a){var s=a.isTagged,c=this.startNode();return this.type===types$1.invalidTemplate?(s||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),c.value={raw:this.value.replace(/\r\n?/g,`
|
53
53
|
`),cooked:null}):c.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
@@ -55,7 +55,7 @@ Defaulting to 2020, but this will stop working in the future.`)),s.ecmaVersion=1
|
|
55
55
|
`;break;default:a+=String.fromCharCode(c);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),s=this.pos}else++this.pos}},pp.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(types$1.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
56
56
|
`&&++this.pos;case`
|
57
57
|
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},pp.readEscapedChar=function(a){var s=this.input.charCodeAt(++this.pos);switch(++this.pos,s){case 110:return`
|
58
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),a){var c=this.pos-1;this.invalidStringToken(c,"Invalid escape sequence in template string")}default:if(s>=48&&s<=55){var u=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],d=parseInt(u,8);return d>255&&(u=u.slice(0,-1),d=parseInt(u,8)),this.pos+=u.length-1,s=this.input.charCodeAt(this.pos),(u!=="0"||s===56||s===57)&&(this.strict||a)&&this.invalidStringToken(this.pos-1-u.length,a?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(d)}return isNewLine(s)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(s)}},pp.readHexChar=function(a){var s=this.pos,c=this.readInt(16,a);return c===null&&this.invalidStringToken(s,"Bad character escape sequence"),c},pp.readWord1=function(){this.containsEsc=!1;for(var a="",s=!0,c=this.pos,u=this.options.ecmaVersion>=6;this.pos<this.input.length;){var d=this.fullCharCodeAtPos();if(isIdentifierChar(d,u))this.pos+=d<=65535?1:2;else if(d===92){this.containsEsc=!0,a+=this.input.slice(c,this.pos);var p=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var v=this.readCodePoint();(s?isIdentifierStart:isIdentifierChar)(v,u)||this.invalidStringToken(p,"Invalid Unicode escape"),a+=codePointToString(v),c=this.pos}else break;s=!1}return a+this.input.slice(c,this.pos)},pp.readWord=function(){var a=this.readWord1(),s=types$1.name;return this.keywords.test(a)&&(s=keywords[a]),this.finishToken(s,a)};var version$2="8.14.1";Parser.acorn={Parser,version:version$2,defaultOptions:defaultOptions$1,Position,SourceLocation,getLineInfo,Node,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types$2,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};function parseExpressionAt(a,s,c){return Parser.parseExpressionAt(a,s,c)}const expressionCache=new Map,parseDataCache=new Map,parseData=a=>{const s=JSON.stringify(a);if(parseDataCache.has(s))return parseDataCache.get(s);const c=Object.fromEntries(Object.entries(a).map(([u,d])=>{if(typeof d=="string")try{const p=JSON.parse(d);return[u,p]}catch{return[u,d]}return[u,d]}));return parseDataCache.set(s,c),c},padZero=a=>String(a).padStart(2,"0"),formatDate=a=>`${a.getFullYear()}/${padZero(a.getMonth()+1)}/${padZero(a.getDate())}`,formatDateTime=a=>`${formatDate(a)} ${padZero(a.getHours())}:${padZero(a.getMinutes())}`,allowedGlobals={Math,String,Number,Boolean,Array,Object,Date,JSON,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent},validateAST=a=>{switch(a.type){case"Literal":case"Identifier":break;case"BinaryExpression":case"LogicalExpression":{const s=a;validateAST(s.left),validateAST(s.right);break}case"UnaryExpression":{validateAST(a.argument);break}case"ConditionalExpression":{const s=a;validateAST(s.test),validateAST(s.consequent),validateAST(s.alternate);break}case"MemberExpression":{const s=a;if(validateAST(s.object),s.computed)validateAST(s.property);else{const c=s.property.name;if(["constructor","__proto__","prototype"].includes(c))throw new Error("Access to prohibited property");if(typeof c=="string"&&["toLocaleString","valueOf"].includes(c))throw new Error(`Access to prohibited method: ${c}`)}break}case"CallExpression":{const s=a;validateAST(s.callee),s.arguments.forEach(validateAST);break}case"ArrayExpression":{a.elements.forEach(c=>{c&&validateAST(c)});break}case"ObjectExpression":{a.properties.forEach(c=>{const u=c;validateAST(u.key),validateAST(u.value)});break}case"ArrowFunctionExpression":{const s=a;s.params.forEach(c=>{if(c.type!=="Identifier")throw new Error("Only identifier parameters are supported in arrow functions");validateAST(c)}),validateAST(s.body);break}default:throw new Error(`Unsupported syntax in placeholder: ${a.type}`)}},evaluateAST=(a,s)=>{switch(a.type){case"Literal":return a.value;case"Identifier":{const c=a;if(Object.prototype.hasOwnProperty.call(s,c.name))return s[c.name];if(Object.prototype.hasOwnProperty.call(allowedGlobals,c.name))return allowedGlobals[c.name];throw new Error(`Undefined variable: ${c.name}`)}case"BinaryExpression":{const c=a,u=evaluateAST(c.left,s),d=evaluateAST(c.right,s);switch(c.operator){case"+":return u+d;case"-":return u-d;case"*":return u*d;case"/":return u/d;case"%":return u%d;case"**":return u**d;case"==":return u==d;case"!=":return u!=d;case"===":return u===d;case"!==":return u!==d;case"<":return u<d;case">":return u>d;case"<=":return u<=d;case">=":return u>=d;default:throw new Error(`Unsupported operator: ${c.operator}`)}}case"LogicalExpression":{const c=a,u=evaluateAST(c.left,s),d=evaluateAST(c.right,s);switch(c.operator){case"&&":return u&&d;case"||":return u||d;default:throw new Error(`Unsupported operator: ${c.operator}`)}}case"UnaryExpression":{const c=a,u=evaluateAST(c.argument,s);switch(c.operator){case"+":return+u;case"-":return-u;case"!":return!u;default:throw new Error(`Unsupported operator: ${c.operator}`)}}case"ConditionalExpression":{const c=a,u=evaluateAST(c.test,s);return evaluateAST(u?c.consequent:c.alternate,s)}case"MemberExpression":{const c=a,u=evaluateAST(c.object,s);let d;if(c.computed?d=evaluateAST(c.property,s):d=c.property.name,typeof d=="string"||typeof d=="number"){if(typeof d=="string"&&["constructor","__proto__","prototype"].includes(d))throw new Error("Access to prohibited property");return u[d]}else throw new Error("Invalid property access")}case"CallExpression":{const c=a,u=evaluateAST(c.callee,s),d=c.arguments.map(p=>evaluateAST(p,s));if(typeof u=="function")if(c.callee.type==="MemberExpression"){const p=c.callee,v=evaluateAST(p.object,s);if(v!==null&&(typeof v=="object"||typeof v=="number"||typeof v=="string"||typeof v=="boolean"))return u.call(v,...d);throw new Error("Invalid object in member function call")}else return u(...d);else throw new Error("Attempted to call a non-function")}case"ArrowFunctionExpression":{const c=a,u=c.params.map(p=>p.name),d=c.body;return(...p)=>{const v={...s};return u.forEach((A,b)=>{v[A]=p[b]}),evaluateAST(d,v)}}case"ArrayExpression":return a.elements.map(u=>u?evaluateAST(u,s):null);case"ObjectExpression":{const c=a,u={};return c.properties.forEach(d=>{const p=d;let v;if(p.key.type==="Identifier")v=p.key.name;else{const b=evaluateAST(p.key,s);if(typeof b!="string"&&typeof b!="number")throw new Error("Object property keys must be strings or numbers");v=String(b)}const A=evaluateAST(p.value,s);u[v]=A}),u}default:throw new Error(`Unsupported syntax in placeholder: ${a.type}`)}},evaluatePlaceholders=a=>{const{content:s,context:c}=a;let u="",d=0;for(;d<s.length;){const p=s.indexOf("{",d);if(p===-1){u+=s.slice(d);break}u+=s.slice(d,p);let v=1,A=p+1;for(;A<s.length&&v>0;)s[A]==="{"?v++:s[A]==="}"&&v--,A++;if(v===0){const b=s.slice(p+1,A-1).trim();if(expressionCache.has(b)){const g=expressionCache.get(b);try{const x=g(c);u+=String(x)}catch{u+=s.slice(p,A)}}else try{const g=parseExpressionAt(b,0,{ecmaVersion:"latest"});validateAST(g);const x=f=>evaluateAST(g,f);expressionCache.set(b,x);const y=x(c);u+=String(y)}catch{u+=s.slice(p,A)}d=A}else throw new Error("Invalid placeholder")}return u},replacePlaceholders=a=>{const{content:s,variables:c,schemas:u}=a;if(!s||typeof s!="string"||!s.includes("{")||!s.includes("}"))return s;const d=new Date,p=formatDate(d),v=formatDateTime(d),A={...Object.fromEntries(u.flat().map(x=>[x.name,x.readOnly&&x.content||""])),...c},b=parseData(A),g={date:p,dateTime:v,...b};return Object.entries(g).forEach(([x,y])=>{typeof y=="string"&&y.includes("{")&&y.includes("}")&&(g[x]=evaluatePlaceholders({content:y,context:g}))}),evaluatePlaceholders({content:s,context:g})},DEFAULT_LANG="en",DESTROYED_ERR_MSG="[@pdfme/ui] this instance is already destroyed",SELECTABLE_CLASSNAME="selectable",RULER_HEIGHT=30,PAGE_GAP=10,LEFT_SIDEBAR_WIDTH=45,RIGHT_SIDEBAR_WIDTH=400,BACKGROUND_COLOR="rgb(74, 74, 74)",DEFAULT_MAX_ZOOM=2,isff=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function addEvent$1(a,s,c,u){a.addEventListener?a.addEventListener(s,c,u):a.attachEvent&&a.attachEvent("on".concat(s),c)}function removeEvent$1(a,s,c,u){a.removeEventListener?a.removeEventListener(s,c,u):a.detachEvent&&a.detachEvent("on".concat(s),c)}function getMods(a,s){const c=s.slice(0,s.length-1);for(let u=0;u<c.length;u++)c[u]=a[c[u].toLowerCase()];return c}function getKeys$1(a){typeof a!="string"&&(a=""),a=a.replace(/\s/g,"");const s=a.split(",");let c=s.lastIndexOf("");for(;c>=0;)s[c-1]+=",",s.splice(c,1),c=s.lastIndexOf("");return s}function compareArray(a,s){const c=a.length>=s.length?a:s,u=a.length>=s.length?s:a;let d=!0;for(let p=0;p<c.length;p++)u.indexOf(c[p])===-1&&(d=!1);return d}const _keyMap={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":isff?173:189,"=":isff?61:187,";":isff?59:186,"'":222,"[":219,"]":221,"\\":220},_modifier={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},modifierMap={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},_mods={16:!1,18:!1,17:!1,91:!1},_handlers={};for(let a=1;a<20;a++)_keyMap["f".concat(a)]=111+a;let _downKeys=[],winListendFocus=null,_scope="all";const elementEventMap=new Map,code=a=>_keyMap[a.toLowerCase()]||_modifier[a.toLowerCase()]||a.toUpperCase().charCodeAt(0),getKey$3=a=>Object.keys(_keyMap).find(s=>_keyMap[s]===a),getModifier=a=>Object.keys(_modifier).find(s=>_modifier[s]===a);function setScope(a){_scope=a||"all"}function getScope(){return _scope||"all"}function getPressedKeyCodes(){return _downKeys.slice(0)}function getPressedKeyString(){return _downKeys.map(a=>getKey$3(a)||getModifier(a)||String.fromCharCode(a))}function getAllKeyCodes(){const a=[];return Object.keys(_handlers).forEach(s=>{_handlers[s].forEach(c=>{let{key:u,scope:d,mods:p,shortcut:v}=c;a.push({scope:d,shortcut:v,mods:p,keys:u.split("+").map(A=>code(A))})})}),a}function filter$1(a){const s=a.target||a.srcElement,{tagName:c}=s;let u=!0;const d=c==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(s.type);return(s.isContentEditable||(d||c==="TEXTAREA"||c==="SELECT")&&!s.readOnly)&&(u=!1),u}function isPressed(a){return typeof a=="string"&&(a=code(a)),_downKeys.indexOf(a)!==-1}function deleteScope(a,s){let c,u;a||(a=getScope());for(const d in _handlers)if(Object.prototype.hasOwnProperty.call(_handlers,d))for(c=_handlers[d],u=0;u<c.length;)c[u].scope===a?c.splice(u,1).forEach(v=>{let{element:A}=v;return removeKeyEvent(A)}):u++;getScope()===a&&setScope(s||"all")}function clearModifier(a){let s=a.keyCode||a.which||a.charCode;const c=_downKeys.indexOf(s);if(c>=0&&_downKeys.splice(c,1),a.key&&a.key.toLowerCase()==="meta"&&_downKeys.splice(0,_downKeys.length),(s===93||s===224)&&(s=91),s in _mods){_mods[s]=!1;for(const u in _modifier)_modifier[u]===s&&(hotkeys$1[u]=!1)}}function unbind(a){if(typeof a>"u")Object.keys(_handlers).forEach(d=>{Array.isArray(_handlers[d])&&_handlers[d].forEach(p=>eachUnbind(p)),delete _handlers[d]}),removeKeyEvent(null);else if(Array.isArray(a))a.forEach(d=>{d.key&&eachUnbind(d)});else if(typeof a=="object")a.key&&eachUnbind(a);else if(typeof a=="string"){for(var s=arguments.length,c=new Array(s>1?s-1:0),u=1;u<s;u++)c[u-1]=arguments[u];let[d,p]=c;typeof d=="function"&&(p=d,d=""),eachUnbind({key:a,scope:d,method:p,splitKey:"+"})}}const eachUnbind=a=>{let{key:s,scope:c,method:u,splitKey:d="+"}=a;getKeys$1(s).forEach(v=>{const A=v.split(d),b=A.length,g=A[b-1],x=g==="*"?"*":code(g);if(!_handlers[x])return;c||(c=getScope());const y=b>1?getMods(_modifier,A):[],f=[];_handlers[x]=_handlers[x].filter(m=>{const S=(u?m.method===u:!0)&&m.scope===c&&compareArray(m.mods,y);return S&&f.push(m.element),!S}),f.forEach(m=>removeKeyEvent(m))})};function eventHandler(a,s,c,u){if(s.element!==u)return;let d;if(s.scope===c||s.scope==="all"){d=s.mods.length>0;for(const p in _mods)Object.prototype.hasOwnProperty.call(_mods,p)&&(!_mods[p]&&s.mods.indexOf(+p)>-1||_mods[p]&&s.mods.indexOf(+p)===-1)&&(d=!1);(s.mods.length===0&&!_mods[16]&&!_mods[18]&&!_mods[17]&&!_mods[91]||d||s.shortcut==="*")&&(s.keys=[],s.keys=s.keys.concat(_downKeys),s.method(a,s)===!1&&(a.preventDefault?a.preventDefault():a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.cancelBubble&&(a.cancelBubble=!0)))}}function dispatch(a,s){const c=_handlers["*"];let u=a.keyCode||a.which||a.charCode;if(!hotkeys$1.filter.call(this,a))return;if((u===93||u===224)&&(u=91),_downKeys.indexOf(u)===-1&&u!==229&&_downKeys.push(u),["metaKey","ctrlKey","altKey","shiftKey"].forEach(A=>{const b=modifierMap[A];a[A]&&_downKeys.indexOf(b)===-1?_downKeys.push(b):!a[A]&&_downKeys.indexOf(b)>-1?_downKeys.splice(_downKeys.indexOf(b),1):A==="metaKey"&&a[A]&&(_downKeys=_downKeys.filter(g=>g in modifierMap||g===u))}),u in _mods){_mods[u]=!0;for(const A in _modifier)if(Object.prototype.hasOwnProperty.call(_modifier,A)){const b=modifierMap[_modifier[A]];hotkeys$1[A]=a[b]}if(!c)return}for(const A in _mods)Object.prototype.hasOwnProperty.call(_mods,A)&&(_mods[A]=a[modifierMap[A]]);a.getModifierState&&!(a.altKey&&!a.ctrlKey)&&a.getModifierState("AltGraph")&&(_downKeys.indexOf(17)===-1&&_downKeys.push(17),_downKeys.indexOf(18)===-1&&_downKeys.push(18),_mods[17]=!0,_mods[18]=!0);const d=getScope();if(c)for(let A=0;A<c.length;A++)c[A].scope===d&&(a.type==="keydown"&&c[A].keydown||a.type==="keyup"&&c[A].keyup)&&eventHandler(a,c[A],d,s);if(!(u in _handlers))return;const p=_handlers[u],v=p.length;for(let A=0;A<v;A++)if((a.type==="keydown"&&p[A].keydown||a.type==="keyup"&&p[A].keyup)&&p[A].key){const b=p[A],{splitKey:g}=b,x=b.key.split(g),y=[];for(let f=0;f<x.length;f++)y.push(code(x[f]));y.sort().join("")===_downKeys.sort().join("")&&eventHandler(a,b,d,s)}}function hotkeys$1(a,s,c){_downKeys=[];const u=getKeys$1(a);let d=[],p="all",v=document,A=0,b=!1,g=!0,x="+",y=!1,f=!1;for(c===void 0&&typeof s=="function"&&(c=s),Object.prototype.toString.call(s)==="[object Object]"&&(s.scope&&(p=s.scope),s.element&&(v=s.element),s.keyup&&(b=s.keyup),s.keydown!==void 0&&(g=s.keydown),s.capture!==void 0&&(y=s.capture),typeof s.splitKey=="string"&&(x=s.splitKey),s.single===!0&&(f=!0)),typeof s=="string"&&(p=s),f&&unbind(a,p);A<u.length;A++)a=u[A].split(x),d=[],a.length>1&&(d=getMods(_modifier,a)),a=a[a.length-1],a=a==="*"?"*":code(a),a in _handlers||(_handlers[a]=[]),_handlers[a].push({keyup:b,keydown:g,scope:p,mods:d,shortcut:u[A],method:c,key:u[A],splitKey:x,element:v});if(typeof v<"u"&&window){if(!elementEventMap.has(v)){const m=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return dispatch(S,v)},C=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;dispatch(S,v),clearModifier(S)};elementEventMap.set(v,{keydownListener:m,keyupListenr:C,capture:y}),addEvent$1(v,"keydown",m,y),addEvent$1(v,"keyup",C,y)}if(!winListendFocus){const m=()=>{_downKeys=[]};winListendFocus={listener:m,capture:y},addEvent$1(window,"focus",m,y)}}}function trigger(a){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(_handlers).forEach(c=>{_handlers[c].filter(d=>d.scope===s&&d.shortcut===a).forEach(d=>{d&&d.method&&d.method()})})}function removeKeyEvent(a){const s=Object.values(_handlers).flat();if(s.findIndex(u=>{let{element:d}=u;return d===a})<0){const{keydownListener:u,keyupListenr:d,capture:p}=elementEventMap.get(a)||{};u&&d&&(removeEvent$1(a,"keyup",d,p),removeEvent$1(a,"keydown",u,p),elementEventMap.delete(a))}if((s.length<=0||elementEventMap.size<=0)&&(Object.keys(elementEventMap).forEach(d=>{const{keydownListener:p,keyupListenr:v,capture:A}=elementEventMap.get(d)||{};p&&v&&(removeEvent$1(d,"keyup",v,A),removeEvent$1(d,"keydown",p,A),elementEventMap.delete(d))}),elementEventMap.clear(),Object.keys(_handlers).forEach(d=>delete _handlers[d]),winListendFocus)){const{listener:d,capture:p}=winListendFocus;removeEvent$1(window,"focus",d,p),winListendFocus=null}}const _api={getPressedKeyString,setScope,getScope,deleteScope,getPressedKeyCodes,getAllKeyCodes,isPressed,filter:filter$1,trigger,unbind,keyMap:_keyMap,modifier:_modifier,modifierMap};for(const a in _api)Object.prototype.hasOwnProperty.call(_api,a)&&(hotkeys$1[a]=_api[a]);if(typeof window<"u"){const a=window.hotkeys;hotkeys$1.noConflict=s=>(s&&window.hotkeys===hotkeys$1&&(window.hotkeys=a),hotkeys$1),window.hotkeys=hotkeys$1}var reactExports=requireReact();const React=getDefaultExportFromCjs(reactExports),React$1=_mergeNamespaces({__proto__:null,default:React},[reactExports]);function commonjsRequire(a){throw new Error('Could not dynamically require "'+a+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var pdf={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$5=getAugmentedNamespace(__viteBrowserExternal$1);var hasRequiredPdf;function requirePdf(){return hasRequiredPdf||(hasRequiredPdf=1,function(module,exports){(function(s,c){module.exports=s.pdfjsLib=c()})(globalThis,()=>(()=>{var __webpack_modules__=[,(a,s)=>{var Le;Object.defineProperty(s,"__esModule",{value:!0}),s.VerbosityLevel=s.Util=s.UnknownErrorException=s.UnexpectedResponseException=s.TextRenderingMode=s.RenderingIntentFlag=s.PromiseCapability=s.PermissionFlag=s.PasswordResponses=s.PasswordException=s.PageActionEventType=s.OPS=s.MissingPDFException=s.MAX_IMAGE_SIZE_TO_CACHE=s.LINE_FACTOR=s.LINE_DESCENT_FACTOR=s.InvalidPDFException=s.ImageKind=s.IDENTITY_MATRIX=s.FormatError=s.FeatureTest=s.FONT_IDENTITY_MATRIX=s.DocumentActionEventType=s.CMapCompressionType=s.BaseException=s.BASELINE_FACTOR=s.AnnotationType=s.AnnotationReplyType=s.AnnotationPrefix=s.AnnotationMode=s.AnnotationFlag=s.AnnotationFieldFlag=s.AnnotationEditorType=s.AnnotationEditorPrefix=s.AnnotationEditorParamsType=s.AnnotationBorderStyleType=s.AnnotationActionEventType=s.AbortException=void 0,s.assert=D,s.bytesToString=ie,s.createValidAbsoluteUrl=Z,s.getModificationDate=Ae,s.getUuid=Pe,s.getVerbosityLevel=L,s.info=F,s.isArrayBuffer=Se,s.isArrayEqual=Ee,s.isNodeJS=void 0,s.normalizeUnicode=ye,s.objectFromMap=ve,s.objectSize=we,s.setVerbosityLevel=q,s.shadow=Q,s.string32=me,s.stringToBytes=ce,s.stringToPDFString=xe,s.stringToUTF8String=Ce,s.unreachable=N,s.utf8StringToString=$e,s.warn=U;const c=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser");s.isNodeJS=c;const u=[1,0,0,1,0,0];s.IDENTITY_MATRIX=u;const d=[.001,0,0,.001,0,0];s.FONT_IDENTITY_MATRIX=d;const p=1e7;s.MAX_IMAGE_SIZE_TO_CACHE=p;const v=1.35;s.LINE_FACTOR=v;const A=.35;s.LINE_DESCENT_FACTOR=A;const b=A/v;s.BASELINE_FACTOR=b;const g={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};s.RenderingIntentFlag=g;const x={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};s.AnnotationMode=x;const y="pdfjs_internal_editor_";s.AnnotationEditorPrefix=y;const f={DISABLE:-1,NONE:0,FREETEXT:3,STAMP:13,INK:15};s.AnnotationEditorType=f;const m={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23};s.AnnotationEditorParamsType=m;const C={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.PermissionFlag=C;const S={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};s.TextRenderingMode=S;const w={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};s.ImageKind=w;const _={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};s.AnnotationType=_;const I={GROUP:"Group",REPLY:"R"};s.AnnotationReplyType=I;const $={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};s.AnnotationFlag=$;const P={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};s.AnnotationFieldFlag=P;const E={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};s.AnnotationBorderStyleType=E;const R={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"};s.AnnotationActionEventType=R;const T={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};s.DocumentActionEventType=T;const B={O:"PageOpen",C:"PageClose"};s.PageActionEventType=B;const M={ERRORS:0,WARNINGS:1,INFOS:5};s.VerbosityLevel=M;const k={NONE:0,BINARY:1};s.CMapCompressionType=k;const O={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};s.OPS=O;const H={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};s.PasswordResponses=H;let j=M.WARNINGS;function q(Oe){Number.isInteger(Oe)&&(j=Oe)}function L(){return j}function F(Oe){j>=M.INFOS&&console.log(`Info: ${Oe}`)}function U(Oe){j>=M.WARNINGS&&console.log(`Warning: ${Oe}`)}function N(Oe){throw new Error(Oe)}function D(Oe,Fe){Oe||N(Fe)}function W(Oe){switch(Oe==null?void 0:Oe.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Z(Oe,Fe=null,_e=null){if(!Oe)return null;try{if(_e&&typeof Oe=="string"){if(_e.addDefaultProtocol&&Oe.startsWith("www.")){const Ye=Oe.match(/\./g);(Ye==null?void 0:Ye.length)>=2&&(Oe=`http://${Oe}`)}if(_e.tryConvertEncoding)try{Oe=Ce(Oe)}catch{}}const je=Fe?new URL(Oe,Fe):new URL(Oe);if(W(je))return je}catch{}return null}function Q(Oe,Fe,_e,je=!1){return Object.defineProperty(Oe,Fe,{value:_e,enumerable:!je,configurable:!0,writable:!1}),_e}const Y=function(){function Fe(_e,je){this.constructor===Fe&&N("Cannot initialize BaseException."),this.message=_e,this.name=je}return Fe.prototype=new Error,Fe.constructor=Fe,Fe}();s.BaseException=Y;class J extends Y{constructor(Fe,_e){super(Fe,"PasswordException"),this.code=_e}}s.PasswordException=J;class ee extends Y{constructor(Fe,_e){super(Fe,"UnknownErrorException"),this.details=_e}}s.UnknownErrorException=ee;class re extends Y{constructor(Fe){super(Fe,"InvalidPDFException")}}s.InvalidPDFException=re;class ae extends Y{constructor(Fe){super(Fe,"MissingPDFException")}}s.MissingPDFException=ae;class V extends Y{constructor(Fe,_e){super(Fe,"UnexpectedResponseException"),this.status=_e}}s.UnexpectedResponseException=V;class K extends Y{constructor(Fe){super(Fe,"FormatError")}}s.FormatError=K;class te extends Y{constructor(Fe){super(Fe,"AbortException")}}s.AbortException=te;function ie(Oe){(typeof Oe!="object"||(Oe==null?void 0:Oe.length)===void 0)&&N("Invalid argument for bytesToString");const Fe=Oe.length,_e=8192;if(Fe<_e)return String.fromCharCode.apply(null,Oe);const je=[];for(let Ye=0;Ye<Fe;Ye+=_e){const Te=Math.min(Ye+_e,Fe),ke=Oe.subarray(Ye,Te);je.push(String.fromCharCode.apply(null,ke))}return je.join("")}function ce(Oe){typeof Oe!="string"&&N("Invalid argument for stringToBytes");const Fe=Oe.length,_e=new Uint8Array(Fe);for(let je=0;je<Fe;++je)_e[je]=Oe.charCodeAt(je)&255;return _e}function me(Oe){return String.fromCharCode(Oe>>24&255,Oe>>16&255,Oe>>8&255,Oe&255)}function we(Oe){return Object.keys(Oe).length}function ve(Oe){const Fe=Object.create(null);for(const[_e,je]of Oe)Fe[_e]=je;return Fe}function ge(){const Oe=new Uint8Array(4);return Oe[0]=1,new Uint32Array(Oe.buffer,0,1)[0]===1}function ue(){try{return new Function(""),!0}catch{return!1}}class se{static get isLittleEndian(){return Q(this,"isLittleEndian",ge())}static get isEvalSupported(){return Q(this,"isEvalSupported",ue())}static get isOffscreenCanvasSupported(){return Q(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator>"u"?Q(this,"platform",{isWin:!1,isMac:!1}):Q(this,"platform",{isWin:navigator.platform.includes("Win"),isMac:navigator.platform.includes("Mac")})}static get isCSSRoundSupported(){var Fe,_e;return Q(this,"isCSSRoundSupported",(_e=(Fe=globalThis.CSS)==null?void 0:Fe.supports)==null?void 0:_e.call(Fe,"width: round(1.5px, 1px)"))}}s.FeatureTest=se;const oe=[...Array(256).keys()].map(Oe=>Oe.toString(16).padStart(2,"0"));class de{static makeHexColor(Fe,_e,je){return`#${oe[Fe]}${oe[_e]}${oe[je]}`}static scaleMinMax(Fe,_e){let je;Fe[0]?(Fe[0]<0&&(je=_e[0],_e[0]=_e[1],_e[1]=je),_e[0]*=Fe[0],_e[1]*=Fe[0],Fe[3]<0&&(je=_e[2],_e[2]=_e[3],_e[3]=je),_e[2]*=Fe[3],_e[3]*=Fe[3]):(je=_e[0],_e[0]=_e[2],_e[2]=je,je=_e[1],_e[1]=_e[3],_e[3]=je,Fe[1]<0&&(je=_e[2],_e[2]=_e[3],_e[3]=je),_e[2]*=Fe[1],_e[3]*=Fe[1],Fe[2]<0&&(je=_e[0],_e[0]=_e[1],_e[1]=je),_e[0]*=Fe[2],_e[1]*=Fe[2]),_e[0]+=Fe[4],_e[1]+=Fe[4],_e[2]+=Fe[5],_e[3]+=Fe[5]}static transform(Fe,_e){return[Fe[0]*_e[0]+Fe[2]*_e[1],Fe[1]*_e[0]+Fe[3]*_e[1],Fe[0]*_e[2]+Fe[2]*_e[3],Fe[1]*_e[2]+Fe[3]*_e[3],Fe[0]*_e[4]+Fe[2]*_e[5]+Fe[4],Fe[1]*_e[4]+Fe[3]*_e[5]+Fe[5]]}static applyTransform(Fe,_e){const je=Fe[0]*_e[0]+Fe[1]*_e[2]+_e[4],Ye=Fe[0]*_e[1]+Fe[1]*_e[3]+_e[5];return[je,Ye]}static applyInverseTransform(Fe,_e){const je=_e[0]*_e[3]-_e[1]*_e[2],Ye=(Fe[0]*_e[3]-Fe[1]*_e[2]+_e[2]*_e[5]-_e[4]*_e[3])/je,Te=(-Fe[0]*_e[1]+Fe[1]*_e[0]+_e[4]*_e[1]-_e[5]*_e[0])/je;return[Ye,Te]}static getAxialAlignedBoundingBox(Fe,_e){const je=this.applyTransform(Fe,_e),Ye=this.applyTransform(Fe.slice(2,4),_e),Te=this.applyTransform([Fe[0],Fe[3]],_e),ke=this.applyTransform([Fe[2],Fe[1]],_e);return[Math.min(je[0],Ye[0],Te[0],ke[0]),Math.min(je[1],Ye[1],Te[1],ke[1]),Math.max(je[0],Ye[0],Te[0],ke[0]),Math.max(je[1],Ye[1],Te[1],ke[1])]}static inverseTransform(Fe){const _e=Fe[0]*Fe[3]-Fe[1]*Fe[2];return[Fe[3]/_e,-Fe[1]/_e,-Fe[2]/_e,Fe[0]/_e,(Fe[2]*Fe[5]-Fe[4]*Fe[3])/_e,(Fe[4]*Fe[1]-Fe[5]*Fe[0])/_e]}static singularValueDecompose2dScale(Fe){const _e=[Fe[0],Fe[2],Fe[1],Fe[3]],je=Fe[0]*_e[0]+Fe[1]*_e[2],Ye=Fe[0]*_e[1]+Fe[1]*_e[3],Te=Fe[2]*_e[0]+Fe[3]*_e[2],ke=Fe[2]*_e[1]+Fe[3]*_e[3],De=(je+ke)/2,Re=Math.sqrt((je+ke)**2-4*(je*ke-Te*Ye))/2,Ge=De+Re||1,Ve=De-Re||1;return[Math.sqrt(Ge),Math.sqrt(Ve)]}static normalizeRect(Fe){const _e=Fe.slice(0);return Fe[0]>Fe[2]&&(_e[0]=Fe[2],_e[2]=Fe[0]),Fe[1]>Fe[3]&&(_e[1]=Fe[3],_e[3]=Fe[1]),_e}static intersect(Fe,_e){const je=Math.max(Math.min(Fe[0],Fe[2]),Math.min(_e[0],_e[2])),Ye=Math.min(Math.max(Fe[0],Fe[2]),Math.max(_e[0],_e[2]));if(je>Ye)return null;const Te=Math.max(Math.min(Fe[1],Fe[3]),Math.min(_e[1],_e[3])),ke=Math.min(Math.max(Fe[1],Fe[3]),Math.max(_e[1],_e[3]));return Te>ke?null:[je,Te,Ye,ke]}static bezierBoundingBox(Fe,_e,je,Ye,Te,ke,De,Re){const Ge=[],Ve=[[],[]];let Xe,We,ze,Qe,et,Ze,qe,Je;for(let vt=0;vt<2;++vt){if(vt===0?(We=6*Fe-12*je+6*Te,Xe=-3*Fe+9*je-9*Te+3*De,ze=3*je-3*Fe):(We=6*_e-12*Ye+6*ke,Xe=-3*_e+9*Ye-9*ke+3*Re,ze=3*Ye-3*_e),Math.abs(Xe)<1e-12){if(Math.abs(We)<1e-12)continue;Qe=-ze/We,0<Qe&&Qe<1&&Ge.push(Qe);continue}qe=We*We-4*ze*Xe,Je=Math.sqrt(qe),!(qe<0)&&(et=(-We+Je)/(2*Xe),0<et&&et<1&&Ge.push(et),Ze=(-We-Je)/(2*Xe),0<Ze&&Ze<1&&Ge.push(Ze))}let ot=Ge.length,nt;const st=ot;for(;ot--;)Qe=Ge[ot],nt=1-Qe,Ve[0][ot]=nt*nt*nt*Fe+3*nt*nt*Qe*je+3*nt*Qe*Qe*Te+Qe*Qe*Qe*De,Ve[1][ot]=nt*nt*nt*_e+3*nt*nt*Qe*Ye+3*nt*Qe*Qe*ke+Qe*Qe*Qe*Re;return Ve[0][st]=Fe,Ve[1][st]=_e,Ve[0][st+1]=De,Ve[1][st+1]=Re,Ve[0].length=Ve[1].length=st+2,[Math.min(...Ve[0]),Math.min(...Ve[1]),Math.max(...Ve[0]),Math.max(...Ve[1])]}}s.Util=de;const le=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function xe(Oe){if(Oe[0]>="ï"){let _e;if(Oe[0]==="þ"&&Oe[1]==="ÿ"?_e="utf-16be":Oe[0]==="ÿ"&&Oe[1]==="þ"?_e="utf-16le":Oe[0]==="ï"&&Oe[1]==="»"&&Oe[2]==="¿"&&(_e="utf-8"),_e)try{const je=new TextDecoder(_e,{fatal:!0}),Ye=ce(Oe);return je.decode(Ye)}catch(je){U(`stringToPDFString: "${je}".`)}}const Fe=[];for(let _e=0,je=Oe.length;_e<je;_e++){const Ye=le[Oe.charCodeAt(_e)];Fe.push(Ye?String.fromCharCode(Ye):Oe.charAt(_e))}return Fe.join("")}function Ce(Oe){return decodeURIComponent(escape(Oe))}function $e(Oe){return unescape(encodeURIComponent(Oe))}function Se(Oe){return typeof Oe=="object"&&(Oe==null?void 0:Oe.byteLength)!==void 0}function Ee(Oe,Fe){if(Oe.length!==Fe.length)return!1;for(let _e=0,je=Oe.length;_e<je;_e++)if(Oe[_e]!==Fe[_e])return!1;return!0}function Ae(Oe=new Date){return[Oe.getUTCFullYear().toString(),(Oe.getUTCMonth()+1).toString().padStart(2,"0"),Oe.getUTCDate().toString().padStart(2,"0"),Oe.getUTCHours().toString().padStart(2,"0"),Oe.getUTCMinutes().toString().padStart(2,"0"),Oe.getUTCSeconds().toString().padStart(2,"0")].join("")}class pe{constructor(){bt(this,Le,!1);this.promise=new Promise((Fe,_e)=>{this.resolve=je=>{Ct(this,Le,!0),Fe(je)},this.reject=je=>{Ct(this,Le,!0),_e(je)}})}get settled(){return He(this,Le)}}Le=new WeakMap,s.PromiseCapability=pe;let he=null,Ie=null;function ye(Oe){return he||(he=/([\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,Ie=new Map([["ſt","ſt"]])),Oe.replaceAll(he,(Fe,_e,je)=>_e?_e.normalize("NFKC"):Ie.get(je))}function Pe(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const Oe=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(Oe);else for(let Fe=0;Fe<32;Fe++)Oe[Fe]=Math.floor(Math.random()*255);return ie(Oe)}const Ne="pdfjs_internal_id_";s.AnnotationPrefix=Ne},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{var a,c,u,d,ka,po,A,b,g,x,y,f,m,C,S,go,_,I,Gs,P,E;Object.defineProperty(exports,"__esModule",{value:!0}),exports.RenderTask=exports.PDFWorkerUtil=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultFilterFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,Object.defineProperty(exports,"SVGGraphics",{enumerable:!0,get:function(){return _displaySvg.SVGGraphics}}),exports.build=void 0,exports.getDocument=getDocument,exports.version=void 0;var _util=__w_pdfjs_require__(1),_annotation_storage=__w_pdfjs_require__(3),_display_utils=__w_pdfjs_require__(6),_font_loader=__w_pdfjs_require__(9),_displayNode_utils=__w_pdfjs_require__(10),_canvas=__w_pdfjs_require__(11),_worker_options=__w_pdfjs_require__(14),_message_handler=__w_pdfjs_require__(15),_metadata=__w_pdfjs_require__(16),_optional_content_config=__w_pdfjs_require__(17),_transport_stream=__w_pdfjs_require__(18),_displayFetch_stream=__w_pdfjs_require__(19),_displayNetwork=__w_pdfjs_require__(22),_displayNode_stream=__w_pdfjs_require__(23),_displaySvg=__w_pdfjs_require__(24),_xfa_text=__w_pdfjs_require__(25);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,DELAYED_CLEANUP_TIMEOUT=5e3,DefaultCanvasFactory=_util.isNodeJS?_displayNode_utils.NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;const DefaultCMapReaderFactory=_util.isNodeJS?_displayNode_utils.NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;const DefaultFilterFactory=_util.isNodeJS?_displayNode_utils.NodeFilterFactory:_display_utils.DOMFilterFactory;exports.DefaultFilterFactory=DefaultFilterFactory;const DefaultStandardFontDataFactory=_util.isNodeJS?_displayNode_utils.NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory;exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory;function getDocument(T){if(typeof T=="string"||T instanceof URL?T={url:T}:(0,_util.isArrayBuffer)(T)&&(T={data:T}),typeof T!="object")throw new Error("Invalid parameter in getDocument, need parameter object.");if(!T.url&&!T.data&&!T.range)throw new Error("Invalid parameter object: need either .data, .range or .url");const B=new PDFDocumentLoadingTask,{docId:M}=B,k=T.url?getUrlProp(T.url):null,O=T.data?getDataProp(T.data):null,H=T.httpHeaders||null,j=T.withCredentials===!0,q=T.password??null,L=T.range instanceof PDFDataRangeTransport?T.range:null,F=Number.isInteger(T.rangeChunkSize)&&T.rangeChunkSize>0?T.rangeChunkSize:DEFAULT_RANGE_CHUNK_SIZE;let U=T.worker instanceof PDFWorker?T.worker:null;const N=T.verbosity,D=typeof T.docBaseUrl=="string"&&!(0,_display_utils.isDataScheme)(T.docBaseUrl)?T.docBaseUrl:null,W=typeof T.cMapUrl=="string"?T.cMapUrl:null,Z=T.cMapPacked!==!1,Q=T.CMapReaderFactory||DefaultCMapReaderFactory,Y=typeof T.standardFontDataUrl=="string"?T.standardFontDataUrl:null,J=T.StandardFontDataFactory||DefaultStandardFontDataFactory,ee=T.stopAtErrors!==!0,re=Number.isInteger(T.maxImageSize)&&T.maxImageSize>-1?T.maxImageSize:-1,ae=T.isEvalSupported!==!1,V=typeof T.isOffscreenCanvasSupported=="boolean"?T.isOffscreenCanvasSupported:!_util.isNodeJS,K=Number.isInteger(T.canvasMaxAreaInBytes)?T.canvasMaxAreaInBytes:-1,te=typeof T.disableFontFace=="boolean"?T.disableFontFace:_util.isNodeJS,ie=T.fontExtraProperties===!0,ce=T.enableXfa===!0,me=T.ownerDocument||globalThis.document,we=T.disableRange===!0,ve=T.disableStream===!0,ge=T.disableAutoFetch===!0,ue=T.pdfBug===!0,se=L?L.length:T.length??NaN,oe=typeof T.useSystemFonts=="boolean"?T.useSystemFonts:!_util.isNodeJS&&!te,de=typeof T.useWorkerFetch=="boolean"?T.useWorkerFetch:Q===_display_utils.DOMCMapReaderFactory&&J===_display_utils.DOMStandardFontDataFactory&&W&&Y&&(0,_display_utils.isValidFetchUrl)(W,document.baseURI)&&(0,_display_utils.isValidFetchUrl)(Y,document.baseURI),le=T.canvasFactory||new DefaultCanvasFactory({ownerDocument:me}),xe=T.filterFactory||new DefaultFilterFactory({docId:M,ownerDocument:me}),Ce=null;(0,_util.setVerbosityLevel)(N);const $e={canvasFactory:le,filterFactory:xe};if(de||($e.cMapReaderFactory=new Q({baseUrl:W,isCompressed:Z}),$e.standardFontDataFactory=new J({baseUrl:Y})),!U){const Ae={verbosity:N,port:_worker_options.GlobalWorkerOptions.workerPort};U=Ae.port?PDFWorker.fromPort(Ae):new PDFWorker(Ae),B._worker=U}const Se={docId:M,apiVersion:"3.11.174",data:O,password:q,disableAutoFetch:ge,rangeChunkSize:F,length:se,docBaseUrl:D,enableXfa:ce,evaluatorOptions:{maxImageSize:re,disableFontFace:te,ignoreErrors:ee,isEvalSupported:ae,isOffscreenCanvasSupported:V,canvasMaxAreaInBytes:K,fontExtraProperties:ie,useSystemFonts:oe,cMapUrl:de?W:null,standardFontDataUrl:de?Y:null}},Ee={ignoreErrors:ee,isEvalSupported:ae,disableFontFace:te,fontExtraProperties:ie,enableXfa:ce,ownerDocument:me,disableAutoFetch:ge,pdfBug:ue,styleElement:Ce};return U.promise.then(function(){if(B.destroyed)throw new Error("Loading aborted");const Ae=_fetchDocument(U,Se),pe=new Promise(function(he){let Ie;L?Ie=new _transport_stream.PDFDataTransportStream({length:se,initialData:L.initialData,progressiveDone:L.progressiveDone,contentDispositionFilename:L.contentDispositionFilename,disableRange:we,disableStream:ve},L):O||(Ie=(Pe=>_util.isNodeJS?new _displayNode_stream.PDFNodeStream(Pe):(0,_display_utils.isValidFetchUrl)(Pe.url)?new _displayFetch_stream.PDFFetchStream(Pe):new _displayNetwork.PDFNetworkStream(Pe))({url:k,length:se,httpHeaders:H,withCredentials:j,rangeChunkSize:F,disableRange:we,disableStream:ve})),he(Ie)});return Promise.all([Ae,pe]).then(function([he,Ie]){if(B.destroyed)throw new Error("Loading aborted");const ye=new _message_handler.MessageHandler(M,he,U.port),Pe=new WorkerTransport(ye,B,Ie,Ee,$e);B._transport=Pe,ye.send("Ready",null)})}).catch(B._capability.reject),B}async function _fetchDocument(T,B){if(T.destroyed)throw new Error("Worker was destroyed");const M=await T.messageHandler.sendWithPromise("GetDocRequest",B,B.data?[B.data.buffer]:null);if(T.destroyed)throw new Error("Worker was destroyed");return M}function getUrlProp(T){if(T instanceof URL)return T.href;try{return new URL(T,window.location).href}catch{if(_util.isNodeJS&&typeof T=="string")return T}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function getDataProp(T){if(_util.isNodeJS&&typeof Buffer<"u"&&T instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(T instanceof Uint8Array&&T.byteLength===T.buffer.byteLength)return T;if(typeof T=="string")return(0,_util.stringToBytes)(T);if(typeof T=="object"&&!isNaN(T==null?void 0:T.length)||(0,_util.isArrayBuffer)(T))return new Uint8Array(T);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}const s=class s{constructor(){this._capability=new _util.PromiseCapability,this._transport=null,this._worker=null,this.docId=`d${hi(s,a)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var B,M,k;this.destroyed=!0;try{(B=this._worker)!=null&&B.port&&(this._worker._pendingDestroy=!0),await((M=this._transport)==null?void 0:M.destroy())}catch(O){throw(k=this._worker)!=null&&k.port&&delete this._worker._pendingDestroy,O}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};a=new WeakMap,bt(s,a,0);let PDFDocumentLoadingTask=s;exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(B,M,k=!1,O=null){this.length=B,this.initialData=M,this.progressiveDone=k,this.contentDispositionFilename=O,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=new _util.PromiseCapability}addRangeListener(B){this._rangeListeners.push(B)}addProgressListener(B){this._progressListeners.push(B)}addProgressiveReadListener(B){this._progressiveReadListeners.push(B)}addProgressiveDoneListener(B){this._progressiveDoneListeners.push(B)}onDataRange(B,M){for(const k of this._rangeListeners)k(B,M)}onDataProgress(B,M){this._readyCapability.promise.then(()=>{for(const k of this._progressListeners)k(B,M)})}onDataProgressiveRead(B){this._readyCapability.promise.then(()=>{for(const M of this._progressiveReadListeners)M(B)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const B of this._progressiveDoneListeners)B()})}transportReady(){this._readyCapability.resolve()}requestDataRange(B,M){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(B,M){this._pdfInfo=B,this._transport=M,Object.defineProperty(this,"getJavaScript",{value:()=>((0,_display_utils.deprecated)("`PDFDocumentProxy.getJavaScript`, please use `PDFDocumentProxy.getJSActions` instead."),this.getJSActions().then(k=>{if(!k)return k;const O=[];for(const H in k)O.push(...k[H]);return O}))})}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(B){return this._transport.getPage(B)}getPageIndex(B){return this._transport.getPageIndex(B)}getDestinations(){return this._transport.getDestinations()}getDestination(B){return this._transport.getDestination(B)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(B=!1){return this._transport.startCleanup(B||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}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()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(B,M,k,O=!1){bt(this,d);bt(this,c,null);bt(this,u,!1);this._pageIndex=B,this._pageInfo=M,this._transport=k,this._stats=O?new _display_utils.StatTimer:null,this._pdfBug=O,this.commonObjs=k.commonObjs,this.objs=new PDFObjects,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:B,rotation:M=this.rotate,offsetX:k=0,offsetY:O=0,dontFlip:H=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:B,rotation:M,offsetX:k,offsetY:O,dontFlip:H})}getAnnotations({intent:B="display"}={}){const M=this._transport.getRenderingIntent(B);return this._transport.getAnnotations(this._pageIndex,M.renderingIntent)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var B;return((B=this._transport._htmlForXfa)==null?void 0:B.children[this._pageIndex])||null}render({canvasContext:B,viewport:M,intent:k="display",annotationMode:O=_util.AnnotationMode.ENABLE,transform:H=null,background:j=null,optionalContentConfigPromise:q=null,annotationCanvasMap:L=null,pageColors:F=null,printAnnotationStorage:U=null}){var J,ee;(J=this._stats)==null||J.time("Overall");const N=this._transport.getRenderingIntent(k,O,U);Ct(this,u,!1),it(this,d,po).call(this),q||(q=this._transport.getOptionalContentConfig());let D=this._intentStates.get(N.cacheKey);D||(D=Object.create(null),this._intentStates.set(N.cacheKey,D)),D.streamReaderCancelTimeout&&(clearTimeout(D.streamReaderCancelTimeout),D.streamReaderCancelTimeout=null);const W=!!(N.renderingIntent&_util.RenderingIntentFlag.PRINT);D.displayReadyCapability||(D.displayReadyCapability=new _util.PromiseCapability,D.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(ee=this._stats)==null||ee.time("Page Request"),this._pumpOperatorList(N));const Z=re=>{var ae,V;D.renderTasks.delete(Q),(this._maybeCleanupAfterRender||W)&&Ct(this,u,!0),it(this,d,ka).call(this,!W),re?(Q.capability.reject(re),this._abortOperatorList({intentState:D,reason:re instanceof Error?re:new Error(re)})):Q.capability.resolve(),(ae=this._stats)==null||ae.timeEnd("Rendering"),(V=this._stats)==null||V.timeEnd("Overall")},Q=new InternalRenderTask({callback:Z,params:{canvasContext:B,viewport:M,transform:H,background:j},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:L,operatorList:D.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!W,pdfBug:this._pdfBug,pageColors:F});(D.renderTasks||(D.renderTasks=new Set)).add(Q);const Y=Q.task;return Promise.all([D.displayReadyCapability.promise,q]).then(([re,ae])=>{var V;if(this.destroyed){Z();return}(V=this._stats)==null||V.time("Rendering"),Q.initializeGraphics({transparency:re,optionalContentConfig:ae}),Q.operatorListChanged()}).catch(Z),Y}getOperatorList({intent:B="display",annotationMode:M=_util.AnnotationMode.ENABLE,printAnnotationStorage:k=null}={}){var L;function O(){j.operatorList.lastChunk&&(j.opListReadCapability.resolve(j.operatorList),j.renderTasks.delete(q))}const H=this._transport.getRenderingIntent(B,M,k,!0);let j=this._intentStates.get(H.cacheKey);j||(j=Object.create(null),this._intentStates.set(H.cacheKey,j));let q;return j.opListReadCapability||(q=Object.create(null),q.operatorListChanged=O,j.opListReadCapability=new _util.PromiseCapability,(j.renderTasks||(j.renderTasks=new Set)).add(q),j.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(L=this._stats)==null||L.time("Page Request"),this._pumpOperatorList(H)),j.opListReadCapability.promise}streamTextContent({includeMarkedContent:B=!1,disableNormalization:M=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:B===!0,disableNormalization:M===!0},{highWaterMark:100,size(O){return O.items.length}})}getTextContent(B={}){if(this._transport._htmlForXfa)return this.getXfa().then(k=>_xfa_text.XfaText.textContent(k));const M=this.streamTextContent(B);return new Promise(function(k,O){function H(){j.read().then(function({value:L,done:F}){if(F){k(q);return}Object.assign(q.styles,L.styles),q.items.push(...L.items),H()},O)}const j=M.getReader(),q={items:[],styles:Object.create(null)};H()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const B=[];for(const M of this._intentStates.values())if(this._abortOperatorList({intentState:M,reason:new Error("Page was destroyed."),force:!0}),!M.opListReadCapability)for(const k of M.renderTasks)B.push(k.completed),k.cancel();return this.objs.clear(),Ct(this,u,!1),it(this,d,po).call(this),Promise.all(B)}cleanup(B=!1){Ct(this,u,!0);const M=it(this,d,ka).call(this,!1);return B&&M&&this._stats&&(this._stats=new _display_utils.StatTimer),M}_startRenderPage(B,M){var O,H;const k=this._intentStates.get(M);k&&((O=this._stats)==null||O.timeEnd("Page Request"),(H=k.displayReadyCapability)==null||H.resolve(B))}_renderPageChunk(B,M){for(let k=0,O=B.length;k<O;k++)M.operatorList.fnArray.push(B.fnArray[k]),M.operatorList.argsArray.push(B.argsArray[k]);M.operatorList.lastChunk=B.lastChunk,M.operatorList.separateAnnots=B.separateAnnots;for(const k of M.renderTasks)k.operatorListChanged();B.lastChunk&&it(this,d,ka).call(this,!0)}_pumpOperatorList({renderingIntent:B,cacheKey:M,annotationStorageSerializable:k}){const{map:O,transfers:H}=k,q=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:B,cacheKey:M,annotationStorage:O},H).getReader(),L=this._intentStates.get(M);L.streamReader=q;const F=()=>{q.read().then(({value:U,done:N})=>{if(N){L.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(U,L),F())},U=>{if(L.streamReader=null,!this._transport.destroyed){if(L.operatorList){L.operatorList.lastChunk=!0;for(const N of L.renderTasks)N.operatorListChanged();it(this,d,ka).call(this,!0)}if(L.displayReadyCapability)L.displayReadyCapability.reject(U);else if(L.opListReadCapability)L.opListReadCapability.reject(U);else throw U}})};F()}_abortOperatorList({intentState:B,reason:M,force:k=!1}){if(B.streamReader){if(B.streamReaderCancelTimeout&&(clearTimeout(B.streamReaderCancelTimeout),B.streamReaderCancelTimeout=null),!k){if(B.renderTasks.size>0)return;if(M instanceof _display_utils.RenderingCancelledException){let O=RENDERING_CANCELLED_TIMEOUT;M.extraDelay>0&&M.extraDelay<1e3&&(O+=M.extraDelay),B.streamReaderCancelTimeout=setTimeout(()=>{B.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:B,reason:M,force:!0})},O);return}}if(B.streamReader.cancel(new _util.AbortException(M.message)).catch(()=>{}),B.streamReader=null,!this._transport.destroyed){for(const[O,H]of this._intentStates)if(H===B){this._intentStates.delete(O);break}this.cleanup()}}}get stats(){return this._stats}}c=new WeakMap,u=new WeakMap,d=new WeakSet,ka=function(B=!1){if(it(this,d,po).call(this),!He(this,u)||this.destroyed)return!1;if(B)return Ct(this,c,setTimeout(()=>{Ct(this,c,null),it(this,d,ka).call(this,!1)},DELAYED_CLEANUP_TIMEOUT)),!1;for(const{renderTasks:M,operatorList:k}of this._intentStates.values())if(M.size>0||!k.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),Ct(this,u,!1),!0},po=function(){He(this,c)&&(clearTimeout(He(this,c)),Ct(this,c,null))},exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){bt(this,A,new Set);bt(this,b,Promise.resolve())}postMessage(B,M){const k={data:structuredClone(B,M?{transfer:M}:null)};He(this,b).then(()=>{for(const O of He(this,A))O.call(this,k)})}addEventListener(B,M){He(this,A).add(M)}removeEventListener(B,M){He(this,A).delete(M)}terminate(){He(this,A).clear()}}A=new WeakMap,b=new WeakMap,exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};exports.PDFWorkerUtil=PDFWorkerUtil;{if(_util.isNodeJS&&typeof commonjsRequire=="function")PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if(typeof document=="object"){const T=(g=document==null?void 0:document.currentScript)==null?void 0:g.src;T&&(PDFWorkerUtil.fallbackWorkerSrc=T.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(T,B){let M;try{if(M=new URL(T),!M.origin||M.origin==="null")return!1}catch{return!1}const k=new URL(B,M);return M.origin===k.origin},PDFWorkerUtil.createCDNWrapper=function(T){const B=`importScripts("${T}");`;return URL.createObjectURL(new Blob([B]))}}const _PDFWorker=class _PDFWorker{constructor({name:T=null,port:B=null,verbosity:M=(0,_util.getVerbosityLevel)()}={}){var k;if(this.name=T,this.destroyed=!1,this.verbosity=M,this._readyCapability=new _util.PromiseCapability,this._port=null,this._webWorker=null,this._messageHandler=null,B){if((k=He(_PDFWorker,x))!=null&&k.has(B))throw new Error("Cannot use more than one PDFWorker per port.");(He(_PDFWorker,x)||Ct(_PDFWorker,x,new WeakMap)).set(B,this),this._initializeFromPort(B);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(T){this._port=T,this._messageHandler=new _message_handler.MessageHandler("main","worker",T),this._messageHandler.on("ready",function(){}),this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!PDFWorkerUtil.isWorkerDisabled&&!_PDFWorker._mainThreadWorkerMessageHandler){let{workerSrc:T}=_PDFWorker;try{PDFWorkerUtil.isSameOrigin(window.location.href,T)||(T=PDFWorkerUtil.createCDNWrapper(new URL(T,window.location).href));const B=new Worker(T),M=new _message_handler.MessageHandler("main","worker",B),k=()=>{B.removeEventListener("error",O),M.destroy(),B.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},O=()=>{this._webWorker||k()};B.addEventListener("error",O),M.on("test",j=>{if(B.removeEventListener("error",O),this.destroyed){k();return}j?(this._messageHandler=M,this._port=B,this._webWorker=B,this._readyCapability.resolve(),M.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),M.destroy(),B.terminate())}),M.on("ready",j=>{if(B.removeEventListener("error",O),this.destroyed){k();return}try{H()}catch{this._setupFakeWorker()}});const H=()=>{const j=new Uint8Array;M.send("test",j,[j.buffer])};H();return}catch{(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),_PDFWorker._setupFakeWorkerGlobal.then(T=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const B=new LoopbackPort;this._port=B;const M=`fake${PDFWorkerUtil.fakeWorkerId++}`,k=new _message_handler.MessageHandler(M+"_worker",M,B);T.setup(k,B);const O=new _message_handler.MessageHandler(M,M+"_worker",B);this._messageHandler=O,this._readyCapability.resolve(),O.send("configure",{verbosity:this.verbosity})}).catch(T=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${T.message}".`))})}destroy(){var T;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(T=He(_PDFWorker,x))==null||T.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(T){var M;if(!(T!=null&&T.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const B=(M=He(this,x))==null?void 0:M.get(T.port);if(B){if(B._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return B}return new _PDFWorker(T)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(PDFWorkerUtil.fallbackWorkerSrc!==null)return _util.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){var T;try{return((T=globalThis.pdfjsWorker)==null?void 0:T.WorkerMessageHandler)||null}catch{return null}}static get _setupFakeWorkerGlobal(){const loader=async()=>{const mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_util.isNodeJS&&typeof commonjsRequire=="function"){const worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return await(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler};return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}};x=new WeakMap,bt(_PDFWorker,x);let PDFWorker=_PDFWorker;exports.PDFWorker=PDFWorker;class WorkerTransport{constructor(B,M,k,O,H){bt(this,S);bt(this,y,new Map);bt(this,f,new Map);bt(this,m,new Map);bt(this,C,null);this.messageHandler=B,this.loadingTask=M,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({ownerDocument:O.ownerDocument,styleElement:O.styleElement}),this._params=O,this.canvasFactory=H.canvasFactory,this.filterFactory=H.filterFactory,this.cMapReaderFactory=H.cMapReaderFactory,this.standardFontDataFactory=H.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=k,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=new _util.PromiseCapability,this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}getRenderingIntent(B,M=_util.AnnotationMode.ENABLE,k=null,O=!1){let H=_util.RenderingIntentFlag.DISPLAY,j=_annotation_storage.SerializableEmpty;switch(B){case"any":H=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":H=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${B}`)}switch(M){case _util.AnnotationMode.DISABLE:H+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:H+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:H+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,j=(H&_util.RenderingIntentFlag.PRINT&&k instanceof _annotation_storage.PrintAnnotationStorage?k:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${M}`)}return O&&(H+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:H,cacheKey:`${H}_${j.hash}`,annotationStorageSerializable:j}}destroy(){var k;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=new _util.PromiseCapability,(k=He(this,C))==null||k.reject(new Error("Worker was destroyed during onPassword callback"));const B=[];for(const O of He(this,f).values())B.push(O._destroy());He(this,f).clear(),He(this,m).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const M=this.messageHandler.sendWithPromise("Terminate",null);return B.push(M),Promise.all(B).then(()=>{var O;this.commonObjs.clear(),this.fontLoader.clear(),He(this,y).clear(),this.filterFactory.destroy(),(O=this._networkStream)==null||O.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:B,loadingTask:M}=this;B.on("GetReader",(k,O)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=H=>{this._lastProgress={loaded:H.loaded,total:H.total}},O.onPull=()=>{this._fullReader.read().then(function({value:H,done:j}){if(j){O.close();return}(0,_util.assert)(H instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),O.enqueue(new Uint8Array(H),1,[H])}).catch(H=>{O.error(H)})},O.onCancel=H=>{this._fullReader.cancel(H),O.ready.catch(j=>{if(!this.destroyed)throw j})}}),B.on("ReaderHeadersReady",k=>{const O=new _util.PromiseCapability,H=this._fullReader;return H.headersReady.then(()=>{var j;(!H.isStreamingSupported||!H.isRangeSupported)&&(this._lastProgress&&((j=M.onProgress)==null||j.call(M,this._lastProgress)),H.onProgress=q=>{var L;(L=M.onProgress)==null||L.call(M,{loaded:q.loaded,total:q.total})}),O.resolve({isStreamingSupported:H.isStreamingSupported,isRangeSupported:H.isRangeSupported,contentLength:H.contentLength})},O.reject),O.promise}),B.on("GetRangeReader",(k,O)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const H=this._networkStream.getRangeReader(k.begin,k.end);if(!H){O.close();return}O.onPull=()=>{H.read().then(function({value:j,done:q}){if(q){O.close();return}(0,_util.assert)(j instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),O.enqueue(new Uint8Array(j),1,[j])}).catch(j=>{O.error(j)})},O.onCancel=j=>{H.cancel(j),O.ready.catch(q=>{if(!this.destroyed)throw q})}}),B.on("GetDoc",({pdfInfo:k})=>{this._numPages=k.numPages,this._htmlForXfa=k.htmlForXfa,delete k.htmlForXfa,M._capability.resolve(new PDFDocumentProxy(k,this))}),B.on("DocException",function(k){let O;switch(k.name){case"PasswordException":O=new _util.PasswordException(k.message,k.code);break;case"InvalidPDFException":O=new _util.InvalidPDFException(k.message);break;case"MissingPDFException":O=new _util.MissingPDFException(k.message);break;case"UnexpectedResponseException":O=new _util.UnexpectedResponseException(k.message,k.status);break;case"UnknownErrorException":O=new _util.UnknownErrorException(k.message,k.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}M._capability.reject(O)}),B.on("PasswordRequest",k=>{if(Ct(this,C,new _util.PromiseCapability),M.onPassword){const O=H=>{H instanceof Error?He(this,C).reject(H):He(this,C).resolve({password:H})};try{M.onPassword(O,k.code)}catch(H){He(this,C).reject(H)}}else He(this,C).reject(new _util.PasswordException(k.message,k.code));return He(this,C).promise}),B.on("DataLoaded",k=>{var O;(O=M.onProgress)==null||O.call(M,{loaded:k.length,total:k.length}),this.downloadInfoCapability.resolve(k)}),B.on("StartRenderPage",k=>{if(this.destroyed)return;He(this,f).get(k.pageIndex)._startRenderPage(k.transparency,k.cacheKey)}),B.on("commonobj",([k,O,H])=>{var j;if(!this.destroyed&&!this.commonObjs.has(k))switch(O){case"Font":const q=this._params;if("error"in H){const U=H.error;(0,_util.warn)(`Error during font loading: ${U}`),this.commonObjs.resolve(k,U);break}const L=q.pdfBug&&((j=globalThis.FontInspector)!=null&&j.enabled)?(U,N)=>globalThis.FontInspector.fontAdded(U,N):null,F=new _font_loader.FontFaceObject(H,{isEvalSupported:q.isEvalSupported,disableFontFace:q.disableFontFace,ignoreErrors:q.ignoreErrors,inspectFont:L});this.fontLoader.bind(F).catch(U=>B.sendWithPromise("FontFallback",{id:k})).finally(()=>{!q.fontExtraProperties&&F.data&&(F.data=null),this.commonObjs.resolve(k,F)});break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(k,H);break;default:throw new Error(`Got unknown common object type ${O}`)}}),B.on("obj",([k,O,H,j])=>{var L;if(this.destroyed)return;const q=He(this,f).get(O);if(!q.objs.has(k))switch(H){case"Image":if(q.objs.resolve(k,j),j){let F;if(j.bitmap){const{width:U,height:N}=j;F=U*N*4}else F=((L=j.data)==null?void 0:L.length)||0;F>_util.MAX_IMAGE_SIZE_TO_CACHE&&(q._maybeCleanupAfterRender=!0)}break;case"Pattern":q.objs.resolve(k,j);break;default:throw new Error(`Got unknown object type ${H}`)}}),B.on("DocProgress",k=>{var O;this.destroyed||(O=M.onProgress)==null||O.call(M,{loaded:k.loaded,total:k.total})}),B.on("FetchBuiltInCMap",k=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(k):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),B.on("FetchStandardFontData",k=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(k):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var k;this.annotationStorage.size<=0&&(0,_util.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:B,transfers:M}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:B,filename:((k=this._fullReader)==null?void 0:k.filename)??null},M).finally(()=>{this.annotationStorage.resetModified()})}getPage(B){if(!Number.isInteger(B)||B<=0||B>this._numPages)return Promise.reject(new Error("Invalid page request."));const M=B-1,k=He(this,m).get(M);if(k)return k;const O=this.messageHandler.sendWithPromise("GetPage",{pageIndex:M}).then(H=>{if(this.destroyed)throw new Error("Transport destroyed");const j=new PDFPageProxy(M,H,this,this._params.pdfBug);return He(this,f).set(M,j),j});return He(this,m).set(M,O),O}getPageIndex(B){return typeof B!="object"||B===null||!Number.isInteger(B.num)||B.num<0||!Number.isInteger(B.gen)||B.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:B.num,gen:B.gen})}getAnnotations(B,M){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:B,intent:M})}getFieldObjects(){return it(this,S,go).call(this,"GetFieldObjects")}hasJSActions(){return it(this,S,go).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(B){return typeof B!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:B})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return it(this,S,go).call(this,"GetDocJSActions")}getPageJSActions(B){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:B})}getStructTree(B){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:B})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then(B=>new _optional_content_config.OptionalContentConfig(B))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const B="GetMetadata",M=He(this,y).get(B);if(M)return M;const k=this.messageHandler.sendWithPromise(B,null).then(O=>{var H,j;return{info:O[0],metadata:O[1]?new _metadata.Metadata(O[1]):null,contentDispositionFilename:((H=this._fullReader)==null?void 0:H.filename)??null,contentLength:((j=this._fullReader)==null?void 0:j.contentLength)??null}});return He(this,y).set(B,k),k}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(B=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const M of He(this,f).values())if(!M.cleanup())throw new Error(`startCleanup: Page ${M.pageNumber} is currently rendering.`);this.commonObjs.clear(),B||this.fontLoader.clear(),He(this,y).clear(),this.filterFactory.destroy(!0)}}get loadingParams(){const{disableAutoFetch:B,enableXfa:M}=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:B,enableXfa:M})}}y=new WeakMap,f=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakSet,go=function(B,M=null){const k=He(this,y).get(B);if(k)return k;const O=this.messageHandler.sendWithPromise(B,M);return He(this,y).set(B,O),O};class PDFObjects{constructor(){bt(this,I);bt(this,_,Object.create(null))}get(B,M=null){if(M){const O=it(this,I,Gs).call(this,B);return O.capability.promise.then(()=>M(O.data)),null}const k=He(this,_)[B];if(!(k!=null&&k.capability.settled))throw new Error(`Requesting object that isn't resolved yet ${B}.`);return k.data}has(B){const M=He(this,_)[B];return(M==null?void 0:M.capability.settled)||!1}resolve(B,M=null){const k=it(this,I,Gs).call(this,B);k.data=M,k.capability.resolve()}clear(){var B;for(const M in He(this,_)){const{data:k}=He(this,_)[M];(B=k==null?void 0:k.bitmap)==null||B.close()}Ct(this,_,Object.create(null))}}_=new WeakMap,I=new WeakSet,Gs=function(B){var M;return(M=He(this,_))[B]||(M[B]={capability:new _util.PromiseCapability,data:null})};class RenderTask{constructor(B){bt(this,P,null);Ct(this,P,B),this.onContinue=null}get promise(){return He(this,P).capability.promise}cancel(B=0){He(this,P).cancel(null,B)}get separateAnnots(){const{separateAnnots:B}=He(this,P).operatorList;if(!B)return!1;const{annotationCanvasMap:M}=He(this,P);return B.form||B.canvas&&(M==null?void 0:M.size)>0}}P=new WeakMap,exports.RenderTask=RenderTask;const R=class R{constructor({callback:B,params:M,objs:k,commonObjs:O,annotationCanvasMap:H,operatorList:j,pageIndex:q,canvasFactory:L,filterFactory:F,useRequestAnimationFrame:U=!1,pdfBug:N=!1,pageColors:D=null}){this.callback=B,this.params=M,this.objs=k,this.commonObjs=O,this.annotationCanvasMap=H,this.operatorListIdx=null,this.operatorList=j,this._pageIndex=q,this.canvasFactory=L,this.filterFactory=F,this._pdfBug=N,this.pageColors=D,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=U===!0&&typeof window<"u",this.cancelled=!1,this.capability=new _util.PromiseCapability,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=M.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:B=!1,optionalContentConfig:M}){var q,L;if(this.cancelled)return;if(this._canvas){if(He(R,E).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.");He(R,E).add(this._canvas)}this._pdfBug&&((q=globalThis.StepperManager)!=null&&q.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:k,viewport:O,transform:H,background:j}=this.params;this.gfx=new _canvas.CanvasGraphics(k,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:M},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:H,viewport:O,transparency:B,background:j}),this.operatorListIdx=0,this.graphicsReady=!0,(L=this.graphicsReadyCallback)==null||L.call(this)}cancel(B=null,M=0){var k;this.running=!1,this.cancelled=!0,(k=this.gfx)==null||k.endDrawing(),He(R,E).delete(this._canvas),this.callback(B||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,M))}operatorListChanged(){var B;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(B=this.stepper)==null||B.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame(()=>{this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),He(R,E).delete(this._canvas),this.callback())))}};E=new WeakMap,bt(R,E,new WeakSet);let InternalRenderTask=R;const version="3.11.174";exports.version=version;const build="ce8716743";exports.build=build},(a,s,c)=>{var g,x,y,Su,m;Object.defineProperty(s,"__esModule",{value:!0}),s.SerializableEmpty=s.PrintAnnotationStorage=s.AnnotationStorage=void 0;var u=c(1),d=c(4),p=c(8);const v=Object.freeze({map:null,hash:"",transfers:void 0});s.SerializableEmpty=v;class A{constructor(){bt(this,y);bt(this,g,!1);bt(this,x,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(S,w){const _=He(this,x).get(S);return _===void 0?w:Object.assign(w,_)}getRawValue(S){return He(this,x).get(S)}remove(S){if(He(this,x).delete(S),He(this,x).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const w of He(this,x).values())if(w instanceof d.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(S,w){const _=He(this,x).get(S);let I=!1;if(_!==void 0)for(const[$,P]of Object.entries(w))_[$]!==P&&(I=!0,_[$]=P);else I=!0,He(this,x).set(S,w);I&&it(this,y,Su).call(this),w instanceof d.AnnotationEditor&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(w.constructor._type)}has(S){return He(this,x).has(S)}getAll(){return He(this,x).size>0?(0,u.objectFromMap)(He(this,x)):null}setAll(S){for(const[w,_]of Object.entries(S))this.setValue(w,_)}get size(){return He(this,x).size}resetModified(){He(this,g)&&(Ct(this,g,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new b(this)}get serializable(){if(He(this,x).size===0)return v;const S=new Map,w=new p.MurmurHash3_64,_=[],I=Object.create(null);let $=!1;for(const[P,E]of He(this,x)){const R=E instanceof d.AnnotationEditor?E.serialize(!1,I):E;R&&(S.set(P,R),w.update(`${P}:${JSON.stringify(R)}`),$||($=!!R.bitmap))}if($)for(const P of S.values())P.bitmap&&_.push(P.bitmap);return S.size>0?{map:S,hash:w.hexdigest(),transfers:_}:v}}g=new WeakMap,x=new WeakMap,y=new WeakSet,Su=function(){He(this,g)||(Ct(this,g,!0),typeof this.onSetModified=="function"&&this.onSetModified())},s.AnnotationStorage=A;class b extends A{constructor(w){super();bt(this,m);const{map:_,hash:I,transfers:$}=w.serializable,P=structuredClone(_,$?{transfer:$}:null);Ct(this,m,{map:P,hash:I,transfers:$})}get print(){(0,u.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return He(this,m)}}m=new WeakMap,s.PrintAnnotationStorage=b},(a,s,c)=>{var b,g,x,y,f,m,C,S,w,_,I,$,P,E,R,Vs,Qs,M,qs,Ys,$u,_u,Iu,Ks,Pu;Object.defineProperty(s,"__esModule",{value:!0}),s.AnnotationEditor=void 0;var u=c(5),d=c(1),p=c(6);const U=class U{constructor(D){bt(this,R);bt(this,b,"");bt(this,g,!1);bt(this,x,null);bt(this,y,null);bt(this,f,null);bt(this,m,!1);bt(this,C,null);bt(this,S,this.focusin.bind(this));bt(this,w,this.focusout.bind(this));bt(this,_,!1);bt(this,I,!1);bt(this,$,!1);yr(this,"_initialOptions",Object.create(null));yr(this,"_uiManager",null);yr(this,"_focusEventsAllowed",!0);yr(this,"_l10nPromise",null);bt(this,P,!1);bt(this,E,U._zIndex++);this.constructor===U&&(0,d.unreachable)("Cannot initialize AnnotationEditor."),this.parent=D.parent,this.id=D.id,this.width=this.height=null,this.pageIndex=D.parent.pageIndex,this.name=D.name,this.div=null,this._uiManager=D.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=D.isCentered,this._structTreeParentId=null;const{rotation:W,rawDims:{pageWidth:Z,pageHeight:Q,pageX:Y,pageY:J}}=this.parent.viewport;this.rotation=W,this.pageRotation=(360+W-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[Z,Q],this.pageTranslation=[Y,J];const[ee,re]=this.parentDimensions;this.x=D.x/ee,this.y=D.y/re,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return(0,d.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(D){const W=new A({id:D.parent.getNextId(),parent:D.parent,uiManager:D._uiManager});W.annotationElementId=D.annotationElementId,W.deleted=!0,W._uiManager.addToAnnotationStorage(W)}static initialize(D,W=null){if(U._l10nPromise||(U._l10nPromise=new Map(["editor_alt_text_button_label","editor_alt_text_edit_button_label","editor_alt_text_decorative_tooltip"].map(Q=>[Q,D.get(Q)]))),W!=null&&W.strings)for(const Q of W.strings)U._l10nPromise.set(Q,D.get(Q));if(U._borderLineWidth!==-1)return;const Z=getComputedStyle(document.documentElement);U._borderLineWidth=parseFloat(Z.getPropertyValue("--outline-width"))||0}static updateDefaultParams(D,W){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(D){return!1}static paste(D,W){(0,d.unreachable)("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return He(this,P)}set _isDraggable(D){var W;Ct(this,P,D),(W=this.div)==null||W.classList.toggle("draggable",D)}center(){const[D,W]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*W/(D*2),this.y+=this.width*D/(W*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*W/(D*2),this.y-=this.width*D/(W*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(D){this._uiManager.addCommands(D)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=He(this,E)}setParent(D){D!==null&&(this.pageIndex=D.pageIndex,this.pageDimensions=D.pageDimensions),this.parent=D}focusin(D){this._focusEventsAllowed&&(He(this,_)?Ct(this,_,!1):this.parent.setSelected(this))}focusout(D){var Z;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const W=D.relatedTarget;W!=null&&W.closest(`#${this.id}`)||(D.preventDefault(),(Z=this.parent)!=null&&Z.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(D,W,Z,Q){const[Y,J]=this.parentDimensions;[Z,Q]=this.screenToPageTranslation(Z,Q),this.x=(D+Z)/Y,this.y=(W+Q)/J,this.fixAndSetPosition()}translate(D,W){it(this,R,Vs).call(this,this.parentDimensions,D,W)}translateInPage(D,W){it(this,R,Vs).call(this,this.pageDimensions,D,W),this.div.scrollIntoView({block:"nearest"})}drag(D,W){const[Z,Q]=this.parentDimensions;if(this.x+=D/Z,this.y+=W/Q,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:ae,y:V}=this.div.getBoundingClientRect();this.parent.findNewParent(this,ae,V)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:Y,y:J}=this;const[ee,re]=it(this,R,Qs).call(this);Y+=ee,J+=re,this.div.style.left=`${(100*Y).toFixed(2)}%`,this.div.style.top=`${(100*J).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}fixAndSetPosition(){const[D,W]=this.pageDimensions;let{x:Z,y:Q,width:Y,height:J}=this;switch(Y*=D,J*=W,Z*=D,Q*=W,this.rotation){case 0:Z=Math.max(0,Math.min(D-Y,Z)),Q=Math.max(0,Math.min(W-J,Q));break;case 90:Z=Math.max(0,Math.min(D-J,Z)),Q=Math.min(W,Math.max(Y,Q));break;case 180:Z=Math.min(D,Math.max(Y,Z)),Q=Math.min(W,Math.max(J,Q));break;case 270:Z=Math.min(D,Math.max(J,Z)),Q=Math.max(0,Math.min(W-Y,Q));break}this.x=Z/=D,this.y=Q/=W;const[ee,re]=it(this,R,Qs).call(this);Z+=ee,Q+=re;const{style:ae}=this.div;ae.left=`${(100*Z).toFixed(2)}%`,ae.top=`${(100*Q).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(D,W){var Z;return it(Z=U,M,qs).call(Z,D,W,this.parentRotation)}pageTranslationToScreen(D,W){var Z;return it(Z=U,M,qs).call(Z,D,W,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:D,pageDimensions:[W,Z]}=this,Q=W*D,Y=Z*D;return d.FeatureTest.isCSSRoundSupported?[Math.round(Q),Math.round(Y)]:[Q,Y]}setDims(D,W){var Y;const[Z,Q]=this.parentDimensions;this.div.style.width=`${(100*D/Z).toFixed(2)}%`,He(this,m)||(this.div.style.height=`${(100*W/Q).toFixed(2)}%`),(Y=He(this,x))==null||Y.classList.toggle("small",D<U.SMALL_EDITOR_SIZE||W<U.SMALL_EDITOR_SIZE)}fixDims(){const{style:D}=this.div,{height:W,width:Z}=D,Q=Z.endsWith("%"),Y=!He(this,m)&&W.endsWith("%");if(Q&&Y)return;const[J,ee]=this.parentDimensions;Q||(D.width=`${(100*parseFloat(Z)/J).toFixed(2)}%`),!He(this,m)&&!Y&&(D.height=`${(100*parseFloat(W)/ee).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}async addAltTextButton(){if(He(this,x))return;const D=Ct(this,x,document.createElement("button"));D.className="altText";const W=await U._l10nPromise.get("editor_alt_text_button_label");D.textContent=W,D.setAttribute("aria-label",W),D.tabIndex="0",D.addEventListener("contextmenu",p.noContextMenu),D.addEventListener("pointerdown",Z=>Z.stopPropagation()),D.addEventListener("click",Z=>{Z.preventDefault(),this._uiManager.editAltText(this)},{capture:!0}),D.addEventListener("keydown",Z=>{Z.target===D&&Z.key==="Enter"&&(Z.preventDefault(),this._uiManager.editAltText(this))}),it(this,R,Ks).call(this),this.div.append(D),U.SMALL_EDITOR_SIZE||(U.SMALL_EDITOR_SIZE=Math.min(128,Math.round(D.getBoundingClientRect().width*1.4)))}getClientDimensions(){return this.div.getBoundingClientRect()}get altTextData(){return{altText:He(this,b),decorative:He(this,g)}}set altTextData({altText:D,decorative:W}){He(this,b)===D&&He(this,g)===W||(Ct(this,b,D),Ct(this,g,W),it(this,R,Ks).call(this))}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.setAttribute("tabIndex",0),this.setInForeground(),this.div.addEventListener("focusin",He(this,S)),this.div.addEventListener("focusout",He(this,w));const[D,W]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*W/D).toFixed(2)}%`,this.div.style.maxHeight=`${(100*D/W).toFixed(2)}%`);const[Z,Q]=this.getInitialTranslation();return this.translate(Z,Q),(0,u.bindEvents)(this,this.div,["pointerdown"]),this.div}pointerdown(D){const{isMac:W}=d.FeatureTest.platform;if(D.button!==0||D.ctrlKey&&W){D.preventDefault();return}Ct(this,_,!0),it(this,R,Pu).call(this,D)}moveInDOM(){var D;(D=this.parent)==null||D.moveEditorInDOM(this)}_setParentAndPosition(D,W,Z){D.changeParent(this),this.x=W,this.y=Z,this.fixAndSetPosition()}getRect(D,W){const Z=this.parentScale,[Q,Y]=this.pageDimensions,[J,ee]=this.pageTranslation,re=D/Z,ae=W/Z,V=this.x*Q,K=this.y*Y,te=this.width*Q,ie=this.height*Y;switch(this.rotation){case 0:return[V+re+J,Y-K-ae-ie+ee,V+re+te+J,Y-K-ae+ee];case 90:return[V+ae+J,Y-K+re+ee,V+ae+ie+J,Y-K+re+te+ee];case 180:return[V-re-te+J,Y-K+ae+ee,V-re+J,Y-K+ae+ie+ee];case 270:return[V-ae-ie+J,Y-K-re-te+ee,V-ae+J,Y-K-re+ee];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(D,W){const[Z,Q,Y,J]=D,ee=Y-Z,re=J-Q;switch(this.rotation){case 0:return[Z,W-J,ee,re];case 90:return[Z,W-Q,re,ee];case 180:return[Y,W-Q,ee,re];case 270:return[Y,W-J,re,ee];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){Ct(this,$,!0)}disableEditMode(){Ct(this,$,!1)}isInEditMode(){return He(this,$)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var D,W;(D=this.div)==null||D.addEventListener("focusin",He(this,S)),(W=this.div)==null||W.addEventListener("focusout",He(this,w))}serialize(D=!1,W=null){(0,d.unreachable)("An editor must be serializable")}static deserialize(D,W,Z){const Q=new this.prototype.constructor({parent:W,id:W.getNextId(),uiManager:Z});Q.rotation=D.rotation;const[Y,J]=Q.pageDimensions,[ee,re,ae,V]=Q.getRectInCurrentCoords(D.rect,J);return Q.x=ee/Y,Q.y=re/J,Q.width=ae/Y,Q.height=V/J,Q}remove(){var D;this.div.removeEventListener("focusin",He(this,S)),this.div.removeEventListener("focusout",He(this,w)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),(D=He(this,x))==null||D.remove(),Ct(this,x,null),Ct(this,y,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(it(this,R,$u).call(this),He(this,C).classList.remove("hidden"))}select(){var D;this.makeResizable(),(D=this.div)==null||D.classList.add("selectedEditor")}unselect(){var D,W,Z;(D=He(this,C))==null||D.classList.add("hidden"),(W=this.div)==null||W.classList.remove("selectedEditor"),(Z=this.div)!=null&&Z.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus()}updateParams(D,W){}disableEditing(){He(this,x)&&(He(this,x).hidden=!0)}enableEditing(){He(this,x)&&(He(this,x).hidden=!1)}enterInEditMode(){}get contentDiv(){return this.div}get isEditing(){return He(this,I)}set isEditing(D){Ct(this,I,D),this.parent&&(D?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(D,W){Ct(this,m,!0);const Z=D/W,{style:Q}=this.div;Q.aspectRatio=Z,Q.height="auto"}static get MIN_SIZE(){return 16}};b=new WeakMap,g=new WeakMap,x=new WeakMap,y=new WeakMap,f=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakMap,w=new WeakMap,_=new WeakMap,I=new WeakMap,$=new WeakMap,P=new WeakMap,E=new WeakMap,R=new WeakSet,Vs=function([D,W],Z,Q){[Z,Q]=this.screenToPageTranslation(Z,Q),this.x+=Z/D,this.y+=Q/W,this.fixAndSetPosition()},Qs=function(){const[D,W]=this.parentDimensions,{_borderLineWidth:Z}=U,Q=Z/D,Y=Z/W;switch(this.rotation){case 90:return[-Q,Y];case 180:return[Q,Y];case 270:return[Q,-Y];default:return[-Q,-Y]}},M=new WeakSet,qs=function(D,W,Z){switch(Z){case 90:return[W,-D];case 180:return[-D,-W];case 270:return[-W,D];default:return[D,W]}},Ys=function(D){switch(D){case 90:{const[W,Z]=this.pageDimensions;return[0,-W/Z,Z/W,0]}case 180:return[-1,0,0,-1];case 270:{const[W,Z]=this.pageDimensions;return[0,W/Z,-Z/W,0]}default:return[1,0,0,1]}},$u=function(){if(He(this,C))return;Ct(this,C,document.createElement("div")),He(this,C).classList.add("resizers");const D=["topLeft","topRight","bottomRight","bottomLeft"];this._willKeepAspectRatio||D.push("topMiddle","middleRight","bottomMiddle","middleLeft");for(const W of D){const Z=document.createElement("div");He(this,C).append(Z),Z.classList.add("resizer",W),Z.addEventListener("pointerdown",it(this,R,_u).bind(this,W)),Z.addEventListener("contextmenu",p.noContextMenu)}this.div.prepend(He(this,C))},_u=function(D,W){W.preventDefault();const{isMac:Z}=d.FeatureTest.platform;if(W.button!==0||W.ctrlKey&&Z)return;const Q=it(this,R,Iu).bind(this,D),Y=this._isDraggable;this._isDraggable=!1;const J={passive:!0,capture:!0};window.addEventListener("pointermove",Q,J);const ee=this.x,re=this.y,ae=this.width,V=this.height,K=this.parent.div.style.cursor,te=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(W.target).cursor;const ie=()=>{this._isDraggable=Y,window.removeEventListener("pointerup",ie),window.removeEventListener("blur",ie),window.removeEventListener("pointermove",Q,J),this.parent.div.style.cursor=K,this.div.style.cursor=te;const ce=this.x,me=this.y,we=this.width,ve=this.height;ce===ee&&me===re&&we===ae&&ve===V||this.addCommands({cmd:()=>{this.width=we,this.height=ve,this.x=ce,this.y=me;const[ge,ue]=this.parentDimensions;this.setDims(ge*we,ue*ve),this.fixAndSetPosition()},undo:()=>{this.width=ae,this.height=V,this.x=ee,this.y=re;const[ge,ue]=this.parentDimensions;this.setDims(ge*ae,ue*V),this.fixAndSetPosition()},mustExec:!0})};window.addEventListener("pointerup",ie),window.addEventListener("blur",ie)},Iu=function(D,W){const[Z,Q]=this.parentDimensions,Y=this.x,J=this.y,ee=this.width,re=this.height,ae=U.MIN_SIZE/Z,V=U.MIN_SIZE/Q,K=ye=>Math.round(ye*1e4)/1e4,te=it(this,R,Ys).call(this,this.rotation),ie=(ye,Pe)=>[te[0]*ye+te[2]*Pe,te[1]*ye+te[3]*Pe],ce=it(this,R,Ys).call(this,360-this.rotation),me=(ye,Pe)=>[ce[0]*ye+ce[2]*Pe,ce[1]*ye+ce[3]*Pe];let we,ve,ge=!1,ue=!1;switch(D){case"topLeft":ge=!0,we=(ye,Pe)=>[0,0],ve=(ye,Pe)=>[ye,Pe];break;case"topMiddle":we=(ye,Pe)=>[ye/2,0],ve=(ye,Pe)=>[ye/2,Pe];break;case"topRight":ge=!0,we=(ye,Pe)=>[ye,0],ve=(ye,Pe)=>[0,Pe];break;case"middleRight":ue=!0,we=(ye,Pe)=>[ye,Pe/2],ve=(ye,Pe)=>[0,Pe/2];break;case"bottomRight":ge=!0,we=(ye,Pe)=>[ye,Pe],ve=(ye,Pe)=>[0,0];break;case"bottomMiddle":we=(ye,Pe)=>[ye/2,Pe],ve=(ye,Pe)=>[ye/2,0];break;case"bottomLeft":ge=!0,we=(ye,Pe)=>[0,Pe],ve=(ye,Pe)=>[ye,0];break;case"middleLeft":ue=!0,we=(ye,Pe)=>[0,Pe/2],ve=(ye,Pe)=>[ye,Pe/2];break}const se=we(ee,re),oe=ve(ee,re);let de=ie(...oe);const le=K(Y+de[0]),xe=K(J+de[1]);let Ce=1,$e=1,[Se,Ee]=this.screenToPageTranslation(W.movementX,W.movementY);if([Se,Ee]=me(Se/Z,Ee/Q),ge){const ye=Math.hypot(ee,re);Ce=$e=Math.max(Math.min(Math.hypot(oe[0]-se[0]-Se,oe[1]-se[1]-Ee)/ye,1/ee,1/re),ae/ee,V/re)}else ue?Ce=Math.max(ae,Math.min(1,Math.abs(oe[0]-se[0]-Se)))/ee:$e=Math.max(V,Math.min(1,Math.abs(oe[1]-se[1]-Ee)))/re;const Ae=K(ee*Ce),pe=K(re*$e);de=ie(...ve(Ae,pe));const he=le-de[0],Ie=xe-de[1];this.width=Ae,this.height=pe,this.x=he,this.y=Ie,this.setDims(Z*Ae,Q*pe),this.fixAndSetPosition()},Ks=async function(){var Z;const D=He(this,x);if(!D)return;if(!He(this,b)&&!He(this,g)){D.classList.remove("done"),(Z=He(this,y))==null||Z.remove();return}U._l10nPromise.get("editor_alt_text_edit_button_label").then(Q=>{D.setAttribute("aria-label",Q)});let W=He(this,y);if(!W){Ct(this,y,W=document.createElement("span")),W.className="tooltip",W.setAttribute("role","tooltip");const Q=W.id=`alt-text-tooltip-${this.id}`;D.setAttribute("aria-describedby",Q);const Y=100;D.addEventListener("mouseenter",()=>{Ct(this,f,setTimeout(()=>{Ct(this,f,null),He(this,y).classList.add("show"),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",subtype:this.editorType,data:{action:"alt_text_tooltip"}}})},Y))}),D.addEventListener("mouseleave",()=>{var J;clearTimeout(He(this,f)),Ct(this,f,null),(J=He(this,y))==null||J.classList.remove("show")})}D.classList.add("done"),W.innerText=He(this,g)?await U._l10nPromise.get("editor_alt_text_decorative_tooltip"):He(this,b),W.parentNode||D.append(W)},Pu=function(D){if(!this._isDraggable)return;const W=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let Z,Q;W&&(Z={passive:!0,capture:!0},Q=J=>{const[ee,re]=this.screenToPageTranslation(J.movementX,J.movementY);this._uiManager.dragSelectedEditors(ee,re)},window.addEventListener("pointermove",Q,Z));const Y=()=>{if(window.removeEventListener("pointerup",Y),window.removeEventListener("blur",Y),W&&window.removeEventListener("pointermove",Q,Z),Ct(this,_,!1),!this._uiManager.endDragSession()){const{isMac:J}=d.FeatureTest.platform;D.ctrlKey&&!J||D.shiftKey||D.metaKey&&J?this.parent.toggleSelected(this):this.parent.setSelected(this)}};window.addEventListener("pointerup",Y),window.addEventListener("blur",Y)},bt(U,M),yr(U,"_borderLineWidth",-1),yr(U,"_colorManager",new u.ColorManager),yr(U,"_zIndex",1),yr(U,"SMALL_EDITOR_SIZE",0);let v=U;s.AnnotationEditor=v;class A extends v{constructor(D){super(D),this.annotationElementId=D.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}},(a,s,c)=>{var m,C,S,w,_,Xs,P,E,R,T,B,Tu,O,H,j,q,L,F,U,N,D,W,Z,Q,Y,J,ee,re,ae,V,K,te,ie,ce,me,we,ve,ge,ue,se,oe,de,le,xe,Ce,$e,Se,Ru,Zs,Js,mo,el,tl,_n,pi,Bu,Mu,rl,gi,nl;Object.defineProperty(s,"__esModule",{value:!0}),s.KeyboardManager=s.CommandManager=s.ColorManager=s.AnnotationEditorUIManager=void 0,s.bindEvents=p,s.opacityToHex=v;var u=c(1),d=c(6);function p(Te,ke,De){for(const Re of De)ke.addEventListener(Re,Te[Re].bind(Te))}function v(Te){return Math.round(Math.min(255,Math.max(1,255*Te))).toString(16).padStart(2,"0")}class A{constructor(){bt(this,m,0)}getId(){return`${u.AnnotationEditorPrefix}${hi(this,m)._++}`}}m=new WeakMap;const $=class ${constructor(){bt(this,_);bt(this,C,(0,u.getUuid)());bt(this,S,0);bt(this,w,null)}static get _isSVGFittingCanvas(){const ke='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',Re=new OffscreenCanvas(1,3).getContext("2d"),Ge=new Image;Ge.src=ke;const Ve=Ge.decode().then(()=>(Re.drawImage(Ge,0,0,1,1,0,0,1,3),new Uint32Array(Re.getImageData(0,0,1,1).data.buffer)[0]===0));return(0,u.shadow)(this,"_isSVGFittingCanvas",Ve)}async getFromFile(ke){const{lastModified:De,name:Re,size:Ge,type:Ve}=ke;return it(this,_,Xs).call(this,`${De}_${Re}_${Ge}_${Ve}`,ke)}async getFromUrl(ke){return it(this,_,Xs).call(this,ke,ke)}async getFromId(ke){He(this,w)||Ct(this,w,new Map);const De=He(this,w).get(ke);return De?De.bitmap?(De.refCounter+=1,De):De.file?this.getFromFile(De.file):this.getFromUrl(De.url):null}getSvgUrl(ke){const De=He(this,w).get(ke);return De!=null&&De.isSvg?De.svgUrl:null}deleteId(ke){He(this,w)||Ct(this,w,new Map);const De=He(this,w).get(ke);De&&(De.refCounter-=1,De.refCounter===0&&(De.bitmap=null))}isValidId(ke){return ke.startsWith(`image_${He(this,C)}_`)}};C=new WeakMap,S=new WeakMap,w=new WeakMap,_=new WeakSet,Xs=async function(ke,De){He(this,w)||Ct(this,w,new Map);let Re=He(this,w).get(ke);if(Re===null)return null;if(Re!=null&&Re.bitmap)return Re.refCounter+=1,Re;try{Re||(Re={bitmap:null,id:`image_${He(this,C)}_${hi(this,S)._++}`,refCounter:0,isSvg:!1});let Ge;if(typeof De=="string"){Re.url=De;const Ve=await fetch(De);if(!Ve.ok)throw new Error(Ve.statusText);Ge=await Ve.blob()}else Ge=Re.file=De;if(Ge.type==="image/svg+xml"){const Ve=$._isSVGFittingCanvas,Xe=new FileReader,We=new Image,ze=new Promise((Qe,et)=>{We.onload=()=>{Re.bitmap=We,Re.isSvg=!0,Qe()},Xe.onload=async()=>{const Ze=Re.svgUrl=Xe.result;We.src=await Ve?`${Ze}#svgView(preserveAspectRatio(none))`:Ze},We.onerror=Xe.onerror=et});Xe.readAsDataURL(Ge),await ze}else Re.bitmap=await createImageBitmap(Ge);Re.refCounter=1}catch(Ge){console.error(Ge),Re=null}return He(this,w).set(ke,Re),Re&&He(this,w).set(Re.id,Re),Re};let b=$;class g{constructor(ke=128){bt(this,P,[]);bt(this,E,!1);bt(this,R);bt(this,T,-1);Ct(this,R,ke)}add({cmd:ke,undo:De,mustExec:Re,type:Ge=NaN,overwriteIfSameType:Ve=!1,keepUndo:Xe=!1}){if(Re&&ke(),He(this,E))return;const We={cmd:ke,undo:De,type:Ge};if(He(this,T)===-1){He(this,P).length>0&&(He(this,P).length=0),Ct(this,T,0),He(this,P).push(We);return}if(Ve&&He(this,P)[He(this,T)].type===Ge){Xe&&(We.undo=He(this,P)[He(this,T)].undo),He(this,P)[He(this,T)]=We;return}const ze=He(this,T)+1;ze===He(this,R)?He(this,P).splice(0,1):(Ct(this,T,ze),ze<He(this,P).length&&He(this,P).splice(ze)),He(this,P).push(We)}undo(){He(this,T)!==-1&&(Ct(this,E,!0),He(this,P)[He(this,T)].undo(),Ct(this,E,!1),Ct(this,T,He(this,T)-1))}redo(){He(this,T)<He(this,P).length-1&&(Ct(this,T,He(this,T)+1),Ct(this,E,!0),He(this,P)[He(this,T)].cmd(),Ct(this,E,!1))}hasSomethingToUndo(){return He(this,T)!==-1}hasSomethingToRedo(){return He(this,T)<He(this,P).length-1}destroy(){Ct(this,P,null)}}P=new WeakMap,E=new WeakMap,R=new WeakMap,T=new WeakMap,s.CommandManager=g;class x{constructor(ke){bt(this,B);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:De}=u.FeatureTest.platform;for(const[Re,Ge,Ve={}]of ke)for(const Xe of Re){const We=Xe.startsWith("mac+");De&&We?(this.callbacks.set(Xe.slice(4),{callback:Ge,options:Ve}),this.allKeys.add(Xe.split("+").at(-1))):!De&&!We&&(this.callbacks.set(Xe,{callback:Ge,options:Ve}),this.allKeys.add(Xe.split("+").at(-1)))}}exec(ke,De){if(!this.allKeys.has(De.key))return;const Re=this.callbacks.get(it(this,B,Tu).call(this,De));if(!Re)return;const{callback:Ge,options:{bubbles:Ve=!1,args:Xe=[],checker:We=null}}=Re;We&&!We(ke,De)||(Ge.bind(ke,...Xe)(),Ve||(De.stopPropagation(),De.preventDefault()))}}B=new WeakSet,Tu=function(ke){ke.altKey&&this.buffer.push("alt"),ke.ctrlKey&&this.buffer.push("ctrl"),ke.metaKey&&this.buffer.push("meta"),ke.shiftKey&&this.buffer.push("shift"),this.buffer.push(ke.key);const De=this.buffer.join("+");return this.buffer.length=0,De},s.KeyboardManager=x;const k=class k{get _colors(){const ke=new Map([["CanvasText",null],["Canvas",null]]);return(0,d.getColorValues)(ke),(0,u.shadow)(this,"_colors",ke)}convert(ke){const De=(0,d.getRGB)(ke);if(!window.matchMedia("(forced-colors: active)").matches)return De;for(const[Re,Ge]of this._colors)if(Ge.every((Ve,Xe)=>Ve===De[Xe]))return k._colorsMapping.get(Re);return De}getHexCode(ke){const De=this._colors.get(ke);return De?u.Util.makeHexColor(...De):ke}};yr(k,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let y=k;s.ColorManager=y;const Ye=class Ye{constructor(ke,De,Re,Ge,Ve,Xe){bt(this,Se);bt(this,O,null);bt(this,H,new Map);bt(this,j,new Map);bt(this,q,null);bt(this,L,null);bt(this,F,new g);bt(this,U,0);bt(this,N,new Set);bt(this,D,null);bt(this,W,null);bt(this,Z,new Set);bt(this,Q,null);bt(this,Y,new A);bt(this,J,!1);bt(this,ee,!1);bt(this,re,null);bt(this,ae,u.AnnotationEditorType.NONE);bt(this,V,new Set);bt(this,K,null);bt(this,te,this.blur.bind(this));bt(this,ie,this.focus.bind(this));bt(this,ce,this.copy.bind(this));bt(this,me,this.cut.bind(this));bt(this,we,this.paste.bind(this));bt(this,ve,this.keydown.bind(this));bt(this,ge,this.onEditingAction.bind(this));bt(this,ue,this.onPageChanging.bind(this));bt(this,se,this.onScaleChanging.bind(this));bt(this,oe,this.onRotationChanging.bind(this));bt(this,de,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1});bt(this,le,[0,0]);bt(this,xe,null);bt(this,Ce,null);bt(this,$e,null);Ct(this,Ce,ke),Ct(this,$e,De),Ct(this,q,Re),this._eventBus=Ge,this._eventBus._on("editingaction",He(this,ge)),this._eventBus._on("pagechanging",He(this,ue)),this._eventBus._on("scalechanging",He(this,se)),this._eventBus._on("rotationchanging",He(this,oe)),Ct(this,L,Ve.annotationStorage),Ct(this,Q,Ve.filterFactory),Ct(this,K,Xe),this.viewParameters={realScale:d.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}static get _keyboardManager(){const ke=Ye.prototype,De=Ve=>{const{activeElement:Xe}=document;return Xe&&He(Ve,Ce).contains(Xe)&&Ve.hasSomethingToControl()},Re=this.TRANSLATE_SMALL,Ge=this.TRANSLATE_BIG;return(0,u.shadow)(this,"_keyboardManager",new x([[["ctrl+a","mac+meta+a"],ke.selectAll],[["ctrl+z","mac+meta+z"],ke.undo],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],ke.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],ke.delete],[["Escape","mac+Escape"],ke.unselectAll],[["ArrowLeft","mac+ArrowLeft"],ke.translateSelectedEditors,{args:[-Re,0],checker:De}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],ke.translateSelectedEditors,{args:[-Ge,0],checker:De}],[["ArrowRight","mac+ArrowRight"],ke.translateSelectedEditors,{args:[Re,0],checker:De}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],ke.translateSelectedEditors,{args:[Ge,0],checker:De}],[["ArrowUp","mac+ArrowUp"],ke.translateSelectedEditors,{args:[0,-Re],checker:De}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],ke.translateSelectedEditors,{args:[0,-Ge],checker:De}],[["ArrowDown","mac+ArrowDown"],ke.translateSelectedEditors,{args:[0,Re],checker:De}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],ke.translateSelectedEditors,{args:[0,Ge],checker:De}]]))}destroy(){it(this,Se,mo).call(this),it(this,Se,Zs).call(this),this._eventBus._off("editingaction",He(this,ge)),this._eventBus._off("pagechanging",He(this,ue)),this._eventBus._off("scalechanging",He(this,se)),this._eventBus._off("rotationchanging",He(this,oe));for(const ke of He(this,j).values())ke.destroy();He(this,j).clear(),He(this,H).clear(),He(this,Z).clear(),Ct(this,O,null),He(this,V).clear(),He(this,F).destroy(),He(this,q).destroy()}get hcmFilter(){return(0,u.shadow)(this,"hcmFilter",He(this,K)?He(this,Q).addHCMFilter(He(this,K).foreground,He(this,K).background):"none")}get direction(){return(0,u.shadow)(this,"direction",getComputedStyle(He(this,Ce)).direction)}editAltText(ke){var De;(De=He(this,q))==null||De.editAltText(this,ke)}onPageChanging({pageNumber:ke}){Ct(this,U,ke-1)}focusMainContainer(){He(this,Ce).focus()}findParent(ke,De){for(const Re of He(this,j).values()){const{x:Ge,y:Ve,width:Xe,height:We}=Re.div.getBoundingClientRect();if(ke>=Ge&&ke<=Ge+Xe&&De>=Ve&&De<=Ve+We)return Re}return null}disableUserSelect(ke=!1){He(this,$e).classList.toggle("noUserSelect",ke)}addShouldRescale(ke){He(this,Z).add(ke)}removeShouldRescale(ke){He(this,Z).delete(ke)}onScaleChanging({scale:ke}){this.commitOrRemove(),this.viewParameters.realScale=ke*d.PixelsPerInch.PDF_TO_CSS_UNITS;for(const De of He(this,Z))De.onScaleChanging()}onRotationChanging({pagesRotation:ke}){this.commitOrRemove(),this.viewParameters.rotation=ke}addToAnnotationStorage(ke){!ke.isEmpty()&&He(this,L)&&!He(this,L).has(ke.id)&&He(this,L).setValue(ke.id,ke)}blur(){if(!this.hasSelection)return;const{activeElement:ke}=document;for(const De of He(this,V))if(De.div.contains(ke)){Ct(this,re,[De,ke]),De._focusEventsAllowed=!1;break}}focus(){if(!He(this,re))return;const[ke,De]=He(this,re);Ct(this,re,null),De.addEventListener("focusin",()=>{ke._focusEventsAllowed=!0},{once:!0}),De.focus()}addEditListeners(){it(this,Se,Js).call(this),it(this,Se,el).call(this)}removeEditListeners(){it(this,Se,mo).call(this),it(this,Se,tl).call(this)}copy(ke){var Re;if(ke.preventDefault(),(Re=He(this,O))==null||Re.commitOrRemove(),!this.hasSelection)return;const De=[];for(const Ge of He(this,V)){const Ve=Ge.serialize(!0);Ve&&De.push(Ve)}De.length!==0&&ke.clipboardData.setData("application/pdfjs",JSON.stringify(De))}cut(ke){this.copy(ke),this.delete()}paste(ke){ke.preventDefault();const{clipboardData:De}=ke;for(const Ve of De.items)for(const Xe of He(this,W))if(Xe.isHandlingMimeForPasting(Ve.type)){Xe.paste(Ve,this.currentLayer);return}let Re=De.getData("application/pdfjs");if(!Re)return;try{Re=JSON.parse(Re)}catch(Ve){(0,u.warn)(`paste: "${Ve.message}".`);return}if(!Array.isArray(Re))return;this.unselectAll();const Ge=this.currentLayer;try{const Ve=[];for(const ze of Re){const Qe=Ge.deserialize(ze);if(!Qe)return;Ve.push(Qe)}const Xe=()=>{for(const ze of Ve)it(this,Se,rl).call(this,ze);it(this,Se,nl).call(this,Ve)},We=()=>{for(const ze of Ve)ze.remove()};this.addCommands({cmd:Xe,undo:We,mustExec:!0})}catch(Ve){(0,u.warn)(`paste: "${Ve.message}".`)}}keydown(ke){var De;(De=this.getActive())!=null&&De.shouldGetKeyboardEvents()||Ye._keyboardManager.exec(this,ke)}onEditingAction(ke){["undo","redo","delete","selectAll"].includes(ke.name)&&this[ke.name]()}setEditingState(ke){ke?(it(this,Se,Ru).call(this),it(this,Se,Js).call(this),it(this,Se,el).call(this),it(this,Se,_n).call(this,{isEditing:He(this,ae)!==u.AnnotationEditorType.NONE,isEmpty:it(this,Se,gi).call(this),hasSomethingToUndo:He(this,F).hasSomethingToUndo(),hasSomethingToRedo:He(this,F).hasSomethingToRedo(),hasSelectedEditor:!1})):(it(this,Se,Zs).call(this),it(this,Se,mo).call(this),it(this,Se,tl).call(this),it(this,Se,_n).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(ke){if(!He(this,W)){Ct(this,W,ke);for(const De of He(this,W))it(this,Se,pi).call(this,De.defaultPropertiesToUpdate)}}getId(){return He(this,Y).getId()}get currentLayer(){return He(this,j).get(He(this,U))}getLayer(ke){return He(this,j).get(ke)}get currentPageIndex(){return He(this,U)}addLayer(ke){He(this,j).set(ke.pageIndex,ke),He(this,J)?ke.enable():ke.disable()}removeLayer(ke){He(this,j).delete(ke.pageIndex)}updateMode(ke,De=null){if(He(this,ae)!==ke){if(Ct(this,ae,ke),ke===u.AnnotationEditorType.NONE){this.setEditingState(!1),it(this,Se,Mu).call(this);return}this.setEditingState(!0),it(this,Se,Bu).call(this),this.unselectAll();for(const Re of He(this,j).values())Re.updateMode(ke);if(De){for(const Re of He(this,H).values())if(Re.annotationElementId===De){this.setSelected(Re),Re.enterInEditMode();break}}}}updateToolbar(ke){ke!==He(this,ae)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:ke})}updateParams(ke,De){if(He(this,W)){if(ke===u.AnnotationEditorParamsType.CREATE){this.currentLayer.addNewEditor(ke);return}for(const Re of He(this,V))Re.updateParams(ke,De);for(const Re of He(this,W))Re.updateDefaultParams(ke,De)}}enableWaiting(ke=!1){if(He(this,ee)!==ke){Ct(this,ee,ke);for(const De of He(this,j).values())ke?De.disableClick():De.enableClick(),De.div.classList.toggle("waiting",ke)}}getEditors(ke){const De=[];for(const Re of He(this,H).values())Re.pageIndex===ke&&De.push(Re);return De}getEditor(ke){return He(this,H).get(ke)}addEditor(ke){He(this,H).set(ke.id,ke)}removeEditor(ke){var De;He(this,H).delete(ke.id),this.unselect(ke),(!ke.annotationElementId||!He(this,N).has(ke.annotationElementId))&&((De=He(this,L))==null||De.remove(ke.id))}addDeletedAnnotationElement(ke){He(this,N).add(ke.annotationElementId),ke.deleted=!0}isDeletedAnnotationElement(ke){return He(this,N).has(ke)}removeDeletedAnnotationElement(ke){He(this,N).delete(ke.annotationElementId),ke.deleted=!1}setActiveEditor(ke){He(this,O)!==ke&&(Ct(this,O,ke),ke&&it(this,Se,pi).call(this,ke.propertiesToUpdate))}toggleSelected(ke){if(He(this,V).has(ke)){He(this,V).delete(ke),ke.unselect(),it(this,Se,_n).call(this,{hasSelectedEditor:this.hasSelection});return}He(this,V).add(ke),ke.select(),it(this,Se,pi).call(this,ke.propertiesToUpdate),it(this,Se,_n).call(this,{hasSelectedEditor:!0})}setSelected(ke){for(const De of He(this,V))De!==ke&&De.unselect();He(this,V).clear(),He(this,V).add(ke),ke.select(),it(this,Se,pi).call(this,ke.propertiesToUpdate),it(this,Se,_n).call(this,{hasSelectedEditor:!0})}isSelected(ke){return He(this,V).has(ke)}unselect(ke){ke.unselect(),He(this,V).delete(ke),it(this,Se,_n).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return He(this,V).size!==0}undo(){He(this,F).undo(),it(this,Se,_n).call(this,{hasSomethingToUndo:He(this,F).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:it(this,Se,gi).call(this)})}redo(){He(this,F).redo(),it(this,Se,_n).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:He(this,F).hasSomethingToRedo(),isEmpty:it(this,Se,gi).call(this)})}addCommands(ke){He(this,F).add(ke),it(this,Se,_n).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:it(this,Se,gi).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const ke=[...He(this,V)],De=()=>{for(const Ge of ke)Ge.remove()},Re=()=>{for(const Ge of ke)it(this,Se,rl).call(this,Ge)};this.addCommands({cmd:De,undo:Re,mustExec:!0})}commitOrRemove(){var ke;(ke=He(this,O))==null||ke.commitOrRemove()}hasSomethingToControl(){return He(this,O)||this.hasSelection}selectAll(){for(const ke of He(this,V))ke.commit();it(this,Se,nl).call(this,He(this,H).values())}unselectAll(){if(He(this,O)){He(this,O).commitOrRemove();return}if(this.hasSelection){for(const ke of He(this,V))ke.unselect();He(this,V).clear(),it(this,Se,_n).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(ke,De,Re=!1){if(Re||this.commitOrRemove(),!this.hasSelection)return;He(this,le)[0]+=ke,He(this,le)[1]+=De;const[Ge,Ve]=He(this,le),Xe=[...He(this,V)],We=1e3;He(this,xe)&&clearTimeout(He(this,xe)),Ct(this,xe,setTimeout(()=>{Ct(this,xe,null),He(this,le)[0]=He(this,le)[1]=0,this.addCommands({cmd:()=>{for(const ze of Xe)He(this,H).has(ze.id)&&ze.translateInPage(Ge,Ve)},undo:()=>{for(const ze of Xe)He(this,H).has(ze.id)&&ze.translateInPage(-Ge,-Ve)},mustExec:!1})},We));for(const ze of Xe)ze.translateInPage(ke,De)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),Ct(this,D,new Map);for(const ke of He(this,V))He(this,D).set(ke,{savedX:ke.x,savedY:ke.y,savedPageIndex:ke.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!He(this,D))return!1;this.disableUserSelect(!1);const ke=He(this,D);Ct(this,D,null);let De=!1;for(const[{x:Ge,y:Ve,pageIndex:Xe},We]of ke)We.newX=Ge,We.newY=Ve,We.newPageIndex=Xe,De||(De=Ge!==We.savedX||Ve!==We.savedY||Xe!==We.savedPageIndex);if(!De)return!1;const Re=(Ge,Ve,Xe,We)=>{if(He(this,H).has(Ge.id)){const ze=He(this,j).get(We);ze?Ge._setParentAndPosition(ze,Ve,Xe):(Ge.pageIndex=We,Ge.x=Ve,Ge.y=Xe)}};return this.addCommands({cmd:()=>{for(const[Ge,{newX:Ve,newY:Xe,newPageIndex:We}]of ke)Re(Ge,Ve,Xe,We)},undo:()=>{for(const[Ge,{savedX:Ve,savedY:Xe,savedPageIndex:We}]of ke)Re(Ge,Ve,Xe,We)},mustExec:!0}),!0}dragSelectedEditors(ke,De){if(He(this,D))for(const Re of He(this,D).keys())Re.drag(ke,De)}rebuild(ke){if(ke.parent===null){const De=this.getLayer(ke.pageIndex);De?(De.changeParent(ke),De.addOrRebuild(ke)):(this.addEditor(ke),this.addToAnnotationStorage(ke),ke.rebuild())}else ke.parent.addOrRebuild(ke)}isActive(ke){return He(this,O)===ke}getActive(){return He(this,O)}getMode(){return He(this,ae)}get imageManager(){return(0,u.shadow)(this,"imageManager",new b)}};O=new WeakMap,H=new WeakMap,j=new WeakMap,q=new WeakMap,L=new WeakMap,F=new WeakMap,U=new WeakMap,N=new WeakMap,D=new WeakMap,W=new WeakMap,Z=new WeakMap,Q=new WeakMap,Y=new WeakMap,J=new WeakMap,ee=new WeakMap,re=new WeakMap,ae=new WeakMap,V=new WeakMap,K=new WeakMap,te=new WeakMap,ie=new WeakMap,ce=new WeakMap,me=new WeakMap,we=new WeakMap,ve=new WeakMap,ge=new WeakMap,ue=new WeakMap,se=new WeakMap,oe=new WeakMap,de=new WeakMap,le=new WeakMap,xe=new WeakMap,Ce=new WeakMap,$e=new WeakMap,Se=new WeakSet,Ru=function(){window.addEventListener("focus",He(this,ie)),window.addEventListener("blur",He(this,te))},Zs=function(){window.removeEventListener("focus",He(this,ie)),window.removeEventListener("blur",He(this,te))},Js=function(){window.addEventListener("keydown",He(this,ve),{capture:!0})},mo=function(){window.removeEventListener("keydown",He(this,ve),{capture:!0})},el=function(){document.addEventListener("copy",He(this,ce)),document.addEventListener("cut",He(this,me)),document.addEventListener("paste",He(this,we))},tl=function(){document.removeEventListener("copy",He(this,ce)),document.removeEventListener("cut",He(this,me)),document.removeEventListener("paste",He(this,we))},_n=function(ke){Object.entries(ke).some(([Re,Ge])=>He(this,de)[Re]!==Ge)&&this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(He(this,de),ke)})},pi=function(ke){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:ke})},Bu=function(){if(!He(this,J)){Ct(this,J,!0);for(const ke of He(this,j).values())ke.enable()}},Mu=function(){if(this.unselectAll(),He(this,J)){Ct(this,J,!1);for(const ke of He(this,j).values())ke.disable()}},rl=function(ke){const De=He(this,j).get(ke.pageIndex);De?De.addOrRebuild(ke):this.addEditor(ke)},gi=function(){if(He(this,H).size===0)return!0;if(He(this,H).size===1)for(const ke of He(this,H).values())return ke.isEmpty();return!1},nl=function(ke){He(this,V).clear();for(const De of ke)De.isEmpty()||(He(this,V).add(De),De.select());it(this,Se,_n).call(this,{hasSelectedEditor:!0})},yr(Ye,"TRANSLATE_SMALL",1),yr(Ye,"TRANSLATE_BIG",10);let f=Ye;s.AnnotationEditorUIManager=f},(a,s,c)=>{var U,N,D,W,Z,Q,Y,J,ee,re,ae,V,Fa,Na,al,Ao,vo,mi,Ai;Object.defineProperty(s,"__esModule",{value:!0}),s.StatTimer=s.RenderingCancelledException=s.PixelsPerInch=s.PageViewport=s.PDFDateString=s.DOMStandardFontDataFactory=s.DOMSVGFactory=s.DOMFilterFactory=s.DOMCanvasFactory=s.DOMCMapReaderFactory=void 0,s.deprecated=T,s.getColorValues=H,s.getCurrentTransform=j,s.getCurrentTransformInverse=q,s.getFilenameFromUrl=_,s.getPdfFilenameFromUrl=I,s.getRGB=O,s.getXfaPageViewport=k,s.isDataScheme=S,s.isPdfFile=w,s.isValidFetchUrl=P,s.loadScript=R,s.noContextMenu=E,s.setLayerDimensions=L;var u=c(7),d=c(1);const p="http://www.w3.org/2000/svg",F=class F{};yr(F,"CSS",96),yr(F,"PDF",72),yr(F,"PDF_TO_CSS_UNITS",F.CSS/F.PDF);let v=F;s.PixelsPerInch=v;class A extends u.BaseFilterFactory{constructor({docId:se,ownerDocument:oe=globalThis.document}={}){super();bt(this,V);bt(this,U);bt(this,N);bt(this,D);bt(this,W);bt(this,Z);bt(this,Q);bt(this,Y);bt(this,J);bt(this,ee);bt(this,re);bt(this,ae,0);Ct(this,D,se),Ct(this,W,oe)}addFilter(se){if(!se)return"none";let oe=He(this,V,Fa).get(se);if(oe)return oe;let de,le,xe,Ce;if(se.length===1){const Ae=se[0],pe=new Array(256);for(let he=0;he<256;he++)pe[he]=Ae[he]/255;Ce=de=le=xe=pe.join(",")}else{const[Ae,pe,he]=se,Ie=new Array(256),ye=new Array(256),Pe=new Array(256);for(let Ne=0;Ne<256;Ne++)Ie[Ne]=Ae[Ne]/255,ye[Ne]=pe[Ne]/255,Pe[Ne]=he[Ne]/255;de=Ie.join(","),le=ye.join(","),xe=Pe.join(","),Ce=`${de}${le}${xe}`}if(oe=He(this,V,Fa).get(Ce),oe)return He(this,V,Fa).set(se,oe),oe;const $e=`g_${He(this,D)}_transfer_map_${hi(this,ae)._++}`,Se=`url(#${$e})`;He(this,V,Fa).set(se,Se),He(this,V,Fa).set(Ce,Se);const Ee=it(this,V,Ao).call(this,$e);return it(this,V,mi).call(this,de,le,xe,Ee),Se}addHCMFilter(se,oe){var pe;const de=`${se}-${oe}`;if(He(this,Q)===de)return He(this,Y);if(Ct(this,Q,de),Ct(this,Y,"none"),(pe=He(this,Z))==null||pe.remove(),!se||!oe)return He(this,Y);const le=it(this,V,Ai).call(this,se);se=d.Util.makeHexColor(...le);const xe=it(this,V,Ai).call(this,oe);if(oe=d.Util.makeHexColor(...xe),He(this,V,Na).style.color="",se==="#000000"&&oe==="#ffffff"||se===oe)return He(this,Y);const Ce=new Array(256);for(let he=0;he<=255;he++){const Ie=he/255;Ce[he]=Ie<=.03928?Ie/12.92:((Ie+.055)/1.055)**2.4}const $e=Ce.join(","),Se=`g_${He(this,D)}_hcm_filter`,Ee=Ct(this,J,it(this,V,Ao).call(this,Se));it(this,V,mi).call(this,$e,$e,$e,Ee),it(this,V,al).call(this,Ee);const Ae=(he,Ie)=>{const ye=le[he]/255,Pe=xe[he]/255,Ne=new Array(Ie+1);for(let Le=0;Le<=Ie;Le++)Ne[Le]=ye+Le/Ie*(Pe-ye);return Ne.join(",")};return it(this,V,mi).call(this,Ae(0,5),Ae(1,5),Ae(2,5),Ee),Ct(this,Y,`url(#${Se})`),He(this,Y)}addHighlightHCMFilter(se,oe,de,le){var Pe;const xe=`${se}-${oe}-${de}-${le}`;if(He(this,ee)===xe)return He(this,re);if(Ct(this,ee,xe),Ct(this,re,"none"),(Pe=He(this,J))==null||Pe.remove(),!se||!oe)return He(this,re);const[Ce,$e]=[se,oe].map(it(this,V,Ai).bind(this));let Se=Math.round(.2126*Ce[0]+.7152*Ce[1]+.0722*Ce[2]),Ee=Math.round(.2126*$e[0]+.7152*$e[1]+.0722*$e[2]),[Ae,pe]=[de,le].map(it(this,V,Ai).bind(this));Ee<Se&&([Se,Ee,Ae,pe]=[Ee,Se,pe,Ae]),He(this,V,Na).style.color="";const he=(Ne,Le,Oe)=>{const Fe=new Array(256),_e=(Ee-Se)/Oe,je=Ne/255,Ye=(Le-Ne)/(255*Oe);let Te=0;for(let ke=0;ke<=Oe;ke++){const De=Math.round(Se+ke*_e),Re=je+ke*Ye;for(let Ge=Te;Ge<=De;Ge++)Fe[Ge]=Re;Te=De+1}for(let ke=Te;ke<256;ke++)Fe[ke]=Fe[Te-1];return Fe.join(",")},Ie=`g_${He(this,D)}_hcm_highlight_filter`,ye=Ct(this,J,it(this,V,Ao).call(this,Ie));return it(this,V,al).call(this,ye),it(this,V,mi).call(this,he(Ae[0],pe[0],5),he(Ae[1],pe[1],5),he(Ae[2],pe[2],5),ye),Ct(this,re,`url(#${Ie})`),He(this,re)}destroy(se=!1){se&&(He(this,Y)||He(this,re))||(He(this,N)&&(He(this,N).parentNode.parentNode.remove(),Ct(this,N,null)),He(this,U)&&(He(this,U).clear(),Ct(this,U,null)),Ct(this,ae,0))}}U=new WeakMap,N=new WeakMap,D=new WeakMap,W=new WeakMap,Z=new WeakMap,Q=new WeakMap,Y=new WeakMap,J=new WeakMap,ee=new WeakMap,re=new WeakMap,ae=new WeakMap,V=new WeakSet,Fa=function(){return He(this,U)||Ct(this,U,new Map)},Na=function(){if(!He(this,N)){const se=He(this,W).createElement("div"),{style:oe}=se;oe.visibility="hidden",oe.contain="strict",oe.width=oe.height=0,oe.position="absolute",oe.top=oe.left=0,oe.zIndex=-1;const de=He(this,W).createElementNS(p,"svg");de.setAttribute("width",0),de.setAttribute("height",0),Ct(this,N,He(this,W).createElementNS(p,"defs")),se.append(de),de.append(He(this,N)),He(this,W).body.append(se)}return He(this,N)},al=function(se){const oe=He(this,W).createElementNS(p,"feColorMatrix");oe.setAttribute("type","matrix"),oe.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"),se.append(oe)},Ao=function(se){const oe=He(this,W).createElementNS(p,"filter");return oe.setAttribute("color-interpolation-filters","sRGB"),oe.setAttribute("id",se),He(this,V,Na).append(oe),oe},vo=function(se,oe,de){const le=He(this,W).createElementNS(p,oe);le.setAttribute("type","discrete"),le.setAttribute("tableValues",de),se.append(le)},mi=function(se,oe,de,le){const xe=He(this,W).createElementNS(p,"feComponentTransfer");le.append(xe),it(this,V,vo).call(this,xe,"feFuncR",se),it(this,V,vo).call(this,xe,"feFuncG",oe),it(this,V,vo).call(this,xe,"feFuncB",de)},Ai=function(se){return He(this,V,Na).style.color=se,O(getComputedStyle(He(this,V,Na)).getPropertyValue("color"))},s.DOMFilterFactory=A;class b extends u.BaseCanvasFactory{constructor({ownerDocument:ue=globalThis.document}={}){super(),this._document=ue}_createCanvas(ue,se){const oe=this._document.createElement("canvas");return oe.width=ue,oe.height=se,oe}}s.DOMCanvasFactory=b;async function g(ge,ue=!1){if(P(ge,document.baseURI)){const se=await fetch(ge);if(!se.ok)throw new Error(se.statusText);return ue?new Uint8Array(await se.arrayBuffer()):(0,d.stringToBytes)(await se.text())}return new Promise((se,oe)=>{const de=new XMLHttpRequest;de.open("GET",ge,!0),ue&&(de.responseType="arraybuffer"),de.onreadystatechange=()=>{if(de.readyState===XMLHttpRequest.DONE){if(de.status===200||de.status===0){let le;if(ue&&de.response?le=new Uint8Array(de.response):!ue&&de.responseText&&(le=(0,d.stringToBytes)(de.responseText)),le){se(le);return}}oe(new Error(de.statusText))}},de.send(null)})}class x extends u.BaseCMapReaderFactory{_fetchData(ue,se){return g(ue,this.isCompressed).then(oe=>({cMapData:oe,compressionType:se}))}}s.DOMCMapReaderFactory=x;class y extends u.BaseStandardFontDataFactory{_fetchData(ue){return g(ue,!0)}}s.DOMStandardFontDataFactory=y;class f extends u.BaseSVGFactory{_createSVG(ue){return document.createElementNS(p,ue)}}s.DOMSVGFactory=f;class m{constructor({viewBox:ue,scale:se,rotation:oe,offsetX:de=0,offsetY:le=0,dontFlip:xe=!1}){this.viewBox=ue,this.scale=se,this.rotation=oe,this.offsetX=de,this.offsetY=le;const Ce=(ue[2]+ue[0])/2,$e=(ue[3]+ue[1])/2;let Se,Ee,Ae,pe;switch(oe%=360,oe<0&&(oe+=360),oe){case 180:Se=-1,Ee=0,Ae=0,pe=1;break;case 90:Se=0,Ee=1,Ae=1,pe=0;break;case 270:Se=0,Ee=-1,Ae=-1,pe=0;break;case 0:Se=1,Ee=0,Ae=0,pe=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}xe&&(Ae=-Ae,pe=-pe);let he,Ie,ye,Pe;Se===0?(he=Math.abs($e-ue[1])*se+de,Ie=Math.abs(Ce-ue[0])*se+le,ye=(ue[3]-ue[1])*se,Pe=(ue[2]-ue[0])*se):(he=Math.abs(Ce-ue[0])*se+de,Ie=Math.abs($e-ue[1])*se+le,ye=(ue[2]-ue[0])*se,Pe=(ue[3]-ue[1])*se),this.transform=[Se*se,Ee*se,Ae*se,pe*se,he-Se*se*Ce-Ae*se*$e,Ie-Ee*se*Ce-pe*se*$e],this.width=ye,this.height=Pe}get rawDims(){const{viewBox:ue}=this;return(0,d.shadow)(this,"rawDims",{pageWidth:ue[2]-ue[0],pageHeight:ue[3]-ue[1],pageX:ue[0],pageY:ue[1]})}clone({scale:ue=this.scale,rotation:se=this.rotation,offsetX:oe=this.offsetX,offsetY:de=this.offsetY,dontFlip:le=!1}={}){return new m({viewBox:this.viewBox.slice(),scale:ue,rotation:se,offsetX:oe,offsetY:de,dontFlip:le})}convertToViewportPoint(ue,se){return d.Util.applyTransform([ue,se],this.transform)}convertToViewportRectangle(ue){const se=d.Util.applyTransform([ue[0],ue[1]],this.transform),oe=d.Util.applyTransform([ue[2],ue[3]],this.transform);return[se[0],se[1],oe[0],oe[1]]}convertToPdfPoint(ue,se){return d.Util.applyInverseTransform([ue,se],this.transform)}}s.PageViewport=m;class C extends d.BaseException{constructor(ue,se=0){super(ue,"RenderingCancelledException"),this.extraDelay=se}}s.RenderingCancelledException=C;function S(ge){const ue=ge.length;let se=0;for(;se<ue&&ge[se].trim()==="";)se++;return ge.substring(se,se+5).toLowerCase()==="data:"}function w(ge){return typeof ge=="string"&&/\.pdf$/i.test(ge)}function _(ge,ue=!1){return ue||([ge]=ge.split(/[#?]/,1)),ge.substring(ge.lastIndexOf("/")+1)}function I(ge,ue="document.pdf"){if(typeof ge!="string")return ue;if(S(ge))return(0,d.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),ue;const se=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,oe=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,de=se.exec(ge);let le=oe.exec(de[1])||oe.exec(de[2])||oe.exec(de[3]);if(le&&(le=le[0],le.includes("%")))try{le=oe.exec(decodeURIComponent(le))[0]}catch{}return le||ue}class ${constructor(){yr(this,"started",Object.create(null));yr(this,"times",[])}time(ue){ue in this.started&&(0,d.warn)(`Timer is already running for ${ue}`),this.started[ue]=Date.now()}timeEnd(ue){ue in this.started||(0,d.warn)(`Timer has not been started for ${ue}`),this.times.push({name:ue,start:this.started[ue],end:Date.now()}),delete this.started[ue]}toString(){const ue=[];let se=0;for(const{name:oe}of this.times)se=Math.max(oe.length,se);for(const{name:oe,start:de,end:le}of this.times)ue.push(`${oe.padEnd(se)} ${le-de}ms
|
58
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return codePointToString(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),a){var c=this.pos-1;this.invalidStringToken(c,"Invalid escape sequence in template string")}default:if(s>=48&&s<=55){var u=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],d=parseInt(u,8);return d>255&&(u=u.slice(0,-1),d=parseInt(u,8)),this.pos+=u.length-1,s=this.input.charCodeAt(this.pos),(u!=="0"||s===56||s===57)&&(this.strict||a)&&this.invalidStringToken(this.pos-1-u.length,a?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(d)}return isNewLine(s)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(s)}},pp.readHexChar=function(a){var s=this.pos,c=this.readInt(16,a);return c===null&&this.invalidStringToken(s,"Bad character escape sequence"),c},pp.readWord1=function(){this.containsEsc=!1;for(var a="",s=!0,c=this.pos,u=this.options.ecmaVersion>=6;this.pos<this.input.length;){var d=this.fullCharCodeAtPos();if(isIdentifierChar(d,u))this.pos+=d<=65535?1:2;else if(d===92){this.containsEsc=!0,a+=this.input.slice(c,this.pos);var p=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var v=this.readCodePoint();(s?isIdentifierStart:isIdentifierChar)(v,u)||this.invalidStringToken(p,"Invalid Unicode escape"),a+=codePointToString(v),c=this.pos}else break;s=!1}return a+this.input.slice(c,this.pos)},pp.readWord=function(){var a=this.readWord1(),s=types$1.name;return this.keywords.test(a)&&(s=keywords[a]),this.finishToken(s,a)};var version$2="8.14.1";Parser.acorn={Parser,version:version$2,defaultOptions:defaultOptions$1,Position,SourceLocation,getLineInfo,Node,TokenType,tokTypes:types$1,keywordTypes:keywords,TokContext,tokContexts:types$2,isIdentifierChar,isIdentifierStart,Token,isNewLine,lineBreak,lineBreakG,nonASCIIwhitespace};function parseExpressionAt(a,s,c){return Parser.parseExpressionAt(a,s,c)}const expressionCache=new Map,parseDataCache=new Map,parseData=a=>{const s=JSON.stringify(a);if(parseDataCache.has(s))return parseDataCache.get(s);const c=Object.fromEntries(Object.entries(a).map(([u,d])=>{if(typeof d=="string")try{const p=JSON.parse(d);return[u,p]}catch{return[u,d]}return[u,d]}));return parseDataCache.set(s,c),c},padZero=a=>String(a).padStart(2,"0"),formatDate=a=>`${a.getFullYear()}/${padZero(a.getMonth()+1)}/${padZero(a.getDate())}`,formatDateTime=a=>`${formatDate(a)} ${padZero(a.getHours())}:${padZero(a.getMinutes())}`,allowedGlobals={Math,String,Number,Boolean,Array,Object,Date,JSON,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent},validateAST=a=>{switch(a.type){case"Literal":case"Identifier":break;case"BinaryExpression":case"LogicalExpression":{const s=a;validateAST(s.left),validateAST(s.right);break}case"UnaryExpression":{validateAST(a.argument);break}case"ConditionalExpression":{const s=a;validateAST(s.test),validateAST(s.consequent),validateAST(s.alternate);break}case"MemberExpression":{const s=a;if(validateAST(s.object),s.computed)validateAST(s.property);else{const c=s.property.name;if(["constructor","__proto__","prototype"].includes(c))throw new Error("Access to prohibited property");if(typeof c=="string"&&["toLocaleString","valueOf"].includes(c))throw new Error(`Access to prohibited method: ${c}`)}break}case"CallExpression":{const s=a;validateAST(s.callee),s.arguments.forEach(validateAST);break}case"ArrayExpression":{a.elements.forEach(c=>{c&&validateAST(c)});break}case"ObjectExpression":{a.properties.forEach(c=>{const u=c;validateAST(u.key),validateAST(u.value)});break}case"ArrowFunctionExpression":{const s=a;s.params.forEach(c=>{if(c.type!=="Identifier")throw new Error("Only identifier parameters are supported in arrow functions");validateAST(c)}),validateAST(s.body);break}default:throw new Error(`Unsupported syntax in placeholder: ${a.type}`)}},evaluateAST=(a,s)=>{switch(a.type){case"Literal":return a.value;case"Identifier":{const c=a;if(Object.prototype.hasOwnProperty.call(s,c.name))return s[c.name];if(Object.prototype.hasOwnProperty.call(allowedGlobals,c.name))return allowedGlobals[c.name];throw new Error(`Undefined variable: ${c.name}`)}case"BinaryExpression":{const c=a,u=evaluateAST(c.left,s),d=evaluateAST(c.right,s);switch(c.operator){case"+":return u+d;case"-":return u-d;case"*":return u*d;case"/":return u/d;case"%":return u%d;case"**":return u**d;case"==":return u==d;case"!=":return u!=d;case"===":return u===d;case"!==":return u!==d;case"<":return u<d;case">":return u>d;case"<=":return u<=d;case">=":return u>=d;default:throw new Error(`Unsupported operator: ${c.operator}`)}}case"LogicalExpression":{const c=a,u=evaluateAST(c.left,s),d=evaluateAST(c.right,s);switch(c.operator){case"&&":return u&&d;case"||":return u||d;default:throw new Error(`Unsupported operator: ${c.operator}`)}}case"UnaryExpression":{const c=a,u=evaluateAST(c.argument,s);switch(c.operator){case"+":return+u;case"-":return-u;case"!":return!u;default:throw new Error(`Unsupported operator: ${c.operator}`)}}case"ConditionalExpression":{const c=a,u=evaluateAST(c.test,s);return evaluateAST(u?c.consequent:c.alternate,s)}case"MemberExpression":{const c=a,u=evaluateAST(c.object,s);let d;if(c.computed?d=evaluateAST(c.property,s):d=c.property.name,typeof d=="string"||typeof d=="number"){if(typeof d=="string"&&["constructor","__proto__","prototype"].includes(d))throw new Error("Access to prohibited property");return u[d]}else throw new Error("Invalid property access")}case"CallExpression":{const c=a,u=evaluateAST(c.callee,s),d=c.arguments.map(p=>evaluateAST(p,s));if(typeof u=="function")if(c.callee.type==="MemberExpression"){const p=c.callee,v=evaluateAST(p.object,s);if(v!==null&&(typeof v=="object"||typeof v=="number"||typeof v=="string"||typeof v=="boolean"))return u.call(v,...d);throw new Error("Invalid object in member function call")}else return u(...d);else throw new Error("Attempted to call a non-function")}case"ArrowFunctionExpression":{const c=a,u=c.params.map(p=>p.name),d=c.body;return(...p)=>{const v={...s};return u.forEach((A,b)=>{v[A]=p[b]}),evaluateAST(d,v)}}case"ArrayExpression":return a.elements.map(u=>u?evaluateAST(u,s):null);case"ObjectExpression":{const c=a,u={};return c.properties.forEach(d=>{const p=d;let v;if(p.key.type==="Identifier")v=p.key.name;else{const b=evaluateAST(p.key,s);if(typeof b!="string"&&typeof b!="number")throw new Error("Object property keys must be strings or numbers");v=String(b)}const A=evaluateAST(p.value,s);u[v]=A}),u}default:throw new Error(`Unsupported syntax in placeholder: ${a.type}`)}},evaluatePlaceholders=a=>{const{content:s,context:c}=a;let u="",d=0;for(;d<s.length;){const p=s.indexOf("{",d);if(p===-1){u+=s.slice(d);break}u+=s.slice(d,p);let v=1,A=p+1;for(;A<s.length&&v>0;)s[A]==="{"?v++:s[A]==="}"&&v--,A++;if(v===0){const b=s.slice(p+1,A-1).trim();if(expressionCache.has(b)){const g=expressionCache.get(b);try{const x=g(c);u+=String(x)}catch{u+=s.slice(p,A)}}else try{const g=parseExpressionAt(b,0,{ecmaVersion:"latest"});validateAST(g);const x=f=>evaluateAST(g,f);expressionCache.set(b,x);const y=x(c);u+=String(y)}catch{u+=s.slice(p,A)}d=A}else throw new Error("Invalid placeholder")}return u},replacePlaceholders=a=>{const{content:s,variables:c,schemas:u}=a;if(!s||typeof s!="string"||!s.includes("{")||!s.includes("}"))return s;const d=new Date,p=formatDate(d),v=formatDateTime(d),A={...Object.fromEntries(u.flat().map(x=>[x.name,x.readOnly&&x.content||""])),...c},b=parseData(A),g={date:p,dateTime:v,...b};return Object.entries(g).forEach(([x,y])=>{typeof y=="string"&&y.includes("{")&&y.includes("}")&&(g[x]=evaluatePlaceholders({content:y,context:g}))}),evaluatePlaceholders({content:s,context:g})},pluginRegistry=a=>({plugins:a,entries:()=>Object.entries(a),values:()=>Object.values(a),exists:()=>Object.values(a).length>0,findWithLabelByType(s){for(const[c,u]of Object.entries(this.plugins)){if(!u||typeof u!="object"||!u.propPanel||typeof u.propPanel!="object")continue;const d=u.propPanel.defaultSchema;if(d&&"type"in d&&d.type===s)return[c,u]}return["",void 0]},findByType(s){const[,c]=this.findWithLabelByType(s);return c}}),DEFAULT_LANG="en",DESTROYED_ERR_MSG="[@pdfme/ui] this instance is already destroyed",SELECTABLE_CLASSNAME="selectable",RULER_HEIGHT=30,PAGE_GAP=10,LEFT_SIDEBAR_WIDTH=45,RIGHT_SIDEBAR_WIDTH=400,BACKGROUND_COLOR="rgb(74, 74, 74)",DEFAULT_MAX_ZOOM=2,isff=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function addEvent$1(a,s,c,u){a.addEventListener?a.addEventListener(s,c,u):a.attachEvent&&a.attachEvent("on".concat(s),c)}function removeEvent$1(a,s,c,u){a.removeEventListener?a.removeEventListener(s,c,u):a.detachEvent&&a.detachEvent("on".concat(s),c)}function getMods(a,s){const c=s.slice(0,s.length-1);for(let u=0;u<c.length;u++)c[u]=a[c[u].toLowerCase()];return c}function getKeys$1(a){typeof a!="string"&&(a=""),a=a.replace(/\s/g,"");const s=a.split(",");let c=s.lastIndexOf("");for(;c>=0;)s[c-1]+=",",s.splice(c,1),c=s.lastIndexOf("");return s}function compareArray(a,s){const c=a.length>=s.length?a:s,u=a.length>=s.length?s:a;let d=!0;for(let p=0;p<c.length;p++)u.indexOf(c[p])===-1&&(d=!1);return d}const _keyMap={backspace:8,"⌫":8,tab:9,clear:12,enter:13,"↩":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":isff?173:189,"=":isff?61:187,";":isff?59:186,"'":222,"[":219,"]":221,"\\":220},_modifier={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},modifierMap={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},_mods={16:!1,18:!1,17:!1,91:!1},_handlers={};for(let a=1;a<20;a++)_keyMap["f".concat(a)]=111+a;let _downKeys=[],winListendFocus=null,_scope="all";const elementEventMap=new Map,code=a=>_keyMap[a.toLowerCase()]||_modifier[a.toLowerCase()]||a.toUpperCase().charCodeAt(0),getKey$3=a=>Object.keys(_keyMap).find(s=>_keyMap[s]===a),getModifier=a=>Object.keys(_modifier).find(s=>_modifier[s]===a);function setScope(a){_scope=a||"all"}function getScope(){return _scope||"all"}function getPressedKeyCodes(){return _downKeys.slice(0)}function getPressedKeyString(){return _downKeys.map(a=>getKey$3(a)||getModifier(a)||String.fromCharCode(a))}function getAllKeyCodes(){const a=[];return Object.keys(_handlers).forEach(s=>{_handlers[s].forEach(c=>{let{key:u,scope:d,mods:p,shortcut:v}=c;a.push({scope:d,shortcut:v,mods:p,keys:u.split("+").map(A=>code(A))})})}),a}function filter$1(a){const s=a.target||a.srcElement,{tagName:c}=s;let u=!0;const d=c==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(s.type);return(s.isContentEditable||(d||c==="TEXTAREA"||c==="SELECT")&&!s.readOnly)&&(u=!1),u}function isPressed(a){return typeof a=="string"&&(a=code(a)),_downKeys.indexOf(a)!==-1}function deleteScope(a,s){let c,u;a||(a=getScope());for(const d in _handlers)if(Object.prototype.hasOwnProperty.call(_handlers,d))for(c=_handlers[d],u=0;u<c.length;)c[u].scope===a?c.splice(u,1).forEach(v=>{let{element:A}=v;return removeKeyEvent(A)}):u++;getScope()===a&&setScope(s||"all")}function clearModifier(a){let s=a.keyCode||a.which||a.charCode;const c=_downKeys.indexOf(s);if(c>=0&&_downKeys.splice(c,1),a.key&&a.key.toLowerCase()==="meta"&&_downKeys.splice(0,_downKeys.length),(s===93||s===224)&&(s=91),s in _mods){_mods[s]=!1;for(const u in _modifier)_modifier[u]===s&&(hotkeys$1[u]=!1)}}function unbind(a){if(typeof a>"u")Object.keys(_handlers).forEach(d=>{Array.isArray(_handlers[d])&&_handlers[d].forEach(p=>eachUnbind(p)),delete _handlers[d]}),removeKeyEvent(null);else if(Array.isArray(a))a.forEach(d=>{d.key&&eachUnbind(d)});else if(typeof a=="object")a.key&&eachUnbind(a);else if(typeof a=="string"){for(var s=arguments.length,c=new Array(s>1?s-1:0),u=1;u<s;u++)c[u-1]=arguments[u];let[d,p]=c;typeof d=="function"&&(p=d,d=""),eachUnbind({key:a,scope:d,method:p,splitKey:"+"})}}const eachUnbind=a=>{let{key:s,scope:c,method:u,splitKey:d="+"}=a;getKeys$1(s).forEach(v=>{const A=v.split(d),b=A.length,g=A[b-1],x=g==="*"?"*":code(g);if(!_handlers[x])return;c||(c=getScope());const y=b>1?getMods(_modifier,A):[],f=[];_handlers[x]=_handlers[x].filter(m=>{const S=(u?m.method===u:!0)&&m.scope===c&&compareArray(m.mods,y);return S&&f.push(m.element),!S}),f.forEach(m=>removeKeyEvent(m))})};function eventHandler(a,s,c,u){if(s.element!==u)return;let d;if(s.scope===c||s.scope==="all"){d=s.mods.length>0;for(const p in _mods)Object.prototype.hasOwnProperty.call(_mods,p)&&(!_mods[p]&&s.mods.indexOf(+p)>-1||_mods[p]&&s.mods.indexOf(+p)===-1)&&(d=!1);(s.mods.length===0&&!_mods[16]&&!_mods[18]&&!_mods[17]&&!_mods[91]||d||s.shortcut==="*")&&(s.keys=[],s.keys=s.keys.concat(_downKeys),s.method(a,s)===!1&&(a.preventDefault?a.preventDefault():a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.cancelBubble&&(a.cancelBubble=!0)))}}function dispatch(a,s){const c=_handlers["*"];let u=a.keyCode||a.which||a.charCode;if(!hotkeys$1.filter.call(this,a))return;if((u===93||u===224)&&(u=91),_downKeys.indexOf(u)===-1&&u!==229&&_downKeys.push(u),["metaKey","ctrlKey","altKey","shiftKey"].forEach(A=>{const b=modifierMap[A];a[A]&&_downKeys.indexOf(b)===-1?_downKeys.push(b):!a[A]&&_downKeys.indexOf(b)>-1?_downKeys.splice(_downKeys.indexOf(b),1):A==="metaKey"&&a[A]&&(_downKeys=_downKeys.filter(g=>g in modifierMap||g===u))}),u in _mods){_mods[u]=!0;for(const A in _modifier)if(Object.prototype.hasOwnProperty.call(_modifier,A)){const b=modifierMap[_modifier[A]];hotkeys$1[A]=a[b]}if(!c)return}for(const A in _mods)Object.prototype.hasOwnProperty.call(_mods,A)&&(_mods[A]=a[modifierMap[A]]);a.getModifierState&&!(a.altKey&&!a.ctrlKey)&&a.getModifierState("AltGraph")&&(_downKeys.indexOf(17)===-1&&_downKeys.push(17),_downKeys.indexOf(18)===-1&&_downKeys.push(18),_mods[17]=!0,_mods[18]=!0);const d=getScope();if(c)for(let A=0;A<c.length;A++)c[A].scope===d&&(a.type==="keydown"&&c[A].keydown||a.type==="keyup"&&c[A].keyup)&&eventHandler(a,c[A],d,s);if(!(u in _handlers))return;const p=_handlers[u],v=p.length;for(let A=0;A<v;A++)if((a.type==="keydown"&&p[A].keydown||a.type==="keyup"&&p[A].keyup)&&p[A].key){const b=p[A],{splitKey:g}=b,x=b.key.split(g),y=[];for(let f=0;f<x.length;f++)y.push(code(x[f]));y.sort().join("")===_downKeys.sort().join("")&&eventHandler(a,b,d,s)}}function hotkeys$1(a,s,c){_downKeys=[];const u=getKeys$1(a);let d=[],p="all",v=document,A=0,b=!1,g=!0,x="+",y=!1,f=!1;for(c===void 0&&typeof s=="function"&&(c=s),Object.prototype.toString.call(s)==="[object Object]"&&(s.scope&&(p=s.scope),s.element&&(v=s.element),s.keyup&&(b=s.keyup),s.keydown!==void 0&&(g=s.keydown),s.capture!==void 0&&(y=s.capture),typeof s.splitKey=="string"&&(x=s.splitKey),s.single===!0&&(f=!0)),typeof s=="string"&&(p=s),f&&unbind(a,p);A<u.length;A++)a=u[A].split(x),d=[],a.length>1&&(d=getMods(_modifier,a)),a=a[a.length-1],a=a==="*"?"*":code(a),a in _handlers||(_handlers[a]=[]),_handlers[a].push({keyup:b,keydown:g,scope:p,mods:d,shortcut:u[A],method:c,key:u[A],splitKey:x,element:v});if(typeof v<"u"&&window){if(!elementEventMap.has(v)){const m=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return dispatch(S,v)},C=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;dispatch(S,v),clearModifier(S)};elementEventMap.set(v,{keydownListener:m,keyupListenr:C,capture:y}),addEvent$1(v,"keydown",m,y),addEvent$1(v,"keyup",C,y)}if(!winListendFocus){const m=()=>{_downKeys=[]};winListendFocus={listener:m,capture:y},addEvent$1(window,"focus",m,y)}}}function trigger(a){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(_handlers).forEach(c=>{_handlers[c].filter(d=>d.scope===s&&d.shortcut===a).forEach(d=>{d&&d.method&&d.method()})})}function removeKeyEvent(a){const s=Object.values(_handlers).flat();if(s.findIndex(u=>{let{element:d}=u;return d===a})<0){const{keydownListener:u,keyupListenr:d,capture:p}=elementEventMap.get(a)||{};u&&d&&(removeEvent$1(a,"keyup",d,p),removeEvent$1(a,"keydown",u,p),elementEventMap.delete(a))}if((s.length<=0||elementEventMap.size<=0)&&(Object.keys(elementEventMap).forEach(d=>{const{keydownListener:p,keyupListenr:v,capture:A}=elementEventMap.get(d)||{};p&&v&&(removeEvent$1(d,"keyup",v,A),removeEvent$1(d,"keydown",p,A),elementEventMap.delete(d))}),elementEventMap.clear(),Object.keys(_handlers).forEach(d=>delete _handlers[d]),winListendFocus)){const{listener:d,capture:p}=winListendFocus;removeEvent$1(window,"focus",d,p),winListendFocus=null}}const _api={getPressedKeyString,setScope,getScope,deleteScope,getPressedKeyCodes,getAllKeyCodes,isPressed,filter:filter$1,trigger,unbind,keyMap:_keyMap,modifier:_modifier,modifierMap};for(const a in _api)Object.prototype.hasOwnProperty.call(_api,a)&&(hotkeys$1[a]=_api[a]);if(typeof window<"u"){const a=window.hotkeys;hotkeys$1.noConflict=s=>(s&&window.hotkeys===hotkeys$1&&(window.hotkeys=a),hotkeys$1),window.hotkeys=hotkeys$1}var reactExports=requireReact();const React=getDefaultExportFromCjs(reactExports),React$1=_mergeNamespaces({__proto__:null,default:React},[reactExports]);function commonjsRequire(a){throw new Error('Could not dynamically require "'+a+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var pdf={exports:{}};const __viteBrowserExternal={},__viteBrowserExternal$1=Object.freeze(Object.defineProperty({__proto__:null,default:__viteBrowserExternal},Symbol.toStringTag,{value:"Module"})),require$$5=getAugmentedNamespace(__viteBrowserExternal$1);var hasRequiredPdf;function requirePdf(){return hasRequiredPdf||(hasRequiredPdf=1,function(module,exports){(function(s,c){module.exports=s.pdfjsLib=c()})(globalThis,()=>(()=>{var __webpack_modules__=[,(a,s)=>{var Le;Object.defineProperty(s,"__esModule",{value:!0}),s.VerbosityLevel=s.Util=s.UnknownErrorException=s.UnexpectedResponseException=s.TextRenderingMode=s.RenderingIntentFlag=s.PromiseCapability=s.PermissionFlag=s.PasswordResponses=s.PasswordException=s.PageActionEventType=s.OPS=s.MissingPDFException=s.MAX_IMAGE_SIZE_TO_CACHE=s.LINE_FACTOR=s.LINE_DESCENT_FACTOR=s.InvalidPDFException=s.ImageKind=s.IDENTITY_MATRIX=s.FormatError=s.FeatureTest=s.FONT_IDENTITY_MATRIX=s.DocumentActionEventType=s.CMapCompressionType=s.BaseException=s.BASELINE_FACTOR=s.AnnotationType=s.AnnotationReplyType=s.AnnotationPrefix=s.AnnotationMode=s.AnnotationFlag=s.AnnotationFieldFlag=s.AnnotationEditorType=s.AnnotationEditorPrefix=s.AnnotationEditorParamsType=s.AnnotationBorderStyleType=s.AnnotationActionEventType=s.AbortException=void 0,s.assert=D,s.bytesToString=ie,s.createValidAbsoluteUrl=Z,s.getModificationDate=Ae,s.getUuid=Pe,s.getVerbosityLevel=L,s.info=F,s.isArrayBuffer=Se,s.isArrayEqual=Ee,s.isNodeJS=void 0,s.normalizeUnicode=ye,s.objectFromMap=ve,s.objectSize=we,s.setVerbosityLevel=q,s.shadow=Q,s.string32=me,s.stringToBytes=ce,s.stringToPDFString=xe,s.stringToUTF8String=Ce,s.unreachable=N,s.utf8StringToString=$e,s.warn=U;const c=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser");s.isNodeJS=c;const u=[1,0,0,1,0,0];s.IDENTITY_MATRIX=u;const d=[.001,0,0,.001,0,0];s.FONT_IDENTITY_MATRIX=d;const p=1e7;s.MAX_IMAGE_SIZE_TO_CACHE=p;const v=1.35;s.LINE_FACTOR=v;const A=.35;s.LINE_DESCENT_FACTOR=A;const b=A/v;s.BASELINE_FACTOR=b;const g={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};s.RenderingIntentFlag=g;const x={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};s.AnnotationMode=x;const y="pdfjs_internal_editor_";s.AnnotationEditorPrefix=y;const f={DISABLE:-1,NONE:0,FREETEXT:3,STAMP:13,INK:15};s.AnnotationEditorType=f;const m={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23};s.AnnotationEditorParamsType=m;const C={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.PermissionFlag=C;const S={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};s.TextRenderingMode=S;const w={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};s.ImageKind=w;const _={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};s.AnnotationType=_;const I={GROUP:"Group",REPLY:"R"};s.AnnotationReplyType=I;const $={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};s.AnnotationFlag=$;const P={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};s.AnnotationFieldFlag=P;const E={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};s.AnnotationBorderStyleType=E;const R={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"};s.AnnotationActionEventType=R;const T={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};s.DocumentActionEventType=T;const B={O:"PageOpen",C:"PageClose"};s.PageActionEventType=B;const M={ERRORS:0,WARNINGS:1,INFOS:5};s.VerbosityLevel=M;const k={NONE:0,BINARY:1};s.CMapCompressionType=k;const O={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};s.OPS=O;const H={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};s.PasswordResponses=H;let j=M.WARNINGS;function q(Oe){Number.isInteger(Oe)&&(j=Oe)}function L(){return j}function F(Oe){j>=M.INFOS&&console.log(`Info: ${Oe}`)}function U(Oe){j>=M.WARNINGS&&console.log(`Warning: ${Oe}`)}function N(Oe){throw new Error(Oe)}function D(Oe,Fe){Oe||N(Fe)}function W(Oe){switch(Oe==null?void 0:Oe.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Z(Oe,Fe=null,_e=null){if(!Oe)return null;try{if(_e&&typeof Oe=="string"){if(_e.addDefaultProtocol&&Oe.startsWith("www.")){const Ye=Oe.match(/\./g);(Ye==null?void 0:Ye.length)>=2&&(Oe=`http://${Oe}`)}if(_e.tryConvertEncoding)try{Oe=Ce(Oe)}catch{}}const je=Fe?new URL(Oe,Fe):new URL(Oe);if(W(je))return je}catch{}return null}function Q(Oe,Fe,_e,je=!1){return Object.defineProperty(Oe,Fe,{value:_e,enumerable:!je,configurable:!0,writable:!1}),_e}const Y=function(){function Fe(_e,je){this.constructor===Fe&&N("Cannot initialize BaseException."),this.message=_e,this.name=je}return Fe.prototype=new Error,Fe.constructor=Fe,Fe}();s.BaseException=Y;class J extends Y{constructor(Fe,_e){super(Fe,"PasswordException"),this.code=_e}}s.PasswordException=J;class ee extends Y{constructor(Fe,_e){super(Fe,"UnknownErrorException"),this.details=_e}}s.UnknownErrorException=ee;class re extends Y{constructor(Fe){super(Fe,"InvalidPDFException")}}s.InvalidPDFException=re;class ae extends Y{constructor(Fe){super(Fe,"MissingPDFException")}}s.MissingPDFException=ae;class V extends Y{constructor(Fe,_e){super(Fe,"UnexpectedResponseException"),this.status=_e}}s.UnexpectedResponseException=V;class K extends Y{constructor(Fe){super(Fe,"FormatError")}}s.FormatError=K;class te extends Y{constructor(Fe){super(Fe,"AbortException")}}s.AbortException=te;function ie(Oe){(typeof Oe!="object"||(Oe==null?void 0:Oe.length)===void 0)&&N("Invalid argument for bytesToString");const Fe=Oe.length,_e=8192;if(Fe<_e)return String.fromCharCode.apply(null,Oe);const je=[];for(let Ye=0;Ye<Fe;Ye+=_e){const Te=Math.min(Ye+_e,Fe),ke=Oe.subarray(Ye,Te);je.push(String.fromCharCode.apply(null,ke))}return je.join("")}function ce(Oe){typeof Oe!="string"&&N("Invalid argument for stringToBytes");const Fe=Oe.length,_e=new Uint8Array(Fe);for(let je=0;je<Fe;++je)_e[je]=Oe.charCodeAt(je)&255;return _e}function me(Oe){return String.fromCharCode(Oe>>24&255,Oe>>16&255,Oe>>8&255,Oe&255)}function we(Oe){return Object.keys(Oe).length}function ve(Oe){const Fe=Object.create(null);for(const[_e,je]of Oe)Fe[_e]=je;return Fe}function ge(){const Oe=new Uint8Array(4);return Oe[0]=1,new Uint32Array(Oe.buffer,0,1)[0]===1}function ue(){try{return new Function(""),!0}catch{return!1}}class se{static get isLittleEndian(){return Q(this,"isLittleEndian",ge())}static get isEvalSupported(){return Q(this,"isEvalSupported",ue())}static get isOffscreenCanvasSupported(){return Q(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator>"u"?Q(this,"platform",{isWin:!1,isMac:!1}):Q(this,"platform",{isWin:navigator.platform.includes("Win"),isMac:navigator.platform.includes("Mac")})}static get isCSSRoundSupported(){var Fe,_e;return Q(this,"isCSSRoundSupported",(_e=(Fe=globalThis.CSS)==null?void 0:Fe.supports)==null?void 0:_e.call(Fe,"width: round(1.5px, 1px)"))}}s.FeatureTest=se;const oe=[...Array(256).keys()].map(Oe=>Oe.toString(16).padStart(2,"0"));class de{static makeHexColor(Fe,_e,je){return`#${oe[Fe]}${oe[_e]}${oe[je]}`}static scaleMinMax(Fe,_e){let je;Fe[0]?(Fe[0]<0&&(je=_e[0],_e[0]=_e[1],_e[1]=je),_e[0]*=Fe[0],_e[1]*=Fe[0],Fe[3]<0&&(je=_e[2],_e[2]=_e[3],_e[3]=je),_e[2]*=Fe[3],_e[3]*=Fe[3]):(je=_e[0],_e[0]=_e[2],_e[2]=je,je=_e[1],_e[1]=_e[3],_e[3]=je,Fe[1]<0&&(je=_e[2],_e[2]=_e[3],_e[3]=je),_e[2]*=Fe[1],_e[3]*=Fe[1],Fe[2]<0&&(je=_e[0],_e[0]=_e[1],_e[1]=je),_e[0]*=Fe[2],_e[1]*=Fe[2]),_e[0]+=Fe[4],_e[1]+=Fe[4],_e[2]+=Fe[5],_e[3]+=Fe[5]}static transform(Fe,_e){return[Fe[0]*_e[0]+Fe[2]*_e[1],Fe[1]*_e[0]+Fe[3]*_e[1],Fe[0]*_e[2]+Fe[2]*_e[3],Fe[1]*_e[2]+Fe[3]*_e[3],Fe[0]*_e[4]+Fe[2]*_e[5]+Fe[4],Fe[1]*_e[4]+Fe[3]*_e[5]+Fe[5]]}static applyTransform(Fe,_e){const je=Fe[0]*_e[0]+Fe[1]*_e[2]+_e[4],Ye=Fe[0]*_e[1]+Fe[1]*_e[3]+_e[5];return[je,Ye]}static applyInverseTransform(Fe,_e){const je=_e[0]*_e[3]-_e[1]*_e[2],Ye=(Fe[0]*_e[3]-Fe[1]*_e[2]+_e[2]*_e[5]-_e[4]*_e[3])/je,Te=(-Fe[0]*_e[1]+Fe[1]*_e[0]+_e[4]*_e[1]-_e[5]*_e[0])/je;return[Ye,Te]}static getAxialAlignedBoundingBox(Fe,_e){const je=this.applyTransform(Fe,_e),Ye=this.applyTransform(Fe.slice(2,4),_e),Te=this.applyTransform([Fe[0],Fe[3]],_e),ke=this.applyTransform([Fe[2],Fe[1]],_e);return[Math.min(je[0],Ye[0],Te[0],ke[0]),Math.min(je[1],Ye[1],Te[1],ke[1]),Math.max(je[0],Ye[0],Te[0],ke[0]),Math.max(je[1],Ye[1],Te[1],ke[1])]}static inverseTransform(Fe){const _e=Fe[0]*Fe[3]-Fe[1]*Fe[2];return[Fe[3]/_e,-Fe[1]/_e,-Fe[2]/_e,Fe[0]/_e,(Fe[2]*Fe[5]-Fe[4]*Fe[3])/_e,(Fe[4]*Fe[1]-Fe[5]*Fe[0])/_e]}static singularValueDecompose2dScale(Fe){const _e=[Fe[0],Fe[2],Fe[1],Fe[3]],je=Fe[0]*_e[0]+Fe[1]*_e[2],Ye=Fe[0]*_e[1]+Fe[1]*_e[3],Te=Fe[2]*_e[0]+Fe[3]*_e[2],ke=Fe[2]*_e[1]+Fe[3]*_e[3],De=(je+ke)/2,Re=Math.sqrt((je+ke)**2-4*(je*ke-Te*Ye))/2,Ge=De+Re||1,Ve=De-Re||1;return[Math.sqrt(Ge),Math.sqrt(Ve)]}static normalizeRect(Fe){const _e=Fe.slice(0);return Fe[0]>Fe[2]&&(_e[0]=Fe[2],_e[2]=Fe[0]),Fe[1]>Fe[3]&&(_e[1]=Fe[3],_e[3]=Fe[1]),_e}static intersect(Fe,_e){const je=Math.max(Math.min(Fe[0],Fe[2]),Math.min(_e[0],_e[2])),Ye=Math.min(Math.max(Fe[0],Fe[2]),Math.max(_e[0],_e[2]));if(je>Ye)return null;const Te=Math.max(Math.min(Fe[1],Fe[3]),Math.min(_e[1],_e[3])),ke=Math.min(Math.max(Fe[1],Fe[3]),Math.max(_e[1],_e[3]));return Te>ke?null:[je,Te,Ye,ke]}static bezierBoundingBox(Fe,_e,je,Ye,Te,ke,De,Re){const Ge=[],Ve=[[],[]];let Xe,We,ze,Qe,et,Ze,qe,Je;for(let vt=0;vt<2;++vt){if(vt===0?(We=6*Fe-12*je+6*Te,Xe=-3*Fe+9*je-9*Te+3*De,ze=3*je-3*Fe):(We=6*_e-12*Ye+6*ke,Xe=-3*_e+9*Ye-9*ke+3*Re,ze=3*Ye-3*_e),Math.abs(Xe)<1e-12){if(Math.abs(We)<1e-12)continue;Qe=-ze/We,0<Qe&&Qe<1&&Ge.push(Qe);continue}qe=We*We-4*ze*Xe,Je=Math.sqrt(qe),!(qe<0)&&(et=(-We+Je)/(2*Xe),0<et&&et<1&&Ge.push(et),Ze=(-We-Je)/(2*Xe),0<Ze&&Ze<1&&Ge.push(Ze))}let ot=Ge.length,nt;const st=ot;for(;ot--;)Qe=Ge[ot],nt=1-Qe,Ve[0][ot]=nt*nt*nt*Fe+3*nt*nt*Qe*je+3*nt*Qe*Qe*Te+Qe*Qe*Qe*De,Ve[1][ot]=nt*nt*nt*_e+3*nt*nt*Qe*Ye+3*nt*Qe*Qe*ke+Qe*Qe*Qe*Re;return Ve[0][st]=Fe,Ve[1][st]=_e,Ve[0][st+1]=De,Ve[1][st+1]=Re,Ve[0].length=Ve[1].length=st+2,[Math.min(...Ve[0]),Math.min(...Ve[1]),Math.max(...Ve[0]),Math.max(...Ve[1])]}}s.Util=de;const le=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function xe(Oe){if(Oe[0]>="ï"){let _e;if(Oe[0]==="þ"&&Oe[1]==="ÿ"?_e="utf-16be":Oe[0]==="ÿ"&&Oe[1]==="þ"?_e="utf-16le":Oe[0]==="ï"&&Oe[1]==="»"&&Oe[2]==="¿"&&(_e="utf-8"),_e)try{const je=new TextDecoder(_e,{fatal:!0}),Ye=ce(Oe);return je.decode(Ye)}catch(je){U(`stringToPDFString: "${je}".`)}}const Fe=[];for(let _e=0,je=Oe.length;_e<je;_e++){const Ye=le[Oe.charCodeAt(_e)];Fe.push(Ye?String.fromCharCode(Ye):Oe.charAt(_e))}return Fe.join("")}function Ce(Oe){return decodeURIComponent(escape(Oe))}function $e(Oe){return unescape(encodeURIComponent(Oe))}function Se(Oe){return typeof Oe=="object"&&(Oe==null?void 0:Oe.byteLength)!==void 0}function Ee(Oe,Fe){if(Oe.length!==Fe.length)return!1;for(let _e=0,je=Oe.length;_e<je;_e++)if(Oe[_e]!==Fe[_e])return!1;return!0}function Ae(Oe=new Date){return[Oe.getUTCFullYear().toString(),(Oe.getUTCMonth()+1).toString().padStart(2,"0"),Oe.getUTCDate().toString().padStart(2,"0"),Oe.getUTCHours().toString().padStart(2,"0"),Oe.getUTCMinutes().toString().padStart(2,"0"),Oe.getUTCSeconds().toString().padStart(2,"0")].join("")}class pe{constructor(){bt(this,Le,!1);this.promise=new Promise((Fe,_e)=>{this.resolve=je=>{Ct(this,Le,!0),Fe(je)},this.reject=je=>{Ct(this,Le,!0),_e(je)}})}get settled(){return He(this,Le)}}Le=new WeakMap,s.PromiseCapability=pe;let he=null,Ie=null;function ye(Oe){return he||(he=/([\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,Ie=new Map([["ſt","ſt"]])),Oe.replaceAll(he,(Fe,_e,je)=>_e?_e.normalize("NFKC"):Ie.get(je))}function Pe(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const Oe=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(Oe);else for(let Fe=0;Fe<32;Fe++)Oe[Fe]=Math.floor(Math.random()*255);return ie(Oe)}const Ne="pdfjs_internal_id_";s.AnnotationPrefix=Ne},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{var a,c,u,d,ka,po,A,b,g,x,y,f,m,C,S,go,_,I,Gs,P,E;Object.defineProperty(exports,"__esModule",{value:!0}),exports.RenderTask=exports.PDFWorkerUtil=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultFilterFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,Object.defineProperty(exports,"SVGGraphics",{enumerable:!0,get:function(){return _displaySvg.SVGGraphics}}),exports.build=void 0,exports.getDocument=getDocument,exports.version=void 0;var _util=__w_pdfjs_require__(1),_annotation_storage=__w_pdfjs_require__(3),_display_utils=__w_pdfjs_require__(6),_font_loader=__w_pdfjs_require__(9),_displayNode_utils=__w_pdfjs_require__(10),_canvas=__w_pdfjs_require__(11),_worker_options=__w_pdfjs_require__(14),_message_handler=__w_pdfjs_require__(15),_metadata=__w_pdfjs_require__(16),_optional_content_config=__w_pdfjs_require__(17),_transport_stream=__w_pdfjs_require__(18),_displayFetch_stream=__w_pdfjs_require__(19),_displayNetwork=__w_pdfjs_require__(22),_displayNode_stream=__w_pdfjs_require__(23),_displaySvg=__w_pdfjs_require__(24),_xfa_text=__w_pdfjs_require__(25);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,DELAYED_CLEANUP_TIMEOUT=5e3,DefaultCanvasFactory=_util.isNodeJS?_displayNode_utils.NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;const DefaultCMapReaderFactory=_util.isNodeJS?_displayNode_utils.NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;const DefaultFilterFactory=_util.isNodeJS?_displayNode_utils.NodeFilterFactory:_display_utils.DOMFilterFactory;exports.DefaultFilterFactory=DefaultFilterFactory;const DefaultStandardFontDataFactory=_util.isNodeJS?_displayNode_utils.NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory;exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory;function getDocument(T){if(typeof T=="string"||T instanceof URL?T={url:T}:(0,_util.isArrayBuffer)(T)&&(T={data:T}),typeof T!="object")throw new Error("Invalid parameter in getDocument, need parameter object.");if(!T.url&&!T.data&&!T.range)throw new Error("Invalid parameter object: need either .data, .range or .url");const B=new PDFDocumentLoadingTask,{docId:M}=B,k=T.url?getUrlProp(T.url):null,O=T.data?getDataProp(T.data):null,H=T.httpHeaders||null,j=T.withCredentials===!0,q=T.password??null,L=T.range instanceof PDFDataRangeTransport?T.range:null,F=Number.isInteger(T.rangeChunkSize)&&T.rangeChunkSize>0?T.rangeChunkSize:DEFAULT_RANGE_CHUNK_SIZE;let U=T.worker instanceof PDFWorker?T.worker:null;const N=T.verbosity,D=typeof T.docBaseUrl=="string"&&!(0,_display_utils.isDataScheme)(T.docBaseUrl)?T.docBaseUrl:null,W=typeof T.cMapUrl=="string"?T.cMapUrl:null,Z=T.cMapPacked!==!1,Q=T.CMapReaderFactory||DefaultCMapReaderFactory,Y=typeof T.standardFontDataUrl=="string"?T.standardFontDataUrl:null,J=T.StandardFontDataFactory||DefaultStandardFontDataFactory,ee=T.stopAtErrors!==!0,re=Number.isInteger(T.maxImageSize)&&T.maxImageSize>-1?T.maxImageSize:-1,ae=T.isEvalSupported!==!1,V=typeof T.isOffscreenCanvasSupported=="boolean"?T.isOffscreenCanvasSupported:!_util.isNodeJS,K=Number.isInteger(T.canvasMaxAreaInBytes)?T.canvasMaxAreaInBytes:-1,te=typeof T.disableFontFace=="boolean"?T.disableFontFace:_util.isNodeJS,ie=T.fontExtraProperties===!0,ce=T.enableXfa===!0,me=T.ownerDocument||globalThis.document,we=T.disableRange===!0,ve=T.disableStream===!0,ge=T.disableAutoFetch===!0,ue=T.pdfBug===!0,se=L?L.length:T.length??NaN,oe=typeof T.useSystemFonts=="boolean"?T.useSystemFonts:!_util.isNodeJS&&!te,de=typeof T.useWorkerFetch=="boolean"?T.useWorkerFetch:Q===_display_utils.DOMCMapReaderFactory&&J===_display_utils.DOMStandardFontDataFactory&&W&&Y&&(0,_display_utils.isValidFetchUrl)(W,document.baseURI)&&(0,_display_utils.isValidFetchUrl)(Y,document.baseURI),le=T.canvasFactory||new DefaultCanvasFactory({ownerDocument:me}),xe=T.filterFactory||new DefaultFilterFactory({docId:M,ownerDocument:me}),Ce=null;(0,_util.setVerbosityLevel)(N);const $e={canvasFactory:le,filterFactory:xe};if(de||($e.cMapReaderFactory=new Q({baseUrl:W,isCompressed:Z}),$e.standardFontDataFactory=new J({baseUrl:Y})),!U){const Ae={verbosity:N,port:_worker_options.GlobalWorkerOptions.workerPort};U=Ae.port?PDFWorker.fromPort(Ae):new PDFWorker(Ae),B._worker=U}const Se={docId:M,apiVersion:"3.11.174",data:O,password:q,disableAutoFetch:ge,rangeChunkSize:F,length:se,docBaseUrl:D,enableXfa:ce,evaluatorOptions:{maxImageSize:re,disableFontFace:te,ignoreErrors:ee,isEvalSupported:ae,isOffscreenCanvasSupported:V,canvasMaxAreaInBytes:K,fontExtraProperties:ie,useSystemFonts:oe,cMapUrl:de?W:null,standardFontDataUrl:de?Y:null}},Ee={ignoreErrors:ee,isEvalSupported:ae,disableFontFace:te,fontExtraProperties:ie,enableXfa:ce,ownerDocument:me,disableAutoFetch:ge,pdfBug:ue,styleElement:Ce};return U.promise.then(function(){if(B.destroyed)throw new Error("Loading aborted");const Ae=_fetchDocument(U,Se),pe=new Promise(function(he){let Ie;L?Ie=new _transport_stream.PDFDataTransportStream({length:se,initialData:L.initialData,progressiveDone:L.progressiveDone,contentDispositionFilename:L.contentDispositionFilename,disableRange:we,disableStream:ve},L):O||(Ie=(Pe=>_util.isNodeJS?new _displayNode_stream.PDFNodeStream(Pe):(0,_display_utils.isValidFetchUrl)(Pe.url)?new _displayFetch_stream.PDFFetchStream(Pe):new _displayNetwork.PDFNetworkStream(Pe))({url:k,length:se,httpHeaders:H,withCredentials:j,rangeChunkSize:F,disableRange:we,disableStream:ve})),he(Ie)});return Promise.all([Ae,pe]).then(function([he,Ie]){if(B.destroyed)throw new Error("Loading aborted");const ye=new _message_handler.MessageHandler(M,he,U.port),Pe=new WorkerTransport(ye,B,Ie,Ee,$e);B._transport=Pe,ye.send("Ready",null)})}).catch(B._capability.reject),B}async function _fetchDocument(T,B){if(T.destroyed)throw new Error("Worker was destroyed");const M=await T.messageHandler.sendWithPromise("GetDocRequest",B,B.data?[B.data.buffer]:null);if(T.destroyed)throw new Error("Worker was destroyed");return M}function getUrlProp(T){if(T instanceof URL)return T.href;try{return new URL(T,window.location).href}catch{if(_util.isNodeJS&&typeof T=="string")return T}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function getDataProp(T){if(_util.isNodeJS&&typeof Buffer<"u"&&T instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(T instanceof Uint8Array&&T.byteLength===T.buffer.byteLength)return T;if(typeof T=="string")return(0,_util.stringToBytes)(T);if(typeof T=="object"&&!isNaN(T==null?void 0:T.length)||(0,_util.isArrayBuffer)(T))return new Uint8Array(T);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}const s=class s{constructor(){this._capability=new _util.PromiseCapability,this._transport=null,this._worker=null,this.docId=`d${hi(s,a)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var B,M,k;this.destroyed=!0;try{(B=this._worker)!=null&&B.port&&(this._worker._pendingDestroy=!0),await((M=this._transport)==null?void 0:M.destroy())}catch(O){throw(k=this._worker)!=null&&k.port&&delete this._worker._pendingDestroy,O}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};a=new WeakMap,bt(s,a,0);let PDFDocumentLoadingTask=s;exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(B,M,k=!1,O=null){this.length=B,this.initialData=M,this.progressiveDone=k,this.contentDispositionFilename=O,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=new _util.PromiseCapability}addRangeListener(B){this._rangeListeners.push(B)}addProgressListener(B){this._progressListeners.push(B)}addProgressiveReadListener(B){this._progressiveReadListeners.push(B)}addProgressiveDoneListener(B){this._progressiveDoneListeners.push(B)}onDataRange(B,M){for(const k of this._rangeListeners)k(B,M)}onDataProgress(B,M){this._readyCapability.promise.then(()=>{for(const k of this._progressListeners)k(B,M)})}onDataProgressiveRead(B){this._readyCapability.promise.then(()=>{for(const M of this._progressiveReadListeners)M(B)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const B of this._progressiveDoneListeners)B()})}transportReady(){this._readyCapability.resolve()}requestDataRange(B,M){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(B,M){this._pdfInfo=B,this._transport=M,Object.defineProperty(this,"getJavaScript",{value:()=>((0,_display_utils.deprecated)("`PDFDocumentProxy.getJavaScript`, please use `PDFDocumentProxy.getJSActions` instead."),this.getJSActions().then(k=>{if(!k)return k;const O=[];for(const H in k)O.push(...k[H]);return O}))})}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(B){return this._transport.getPage(B)}getPageIndex(B){return this._transport.getPageIndex(B)}getDestinations(){return this._transport.getDestinations()}getDestination(B){return this._transport.getDestination(B)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(B=!1){return this._transport.startCleanup(B||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}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()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(B,M,k,O=!1){bt(this,d);bt(this,c,null);bt(this,u,!1);this._pageIndex=B,this._pageInfo=M,this._transport=k,this._stats=O?new _display_utils.StatTimer:null,this._pdfBug=O,this.commonObjs=k.commonObjs,this.objs=new PDFObjects,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:B,rotation:M=this.rotate,offsetX:k=0,offsetY:O=0,dontFlip:H=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:B,rotation:M,offsetX:k,offsetY:O,dontFlip:H})}getAnnotations({intent:B="display"}={}){const M=this._transport.getRenderingIntent(B);return this._transport.getAnnotations(this._pageIndex,M.renderingIntent)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var B;return((B=this._transport._htmlForXfa)==null?void 0:B.children[this._pageIndex])||null}render({canvasContext:B,viewport:M,intent:k="display",annotationMode:O=_util.AnnotationMode.ENABLE,transform:H=null,background:j=null,optionalContentConfigPromise:q=null,annotationCanvasMap:L=null,pageColors:F=null,printAnnotationStorage:U=null}){var J,ee;(J=this._stats)==null||J.time("Overall");const N=this._transport.getRenderingIntent(k,O,U);Ct(this,u,!1),it(this,d,po).call(this),q||(q=this._transport.getOptionalContentConfig());let D=this._intentStates.get(N.cacheKey);D||(D=Object.create(null),this._intentStates.set(N.cacheKey,D)),D.streamReaderCancelTimeout&&(clearTimeout(D.streamReaderCancelTimeout),D.streamReaderCancelTimeout=null);const W=!!(N.renderingIntent&_util.RenderingIntentFlag.PRINT);D.displayReadyCapability||(D.displayReadyCapability=new _util.PromiseCapability,D.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(ee=this._stats)==null||ee.time("Page Request"),this._pumpOperatorList(N));const Z=re=>{var ae,V;D.renderTasks.delete(Q),(this._maybeCleanupAfterRender||W)&&Ct(this,u,!0),it(this,d,ka).call(this,!W),re?(Q.capability.reject(re),this._abortOperatorList({intentState:D,reason:re instanceof Error?re:new Error(re)})):Q.capability.resolve(),(ae=this._stats)==null||ae.timeEnd("Rendering"),(V=this._stats)==null||V.timeEnd("Overall")},Q=new InternalRenderTask({callback:Z,params:{canvasContext:B,viewport:M,transform:H,background:j},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:L,operatorList:D.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!W,pdfBug:this._pdfBug,pageColors:F});(D.renderTasks||(D.renderTasks=new Set)).add(Q);const Y=Q.task;return Promise.all([D.displayReadyCapability.promise,q]).then(([re,ae])=>{var V;if(this.destroyed){Z();return}(V=this._stats)==null||V.time("Rendering"),Q.initializeGraphics({transparency:re,optionalContentConfig:ae}),Q.operatorListChanged()}).catch(Z),Y}getOperatorList({intent:B="display",annotationMode:M=_util.AnnotationMode.ENABLE,printAnnotationStorage:k=null}={}){var L;function O(){j.operatorList.lastChunk&&(j.opListReadCapability.resolve(j.operatorList),j.renderTasks.delete(q))}const H=this._transport.getRenderingIntent(B,M,k,!0);let j=this._intentStates.get(H.cacheKey);j||(j=Object.create(null),this._intentStates.set(H.cacheKey,j));let q;return j.opListReadCapability||(q=Object.create(null),q.operatorListChanged=O,j.opListReadCapability=new _util.PromiseCapability,(j.renderTasks||(j.renderTasks=new Set)).add(q),j.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(L=this._stats)==null||L.time("Page Request"),this._pumpOperatorList(H)),j.opListReadCapability.promise}streamTextContent({includeMarkedContent:B=!1,disableNormalization:M=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:B===!0,disableNormalization:M===!0},{highWaterMark:100,size(O){return O.items.length}})}getTextContent(B={}){if(this._transport._htmlForXfa)return this.getXfa().then(k=>_xfa_text.XfaText.textContent(k));const M=this.streamTextContent(B);return new Promise(function(k,O){function H(){j.read().then(function({value:L,done:F}){if(F){k(q);return}Object.assign(q.styles,L.styles),q.items.push(...L.items),H()},O)}const j=M.getReader(),q={items:[],styles:Object.create(null)};H()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const B=[];for(const M of this._intentStates.values())if(this._abortOperatorList({intentState:M,reason:new Error("Page was destroyed."),force:!0}),!M.opListReadCapability)for(const k of M.renderTasks)B.push(k.completed),k.cancel();return this.objs.clear(),Ct(this,u,!1),it(this,d,po).call(this),Promise.all(B)}cleanup(B=!1){Ct(this,u,!0);const M=it(this,d,ka).call(this,!1);return B&&M&&this._stats&&(this._stats=new _display_utils.StatTimer),M}_startRenderPage(B,M){var O,H;const k=this._intentStates.get(M);k&&((O=this._stats)==null||O.timeEnd("Page Request"),(H=k.displayReadyCapability)==null||H.resolve(B))}_renderPageChunk(B,M){for(let k=0,O=B.length;k<O;k++)M.operatorList.fnArray.push(B.fnArray[k]),M.operatorList.argsArray.push(B.argsArray[k]);M.operatorList.lastChunk=B.lastChunk,M.operatorList.separateAnnots=B.separateAnnots;for(const k of M.renderTasks)k.operatorListChanged();B.lastChunk&&it(this,d,ka).call(this,!0)}_pumpOperatorList({renderingIntent:B,cacheKey:M,annotationStorageSerializable:k}){const{map:O,transfers:H}=k,q=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:B,cacheKey:M,annotationStorage:O},H).getReader(),L=this._intentStates.get(M);L.streamReader=q;const F=()=>{q.read().then(({value:U,done:N})=>{if(N){L.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(U,L),F())},U=>{if(L.streamReader=null,!this._transport.destroyed){if(L.operatorList){L.operatorList.lastChunk=!0;for(const N of L.renderTasks)N.operatorListChanged();it(this,d,ka).call(this,!0)}if(L.displayReadyCapability)L.displayReadyCapability.reject(U);else if(L.opListReadCapability)L.opListReadCapability.reject(U);else throw U}})};F()}_abortOperatorList({intentState:B,reason:M,force:k=!1}){if(B.streamReader){if(B.streamReaderCancelTimeout&&(clearTimeout(B.streamReaderCancelTimeout),B.streamReaderCancelTimeout=null),!k){if(B.renderTasks.size>0)return;if(M instanceof _display_utils.RenderingCancelledException){let O=RENDERING_CANCELLED_TIMEOUT;M.extraDelay>0&&M.extraDelay<1e3&&(O+=M.extraDelay),B.streamReaderCancelTimeout=setTimeout(()=>{B.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:B,reason:M,force:!0})},O);return}}if(B.streamReader.cancel(new _util.AbortException(M.message)).catch(()=>{}),B.streamReader=null,!this._transport.destroyed){for(const[O,H]of this._intentStates)if(H===B){this._intentStates.delete(O);break}this.cleanup()}}}get stats(){return this._stats}}c=new WeakMap,u=new WeakMap,d=new WeakSet,ka=function(B=!1){if(it(this,d,po).call(this),!He(this,u)||this.destroyed)return!1;if(B)return Ct(this,c,setTimeout(()=>{Ct(this,c,null),it(this,d,ka).call(this,!1)},DELAYED_CLEANUP_TIMEOUT)),!1;for(const{renderTasks:M,operatorList:k}of this._intentStates.values())if(M.size>0||!k.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),Ct(this,u,!1),!0},po=function(){He(this,c)&&(clearTimeout(He(this,c)),Ct(this,c,null))},exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){bt(this,A,new Set);bt(this,b,Promise.resolve())}postMessage(B,M){const k={data:structuredClone(B,M?{transfer:M}:null)};He(this,b).then(()=>{for(const O of He(this,A))O.call(this,k)})}addEventListener(B,M){He(this,A).add(M)}removeEventListener(B,M){He(this,A).delete(M)}terminate(){He(this,A).clear()}}A=new WeakMap,b=new WeakMap,exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};exports.PDFWorkerUtil=PDFWorkerUtil;{if(_util.isNodeJS&&typeof commonjsRequire=="function")PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if(typeof document=="object"){const T=(g=document==null?void 0:document.currentScript)==null?void 0:g.src;T&&(PDFWorkerUtil.fallbackWorkerSrc=T.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(T,B){let M;try{if(M=new URL(T),!M.origin||M.origin==="null")return!1}catch{return!1}const k=new URL(B,M);return M.origin===k.origin},PDFWorkerUtil.createCDNWrapper=function(T){const B=`importScripts("${T}");`;return URL.createObjectURL(new Blob([B]))}}const _PDFWorker=class _PDFWorker{constructor({name:T=null,port:B=null,verbosity:M=(0,_util.getVerbosityLevel)()}={}){var k;if(this.name=T,this.destroyed=!1,this.verbosity=M,this._readyCapability=new _util.PromiseCapability,this._port=null,this._webWorker=null,this._messageHandler=null,B){if((k=He(_PDFWorker,x))!=null&&k.has(B))throw new Error("Cannot use more than one PDFWorker per port.");(He(_PDFWorker,x)||Ct(_PDFWorker,x,new WeakMap)).set(B,this),this._initializeFromPort(B);return}this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(T){this._port=T,this._messageHandler=new _message_handler.MessageHandler("main","worker",T),this._messageHandler.on("ready",function(){}),this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!PDFWorkerUtil.isWorkerDisabled&&!_PDFWorker._mainThreadWorkerMessageHandler){let{workerSrc:T}=_PDFWorker;try{PDFWorkerUtil.isSameOrigin(window.location.href,T)||(T=PDFWorkerUtil.createCDNWrapper(new URL(T,window.location).href));const B=new Worker(T),M=new _message_handler.MessageHandler("main","worker",B),k=()=>{B.removeEventListener("error",O),M.destroy(),B.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},O=()=>{this._webWorker||k()};B.addEventListener("error",O),M.on("test",j=>{if(B.removeEventListener("error",O),this.destroyed){k();return}j?(this._messageHandler=M,this._port=B,this._webWorker=B,this._readyCapability.resolve(),M.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),M.destroy(),B.terminate())}),M.on("ready",j=>{if(B.removeEventListener("error",O),this.destroyed){k();return}try{H()}catch{this._setupFakeWorker()}});const H=()=>{const j=new Uint8Array;M.send("test",j,[j.buffer])};H();return}catch{(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),_PDFWorker._setupFakeWorkerGlobal.then(T=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const B=new LoopbackPort;this._port=B;const M=`fake${PDFWorkerUtil.fakeWorkerId++}`,k=new _message_handler.MessageHandler(M+"_worker",M,B);T.setup(k,B);const O=new _message_handler.MessageHandler(M,M+"_worker",B);this._messageHandler=O,this._readyCapability.resolve(),O.send("configure",{verbosity:this.verbosity})}).catch(T=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${T.message}".`))})}destroy(){var T;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(T=He(_PDFWorker,x))==null||T.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(T){var M;if(!(T!=null&&T.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const B=(M=He(this,x))==null?void 0:M.get(T.port);if(B){if(B._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return B}return new _PDFWorker(T)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(PDFWorkerUtil.fallbackWorkerSrc!==null)return _util.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){var T;try{return((T=globalThis.pdfjsWorker)==null?void 0:T.WorkerMessageHandler)||null}catch{return null}}static get _setupFakeWorkerGlobal(){const loader=async()=>{const mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_util.isNodeJS&&typeof commonjsRequire=="function"){const worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return await(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler};return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}};x=new WeakMap,bt(_PDFWorker,x);let PDFWorker=_PDFWorker;exports.PDFWorker=PDFWorker;class WorkerTransport{constructor(B,M,k,O,H){bt(this,S);bt(this,y,new Map);bt(this,f,new Map);bt(this,m,new Map);bt(this,C,null);this.messageHandler=B,this.loadingTask=M,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({ownerDocument:O.ownerDocument,styleElement:O.styleElement}),this._params=O,this.canvasFactory=H.canvasFactory,this.filterFactory=H.filterFactory,this.cMapReaderFactory=H.cMapReaderFactory,this.standardFontDataFactory=H.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=k,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=new _util.PromiseCapability,this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}getRenderingIntent(B,M=_util.AnnotationMode.ENABLE,k=null,O=!1){let H=_util.RenderingIntentFlag.DISPLAY,j=_annotation_storage.SerializableEmpty;switch(B){case"any":H=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":H=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${B}`)}switch(M){case _util.AnnotationMode.DISABLE:H+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:H+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:H+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,j=(H&_util.RenderingIntentFlag.PRINT&&k instanceof _annotation_storage.PrintAnnotationStorage?k:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${M}`)}return O&&(H+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:H,cacheKey:`${H}_${j.hash}`,annotationStorageSerializable:j}}destroy(){var k;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=new _util.PromiseCapability,(k=He(this,C))==null||k.reject(new Error("Worker was destroyed during onPassword callback"));const B=[];for(const O of He(this,f).values())B.push(O._destroy());He(this,f).clear(),He(this,m).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const M=this.messageHandler.sendWithPromise("Terminate",null);return B.push(M),Promise.all(B).then(()=>{var O;this.commonObjs.clear(),this.fontLoader.clear(),He(this,y).clear(),this.filterFactory.destroy(),(O=this._networkStream)==null||O.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:B,loadingTask:M}=this;B.on("GetReader",(k,O)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=H=>{this._lastProgress={loaded:H.loaded,total:H.total}},O.onPull=()=>{this._fullReader.read().then(function({value:H,done:j}){if(j){O.close();return}(0,_util.assert)(H instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),O.enqueue(new Uint8Array(H),1,[H])}).catch(H=>{O.error(H)})},O.onCancel=H=>{this._fullReader.cancel(H),O.ready.catch(j=>{if(!this.destroyed)throw j})}}),B.on("ReaderHeadersReady",k=>{const O=new _util.PromiseCapability,H=this._fullReader;return H.headersReady.then(()=>{var j;(!H.isStreamingSupported||!H.isRangeSupported)&&(this._lastProgress&&((j=M.onProgress)==null||j.call(M,this._lastProgress)),H.onProgress=q=>{var L;(L=M.onProgress)==null||L.call(M,{loaded:q.loaded,total:q.total})}),O.resolve({isStreamingSupported:H.isStreamingSupported,isRangeSupported:H.isRangeSupported,contentLength:H.contentLength})},O.reject),O.promise}),B.on("GetRangeReader",(k,O)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const H=this._networkStream.getRangeReader(k.begin,k.end);if(!H){O.close();return}O.onPull=()=>{H.read().then(function({value:j,done:q}){if(q){O.close();return}(0,_util.assert)(j instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),O.enqueue(new Uint8Array(j),1,[j])}).catch(j=>{O.error(j)})},O.onCancel=j=>{H.cancel(j),O.ready.catch(q=>{if(!this.destroyed)throw q})}}),B.on("GetDoc",({pdfInfo:k})=>{this._numPages=k.numPages,this._htmlForXfa=k.htmlForXfa,delete k.htmlForXfa,M._capability.resolve(new PDFDocumentProxy(k,this))}),B.on("DocException",function(k){let O;switch(k.name){case"PasswordException":O=new _util.PasswordException(k.message,k.code);break;case"InvalidPDFException":O=new _util.InvalidPDFException(k.message);break;case"MissingPDFException":O=new _util.MissingPDFException(k.message);break;case"UnexpectedResponseException":O=new _util.UnexpectedResponseException(k.message,k.status);break;case"UnknownErrorException":O=new _util.UnknownErrorException(k.message,k.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}M._capability.reject(O)}),B.on("PasswordRequest",k=>{if(Ct(this,C,new _util.PromiseCapability),M.onPassword){const O=H=>{H instanceof Error?He(this,C).reject(H):He(this,C).resolve({password:H})};try{M.onPassword(O,k.code)}catch(H){He(this,C).reject(H)}}else He(this,C).reject(new _util.PasswordException(k.message,k.code));return He(this,C).promise}),B.on("DataLoaded",k=>{var O;(O=M.onProgress)==null||O.call(M,{loaded:k.length,total:k.length}),this.downloadInfoCapability.resolve(k)}),B.on("StartRenderPage",k=>{if(this.destroyed)return;He(this,f).get(k.pageIndex)._startRenderPage(k.transparency,k.cacheKey)}),B.on("commonobj",([k,O,H])=>{var j;if(!this.destroyed&&!this.commonObjs.has(k))switch(O){case"Font":const q=this._params;if("error"in H){const U=H.error;(0,_util.warn)(`Error during font loading: ${U}`),this.commonObjs.resolve(k,U);break}const L=q.pdfBug&&((j=globalThis.FontInspector)!=null&&j.enabled)?(U,N)=>globalThis.FontInspector.fontAdded(U,N):null,F=new _font_loader.FontFaceObject(H,{isEvalSupported:q.isEvalSupported,disableFontFace:q.disableFontFace,ignoreErrors:q.ignoreErrors,inspectFont:L});this.fontLoader.bind(F).catch(U=>B.sendWithPromise("FontFallback",{id:k})).finally(()=>{!q.fontExtraProperties&&F.data&&(F.data=null),this.commonObjs.resolve(k,F)});break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(k,H);break;default:throw new Error(`Got unknown common object type ${O}`)}}),B.on("obj",([k,O,H,j])=>{var L;if(this.destroyed)return;const q=He(this,f).get(O);if(!q.objs.has(k))switch(H){case"Image":if(q.objs.resolve(k,j),j){let F;if(j.bitmap){const{width:U,height:N}=j;F=U*N*4}else F=((L=j.data)==null?void 0:L.length)||0;F>_util.MAX_IMAGE_SIZE_TO_CACHE&&(q._maybeCleanupAfterRender=!0)}break;case"Pattern":q.objs.resolve(k,j);break;default:throw new Error(`Got unknown object type ${H}`)}}),B.on("DocProgress",k=>{var O;this.destroyed||(O=M.onProgress)==null||O.call(M,{loaded:k.loaded,total:k.total})}),B.on("FetchBuiltInCMap",k=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(k):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),B.on("FetchStandardFontData",k=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(k):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var k;this.annotationStorage.size<=0&&(0,_util.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:B,transfers:M}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:B,filename:((k=this._fullReader)==null?void 0:k.filename)??null},M).finally(()=>{this.annotationStorage.resetModified()})}getPage(B){if(!Number.isInteger(B)||B<=0||B>this._numPages)return Promise.reject(new Error("Invalid page request."));const M=B-1,k=He(this,m).get(M);if(k)return k;const O=this.messageHandler.sendWithPromise("GetPage",{pageIndex:M}).then(H=>{if(this.destroyed)throw new Error("Transport destroyed");const j=new PDFPageProxy(M,H,this,this._params.pdfBug);return He(this,f).set(M,j),j});return He(this,m).set(M,O),O}getPageIndex(B){return typeof B!="object"||B===null||!Number.isInteger(B.num)||B.num<0||!Number.isInteger(B.gen)||B.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:B.num,gen:B.gen})}getAnnotations(B,M){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:B,intent:M})}getFieldObjects(){return it(this,S,go).call(this,"GetFieldObjects")}hasJSActions(){return it(this,S,go).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(B){return typeof B!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:B})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return it(this,S,go).call(this,"GetDocJSActions")}getPageJSActions(B){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:B})}getStructTree(B){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:B})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then(B=>new _optional_content_config.OptionalContentConfig(B))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const B="GetMetadata",M=He(this,y).get(B);if(M)return M;const k=this.messageHandler.sendWithPromise(B,null).then(O=>{var H,j;return{info:O[0],metadata:O[1]?new _metadata.Metadata(O[1]):null,contentDispositionFilename:((H=this._fullReader)==null?void 0:H.filename)??null,contentLength:((j=this._fullReader)==null?void 0:j.contentLength)??null}});return He(this,y).set(B,k),k}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(B=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const M of He(this,f).values())if(!M.cleanup())throw new Error(`startCleanup: Page ${M.pageNumber} is currently rendering.`);this.commonObjs.clear(),B||this.fontLoader.clear(),He(this,y).clear(),this.filterFactory.destroy(!0)}}get loadingParams(){const{disableAutoFetch:B,enableXfa:M}=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:B,enableXfa:M})}}y=new WeakMap,f=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakSet,go=function(B,M=null){const k=He(this,y).get(B);if(k)return k;const O=this.messageHandler.sendWithPromise(B,M);return He(this,y).set(B,O),O};class PDFObjects{constructor(){bt(this,I);bt(this,_,Object.create(null))}get(B,M=null){if(M){const O=it(this,I,Gs).call(this,B);return O.capability.promise.then(()=>M(O.data)),null}const k=He(this,_)[B];if(!(k!=null&&k.capability.settled))throw new Error(`Requesting object that isn't resolved yet ${B}.`);return k.data}has(B){const M=He(this,_)[B];return(M==null?void 0:M.capability.settled)||!1}resolve(B,M=null){const k=it(this,I,Gs).call(this,B);k.data=M,k.capability.resolve()}clear(){var B;for(const M in He(this,_)){const{data:k}=He(this,_)[M];(B=k==null?void 0:k.bitmap)==null||B.close()}Ct(this,_,Object.create(null))}}_=new WeakMap,I=new WeakSet,Gs=function(B){var M;return(M=He(this,_))[B]||(M[B]={capability:new _util.PromiseCapability,data:null})};class RenderTask{constructor(B){bt(this,P,null);Ct(this,P,B),this.onContinue=null}get promise(){return He(this,P).capability.promise}cancel(B=0){He(this,P).cancel(null,B)}get separateAnnots(){const{separateAnnots:B}=He(this,P).operatorList;if(!B)return!1;const{annotationCanvasMap:M}=He(this,P);return B.form||B.canvas&&(M==null?void 0:M.size)>0}}P=new WeakMap,exports.RenderTask=RenderTask;const R=class R{constructor({callback:B,params:M,objs:k,commonObjs:O,annotationCanvasMap:H,operatorList:j,pageIndex:q,canvasFactory:L,filterFactory:F,useRequestAnimationFrame:U=!1,pdfBug:N=!1,pageColors:D=null}){this.callback=B,this.params=M,this.objs=k,this.commonObjs=O,this.annotationCanvasMap=H,this.operatorListIdx=null,this.operatorList=j,this._pageIndex=q,this.canvasFactory=L,this.filterFactory=F,this._pdfBug=N,this.pageColors=D,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=U===!0&&typeof window<"u",this.cancelled=!1,this.capability=new _util.PromiseCapability,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=M.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:B=!1,optionalContentConfig:M}){var q,L;if(this.cancelled)return;if(this._canvas){if(He(R,E).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.");He(R,E).add(this._canvas)}this._pdfBug&&((q=globalThis.StepperManager)!=null&&q.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:k,viewport:O,transform:H,background:j}=this.params;this.gfx=new _canvas.CanvasGraphics(k,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:M},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:H,viewport:O,transparency:B,background:j}),this.operatorListIdx=0,this.graphicsReady=!0,(L=this.graphicsReadyCallback)==null||L.call(this)}cancel(B=null,M=0){var k;this.running=!1,this.cancelled=!0,(k=this.gfx)==null||k.endDrawing(),He(R,E).delete(this._canvas),this.callback(B||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,M))}operatorListChanged(){var B;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(B=this.stepper)==null||B.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame(()=>{this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),He(R,E).delete(this._canvas),this.callback())))}};E=new WeakMap,bt(R,E,new WeakSet);let InternalRenderTask=R;const version="3.11.174";exports.version=version;const build="ce8716743";exports.build=build},(a,s,c)=>{var g,x,y,Su,m;Object.defineProperty(s,"__esModule",{value:!0}),s.SerializableEmpty=s.PrintAnnotationStorage=s.AnnotationStorage=void 0;var u=c(1),d=c(4),p=c(8);const v=Object.freeze({map:null,hash:"",transfers:void 0});s.SerializableEmpty=v;class A{constructor(){bt(this,y);bt(this,g,!1);bt(this,x,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(S,w){const _=He(this,x).get(S);return _===void 0?w:Object.assign(w,_)}getRawValue(S){return He(this,x).get(S)}remove(S){if(He(this,x).delete(S),He(this,x).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const w of He(this,x).values())if(w instanceof d.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(S,w){const _=He(this,x).get(S);let I=!1;if(_!==void 0)for(const[$,P]of Object.entries(w))_[$]!==P&&(I=!0,_[$]=P);else I=!0,He(this,x).set(S,w);I&&it(this,y,Su).call(this),w instanceof d.AnnotationEditor&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(w.constructor._type)}has(S){return He(this,x).has(S)}getAll(){return He(this,x).size>0?(0,u.objectFromMap)(He(this,x)):null}setAll(S){for(const[w,_]of Object.entries(S))this.setValue(w,_)}get size(){return He(this,x).size}resetModified(){He(this,g)&&(Ct(this,g,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new b(this)}get serializable(){if(He(this,x).size===0)return v;const S=new Map,w=new p.MurmurHash3_64,_=[],I=Object.create(null);let $=!1;for(const[P,E]of He(this,x)){const R=E instanceof d.AnnotationEditor?E.serialize(!1,I):E;R&&(S.set(P,R),w.update(`${P}:${JSON.stringify(R)}`),$||($=!!R.bitmap))}if($)for(const P of S.values())P.bitmap&&_.push(P.bitmap);return S.size>0?{map:S,hash:w.hexdigest(),transfers:_}:v}}g=new WeakMap,x=new WeakMap,y=new WeakSet,Su=function(){He(this,g)||(Ct(this,g,!0),typeof this.onSetModified=="function"&&this.onSetModified())},s.AnnotationStorage=A;class b extends A{constructor(w){super();bt(this,m);const{map:_,hash:I,transfers:$}=w.serializable,P=structuredClone(_,$?{transfer:$}:null);Ct(this,m,{map:P,hash:I,transfers:$})}get print(){(0,u.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return He(this,m)}}m=new WeakMap,s.PrintAnnotationStorage=b},(a,s,c)=>{var b,g,x,y,f,m,C,S,w,_,I,$,P,E,R,Vs,Qs,M,qs,Ys,$u,_u,Iu,Ks,Pu;Object.defineProperty(s,"__esModule",{value:!0}),s.AnnotationEditor=void 0;var u=c(5),d=c(1),p=c(6);const U=class U{constructor(D){bt(this,R);bt(this,b,"");bt(this,g,!1);bt(this,x,null);bt(this,y,null);bt(this,f,null);bt(this,m,!1);bt(this,C,null);bt(this,S,this.focusin.bind(this));bt(this,w,this.focusout.bind(this));bt(this,_,!1);bt(this,I,!1);bt(this,$,!1);yr(this,"_initialOptions",Object.create(null));yr(this,"_uiManager",null);yr(this,"_focusEventsAllowed",!0);yr(this,"_l10nPromise",null);bt(this,P,!1);bt(this,E,U._zIndex++);this.constructor===U&&(0,d.unreachable)("Cannot initialize AnnotationEditor."),this.parent=D.parent,this.id=D.id,this.width=this.height=null,this.pageIndex=D.parent.pageIndex,this.name=D.name,this.div=null,this._uiManager=D.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=D.isCentered,this._structTreeParentId=null;const{rotation:W,rawDims:{pageWidth:Z,pageHeight:Q,pageX:Y,pageY:J}}=this.parent.viewport;this.rotation=W,this.pageRotation=(360+W-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[Z,Q],this.pageTranslation=[Y,J];const[ee,re]=this.parentDimensions;this.x=D.x/ee,this.y=D.y/re,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return(0,d.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(D){const W=new A({id:D.parent.getNextId(),parent:D.parent,uiManager:D._uiManager});W.annotationElementId=D.annotationElementId,W.deleted=!0,W._uiManager.addToAnnotationStorage(W)}static initialize(D,W=null){if(U._l10nPromise||(U._l10nPromise=new Map(["editor_alt_text_button_label","editor_alt_text_edit_button_label","editor_alt_text_decorative_tooltip"].map(Q=>[Q,D.get(Q)]))),W!=null&&W.strings)for(const Q of W.strings)U._l10nPromise.set(Q,D.get(Q));if(U._borderLineWidth!==-1)return;const Z=getComputedStyle(document.documentElement);U._borderLineWidth=parseFloat(Z.getPropertyValue("--outline-width"))||0}static updateDefaultParams(D,W){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(D){return!1}static paste(D,W){(0,d.unreachable)("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return He(this,P)}set _isDraggable(D){var W;Ct(this,P,D),(W=this.div)==null||W.classList.toggle("draggable",D)}center(){const[D,W]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*W/(D*2),this.y+=this.width*D/(W*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*W/(D*2),this.y-=this.width*D/(W*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(D){this._uiManager.addCommands(D)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=He(this,E)}setParent(D){D!==null&&(this.pageIndex=D.pageIndex,this.pageDimensions=D.pageDimensions),this.parent=D}focusin(D){this._focusEventsAllowed&&(He(this,_)?Ct(this,_,!1):this.parent.setSelected(this))}focusout(D){var Z;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const W=D.relatedTarget;W!=null&&W.closest(`#${this.id}`)||(D.preventDefault(),(Z=this.parent)!=null&&Z.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(D,W,Z,Q){const[Y,J]=this.parentDimensions;[Z,Q]=this.screenToPageTranslation(Z,Q),this.x=(D+Z)/Y,this.y=(W+Q)/J,this.fixAndSetPosition()}translate(D,W){it(this,R,Vs).call(this,this.parentDimensions,D,W)}translateInPage(D,W){it(this,R,Vs).call(this,this.pageDimensions,D,W),this.div.scrollIntoView({block:"nearest"})}drag(D,W){const[Z,Q]=this.parentDimensions;if(this.x+=D/Z,this.y+=W/Q,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:ae,y:V}=this.div.getBoundingClientRect();this.parent.findNewParent(this,ae,V)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:Y,y:J}=this;const[ee,re]=it(this,R,Qs).call(this);Y+=ee,J+=re,this.div.style.left=`${(100*Y).toFixed(2)}%`,this.div.style.top=`${(100*J).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}fixAndSetPosition(){const[D,W]=this.pageDimensions;let{x:Z,y:Q,width:Y,height:J}=this;switch(Y*=D,J*=W,Z*=D,Q*=W,this.rotation){case 0:Z=Math.max(0,Math.min(D-Y,Z)),Q=Math.max(0,Math.min(W-J,Q));break;case 90:Z=Math.max(0,Math.min(D-J,Z)),Q=Math.min(W,Math.max(Y,Q));break;case 180:Z=Math.min(D,Math.max(Y,Z)),Q=Math.min(W,Math.max(J,Q));break;case 270:Z=Math.min(D,Math.max(J,Z)),Q=Math.max(0,Math.min(W-Y,Q));break}this.x=Z/=D,this.y=Q/=W;const[ee,re]=it(this,R,Qs).call(this);Z+=ee,Q+=re;const{style:ae}=this.div;ae.left=`${(100*Z).toFixed(2)}%`,ae.top=`${(100*Q).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(D,W){var Z;return it(Z=U,M,qs).call(Z,D,W,this.parentRotation)}pageTranslationToScreen(D,W){var Z;return it(Z=U,M,qs).call(Z,D,W,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:D,pageDimensions:[W,Z]}=this,Q=W*D,Y=Z*D;return d.FeatureTest.isCSSRoundSupported?[Math.round(Q),Math.round(Y)]:[Q,Y]}setDims(D,W){var Y;const[Z,Q]=this.parentDimensions;this.div.style.width=`${(100*D/Z).toFixed(2)}%`,He(this,m)||(this.div.style.height=`${(100*W/Q).toFixed(2)}%`),(Y=He(this,x))==null||Y.classList.toggle("small",D<U.SMALL_EDITOR_SIZE||W<U.SMALL_EDITOR_SIZE)}fixDims(){const{style:D}=this.div,{height:W,width:Z}=D,Q=Z.endsWith("%"),Y=!He(this,m)&&W.endsWith("%");if(Q&&Y)return;const[J,ee]=this.parentDimensions;Q||(D.width=`${(100*parseFloat(Z)/J).toFixed(2)}%`),!He(this,m)&&!Y&&(D.height=`${(100*parseFloat(W)/ee).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}async addAltTextButton(){if(He(this,x))return;const D=Ct(this,x,document.createElement("button"));D.className="altText";const W=await U._l10nPromise.get("editor_alt_text_button_label");D.textContent=W,D.setAttribute("aria-label",W),D.tabIndex="0",D.addEventListener("contextmenu",p.noContextMenu),D.addEventListener("pointerdown",Z=>Z.stopPropagation()),D.addEventListener("click",Z=>{Z.preventDefault(),this._uiManager.editAltText(this)},{capture:!0}),D.addEventListener("keydown",Z=>{Z.target===D&&Z.key==="Enter"&&(Z.preventDefault(),this._uiManager.editAltText(this))}),it(this,R,Ks).call(this),this.div.append(D),U.SMALL_EDITOR_SIZE||(U.SMALL_EDITOR_SIZE=Math.min(128,Math.round(D.getBoundingClientRect().width*1.4)))}getClientDimensions(){return this.div.getBoundingClientRect()}get altTextData(){return{altText:He(this,b),decorative:He(this,g)}}set altTextData({altText:D,decorative:W}){He(this,b)===D&&He(this,g)===W||(Ct(this,b,D),Ct(this,g,W),it(this,R,Ks).call(this))}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.setAttribute("tabIndex",0),this.setInForeground(),this.div.addEventListener("focusin",He(this,S)),this.div.addEventListener("focusout",He(this,w));const[D,W]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*W/D).toFixed(2)}%`,this.div.style.maxHeight=`${(100*D/W).toFixed(2)}%`);const[Z,Q]=this.getInitialTranslation();return this.translate(Z,Q),(0,u.bindEvents)(this,this.div,["pointerdown"]),this.div}pointerdown(D){const{isMac:W}=d.FeatureTest.platform;if(D.button!==0||D.ctrlKey&&W){D.preventDefault();return}Ct(this,_,!0),it(this,R,Pu).call(this,D)}moveInDOM(){var D;(D=this.parent)==null||D.moveEditorInDOM(this)}_setParentAndPosition(D,W,Z){D.changeParent(this),this.x=W,this.y=Z,this.fixAndSetPosition()}getRect(D,W){const Z=this.parentScale,[Q,Y]=this.pageDimensions,[J,ee]=this.pageTranslation,re=D/Z,ae=W/Z,V=this.x*Q,K=this.y*Y,te=this.width*Q,ie=this.height*Y;switch(this.rotation){case 0:return[V+re+J,Y-K-ae-ie+ee,V+re+te+J,Y-K-ae+ee];case 90:return[V+ae+J,Y-K+re+ee,V+ae+ie+J,Y-K+re+te+ee];case 180:return[V-re-te+J,Y-K+ae+ee,V-re+J,Y-K+ae+ie+ee];case 270:return[V-ae-ie+J,Y-K-re-te+ee,V-ae+J,Y-K-re+ee];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(D,W){const[Z,Q,Y,J]=D,ee=Y-Z,re=J-Q;switch(this.rotation){case 0:return[Z,W-J,ee,re];case 90:return[Z,W-Q,re,ee];case 180:return[Y,W-Q,ee,re];case 270:return[Y,W-J,re,ee];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){Ct(this,$,!0)}disableEditMode(){Ct(this,$,!1)}isInEditMode(){return He(this,$)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var D,W;(D=this.div)==null||D.addEventListener("focusin",He(this,S)),(W=this.div)==null||W.addEventListener("focusout",He(this,w))}serialize(D=!1,W=null){(0,d.unreachable)("An editor must be serializable")}static deserialize(D,W,Z){const Q=new this.prototype.constructor({parent:W,id:W.getNextId(),uiManager:Z});Q.rotation=D.rotation;const[Y,J]=Q.pageDimensions,[ee,re,ae,V]=Q.getRectInCurrentCoords(D.rect,J);return Q.x=ee/Y,Q.y=re/J,Q.width=ae/Y,Q.height=V/J,Q}remove(){var D;this.div.removeEventListener("focusin",He(this,S)),this.div.removeEventListener("focusout",He(this,w)),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),(D=He(this,x))==null||D.remove(),Ct(this,x,null),Ct(this,y,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(it(this,R,$u).call(this),He(this,C).classList.remove("hidden"))}select(){var D;this.makeResizable(),(D=this.div)==null||D.classList.add("selectedEditor")}unselect(){var D,W,Z;(D=He(this,C))==null||D.classList.add("hidden"),(W=this.div)==null||W.classList.remove("selectedEditor"),(Z=this.div)!=null&&Z.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus()}updateParams(D,W){}disableEditing(){He(this,x)&&(He(this,x).hidden=!0)}enableEditing(){He(this,x)&&(He(this,x).hidden=!1)}enterInEditMode(){}get contentDiv(){return this.div}get isEditing(){return He(this,I)}set isEditing(D){Ct(this,I,D),this.parent&&(D?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(D,W){Ct(this,m,!0);const Z=D/W,{style:Q}=this.div;Q.aspectRatio=Z,Q.height="auto"}static get MIN_SIZE(){return 16}};b=new WeakMap,g=new WeakMap,x=new WeakMap,y=new WeakMap,f=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakMap,w=new WeakMap,_=new WeakMap,I=new WeakMap,$=new WeakMap,P=new WeakMap,E=new WeakMap,R=new WeakSet,Vs=function([D,W],Z,Q){[Z,Q]=this.screenToPageTranslation(Z,Q),this.x+=Z/D,this.y+=Q/W,this.fixAndSetPosition()},Qs=function(){const[D,W]=this.parentDimensions,{_borderLineWidth:Z}=U,Q=Z/D,Y=Z/W;switch(this.rotation){case 90:return[-Q,Y];case 180:return[Q,Y];case 270:return[Q,-Y];default:return[-Q,-Y]}},M=new WeakSet,qs=function(D,W,Z){switch(Z){case 90:return[W,-D];case 180:return[-D,-W];case 270:return[-W,D];default:return[D,W]}},Ys=function(D){switch(D){case 90:{const[W,Z]=this.pageDimensions;return[0,-W/Z,Z/W,0]}case 180:return[-1,0,0,-1];case 270:{const[W,Z]=this.pageDimensions;return[0,W/Z,-Z/W,0]}default:return[1,0,0,1]}},$u=function(){if(He(this,C))return;Ct(this,C,document.createElement("div")),He(this,C).classList.add("resizers");const D=["topLeft","topRight","bottomRight","bottomLeft"];this._willKeepAspectRatio||D.push("topMiddle","middleRight","bottomMiddle","middleLeft");for(const W of D){const Z=document.createElement("div");He(this,C).append(Z),Z.classList.add("resizer",W),Z.addEventListener("pointerdown",it(this,R,_u).bind(this,W)),Z.addEventListener("contextmenu",p.noContextMenu)}this.div.prepend(He(this,C))},_u=function(D,W){W.preventDefault();const{isMac:Z}=d.FeatureTest.platform;if(W.button!==0||W.ctrlKey&&Z)return;const Q=it(this,R,Iu).bind(this,D),Y=this._isDraggable;this._isDraggable=!1;const J={passive:!0,capture:!0};window.addEventListener("pointermove",Q,J);const ee=this.x,re=this.y,ae=this.width,V=this.height,K=this.parent.div.style.cursor,te=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(W.target).cursor;const ie=()=>{this._isDraggable=Y,window.removeEventListener("pointerup",ie),window.removeEventListener("blur",ie),window.removeEventListener("pointermove",Q,J),this.parent.div.style.cursor=K,this.div.style.cursor=te;const ce=this.x,me=this.y,we=this.width,ve=this.height;ce===ee&&me===re&&we===ae&&ve===V||this.addCommands({cmd:()=>{this.width=we,this.height=ve,this.x=ce,this.y=me;const[ge,ue]=this.parentDimensions;this.setDims(ge*we,ue*ve),this.fixAndSetPosition()},undo:()=>{this.width=ae,this.height=V,this.x=ee,this.y=re;const[ge,ue]=this.parentDimensions;this.setDims(ge*ae,ue*V),this.fixAndSetPosition()},mustExec:!0})};window.addEventListener("pointerup",ie),window.addEventListener("blur",ie)},Iu=function(D,W){const[Z,Q]=this.parentDimensions,Y=this.x,J=this.y,ee=this.width,re=this.height,ae=U.MIN_SIZE/Z,V=U.MIN_SIZE/Q,K=ye=>Math.round(ye*1e4)/1e4,te=it(this,R,Ys).call(this,this.rotation),ie=(ye,Pe)=>[te[0]*ye+te[2]*Pe,te[1]*ye+te[3]*Pe],ce=it(this,R,Ys).call(this,360-this.rotation),me=(ye,Pe)=>[ce[0]*ye+ce[2]*Pe,ce[1]*ye+ce[3]*Pe];let we,ve,ge=!1,ue=!1;switch(D){case"topLeft":ge=!0,we=(ye,Pe)=>[0,0],ve=(ye,Pe)=>[ye,Pe];break;case"topMiddle":we=(ye,Pe)=>[ye/2,0],ve=(ye,Pe)=>[ye/2,Pe];break;case"topRight":ge=!0,we=(ye,Pe)=>[ye,0],ve=(ye,Pe)=>[0,Pe];break;case"middleRight":ue=!0,we=(ye,Pe)=>[ye,Pe/2],ve=(ye,Pe)=>[0,Pe/2];break;case"bottomRight":ge=!0,we=(ye,Pe)=>[ye,Pe],ve=(ye,Pe)=>[0,0];break;case"bottomMiddle":we=(ye,Pe)=>[ye/2,Pe],ve=(ye,Pe)=>[ye/2,0];break;case"bottomLeft":ge=!0,we=(ye,Pe)=>[0,Pe],ve=(ye,Pe)=>[ye,0];break;case"middleLeft":ue=!0,we=(ye,Pe)=>[0,Pe/2],ve=(ye,Pe)=>[ye,Pe/2];break}const se=we(ee,re),oe=ve(ee,re);let de=ie(...oe);const le=K(Y+de[0]),xe=K(J+de[1]);let Ce=1,$e=1,[Se,Ee]=this.screenToPageTranslation(W.movementX,W.movementY);if([Se,Ee]=me(Se/Z,Ee/Q),ge){const ye=Math.hypot(ee,re);Ce=$e=Math.max(Math.min(Math.hypot(oe[0]-se[0]-Se,oe[1]-se[1]-Ee)/ye,1/ee,1/re),ae/ee,V/re)}else ue?Ce=Math.max(ae,Math.min(1,Math.abs(oe[0]-se[0]-Se)))/ee:$e=Math.max(V,Math.min(1,Math.abs(oe[1]-se[1]-Ee)))/re;const Ae=K(ee*Ce),pe=K(re*$e);de=ie(...ve(Ae,pe));const he=le-de[0],Ie=xe-de[1];this.width=Ae,this.height=pe,this.x=he,this.y=Ie,this.setDims(Z*Ae,Q*pe),this.fixAndSetPosition()},Ks=async function(){var Z;const D=He(this,x);if(!D)return;if(!He(this,b)&&!He(this,g)){D.classList.remove("done"),(Z=He(this,y))==null||Z.remove();return}U._l10nPromise.get("editor_alt_text_edit_button_label").then(Q=>{D.setAttribute("aria-label",Q)});let W=He(this,y);if(!W){Ct(this,y,W=document.createElement("span")),W.className="tooltip",W.setAttribute("role","tooltip");const Q=W.id=`alt-text-tooltip-${this.id}`;D.setAttribute("aria-describedby",Q);const Y=100;D.addEventListener("mouseenter",()=>{Ct(this,f,setTimeout(()=>{Ct(this,f,null),He(this,y).classList.add("show"),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",subtype:this.editorType,data:{action:"alt_text_tooltip"}}})},Y))}),D.addEventListener("mouseleave",()=>{var J;clearTimeout(He(this,f)),Ct(this,f,null),(J=He(this,y))==null||J.classList.remove("show")})}D.classList.add("done"),W.innerText=He(this,g)?await U._l10nPromise.get("editor_alt_text_decorative_tooltip"):He(this,b),W.parentNode||D.append(W)},Pu=function(D){if(!this._isDraggable)return;const W=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let Z,Q;W&&(Z={passive:!0,capture:!0},Q=J=>{const[ee,re]=this.screenToPageTranslation(J.movementX,J.movementY);this._uiManager.dragSelectedEditors(ee,re)},window.addEventListener("pointermove",Q,Z));const Y=()=>{if(window.removeEventListener("pointerup",Y),window.removeEventListener("blur",Y),W&&window.removeEventListener("pointermove",Q,Z),Ct(this,_,!1),!this._uiManager.endDragSession()){const{isMac:J}=d.FeatureTest.platform;D.ctrlKey&&!J||D.shiftKey||D.metaKey&&J?this.parent.toggleSelected(this):this.parent.setSelected(this)}};window.addEventListener("pointerup",Y),window.addEventListener("blur",Y)},bt(U,M),yr(U,"_borderLineWidth",-1),yr(U,"_colorManager",new u.ColorManager),yr(U,"_zIndex",1),yr(U,"SMALL_EDITOR_SIZE",0);let v=U;s.AnnotationEditor=v;class A extends v{constructor(D){super(D),this.annotationElementId=D.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}},(a,s,c)=>{var m,C,S,w,_,Xs,P,E,R,T,B,Tu,O,H,j,q,L,F,U,N,D,W,Z,Q,Y,J,ee,re,ae,V,K,te,ie,ce,me,we,ve,ge,ue,se,oe,de,le,xe,Ce,$e,Se,Ru,Zs,Js,mo,el,tl,_n,pi,Bu,Mu,rl,gi,nl;Object.defineProperty(s,"__esModule",{value:!0}),s.KeyboardManager=s.CommandManager=s.ColorManager=s.AnnotationEditorUIManager=void 0,s.bindEvents=p,s.opacityToHex=v;var u=c(1),d=c(6);function p(Te,ke,De){for(const Re of De)ke.addEventListener(Re,Te[Re].bind(Te))}function v(Te){return Math.round(Math.min(255,Math.max(1,255*Te))).toString(16).padStart(2,"0")}class A{constructor(){bt(this,m,0)}getId(){return`${u.AnnotationEditorPrefix}${hi(this,m)._++}`}}m=new WeakMap;const $=class ${constructor(){bt(this,_);bt(this,C,(0,u.getUuid)());bt(this,S,0);bt(this,w,null)}static get _isSVGFittingCanvas(){const ke='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',Re=new OffscreenCanvas(1,3).getContext("2d"),Ge=new Image;Ge.src=ke;const Ve=Ge.decode().then(()=>(Re.drawImage(Ge,0,0,1,1,0,0,1,3),new Uint32Array(Re.getImageData(0,0,1,1).data.buffer)[0]===0));return(0,u.shadow)(this,"_isSVGFittingCanvas",Ve)}async getFromFile(ke){const{lastModified:De,name:Re,size:Ge,type:Ve}=ke;return it(this,_,Xs).call(this,`${De}_${Re}_${Ge}_${Ve}`,ke)}async getFromUrl(ke){return it(this,_,Xs).call(this,ke,ke)}async getFromId(ke){He(this,w)||Ct(this,w,new Map);const De=He(this,w).get(ke);return De?De.bitmap?(De.refCounter+=1,De):De.file?this.getFromFile(De.file):this.getFromUrl(De.url):null}getSvgUrl(ke){const De=He(this,w).get(ke);return De!=null&&De.isSvg?De.svgUrl:null}deleteId(ke){He(this,w)||Ct(this,w,new Map);const De=He(this,w).get(ke);De&&(De.refCounter-=1,De.refCounter===0&&(De.bitmap=null))}isValidId(ke){return ke.startsWith(`image_${He(this,C)}_`)}};C=new WeakMap,S=new WeakMap,w=new WeakMap,_=new WeakSet,Xs=async function(ke,De){He(this,w)||Ct(this,w,new Map);let Re=He(this,w).get(ke);if(Re===null)return null;if(Re!=null&&Re.bitmap)return Re.refCounter+=1,Re;try{Re||(Re={bitmap:null,id:`image_${He(this,C)}_${hi(this,S)._++}`,refCounter:0,isSvg:!1});let Ge;if(typeof De=="string"){Re.url=De;const Ve=await fetch(De);if(!Ve.ok)throw new Error(Ve.statusText);Ge=await Ve.blob()}else Ge=Re.file=De;if(Ge.type==="image/svg+xml"){const Ve=$._isSVGFittingCanvas,Xe=new FileReader,We=new Image,ze=new Promise((Qe,et)=>{We.onload=()=>{Re.bitmap=We,Re.isSvg=!0,Qe()},Xe.onload=async()=>{const Ze=Re.svgUrl=Xe.result;We.src=await Ve?`${Ze}#svgView(preserveAspectRatio(none))`:Ze},We.onerror=Xe.onerror=et});Xe.readAsDataURL(Ge),await ze}else Re.bitmap=await createImageBitmap(Ge);Re.refCounter=1}catch(Ge){console.error(Ge),Re=null}return He(this,w).set(ke,Re),Re&&He(this,w).set(Re.id,Re),Re};let b=$;class g{constructor(ke=128){bt(this,P,[]);bt(this,E,!1);bt(this,R);bt(this,T,-1);Ct(this,R,ke)}add({cmd:ke,undo:De,mustExec:Re,type:Ge=NaN,overwriteIfSameType:Ve=!1,keepUndo:Xe=!1}){if(Re&&ke(),He(this,E))return;const We={cmd:ke,undo:De,type:Ge};if(He(this,T)===-1){He(this,P).length>0&&(He(this,P).length=0),Ct(this,T,0),He(this,P).push(We);return}if(Ve&&He(this,P)[He(this,T)].type===Ge){Xe&&(We.undo=He(this,P)[He(this,T)].undo),He(this,P)[He(this,T)]=We;return}const ze=He(this,T)+1;ze===He(this,R)?He(this,P).splice(0,1):(Ct(this,T,ze),ze<He(this,P).length&&He(this,P).splice(ze)),He(this,P).push(We)}undo(){He(this,T)!==-1&&(Ct(this,E,!0),He(this,P)[He(this,T)].undo(),Ct(this,E,!1),Ct(this,T,He(this,T)-1))}redo(){He(this,T)<He(this,P).length-1&&(Ct(this,T,He(this,T)+1),Ct(this,E,!0),He(this,P)[He(this,T)].cmd(),Ct(this,E,!1))}hasSomethingToUndo(){return He(this,T)!==-1}hasSomethingToRedo(){return He(this,T)<He(this,P).length-1}destroy(){Ct(this,P,null)}}P=new WeakMap,E=new WeakMap,R=new WeakMap,T=new WeakMap,s.CommandManager=g;class x{constructor(ke){bt(this,B);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:De}=u.FeatureTest.platform;for(const[Re,Ge,Ve={}]of ke)for(const Xe of Re){const We=Xe.startsWith("mac+");De&&We?(this.callbacks.set(Xe.slice(4),{callback:Ge,options:Ve}),this.allKeys.add(Xe.split("+").at(-1))):!De&&!We&&(this.callbacks.set(Xe,{callback:Ge,options:Ve}),this.allKeys.add(Xe.split("+").at(-1)))}}exec(ke,De){if(!this.allKeys.has(De.key))return;const Re=this.callbacks.get(it(this,B,Tu).call(this,De));if(!Re)return;const{callback:Ge,options:{bubbles:Ve=!1,args:Xe=[],checker:We=null}}=Re;We&&!We(ke,De)||(Ge.bind(ke,...Xe)(),Ve||(De.stopPropagation(),De.preventDefault()))}}B=new WeakSet,Tu=function(ke){ke.altKey&&this.buffer.push("alt"),ke.ctrlKey&&this.buffer.push("ctrl"),ke.metaKey&&this.buffer.push("meta"),ke.shiftKey&&this.buffer.push("shift"),this.buffer.push(ke.key);const De=this.buffer.join("+");return this.buffer.length=0,De},s.KeyboardManager=x;const k=class k{get _colors(){const ke=new Map([["CanvasText",null],["Canvas",null]]);return(0,d.getColorValues)(ke),(0,u.shadow)(this,"_colors",ke)}convert(ke){const De=(0,d.getRGB)(ke);if(!window.matchMedia("(forced-colors: active)").matches)return De;for(const[Re,Ge]of this._colors)if(Ge.every((Ve,Xe)=>Ve===De[Xe]))return k._colorsMapping.get(Re);return De}getHexCode(ke){const De=this._colors.get(ke);return De?u.Util.makeHexColor(...De):ke}};yr(k,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let y=k;s.ColorManager=y;const Ye=class Ye{constructor(ke,De,Re,Ge,Ve,Xe){bt(this,Se);bt(this,O,null);bt(this,H,new Map);bt(this,j,new Map);bt(this,q,null);bt(this,L,null);bt(this,F,new g);bt(this,U,0);bt(this,N,new Set);bt(this,D,null);bt(this,W,null);bt(this,Z,new Set);bt(this,Q,null);bt(this,Y,new A);bt(this,J,!1);bt(this,ee,!1);bt(this,re,null);bt(this,ae,u.AnnotationEditorType.NONE);bt(this,V,new Set);bt(this,K,null);bt(this,te,this.blur.bind(this));bt(this,ie,this.focus.bind(this));bt(this,ce,this.copy.bind(this));bt(this,me,this.cut.bind(this));bt(this,we,this.paste.bind(this));bt(this,ve,this.keydown.bind(this));bt(this,ge,this.onEditingAction.bind(this));bt(this,ue,this.onPageChanging.bind(this));bt(this,se,this.onScaleChanging.bind(this));bt(this,oe,this.onRotationChanging.bind(this));bt(this,de,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1});bt(this,le,[0,0]);bt(this,xe,null);bt(this,Ce,null);bt(this,$e,null);Ct(this,Ce,ke),Ct(this,$e,De),Ct(this,q,Re),this._eventBus=Ge,this._eventBus._on("editingaction",He(this,ge)),this._eventBus._on("pagechanging",He(this,ue)),this._eventBus._on("scalechanging",He(this,se)),this._eventBus._on("rotationchanging",He(this,oe)),Ct(this,L,Ve.annotationStorage),Ct(this,Q,Ve.filterFactory),Ct(this,K,Xe),this.viewParameters={realScale:d.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}static get _keyboardManager(){const ke=Ye.prototype,De=Ve=>{const{activeElement:Xe}=document;return Xe&&He(Ve,Ce).contains(Xe)&&Ve.hasSomethingToControl()},Re=this.TRANSLATE_SMALL,Ge=this.TRANSLATE_BIG;return(0,u.shadow)(this,"_keyboardManager",new x([[["ctrl+a","mac+meta+a"],ke.selectAll],[["ctrl+z","mac+meta+z"],ke.undo],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],ke.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],ke.delete],[["Escape","mac+Escape"],ke.unselectAll],[["ArrowLeft","mac+ArrowLeft"],ke.translateSelectedEditors,{args:[-Re,0],checker:De}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],ke.translateSelectedEditors,{args:[-Ge,0],checker:De}],[["ArrowRight","mac+ArrowRight"],ke.translateSelectedEditors,{args:[Re,0],checker:De}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],ke.translateSelectedEditors,{args:[Ge,0],checker:De}],[["ArrowUp","mac+ArrowUp"],ke.translateSelectedEditors,{args:[0,-Re],checker:De}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],ke.translateSelectedEditors,{args:[0,-Ge],checker:De}],[["ArrowDown","mac+ArrowDown"],ke.translateSelectedEditors,{args:[0,Re],checker:De}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],ke.translateSelectedEditors,{args:[0,Ge],checker:De}]]))}destroy(){it(this,Se,mo).call(this),it(this,Se,Zs).call(this),this._eventBus._off("editingaction",He(this,ge)),this._eventBus._off("pagechanging",He(this,ue)),this._eventBus._off("scalechanging",He(this,se)),this._eventBus._off("rotationchanging",He(this,oe));for(const ke of He(this,j).values())ke.destroy();He(this,j).clear(),He(this,H).clear(),He(this,Z).clear(),Ct(this,O,null),He(this,V).clear(),He(this,F).destroy(),He(this,q).destroy()}get hcmFilter(){return(0,u.shadow)(this,"hcmFilter",He(this,K)?He(this,Q).addHCMFilter(He(this,K).foreground,He(this,K).background):"none")}get direction(){return(0,u.shadow)(this,"direction",getComputedStyle(He(this,Ce)).direction)}editAltText(ke){var De;(De=He(this,q))==null||De.editAltText(this,ke)}onPageChanging({pageNumber:ke}){Ct(this,U,ke-1)}focusMainContainer(){He(this,Ce).focus()}findParent(ke,De){for(const Re of He(this,j).values()){const{x:Ge,y:Ve,width:Xe,height:We}=Re.div.getBoundingClientRect();if(ke>=Ge&&ke<=Ge+Xe&&De>=Ve&&De<=Ve+We)return Re}return null}disableUserSelect(ke=!1){He(this,$e).classList.toggle("noUserSelect",ke)}addShouldRescale(ke){He(this,Z).add(ke)}removeShouldRescale(ke){He(this,Z).delete(ke)}onScaleChanging({scale:ke}){this.commitOrRemove(),this.viewParameters.realScale=ke*d.PixelsPerInch.PDF_TO_CSS_UNITS;for(const De of He(this,Z))De.onScaleChanging()}onRotationChanging({pagesRotation:ke}){this.commitOrRemove(),this.viewParameters.rotation=ke}addToAnnotationStorage(ke){!ke.isEmpty()&&He(this,L)&&!He(this,L).has(ke.id)&&He(this,L).setValue(ke.id,ke)}blur(){if(!this.hasSelection)return;const{activeElement:ke}=document;for(const De of He(this,V))if(De.div.contains(ke)){Ct(this,re,[De,ke]),De._focusEventsAllowed=!1;break}}focus(){if(!He(this,re))return;const[ke,De]=He(this,re);Ct(this,re,null),De.addEventListener("focusin",()=>{ke._focusEventsAllowed=!0},{once:!0}),De.focus()}addEditListeners(){it(this,Se,Js).call(this),it(this,Se,el).call(this)}removeEditListeners(){it(this,Se,mo).call(this),it(this,Se,tl).call(this)}copy(ke){var Re;if(ke.preventDefault(),(Re=He(this,O))==null||Re.commitOrRemove(),!this.hasSelection)return;const De=[];for(const Ge of He(this,V)){const Ve=Ge.serialize(!0);Ve&&De.push(Ve)}De.length!==0&&ke.clipboardData.setData("application/pdfjs",JSON.stringify(De))}cut(ke){this.copy(ke),this.delete()}paste(ke){ke.preventDefault();const{clipboardData:De}=ke;for(const Ve of De.items)for(const Xe of He(this,W))if(Xe.isHandlingMimeForPasting(Ve.type)){Xe.paste(Ve,this.currentLayer);return}let Re=De.getData("application/pdfjs");if(!Re)return;try{Re=JSON.parse(Re)}catch(Ve){(0,u.warn)(`paste: "${Ve.message}".`);return}if(!Array.isArray(Re))return;this.unselectAll();const Ge=this.currentLayer;try{const Ve=[];for(const ze of Re){const Qe=Ge.deserialize(ze);if(!Qe)return;Ve.push(Qe)}const Xe=()=>{for(const ze of Ve)it(this,Se,rl).call(this,ze);it(this,Se,nl).call(this,Ve)},We=()=>{for(const ze of Ve)ze.remove()};this.addCommands({cmd:Xe,undo:We,mustExec:!0})}catch(Ve){(0,u.warn)(`paste: "${Ve.message}".`)}}keydown(ke){var De;(De=this.getActive())!=null&&De.shouldGetKeyboardEvents()||Ye._keyboardManager.exec(this,ke)}onEditingAction(ke){["undo","redo","delete","selectAll"].includes(ke.name)&&this[ke.name]()}setEditingState(ke){ke?(it(this,Se,Ru).call(this),it(this,Se,Js).call(this),it(this,Se,el).call(this),it(this,Se,_n).call(this,{isEditing:He(this,ae)!==u.AnnotationEditorType.NONE,isEmpty:it(this,Se,gi).call(this),hasSomethingToUndo:He(this,F).hasSomethingToUndo(),hasSomethingToRedo:He(this,F).hasSomethingToRedo(),hasSelectedEditor:!1})):(it(this,Se,Zs).call(this),it(this,Se,mo).call(this),it(this,Se,tl).call(this),it(this,Se,_n).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(ke){if(!He(this,W)){Ct(this,W,ke);for(const De of He(this,W))it(this,Se,pi).call(this,De.defaultPropertiesToUpdate)}}getId(){return He(this,Y).getId()}get currentLayer(){return He(this,j).get(He(this,U))}getLayer(ke){return He(this,j).get(ke)}get currentPageIndex(){return He(this,U)}addLayer(ke){He(this,j).set(ke.pageIndex,ke),He(this,J)?ke.enable():ke.disable()}removeLayer(ke){He(this,j).delete(ke.pageIndex)}updateMode(ke,De=null){if(He(this,ae)!==ke){if(Ct(this,ae,ke),ke===u.AnnotationEditorType.NONE){this.setEditingState(!1),it(this,Se,Mu).call(this);return}this.setEditingState(!0),it(this,Se,Bu).call(this),this.unselectAll();for(const Re of He(this,j).values())Re.updateMode(ke);if(De){for(const Re of He(this,H).values())if(Re.annotationElementId===De){this.setSelected(Re),Re.enterInEditMode();break}}}}updateToolbar(ke){ke!==He(this,ae)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:ke})}updateParams(ke,De){if(He(this,W)){if(ke===u.AnnotationEditorParamsType.CREATE){this.currentLayer.addNewEditor(ke);return}for(const Re of He(this,V))Re.updateParams(ke,De);for(const Re of He(this,W))Re.updateDefaultParams(ke,De)}}enableWaiting(ke=!1){if(He(this,ee)!==ke){Ct(this,ee,ke);for(const De of He(this,j).values())ke?De.disableClick():De.enableClick(),De.div.classList.toggle("waiting",ke)}}getEditors(ke){const De=[];for(const Re of He(this,H).values())Re.pageIndex===ke&&De.push(Re);return De}getEditor(ke){return He(this,H).get(ke)}addEditor(ke){He(this,H).set(ke.id,ke)}removeEditor(ke){var De;He(this,H).delete(ke.id),this.unselect(ke),(!ke.annotationElementId||!He(this,N).has(ke.annotationElementId))&&((De=He(this,L))==null||De.remove(ke.id))}addDeletedAnnotationElement(ke){He(this,N).add(ke.annotationElementId),ke.deleted=!0}isDeletedAnnotationElement(ke){return He(this,N).has(ke)}removeDeletedAnnotationElement(ke){He(this,N).delete(ke.annotationElementId),ke.deleted=!1}setActiveEditor(ke){He(this,O)!==ke&&(Ct(this,O,ke),ke&&it(this,Se,pi).call(this,ke.propertiesToUpdate))}toggleSelected(ke){if(He(this,V).has(ke)){He(this,V).delete(ke),ke.unselect(),it(this,Se,_n).call(this,{hasSelectedEditor:this.hasSelection});return}He(this,V).add(ke),ke.select(),it(this,Se,pi).call(this,ke.propertiesToUpdate),it(this,Se,_n).call(this,{hasSelectedEditor:!0})}setSelected(ke){for(const De of He(this,V))De!==ke&&De.unselect();He(this,V).clear(),He(this,V).add(ke),ke.select(),it(this,Se,pi).call(this,ke.propertiesToUpdate),it(this,Se,_n).call(this,{hasSelectedEditor:!0})}isSelected(ke){return He(this,V).has(ke)}unselect(ke){ke.unselect(),He(this,V).delete(ke),it(this,Se,_n).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return He(this,V).size!==0}undo(){He(this,F).undo(),it(this,Se,_n).call(this,{hasSomethingToUndo:He(this,F).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:it(this,Se,gi).call(this)})}redo(){He(this,F).redo(),it(this,Se,_n).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:He(this,F).hasSomethingToRedo(),isEmpty:it(this,Se,gi).call(this)})}addCommands(ke){He(this,F).add(ke),it(this,Se,_n).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:it(this,Se,gi).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const ke=[...He(this,V)],De=()=>{for(const Ge of ke)Ge.remove()},Re=()=>{for(const Ge of ke)it(this,Se,rl).call(this,Ge)};this.addCommands({cmd:De,undo:Re,mustExec:!0})}commitOrRemove(){var ke;(ke=He(this,O))==null||ke.commitOrRemove()}hasSomethingToControl(){return He(this,O)||this.hasSelection}selectAll(){for(const ke of He(this,V))ke.commit();it(this,Se,nl).call(this,He(this,H).values())}unselectAll(){if(He(this,O)){He(this,O).commitOrRemove();return}if(this.hasSelection){for(const ke of He(this,V))ke.unselect();He(this,V).clear(),it(this,Se,_n).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(ke,De,Re=!1){if(Re||this.commitOrRemove(),!this.hasSelection)return;He(this,le)[0]+=ke,He(this,le)[1]+=De;const[Ge,Ve]=He(this,le),Xe=[...He(this,V)],We=1e3;He(this,xe)&&clearTimeout(He(this,xe)),Ct(this,xe,setTimeout(()=>{Ct(this,xe,null),He(this,le)[0]=He(this,le)[1]=0,this.addCommands({cmd:()=>{for(const ze of Xe)He(this,H).has(ze.id)&&ze.translateInPage(Ge,Ve)},undo:()=>{for(const ze of Xe)He(this,H).has(ze.id)&&ze.translateInPage(-Ge,-Ve)},mustExec:!1})},We));for(const ze of Xe)ze.translateInPage(ke,De)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),Ct(this,D,new Map);for(const ke of He(this,V))He(this,D).set(ke,{savedX:ke.x,savedY:ke.y,savedPageIndex:ke.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!He(this,D))return!1;this.disableUserSelect(!1);const ke=He(this,D);Ct(this,D,null);let De=!1;for(const[{x:Ge,y:Ve,pageIndex:Xe},We]of ke)We.newX=Ge,We.newY=Ve,We.newPageIndex=Xe,De||(De=Ge!==We.savedX||Ve!==We.savedY||Xe!==We.savedPageIndex);if(!De)return!1;const Re=(Ge,Ve,Xe,We)=>{if(He(this,H).has(Ge.id)){const ze=He(this,j).get(We);ze?Ge._setParentAndPosition(ze,Ve,Xe):(Ge.pageIndex=We,Ge.x=Ve,Ge.y=Xe)}};return this.addCommands({cmd:()=>{for(const[Ge,{newX:Ve,newY:Xe,newPageIndex:We}]of ke)Re(Ge,Ve,Xe,We)},undo:()=>{for(const[Ge,{savedX:Ve,savedY:Xe,savedPageIndex:We}]of ke)Re(Ge,Ve,Xe,We)},mustExec:!0}),!0}dragSelectedEditors(ke,De){if(He(this,D))for(const Re of He(this,D).keys())Re.drag(ke,De)}rebuild(ke){if(ke.parent===null){const De=this.getLayer(ke.pageIndex);De?(De.changeParent(ke),De.addOrRebuild(ke)):(this.addEditor(ke),this.addToAnnotationStorage(ke),ke.rebuild())}else ke.parent.addOrRebuild(ke)}isActive(ke){return He(this,O)===ke}getActive(){return He(this,O)}getMode(){return He(this,ae)}get imageManager(){return(0,u.shadow)(this,"imageManager",new b)}};O=new WeakMap,H=new WeakMap,j=new WeakMap,q=new WeakMap,L=new WeakMap,F=new WeakMap,U=new WeakMap,N=new WeakMap,D=new WeakMap,W=new WeakMap,Z=new WeakMap,Q=new WeakMap,Y=new WeakMap,J=new WeakMap,ee=new WeakMap,re=new WeakMap,ae=new WeakMap,V=new WeakMap,K=new WeakMap,te=new WeakMap,ie=new WeakMap,ce=new WeakMap,me=new WeakMap,we=new WeakMap,ve=new WeakMap,ge=new WeakMap,ue=new WeakMap,se=new WeakMap,oe=new WeakMap,de=new WeakMap,le=new WeakMap,xe=new WeakMap,Ce=new WeakMap,$e=new WeakMap,Se=new WeakSet,Ru=function(){window.addEventListener("focus",He(this,ie)),window.addEventListener("blur",He(this,te))},Zs=function(){window.removeEventListener("focus",He(this,ie)),window.removeEventListener("blur",He(this,te))},Js=function(){window.addEventListener("keydown",He(this,ve),{capture:!0})},mo=function(){window.removeEventListener("keydown",He(this,ve),{capture:!0})},el=function(){document.addEventListener("copy",He(this,ce)),document.addEventListener("cut",He(this,me)),document.addEventListener("paste",He(this,we))},tl=function(){document.removeEventListener("copy",He(this,ce)),document.removeEventListener("cut",He(this,me)),document.removeEventListener("paste",He(this,we))},_n=function(ke){Object.entries(ke).some(([Re,Ge])=>He(this,de)[Re]!==Ge)&&this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(He(this,de),ke)})},pi=function(ke){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:ke})},Bu=function(){if(!He(this,J)){Ct(this,J,!0);for(const ke of He(this,j).values())ke.enable()}},Mu=function(){if(this.unselectAll(),He(this,J)){Ct(this,J,!1);for(const ke of He(this,j).values())ke.disable()}},rl=function(ke){const De=He(this,j).get(ke.pageIndex);De?De.addOrRebuild(ke):this.addEditor(ke)},gi=function(){if(He(this,H).size===0)return!0;if(He(this,H).size===1)for(const ke of He(this,H).values())return ke.isEmpty();return!1},nl=function(ke){He(this,V).clear();for(const De of ke)De.isEmpty()||(He(this,V).add(De),De.select());it(this,Se,_n).call(this,{hasSelectedEditor:!0})},yr(Ye,"TRANSLATE_SMALL",1),yr(Ye,"TRANSLATE_BIG",10);let f=Ye;s.AnnotationEditorUIManager=f},(a,s,c)=>{var U,N,D,W,Z,Q,Y,J,ee,re,ae,V,Fa,Na,al,Ao,vo,mi,Ai;Object.defineProperty(s,"__esModule",{value:!0}),s.StatTimer=s.RenderingCancelledException=s.PixelsPerInch=s.PageViewport=s.PDFDateString=s.DOMStandardFontDataFactory=s.DOMSVGFactory=s.DOMFilterFactory=s.DOMCanvasFactory=s.DOMCMapReaderFactory=void 0,s.deprecated=T,s.getColorValues=H,s.getCurrentTransform=j,s.getCurrentTransformInverse=q,s.getFilenameFromUrl=_,s.getPdfFilenameFromUrl=I,s.getRGB=O,s.getXfaPageViewport=k,s.isDataScheme=S,s.isPdfFile=w,s.isValidFetchUrl=P,s.loadScript=R,s.noContextMenu=E,s.setLayerDimensions=L;var u=c(7),d=c(1);const p="http://www.w3.org/2000/svg",F=class F{};yr(F,"CSS",96),yr(F,"PDF",72),yr(F,"PDF_TO_CSS_UNITS",F.CSS/F.PDF);let v=F;s.PixelsPerInch=v;class A extends u.BaseFilterFactory{constructor({docId:se,ownerDocument:oe=globalThis.document}={}){super();bt(this,V);bt(this,U);bt(this,N);bt(this,D);bt(this,W);bt(this,Z);bt(this,Q);bt(this,Y);bt(this,J);bt(this,ee);bt(this,re);bt(this,ae,0);Ct(this,D,se),Ct(this,W,oe)}addFilter(se){if(!se)return"none";let oe=He(this,V,Fa).get(se);if(oe)return oe;let de,le,xe,Ce;if(se.length===1){const Ae=se[0],pe=new Array(256);for(let he=0;he<256;he++)pe[he]=Ae[he]/255;Ce=de=le=xe=pe.join(",")}else{const[Ae,pe,he]=se,Ie=new Array(256),ye=new Array(256),Pe=new Array(256);for(let Ne=0;Ne<256;Ne++)Ie[Ne]=Ae[Ne]/255,ye[Ne]=pe[Ne]/255,Pe[Ne]=he[Ne]/255;de=Ie.join(","),le=ye.join(","),xe=Pe.join(","),Ce=`${de}${le}${xe}`}if(oe=He(this,V,Fa).get(Ce),oe)return He(this,V,Fa).set(se,oe),oe;const $e=`g_${He(this,D)}_transfer_map_${hi(this,ae)._++}`,Se=`url(#${$e})`;He(this,V,Fa).set(se,Se),He(this,V,Fa).set(Ce,Se);const Ee=it(this,V,Ao).call(this,$e);return it(this,V,mi).call(this,de,le,xe,Ee),Se}addHCMFilter(se,oe){var pe;const de=`${se}-${oe}`;if(He(this,Q)===de)return He(this,Y);if(Ct(this,Q,de),Ct(this,Y,"none"),(pe=He(this,Z))==null||pe.remove(),!se||!oe)return He(this,Y);const le=it(this,V,Ai).call(this,se);se=d.Util.makeHexColor(...le);const xe=it(this,V,Ai).call(this,oe);if(oe=d.Util.makeHexColor(...xe),He(this,V,Na).style.color="",se==="#000000"&&oe==="#ffffff"||se===oe)return He(this,Y);const Ce=new Array(256);for(let he=0;he<=255;he++){const Ie=he/255;Ce[he]=Ie<=.03928?Ie/12.92:((Ie+.055)/1.055)**2.4}const $e=Ce.join(","),Se=`g_${He(this,D)}_hcm_filter`,Ee=Ct(this,J,it(this,V,Ao).call(this,Se));it(this,V,mi).call(this,$e,$e,$e,Ee),it(this,V,al).call(this,Ee);const Ae=(he,Ie)=>{const ye=le[he]/255,Pe=xe[he]/255,Ne=new Array(Ie+1);for(let Le=0;Le<=Ie;Le++)Ne[Le]=ye+Le/Ie*(Pe-ye);return Ne.join(",")};return it(this,V,mi).call(this,Ae(0,5),Ae(1,5),Ae(2,5),Ee),Ct(this,Y,`url(#${Se})`),He(this,Y)}addHighlightHCMFilter(se,oe,de,le){var Pe;const xe=`${se}-${oe}-${de}-${le}`;if(He(this,ee)===xe)return He(this,re);if(Ct(this,ee,xe),Ct(this,re,"none"),(Pe=He(this,J))==null||Pe.remove(),!se||!oe)return He(this,re);const[Ce,$e]=[se,oe].map(it(this,V,Ai).bind(this));let Se=Math.round(.2126*Ce[0]+.7152*Ce[1]+.0722*Ce[2]),Ee=Math.round(.2126*$e[0]+.7152*$e[1]+.0722*$e[2]),[Ae,pe]=[de,le].map(it(this,V,Ai).bind(this));Ee<Se&&([Se,Ee,Ae,pe]=[Ee,Se,pe,Ae]),He(this,V,Na).style.color="";const he=(Ne,Le,Oe)=>{const Fe=new Array(256),_e=(Ee-Se)/Oe,je=Ne/255,Ye=(Le-Ne)/(255*Oe);let Te=0;for(let ke=0;ke<=Oe;ke++){const De=Math.round(Se+ke*_e),Re=je+ke*Ye;for(let Ge=Te;Ge<=De;Ge++)Fe[Ge]=Re;Te=De+1}for(let ke=Te;ke<256;ke++)Fe[ke]=Fe[Te-1];return Fe.join(",")},Ie=`g_${He(this,D)}_hcm_highlight_filter`,ye=Ct(this,J,it(this,V,Ao).call(this,Ie));return it(this,V,al).call(this,ye),it(this,V,mi).call(this,he(Ae[0],pe[0],5),he(Ae[1],pe[1],5),he(Ae[2],pe[2],5),ye),Ct(this,re,`url(#${Ie})`),He(this,re)}destroy(se=!1){se&&(He(this,Y)||He(this,re))||(He(this,N)&&(He(this,N).parentNode.parentNode.remove(),Ct(this,N,null)),He(this,U)&&(He(this,U).clear(),Ct(this,U,null)),Ct(this,ae,0))}}U=new WeakMap,N=new WeakMap,D=new WeakMap,W=new WeakMap,Z=new WeakMap,Q=new WeakMap,Y=new WeakMap,J=new WeakMap,ee=new WeakMap,re=new WeakMap,ae=new WeakMap,V=new WeakSet,Fa=function(){return He(this,U)||Ct(this,U,new Map)},Na=function(){if(!He(this,N)){const se=He(this,W).createElement("div"),{style:oe}=se;oe.visibility="hidden",oe.contain="strict",oe.width=oe.height=0,oe.position="absolute",oe.top=oe.left=0,oe.zIndex=-1;const de=He(this,W).createElementNS(p,"svg");de.setAttribute("width",0),de.setAttribute("height",0),Ct(this,N,He(this,W).createElementNS(p,"defs")),se.append(de),de.append(He(this,N)),He(this,W).body.append(se)}return He(this,N)},al=function(se){const oe=He(this,W).createElementNS(p,"feColorMatrix");oe.setAttribute("type","matrix"),oe.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"),se.append(oe)},Ao=function(se){const oe=He(this,W).createElementNS(p,"filter");return oe.setAttribute("color-interpolation-filters","sRGB"),oe.setAttribute("id",se),He(this,V,Na).append(oe),oe},vo=function(se,oe,de){const le=He(this,W).createElementNS(p,oe);le.setAttribute("type","discrete"),le.setAttribute("tableValues",de),se.append(le)},mi=function(se,oe,de,le){const xe=He(this,W).createElementNS(p,"feComponentTransfer");le.append(xe),it(this,V,vo).call(this,xe,"feFuncR",se),it(this,V,vo).call(this,xe,"feFuncG",oe),it(this,V,vo).call(this,xe,"feFuncB",de)},Ai=function(se){return He(this,V,Na).style.color=se,O(getComputedStyle(He(this,V,Na)).getPropertyValue("color"))},s.DOMFilterFactory=A;class b extends u.BaseCanvasFactory{constructor({ownerDocument:ue=globalThis.document}={}){super(),this._document=ue}_createCanvas(ue,se){const oe=this._document.createElement("canvas");return oe.width=ue,oe.height=se,oe}}s.DOMCanvasFactory=b;async function g(ge,ue=!1){if(P(ge,document.baseURI)){const se=await fetch(ge);if(!se.ok)throw new Error(se.statusText);return ue?new Uint8Array(await se.arrayBuffer()):(0,d.stringToBytes)(await se.text())}return new Promise((se,oe)=>{const de=new XMLHttpRequest;de.open("GET",ge,!0),ue&&(de.responseType="arraybuffer"),de.onreadystatechange=()=>{if(de.readyState===XMLHttpRequest.DONE){if(de.status===200||de.status===0){let le;if(ue&&de.response?le=new Uint8Array(de.response):!ue&&de.responseText&&(le=(0,d.stringToBytes)(de.responseText)),le){se(le);return}}oe(new Error(de.statusText))}},de.send(null)})}class x extends u.BaseCMapReaderFactory{_fetchData(ue,se){return g(ue,this.isCompressed).then(oe=>({cMapData:oe,compressionType:se}))}}s.DOMCMapReaderFactory=x;class y extends u.BaseStandardFontDataFactory{_fetchData(ue){return g(ue,!0)}}s.DOMStandardFontDataFactory=y;class f extends u.BaseSVGFactory{_createSVG(ue){return document.createElementNS(p,ue)}}s.DOMSVGFactory=f;class m{constructor({viewBox:ue,scale:se,rotation:oe,offsetX:de=0,offsetY:le=0,dontFlip:xe=!1}){this.viewBox=ue,this.scale=se,this.rotation=oe,this.offsetX=de,this.offsetY=le;const Ce=(ue[2]+ue[0])/2,$e=(ue[3]+ue[1])/2;let Se,Ee,Ae,pe;switch(oe%=360,oe<0&&(oe+=360),oe){case 180:Se=-1,Ee=0,Ae=0,pe=1;break;case 90:Se=0,Ee=1,Ae=1,pe=0;break;case 270:Se=0,Ee=-1,Ae=-1,pe=0;break;case 0:Se=1,Ee=0,Ae=0,pe=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}xe&&(Ae=-Ae,pe=-pe);let he,Ie,ye,Pe;Se===0?(he=Math.abs($e-ue[1])*se+de,Ie=Math.abs(Ce-ue[0])*se+le,ye=(ue[3]-ue[1])*se,Pe=(ue[2]-ue[0])*se):(he=Math.abs(Ce-ue[0])*se+de,Ie=Math.abs($e-ue[1])*se+le,ye=(ue[2]-ue[0])*se,Pe=(ue[3]-ue[1])*se),this.transform=[Se*se,Ee*se,Ae*se,pe*se,he-Se*se*Ce-Ae*se*$e,Ie-Ee*se*Ce-pe*se*$e],this.width=ye,this.height=Pe}get rawDims(){const{viewBox:ue}=this;return(0,d.shadow)(this,"rawDims",{pageWidth:ue[2]-ue[0],pageHeight:ue[3]-ue[1],pageX:ue[0],pageY:ue[1]})}clone({scale:ue=this.scale,rotation:se=this.rotation,offsetX:oe=this.offsetX,offsetY:de=this.offsetY,dontFlip:le=!1}={}){return new m({viewBox:this.viewBox.slice(),scale:ue,rotation:se,offsetX:oe,offsetY:de,dontFlip:le})}convertToViewportPoint(ue,se){return d.Util.applyTransform([ue,se],this.transform)}convertToViewportRectangle(ue){const se=d.Util.applyTransform([ue[0],ue[1]],this.transform),oe=d.Util.applyTransform([ue[2],ue[3]],this.transform);return[se[0],se[1],oe[0],oe[1]]}convertToPdfPoint(ue,se){return d.Util.applyInverseTransform([ue,se],this.transform)}}s.PageViewport=m;class C extends d.BaseException{constructor(ue,se=0){super(ue,"RenderingCancelledException"),this.extraDelay=se}}s.RenderingCancelledException=C;function S(ge){const ue=ge.length;let se=0;for(;se<ue&&ge[se].trim()==="";)se++;return ge.substring(se,se+5).toLowerCase()==="data:"}function w(ge){return typeof ge=="string"&&/\.pdf$/i.test(ge)}function _(ge,ue=!1){return ue||([ge]=ge.split(/[#?]/,1)),ge.substring(ge.lastIndexOf("/")+1)}function I(ge,ue="document.pdf"){if(typeof ge!="string")return ue;if(S(ge))return(0,d.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),ue;const se=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/,oe=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,de=se.exec(ge);let le=oe.exec(de[1])||oe.exec(de[2])||oe.exec(de[3]);if(le&&(le=le[0],le.includes("%")))try{le=oe.exec(decodeURIComponent(le))[0]}catch{}return le||ue}class ${constructor(){yr(this,"started",Object.create(null));yr(this,"times",[])}time(ue){ue in this.started&&(0,d.warn)(`Timer is already running for ${ue}`),this.started[ue]=Date.now()}timeEnd(ue){ue in this.started||(0,d.warn)(`Timer has not been started for ${ue}`),this.times.push({name:ue,start:this.started[ue],end:Date.now()}),delete this.started[ue]}toString(){const ue=[];let se=0;for(const{name:oe}of this.times)se=Math.max(oe.length,se);for(const{name:oe,start:de,end:le}of this.times)ue.push(`${oe.padEnd(se)} ${le-de}ms
|
59
59
|
`);return ue.join("")}}s.StatTimer=$;function P(ge,ue){try{const{protocol:se}=ue?new URL(ge,ue):new URL(ge);return se==="http:"||se==="https:"}catch{return!1}}function E(ge){ge.preventDefault()}function R(ge,ue=!1){return new Promise((se,oe)=>{const de=document.createElement("script");de.src=ge,de.onload=function(le){ue&&de.remove(),se(le)},de.onerror=function(){oe(new Error(`Cannot load script at: ${de.src}`))},(document.head||document.documentElement).append(de)})}function T(ge){console.log("Deprecated API usage: "+ge)}let B;class M{static toDateObject(ue){if(!ue||typeof ue!="string")return null;B||(B=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const se=B.exec(ue);if(!se)return null;const oe=parseInt(se[1],10);let de=parseInt(se[2],10);de=de>=1&&de<=12?de-1:0;let le=parseInt(se[3],10);le=le>=1&&le<=31?le:1;let xe=parseInt(se[4],10);xe=xe>=0&&xe<=23?xe:0;let Ce=parseInt(se[5],10);Ce=Ce>=0&&Ce<=59?Ce:0;let $e=parseInt(se[6],10);$e=$e>=0&&$e<=59?$e:0;const Se=se[7]||"Z";let Ee=parseInt(se[8],10);Ee=Ee>=0&&Ee<=23?Ee:0;let Ae=parseInt(se[9],10)||0;return Ae=Ae>=0&&Ae<=59?Ae:0,Se==="-"?(xe+=Ee,Ce+=Ae):Se==="+"&&(xe-=Ee,Ce-=Ae),new Date(Date.UTC(oe,de,le,xe,Ce,$e))}}s.PDFDateString=M;function k(ge,{scale:ue=1,rotation:se=0}){const{width:oe,height:de}=ge.attributes.style,le=[0,0,parseInt(oe),parseInt(de)];return new m({viewBox:le,scale:ue,rotation:se})}function O(ge){if(ge.startsWith("#")){const ue=parseInt(ge.slice(1),16);return[(ue&16711680)>>16,(ue&65280)>>8,ue&255]}return ge.startsWith("rgb(")?ge.slice(4,-1).split(",").map(ue=>parseInt(ue)):ge.startsWith("rgba(")?ge.slice(5,-1).split(",").map(ue=>parseInt(ue)).slice(0,3):((0,d.warn)(`Not a valid color format: "${ge}"`),[0,0,0])}function H(ge){const ue=document.createElement("span");ue.style.visibility="hidden",document.body.append(ue);for(const se of ge.keys()){ue.style.color=se;const oe=window.getComputedStyle(ue).color;ge.set(se,O(oe))}ue.remove()}function j(ge){const{a:ue,b:se,c:oe,d:de,e:le,f:xe}=ge.getTransform();return[ue,se,oe,de,le,xe]}function q(ge){const{a:ue,b:se,c:oe,d:de,e:le,f:xe}=ge.getTransform().invertSelf();return[ue,se,oe,de,le,xe]}function L(ge,ue,se=!1,oe=!0){if(ue instanceof m){const{pageWidth:de,pageHeight:le}=ue.rawDims,{style:xe}=ge,Ce=d.FeatureTest.isCSSRoundSupported,$e=`var(--scale-factor) * ${de}px`,Se=`var(--scale-factor) * ${le}px`,Ee=Ce?`round(${$e}, 1px)`:`calc(${$e})`,Ae=Ce?`round(${Se}, 1px)`:`calc(${Se})`;!se||ue.rotation%180===0?(xe.width=Ee,xe.height=Ae):(xe.width=Ae,xe.height=Ee)}oe&&ge.setAttribute("data-main-rotation",ue.rotation)}},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BaseStandardFontDataFactory=s.BaseSVGFactory=s.BaseFilterFactory=s.BaseCanvasFactory=s.BaseCMapReaderFactory=void 0;var u=c(1);class d{constructor(){this.constructor===d&&(0,u.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(x){return"none"}addHCMFilter(x,y){return"none"}addHighlightHCMFilter(x,y,f,m){return"none"}destroy(x=!1){}}s.BaseFilterFactory=d;class p{constructor(){this.constructor===p&&(0,u.unreachable)("Cannot initialize BaseCanvasFactory.")}create(x,y){if(x<=0||y<=0)throw new Error("Invalid canvas size");const f=this._createCanvas(x,y);return{canvas:f,context:f.getContext("2d")}}reset(x,y,f){if(!x.canvas)throw new Error("Canvas is not specified");if(y<=0||f<=0)throw new Error("Invalid canvas size");x.canvas.width=y,x.canvas.height=f}destroy(x){if(!x.canvas)throw new Error("Canvas is not specified");x.canvas.width=0,x.canvas.height=0,x.canvas=null,x.context=null}_createCanvas(x,y){(0,u.unreachable)("Abstract method `_createCanvas` called.")}}s.BaseCanvasFactory=p;class v{constructor({baseUrl:x=null,isCompressed:y=!0}){this.constructor===v&&(0,u.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=x,this.isCompressed=y}async fetch({name:x}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!x)throw new Error("CMap name must be specified.");const y=this.baseUrl+x+(this.isCompressed?".bcmap":""),f=this.isCompressed?u.CMapCompressionType.BINARY:u.CMapCompressionType.NONE;return this._fetchData(y,f).catch(m=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${y}`)})}_fetchData(x,y){(0,u.unreachable)("Abstract method `_fetchData` called.")}}s.BaseCMapReaderFactory=v;class A{constructor({baseUrl:x=null}){this.constructor===A&&(0,u.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=x}async fetch({filename:x}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!x)throw new Error("Font filename must be specified.");const y=`${this.baseUrl}${x}`;return this._fetchData(y).catch(f=>{throw new Error(`Unable to load font data at: ${y}`)})}_fetchData(x){(0,u.unreachable)("Abstract method `_fetchData` called.")}}s.BaseStandardFontDataFactory=A;class b{constructor(){this.constructor===b&&(0,u.unreachable)("Cannot initialize BaseSVGFactory.")}create(x,y,f=!1){if(x<=0||y<=0)throw new Error("Invalid SVG dimensions");const m=this._createSVG("svg:svg");return m.setAttribute("version","1.1"),f||(m.setAttribute("width",`${x}px`),m.setAttribute("height",`${y}px`)),m.setAttribute("preserveAspectRatio","none"),m.setAttribute("viewBox",`0 0 ${x} ${y}`),m}createElement(x){if(typeof x!="string")throw new Error("Invalid SVG element type");return this._createSVG(x)}_createSVG(x){(0,u.unreachable)("Abstract method `_createSVG` called.")}}s.BaseSVGFactory=b},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.MurmurHash3_64=void 0;var u=c(1);const d=3285377520,p=4294901760,v=65535;class A{constructor(g){this.h1=g?g&4294967295:d,this.h2=g?g&4294967295:d}update(g){let x,y;if(typeof g=="string"){x=new Uint8Array(g.length*2),y=0;for(let T=0,B=g.length;T<B;T++){const M=g.charCodeAt(T);M<=255?x[y++]=M:(x[y++]=M>>>8,x[y++]=M&255)}}else if((0,u.isArrayBuffer)(g))x=g.slice(),y=x.byteLength;else throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");const f=y>>2,m=y-f*4,C=new Uint32Array(x.buffer,0,f);let S=0,w=0,_=this.h1,I=this.h2;const $=3432918353,P=461845907,E=$&v,R=P&v;for(let T=0;T<f;T++)T&1?(S=C[T],S=S*$&p|S*E&v,S=S<<15|S>>>17,S=S*P&p|S*R&v,_^=S,_=_<<13|_>>>19,_=_*5+3864292196):(w=C[T],w=w*$&p|w*E&v,w=w<<15|w>>>17,w=w*P&p|w*R&v,I^=w,I=I<<13|I>>>19,I=I*5+3864292196);switch(S=0,m){case 3:S^=x[f*4+2]<<16;case 2:S^=x[f*4+1]<<8;case 1:S^=x[f*4],S=S*$&p|S*E&v,S=S<<15|S>>>17,S=S*P&p|S*R&v,f&1?_^=S:I^=S}this.h1=_,this.h2=I}hexdigest(){let g=this.h1,x=this.h2;return g^=x>>>1,g=g*3981806797&p|g*36045&v,x=x*4283543511&p|((x<<16|g>>>16)*2950163797&p)>>>16,g^=x>>>1,g=g*444984403&p|g*60499&v,x=x*3301882366&p|((x<<16|g>>>16)*3120437893&p)>>>16,g^=x>>>1,(g>>>0).toString(16).padStart(8,"0")+(x>>>0).toString(16).padStart(8,"0")}}s.MurmurHash3_64=A},(a,s,c)=>{var v;Object.defineProperty(s,"__esModule",{value:!0}),s.FontLoader=s.FontFaceObject=void 0;var u=c(1);class d{constructor({ownerDocument:b=globalThis.document,styleElement:g=null}){bt(this,v,new Set);this._document=b,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(b){this.nativeFontFaces.add(b),this._document.fonts.add(b)}removeNativeFontFace(b){this.nativeFontFaces.delete(b),this._document.fonts.delete(b)}insertRule(b){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const g=this.styleElement.sheet;g.insertRule(b,g.cssRules.length)}clear(){for(const b of this.nativeFontFaces)this._document.fonts.delete(b);this.nativeFontFaces.clear(),He(this,v).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont(b){if(!(!b||He(this,v).has(b.loadedName))){if((0,u.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:g,src:x,style:y}=b,f=new FontFace(g,x,y);this.addNativeFontFace(f);try{await f.load(),He(this,v).add(g)}catch{(0,u.warn)(`Cannot load system font: ${b.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(f)}return}(0,u.unreachable)("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(b){if(b.attached||b.missingFile&&!b.systemFontInfo)return;if(b.attached=!0,b.systemFontInfo){await this.loadSystemFont(b.systemFontInfo);return}if(this.isFontLoadingAPISupported){const x=b.createNativeFontFace();if(x){this.addNativeFontFace(x);try{await x.loaded}catch(y){throw(0,u.warn)(`Failed to load font '${x.family}': '${y}'.`),b.disableFontFace=!0,y}}return}const g=b.createFontFaceRule();if(g){if(this.insertRule(g),this.isSyncFontLoadingSupported)return;await new Promise(x=>{const y=this._queueLoadingCallback(x);this._prepareFontLoadEvent(b,y)})}}get isFontLoadingAPISupported(){var g;const b=!!((g=this._document)!=null&&g.fonts);return(0,u.shadow)(this,"isFontLoadingAPISupported",b)}get isSyncFontLoadingSupported(){let b=!1;return(u.isNodeJS||typeof navigator<"u"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(b=!0),(0,u.shadow)(this,"isSyncFontLoadingSupported",b)}_queueLoadingCallback(b){function g(){for((0,u.assert)(!y.done,"completeRequest() cannot be called twice."),y.done=!0;x.length>0&&x[0].done;){const f=x.shift();setTimeout(f.callback,0)}}const{loadingRequests:x}=this,y={done:!1,complete:g,callback:b};return x.push(y),y}get _loadTestFont(){const b=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return(0,u.shadow)(this,"_loadTestFont",b)}_prepareFontLoadEvent(b,g){function x(O,H){return O.charCodeAt(H)<<24|O.charCodeAt(H+1)<<16|O.charCodeAt(H+2)<<8|O.charCodeAt(H+3)&255}function y(O,H,j,q){const L=O.substring(0,H),F=O.substring(H+j);return L+q+F}let f,m;const C=this._document.createElement("canvas");C.width=1,C.height=1;const S=C.getContext("2d");let w=0;function _(O,H){if(++w>30){(0,u.warn)("Load test font never loaded."),H();return}if(S.font="30px "+O,S.fillText(".",0,20),S.getImageData(0,0,1,1).data[3]>0){H();return}setTimeout(_.bind(null,O,H))}const I=`lt${Date.now()}${this.loadTestFontId++}`;let $=this._loadTestFont;$=y($,976,I.length,I);const E=16,R=1482184792;let T=x($,E);for(f=0,m=I.length-3;f<m;f+=4)T=T-R+x(I,f)|0;f<I.length&&(T=T-R+x(I+"XXX",f)|0),$=y($,E,4,(0,u.string32)(T));const B=`url(data:font/opentype;base64,${btoa($)});`,M=`@font-face {font-family:"${I}";src:${B}}`;this.insertRule(M);const k=this._document.createElement("div");k.style.visibility="hidden",k.style.width=k.style.height="10px",k.style.position="absolute",k.style.top=k.style.left="0px";for(const O of[b.loadedName,I]){const H=this._document.createElement("span");H.textContent="Hi",H.style.fontFamily=O,k.append(H)}this._document.body.append(k),_(I,()=>{k.remove(),g.complete()})}}v=new WeakMap,s.FontLoader=d;class p{constructor(b,{isEvalSupported:g=!0,disableFontFace:x=!1,ignoreErrors:y=!1,inspectFont:f=null}){this.compiledGlyphs=Object.create(null);for(const m in b)this[m]=b[m];this.isEvalSupported=g!==!1,this.disableFontFace=x===!0,this.ignoreErrors=y===!0,this._inspectFont=f}createNativeFontFace(){var g;if(!this.data||this.disableFontFace)return null;let b;if(!this.cssFontInfo)b=new FontFace(this.loadedName,this.data,{});else{const x={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(x.style=`oblique ${this.cssFontInfo.italicAngle}deg`),b=new FontFace(this.cssFontInfo.fontFamily,this.data,x)}return(g=this._inspectFont)==null||g.call(this,this),b}createFontFaceRule(){var y;if(!this.data||this.disableFontFace)return null;const b=(0,u.bytesToString)(this.data),g=`url(data:${this.mimetype};base64,${btoa(b)});`;let x;if(!this.cssFontInfo)x=`@font-face {font-family:"${this.loadedName}";src:${g}}`;else{let f=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(f+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),x=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${f}src:${g}}`}return(y=this._inspectFont)==null||y.call(this,this,g),x}getPathGenerator(b,g){if(this.compiledGlyphs[g]!==void 0)return this.compiledGlyphs[g];let x;try{x=b.get(this.loadedName+"_path_"+g)}catch(y){if(!this.ignoreErrors)throw y;return(0,u.warn)(`getPathGenerator - ignoring character: "${y}".`),this.compiledGlyphs[g]=function(f,m){}}if(this.isEvalSupported&&u.FeatureTest.isEvalSupported){const y=[];for(const f of x){const m=f.args!==void 0?f.args.join(","):"";y.push("c.",f.cmd,"(",m,`);
|
60
60
|
`)}return this.compiledGlyphs[g]=new Function("c","size",y.join(""))}return this.compiledGlyphs[g]=function(y,f){for(const m of x)m.cmd==="scale"&&(m.args=[f,-f]),y[m.cmd].apply(y,m.args)}}}s.FontFaceObject=p},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.NodeStandardFontDataFactory=s.NodeFilterFactory=s.NodeCanvasFactory=s.NodeCMapReaderFactory=void 0;var u=c(7);c(1);const d=function(g){return new Promise((x,y)=>{require$$5.readFile(g,(m,C)=>{if(m||!C){y(new Error(m));return}x(new Uint8Array(C))})})};class p extends u.BaseFilterFactory{}s.NodeFilterFactory=p;class v extends u.BaseCanvasFactory{_createCanvas(x,y){return require$$5.createCanvas(x,y)}}s.NodeCanvasFactory=v;class A extends u.BaseCMapReaderFactory{_fetchData(x,y){return d(x).then(f=>({cMapData:f,compressionType:y}))}}s.NodeCMapReaderFactory=A;class b extends u.BaseStandardFontDataFactory{_fetchData(x){return d(x)}}s.NodeStandardFontDataFactory=b},(a,s,c)=>{var N,il,ol;Object.defineProperty(s,"__esModule",{value:!0}),s.CanvasGraphics=void 0;var u=c(1),d=c(6),p=c(12),v=c(13);const A=16,b=100,g=4096,x=15,y=10,f=1e3,m=16;function C(Q,Y){if(Q._removeMirroring)throw new Error("Context is already forwarding operations.");Q.__originalSave=Q.save,Q.__originalRestore=Q.restore,Q.__originalRotate=Q.rotate,Q.__originalScale=Q.scale,Q.__originalTranslate=Q.translate,Q.__originalTransform=Q.transform,Q.__originalSetTransform=Q.setTransform,Q.__originalResetTransform=Q.resetTransform,Q.__originalClip=Q.clip,Q.__originalMoveTo=Q.moveTo,Q.__originalLineTo=Q.lineTo,Q.__originalBezierCurveTo=Q.bezierCurveTo,Q.__originalRect=Q.rect,Q.__originalClosePath=Q.closePath,Q.__originalBeginPath=Q.beginPath,Q._removeMirroring=()=>{Q.save=Q.__originalSave,Q.restore=Q.__originalRestore,Q.rotate=Q.__originalRotate,Q.scale=Q.__originalScale,Q.translate=Q.__originalTranslate,Q.transform=Q.__originalTransform,Q.setTransform=Q.__originalSetTransform,Q.resetTransform=Q.__originalResetTransform,Q.clip=Q.__originalClip,Q.moveTo=Q.__originalMoveTo,Q.lineTo=Q.__originalLineTo,Q.bezierCurveTo=Q.__originalBezierCurveTo,Q.rect=Q.__originalRect,Q.closePath=Q.__originalClosePath,Q.beginPath=Q.__originalBeginPath,delete Q._removeMirroring},Q.save=function(){Y.save(),this.__originalSave()},Q.restore=function(){Y.restore(),this.__originalRestore()},Q.translate=function(ee,re){Y.translate(ee,re),this.__originalTranslate(ee,re)},Q.scale=function(ee,re){Y.scale(ee,re),this.__originalScale(ee,re)},Q.transform=function(ee,re,ae,V,K,te){Y.transform(ee,re,ae,V,K,te),this.__originalTransform(ee,re,ae,V,K,te)},Q.setTransform=function(ee,re,ae,V,K,te){Y.setTransform(ee,re,ae,V,K,te),this.__originalSetTransform(ee,re,ae,V,K,te)},Q.resetTransform=function(){Y.resetTransform(),this.__originalResetTransform()},Q.rotate=function(ee){Y.rotate(ee),this.__originalRotate(ee)},Q.clip=function(ee){Y.clip(ee),this.__originalClip(ee)},Q.moveTo=function(J,ee){Y.moveTo(J,ee),this.__originalMoveTo(J,ee)},Q.lineTo=function(J,ee){Y.lineTo(J,ee),this.__originalLineTo(J,ee)},Q.bezierCurveTo=function(J,ee,re,ae,V,K){Y.bezierCurveTo(J,ee,re,ae,V,K),this.__originalBezierCurveTo(J,ee,re,ae,V,K)},Q.rect=function(J,ee,re,ae){Y.rect(J,ee,re,ae),this.__originalRect(J,ee,re,ae)},Q.closePath=function(){Y.closePath(),this.__originalClosePath()},Q.beginPath=function(){Y.beginPath(),this.__originalBeginPath()}}class S{constructor(Y){this.canvasFactory=Y,this.cache=Object.create(null)}getCanvas(Y,J,ee){let re;return this.cache[Y]!==void 0?(re=this.cache[Y],this.canvasFactory.reset(re,J,ee)):(re=this.canvasFactory.create(J,ee),this.cache[Y]=re),re}delete(Y){delete this.cache[Y]}clear(){for(const Y in this.cache){const J=this.cache[Y];this.canvasFactory.destroy(J),delete this.cache[Y]}}}function w(Q,Y,J,ee,re,ae,V,K,te,ie){const[ce,me,we,ve,ge,ue]=(0,d.getCurrentTransform)(Q);if(me===0&&we===0){const de=V*ce+ge,le=Math.round(de),xe=K*ve+ue,Ce=Math.round(xe),$e=(V+te)*ce+ge,Se=Math.abs(Math.round($e)-le)||1,Ee=(K+ie)*ve+ue,Ae=Math.abs(Math.round(Ee)-Ce)||1;return Q.setTransform(Math.sign(ce),0,0,Math.sign(ve),le,Ce),Q.drawImage(Y,J,ee,re,ae,0,0,Se,Ae),Q.setTransform(ce,me,we,ve,ge,ue),[Se,Ae]}if(ce===0&&ve===0){const de=K*we+ge,le=Math.round(de),xe=V*me+ue,Ce=Math.round(xe),$e=(K+ie)*we+ge,Se=Math.abs(Math.round($e)-le)||1,Ee=(V+te)*me+ue,Ae=Math.abs(Math.round(Ee)-Ce)||1;return Q.setTransform(0,Math.sign(me),Math.sign(we),0,le,Ce),Q.drawImage(Y,J,ee,re,ae,0,0,Ae,Se),Q.setTransform(ce,me,we,ve,ge,ue),[Ae,Se]}Q.drawImage(Y,J,ee,re,ae,V,K,te,ie);const se=Math.hypot(ce,me),oe=Math.hypot(we,ve);return[se*te,oe*ie]}function _(Q){const{width:Y,height:J}=Q;if(Y>f||J>f)return null;const ee=1e3,re=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),ae=Y+1;let V=new Uint8Array(ae*(J+1)),K,te,ie;const ce=Y+7&-8;let me=new Uint8Array(ce*J),we=0;for(const oe of Q.data){let de=128;for(;de>0;)me[we++]=oe&de?0:255,de>>=1}let ve=0;for(we=0,me[we]!==0&&(V[0]=1,++ve),te=1;te<Y;te++)me[we]!==me[we+1]&&(V[te]=me[we]?2:1,++ve),we++;for(me[we]!==0&&(V[te]=2,++ve),K=1;K<J;K++){we=K*ce,ie=K*ae,me[we-ce]!==me[we]&&(V[ie]=me[we]?1:8,++ve);let oe=(me[we]?4:0)+(me[we-ce]?8:0);for(te=1;te<Y;te++)oe=(oe>>2)+(me[we+1]?4:0)+(me[we-ce+1]?8:0),re[oe]&&(V[ie+te]=re[oe],++ve),we++;if(me[we-ce]!==me[we]&&(V[ie+te]=me[we]?2:4,++ve),ve>ee)return null}for(we=ce*(J-1),ie=K*ae,me[we]!==0&&(V[ie]=8,++ve),te=1;te<Y;te++)me[we]!==me[we+1]&&(V[ie+te]=me[we]?4:8,++ve),we++;if(me[we]!==0&&(V[ie+te]=4,++ve),ve>ee)return null;const ge=new Int32Array([0,ae,-1,0,-ae,0,0,0,1]),ue=new Path2D;for(K=0;ve&&K<=J;K++){let oe=K*ae;const de=oe+Y;for(;oe<de&&!V[oe];)oe++;if(oe===de)continue;ue.moveTo(oe%ae,K);const le=oe;let xe=V[oe];do{const Ce=ge[xe];do oe+=Ce;while(!V[oe]);const $e=V[oe];$e!==5&&$e!==10?(xe=$e,V[oe]=0):(xe=$e&51*xe>>4,V[oe]&=xe>>2|xe<<2),ue.lineTo(oe%ae,oe/ae|0),V[oe]||--ve}while(le!==oe);--K}return me=null,V=null,function(oe){oe.save(),oe.scale(1/Y,-1/J),oe.translate(0,-J),oe.fill(ue),oe.beginPath(),oe.restore()}}class I{constructor(Y,J){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=u.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=u.FONT_IDENTITY_MATRIX,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=u.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,Y,J])}clone(){const Y=Object.create(this);return Y.clipBox=this.clipBox.slice(),Y}setCurrentPoint(Y,J){this.x=Y,this.y=J}updatePathMinMax(Y,J,ee){[J,ee]=u.Util.applyTransform([J,ee],Y),this.minX=Math.min(this.minX,J),this.minY=Math.min(this.minY,ee),this.maxX=Math.max(this.maxX,J),this.maxY=Math.max(this.maxY,ee)}updateRectMinMax(Y,J){const ee=u.Util.applyTransform(J,Y),re=u.Util.applyTransform(J.slice(2),Y);this.minX=Math.min(this.minX,ee[0],re[0]),this.minY=Math.min(this.minY,ee[1],re[1]),this.maxX=Math.max(this.maxX,ee[0],re[0]),this.maxY=Math.max(this.maxY,ee[1],re[1])}updateScalingPathMinMax(Y,J){u.Util.scaleMinMax(Y,J),this.minX=Math.min(this.minX,J[0]),this.maxX=Math.max(this.maxX,J[1]),this.minY=Math.min(this.minY,J[2]),this.maxY=Math.max(this.maxY,J[3])}updateCurvePathMinMax(Y,J,ee,re,ae,V,K,te,ie,ce){const me=u.Util.bezierBoundingBox(J,ee,re,ae,V,K,te,ie);if(ce){ce[0]=Math.min(ce[0],me[0],me[2]),ce[1]=Math.max(ce[1],me[0],me[2]),ce[2]=Math.min(ce[2],me[1],me[3]),ce[3]=Math.max(ce[3],me[1],me[3]);return}this.updateRectMinMax(Y,me)}getPathBoundingBox(Y=p.PathType.FILL,J=null){const ee=[this.minX,this.minY,this.maxX,this.maxY];if(Y===p.PathType.STROKE){J||(0,u.unreachable)("Stroke bounding box must include transform.");const re=u.Util.singularValueDecompose2dScale(J),ae=re[0]*this.lineWidth/2,V=re[1]*this.lineWidth/2;ee[0]-=ae,ee[1]-=V,ee[2]+=ae,ee[3]+=V}return ee}updateClipFromPath(){const Y=u.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(Y||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(Y){this.clipBox=Y,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(Y=p.PathType.FILL,J=null){return u.Util.intersect(this.clipBox,this.getPathBoundingBox(Y,J))}}function $(Q,Y){if(typeof ImageData<"u"&&Y instanceof ImageData){Q.putImageData(Y,0,0);return}const J=Y.height,ee=Y.width,re=J%m,ae=(J-re)/m,V=re===0?ae:ae+1,K=Q.createImageData(ee,m);let te=0,ie;const ce=Y.data,me=K.data;let we,ve,ge,ue;if(Y.kind===u.ImageKind.GRAYSCALE_1BPP){const se=ce.byteLength,oe=new Uint32Array(me.buffer,0,me.byteLength>>2),de=oe.length,le=ee+7>>3,xe=4294967295,Ce=u.FeatureTest.isLittleEndian?4278190080:255;for(we=0;we<V;we++){for(ge=we<ae?m:re,ie=0,ve=0;ve<ge;ve++){const $e=se-te;let Se=0;const Ee=$e>le?ee:$e*8-7,Ae=Ee&-8;let pe=0,he=0;for(;Se<Ae;Se+=8)he=ce[te++],oe[ie++]=he&128?xe:Ce,oe[ie++]=he&64?xe:Ce,oe[ie++]=he&32?xe:Ce,oe[ie++]=he&16?xe:Ce,oe[ie++]=he&8?xe:Ce,oe[ie++]=he&4?xe:Ce,oe[ie++]=he&2?xe:Ce,oe[ie++]=he&1?xe:Ce;for(;Se<Ee;Se++)pe===0&&(he=ce[te++],pe=128),oe[ie++]=he&pe?xe:Ce,pe>>=1}for(;ie<de;)oe[ie++]=0;Q.putImageData(K,0,we*m)}}else if(Y.kind===u.ImageKind.RGBA_32BPP){for(ve=0,ue=ee*m*4,we=0;we<ae;we++)me.set(ce.subarray(te,te+ue)),te+=ue,Q.putImageData(K,0,ve),ve+=m;we<V&&(ue=ee*re*4,me.set(ce.subarray(te,te+ue)),Q.putImageData(K,0,ve))}else if(Y.kind===u.ImageKind.RGB_24BPP)for(ge=m,ue=ee*ge,we=0;we<V;we++){for(we>=ae&&(ge=re,ue=ee*ge),ie=0,ve=ue;ve--;)me[ie++]=ce[te++],me[ie++]=ce[te++],me[ie++]=ce[te++],me[ie++]=255;Q.putImageData(K,0,we*m)}else throw new Error(`bad image kind: ${Y.kind}`)}function P(Q,Y){if(Y.bitmap){Q.drawImage(Y.bitmap,0,0);return}const J=Y.height,ee=Y.width,re=J%m,ae=(J-re)/m,V=re===0?ae:ae+1,K=Q.createImageData(ee,m);let te=0;const ie=Y.data,ce=K.data;for(let me=0;me<V;me++){const we=me<ae?m:re;({srcPos:te}=(0,v.convertBlackAndWhiteToRGBA)({src:ie,srcPos:te,dest:ce,width:ee,height:we,nonBlackColor:0})),Q.putImageData(K,0,me*m)}}function E(Q,Y){const J=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const ee of J)Q[ee]!==void 0&&(Y[ee]=Q[ee]);Q.setLineDash!==void 0&&(Y.setLineDash(Q.getLineDash()),Y.lineDashOffset=Q.lineDashOffset)}function R(Q){if(Q.strokeStyle=Q.fillStyle="#000000",Q.fillRule="nonzero",Q.globalAlpha=1,Q.lineWidth=1,Q.lineCap="butt",Q.lineJoin="miter",Q.miterLimit=10,Q.globalCompositeOperation="source-over",Q.font="10px sans-serif",Q.setLineDash!==void 0&&(Q.setLineDash([]),Q.lineDashOffset=0),!u.isNodeJS){const{filter:Y}=Q;Y!=="none"&&Y!==""&&(Q.filter="none")}}function T(Q,Y,J,ee){const re=Q.length;for(let ae=3;ae<re;ae+=4){const V=Q[ae];if(V===0)Q[ae-3]=Y,Q[ae-2]=J,Q[ae-1]=ee;else if(V<255){const K=255-V;Q[ae-3]=Q[ae-3]*V+Y*K>>8,Q[ae-2]=Q[ae-2]*V+J*K>>8,Q[ae-1]=Q[ae-1]*V+ee*K>>8}}}function B(Q,Y,J){const ee=Q.length,re=1/255;for(let ae=3;ae<ee;ae+=4){const V=J?J[Q[ae]]:Q[ae];Y[ae]=Y[ae]*V*re|0}}function M(Q,Y,J){const ee=Q.length;for(let re=3;re<ee;re+=4){const ae=Q[re-3]*77+Q[re-2]*152+Q[re-1]*28;Y[re]=J?Y[re]*J[ae>>8]>>8:Y[re]*ae>>16}}function k(Q,Y,J,ee,re,ae,V,K,te,ie,ce){const me=!!ae,we=me?ae[0]:0,ve=me?ae[1]:0,ge=me?ae[2]:0,ue=re==="Luminosity"?M:B,oe=Math.min(ee,Math.ceil(1048576/J));for(let de=0;de<ee;de+=oe){const le=Math.min(oe,ee-de),xe=Q.getImageData(K-ie,de+(te-ce),J,le),Ce=Y.getImageData(K,de+te,J,le);me&&T(xe.data,we,ve,ge),ue(xe.data,Ce.data,V),Y.putImageData(Ce,K,de+te)}}function O(Q,Y,J,ee){const re=ee[0],ae=ee[1],V=ee[2]-re,K=ee[3]-ae;V===0||K===0||(k(Y.context,J,V,K,Y.subtype,Y.backdrop,Y.transferMap,re,ae,Y.offsetX,Y.offsetY),Q.save(),Q.globalAlpha=1,Q.globalCompositeOperation="source-over",Q.setTransform(1,0,0,1,0,0),Q.drawImage(J.canvas,0,0),Q.restore())}function H(Q,Y){const J=u.Util.singularValueDecompose2dScale(Q);J[0]=Math.fround(J[0]),J[1]=Math.fround(J[1]);const ee=Math.fround((globalThis.devicePixelRatio||1)*d.PixelsPerInch.PDF_TO_CSS_UNITS);return Y!==void 0?Y:J[0]<=ee||J[1]<=ee}const j=["butt","round","square"],q=["miter","round","bevel"],L={},F={},Z=class Z{constructor(Y,J,ee,re,ae,{optionalContentConfig:V,markedContentStack:K=null},te,ie){bt(this,N);this.ctx=Y,this.current=new I(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=J,this.objs=ee,this.canvasFactory=re,this.filterFactory=ae,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=K||[],this.optionalContentConfig=V,this.cachedCanvases=new S(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=te,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=ie,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(Y,J=null){return typeof Y=="string"?Y.startsWith("g_")?this.commonObjs.get(Y):this.objs.get(Y):J}beginDrawing({transform:Y,viewport:J,transparency:ee=!1,background:re=null}){const ae=this.ctx.canvas.width,V=this.ctx.canvas.height,K=this.ctx.fillStyle;if(this.ctx.fillStyle=re||"#ffffff",this.ctx.fillRect(0,0,ae,V),this.ctx.fillStyle=K,ee){const te=this.cachedCanvases.getCanvas("transparent",ae,V);this.compositeCtx=this.ctx,this.transparentCanvas=te.canvas,this.ctx=te.context,this.ctx.save(),this.ctx.transform(...(0,d.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),R(this.ctx),Y&&(this.ctx.transform(...Y),this.outputScaleX=Y[0],this.outputScaleY=Y[0]),this.ctx.transform(...J.transform),this.viewportScale=J.scale,this.baseTransform=(0,d.getCurrentTransform)(this.ctx)}executeOperatorList(Y,J,ee,re){const ae=Y.argsArray,V=Y.fnArray;let K=J||0;const te=ae.length;if(te===K)return K;const ie=te-K>y&&typeof ee=="function",ce=ie?Date.now()+x:0;let me=0;const we=this.commonObjs,ve=this.objs;let ge;for(;;){if(re!==void 0&&K===re.nextBreakPoint)return re.breakIt(K,ee),K;if(ge=V[K],ge!==u.OPS.dependency)this[ge].apply(this,ae[K]);else for(const ue of ae[K]){const se=ue.startsWith("g_")?we:ve;if(!se.has(ue))return se.get(ue,ee),K}if(K++,K===te)return K;if(ie&&++me>y){if(Date.now()>ce)return ee(),K;me=0}}}endDrawing(){it(this,N,il).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const Y of this._cachedBitmapsMap.values()){for(const J of Y.values())typeof HTMLCanvasElement<"u"&&J instanceof HTMLCanvasElement&&(J.width=J.height=0);Y.clear()}this._cachedBitmapsMap.clear(),it(this,N,ol).call(this)}_scaleImage(Y,J){const ee=Y.width,re=Y.height;let ae=Math.max(Math.hypot(J[0],J[1]),1),V=Math.max(Math.hypot(J[2],J[3]),1),K=ee,te=re,ie="prescale1",ce,me;for(;ae>2&&K>1||V>2&&te>1;){let we=K,ve=te;ae>2&&K>1&&(we=K>=16384?Math.floor(K/2)-1||1:Math.ceil(K/2),ae/=K/we),V>2&&te>1&&(ve=te>=16384?Math.floor(te/2)-1||1:Math.ceil(te)/2,V/=te/ve),ce=this.cachedCanvases.getCanvas(ie,we,ve),me=ce.context,me.clearRect(0,0,we,ve),me.drawImage(Y,0,0,K,te,0,0,we,ve),Y=ce.canvas,K=we,te=ve,ie=ie==="prescale1"?"prescale2":"prescale1"}return{img:Y,paintWidth:K,paintHeight:te}}_createMaskCanvas(Y){const J=this.ctx,{width:ee,height:re}=Y,ae=this.current.fillColor,V=this.current.patternFill,K=(0,d.getCurrentTransform)(J);let te,ie,ce,me;if((Y.bitmap||Y.data)&&Y.count>1){const Se=Y.bitmap||Y.data.buffer;ie=JSON.stringify(V?K:[K.slice(0,4),ae]),te=this._cachedBitmapsMap.get(Se),te||(te=new Map,this._cachedBitmapsMap.set(Se,te));const Ee=te.get(ie);if(Ee&&!V){const Ae=Math.round(Math.min(K[0],K[2])+K[4]),pe=Math.round(Math.min(K[1],K[3])+K[5]);return{canvas:Ee,offsetX:Ae,offsetY:pe}}ce=Ee}ce||(me=this.cachedCanvases.getCanvas("maskCanvas",ee,re),P(me.context,Y));let we=u.Util.transform(K,[1/ee,0,0,-1/re,0,0]);we=u.Util.transform(we,[1,0,0,1,0,-re]);const ve=u.Util.applyTransform([0,0],we),ge=u.Util.applyTransform([ee,re],we),ue=u.Util.normalizeRect([ve[0],ve[1],ge[0],ge[1]]),se=Math.round(ue[2]-ue[0])||1,oe=Math.round(ue[3]-ue[1])||1,de=this.cachedCanvases.getCanvas("fillCanvas",se,oe),le=de.context,xe=Math.min(ve[0],ge[0]),Ce=Math.min(ve[1],ge[1]);le.translate(-xe,-Ce),le.transform(...we),ce||(ce=this._scaleImage(me.canvas,(0,d.getCurrentTransformInverse)(le)),ce=ce.img,te&&V&&te.set(ie,ce)),le.imageSmoothingEnabled=H((0,d.getCurrentTransform)(le),Y.interpolate),w(le,ce,0,0,ce.width,ce.height,0,0,ee,re),le.globalCompositeOperation="source-in";const $e=u.Util.transform((0,d.getCurrentTransformInverse)(le),[1,0,0,1,-xe,-Ce]);return le.fillStyle=V?ae.getPattern(J,this,$e,p.PathType.FILL):ae,le.fillRect(0,0,ee,re),te&&!V&&(this.cachedCanvases.delete("fillCanvas"),te.set(ie,de.canvas)),{canvas:de.canvas,offsetX:Math.round(xe),offsetY:Math.round(Ce)}}setLineWidth(Y){Y!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=Y,this.ctx.lineWidth=Y}setLineCap(Y){this.ctx.lineCap=j[Y]}setLineJoin(Y){this.ctx.lineJoin=q[Y]}setMiterLimit(Y){this.ctx.miterLimit=Y}setDash(Y,J){const ee=this.ctx;ee.setLineDash!==void 0&&(ee.setLineDash(Y),ee.lineDashOffset=J)}setRenderingIntent(Y){}setFlatness(Y){}setGState(Y){for(const[J,ee]of Y)switch(J){case"LW":this.setLineWidth(ee);break;case"LC":this.setLineCap(ee);break;case"LJ":this.setLineJoin(ee);break;case"ML":this.setMiterLimit(ee);break;case"D":this.setDash(ee[0],ee[1]);break;case"RI":this.setRenderingIntent(ee);break;case"FL":this.setFlatness(ee);break;case"Font":this.setFont(ee[0],ee[1]);break;case"CA":this.current.strokeAlpha=ee;break;case"ca":this.current.fillAlpha=ee,this.ctx.globalAlpha=ee;break;case"BM":this.ctx.globalCompositeOperation=ee;break;case"SMask":this.current.activeSMask=ee?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(ee);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const Y=this.inSMaskMode;this.current.activeSMask&&!Y?this.beginSMaskMode():!this.current.activeSMask&&Y&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const Y=this.ctx.canvas.width,J=this.ctx.canvas.height,ee="smaskGroupAt"+this.groupLevel,re=this.cachedCanvases.getCanvas(ee,Y,J);this.suspendedCtx=this.ctx,this.ctx=re.context;const ae=this.ctx;ae.setTransform(...(0,d.getCurrentTransform)(this.suspendedCtx)),E(this.suspendedCtx,ae),C(ae,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),E(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(Y){if(!this.current.activeSMask)return;Y?(Y[0]=Math.floor(Y[0]),Y[1]=Math.floor(Y[1]),Y[2]=Math.ceil(Y[2]),Y[3]=Math.ceil(Y[3])):Y=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const J=this.current.activeSMask,ee=this.suspendedCtx;O(ee,J,this.ctx,Y),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()}save(){this.inSMaskMode?(E(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const Y=this.current;this.stateStack.push(Y),this.current=Y.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),E(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(Y,J,ee,re,ae,V){this.ctx.transform(Y,J,ee,re,ae,V),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(Y,J,ee){const re=this.ctx,ae=this.current;let V=ae.x,K=ae.y,te,ie;const ce=(0,d.getCurrentTransform)(re),me=ce[0]===0&&ce[3]===0||ce[1]===0&&ce[2]===0,we=me?ee.slice(0):null;for(let ve=0,ge=0,ue=Y.length;ve<ue;ve++)switch(Y[ve]|0){case u.OPS.rectangle:V=J[ge++],K=J[ge++];const se=J[ge++],oe=J[ge++],de=V+se,le=K+oe;re.moveTo(V,K),se===0||oe===0?re.lineTo(de,le):(re.lineTo(de,K),re.lineTo(de,le),re.lineTo(V,le)),me||ae.updateRectMinMax(ce,[V,K,de,le]),re.closePath();break;case u.OPS.moveTo:V=J[ge++],K=J[ge++],re.moveTo(V,K),me||ae.updatePathMinMax(ce,V,K);break;case u.OPS.lineTo:V=J[ge++],K=J[ge++],re.lineTo(V,K),me||ae.updatePathMinMax(ce,V,K);break;case u.OPS.curveTo:te=V,ie=K,V=J[ge+4],K=J[ge+5],re.bezierCurveTo(J[ge],J[ge+1],J[ge+2],J[ge+3],V,K),ae.updateCurvePathMinMax(ce,te,ie,J[ge],J[ge+1],J[ge+2],J[ge+3],V,K,we),ge+=6;break;case u.OPS.curveTo2:te=V,ie=K,re.bezierCurveTo(V,K,J[ge],J[ge+1],J[ge+2],J[ge+3]),ae.updateCurvePathMinMax(ce,te,ie,V,K,J[ge],J[ge+1],J[ge+2],J[ge+3],we),V=J[ge+2],K=J[ge+3],ge+=4;break;case u.OPS.curveTo3:te=V,ie=K,V=J[ge+2],K=J[ge+3],re.bezierCurveTo(J[ge],J[ge+1],V,K,V,K),ae.updateCurvePathMinMax(ce,te,ie,J[ge],J[ge+1],V,K,V,K,we),ge+=4;break;case u.OPS.closePath:re.closePath();break}me&&ae.updateScalingPathMinMax(ce,we),ae.setCurrentPoint(V,K)}closePath(){this.ctx.closePath()}stroke(Y=!0){const J=this.ctx,ee=this.current.strokeColor;J.globalAlpha=this.current.strokeAlpha,this.contentVisible&&(typeof ee=="object"&&(ee!=null&&ee.getPattern)?(J.save(),J.strokeStyle=ee.getPattern(J,this,(0,d.getCurrentTransformInverse)(J),p.PathType.STROKE),this.rescaleAndStroke(!1),J.restore()):this.rescaleAndStroke(!0)),Y&&this.consumePath(this.current.getClippedPathBoundingBox()),J.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(Y=!0){const J=this.ctx,ee=this.current.fillColor,re=this.current.patternFill;let ae=!1;re&&(J.save(),J.fillStyle=ee.getPattern(J,this,(0,d.getCurrentTransformInverse)(J),p.PathType.FILL),ae=!0);const V=this.current.getClippedPathBoundingBox();this.contentVisible&&V!==null&&(this.pendingEOFill?(J.fill("evenodd"),this.pendingEOFill=!1):J.fill()),ae&&J.restore(),Y&&this.consumePath(V)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=L}eoClip(){this.pendingClip=F}beginText(){this.current.textMatrix=u.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const Y=this.pendingTextPaths,J=this.ctx;if(Y===void 0){J.beginPath();return}J.save(),J.beginPath();for(const ee of Y)J.setTransform(...ee.transform),J.translate(ee.x,ee.y),ee.addToPath(J,ee.fontSize);J.restore(),J.clip(),J.beginPath(),delete this.pendingTextPaths}setCharSpacing(Y){this.current.charSpacing=Y}setWordSpacing(Y){this.current.wordSpacing=Y}setHScale(Y){this.current.textHScale=Y/100}setLeading(Y){this.current.leading=-Y}setFont(Y,J){var ce;const ee=this.commonObjs.get(Y),re=this.current;if(!ee)throw new Error(`Can't find font for ${Y}`);if(re.fontMatrix=ee.fontMatrix||u.FONT_IDENTITY_MATRIX,(re.fontMatrix[0]===0||re.fontMatrix[3]===0)&&(0,u.warn)("Invalid font matrix for font "+Y),J<0?(J=-J,re.fontDirection=-1):re.fontDirection=1,this.current.font=ee,this.current.fontSize=J,ee.isType3Font)return;const ae=ee.loadedName||"sans-serif",V=((ce=ee.systemFontInfo)==null?void 0:ce.css)||`"${ae}", ${ee.fallbackName}`;let K="normal";ee.black?K="900":ee.bold&&(K="bold");const te=ee.italic?"italic":"normal";let ie=J;J<A?ie=A:J>b&&(ie=b),this.current.fontSizeScale=J/ie,this.ctx.font=`${te} ${K} ${ie}px ${V}`}setTextRenderingMode(Y){this.current.textRenderingMode=Y}setTextRise(Y){this.current.textRise=Y}moveText(Y,J){this.current.x=this.current.lineX+=Y,this.current.y=this.current.lineY+=J}setLeadingMoveText(Y,J){this.setLeading(-J),this.moveText(Y,J)}setTextMatrix(Y,J,ee,re,ae,V){this.current.textMatrix=[Y,J,ee,re,ae,V],this.current.textMatrixScale=Math.hypot(Y,J),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(Y,J,ee,re){const ae=this.ctx,V=this.current,K=V.font,te=V.textRenderingMode,ie=V.fontSize/V.fontSizeScale,ce=te&u.TextRenderingMode.FILL_STROKE_MASK,me=!!(te&u.TextRenderingMode.ADD_TO_PATH_FLAG),we=V.patternFill&&!K.missingFile;let ve;(K.disableFontFace||me||we)&&(ve=K.getPathGenerator(this.commonObjs,Y)),K.disableFontFace||we?(ae.save(),ae.translate(J,ee),ae.beginPath(),ve(ae,ie),re&&ae.setTransform(...re),(ce===u.TextRenderingMode.FILL||ce===u.TextRenderingMode.FILL_STROKE)&&ae.fill(),(ce===u.TextRenderingMode.STROKE||ce===u.TextRenderingMode.FILL_STROKE)&&ae.stroke(),ae.restore()):((ce===u.TextRenderingMode.FILL||ce===u.TextRenderingMode.FILL_STROKE)&&ae.fillText(Y,J,ee),(ce===u.TextRenderingMode.STROKE||ce===u.TextRenderingMode.FILL_STROKE)&&ae.strokeText(Y,J,ee)),me&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:(0,d.getCurrentTransform)(ae),x:J,y:ee,fontSize:ie,addToPath:ve})}get isFontSubpixelAAEnabled(){const{context:Y}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);Y.scale(1.5,1),Y.fillText("I",0,10);const J=Y.getImageData(0,0,10,10).data;let ee=!1;for(let re=3;re<J.length;re+=4)if(J[re]>0&&J[re]<255){ee=!0;break}return(0,u.shadow)(this,"isFontSubpixelAAEnabled",ee)}showText(Y){const J=this.current,ee=J.font;if(ee.isType3Font)return this.showType3Text(Y);const re=J.fontSize;if(re===0)return;const ae=this.ctx,V=J.fontSizeScale,K=J.charSpacing,te=J.wordSpacing,ie=J.fontDirection,ce=J.textHScale*ie,me=Y.length,we=ee.vertical,ve=we?1:-1,ge=ee.defaultVMetrics,ue=re*J.fontMatrix[0],se=J.textRenderingMode===u.TextRenderingMode.FILL&&!ee.disableFontFace&&!J.patternFill;ae.save(),ae.transform(...J.textMatrix),ae.translate(J.x,J.y+J.textRise),ie>0?ae.scale(ce,-1):ae.scale(ce,1);let oe;if(J.patternFill){ae.save();const $e=J.fillColor.getPattern(ae,this,(0,d.getCurrentTransformInverse)(ae),p.PathType.FILL);oe=(0,d.getCurrentTransform)(ae),ae.restore(),ae.fillStyle=$e}let de=J.lineWidth;const le=J.textMatrixScale;if(le===0||de===0){const $e=J.textRenderingMode&u.TextRenderingMode.FILL_STROKE_MASK;($e===u.TextRenderingMode.STROKE||$e===u.TextRenderingMode.FILL_STROKE)&&(de=this.getSinglePixelWidth())}else de/=le;if(V!==1&&(ae.scale(V,V),de/=V),ae.lineWidth=de,ee.isInvalidPDFjsFont){const $e=[];let Se=0;for(const Ee of Y)$e.push(Ee.unicode),Se+=Ee.width;ae.fillText($e.join(""),0,0),J.x+=Se*ue*ce,ae.restore(),this.compose();return}let xe=0,Ce;for(Ce=0;Ce<me;++Ce){const $e=Y[Ce];if(typeof $e=="number"){xe+=ve*$e*re/1e3;continue}let Se=!1;const Ee=($e.isSpace?te:0)+K,Ae=$e.fontChar,pe=$e.accent;let he,Ie,ye=$e.width;if(we){const Ne=$e.vmetric||ge,Le=-($e.vmetric?Ne[1]:ye*.5)*ue,Oe=Ne[2]*ue;ye=Ne?-Ne[0]:ye,he=Le/V,Ie=(xe+Oe)/V}else he=xe/V,Ie=0;if(ee.remeasure&&ye>0){const Ne=ae.measureText(Ae).width*1e3/re*V;if(ye<Ne&&this.isFontSubpixelAAEnabled){const Le=ye/Ne;Se=!0,ae.save(),ae.scale(Le,1),he/=Le}else ye!==Ne&&(he+=(ye-Ne)/2e3*re/V)}if(this.contentVisible&&($e.isInFont||ee.missingFile)){if(se&&!pe)ae.fillText(Ae,he,Ie);else if(this.paintChar(Ae,he,Ie,oe),pe){const Ne=he+re*pe.offset.x/V,Le=Ie-re*pe.offset.y/V;this.paintChar(pe.fontChar,Ne,Le,oe)}}const Pe=we?ye*ue-Ee*ie:ye*ue+Ee*ie;xe+=Pe,Se&&ae.restore()}we?J.y-=xe:J.x+=xe*ce,ae.restore(),this.compose()}showType3Text(Y){const J=this.ctx,ee=this.current,re=ee.font,ae=ee.fontSize,V=ee.fontDirection,K=re.vertical?1:-1,te=ee.charSpacing,ie=ee.wordSpacing,ce=ee.textHScale*V,me=ee.fontMatrix||u.FONT_IDENTITY_MATRIX,we=Y.length,ve=ee.textRenderingMode===u.TextRenderingMode.INVISIBLE;let ge,ue,se,oe;if(!(ve||ae===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,J.save(),J.transform(...ee.textMatrix),J.translate(ee.x,ee.y),J.scale(ce,V),ge=0;ge<we;++ge){if(ue=Y[ge],typeof ue=="number"){oe=K*ue*ae/1e3,this.ctx.translate(oe,0),ee.x+=oe*ce;continue}const de=(ue.isSpace?ie:0)+te,le=re.charProcOperatorList[ue.operatorListId];if(!le){(0,u.warn)(`Type3 character "${ue.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=ue,this.save(),J.scale(ae,ae),J.transform(...me),this.executeOperatorList(le),this.restore()),se=u.Util.applyTransform([ue.width,0],me)[0]*ae+de,J.translate(se,0),ee.x+=se*ce}J.restore(),this.processingType3=null}}setCharWidth(Y,J){}setCharWidthAndBounds(Y,J,ee,re,ae,V){this.ctx.rect(ee,re,ae-ee,V-re),this.ctx.clip(),this.endPath()}getColorN_Pattern(Y){let J;if(Y[0]==="TilingPattern"){const ee=Y[1],re=this.baseTransform||(0,d.getCurrentTransform)(this.ctx),ae={createCanvasGraphics:V=>new Z(V,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};J=new p.TilingPattern(Y,ee,this.ctx,ae,re)}else J=this._getPattern(Y[1],Y[2]);return J}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(Y,J,ee){const re=u.Util.makeHexColor(Y,J,ee);this.ctx.strokeStyle=re,this.current.strokeColor=re}setFillRGBColor(Y,J,ee){const re=u.Util.makeHexColor(Y,J,ee);this.ctx.fillStyle=re,this.current.fillColor=re,this.current.patternFill=!1}_getPattern(Y,J=null){let ee;return this.cachedPatterns.has(Y)?ee=this.cachedPatterns.get(Y):(ee=(0,p.getShadingPattern)(this.getObject(Y)),this.cachedPatterns.set(Y,ee)),J&&(ee.matrix=J),ee}shadingFill(Y){if(!this.contentVisible)return;const J=this.ctx;this.save();const ee=this._getPattern(Y);J.fillStyle=ee.getPattern(J,this,(0,d.getCurrentTransformInverse)(J),p.PathType.SHADING);const re=(0,d.getCurrentTransformInverse)(J);if(re){const{width:ae,height:V}=J.canvas,[K,te,ie,ce]=u.Util.getAxialAlignedBoundingBox([0,0,ae,V],re);this.ctx.fillRect(K,te,ie-K,ce-te)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,u.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,u.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(Y,J){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(Y)&&Y.length===6&&this.transform(...Y),this.baseTransform=(0,d.getCurrentTransform)(this.ctx),J)){const ee=J[2]-J[0],re=J[3]-J[1];this.ctx.rect(J[0],J[1],ee,re),this.current.updateRectMinMax((0,d.getCurrentTransform)(this.ctx),J),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(Y){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const J=this.ctx;Y.isolated||(0,u.info)("TODO: Support non-isolated groups."),Y.knockout&&(0,u.warn)("Knockout groups not supported.");const ee=(0,d.getCurrentTransform)(J);if(Y.matrix&&J.transform(...Y.matrix),!Y.bbox)throw new Error("Bounding box is required.");let re=u.Util.getAxialAlignedBoundingBox(Y.bbox,(0,d.getCurrentTransform)(J));const ae=[0,0,J.canvas.width,J.canvas.height];re=u.Util.intersect(re,ae)||[0,0,0,0];const V=Math.floor(re[0]),K=Math.floor(re[1]);let te=Math.max(Math.ceil(re[2])-V,1),ie=Math.max(Math.ceil(re[3])-K,1),ce=1,me=1;te>g&&(ce=te/g,te=g),ie>g&&(me=ie/g,ie=g),this.current.startNewPathAndClipBox([0,0,te,ie]);let we="groupAt"+this.groupLevel;Y.smask&&(we+="_smask_"+this.smaskCounter++%2);const ve=this.cachedCanvases.getCanvas(we,te,ie),ge=ve.context;ge.scale(1/ce,1/me),ge.translate(-V,-K),ge.transform(...ee),Y.smask?this.smaskStack.push({canvas:ve.canvas,context:ge,offsetX:V,offsetY:K,scaleX:ce,scaleY:me,subtype:Y.smask.subtype,backdrop:Y.smask.backdrop,transferMap:Y.smask.transferMap||null,startTransformInverse:null}):(J.setTransform(1,0,0,1,0,0),J.translate(V,K),J.scale(ce,me),J.save()),E(J,ge),this.ctx=ge,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(J),this.groupLevel++}endGroup(Y){if(!this.contentVisible)return;this.groupLevel--;const J=this.ctx,ee=this.groupStack.pop();if(this.ctx=ee,this.ctx.imageSmoothingEnabled=!1,Y.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const re=(0,d.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...re);const ae=u.Util.getAxialAlignedBoundingBox([0,0,J.canvas.width,J.canvas.height],re);this.ctx.drawImage(J.canvas,0,0),this.ctx.restore(),this.compose(ae)}}beginAnnotation(Y,J,ee,re,ae){if(it(this,N,il).call(this),R(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(J)&&J.length===4){const V=J[2]-J[0],K=J[3]-J[1];if(ae&&this.annotationCanvasMap){ee=ee.slice(),ee[4]-=J[0],ee[5]-=J[1],J=J.slice(),J[0]=J[1]=0,J[2]=V,J[3]=K;const[te,ie]=u.Util.singularValueDecompose2dScale((0,d.getCurrentTransform)(this.ctx)),{viewportScale:ce}=this,me=Math.ceil(V*this.outputScaleX*ce),we=Math.ceil(K*this.outputScaleY*ce);this.annotationCanvas=this.canvasFactory.create(me,we);const{canvas:ve,context:ge}=this.annotationCanvas;this.annotationCanvasMap.set(Y,ve),this.annotationCanvas.savedCtx=this.ctx,this.ctx=ge,this.ctx.save(),this.ctx.setTransform(te,0,0,-ie,0,K*ie),R(this.ctx)}else R(this.ctx),this.ctx.rect(J[0],J[1],V,K),this.ctx.clip(),this.endPath()}this.current=new I(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...ee),this.transform(...re)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),it(this,N,ol).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(Y){if(!this.contentVisible)return;const J=Y.count;Y=this.getObject(Y.data,Y),Y.count=J;const ee=this.ctx,re=this.processingType3;if(re&&(re.compiled===void 0&&(re.compiled=_(Y)),re.compiled)){re.compiled(ee);return}const ae=this._createMaskCanvas(Y),V=ae.canvas;ee.save(),ee.setTransform(1,0,0,1,0,0),ee.drawImage(V,ae.offsetX,ae.offsetY),ee.restore(),this.compose()}paintImageMaskXObjectRepeat(Y,J,ee=0,re=0,ae,V){if(!this.contentVisible)return;Y=this.getObject(Y.data,Y);const K=this.ctx;K.save();const te=(0,d.getCurrentTransform)(K);K.transform(J,ee,re,ae,0,0);const ie=this._createMaskCanvas(Y);K.setTransform(1,0,0,1,ie.offsetX-te[4],ie.offsetY-te[5]);for(let ce=0,me=V.length;ce<me;ce+=2){const we=u.Util.transform(te,[J,ee,re,ae,V[ce],V[ce+1]]),[ve,ge]=u.Util.applyTransform([0,0],we);K.drawImage(ie.canvas,ve,ge)}K.restore(),this.compose()}paintImageMaskXObjectGroup(Y){if(!this.contentVisible)return;const J=this.ctx,ee=this.current.fillColor,re=this.current.patternFill;for(const ae of Y){const{data:V,width:K,height:te,transform:ie}=ae,ce=this.cachedCanvases.getCanvas("maskCanvas",K,te),me=ce.context;me.save();const we=this.getObject(V,ae);P(me,we),me.globalCompositeOperation="source-in",me.fillStyle=re?ee.getPattern(me,this,(0,d.getCurrentTransformInverse)(J),p.PathType.FILL):ee,me.fillRect(0,0,K,te),me.restore(),J.save(),J.transform(...ie),J.scale(1,-1),w(J,ce.canvas,0,0,K,te,0,-1,1,1),J.restore()}this.compose()}paintImageXObject(Y){if(!this.contentVisible)return;const J=this.getObject(Y);if(!J){(0,u.warn)("Dependent image isn't ready yet");return}this.paintInlineImageXObject(J)}paintImageXObjectRepeat(Y,J,ee,re){if(!this.contentVisible)return;const ae=this.getObject(Y);if(!ae){(0,u.warn)("Dependent image isn't ready yet");return}const V=ae.width,K=ae.height,te=[];for(let ie=0,ce=re.length;ie<ce;ie+=2)te.push({transform:[J,0,0,ee,re[ie],re[ie+1]],x:0,y:0,w:V,h:K});this.paintInlineImageXObjectGroup(ae,te)}applyTransferMapsToCanvas(Y){return this.current.transferMaps!=="none"&&(Y.filter=this.current.transferMaps,Y.drawImage(Y.canvas,0,0),Y.filter="none"),Y.canvas}applyTransferMapsToBitmap(Y){if(this.current.transferMaps==="none")return Y.bitmap;const{bitmap:J,width:ee,height:re}=Y,ae=this.cachedCanvases.getCanvas("inlineImage",ee,re),V=ae.context;return V.filter=this.current.transferMaps,V.drawImage(J,0,0),V.filter="none",ae.canvas}paintInlineImageXObject(Y){if(!this.contentVisible)return;const J=Y.width,ee=Y.height,re=this.ctx;if(this.save(),!u.isNodeJS){const{filter:K}=re;K!=="none"&&K!==""&&(re.filter="none")}re.scale(1/J,-1/ee);let ae;if(Y.bitmap)ae=this.applyTransferMapsToBitmap(Y);else if(typeof HTMLElement=="function"&&Y instanceof HTMLElement||!Y.data)ae=Y;else{const te=this.cachedCanvases.getCanvas("inlineImage",J,ee).context;$(te,Y),ae=this.applyTransferMapsToCanvas(te)}const V=this._scaleImage(ae,(0,d.getCurrentTransformInverse)(re));re.imageSmoothingEnabled=H((0,d.getCurrentTransform)(re),Y.interpolate),w(re,V.img,0,0,V.paintWidth,V.paintHeight,0,-ee,J,ee),this.compose(),this.restore()}paintInlineImageXObjectGroup(Y,J){if(!this.contentVisible)return;const ee=this.ctx;let re;if(Y.bitmap)re=Y.bitmap;else{const ae=Y.width,V=Y.height,te=this.cachedCanvases.getCanvas("inlineImage",ae,V).context;$(te,Y),re=this.applyTransferMapsToCanvas(te)}for(const ae of J)ee.save(),ee.transform(...ae.transform),ee.scale(1,-1),w(ee,re,ae.x,ae.y,ae.w,ae.h,0,-1,1,1),ee.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(Y){}markPointProps(Y,J){}beginMarkedContent(Y){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(Y,J){Y==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(J)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(Y){const J=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(Y);const ee=this.ctx;this.pendingClip&&(J||(this.pendingClip===F?ee.clip("evenodd"):ee.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),ee.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const Y=(0,d.getCurrentTransform)(this.ctx);if(Y[1]===0&&Y[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(Y[0]),Math.abs(Y[3]));else{const J=Math.abs(Y[0]*Y[3]-Y[2]*Y[1]),ee=Math.hypot(Y[0],Y[2]),re=Math.hypot(Y[1],Y[3]);this._cachedGetSinglePixelWidth=Math.max(ee,re)/J}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:Y}=this.current,{a:J,b:ee,c:re,d:ae}=this.ctx.getTransform();let V,K;if(ee===0&&re===0){const te=Math.abs(J),ie=Math.abs(ae);if(te===ie)if(Y===0)V=K=1/te;else{const ce=te*Y;V=K=ce<1?1/ce:1}else if(Y===0)V=1/te,K=1/ie;else{const ce=te*Y,me=ie*Y;V=ce<1?1/ce:1,K=me<1?1/me:1}}else{const te=Math.abs(J*ae-ee*re),ie=Math.hypot(J,ee),ce=Math.hypot(re,ae);if(Y===0)V=ce/te,K=ie/te;else{const me=Y*te;V=ce>me?ce/me:1,K=ie>me?ie/me:1}}this._cachedScaleForStroking[0]=V,this._cachedScaleForStroking[1]=K}return this._cachedScaleForStroking}rescaleAndStroke(Y){const{ctx:J}=this,{lineWidth:ee}=this.current,[re,ae]=this.getScaleForStroking();if(J.lineWidth=ee||1,re===1&&ae===1){J.stroke();return}const V=J.getLineDash();if(Y&&J.save(),J.scale(re,ae),V.length>0){const K=Math.max(re,ae);J.setLineDash(V.map(te=>te/K)),J.lineDashOffset/=K}J.stroke(),Y&&J.restore()}isContentVisible(){for(let Y=this.markedContentStack.length-1;Y>=0;Y--)if(!this.markedContentStack[Y].visible)return!1;return!0}};N=new WeakSet,il=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},ol=function(){if(this.pageColors){const Y=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(Y!=="none"){const J=this.ctx.filter;this.ctx.filter=Y,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=J}}};let U=Z;s.CanvasGraphics=U;for(const Q in u.OPS)U.prototype[Q]!==void 0&&(U.prototype[u.OPS[Q]]=U.prototype[Q])},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TilingPattern=s.PathType=void 0,s.getShadingPattern=m;var u=c(1),d=c(6);const p={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};s.PathType=p;function v(_,I){if(!I)return;const $=I[2]-I[0],P=I[3]-I[1],E=new Path2D;E.rect(I[0],I[1],$,P),_.clip(E)}class A{constructor(){this.constructor===A&&(0,u.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,u.unreachable)("Abstract method `getPattern` called.")}}class b extends A{constructor(I){super(),this._type=I[1],this._bbox=I[2],this._colorStops=I[3],this._p0=I[4],this._p1=I[5],this._r0=I[6],this._r1=I[7],this.matrix=null}_createGradient(I){let $;this._type==="axial"?$=I.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&($=I.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const P of this._colorStops)$.addColorStop(P[0],P[1]);return $}getPattern(I,$,P,E){let R;if(E===p.STROKE||E===p.FILL){const T=$.current.getClippedPathBoundingBox(E,(0,d.getCurrentTransform)(I))||[0,0,0,0],B=Math.ceil(T[2]-T[0])||1,M=Math.ceil(T[3]-T[1])||1,k=$.cachedCanvases.getCanvas("pattern",B,M,!0),O=k.context;O.clearRect(0,0,O.canvas.width,O.canvas.height),O.beginPath(),O.rect(0,0,O.canvas.width,O.canvas.height),O.translate(-T[0],-T[1]),P=u.Util.transform(P,[1,0,0,1,T[0],T[1]]),O.transform(...$.baseTransform),this.matrix&&O.transform(...this.matrix),v(O,this._bbox),O.fillStyle=this._createGradient(O),O.fill(),R=I.createPattern(k.canvas,"no-repeat");const H=new DOMMatrix(P);R.setTransform(H)}else v(I,this._bbox),R=this._createGradient(I);return R}}function g(_,I,$,P,E,R,T,B){const M=I.coords,k=I.colors,O=_.data,H=_.width*4;let j;M[$+1]>M[P+1]&&(j=$,$=P,P=j,j=R,R=T,T=j),M[P+1]>M[E+1]&&(j=P,P=E,E=j,j=T,T=B,B=j),M[$+1]>M[P+1]&&(j=$,$=P,P=j,j=R,R=T,T=j);const q=(M[$]+I.offsetX)*I.scaleX,L=(M[$+1]+I.offsetY)*I.scaleY,F=(M[P]+I.offsetX)*I.scaleX,U=(M[P+1]+I.offsetY)*I.scaleY,N=(M[E]+I.offsetX)*I.scaleX,D=(M[E+1]+I.offsetY)*I.scaleY;if(L>=D)return;const W=k[R],Z=k[R+1],Q=k[R+2],Y=k[T],J=k[T+1],ee=k[T+2],re=k[B],ae=k[B+1],V=k[B+2],K=Math.round(L),te=Math.round(D);let ie,ce,me,we,ve,ge,ue,se;for(let oe=K;oe<=te;oe++){if(oe<U){const $e=oe<L?0:(L-oe)/(L-U);ie=q-(q-F)*$e,ce=W-(W-Y)*$e,me=Z-(Z-J)*$e,we=Q-(Q-ee)*$e}else{let $e;oe>D?$e=1:U===D?$e=0:$e=(U-oe)/(U-D),ie=F-(F-N)*$e,ce=Y-(Y-re)*$e,me=J-(J-ae)*$e,we=ee-(ee-V)*$e}let de;oe<L?de=0:oe>D?de=1:de=(L-oe)/(L-D),ve=q-(q-N)*de,ge=W-(W-re)*de,ue=Z-(Z-ae)*de,se=Q-(Q-V)*de;const le=Math.round(Math.min(ie,ve)),xe=Math.round(Math.max(ie,ve));let Ce=H*oe+le*4;for(let $e=le;$e<=xe;$e++)de=(ie-$e)/(ie-ve),de<0?de=0:de>1&&(de=1),O[Ce++]=ce-(ce-ge)*de|0,O[Ce++]=me-(me-ue)*de|0,O[Ce++]=we-(we-se)*de|0,O[Ce++]=255}}function x(_,I,$){const P=I.coords,E=I.colors;let R,T;switch(I.type){case"lattice":const B=I.verticesPerRow,M=Math.floor(P.length/B)-1,k=B-1;for(R=0;R<M;R++){let O=R*B;for(let H=0;H<k;H++,O++)g(_,$,P[O],P[O+1],P[O+B],E[O],E[O+1],E[O+B]),g(_,$,P[O+B+1],P[O+1],P[O+B],E[O+B+1],E[O+1],E[O+B])}break;case"triangles":for(R=0,T=P.length;R<T;R+=3)g(_,$,P[R],P[R+1],P[R+2],E[R],E[R+1],E[R+2]);break;default:throw new Error("illegal figure")}}class y extends A{constructor(I){super(),this._coords=I[2],this._colors=I[3],this._figures=I[4],this._bounds=I[5],this._bbox=I[7],this._background=I[8],this.matrix=null}_createMeshCanvas(I,$,P){const B=Math.floor(this._bounds[0]),M=Math.floor(this._bounds[1]),k=Math.ceil(this._bounds[2])-B,O=Math.ceil(this._bounds[3])-M,H=Math.min(Math.ceil(Math.abs(k*I[0]*1.1)),3e3),j=Math.min(Math.ceil(Math.abs(O*I[1]*1.1)),3e3),q=k/H,L=O/j,F={coords:this._coords,colors:this._colors,offsetX:-B,offsetY:-M,scaleX:1/q,scaleY:1/L},U=H+2*2,N=j+2*2,D=P.getCanvas("mesh",U,N,!1),W=D.context,Z=W.createImageData(H,j);if($){const Y=Z.data;for(let J=0,ee=Y.length;J<ee;J+=4)Y[J]=$[0],Y[J+1]=$[1],Y[J+2]=$[2],Y[J+3]=255}for(const Y of this._figures)x(Z,Y,F);return W.putImageData(Z,2,2),{canvas:D.canvas,offsetX:B-2*q,offsetY:M-2*L,scaleX:q,scaleY:L}}getPattern(I,$,P,E){v(I,this._bbox);let R;if(E===p.SHADING)R=u.Util.singularValueDecompose2dScale((0,d.getCurrentTransform)(I));else if(R=u.Util.singularValueDecompose2dScale($.baseTransform),this.matrix){const B=u.Util.singularValueDecompose2dScale(this.matrix);R=[R[0]*B[0],R[1]*B[1]]}const T=this._createMeshCanvas(R,E===p.SHADING?null:this._background,$.cachedCanvases);return E!==p.SHADING&&(I.setTransform(...$.baseTransform),this.matrix&&I.transform(...this.matrix)),I.translate(T.offsetX,T.offsetY),I.scale(T.scaleX,T.scaleY),I.createPattern(T.canvas,"no-repeat")}}class f extends A{getPattern(){return"hotpink"}}function m(_){switch(_[0]){case"RadialAxial":return new b(_);case"Mesh":return new y(_);case"Dummy":return new f}throw new Error(`Unknown IR type: ${_[0]}`)}const C={COLORED:1,UNCOLORED:2},w=class w{constructor(I,$,P,E,R){this.operatorList=I[2],this.matrix=I[3]||[1,0,0,1,0,0],this.bbox=I[4],this.xstep=I[5],this.ystep=I[6],this.paintType=I[7],this.tilingType=I[8],this.color=$,this.ctx=P,this.canvasGraphicsFactory=E,this.baseTransform=R}createPatternCanvas(I){const $=this.operatorList,P=this.bbox,E=this.xstep,R=this.ystep,T=this.paintType,B=this.tilingType,M=this.color,k=this.canvasGraphicsFactory;(0,u.info)("TilingType: "+B);const O=P[0],H=P[1],j=P[2],q=P[3],L=u.Util.singularValueDecompose2dScale(this.matrix),F=u.Util.singularValueDecompose2dScale(this.baseTransform),U=[L[0]*F[0],L[1]*F[1]],N=this.getSizeAndScale(E,this.ctx.canvas.width,U[0]),D=this.getSizeAndScale(R,this.ctx.canvas.height,U[1]),W=I.cachedCanvases.getCanvas("pattern",N.size,D.size,!0),Z=W.context,Q=k.createCanvasGraphics(Z);Q.groupLevel=I.groupLevel,this.setFillAndStrokeStyleToContext(Q,T,M);let Y=O,J=H,ee=j,re=q;return O<0&&(Y=0,ee+=Math.abs(O)),H<0&&(J=0,re+=Math.abs(H)),Z.translate(-(N.scale*Y),-(D.scale*J)),Q.transform(N.scale,0,0,D.scale,0,0),Z.save(),this.clipBbox(Q,Y,J,ee,re),Q.baseTransform=(0,d.getCurrentTransform)(Q.ctx),Q.executeOperatorList($),Q.endDrawing(),{canvas:W.canvas,scaleX:N.scale,scaleY:D.scale,offsetX:Y,offsetY:J}}getSizeAndScale(I,$,P){I=Math.abs(I);const E=Math.max(w.MAX_PATTERN_SIZE,$);let R=Math.ceil(I*P);return R>=E?R=E:P=R/I,{scale:P,size:R}}clipBbox(I,$,P,E,R){const T=E-$,B=R-P;I.ctx.rect($,P,T,B),I.current.updateRectMinMax((0,d.getCurrentTransform)(I.ctx),[$,P,E,R]),I.clip(),I.endPath()}setFillAndStrokeStyleToContext(I,$,P){const E=I.ctx,R=I.current;switch($){case C.COLORED:const T=this.ctx;E.fillStyle=T.fillStyle,E.strokeStyle=T.strokeStyle,R.fillColor=T.fillStyle,R.strokeColor=T.strokeStyle;break;case C.UNCOLORED:const B=u.Util.makeHexColor(P[0],P[1],P[2]);E.fillStyle=B,E.strokeStyle=B,R.fillColor=B,R.strokeColor=B;break;default:throw new u.FormatError(`Unsupported paint type: ${$}`)}}getPattern(I,$,P,E){let R=P;E!==p.SHADING&&(R=u.Util.transform(R,$.baseTransform),this.matrix&&(R=u.Util.transform(R,this.matrix)));const T=this.createPatternCanvas($);let B=new DOMMatrix(R);B=B.translate(T.offsetX,T.offsetY),B=B.scale(1/T.scaleX,1/T.scaleY);const M=I.createPattern(T.canvas,"repeat");return M.setTransform(B),M}};yr(w,"MAX_PATTERN_SIZE",3e3);let S=w;s.TilingPattern=S},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.convertBlackAndWhiteToRGBA=p,s.convertToRGBA=d,s.grayToRGBA=A;var u=c(1);function d(b){switch(b.kind){case u.ImageKind.GRAYSCALE_1BPP:return p(b);case u.ImageKind.RGB_24BPP:return v(b)}return null}function p({src:b,srcPos:g=0,dest:x,width:y,height:f,nonBlackColor:m=4294967295,inverseDecode:C=!1}){const S=u.FeatureTest.isLittleEndian?4278190080:255,[w,_]=C?[m,S]:[S,m],I=y>>3,$=y&7,P=b.length;x=new Uint32Array(x.buffer);let E=0;for(let R=0;R<f;R++){for(const B=g+I;g<B;g++){const M=g<P?b[g]:255;x[E++]=M&128?_:w,x[E++]=M&64?_:w,x[E++]=M&32?_:w,x[E++]=M&16?_:w,x[E++]=M&8?_:w,x[E++]=M&4?_:w,x[E++]=M&2?_:w,x[E++]=M&1?_:w}if($===0)continue;const T=g<P?b[g++]:255;for(let B=0;B<$;B++)x[E++]=T&1<<7-B?_:w}return{srcPos:g,destPos:E}}function v({src:b,srcPos:g=0,dest:x,destPos:y=0,width:f,height:m}){let C=0;const S=b.length>>2,w=new Uint32Array(b.buffer,g,S);if(u.FeatureTest.isLittleEndian){for(;C<S-2;C+=3,y+=4){const _=w[C],I=w[C+1],$=w[C+2];x[y]=_|4278190080,x[y+1]=_>>>24|I<<8|4278190080,x[y+2]=I>>>16|$<<16|4278190080,x[y+3]=$>>>8|4278190080}for(let _=C*4,I=b.length;_<I;_+=3)x[y++]=b[_]|b[_+1]<<8|b[_+2]<<16|4278190080}else{for(;C<S-2;C+=3,y+=4){const _=w[C],I=w[C+1],$=w[C+2];x[y]=_|255,x[y+1]=_<<24|I>>>8|255,x[y+2]=I<<16|$>>>16|255,x[y+3]=$<<8|255}for(let _=C*4,I=b.length;_<I;_+=3)x[y++]=b[_]<<24|b[_+1]<<16|b[_+2]<<8|255}return{srcPos:g,destPos:y}}function A(b,g){if(u.FeatureTest.isLittleEndian)for(let x=0,y=b.length;x<y;x++)g[x]=b[x]*65793|4278190080;else for(let x=0,y=b.length;x<y;x++)g[x]=b[x]*16843008|255}},(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.GlobalWorkerOptions=void 0;const c=Object.create(null);s.GlobalWorkerOptions=c,c.workerPort=null,c.workerSrc=""},(a,s,c)=>{var b,Ou,Du,bo;Object.defineProperty(s,"__esModule",{value:!0}),s.MessageHandler=void 0;var u=c(1);const d={DATA:1,ERROR:2},p={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function v(f){switch(f instanceof Error||typeof f=="object"&&f!==null||(0,u.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),f.name){case"AbortException":return new u.AbortException(f.message);case"MissingPDFException":return new u.MissingPDFException(f.message);case"PasswordException":return new u.PasswordException(f.message,f.code);case"UnexpectedResponseException":return new u.UnexpectedResponseException(f.message,f.status);case"UnknownErrorException":return new u.UnknownErrorException(f.message,f.details);default:return new u.UnknownErrorException(f.message,f.toString())}}class A{constructor(m,C,S){bt(this,b);this.sourceName=m,this.targetName=C,this.comObj=S,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),this._onComObjOnMessage=w=>{const _=w.data;if(_.targetName!==this.sourceName)return;if(_.stream){it(this,b,Du).call(this,_);return}if(_.callback){const $=_.callbackId,P=this.callbackCapabilities[$];if(!P)throw new Error(`Cannot resolve callback ${$}`);if(delete this.callbackCapabilities[$],_.callback===d.DATA)P.resolve(_.data);else if(_.callback===d.ERROR)P.reject(v(_.reason));else throw new Error("Unexpected callback case");return}const I=this.actionHandler[_.action];if(!I)throw new Error(`Unknown action from worker: ${_.action}`);if(_.callbackId){const $=this.sourceName,P=_.sourceName;new Promise(function(E){E(I(_.data))}).then(function(E){S.postMessage({sourceName:$,targetName:P,callback:d.DATA,callbackId:_.callbackId,data:E})},function(E){S.postMessage({sourceName:$,targetName:P,callback:d.ERROR,callbackId:_.callbackId,reason:v(E)})});return}if(_.streamId){it(this,b,Ou).call(this,_);return}I(_.data)},S.addEventListener("message",this._onComObjOnMessage)}on(m,C){const S=this.actionHandler;if(S[m])throw new Error(`There is already an actionName called "${m}"`);S[m]=C}send(m,C,S){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:m,data:C},S)}sendWithPromise(m,C,S){const w=this.callbackId++,_=new u.PromiseCapability;this.callbackCapabilities[w]=_;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:m,callbackId:w,data:C},S)}catch(I){_.reject(I)}return _.promise}sendWithStream(m,C,S,w){const _=this.streamId++,I=this.sourceName,$=this.targetName,P=this.comObj;return new ReadableStream({start:E=>{const R=new u.PromiseCapability;return this.streamControllers[_]={controller:E,startCall:R,pullCall:null,cancelCall:null,isClosed:!1},P.postMessage({sourceName:I,targetName:$,action:m,streamId:_,data:C,desiredSize:E.desiredSize},w),R.promise},pull:E=>{const R=new u.PromiseCapability;return this.streamControllers[_].pullCall=R,P.postMessage({sourceName:I,targetName:$,stream:p.PULL,streamId:_,desiredSize:E.desiredSize}),R.promise},cancel:E=>{(0,u.assert)(E instanceof Error,"cancel must have a valid reason");const R=new u.PromiseCapability;return this.streamControllers[_].cancelCall=R,this.streamControllers[_].isClosed=!0,P.postMessage({sourceName:I,targetName:$,stream:p.CANCEL,streamId:_,reason:v(E)}),R.promise}},S)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}b=new WeakSet,Ou=function(m){const C=m.streamId,S=this.sourceName,w=m.sourceName,_=this.comObj,I=this,$=this.actionHandler[m.action],P={enqueue(E,R=1,T){if(this.isCancelled)return;const B=this.desiredSize;this.desiredSize-=R,B>0&&this.desiredSize<=0&&(this.sinkCapability=new u.PromiseCapability,this.ready=this.sinkCapability.promise),_.postMessage({sourceName:S,targetName:w,stream:p.ENQUEUE,streamId:C,chunk:E},T)},close(){this.isCancelled||(this.isCancelled=!0,_.postMessage({sourceName:S,targetName:w,stream:p.CLOSE,streamId:C}),delete I.streamSinks[C])},error(E){(0,u.assert)(E instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,_.postMessage({sourceName:S,targetName:w,stream:p.ERROR,streamId:C,reason:v(E)}))},sinkCapability:new u.PromiseCapability,onPull:null,onCancel:null,isCancelled:!1,desiredSize:m.desiredSize,ready:null};P.sinkCapability.resolve(),P.ready=P.sinkCapability.promise,this.streamSinks[C]=P,new Promise(function(E){E($(m.data,P))}).then(function(){_.postMessage({sourceName:S,targetName:w,stream:p.START_COMPLETE,streamId:C,success:!0})},function(E){_.postMessage({sourceName:S,targetName:w,stream:p.START_COMPLETE,streamId:C,reason:v(E)})})},Du=function(m){const C=m.streamId,S=this.sourceName,w=m.sourceName,_=this.comObj,I=this.streamControllers[C],$=this.streamSinks[C];switch(m.stream){case p.START_COMPLETE:m.success?I.startCall.resolve():I.startCall.reject(v(m.reason));break;case p.PULL_COMPLETE:m.success?I.pullCall.resolve():I.pullCall.reject(v(m.reason));break;case p.PULL:if(!$){_.postMessage({sourceName:S,targetName:w,stream:p.PULL_COMPLETE,streamId:C,success:!0});break}$.desiredSize<=0&&m.desiredSize>0&&$.sinkCapability.resolve(),$.desiredSize=m.desiredSize,new Promise(function(P){var E;P((E=$.onPull)==null?void 0:E.call($))}).then(function(){_.postMessage({sourceName:S,targetName:w,stream:p.PULL_COMPLETE,streamId:C,success:!0})},function(P){_.postMessage({sourceName:S,targetName:w,stream:p.PULL_COMPLETE,streamId:C,reason:v(P)})});break;case p.ENQUEUE:if((0,u.assert)(I,"enqueue should have stream controller"),I.isClosed)break;I.controller.enqueue(m.chunk);break;case p.CLOSE:if((0,u.assert)(I,"close should have stream controller"),I.isClosed)break;I.isClosed=!0,I.controller.close(),it(this,b,bo).call(this,I,C);break;case p.ERROR:(0,u.assert)(I,"error should have stream controller"),I.controller.error(v(m.reason)),it(this,b,bo).call(this,I,C);break;case p.CANCEL_COMPLETE:m.success?I.cancelCall.resolve():I.cancelCall.reject(v(m.reason)),it(this,b,bo).call(this,I,C);break;case p.CANCEL:if(!$)break;new Promise(function(P){var E;P((E=$.onCancel)==null?void 0:E.call($,v(m.reason)))}).then(function(){_.postMessage({sourceName:S,targetName:w,stream:p.CANCEL_COMPLETE,streamId:C,success:!0})},function(P){_.postMessage({sourceName:S,targetName:w,stream:p.CANCEL_COMPLETE,streamId:C,reason:v(P)})}),$.sinkCapability.reject(v(m.reason)),$.isCancelled=!0,delete this.streamSinks[C];break;default:throw new Error("Unexpected stream case")}},bo=async function(m,C){var S,w,_;await Promise.allSettled([(S=m.startCall)==null?void 0:S.promise,(w=m.pullCall)==null?void 0:w.promise,(_=m.cancelCall)==null?void 0:_.promise]),delete this.streamControllers[C]},s.MessageHandler=A},(a,s,c)=>{var p,v;Object.defineProperty(s,"__esModule",{value:!0}),s.Metadata=void 0;var u=c(1);class d{constructor({parsedData:b,rawData:g}){bt(this,p);bt(this,v);Ct(this,p,b),Ct(this,v,g)}getRaw(){return He(this,v)}get(b){return He(this,p).get(b)??null}getAll(){return(0,u.objectFromMap)(He(this,p))}has(b){return He(this,p).has(b)}}p=new WeakMap,v=new WeakMap,s.Metadata=d},(a,s,c)=>{var b,g,x,y,f,m,sl;Object.defineProperty(s,"__esModule",{value:!0}),s.OptionalContentConfig=void 0;var u=c(1),d=c(8);const p=Symbol("INTERNAL");class v{constructor(w,_){bt(this,b,!0);this.name=w,this.intent=_}get visible(){return He(this,b)}_setVisible(w,_){w!==p&&(0,u.unreachable)("Internal method `_setVisible` called."),Ct(this,b,_)}}b=new WeakMap;class A{constructor(w){bt(this,m);bt(this,g,null);bt(this,x,new Map);bt(this,y,null);bt(this,f,null);if(this.name=null,this.creator=null,w!==null){this.name=w.name,this.creator=w.creator,Ct(this,f,w.order);for(const _ of w.groups)He(this,x).set(_.id,new v(_.name,_.intent));if(w.baseState==="OFF")for(const _ of He(this,x).values())_._setVisible(p,!1);for(const _ of w.on)He(this,x).get(_)._setVisible(p,!0);for(const _ of w.off)He(this,x).get(_)._setVisible(p,!1);Ct(this,y,this.getHash())}}isVisible(w){if(He(this,x).size===0)return!0;if(!w)return(0,u.warn)("Optional content group not defined."),!0;if(w.type==="OCG")return He(this,x).has(w.id)?He(this,x).get(w.id).visible:((0,u.warn)(`Optional content group not found: ${w.id}`),!0);if(w.type==="OCMD"){if(w.expression)return it(this,m,sl).call(this,w.expression);if(!w.policy||w.policy==="AnyOn"){for(const _ of w.ids){if(!He(this,x).has(_))return(0,u.warn)(`Optional content group not found: ${_}`),!0;if(He(this,x).get(_).visible)return!0}return!1}else if(w.policy==="AllOn"){for(const _ of w.ids){if(!He(this,x).has(_))return(0,u.warn)(`Optional content group not found: ${_}`),!0;if(!He(this,x).get(_).visible)return!1}return!0}else if(w.policy==="AnyOff"){for(const _ of w.ids){if(!He(this,x).has(_))return(0,u.warn)(`Optional content group not found: ${_}`),!0;if(!He(this,x).get(_).visible)return!0}return!1}else if(w.policy==="AllOff"){for(const _ of w.ids){if(!He(this,x).has(_))return(0,u.warn)(`Optional content group not found: ${_}`),!0;if(He(this,x).get(_).visible)return!1}return!0}return(0,u.warn)(`Unknown optional content policy ${w.policy}.`),!0}return(0,u.warn)(`Unknown group type ${w.type}.`),!0}setVisibility(w,_=!0){if(!He(this,x).has(w)){(0,u.warn)(`Optional content group not found: ${w}`);return}He(this,x).get(w)._setVisible(p,!!_),Ct(this,g,null)}get hasInitialVisibility(){return He(this,y)===null||this.getHash()===He(this,y)}getOrder(){return He(this,x).size?He(this,f)?He(this,f).slice():[...He(this,x).keys()]:null}getGroups(){return He(this,x).size>0?(0,u.objectFromMap)(He(this,x)):null}getGroup(w){return He(this,x).get(w)||null}getHash(){if(He(this,g)!==null)return He(this,g);const w=new d.MurmurHash3_64;for(const[_,I]of He(this,x))w.update(`${_}:${I.visible}`);return Ct(this,g,w.hexdigest())}}g=new WeakMap,x=new WeakMap,y=new WeakMap,f=new WeakMap,m=new WeakSet,sl=function(w){const _=w.length;if(_<2)return!0;const I=w[0];for(let $=1;$<_;$++){const P=w[$];let E;if(Array.isArray(P))E=it(this,m,sl).call(this,P);else if(He(this,x).has(P))E=He(this,x).get(P).visible;else return(0,u.warn)(`Optional content group not found: ${P}`),!0;switch(I){case"And":if(!E)return!1;break;case"Or":if(E)return!0;break;case"Not":return!E;default:return!0}}return I==="And"},s.OptionalContentConfig=A},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.PDFDataTransportStream=void 0;var u=c(1),d=c(6);class p{constructor({length:g,initialData:x,progressiveDone:y=!1,contentDispositionFilename:f=null,disableRange:m=!1,disableStream:C=!1},S){if((0,u.assert)(S,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=y,this._contentDispositionFilename=f,(x==null?void 0:x.length)>0){const w=x instanceof Uint8Array&&x.byteLength===x.buffer.byteLength?x.buffer:new Uint8Array(x).buffer;this._queuedChunks.push(w)}this._pdfDataRangeTransport=S,this._isStreamingSupported=!C,this._isRangeSupported=!m,this._contentLength=g,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener((w,_)=>{this._onReceiveData({begin:w,chunk:_})}),this._pdfDataRangeTransport.addProgressListener((w,_)=>{this._onProgress({loaded:w,total:_})}),this._pdfDataRangeTransport.addProgressiveReadListener(w=>{this._onReceiveData({chunk:w})}),this._pdfDataRangeTransport.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),this._pdfDataRangeTransport.transportReady()}_onReceiveData({begin:g,chunk:x}){const y=x instanceof Uint8Array&&x.byteLength===x.buffer.byteLength?x.buffer:new Uint8Array(x).buffer;if(g===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(y):this._queuedChunks.push(y);else{const f=this._rangeReaders.some(function(m){return m._begin!==g?!1:(m._enqueue(y),!0)});(0,u.assert)(f,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var g;return((g=this._fullRequestReader)==null?void 0:g._loaded)??0}_onProgress(g){var x,y,f,m;g.total===void 0?(y=(x=this._rangeReaders[0])==null?void 0:x.onProgress)==null||y.call(x,{loaded:g.loaded}):(m=(f=this._fullRequestReader)==null?void 0:f.onProgress)==null||m.call(f,{loaded:g.loaded,total:g.total})}_onProgressiveDone(){var g;(g=this._fullRequestReader)==null||g.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(g){const x=this._rangeReaders.indexOf(g);x>=0&&this._rangeReaders.splice(x,1)}getFullReader(){(0,u.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const g=this._queuedChunks;return this._queuedChunks=null,new v(this,g,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(g,x){if(x<=this._progressiveDataLength)return null;const y=new A(this,g,x);return this._pdfDataRangeTransport.requestDataRange(g,x),this._rangeReaders.push(y),y}cancelAllRequests(g){var x;(x=this._fullRequestReader)==null||x.cancel(g);for(const y of this._rangeReaders.slice(0))y.cancel(g);this._pdfDataRangeTransport.abort()}}s.PDFDataTransportStream=p;class v{constructor(g,x,y=!1,f=null){this._stream=g,this._done=y||!1,this._filename=(0,d.isPdfFile)(f)?f:null,this._queuedChunks=x||[],this._loaded=0;for(const m of this._queuedChunks)this._loaded+=m.byteLength;this._requests=[],this._headersReady=Promise.resolve(),g._fullRequestReader=this,this.onProgress=null}_enqueue(g){this._done||(this._requests.length>0?this._requests.shift().resolve({value:g,done:!1}):this._queuedChunks.push(g),this._loaded+=g.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const g=new u.PromiseCapability;return this._requests.push(g),g.promise}cancel(g){this._done=!0;for(const x of this._requests)x.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class A{constructor(g,x,y){this._stream=g,this._begin=x,this._end=y,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(g){if(!this._done){if(this._requests.length===0)this._queuedChunk=g;else{this._requests.shift().resolve({value:g,done:!1});for(const y of this._requests)y.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const x=this._queuedChunk;return this._queuedChunk=null,{value:x,done:!1}}if(this._done)return{value:void 0,done:!0};const g=new u.PromiseCapability;return this._requests.push(g),g.promise}cancel(g){this._done=!0;for(const x of this._requests)x.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.PDFFetchStream=void 0;var u=c(1),d=c(20);function p(y,f,m){return{method:"GET",headers:y,signal:m.signal,mode:"cors",credentials:f?"include":"same-origin",redirect:"follow"}}function v(y){const f=new Headers;for(const m in y){const C=y[m];C!==void 0&&f.append(m,C)}return f}function A(y){return y instanceof Uint8Array?y.buffer:y instanceof ArrayBuffer?y:((0,u.warn)(`getArrayBuffer - unexpected data format: ${y}`),new Uint8Array(y).buffer)}class b{constructor(f){this.source=f,this.isHttp=/^https?:/i.test(f.url),this.httpHeaders=this.isHttp&&f.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var f;return((f=this._fullRequestReader)==null?void 0:f._loaded)??0}getFullReader(){return(0,u.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new g(this),this._fullRequestReader}getRangeReader(f,m){if(m<=this._progressiveDataLength)return null;const C=new x(this,f,m);return this._rangeRequestReaders.push(C),C}cancelAllRequests(f){var m;(m=this._fullRequestReader)==null||m.cancel(f);for(const C of this._rangeRequestReaders.slice(0))C.cancel(f)}}s.PDFFetchStream=b;class g{constructor(f){this._stream=f,this._reader=null,this._loaded=0,this._filename=null;const m=f.source;this._withCredentials=m.withCredentials||!1,this._contentLength=m.length,this._headersCapability=new u.PromiseCapability,this._disableRange=m.disableRange||!1,this._rangeChunkSize=m.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!m.disableStream,this._isRangeSupported=!m.disableRange,this._headers=v(this._stream.httpHeaders);const C=m.url;fetch(C,p(this._headers,this._withCredentials,this._abortController)).then(S=>{if(!(0,d.validateResponseStatus)(S.status))throw(0,d.createResponseStatusError)(S.status,C);this._reader=S.body.getReader(),this._headersCapability.resolve();const w=$=>S.headers.get($),{allowRangeRequests:_,suggestedLength:I}=(0,d.validateRangeRequestCapabilities)({getResponseHeader:w,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=_,this._contentLength=I||this._contentLength,this._filename=(0,d.extractFilenameFromHeader)(w),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new u.AbortException("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var C;await this._headersCapability.promise;const{value:f,done:m}=await this._reader.read();return m?{value:f,done:m}:(this._loaded+=f.byteLength,(C=this.onProgress)==null||C.call(this,{loaded:this._loaded,total:this._contentLength}),{value:A(f),done:!1})}cancel(f){var m;(m=this._reader)==null||m.cancel(f),this._abortController.abort()}}class x{constructor(f,m,C){this._stream=f,this._reader=null,this._loaded=0;const S=f.source;this._withCredentials=S.withCredentials||!1,this._readCapability=new u.PromiseCapability,this._isStreamingSupported=!S.disableStream,this._abortController=new AbortController,this._headers=v(this._stream.httpHeaders),this._headers.append("Range",`bytes=${m}-${C-1}`);const w=S.url;fetch(w,p(this._headers,this._withCredentials,this._abortController)).then(_=>{if(!(0,d.validateResponseStatus)(_.status))throw(0,d.createResponseStatusError)(_.status,w);this._readCapability.resolve(),this._reader=_.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var C;await this._readCapability.promise;const{value:f,done:m}=await this._reader.read();return m?{value:f,done:m}:(this._loaded+=f.byteLength,(C=this.onProgress)==null||C.call(this,{loaded:this._loaded}),{value:A(f),done:!1})}cancel(f){var m;(m=this._reader)==null||m.cancel(f),this._abortController.abort()}}},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.createResponseStatusError=b,s.extractFilenameFromHeader=A,s.validateRangeRequestCapabilities=v,s.validateResponseStatus=g;var u=c(1),d=c(21),p=c(6);function v({getResponseHeader:x,isHttp:y,rangeChunkSize:f,disableRange:m}){const C={allowRangeRequests:!1,suggestedLength:void 0},S=parseInt(x("Content-Length"),10);return!Number.isInteger(S)||(C.suggestedLength=S,S<=2*f)||m||!y||x("Accept-Ranges")!=="bytes"||(x("Content-Encoding")||"identity")!=="identity"||(C.allowRangeRequests=!0),C}function A(x){const y=x("Content-Disposition");if(y){let f=(0,d.getFilenameFromContentDispositionHeader)(y);if(f.includes("%"))try{f=decodeURIComponent(f)}catch{}if((0,p.isPdfFile)(f))return f}return null}function b(x,y){return x===404||x===0&&y.startsWith("file:")?new u.MissingPDFException('Missing PDF "'+y+'".'):new u.UnexpectedResponseException(`Unexpected server response (${x}) while retrieving PDF "${y}".`,x)}function g(x){return x===200||x===206}},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.getFilenameFromContentDispositionHeader=d;var u=c(1);function d(p){let v=!0,A=b("filename\\*","i").exec(p);if(A){A=A[1];let S=f(A);return S=unescape(S),S=m(S),S=C(S),x(S)}if(A=y(p),A){const S=C(A);return x(S)}if(A=b("filename","i").exec(p),A){A=A[1];let S=f(A);return S=C(S),x(S)}function b(S,w){return new RegExp("(?:^|;)\\s*"+S+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',w)}function g(S,w){if(S){if(!/^[\x00-\xFF]+$/.test(w))return w;try{const _=new TextDecoder(S,{fatal:!0}),I=(0,u.stringToBytes)(w);w=_.decode(I),v=!1}catch{}}return w}function x(S){return v&&/[\x80-\xff]/.test(S)&&(S=g("utf-8",S),v&&(S=g("iso-8859-1",S))),S}function y(S){const w=[];let _;const I=b("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(_=I.exec(S))!==null;){let[,P,E,R]=_;if(P=parseInt(P,10),P in w){if(P===0)break;continue}w[P]=[E,R]}const $=[];for(let P=0;P<w.length&&P in w;++P){let[E,R]=w[P];R=f(R),E&&(R=unescape(R),P===0&&(R=m(R))),$.push(R)}return $.join("")}function f(S){if(S.startsWith('"')){const w=S.slice(1).split('\\"');for(let _=0;_<w.length;++_){const I=w[_].indexOf('"');I!==-1&&(w[_]=w[_].slice(0,I),w.length=_+1),w[_]=w[_].replaceAll(/\\(.)/g,"$1")}S=w.join('"')}return S}function m(S){const w=S.indexOf("'");if(w===-1)return S;const _=S.slice(0,w),$=S.slice(w+1).replace(/^[^']*'/,"");return g(_,$)}function C(S){return!S.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(S)?S:S.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(w,_,I,$){if(I==="q"||I==="Q")return $=$.replaceAll("_"," "),$=$.replaceAll(/=([0-9a-fA-F]{2})/g,function(P,E){return String.fromCharCode(parseInt(E,16))}),g(_,$);try{$=atob($)}catch{}return g(_,$)})}return""}},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.PDFNetworkStream=void 0;var u=c(1),d=c(20);const p=200,v=206;function A(f){const m=f.response;return typeof m!="string"?m:(0,u.stringToBytes)(m).buffer}class b{constructor(m,C={}){this.url=m,this.isHttp=/^https?:/i.test(m),this.httpHeaders=this.isHttp&&C.httpHeaders||Object.create(null),this.withCredentials=C.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(m,C,S){const w={begin:m,end:C};for(const _ in S)w[_]=S[_];return this.request(w)}requestFull(m){return this.request(m)}request(m){const C=new XMLHttpRequest,S=this.currXhrId++,w=this.pendingRequests[S]={xhr:C};C.open("GET",this.url),C.withCredentials=this.withCredentials;for(const _ in this.httpHeaders){const I=this.httpHeaders[_];I!==void 0&&C.setRequestHeader(_,I)}return this.isHttp&&"begin"in m&&"end"in m?(C.setRequestHeader("Range",`bytes=${m.begin}-${m.end-1}`),w.expectedStatus=v):w.expectedStatus=p,C.responseType="arraybuffer",m.onError&&(C.onerror=function(_){m.onError(C.status)}),C.onreadystatechange=this.onStateChange.bind(this,S),C.onprogress=this.onProgress.bind(this,S),w.onHeadersReceived=m.onHeadersReceived,w.onDone=m.onDone,w.onError=m.onError,w.onProgress=m.onProgress,C.send(null),S}onProgress(m,C){var w;const S=this.pendingRequests[m];S&&((w=S.onProgress)==null||w.call(S,C))}onStateChange(m,C){var P,E,R;const S=this.pendingRequests[m];if(!S)return;const w=S.xhr;if(w.readyState>=2&&S.onHeadersReceived&&(S.onHeadersReceived(),delete S.onHeadersReceived),w.readyState!==4||!(m in this.pendingRequests))return;if(delete this.pendingRequests[m],w.status===0&&this.isHttp){(P=S.onError)==null||P.call(S,w.status);return}const _=w.status||p;if(!(_===p&&S.expectedStatus===v)&&_!==S.expectedStatus){(E=S.onError)==null||E.call(S,w.status);return}const $=A(w);if(_===v){const T=w.getResponseHeader("Content-Range"),B=/bytes (\d+)-(\d+)\/(\d+)/.exec(T);S.onDone({begin:parseInt(B[1],10),chunk:$})}else $?S.onDone({begin:0,chunk:$}):(R=S.onError)==null||R.call(S,w.status)}getRequestXhr(m){return this.pendingRequests[m].xhr}isPendingRequest(m){return m in this.pendingRequests}abortRequest(m){const C=this.pendingRequests[m].xhr;delete this.pendingRequests[m],C.abort()}}class g{constructor(m){this._source=m,this._manager=new b(m.url,{httpHeaders:m.httpHeaders,withCredentials:m.withCredentials}),this._rangeChunkSize=m.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(m){const C=this._rangeRequestReaders.indexOf(m);C>=0&&this._rangeRequestReaders.splice(C,1)}getFullReader(){return(0,u.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new x(this._manager,this._source),this._fullRequestReader}getRangeReader(m,C){const S=new y(this._manager,m,C);return S.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(S),S}cancelAllRequests(m){var C;(C=this._fullRequestReader)==null||C.cancel(m);for(const S of this._rangeRequestReaders.slice(0))S.cancel(m)}}s.PDFNetworkStream=g;class x{constructor(m,C){this._manager=m;const S={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=C.url,this._fullRequestId=m.requestFull(S),this._headersReceivedCapability=new u.PromiseCapability,this._disableRange=C.disableRange||!1,this._contentLength=C.length,this._rangeChunkSize=C.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const m=this._fullRequestId,C=this._manager.getRequestXhr(m),S=I=>C.getResponseHeader(I),{allowRangeRequests:w,suggestedLength:_}=(0,d.validateRangeRequestCapabilities)({getResponseHeader:S,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});w&&(this._isRangeSupported=!0),this._contentLength=_||this._contentLength,this._filename=(0,d.extractFilenameFromHeader)(S),this._isRangeSupported&&this._manager.abortRequest(m),this._headersReceivedCapability.resolve()}_onDone(m){if(m&&(this._requests.length>0?this._requests.shift().resolve({value:m.chunk,done:!1}):this._cachedChunks.push(m.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const C of this._requests)C.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(m){this._storedError=(0,d.createResponseStatusError)(m,this._url),this._headersReceivedCapability.reject(this._storedError);for(const C of this._requests)C.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(m){var C;(C=this.onProgress)==null||C.call(this,{loaded:m.loaded,total:m.lengthComputable?m.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){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 m=new u.PromiseCapability;return this._requests.push(m),m.promise}cancel(m){this._done=!0,this._headersReceivedCapability.reject(m);for(const C of this._requests)C.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class y{constructor(m,C,S){this._manager=m;const w={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=m.url,this._requestId=m.requestRange(C,S,w),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var m;(m=this.onClosed)==null||m.call(this,this)}_onDone(m){const C=m.chunk;this._requests.length>0?this._requests.shift().resolve({value:C,done:!1}):this._queuedChunk=C,this._done=!0;for(const S of this._requests)S.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(m){this._storedError=(0,d.createResponseStatusError)(m,this._url);for(const C of this._requests)C.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(m){var C;this.isStreamingSupported||(C=this.onProgress)==null||C.call(this,{loaded:m.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const C=this._queuedChunk;return this._queuedChunk=null,{value:C,done:!1}}if(this._done)return{value:void 0,done:!0};const m=new u.PromiseCapability;return this._requests.push(m),m.promise}cancel(m){this._done=!0;for(const C of this._requests)C.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.PDFNodeStream=void 0;var u=c(1),d=c(20);const p=/^file:\/\/\/[a-zA-Z]:\//;function v(S){const w=require$$5,_=w.parse(S);return _.protocol==="file:"||_.host?_:/^[a-z]:[/\\]/i.test(S)?w.parse(`file:///${S}`):(_.host||(_.protocol="file:"),_)}class A{constructor(w){this.source=w,this.url=v(w.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.httpHeaders=this.isHttp&&w.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var w;return((w=this._fullRequestReader)==null?void 0:w._loaded)??0}getFullReader(){return(0,u.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new m(this):new y(this),this._fullRequestReader}getRangeReader(w,_){if(_<=this._progressiveDataLength)return null;const I=this.isFsUrl?new C(this,w,_):new f(this,w,_);return this._rangeRequestReaders.push(I),I}cancelAllRequests(w){var _;(_=this._fullRequestReader)==null||_.cancel(w);for(const I of this._rangeRequestReaders.slice(0))I.cancel(w)}}s.PDFNodeStream=A;class b{constructor(w){this._url=w.url,this._done=!1,this._storedError=null,this.onProgress=null;const _=w.source;this._contentLength=_.length,this._loaded=0,this._filename=null,this._disableRange=_.disableRange||!1,this._rangeChunkSize=_.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!_.disableStream,this._isRangeSupported=!_.disableRange,this._readableStream=null,this._readCapability=new u.PromiseCapability,this._headersCapability=new u.PromiseCapability}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(){var I;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const w=this._readableStream.read();return w===null?(this._readCapability=new u.PromiseCapability,this.read()):(this._loaded+=w.length,(I=this.onProgress)==null||I.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(w).buffer,done:!1})}cancel(w){if(!this._readableStream){this._error(w);return}this._readableStream.destroy(w)}_error(w){this._storedError=w,this._readCapability.resolve()}_setReadableStream(w){this._readableStream=w,w.on("readable",()=>{this._readCapability.resolve()}),w.on("end",()=>{w.destroy(),this._done=!0,this._readCapability.resolve()}),w.on("error",_=>{this._error(_)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new u.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class g{constructor(w){this._url=w.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=new u.PromiseCapability;const _=w.source;this._isStreamingSupported=!_.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){var I;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const w=this._readableStream.read();return w===null?(this._readCapability=new u.PromiseCapability,this.read()):(this._loaded+=w.length,(I=this.onProgress)==null||I.call(this,{loaded:this._loaded}),{value:new Uint8Array(w).buffer,done:!1})}cancel(w){if(!this._readableStream){this._error(w);return}this._readableStream.destroy(w)}_error(w){this._storedError=w,this._readCapability.resolve()}_setReadableStream(w){this._readableStream=w,w.on("readable",()=>{this._readCapability.resolve()}),w.on("end",()=>{w.destroy(),this._done=!0,this._readCapability.resolve()}),w.on("error",_=>{this._error(_)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function x(S,w){return{protocol:S.protocol,auth:S.auth,host:S.hostname,port:S.port,path:S.path,method:"GET",headers:w}}class y extends b{constructor(w){super(w);const _=I=>{if(I.statusCode===404){const R=new u.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=R,this._headersCapability.reject(R);return}this._headersCapability.resolve(),this._setReadableStream(I);const $=R=>this._readableStream.headers[R.toLowerCase()],{allowRangeRequests:P,suggestedLength:E}=(0,d.validateRangeRequestCapabilities)({getResponseHeader:$,isHttp:w.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=P,this._contentLength=E||this._contentLength,this._filename=(0,d.extractFilenameFromHeader)($)};if(this._request=null,this._url.protocol==="http:"){const I=require$$5;this._request=I.request(x(this._url,w.httpHeaders),_)}else{const I=require$$5;this._request=I.request(x(this._url,w.httpHeaders),_)}this._request.on("error",I=>{this._storedError=I,this._headersCapability.reject(I)}),this._request.end()}}class f extends g{constructor(w,_,I){super(w),this._httpHeaders={};for(const P in w.httpHeaders){const E=w.httpHeaders[P];E!==void 0&&(this._httpHeaders[P]=E)}this._httpHeaders.Range=`bytes=${_}-${I-1}`;const $=P=>{if(P.statusCode===404){const E=new u.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=E;return}this._setReadableStream(P)};if(this._request=null,this._url.protocol==="http:"){const P=require$$5;this._request=P.request(x(this._url,this._httpHeaders),$)}else{const P=require$$5;this._request=P.request(x(this._url,this._httpHeaders),$)}this._request.on("error",P=>{this._storedError=P}),this._request.end()}}class m extends b{constructor(w){super(w);let _=decodeURIComponent(this._url.path);p.test(this._url.href)&&(_=_.replace(/^\//,""));const I=require$$5;I.lstat(_,($,P)=>{if($){$.code==="ENOENT"&&($=new u.MissingPDFException(`Missing PDF "${_}".`)),this._storedError=$,this._headersCapability.reject($);return}this._contentLength=P.size,this._setReadableStream(I.createReadStream(_)),this._headersCapability.resolve()})}}class C extends g{constructor(w,_,I){super(w);let $=decodeURIComponent(this._url.path);p.test(this._url.href)&&($=$.replace(/^\//,""));const P=require$$5;this._setReadableStream(P.createReadStream($,{start:_,end:I-1}))}}},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.SVGGraphics=void 0;var u=c(6),d=c(1);const p={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"},v="http://www.w3.org/XML/1998/namespace",A="http://www.w3.org/1999/xlink",b=["butt","round","square"],g=["miter","round","bevel"],x=function(P,E="",R=!1){if(URL.createObjectURL&&typeof Blob<"u"&&!R)return URL.createObjectURL(new Blob([P],{type:E}));const T="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let B=`data:${E};base64,`;for(let M=0,k=P.length;M<k;M+=3){const O=P[M]&255,H=P[M+1]&255,j=P[M+2]&255,q=O>>2,L=(O&3)<<4|H>>4,F=M+1<k?(H&15)<<2|j>>6:64,U=M+2<k?j&63:64;B+=T[q]+T[L]+T[F]+T[U]}return B},y=function(){const P=new Uint8Array([137,80,78,71,13,10,26,10]),E=12,R=new Int32Array(256);for(let j=0;j<256;j++){let q=j;for(let L=0;L<8;L++)q=q&1?3988292384^q>>1&2147483647:q>>1&2147483647;R[j]=q}function T(j,q,L){let F=-1;for(let U=q;U<L;U++){const N=(F^j[U])&255,D=R[N];F=F>>>8^D}return F^-1}function B(j,q,L,F){let U=F;const N=q.length;L[U]=N>>24&255,L[U+1]=N>>16&255,L[U+2]=N>>8&255,L[U+3]=N&255,U+=4,L[U]=j.charCodeAt(0)&255,L[U+1]=j.charCodeAt(1)&255,L[U+2]=j.charCodeAt(2)&255,L[U+3]=j.charCodeAt(3)&255,U+=4,L.set(q,U),U+=q.length;const D=T(L,F+4,U);L[U]=D>>24&255,L[U+1]=D>>16&255,L[U+2]=D>>8&255,L[U+3]=D&255}function M(j,q,L){let F=1,U=0;for(let N=q;N<L;++N)F=(F+(j[N]&255))%65521,U=(U+F)%65521;return U<<16|F}function k(j){if(!d.isNodeJS)return O(j);try{const q=parseInt(process.versions.node)>=8?j:Buffer.from(j),L=require$$5.deflateSync(q,{level:9});return L instanceof Uint8Array?L:new Uint8Array(L)}catch(q){(0,d.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+q)}return O(j)}function O(j){let q=j.length;const L=65535,F=Math.ceil(q/L),U=new Uint8Array(2+q+F*5+4);let N=0;U[N++]=120,U[N++]=156;let D=0;for(;q>L;)U[N++]=0,U[N++]=255,U[N++]=255,U[N++]=0,U[N++]=0,U.set(j.subarray(D,D+L),N),N+=L,D+=L,q-=L;U[N++]=1,U[N++]=q&255,U[N++]=q>>8&255,U[N++]=~q&65535&255,U[N++]=(~q&65535)>>8&255,U.set(j.subarray(D),N),N+=j.length-D;const W=M(j,0,j.length);return U[N++]=W>>24&255,U[N++]=W>>16&255,U[N++]=W>>8&255,U[N++]=W&255,U}function H(j,q,L,F){const U=j.width,N=j.height;let D,W,Z;const Q=j.data;switch(q){case d.ImageKind.GRAYSCALE_1BPP:W=0,D=1,Z=U+7>>3;break;case d.ImageKind.RGB_24BPP:W=2,D=8,Z=U*3;break;case d.ImageKind.RGBA_32BPP:W=6,D=8,Z=U*4;break;default:throw new Error("invalid format")}const Y=new Uint8Array((1+Z)*N);let J=0,ee=0;for(let ie=0;ie<N;++ie)Y[J++]=0,Y.set(Q.subarray(ee,ee+Z),J),ee+=Z,J+=Z;if(q===d.ImageKind.GRAYSCALE_1BPP&&F){J=0;for(let ie=0;ie<N;ie++){J++;for(let ce=0;ce<Z;ce++)Y[J++]^=255}}const re=new Uint8Array([U>>24&255,U>>16&255,U>>8&255,U&255,N>>24&255,N>>16&255,N>>8&255,N&255,D,W,0,0,0]),ae=k(Y),V=P.length+E*3+re.length+ae.length,K=new Uint8Array(V);let te=0;return K.set(P,te),te+=P.length,B("IHDR",re,K,te),te+=E+re.length,B("IDATA",ae,K,te),te+=E+ae.length,B("IEND",new Uint8Array(0),K,te),x(K,"image/png",L)}return function(q,L,F){const U=q.kind===void 0?d.ImageKind.GRAYSCALE_1BPP:q.kind;return H(q,U,L,F)}}();class f{constructor(){this.fontSizeScale=1,this.fontWeight=p.fontWeight,this.fontSize=0,this.textMatrix=d.IDENTITY_MATRIX,this.fontMatrix=d.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=d.TextRenderingMode.FILL,this.textMatrixScale=1,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=p.fillColor,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(E,R){this.x=E,this.y=R}}function m(P){let E=[];const R=[];for(const T of P){if(T.fn==="save"){E.push({fnId:92,fn:"group",items:[]}),R.push(E),E=E.at(-1).items;continue}T.fn==="restore"?E=R.pop():E.push(T)}return E}function C(P){if(Number.isInteger(P))return P.toString();const E=P.toFixed(10);let R=E.length-1;if(E[R]!=="0")return E;do R--;while(E[R]==="0");return E.substring(0,E[R]==="."?R:R+1)}function S(P){if(P[4]===0&&P[5]===0){if(P[1]===0&&P[2]===0)return P[0]===1&&P[3]===1?"":`scale(${C(P[0])} ${C(P[3])})`;if(P[0]===P[3]&&P[1]===-P[2]){const E=Math.acos(P[0])*180/Math.PI;return`rotate(${C(E)})`}}else if(P[0]===1&&P[1]===0&&P[2]===0&&P[3]===1)return`translate(${C(P[4])} ${C(P[5])})`;return`matrix(${C(P[0])} ${C(P[1])} ${C(P[2])} ${C(P[3])} ${C(P[4])} ${C(P[5])})`}let w=0,_=0,I=0;class ${constructor(E,R,T=!1){(0,u.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."),this.svgFactory=new u.DOMSVGFactory,this.current=new f,this.transformMatrix=d.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=E,this.objs=R,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!T,this._operatorIdMapping=[];for(const B in d.OPS)this._operatorIdMapping[d.OPS[B]]=B}getObject(E,R=null){return typeof E=="string"?E.startsWith("g_")?this.commonObjs.get(E):this.objs.get(E):R}save(){this.transformStack.push(this.transformMatrix);const E=this.current;this.extraStack.push(E),this.current=E.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(E){this.save(),this.executeOpTree(E),this.restore()}loadDependencies(E){const R=E.fnArray,T=E.argsArray;for(let B=0,M=R.length;B<M;B++)if(R[B]===d.OPS.dependency)for(const k of T[B]){const O=k.startsWith("g_")?this.commonObjs:this.objs,H=new Promise(j=>{O.get(k,j)});this.current.dependencies.push(H)}return Promise.all(this.current.dependencies)}transform(E,R,T,B,M,k){const O=[E,R,T,B,M,k];this.transformMatrix=d.Util.transform(this.transformMatrix,O),this.tgrp=null}getSVG(E,R){this.viewport=R;const T=this._initialize(R);return this.loadDependencies(E).then(()=>(this.transformMatrix=d.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(E)),T))}convertOpList(E){const R=this._operatorIdMapping,T=E.argsArray,B=E.fnArray,M=[];for(let k=0,O=B.length;k<O;k++){const H=B[k];M.push({fnId:H,fn:R[H],args:T[k]})}return m(M)}executeOpTree(E){for(const R of E){const T=R.fn,B=R.fnId,M=R.args;switch(B|0){case d.OPS.beginText:this.beginText();break;case d.OPS.dependency:break;case d.OPS.setLeading:this.setLeading(M);break;case d.OPS.setLeadingMoveText:this.setLeadingMoveText(M[0],M[1]);break;case d.OPS.setFont:this.setFont(M);break;case d.OPS.showText:this.showText(M[0]);break;case d.OPS.showSpacedText:this.showText(M[0]);break;case d.OPS.endText:this.endText();break;case d.OPS.moveText:this.moveText(M[0],M[1]);break;case d.OPS.setCharSpacing:this.setCharSpacing(M[0]);break;case d.OPS.setWordSpacing:this.setWordSpacing(M[0]);break;case d.OPS.setHScale:this.setHScale(M[0]);break;case d.OPS.setTextMatrix:this.setTextMatrix(M[0],M[1],M[2],M[3],M[4],M[5]);break;case d.OPS.setTextRise:this.setTextRise(M[0]);break;case d.OPS.setTextRenderingMode:this.setTextRenderingMode(M[0]);break;case d.OPS.setLineWidth:this.setLineWidth(M[0]);break;case d.OPS.setLineJoin:this.setLineJoin(M[0]);break;case d.OPS.setLineCap:this.setLineCap(M[0]);break;case d.OPS.setMiterLimit:this.setMiterLimit(M[0]);break;case d.OPS.setFillRGBColor:this.setFillRGBColor(M[0],M[1],M[2]);break;case d.OPS.setStrokeRGBColor:this.setStrokeRGBColor(M[0],M[1],M[2]);break;case d.OPS.setStrokeColorN:this.setStrokeColorN(M);break;case d.OPS.setFillColorN:this.setFillColorN(M);break;case d.OPS.shadingFill:this.shadingFill(M[0]);break;case d.OPS.setDash:this.setDash(M[0],M[1]);break;case d.OPS.setRenderingIntent:this.setRenderingIntent(M[0]);break;case d.OPS.setFlatness:this.setFlatness(M[0]);break;case d.OPS.setGState:this.setGState(M[0]);break;case d.OPS.fill:this.fill();break;case d.OPS.eoFill:this.eoFill();break;case d.OPS.stroke:this.stroke();break;case d.OPS.fillStroke:this.fillStroke();break;case d.OPS.eoFillStroke:this.eoFillStroke();break;case d.OPS.clip:this.clip("nonzero");break;case d.OPS.eoClip:this.clip("evenodd");break;case d.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case d.OPS.paintImageXObject:this.paintImageXObject(M[0]);break;case d.OPS.paintInlineImageXObject:this.paintInlineImageXObject(M[0]);break;case d.OPS.paintImageMaskXObject:this.paintImageMaskXObject(M[0]);break;case d.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(M[0],M[1]);break;case d.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case d.OPS.closePath:this.closePath();break;case d.OPS.closeStroke:this.closeStroke();break;case d.OPS.closeFillStroke:this.closeFillStroke();break;case d.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case d.OPS.nextLine:this.nextLine();break;case d.OPS.transform:this.transform(M[0],M[1],M[2],M[3],M[4],M[5]);break;case d.OPS.constructPath:this.constructPath(M[0],M[1]);break;case d.OPS.endPath:this.endPath();break;case 92:this.group(R.items);break;default:(0,d.warn)(`Unimplemented operator ${T}`);break}}}setWordSpacing(E){this.current.wordSpacing=E}setCharSpacing(E){this.current.charSpacing=E}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(E,R,T,B,M,k){const O=this.current;O.textMatrix=O.lineMatrix=[E,R,T,B,M,k],O.textMatrixScale=Math.hypot(E,R),O.x=O.lineX=0,O.y=O.lineY=0,O.xcoords=[],O.ycoords=[],O.tspan=this.svgFactory.createElement("svg:tspan"),O.tspan.setAttributeNS(null,"font-family",O.fontFamily),O.tspan.setAttributeNS(null,"font-size",`${C(O.fontSize)}px`),O.tspan.setAttributeNS(null,"y",C(-O.y)),O.txtElement=this.svgFactory.createElement("svg:text"),O.txtElement.append(O.tspan)}beginText(){const E=this.current;E.x=E.lineX=0,E.y=E.lineY=0,E.textMatrix=d.IDENTITY_MATRIX,E.lineMatrix=d.IDENTITY_MATRIX,E.textMatrixScale=1,E.tspan=this.svgFactory.createElement("svg:tspan"),E.txtElement=this.svgFactory.createElement("svg:text"),E.txtgrp=this.svgFactory.createElement("svg:g"),E.xcoords=[],E.ycoords=[]}moveText(E,R){const T=this.current;T.x=T.lineX+=E,T.y=T.lineY+=R,T.xcoords=[],T.ycoords=[],T.tspan=this.svgFactory.createElement("svg:tspan"),T.tspan.setAttributeNS(null,"font-family",T.fontFamily),T.tspan.setAttributeNS(null,"font-size",`${C(T.fontSize)}px`),T.tspan.setAttributeNS(null,"y",C(-T.y))}showText(E){const R=this.current,T=R.font,B=R.fontSize;if(B===0)return;const M=R.fontSizeScale,k=R.charSpacing,O=R.wordSpacing,H=R.fontDirection,j=R.textHScale*H,q=T.vertical,L=q?1:-1,F=T.defaultVMetrics,U=B*R.fontMatrix[0];let N=0;for(const Z of E){if(Z===null){N+=H*O;continue}else if(typeof Z=="number"){N+=L*Z*B/1e3;continue}const Q=(Z.isSpace?O:0)+k,Y=Z.fontChar;let J,ee,re=Z.width;if(q){let V;const K=Z.vmetric||F;V=Z.vmetric?K[1]:re*.5,V=-V*U;const te=K[2]*U;re=K?-K[0]:re,J=V/M,ee=(N+te)/M}else J=N/M,ee=0;(Z.isInFont||T.missingFile)&&(R.xcoords.push(R.x+J),q&&R.ycoords.push(-R.y+ee),R.tspan.textContent+=Y);const ae=q?re*U-Q*H:re*U+Q*H;N+=ae}R.tspan.setAttributeNS(null,"x",R.xcoords.map(C).join(" ")),q?R.tspan.setAttributeNS(null,"y",R.ycoords.map(C).join(" ")):R.tspan.setAttributeNS(null,"y",C(-R.y)),q?R.y-=N:R.x+=N*j,R.tspan.setAttributeNS(null,"font-family",R.fontFamily),R.tspan.setAttributeNS(null,"font-size",`${C(R.fontSize)}px`),R.fontStyle!==p.fontStyle&&R.tspan.setAttributeNS(null,"font-style",R.fontStyle),R.fontWeight!==p.fontWeight&&R.tspan.setAttributeNS(null,"font-weight",R.fontWeight);const D=R.textRenderingMode&d.TextRenderingMode.FILL_STROKE_MASK;if(D===d.TextRenderingMode.FILL||D===d.TextRenderingMode.FILL_STROKE?(R.fillColor!==p.fillColor&&R.tspan.setAttributeNS(null,"fill",R.fillColor),R.fillAlpha<1&&R.tspan.setAttributeNS(null,"fill-opacity",R.fillAlpha)):R.textRenderingMode===d.TextRenderingMode.ADD_TO_PATH?R.tspan.setAttributeNS(null,"fill","transparent"):R.tspan.setAttributeNS(null,"fill","none"),D===d.TextRenderingMode.STROKE||D===d.TextRenderingMode.FILL_STROKE){const Z=1/(R.textMatrixScale||1);this._setStrokeAttributes(R.tspan,Z)}let W=R.textMatrix;R.textRise!==0&&(W=W.slice(),W[5]+=R.textRise),R.txtElement.setAttributeNS(null,"transform",`${S(W)} scale(${C(j)}, -1)`),R.txtElement.setAttributeNS(v,"xml:space","preserve"),R.txtElement.append(R.tspan),R.txtgrp.append(R.txtElement),this._ensureTransformGroup().append(R.txtElement)}setLeadingMoveText(E,R){this.setLeading(-R),this.moveText(E,R)}addFontStyle(E){if(!E.data)throw new Error('addFontStyle: No font data available, ensure that the "fontExtraProperties" API parameter is set.');this.cssStyle||(this.cssStyle=this.svgFactory.createElement("svg:style"),this.cssStyle.setAttributeNS(null,"type","text/css"),this.defs.append(this.cssStyle));const R=x(E.data,E.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${E.loadedName}"; src: url(${R}); }
|
61
61
|
`}setFont(E){const R=this.current,T=this.commonObjs.get(E[0]);let B=E[1];R.font=T,this.embedFonts&&!T.missingFile&&!this.embeddedFonts[T.loadedName]&&(this.addFontStyle(T),this.embeddedFonts[T.loadedName]=T),R.fontMatrix=T.fontMatrix||d.FONT_IDENTITY_MATRIX;let M="normal";T.black?M="900":T.bold&&(M="bold");const k=T.italic?"italic":"normal";B<0?(B=-B,R.fontDirection=-1):R.fontDirection=1,R.fontSize=B,R.fontFamily=T.loadedName,R.fontWeight=M,R.fontStyle=k,R.tspan=this.svgFactory.createElement("svg:tspan"),R.tspan.setAttributeNS(null,"y",C(-R.y)),R.xcoords=[],R.ycoords=[]}endText(){var R;const E=this.current;E.textRenderingMode&d.TextRenderingMode.ADD_TO_PATH_FLAG&&((R=E.txtElement)!=null&&R.hasChildNodes())&&(E.element=E.txtElement,this.clip("nonzero"),this.endPath())}setLineWidth(E){E>0&&(this.current.lineWidth=E)}setLineCap(E){this.current.lineCap=b[E]}setLineJoin(E){this.current.lineJoin=g[E]}setMiterLimit(E){this.current.miterLimit=E}setStrokeAlpha(E){this.current.strokeAlpha=E}setStrokeRGBColor(E,R,T){this.current.strokeColor=d.Util.makeHexColor(E,R,T)}setFillAlpha(E){this.current.fillAlpha=E}setFillRGBColor(E,R,T){this.current.fillColor=d.Util.makeHexColor(E,R,T),this.current.tspan=this.svgFactory.createElement("svg:tspan"),this.current.xcoords=[],this.current.ycoords=[]}setStrokeColorN(E){this.current.strokeColor=this._makeColorN_Pattern(E)}setFillColorN(E){this.current.fillColor=this._makeColorN_Pattern(E)}shadingFill(E){const{width:R,height:T}=this.viewport,B=d.Util.inverseTransform(this.transformMatrix),[M,k,O,H]=d.Util.getAxialAlignedBoundingBox([0,0,R,T],B),j=this.svgFactory.createElement("svg:rect");j.setAttributeNS(null,"x",M),j.setAttributeNS(null,"y",k),j.setAttributeNS(null,"width",O-M),j.setAttributeNS(null,"height",H-k),j.setAttributeNS(null,"fill",this._makeShadingPattern(E)),this.current.fillAlpha<1&&j.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().append(j)}_makeColorN_Pattern(E){return E[0]==="TilingPattern"?this._makeTilingPattern(E):this._makeShadingPattern(E)}_makeTilingPattern(E){const R=E[1],T=E[2],B=E[3]||d.IDENTITY_MATRIX,[M,k,O,H]=E[4],j=E[5],q=E[6],L=E[7],F=`shading${I++}`,[U,N,D,W]=d.Util.normalizeRect([...d.Util.applyTransform([M,k],B),...d.Util.applyTransform([O,H],B)]),[Z,Q]=d.Util.singularValueDecompose2dScale(B),Y=j*Z,J=q*Q,ee=this.svgFactory.createElement("svg:pattern");ee.setAttributeNS(null,"id",F),ee.setAttributeNS(null,"patternUnits","userSpaceOnUse"),ee.setAttributeNS(null,"width",Y),ee.setAttributeNS(null,"height",J),ee.setAttributeNS(null,"x",`${U}`),ee.setAttributeNS(null,"y",`${N}`);const re=this.svg,ae=this.transformMatrix,V=this.current.fillColor,K=this.current.strokeColor,te=this.svgFactory.create(D-U,W-N);if(this.svg=te,this.transformMatrix=B,L===2){const ie=d.Util.makeHexColor(...R);this.current.fillColor=ie,this.current.strokeColor=ie}return this.executeOpTree(this.convertOpList(T)),this.svg=re,this.transformMatrix=ae,this.current.fillColor=V,this.current.strokeColor=K,ee.append(te.childNodes[0]),this.defs.append(ee),`url(#${F})`}_makeShadingPattern(E){switch(typeof E=="string"&&(E=this.objs.get(E)),E[0]){case"RadialAxial":const R=`shading${I++}`,T=E[3];let B;switch(E[1]){case"axial":const M=E[4],k=E[5];B=this.svgFactory.createElement("svg:linearGradient"),B.setAttributeNS(null,"id",R),B.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),B.setAttributeNS(null,"x1",M[0]),B.setAttributeNS(null,"y1",M[1]),B.setAttributeNS(null,"x2",k[0]),B.setAttributeNS(null,"y2",k[1]);break;case"radial":const O=E[4],H=E[5],j=E[6],q=E[7];B=this.svgFactory.createElement("svg:radialGradient"),B.setAttributeNS(null,"id",R),B.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),B.setAttributeNS(null,"cx",H[0]),B.setAttributeNS(null,"cy",H[1]),B.setAttributeNS(null,"r",q),B.setAttributeNS(null,"fx",O[0]),B.setAttributeNS(null,"fy",O[1]),B.setAttributeNS(null,"fr",j);break;default:throw new Error(`Unknown RadialAxial type: ${E[1]}`)}for(const M of T){const k=this.svgFactory.createElement("svg:stop");k.setAttributeNS(null,"offset",M[0]),k.setAttributeNS(null,"stop-color",M[1]),B.append(k)}return this.defs.append(B),`url(#${R})`;case"Mesh":return(0,d.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${E[0]}`)}}setDash(E,R){this.current.dashArray=E,this.current.dashPhase=R}constructPath(E,R){const T=this.current;let B=T.x,M=T.y,k=[],O=0;for(const H of E)switch(H|0){case d.OPS.rectangle:B=R[O++],M=R[O++];const j=R[O++],q=R[O++],L=B+j,F=M+q;k.push("M",C(B),C(M),"L",C(L),C(M),"L",C(L),C(F),"L",C(B),C(F),"Z");break;case d.OPS.moveTo:B=R[O++],M=R[O++],k.push("M",C(B),C(M));break;case d.OPS.lineTo:B=R[O++],M=R[O++],k.push("L",C(B),C(M));break;case d.OPS.curveTo:B=R[O+4],M=R[O+5],k.push("C",C(R[O]),C(R[O+1]),C(R[O+2]),C(R[O+3]),C(B),C(M)),O+=6;break;case d.OPS.curveTo2:k.push("C",C(B),C(M),C(R[O]),C(R[O+1]),C(R[O+2]),C(R[O+3])),B=R[O+2],M=R[O+3],O+=4;break;case d.OPS.curveTo3:B=R[O+2],M=R[O+3],k.push("C",C(R[O]),C(R[O+1]),C(B),C(M),C(B),C(M)),O+=4;break;case d.OPS.closePath:k.push("Z");break}k=k.join(" "),T.path&&E.length>0&&E[0]!==d.OPS.rectangle&&E[0]!==d.OPS.moveTo?k=T.path.getAttributeNS(null,"d")+k:(T.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(T.path)),T.path.setAttributeNS(null,"d",k),T.path.setAttributeNS(null,"fill","none"),T.element=T.path,T.setCurrentPoint(B,M)}endPath(){const E=this.current;if(E.path=null,!this.pendingClip)return;if(!E.element){this.pendingClip=null;return}const R=`clippath${w++}`,T=this.svgFactory.createElement("svg:clipPath");T.setAttributeNS(null,"id",R),T.setAttributeNS(null,"transform",S(this.transformMatrix));const B=E.element.cloneNode(!0);if(this.pendingClip==="evenodd"?B.setAttributeNS(null,"clip-rule","evenodd"):B.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,T.append(B),this.defs.append(T),E.activeClipUrl){E.clipGroup=null;for(const M of this.extraStack)M.clipGroup=null;T.setAttributeNS(null,"clip-path",E.activeClipUrl)}E.activeClipUrl=`url(#${R})`,this.tgrp=null}clip(E){this.pendingClip=E}closePath(){const E=this.current;if(E.path){const R=`${E.path.getAttributeNS(null,"d")}Z`;E.path.setAttributeNS(null,"d",R)}}setLeading(E){this.current.leading=-E}setTextRise(E){this.current.textRise=E}setTextRenderingMode(E){this.current.textRenderingMode=E}setHScale(E){this.current.textHScale=E/100}setRenderingIntent(E){}setFlatness(E){}setGState(E){for(const[R,T]of E)switch(R){case"LW":this.setLineWidth(T);break;case"LC":this.setLineCap(T);break;case"LJ":this.setLineJoin(T);break;case"ML":this.setMiterLimit(T);break;case"D":this.setDash(T[0],T[1]);break;case"RI":this.setRenderingIntent(T);break;case"FL":this.setFlatness(T);break;case"Font":this.setFont(T);break;case"CA":this.setStrokeAlpha(T);break;case"ca":this.setFillAlpha(T);break;default:(0,d.warn)(`Unimplemented graphic state operator ${R}`);break}}fill(){const E=this.current;E.element&&(E.element.setAttributeNS(null,"fill",E.fillColor),E.element.setAttributeNS(null,"fill-opacity",E.fillAlpha),this.endPath())}stroke(){const E=this.current;E.element&&(this._setStrokeAttributes(E.element),E.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(E,R=1){const T=this.current;let B=T.dashArray;R!==1&&B.length>0&&(B=B.map(function(M){return R*M})),E.setAttributeNS(null,"stroke",T.strokeColor),E.setAttributeNS(null,"stroke-opacity",T.strokeAlpha),E.setAttributeNS(null,"stroke-miterlimit",C(T.miterLimit)),E.setAttributeNS(null,"stroke-linecap",T.lineCap),E.setAttributeNS(null,"stroke-linejoin",T.lineJoin),E.setAttributeNS(null,"stroke-width",C(R*T.lineWidth)+"px"),E.setAttributeNS(null,"stroke-dasharray",B.map(C).join(" ")),E.setAttributeNS(null,"stroke-dashoffset",C(R*T.dashPhase)+"px")}eoFill(){var E;(E=this.current.element)==null||E.setAttributeNS(null,"fill-rule","evenodd"),this.fill()}fillStroke(){this.stroke(),this.fill()}eoFillStroke(){var E;(E=this.current.element)==null||E.setAttributeNS(null,"fill-rule","evenodd"),this.fillStroke()}closeStroke(){this.closePath(),this.stroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.closePath(),this.eoFillStroke()}paintSolidColorImageMask(){const E=this.svgFactory.createElement("svg:rect");E.setAttributeNS(null,"x","0"),E.setAttributeNS(null,"y","0"),E.setAttributeNS(null,"width","1px"),E.setAttributeNS(null,"height","1px"),E.setAttributeNS(null,"fill",this.current.fillColor),this._ensureTransformGroup().append(E)}paintImageXObject(E){const R=this.getObject(E);if(!R){(0,d.warn)(`Dependent image with object ID ${E} is not ready yet`);return}this.paintInlineImageXObject(R)}paintInlineImageXObject(E,R){const T=E.width,B=E.height,M=y(E,this.forceDataSchema,!!R),k=this.svgFactory.createElement("svg:rect");k.setAttributeNS(null,"x","0"),k.setAttributeNS(null,"y","0"),k.setAttributeNS(null,"width",C(T)),k.setAttributeNS(null,"height",C(B)),this.current.element=k,this.clip("nonzero");const O=this.svgFactory.createElement("svg:image");O.setAttributeNS(A,"xlink:href",M),O.setAttributeNS(null,"x","0"),O.setAttributeNS(null,"y",C(-B)),O.setAttributeNS(null,"width",C(T)+"px"),O.setAttributeNS(null,"height",C(B)+"px"),O.setAttributeNS(null,"transform",`scale(${C(1/T)} ${C(-1/B)})`),R?R.append(O):this._ensureTransformGroup().append(O)}paintImageMaskXObject(E){const R=this.getObject(E.data,E);if(R.bitmap){(0,d.warn)("paintImageMaskXObject: ImageBitmap support is not implemented, ensure that the `isOffscreenCanvasSupported` API parameter is disabled.");return}const T=this.current,B=R.width,M=R.height,k=T.fillColor;T.maskId=`mask${_++}`;const O=this.svgFactory.createElement("svg:mask");O.setAttributeNS(null,"id",T.maskId);const H=this.svgFactory.createElement("svg:rect");H.setAttributeNS(null,"x","0"),H.setAttributeNS(null,"y","0"),H.setAttributeNS(null,"width",C(B)),H.setAttributeNS(null,"height",C(M)),H.setAttributeNS(null,"fill",k),H.setAttributeNS(null,"mask",`url(#${T.maskId})`),this.defs.append(O),this._ensureTransformGroup().append(H),this.paintInlineImageXObject(R,O)}paintFormXObjectBegin(E,R){if(Array.isArray(E)&&E.length===6&&this.transform(E[0],E[1],E[2],E[3],E[4],E[5]),R){const T=R[2]-R[0],B=R[3]-R[1],M=this.svgFactory.createElement("svg:rect");M.setAttributeNS(null,"x",R[0]),M.setAttributeNS(null,"y",R[1]),M.setAttributeNS(null,"width",C(T)),M.setAttributeNS(null,"height",C(B)),this.current.element=M,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(E){const R=this.svgFactory.create(E.width,E.height),T=this.svgFactory.createElement("svg:defs");R.append(T),this.defs=T;const B=this.svgFactory.createElement("svg:g");return B.setAttributeNS(null,"transform",S(E.transform)),R.append(B),this.svg=B,R}_ensureClipGroup(){if(!this.current.clipGroup){const E=this.svgFactory.createElement("svg:g");E.setAttributeNS(null,"clip-path",this.current.activeClipUrl),this.svg.append(E),this.current.clipGroup=E}return this.current.clipGroup}_ensureTransformGroup(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",S(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)),this.tgrp}}s.SVGGraphics=$},(a,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.XfaText=void 0;class c{static textContent(d){const p=[],v={items:p,styles:Object.create(null)};function A(b){var y;if(!b)return;let g=null;const x=b.name;if(x==="#text")g=b.value;else if(c.shouldBuildText(x))(y=b==null?void 0:b.attributes)!=null&&y.textContent?g=b.attributes.textContent:b.value&&(g=b.value);else return;if(g!==null&&p.push({str:g}),!!b.children)for(const f of b.children)A(f)}return A(d),v}static shouldBuildText(d){return!(d==="textarea"||d==="input"||d==="option"||d==="select")}}s.XfaText=c},(a,s,c)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TextLayerRenderTask=void 0,s.renderTextLayer=S,s.updateTextLayer=w;var u=c(1),d=c(6);const p=1e5,v=30,A=.8,b=new Map;function g(_,I){let $;if(I&&u.FeatureTest.isOffscreenCanvasSupported)$=new OffscreenCanvas(_,_).getContext("2d",{alpha:!1});else{const P=document.createElement("canvas");P.width=P.height=_,$=P.getContext("2d",{alpha:!1})}return $}function x(_,I){const $=b.get(_);if($)return $;const P=g(v,I);P.font=`${v}px ${_}`;const E=P.measureText("");let R=E.fontBoundingBoxAscent,T=Math.abs(E.fontBoundingBoxDescent);if(R){const M=R/(R+T);return b.set(_,M),P.canvas.width=P.canvas.height=0,M}P.strokeStyle="red",P.clearRect(0,0,v,v),P.strokeText("g",0,0);let B=P.getImageData(0,0,v,v).data;T=0;for(let M=B.length-1-3;M>=0;M-=4)if(B[M]>0){T=Math.ceil(M/4/v);break}P.clearRect(0,0,v,v),P.strokeText("A",0,v),B=P.getImageData(0,0,v,v).data,R=0;for(let M=0,k=B.length;M<k;M+=4)if(B[M]>0){R=v-Math.floor(M/4/v);break}if(P.canvas.width=P.canvas.height=0,R){const M=R/(R+T);return b.set(_,M),M}return b.set(_,A),A}function y(_,I,$){const P=document.createElement("span"),E={angle:0,canvasWidth:0,hasText:I.str!=="",hasEOL:I.hasEOL,fontSize:0};_._textDivs.push(P);const R=u.Util.transform(_._transform,I.transform);let T=Math.atan2(R[1],R[0]);const B=$[I.fontName];B.vertical&&(T+=Math.PI/2);const M=Math.hypot(R[2],R[3]),k=M*x(B.fontFamily,_._isOffscreenCanvasSupported);let O,H;T===0?(O=R[4],H=R[5]-k):(O=R[4]+k*Math.sin(T),H=R[5]-k*Math.cos(T));const j="calc(var(--scale-factor)*",q=P.style;_._container===_._rootContainer?(q.left=`${(100*O/_._pageWidth).toFixed(2)}%`,q.top=`${(100*H/_._pageHeight).toFixed(2)}%`):(q.left=`${j}${O.toFixed(2)}px)`,q.top=`${j}${H.toFixed(2)}px)`),q.fontSize=`${j}${M.toFixed(2)}px)`,q.fontFamily=B.fontFamily,E.fontSize=M,P.setAttribute("role","presentation"),P.textContent=I.str,P.dir=I.dir,_._fontInspectorEnabled&&(P.dataset.fontName=I.fontName),T!==0&&(E.angle=T*(180/Math.PI));let L=!1;if(I.str.length>1)L=!0;else if(I.str!==" "&&I.transform[0]!==I.transform[3]){const F=Math.abs(I.transform[0]),U=Math.abs(I.transform[3]);F!==U&&Math.max(F,U)/Math.min(F,U)>1.5&&(L=!0)}L&&(E.canvasWidth=B.vertical?I.height:I.width),_._textDivProperties.set(P,E),_._isReadableStream&&_._layoutText(P)}function f(_){const{div:I,scale:$,properties:P,ctx:E,prevFontSize:R,prevFontFamily:T}=_,{style:B}=I;let M="";if(P.canvasWidth!==0&&P.hasText){const{fontFamily:k}=B,{canvasWidth:O,fontSize:H}=P;(R!==H||T!==k)&&(E.font=`${H*$}px ${k}`,_.prevFontSize=H,_.prevFontFamily=k);const{width:j}=E.measureText(I.textContent);j>0&&(M=`scaleX(${O*$/j})`)}P.angle!==0&&(M=`rotate(${P.angle}deg) ${M}`),M.length>0&&(B.transform=M)}function m(_){if(_._canceled)return;const I=_._textDivs,$=_._capability;if(I.length>p){$.resolve();return}if(!_._isReadableStream)for(const E of I)_._layoutText(E);$.resolve()}class C{constructor({textContentSource:I,container:$,viewport:P,textDivs:E,textDivProperties:R,textContentItemsStr:T,isOffscreenCanvasSupported:B}){var j;this._textContentSource=I,this._isReadableStream=I instanceof ReadableStream,this._container=this._rootContainer=$,this._textDivs=E||[],this._textContentItemsStr=T||[],this._isOffscreenCanvasSupported=B,this._fontInspectorEnabled=!!((j=globalThis.FontInspector)!=null&&j.enabled),this._reader=null,this._textDivProperties=R||new WeakMap,this._canceled=!1,this._capability=new u.PromiseCapability,this._layoutTextParams={prevFontSize:null,prevFontFamily:null,div:null,scale:P.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:g(0,B)};const{pageWidth:M,pageHeight:k,pageX:O,pageY:H}=P.rawDims;this._transform=[1,0,0,-1,-O,H+k],this._pageWidth=M,this._pageHeight=k,(0,d.setLayerDimensions)($,P),this._capability.promise.finally(()=>{this._layoutTextParams=null}).catch(()=>{})}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new u.AbortException("TextLayer task cancelled.")).catch(()=>{}),this._reader=null),this._capability.reject(new u.AbortException("TextLayer task cancelled."))}_processItems(I,$){for(const P of I){if(P.str===void 0){if(P.type==="beginMarkedContentProps"||P.type==="beginMarkedContent"){const E=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),P.id!==null&&this._container.setAttribute("id",`${P.id}`),E.append(this._container)}else P.type==="endMarkedContent"&&(this._container=this._container.parentNode);continue}this._textContentItemsStr.push(P.str),y(this,P,$)}}_layoutText(I){const $=this._layoutTextParams.properties=this._textDivProperties.get(I);if(this._layoutTextParams.div=I,f(this._layoutTextParams),$.hasText&&this._container.append(I),$.hasEOL){const P=document.createElement("br");P.setAttribute("role","presentation"),this._container.append(P)}}_render(){const I=new u.PromiseCapability;let $=Object.create(null);if(this._isReadableStream){const P=()=>{this._reader.read().then(({value:E,done:R})=>{if(R){I.resolve();return}Object.assign($,E.styles),this._processItems(E.items,$),P()},I.reject)};this._reader=this._textContentSource.getReader(),P()}else if(this._textContentSource){const{items:P,styles:E}=this._textContentSource;this._processItems(P,E),I.resolve()}else throw new Error('No "textContentSource" parameter specified.');I.promise.then(()=>{$=null,m(this)},this._capability.reject)}}s.TextLayerRenderTask=C;function S(_){!_.textContentSource&&(_.textContent||_.textContentStream)&&((0,d.deprecated)("The TextLayerRender `textContent`/`textContentStream` parameters will be removed in the future, please use `textContentSource` instead."),_.textContentSource=_.textContent||_.textContentStream);const{container:I,viewport:$}=_,P=getComputedStyle(I),E=P.getPropertyValue("visibility"),R=parseFloat(P.getPropertyValue("--scale-factor"));E==="visible"&&(!R||Math.abs(R-$.scale)>1e-5)&&console.error("The `--scale-factor` CSS-variable must be set, to the same value as `viewport.scale`, either on the `container`-element itself or higher up in the DOM.");const T=new C(_);return T._render(),T}function w({container:_,viewport:I,textDivs:$,textDivProperties:P,isOffscreenCanvasSupported:E,mustRotate:R=!0,mustRescale:T=!0}){if(R&&(0,d.setLayerDimensions)(_,{rotation:I.rotation}),T){const B=g(0,E),k={prevFontSize:null,prevFontFamily:null,div:null,scale:I.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:B};for(const O of $)k.properties=P.get(O),k.div=O,f(k)}}},(a,s,c)=>{var x,y,f,m,C,S,w,_,I,$,P,ll,xo,cl,ul;Object.defineProperty(s,"__esModule",{value:!0}),s.AnnotationEditorLayer=void 0;var u=c(1),d=c(4),p=c(28),v=c(33),A=c(6),b=c(34);const M=class M{constructor({uiManager:O,pageIndex:H,div:j,accessibilityManager:q,annotationLayer:L,viewport:F,l10n:U}){bt(this,P);bt(this,x);bt(this,y,!1);bt(this,f,null);bt(this,m,this.pointerup.bind(this));bt(this,C,this.pointerdown.bind(this));bt(this,S,new Map);bt(this,w,!1);bt(this,_,!1);bt(this,I,!1);bt(this,$);const N=[p.FreeTextEditor,v.InkEditor,b.StampEditor];if(!M._initialized){M._initialized=!0;for(const D of N)D.initialize(U)}O.registerEditorTypes(N),Ct(this,$,O),this.pageIndex=H,this.div=j,Ct(this,x,q),Ct(this,f,L),this.viewport=F,He(this,$).addLayer(this)}get isEmpty(){return He(this,S).size===0}updateToolbar(O){He(this,$).updateToolbar(O)}updateMode(O=He(this,$).getMode()){it(this,P,ul).call(this),O===u.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),O!==u.AnnotationEditorType.NONE&&(this.div.classList.toggle("freeTextEditing",O===u.AnnotationEditorType.FREETEXT),this.div.classList.toggle("inkEditing",O===u.AnnotationEditorType.INK),this.div.classList.toggle("stampEditing",O===u.AnnotationEditorType.STAMP),this.div.hidden=!1)}addInkEditorIfNeeded(O){if(!O&&He(this,$).getMode()!==u.AnnotationEditorType.INK)return;if(!O){for(const j of He(this,S).values())if(j.isEmpty()){j.setInBackground();return}}it(this,P,xo).call(this,{offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(O){He(this,$).setEditingState(O)}addCommands(O){He(this,$).addCommands(O)}enable(){this.div.style.pointerEvents="auto";const O=new Set;for(const j of He(this,S).values())j.enableEditing(),j.annotationElementId&&O.add(j.annotationElementId);if(!He(this,f))return;const H=He(this,f).getEditableAnnotations();for(const j of H){if(j.hide(),He(this,$).isDeletedAnnotationElement(j.data.id)||O.has(j.data.id))continue;const q=this.deserialize(j);q&&(this.addOrRebuild(q),q.enableEditing())}}disable(){var H;Ct(this,I,!0),this.div.style.pointerEvents="none";const O=new Set;for(const j of He(this,S).values()){if(j.disableEditing(),!j.annotationElementId||j.serialize()!==null){O.add(j.annotationElementId);continue}(H=this.getEditableAnnotation(j.annotationElementId))==null||H.show(),j.remove()}if(He(this,f)){const j=He(this,f).getEditableAnnotations();for(const q of j){const{id:L}=q.data;O.has(L)||He(this,$).isDeletedAnnotationElement(L)||q.show()}}it(this,P,ul).call(this),this.isEmpty&&(this.div.hidden=!0),Ct(this,I,!1)}getEditableAnnotation(O){var H;return((H=He(this,f))==null?void 0:H.getEditableAnnotation(O))||null}setActiveEditor(O){He(this,$).getActive()!==O&&He(this,$).setActiveEditor(O)}enableClick(){this.div.addEventListener("pointerdown",He(this,C)),this.div.addEventListener("pointerup",He(this,m))}disableClick(){this.div.removeEventListener("pointerdown",He(this,C)),this.div.removeEventListener("pointerup",He(this,m))}attach(O){He(this,S).set(O.id,O);const{annotationElementId:H}=O;H&&He(this,$).isDeletedAnnotationElement(H)&&He(this,$).removeDeletedAnnotationElement(O)}detach(O){var H;He(this,S).delete(O.id),(H=He(this,x))==null||H.removePointerInTextLayer(O.contentDiv),!He(this,I)&&O.annotationElementId&&He(this,$).addDeletedAnnotationElement(O)}remove(O){this.detach(O),He(this,$).removeEditor(O),O.div.contains(document.activeElement)&&setTimeout(()=>{He(this,$).focusMainContainer()},0),O.div.remove(),O.isAttachedToDOM=!1,He(this,_)||this.addInkEditorIfNeeded(!1)}changeParent(O){var H;O.parent!==this&&(O.annotationElementId&&(He(this,$).addDeletedAnnotationElement(O.annotationElementId),d.AnnotationEditor.deleteAnnotationElement(O),O.annotationElementId=null),this.attach(O),(H=O.parent)==null||H.detach(O),O.setParent(this),O.div&&O.isAttachedToDOM&&(O.div.remove(),this.div.append(O.div)))}add(O){if(this.changeParent(O),He(this,$).addEditor(O),this.attach(O),!O.isAttachedToDOM){const H=O.render();this.div.append(H),O.isAttachedToDOM=!0}O.fixAndSetPosition(),O.onceAdded(),He(this,$).addToAnnotationStorage(O)}moveEditorInDOM(O){var j;if(!O.isAttachedToDOM)return;const{activeElement:H}=document;O.div.contains(H)&&(O._focusEventsAllowed=!1,setTimeout(()=>{O.div.contains(document.activeElement)?O._focusEventsAllowed=!0:(O.div.addEventListener("focusin",()=>{O._focusEventsAllowed=!0},{once:!0}),H.focus())},0)),O._structTreeParentId=(j=He(this,x))==null?void 0:j.moveElementInDOM(this.div,O.div,O.contentDiv,!0)}addOrRebuild(O){O.needsToBeRebuilt()?O.rebuild():this.add(O)}addUndoableEditor(O){const H=()=>O._uiManager.rebuild(O),j=()=>{O.remove()};this.addCommands({cmd:H,undo:j,mustExec:!1})}getNextId(){return He(this,$).getId()}pasteEditor(O,H){He(this,$).updateToolbar(O),He(this,$).updateMode(O);const{offsetX:j,offsetY:q}=it(this,P,cl).call(this),L=this.getNextId(),F=it(this,P,ll).call(this,{parent:this,id:L,x:j,y:q,uiManager:He(this,$),isCentered:!0,...H});F&&this.add(F)}deserialize(O){switch(O.annotationType??O.annotationEditorType){case u.AnnotationEditorType.FREETEXT:return p.FreeTextEditor.deserialize(O,this,He(this,$));case u.AnnotationEditorType.INK:return v.InkEditor.deserialize(O,this,He(this,$));case u.AnnotationEditorType.STAMP:return b.StampEditor.deserialize(O,this,He(this,$))}return null}addNewEditor(){it(this,P,xo).call(this,it(this,P,cl).call(this),!0)}setSelected(O){He(this,$).setSelected(O)}toggleSelected(O){He(this,$).toggleSelected(O)}isSelected(O){return He(this,$).isSelected(O)}unselect(O){He(this,$).unselect(O)}pointerup(O){const{isMac:H}=u.FeatureTest.platform;if(!(O.button!==0||O.ctrlKey&&H)&&O.target===this.div&&He(this,w)){if(Ct(this,w,!1),!He(this,y)){Ct(this,y,!0);return}if(He(this,$).getMode()===u.AnnotationEditorType.STAMP){He(this,$).unselectAll();return}it(this,P,xo).call(this,O,!1)}}pointerdown(O){if(He(this,w)){Ct(this,w,!1);return}const{isMac:H}=u.FeatureTest.platform;if(O.button!==0||O.ctrlKey&&H||O.target!==this.div)return;Ct(this,w,!0);const j=He(this,$).getActive();Ct(this,y,!j||j.isEmpty())}findNewParent(O,H,j){const q=He(this,$).findParent(H,j);return q===null||q===this?!1:(q.changeParent(O),!0)}destroy(){var O,H;((O=He(this,$).getActive())==null?void 0:O.parent)===this&&(He(this,$).commitOrRemove(),He(this,$).setActiveEditor(null));for(const j of He(this,S).values())(H=He(this,x))==null||H.removePointerInTextLayer(j.contentDiv),j.setParent(null),j.isAttachedToDOM=!1,j.div.remove();this.div=null,He(this,S).clear(),He(this,$).removeLayer(this)}render({viewport:O}){this.viewport=O,(0,A.setLayerDimensions)(this.div,O);for(const H of He(this,$).getEditors(this.pageIndex))this.add(H);this.updateMode()}update({viewport:O}){He(this,$).commitOrRemove(),this.viewport=O,(0,A.setLayerDimensions)(this.div,{rotation:O.rotation}),this.updateMode()}get pageDimensions(){const{pageWidth:O,pageHeight:H}=this.viewport.rawDims;return[O,H]}};x=new WeakMap,y=new WeakMap,f=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakMap,w=new WeakMap,_=new WeakMap,I=new WeakMap,$=new WeakMap,P=new WeakSet,ll=function(O){switch(He(this,$).getMode()){case u.AnnotationEditorType.FREETEXT:return new p.FreeTextEditor(O);case u.AnnotationEditorType.INK:return new v.InkEditor(O);case u.AnnotationEditorType.STAMP:return new b.StampEditor(O)}return null},xo=function(O,H){const j=this.getNextId(),q=it(this,P,ll).call(this,{parent:this,id:j,x:O.offsetX,y:O.offsetY,uiManager:He(this,$),isCentered:H});return q&&this.add(q),q},cl=function(){const{x:O,y:H,width:j,height:q}=this.div.getBoundingClientRect(),L=Math.max(0,O),F=Math.max(0,H),U=Math.min(window.innerWidth,O+j),N=Math.min(window.innerHeight,H+q),D=(L+U)/2-O,W=(F+N)/2-H,[Z,Q]=this.viewport.rotation%180===0?[D,W]:[W,D];return{offsetX:Z,offsetY:Q}},ul=function(){Ct(this,_,!0);for(const O of He(this,S).values())O.isEmpty()&&O.remove();Ct(this,_,!1)},yr(M,"_initialized",!1);let g=M;s.AnnotationEditorLayer=g},(a,s,c)=>{var b,g,x,y,f,m,C,S,w,_,ku,Fu,Nu,vi,dl,Lu,fl;Object.defineProperty(s,"__esModule",{value:!0}),s.FreeTextEditor=void 0;var u=c(1),d=c(5),p=c(4),v=c(29);const M=class M extends p.AnnotationEditor{constructor(H){super({...H,name:"freeTextEditor"});bt(this,_);bt(this,b,this.editorDivBlur.bind(this));bt(this,g,this.editorDivFocus.bind(this));bt(this,x,this.editorDivInput.bind(this));bt(this,y,this.editorDivKeydown.bind(this));bt(this,f);bt(this,m,"");bt(this,C,`${this.id}-editor`);bt(this,S);bt(this,w,null);Ct(this,f,H.color||M._defaultColor||p.AnnotationEditor._defaultLineColor),Ct(this,S,H.fontSize||M._defaultFontSize)}static get _keyboardManager(){const H=M.prototype,j=F=>F.isEmpty(),q=d.AnnotationEditorUIManager.TRANSLATE_SMALL,L=d.AnnotationEditorUIManager.TRANSLATE_BIG;return(0,u.shadow)(this,"_keyboardManager",new d.KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],H.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],H.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],H._translateEmpty,{args:[-q,0],checker:j}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],H._translateEmpty,{args:[-L,0],checker:j}],[["ArrowRight","mac+ArrowRight"],H._translateEmpty,{args:[q,0],checker:j}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],H._translateEmpty,{args:[L,0],checker:j}],[["ArrowUp","mac+ArrowUp"],H._translateEmpty,{args:[0,-q],checker:j}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],H._translateEmpty,{args:[0,-L],checker:j}],[["ArrowDown","mac+ArrowDown"],H._translateEmpty,{args:[0,q],checker:j}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],H._translateEmpty,{args:[0,L],checker:j}]]))}static initialize(H){p.AnnotationEditor.initialize(H,{strings:["free_text2_default_content","editor_free_text2_aria_label"]});const j=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(j.getPropertyValue("--freetext-padding"))}static updateDefaultParams(H,j){switch(H){case u.AnnotationEditorParamsType.FREETEXT_SIZE:M._defaultFontSize=j;break;case u.AnnotationEditorParamsType.FREETEXT_COLOR:M._defaultColor=j;break}}updateParams(H,j){switch(H){case u.AnnotationEditorParamsType.FREETEXT_SIZE:it(this,_,ku).call(this,j);break;case u.AnnotationEditorParamsType.FREETEXT_COLOR:it(this,_,Fu).call(this,j);break}}static get defaultPropertiesToUpdate(){return[[u.AnnotationEditorParamsType.FREETEXT_SIZE,M._defaultFontSize],[u.AnnotationEditorParamsType.FREETEXT_COLOR,M._defaultColor||p.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[u.AnnotationEditorParamsType.FREETEXT_SIZE,He(this,S)],[u.AnnotationEditorParamsType.FREETEXT_COLOR,He(this,f)]]}_translateEmpty(H,j){this._uiManager.translateSelectedEditors(H,j,!0)}getInitialTranslation(){const H=this.parentScale;return[-M._internalPadding*H,-(M._internalPadding+He(this,S))*H]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){this.isInEditMode()||(this.parent.setEditingState(!1),this.parent.updateToolbar(u.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.editorDiv.addEventListener("keydown",He(this,y)),this.editorDiv.addEventListener("focus",He(this,g)),this.editorDiv.addEventListener("blur",He(this,b)),this.editorDiv.addEventListener("input",He(this,x)))}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",He(this,C)),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",He(this,y)),this.editorDiv.removeEventListener("focus",He(this,g)),this.editorDiv.removeEventListener("blur",He(this,b)),this.editorDiv.removeEventListener("input",He(this,x)),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freeTextEditing"))}focusin(H){this._focusEventsAllowed&&(super.focusin(H),H.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var H;if(this.width){it(this,_,fl).call(this);return}this.enableEditMode(),this.editorDiv.focus(),(H=this._initialOptions)!=null&&H.isCentered&&this.center(),this._initialOptions=null}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freeTextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const H=He(this,m),j=Ct(this,m,it(this,_,Nu).call(this).trimEnd());if(H===j)return;const q=L=>{if(Ct(this,m,L),!L){this.remove();return}it(this,_,dl).call(this),this._uiManager.rebuild(this),it(this,_,vi).call(this)};this.addCommands({cmd:()=>{q(j)},undo:()=>{q(H)},mustExec:!1}),it(this,_,vi).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(H){this.enterInEditMode()}keydown(H){H.target===this.div&&H.key==="Enter"&&(this.enterInEditMode(),H.preventDefault())}editorDivKeydown(H){M._keyboardManager.exec(this,H)}editorDivFocus(H){this.isEditing=!0}editorDivBlur(H){this.isEditing=!1}editorDivInput(H){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)}render(){if(this.div)return this.div;let H,j;this.width&&(H=this.x,j=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",He(this,C)),this.enableEditing(),p.AnnotationEditor._l10nPromise.get("editor_free_text2_aria_label").then(L=>{var F;return(F=this.editorDiv)==null?void 0:F.setAttribute("aria-label",L)}),p.AnnotationEditor._l10nPromise.get("free_text2_default_content").then(L=>{var F;return(F=this.editorDiv)==null?void 0:F.setAttribute("default-content",L)}),this.editorDiv.contentEditable=!0;const{style:q}=this.editorDiv;if(q.fontSize=`calc(${He(this,S)}px * var(--scale-factor))`,q.color=He(this,f),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),(0,d.bindEvents)(this,this.div,["dblclick","keydown"]),this.width){const[L,F]=this.parentDimensions;if(this.annotationElementId){const{position:U}=He(this,w);let[N,D]=this.getInitialTranslation();[N,D]=this.pageTranslationToScreen(N,D);const[W,Z]=this.pageDimensions,[Q,Y]=this.pageTranslation;let J,ee;switch(this.rotation){case 0:J=H+(U[0]-Q)/W,ee=j+this.height-(U[1]-Y)/Z;break;case 90:J=H+(U[0]-Q)/W,ee=j-(U[1]-Y)/Z,[N,D]=[D,-N];break;case 180:J=H-this.width+(U[0]-Q)/W,ee=j-(U[1]-Y)/Z,[N,D]=[-N,-D];break;case 270:J=H+(U[0]-Q-this.height*Z)/W,ee=j+(U[1]-Y-this.width*W)/Z,[N,D]=[-D,N];break}this.setAt(J*L,ee*F,N,D)}else this.setAt(H*L,j*F,this.width*L,this.height*F);it(this,_,dl).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}get contentDiv(){return this.editorDiv}static deserialize(H,j,q){let L=null;if(H instanceof v.FreeTextAnnotationElement){const{data:{defaultAppearanceData:{fontSize:U,fontColor:N},rect:D,rotation:W,id:Z},textContent:Q,textPosition:Y,parent:{page:{pageNumber:J}}}=H;if(!Q||Q.length===0)return null;L=H={annotationType:u.AnnotationEditorType.FREETEXT,color:Array.from(N),fontSize:U,value:Q.join(`
|
@@ -183,7 +183,7 @@ endstream`,s}copyBytesInto(s,c){this.updateDict();const u=c;c+=this.dict.copyByt
|
|
183
183
|
* This source code is licensed under the ISC license.
|
184
184
|
* See the LICENSE file in the root directory of this source tree.
|
185
185
|
*/const Underline=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20"}]],TextStrikethroughIcon=createSvgStr(Strikethrough),TextUnderlineIcon=createSvgStr(Underline),TextAlignLeftIcon=createSvgStr(AlignLeft),TextAlignCenterIcon=createSvgStr(AlignCenter),TextAlignRightIcon=createSvgStr(AlignRight),TextAlignJustifyIcon=createSvgStr(AlignJustify),TextVerticalAlignTopIcon=createSvgStr(ArrowUpToLine),TextVerticalAlignMiddleIcon='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><path d="M8 19h3v4h2v-4h3l-4-4l-4 4zm8-14h-3V1h-2v4H8l4 4l4-4zM4 11v2h16v-2H4z" fill="currentColor"></path></svg>',TextVerticalAlignBottomIcon=createSvgStr(ArrowDownToLine);var Formatter;(function(a){a.STRIKETHROUGH="strikethrough",a.UNDERLINE="underline",a.ALIGNMENT="alignment",a.VERTICAL_ALIGNMENT="verticalAlignment"})(Formatter||(Formatter={}));function getExtraFormatterSchema(a){const s=[{key:Formatter.STRIKETHROUGH,icon:TextStrikethroughIcon,type:"boolean"},{key:Formatter.UNDERLINE,icon:TextUnderlineIcon,type:"boolean"},{key:Formatter.ALIGNMENT,icon:TextAlignLeftIcon,type:"select",value:DEFAULT_ALIGNMENT},{key:Formatter.ALIGNMENT,icon:TextAlignCenterIcon,type:"select",value:ALIGN_CENTER},{key:Formatter.ALIGNMENT,icon:TextAlignRightIcon,type:"select",value:ALIGN_RIGHT},{key:Formatter.ALIGNMENT,icon:TextAlignJustifyIcon,type:"select",value:ALIGN_JUSTIFY},{key:Formatter.VERTICAL_ALIGNMENT,icon:TextVerticalAlignTopIcon,type:"select",value:DEFAULT_VERTICAL_ALIGNMENT},{key:Formatter.VERTICAL_ALIGNMENT,icon:TextVerticalAlignMiddleIcon,type:"select",value:VERTICAL_ALIGN_MIDDLE},{key:Formatter.VERTICAL_ALIGNMENT,icon:TextVerticalAlignBottomIcon,type:"select",value:VERTICAL_ALIGN_BOTTOM}];return{title:a("schemas.text.format"),widget:"ButtonGroup",buttons:s,span:24}}const UseDynamicFontSize=a=>{const{rootElement:s,changeSchemas:c,activeSchema:u,i18n:d}=a,p=document.createElement("input");p.type="checkbox",p.checked=!!(u!=null&&u.dynamicFontSize),p.onchange=b=>{const g=b.target.checked?{min:DEFAULT_DYNAMIC_MIN_FONT_SIZE,max:DEFAULT_DYNAMIC_MAX_FONT_SIZE,fit:DEFAULT_DYNAMIC_FIT}:void 0;c([{key:"dynamicFontSize",value:g,schemaId:u.id}])};const v=document.createElement("label"),A=document.createElement("span");A.innerText=d("schemas.text.dynamicFontSize")||"",A.style.cssText="margin-left: 0.5rem",v.style.cssText="display: flex; width: 100%;",v.appendChild(p),v.appendChild(A),s.appendChild(v)},propPanel={schema:({options:a,activeSchema:s,i18n:c})=>{const u=a.font||{[DEFAULT_FONT_NAME]:{data:"",fallback:!0}},d=Object.keys(u),p=getFallbackFontName(u),v=!!(s!=null&&s.dynamicFontSize);return{fontName:{title:c("schemas.text.fontName"),type:"string",widget:"select",default:p,placeholder:p,props:{options:d.map(b=>({label:b,value:b}))},span:12},fontSize:{title:c("schemas.text.size"),type:"number",widget:"inputNumber",span:6,disabled:v,props:{min:0}},characterSpacing:{title:c("schemas.text.spacing"),type:"number",widget:"inputNumber",span:6,props:{min:0}},formatter:getExtraFormatterSchema(c),lineHeight:{title:c("schemas.text.lineHeight"),type:"number",widget:"inputNumber",props:{step:.1,min:0},span:8},useDynamicFontSize:{type:"boolean",widget:"UseDynamicFontSize",bind:!1,span:16},dynamicFontSize:{type:"object",widget:"card",column:3,properties:{min:{title:c("schemas.text.min"),type:"number",widget:"inputNumber",hidden:!v,props:{min:0}},max:{title:c("schemas.text.max"),type:"number",widget:"inputNumber",hidden:!v,props:{min:0}},fit:{title:c("schemas.text.fit"),type:"string",widget:"select",hidden:!v,props:{options:[{label:c("schemas.horizontal"),value:DYNAMIC_FIT_HORIZONTAL},{label:c("schemas.vertical"),value:DYNAMIC_FIT_VERTICAL}]}}}},fontColor:{title:c("schemas.textColor"),type:"string",widget:"color",props:{disabledAlpha:!0},rules:[{pattern:HEX_COLOR_PATTERN,message:c("validation.hexColor")}]},backgroundColor:{title:c("schemas.bgColor"),type:"string",widget:"color",props:{disabledAlpha:!0},rules:[{pattern:HEX_COLOR_PATTERN,message:c("validation.hexColor")}]}}},widgets:{UseDynamicFontSize},defaultSchema:{name:"",type:"text",content:"Type Something...",position:{x:0,y:0},width:45,height:10,rotate:0,alignment:DEFAULT_ALIGNMENT,verticalAlignment:DEFAULT_VERTICAL_ALIGNMENT,fontSize:DEFAULT_FONT_SIZE,lineHeight:DEFAULT_LINE_HEIGHT,characterSpacing:DEFAULT_CHARACTER_SPACING,dynamicFontSize:void 0,fontColor:DEFAULT_FONT_COLOR,fontName:void 0,backgroundColor:"",opacity:DEFAULT_OPACITY,strikethrough:!1,underline:!1}},replaceUnsupportedChars=(a,s)=>{const c={},u=p=>{if(p in c)return c[p];const v=s.hasGlyphForCodePoint(p.codePointAt(0)||0);return c[p]=v,v};return a.split(/(\r\n|\n|\r)/).map(p=>/\r\n|\n|\r/.test(p)?p:p.split("").map(v=>/\s/.test(v)||v.charCodeAt(0)<32||u(v)?v:"〿").join("")).join("")},uiRender=async a=>{const{value:s,schema:c,mode:u,onChange:d,stopEditing:p,tabIndex:v,placeholder:A,options:b,_cache:g}=a,x=isEditable(u,c)&&A&&!s,y=w=>{let _=w.innerText;return _.endsWith(`
|
186
|
-
`)&&(_=_.slice(0,-1)),_},f=(b==null?void 0:b.font)||getDefaultFont(),m=await getFontKitFont(c.fontName,f,g),C=buildStyledTextContainer(a,m,x?A:s),S=replaceUnsupportedChars(s,m);if(!isEditable(u,c)){C.innerHTML=S.split("").map((w,_)=>`<span style="letter-spacing:${String(s).length===_+1?0:"inherit"};">${w}</span>`).join("");return}if(makeElementPlainTextContentEditable(C),C.tabIndex=v||0,C.innerText=u==="designer"?s:S,C.addEventListener("blur",w=>{d&&d({key:"content",value:y(w.target)}),p&&p()}),c.dynamicFontSize){let w;C.addEventListener("keyup",()=>{setTimeout(()=>{(()=>{if(!C.textContent)return;w=calculateDynamicFontSize({textSchema:c,fontKitFont:m,value:y(C),startingFontSize:w}),C.style.fontSize=`${w}pt`;const{topAdj:_,bottomAdj:I}=getBrowserVerticalFontAdjustments(m,w??c.fontSize??DEFAULT_FONT_SIZE,c.lineHeight??DEFAULT_LINE_HEIGHT,c.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT);C.style.paddingTop=`${_}px`,C.style.marginBottom=`${I}px`})()},0)})}x&&(C.style.color=PLACEHOLDER_FONT_COLOR,C.addEventListener("focus",()=>{C.innerText===A&&(C.innerText="",C.style.color=c.fontColor??DEFAULT_FONT_COLOR)})),u==="designer"&&setTimeout(()=>{C.focus();const w=window.getSelection(),_=document.createRange();w&&_&&(_.selectNodeContents(C),_.collapse(!1),w==null||w.removeAllRanges(),w==null||w.addRange(_))})},buildStyledTextContainer=(a,s,c)=>{const{schema:u,rootElement:d,mode:p}=a;let v;u.dynamicFontSize&&c&&(v=calculateDynamicFontSize({textSchema:u,fontKitFont:s,value:c,startingFontSize:v}));const{topAdj:A,bottomAdj:b}=getBrowserVerticalFontAdjustments(s,v??u.fontSize??DEFAULT_FONT_SIZE,u.lineHeight??DEFAULT_LINE_HEIGHT,u.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT),g=A.toString(),x=b.toString(),y=document.createElement("div"),f={padding:0,resize:"none",backgroundColor:getBackgroundColor(c,u),border:"none",display:"flex",flexDirection:"column",justifyContent:mapVerticalAlignToFlex(u.verticalAlignment),width:"100%",height:"100%",cursor:isEditable(p,u)?"text":"default"};Object.assign(y.style,f),d.innerHTML="",d.appendChild(y);const m=[];u.strikethrough&&m.push("line-through"),u.underline&&m.push("underline");const C={fontFamily:u.fontName?`'${u.fontName}'`:"inherit",color:u.fontColor?u.fontColor:DEFAULT_FONT_COLOR,fontSize:`${v??u.fontSize??DEFAULT_FONT_SIZE}pt`,letterSpacing:`${u.characterSpacing??DEFAULT_CHARACTER_SPACING}pt`,lineHeight:`${u.lineHeight??DEFAULT_LINE_HEIGHT}em`,textAlign:u.alignment??DEFAULT_ALIGNMENT,whiteSpace:"pre-wrap",wordBreak:"break-word",resize:"none",border:"none",outline:"none",marginBottom:`${x}px`,paddingTop:`${g}px`,backgroundColor:"transparent",textDecoration:m.join(" ")},S=document.createElement("div");return S.id="text-"+String(u.id),Object.assign(S.style,C),y.appendChild(S),S},makeElementPlainTextContentEditable=a=>{if(!isFirefox()){a.contentEditable="plaintext-only";return}a.contentEditable="true",a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),document.execCommand("insertLineBreak",!1,void 0))}),a.addEventListener("paste",s=>{var d;s.preventDefault();const c=(d=s.clipboardData)==null?void 0:d.getData("text"),u=window.getSelection();u!=null&&u.rangeCount&&(u.deleteFromDocument(),u.getRangeAt(0).insertNode(document.createTextNode(c||"")),u.collapseToEnd())})},mapVerticalAlignToFlex=a=>{switch(a){case VERTICAL_ALIGN_TOP:return"flex-start";case VERTICAL_ALIGN_MIDDLE:return"center";case VERTICAL_ALIGN_BOTTOM:return"flex-end"}return"flex-start"},getBackgroundColor=(a,s)=>!a||!s.backgroundColor?"transparent":s.backgroundColor,textSchema={pdf:pdfRender,ui:uiRender,propPanel,icon:createSvgStr(TextCursorInput)},builtInPlugins={Text:textSchema},I18nContext=reactExports.createContext(i18n),FontContext=reactExports.createContext(getDefaultFont()),PluginsRegistry=reactExports.createContext(builtInPlugins),OptionsContext=reactExports.createContext({}),CacheContext=reactExports.createContext(new Map),hotkeys=function(a,s){return hotkeys$1(a,s)};hotkeys.shift=!1,hotkeys.unbind=function(a){const s=hotkeys$1;typeof s.unbind=="function"&&s.unbind(a)};const uuid$6=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const s=Math.random()*16|0;return(a=="x"?s:s&3|8).toString(16)}),set$2=(a,s,c)=>{s=Array.isArray(s)?s:s.replace("[",".").replace("]","").split(".");let u=a;s.forEach((d,p,v)=>{if(p==s.length-1)u[d]=c;else{if(!Object.prototype.hasOwnProperty.call(u,d)){const A=v[p+1];u[d]=String(Number(A))===A?[]:{}}u=u[d]}})},debounce$1=(a,s=20)=>{let c=null;return(...d)=>{c&&clearTimeout(c),c=setTimeout(()=>a(...d),s)}},shift=(a,s,c)=>{c&&(s=-s);const u=`${a}`.split("e");return+`${u[0]}e${u[1]?Number(u[1])+s:s}`},round$1=(a,s)=>shift(Math.round(shift(a,s,!1)),s,!0),flatten=a=>[].concat(...a),up="up",shiftUp="shift+up",down="down",shiftDown="shift+down",left="left",shiftLeft="shift+left",right="right",shiftRight="shift+right",rmWin="backspace",rmMac="delete",esc="esc",copyWin="ctrl+c",copyMac="command+c",pasteWin="ctrl+v",pasteMac="command+v",redoWin="ctrl+y",redoMac="shift+command+z",undoWin="ctrl+z",undoMac="command+z",saveWin="ctrl+s",saveMac="command+s",selectAllWin="ctrl+a",selectAllMac="command+a",keys$2=[up,shiftUp,down,shiftDown,left,shiftLeft,right,shiftRight,rmMac,rmWin,esc,copyWin,copyMac,pasteWin,pasteMac,redoWin,redoMac,undoWin,undoMac,saveWin,saveMac,selectAllWin,selectAllMac],initShortCuts=a=>{hotkeys(keys$2.join(),(s,c)=>{switch(c.shortcut){case up:case shiftUp:s.preventDefault(),a.move("up",hotkeys.shift);break;case down:case shiftDown:s.preventDefault(),a.move("down",hotkeys.shift);break;case left:case shiftLeft:s.preventDefault(),a.move("left",hotkeys.shift);break;case right:case shiftRight:s.preventDefault(),a.move("right",hotkeys.shift);break;case rmWin:case rmMac:a.remove();break;case esc:a.esc();break;case copyWin:case copyMac:a.copy();break;case pasteWin:case pasteMac:a.paste();break;case redoWin:case redoMac:a.redo();break;case undoWin:case undoMac:a.undo();break;case saveWin:case saveMac:s.preventDefault(),a.save();break;case selectAllWin:case selectAllMac:s.preventDefault(),a.selectAll();break}})},destroyShortCuts=()=>{hotkeys.unbind(keys$2.join())};function detectMimeType(a){const s=new DataView(a);return s.getUint8(0)===137&&s.getUint8(1)===80&&s.getUint8(2)===78&&s.getUint8(3)===71?"image/png":s.getUint8(0)===255&&s.getUint8(1)===216&&s.getUint8(2)===255?"image/jpeg":""}const arrayBufferToBase64=a=>{const s=detectMimeType(a),c=new Uint8Array(a);let u="";for(let p=0;p<c.length;p++)u+=String.fromCharCode(c[p]);const d=btoa(u);return s?`data:${s};base64,${d}`:`data:application/octet-stream;base64,${d}`},convertSchemasForUI=a=>(a.schemas.forEach(s=>{s.forEach(c=>{c.id=uuid$6(),c.content=c.content||""})}),a.schemas),template2SchemasList=async a=>{const s=cloneDeep$1(a),{basePdf:c,schemas:u}=s,d=convertSchemasForUI(s);let p=[];if(isBlankPdf(c))p=u.map(()=>({width:c.width,height:c.height}));else{const b=await getB64BasePdf(c),g=b64toUint8Array(b);p=await pdf2size(g)}const v=d.length,A=p.length;return(v<A?d.concat(new Array(A-v).fill(cloneDeep$1([]))):d.slice(0,p.length)).map((b,g)=>(Object.values(b).forEach(x=>{const{width:y,height:f}=p[g],m=x.position.x+x.width,C=x.position.y+x.height;if(y<m){const S=m-y;x.position.x+=S}if(f<C){const S=C-f;x.position.y+=S}}),b))},schemasList2template=(a,s)=>({schemas:cloneDeep$1(a).map(c=>c.map(u=>(delete u.id,u))),basePdf:s}),getUniqueSchemaName=a=>{const{copiedSchemaName:s,schema:c,stackUniqueSchemaNames:u}=a,d=c.map(g=>g.name).concat(u),p=d.reduce((g,x)=>Object.assign(g,{originalName:x,copiedNum:0}),{}),v=g=>g.replace(/ copy$| copy [0-9]*$/,"");d.filter(g=>/ copy$| copy [0-9]*$/.test(g)).forEach(g=>{const x=v(g),y=g.match(/[0-9]*$/),f=y&&y[0]?Number(y[0]):1;(p[x]??0)<f&&(p[x]=f)});const A=v(s);if(p[A]){const g=p[A],x=`${A} copy ${g+1}`;return u.push(x),x}const b=`${s} copy`;return u.push(b),b},moveCommandToChangeSchemasArg=a=>{const{command:s,activeSchemas:c,isShift:u,pageSize:d}=a,p=s==="up"||s==="down"?"y":"x",v=u?.1:1,A=b=>{let g=0;const{position:x}=b;switch(s){case"up":g=round$1(x.y-v,2);break;case"down":g=round$1(x.y+v,2);break;case"left":g=round$1(x.x-v,2);break;case"right":g=round$1(x.x+v,2);break}return g>0?g:0};return c.map(b=>{let g=A(b);const{width:x,height:y}=b;return p==="x"?g=g>d.width-x?round$1(d.width-x,2):g:g=g>d.height-y?round$1(d.height-y,2):g,{key:`position.${p}`,value:g,schemaId:b.id}})},getPagesScrollTopByIndex=(a,s,c)=>a.slice(0,s).reduce((u,d)=>u+(d.height*ZOOM+RULER_HEIGHT*c)*c,0),getSidebarContentHeight=a=>a-RULER_HEIGHT-RULER_HEIGHT/2-30,handlePositionSizeChange=(a,s,c,u,d)=>{const p=isBlankPdf(u)?u.padding:[0,0,0,0],[v,A,b,g]=p,{width:x,height:y}=d,f=(m,C,S)=>Math.min(Math.max(Number(m),C),S);s==="position.x"?a.position.x=f(c,g,x-a.width-A):s==="position.y"?a.position.y=f(c,v,y-a.height-b):s==="width"?a.width=f(c,0,x-a.position.x-A):s==="height"&&(a.height=f(c,0,y-a.position.y-b))},handleTypeChange=(a,s,c,u)=>{if(s!=="type")return;const d=["id","name","type","position","required"];Object.keys(a).forEach(g=>{d.includes(g)||delete a[g]});const p=c;let v;const A=Object.entries(u);for(let g=0;g<A.length;g++){const[,x]=A[g];if(!x||typeof x!="object"||!("propPanel"in x)||!x.propPanel||typeof x.propPanel!="object")continue;const y=x.propPanel;if(!("defaultSchema"in y)||!y.defaultSchema||typeof y.defaultSchema!="object")continue;const f=y.defaultSchema;if(!("type"in f)||typeof f.type!="string")continue;const m=f.type;if(m===p){const C={type:m};Object.keys(f).forEach(S=>{S!=="type"&&Object.prototype.hasOwnProperty.call(f,S)&&(C[S]=f[S])}),v={propPanel:{defaultSchema:C}};break}}const b=v==null?void 0:v.propPanel;if(b!=null&&b.defaultSchema){const g=b.defaultSchema,x=a;for(const y of Object.keys(g))if(!Object.prototype.hasOwnProperty.call(a,y)&&Object.prototype.hasOwnProperty.call(g,y)){const f=g[y];f!==void 0&&(x[y]=f)}}a.readOnly&&(a.required=!1)},changeSchemas=a=>{const{objs:s,schemas:c,basePdf:u,pluginsRegistry:d,pageSize:p,commitSchemas:v}=a,A=s.reduce((b,{key:g,value:x,schemaId:y})=>{const f=b.find(m=>m.id===y);return f&&(set$2(f,g,x),g==="type"?handleTypeChange(f,g,x,d):["position.x","position.y","width","height"].includes(g)&&handlePositionSizeChange(f,g,x,u,p)),b},cloneDeep$1(c));v(A)},useMaxZoom=()=>{const a=reactExports.useContext(OptionsContext);return a.maxZoom?a.maxZoom/100:DEFAULT_MAX_ZOOM};class BaseUIClass{constructor(s){this.lang=DEFAULT_LANG,this.font=getDefaultFont(),this.pluginsRegistry=builtInPlugins,this.options={},this.setSize=debounce$1(()=>{this.domContainer&&(this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.render())},100),this.resizeObserver=new ResizeObserver(this.setSize),checkUIProps(s);const{domContainer:c,template:u,options:d={},plugins:p={}}=s;this.domContainer=c,this.template=cloneDeep$1(u),this.options=d,this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.resizeObserver.observe(this.domContainer);const{lang:v,font:A}=d;v&&(this.lang=v),A&&(this.font=A),Object.values(p).length>0&&(this.pluginsRegistry=p)}getLang(){return this.lang}getFont(){return this.font}getPluginsRegistry(){return this.pluginsRegistry}getOptions(){return this.options}getTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$1(s),this.render()}updateOptions(s){checkUIOptions(s);const{lang:c,font:u}=s||{};c&&(this.lang=c),u&&(this.font=u),this.options=Object.assign(this.options,s),this.render()}destroy(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.unmountComponentAtNode(this.domContainer),this.resizeObserver.unobserve(this.domContainer),this.domContainer=null}}class PreviewUI extends BaseUIClass{constructor(s){super(s),checkPreviewProps(s),this.inputs=convertToStingObjectArray(cloneDeep$1(s.inputs))}getInputs(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.inputs}setInputs(s){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);checkInputs(s),this.inputs=convertToStingObjectArray(s),this.render()}}function convertToStingObjectArray(a){return a.map(s=>{const c={};return Object.keys(s).forEach(u=>{const d=s[u];Array.isArray(d)?c[u]=JSON.stringify(d):c[u]=d}),c})}function useCombinedRefs(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return reactExports.useMemo(()=>u=>{s.forEach(d=>d(u))},s)}const canUseDOM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function isWindow$4(a){const s=Object.prototype.toString.call(a);return s==="[object Window]"||s==="[object global]"}function isNode$1(a){return"nodeType"in a}function getWindow$1(a){var s,c;return a?isWindow$4(a)?a:isNode$1(a)&&(s=(c=a.ownerDocument)==null?void 0:c.defaultView)!=null?s:window:window}function isDocument(a){const{Document:s}=getWindow$1(a);return a instanceof s}function isHTMLElement(a){return isWindow$4(a)?!1:a instanceof getWindow$1(a).HTMLElement}function isSVGElement(a){return a instanceof getWindow$1(a).SVGElement}function getOwnerDocument(a){return a?isWindow$4(a)?a.document:isNode$1(a)?isDocument(a)?a:isHTMLElement(a)||isSVGElement(a)?a.ownerDocument:document:document:document}const useIsomorphicLayoutEffect$1=canUseDOM?reactExports.useLayoutEffect:reactExports.useEffect;function useEvent$1(a){const s=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{s.current=a}),reactExports.useCallback(function(){for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];return s.current==null?void 0:s.current(...u)},[])}function useInterval(){const a=reactExports.useRef(null),s=reactExports.useCallback((u,d)=>{a.current=setInterval(u,d)},[]),c=reactExports.useCallback(()=>{a.current!==null&&(clearInterval(a.current),a.current=null)},[]);return[s,c]}function useLatestValue(a,s){s===void 0&&(s=[a]);const c=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{c.current!==a&&(c.current=a)},s),c}function useLazyMemo(a,s){const c=reactExports.useRef();return reactExports.useMemo(()=>{const u=a(c.current);return c.current=u,u},[...s])}function useNodeRef(a){const s=useEvent$1(a),c=reactExports.useRef(null),u=reactExports.useCallback(d=>{d!==c.current&&(s==null||s(d,c.current)),c.current=d},[]);return[c,u]}function usePrevious$2(a){const s=reactExports.useRef();return reactExports.useEffect(()=>{s.current=a},[a]),s.current}let ids={};function useUniqueId(a,s){return reactExports.useMemo(()=>{if(s)return s;const c=ids[a]==null?0:ids[a]+1;return ids[a]=c,a+"-"+c},[a,s])}function createAdjustmentFn(a){return function(s){for(var c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];return u.reduce((p,v)=>{const A=Object.entries(v);for(const[b,g]of A){const x=p[b];x!=null&&(p[b]=x+a*g)}return p},{...s})}}const add$1=createAdjustmentFn(1),subtract=createAdjustmentFn(-1);function hasViewportRelativeCoordinates(a){return"clientX"in a&&"clientY"in a}function isKeyboardEvent(a){if(!a)return!1;const{KeyboardEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function isTouchEvent(a){if(!a)return!1;const{TouchEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function getEventCoordinates(a){if(isTouchEvent(a)){if(a.touches&&a.touches.length){const{clientX:s,clientY:c}=a.touches[0];return{x:s,y:c}}else if(a.changedTouches&&a.changedTouches.length){const{clientX:s,clientY:c}=a.changedTouches[0];return{x:s,y:c}}}return hasViewportRelativeCoordinates(a)?{x:a.clientX,y:a.clientY}:null}const CSS$1=Object.freeze({Translate:{toString(a){if(!a)return;const{x:s,y:c}=a;return"translate3d("+(s?Math.round(s):0)+"px, "+(c?Math.round(c):0)+"px, 0)"}},Scale:{toString(a){if(!a)return;const{scaleX:s,scaleY:c}=a;return"scaleX("+s+") scaleY("+c+")"}},Transform:{toString(a){if(a)return[CSS$1.Translate.toString(a),CSS$1.Scale.toString(a)].join(" ")}},Transition:{toString(a){let{property:s,duration:c,easing:u}=a;return s+" "+c+"ms "+u}}}),SELECTOR="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function findFirstFocusableNode(a){return a.matches(SELECTOR)?a:a.querySelector(SELECTOR)}const hiddenStyles={display:"none"};function HiddenText(a){let{id:s,value:c}=a;return React.createElement("div",{id:s,style:hiddenStyles},c)}function LiveRegion(a){let{id:s,announcement:c,ariaLiveType:u="assertive"}=a;const d={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return React.createElement("div",{id:s,style:d,role:"status","aria-live":u,"aria-atomic":!0},c)}function useAnnouncement(){const[a,s]=reactExports.useState("");return{announce:reactExports.useCallback(u=>{u!=null&&s(u)},[]),announcement:a}}const DndMonitorContext=reactExports.createContext(null);function useDndMonitor(a){const s=reactExports.useContext(DndMonitorContext);reactExports.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(a)},[a,s])}function useDndMonitorProvider(){const[a]=reactExports.useState(()=>new Set),s=reactExports.useCallback(u=>(a.add(u),()=>a.delete(u)),[a]);return[reactExports.useCallback(u=>{let{type:d,event:p}=u;a.forEach(v=>{var A;return(A=v[d])==null?void 0:A.call(v,p)})},[a]),s]}const defaultScreenReaderInstructions={draggable:`
|
186
|
+
`)&&(_=_.slice(0,-1)),_},f=(b==null?void 0:b.font)||getDefaultFont(),m=await getFontKitFont(c.fontName,f,g),C=buildStyledTextContainer(a,m,x?A:s),S=replaceUnsupportedChars(s,m);if(!isEditable(u,c)){C.innerHTML=S.split("").map((w,_)=>`<span style="letter-spacing:${String(s).length===_+1?0:"inherit"};">${w}</span>`).join("");return}if(makeElementPlainTextContentEditable(C),C.tabIndex=v||0,C.innerText=u==="designer"?s:S,C.addEventListener("blur",w=>{d&&d({key:"content",value:y(w.target)}),p&&p()}),c.dynamicFontSize){let w;C.addEventListener("keyup",()=>{setTimeout(()=>{(()=>{if(!C.textContent)return;w=calculateDynamicFontSize({textSchema:c,fontKitFont:m,value:y(C),startingFontSize:w}),C.style.fontSize=`${w}pt`;const{topAdj:_,bottomAdj:I}=getBrowserVerticalFontAdjustments(m,w??c.fontSize??DEFAULT_FONT_SIZE,c.lineHeight??DEFAULT_LINE_HEIGHT,c.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT);C.style.paddingTop=`${_}px`,C.style.marginBottom=`${I}px`})()},0)})}x&&(C.style.color=PLACEHOLDER_FONT_COLOR,C.addEventListener("focus",()=>{C.innerText===A&&(C.innerText="",C.style.color=c.fontColor??DEFAULT_FONT_COLOR)})),u==="designer"&&setTimeout(()=>{C.focus();const w=window.getSelection(),_=document.createRange();w&&_&&(_.selectNodeContents(C),_.collapse(!1),w==null||w.removeAllRanges(),w==null||w.addRange(_))})},buildStyledTextContainer=(a,s,c)=>{const{schema:u,rootElement:d,mode:p}=a;let v;u.dynamicFontSize&&c&&(v=calculateDynamicFontSize({textSchema:u,fontKitFont:s,value:c,startingFontSize:v}));const{topAdj:A,bottomAdj:b}=getBrowserVerticalFontAdjustments(s,v??u.fontSize??DEFAULT_FONT_SIZE,u.lineHeight??DEFAULT_LINE_HEIGHT,u.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT),g=A.toString(),x=b.toString(),y=document.createElement("div"),f={padding:0,resize:"none",backgroundColor:getBackgroundColor(c,u),border:"none",display:"flex",flexDirection:"column",justifyContent:mapVerticalAlignToFlex(u.verticalAlignment),width:"100%",height:"100%",cursor:isEditable(p,u)?"text":"default"};Object.assign(y.style,f),d.innerHTML="",d.appendChild(y);const m=[];u.strikethrough&&m.push("line-through"),u.underline&&m.push("underline");const C={fontFamily:u.fontName?`'${u.fontName}'`:"inherit",color:u.fontColor?u.fontColor:DEFAULT_FONT_COLOR,fontSize:`${v??u.fontSize??DEFAULT_FONT_SIZE}pt`,letterSpacing:`${u.characterSpacing??DEFAULT_CHARACTER_SPACING}pt`,lineHeight:`${u.lineHeight??DEFAULT_LINE_HEIGHT}em`,textAlign:u.alignment??DEFAULT_ALIGNMENT,whiteSpace:"pre-wrap",wordBreak:"break-word",resize:"none",border:"none",outline:"none",marginBottom:`${x}px`,paddingTop:`${g}px`,backgroundColor:"transparent",textDecoration:m.join(" ")},S=document.createElement("div");return S.id="text-"+String(u.id),Object.assign(S.style,C),y.appendChild(S),S},makeElementPlainTextContentEditable=a=>{if(!isFirefox()){a.contentEditable="plaintext-only";return}a.contentEditable="true",a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),document.execCommand("insertLineBreak",!1,void 0))}),a.addEventListener("paste",s=>{var d;s.preventDefault();const c=(d=s.clipboardData)==null?void 0:d.getData("text"),u=window.getSelection();u!=null&&u.rangeCount&&(u.deleteFromDocument(),u.getRangeAt(0).insertNode(document.createTextNode(c||"")),u.collapseToEnd())})},mapVerticalAlignToFlex=a=>{switch(a){case VERTICAL_ALIGN_TOP:return"flex-start";case VERTICAL_ALIGN_MIDDLE:return"center";case VERTICAL_ALIGN_BOTTOM:return"flex-end"}return"flex-start"},getBackgroundColor=(a,s)=>!a||!s.backgroundColor?"transparent":s.backgroundColor,textSchema={pdf:pdfRender,ui:uiRender,propPanel,icon:createSvgStr(TextCursorInput)},builtInPlugins={Text:textSchema},I18nContext=reactExports.createContext(i18n),FontContext=reactExports.createContext(getDefaultFont()),PluginsRegistry=reactExports.createContext(pluginRegistry(builtInPlugins)),OptionsContext=reactExports.createContext({}),CacheContext=reactExports.createContext(new Map),hotkeys=function(a,s){return hotkeys$1(a,s)};hotkeys.shift=!1,hotkeys.unbind=function(a){const s=hotkeys$1;typeof s.unbind=="function"&&s.unbind(a)};const uuid$6=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const s=Math.random()*16|0;return(a=="x"?s:s&3|8).toString(16)}),set$2=(a,s,c)=>{s=Array.isArray(s)?s:s.replace("[",".").replace("]","").split(".");let u=a;s.forEach((d,p,v)=>{if(p==s.length-1)u[d]=c;else{if(!Object.prototype.hasOwnProperty.call(u,d)){const A=v[p+1];u[d]=String(Number(A))===A?[]:{}}u=u[d]}})},debounce$1=(a,s=20)=>{let c=null;return(...d)=>{c&&clearTimeout(c),c=setTimeout(()=>a(...d),s)}},shift=(a,s,c)=>{c&&(s=-s);const u=`${a}`.split("e");return+`${u[0]}e${u[1]?Number(u[1])+s:s}`},round$1=(a,s)=>shift(Math.round(shift(a,s,!1)),s,!0),flatten=a=>[].concat(...a),up="up",shiftUp="shift+up",down="down",shiftDown="shift+down",left="left",shiftLeft="shift+left",right="right",shiftRight="shift+right",rmWin="backspace",rmMac="delete",esc="esc",copyWin="ctrl+c",copyMac="command+c",pasteWin="ctrl+v",pasteMac="command+v",redoWin="ctrl+y",redoMac="shift+command+z",undoWin="ctrl+z",undoMac="command+z",saveWin="ctrl+s",saveMac="command+s",selectAllWin="ctrl+a",selectAllMac="command+a",keys$2=[up,shiftUp,down,shiftDown,left,shiftLeft,right,shiftRight,rmMac,rmWin,esc,copyWin,copyMac,pasteWin,pasteMac,redoWin,redoMac,undoWin,undoMac,saveWin,saveMac,selectAllWin,selectAllMac],initShortCuts=a=>{hotkeys(keys$2.join(),(s,c)=>{switch(c.shortcut){case up:case shiftUp:s.preventDefault(),a.move("up",hotkeys.shift);break;case down:case shiftDown:s.preventDefault(),a.move("down",hotkeys.shift);break;case left:case shiftLeft:s.preventDefault(),a.move("left",hotkeys.shift);break;case right:case shiftRight:s.preventDefault(),a.move("right",hotkeys.shift);break;case rmWin:case rmMac:a.remove();break;case esc:a.esc();break;case copyWin:case copyMac:a.copy();break;case pasteWin:case pasteMac:a.paste();break;case redoWin:case redoMac:a.redo();break;case undoWin:case undoMac:a.undo();break;case saveWin:case saveMac:s.preventDefault(),a.save();break;case selectAllWin:case selectAllMac:s.preventDefault(),a.selectAll();break}})},destroyShortCuts=()=>{hotkeys.unbind(keys$2.join())};function detectMimeType(a){const s=new DataView(a);return s.getUint8(0)===137&&s.getUint8(1)===80&&s.getUint8(2)===78&&s.getUint8(3)===71?"image/png":s.getUint8(0)===255&&s.getUint8(1)===216&&s.getUint8(2)===255?"image/jpeg":""}const arrayBufferToBase64=a=>{const s=detectMimeType(a),c=new Uint8Array(a);let u="";for(let p=0;p<c.length;p++)u+=String.fromCharCode(c[p]);const d=btoa(u);return s?`data:${s};base64,${d}`:`data:application/octet-stream;base64,${d}`},convertSchemasForUI=a=>(a.schemas.forEach(s=>{s.forEach(c=>{c.id=uuid$6(),c.content=c.content||""})}),a.schemas),template2SchemasList=async a=>{const s=cloneDeep$1(a),{basePdf:c,schemas:u}=s,d=convertSchemasForUI(s);let p=[];if(isBlankPdf(c))p=u.map(()=>({width:c.width,height:c.height}));else{const b=await getB64BasePdf(c),g=b64toUint8Array(b);p=await pdf2size(g)}const v=d.length,A=p.length;return(v<A?d.concat(new Array(A-v).fill(cloneDeep$1([]))):d.slice(0,p.length)).map((b,g)=>(Object.values(b).forEach(x=>{const{width:y,height:f}=p[g],m=x.position.x+x.width,C=x.position.y+x.height;if(y<m){const S=m-y;x.position.x+=S}if(f<C){const S=C-f;x.position.y+=S}}),b))},schemasList2template=(a,s)=>({schemas:cloneDeep$1(a).map(c=>c.map(u=>(delete u.id,u))),basePdf:s}),getUniqueSchemaName=a=>{const{copiedSchemaName:s,schema:c,stackUniqueSchemaNames:u}=a,d=c.map(g=>g.name).concat(u),p=d.reduce((g,x)=>Object.assign(g,{originalName:x,copiedNum:0}),{}),v=g=>g.replace(/ copy$| copy [0-9]*$/,"");d.filter(g=>/ copy$| copy [0-9]*$/.test(g)).forEach(g=>{const x=v(g),y=g.match(/[0-9]*$/),f=y&&y[0]?Number(y[0]):1;(p[x]??0)<f&&(p[x]=f)});const A=v(s);if(p[A]){const g=p[A],x=`${A} copy ${g+1}`;return u.push(x),x}const b=`${s} copy`;return u.push(b),b},moveCommandToChangeSchemasArg=a=>{const{command:s,activeSchemas:c,isShift:u,pageSize:d}=a,p=s==="up"||s==="down"?"y":"x",v=u?.1:1,A=b=>{let g=0;const{position:x}=b;switch(s){case"up":g=round$1(x.y-v,2);break;case"down":g=round$1(x.y+v,2);break;case"left":g=round$1(x.x-v,2);break;case"right":g=round$1(x.x+v,2);break}return g>0?g:0};return c.map(b=>{let g=A(b);const{width:x,height:y}=b;return p==="x"?g=g>d.width-x?round$1(d.width-x,2):g:g=g>d.height-y?round$1(d.height-y,2):g,{key:`position.${p}`,value:g,schemaId:b.id}})},getPagesScrollTopByIndex=(a,s,c)=>a.slice(0,s).reduce((u,d)=>u+(d.height*ZOOM+RULER_HEIGHT*c)*c,0),getSidebarContentHeight=a=>a-RULER_HEIGHT-RULER_HEIGHT/2-30,handlePositionSizeChange=(a,s,c,u,d)=>{const p=isBlankPdf(u)?u.padding:[0,0,0,0],[v,A,b,g]=p,{width:x,height:y}=d,f=(m,C,S)=>Math.min(Math.max(Number(m),C),S);s==="position.x"?a.position.x=f(c,g,x-a.width-A):s==="position.y"?a.position.y=f(c,v,y-a.height-b):s==="width"?a.width=f(c,0,x-a.position.x-A):s==="height"&&(a.height=f(c,0,y-a.position.y-b))},handleTypeChange=(a,s,c,u)=>{if(s!=="type")return;const d=["id","name","type","position","required"];Object.keys(a).forEach(v=>{d.includes(v)||delete a[v]});const p=u.findByType(c);if(p!=null&&p.propPanel.defaultSchema){const v=p.propPanel.defaultSchema,A=a;for(const b of Object.keys(v))if(!Object.prototype.hasOwnProperty.call(a,b)){const g=v[b];g!==void 0&&(A[b]=g)}}a.readOnly&&(a.required=!1)},changeSchemas=a=>{const{objs:s,schemas:c,basePdf:u,pluginsRegistry:d,pageSize:p,commitSchemas:v}=a,A=s.reduce((b,{key:g,value:x,schemaId:y})=>{const f=b.find(m=>m.id===y);return f&&(set$2(f,g,x),g==="type"?handleTypeChange(f,g,x,d):["position.x","position.y","width","height"].includes(g)&&handlePositionSizeChange(f,g,x,u,p)),b},cloneDeep$1(c));v(A)},useMaxZoom=()=>{const a=reactExports.useContext(OptionsContext);return a.maxZoom?a.maxZoom/100:DEFAULT_MAX_ZOOM};class BaseUIClass{constructor(s){this.lang=DEFAULT_LANG,this.font=getDefaultFont(),this.pluginsRegistry=pluginRegistry(builtInPlugins),this.options={},this.setSize=debounce$1(()=>{this.domContainer&&(this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.render())},100),this.resizeObserver=new ResizeObserver(this.setSize),checkUIProps(s);const{domContainer:c,template:u,options:d={},plugins:p={}}=s;this.domContainer=c,this.template=cloneDeep$1(u),this.options=d,this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.resizeObserver.observe(this.domContainer);const{lang:v,font:A}=d;v&&(this.lang=v),A&&(this.font=A),Object.values(p).length>0&&(this.pluginsRegistry=pluginRegistry(p))}getLang(){return this.lang}getFont(){return this.font}getPluginsRegistry(){return this.pluginsRegistry}getOptions(){return this.options}getTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$1(s),this.render()}updateOptions(s){checkUIOptions(s);const{lang:c,font:u}=s||{};c&&(this.lang=c),u&&(this.font=u),this.options=Object.assign(this.options,s),this.render()}destroy(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.unmountComponentAtNode(this.domContainer),this.resizeObserver.unobserve(this.domContainer),this.domContainer=null}}class PreviewUI extends BaseUIClass{constructor(s){super(s),checkPreviewProps(s),this.inputs=convertToStingObjectArray(cloneDeep$1(s.inputs))}getInputs(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.inputs}setInputs(s){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);checkInputs(s),this.inputs=convertToStingObjectArray(s),this.render()}}function convertToStingObjectArray(a){return a.map(s=>{const c={};return Object.keys(s).forEach(u=>{const d=s[u];Array.isArray(d)?c[u]=JSON.stringify(d):c[u]=d}),c})}function useCombinedRefs(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return reactExports.useMemo(()=>u=>{s.forEach(d=>d(u))},s)}const canUseDOM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function isWindow$4(a){const s=Object.prototype.toString.call(a);return s==="[object Window]"||s==="[object global]"}function isNode$1(a){return"nodeType"in a}function getWindow$1(a){var s,c;return a?isWindow$4(a)?a:isNode$1(a)&&(s=(c=a.ownerDocument)==null?void 0:c.defaultView)!=null?s:window:window}function isDocument(a){const{Document:s}=getWindow$1(a);return a instanceof s}function isHTMLElement(a){return isWindow$4(a)?!1:a instanceof getWindow$1(a).HTMLElement}function isSVGElement(a){return a instanceof getWindow$1(a).SVGElement}function getOwnerDocument(a){return a?isWindow$4(a)?a.document:isNode$1(a)?isDocument(a)?a:isHTMLElement(a)||isSVGElement(a)?a.ownerDocument:document:document:document}const useIsomorphicLayoutEffect$1=canUseDOM?reactExports.useLayoutEffect:reactExports.useEffect;function useEvent$1(a){const s=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{s.current=a}),reactExports.useCallback(function(){for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];return s.current==null?void 0:s.current(...u)},[])}function useInterval(){const a=reactExports.useRef(null),s=reactExports.useCallback((u,d)=>{a.current=setInterval(u,d)},[]),c=reactExports.useCallback(()=>{a.current!==null&&(clearInterval(a.current),a.current=null)},[]);return[s,c]}function useLatestValue(a,s){s===void 0&&(s=[a]);const c=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{c.current!==a&&(c.current=a)},s),c}function useLazyMemo(a,s){const c=reactExports.useRef();return reactExports.useMemo(()=>{const u=a(c.current);return c.current=u,u},[...s])}function useNodeRef(a){const s=useEvent$1(a),c=reactExports.useRef(null),u=reactExports.useCallback(d=>{d!==c.current&&(s==null||s(d,c.current)),c.current=d},[]);return[c,u]}function usePrevious$2(a){const s=reactExports.useRef();return reactExports.useEffect(()=>{s.current=a},[a]),s.current}let ids={};function useUniqueId(a,s){return reactExports.useMemo(()=>{if(s)return s;const c=ids[a]==null?0:ids[a]+1;return ids[a]=c,a+"-"+c},[a,s])}function createAdjustmentFn(a){return function(s){for(var c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];return u.reduce((p,v)=>{const A=Object.entries(v);for(const[b,g]of A){const x=p[b];x!=null&&(p[b]=x+a*g)}return p},{...s})}}const add$1=createAdjustmentFn(1),subtract=createAdjustmentFn(-1);function hasViewportRelativeCoordinates(a){return"clientX"in a&&"clientY"in a}function isKeyboardEvent(a){if(!a)return!1;const{KeyboardEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function isTouchEvent(a){if(!a)return!1;const{TouchEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function getEventCoordinates(a){if(isTouchEvent(a)){if(a.touches&&a.touches.length){const{clientX:s,clientY:c}=a.touches[0];return{x:s,y:c}}else if(a.changedTouches&&a.changedTouches.length){const{clientX:s,clientY:c}=a.changedTouches[0];return{x:s,y:c}}}return hasViewportRelativeCoordinates(a)?{x:a.clientX,y:a.clientY}:null}const CSS$1=Object.freeze({Translate:{toString(a){if(!a)return;const{x:s,y:c}=a;return"translate3d("+(s?Math.round(s):0)+"px, "+(c?Math.round(c):0)+"px, 0)"}},Scale:{toString(a){if(!a)return;const{scaleX:s,scaleY:c}=a;return"scaleX("+s+") scaleY("+c+")"}},Transform:{toString(a){if(a)return[CSS$1.Translate.toString(a),CSS$1.Scale.toString(a)].join(" ")}},Transition:{toString(a){let{property:s,duration:c,easing:u}=a;return s+" "+c+"ms "+u}}}),SELECTOR="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function findFirstFocusableNode(a){return a.matches(SELECTOR)?a:a.querySelector(SELECTOR)}const hiddenStyles={display:"none"};function HiddenText(a){let{id:s,value:c}=a;return React.createElement("div",{id:s,style:hiddenStyles},c)}function LiveRegion(a){let{id:s,announcement:c,ariaLiveType:u="assertive"}=a;const d={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return React.createElement("div",{id:s,style:d,role:"status","aria-live":u,"aria-atomic":!0},c)}function useAnnouncement(){const[a,s]=reactExports.useState("");return{announce:reactExports.useCallback(u=>{u!=null&&s(u)},[]),announcement:a}}const DndMonitorContext=reactExports.createContext(null);function useDndMonitor(a){const s=reactExports.useContext(DndMonitorContext);reactExports.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(a)},[a,s])}function useDndMonitorProvider(){const[a]=reactExports.useState(()=>new Set),s=reactExports.useCallback(u=>(a.add(u),()=>a.delete(u)),[a]);return[reactExports.useCallback(u=>{let{type:d,event:p}=u;a.forEach(v=>{var A;return(A=v[d])==null?void 0:A.call(v,p)})},[a]),s]}const defaultScreenReaderInstructions={draggable:`
|
187
187
|
To pick up a draggable item, press the space bar.
|
188
188
|
While dragging, use the arrow keys to move the item.
|
189
189
|
Press space again to drop the item in its new position, or press escape to cancel.
|
@@ -770,7 +770,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
770
770
|
*
|
771
771
|
* This source code is licensed under the ISC license.
|
772
772
|
* See the LICENSE file in the root directory of this source tree.
|
773
|
-
*/const __iconNode=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],X=createLucideIcon("x",__iconNode);function arrayMove(a,s,c){const u=a.slice();return u.splice(c<0?u.length+c:c,0,u.splice(s,1)[0]),u}function getSortedRects(a,s){return a.reduce((c,u,d)=>{const p=s.get(u);return p&&(c[d]=p),c},Array(a.length))}function isValidIndex(a){return a!==null&&a>=0}function itemsEqual(a,s){if(a===s)return!0;if(a.length!==s.length)return!1;for(let c=0;c<a.length;c++)if(a[c]!==s[c])return!1;return!0}function normalizeDisabled(a){return typeof a=="boolean"?{draggable:a,droppable:a}:a}const rectSortingStrategy=a=>{let{rects:s,activeIndex:c,overIndex:u,index:d}=a;const p=arrayMove(s,u,c),v=s[d],A=p[d];return!A||!v?null:{x:A.left-v.left,y:A.top-v.top,scaleX:A.width/v.width,scaleY:A.height/v.height}},defaultScale$1={scaleX:1,scaleY:1},verticalListSortingStrategy=a=>{var s;let{activeIndex:c,activeNodeRect:u,index:d,rects:p,overIndex:v}=a;const A=(s=p[c])!=null?s:u;if(!A)return null;if(d===c){const g=p[v];return g?{x:0,y:c<v?g.top+g.height-(A.top+A.height):g.top-A.top,...defaultScale$1}:null}const b=getItemGap$1(p,d,c);return d>c&&d<=v?{x:0,y:-A.height-b,...defaultScale$1}:d<c&&d>=v?{x:0,y:A.height+b,...defaultScale$1}:{x:0,y:0,...defaultScale$1}};function getItemGap$1(a,s,c){const u=a[s],d=a[s-1],p=a[s+1];return u?c<s?d?u.top-(d.top+d.height):p?p.top-(u.top+u.height):0:p?p.top-(u.top+u.height):d?u.top-(d.top+d.height):0:0}const ID_PREFIX="Sortable",Context$1=React.createContext({activeIndex:-1,containerId:ID_PREFIX,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:rectSortingStrategy,disabled:{draggable:!1,droppable:!1}});function SortableContext(a){let{children:s,id:c,items:u,strategy:d=rectSortingStrategy,disabled:p=!1}=a;const{active:v,dragOverlay:A,droppableRects:b,over:g,measureDroppableContainers:x}=useDndContext(),y=useUniqueId(ID_PREFIX,c),f=A.rect!==null,m=reactExports.useMemo(()=>u.map(R=>typeof R=="object"&&"id"in R?R.id:R),[u]),C=v!=null,S=v?m.indexOf(v.id):-1,w=g?m.indexOf(g.id):-1,_=reactExports.useRef(m),I=!itemsEqual(m,_.current),$=w!==-1&&S===-1||I,P=normalizeDisabled(p);useIsomorphicLayoutEffect$1(()=>{I&&C&&x(m)},[I,m,C,x]),reactExports.useEffect(()=>{_.current=m},[m]);const E=reactExports.useMemo(()=>({activeIndex:S,containerId:y,disabled:P,disableTransforms:$,items:m,overIndex:w,useDragOverlay:f,sortedRects:getSortedRects(m,b),strategy:d}),[S,y,P.draggable,P.droppable,$,m,w,b,f,d]);return React.createElement(Context$1.Provider,{value:E},s)}const defaultNewIndexGetter=a=>{let{id:s,items:c,activeIndex:u,overIndex:d}=a;return arrayMove(c,u,d).indexOf(s)},defaultAnimateLayoutChanges=a=>{let{containerId:s,isSorting:c,wasDragging:u,index:d,items:p,newIndex:v,previousItems:A,previousContainerId:b,transition:g}=a;return!g||!u||A!==p&&d===v?!1:c?!0:v!==d&&s===b},defaultTransition={duration:200,easing:"ease"},transitionProperty="transform",disabledTransition=CSS$1.Transition.toString({property:transitionProperty,duration:0,easing:"linear"}),defaultAttributes={roleDescription:"sortable"};function useDerivedTransform(a){let{disabled:s,index:c,node:u,rect:d}=a;const[p,v]=reactExports.useState(null),A=reactExports.useRef(c);return useIsomorphicLayoutEffect$1(()=>{if(!s&&c!==A.current&&u.current){const b=d.current;if(b){const g=getClientRect$1(u.current,{ignoreTransform:!0}),x={x:b.left-g.left,y:b.top-g.top,scaleX:b.width/g.width,scaleY:b.height/g.height};(x.x||x.y)&&v(x)}}c!==A.current&&(A.current=c)},[s,c,u,d]),reactExports.useEffect(()=>{p&&v(null)},[p]),p}function useSortable(a){let{animateLayoutChanges:s=defaultAnimateLayoutChanges,attributes:c,disabled:u,data:d,getNewIndex:p=defaultNewIndexGetter,id:v,strategy:A,resizeObserverConfig:b,transition:g=defaultTransition}=a;const{items:x,containerId:y,activeIndex:f,disabled:m,disableTransforms:C,sortedRects:S,overIndex:w,useDragOverlay:_,strategy:I}=reactExports.useContext(Context$1),$=normalizeLocalDisabled(u,m),P=x.indexOf(v),E=reactExports.useMemo(()=>({sortable:{containerId:y,index:P,items:x},...d}),[y,d,P,x]),R=reactExports.useMemo(()=>x.slice(x.indexOf(v)),[x,v]),{rect:T,node:B,isOver:M,setNodeRef:k}=useDroppable({id:v,data:E,disabled:$.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...b}}),{active:O,activatorEvent:H,activeNodeRect:j,attributes:q,setNodeRef:L,listeners:F,isDragging:U,over:N,setActivatorNodeRef:D,transform:W}=useDraggable({id:v,data:E,attributes:{...defaultAttributes,...c},disabled:$.draggable}),Z=useCombinedRefs(k,L),Q=!!O,Y=Q&&!C&&isValidIndex(f)&&isValidIndex(w),J=!_&&U,ee=J&&Y?W:null,ae=Y?ee??(A??I)({rects:S,activeNodeRect:j,activeIndex:f,overIndex:w,index:P}):null,V=isValidIndex(f)&&isValidIndex(w)?p({id:v,items:x,activeIndex:f,overIndex:w}):P,K=O==null?void 0:O.id,te=reactExports.useRef({activeId:K,items:x,newIndex:V,containerId:y}),ie=x!==te.current.items,ce=s({active:O,containerId:y,isDragging:U,isSorting:Q,id:v,index:P,items:x,newIndex:te.current.newIndex,previousItems:te.current.items,previousContainerId:te.current.containerId,transition:g,wasDragging:te.current.activeId!=null}),me=useDerivedTransform({disabled:!ce,index:P,node:B,rect:T});return reactExports.useEffect(()=>{Q&&te.current.newIndex!==V&&(te.current.newIndex=V),y!==te.current.containerId&&(te.current.containerId=y),x!==te.current.items&&(te.current.items=x)},[Q,V,y,x]),reactExports.useEffect(()=>{if(K===te.current.activeId)return;if(K!=null&&te.current.activeId==null){te.current.activeId=K;return}const ve=setTimeout(()=>{te.current.activeId=K},50);return()=>clearTimeout(ve)},[K]),{active:O,activeIndex:f,attributes:q,data:E,rect:T,index:P,newIndex:V,items:x,isOver:M,isSorting:Q,isDragging:U,listeners:F,node:B,overIndex:w,over:N,setNodeRef:Z,setActivatorNodeRef:D,setDroppableNodeRef:k,setDraggableNodeRef:L,transform:me??ae,transition:we()};function we(){if(me||ie&&te.current.newIndex===P)return disabledTransition;if(!(J&&!isKeyboardEvent(H)||!g)&&(Q||ce))return CSS$1.Transition.toString({...g,property:transitionProperty})}}function normalizeLocalDisabled(a,s){var c,u;return typeof a=="boolean"?{draggable:a,droppable:!1}:{draggable:(c=a==null?void 0:a.draggable)!=null?c:s.draggable,droppable:(u=a==null?void 0:a.droppable)!=null?u:s.droppable}}function hasSortableData(a){if(!a)return!1;const s=a.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const directions=[KeyboardCode.Down,KeyboardCode.Right,KeyboardCode.Up,KeyboardCode.Left],sortableKeyboardCoordinates=(a,s)=>{let{context:{active:c,collisionRect:u,droppableRects:d,droppableContainers:p,over:v,scrollableAncestors:A}}=s;if(directions.includes(a.code)){if(a.preventDefault(),!c||!u)return;const b=[];p.getEnabled().forEach(y=>{if(!y||y!=null&&y.disabled)return;const f=d.get(y.id);if(f)switch(a.code){case KeyboardCode.Down:u.top<f.top&&b.push(y);break;case KeyboardCode.Up:u.top>f.top&&b.push(y);break;case KeyboardCode.Left:u.left>f.left&&b.push(y);break;case KeyboardCode.Right:u.left<f.left&&b.push(y);break}});const g=closestCorners({collisionRect:u,droppableRects:d,droppableContainers:b});let x=getFirstCollision(g,"id");if(x===(v==null?void 0:v.id)&&g.length>1&&(x=g[1].id),x!=null){const y=p.get(c.id),f=p.get(x),m=f?d.get(f.id):null,C=f==null?void 0:f.node.current;if(C&&m&&y&&f){const w=getScrollableAncestors(C).some((R,T)=>A[T]!==R),_=isSameContainer(y,f),I=isAfter(y,f),$=w||!_?{x:0,y:0}:{x:I?u.width-m.width:0,y:I?u.height-m.height:0},P={x:m.left,y:m.top};return $.x&&$.y?P:subtract(P,$)}}}};function isSameContainer(a,s){return!hasSortableData(a)||!hasSortableData(s)?!1:a.data.current.sortable.containerId===s.data.current.sortable.containerId}function isAfter(a,s){return!hasSortableData(a)||!hasSortableData(s)||!isSameContainer(a,s)?!1:a.data.current.sortable.index<s.data.current.sortable.index}const{Text:Text$4}=Typography,Item=React.memo(React.forwardRef(function a({icon:s,value:c,status:u,title:d,required:p,readOnly:v,style:A,dragOverlay:b,onClick:g,onMouseEnter:x,onMouseLeave:y,dragging:f,fadeIn:m,listeners:C,sorting:S,transition:w,transform:_,...I},$){const P=reactExports.useContext(I18nContext);reactExports.useEffect(()=>{if(b)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[b]);const{x:E,y:R,scaleX:T,scaleY:B}=_||{x:0,y:0,scaleX:1,scaleY:1};return jsxRuntimeExports.jsx("li",{style:{marginTop:10,transition:w,transform:`translate(${E}px, ${R}px) scale(${T}, ${B})`},onMouseEnter:x,onMouseLeave:y,ref:$,children:jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",cursor:"pointer",gap:"0.5rem",...A},...I,onClick:()=>g&&g(),children:[jsxRuntimeExports.jsx(Button$1,{...C,style:{display:"flex",alignItems:"center",background:"none",boxShadow:"none",border:"none",paddingLeft:"0.25rem"},icon:jsxRuntimeExports.jsx(GripVertical,{size:15,style:{cursor:"grab"}})}),s,jsxRuntimeExports.jsx(Text$4,{style:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",width:"100%"},title:d||"",children:u===void 0?c:jsxRuntimeExports.jsxs("span",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(CircleAlert,{size:15,style:{marginRight:"0.25rem"}}),u==="is-warning"?P("noKeyName"):c,u==="is-danger"?P("notUniq"):""]})}),v&&jsxRuntimeExports.jsx(Lock,{size:15,style:{marginRight:"0.5rem"}}),p&&jsxRuntimeExports.jsx("span",{style:{color:"red",marginRight:"0.5rem"},children:"*"})]})})}));Item.displayName="Item";const usePrevious=a=>{const s=reactExports.useRef(null);return reactExports.useEffect(()=>{s.current=a}),s.current},getScale=(a,s)=>Math.floor((a/s>1?1:a/s)*100)/100,useUIPreProcessor=({template:a,size:s,zoomLevel:c,maxZoom:u})=>{const[d,p]=reactExports.useState([]),[v,A]=reactExports.useState([]),[b,g]=reactExports.useState(0),[x,y]=reactExports.useState(null),f=async m=>{const{template:{basePdf:C,schemas:S},size:w}=m;let _,I,$,P;if(isBlankPdf(C)){const{width:R,height:T}=C;_=R*ZOOM,I=T*ZOOM,$=S.map(()=>"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII="),P=S.map(()=>({width:R,height:T}))}else{const R=await getB64BasePdf(C),T=b64toUint8Array(R),B=new ArrayBuffer(T.byteLength);new Uint8Array(B).set(T);const[M,k]=await Promise.all([pdf2size(B),pdf2img(B.slice(),{scale:u})]);P=M,_=P[0].width*ZOOM,I=P[0].height*ZOOM,$=k.map(arrayBufferToBase64)}const E=Math.min(getScale(w.width,_),getScale(w.height-RULER_HEIGHT,I));return{backgrounds:$,pageSizes:P,scale:E}};return reactExports.useEffect(()=>{f({template:a,size:s}).then(({pageSizes:m,scale:C,backgrounds:S})=>{A(m),g(C),p(S)}).catch(m=>{y(m),console.error("[@pdfme/ui]",m)})},[a,s]),{backgrounds:d,pageSizes:v,scale:b*c,error:x,refresh:m=>f({template:m,size:s}).then(({pageSizes:C,scale:S,backgrounds:w})=>{A(C),g(S),p(w)})}},useScrollPageCursor=({ref:a,pageSizes:s,scale:c,pageCursor:u,onChangePageCursor:d})=>{const p=reactExports.useCallback(()=>{if(!s[0]||!a.current)return;const v=a.current.scrollTop,{top:A}=a.current.getBoundingClientRect(),b=s.reduce((x,y,f)=>{let m=(y.height*ZOOM+RULER_HEIGHT)*c;return f===0?m+=A-m/2:m+=x[f-1],x.concat(m)},[]);let g=0;b.forEach((x,y)=>{v>x&&(g=y+1>=b.length?b.length-1:y+1)}),g!==u&&d(g)},[d,u,s,a,c]);reactExports.useEffect(()=>{var v;return(v=a.current)==null||v.addEventListener("scroll",p),()=>{var A;(A=a.current)==null||A.removeEventListener("scroll",p)}},[a,p])},useMountStatus=()=>{const[a,s]=reactExports.useState(!1);return reactExports.useEffect(()=>{const c=setTimeout(()=>s(!0),500);return()=>clearTimeout(c)},[]),a},useInitEvents=({pageCursor:a,pageSizes:s,activeElements:c,template:u,schemasList:d,changeSchemas:p,commitSchemas:v,removeSchemas:A,onSaveTemplate:b,past:g,future:x,setSchemasList:y,onEdit:f,onEditEnd:m})=>{const C=reactExports.useRef(null),S=reactExports.useCallback(()=>{const _=()=>{const $=c.map(P=>P.id);return d[a].filter(P=>$.includes(P.id))},I=$=>{const P=$==="undo",E=P?g:x;if(E.current.length<=0)return;(P?x:g).current.push(cloneDeep$1(d[a]));const R=cloneDeep$1(d);R[a]=E.current.pop(),y(R)};initShortCuts({move:($,P)=>{const E=s[a],R=_(),T=moveCommandToChangeSchemasArg({command:$,activeSchemas:R,pageSize:E,isShift:P});p(T)},copy:()=>{const $=_();$.length!==0&&(C.current=$)},paste:()=>{if(!C.current||C.current.length===0)return;const $=d[a],P=[],E=C.current.map(R=>{const T=uuid$6(),B=getUniqueSchemaName({copiedSchemaName:R.name,schema:$,stackUniqueSchemaNames:P}),{height:M,width:k,position:O}=R,H=s[a],j={x:O.x+10>H.width-k?H.width-k:O.x+10,y:O.y+10>H.height-M?H.height-M:O.y+10};return Object.assign(cloneDeep$1(R),{id:T,name:B,position:j})});v(d[a].concat(E)),f(E.map(R=>document.getElementById(R.id))),C.current=E},redo:()=>I("redo"),undo:()=>I("undo"),save:()=>b&&b(schemasList2template(d,u.basePdf)),remove:()=>A(_().map($=>$.id)),esc:m,selectAll:()=>f(d[a].map($=>document.getElementById($.id)))})},[u,c,a,s,p,v,d,b,A,g,x,y,C,f,m]),w=reactExports.useCallback(()=>{destroyShortCuts()},[]);reactExports.useEffect(()=>(S(),w),[S,w])},getWithModifiedSize=(a,s,c,u)=>{const p=new DOMParser().parseFromString(a,"text/html"),v=A=>{(A.tagName==="SVG"||A.tagName==="svg")&&(A.setAttribute("width",c.toString()),A.setAttribute("height",c.toString())),Array.from(A.children).forEach(b=>v(b))};return Array.from(p.body.children).forEach(A=>v(A)),jsxRuntimeExports.jsx("div",{style:u,title:s,dangerouslySetInnerHTML:{__html:p.body.innerHTML}})},PluginIcon=a=>{var x;const{plugin:s,label:c,size:u,styles:d}=a,{token:p}=theme.useToken(),v=reactExports.useContext(OptionsContext),A=s.propPanel&&typeof s.propPanel=="object"&&s.propPanel.defaultSchema&&typeof s.propPanel.defaultSchema=="object"&&"type"in s.propPanel.defaultSchema&&typeof s.propPanel.defaultSchema.type=="string"?s.propPanel.defaultSchema.type:"",b=((x=v.icons)==null?void 0:x[A])??s.icon,g={...d,color:p.colorText,display:"flex",justifyContent:"center"};return b?u?getWithModifiedSize(b,c,u,g):jsxRuntimeExports.jsx("div",{style:g,title:c,dangerouslySetInnerHTML:{__html:b}}):jsxRuntimeExports.jsx("div",{style:{...d,overflow:"hidden",fontSize:10},title:c,children:c})},SelectableSortableItem=({isSelected:a,style:s,onSelect:c,onEdit:u,schema:d,schemas:p,onMouseEnter:v,onMouseLeave:A})=>{const{token:b}=theme.useToken(),g=reactExports.useContext(I18nContext),x=reactExports.useContext(PluginsRegistry),{setNodeRef:y,listeners:f,isDragging:m,isSorting:C,transform:S,transition:w}=useSortable({id:d.id}),_=useMountStatus(),I=m&&!_,$={...f,onClick:O=>c(d.id,O.shiftKey)},P=typeof d.type=="string"?d.type:"",E=Object.entries(x).find(([,O])=>{if(!O||typeof O!="object"||!O.propPanel||typeof O.propPanel!="object"||!O.propPanel.defaultSchema||typeof O.propPanel.defaultSchema!="object")return!1;const H=O.propPanel.defaultSchema;return"type"in H&&typeof H.type=="string"&&H.type===P}),[R,T]=E||["",void 0];let B;d.name?p.find(O=>d.name&&O.name===d.name&&O.id!==d.id)&&(B="is-danger"):B="is-warning";let M=g("edit");B==="is-warning"?M=g("plsInputName"):B==="is-danger"&&(M=g("fieldMustUniq"));const k=a?{background:b.colorPrimary,opacity:C||m?.5:1}:{};return jsxRuntimeExports.jsx(Item,{ref:y,onMouseEnter:v,onMouseLeave:A,onClick:()=>u(d.id),icon:T&&jsxRuntimeExports.jsx(PluginIcon,{plugin:T,label:R,size:20}),value:d.name,status:B,title:M,required:d.required,readOnly:d.readOnly,style:{...k,...s},dragging:m,sorting:C,transition:w,transform:S,fadeIn:I,listeners:$})},SelectableSortableContainer=a=>{const{token:s}=theme.useToken(),{schemas:c,onEdit:u,onSortEnd:d,hoveringSchemaId:p,onChangeHoveringSchemaId:v}=a,[A,b]=reactExports.useState([]),[g,x]=reactExports.useState(null),[y,f]=reactExports.useState(null),m=reactExports.useContext(PluginsRegistry),C=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:15}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),S=I=>A.map($=>$.id).includes(I),w=(I,$)=>{if($)if(S(I)){const P=A.filter(E=>E.id!==I);b(P)}else{const P=c.find(R=>R.id===I),E=A.concat(P);b(E)}else b([])},_=I=>{const $=typeof I=="string"?c.find(B=>B.id===I):I;if(!$)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});const P=typeof $.type=="string"?$.type:"",E=Object.entries(m).find(([,B])=>{if(!B||typeof B!="object"||!B.propPanel||typeof B.propPanel!="object"||!B.propPanel.defaultSchema||typeof B.propPanel.defaultSchema!="object")return!1;const M=B.propPanel.defaultSchema;return"type"in M&&typeof M.type=="string"&&M.type===P}),[R,T]=E||["",void 0];return T?jsxRuntimeExports.jsx(PluginIcon,{plugin:T,label:R,size:20,styles:{marginRight:"0.5rem"}}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})};return jsxRuntimeExports.jsx(DndContext,{sensors:C,collisionDetection:closestCorners,onDragStart:({active:I})=>{f(String(I.id)),x(c),S(String(I.id))?A.length>0&&d(A.reduce(($,P)=>P.id===String(I.id)?$:$.filter(E=>E!==P),c)):b([])},onDragEnd:({active:I,over:$})=>{const P=($==null?void 0:$.id)||"",E=c.map(T=>T.id).indexOf(String(I.id)),R=c.map(T=>T.id).indexOf(String(P));if(A.length){let T=[...c];T=arrayMove(T,E,R),T.splice(R+1,0,...A.filter(B=>B.id!==y)),d(T),b([])}else E!==R&&d(arrayMove(c,E,R));f(null)},onDragCancel:()=>{g&&d(g),f(null),x(null)},children:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{style:{height:"100%",overflowY:"auto"},children:jsxRuntimeExports.jsx(SortableContext,{items:c,strategy:verticalListSortingStrategy,children:jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",borderRadius:5},children:c.map(I=>jsxRuntimeExports.jsx(SelectableSortableItem,{style:{border:`1px solid ${I.id===p?s.colorPrimary:"transparent"}`},schema:I,schemas:c,isSelected:S(I.id)||y===I.id,onEdit:u,onSelect:w,onMouseEnter:()=>v(I.id),onMouseLeave:()=>v(null)},I.id))})})}),reactDomExports.createPortal(jsxRuntimeExports.jsx(DragOverlay,{adjustScale:!0,children:y?(()=>{const I=c.find($=>$.id===y);return I?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none"},children:jsxRuntimeExports.jsx(Item,{icon:_(y),value:I.name,required:I.required,readOnly:I.readOnly,style:{background:s.colorPrimary},dragOverlay:!0})}),jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none"},children:A.filter($=>$.id!==y).map($=>jsxRuntimeExports.jsx(Item,{icon:_($),value:$.name,required:$.required,readOnly:$.readOnly,style:{background:s.colorPrimary},dragOverlay:!0},$.id))})]}):null})():null}),document.body)]})})},{Text:Text$3}=Typography,{TextArea:TextArea$2}=Input$1,headHeight=40,ListView=a=>{const{schemas:s,onSortEnd:c,onEdit:u,size:d,hoveringSchemaId:p,onChangeHoveringSchemaId:v,changeSchemas:A}=a,{token:b}=theme.useToken(),g=reactExports.useContext(I18nContext),[x,y]=reactExports.useState(!1),[f,m]=reactExports.useState(""),C=getSidebarContentHeight(d.height),S=()=>{const _=f.split(`
|
773
|
+
*/const __iconNode=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],X=createLucideIcon("x",__iconNode);function arrayMove(a,s,c){const u=a.slice();return u.splice(c<0?u.length+c:c,0,u.splice(s,1)[0]),u}function getSortedRects(a,s){return a.reduce((c,u,d)=>{const p=s.get(u);return p&&(c[d]=p),c},Array(a.length))}function isValidIndex(a){return a!==null&&a>=0}function itemsEqual(a,s){if(a===s)return!0;if(a.length!==s.length)return!1;for(let c=0;c<a.length;c++)if(a[c]!==s[c])return!1;return!0}function normalizeDisabled(a){return typeof a=="boolean"?{draggable:a,droppable:a}:a}const rectSortingStrategy=a=>{let{rects:s,activeIndex:c,overIndex:u,index:d}=a;const p=arrayMove(s,u,c),v=s[d],A=p[d];return!A||!v?null:{x:A.left-v.left,y:A.top-v.top,scaleX:A.width/v.width,scaleY:A.height/v.height}},defaultScale$1={scaleX:1,scaleY:1},verticalListSortingStrategy=a=>{var s;let{activeIndex:c,activeNodeRect:u,index:d,rects:p,overIndex:v}=a;const A=(s=p[c])!=null?s:u;if(!A)return null;if(d===c){const g=p[v];return g?{x:0,y:c<v?g.top+g.height-(A.top+A.height):g.top-A.top,...defaultScale$1}:null}const b=getItemGap$1(p,d,c);return d>c&&d<=v?{x:0,y:-A.height-b,...defaultScale$1}:d<c&&d>=v?{x:0,y:A.height+b,...defaultScale$1}:{x:0,y:0,...defaultScale$1}};function getItemGap$1(a,s,c){const u=a[s],d=a[s-1],p=a[s+1];return u?c<s?d?u.top-(d.top+d.height):p?p.top-(u.top+u.height):0:p?p.top-(u.top+u.height):d?u.top-(d.top+d.height):0:0}const ID_PREFIX="Sortable",Context$1=React.createContext({activeIndex:-1,containerId:ID_PREFIX,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:rectSortingStrategy,disabled:{draggable:!1,droppable:!1}});function SortableContext(a){let{children:s,id:c,items:u,strategy:d=rectSortingStrategy,disabled:p=!1}=a;const{active:v,dragOverlay:A,droppableRects:b,over:g,measureDroppableContainers:x}=useDndContext(),y=useUniqueId(ID_PREFIX,c),f=A.rect!==null,m=reactExports.useMemo(()=>u.map(R=>typeof R=="object"&&"id"in R?R.id:R),[u]),C=v!=null,S=v?m.indexOf(v.id):-1,w=g?m.indexOf(g.id):-1,_=reactExports.useRef(m),I=!itemsEqual(m,_.current),$=w!==-1&&S===-1||I,P=normalizeDisabled(p);useIsomorphicLayoutEffect$1(()=>{I&&C&&x(m)},[I,m,C,x]),reactExports.useEffect(()=>{_.current=m},[m]);const E=reactExports.useMemo(()=>({activeIndex:S,containerId:y,disabled:P,disableTransforms:$,items:m,overIndex:w,useDragOverlay:f,sortedRects:getSortedRects(m,b),strategy:d}),[S,y,P.draggable,P.droppable,$,m,w,b,f,d]);return React.createElement(Context$1.Provider,{value:E},s)}const defaultNewIndexGetter=a=>{let{id:s,items:c,activeIndex:u,overIndex:d}=a;return arrayMove(c,u,d).indexOf(s)},defaultAnimateLayoutChanges=a=>{let{containerId:s,isSorting:c,wasDragging:u,index:d,items:p,newIndex:v,previousItems:A,previousContainerId:b,transition:g}=a;return!g||!u||A!==p&&d===v?!1:c?!0:v!==d&&s===b},defaultTransition={duration:200,easing:"ease"},transitionProperty="transform",disabledTransition=CSS$1.Transition.toString({property:transitionProperty,duration:0,easing:"linear"}),defaultAttributes={roleDescription:"sortable"};function useDerivedTransform(a){let{disabled:s,index:c,node:u,rect:d}=a;const[p,v]=reactExports.useState(null),A=reactExports.useRef(c);return useIsomorphicLayoutEffect$1(()=>{if(!s&&c!==A.current&&u.current){const b=d.current;if(b){const g=getClientRect$1(u.current,{ignoreTransform:!0}),x={x:b.left-g.left,y:b.top-g.top,scaleX:b.width/g.width,scaleY:b.height/g.height};(x.x||x.y)&&v(x)}}c!==A.current&&(A.current=c)},[s,c,u,d]),reactExports.useEffect(()=>{p&&v(null)},[p]),p}function useSortable(a){let{animateLayoutChanges:s=defaultAnimateLayoutChanges,attributes:c,disabled:u,data:d,getNewIndex:p=defaultNewIndexGetter,id:v,strategy:A,resizeObserverConfig:b,transition:g=defaultTransition}=a;const{items:x,containerId:y,activeIndex:f,disabled:m,disableTransforms:C,sortedRects:S,overIndex:w,useDragOverlay:_,strategy:I}=reactExports.useContext(Context$1),$=normalizeLocalDisabled(u,m),P=x.indexOf(v),E=reactExports.useMemo(()=>({sortable:{containerId:y,index:P,items:x},...d}),[y,d,P,x]),R=reactExports.useMemo(()=>x.slice(x.indexOf(v)),[x,v]),{rect:T,node:B,isOver:M,setNodeRef:k}=useDroppable({id:v,data:E,disabled:$.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...b}}),{active:O,activatorEvent:H,activeNodeRect:j,attributes:q,setNodeRef:L,listeners:F,isDragging:U,over:N,setActivatorNodeRef:D,transform:W}=useDraggable({id:v,data:E,attributes:{...defaultAttributes,...c},disabled:$.draggable}),Z=useCombinedRefs(k,L),Q=!!O,Y=Q&&!C&&isValidIndex(f)&&isValidIndex(w),J=!_&&U,ee=J&&Y?W:null,ae=Y?ee??(A??I)({rects:S,activeNodeRect:j,activeIndex:f,overIndex:w,index:P}):null,V=isValidIndex(f)&&isValidIndex(w)?p({id:v,items:x,activeIndex:f,overIndex:w}):P,K=O==null?void 0:O.id,te=reactExports.useRef({activeId:K,items:x,newIndex:V,containerId:y}),ie=x!==te.current.items,ce=s({active:O,containerId:y,isDragging:U,isSorting:Q,id:v,index:P,items:x,newIndex:te.current.newIndex,previousItems:te.current.items,previousContainerId:te.current.containerId,transition:g,wasDragging:te.current.activeId!=null}),me=useDerivedTransform({disabled:!ce,index:P,node:B,rect:T});return reactExports.useEffect(()=>{Q&&te.current.newIndex!==V&&(te.current.newIndex=V),y!==te.current.containerId&&(te.current.containerId=y),x!==te.current.items&&(te.current.items=x)},[Q,V,y,x]),reactExports.useEffect(()=>{if(K===te.current.activeId)return;if(K!=null&&te.current.activeId==null){te.current.activeId=K;return}const ve=setTimeout(()=>{te.current.activeId=K},50);return()=>clearTimeout(ve)},[K]),{active:O,activeIndex:f,attributes:q,data:E,rect:T,index:P,newIndex:V,items:x,isOver:M,isSorting:Q,isDragging:U,listeners:F,node:B,overIndex:w,over:N,setNodeRef:Z,setActivatorNodeRef:D,setDroppableNodeRef:k,setDraggableNodeRef:L,transform:me??ae,transition:we()};function we(){if(me||ie&&te.current.newIndex===P)return disabledTransition;if(!(J&&!isKeyboardEvent(H)||!g)&&(Q||ce))return CSS$1.Transition.toString({...g,property:transitionProperty})}}function normalizeLocalDisabled(a,s){var c,u;return typeof a=="boolean"?{draggable:a,droppable:!1}:{draggable:(c=a==null?void 0:a.draggable)!=null?c:s.draggable,droppable:(u=a==null?void 0:a.droppable)!=null?u:s.droppable}}function hasSortableData(a){if(!a)return!1;const s=a.data.current;return!!(s&&"sortable"in s&&typeof s.sortable=="object"&&"containerId"in s.sortable&&"items"in s.sortable&&"index"in s.sortable)}const directions=[KeyboardCode.Down,KeyboardCode.Right,KeyboardCode.Up,KeyboardCode.Left],sortableKeyboardCoordinates=(a,s)=>{let{context:{active:c,collisionRect:u,droppableRects:d,droppableContainers:p,over:v,scrollableAncestors:A}}=s;if(directions.includes(a.code)){if(a.preventDefault(),!c||!u)return;const b=[];p.getEnabled().forEach(y=>{if(!y||y!=null&&y.disabled)return;const f=d.get(y.id);if(f)switch(a.code){case KeyboardCode.Down:u.top<f.top&&b.push(y);break;case KeyboardCode.Up:u.top>f.top&&b.push(y);break;case KeyboardCode.Left:u.left>f.left&&b.push(y);break;case KeyboardCode.Right:u.left<f.left&&b.push(y);break}});const g=closestCorners({collisionRect:u,droppableRects:d,droppableContainers:b});let x=getFirstCollision(g,"id");if(x===(v==null?void 0:v.id)&&g.length>1&&(x=g[1].id),x!=null){const y=p.get(c.id),f=p.get(x),m=f?d.get(f.id):null,C=f==null?void 0:f.node.current;if(C&&m&&y&&f){const w=getScrollableAncestors(C).some((R,T)=>A[T]!==R),_=isSameContainer(y,f),I=isAfter(y,f),$=w||!_?{x:0,y:0}:{x:I?u.width-m.width:0,y:I?u.height-m.height:0},P={x:m.left,y:m.top};return $.x&&$.y?P:subtract(P,$)}}}};function isSameContainer(a,s){return!hasSortableData(a)||!hasSortableData(s)?!1:a.data.current.sortable.containerId===s.data.current.sortable.containerId}function isAfter(a,s){return!hasSortableData(a)||!hasSortableData(s)||!isSameContainer(a,s)?!1:a.data.current.sortable.index<s.data.current.sortable.index}const{Text:Text$4}=Typography,Item=React.memo(React.forwardRef(function a({icon:s,value:c,status:u,title:d,required:p,readOnly:v,style:A,dragOverlay:b,onClick:g,onMouseEnter:x,onMouseLeave:y,dragging:f,fadeIn:m,listeners:C,sorting:S,transition:w,transform:_,...I},$){const P=reactExports.useContext(I18nContext);reactExports.useEffect(()=>{if(b)return document.body.style.cursor="grabbing",()=>{document.body.style.cursor=""}},[b]);const{x:E,y:R,scaleX:T,scaleY:B}=_||{x:0,y:0,scaleX:1,scaleY:1};return jsxRuntimeExports.jsx("li",{style:{marginTop:10,transition:w,transform:`translate(${E}px, ${R}px) scale(${T}, ${B})`},onMouseEnter:x,onMouseLeave:y,ref:$,children:jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",cursor:"pointer",gap:"0.5rem",...A},...I,onClick:()=>g&&g(),children:[jsxRuntimeExports.jsx(Button$1,{...C,style:{display:"flex",alignItems:"center",background:"none",boxShadow:"none",border:"none",paddingLeft:"0.25rem"},icon:jsxRuntimeExports.jsx(GripVertical,{size:15,style:{cursor:"grab"}})}),s,jsxRuntimeExports.jsx(Text$4,{style:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",width:"100%"},title:d||"",children:u===void 0?c:jsxRuntimeExports.jsxs("span",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(CircleAlert,{size:15,style:{marginRight:"0.25rem"}}),u==="is-warning"?P("noKeyName"):c,u==="is-danger"?P("notUniq"):""]})}),v&&jsxRuntimeExports.jsx(Lock,{size:15,style:{marginRight:"0.5rem"}}),p&&jsxRuntimeExports.jsx("span",{style:{color:"red",marginRight:"0.5rem"},children:"*"})]})})}));Item.displayName="Item";const usePrevious=a=>{const s=reactExports.useRef(null);return reactExports.useEffect(()=>{s.current=a}),s.current},getScale=(a,s)=>Math.floor((a/s>1?1:a/s)*100)/100,useUIPreProcessor=({template:a,size:s,zoomLevel:c,maxZoom:u})=>{const[d,p]=reactExports.useState([]),[v,A]=reactExports.useState([]),[b,g]=reactExports.useState(0),[x,y]=reactExports.useState(null),f=async m=>{const{template:{basePdf:C,schemas:S},size:w}=m;let _,I,$,P;if(isBlankPdf(C)){const{width:R,height:T}=C;_=R*ZOOM,I=T*ZOOM,$=S.map(()=>"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII="),P=S.map(()=>({width:R,height:T}))}else{const R=await getB64BasePdf(C),T=b64toUint8Array(R),B=new ArrayBuffer(T.byteLength);new Uint8Array(B).set(T);const[M,k]=await Promise.all([pdf2size(B),pdf2img(B.slice(),{scale:u})]);P=M,_=P[0].width*ZOOM,I=P[0].height*ZOOM,$=k.map(arrayBufferToBase64)}const E=Math.min(getScale(w.width,_),getScale(w.height-RULER_HEIGHT,I));return{backgrounds:$,pageSizes:P,scale:E}};return reactExports.useEffect(()=>{f({template:a,size:s}).then(({pageSizes:m,scale:C,backgrounds:S})=>{A(m),g(C),p(S)}).catch(m=>{y(m),console.error("[@pdfme/ui]",m)})},[a,s]),{backgrounds:d,pageSizes:v,scale:b*c,error:x,refresh:m=>f({template:m,size:s}).then(({pageSizes:C,scale:S,backgrounds:w})=>{A(C),g(S),p(w)})}},useScrollPageCursor=({ref:a,pageSizes:s,scale:c,pageCursor:u,onChangePageCursor:d})=>{const p=reactExports.useCallback(()=>{if(!s[0]||!a.current)return;const v=a.current.scrollTop,{top:A}=a.current.getBoundingClientRect(),b=s.reduce((x,y,f)=>{let m=(y.height*ZOOM+RULER_HEIGHT)*c;return f===0?m+=A-m/2:m+=x[f-1],x.concat(m)},[]);let g=0;b.forEach((x,y)=>{v>x&&(g=y+1>=b.length?b.length-1:y+1)}),g!==u&&d(g)},[d,u,s,a,c]);reactExports.useEffect(()=>{var v;return(v=a.current)==null||v.addEventListener("scroll",p),()=>{var A;(A=a.current)==null||A.removeEventListener("scroll",p)}},[a,p])},useMountStatus=()=>{const[a,s]=reactExports.useState(!1);return reactExports.useEffect(()=>{const c=setTimeout(()=>s(!0),500);return()=>clearTimeout(c)},[]),a},useInitEvents=({pageCursor:a,pageSizes:s,activeElements:c,template:u,schemasList:d,changeSchemas:p,commitSchemas:v,removeSchemas:A,onSaveTemplate:b,past:g,future:x,setSchemasList:y,onEdit:f,onEditEnd:m})=>{const C=reactExports.useRef(null),S=reactExports.useCallback(()=>{const _=()=>{const $=c.map(P=>P.id);return d[a].filter(P=>$.includes(P.id))},I=$=>{const P=$==="undo",E=P?g:x;if(E.current.length<=0)return;(P?x:g).current.push(cloneDeep$1(d[a]));const R=cloneDeep$1(d);R[a]=E.current.pop(),y(R)};initShortCuts({move:($,P)=>{const E=s[a],R=_(),T=moveCommandToChangeSchemasArg({command:$,activeSchemas:R,pageSize:E,isShift:P});p(T)},copy:()=>{const $=_();$.length!==0&&(C.current=$)},paste:()=>{if(!C.current||C.current.length===0)return;const $=d[a],P=[],E=C.current.map(R=>{const T=uuid$6(),B=getUniqueSchemaName({copiedSchemaName:R.name,schema:$,stackUniqueSchemaNames:P}),{height:M,width:k,position:O}=R,H=s[a],j={x:O.x+10>H.width-k?H.width-k:O.x+10,y:O.y+10>H.height-M?H.height-M:O.y+10};return Object.assign(cloneDeep$1(R),{id:T,name:B,position:j})});v(d[a].concat(E)),f(E.map(R=>document.getElementById(R.id))),C.current=E},redo:()=>I("redo"),undo:()=>I("undo"),save:()=>b&&b(schemasList2template(d,u.basePdf)),remove:()=>A(_().map($=>$.id)),esc:m,selectAll:()=>f(d[a].map($=>document.getElementById($.id)))})},[u,c,a,s,p,v,d,b,A,g,x,y,C,f,m]),w=reactExports.useCallback(()=>{destroyShortCuts()},[]);reactExports.useEffect(()=>(S(),w),[S,w])},getWithModifiedSize=(a,s,c,u)=>{const p=new DOMParser().parseFromString(a,"text/html"),v=A=>{(A.tagName==="SVG"||A.tagName==="svg")&&(A.setAttribute("width",c.toString()),A.setAttribute("height",c.toString())),Array.from(A.children).forEach(b=>v(b))};return Array.from(p.body.children).forEach(A=>v(A)),jsxRuntimeExports.jsx("div",{style:u,title:s,dangerouslySetInnerHTML:{__html:p.body.innerHTML}})},PluginIcon=a=>{var x,y;const{plugin:s,label:c,size:u,styles:d}=a,{token:p}=theme.useToken(),v=reactExports.useContext(OptionsContext),A=((x=s.propPanel.defaultSchema)==null?void 0:x.type)??"",b=((y=v.icons)==null?void 0:y[A])??s.icon,g={...d,color:p.colorText,display:"flex",justifyContent:"center"};return b?u?getWithModifiedSize(b,c,u,g):jsxRuntimeExports.jsx("div",{style:g,title:c,dangerouslySetInnerHTML:{__html:b}}):jsxRuntimeExports.jsx("div",{style:{...d,overflow:"hidden",fontSize:10},title:c,children:c})},SelectableSortableItem=({isSelected:a,style:s,onSelect:c,onEdit:u,schema:d,schemas:p,onMouseEnter:v,onMouseLeave:A})=>{const{token:b}=theme.useToken(),g=reactExports.useContext(I18nContext),x=reactExports.useContext(PluginsRegistry),{setNodeRef:y,listeners:f,isDragging:m,isSorting:C,transform:S,transition:w}=useSortable({id:d.id}),_=useMountStatus(),I=m&&!_,$={...f,onClick:M=>c(d.id,M.shiftKey)},[P,E]=x.findWithLabelByType(d.type);let R;d.name?p.find(M=>d.name&&M.name===d.name&&M.id!==d.id)&&(R="is-danger"):R="is-warning";let T=g("edit");R==="is-warning"?T=g("plsInputName"):R==="is-danger"&&(T=g("fieldMustUniq"));const B=a?{background:b.colorPrimary,opacity:C||m?.5:1}:{};return jsxRuntimeExports.jsx(Item,{ref:y,onMouseEnter:v,onMouseLeave:A,onClick:()=>u(d.id),icon:E&&jsxRuntimeExports.jsx(PluginIcon,{plugin:E,label:P,size:20}),value:d.name,status:R,title:T,required:d.required,readOnly:d.readOnly,style:{...B,...s},dragging:m,sorting:C,transition:w,transform:S,fadeIn:I,listeners:$})},SelectableSortableContainer=a=>{const{token:s}=theme.useToken(),{schemas:c,onEdit:u,onSortEnd:d,hoveringSchemaId:p,onChangeHoveringSchemaId:v}=a,[A,b]=reactExports.useState([]),[g,x]=reactExports.useState(null),[y,f]=reactExports.useState(null),m=reactExports.useContext(PluginsRegistry),C=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:15}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),S=I=>A.map($=>$.id).includes(I),w=(I,$)=>{if($)if(S(I)){const P=A.filter(E=>E.id!==I);b(P)}else{const P=c.find(R=>R.id===I),E=A.concat(P);b(E)}else b([])},_=I=>{const $=typeof I=="string"?c.find(R=>R.id===I):I;if(!$)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});const[P,E]=m.findWithLabelByType($.type);return E?jsxRuntimeExports.jsx(PluginIcon,{plugin:E,label:P,size:20,styles:{marginRight:"0.5rem"}}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})};return jsxRuntimeExports.jsx(DndContext,{sensors:C,collisionDetection:closestCorners,onDragStart:({active:I})=>{f(String(I.id)),x(c),S(String(I.id))?A.length>0&&d(A.reduce(($,P)=>P.id===String(I.id)?$:$.filter(E=>E!==P),c)):b([])},onDragEnd:({active:I,over:$})=>{const P=($==null?void 0:$.id)||"",E=c.map(T=>T.id).indexOf(String(I.id)),R=c.map(T=>T.id).indexOf(String(P));if(A.length){let T=[...c];T=arrayMove(T,E,R),T.splice(R+1,0,...A.filter(B=>B.id!==y)),d(T),b([])}else E!==R&&d(arrayMove(c,E,R));f(null)},onDragCancel:()=>{g&&d(g),f(null),x(null)},children:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{style:{height:"100%",overflowY:"auto"},children:jsxRuntimeExports.jsx(SortableContext,{items:c,strategy:verticalListSortingStrategy,children:jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",borderRadius:5},children:c.map(I=>jsxRuntimeExports.jsx(SelectableSortableItem,{style:{border:`1px solid ${I.id===p?s.colorPrimary:"transparent"}`},schema:I,schemas:c,isSelected:S(I.id)||y===I.id,onEdit:u,onSelect:w,onMouseEnter:()=>v(I.id),onMouseLeave:()=>v(null)},I.id))})})}),reactDomExports.createPortal(jsxRuntimeExports.jsx(DragOverlay,{adjustScale:!0,children:y?(()=>{const I=c.find($=>$.id===y);return I?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none"},children:jsxRuntimeExports.jsx(Item,{icon:_(y),value:I.name,required:I.required,readOnly:I.readOnly,style:{background:s.colorPrimary},dragOverlay:!0})}),jsxRuntimeExports.jsx("ul",{style:{margin:0,padding:0,listStyle:"none"},children:A.filter($=>$.id!==y).map($=>jsxRuntimeExports.jsx(Item,{icon:_($),value:$.name,required:$.required,readOnly:$.readOnly,style:{background:s.colorPrimary},dragOverlay:!0},$.id))})]}):null})():null}),document.body)]})})},{Text:Text$3}=Typography,{TextArea:TextArea$2}=Input$1,headHeight=40,ListView=a=>{const{schemas:s,onSortEnd:c,onEdit:u,size:d,hoveringSchemaId:p,onChangeHoveringSchemaId:v,changeSchemas:A}=a,{token:b}=theme.useToken(),g=reactExports.useContext(I18nContext),[x,y]=reactExports.useState(!1),[f,m]=reactExports.useState(""),C=getSidebarContentHeight(d.height),S=()=>{const _=f.split(`
|
774
774
|
`);_.length!==s.length?alert(g("errorBulkUpdateFieldName")):(A(_.map((I,$)=>({key:"name",value:I,schemaId:s[$].id}))),y(!1))},w=()=>{m(s.map(_=>_.name).join(`
|
775
775
|
`)),y(!0)};return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{style:{height:headHeight,display:"flex",alignItems:"center"},children:jsxRuntimeExports.jsx(Text$3,{strong:!0,style:{textAlign:"center",width:"100%"},children:g("fieldsList")})}),jsxRuntimeExports.jsx(Divider,{style:{marginTop:b.marginXS,marginBottom:b.marginXS}}),jsxRuntimeExports.jsxs("div",{style:{height:C-headHeight},children:[x?jsxRuntimeExports.jsx(TextArea$2,{wrap:"off",value:f,onChange:_=>m(_.target.value),style:{paddingLeft:30,height:C-headHeight,width:RIGHT_SIDEBAR_WIDTH-35,lineHeight:"2.75rem"}}):jsxRuntimeExports.jsx(SelectableSortableContainer,{schemas:s,hoveringSchemaId:p,onChangeHoveringSchemaId:v,onSortEnd:c,onEdit:u}),jsxRuntimeExports.jsx("div",{style:{paddingTop:"0.5rem",display:"flex",alignItems:"center",justifyContent:"flex-end"},children:x?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Button$1,{size:"small",type:"text",onClick:S,children:jsxRuntimeExports.jsxs("u",{children:[" ",g("commitBulkUpdateFieldName")]})}),jsxRuntimeExports.jsx("span",{style:{margin:"0 1rem"},children:"/"}),jsxRuntimeExports.jsx(Button$1,{size:"small",type:"text",onClick:()=>y(!1),children:jsxRuntimeExports.jsxs("u",{children:[" ",g("cancel")]})})]}):jsxRuntimeExports.jsx(Button$1,{size:"small",type:"text",onClick:w,children:jsxRuntimeExports.jsxs("u",{children:[" ",g("bulkUpdateFieldName")]})})})]})]})};var freeGlobal=typeof global=="object"&&global&&global.Object===Object&&global,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),Symbol$1=root.Symbol,objectProto$g=Object.prototype,hasOwnProperty$d=objectProto$g.hasOwnProperty,nativeObjectToString$1=objectProto$g.toString,symToStringTag$1=Symbol$1?Symbol$1.toStringTag:void 0;function getRawTag(a){var s=hasOwnProperty$d.call(a,symToStringTag$1),c=a[symToStringTag$1];try{a[symToStringTag$1]=void 0;var u=!0}catch{}var d=nativeObjectToString$1.call(a);return u&&(s?a[symToStringTag$1]=c:delete a[symToStringTag$1]),d}var objectProto$f=Object.prototype,nativeObjectToString=objectProto$f.toString;function objectToString(a){return nativeObjectToString.call(a)}var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$1?Symbol$1.toStringTag:void 0;function baseGetTag(a){return a==null?a===void 0?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(a)?getRawTag(a):objectToString(a)}function isObjectLike(a){return a!=null&&typeof a=="object"}var symbolTag$3="[object Symbol]";function isSymbol(a){return typeof a=="symbol"||isObjectLike(a)&&baseGetTag(a)==symbolTag$3}function arrayMap(a,s){for(var c=-1,u=a==null?0:a.length,d=Array(u);++c<u;)d[c]=s(a[c],c,a);return d}var isArray$2=Array.isArray,symbolProto$2=Symbol$1?Symbol$1.prototype:void 0,symbolToString=symbolProto$2?symbolProto$2.toString:void 0;function baseToString(a){if(typeof a=="string")return a;if(isArray$2(a))return arrayMap(a,baseToString)+"";if(isSymbol(a))return symbolToString?symbolToString.call(a):"";var s=a+"";return s=="0"&&1/a==-1/0?"-0":s}function isObject$3(a){var s=typeof a;return a!=null&&(s=="object"||s=="function")}function identity$1(a){return a}var asyncTag="[object AsyncFunction]",funcTag$2="[object Function]",genTag$1="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$2(a){if(!isObject$3(a))return!1;var s=baseGetTag(a);return s==funcTag$2||s==genTag$1||s==asyncTag||s==proxyTag}var coreJsData=root["__core-js_shared__"],maskSrcKey=function(){var a=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}();function isMasked(a){return!!maskSrcKey&&maskSrcKey in a}var funcProto$2=Function.prototype,funcToString$2=funcProto$2.toString;function toSource(a){if(a!=null){try{return funcToString$2.call(a)}catch{}try{return a+""}catch{}}return""}var reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto$1=Function.prototype,objectProto$e=Object.prototype,funcToString$1=funcProto$1.toString,hasOwnProperty$c=objectProto$e.hasOwnProperty,reIsNative=RegExp("^"+funcToString$1.call(hasOwnProperty$c).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative(a){if(!isObject$3(a)||isMasked(a))return!1;var s=isFunction$2(a)?reIsNative:reIsHostCtor;return s.test(toSource(a))}function getValue$1(a,s){return a==null?void 0:a[s]}function getNative(a,s){var c=getValue$1(a,s);return baseIsNative(c)?c:void 0}var WeakMap$1=getNative(root,"WeakMap"),objectCreate=Object.create,baseCreate=function(){function a(){}return function(s){if(!isObject$3(s))return{};if(objectCreate)return objectCreate(s);a.prototype=s;var c=new a;return a.prototype=void 0,c}}();function apply(a,s,c){switch(c.length){case 0:return a.call(s);case 1:return a.call(s,c[0]);case 2:return a.call(s,c[0],c[1]);case 3:return a.call(s,c[0],c[1],c[2])}return a.apply(s,c)}function copyArray(a,s){var c=-1,u=a.length;for(s||(s=Array(u));++c<u;)s[c]=a[c];return s}var HOT_COUNT=800,HOT_SPAN=16,nativeNow=Date.now;function shortOut(a){var s=0,c=0;return function(){var u=nativeNow(),d=HOT_SPAN-(u-c);if(c=u,d>0){if(++s>=HOT_COUNT)return arguments[0]}else s=0;return a.apply(void 0,arguments)}}function constant(a){return function(){return a}}var defineProperty$4=function(){try{var a=getNative(Object,"defineProperty");return a({},"",{}),a}catch{}}(),baseSetToString=defineProperty$4?function(a,s){return defineProperty$4(a,"toString",{configurable:!0,enumerable:!1,value:constant(s),writable:!0})}:identity$1,setToString=shortOut(baseSetToString);function arrayEach(a,s){for(var c=-1,u=a==null?0:a.length;++c<u&&s(a[c],c,a)!==!1;);return a}var MAX_SAFE_INTEGER$1=9007199254740991,reIsUint=/^(?:0|[1-9]\d*)$/;function isIndex(a,s){var c=typeof a;return s=s??MAX_SAFE_INTEGER$1,!!s&&(c=="number"||c!="symbol"&&reIsUint.test(a))&&a>-1&&a%1==0&&a<s}function baseAssignValue(a,s,c){s=="__proto__"&&defineProperty$4?defineProperty$4(a,s,{configurable:!0,enumerable:!0,value:c,writable:!0}):a[s]=c}function eq(a,s){return a===s||a!==a&&s!==s}var objectProto$d=Object.prototype,hasOwnProperty$b=objectProto$d.hasOwnProperty;function assignValue(a,s,c){var u=a[s];(!(hasOwnProperty$b.call(a,s)&&eq(u,c))||c===void 0&&!(s in a))&&baseAssignValue(a,s,c)}function copyObject(a,s,c,u){var d=!c;c||(c={});for(var p=-1,v=s.length;++p<v;){var A=s[p],b=void 0;b===void 0&&(b=a[A]),d?baseAssignValue(c,A,b):assignValue(c,A,b)}return c}var nativeMax=Math.max;function overRest(a,s,c){return s=nativeMax(s===void 0?a.length-1:s,0),function(){for(var u=arguments,d=-1,p=nativeMax(u.length-s,0),v=Array(p);++d<p;)v[d]=u[s+d];d=-1;for(var A=Array(s+1);++d<s;)A[d]=u[d];return A[s]=c(v),apply(a,this,A)}}function baseRest(a,s){return setToString(overRest(a,s,identity$1),a+"")}var MAX_SAFE_INTEGER=9007199254740991;function isLength(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=MAX_SAFE_INTEGER}function isArrayLike(a){return a!=null&&isLength(a.length)&&!isFunction$2(a)}function isIterateeCall(a,s,c){if(!isObject$3(c))return!1;var u=typeof s;return(u=="number"?isArrayLike(c)&&isIndex(s,c.length):u=="string"&&s in c)?eq(c[s],a):!1}function createAssigner(a){return baseRest(function(s,c){var u=-1,d=c.length,p=d>1?c[d-1]:void 0,v=d>2?c[2]:void 0;for(p=a.length>3&&typeof p=="function"?(d--,p):void 0,v&&isIterateeCall(c[0],c[1],v)&&(p=d<3?void 0:p,d=1),s=Object(s);++u<d;){var A=c[u];A&&a(s,A,u,p)}return s})}var objectProto$c=Object.prototype;function isPrototype(a){var s=a&&a.constructor,c=typeof s=="function"&&s.prototype||objectProto$c;return a===c}function baseTimes(a,s){for(var c=-1,u=Array(a);++c<a;)u[c]=s(c);return u}var argsTag$3="[object Arguments]";function baseIsArguments(a){return isObjectLike(a)&&baseGetTag(a)==argsTag$3}var objectProto$b=Object.prototype,hasOwnProperty$a=objectProto$b.hasOwnProperty,propertyIsEnumerable$1=objectProto$b.propertyIsEnumerable,isArguments=baseIsArguments(function(){return arguments}())?baseIsArguments:function(a){return isObjectLike(a)&&hasOwnProperty$a.call(a,"callee")&&!propertyIsEnumerable$1.call(a,"callee")};function stubFalse(){return!1}var freeExports$2=typeof exports=="object"&&exports&&!exports.nodeType&&exports,freeModule$2=freeExports$2&&typeof module=="object"&&module&&!module.nodeType&&module,moduleExports$2=freeModule$2&&freeModule$2.exports===freeExports$2,Buffer$2=moduleExports$2?root.Buffer:void 0,nativeIsBuffer=Buffer$2?Buffer$2.isBuffer:void 0,isBuffer=nativeIsBuffer||stubFalse,argsTag$2="[object Arguments]",arrayTag$2="[object Array]",boolTag$3="[object Boolean]",dateTag$3="[object Date]",errorTag$2="[object Error]",funcTag$1="[object Function]",mapTag$5="[object Map]",numberTag$3="[object Number]",objectTag$4="[object Object]",regexpTag$3="[object RegExp]",setTag$5="[object Set]",stringTag$3="[object String]",weakMapTag$2="[object WeakMap]",arrayBufferTag$3="[object ArrayBuffer]",dataViewTag$4="[object DataView]",float32Tag$2="[object Float32Array]",float64Tag$2="[object Float64Array]",int8Tag$2="[object Int8Array]",int16Tag$2="[object Int16Array]",int32Tag$2="[object Int32Array]",uint8Tag$2="[object Uint8Array]",uint8ClampedTag$2="[object Uint8ClampedArray]",uint16Tag$2="[object Uint16Array]",uint32Tag$2="[object Uint32Array]",typedArrayTags={};typedArrayTags[float32Tag$2]=typedArrayTags[float64Tag$2]=typedArrayTags[int8Tag$2]=typedArrayTags[int16Tag$2]=typedArrayTags[int32Tag$2]=typedArrayTags[uint8Tag$2]=typedArrayTags[uint8ClampedTag$2]=typedArrayTags[uint16Tag$2]=typedArrayTags[uint32Tag$2]=!0,typedArrayTags[argsTag$2]=typedArrayTags[arrayTag$2]=typedArrayTags[arrayBufferTag$3]=typedArrayTags[boolTag$3]=typedArrayTags[dataViewTag$4]=typedArrayTags[dateTag$3]=typedArrayTags[errorTag$2]=typedArrayTags[funcTag$1]=typedArrayTags[mapTag$5]=typedArrayTags[numberTag$3]=typedArrayTags[objectTag$4]=typedArrayTags[regexpTag$3]=typedArrayTags[setTag$5]=typedArrayTags[stringTag$3]=typedArrayTags[weakMapTag$2]=!1;function baseIsTypedArray(a){return isObjectLike(a)&&isLength(a.length)&&!!typedArrayTags[baseGetTag(a)]}function baseUnary(a){return function(s){return a(s)}}var freeExports$1=typeof exports=="object"&&exports&&!exports.nodeType&&exports,freeModule$1=freeExports$1&&typeof module=="object"&&module&&!module.nodeType&&module,moduleExports$1=freeModule$1&&freeModule$1.exports===freeExports$1,freeProcess=moduleExports$1&&freeGlobal.process,nodeUtil=function(){try{var a=freeModule$1&&freeModule$1.require&&freeModule$1.require("util").types;return a||freeProcess&&freeProcess.binding&&freeProcess.binding("util")}catch{}}(),nodeIsTypedArray=nodeUtil&&nodeUtil.isTypedArray,isTypedArray=nodeIsTypedArray?baseUnary(nodeIsTypedArray):baseIsTypedArray,objectProto$a=Object.prototype,hasOwnProperty$9=objectProto$a.hasOwnProperty;function arrayLikeKeys(a,s){var c=isArray$2(a),u=!c&&isArguments(a),d=!c&&!u&&isBuffer(a),p=!c&&!u&&!d&&isTypedArray(a),v=c||u||d||p,A=v?baseTimes(a.length,String):[],b=A.length;for(var g in a)(s||hasOwnProperty$9.call(a,g))&&!(v&&(g=="length"||d&&(g=="offset"||g=="parent")||p&&(g=="buffer"||g=="byteLength"||g=="byteOffset")||isIndex(g,b)))&&A.push(g);return A}function overArg(a,s){return function(c){return a(s(c))}}var nativeKeys=overArg(Object.keys,Object),objectProto$9=Object.prototype,hasOwnProperty$8=objectProto$9.hasOwnProperty;function baseKeys(a){if(!isPrototype(a))return nativeKeys(a);var s=[];for(var c in Object(a))hasOwnProperty$8.call(a,c)&&c!="constructor"&&s.push(c);return s}function keys(a){return isArrayLike(a)?arrayLikeKeys(a):baseKeys(a)}function nativeKeysIn(a){var s=[];if(a!=null)for(var c in Object(a))s.push(c);return s}var objectProto$8=Object.prototype,hasOwnProperty$7=objectProto$8.hasOwnProperty;function baseKeysIn(a){if(!isObject$3(a))return nativeKeysIn(a);var s=isPrototype(a),c=[];for(var u in a)u=="constructor"&&(s||!hasOwnProperty$7.call(a,u))||c.push(u);return c}function keysIn(a){return isArrayLike(a)?arrayLikeKeys(a,!0):baseKeysIn(a)}var reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey(a,s){if(isArray$2(a))return!1;var c=typeof a;return c=="number"||c=="symbol"||c=="boolean"||a==null||isSymbol(a)?!0:reIsPlainProp.test(a)||!reIsDeepProp.test(a)||s!=null&&a in Object(s)}var nativeCreate=getNative(Object,"create");function hashClear(){this.__data__=nativeCreate?nativeCreate(null):{},this.size=0}function hashDelete(a){var s=this.has(a)&&delete this.__data__[a];return this.size-=s?1:0,s}var HASH_UNDEFINED$2="__lodash_hash_undefined__",objectProto$7=Object.prototype,hasOwnProperty$6=objectProto$7.hasOwnProperty;function hashGet(a){var s=this.__data__;if(nativeCreate){var c=s[a];return c===HASH_UNDEFINED$2?void 0:c}return hasOwnProperty$6.call(s,a)?s[a]:void 0}var objectProto$6=Object.prototype,hasOwnProperty$5=objectProto$6.hasOwnProperty;function hashHas(a){var s=this.__data__;return nativeCreate?s[a]!==void 0:hasOwnProperty$5.call(s,a)}var HASH_UNDEFINED$1="__lodash_hash_undefined__";function hashSet(a,s){var c=this.__data__;return this.size+=this.has(a)?0:1,c[a]=nativeCreate&&s===void 0?HASH_UNDEFINED$1:s,this}function Hash(a){var s=-1,c=a==null?0:a.length;for(this.clear();++s<c;){var u=a[s];this.set(u[0],u[1])}}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet;function listCacheClear(){this.__data__=[],this.size=0}function assocIndexOf(a,s){for(var c=a.length;c--;)if(eq(a[c][0],s))return c;return-1}var arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete(a){var s=this.__data__,c=assocIndexOf(s,a);if(c<0)return!1;var u=s.length-1;return c==u?s.pop():splice.call(s,c,1),--this.size,!0}function listCacheGet(a){var s=this.__data__,c=assocIndexOf(s,a);return c<0?void 0:s[c][1]}function listCacheHas(a){return assocIndexOf(this.__data__,a)>-1}function listCacheSet(a,s){var c=this.__data__,u=assocIndexOf(c,a);return u<0?(++this.size,c.push([a,s])):c[u][1]=s,this}function ListCache(a){var s=-1,c=a==null?0:a.length;for(this.clear();++s<c;){var u=a[s];this.set(u[0],u[1])}}ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;var Map$1=getNative(root,"Map");function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}function isKeyable(a){var s=typeof a;return s=="string"||s=="number"||s=="symbol"||s=="boolean"?a!=="__proto__":a===null}function getMapData(a,s){var c=a.__data__;return isKeyable(s)?c[typeof s=="string"?"string":"hash"]:c.map}function mapCacheDelete(a){var s=getMapData(this,a).delete(a);return this.size-=s?1:0,s}function mapCacheGet(a){return getMapData(this,a).get(a)}function mapCacheHas(a){return getMapData(this,a).has(a)}function mapCacheSet(a,s){var c=getMapData(this,a),u=c.size;return c.set(a,s),this.size+=c.size==u?0:1,this}function MapCache(a){var s=-1,c=a==null?0:a.length;for(this.clear();++s<c;){var u=a[s];this.set(u[0],u[1])}}MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var FUNC_ERROR_TEXT$1="Expected a function";function memoize(a,s){if(typeof a!="function"||s!=null&&typeof s!="function")throw new TypeError(FUNC_ERROR_TEXT$1);var c=function(){var u=arguments,d=s?s.apply(this,u):u[0],p=c.cache;if(p.has(d))return p.get(d);var v=a.apply(this,u);return c.cache=p.set(d,v)||p,v};return c.cache=new(memoize.Cache||MapCache),c}memoize.Cache=MapCache;var MAX_MEMOIZE_SIZE=500;function memoizeCapped(a){var s=memoize(a,function(u){return c.size===MAX_MEMOIZE_SIZE&&c.clear(),u}),c=s.cache;return s}var rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath=memoizeCapped(function(a){var s=[];return a.charCodeAt(0)===46&&s.push(""),a.replace(rePropName,function(c,u,d,p){s.push(d?p.replace(reEscapeChar,"$1"):u||c)}),s});function toString(a){return a==null?"":baseToString(a)}function castPath(a,s){return isArray$2(a)?a:isKey(a,s)?[a]:stringToPath(toString(a))}function toKey(a){if(typeof a=="string"||isSymbol(a))return a;var s=a+"";return s=="0"&&1/a==-1/0?"-0":s}function baseGet(a,s){s=castPath(s,a);for(var c=0,u=s.length;a!=null&&c<u;)a=a[toKey(s[c++])];return c&&c==u?a:void 0}function get(a,s,c){var u=a==null?void 0:baseGet(a,s);return u===void 0?c:u}function arrayPush(a,s){for(var c=-1,u=s.length,d=a.length;++c<u;)a[d+c]=s[c];return a}var getPrototype=overArg(Object.getPrototypeOf,Object),objectTag$3="[object Object]",funcProto=Function.prototype,objectProto$5=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$4=objectProto$5.hasOwnProperty,objectCtorString=funcToString.call(Object);function isPlainObject(a){if(!isObjectLike(a)||baseGetTag(a)!=objectTag$3)return!1;var s=getPrototype(a);if(s===null)return!0;var c=hasOwnProperty$4.call(s,"constructor")&&s.constructor;return typeof c=="function"&&c instanceof c&&funcToString.call(c)==objectCtorString}function baseSlice(a,s,c){var u=-1,d=a.length;s<0&&(s=-s>d?0:d+s),c=c>d?d:c,c<0&&(c+=d),d=s>c?0:c-s>>>0,s>>>=0;for(var p=Array(d);++u<d;)p[u]=a[u+s];return p}function stackClear(){this.__data__=new ListCache,this.size=0}function stackDelete(a){var s=this.__data__,c=s.delete(a);return this.size=s.size,c}function stackGet(a){return this.__data__.get(a)}function stackHas(a){return this.__data__.has(a)}var LARGE_ARRAY_SIZE=200;function stackSet(a,s){var c=this.__data__;if(c instanceof ListCache){var u=c.__data__;if(!Map$1||u.length<LARGE_ARRAY_SIZE-1)return u.push([a,s]),this.size=++c.size,this;c=this.__data__=new MapCache(u)}return c.set(a,s),this.size=c.size,this}function Stack(a){var s=this.__data__=new ListCache(a);this.size=s.size}Stack.prototype.clear=stackClear,Stack.prototype.delete=stackDelete,Stack.prototype.get=stackGet,Stack.prototype.has=stackHas,Stack.prototype.set=stackSet;var freeExports=typeof exports=="object"&&exports&&!exports.nodeType&&exports,freeModule=freeExports&&typeof module=="object"&&module&&!module.nodeType&&module,moduleExports=freeModule&&freeModule.exports===freeExports,Buffer$1=moduleExports?root.Buffer:void 0,allocUnsafe=Buffer$1?Buffer$1.allocUnsafe:void 0;function cloneBuffer(a,s){if(s)return a.slice();var c=a.length,u=allocUnsafe?allocUnsafe(c):new a.constructor(c);return a.copy(u),u}function arrayFilter(a,s){for(var c=-1,u=a==null?0:a.length,d=0,p=[];++c<u;){var v=a[c];s(v,c,a)&&(p[d++]=v)}return p}function stubArray(){return[]}var objectProto$4=Object.prototype,propertyIsEnumerable=objectProto$4.propertyIsEnumerable,nativeGetSymbols$1=Object.getOwnPropertySymbols,getSymbols=nativeGetSymbols$1?function(a){return a==null?[]:(a=Object(a),arrayFilter(nativeGetSymbols$1(a),function(s){return propertyIsEnumerable.call(a,s)}))}:stubArray,nativeGetSymbols=Object.getOwnPropertySymbols,getSymbolsIn=nativeGetSymbols?function(a){for(var s=[];a;)arrayPush(s,getSymbols(a)),a=getPrototype(a);return s}:stubArray;function baseGetAllKeys(a,s,c){var u=s(a);return isArray$2(a)?u:arrayPush(u,c(a))}function getAllKeys(a){return baseGetAllKeys(a,keys,getSymbols)}function getAllKeysIn(a){return baseGetAllKeys(a,keysIn,getSymbolsIn)}var DataView$1=getNative(root,"DataView"),Promise$1=getNative(root,"Promise"),Set$1=getNative(root,"Set"),mapTag$4="[object Map]",objectTag$2="[object Object]",promiseTag="[object Promise]",setTag$4="[object Set]",weakMapTag$1="[object WeakMap]",dataViewTag$3="[object DataView]",dataViewCtorString=toSource(DataView$1),mapCtorString=toSource(Map$1),promiseCtorString=toSource(Promise$1),setCtorString=toSource(Set$1),weakMapCtorString=toSource(WeakMap$1),getTag=baseGetTag;(DataView$1&&getTag(new DataView$1(new ArrayBuffer(1)))!=dataViewTag$3||Map$1&&getTag(new Map$1)!=mapTag$4||Promise$1&&getTag(Promise$1.resolve())!=promiseTag||Set$1&&getTag(new Set$1)!=setTag$4||WeakMap$1&&getTag(new WeakMap$1)!=weakMapTag$1)&&(getTag=function(a){var s=baseGetTag(a),c=s==objectTag$2?a.constructor:void 0,u=c?toSource(c):"";if(u)switch(u){case dataViewCtorString:return dataViewTag$3;case mapCtorString:return mapTag$4;case promiseCtorString:return promiseTag;case setCtorString:return setTag$4;case weakMapCtorString:return weakMapTag$1}return s});var objectProto$3=Object.prototype,hasOwnProperty$3=objectProto$3.hasOwnProperty;function initCloneArray(a){var s=a.length,c=new a.constructor(s);return s&&typeof a[0]=="string"&&hasOwnProperty$3.call(a,"index")&&(c.index=a.index,c.input=a.input),c}var Uint8Array$1=root.Uint8Array;function cloneArrayBuffer(a){var s=new a.constructor(a.byteLength);return new Uint8Array$1(s).set(new Uint8Array$1(a)),s}function cloneDataView(a,s){var c=cloneArrayBuffer(a.buffer);return new a.constructor(c,a.byteOffset,a.byteLength)}var reFlags=/\w*$/;function cloneRegExp(a){var s=new a.constructor(a.source,reFlags.exec(a));return s.lastIndex=a.lastIndex,s}var symbolProto$1=Symbol$1?Symbol$1.prototype:void 0,symbolValueOf$1=symbolProto$1?symbolProto$1.valueOf:void 0;function cloneSymbol(a){return symbolValueOf$1?Object(symbolValueOf$1.call(a)):{}}function cloneTypedArray(a,s){var c=s?cloneArrayBuffer(a.buffer):a.buffer;return new a.constructor(c,a.byteOffset,a.length)}var boolTag$2="[object Boolean]",dateTag$2="[object Date]",mapTag$3="[object Map]",numberTag$2="[object Number]",regexpTag$2="[object RegExp]",setTag$3="[object Set]",stringTag$2="[object String]",symbolTag$2="[object Symbol]",arrayBufferTag$2="[object ArrayBuffer]",dataViewTag$2="[object DataView]",float32Tag$1="[object Float32Array]",float64Tag$1="[object Float64Array]",int8Tag$1="[object Int8Array]",int16Tag$1="[object Int16Array]",int32Tag$1="[object Int32Array]",uint8Tag$1="[object Uint8Array]",uint8ClampedTag$1="[object Uint8ClampedArray]",uint16Tag$1="[object Uint16Array]",uint32Tag$1="[object Uint32Array]";function initCloneByTag(a,s,c){var u=a.constructor;switch(s){case arrayBufferTag$2:return cloneArrayBuffer(a);case boolTag$2:case dateTag$2:return new u(+a);case dataViewTag$2:return cloneDataView(a);case float32Tag$1:case float64Tag$1:case int8Tag$1:case int16Tag$1:case int32Tag$1:case uint8Tag$1:case uint8ClampedTag$1:case uint16Tag$1:case uint32Tag$1:return cloneTypedArray(a,c);case mapTag$3:return new u;case numberTag$2:case stringTag$2:return new u(a);case regexpTag$2:return cloneRegExp(a);case setTag$3:return new u;case symbolTag$2:return cloneSymbol(a)}}function initCloneObject(a){return typeof a.constructor=="function"&&!isPrototype(a)?baseCreate(getPrototype(a)):{}}var mapTag$2="[object Map]";function baseIsMap(a){return isObjectLike(a)&&getTag(a)==mapTag$2}var nodeIsMap=nodeUtil&&nodeUtil.isMap,isMap=nodeIsMap?baseUnary(nodeIsMap):baseIsMap,setTag$2="[object Set]";function baseIsSet(a){return isObjectLike(a)&&getTag(a)==setTag$2}var nodeIsSet=nodeUtil&&nodeUtil.isSet,isSet=nodeIsSet?baseUnary(nodeIsSet):baseIsSet,CLONE_DEEP_FLAG$1=1,argsTag$1="[object Arguments]",arrayTag$1="[object Array]",boolTag$1="[object Boolean]",dateTag$1="[object Date]",errorTag$1="[object Error]",funcTag="[object Function]",genTag="[object GeneratorFunction]",mapTag$1="[object Map]",numberTag$1="[object Number]",objectTag$1="[object Object]",regexpTag$1="[object RegExp]",setTag$1="[object Set]",stringTag$1="[object String]",symbolTag$1="[object Symbol]",weakMapTag="[object WeakMap]",arrayBufferTag$1="[object ArrayBuffer]",dataViewTag$1="[object DataView]",float32Tag="[object Float32Array]",float64Tag="[object Float64Array]",int8Tag="[object Int8Array]",int16Tag="[object Int16Array]",int32Tag="[object Int32Array]",uint8Tag="[object Uint8Array]",uint8ClampedTag="[object Uint8ClampedArray]",uint16Tag="[object Uint16Array]",uint32Tag="[object Uint32Array]",cloneableTags={};cloneableTags[argsTag$1]=cloneableTags[arrayTag$1]=cloneableTags[arrayBufferTag$1]=cloneableTags[dataViewTag$1]=cloneableTags[boolTag$1]=cloneableTags[dateTag$1]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[mapTag$1]=cloneableTags[numberTag$1]=cloneableTags[objectTag$1]=cloneableTags[regexpTag$1]=cloneableTags[setTag$1]=cloneableTags[stringTag$1]=cloneableTags[symbolTag$1]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=!0,cloneableTags[errorTag$1]=cloneableTags[funcTag]=cloneableTags[weakMapTag]=!1;function baseClone(a,s,c,u,d,p){var v,A=s&CLONE_DEEP_FLAG$1;if(v!==void 0)return v;if(!isObject$3(a))return a;var b=isArray$2(a);if(b)v=initCloneArray(a);else{var g=getTag(a),x=g==funcTag||g==genTag;if(isBuffer(a))return cloneBuffer(a,A);if(g==objectTag$1||g==argsTag$1||x&&!d)v=x?{}:initCloneObject(a);else{if(!cloneableTags[g])return d?a:{};v=initCloneByTag(a,g,A)}}p||(p=new Stack);var y=p.get(a);if(y)return y;p.set(a,v),isSet(a)?a.forEach(function(C){v.add(baseClone(C,s,c,C,a,p))}):isMap(a)&&a.forEach(function(C,S){v.set(S,baseClone(C,s,c,S,a,p))});var f=getAllKeys,m=b?void 0:f(a);return arrayEach(m||a,function(C,S){m&&(S=C,C=a[S]),assignValue(v,S,baseClone(C,s,c,S,a,p))}),v}var CLONE_DEEP_FLAG=1,CLONE_SYMBOLS_FLAG=4;function cloneDeep(a){return baseClone(a,CLONE_DEEP_FLAG|CLONE_SYMBOLS_FLAG)}var HASH_UNDEFINED="__lodash_hash_undefined__";function setCacheAdd(a){return this.__data__.set(a,HASH_UNDEFINED),this}function setCacheHas(a){return this.__data__.has(a)}function SetCache(a){var s=-1,c=a==null?0:a.length;for(this.__data__=new MapCache;++s<c;)this.add(a[s])}SetCache.prototype.add=SetCache.prototype.push=setCacheAdd,SetCache.prototype.has=setCacheHas;function arraySome(a,s){for(var c=-1,u=a==null?0:a.length;++c<u;)if(s(a[c],c,a))return!0;return!1}function cacheHas(a,s){return a.has(s)}var COMPARE_PARTIAL_FLAG$5=1,COMPARE_UNORDERED_FLAG$3=2;function equalArrays(a,s,c,u,d,p){var v=c&COMPARE_PARTIAL_FLAG$5,A=a.length,b=s.length;if(A!=b&&!(v&&b>A))return!1;var g=p.get(a),x=p.get(s);if(g&&x)return g==s&&x==a;var y=-1,f=!0,m=c&COMPARE_UNORDERED_FLAG$3?new SetCache:void 0;for(p.set(a,s),p.set(s,a);++y<A;){var C=a[y],S=s[y];if(u)var w=v?u(S,C,y,s,a,p):u(C,S,y,a,s,p);if(w!==void 0){if(w)continue;f=!1;break}if(m){if(!arraySome(s,function(_,I){if(!cacheHas(m,I)&&(C===_||d(C,_,c,u,p)))return m.push(I)})){f=!1;break}}else if(!(C===S||d(C,S,c,u,p))){f=!1;break}}return p.delete(a),p.delete(s),f}function mapToArray(a){var s=-1,c=Array(a.size);return a.forEach(function(u,d){c[++s]=[d,u]}),c}function setToArray(a){var s=-1,c=Array(a.size);return a.forEach(function(u){c[++s]=u}),c}var COMPARE_PARTIAL_FLAG$4=1,COMPARE_UNORDERED_FLAG$2=2,boolTag="[object Boolean]",dateTag="[object Date]",errorTag="[object Error]",mapTag="[object Map]",numberTag="[object Number]",regexpTag="[object RegExp]",setTag="[object Set]",stringTag="[object String]",symbolTag="[object Symbol]",arrayBufferTag="[object ArrayBuffer]",dataViewTag="[object DataView]",symbolProto=Symbol$1?Symbol$1.prototype:void 0,symbolValueOf=symbolProto?symbolProto.valueOf:void 0;function equalByTag(a,s,c,u,d,p,v){switch(c){case dataViewTag:if(a.byteLength!=s.byteLength||a.byteOffset!=s.byteOffset)return!1;a=a.buffer,s=s.buffer;case arrayBufferTag:return!(a.byteLength!=s.byteLength||!p(new Uint8Array$1(a),new Uint8Array$1(s)));case boolTag:case dateTag:case numberTag:return eq(+a,+s);case errorTag:return a.name==s.name&&a.message==s.message;case regexpTag:case stringTag:return a==s+"";case mapTag:var A=mapToArray;case setTag:var b=u&COMPARE_PARTIAL_FLAG$4;if(A||(A=setToArray),a.size!=s.size&&!b)return!1;var g=v.get(a);if(g)return g==s;u|=COMPARE_UNORDERED_FLAG$2,v.set(a,s);var x=equalArrays(A(a),A(s),u,d,p,v);return v.delete(a),x;case symbolTag:if(symbolValueOf)return symbolValueOf.call(a)==symbolValueOf.call(s)}return!1}var COMPARE_PARTIAL_FLAG$3=1,objectProto$2=Object.prototype,hasOwnProperty$2=objectProto$2.hasOwnProperty;function equalObjects(a,s,c,u,d,p){var v=c&COMPARE_PARTIAL_FLAG$3,A=getAllKeys(a),b=A.length,g=getAllKeys(s),x=g.length;if(b!=x&&!v)return!1;for(var y=b;y--;){var f=A[y];if(!(v?f in s:hasOwnProperty$2.call(s,f)))return!1}var m=p.get(a),C=p.get(s);if(m&&C)return m==s&&C==a;var S=!0;p.set(a,s),p.set(s,a);for(var w=v;++y<b;){f=A[y];var _=a[f],I=s[f];if(u)var $=v?u(I,_,f,s,a,p):u(_,I,f,a,s,p);if(!($===void 0?_===I||d(_,I,c,u,p):$)){S=!1;break}w||(w=f=="constructor")}if(S&&!w){var P=a.constructor,E=s.constructor;P!=E&&"constructor"in a&&"constructor"in s&&!(typeof P=="function"&&P instanceof P&&typeof E=="function"&&E instanceof E)&&(S=!1)}return p.delete(a),p.delete(s),S}var COMPARE_PARTIAL_FLAG$2=1,argsTag="[object Arguments]",arrayTag="[object Array]",objectTag="[object Object]",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function baseIsEqualDeep(a,s,c,u,d,p){var v=isArray$2(a),A=isArray$2(s),b=v?arrayTag:getTag(a),g=A?arrayTag:getTag(s);b=b==argsTag?objectTag:b,g=g==argsTag?objectTag:g;var x=b==objectTag,y=g==objectTag,f=b==g;if(f&&isBuffer(a)){if(!isBuffer(s))return!1;v=!0,x=!1}if(f&&!x)return p||(p=new Stack),v||isTypedArray(a)?equalArrays(a,s,c,u,d,p):equalByTag(a,s,b,c,u,d,p);if(!(c&COMPARE_PARTIAL_FLAG$2)){var m=x&&hasOwnProperty$1.call(a,"__wrapped__"),C=y&&hasOwnProperty$1.call(s,"__wrapped__");if(m||C){var S=m?a.value():a,w=C?s.value():s;return p||(p=new Stack),d(S,w,c,u,p)}}return f?(p||(p=new Stack),equalObjects(a,s,c,u,d,p)):!1}function baseIsEqual(a,s,c,u,d){return a===s?!0:a==null||s==null||!isObjectLike(a)&&!isObjectLike(s)?a!==a&&s!==s:baseIsEqualDeep(a,s,c,u,baseIsEqual,d)}var COMPARE_PARTIAL_FLAG$1=1,COMPARE_UNORDERED_FLAG$1=2;function baseIsMatch(a,s,c,u){var d=c.length,p=d;if(a==null)return!p;for(a=Object(a);d--;){var v=c[d];if(v[2]?v[1]!==a[v[0]]:!(v[0]in a))return!1}for(;++d<p;){v=c[d];var A=v[0],b=a[A],g=v[1];if(v[2]){if(b===void 0&&!(A in a))return!1}else{var x=new Stack,y;if(!(y===void 0?baseIsEqual(g,b,COMPARE_PARTIAL_FLAG$1|COMPARE_UNORDERED_FLAG$1,u,x):y))return!1}}return!0}function isStrictComparable(a){return a===a&&!isObject$3(a)}function getMatchData(a){for(var s=keys(a),c=s.length;c--;){var u=s[c],d=a[u];s[c]=[u,d,isStrictComparable(d)]}return s}function matchesStrictComparable(a,s){return function(c){return c==null?!1:c[a]===s&&(s!==void 0||a in Object(c))}}function baseMatches(a){var s=getMatchData(a);return s.length==1&&s[0][2]?matchesStrictComparable(s[0][0],s[0][1]):function(c){return c===a||baseIsMatch(c,a,s)}}function baseHasIn(a,s){return a!=null&&s in Object(a)}function hasPath(a,s,c){s=castPath(s,a);for(var u=-1,d=s.length,p=!1;++u<d;){var v=toKey(s[u]);if(!(p=a!=null&&c(a,v)))break;a=a[v]}return p||++u!=d?p:(d=a==null?0:a.length,!!d&&isLength(d)&&isIndex(v,d)&&(isArray$2(a)||isArguments(a)))}function hasIn(a,s){return a!=null&&hasPath(a,s,baseHasIn)}var COMPARE_PARTIAL_FLAG=1,COMPARE_UNORDERED_FLAG=2;function baseMatchesProperty(a,s){return isKey(a)&&isStrictComparable(s)?matchesStrictComparable(toKey(a),s):function(c){var u=get(c,a);return u===void 0&&u===s?hasIn(c,a):baseIsEqual(s,u,COMPARE_PARTIAL_FLAG|COMPARE_UNORDERED_FLAG)}}function baseProperty(a){return function(s){return s==null?void 0:s[a]}}function basePropertyDeep(a){return function(s){return baseGet(s,a)}}function property(a){return isKey(a)?baseProperty(toKey(a)):basePropertyDeep(a)}function baseIteratee(a){return typeof a=="function"?a:a==null?identity$1:typeof a=="object"?isArray$2(a)?baseMatchesProperty(a[0],a[1]):baseMatches(a):property(a)}function createBaseFor(a){return function(s,c,u){for(var d=-1,p=Object(s),v=u(s),A=v.length;A--;){var b=v[++d];if(c(p[b],b,p)===!1)break}return s}}var baseFor=createBaseFor();function baseForOwn(a,s){return a&&baseFor(a,s,keys)}function createBaseEach(a,s){return function(c,u){if(c==null)return c;if(!isArrayLike(c))return a(c,u);for(var d=c.length,p=-1,v=Object(c);++p<d&&u(v[p],p,v)!==!1;);return c}}var baseEach=createBaseEach(baseForOwn);function assignMergeValue(a,s,c){(c!==void 0&&!eq(a[s],c)||c===void 0&&!(s in a))&&baseAssignValue(a,s,c)}function isArrayLikeObject(a){return isObjectLike(a)&&isArrayLike(a)}function safeGet$1(a,s){if(!(s==="constructor"&&typeof a[s]=="function")&&s!="__proto__")return a[s]}function toPlainObject(a){return copyObject(a,keysIn(a))}function baseMergeDeep(a,s,c,u,d,p,v){var A=safeGet$1(a,c),b=safeGet$1(s,c),g=v.get(b);if(g){assignMergeValue(a,c,g);return}var x=p?p(A,b,c+"",a,s,v):void 0,y=x===void 0;if(y){var f=isArray$2(b),m=!f&&isBuffer(b),C=!f&&!m&&isTypedArray(b);x=b,f||m||C?isArray$2(A)?x=A:isArrayLikeObject(A)?x=copyArray(A):m?(y=!1,x=cloneBuffer(b,!0)):C?(y=!1,x=cloneTypedArray(b,!0)):x=[]:isPlainObject(b)||isArguments(b)?(x=A,isArguments(A)?x=toPlainObject(A):(!isObject$3(A)||isFunction$2(A))&&(x=initCloneObject(b))):y=!1}y&&(v.set(b,x),d(x,b,u,p,v),v.delete(b)),assignMergeValue(a,c,x)}function baseMerge(a,s,c,u,d){a!==s&&baseFor(s,function(p,v){if(d||(d=new Stack),isObject$3(p))baseMergeDeep(a,s,v,c,baseMerge,u,d);else{var A=u?u(safeGet$1(a,v),p,v+"",a,s,d):void 0;A===void 0&&(A=p),assignMergeValue(a,v,A)}},keysIn)}createAssigner(function(a,s,c,u){baseMerge(a,s,c,u)});function last(a){var s=a==null?0:a.length;return s?a[s-1]:void 0}var objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function baseHas(a,s){return a!=null&&hasOwnProperty.call(a,s)}function has(a,s){return a!=null&&hasPath(a,s,baseHas)}function parent(a,s){return s.length<2?a:baseGet(a,baseSlice(s,0,-1))}function isMatch(a,s){return a===s||baseIsMatch(a,s,getMatchData(s))}function isUndefined$1(a){return a===void 0}createAssigner(function(a,s,c){baseMerge(a,s,c)});var FUNC_ERROR_TEXT="Expected a function";function negate(a){if(typeof a!="function")throw new TypeError(FUNC_ERROR_TEXT);return function(){var s=arguments;switch(s.length){case 0:return!a.call(this);case 1:return!a.call(this,s[0]);case 2:return!a.call(this,s[0],s[1]);case 3:return!a.call(this,s[0],s[1],s[2])}return!a.apply(this,s)}}function baseUnset(a,s){return s=castPath(s,a),a=parent(a,s),a==null||delete a[toKey(last(s))]}function baseSet(a,s,c,u){if(!isObject$3(a))return a;s=castPath(s,a);for(var d=-1,p=s.length,v=p-1,A=a;A!=null&&++d<p;){var b=toKey(s[d]),g=c;if(b==="__proto__"||b==="constructor"||b==="prototype")return a;if(d!=v){var x=A[b];g=void 0,g===void 0&&(g=isObject$3(x)?x:isIndex(s[d+1])?[]:{})}assignValue(A,b,g),A=A[b]}return a}function basePickBy(a,s,c){for(var u=-1,d=s.length,p={};++u<d;){var v=s[u],A=baseGet(a,v);c(A,v)&&baseSet(p,castPath(v,a),A)}return p}function pickBy(a,s){if(a==null)return{};var c=arrayMap(getAllKeysIn(a),function(u){return[u]});return s=baseIteratee(s),basePickBy(a,c,function(u,d){return s(u,d[0])})}function omitBy(a,s){return pickBy(a,negate(baseIteratee(s)))}function set(a,s,c){return a==null?a:baseSet(a,s,c)}function baseSome(a,s){var c;return baseEach(a,function(u,d,p){return c=s(u,d,p),!c}),!!c}function some$1(a,s,c){var u=isArray$2(a)?arraySome:baseSome;return c&&isIterateeCall(a,s,c)&&(s=void 0),u(a,baseIteratee(s))}function unset(a,s){return a==null?!0:baseUnset(a,s)}const __vite_import_meta_env__={},createStoreImpl=a=>{let s;const c=new Set,u=(x,y)=>{const f=typeof x=="function"?x(s):x;if(!Object.is(f,s)){const m=s;s=y??(typeof f!="object"||f===null)?f:Object.assign({},s,f),c.forEach(C=>C(s,m))}},d=()=>s,b={setState:u,getState:d,getInitialState:()=>g,subscribe:x=>(c.add(x),()=>c.delete(x)),destroy:()=>{(__vite_import_meta_env__?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),c.clear()}},g=s=a(u,d,b);return b},createStore$1=a=>a?createStoreImpl(a):createStoreImpl;var withSelector={exports:{}},withSelector_production={},shim={exports:{}},useSyncExternalStoreShim_production={};/**
|
776
776
|
* @license React
|
@@ -878,9 +878,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
878
878
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _iterableToArrayLimit$2(a,s){var c=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if(c!=null){var u,d,p,v,A=[],b=!0,g=!1;try{if(p=(c=c.call(a)).next,s!==0)for(;!(b=(u=p.call(c)).done)&&(A.push(u.value),A.length!==s);b=!0);}catch(x){g=!0,d=x}finally{try{if(!b&&c.return!=null&&(v=c.return(),Object(v)!==v))return}finally{if(g)throw d}}return A}}function _arrayWithHoles$2(a){if(Array.isArray(a))return a}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray$2(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
879
879
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _unsupportedIterableToArray$2(a,s){if(a){if(typeof a=="string")return _arrayLikeToArray$2(a,s);var c={}.toString.call(a).slice(8,-1);return c==="Object"&&a.constructor&&(c=a.constructor.name),c==="Map"||c==="Set"?Array.from(a):c==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray$2(a,s):void 0}}function _iterableToArray(a){if(typeof Symbol<"u"&&a[Symbol.iterator]!=null||a["@@iterator"]!=null)return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray$2(a)}function _arrayLikeToArray$2(a,s){(s==null||s>a.length)&&(s=a.length);for(var c=0,u=Array(s);c<s;c++)u[c]=a[c];return u}var TabPaneContent=function a(s){var c=s.renderCore,u=s.name,d=s.schema,p=s.rootPath;return reactExports.useMemo(function(){return React.createElement("div",{style:{flex:1}},c({schema:d,parentPath:[u],rootPath:[].concat(_toConsumableArray(p),[u])}))},[JSON.stringify(s)])},TabList=function a(s){var c=s.schema,u=s.fields,d=s.rootPath,p=s.renderCore,v=s.readOnly,A=s.delConfirmProps,b=s.tabName,g=s.hideDelete,x=s.hideAdd,y=s.addItem,f=s.removeItem,m=s.tabItemProps,C=m===void 0?{}:m,S=s.activeKey,w=__rest$15(s,["schema","fields","rootPath","renderCore","readOnly","delConfirmProps","tabName","hideDelete","hideAdd","addItem","removeItem","tabItemProps","activeKey"]),_=reactExports.useState("0"),I=_slicedToArray$2(_,2),$=I[0],P=I[1],E=reactExports.useContext(ConfigProvider.ConfigContext),R=translation(E);reactExports.useEffect(function(){P(S||"0")},[S]);var T=function(H){return b instanceof Array?b[H]||H+1:"".concat(b||R("item")," ").concat(H+1)},B=function(H){f(H),P("".concat(H>1?H-1:0))},M=function(H,j){if(j==="add"&&(!c.max||u.length<c.max)&&!v&&!x){y();var q=u.length;P("".concat(q))}},k=function(H){return!v&&!g?React.createElement(Popconfirm,Object.assign({onConfirm:function(){return B(H)}},A),React.createElement(_CloseOutlined,null)):React.createElement(React.Fragment,null)};return React.createElement(Tabs,Object.assign({className:"fr-tab-list",type:"editable-card"},w,{onChange:P,activeKey:"".concat($),onEdit:M,hideAdd:v||x}),u.map(function(O){var H=O.key,j=O.name;return React.createElement(Tabs.TabPane,Object.assign({key:H,className:"fr-list-item"},C,{tab:T(j),closeIcon:k(j)}),React.createElement(TabPaneContent,{name:j,rootPath:d,schema:c,renderCore:p}))}))};function _typeof(a){"@babel/helpers - typeof";return _typeof=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},_typeof(a)}function _defineProperty(a,s,c){return(s=_toPropertyKey(s))in a?Object.defineProperty(a,s,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[s]=c,a}function _toPropertyKey(a){var s=_toPrimitive(a,"string");return _typeof(s)=="symbol"?s:s+""}function _toPrimitive(a,s){if(_typeof(a)!="object"||!a)return a;var c=a[Symbol.toPrimitive];if(c!==void 0){var u=c.call(a,s);if(_typeof(u)!="object")return u;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(a)}const index=function(a){var s=a.schema;return React.createElement("div",{className:classnames("fr-void-title",_defineProperty({},s==null?void 0:s.className,!!(s!=null&&s.className)))},s.title)};var ErrorSchema=function a(s){var c=reactExports.useContext(ConfigProvider.ConfigContext),u=translation(c);return React.createElement("div",null,React.createElement("div",{style:{color:"red"}},u("schema_not_match")),React.createElement("div",null,JSON.stringify(s)))};const defaultWidgets=Object.freeze(Object.defineProperty({__proto__:null,Card:BoxCard,CardList,Checkbox,Checkboxes:Checkboxes$1,Collapse:BoxCollapse,Color,DatePicker,DateRange:DateRange$1,DrawerList:TableList,ErrorSchema,Html:html,ImageInput:ImageInput$1,Input,InputNumber,LineTitle:FLineTitle,MultiSelect,PercentSlider,Radio,Rate:index$1,Select:MultiSelect,SimpleList,Slider,SubInline:BoxSubInline,Switch,TabList,TableList:TableList$1,TextArea:TextArea$1,TimePicker,TimeRange,TreeSelect,Upload:FrUpload,UrlInput:UrlInput$1,VirtualList,VoidTitle:index},Symbol.toStringTag,{value:"Module"}));function _slicedToArray$1(a,s){return _arrayWithHoles$1(a)||_iterableToArrayLimit$1(a,s)||_unsupportedIterableToArray$1(a,s)||_nonIterableRest$1()}function _nonIterableRest$1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
880
880
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _unsupportedIterableToArray$1(a,s){if(a){if(typeof a=="string")return _arrayLikeToArray$1(a,s);var c={}.toString.call(a).slice(8,-1);return c==="Object"&&a.constructor&&(c=a.constructor.name),c==="Map"||c==="Set"?Array.from(a):c==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray$1(a,s):void 0}}function _arrayLikeToArray$1(a,s){(s==null||s>a.length)&&(s=a.length);for(var c=0,u=Array(s);c<s;c++)u[c]=a[c];return u}function _iterableToArrayLimit$1(a,s){var c=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if(c!=null){var u,d,p,v,A=[],b=!0,g=!1;try{if(p=(c=c.call(a)).next,s!==0)for(;!(b=(u=p.call(c)).done)&&(A.push(u.value),A.length!==s);b=!0);}catch(x){g=!0,d=x}finally{try{if(!b&&c.return!=null&&(v=c.return(),Object(v)!==v))return}finally{if(g)throw d}}return A}}function _arrayWithHoles$1(a){if(Array.isArray(a))return a}function flattenSchema(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0,c=arguments.length>2?arguments[2]:void 0,u=arguments.length>3?arguments[3]:void 0,d=u||{},p=_cloneDeep(a)||{},v=s||"#";p.$id||(p.$id=v);var A=[];return isObjType(p)&&(sortProperties(Object.entries(p.properties)).forEach(function(b){var g=_slicedToArray$1(b,2),x=g[0],y=g[1],f=isListType(y)?x+"[]":x,m=v==="#"?f:v+"."+f;A.push(m),flattenSchema(y,m,v,d)}),p.properties={}),isListType(p)&&(sortProperties(Object.entries(p.items.properties)).forEach(function(b){var g=_slicedToArray$1(b,2),x=g[0],y=g[1],f=isListType(y)?x+"[]":x,m=v==="#"?f:v+"."+f;A.push(m),flattenSchema(y,m,v,d)}),p.items.properties={}),p.type&&(d[v]={parent:c,schema:p,children:A}),d}function _slicedToArray(a,s){return _arrayWithHoles(a)||_iterableToArrayLimit(a,s)||_unsupportedIterableToArray(a,s)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
881
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _unsupportedIterableToArray(a,s){if(a){if(typeof a=="string")return _arrayLikeToArray(a,s);var c={}.toString.call(a).slice(8,-1);return c==="Object"&&a.constructor&&(c=a.constructor.name),c==="Map"||c==="Set"?Array.from(a):c==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,s):void 0}}function _arrayLikeToArray(a,s){(s==null||s>a.length)&&(s=a.length);for(var c=0,u=Array(s);c<s;c++)u[c]=a[c];return u}function _iterableToArrayLimit(a,s){var c=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if(c!=null){var u,d,p,v,A=[],b=!0,g=!1;try{if(p=(c=c.call(a)).next,s!==0)for(;!(b=(u=p.call(c)).done)&&(A.push(u.value),A.length!==s);b=!0);}catch(x){g=!0,d=x}finally{try{if(!b&&c.return!=null&&(v=c.return(),Object(v)!==v))return}finally{if(g)throw d}}return A}}function _arrayWithHoles(a){if(Array.isArray(a))return a}var updateSchemaByPath=function a(s,c,u){var d=getSchemaFullPath(s,u),p=_get(u,d,{}),v=isFunction$1(c)?c(p):c,A=Object.assign(Object.assign({},p),v);v.props&&(A.props=Object.assign(Object.assign({},p==null?void 0:p.props),v.props)),_set(u,d,A)},getFieldName=function a(s){if(s){if(typeof s=="boolean")return s;var c=[];return isArray$1(s)&&(c=s.map(function(u){return u.split(".").map(function(d){return isNaN(Number(d))?d:d*1})})),c=s.split(".").map(function(u){return isNaN(Number(u))?u:u*1}),c=c.map(function(u){return typeof u=="string"&&(u==null?void 0:u.indexOf("["))===0&&(u==null?void 0:u.indexOf("]"))===(u==null?void 0:u.length)-1?Number(u.substring(1,u.length-1)):u}),c}},useForm=function a(){var s=Form$1.useForm(),c=_slicedToArray(s,1),u=c[0],d=reactExports.useRef({}),p=reactExports.useRef(null),v=reactExports.useRef({}),A=reactExports.useRef({});u.getFieldError;var b=u.getFieldsError,g=u.getFieldInstance,x=u.setFieldsValue,y=u.setFields,f=u.scrollToField,m=u.isFieldsTouched,C=u.isFieldTouched,S=u.isFieldValidating,w=u.resetFields,_=u.validateFields,I=__rest$15(u,["getFieldError","getFieldsError","getFieldInstance","setFieldsValue","setFields","scrollToField","isFieldsTouched","isFieldTouched","isFieldValidating","resetFields","validateFields"]),$=I,P=function(T){var B=p.current.setState;B||setTimeout(function(){B({schema:v.current,flattenSchema:d.current})},0),B(T)},E=function(T){d.current=flattenSchema(T)||{},v.current=T,P({schema:T,flattenSchema:d.current})};return $.setSchema=function(R){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(isObject$2(R)){if(T){E(R);return}var B=cloneDeep(v.current);Object.keys(R||{}).forEach(function(M){updateSchemaByPath(M,R[M],B)}),E(B)}},$.setSchemaByPath=function(R,T){if(!(!_hasFuncProperty(T)&&_isMatch(T,$.getSchemaByPath(R)))){var B=cloneDeep(v.current);updateSchemaByPath(R,T,B),E(B)}},$.setValues=function(R){var T=parseBindToValues(R,d.current);x(T)},$.getValues=function(R,T,B){var M,k=cloneDeep(u.getFieldsValue(getFieldName(R),T)),O=((M=p.current)===null||M===void 0?void 0:M.getState())||{},H=O.removeHiddenData;return H&&(k=filterValuesHidden(k,d.current)),B||(k=filterValuesUndefined(k)),parseValuesToBind(k,d.current)},$.getValueByPath=function(R){var T=getFieldName(R);return u.getFieldValue(T)},$.setValueByPath=function(R,T){if(!u.setFieldValue){var B=u.getFieldsValue();_set(B,R,T),$.setValues(B);return}var M=getFieldName(R);u.setFieldValue(M,T);try{JSON.stringify(u.getFieldValue(M))!==JSON.stringify(T)&&u.setFieldValue(M,T)}catch{}},$.getSchemaByPath=function(R){typeof R!="string"&&console.warn("请输入正确的路径");var T=getSchemaFullPath(R,v.current);return _get(v.current,T)},$.getSchema=function(){return v.current},$.setErrorFields=function(R){var T=transformFieldsData(R,getFieldName);T&&y(T)},$.removeErrorField=function(R){y([{name:getFieldName(R),errors:[]}])},$.getFieldError=function(R){var T=getFieldName(R);return u.getFieldError(T)},$.getFieldsError=function(R){var T=getFieldName(R);return b(T)},$.getFieldInstance=function(R){var T=getFieldName(R);return g(T)},$.getHiddenValues=function(){var R=$.getValues(),T=$.getValues(!0),B={},M=function(O,H,j){Object.keys(O).forEach(function(q){var L=O[q],F=j?"".concat(j,".").concat(q):q;if(!H.hasOwnProperty(q)){_set(B,F,L);return}isObject$2(L)&&M(L,H[q],F),isArray$1(L)&&L.map(function(U,N){M(U,_get(H,"".concat(q,"[").concat(N,"]"),[]),"".concat(F,"[").concat(N,"]"))})})};return M(T,R,null),B},$.setFields=function(R){var T=transformFieldsData(R,getFieldName);T&&y(T)},$.__initStore=function(R){p.current=R},$.scrollToPath=function(R){for(var T=getFieldName(R),B=arguments.length,M=new Array(B>1?B-1:0),k=1;k<B;k++)M[k-1]=arguments[k];f.apply(void 0,[T].concat(M))},$.isFieldsTouched=function(R,T){var B=(R||[]).map(function(M){return getFieldName(M)});return m(B,T)},$.isFieldTouched=function(R){var T=getFieldName(R);return C(T)},$.isFieldValidating=function(R){var T=getFieldName(R);return S(T)},$.resetFields=function(R){var T=(R||[]).map(function(B){return getFieldName(B)});T.length>0?w(T):w()},$.validateFields=function(R,T){var B=(R||[]).map(function(M){return getFieldName(M)});return B.length>0?_(B,T):_()},$.getFlattenSchema=function(R){var T;return R?(T=d.current)===null||T===void 0?void 0:T[R]:d.current},$.onItemChange=$.setValueByPath,$.setFieldRef=function(R,T){R&&(A.current[R]=T)},$.getFieldRef=function(R){return A.current[R]},$};const FormRenderComponent=withProvider(FormCore,defaultWidgets),AlignWidget=a=>{const{activeElements:s,changeSchemas:c,schemas:u,pageSize:d,schema:p}=a,v=g=>{const x=s.map(E=>E.id),y=u.filter(E=>x.includes(E.id)),f=["left","center","right"].includes(g),m=f?"x":"y",C=f?"width":"height",S=y.length===1,w=d&&typeof d=="object"?C==="width"?d.width:d.height:0,_=S?0:Math.min(...y.map(E=>{const R=E.position&&typeof E.position=="object"?E.position:{x:0,y:0};return m==="x"?R.x:R.y})),I=S?w:Math.max(...y.map(E=>{const R=E.position&&typeof E.position=="object"?E.position:{x:0,y:0},T=m==="x"?R.x:R.y,B=E,M=C==="width"?B.width||0:B.height||0;return T+M}));let $=_,P=E=>0;["center","middle"].includes(g)?($=(_+I)/2,P=E=>E/2):["right","bottom"].includes(g)&&($=I,P=E=>E),c(y.map(E=>{const R=E,T=C==="width"?R.width||0:R.height||0;return{key:`position.${m}`,value:round$1($-P(T),2),schemaId:R.id}}))},A=g=>{const x=s.map(T=>T.id),y=u.filter(T=>x.includes(T.id)),f=g==="vertical",m=f?"y":"x",C=f?"height":"width",S=Math.min(...y.map(T=>{const B=T.position&&typeof T.position=="object"?T.position:{x:0,y:0};return m==="x"?B.x:B.y})),w=Math.max(...y.map(T=>{const B=T.position&&typeof T.position=="object"?T.position:{x:0,y:0},M=m==="x"?B.x:B.y,k=T,O=C==="width"?k.width||0:k.height||0;return M+O}));if(y.length<3)return;const _=S,I=w-S,$=y.reduce((T,B)=>{const M=B,k=C==="width"?M.width||0:M.height||0;return T+k},0),E=(I-$)/(y.length-1);let R=0;c(y.map((T,B)=>{const M=B===0?0:(()=>{const H=y[B-1];return C==="width"?H.width||0:H.height||0})();R+=B===0?0:M+E;const k=round$1(_+R,2),O=T;return{key:`position.${m}`,value:k,schemaId:O.id}}))},b=[{id:"left",icon:jsxRuntimeExports.jsx(AlignStartVertical,{size:15}),onClick:()=>v("left")},{id:"center",icon:jsxRuntimeExports.jsx(AlignCenterVertical,{size:15}),onClick:()=>v("center")},{id:"right",icon:jsxRuntimeExports.jsx(AlignEndVertical,{size:15}),onClick:()=>v("right")},{id:"top",icon:jsxRuntimeExports.jsx(AlignStartHorizontal,{size:15}),onClick:()=>v("top")},{id:"middle",icon:jsxRuntimeExports.jsx(AlignCenterHorizontal,{size:15}),onClick:()=>v("middle")},{id:"bottom",icon:jsxRuntimeExports.jsx(AlignEndHorizontal,{size:15}),onClick:()=>v("bottom")},{id:"vertical",icon:jsxRuntimeExports.jsx(AlignVerticalSpaceAround,{size:15}),onClick:()=>A("vertical")},{id:"horizontal",icon:jsxRuntimeExports.jsx(AlignHorizontalSpaceAround,{size:15}),onClick:()=>A("horizontal")}];return jsxRuntimeExports.jsx(Form$1.Item,{label:p.title,children:jsxRuntimeExports.jsx(Space.Compact,{children:b.map(g=>jsxRuntimeExports.jsx(Button$1,{style:{padding:7},disabled:s.length<=2&&["vertical","horizontal"].includes(g.id),...g},g.id))})})},WidgetRenderer=a=>{const{widget:s,...c}=a,u=reactExports.useRef(null);return reactExports.useEffect(()=>(u.current&&(u.current.innerHTML="",s({...c,rootElement:u.current})),()=>{u.current&&(u.current.innerHTML="")}),[a.activeSchema]),jsxRuntimeExports.jsx("div",{ref:u})},ButtonGroupWidget=a=>{const{activeElements:s,changeSchemas:c,schemas:u,schema:d}=a,{token:p}=theme.useToken(),v=x=>{const y=x.key,f=x.type,m=s.map(S=>S.id),C=u.filter(S=>m.includes(S.id));c(C.map(S=>{const w=!!(S[y]??!1),_=f==="boolean"?!w:x.value;return{key:y,value:_,schemaId:S.id}}))},A=x=>{const y=x.key,f=x.type;let m=!1;const C=s.map(w=>w.id);return u.filter(w=>C.includes(w.id)).forEach(w=>{const _=w;m=f==="boolean"?!!(_[y]??!1):_[y]===x.value}),m},b=(x,y)=>y?x.replace(/="currentColor"/g,`="${y}"`):x,g=x=>{const y=`data:image/svg+xml;utf8,${encodeURIComponent(b(x,p.colorText))}`;return jsxRuntimeExports.jsx("img",{width:17,height:17,src:y,alt:""})};return jsxRuntimeExports.jsx(Form$1.Item,{children:jsxRuntimeExports.jsx(Space.Compact,{children:d.buttons.map((x,y)=>{const f=A(x);return jsxRuntimeExports.jsx(Button$1,{type:f?"primary":void 0,ghost:f,onClick:()=>v(x),style:{padding:7,zIndex:f?2:0},icon:g(x.icon)},y)})})})},{Text:Text$2}=Typography,DetailView=a=>{var B,M;const{token:s}=theme.useToken(),{size:c,schemasList:u,changeSchemas:d,deselectSchema:p,activeSchema:v}=a,A=useForm(),b=reactExports.useContext(I18nContext),g=reactExports.useContext(PluginsRegistry),x=reactExports.useContext(OptionsContext),y=k=>typeof b=="function"?b(k):k,[f,m]=reactExports.useState({});reactExports.useEffect(()=>{const k={AlignWidget:O=>jsxRuntimeExports.jsx(AlignWidget,{...O,...a,options:x}),Divider:()=>jsxRuntimeExports.jsx(Divider,{style:{marginTop:s.marginXS,marginBottom:s.marginXS}}),ButtonGroup:O=>jsxRuntimeExports.jsx(ButtonGroupWidget,{...O,...a,options:x})};for(const O of Object.values(g)){const H=(O==null?void 0:O.propPanel.widgets)||{};Object.entries(H).forEach(([j,q])=>{k[j]=L=>jsxRuntimeExports.jsx(WidgetRenderer,{...L,...a,options:x,theme:s,i18n:y,widget:q})})}m(k)},[v,g,JSON.stringify(x)]),reactExports.useEffect(()=>{const k={...v},O=typeof k.readOnly=="boolean"?k.readOnly:!1;k.editable=!O,A.setValues(k)},[v,A]),reactExports.useEffect(()=>A.resetFields(),[v.id]),reactExports.useEffect(()=>{C.current=k=>{for(const O of u)for(const H of Object.values(O))if(H.name===k&&H.id!==v.id)return!1;return!0}},[u,v]);const C=reactExports.useRef(k=>!0),S=(k,O)=>C.current(O),w=debounce$1(function(...k){const O=k[0],H=(q,L)=>typeof q=="object"&&q!==null?JSON.stringify(q)!==JSON.stringify(L):q!==L;let j=[];for(const q in O){if(["id","content"].includes(q))continue;let L=O[q];if(H(L,v[q])){if(L===null&&["rotate","opacity"].includes(q)&&(L=void 0),q==="editable"){const F=!L;j.push({key:"readOnly",value:F,schemaId:v.id}),F&&j.push({key:"required",value:!1,schemaId:v.id});continue}j.push({key:q,value:L,schemaId:v.id})}}j.length&&A.validateFields().then(()=>d(j)).catch(q=>{q.errorFields.length&&(j=j.filter(L=>!q.errorFields.find(F=>F.name.includes(L.key)))),j.length&&d(j)})},100),_=Object.values(g).find(k=>{if(!k||typeof k!="object"||!k.propPanel||typeof k.propPanel!="object"||!k.propPanel.defaultSchema||typeof k.propPanel.defaultSchema!="object")return!1;const O=k.propPanel.defaultSchema;return"type"in O&&typeof O.type=="string"&&O.type===v.type}),I=(B=_==null?void 0:_.propPanel)==null?void 0:B.schema;I||console.error(`[@pdfme/ui] No propPanel.schema for ${v.type}.
|
882
|
-
Check this document: https://pdfme.com/docs/custom-schemas`)
|
883
|
-
Check this document: https://pdfme.com/docs/custom-schemas`),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})):jsxRuntimeExports.jsx(Wrapper,{...a,children:jsxRuntimeExports.jsx("div",{style:{height:"100%",width:"100%"},ref:C})})},Draggable$1=a=>{const{scale:s,basePdf:c,plugin:u}=a,{token:d}=theme.useToken(),p=u.propPanel.defaultSchema,v=useDraggable({id:p.type,data:p}),{listeners:A,setNodeRef:b,attributes:g,transform:x,isDragging:y}=v,f={transform:CSS$1.Translate.toString(x)},m=React.useMemo(()=>jsxRuntimeExports.jsx("div",{style:{transform:`scale(${s})`},children:jsxRuntimeExports.jsx(Renderer,{schema:{...p,id:p.type},basePdf:c,value:p.content||"",onChangeHoveringSchemaId:()=>{},mode:"viewer",outline:`1px solid ${d.colorPrimary}`,scale:s})}),[p,c,s,d.colorPrimary]);return jsxRuntimeExports.jsxs("div",{ref:b,style:f,...A,...g,children:[y&&m,jsxRuntimeExports.jsx("div",{style:{visibility:y?"hidden":"visible"},children:a.children})]})},LeftSidebar=({height:a,scale:s,basePdf:c})=>{const{token:u}=theme.useToken(),d=reactExports.useContext(PluginsRegistry),[p,v]=reactExports.useState(!1);return reactExports.useEffect(()=>{const A=()=>{p&&v(!1)};return document.addEventListener("mouseup",A),()=>{document.removeEventListener("mouseup",A)}},[p]),jsxRuntimeExports.jsx("div",{style:{left:0,right:0,position:"absolute",zIndex:1,height:a,width:LEFT_SIDEBAR_WIDTH,background:u.colorBgLayout,textAlign:"center",overflow:p?"visible":"auto"},children:Object.entries(d).map(([A,b])=>b!=null&&b.propPanel.defaultSchema?jsxRuntimeExports.jsx(Draggable$1,{scale:s,basePdf:c,plugin:b,children:jsxRuntimeExports.jsx(Button$1,{onMouseDown:()=>v(!0),style:{width:35,height:35,marginTop:"0.25rem",padding:"0.25rem"},children:jsxRuntimeExports.jsx(PluginIcon,{plugin:b,label:A})})},A):null)})},Paper=a=>{const{paperRefs:s,scale:c,size:u,schemasList:d,pageSizes:p,backgrounds:v,renderPaper:A,renderSchema:b,hasRulers:g}=a,x=reactExports.useContext(FontContext),y=g?RULER_HEIGHT:0;return p.length!==v.length||p.length!==d.length?null:jsxRuntimeExports.jsx("div",{style:{transform:`scale(${c})`,transformOrigin:"top left",height:c,width:c},children:v.map((f,m)=>{const C=p[m],S={width:C.width*ZOOM,height:C.height*ZOOM},w=S.width*c+y<u.width?`${(u.width/c-S.width)/2}px`:`${y}px`;let _=m>0?(y+PAGE_GAP)*(m+1):y;return g||(_+=PAGE_GAP*2),jsxRuntimeExports.jsxs("div",{ref:I=>{I&&(s.current[m]=I)},onMouseDown:I=>{I.currentTarget===I.target&&document&&document.hasFocus()&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()},style:{fontFamily:`'${getFallbackFontName(x)}'`,top:`${_}px`,left:w,position:"relative",backgroundImage:`url(${f})`,backgroundSize:`${S.width}px ${S.height}px`,...S},children:[A({paperSize:S,index:m}),d[m].map((I,$)=>jsxRuntimeExports.jsx("div",{children:b({schema:I,index:m===0?$:$+d[m-1].length})},I.id))]},String(m)+JSON.stringify(S))})})};var FUNCTION="function",OBJECT="object",STRING="string",NUMBER="number",UNDEFINED="undefined",IS_WINDOW=typeof window!==UNDEFINED,doc=typeof document!==UNDEFINED&&document,OPEN_CLOSED_CHARACTERS=[{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:'\\"',close:'\\"'},{open:"\\'",close:"\\'"}],TINY_NUM$1=1e-7,DEFAULT_UNIT_PRESETS={cm:function(a){return a*96/2.54},mm:function(a){return a*96/254},in:function(a){return a*96},pt:function(a){return a*96/72},pc:function(a){return a*96/6},"%":function(a,s){return a*s/100},vw:function(a,s){return s===void 0&&(s=window.innerWidth),a/100*s},vh:function(a,s){return s===void 0&&(s=window.innerHeight),a/100*s},vmax:function(a,s){return s===void 0&&(s=Math.max(window.innerWidth,window.innerHeight)),a/100*s},vmin:function(a,s){return s===void 0&&(s=Math.min(window.innerWidth,window.innerHeight)),a/100*s}};/*! *****************************************************************************
|
881
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _unsupportedIterableToArray(a,s){if(a){if(typeof a=="string")return _arrayLikeToArray(a,s);var c={}.toString.call(a).slice(8,-1);return c==="Object"&&a.constructor&&(c=a.constructor.name),c==="Map"||c==="Set"?Array.from(a):c==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,s):void 0}}function _arrayLikeToArray(a,s){(s==null||s>a.length)&&(s=a.length);for(var c=0,u=Array(s);c<s;c++)u[c]=a[c];return u}function _iterableToArrayLimit(a,s){var c=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if(c!=null){var u,d,p,v,A=[],b=!0,g=!1;try{if(p=(c=c.call(a)).next,s!==0)for(;!(b=(u=p.call(c)).done)&&(A.push(u.value),A.length!==s);b=!0);}catch(x){g=!0,d=x}finally{try{if(!b&&c.return!=null&&(v=c.return(),Object(v)!==v))return}finally{if(g)throw d}}return A}}function _arrayWithHoles(a){if(Array.isArray(a))return a}var updateSchemaByPath=function a(s,c,u){var d=getSchemaFullPath(s,u),p=_get(u,d,{}),v=isFunction$1(c)?c(p):c,A=Object.assign(Object.assign({},p),v);v.props&&(A.props=Object.assign(Object.assign({},p==null?void 0:p.props),v.props)),_set(u,d,A)},getFieldName=function a(s){if(s){if(typeof s=="boolean")return s;var c=[];return isArray$1(s)&&(c=s.map(function(u){return u.split(".").map(function(d){return isNaN(Number(d))?d:d*1})})),c=s.split(".").map(function(u){return isNaN(Number(u))?u:u*1}),c=c.map(function(u){return typeof u=="string"&&(u==null?void 0:u.indexOf("["))===0&&(u==null?void 0:u.indexOf("]"))===(u==null?void 0:u.length)-1?Number(u.substring(1,u.length-1)):u}),c}},useForm=function a(){var s=Form$1.useForm(),c=_slicedToArray(s,1),u=c[0],d=reactExports.useRef({}),p=reactExports.useRef(null),v=reactExports.useRef({}),A=reactExports.useRef({});u.getFieldError;var b=u.getFieldsError,g=u.getFieldInstance,x=u.setFieldsValue,y=u.setFields,f=u.scrollToField,m=u.isFieldsTouched,C=u.isFieldTouched,S=u.isFieldValidating,w=u.resetFields,_=u.validateFields,I=__rest$15(u,["getFieldError","getFieldsError","getFieldInstance","setFieldsValue","setFields","scrollToField","isFieldsTouched","isFieldTouched","isFieldValidating","resetFields","validateFields"]),$=I,P=function(T){var B=p.current.setState;B||setTimeout(function(){B({schema:v.current,flattenSchema:d.current})},0),B(T)},E=function(T){d.current=flattenSchema(T)||{},v.current=T,P({schema:T,flattenSchema:d.current})};return $.setSchema=function(R){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(isObject$2(R)){if(T){E(R);return}var B=cloneDeep(v.current);Object.keys(R||{}).forEach(function(M){updateSchemaByPath(M,R[M],B)}),E(B)}},$.setSchemaByPath=function(R,T){if(!(!_hasFuncProperty(T)&&_isMatch(T,$.getSchemaByPath(R)))){var B=cloneDeep(v.current);updateSchemaByPath(R,T,B),E(B)}},$.setValues=function(R){var T=parseBindToValues(R,d.current);x(T)},$.getValues=function(R,T,B){var M,k=cloneDeep(u.getFieldsValue(getFieldName(R),T)),O=((M=p.current)===null||M===void 0?void 0:M.getState())||{},H=O.removeHiddenData;return H&&(k=filterValuesHidden(k,d.current)),B||(k=filterValuesUndefined(k)),parseValuesToBind(k,d.current)},$.getValueByPath=function(R){var T=getFieldName(R);return u.getFieldValue(T)},$.setValueByPath=function(R,T){if(!u.setFieldValue){var B=u.getFieldsValue();_set(B,R,T),$.setValues(B);return}var M=getFieldName(R);u.setFieldValue(M,T);try{JSON.stringify(u.getFieldValue(M))!==JSON.stringify(T)&&u.setFieldValue(M,T)}catch{}},$.getSchemaByPath=function(R){typeof R!="string"&&console.warn("请输入正确的路径");var T=getSchemaFullPath(R,v.current);return _get(v.current,T)},$.getSchema=function(){return v.current},$.setErrorFields=function(R){var T=transformFieldsData(R,getFieldName);T&&y(T)},$.removeErrorField=function(R){y([{name:getFieldName(R),errors:[]}])},$.getFieldError=function(R){var T=getFieldName(R);return u.getFieldError(T)},$.getFieldsError=function(R){var T=getFieldName(R);return b(T)},$.getFieldInstance=function(R){var T=getFieldName(R);return g(T)},$.getHiddenValues=function(){var R=$.getValues(),T=$.getValues(!0),B={},M=function(O,H,j){Object.keys(O).forEach(function(q){var L=O[q],F=j?"".concat(j,".").concat(q):q;if(!H.hasOwnProperty(q)){_set(B,F,L);return}isObject$2(L)&&M(L,H[q],F),isArray$1(L)&&L.map(function(U,N){M(U,_get(H,"".concat(q,"[").concat(N,"]"),[]),"".concat(F,"[").concat(N,"]"))})})};return M(T,R,null),B},$.setFields=function(R){var T=transformFieldsData(R,getFieldName);T&&y(T)},$.__initStore=function(R){p.current=R},$.scrollToPath=function(R){for(var T=getFieldName(R),B=arguments.length,M=new Array(B>1?B-1:0),k=1;k<B;k++)M[k-1]=arguments[k];f.apply(void 0,[T].concat(M))},$.isFieldsTouched=function(R,T){var B=(R||[]).map(function(M){return getFieldName(M)});return m(B,T)},$.isFieldTouched=function(R){var T=getFieldName(R);return C(T)},$.isFieldValidating=function(R){var T=getFieldName(R);return S(T)},$.resetFields=function(R){var T=(R||[]).map(function(B){return getFieldName(B)});T.length>0?w(T):w()},$.validateFields=function(R,T){var B=(R||[]).map(function(M){return getFieldName(M)});return B.length>0?_(B,T):_()},$.getFlattenSchema=function(R){var T;return R?(T=d.current)===null||T===void 0?void 0:T[R]:d.current},$.onItemChange=$.setValueByPath,$.setFieldRef=function(R,T){R&&(A.current[R]=T)},$.getFieldRef=function(R){return A.current[R]},$};const FormRenderComponent=withProvider(FormCore,defaultWidgets),AlignWidget=a=>{const{activeElements:s,changeSchemas:c,schemas:u,pageSize:d,schema:p}=a,v=g=>{const x=s.map(E=>E.id),y=u.filter(E=>x.includes(E.id)),f=["left","center","right"].includes(g),m=f?"x":"y",C=f?"width":"height",S=y.length===1,w=d&&typeof d=="object"?C==="width"?d.width:d.height:0,_=S?0:Math.min(...y.map(E=>{const R=E.position&&typeof E.position=="object"?E.position:{x:0,y:0};return m==="x"?R.x:R.y})),I=S?w:Math.max(...y.map(E=>{const R=E.position&&typeof E.position=="object"?E.position:{x:0,y:0},T=m==="x"?R.x:R.y,B=E,M=C==="width"?B.width||0:B.height||0;return T+M}));let $=_,P=E=>0;["center","middle"].includes(g)?($=(_+I)/2,P=E=>E/2):["right","bottom"].includes(g)&&($=I,P=E=>E),c(y.map(E=>{const R=E,T=C==="width"?R.width||0:R.height||0;return{key:`position.${m}`,value:round$1($-P(T),2),schemaId:R.id}}))},A=g=>{const x=s.map(T=>T.id),y=u.filter(T=>x.includes(T.id)),f=g==="vertical",m=f?"y":"x",C=f?"height":"width",S=Math.min(...y.map(T=>{const B=T.position&&typeof T.position=="object"?T.position:{x:0,y:0};return m==="x"?B.x:B.y})),w=Math.max(...y.map(T=>{const B=T.position&&typeof T.position=="object"?T.position:{x:0,y:0},M=m==="x"?B.x:B.y,k=T,O=C==="width"?k.width||0:k.height||0;return M+O}));if(y.length<3)return;const _=S,I=w-S,$=y.reduce((T,B)=>{const M=B,k=C==="width"?M.width||0:M.height||0;return T+k},0),E=(I-$)/(y.length-1);let R=0;c(y.map((T,B)=>{const M=B===0?0:(()=>{const H=y[B-1];return C==="width"?H.width||0:H.height||0})();R+=B===0?0:M+E;const k=round$1(_+R,2),O=T;return{key:`position.${m}`,value:k,schemaId:O.id}}))},b=[{id:"left",icon:jsxRuntimeExports.jsx(AlignStartVertical,{size:15}),onClick:()=>v("left")},{id:"center",icon:jsxRuntimeExports.jsx(AlignCenterVertical,{size:15}),onClick:()=>v("center")},{id:"right",icon:jsxRuntimeExports.jsx(AlignEndVertical,{size:15}),onClick:()=>v("right")},{id:"top",icon:jsxRuntimeExports.jsx(AlignStartHorizontal,{size:15}),onClick:()=>v("top")},{id:"middle",icon:jsxRuntimeExports.jsx(AlignCenterHorizontal,{size:15}),onClick:()=>v("middle")},{id:"bottom",icon:jsxRuntimeExports.jsx(AlignEndHorizontal,{size:15}),onClick:()=>v("bottom")},{id:"vertical",icon:jsxRuntimeExports.jsx(AlignVerticalSpaceAround,{size:15}),onClick:()=>A("vertical")},{id:"horizontal",icon:jsxRuntimeExports.jsx(AlignHorizontalSpaceAround,{size:15}),onClick:()=>A("horizontal")}];return jsxRuntimeExports.jsx(Form$1.Item,{label:p.title,children:jsxRuntimeExports.jsx(Space.Compact,{children:b.map(g=>jsxRuntimeExports.jsx(Button$1,{style:{padding:7},disabled:s.length<=2&&["vertical","horizontal"].includes(g.id),...g},g.id))})})},WidgetRenderer=a=>{const{widget:s,...c}=a,u=reactExports.useRef(null);return reactExports.useEffect(()=>(u.current&&(u.current.innerHTML="",s({...c,rootElement:u.current})),()=>{u.current&&(u.current.innerHTML="")}),[a.activeSchema]),jsxRuntimeExports.jsx("div",{ref:u})},ButtonGroupWidget=a=>{const{activeElements:s,changeSchemas:c,schemas:u,schema:d}=a,{token:p}=theme.useToken(),v=x=>{const y=x.key,f=x.type,m=s.map(S=>S.id),C=u.filter(S=>m.includes(S.id));c(C.map(S=>{const w=!!(S[y]??!1),_=f==="boolean"?!w:x.value;return{key:y,value:_,schemaId:S.id}}))},A=x=>{const y=x.key,f=x.type;let m=!1;const C=s.map(w=>w.id);return u.filter(w=>C.includes(w.id)).forEach(w=>{const _=w;m=f==="boolean"?!!(_[y]??!1):_[y]===x.value}),m},b=(x,y)=>y?x.replace(/="currentColor"/g,`="${y}"`):x,g=x=>{const y=`data:image/svg+xml;utf8,${encodeURIComponent(b(x,p.colorText))}`;return jsxRuntimeExports.jsx("img",{width:17,height:17,src:y,alt:""})};return jsxRuntimeExports.jsx(Form$1.Item,{children:jsxRuntimeExports.jsx(Space.Compact,{children:d.buttons.map((x,y)=>{const f=A(x);return jsxRuntimeExports.jsx(Button$1,{type:f?"primary":void 0,ghost:f,onClick:()=>v(x),style:{padding:7,zIndex:f?2:0},icon:g(x.icon)},y)})})})},{Text:Text$2}=Typography,DetailView=a=>{var B;const{token:s}=theme.useToken(),{size:c,schemasList:u,changeSchemas:d,deselectSchema:p,activeSchema:v}=a,A=useForm(),b=reactExports.useContext(I18nContext),g=reactExports.useContext(PluginsRegistry),x=reactExports.useContext(OptionsContext),y=M=>typeof b=="function"?b(M):M,[f,m]=reactExports.useState({});reactExports.useEffect(()=>{const M={AlignWidget:k=>jsxRuntimeExports.jsx(AlignWidget,{...k,...a,options:x}),Divider:()=>jsxRuntimeExports.jsx(Divider,{style:{marginTop:s.marginXS,marginBottom:s.marginXS}}),ButtonGroup:k=>jsxRuntimeExports.jsx(ButtonGroupWidget,{...k,...a,options:x})};for(const k of g.values()){const O=k.propPanel.widgets||{};Object.entries(O).forEach(([H,j])=>{M[H]=q=>jsxRuntimeExports.jsx(WidgetRenderer,{...q,...a,options:x,theme:s,i18n:y,widget:j})})}m(M)},[v,g,JSON.stringify(x)]),reactExports.useEffect(()=>{const M={...v},k=typeof M.readOnly=="boolean"?M.readOnly:!1;M.editable=!k,A.setValues(M)},[v,A]),reactExports.useEffect(()=>A.resetFields(),[v.id]),reactExports.useEffect(()=>{C.current=M=>{for(const k of u)for(const O of Object.values(k))if(O.name===M&&O.id!==v.id)return!1;return!0}},[u,v]);const C=reactExports.useRef(M=>!0),S=(M,k)=>C.current(k),w=debounce$1(function(...M){const k=M[0],O=(j,q)=>typeof j=="object"&&j!==null?JSON.stringify(j)!==JSON.stringify(q):j!==q;let H=[];for(const j in k){if(["id","content"].includes(j))continue;let q=k[j];if(O(q,v[j])){if(q===null&&["rotate","opacity"].includes(j)&&(q=void 0),j==="editable"){const L=!q;H.push({key:"readOnly",value:L,schemaId:v.id}),L&&H.push({key:"required",value:!1,schemaId:v.id});continue}H.push({key:j,value:q,schemaId:v.id})}}H.length&&A.validateFields().then(()=>d(H)).catch(j=>{j.errorFields.length&&(H=H.filter(q=>!j.errorFields.find(L=>L.name.includes(q.key)))),H.length&&d(H)})},100),_=g.findByType(v.type);if(!_)throw Error(`[@pdfme/ui] Failed to find plugin used for ${v.type}`);const I=_.propPanel.schema,$=[];g.entries().forEach(([M,k])=>{var O;$.push({label:M,value:((O=k.propPanel.defaultSchema)==null?void 0:O.type)??void 0})});const P={},E=(B=_==null?void 0:_.propPanel)!=null&&B.defaultSchema?(()=>{const M={};for(const k in _.propPanel.defaultSchema)Object.prototype.hasOwnProperty.call(_.propPanel.defaultSchema,k)&&(M[k]=_.propPanel.defaultSchema[k]);return M})():P,R={type:"object",column:2,properties:{type:{title:y("type"),type:"string",widget:"select",props:{options:$},required:!0,span:12},name:{title:y("fieldName"),type:"string",required:!0,span:12,rules:[{validator:S,message:y("validation.uniqueName")}],props:{autoComplete:"off"}},editable:{title:y("editable"),type:"boolean",span:8,hidden:typeof E.readOnly<"u"},required:{title:y("required"),type:"boolean",span:16,hidden:"{{!formData.editable}}"},"-":{type:"void",widget:"Divider"},align:{title:y("align"),type:"void",widget:"AlignWidget"},position:{type:"object",widget:"card",properties:{x:{title:"X",type:"number",widget:"inputNumber",required:!0,span:8,min:0},y:{title:"Y",type:"number",widget:"inputNumber",required:!0,span:8,min:0}}},width:{title:y("width"),type:"number",widget:"inputNumber",required:!0,span:6,props:{min:0}},height:{title:y("height"),type:"number",widget:"inputNumber",required:!0,span:6,props:{min:0}},rotate:{title:y("rotate"),type:"number",widget:"inputNumber",disabled:typeof E.rotate>"u",max:360,props:{min:0},span:6},opacity:{title:y("opacity"),type:"number",widget:"inputNumber",disabled:typeof E.opacity>"u",props:{step:.1,min:0,max:1},span:6}}},T={...R.properties};if(typeof I=="function"){const{size:M,schemas:k,pageSize:O,changeSchemas:H,activeElements:j,deselectSchema:q,activeSchema:L}=a,U=I({...{size:M,schemas:k,pageSize:O,changeSchemas:H,activeElements:j,deselectSchema:q,activeSchema:L},options:x,theme:s,i18n:y}),N=U&&typeof U=="object"?U:{},D=Object.keys(N).length===0?{}:{"--":{type:"void",widget:"Divider"}};R.properties={...T,...D,...N}}else{const M=I&&typeof I=="object"?I:{},k=Object.keys(M).length===0?{}:{"--":{type:"void",widget:"Divider"}};R.properties={...T,...k,...M}}return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{style:{height:40,display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$1,{style:{position:"absolute",zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},onClick:p,icon:jsxRuntimeExports.jsx(Menu,{strokeWidth:1.5,size:20})}),jsxRuntimeExports.jsx(Text$2,{strong:!0,style:{textAlign:"center",width:"100%"},children:y("editField")})]}),jsxRuntimeExports.jsx(Divider,{style:{marginTop:s.marginXS,marginBottom:s.marginXS}}),jsxRuntimeExports.jsx("div",{style:{height:getSidebarContentHeight(c.height),overflowY:"auto",overflowX:"hidden"},children:jsxRuntimeExports.jsx(FormRenderComponent,{form:A,schema:R,widgets:f,watch:{"#":w},locale:"en-US"})})]})},propsAreUnchanged=(a,s)=>JSON.stringify(a.activeSchema)==JSON.stringify(s.activeSchema),DetailView$1=React.memo(DetailView,propsAreUnchanged),Sidebar=a=>{const{sidebarOpen:s,setSidebarOpen:c,activeElements:u,schemas:d}=a,{token:p}=theme.useToken(),v=()=>d.filter(g=>u.map(x=>x.id).includes(g.id)),A=()=>{const g=v();return g[g.length-1]},b={strokeWidth:1.5,size:20};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",right:0,zIndex:1,height:"100%",width:s?RIGHT_SIDEBAR_WIDTH:0},children:jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(Button$1,{style:{position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",top:"1rem",right:"1rem",zIndex:100},icon:s?jsxRuntimeExports.jsx(ArrowRight,{...b}):jsxRuntimeExports.jsx(ArrowLeft,{...b}),onClick:()=>c(!s)}),jsxRuntimeExports.jsx("div",{style:{width:RIGHT_SIDEBAR_WIDTH,height:"100%",display:s?"block":"none",top:0,right:0,position:"absolute",padding:"0.7rem 1rem",overflowY:"auto",fontFamily:"'Open Sans', sans-serif",boxSizing:"border-box",background:p.colorBgLayout},children:jsxRuntimeExports.jsx("div",{children:v().length===0?jsxRuntimeExports.jsx(ListView,{...a}):jsxRuntimeExports.jsx(DetailView$1,{...a,activeSchema:A()})})})]})})},useRerenderDependencies=a=>{const{plugin:s,value:c,mode:u,scale:d,schema:p,options:v}=a,A=cloneDeep$1(v);A.font&&Object.values(A.font).forEach(g=>{g.data="..."});const b=JSON.stringify(A);return reactExports.useMemo(()=>s!=null&&s.uninterruptedEditMode&&u==="designer"?[u]:[c,u,d,JSON.stringify(p),b],[s==null?void 0:s.uninterruptedEditMode,c,u,d,p,b,s])},Wrapper=({children:a,outline:s,onChangeHoveringSchemaId:c,schema:u,selectable:d=!0})=>jsxRuntimeExports.jsxs("div",{title:u.name,onMouseEnter:()=>c&&c(u.id),onMouseLeave:()=>c&&c(null),className:d?SELECTABLE_CLASSNAME:"",id:u.id,style:{position:"absolute",cursor:u.readOnly?"initial":"pointer",height:u.height*ZOOM,width:u.width*ZOOM,top:u.position.y*ZOOM,left:u.position.x*ZOOM,transform:`rotate(${u.rotate??0}deg)`,opacity:u.opacity??1,outline:s},children:[u.required&&jsxRuntimeExports.jsx("span",{style:{color:"red",position:"absolute",top:-12,left:-12,fontSize:18,fontWeight:700},children:"*"}),a]}),Renderer=a=>{const{schema:s,basePdf:c,value:u,mode:d,onChange:p,stopEditing:v,tabIndex:A,placeholder:b,scale:g}=a,x=reactExports.useContext(PluginsRegistry),y=reactExports.useContext(OptionsContext),f=reactExports.useContext(I18nContext),{token:m}=theme.useToken(),C=reactExports.useRef(null),S=reactExports.useContext(CacheContext),w=x.findByType(s.type),_=useRerenderDependencies({plugin:w||void 0,value:u,mode:d,scale:g,schema:s,options:y});return reactExports.useEffect(()=>{if(!(w!=null&&w.ui)||!C.current||!s.type)return;C.current.innerHTML="";const I=w.ui;return I({value:u,schema:s,basePdf:c,rootElement:C.current,mode:d,onChange:p,stopEditing:v,tabIndex:A,placeholder:b,options:y,theme:m,i18n:f,_cache:S}),()=>{C.current&&(C.current.innerHTML="")}},[w==null?void 0:w.ui,s.type,_]),!w||!w.ui?(console.error(`[@pdfme/ui] Renderer for type ${s.type} not found.
|
882
|
+
Check this document: https://pdfme.com/docs/custom-schemas`),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})):jsxRuntimeExports.jsx(Wrapper,{...a,children:jsxRuntimeExports.jsx("div",{style:{height:"100%",width:"100%"},ref:C})})},Draggable$1=a=>{const{scale:s,basePdf:c,plugin:u}=a,{token:d}=theme.useToken(),p=u.propPanel.defaultSchema,v=useDraggable({id:p.type,data:p}),{listeners:A,setNodeRef:b,attributes:g,transform:x,isDragging:y}=v,f={transform:CSS$1.Translate.toString(x)},m=React.useMemo(()=>jsxRuntimeExports.jsx("div",{style:{transform:`scale(${s})`},children:jsxRuntimeExports.jsx(Renderer,{schema:{...p,id:p.type},basePdf:c,value:p.content||"",onChangeHoveringSchemaId:()=>{},mode:"viewer",outline:`1px solid ${d.colorPrimary}`,scale:s})}),[p,c,s,d.colorPrimary]);return jsxRuntimeExports.jsxs("div",{ref:b,style:f,...A,...g,children:[y&&m,jsxRuntimeExports.jsx("div",{style:{visibility:y?"hidden":"visible"},children:a.children})]})},LeftSidebar=({height:a,scale:s,basePdf:c})=>{const{token:u}=theme.useToken(),d=reactExports.useContext(PluginsRegistry),[p,v]=reactExports.useState(!1);return reactExports.useEffect(()=>{const A=()=>{p&&v(!1)};return document.addEventListener("mouseup",A),()=>{document.removeEventListener("mouseup",A)}},[p]),jsxRuntimeExports.jsx("div",{style:{left:0,right:0,position:"absolute",zIndex:1,height:a,width:LEFT_SIDEBAR_WIDTH,background:u.colorBgLayout,textAlign:"center",overflow:p?"visible":"auto"},children:d.entries().map(([A,b])=>b!=null&&b.propPanel.defaultSchema?jsxRuntimeExports.jsx(Draggable$1,{scale:s,basePdf:c,plugin:b,children:jsxRuntimeExports.jsx(Button$1,{onMouseDown:()=>v(!0),style:{width:35,height:35,marginTop:"0.25rem",padding:"0.25rem"},children:jsxRuntimeExports.jsx(PluginIcon,{plugin:b,label:A})})},A):null)})},Paper=a=>{const{paperRefs:s,scale:c,size:u,schemasList:d,pageSizes:p,backgrounds:v,renderPaper:A,renderSchema:b,hasRulers:g}=a,x=reactExports.useContext(FontContext),y=g?RULER_HEIGHT:0;return p.length!==v.length||p.length!==d.length?null:jsxRuntimeExports.jsx("div",{style:{transform:`scale(${c})`,transformOrigin:"top left",height:c,width:c},children:v.map((f,m)=>{const C=p[m],S={width:C.width*ZOOM,height:C.height*ZOOM},w=S.width*c+y<u.width?`${(u.width/c-S.width)/2}px`:`${y}px`;let _=m>0?(y+PAGE_GAP)*(m+1):y;return g||(_+=PAGE_GAP*2),jsxRuntimeExports.jsxs("div",{ref:I=>{I&&(s.current[m]=I)},onMouseDown:I=>{I.currentTarget===I.target&&document&&document.hasFocus()&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()},style:{fontFamily:`'${getFallbackFontName(x)}'`,top:`${_}px`,left:w,position:"relative",backgroundImage:`url(${f})`,backgroundSize:`${S.width}px ${S.height}px`,...S},children:[A({paperSize:S,index:m}),d[m].map((I,$)=>jsxRuntimeExports.jsx("div",{children:b({schema:I,index:m===0?$:$+d[m-1].length})},I.id))]},String(m)+JSON.stringify(S))})})};var FUNCTION="function",OBJECT="object",STRING="string",NUMBER="number",UNDEFINED="undefined",IS_WINDOW=typeof window!==UNDEFINED,doc=typeof document!==UNDEFINED&&document,OPEN_CLOSED_CHARACTERS=[{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:'\\"',close:'\\"'},{open:"\\'",close:"\\'"}],TINY_NUM$1=1e-7,DEFAULT_UNIT_PRESETS={cm:function(a){return a*96/2.54},mm:function(a){return a*96/254},in:function(a){return a*96},pt:function(a){return a*96/72},pc:function(a){return a*96/6},"%":function(a,s){return a*s/100},vw:function(a,s){return s===void 0&&(s=window.innerWidth),a/100*s},vh:function(a,s){return s===void 0&&(s=window.innerHeight),a/100*s},vmax:function(a,s){return s===void 0&&(s=Math.max(window.innerWidth,window.innerHeight)),a/100*s},vmin:function(a,s){return s===void 0&&(s=Math.min(window.innerWidth,window.innerHeight)),a/100*s}};/*! *****************************************************************************
|
884
883
|
Copyright (c) Microsoft Corporation.
|
885
884
|
|
886
885
|
Permission to use, copy, modify, and/or distribute this software for any
|
@@ -1350,7 +1349,7 @@ canvas {
|
|
1350
1349
|
.adder.dragging {
|
1351
1350
|
display: block;
|
1352
1351
|
}
|
1353
|
-
`);__spreadArray(["className","rulerStyle","snapThreshold","snaps","displayDragPos","cspNonce","dragPosFormat","defaultGuides","showGuides","scrollOptions","guideStyle","guidesOffset","digit","defaultGuidesPos","dragGuideStyle","displayGuidePos","guidePosFormat","guidePosStyle","lockGuides","guidesZoom"],PROPERTIES,!0);var GuidesElement=styled("div",GUIDES_CSS),Guides=function(a){__extends(s,a);function s(u){var d=a.call(this,u)||this;return d.state={guides:[]},d.scrollPos=0,d.managerRef=reactExports.createRef(),d.guideElements=[],d._isFirstMove=!1,d._zoom=1,d._guidesZoom=1,d._observer=null,d.onDragStart=function(p){var v=p.datas,A=p.inputEvent;d._isFirstMove=!0,d.movePos(p),d.props.onDragStart(__assign(__assign({},p),{dragElement:v.target})),d.gesto.isFlag()&&(A.stopPropagation(),A.preventDefault(),d._startDragScroll(p))},d._onDrag=function(p){d._isFirstMove&&(d._isFirstMove=!1,addClass(p.datas.target,DRAGGING));var v=d.movePos(p);if(d.props.onDrag(__assign(__assign({},p),{dragElement:p.datas.target})),!d.gesto.isFlag()){d._endDragScroll(p);return}return d._dragScroll(p),v},d.onDragEnd=function(p){var v=p.datas,A=p.isDouble,b=p.distX,g=p.distY,x=d.movePos(p),y=d.state.guides,f=d.props,m=f.onChangeGuides,C=f.displayDragPos,S=f.digit,w=f.lockGuides,_=f.guidesOffset,I=d._guidesZoom,$=parseFloat((x/I).toFixed(S||0)),P=d.scrollPos-(_||0);if(C&&(d.displayElement.style.cssText+="display: none;"),removeClass(v.target,DRAGGING),d.props.onDragEnd(__assign(__assign({},p),{dragElement:v.target})),d._endDragScroll(p),v.fromRuler)d._isFirstMove&&d.props.onClickRuler(__assign(__assign({},p),{pos:0})),$>=P&&y.indexOf($)<0&&d.setState({guides:__spreadArray(__spreadArray([],y,!0),[$],!1)},function(){m({guides:d.state.guides,distX:b,distY:g,index:y.length,isAdd:!0,isRemove:!1,isChange:!1})});else{var E=parseFloat(v.target.getAttribute("data-index")),R=!1,T=!1;y=__spreadArray([],y,!0);var B=y.indexOf($);if(A||$<P||B>-1&&B!==E){if(w&&(w===!0||w.indexOf("remove")>-1))return;y.splice(E,1),R=!0}else{if(B>-1)return;if(w&&(w===!0||w.indexOf("change")>-1))return;y[E]=$,T=!0}d.setState({guides:y},function(){var M=d.state.guides;m({distX:b,distY:g,guides:M,isAdd:!1,index:E,isChange:T,isRemove:R})})}},d._onCheck=function(){d.resize()},d.state.guides=u.defaultGuides||[],d.scrollPos=u.defaultGuidesPos||0,d}var c=s.prototype;return c.render=function(){var u=this.props,d=u.className,p=u.type,v=u.zoom,A=u.guidesZoom,b=u.style,g=u.rulerStyle,x=u.displayDragPos,y=u.cspNonce,f=u.dragGuideStyle,m=u.guidePosStyle,C=m===void 0?{}:m,S=this.props,w=this.getTranslateName(),_={};return PROPERTIES.forEach(function(I){I==="style"||I==="warpSelf"||I==="useResizeObserver"||(_[I]=S[I])}),this._zoom=v,this._guidesZoom=A||v,reactExports.createElement(GuidesElement,{ref:this.managerRef,cspNonce:y,className:"".concat(prefix("manager",p)," ").concat(d),style:b},reactExports.createElement("div",{className:prefix("guide-origin"),ref:ref(this,"originElement")}),reactExports.createElement(Ruler,__assign({ref:ref(this,"ruler"),style:g},_)),reactExports.createElement("div",{className:GUIDES,ref:ref(this,"guidesElement"),style:{transform:"".concat(w,"(").concat(-this.scrollPos*this._guidesZoom,"px)")}},x&&reactExports.createElement("div",{className:DISPLAY_DRAG,ref:ref(this,"displayElement"),style:C||{}}),reactExports.createElement("div",{className:ADDER,ref:ref(this,"adderElement"),style:f}),this.renderGuides()))},c.drawRuler=function(u){this.ruler.draw(u)},c.renderGuides=function(){var u=this,d=this.props,p=d,v=p.type,A=p.showGuides,b=p.guideStyle,g=p.displayGuidePos,x=p.guidePosStyle,y=x===void 0?{}:x,f=p.guidesOffset,m=this._guidesZoom,C=this.getTranslateName(),S=this.state.guides,w=d.guidePosFormat||d.dragPosFormat||function(_){return _};if(this.guideElements=[],A)return S.map(function(_,I){var $=_+(f||0);return reactExports.createElement("div",{className:prefix("guide",v),ref:refs(u,"guideElements",I),key:I,"data-index":I,"data-pos":_,style:__assign(__assign({},b),{transform:"".concat(C,"(").concat($*m,"px) translateZ(0px)")})},g&&reactExports.createElement("div",{className:prefix("guide-pos"),style:y||{}},w(_)))})},c.componentDidMount=function(){var u=this;this.gesto=new Gesto(this.managerRef.current,{container:document.body}).on("dragStart",function(d){var p=u.props,v=p.type,A=p.lockGuides,b=u._guidesZoom;if(A===!0){d.stop();return}var g=d.inputEvent,x=g.target,y=d.datas,f=u.ruler.canvasElement,m=u.guidesElement,C=v==="horizontal",S=u.originElement.getBoundingClientRect(),w=getDistElementMatrix(u.managerRef.current),_=calculateMatrixDist(w,[d.clientX-S.left,d.clientY-S.top]);_[0]-=m.offsetLeft,_[1]-=m.offsetTop,_[C?1:0]+=u.scrollPos*b,y.offsetPos=_,y.matrix=w;var I=A&&A.indexOf("add")>-1,$=A&&A.indexOf("remove")>-1,P=A&&A.indexOf("change")>-1;if(x===f){if(I){d.stop();return}y.fromRuler=!0,y.target=u.adderElement}else if(hasClass(x,GUIDE)){if($&&P){d.stop();return}y.target=x}else return d.stop(),!1;u.onDragStart(d)}).on("drag",this._onDrag).on("dragEnd",this.onDragEnd),this.props.useResizeObserver?(this._observer=new ResizeObserver(this._onCheck),this._observer.observe(this.guidesElement,{box:"border-box"}),this._observer.observe(this.getRulerElement(),{box:"border-box"})):this._onCheck()},c.componentWillUnmount=function(){var u;this.gesto.unset(),(u=this._observer)===null||u===void 0||u.disconnect()},c.componentDidUpdate=function(u){var d=this.props.defaultGuides;u.defaultGuides!==d&&this.setState({guides:d||[]})},c.loadGuides=function(u){this.setState({guides:u})},c.getGuides=function(){return this.state.guides},c.scrollGuides=function(u,d){d===void 0&&(d=this._guidesZoom),this._setZoom({guidesZoom:d});var p=this.getTranslateName(),v=this.guidesElement;this.scrollPos=u,v.style.transform="".concat(p,"(").concat(-u*d,"px)");var A=this.state.guides,b=this.props.guidesOffset||0;this.guideElements.forEach(function(g,x){if(g){var y=A[x]+(b||0);g.style.transform="".concat(p,"(").concat(y*d,"px) translateZ(0px)"),g.style.display=-u+y<0?"none":"block"}})},c.zoomTo=function(u,d){d===void 0&&(d=u),this.scroll(this.getRulerScrollPos(),u),this.scrollGuides(this.getGuideScrollPos(),d)},c.getElement=function(){return this.managerRef.current},c.getRulerElement=function(){return this.ruler.canvasElement},c.getGuideScrollPos=function(){return this.scrollPos},c.getRulerScrollPos=function(){return this.ruler.getScrollPos()},c.scroll=function(u,d){d===void 0&&(d=this._zoom),this._setZoom({zoom:d}),this.ruler.scroll(u,d)},c.resize=function(u){u===void 0&&(u=this._zoom),this._setZoom({zoom:u}),this.ruler.resize(u)},c.movePos=function(u){var d=u.datas,p=u.distX,v=u.distY,A=this.props,b=A.type,g=A.snaps,x=A.snapThreshold,y=A.displayDragPos,f=A.digit,m=A.guidesOffset||0,C=this._guidesZoom,S=A.dragPosFormat||function(O){return O},w=b==="horizontal",_=calculateMatrixDist(d.matrix,[p,v]),I=d.offsetPos,$=_[0]+I[0],P=_[1]+I[1],E=m*C,R=Math.round(w?P:$)-m,T=parseFloat((R/C).toFixed(f||0)),B=g.slice().sort(function(O,H){return Math.abs(T-O)-Math.abs(T-H)});if(B.length&&Math.abs(B[0]*C-R)<x&&(T=B[0],R=T*C),!d.fromRuler||!this._isFirstMove){if(y){var M=b==="horizontal"?[$,R+E]:[R+E,P];this.displayElement.style.cssText+="display: block;transform: translate(-50%, -50%) "+"translate(".concat(M.map(function(O){return"".concat(O,"px")}).join(", "),")"),this.displayElement.innerHTML="".concat(S(T))}var k=d.target;k.setAttribute("data-pos",T),k.style.transform="".concat(this.getTranslateName(),"(").concat(R+m*C,"px)")}return R},c.getTranslateName=function(){return this.props.type==="horizontal"?"translateY":"translateX"},c._startDragScroll=function(u){var d=this,p=this.props.scrollOptions;if(p){var v=u.datas,A=new DragScroll;v.dragScroll=A,A.on("scroll",function(b){var g,x,y=b.container,f=b.direction;(x=(g=d.props).onRequestScroll)===null||x===void 0||x.call(g,{container:y,direction:f})}).on("move",function(b){var g=b.offsetX,x=b.offsetY,y=b.inputEvent;d.gesto.scrollBy(g,x,y.inputEvent,!0)}),A.dragStart(u,{container:p.container})}},c._dragScroll=function(u){var d=this.props.scrollOptions;if(d){var p=u.datas.dragScroll;p.drag(u,d)}},c._endDragScroll=function(u){var d;(d=u.datas.dragScroll)===null||d===void 0||d.dragEnd(),u.datas.dragScroll=null},c._setZoom=function(u){var d=u.zoom,p=u.guidesZoom;this.props.zoom;var v=!!this.props.guidesZoom;v?p&&(this._guidesZoom=p):(p&&(this._zoom=p,this._guidesZoom=p),d&&(this._guidesZoom=d)),d&&(this._zoom=d)},s.defaultProps={className:"",type:"horizontal",zoom:1,guidesZoom:0,style:{},snapThreshold:5,snaps:[],digit:0,onClickRuler:function(){},onChangeGuides:function(){},onRequestScroll:function(){},onDragStart:function(){},onDrag:function(){},onDragEnd:function(){},displayDragPos:!1,dragPosFormat:function(u){return u},defaultGuides:[],lockGuides:!1,showGuides:!0,guideStyle:{},dragGuideStyle:{},guidePosStyle:{},defaultGuidesPos:0},s}(reactExports.PureComponent);const guideStyle=(a,s,c,u)=>({position:"absolute",top:a,left:s,height:c,width:u,background:"#333333"}),_Guides=({paperSize:a,horizontalRef:s,verticalRef:c})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"ruler-container",style:guideStyle(-30,-30,RULER_HEIGHT,RULER_HEIGHT)}),jsxRuntimeExports.jsx(Guides,{zoom:ZOOM,style:guideStyle(-30,0,RULER_HEIGHT,a.width),type:"horizontal",ref:s}),jsxRuntimeExports.jsx(Guides,{zoom:ZOOM,style:guideStyle(0,-30,a.height,RULER_HEIGHT),type:"vertical",ref:c})]}),Mask=({width:a,height:s})=>jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:-30,left:-30,zIndex:100,width:a,height:s,background:theme.useToken().token.colorBgMask}}),getPaddingStyle=(a,s,c)=>{const u={position:"absolute",background:c,opacity:.25,pointerEvents:"none"};switch(a){case 0:u.top=0,u.height=`${s*ZOOM}px`,u.left=0,u.right=0;break;case 1:u.right=0,u.width=`${s*ZOOM}px`,u.top=0,u.bottom=0;break;case 2:u.bottom=0,u.height=`${s*ZOOM}px`,u.left=0,u.right=0;break;case 3:u.left=0,u.width=`${s*ZOOM}px`,u.top=0,u.bottom=0;break}return u},Padding=({basePdf:a})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:isBlankPdf(a)&&a.padding.map((s,c)=>jsxRuntimeExports.jsx("div",{style:getPaddingStyle(c,s,theme.useToken().token.colorError)},String(c)))}),StaticSchema=a=>{const{template:{schemas:s,basePdf:c},input:u,scale:d,totalPages:p,currentPage:v}=a;return!isBlankPdf(c)||!c.staticSchema?null:jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:c.staticSchema.map(A=>jsxRuntimeExports.jsx(Renderer,{schema:{...A,id:uuid$6()},basePdf:c,value:replacePlaceholders({content:A.content||"",variables:{...u,totalPages:p,currentPage:v},schemas:s}),onChangeHoveringSchemaId:()=>{},mode:"viewer",outline:"none",scale:d,selectable:!1},A.name))})},mm2px=a=>a*3.7795275591,DELETE_BTN_ID=uuid$6(),fmt4Num=a=>Number(a.replace("px","")),fmt=a=>round$1(fmt4Num(a)/ZOOM,2),isTopLeftResize=a=>a==="-1,-1"||a==="-1,0"||a==="0,-1",normalizeRotate=a=>(a%360+360)%360,DeleteButton=({activeElements:a})=>{const{token:s}=theme.useToken(),c=26,u=Math.min(...a.map(({style:p})=>fmt4Num(p.top))),d=Math.max(...a.map(({style:p})=>fmt4Num(p.left)+fmt4Num(p.width)))+10;return jsxRuntimeExports.jsx(Button$1,{id:DELETE_BTN_ID,style:{position:"absolute",zIndex:1,top:u,left:d,width:c,height:c,padding:2,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:s.borderRadius,color:s.colorWhite,background:s.colorPrimary},children:jsxRuntimeExports.jsx(X,{style:{pointerEvents:"none"}})})},Canvas=(a,s)=>{const{basePdf:c,pageCursor:u,scale:d,backgrounds:p,pageSizes:v,size:A,activeElements:b,schemasList:g,hoveringSchemaId:x,onEdit:y,changeSchemas:f,removeSchemas:m,onChangeHoveringSchemaId:C,paperRefs:S,sidebarOpen:w}=a,{token:_}=theme.useToken(),I=reactExports.useContext(PluginsRegistry),$=reactExports.useRef([]),P=reactExports.useRef([]),E=reactExports.useRef(null),[R,T]=reactExports.useState(!1),[B,M]=reactExports.useState(!1),k=usePrevious(g[u]),O=ae=>{ae.shiftKey&&T(!0)},H=ae=>{(ae.key==="Shift"||!ae.shiftKey)&&T(!1),(ae.key==="Escape"||ae.key==="Esc")&&M(!1)},j=reactExports.useCallback(()=>{window.addEventListener("keydown",O),window.addEventListener("keyup",H)},[]),q=reactExports.useCallback(()=>{window.removeEventListener("keydown",O),window.removeEventListener("keyup",H)},[]);reactExports.useEffect(()=>(j(),q),[j,q]),reactExports.useEffect(()=>{var K,te;if((K=E.current)==null||K.updateRect(),!k)return;const ae=JSON.stringify(k[u]||{}),V=JSON.stringify(g[u]||{});ae===V&&((te=E.current)==null||te.updateRect())},[u,g,k]);const L=({target:ae,top:V,left:K})=>{const{width:te,height:ie}=ae.style,ce=fmt(te),me=fmt(ie),we=V/ZOOM,ve=K/ZOOM,{width:ge,height:ue}=v[u];let se=0,oe=0,de=0,le=0;if(isBlankPdf(c)){const[xe,Ce,$e,Se]=c.padding;se=xe*ZOOM,oe=Ce,de=$e,le=Se*ZOOM}we+me>ue-de?ae.style.top=`${(ue-me-de)*ZOOM}px`:ae.style.top=`${V<se?se:V}px`,ve+ce>ge-oe?ae.style.left=`${(ge-ce-oe)*ZOOM}px`:ae.style.left=`${K<le?le:K}px`},F=({target:ae})=>{const{top:V,left:K}=ae.style;f([{key:"position.y",value:fmt(V),schemaId:ae.id},{key:"position.x",value:fmt(K),schemaId:ae.id}])},U=({targets:ae})=>{const V=ae.map(({style:{top:K,left:te},id:ie})=>[{key:"position.y",value:fmt(K),schemaId:ie},{key:"position.x",value:fmt(te),schemaId:ie}]);f(flatten(V))},N=({target:ae,rotate:V})=>{ae.style.transform=`rotate(${V}deg)`},D=({target:ae})=>{const{transform:V}=ae.style,K=Number(V.replace("rotate(","").replace("deg)","")),te=normalizeRotate(K);f([{key:"rotate",value:te,schemaId:ae.id}])},W=({targets:ae})=>{const V=ae.map(({style:{transform:K},id:te})=>{const ie=Number(K.replace("rotate(","").replace("deg)",""));return[{key:"rotate",value:normalizeRotate(ie),schemaId:te}]});f(flatten(V))},Z=({target:ae})=>{const{id:V,style:K}=ae,{width:te,height:ie,top:ce,left:me}=K;f([{key:"position.x",value:fmt(me),schemaId:V},{key:"position.y",value:fmt(ce),schemaId:V},{key:"width",value:fmt(te),schemaId:V},{key:"height",value:fmt(ie),schemaId:V}]);const we=g[u].find(ve=>ve.id===V);we&&(we.position.x=fmt(me),we.position.y=fmt(ce),we.width=fmt(te),we.height=fmt(ie))},Q=({targets:ae})=>{const V=ae.map(({style:{width:K,height:te,top:ie,left:ce},id:me})=>[{key:"width",value:fmt(K),schemaId:me},{key:"height",value:fmt(te),schemaId:me},{key:"position.y",value:fmt(ie),schemaId:me},{key:"position.x",value:fmt(ce),schemaId:me}]);f(flatten(V))},Y=({target:ae,width:V,height:K,direction:te})=>{if(!ae)return;let ie=0,ce=0,me=0,we=0;if(isBlankPdf(c)){const[xe,Ce,$e,Se]=c.padding;ie=xe*ZOOM,ce=mm2px(Ce),me=mm2px($e),we=Se*ZOOM}const ve=mm2px(v[u].width),ge=mm2px(v[u].height),ue={width:`${V}px`,height:`${K}px`},se=ae.style;let oe=fmt4Num(se.left)+(fmt4Num(se.width)-V),de=fmt4Num(se.top)+(fmt4Num(se.height)-K);oe<we&&(oe=we),de<ie&&(de=ie),oe+V>ve-ce&&(ue.width=`${ve-ce-oe}px`),de+K>ge-me&&(ue.height=`${ge-me-de}px`);const le=te.toString();isTopLeftResize(le)?(ue.top=`${de}px`,ue.left=`${oe}px`):le==="1,-1"?ue.top=`${de}px`:le==="-1,1"&&(ue.left=`${oe}px`),Object.assign(se,ue)},J=(ae,V)=>ae[V]&&ae[V].getGuides().map(K=>K*ZOOM),ee=()=>{M(!0)},re=reactExports.useMemo(()=>{const V=(g[u]||[]).filter(ie=>b.map(ce=>ce.id).includes(ie.id)).map(ie=>ie.type),K=[...new Set(V)],te=[];return Object.values(I).forEach(ie=>{ie&&typeof ie=="object"&&"propPanel"in ie&&ie.propPanel&&typeof ie.propPanel=="object"&&"defaultSchema"in ie.propPanel&&ie.propPanel.defaultSchema&&te.push(ie.propPanel.defaultSchema)}),K.every(ie=>{const ce=te.find(me=>me&&"type"in me&&me.type===ie);return ce&&"rotate"in ce})},[b,u,g,I]);return jsxRuntimeExports.jsxs("div",{style:{position:"relative",overflow:"auto",marginRight:w?RIGHT_SIDEBAR_WIDTH:0,...A},ref:s,children:[jsxRuntimeExports.jsx(Selecto,{container:S.current[u],continueSelect:R,onDragStart:ae=>{var ce;const V=ae.inputEvent,K=V.target,te=(ce=E.current)==null?void 0:ce.isMoveableElement(K);(V.type==="touchstart"&&ae.isTrusted||te)&&ae.stop(),S.current[u]===K&&y([]);const ie=K;ie&&ie.id===DELETE_BTN_ID&&m(b.map(me=>me.id))},onSelect:ae=>{const V=ae.inputEvent,K=ae.added,te=ae.removed,ie=ae.selected,ce=V.type==="mousedown";let me=ce?ie:[];!ce&&K.length>0&&(me=b.concat(K)),!ce&&te.length>0&&(me=b.filter(ve=>!te.includes(ve))),y(me),me!=b&&M(!1);const we=V;we&&typeof we.shiftKey=="boolean"&&!we.shiftKey&&T(!1)}}),jsxRuntimeExports.jsx(Paper,{paperRefs:S,scale:d,size:A,schemasList:g,pageSizes:v,backgrounds:p,hasRulers:!0,renderPaper:({index:ae,paperSize:V})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!B&&b.length>0&&u===ae&&jsxRuntimeExports.jsx(DeleteButton,{activeElements:b}),jsxRuntimeExports.jsx(Padding,{basePdf:c}),jsxRuntimeExports.jsx(StaticSchema,{template:{schemas:g,basePdf:c},input:Object.fromEntries(g.flat().map(({name:K,content:te=""})=>[K,te])),scale:d,totalPages:g.length,currentPage:ae+1}),jsxRuntimeExports.jsx(_Guides,{paperSize:V,horizontalRef:K=>{K&&(P.current[ae]=K)},verticalRef:K=>{K&&($.current[ae]=K)}}),u!==ae?jsxRuntimeExports.jsx(Mask,{width:V.width+RULER_HEIGHT,height:V.height+RULER_HEIGHT}):!B&&jsxRuntimeExports.jsx(Moveable$1,{ref:E,target:b,bounds:{left:0,top:0,bottom:V.height,right:V.width},horizontalGuidelines:J(P.current,ae),verticalGuidelines:J($.current,ae),keepRatio:R,rotatable:re,onDrag:L,onDragEnd:F,onDragGroupEnd:U,onRotate:N,onRotateEnd:D,onRotateGroupEnd:W,onResize:Y,onResizeEnd:Z,onResizeGroupEnd:Q,onClick:ee})]}),renderSchema:({schema:ae,index:V})=>{const K=B&&b.map(ce=>ce.id).includes(ae.id)?"designer":"viewer",te=ae.content||"";let ie=te;if(K!=="designer"&&ae.readOnly){const ce={...g.flat().reduce((me,we)=>(me[we.name]=we.content||"",me),{}),totalPages:g.length,currentPage:V+1};ie=replacePlaceholders({content:te,variables:ce,schemas:g})}return jsxRuntimeExports.jsx(Renderer,{schema:ae,basePdf:c,value:ie,onChangeHoveringSchemaId:C,mode:K,onChange:(g[u]||[]).some(ce=>ce.id===ae.id)?ce=>{const me=Array.isArray(ce)?ce:[ce];f(me.map(({key:we,value:ve})=>({key:we,value:ve,schemaId:ae.id})))}:void 0,stopEditing:()=>M(!1),outline:`1px ${x===ae.id?"solid":"dashed"} ${ae.readOnly&&x!==ae.id?"transparent":_.colorPrimary}`,scale:d},ae.id)}})]})},Canvas$1=reactExports.forwardRef(Canvas),Spinner=()=>{const{token:a}=theme.useToken(),s={position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",color:a.colorPrimary},c={animation:"spin 1s linear infinite"};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("style",{children:`
|
1352
|
+
`);__spreadArray(["className","rulerStyle","snapThreshold","snaps","displayDragPos","cspNonce","dragPosFormat","defaultGuides","showGuides","scrollOptions","guideStyle","guidesOffset","digit","defaultGuidesPos","dragGuideStyle","displayGuidePos","guidePosFormat","guidePosStyle","lockGuides","guidesZoom"],PROPERTIES,!0);var GuidesElement=styled("div",GUIDES_CSS),Guides=function(a){__extends(s,a);function s(u){var d=a.call(this,u)||this;return d.state={guides:[]},d.scrollPos=0,d.managerRef=reactExports.createRef(),d.guideElements=[],d._isFirstMove=!1,d._zoom=1,d._guidesZoom=1,d._observer=null,d.onDragStart=function(p){var v=p.datas,A=p.inputEvent;d._isFirstMove=!0,d.movePos(p),d.props.onDragStart(__assign(__assign({},p),{dragElement:v.target})),d.gesto.isFlag()&&(A.stopPropagation(),A.preventDefault(),d._startDragScroll(p))},d._onDrag=function(p){d._isFirstMove&&(d._isFirstMove=!1,addClass(p.datas.target,DRAGGING));var v=d.movePos(p);if(d.props.onDrag(__assign(__assign({},p),{dragElement:p.datas.target})),!d.gesto.isFlag()){d._endDragScroll(p);return}return d._dragScroll(p),v},d.onDragEnd=function(p){var v=p.datas,A=p.isDouble,b=p.distX,g=p.distY,x=d.movePos(p),y=d.state.guides,f=d.props,m=f.onChangeGuides,C=f.displayDragPos,S=f.digit,w=f.lockGuides,_=f.guidesOffset,I=d._guidesZoom,$=parseFloat((x/I).toFixed(S||0)),P=d.scrollPos-(_||0);if(C&&(d.displayElement.style.cssText+="display: none;"),removeClass(v.target,DRAGGING),d.props.onDragEnd(__assign(__assign({},p),{dragElement:v.target})),d._endDragScroll(p),v.fromRuler)d._isFirstMove&&d.props.onClickRuler(__assign(__assign({},p),{pos:0})),$>=P&&y.indexOf($)<0&&d.setState({guides:__spreadArray(__spreadArray([],y,!0),[$],!1)},function(){m({guides:d.state.guides,distX:b,distY:g,index:y.length,isAdd:!0,isRemove:!1,isChange:!1})});else{var E=parseFloat(v.target.getAttribute("data-index")),R=!1,T=!1;y=__spreadArray([],y,!0);var B=y.indexOf($);if(A||$<P||B>-1&&B!==E){if(w&&(w===!0||w.indexOf("remove")>-1))return;y.splice(E,1),R=!0}else{if(B>-1)return;if(w&&(w===!0||w.indexOf("change")>-1))return;y[E]=$,T=!0}d.setState({guides:y},function(){var M=d.state.guides;m({distX:b,distY:g,guides:M,isAdd:!1,index:E,isChange:T,isRemove:R})})}},d._onCheck=function(){d.resize()},d.state.guides=u.defaultGuides||[],d.scrollPos=u.defaultGuidesPos||0,d}var c=s.prototype;return c.render=function(){var u=this.props,d=u.className,p=u.type,v=u.zoom,A=u.guidesZoom,b=u.style,g=u.rulerStyle,x=u.displayDragPos,y=u.cspNonce,f=u.dragGuideStyle,m=u.guidePosStyle,C=m===void 0?{}:m,S=this.props,w=this.getTranslateName(),_={};return PROPERTIES.forEach(function(I){I==="style"||I==="warpSelf"||I==="useResizeObserver"||(_[I]=S[I])}),this._zoom=v,this._guidesZoom=A||v,reactExports.createElement(GuidesElement,{ref:this.managerRef,cspNonce:y,className:"".concat(prefix("manager",p)," ").concat(d),style:b},reactExports.createElement("div",{className:prefix("guide-origin"),ref:ref(this,"originElement")}),reactExports.createElement(Ruler,__assign({ref:ref(this,"ruler"),style:g},_)),reactExports.createElement("div",{className:GUIDES,ref:ref(this,"guidesElement"),style:{transform:"".concat(w,"(").concat(-this.scrollPos*this._guidesZoom,"px)")}},x&&reactExports.createElement("div",{className:DISPLAY_DRAG,ref:ref(this,"displayElement"),style:C||{}}),reactExports.createElement("div",{className:ADDER,ref:ref(this,"adderElement"),style:f}),this.renderGuides()))},c.drawRuler=function(u){this.ruler.draw(u)},c.renderGuides=function(){var u=this,d=this.props,p=d,v=p.type,A=p.showGuides,b=p.guideStyle,g=p.displayGuidePos,x=p.guidePosStyle,y=x===void 0?{}:x,f=p.guidesOffset,m=this._guidesZoom,C=this.getTranslateName(),S=this.state.guides,w=d.guidePosFormat||d.dragPosFormat||function(_){return _};if(this.guideElements=[],A)return S.map(function(_,I){var $=_+(f||0);return reactExports.createElement("div",{className:prefix("guide",v),ref:refs(u,"guideElements",I),key:I,"data-index":I,"data-pos":_,style:__assign(__assign({},b),{transform:"".concat(C,"(").concat($*m,"px) translateZ(0px)")})},g&&reactExports.createElement("div",{className:prefix("guide-pos"),style:y||{}},w(_)))})},c.componentDidMount=function(){var u=this;this.gesto=new Gesto(this.managerRef.current,{container:document.body}).on("dragStart",function(d){var p=u.props,v=p.type,A=p.lockGuides,b=u._guidesZoom;if(A===!0){d.stop();return}var g=d.inputEvent,x=g.target,y=d.datas,f=u.ruler.canvasElement,m=u.guidesElement,C=v==="horizontal",S=u.originElement.getBoundingClientRect(),w=getDistElementMatrix(u.managerRef.current),_=calculateMatrixDist(w,[d.clientX-S.left,d.clientY-S.top]);_[0]-=m.offsetLeft,_[1]-=m.offsetTop,_[C?1:0]+=u.scrollPos*b,y.offsetPos=_,y.matrix=w;var I=A&&A.indexOf("add")>-1,$=A&&A.indexOf("remove")>-1,P=A&&A.indexOf("change")>-1;if(x===f){if(I){d.stop();return}y.fromRuler=!0,y.target=u.adderElement}else if(hasClass(x,GUIDE)){if($&&P){d.stop();return}y.target=x}else return d.stop(),!1;u.onDragStart(d)}).on("drag",this._onDrag).on("dragEnd",this.onDragEnd),this.props.useResizeObserver?(this._observer=new ResizeObserver(this._onCheck),this._observer.observe(this.guidesElement,{box:"border-box"}),this._observer.observe(this.getRulerElement(),{box:"border-box"})):this._onCheck()},c.componentWillUnmount=function(){var u;this.gesto.unset(),(u=this._observer)===null||u===void 0||u.disconnect()},c.componentDidUpdate=function(u){var d=this.props.defaultGuides;u.defaultGuides!==d&&this.setState({guides:d||[]})},c.loadGuides=function(u){this.setState({guides:u})},c.getGuides=function(){return this.state.guides},c.scrollGuides=function(u,d){d===void 0&&(d=this._guidesZoom),this._setZoom({guidesZoom:d});var p=this.getTranslateName(),v=this.guidesElement;this.scrollPos=u,v.style.transform="".concat(p,"(").concat(-u*d,"px)");var A=this.state.guides,b=this.props.guidesOffset||0;this.guideElements.forEach(function(g,x){if(g){var y=A[x]+(b||0);g.style.transform="".concat(p,"(").concat(y*d,"px) translateZ(0px)"),g.style.display=-u+y<0?"none":"block"}})},c.zoomTo=function(u,d){d===void 0&&(d=u),this.scroll(this.getRulerScrollPos(),u),this.scrollGuides(this.getGuideScrollPos(),d)},c.getElement=function(){return this.managerRef.current},c.getRulerElement=function(){return this.ruler.canvasElement},c.getGuideScrollPos=function(){return this.scrollPos},c.getRulerScrollPos=function(){return this.ruler.getScrollPos()},c.scroll=function(u,d){d===void 0&&(d=this._zoom),this._setZoom({zoom:d}),this.ruler.scroll(u,d)},c.resize=function(u){u===void 0&&(u=this._zoom),this._setZoom({zoom:u}),this.ruler.resize(u)},c.movePos=function(u){var d=u.datas,p=u.distX,v=u.distY,A=this.props,b=A.type,g=A.snaps,x=A.snapThreshold,y=A.displayDragPos,f=A.digit,m=A.guidesOffset||0,C=this._guidesZoom,S=A.dragPosFormat||function(O){return O},w=b==="horizontal",_=calculateMatrixDist(d.matrix,[p,v]),I=d.offsetPos,$=_[0]+I[0],P=_[1]+I[1],E=m*C,R=Math.round(w?P:$)-m,T=parseFloat((R/C).toFixed(f||0)),B=g.slice().sort(function(O,H){return Math.abs(T-O)-Math.abs(T-H)});if(B.length&&Math.abs(B[0]*C-R)<x&&(T=B[0],R=T*C),!d.fromRuler||!this._isFirstMove){if(y){var M=b==="horizontal"?[$,R+E]:[R+E,P];this.displayElement.style.cssText+="display: block;transform: translate(-50%, -50%) "+"translate(".concat(M.map(function(O){return"".concat(O,"px")}).join(", "),")"),this.displayElement.innerHTML="".concat(S(T))}var k=d.target;k.setAttribute("data-pos",T),k.style.transform="".concat(this.getTranslateName(),"(").concat(R+m*C,"px)")}return R},c.getTranslateName=function(){return this.props.type==="horizontal"?"translateY":"translateX"},c._startDragScroll=function(u){var d=this,p=this.props.scrollOptions;if(p){var v=u.datas,A=new DragScroll;v.dragScroll=A,A.on("scroll",function(b){var g,x,y=b.container,f=b.direction;(x=(g=d.props).onRequestScroll)===null||x===void 0||x.call(g,{container:y,direction:f})}).on("move",function(b){var g=b.offsetX,x=b.offsetY,y=b.inputEvent;d.gesto.scrollBy(g,x,y.inputEvent,!0)}),A.dragStart(u,{container:p.container})}},c._dragScroll=function(u){var d=this.props.scrollOptions;if(d){var p=u.datas.dragScroll;p.drag(u,d)}},c._endDragScroll=function(u){var d;(d=u.datas.dragScroll)===null||d===void 0||d.dragEnd(),u.datas.dragScroll=null},c._setZoom=function(u){var d=u.zoom,p=u.guidesZoom;this.props.zoom;var v=!!this.props.guidesZoom;v?p&&(this._guidesZoom=p):(p&&(this._zoom=p,this._guidesZoom=p),d&&(this._guidesZoom=d)),d&&(this._zoom=d)},s.defaultProps={className:"",type:"horizontal",zoom:1,guidesZoom:0,style:{},snapThreshold:5,snaps:[],digit:0,onClickRuler:function(){},onChangeGuides:function(){},onRequestScroll:function(){},onDragStart:function(){},onDrag:function(){},onDragEnd:function(){},displayDragPos:!1,dragPosFormat:function(u){return u},defaultGuides:[],lockGuides:!1,showGuides:!0,guideStyle:{},dragGuideStyle:{},guidePosStyle:{},defaultGuidesPos:0},s}(reactExports.PureComponent);const guideStyle=(a,s,c,u)=>({position:"absolute",top:a,left:s,height:c,width:u,background:"#333333"}),_Guides=({paperSize:a,horizontalRef:s,verticalRef:c})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"ruler-container",style:guideStyle(-30,-30,RULER_HEIGHT,RULER_HEIGHT)}),jsxRuntimeExports.jsx(Guides,{zoom:ZOOM,style:guideStyle(-30,0,RULER_HEIGHT,a.width),type:"horizontal",ref:s}),jsxRuntimeExports.jsx(Guides,{zoom:ZOOM,style:guideStyle(0,-30,a.height,RULER_HEIGHT),type:"vertical",ref:c})]}),Mask=({width:a,height:s})=>jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:-30,left:-30,zIndex:100,width:a,height:s,background:theme.useToken().token.colorBgMask}}),getPaddingStyle=(a,s,c)=>{const u={position:"absolute",background:c,opacity:.25,pointerEvents:"none"};switch(a){case 0:u.top=0,u.height=`${s*ZOOM}px`,u.left=0,u.right=0;break;case 1:u.right=0,u.width=`${s*ZOOM}px`,u.top=0,u.bottom=0;break;case 2:u.bottom=0,u.height=`${s*ZOOM}px`,u.left=0,u.right=0;break;case 3:u.left=0,u.width=`${s*ZOOM}px`,u.top=0,u.bottom=0;break}return u},Padding=({basePdf:a})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:isBlankPdf(a)&&a.padding.map((s,c)=>jsxRuntimeExports.jsx("div",{style:getPaddingStyle(c,s,theme.useToken().token.colorError)},String(c)))}),StaticSchema=a=>{const{template:{schemas:s,basePdf:c},input:u,scale:d,totalPages:p,currentPage:v}=a;return!isBlankPdf(c)||!c.staticSchema?null:jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:c.staticSchema.map(A=>jsxRuntimeExports.jsx(Renderer,{schema:{...A,id:uuid$6()},basePdf:c,value:replacePlaceholders({content:A.content||"",variables:{...u,totalPages:p,currentPage:v},schemas:s}),onChangeHoveringSchemaId:()=>{},mode:"viewer",outline:"none",scale:d,selectable:!1},A.name))})},mm2px=a=>a*3.7795275591,DELETE_BTN_ID=uuid$6(),fmt4Num=a=>Number(a.replace("px","")),fmt=a=>round$1(fmt4Num(a)/ZOOM,2),isTopLeftResize=a=>a==="-1,-1"||a==="-1,0"||a==="0,-1",normalizeRotate=a=>(a%360+360)%360,DeleteButton=({activeElements:a})=>{const{token:s}=theme.useToken(),c=26,u=Math.min(...a.map(({style:p})=>fmt4Num(p.top))),d=Math.max(...a.map(({style:p})=>fmt4Num(p.left)+fmt4Num(p.width)))+10;return jsxRuntimeExports.jsx(Button$1,{id:DELETE_BTN_ID,style:{position:"absolute",zIndex:1,top:u,left:d,width:c,height:c,padding:2,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:s.borderRadius,color:s.colorWhite,background:s.colorPrimary},children:jsxRuntimeExports.jsx(X,{style:{pointerEvents:"none"}})})},Canvas=(a,s)=>{const{basePdf:c,pageCursor:u,scale:d,backgrounds:p,pageSizes:v,size:A,activeElements:b,schemasList:g,hoveringSchemaId:x,onEdit:y,changeSchemas:f,removeSchemas:m,onChangeHoveringSchemaId:C,paperRefs:S,sidebarOpen:w}=a,{token:_}=theme.useToken(),I=reactExports.useContext(PluginsRegistry),$=reactExports.useRef([]),P=reactExports.useRef([]),E=reactExports.useRef(null),[R,T]=reactExports.useState(!1),[B,M]=reactExports.useState(!1),k=usePrevious(g[u]),O=ae=>{ae.shiftKey&&T(!0)},H=ae=>{(ae.key==="Shift"||!ae.shiftKey)&&T(!1),(ae.key==="Escape"||ae.key==="Esc")&&M(!1)},j=reactExports.useCallback(()=>{window.addEventListener("keydown",O),window.addEventListener("keyup",H)},[]),q=reactExports.useCallback(()=>{window.removeEventListener("keydown",O),window.removeEventListener("keyup",H)},[]);reactExports.useEffect(()=>(j(),q),[j,q]),reactExports.useEffect(()=>{var K,te;if((K=E.current)==null||K.updateRect(),!k)return;const ae=JSON.stringify(k[u]||{}),V=JSON.stringify(g[u]||{});ae===V&&((te=E.current)==null||te.updateRect())},[u,g,k]);const L=({target:ae,top:V,left:K})=>{const{width:te,height:ie}=ae.style,ce=fmt(te),me=fmt(ie),we=V/ZOOM,ve=K/ZOOM,{width:ge,height:ue}=v[u];let se=0,oe=0,de=0,le=0;if(isBlankPdf(c)){const[xe,Ce,$e,Se]=c.padding;se=xe*ZOOM,oe=Ce,de=$e,le=Se*ZOOM}we+me>ue-de?ae.style.top=`${(ue-me-de)*ZOOM}px`:ae.style.top=`${V<se?se:V}px`,ve+ce>ge-oe?ae.style.left=`${(ge-ce-oe)*ZOOM}px`:ae.style.left=`${K<le?le:K}px`},F=({target:ae})=>{const{top:V,left:K}=ae.style;f([{key:"position.y",value:fmt(V),schemaId:ae.id},{key:"position.x",value:fmt(K),schemaId:ae.id}])},U=({targets:ae})=>{const V=ae.map(({style:{top:K,left:te},id:ie})=>[{key:"position.y",value:fmt(K),schemaId:ie},{key:"position.x",value:fmt(te),schemaId:ie}]);f(flatten(V))},N=({target:ae,rotate:V})=>{ae.style.transform=`rotate(${V}deg)`},D=({target:ae})=>{const{transform:V}=ae.style,K=Number(V.replace("rotate(","").replace("deg)","")),te=normalizeRotate(K);f([{key:"rotate",value:te,schemaId:ae.id}])},W=({targets:ae})=>{const V=ae.map(({style:{transform:K},id:te})=>{const ie=Number(K.replace("rotate(","").replace("deg)",""));return[{key:"rotate",value:normalizeRotate(ie),schemaId:te}]});f(flatten(V))},Z=({target:ae})=>{const{id:V,style:K}=ae,{width:te,height:ie,top:ce,left:me}=K;f([{key:"position.x",value:fmt(me),schemaId:V},{key:"position.y",value:fmt(ce),schemaId:V},{key:"width",value:fmt(te),schemaId:V},{key:"height",value:fmt(ie),schemaId:V}]);const we=g[u].find(ve=>ve.id===V);we&&(we.position.x=fmt(me),we.position.y=fmt(ce),we.width=fmt(te),we.height=fmt(ie))},Q=({targets:ae})=>{const V=ae.map(({style:{width:K,height:te,top:ie,left:ce},id:me})=>[{key:"width",value:fmt(K),schemaId:me},{key:"height",value:fmt(te),schemaId:me},{key:"position.y",value:fmt(ie),schemaId:me},{key:"position.x",value:fmt(ce),schemaId:me}]);f(flatten(V))},Y=({target:ae,width:V,height:K,direction:te})=>{if(!ae)return;let ie=0,ce=0,me=0,we=0;if(isBlankPdf(c)){const[xe,Ce,$e,Se]=c.padding;ie=xe*ZOOM,ce=mm2px(Ce),me=mm2px($e),we=Se*ZOOM}const ve=mm2px(v[u].width),ge=mm2px(v[u].height),ue={width:`${V}px`,height:`${K}px`},se=ae.style;let oe=fmt4Num(se.left)+(fmt4Num(se.width)-V),de=fmt4Num(se.top)+(fmt4Num(se.height)-K);oe<we&&(oe=we),de<ie&&(de=ie),oe+V>ve-ce&&(ue.width=`${ve-ce-oe}px`),de+K>ge-me&&(ue.height=`${ge-me-de}px`);const le=te.toString();isTopLeftResize(le)?(ue.top=`${de}px`,ue.left=`${oe}px`):le==="1,-1"?ue.top=`${de}px`:le==="-1,1"&&(ue.left=`${oe}px`),Object.assign(se,ue)},J=(ae,V)=>ae[V]&&ae[V].getGuides().map(K=>K*ZOOM),ee=()=>{M(!0)},re=reactExports.useMemo(()=>{const V=(g[u]||[]).filter(ie=>b.map(ce=>ce.id).includes(ie.id)).map(ie=>ie.type),K=[...new Set(V)],te=[];return I.entries().forEach(([,ie])=>{ie.propPanel.defaultSchema&&te.push(ie.propPanel.defaultSchema)}),K.every(ie=>{const ce=te.find(me=>me&&"type"in me&&me.type===ie);return ce&&"rotate"in ce})},[b,u,g,I]);return jsxRuntimeExports.jsxs("div",{style:{position:"relative",overflow:"auto",marginRight:w?RIGHT_SIDEBAR_WIDTH:0,...A},ref:s,children:[jsxRuntimeExports.jsx(Selecto,{container:S.current[u],continueSelect:R,onDragStart:ae=>{var ce;const V=ae.inputEvent,K=V.target,te=(ce=E.current)==null?void 0:ce.isMoveableElement(K);(V.type==="touchstart"&&ae.isTrusted||te)&&ae.stop(),S.current[u]===K&&y([]);const ie=K;ie&&ie.id===DELETE_BTN_ID&&m(b.map(me=>me.id))},onSelect:ae=>{const V=ae.inputEvent,K=ae.added,te=ae.removed,ie=ae.selected,ce=V.type==="mousedown";let me=ce?ie:[];!ce&&K.length>0&&(me=b.concat(K)),!ce&&te.length>0&&(me=b.filter(ve=>!te.includes(ve))),y(me),me!=b&&M(!1);const we=V;we&&typeof we.shiftKey=="boolean"&&!we.shiftKey&&T(!1)}}),jsxRuntimeExports.jsx(Paper,{paperRefs:S,scale:d,size:A,schemasList:g,pageSizes:v,backgrounds:p,hasRulers:!0,renderPaper:({index:ae,paperSize:V})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!B&&b.length>0&&u===ae&&jsxRuntimeExports.jsx(DeleteButton,{activeElements:b}),jsxRuntimeExports.jsx(Padding,{basePdf:c}),jsxRuntimeExports.jsx(StaticSchema,{template:{schemas:g,basePdf:c},input:Object.fromEntries(g.flat().map(({name:K,content:te=""})=>[K,te])),scale:d,totalPages:g.length,currentPage:ae+1}),jsxRuntimeExports.jsx(_Guides,{paperSize:V,horizontalRef:K=>{K&&(P.current[ae]=K)},verticalRef:K=>{K&&($.current[ae]=K)}}),u!==ae?jsxRuntimeExports.jsx(Mask,{width:V.width+RULER_HEIGHT,height:V.height+RULER_HEIGHT}):!B&&jsxRuntimeExports.jsx(Moveable$1,{ref:E,target:b,bounds:{left:0,top:0,bottom:V.height,right:V.width},horizontalGuidelines:J(P.current,ae),verticalGuidelines:J($.current,ae),keepRatio:R,rotatable:re,onDrag:L,onDragEnd:F,onDragGroupEnd:U,onRotate:N,onRotateEnd:D,onRotateGroupEnd:W,onResize:Y,onResizeEnd:Z,onResizeGroupEnd:Q,onClick:ee})]}),renderSchema:({schema:ae,index:V})=>{const K=B&&b.map(ce=>ce.id).includes(ae.id)?"designer":"viewer",te=ae.content||"";let ie=te;if(K!=="designer"&&ae.readOnly){const ce={...g.flat().reduce((me,we)=>(me[we.name]=we.content||"",me),{}),totalPages:g.length,currentPage:V+1};ie=replacePlaceholders({content:te,variables:ce,schemas:g})}return jsxRuntimeExports.jsx(Renderer,{schema:ae,basePdf:c,value:ie,onChangeHoveringSchemaId:C,mode:K,onChange:(g[u]||[]).some(ce=>ce.id===ae.id)?ce=>{const me=Array.isArray(ce)?ce:[ce];f(me.map(({key:we,value:ve})=>({key:we,value:ve,schemaId:ae.id})))}:void 0,stopEditing:()=>M(!1),outline:`1px ${x===ae.id?"solid":"dashed"} ${ae.readOnly&&x!==ae.id?"transparent":_.colorPrimary}`,scale:d},ae.id)}})]})},Canvas$1=reactExports.forwardRef(Canvas),Spinner=()=>{const{token:a}=theme.useToken(),s={position:"relative",width:"100%",height:"100%",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",color:a.colorPrimary},c={animation:"spin 1s linear infinite"};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("style",{children:`
|
1354
1353
|
@keyframes spin {
|
1355
1354
|
0% {
|
1356
1355
|
transform: rotate(0deg);
|