tiny-essentials 1.23.1 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see TinyEssentials.min.js.LICENSE.txt */
2
- (()=>{var e={133:()=>{},251:(e,t)=>{t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,l=(1<<a)-1,u=l>>1,c=-7,h=r?i-1:0,d=r?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-c)-1,f>>=-c,c+=a;c>0;o=256*o+e[t+h],h+=d,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+h],h+=d,c-=8);if(0===o)o=1-u;else{if(o===l)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),o-=u}return(f?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,l,u=8*o-i-1,c=(1<<u)-1,h=c>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,p=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(t*l-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[r+f]=255&s,f+=p,s/=256,u-=8);e[r+f-p]|=128*m}},287:(e,t,r)=>{"use strict";var n=r(526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=l,t.IS=50;var s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,l.prototype),t}function l(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!l.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|m(e,t),n=a(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(F(e,Uint8Array)){var t=new Uint8Array(e);return f(t.buffer,t.byteOffset,t.byteLength)}return d(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer))return f(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(F(e,SharedArrayBuffer)||e&&F(e.buffer,SharedArrayBuffer)))return f(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return l.from(n,t,r);var i=function(e){if(l.isBuffer(e)){var t=0|p(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||W(e.length)?a(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return l.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return c(e),a(e<0?0:0|p(e))}function d(e){for(var t=e.length<0?0:0|p(e.length),r=a(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function f(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,l.prototype),n}function p(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function m(e,t){if(l.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||F(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return P(e).length;default:if(i)return n?-1:$(e).length;t=(""+t).toLowerCase(),i=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return D(this,t,r);case"utf8":case"utf-8":return I(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return L(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function w(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=l.from(t,n)),l.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){var o,s=1,a=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,l/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===l)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(r+l>a&&(r=a-l),o=r;o>=0;o--){for(var h=!0,d=0;d<l;d++)if(u(e,o+d)!==u(t,d)){h=!1;break}if(h)return o}return-1}function v(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(W(a))return s;e[r+s]=a}return s}function E(e,t,r,n){return H($(t,e.length-r),e,r,n)}function T(e,t,r,n){return H(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function S(e,t,r,n){return H(P(t),e,r,n)}function x(e,t,r,n){return H(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function I(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,l,u=e[i],c=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(c=u);break;case 2:128==(192&(o=e[i+1]))&&(l=(31&u)<<6|63&o)>127&&(c=l);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(l=(15&u)<<12|(63&o)<<6|63&s)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&l<1114112&&(c=l)}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(e){var t=e.length;if(t<=C)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=C));return r}(n)}l.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),l.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(e,t,r){return u(e,t,r)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(e,t,r){return function(e,t,r){return c(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},l.allocUnsafe=function(e){return h(e)},l.allocUnsafeSlow=function(e){return h(e)},l.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==l.prototype},l.compare=function(e,t){if(F(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),F(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},l.isEncoding=function(e){switch(String(e).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}},l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return l.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=l.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(F(o,Uint8Array))i+o.length>n.length?l.from(o).copy(n,i):Uint8Array.prototype.set.call(n,o,i);else{if(!l.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i)}i+=o.length}return n},l.byteLength=m,l.prototype._isBuffer=!0,l.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},l.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},l.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},l.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?I(this,0,e):g.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===l.compare(this,e)},l.prototype.inspect=function(){var e="",r=t.IS;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(l.prototype[o]=l.prototype.inspect),l.prototype.compare=function(e,t,r,n,i){if(F(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),h=0;h<a;++h)if(u[h]!==c[h]){o=u[h],s=c[h];break}return o<s?-1:s<o?1:0},l.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},l.prototype.indexOf=function(e,t,r){return w(this,e,t,r,!0)},l.prototype.lastIndexOf=function(e,t,r){return w(this,e,t,r,!1)},l.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":case"latin1":case"binary":return T(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function M(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function L(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function D(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=z[e[o]];return i}function k(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function N(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function _(e,t,r,n,i,o){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function j(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(e,t,r,n,o){return t=+t,r>>>=0,o||j(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function R(e,t,r,n,o){return t=+t,r>>>=0,o||j(e,0,r,8),i.write(e,t,r,n,52,8),r+8}l.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,l.prototype),n},l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},l.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},l.prototype.readInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){e>>>=0,t||N(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt16BE=function(e,t){e>>>=0,t||N(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readFloatLE=function(e,t){return e>>>=0,t||N(e,4,this.length),i.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return e>>>=0,t||N(e,4,this.length),i.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return e>>>=0,t||N(e,8,this.length),i.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return e>>>=0,t||N(e,8,this.length),i.read(this,e,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||_(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||_(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,1,255,0),this[t]=255&e,t+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);_(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},l.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);_(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},l.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},l.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeFloatLE=function(e,t,r){return O(this,e,t,!0,r)},l.prototype.writeFloatBE=function(e,t,r){return O(this,e,t,!1,r)},l.prototype.writeDoubleLE=function(e,t,r){return R(this,e,t,!0,r)},l.prototype.writeDoubleBE=function(e,t,r){return R(this,e,t,!1,r)},l.prototype.copy=function(e,t,r,n){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i},l.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=l.isBuffer(e)?e:l.from(e,n),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var B=/[^+/0-9A-Za-z-_]/g;function $(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function P(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(B,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function W(e){return e!=e}var z=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var n=16*r,i=0;i<16;++i)t[n+i]=e[r]+e[i];return t}()},370:()=>{},526:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,o=a(e),s=o[0],l=o[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,l)),c=0,h=l>0?s-4:s;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],u[c++]=t>>16&255,u[c++]=t>>8&255,u[c++]=255&t;return 2===l&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[c++]=255&t),1===l&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=16383,a=0,l=n-i;a<l;a+=s)o.push(u(e,a,a+s>l?l:a+s));return 1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function u(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(l(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},606:e=>{var t,r,n=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var a,l=[],u=!1,c=-1;function h(){u&&a&&(u=!1,a.length?l=a.concat(l):c=-1,l.length&&d())}function d(){if(!u){var e=s(h);u=!0;for(var t=l.length;t;){for(a=l,l=[];++c<t;)a&&a[c].run();c=-1,t=l.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function f(e,t){this.fun=e,this.array=t}function p(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new f(e,t)),1!==l.length||u||s(d)},f.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},766:()=>{},911:()=>{},975:(e,t,r)=>{"use strict";var n=r(606);function i(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function o(e,t){for(var r,n="",i=0,o=-1,s=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(o===a-1||1===s);else if(o!==a-1&&2===s){if(n.length<2||2!==i||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(n.length>2){var l=n.lastIndexOf("/");if(l!==n.length-1){-1===l?(n="",i=0):i=(n=n.slice(0,l)).length-1-n.lastIndexOf("/"),o=a,s=0;continue}}else if(2===n.length||1===n.length){n="",i=0,o=a,s=0;continue}t&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+e.slice(o+1,a):n=e.slice(o+1,a),i=a-o-1;o=a,s=0}else 46===r&&-1!==s?++s:s=-1}return n}var s={resolve:function(){for(var e,t="",r=!1,s=arguments.length-1;s>=-1&&!r;s--){var a;s>=0?a=arguments[s]:(void 0===e&&(e=n.cwd()),a=e),i(a),0!==a.length&&(t=a+"/"+t,r=47===a.charCodeAt(0))}return t=o(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(i(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=o(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return i(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var r=arguments[t];i(r),r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":s.normalize(e)},relative:function(e,t){if(i(e),i(t),e===t)return"";if((e=s.resolve(e))===(t=s.resolve(t)))return"";for(var r=1;r<e.length&&47===e.charCodeAt(r);++r);for(var n=e.length,o=n-r,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var l=t.length-a,u=o<l?o:l,c=-1,h=0;h<=u;++h){if(h===u){if(l>u){if(47===t.charCodeAt(a+h))return t.slice(a+h+1);if(0===h)return t.slice(a+h)}else o>u&&(47===e.charCodeAt(r+h)?c=h:0===h&&(c=0));break}var d=e.charCodeAt(r+h);if(d!==t.charCodeAt(a+h))break;47===d&&(c=h)}var f="";for(h=r+c+1;h<=n;++h)h!==n&&47!==e.charCodeAt(h)||(0===f.length?f+="..":f+="/..");return f.length>0?f+t.slice(a+c):(a+=c,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(i(e),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,n=-1,o=!0,s=e.length-1;s>=1;--s)if(47===(t=e.charCodeAt(s))){if(!o){n=s;break}}else o=!1;return-1===n?r?"/":".":r&&1===n?"//":e.slice(0,n)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');i(e);var r,n=0,o=-1,s=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(r=e.length-1;r>=0;--r){var u=e.charCodeAt(r);if(47===u){if(!s){n=r+1;break}}else-1===l&&(s=!1,l=r+1),a>=0&&(u===t.charCodeAt(a)?-1===--a&&(o=r):(a=-1,o=l))}return n===o?o=l:-1===o&&(o=e.length),e.slice(n,o)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!s){n=r+1;break}}else-1===o&&(s=!1,o=r+1);return-1===o?"":e.slice(n,o)},extname:function(e){i(e);for(var t=-1,r=0,n=-1,o=!0,s=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===n&&(o=!1,n=a+1),46===l?-1===t?t=a:1!==s&&(s=1):-1!==t&&(s=-1);else if(!o){r=a+1;break}}return-1===t||-1===n||0===s||1===s&&t===n-1&&t===r+1?"":e.slice(t,n)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+"/"+n:n}(0,e)},parse:function(e){i(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var r,n=e.charCodeAt(0),o=47===n;o?(t.root="/",r=1):r=0;for(var s=-1,a=0,l=-1,u=!0,c=e.length-1,h=0;c>=r;--c)if(47!==(n=e.charCodeAt(c)))-1===l&&(u=!1,l=c+1),46===n?-1===s?s=c:1!==h&&(h=1):-1!==s&&(h=-1);else if(!u){a=c+1;break}return-1===s||-1===l||0===h||1===h&&s===l-1&&s===a+1?-1!==l&&(t.base=t.name=0===a&&o?e.slice(1,l):e.slice(a,l)):(0===a&&o?(t.name=e.slice(1,s),t.base=e.slice(1,l)):(t.name=e.slice(a,s),t.base=e.slice(a,l)),t.ext=e.slice(s,l)),a>0?t.dir=e.slice(0,a-1):o&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};s.posix=s,e.exports=s}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{ColorSafeStringify:()=>K,TinyAdvancedRaffle:()=>Zt,TinyAfterScrollWatcher:()=>vt,TinyArrayPaginator:()=>Xt,TinyClipboard:()=>_t,TinyColorConverter:()=>Ot,TinyCookieConsent:()=>nr,TinyDayNightCycle:()=>Yt,TinyDomReadyManager:()=>wt,TinyDragDropDetector:()=>se,TinyDragger:()=>yt,TinyElementObserver:()=>rt,TinyEvents:()=>Lt,TinyGamepad:()=>Gt,TinyHtml:()=>mt,TinyI18:()=>sr,TinyIframeEvents:()=>qt,TinyInventory:()=>tr,TinyInventoryTrader:()=>rr,TinyLevelUp:()=>i,TinyLoadingScreen:()=>cr,TinyLocalStorage:()=>Wt,TinyNeedBar:()=>lr,TinyNewWinEvents:()=>Kt,TinyNotifications:()=>bt,TinyNotifyCenter:()=>Y,TinyPromiseQueue:()=>J,TinyRateLimiter:()=>U,TinySimpleDice:()=>ur,TinySmartScroller:()=>kt,TinyTextRangeEditor:()=>Nt,TinyTextarea:()=>Jt,TinyTimeout:()=>Bt,TinyToastNotify:()=>Q,UltraRandomMsgGen:()=>Mt,addAiMarkerShortcut:()=>W,areElsCollBottom:()=>Pe,areElsCollLeft:()=>He,areElsCollPerfBottom:()=>ze,areElsCollPerfLeft:()=>qe,areElsCollPerfRight:()=>Ve,areElsCollPerfTop:()=>We,areElsCollRight:()=>Fe,areElsCollTop:()=>$e,areElsColliding:()=>Ke,areElsPerfColliding:()=>Je,arraySortPositions:()=>o,asyncReplace:()=>t,backupFile:()=>Se,breakdownDuration:()=>d,calculateMarketcap:()=>$,checkObj:()=>S,clearDirectory:()=>de,clearDirectoryAsync:()=>Ne,cloneObjTypeOrder:()=>v,compareMarketcap:()=>P,countObj:()=>p,diffArrayList:()=>a,diffStrings:()=>q,dirExists:()=>pe,dirSize:()=>Te,dirSizeAsync:()=>Be,documentIsFullScreen:()=>x,ensureCopyFile:()=>ge,ensureDirectory:()=>he,exitFullScreen:()=>M,extendObjType:()=>w,fetchJson:()=>ne,fetchText:()=>ie,fileExists:()=>fe,fileSize:()=>Ee,fileSizeAsync:()=>Re,formatBytes:()=>R,formatCustomTimer:()=>u,formatDayTimer:()=>h,formatTimer:()=>c,genFibonacciSeq:()=>B,getAge:()=>O,getElsCollDetails:()=>tt,getElsCollDirDepth:()=>et,getElsCollOverlap:()=>Ye,getElsCollOverlapPos:()=>Qe,getElsColliding:()=>Ue,getElsPerfColliding:()=>Ge,getElsRelativeCenterOffset:()=>Xe,getLatestBackupPath:()=>xe,getPercentage:()=>j,getRectCenter:()=>Ze,getSimplePerc:()=>_,getTimeDuration:()=>l,installWindowHiddenScript:()=>oe,isDirEmpty:()=>me,isDirEmptyAsync:()=>_e,isFullScreenMode:()=>I,isJsonObject:()=>m,isScreenFilled:()=>A,listDirs:()=>ve,listDirsAsync:()=>Oe,listFiles:()=>be,listFilesAsync:()=>je,objType:()=>T,offFullScreenChange:()=>k,onFullScreenChange:()=>D,readBase64Blob:()=>X,readFileBlob:()=>Z,readJsonBlob:()=>ee,readJsonFile:()=>ue,renameFileAddPrefixSuffix:()=>Me,renameFileBatch:()=>Ie,renameFileNormalizeCase:()=>Le,renameFilePadNumbers:()=>De,renameFileRegex:()=>Ce,reorderObjTypeOrder:()=>b,requestFullScreen:()=>C,restoreLatestBackup:()=>Ae,ruleOfThree:()=>N,safeTextTrim:()=>z,saveJsonFile:()=>te,shuffleArray:()=>s,toTitleCase:()=>H,toTitleCaseLowerFirst:()=>F,tryDeleteFile:()=>ye,writeJsonFile:()=>ce,writeTextFile:()=>we});var e={};async function t(e,t,r){const n=[];e.replace(t,(e,...t)=>(n.push(r(e,...t)),e));const i=await Promise.all(n);return e.replace(t,()=>i.shift())}r.r(e),r.d(e,{areElsCollBottom:()=>Pe,areElsCollLeft:()=>He,areElsCollPerfBottom:()=>ze,areElsCollPerfLeft:()=>qe,areElsCollPerfRight:()=>Ve,areElsCollPerfTop:()=>We,areElsCollRight:()=>Fe,areElsCollTop:()=>$e,areElsColliding:()=>Ke,areElsPerfColliding:()=>Je,getElsCollDetails:()=>tt,getElsCollDirDepth:()=>et,getElsCollOverlap:()=>Ye,getElsCollOverlapPos:()=>Qe,getElsColliding:()=>Ue,getElsPerfColliding:()=>Ge,getElsRelativeCenterOffset:()=>Xe,getRectCenter:()=>Ze});const i=class{constructor(e,t){if("number"!=typeof e||Number.isNaN(e))throw new Error("giveExp must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("expLevel must be a valid number");this.giveExp=e,this.expLevel=t}createUser(){return{exp:0,level:1,totalExp:0}}validateUser(e){if("number"!=typeof e.exp||Number.isNaN(e.exp))throw new Error("exp must be a valid number");if("number"!=typeof e.level||Number.isNaN(e.level))throw new Error("level must be a valid number");if(e.level<1)throw new Error("level must be at least 1");if("number"!=typeof e.totalExp||Number.isNaN(e.totalExp))throw new Error("totalExp must be a valid number")}isValidUser(e){return!("number"!=typeof e.exp||Number.isNaN(e.exp)||"number"!=typeof e.level||Number.isNaN(e.level)||e.level<1||"number"!=typeof e.totalExp||Number.isNaN(e.totalExp))}getGiveExpBase(){if("number"!=typeof this.giveExp||Number.isNaN(this.giveExp))throw new Error("giveExp must be a valid number");return this.giveExp}getExpLevelBase(){if("number"!=typeof this.expLevel||Number.isNaN(this.expLevel))throw new Error("expLevel must be a valid number");return this.expLevel}expValidator(e){const t=this.getExpLevelBase();this.validateUser(e);let r=0;const n=t*e.level;return e.exp>=n&&(e.level++,r=e.exp-n,e.exp=0,r>0)?this.give(e,r,"extra"):e.exp<1&&e.level>1&&(e.level--,r=Math.abs(e.exp),e.exp=t*e.level,r>0)?this.remove(e,r,"extra"):e}getTotalExp(e){this.validateUser(e);let t=0;for(let r=1;r<=e.level;r++)t+=this.getExpLevelBase()*r;return t+=e.exp,t}expGenerator(e=1){if("number"!=typeof e||Number.isNaN(e))throw new Error("multi must be a valid number");return Math.floor(Math.random()*this.getGiveExpBase())*e}getMissingExp(e){return this.getProgress(e)-e.exp}progress(e){return this.getProgress(e)}getProgress(e){return this.validateUser(e),this.getExpLevelBase()*e.level}set(e,t){if("number"!=typeof t||Number.isNaN(t))throw new Error("value must be a valid number");return e.exp=t,this.expValidator(e),e.totalExp=this.getTotalExp(e),e}give(e,t=0,r="add",n=1){if("number"!=typeof n||Number.isNaN(n))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp+=this.expGenerator(n)+t:"extra"===r&&(e.exp+=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}remove(e,t=0,r="add",n=1){if("number"!=typeof n||Number.isNaN(n))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp-=this.expGenerator(n)+t:"extra"===r&&(e.exp-=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}};function o(e,t=!1){return t?function(t,r){return t[e]>r[e]?-1:t[e]<r[e]?1:0}:function(t,r){return t[e]<r[e]?-1:t[e]>r[e]?1:0}}function s(e){let t,r=e.length;for(;0!==r;)t=Math.floor(Math.random()*r),r--,[e[r],e[t]]=[e[t],e[r]];return e}function a(e,t){const r=e.filter(e=>!t.includes(e));return{added:t.filter(t=>!e.includes(t)),removed:r}}function l(e=new Date,t="asSeconds",r=null){if(e instanceof Date){const n=r instanceof Date?r:new Date,i=e.getTime()-n.getTime();switch(t){case"asMilliseconds":return i;case"asSeconds":default:return i/1e3;case"asMinutes":return i/6e4;case"asHours":return i/36e5;case"asDays":return i/864e5}}return null}function u(e,t="seconds",r="{time}"){e=Math.max(0,Math.floor(e));const n=["seconds","minutes","hours","days","months","years"].indexOf(t),i=n>=5,o=n>=4,s=n>=3,a=n>=2,l=n>=1,u=n>=0,c={years:i?0:NaN,months:o?0:NaN,days:s?0:NaN,hours:a?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,total:NaN};let h=e;if(i||o||s){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*h),r=new Date(e);if(i)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),c.years++;if(o)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;h=Math.floor((t.getTime()-r.getTime())/1e3)}a&&(c.hours=Math.floor(h/3600),h%=3600),l&&(c.minutes=Math.floor(h/60),h%=60),u&&(c.seconds=h),o&&(c.years,c.months,c.days),i&&(c.years,c.months,c.days),c.total=+e.toFixed(2).replace(/\.00$/,"");const d=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},f=[a?d(c.hours):null,l?d(c.minutes):null,u?d(c.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(c.years)).replace(/\{months\}/g,String(c.months)).replace(/\{days\}/g,String(c.days)).replace(/\{hours\}/g,d(c.hours)).replace(/\{minutes\}/g,d(c.minutes)).replace(/\{seconds\}/g,d(c.seconds)).replace(/\{time\}/g,f).replace(/\{total\}/g,String(c.total)).trim()}function c(e){return u(e,"hours","{hours}:{minutes}:{seconds}")}function h(e){return u(e,"days","{days}d {hours}:{minutes}:{seconds}")}function d(e,t="milliseconds"){e=Math.max(0,Math.floor(e));const r=["milliseconds","seconds","minutes","hours","days","months","years"].indexOf(t),n=r>=6,i=r>=5,o=r>=4,s=r>=3,a=r>=2,l=r>=1,u=r>=0,c={years:n?0:NaN,months:i?0:NaN,days:o?0:NaN,hours:s?0:NaN,minutes:a?0:NaN,seconds:l?0:NaN,milliseconds:u?0:NaN,total:NaN};let h=e;if(n||i||o){const e=new Date(1980,0,1),t=new Date(e.getTime()+h),r=new Date(e);if(n)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),c.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(o)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;h=t.getTime()-r.getTime()}return s&&(c.hours=Math.floor(h/36e5),h%=36e5),a&&(c.minutes=Math.floor(h/6e4),h%=6e4),l&&(c.seconds=Math.floor(h/1e3),h%=1e3),u&&(c.milliseconds=h),i&&(c.years,c.months,c.days),n&&(c.years,c.months,c.days),c.total=+e,c}var f=r(287);function p(e){return Array.isArray(e)?e.length:m(e)?Object.keys(e).length:0}function m(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const g="undefined"!=typeof window&&void 0!==window.document,y={items:{},order:[]};function w(e,t){const r=[],n=Array.isArray(e)?e:Object.entries(e);for(const[e,i]of n)if(!y.items.hasOwnProperty(e)){y.items[e]=i;let n="number"==typeof t?t:-1;if(-1===n){const e=y.order.indexOf("object");n=e>-1?e:y.order.length}n=Math.min(Math.max(0,n),y.order.length),y.order.splice(n,0,e),r.push(e)}return r}function b(e){const t=[...y.order];return!!e.every(e=>t.includes(e))&&(y.order=e.slice(),!0)}function v(){return[...y.order]}const E=e=>{if(null===e)return"null";for(const t of y.order)if("function"!=typeof y.items[t]||y.items[t](e))return t;return"unknown"};function T(e,t){if(void 0===e)return null;const r=E(e);return"string"==typeof t?r===t.toLowerCase():r}function S(e){const t={valid:null,type:null};for(const r of y.order)if("function"==typeof y.items[r]){const n=y.items[r](e);if(n){t.valid=n,t.type=r;break}}return t}w([["undefined",e=>void 0===e],["null",e=>null===e],["boolean",e=>"boolean"==typeof e],["number",e=>"number"==typeof e&&!Number.isNaN(e)],["bigint",e=>"bigint"==typeof e],["string",e=>"string"==typeof e],["symbol",e=>"symbol"==typeof e],["function",e=>"function"==typeof e],["array",e=>Array.isArray(e)]]),g||w([["buffer",e=>void 0!==f.hp&&f.hp.isBuffer(e)]]),g&&w([["file",e=>"undefined"!=typeof File&&e instanceof File]]),w([["date",e=>e instanceof Date],["regexp",e=>e instanceof RegExp],["map",e=>e instanceof Map],["set",e=>e instanceof Set],["weakmap",e=>e instanceof WeakMap],["weakset",e=>e instanceof WeakSet],["promise",e=>e instanceof Promise]]),g&&w([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),w([["object",e=>m(e)]]);const x=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),A=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,I=()=>x()||A(),C=e=>new Promise(async(t,r)=>{const n=document.documentElement;try{n.requestFullscreen?await n.requestFullscreen(e):n.mozRequestFullScreen?n.mozRequestFullScreen(e):n.webkitRequestFullScreen?n.webkitRequestFullScreen(e):n.msRequestFullscreen&&n.msRequestFullscreen(e),t()}catch(e){r(e)}}),M=()=>new Promise((e,t)=>{if(document.exitFullscreen)document.exitFullscreen().then(e).catch(t);else try{if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Fullscreen API is not supported");document.msExitFullscreen()}e()}catch(e){t(e)}}),L=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],D=(e,t)=>{L.forEach(r=>{document.addEventListener(r,e,t)})},k=(e,t)=>{L.forEach(r=>{document.removeEventListener(r,e,t)})};function N(e,t,r,n=!1){return n?Number(e*t)/r:Number(r*t)/e}function _(e,t){return e*(t/100)}function j(e,t){return 0===t?0:e/t*100}function O(e=0,t=null){if(null!=e&&0!==e){const r=new Date(e);if(Number.isNaN(r.getTime()))return null;const n=t instanceof Date?t:new Date;let i=n.getFullYear()-r.getFullYear();const o=n.getMonth(),s=r.getMonth(),a=n.getDate(),l=r.getDate();return(o<s||o===s&&a<l)&&i--,Math.abs(i)}return null}function R(e,t=null,r=null){if("number"!=typeof e||e<0)return{unit:null,value:null};if(0===e)return{unit:"Bytes",value:0};const n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=r&&n.includes(r)?n.indexOf(r):n.length-1,o=Math.min(Math.floor(Math.log(e)/Math.log(1024)),i);let s=e/Math.pow(1024,o);if(null!==t){const e=t<0?0:t;s=parseFloat(s.toFixed(e))}return{unit:n[o],value:s}}function B({baseValues:e=[0,1],length:t=10,combiner:r=(e,t)=>e+t}={}){if(!Array.isArray(e)||2!==e.length)throw new Error("baseValues must be an array of exactly two numbers");const n=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(n[e-2],n[e-1],e);n.push(t)}return n}function $(e,t){if(Number.isNaN(e)||!Number.isFinite(e))throw new TypeError("Original market cap must be a number.");if(Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("Circulating supply must be a number.");if(t<=0)throw new Error("Circulating supply must be greater than zero.");return e/t}function P(e,t,r){if(Number.isNaN(r)||!Number.isFinite(r))throw new TypeError("New market cap must be a number.");const n=$(e,t),i="number"==typeof r?r/t:NaN;return{originalPrice:n,newPrice:i,priceChangePercent:"number"==typeof r?(i-n)/n*100:NaN}}function H(e){return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function F(e){const t=e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase());return t.charAt(0).toLowerCase()+t.slice(1)}function W({key:e="a",className:t="detect-made-by-ai"}={}){if("undefined"==typeof HTMLElement)throw new Error("[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.");const r=function(r){if(r.ctrlKey&&r.altKey&&r.key.toLowerCase()===e){if(r.preventDefault(),!document.body)return void console.warn("[AiMarkerShortcut] <body> element not found. Cannot toggle class. Ensure the DOM is fully loaded when using the shortcut.");document.body.classList.toggle(t)}};return document.addEventListener("keydown",r),r}function z(e,t,r=.6){if("string"!=typeof e)throw new TypeError("Expected a string for 'text', but received "+typeof e);if(!Number.isInteger(t)||t<=0)throw new TypeError(`Expected 'limit' to be a positive integer, but received ${t}`);if("number"!=typeof r||r<0||r>1)throw new TypeError(`Expected 'safeCutZone' to be a number between 0 and 1, but received ${r}`);let n=e.trim();if(n.length>t){const e=n.lastIndexOf(" ",t);return e>0&&e>=t*r?`${n.substring(0,e).trim()}...`:`${n.substring(0,t).trim()}...`}return n}function q(e,t){const r={added:{},removed:{},modified:{}};for(const n in e)n in t?e[n]!==t[n]&&(r.modified[n]={old:e[n],new:t[n]}):r.removed[n]=e[n];for(const n in t)n in e||(r.added[n]=t[n]);return r}class V{#e;static#t={default:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},solarized:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},monokai:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""}};constructor(e={}){this.#e={...V.#t.default,...e}}#r(e,t){const r=[];e=(e=(e=e.replace(/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,`${t.number}$1${t.reset}`)).replace(/"([^"]+)":/g,(e,t)=>{const n=`___KEY${r.length}___`;return r.push({marker:n,key:t}),`${n}:`})).replace(/"(?:\\.|[^"\\])*?"/g,e=>{const r=e.slice(1,-1);return/^(https?|ftp):\/\/[^\s]+$/i.test(r)?`${t.string_url}${e}${t.reset}`:/^(true|false|null)$/.test(r)?`${t.string_bool}${e}${t.reset}`:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(r)?`${t.string_number}${e}${t.reset}`:`${t.string}${e}${t.reset}`});for(const{marker:n,key:i}of r){const r=new RegExp(n,"g");e=e.replace(r,`${t.key}"${i}"${t.reset}`)}return(e=(e=(e=(e=e.replace(/(?<!")\b(true|false)\b(?!")/g,`${t.boolean}$1${t.reset}`)).replace(/(?<!")\bnull\b(?!")/g,`${t.null}null${t.reset}`)).replace(/\[Circular\]/g,`${t.special}[Circular]${t.reset}`)).replace(/\[undefined\]/g,`${t.special}[undefined]${t.reset}`)).replace(/"function.*?[^\\]"/gs,`${t.func}$&${t.reset}`)}colorize(e,t={}){const r={...this.#e,...t};return this.#r(e,r)}getColors(){return{...this.#e}}updateColors(e){Object.assign(this.#e,e)}resetColors(){this.#e={...V.#t.default}}loadColorPreset(e){const t=V.#t[e];if(!t)throw new Error(`Preset "${e}" not found.`);this.#e={...t}}saveColorPreset(e,t){V.#t[e]={...t}}getAvailablePresets(){return Object.keys(V.#t)}}const K=V,J=class{#n=[];#i=!1;#o={};#s=new Set;isRunning(){return this.#i}async#a(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:r,reject:n,delay:i,id:o}=e;try{if(o&&this.#s.has(o))return n(new Error("The function was canceled on TinyPromiseQueue.")),this.#s.delete(o),this.#i=!1,void this.#l();i&&o&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#o[o],e(null)},i);this.#o[o]=t}),r(await t())}catch(e){n(e)}finally{this.#i=!1,this.#l()}}}async#u(){const e=[];for(;this.#n.length&&"POINT_MARKER"===this.#n[0]?.marker;)e.push(this.#n.shift());if(0===e.length)return this.#i=!1,void this.#l();await Promise.all(e.map(({task:e,resolve:t,reject:r,id:n})=>new Promise(async i=>{if(n&&this.#s.has(n))return this.#s.delete(n),r(new Error("The function was canceled on TinyPromiseQueue.")),void i(!0);await e().then(t).catch(r),i(!0)}))),this.#i=!1,this.#l()}async#l(){if(!this.#i&&0!==this.#n.length)if(this.#i=!0,"string"!=typeof this.#n[0]?.marker||"POINT_MARKER"!==this.#n[0]?.marker){const e=this.#n.shift();this.#a(e)}else this.#u()}getIndexById(e){return this.#n.findIndex(t=>t.id===e)}getQueuedIds(){return this.#n.map((e,t)=>({index:t,id:e.id})).filter(e=>"string"==typeof e.id)}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#n.length||t>=this.#n.length)return;const[r]=this.#n.splice(e,1);this.#n.splice(t,0,r)}async enqueuePoint(e,t){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&"string"!=typeof t)throw new Error('The "id" parameter must be a string.');return this.#i?new Promise((r,n)=>{this.#n.push({marker:"POINT_MARKER",task:e,resolve:r,reject:n,id:t}),this.#l()}):e()}enqueue(e,t,r){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&("number"!=typeof t||t<0))return Promise.reject(new Error("Delay must be a positive number or undefined."));if(void 0!==r&&"string"!=typeof r)throw new Error('The "id" parameter must be a string.');return new Promise((n,i)=>{this.#n.push({task:e,resolve:n,reject:i,id:r,delay:t}),this.#l()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#o&&(clearTimeout(this.#o[e]),delete this.#o[e],t=!0);const r=this.getIndexById(e);if(-1!==r){const[e]=this.#n.splice(r,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#s.add(e),t}},U=class{#c=null;#h=null;#d=null;#f=null;#p=null;#m=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#g=null;setOnMemoryExceeded(e){if("function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#g=e}clearOnMemoryExceeded(){this.#g=null}#y=null;setOnGroupExpired(e){if("function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#y=e}clearOnGroupExpired(){this.#y=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:n=3e5,maxMemory:i=1e5}){const o=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),s=o(e),a=o(t),l=o(r),u=o(n);if(!s&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==e&&!s)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==t&&!a)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==r&&!l)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!u)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof i&&Number.isFinite(i)&&i>0)this.#c=Math.floor(i);else{if(null!=i)throw new Error("maxMemory must be a positive number or null");this.#c=null}this.#d=s?e:null,this.#f=a?t:null,this.#p=l?r:null,this.#m=n,null!==this.#p&&(this.#h=setInterval(()=>this._cleanup(),this.#p))}isGroupId(e){const t=this.groupFlags.get(e);return"boolean"==typeof t&&t}getUsersInGroup(e){const t=[];for(const[r,n]of this.userToGroup.entries())n===e&&t.push(r);return t}setGroupTTL(e,t){if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new Error("TTL must be a positive number in milliseconds");this.groupTTL.set(e,t)}getGroupTTL(e){return this.groupTTL.get(e)??null}deleteGroupTTL(e){this.groupTTL.delete(e)}assignToGroup(e,t){const r=this.userToGroup.get(e);if(r&&r!==t)throw new Error(`User ${e} is already assigned to group ${r}`);if(r===t)return;const n=this.groupData.get(e);if(this.isGroupId(e)){for(const[r,n]of this.userToGroup.entries())n===e&&this.userToGroup.set(r,t);this.userToGroup.delete(e)}else this.userToGroup.set(e,t);if(!n)return;const i=this.groupData.get(t);if(i)for(const e of n)i.push(e);else{const e=[];for(const t of n)e.push(t);this.groupData.set(t,e)}this.lastSeen.set(t,Date.now()),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e),this.groupFlags.set(t,!0)}getGroupId(e){return this.userToGroup.get(e)||e}hit(e){const t=this.getGroupId(e),r=Date.now();this.groupData.has(t)||(this.groupData.set(t,[]),this.groupFlags.set(t,!1));const n=this.groupData.get(t);if(!n)throw new Error(`No data found for groupId: ${t}`);if(n.push(r),this.lastSeen.set(t,r),null!==this.#f){const e=r-this.getInterval();for(;n.length&&n[0]<e;)n.shift()}null!==this.#c&&"number"==typeof this.#c&&n.length>this.#c&&(n.splice(0,n.length-this.#c),"function"==typeof this.#g&&this.#g(t))}isRateLimited(e){const t=this.getGroupId(e);if(!this.groupData.has(t))return!1;const r=this.groupData.get(t);if(!r)throw new Error(`No data found for groupId: ${t}`);if(null!==this.#f){const e=Date.now()-this.getInterval();let t=0;for(let n=r.length-1;n>=0&&r[n]>e;n--)t++;return null!==this.#d?t>this.getMaxHits():t>0}return null!==this.#d&&r.length>this.getMaxHits()}resetGroup(e){this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e)}resetUserGroup(e){this.userToGroup.delete(e)}setData(e,t){if(!Array.isArray(t))throw new Error("timestamps must be an array of numbers.");for(const e of t)if("number"!=typeof e||!Number.isFinite(e))throw new Error("All timestamps must be finite numbers.");this.groupData.has(e)||this.groupFlags.set(e,!1),this.groupData.set(e,t),this.lastSeen.set(e,Date.now())}hasData(e){return this.groupData.has(e)}getData(e){return this.groupData.get(e)||[]}getMaxIdle(){if("number"!=typeof this.#m||!Number.isFinite(this.#m)||this.#m<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#m}setMaxIdle(e){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#m=e}_cleanup(){const e=Date.now();for(const[t,r]of this.lastSeen.entries())e-r>(this.getGroupTTL(t)??this.getMaxIdle())&&(this.groupFlags.delete(t),this.groupData.delete(t),this.lastSeen.delete(t),this.groupTTL.delete(t),"function"==typeof this.#y&&this.#y(t))}getActiveGroups(){return Array.from(this.groupData.keys())}getAllUserMappings(){return Object.fromEntries(this.userToGroup)}getInterval(){if("number"!=typeof this.#f||!Number.isFinite(this.#f))throw new Error("'interval' is not a valid finite number.");return this.#f}getMaxHits(){if("number"!=typeof this.#d||!Number.isFinite(this.#d))throw new Error("'maxHits' is not a valid finite number.");return this.#d}getTotalHits(e){const t=this.groupData.get(e);return Array.isArray(t)?t.length:0}getLastHit(e){const t=this.groupData.get(e);return t?.length?t[t.length-1]:null}getTimeSinceLastHit(e){const t=this.getLastHit(e);return null!==t?Date.now()-t:null}_calculateAverageSpacing(e){if(!Array.isArray(e)||e.length<2)return null;let t=0;for(let r=1;r<e.length;r++)t+=e[r]-e[r-1];return t/(e.length-1)}getAverageHitSpacing(e){return this._calculateAverageSpacing(this.groupData.get(e))}getMetrics(e){const t=this.groupData.get(e);if(!Array.isArray(t)||0===t.length)return{totalHits:0,lastHit:null,timeSinceLastHit:null,averageHitSpacing:null};const r=t.length,n=t[r-1];return{totalHits:r,lastHit:n,timeSinceLastHit:Date.now()-n,averageHitSpacing:this._calculateAverageSpacing(t)}}destroy(){this.#h&&clearInterval(this.#h),this._cleanup(),this.groupData.clear(),this.lastSeen.clear(),this.userToGroup.clear(),this.groupTTL.clear(),this.groupFlags.clear()}};class G{static getTemplate(){return'\n<div class="notify-overlay hidden">\n <div class="notify-center" id="notifCenter">\n <div class="header">\n <div>Notifications</div>\n <div class="options">\n <button class="clear-all" type="button">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n viewBox="0 0 24 24"\n width="24"\n height="24"\n fill="currentColor"\n >\n <path\n d="M21.6 2.4a1 1 0 0 0-1.4 0L13 9.6l-1.3-1.3a1 1 0 0 0-1.4 0L3 15.6a1 1 0 0 0 0 1.4l4 4a1 1 0 0 0 1.4 0l7.3-7.3a1 1 0 0 0 0-1.4l-1.3-1.3 7.2-7.2a1 1 0 0 0 0-1.4zM6 17l3.5-3.5 1.5 1.5L7.5 18.5 6 17z"\n />\n </svg>\n </button>\n <button class="close">×</button>\n </div>\n </div>\n <div class="list"></div>\n </div>\n</div>\n\n<button class="notify-bell" aria-label="Open notifications">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="20"\n height="20"\n fill="currentColor"\n viewBox="0 0 24 24"\n >\n <path\n d="M12 2C10.3 2 9 3.3 9 5v1.1C6.7 7.2 5 9.4 5 12v5l-1 1v1h16v-1l-1-1v-5c0-2.6-1.7-4.8-4-5.9V5c0-1.7-1.3-3-3-3zm0 20c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2z"\n />\n </svg>\n <span class="badge" id="notifBadge">0</span>\n</button>\n '}static insertTemplate(e="afterbegin"){document.body.insertAdjacentHTML(e,G.getTemplate())}#w;#b;#v;#E;#T;#S=0;#x=99;#A=300;#I=!1;#C=new WeakMap;#M(e){if(this.#C.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout(()=>{this.markAsRead(e),e.remove()},this.#A)}#L(e){this.#S=Math.max(0,e),this.#v.setAttribute("data-value",String(this.#S)),this.#v.textContent=this.#S>this.#x?`${this.#x}+`:String(this.#S)}constructor(e={}){const{center:t=document.getElementById("notifCenter"),badge:r=document.getElementById("notifBadge"),button:n=document.querySelector(".notify-bell"),overlay:i=document.querySelector(".notify-overlay")}=e;if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${t}`);if(!(i instanceof HTMLElement))throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${i}`);if(!(r instanceof HTMLElement))throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${r}`);if(!(n instanceof HTMLElement))throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${n}`);const o=t?.querySelector(".clear-all"),s=t?.querySelector(".list")??null;if(!(s instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${s}`);this.#w=t,this.#b=s,this.#v=r,this.#E=n,this.#T=i,this.#E.addEventListener("click",()=>this.toggle()),this.#w.querySelector(".close")?.addEventListener("click",()=>this.close()),o&&o.addEventListener("click",()=>this.clear()),this.#T.addEventListener("click",e=>{e.target===this.#T&&this.close()})}setMarkAllAsReadOnClose(e){if("boolean"!=typeof e)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof e);this.#I=e}setRemoveDelay(e){if("number"!=typeof e)throw new Error('NotificationCenter: "ms" must be an number.');this.#A=e}getItemMode(e){const t=this.getItem(e);return t?this.#C.get(t):null}getItem(e){const t=this.#b.children.item(e);if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${t}`);return t}hasItem(e){return e>=0&&e<this.#b.children.length}markAsRead(e){const t=e instanceof HTMLElement?e:this.getItem(e);t.classList.contains("unread")&&(t.classList.remove("unread"),this.#L(this.#S-1))}add(e,t="text"){const r=document.createElement("div");r.className="item unread";let n=null,i=null,o=null,s=null;if("object"==typeof e&&null!==e?(n=e.title,i=e.message,o=e.avatar,s=e.onClick):i=e,o){const e=document.createElement("div");e.className="avatar",e.style.backgroundImage=`url("${o}")`,r.appendChild(e)}const a=document.createElement("div");if(a.className="content",n){const e=document.createElement("div");e.className="title",e.textContent=n,a.appendChild(e)}const l=document.createElement("div");l.className="message","html"===t?l.innerHTML=i:l.textContent=i,a.appendChild(l),"function"==typeof s&&(r.classList.add("clickable"),r.addEventListener("click",e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&s(e)}));const u=document.createElement("button");u.className="notify-close",u.setAttribute("type","button"),u.innerHTML="&times;",u.addEventListener("click",e=>{e.stopPropagation(),this.#M(r)}),r.append(a,u),this.#b.prepend(r),this.#C.set(r,t),this.#L(this.#S+1)}remove(e){const t=this.getItem(e);this.#M(t)}clear(){let e=!0;for(;e;){e=!1;const t=Array.from(this.#b.children);for(const r of t)r instanceof HTMLElement&&!r.classList.contains("removing")&&(this.#M(r),e=!0)}}open(){this.#T.classList.remove("hidden"),this.#w.classList.add("open")}close(){if(this.#T.classList.add("hidden"),this.#w.classList.remove("open"),this.#I){const e=this.#b.querySelectorAll(".item.unread");for(const t of e)t instanceof HTMLElement&&this.markAsRead(t)}}toggle(){this.#w.classList.contains("open")?this.close():this.open()}recount(){const e=this.#b.querySelectorAll(".item.unread").length;this.#L(e)}get count(){return this.#S}destroy(){this.#E?.removeEventListener("click",this.toggle),this.#w?.querySelector(".close")?.removeEventListener("click",this.close),this.#w?.querySelector(".clear-all")?.removeEventListener("click",this.clear),this.#T?.removeEventListener("click",this.close),this.clear(),this.#w?.remove(),this.#T?.remove(),this.#E?.remove(),this.#S=0,this.#C=new WeakMap}}const Y=G,Q=class{#D;#k;#N;#_;#j;#O;constructor(e="top",t="right",r=3e3,n=50,i=300,o=".notify-container"){this.#R(e),this.#B(t),this.#$(r,"baseDuration"),this.#$(n,"extraPerChar"),this.#$(i,"fadeOutDuration"),this.#D=e,this.#k=t,this.#N=r,this.#_=n,this.#j=i;const s=document.querySelector(`${o}.${e}.${t}`);s instanceof HTMLElement?this.#O=s:(this.#O=document.createElement("div"),this.#O.className=`notify-container ${e} ${t}`,document.body.appendChild(this.#O))}getContainer(){if(!(this.#O instanceof HTMLElement))throw new Error("Container is not a valid HTMLElement.");return this.#O}#R(e){if(!["top","bottom"].includes(e))throw new Error(`Invalid vertical direction "${e}". Expected "top" or "bottom".`)}#B(e){if(!["left","right","center"].includes(e))throw new Error(`Invalid horizontal position "${e}". Expected "left", "right" or "center".`)}#$(e,t){if("number"!=typeof e||e<0||!Number.isFinite(e))throw new Error(`Invalid value for "${t}": ${e}. Must be a non-negative finite number.`)}getY(){return this.#D}setY(e){this.#R(e);const t=this.getContainer();t.classList.remove(this.#D),t.classList.add(e),this.#D=e}getX(){return this.#k}setX(e){this.#B(e);const t=this.getContainer();t.classList.remove(this.#k),t.classList.add(e),this.#k=e}getBaseDuration(){return this.#N}setBaseDuration(e){this.#$(e,"baseDuration"),this.#N=e}getExtraPerChar(){return this.#_}setExtraPerChar(e){this.#$(e,"extraPerChar"),this.#_=e}getFadeOutDuration(){return this.#j}setFadeOutDuration(e){this.#$(e,"fadeOutDuration"),this.#j=e}show(e){let t="",r="",n=null,i=!1,o=null;const s=document.createElement("div");if(s.className="notify enter","string"==typeof e)t=e;else{if("object"!=typeof e||null===e||"string"!=typeof e.message)throw new Error("Invalid argument for show(): expected string or { message: string, title?: string, onClick?: function, html?: boolean, avatar?: string }");if(t=e.message,r="string"==typeof e.title?e.title:"",i=!0===e.html,o="string"==typeof e.avatar?e.avatar:null,void 0!==e.onClick){if("function"!=typeof e.onClick)throw new Error("onClick must be a function if defined");n=e.onClick,s.classList.add("clickable")}}const a=document.createElement("button");if(a.innerHTML="&times;",a.className="close",a.setAttribute("aria-label","Close"),a.addEventListener("mouseenter",()=>{a.style.color="var(--notify-close-color-hover)"}),a.addEventListener("mouseleave",()=>{a.style.color="var(--notify-close-color)"}),o){const e=document.createElement("img");e.src=o,e.alt="avatar",e.className="avatar",s.appendChild(e)}if(r){const e=document.createElement("strong");e.textContent=r,e.style.display="block",s.appendChild(e)}if(i){const e=document.createElement("div");e.innerHTML=t,s.appendChild(e)}else s.appendChild(document.createTextNode(t));s.appendChild(a),this.getContainer().appendChild(s);const l=this.#N+t.length*this.#_+this.#j;let u=!1;const c=()=>{u||(u=!0,s.classList.remove("enter","show"),s.classList.add("exit"),setTimeout(()=>s.remove(),this.#j))};"function"==typeof n&&s.addEventListener("click",e=>{e.target!==a&&n(e,c)}),a.addEventListener("click",e=>{e.stopPropagation(),c()}),setTimeout(()=>{s.classList.remove("enter"),s.classList.add("show")},1),setTimeout(()=>c(),l)}destroy(){this.#O instanceof HTMLElement&&(this.#O.querySelectorAll(".notify").forEach(e=>e.remove()),this.#O.parentNode&&this.#O.parentNode.removeChild(this.#O),this.#O=null)}};function Z(e,t){return new Promise((r,n)=>{const i=new FileReader;i.onload=()=>{try{r(i.result)}catch(e){n(e)}},i.onerror=()=>{n(i.error)},i[t](e)})}function X(e,t=!1){return new Promise((r,n)=>{"string"!=typeof t&&"boolean"!=typeof t&&n(new TypeError("The isDataUrl parameter must be a boolean or a string.")),Z(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const n=e.match(/^data:(.+);base64,(.*)$/);if(!n||!n[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,i,o]=n;if(!/^[\w/+]+=*$/.test(o))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:o);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${o}`)}).catch(n)})}function ee(e){return new Promise((t,r)=>Z(e,"readAsText").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const r=e.trim();if(0===r.length)throw new Error("File is empty or contains only whitespace.");const n=JSON.parse(r);if("object"!=typeof n||null===n)throw new Error("Parsed content is not a valid JSON object or array.");t(n)}).catch(r))}function te(e,t,r=2){const n=JSON.stringify(t,null,r),i=new Blob([n],{type:"application/json"}),o=URL.createObjectURL(i),s=document.createElement("a");s.href=o,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}async function re(e,{method:t="GET",body:r,timeout:n=0,retries:i=0,headers:o={},signal:s=null}={}){if("string"!=typeof e||!e.startsWith("../")&&!e.startsWith("./")&&!e.startsWith("/")&&!e.startsWith("https://")&&!e.startsWith("http://"))throw new Error("Invalid URL: must be a valid http or https address.");if("string"!=typeof t||!t.trim())throw new Error("Invalid method: must be a non-empty string.");if(!s){if("number"!=typeof n||!Number.isFinite(n)||Number.isNaN(n)||n<0)throw new Error("Invalid timeout: must be a positive number.");if("number"!=typeof i||!Number.isFinite(i)||Number.isNaN(i)||i<0)throw new Error("Invalid retries: must be a positive number.")}const a=s?1:i+1;let l=null;for(let u=0;u<a;u++){const a=s?null:new AbortController,c=s||(a?.signal??null),h=!s&&n&&a?setTimeout(()=>a.abort(),n):null;try{const n=await fetch(e,{method:t.toUpperCase(),headers:{Accept:"application/json",...o},body:void 0!==r?m(r)?JSON.stringify(r):r:void 0,signal:c});if(h&&clearTimeout(h),!n.ok)throw new Error(`HTTP error: ${n.status} ${n.statusText}`);return n}catch(e){if(l=e,s)break;u<i&&await new Promise(e=>setTimeout(e,300*(u+1)))}}throw new Error(`Failed to fetch JSON from "${e}"${l?`: ${l.message}`:"."}`)}async function ne(e,t){return new Promise((r,n)=>{re(e,t).then(async e=>{const t=e.headers.get("content-type")||"";if(!t.includes("application/json"))throw new Error(`Unexpected content-type: ${t}`);const n=await e.json();if(!Array.isArray(n)&&!m(n))throw new Error("Received invalid data instead of valid JSON.");return r(n)}).catch(n)})}async function ie(e,t,r){return new Promise((n,i)=>{re(e,r).then(async e=>{const r=e.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>r.includes(e)))throw new Error(`Blocked MIME type: ${r}`);const i=await e.text();return n(i)}).catch(i)})}function oe({element:e=document.body,hiddenClass:t="windowHidden",visibleClass:r="windowVisible",onVisible:n,onHidden:i}={}){if(!(e instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof t)throw new TypeError('"hiddenClass" must be a string.');if("string"!=typeof r)throw new TypeError('"visibleClass" must be a string.');if(void 0!==n&&"function"!=typeof n)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==i&&"function"!=typeof i)throw new TypeError('"onHidden" must be a function if provided.');let o="",s="";const a=()=>{e.classList.remove(t),e.classList.remove(r)};let l=null;const u=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],c=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<c.length;e++)if(c[e]in document){l=c[e];break}const h=function(u){a();const c=u?.type,h=l&&document[l];["focus","focusin","pageshow"].includes(c)?(e.classList.add(r),n?.({type:c,oldClass:s,oldType:o}),s=r):["blur","focusout","pagehide"].includes(c)||h?(e.classList.add(t),i?.({type:c,oldClass:s,oldType:o}),s=t):(e.classList.add(r),n?.({type:c,oldClass:s,oldType:o}),s=r),o=c};let d=()=>{};if(l){const e=u[c.indexOf(l)];document.addEventListener(e,h),window.addEventListener("focus",h),window.addEventListener("blur",h),d=()=>{document.removeEventListener(e,h),window.removeEventListener("focus",h),window.removeEventListener("blur",h),a()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=h,d=()=>{document.onfocusin=document.onfocusout=null,a()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=h,d=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,a()});const f=new Event(l&&document[l]?"blur":"focus");return h(f),d}const se=class{#P;#H;#F;#W;#z;#q;#V;#K;constructor(e={}){const{target:t,fullscreen:r=!0,hoverClass:n="dnd-hover",onDrop:i,onEnter:o,onLeave:s}=e;if("boolean"!=typeof r)throw new TypeError('The "fullscreen" option must be a boolean.');const a=r?document.body:t||document.body;if(!(a instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof n)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof i)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof o)throw new TypeError('The "onEnter" option must be a function.');if("function"!=typeof s)throw new TypeError('The "onLeave" option must be a function.');this.#P=a,this.#H=r,this.#F=n,this.#W=i||(()=>{}),this.#z=o,this.#q=s,this.#V=!1,this.#K=!1,this._handleDragEnter=this._handleDragEnter.bind(this),this._handleDragOver=this._handleDragOver.bind(this),this._handleDragLeave=this._handleDragLeave.bind(this),this._handleDrop=this._handleDrop.bind(this),this.#J()}getTarget(){return this.#P}getHoverClass(){return this.#F}isFullScreen(){return this.#H}isDragging(){return this.#V}bound(){return this.#K}#J(){if(this.#K)return;const e=this.getTarget();e.addEventListener("dragenter",this._handleDragEnter),e.addEventListener("dragover",this._handleDragOver),e.addEventListener("dragleave",this._handleDragLeave),e.addEventListener("drop",this._handleDrop),this.#K=!0}#U(){if(!this.#K)return;const e=this.getTarget();e.removeEventListener("dragenter",this._handleDragEnter),e.removeEventListener("dragover",this._handleDragOver),e.removeEventListener("dragleave",this._handleDragLeave),e.removeEventListener("drop",this._handleDrop),this.#K=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#V){const t=this.getTarget();this.#V=!0,t.classList.add(this.#F),this.#z(e)}}_handleDragOver(e){e.preventDefault(),e.dataTransfer?e.dataTransfer.dropEffect="copy":console.warn("[TinyDragDropDetector] [handleDragOver] DragOver event missing dataTransfer.")}_handleDragLeave(e){e.preventDefault();const t=this.getTarget();null!==e.relatedTarget&&t.contains(e.relatedTarget)||(this.#V=!1,t.classList.remove(this.#F),this.#q(e))}_handleDrop(e){if(e.preventDefault(),!e.dataTransfer)return void console.warn("[TinyDragDropDetector] [handleDrop] DragOver event missing dataTransfer.");const t=this.getTarget();this.#V=!1,t.classList.remove(this.#F);const r=e.dataTransfer.files;r.length>0&&this.#W(r,e)}destroy(){this.#U(),this.getTarget().classList.remove(this.#F)}};var ae=r(133),le=r(975);function ue(e){if(!(0,ae.existsSync)(e))throw new Error(`File not found: ${e}`);const t=(0,ae.readFileSync)(e,"utf-8");return JSON.parse(t)}function ce(e,t,r=2){const n=JSON.stringify(t,null,r);(0,ae.writeFileSync)(e,n,"utf-8")}function he(e){(0,ae.existsSync)(e)||(0,ae.mkdirSync)(e,{recursive:!0})}function de(e){if(!(0,ae.existsSync)(e))return;const t=(0,ae.readdirSync)(e);for(const r of t){const t=(0,le.join)(e,r);(0,ae.lstatSync)(t).isDirectory()?(0,ae.rmSync)(t,{recursive:!0,force:!0}):(0,ae.unlinkSync)(t)}}function fe(e){return(0,ae.existsSync)(e)&&(0,ae.lstatSync)(e).isFile()}function pe(e){return(0,ae.existsSync)(e)&&(0,ae.lstatSync)(e).isDirectory()}function me(e){return 0===(0,ae.readdirSync)(e).length}function ge(e,t,r){he((0,le.dirname)(t)),(0,ae.copyFileSync)(e,t,r)}function ye(e){return!!fe(e)&&((0,ae.unlinkSync)(e),!0)}function we(e,t,r="utf-8"){he((0,le.dirname)(e)),(0,ae.writeFileSync)(e,t,r)}function be(e,t=!1){const r={files:[],dirs:[]};if(!pe(e))return r;const n=(0,ae.readdirSync)(e);for(const i of n){const n=(0,le.join)(e,i);if((0,ae.lstatSync)(n).isDirectory()){if(r.dirs.push(n),t){const e=be(n,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(n)}return r}function ve(e,t=!1){const r=[];if(!pe(e))return r;const n=(0,ae.readdirSync)(e);for(const i of n){const n=(0,le.join)(e,i);(0,ae.lstatSync)(n).isDirectory()&&(r.push(n),t&&r.push(...ve(n,!0)))}return r}function Ee(e){return fe(e)?(0,ae.statSync)(e).size:0}function Te(e){let t=0;const r=be(e,!0).files;for(const e of r)t+=Ee(e);return t}function Se(e,t="bak"){fe(e)&&ge(e,`${e}.${t}.${(new Date).toISOString().replace(/[:.]/g,"-")}`)}function xe(e,t="bak"){const r=(0,le.dirname)(e),n=(0,le.basename)(e),i=(0,ae.readdirSync)(r).filter(e=>e.startsWith(`${n}.${t}.`)).sort().reverse();if(0===i.length)throw new Error(`No backups found for ${e}`);return(0,le.join)(r,i[0])}function Ae(e,t="bak"){ge(xe(e,t),e)}function Ie(e,t,r=[]){if("string"!=typeof e)throw new TypeError("dirPath must be a string");if("function"!=typeof t)throw new TypeError("renameFn must be a function");if(!Array.isArray(r))throw new TypeError("extensions must be an array of strings");if(!(0,ae.existsSync)(e)||!(0,ae.statSync)(e).isDirectory())throw new Error(`Directory not found or invalid: ${e}`);for(const e of r)if("string"!=typeof e||!e.startsWith("."))throw new TypeError(`Invalid extension: ${e}`);const n=be(e).files;let i=0;for(const o of n){const n=(0,le.extname)(o);if(r.length&&!r.includes(n))continue;const s=(0,le.basename)(o),a=t(s,i++),l=(0,le.join)(e,a);s!==a&&(0,ae.renameSync)(o,l)}}function Ce(e,t,r,n=[]){Ie(e,e=>{const n=(0,le.extname)(e);return`${(0,le.basename)(e,n).replace(t,r)}${n}`},n)}function Me(e,{prefix:t="",suffix:r=""},n=[]){Ie(e,e=>{const n=(0,le.extname)(e),i=(0,le.basename)(e,n);return`${t}${i}${r}${n}`},n)}function Le(e,t="lower",r=[],n=!1){if("string"!=typeof t||!["lower","upper","title"].includes(t))throw new Error(`Invalid mode "${t}". Must be 'lower', 'upper' or 'title'.`);Ie(e,e=>{const r=e=>"lower"===t?e.toLowerCase():"upper"===t?e.toUpperCase():"title"===t?H(e):e,i=(0,le.extname)(e),o=n?r(i):i;return`${r((0,le.basename)(e,i))}${o}`},r)}function De(e,t=3,r=[]){Ie(e,e=>e.replace(/\d+/,e=>e.padStart(t,"0")),r)}var ke=r(370);async function Ne(e){if(!(0,ae.existsSync)(e))return;const t=await(0,ke.readdir)(e),r={},n=[];for(const i of t){const t=(0,le.join)(e,i),o=(0,ke.lstat)(t);o.then(e=>(r[t]=e,e)),n.push(o)}await Promise.all(n);const i=[];for(const e in r)r[e].isDirectory()?i.push((0,ke.rm)(e,{recursive:!0,force:!0})):i.push((0,ke.unlink)(e));await Promise.all(i)}async function _e(e){return 0===(await(0,ke.readdir)(e)).length}async function je(e,t=!1){const r={files:[],dirs:[]};if(!pe(e))return r;const n=await(0,ke.readdir)(e);for(const i of n){const n=(0,le.join)(e,i);if((await(0,ke.lstat)(n)).isDirectory()){if(r.dirs.push(n),t){const e=await je(n,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(n)}return r}async function Oe(e,t=!1){const r=[];if(!pe(e))return r;const n=await(0,ke.readdir)(e);for(const i of n){const n=(0,le.join)(e,i);(await(0,ke.lstat)(n)).isDirectory()&&(r.push(n),t&&r.push(...await Oe(n,!0)))}return r}async function Re(e){return fe(e)?(await(0,ke.stat)(e)).size:0}async function Be(e){let t=0;const{files:r}=await je(e,!0),n=[];for(const e of r){const r=Re(e);r.then(e=>(t+=e,e)),n.push(r)}return await Promise.all(n),t}const $e=(e,t)=>e.bottom<t.top,Pe=(e,t)=>e.top>t.bottom,He=(e,t)=>e.right<t.left,Fe=(e,t)=>e.left>t.right,We=(e,t)=>e.bottom<=t.top,ze=(e,t)=>e.top>=t.bottom,qe=(e,t)=>e.right<=t.left,Ve=(e,t)=>e.left>=t.right,Ke=(e,t)=>!(He(e,t)||Fe(e,t)||$e(e,t)||Pe(e,t)),Je=(e,t)=>!(qe(e,t)||Ve(e,t)||We(e,t)||ze(e,t)),Ue=(e,t)=>He(e,t)?"left":Fe(e,t)?"right":$e(e,t)?"top":Pe(e,t)?"bottom":null,Ge=(e,t)=>qe(e,t)?"left":Ve(e,t)?"right":We(e,t)?"top":ze(e,t)?"bottom":null,Ye=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),Qe=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:e<t?"right":"left",dirY:r<n?"bottom":"top"}),Ze=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function Xe(e,t){const r=e.left+e.width/2,n=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-n}}function et(e,t){if(!Je(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:i,overlapBottom:o}=Ye(e,t),{dirX:s,dirY:a}=Qe({overlapLeft:r,overlapRight:n,overlapTop:i,overlapBottom:o}),l=Math.min(r,n),u=Math.min(i,o);let c;return c=l<u?s:a,{inDir:c,dirX:s,dirY:a,depthX:l,depthY:u}}function tt(e,t){const r=Je(e,t),n={in:null,x:null,y:null},i={y:null,x:null},o={top:0,bottom:0,left:0,right:0},{overlapLeft:s,overlapRight:a,overlapTop:l,overlapBottom:u}=Ye(t,e);o.top=l,o.bottom=u,o.left=s,o.right=a;const c=Object.entries(o).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:h,dirY:d}=Qe({overlapLeft:a,overlapRight:s,overlapTop:u,overlapBottom:l});return n.y=d,n.x=h,o.bottom<0?i.y="bottom":o.top<0&&(i.y="top"),o.left<0?i.x="left":o.right<0&&(i.x="right"),n.in=r?o.top===o.bottom&&o.bottom===o.left&&o.left===o.right?"center":c.length?c[0][0]:"top":null,{dirs:n,depth:o,isNeg:i}}const rt=class{#G;get el(){return this.#G}set el(e){if(this.#G)throw new Error("The observed element has already been set and cannot be reassigned.");if(void 0!==e&&!(e instanceof Element))throw new TypeError("The observed element must be a valid DOM Element.");this.#G=e}#Y={};get settings(){return this.#Y}set settings(e){if("object"!=typeof e||null===e)throw new TypeError("settings must be a non-null object.");this.#Y=e}#Q=null;get observer(){return this.#Q}#Z=[];get detectors(){return this.#Z.map(e=>[e[0],e[1]])}set detectors(e){if(!Array.isArray(e))throw new TypeError("detectors must be an array.");const t=[];for(const[r,n]of e){if("string"!=typeof r)throw new TypeError("Detector name must be a string.");if("function"!=typeof n)throw new TypeError(`Detector handler for "${r}" must be a function.`);t.push([r,n])}this.#Z=t}get isActive(){return!!this.#Q}get size(){return this.#Z.length}constructor({el:e,initDetectors:t=[],initCfg:r={}}={}){this.el=e,t.length&&(this.detectors=t),r&&(this.settings=r)}clear(){this.#Z=[]}start(){if(!this.#G)throw new Error("Cannot start observation: no target element has been set.");this.#Q||(this.#Q=new MutationObserver(e=>{e.forEach((e,t,r)=>this.#Z.forEach(n=>n[1](e,t,r)))}),this.#Q.observe(this.#G,this.#Y))}stop(){this.#Q&&(this.#Q.disconnect(),this.#Q=null)}add(e,t){this.#X(e,t),this.#Z.push([e,t])}insertAtStart(e,t){this.#X(e,t),this.#Z.unshift([e,t])}insertAt(e,t,r,n="after"){if(this.#X(t,r),"number"!=typeof e||e<0||e>=this.#Z.length)throw new RangeError("Invalid index for insertDetectorAt.");const i="before"===n?e:e+1;this.#Z.splice(i,0,[t,r])}removeAt(e){if("number"!=typeof e||e<0||e>=this.#Z.length)throw new RangeError("Invalid index for removeDetectorAt.");this.#Z.splice(e,1)}removeAround(e,t=0,r=0){if("number"!=typeof e||e<0||e>=this.#Z.length)throw new RangeError("Invalid index for removeDetectorsAround.");const n=Math.max(0,e-t),i=t+1+r;this.#Z.splice(n,i)}isIndexUsed(e){return e>=0&&e<this.#Z.length}hasHandler(e){if("function"!=typeof e)throw new TypeError("Handler must be a function.");return this.#Z.some(([t,r])=>r===e)}#X(e,t){if("string"!=typeof e||!e.trim())throw new TypeError("Detector name must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Detector handler for "${e}" must be a function.`)}destroy(){this.stop(),this.clear()}},{areElsColliding:nt,areElsPerfColliding:it,areElsCollTop:ot,areElsCollBottom:st,areElsCollLeft:at,areElsCollRight:lt}=e,ut=new WeakMap,ct=new WeakMap,ht=new WeakMap,dt=new WeakMap,ft={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class pt{static Utils={...e};static#ee=!1;static get elemDebug(){return pt.#ee}static set elemDebug(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value for elemDebug");pt.#ee=e}static _debugElemError(e,t){if(!pt.#ee)return;const r="[TinyHtml Debug] Element validation error";if(console.groupCollapsed(`${r}${t?" — details below":""}`),console.error(r),"undefined"!=typeof Error&&"function"==typeof Error.captureStackTrace){const e=new Error(r);Error.captureStackTrace(e,pt._debugElemError),console.error(e.stack)}else console.trace(r);if(Array.isArray(e)){const t=e.map((e,t)=>({index:t,typeOf:null===e?"null":typeof e,constructor:e?.constructor?.name??(null===e?"null":"primitive"),summary:"undefined"!=typeof Element&&e instanceof Element?`${e.tagName?.toLowerCase?.()??"element"}#${e.id||""}.${String(e.className||"").trim().replace(/\s+/g,".")}`:e&&"object"==typeof e&&"nodeType"in e?`nodeType:${e.nodeType}`:"",value:e}));console.table(t)}else console.warn('[TinyHtml Debug] "elems" is not an array:',e);arguments.length>1&&(console.error("[TinyHtml Debug] Problematic element:",t),t&&"object"==typeof t&&console.dir(t)),console.groupEnd()}static parseStyle(e){const t={};return e.split(";").forEach(e=>{const[r,n]=e.split(":").map(e=>e&&e.trim());r&&n&&(t[r]=n)}),t}static#te=!0;static get autoStartElemObserver(){return pt.#te}static set autoStartElemObserver(e){if("boolean"!=typeof e)throw new TypeError("autoStartElemObserver must be a boolean.");pt.#te=e}static#re=new rt({el:"undefined"!=typeof window&&void 0!==window.document?window.document.documentElement:void 0,initDetectors:[["tinyStyleEvent",e=>{if("attributes"!==e.type||"style"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.getAttribute("style")||"",n=q(pt.parseStyle(t),pt.parseStyle(r));(Object.keys(n.added).length||Object.keys(n.removed).length||Object.keys(n.modified).length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.stylechanged",{detail:n}))}],["tinyClassEvent",e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.className||"",n=a(t.split(/\s+/).filter(Boolean),r.split(/\s+/).filter(Boolean));(n.added.length||n.removed.length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.classchanged",{detail:n}))}]],initCfg:{attributeOldValue:!0,attributes:!0,subtree:!0,attributeFilter:["style","class"]}});static get tinyObserver(){return pt.#re}static async fetchHtmlFile(e,t={method:"GET"}){const r=await fetch(e,t),n=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!n.includes("text/html"))throw new Error(`Invalid content type: ${n} (expected text/html)`);const i=await r.text();return pt.htmlToJson(i)}static async fetchHtmlNodes(e,t){const r=await pt.fetchHtmlFile(e,t);return pt.jsonToNodes(r)}static async fetchHtmlTinyElems(e,t){const r=await pt.fetchHtmlNodes(e,t);return pt.toTinyElm(r)}static templateToJson(e){return pt.htmlToJson([...e.content.childNodes].map(e=>e instanceof Element?e.getHTML():e instanceof Text?e.textContent:"").join(""))}static templateToNodes(e){const t=[];return[...e.content.cloneNode(!0).childNodes].map(e=>{if(!(e instanceof Element||e instanceof Text||e instanceof Comment))throw new Error(`Expected only Element nodes in <template>, but found: ${e.constructor.name}`);e instanceof Comment||t.push(e)}),t}static templateToTinyElems(e){return pt.toTinyElm(pt.templateToNodes(e))}static htmlToJson(e){const t=document.createElement("div");t.innerHTML=e.trim();const r=[],n=e=>{if(e instanceof Comment)return null;if(e instanceof Text){const t=e.textContent?.trim();return t||null}if(!(e instanceof Element))return null;const t=e.tagName.toLowerCase(),r={};for(const t of e.attributes)r[pt.getPropName(t.name)]=t.value;const i=Array.from(e.childNodes).map(n).filter(Boolean);return i.length>0?[t,r,...i]:[t,r]};for(const e of t.childNodes){const t=n(e);t&&r.push(t)}return t.innerHTML="",r}static jsonToNodes(e){const t=e=>{if("string"==typeof e)return document.createTextNode(e);if(!Array.isArray(e))return document.createTextNode("");const[r,n,...i]=e,o=document.createElement(r);for(const[e,t]of Object.entries(n))o.setAttribute(pt.getAttrName(e),t);for(const e of i){const r=t(e);r instanceof Comment||o.appendChild(r)}return o};return e.map(t).filter(e=>!(e instanceof Comment))}static jsonToTinyElems(e){return pt.toTinyElm(pt.jsonToNodes(e))}static createFrom(e,t){if("string"!=typeof e)throw new TypeError('The "tagName" must be a string.');if(void 0!==t&&"object"!=typeof t)throw new TypeError('The "attrs" must be a object.');const r=pt.createElement(e);if("object"==typeof t)for(const e in t)r.setAttr(e,t[e]);return r}static createElement(e,t){if("string"!=typeof e)throw new TypeError("[TinyHtml] createElement(): The tagName must be a string.");if(void 0!==t&&"object"!=typeof t)throw new TypeError("[TinyHtml] createElement(): The ops must be a object.");return new pt(document.createElement(e,t))}static createTextNode(e){if("string"!=typeof e)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new pt(document.createTextNode(e))}static createElementFromHTML(e){const t=document.createElement("template");if(!(e=e.trim()).startsWith("<"))return pt.createTextNode(e);if(t.innerHTML=e,!(t.content.firstChild instanceof Element))throw new Error("The HTML string must contain a valid HTML element.");return new pt(t.content.firstChild)}static createFromHTML(e){const t=document.createElement("template");e=e.trim(),t.innerHTML=e;const r=Array.from(t.content.childNodes);if(!r.every(e=>e instanceof Element||e instanceof Text))throw new Error("The HTML string must contain a valid HTML element.");return new pt(r)}static createFromHtml(e){return pt.createFromHTML(e)}static query(e,t=document){const r=t.querySelector(e);return r?new pt(r):null}querySelector(e){return pt.query(e,pt._preElem(this,"query"))}static queryAll(e,t=document){return new pt(t.querySelectorAll(e))}querySelectorAll(e){return pt.queryAll(e,pt._preElem(this,"queryAll"))}static getById(e){const t=document.getElementById(e);return t?new pt(t):null}static getByClassName(e,t=document){return new pt(t.getElementsByClassName(e))}getElementsByClassName(e){return pt.getByClassName(e,pt._preElem(this,"getByClassName"))}static getByName(e){return new pt(document.getElementsByName(e))}static getByTagNameNS(e,t="http://www.w3.org/1999/xhtml",r=document){return new pt(r.getElementsByTagNameNS(t,e))}getElementsByTagNameNS(e,t="http://www.w3.org/1999/xhtml"){return pt.getByTagNameNS(e,t,pt._preElem(this,"getByTagNameNS"))}get elements(){return[...this.#G]}forEach(e){const t=this.elements.map((e,t)=>this.extract(t));for(const r in t)e(t[r],Number(r),t);return this}get(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#G[e])throw new Error(`No element found at index ${e}.`);return this.#G[e]}extract(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#G[e])throw new Error(`Cannot extract: no element exists at index ${e}.`);return new pt(this.#G[e])}exists(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");return!!this.#G[e]}getAll(){return[...this.#G]}_getElement(e,t){if(!(this.#G[t]instanceof Element||this.#G[t]instanceof Window||this.#G[t]instanceof Document||this.#G[t]instanceof Text))throw pt._debugElemError([...this.#G],this.#G[t]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return this.#G[t]}_getElements(e){if(!this.#G.every(e=>e instanceof Element||e instanceof Window||e instanceof Document||e instanceof Text))throw pt._debugElemError([...this.#G]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return[...this.#G]}static _preElemsTemplate(e,t,r,n){const i=e=>{const i=[];return e.map(o=>(o instanceof pt?o._getElements(t):[o]).map(o=>{let s=!1;for(const e of r)if(o instanceof e){s=!0;break}if(!s)throw pt._debugElemError([...e],o),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${t}().`);return i.push(o),o})),i};return Array.isArray(e)?i(e):i([e])}static _preElemTemplate(e,t,r,n,i=!1){const o=e=>{const o=e[0],s=o instanceof pt?o._getElements(t):[o];if(s.length>1)throw pt._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${s.length}/1).`);let a=!1;for(const e of r)if(s[0]instanceof e){a=!0;break}if(!i||null!==s[0]&&void 0!==s[0]||(s[0]=null,a=!0),!a)throw pt._debugElemError([...e],s[0]),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${t}().`);return s[0]};if(!Array.isArray(e))return o([e]);if(e.length>1)throw pt._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${e.length}/1).`);return o(e)}static _preElems(e,t){return pt._preElemsTemplate(e,t,[Element],["Element"])}static _preElem(e,t){return pt._preElemTemplate(e,t,[Element],["Element"])}static _preNodeElems(e,t){return pt._preElemsTemplate(e,t,[Node],["Node"])}static _preNodeElem(e,t){return pt._preElemTemplate(e,t,[Node],["Node"])}static _preNodeElemWithNull(e,t){return pt._preElemTemplate(e,t,[Node],["Node"],!0)}static _preHtmlElems(e,t){return pt._preElemsTemplate(e,t,[HTMLElement],["HTMLElement"])}static _preHtmlElem(e,t){return pt._preElemTemplate(e,t,[HTMLElement],["HTMLElement"])}static _preInputElems(e,t){return pt._preElemsTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}static _preInputElem(e,t){return pt._preElemTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}static _preEventTargetElems(e,t){return pt._preElemsTemplate(e,t,[EventTarget],["EventTarget"])}static _preEventTargetElem(e,t){return pt._preElemTemplate(e,t,[EventTarget],["EventTarget"])}static _preElemsAndWindow(e,t){return pt._preElemsTemplate(e,t,[Element,Window],["Element","Window"])}static _preElemAndWindow(e,t){return pt._preElemTemplate(e,t,[Element,Window],["Element","Window"])}static _preElemsAndWinAndDoc(e,t){return pt._preElemsTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]).map(e=>e instanceof Document?e.documentElement:e)}static _preElemAndWinAndDoc(e,t){const r=pt._preElemTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}static _preElemsWithDoc(e,t){return pt._preElemsTemplate(e,t,[Element,Document],["Element","Document"])}static _preElemWithDoc(e,t){return pt._preElemTemplate(e,t,[Element,Document],["Element","Document"])}static toTinyElm(e){const t=e=>e.map(e=>e instanceof pt?e:new pt(e));return Array.isArray(e)?t(e):t([e])}static fromTinyElm(e){const t=e=>{const t=[];return e.map(e=>(e instanceof pt?e._getElements("fromTinyElm"):[e]).map(e=>t.push(e))),t};return Array.isArray(e)?t(e):t([e])}static winnow(e,t,r,n=!1){if("boolean"!=typeof n)throw new TypeError('The "not" must be a boolean.');if("function"==typeof t)return pt._preElems(e,r).filter((e,r)=>!!t.call(e,r,e)!==n);if(t instanceof Element)return pt._preElems(e,r).filter(e=>e===t!==n);if(Array.isArray(t)||"string"!=typeof t&&null!=t.length)return pt._preElems(e,r).filter(e=>t.includes(e)!==n);let i=t;return n&&(i=`:not(${i})`),pt._preElems(e,r).filter(e=>1===e.nodeType&&e.matches(i))}static filter(e,t,r=!1){return r&&(t=`:not(${t})`),pt._preElems(e,"filter").filter(e=>1===e.nodeType&&e.matches(t))}static filterOnly(e,t){return pt.winnow(e,t,"filterOnly",!1)}static not(e,t){return pt.winnow(e,t,"not",!0)}not(e){return pt.not(this,e)}static find(e,t){const r=[];for(const n of pt._preElems(e,"find"))r.push(...n.querySelectorAll(t));return[...new Set(r)]}find(e){return pt.find(this,e)}static is(e,t){return pt.winnow(e,t,"is",!1).length>0}is(e){return pt.is(this,e)}static has(e,t){const r="string"==typeof t?[...document.querySelectorAll(t)]:pt._preElems(t,"has");return pt._preElems(e,"has").filter(e=>r.some(t=>e&&e.contains(t)))}has(e){return pt.has(this,e)}static closest(e,t,r){const n=[];for(const i of pt._preElems(e,"closest")){let e=i;for(;e&&e!==r;){if(1===e.nodeType&&("string"==typeof t?e.matches(t):e===t)){n.push(e);break}e=e.parentElement}}return[...new Set(n)]}closest(e,t){return pt.closest(this,e,t)}static isSameDom(e,t){return pt._preNodeElem(e,"isSameDom")===pt._preNodeElem(t,"isSameDom")}isSameDom(e){return pt.isSameDom(this,e)}#ne={};get _data(){return{...this.#ne}}set _data(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("value must be a non-null object.");this.#ne=e}static _dataSelector={public:(e,t)=>{const r=pt._preElem(t,e);let n=ct.get(r);return n||(n={},ct.set(r,n)),n},private:(e,t)=>{if(!(t instanceof pt))throw new Error(`Element must be a TinyHtml instance to execute ${e}().`);return t.#ne}};static data(e,t,r=!1){const n=pt._dataSelector[r?"private":"public"]("data",e);if(null==t)return{...n};if("string"!=typeof t)throw new TypeError("The key must be a string.");return n.hasOwnProperty(t)?n[t]:void 0}data(e,t){return pt.data(this,e,t)}static setData(e,t,r,n=!1){const i=pt._dataSelector[n?"private":"public"]("setData",e);if("string"!=typeof t)throw new TypeError("The key must be a string.");return void 0!==r?i[t]=r:pt.removeData(e,t),e}setData(e,t,r=!1){return pt.setData(this,e,t,r)}static hasData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");const n=pt._dataSelector[r?"private":"public"]("hasData",e);return Object.prototype.hasOwnProperty.call(n,t)}hasData(e,t=!1){return pt.hasData(this,e,t)}static removeData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");return delete pt._dataSelector[r?"private":"public"]("removeData",e)[t]}removeData(e,t=!1){return pt.removeData(this,e,t)}static _getSibling(e,t,r){let n=pt._preNodeElemWithNull(e,r);for(;n&&(n=n[t])&&1!==n.nodeType;);return n instanceof Node?n:null}static _getSiblings(e,t){let r=e;const n=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==t&&n.push(r);return n}static domDir(e,t,r,n="domDir"){if("string"!=typeof t)throw new TypeError('The "direction" must be a string.');let i=pt._preNodeElemWithNull(e,n);const o=[];for(;i&&(i=i[t]);)if(1===i.nodeType){if(r&&("string"==typeof r?i.matches(r):i===r))break;o.push(i)}return o}static parent(e){let t=pt._preNodeElemWithNull(e,"parent");const r=t?t.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return pt.parent(this)}static parents(e,t){return pt.domDir(e,"parentNode",t,"parents")}parents(e){return pt.parents(this,e)}static next(e){return pt._getSibling(e,"nextSibling","next")}next(){return pt.next(this)}static prev(e){return pt._getSibling(e,"previousSibling","prev")}prev(){return pt.prev(this)}static nextAll(e){return pt.domDir(e,"nextSibling",void 0,"nextAll")}nextAll(){return pt.nextAll(this)}static prevAll(e){return pt.domDir(e,"previousSibling",void 0,"prevAll")}prevAll(){return pt.prevAll(this)}static nextUntil(e,t){return pt.domDir(e,"nextSibling",t,"nextUtil")}nextUntil(e){return pt.nextUntil(this,e)}static prevUntil(e,t){return pt.domDir(e,"previousSibling",t,"prevUtil")}prevUntil(e){return pt.prevUntil(this,e)}static siblings(e){const t=pt._preNodeElemWithNull(e,"siblings");return pt._getSiblings(t&&t.parentNode?t.parentNode.firstChild:null,t)}siblings(){return pt.siblings(this)}static children(e){const t=pt._preNodeElemWithNull(e,"children");return pt._getSiblings(t?t.firstChild:null)}children(){return pt.children(this)}static contents(e){const t=pt._preNodeElemWithNull(e,"contents");return t instanceof HTMLIFrameElement&&null!=t.contentDocument&&Object.getPrototypeOf(t.contentDocument)?[t.contentDocument]:t instanceof HTMLTemplateElement?Array.from((t.content||t).childNodes):t?Array.from(t.childNodes):[]}contents(){return pt.contents(this)}static clone(e,t=!0){if("boolean"!=typeof t)throw new TypeError('The "deep" must be a boolean.');return pt._preNodeElems(e,"clone").map(e=>e.cloneNode(t))}clone(e){return pt.clone(this,e)[0]}static _appendChecker(e,...t){const r=[];for(const n of t)if(null!=n&&!1!==n)if("string"!=typeof n&&"number"!=typeof n)if(n instanceof Node||n instanceof pt)r.push(...pt._preNodeElems(n,e));else if(Array.isArray(n))r.push(...pt._appendChecker(e,...n));else for(const t in n){const i=n[t];r.push(...pt._appendChecker(e,i))}else r.push(n);return r}static append(e,...t){return pt._preElem(e,"append").append(...pt._appendChecker("append",...t)),e}append(...e){return pt.append(this,...e)}static prepend(e,...t){return pt._preElem(e,"prepend").prepend(...pt._appendChecker("prepend",...t)),e}prepend(...e){return pt.prepend(this,...e)}static before(e,...t){return pt._preElem(e,"before").before(...pt._appendChecker("before",...t)),e}before(...e){return pt.before(this,...e)}static after(e,...t){return pt._preElem(e,"after").after(...pt._appendChecker("after",...t)),e}after(...e){return pt.after(this,...e)}static replaceWith(e,...t){return pt._preElem(e,"replaceWith").replaceWith(...pt._appendChecker("replaceWith",...t)),e}replaceWith(...e){return pt.replaceWith(this,...e)}static appendTo(e,t){const r=pt._preNodeElems(e,"appendTo"),n=pt._preNodeElems(t,"appendTo");return n.forEach((e,t)=>{r.forEach(r=>e.appendChild(t===n.length-1?r:r.cloneNode(!0)))}),e}appendTo(e){return pt.appendTo(this,e)}static prependTo(e,t){const r=pt._preElems(e,"prependTo"),n=pt._preElems(t,"prependTo");return n.forEach((e,t)=>{r.slice().reverse().forEach(r=>e.prepend(t===n.length-1?r:r.cloneNode(!0)))}),e}prependTo(e){return pt.prependTo(this,e)}static insertBefore(e,t,r=null){const n=pt._preNodeElem(e,"insertBefore"),i=pt._preNodeElem(t,"insertBefore"),o=pt._preNodeElemWithNull(r,"insertBefore");if(!i.parentNode)throw new Error("The target element has no parent node to insert before.");return i.parentNode.insertBefore(n,o||i),e}insertBefore(e,t){return pt.insertBefore(this,e,t)}static insertAfter(e,t,r=null){const n=pt._preNodeElem(e,"insertAfter"),i=pt._preNodeElem(t,"insertBefore"),o=pt._preNodeElemWithNull(r,"insertBefore");if(!i.parentNode)throw new Error("The target element has no parent node to insert after.");return i.parentNode.insertBefore(n,o||i.nextSibling),e}insertAfter(e,t){return pt.insertAfter(this,e,t)}static replaceAll(e,t){const r=pt._preNodeElems(e,"replaceAll"),n=pt._preNodeElems(t,"replaceAll");return n.forEach((e,t)=>{const i=e.parentNode;r.forEach(r=>{i&&i.replaceChild(t===n.length-1?r:r.cloneNode(!0),e)})}),e}replaceAll(e){return pt.replaceAll(this,e)}#G;get size(){return this.#G.length}static _elCheck(e){for(const t of e)if(!(t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw new Error("[TinyHtml] Invalid Target in constructor.")}add(e){return new pt([...this.#G,...pt._selector(e)])}static _selector(e){if(e instanceof pt)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const t=e=>Array.from(new Set(e)),r="string"!=typeof e?e:document.querySelectorAll(e);if(Array.isArray(r))return pt._elCheck(r),t(r);if(r instanceof NodeList||r instanceof HTMLCollection){const e=[...r];return pt._elCheck(e),t(e)}{const e=[r];return pt._elCheck(e),t(e)}}constructor(e){this.#G=pt._selector(e),this.#ie=pt.#oe}static isWindow(e){return null!=e&&e===e.window}static css(e){const t=pt._preElem(e,"css");return window.getComputedStyle(t)}css(){return pt.css(this)}static cssString(e,t){const r=pt._preElem(e,"cssString");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[t];return"string"==typeof n?n:"number"==typeof n?n.toString():null}cssString(e){return pt.cssString(this,e)}static cssList(e,t){const r=pt._preElem(e,"cssList");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),i={};for(const e of t)void 0!==e&&(i[e]=n.getPropertyValue(e));return i}cssList(e){return pt.cssList(this,e)}static cssFloat(e,t){const r=pt._preElem(e,"cssFloat");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[t];return parseFloat(n)||0}cssFloat(e){return pt.cssFloat(this,e)}static cssFloats(e,t){const r=pt._preElem(e,"cssFloats");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),i={};for(const e of t)i[e]=parseFloat(n[e])||0;return i}cssFloats(e){return pt.cssFloats(this,e)}static#se={alignContent:"align-content",alignItems:"align-items",alignSelf:"align-self",animationDelay:"animation-delay",animationDirection:"animation-direction",animationDuration:"animation-duration",animationFillMode:"animation-fill-mode",animationIterationCount:"animation-iteration-count",animationName:"animation-name",animationPlayState:"animation-play-state",animationTimingFunction:"animation-timing-function",backfaceVisibility:"backface-visibility",backgroundAttachment:"background-attachment",backgroundBlendMode:"background-blend-mode",backgroundClip:"background-clip",backgroundColor:"background-color",backgroundImage:"background-image",backgroundOrigin:"background-origin",backgroundPosition:"background-position",backgroundRepeat:"background-repeat",backgroundSize:"background-size",borderBottom:"border-bottom",borderBottomColor:"border-bottom-color",borderBottomLeftRadius:"border-bottom-left-radius",borderBottomRightRadius:"border-bottom-right-radius",borderBottomStyle:"border-bottom-style",borderBottomWidth:"border-bottom-width",borderCollapse:"border-collapse",borderColor:"border-color",borderImage:"border-image",borderImageOutset:"border-image-outset",borderImageRepeat:"border-image-repeat",borderImageSlice:"border-image-slice",borderImageSource:"border-image-source",borderImageWidth:"border-image-width",borderLeft:"border-left",borderLeftColor:"border-left-color",borderLeftStyle:"border-left-style",borderLeftWidth:"border-left-width",borderRadius:"border-radius",borderRight:"border-right",borderRightColor:"border-right-color",borderRightStyle:"border-right-style",borderRightWidth:"border-right-width",borderSpacing:"border-spacing",borderStyle:"border-style",borderTop:"border-top",borderTopColor:"border-top-color",borderTopLeftRadius:"border-top-left-radius",borderTopRightRadius:"border-top-right-radius",borderTopStyle:"border-top-style",borderTopWidth:"border-top-width",borderWidth:"border-width",boxDecorationBreak:"box-decoration-break",boxShadow:"box-shadow",boxSizing:"box-sizing",breakAfter:"break-after",breakBefore:"break-before",breakInside:"break-inside",captionSide:"caption-side",caretColor:"caret-color",clipPath:"clip-path",columnCount:"column-count",columnFill:"column-fill",columnGap:"column-gap",columnRule:"column-rule",columnRuleColor:"column-rule-color",columnRuleStyle:"column-rule-style",columnRuleWidth:"column-rule-width",columnSpan:"column-span",columnWidth:"column-width",counterIncrement:"counter-increment",counterReset:"counter-reset",emptyCells:"empty-cells",flexBasis:"flex-basis",flexDirection:"flex-direction",flexFlow:"flex-flow",flexGrow:"flex-grow",flexShrink:"flex-shrink",flexWrap:"flex-wrap",fontFamily:"font-family",fontFeatureSettings:"font-feature-settings",fontKerning:"font-kerning",fontLanguageOverride:"font-language-override",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontSynthesis:"font-synthesis",fontVariant:"font-variant",fontVariantAlternates:"font-variant-alternates",fontVariantCaps:"font-variant-caps",fontVariantEastAsian:"font-variant-east-asian",fontVariantLigatures:"font-variant-ligatures",fontVariantNumeric:"font-variant-numeric",fontVariantPosition:"font-variant-position",fontWeight:"font-weight",gridArea:"grid-area",gridAutoColumns:"grid-auto-columns",gridAutoFlow:"grid-auto-flow",gridAutoRows:"grid-auto-rows",gridColumn:"grid-column",gridColumnEnd:"grid-column-end",gridColumnGap:"grid-column-gap",gridColumnStart:"grid-column-start",gridGap:"grid-gap",gridRow:"grid-row",gridRowEnd:"grid-row-end",gridRowGap:"grid-row-gap",gridRowStart:"grid-row-start",gridTemplate:"grid-template",gridTemplateAreas:"grid-template-areas",gridTemplateColumns:"grid-template-columns",gridTemplateRows:"grid-template-rows",imageRendering:"image-rendering",justifyContent:"justify-content",letterSpacing:"letter-spacing",lineBreak:"line-break",lineHeight:"line-height",listStyle:"list-style",listStyleImage:"list-style-image",listStylePosition:"list-style-position",listStyleType:"list-style-type",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",maskClip:"mask-clip",maskComposite:"mask-composite",maskImage:"mask-image",maskMode:"mask-mode",maskOrigin:"mask-origin",maskPosition:"mask-position",maskRepeat:"mask-repeat",maskSize:"mask-size",maskType:"mask-type",maxHeight:"max-height",maxWidth:"max-width",minHeight:"min-height",minWidth:"min-width",mixBlendMode:"mix-blend-mode",objectFit:"object-fit",objectPosition:"object-position",offsetAnchor:"offset-anchor",offsetDistance:"offset-distance",offsetPath:"offset-path",offsetRotate:"offset-rotate",outlineColor:"outline-color",outlineOffset:"outline-offset",outlineStyle:"outline-style",outlineWidth:"outline-width",overflowAnchor:"overflow-anchor",overflowWrap:"overflow-wrap",overflowX:"overflow-x",overflowY:"overflow-y",paddingBottom:"padding-bottom",paddingLeft:"padding-left",paddingRight:"padding-right",paddingTop:"padding-top",pageBreakAfter:"page-break-after",pageBreakBefore:"page-break-before",pageBreakInside:"page-break-inside",perspectiveOrigin:"perspective-origin",placeContent:"place-content",placeItems:"place-items",placeSelf:"place-self",pointerEvents:"pointer-events",rowGap:"row-gap",scrollBehavior:"scroll-behavior",scrollMargin:"scroll-margin",scrollMarginBlock:"scroll-margin-block",scrollMarginBlockEnd:"scroll-margin-block-end",scrollMarginBlockStart:"scroll-margin-block-start",scrollMarginBottom:"scroll-margin-bottom",scrollMarginInline:"scroll-margin-inline",scrollMarginInlineEnd:"scroll-margin-inline-end",scrollMarginInlineStart:"scroll-margin-inline-start",scrollMarginLeft:"scroll-margin-left",scrollMarginRight:"scroll-margin-right",scrollMarginTop:"scroll-margin-top",scrollPadding:"scroll-padding",scrollPaddingBlock:"scroll-padding-block",scrollPaddingBlockEnd:"scroll-padding-block-end",scrollPaddingBlockStart:"scroll-padding-block-start",scrollPaddingBottom:"scroll-padding-bottom",scrollPaddingInline:"scroll-padding-inline",scrollPaddingInlineEnd:"scroll-padding-inline-end",scrollPaddingInlineStart:"scroll-padding-inline-start",scrollPaddingLeft:"scroll-padding-left",scrollPaddingRight:"scroll-padding-right",scrollPaddingTop:"scroll-padding-top",scrollSnapAlign:"scroll-snap-align",scrollSnapStop:"scroll-snap-stop",scrollSnapType:"scroll-snap-type",shapeImageThreshold:"shape-image-threshold",shapeMargin:"shape-margin",shapeOutside:"shape-outside",tabSize:"tab-size",tableLayout:"table-layout",textAlign:"text-align",textAlignLast:"text-align-last",textCombineUpright:"text-combine-upright",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",textDecorationLine:"text-decoration-line",textDecorationStyle:"text-decoration-style",textIndent:"text-indent",textJustify:"text-justify",textOrientation:"text-orientation",textOverflow:"text-overflow",textShadow:"text-shadow",textTransform:"text-transform",transformBox:"transform-box",transformOrigin:"transform-origin",transformStyle:"transform-style",transitionDelay:"transition-delay",transitionDuration:"transition-duration",transitionProperty:"transition-property",transitionTimingFunction:"transition-timing-function",unicodeBidi:"unicode-bidi",userSelect:"user-select",verticalAlign:"vertical-align",whiteSpace:"white-space",willChange:"will-change",wordBreak:"word-break",wordSpacing:"word-spacing",wordWrap:"word-wrap",writingMode:"writing-mode",zIndex:"z-index",WebkitTransform:"-webkit-transform",WebkitTransition:"-webkit-transition",WebkitBoxShadow:"-webkit-box-shadow",MozBoxShadow:"-moz-box-shadow",MozTransform:"-moz-transform",MozTransition:"-moz-transition",msTransform:"-ms-transform",msTransition:"-ms-transition"};static cssPropAliases=new Proxy(pt.#se,{set:(e,t,r)=>(e[t]=r,pt.cssPropRevAliases[r]=t,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(pt.#se).map(([e,t])=>[t,e]));static toStyleKc(e){return"string"==typeof pt.cssPropAliases[e]?pt.cssPropAliases[e]:e}static toStyleCc(e){return"string"==typeof pt.cssPropRevAliases[e]?pt.cssPropRevAliases[e]:e}static setStyle(e,t,r=null){return pt._preHtmlElems(e,"setStyle").forEach(e=>{if("object"==typeof t)for(const[r,n]of Object.entries(t))e.style.setProperty(pt.toStyleKc(r),"string"==typeof n?n:"number"==typeof n?`${n}px`:String(n));else e.style.setProperty(pt.toStyleKc(t),r)}),e}setStyle(e,t){return pt.setStyle(this,e,t)}static getStyle(e,t){return pt._preHtmlElem(e,"getStyle").style.getPropertyValue(pt.toStyleKc(t))}getStyle(e){return pt.getStyle(this,e)}static style(e,{camelCase:t=!1,rawAttr:r=!1}={}){if("boolean"!=typeof t)throw new TypeError('"camelCase" must be a boolean. Received: '+typeof t);if("boolean"!=typeof r)throw new TypeError('"rawAttr" must be a boolean. Received: '+typeof r);const n=pt._preHtmlElem(e,"style"),i={};if(r){const e=(n.getAttribute("style")||"").split(";");for(const r of e){const[e,n]=r.split(":");if(!e||!n)continue;const o=e.trim(),s=n.trim();i[t?pt.toStyleCc(o):o]=s}}else{const e=n.style;for(let r=0;r<e.length;r++){const n=e[r],o=e.getPropertyValue(n);i[t?pt.toStyleCc(n):n]=o}}return i}style(e){return pt.style(this,e)}static removeStyle(e,t){return pt._preHtmlElems(e,"removeStyle").forEach(e=>{if(Array.isArray(t))for(const r of t)e.style.removeProperty(pt.toStyleKc(r));else e.style.removeProperty(pt.toStyleKc(t))}),e}removeStyle(e){return pt.removeStyle(this,e)}static toggleStyle(e,t,r,n){return pt._preHtmlElems(e,"toggleStyle").forEach(e=>{const i=pt.getStyle(e,t).trim()===pt.toStyleKc(r)?n:r;pt.setStyle(e,t,i)}),e}toggleStyle(e,t,r){return pt.toggleStyle(this,e,t,r)}static clearStyle(e){return pt._preElems(e,"clearStyle").forEach(e=>e.removeAttribute("style")),e}clearStyle(){return pt.clearStyle(this)}static focus(e){return pt._preHtmlElem(e,"focus").focus(),e}focus(){return pt.focus(this)}static blur(e){return pt._preHtmlElem(e,"blur").blur(),e}blur(){return pt.blur(this)}static select(e){const t=pt._preHtmlElem(e,"select");if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement))throw new Error("Element must be an <input> or <textarea> to use select().");return t.select(),e}select(){return pt.select(this)}static boolCheck(e){return void 0!==e&&("true"===e||"1"===e||!0===e||"on"===e||"number"==typeof e&&e>0)}static setWinScrollTop(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");pt.setScrollTop(window,e)}static setWinScrollLeft(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");pt.setScrollLeft(window,e)}static winScrollTop(){return window.scrollY||document.documentElement.scrollTop}static winScrollLeft(){return window.scrollX||document.documentElement.scrollLeft}static winInnerHeight(){return window.innerHeight||document.documentElement.clientHeight}static winInnerWidth(){return window.innerWidth||document.documentElement.clientWidth}static isPageTop(){return 0===window.scrollY}static isPageBottom(){return window.innerHeight+window.scrollY>=document.body.offsetHeight}static getDimension(e,t,r="content"){const n=pt._preElemAndWinAndDoc(e,"getDimension");if("string"!=typeof t)throw new TypeError("The type must be a string.");if("string"!=typeof r)throw new TypeError("The extra must be a string.");const i="width"===t?"Width":"Height";if(pt.isWindow(n))return"margin"===r?n["inner"+i]:n.document.documentElement["client"+i];const o=n;if(9===o.nodeType){const e=o.documentElement;return Math.max(o.body["scroll"+i],e["scroll"+i],o.body["offset"+i],e["offset"+i],e["client"+i])}let s=o.getBoundingClientRect()[t];function a(e){return"width"===t?pt.cssFloat(o,e+"Left")+pt.cssFloat(o,e+"Right"):pt.cssFloat(o,e+"Top")+pt.cssFloat(o,e+"Bottom")}switch(r){case"content":s-=a("padding"),s-=a("border");break;case"padding":s-=a("border");break;case"border":break;case"margin":s+=a("margin")}return s}getDimension(e,t){return pt.getDimension(this,e,t)}static setHeight(e,t){const r=pt._preHtmlElem(e,"setHeight");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.height="number"==typeof t?`${t}px`:t,e}setHeight(e){return pt.setHeight(this,e)}static setWidth(e,t){const r=pt._preHtmlElem(e,"setWidth");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.width="number"==typeof t?`${t}px`:t,e}setWidth(e){return pt.setWidth(this,e)}static height(e){const t=pt._preElemAndWinAndDoc(e,"height");return pt.getDimension(t,"height","content")}height(){return pt.height(this)}static width(e){const t=pt._preElemAndWinAndDoc(e,"width");return pt.getDimension(t,"width","content")}width(){return pt.width(this)}static innerHeight(e){const t=pt._preElemAndWinAndDoc(e,"innerHeight");return pt.getDimension(t,"height","padding")}innerHeight(){return pt.innerHeight(this)}static innerWidth(e){const t=pt._preElemAndWinAndDoc(e,"innerWidth");return pt.getDimension(t,"width","padding")}innerWidth(){return pt.innerWidth(this)}static outerHeight(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=pt._preElemAndWinAndDoc(e,"outerHeight");return pt.getDimension(r,"height",t?"margin":"border")}outerHeight(e){return pt.outerHeight(this,e)}static outerWidth(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=pt._preElemAndWinAndDoc(e,"outerWidth");return pt.getDimension(r,"width",t?"margin":"border")}outerWidth(e){return pt.outerWidth(this,e)}#ie="";get mainDisplay(){return this.#ie}set mainDisplay(e){if("string"!=typeof e)throw new TypeError("mainDisplay must be a string.");this.#ie=e}static#oe="block";static get defaultDisplay(){return pt.#oe}static set defaultDisplay(e){if("string"!=typeof e)throw new TypeError("defaultDisplay must be a string.");pt.#oe=e}static getAnimateData(e,t){let r=ht.get(e);return r||(r={},ht.set(e,r)),r[t]}static setAnimateData(e,t,r){if(!(e instanceof HTMLElement))throw new TypeError("setAnimateData: el must be an HTMLElement.");if("string"!=typeof t)throw new TypeError("setAnimateData: where must be a string.");if("string"!=typeof r&&"number"!=typeof r)throw new TypeError("setAnimateData: value must be a string or number.");let n=ht.get(e);n||(n={},ht.set(e,n)),n[t]=r}static#ae=!0;static get cancelOldStyleFx(){return pt.#ae}static set cancelOldStyleFx(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value.");pt.#ae=e}static#le={slow:{duration:600,easing:"ease"},fast:{duration:200,easing:"ease-out"},_default:{duration:400,easing:"linear"}};static get styleFxSpeeds(){const e={};for(const t in pt.#le){const r=pt.#le[t];e[t]="object"==typeof r?{...r}:r}return e}static set styleFxSpeeds(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleFxSpeeds must be an object.");for(const[t,r]of Object.entries(e))if("number"!=typeof r&&"object"!=typeof r)throw new TypeError(`styleFxSpeeds["${t}"] must be a number or KeyframeAnimationOptions.`);pt.#le={};for(const[t,r]of Object.entries(e))pt.setStyleFxSpeed(t,r)}static getStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=pt.#le[e];return"object"==typeof t?{...t}:t}static setStyleFxSpeed(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("number"!=typeof t&&"object"!=typeof t)throw new TypeError("styleFxSpeed must be a number or KeyframeAnimationOptions");pt.#le[e]="object"==typeof t?{...t}:t}static deleteStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete pt.#le[e]}static hasStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(pt.#le,e)}static#ue=["Top","Right","Bottom","Left"];static#ce={slideDown:pt.genStyleFx("show"),slideUp:pt.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(pt.#ce))}static set styleEffects(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffects must be an object");for(const t in e)for(const[r,n]of Object.entries(e[t]))if(!("string"==typeof n||Array.isArray(n)&&n.every(e=>"string"==typeof e||"number"==typeof e)))throw new TypeError(`Invalid styleEffect["${r}"]`);pt.#ce={};for(const t in e)pt.setStyleEffect(t,e[t])}static getStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=pt.#ce[e];return t?JSON.parse(JSON.stringify(t)):void 0}static setStyleEffect(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleEffect must be an object");const r={};for(const[e,n]of Object.entries(t))if("string"==typeof n)r[e]=n;else{if(!Array.isArray(n)||!n.every(e=>"string"==typeof e||"number"==typeof e))throw new TypeError(`Invalid styleEffect["${e}"]`);r[e]=[...n]}pt.#ce[e]=r}static deleteStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete pt.#ce[e]}static hasStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(pt.#ce,e)}static#he={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...pt.#he}}static set styleEffectInverse(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectInverse must be an object.");for(const[t,r]of Object.entries(e))if("string"!=typeof r)throw new TypeError(`styleEffectInverse["${t}"] must be a string.`);pt.#he={};for(const[t,r]of Object.entries(e))pt.setStyleEffectInverse(t,r)}static getStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return pt.#he[e]||null}static setStyleEffectInverse(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("string"!=typeof t)throw new TypeError(`styleEffectInverse["${e}"] must be a string.`);pt.#he[e]=t}static deleteStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete pt.#he[e]}static hasStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(pt.#he,e)}static#de={slideDown:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),slideUp:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),fadeIn:e=>Number(e.opacity[0])===Number(e.opacity[1]),fadeOut:e=>Number(e.opacity[0])===Number(e.opacity[1])};static get styleEffectsRd(){return{...pt.#de}}static set styleEffectsRd(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectsRd must be an object.");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsRd["${t}"] must be a function.`);pt.#de={};for(const[t,r]of Object.entries(e))pt.setStyleEffectRd(t,r)}static getStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return pt.#de[e]||null}static setStyleEffectRd(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsRd["${e}"] must be a function.`);pt.#de[e]=t}static deleteStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete pt.#de[e]}static hasStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(pt.#de,e)}static#fe={show:(e,t,r,n)=>{if("height"===r||"width"===r){const i=pt.getAnimateData(e,`orig${r}`)||e.scrollHeight+"px";pt.setAnimateData(e,`orig${r}`,i);const o=n[r];t[r]=[o,i]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=pt.getAnimateData(e,r)||n[r];pt.setAnimateData(e,r,i),t[r]=["0px",i]}else if("opacity"===r){const e=n.opacity;t[r]=[e,1]}else{const i=pt.getAnimateData(e,r)||n[r];pt.setAnimateData(e,r,i),t[r]=[i,n[r]||1]}},hide:(e,t,r,n)=>{if("height"===r||"width"===r){const i=pt.getAnimateData(e,`orig${r}`)||n[r];pt.setAnimateData(e,`orig${r}`,i);const o=n[r];t[r]=[o,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=pt.getAnimateData(e,r)||n[r];pt.setAnimateData(e,r,i),t[r]=[n[r],"0px"]}else if("opacity"===r){const e=n.opacity;t[r]=[e,0]}else{const i=pt.getAnimateData(e,r)||n[r];pt.setAnimateData(e,r,i),t[r]=[i,0]}}};static get styleEffectsProps(){return{...pt.#fe}}static set styleEffectsProps(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffectsProps must be an object");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsProps["${t}"] must be a function`);pt.#fe={};for(const[t,r]of Object.entries(e))pt.setStyleEffectProp(t,r)}static getStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return pt.#fe[e]||null}static setStyleEffectProp(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsProps["${e}"] must be a function`);pt.#fe[e]=t}static deleteStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete pt.#fe[e]}static hasStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(pt.#fe,e)}static genStyleFx(e,t=!1){if("string"!=typeof e)throw new TypeError("genStyleFx: type must be a string.");if("boolean"!=typeof t)throw new TypeError("genStyleFx: includeWidth must be a boolean.");let r,n=0;const i={height:e},o=t?1:0;for(;n<4;n+=2-o)r=pt.#ue[n],i["margin"+r]=e,i["padding"+r]=e;return t&&(i.opacity=e,i.width=e),i}static applyStyleFx(e,t,r,n){if("string"!=typeof t)throw new TypeError("applyStyleFx: id must be a string.");if("object"!=typeof r||null===r)throw new TypeError("applyStyleFx: props must be a non-null object.");if(void 0!==n&&"number"!=typeof n&&"string"!=typeof n&&("object"!=typeof n||null===n))throw new TypeError("applyStyleFx: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const i=new Map;return pt._preHtmlElems(e,"applyStyleFx").forEach(o=>{const s={};for(const[e,t]of Object.entries(r))if("string"==typeof t&&this.#fe[t]){const r=getComputedStyle(o);this.#fe[t](o,s,e,r)}else{if("object"!=typeof t)throw new TypeError(`applyStyleFx: invalid action for prop "${e}". Must be string or array.`);s[e]=t}if("function"==typeof pt.#de[t]&&pt.#de[t](s))return void i.set(o,null);const a=[],l=s[Object.keys(s)[0]].length;for(let e=0;e<l;e++){const t={};for(const r in s)t[r]=s[r][e];a.push(t)}i.set(o,pt.animate(e,a,n,t)[0])}),i}applyStyleFx(e,t,r){return pt.applyStyleFx(this,e,t,r)}static getCurrentAnimationId(e){if(!(e instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return dt.get(e)?.id??void 0}static animate(e,t,r=pt.#le._default,n=null,i=pt.#ae){const o="string"==typeof r?pt.#le[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof o&&void 0===o.fill&&(o.fill="forwards");const s=[];return pt._preHtmlElems(e,"animate").forEach(e=>{if(i){const t=dt.get(e);t&&t.animation.cancel()}const r=e.animate(t,o);s.push(r),dt.set(e,{animation:r,id:n??""}),r.addEventListener("finish",()=>{dt.get(e)?.animation===r&&dt.delete(e)})}),s}animate(e,t,r,n){return pt.animate(this,e,t,r,n)}static stop(e){const t=[];return pt._preHtmlElems(e,"stop").forEach(e=>{const r=dt.get(e);r?(r.animation.cancel(),dt.delete(e),t.push(!0)):t.push(!1)}),t}stop(){return pt.stop(this)}static slideDown(e,t){return pt.applyStyleFx(e,"slideDown",this.#ce.slideDown,t??{duration:500,easing:"ease-out"})}slideDown(e){return pt.slideDown(this,e)}static slideUp(e,t){return pt.applyStyleFx(e,"slideUp",this.#ce.slideUp,t??{duration:500,easing:"ease-out"})}slideUp(e){return pt.slideUp(this,e)}static slideToggle(e,t){const r=pt._preHtmlElem(e,"slideToggle"),n=getComputedStyle(r),i=pt.getCurrentAnimationId(r),o="none"===n.display||0===r.offsetHeight;return("string"==typeof i?"slideUp"===i:o)?pt.slideDown(e,t):pt.slideUp(e,t)}slideToggle(e){return pt.slideToggle(this,e)}static fadeIn(e,t){return pt.applyStyleFx(e,"fadeIn",this.#ce.fadeIn,t)}fadeIn(e){return pt.fadeIn(this,e)}static fadeOut(e,t){return pt.applyStyleFx(e,"fadeOut",this.#ce.fadeOut,t)}fadeOut(e){return pt.fadeOut(this,e)}static fadeToggle(e,t){const r=pt._preHtmlElem(e,"fadeToggle"),n=getComputedStyle(r),i=pt.getCurrentAnimationId(r),o="0"===n.opacity||null===r.offsetParent;return("string"==typeof i?"fadeOut"===i:o)?pt.fadeIn(e,t):pt.fadeOut(e,t)}fadeToggle(e){return pt.fadeToggle(this,e)}static fadeTo(e,t,r,n=pt.#oe){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new TypeError("fadeTo: opacity must be a number between 0 and 1.");if(void 0!==r&&"number"!=typeof r&&"string"!=typeof r&&("object"!=typeof r||null===r))throw new TypeError("fadeTo: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const i=new Map;return pt._preHtmlElems(e,"fadeTo").forEach(o=>{const s=getComputedStyle(o);if(!(e instanceof Element&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length))){const e=pt.getAnimateData(o,"origdisplay");o.style.display="string"==typeof e?e:n}const a=[s.opacity,t].map(e=>({opacity:e}));i.set(o,pt.animate(o,a,r,"fadeTo")[0])}),i}fadeTo(e,t,r=this.#ie){return pt.fadeTo(this,e,t,r)}static offset(e){const t=pt._preElem(e,"offset").getBoundingClientRect(),r=window.scrollY||document.documentElement.scrollTop,n=window.scrollX||document.documentElement.scrollLeft;return{top:t.top+r,left:t.left+n}}offset(){return pt.offset(this)}static position(e){const t=pt._preHtmlElem(e,"position");let r,n,i={top:0,left:0};if("fixed"===window.getComputedStyle(t).position)n=t.getBoundingClientRect();else{n=pt.offset(t),r=t.offsetParent||document.documentElement;const{position:e}=window.getComputedStyle(r);for(;r instanceof HTMLElement&&(r===document.body||r===document.documentElement)&&"static"===e;)r=r.parentNode;if(r instanceof HTMLElement&&r!==t&&1===r.nodeType){const{borderTopWidth:e,borderLeftWidth:t}=pt.cssFloats(r,["borderTopWidth","borderLeftWidth"]);i=pt.offset(r),i.top+=e,i.left+=t}}return{top:n.top-i.top-pt.cssFloat(t,"marginTop"),left:n.left-i.left-pt.cssFloat(t,"marginLeft")}}position(){return pt.position(this)}static offsetParent(e){let t=pt._preHtmlElem(e,"offsetParent").offsetParent;for(;t instanceof HTMLElement&&"static"===window.getComputedStyle(t).position;)t=t.offsetParent;return t instanceof HTMLElement?t:document.documentElement}offsetParent(){return pt.offsetParent(this)}static scrollTop(e){const t=pt._preElemAndWindow(e,"scrollTop");return pt.isWindow(t)?t.pageYOffset:9===t.nodeType?t.defaultView.pageYOffset:t.scrollTop}scrollTop(){return pt.scrollTop(this)}static scrollLeft(e){const t=pt._preElemAndWindow(e,"scrollLeft");return pt.isWindow(t)?t.pageXOffset:9===t.nodeType?t.defaultView.pageXOffset:t.scrollLeft}scrollLeft(){return pt.scrollLeft(this)}static easings={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:(4-2*e)*e-1,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1};static scrollToXY(e,{targetX:t,targetY:r,duration:n,easing:i,onAnimation:o}={}){if(void 0!==t&&"number"!=typeof t)throw new TypeError("`targetX` must be a number if provided.");if(void 0!==r&&"number"!=typeof r)throw new TypeError("`targetY` must be a number if provided.");if(void 0!==n&&"number"!=typeof n)throw new TypeError("`duration` must be a number if provided.");if(void 0!==i&&"string"!=typeof i)throw new TypeError("`easing` must be a string if provided.");if(void 0!==i&&"function"!=typeof pt.easings[i])throw new TypeError(`Unknown easing function: "${i}".`);if(void 0!==o&&"function"!=typeof o)throw new TypeError("`onAnimation` must be a function if provided.");const s=(e,t,r,n)=>{if(e instanceof Window)window.scrollTo(t,r);else if(9===e.nodeType)e.defaultView.scrollTo(t,r);else{const n=e instanceof Window?window.scrollX:e.scrollLeft,i=e instanceof Window?window.scrollY:e.scrollTop;n!==t&&(e.scrollLeft=t),i!==r&&(e.scrollTop=r)}"function"==typeof o&&o({x:t,y:r,isComplete:n>=1,time:n})};return pt._preElemsAndWindow(e,"scrollToXY").forEach(e=>{const o=e instanceof Window?window.scrollX:e.scrollLeft,a=e instanceof Window?window.scrollY:e.scrollTop,l=t??o,u=r??a,c=l-o,h=u-a,d="string"==typeof i&&pt.easings[i]||null;if("number"!=typeof n||"function"!=typeof d)return s(e,l,u,1);const f=performance.now(),p=n??0;requestAnimationFrame(function t(r){if("function"!=typeof d)return;const n=Math.min(1,(r-f)/p),i=d(n);s(e,o+c*i,a+h*i,n),n<1&&requestAnimationFrame(t)})}),e}scrollToXY({targetX:e,targetY:t,duration:r,easing:n,onAnimation:i}={}){return pt.scrollToXY(this,{targetX:e,targetY:t,duration:r,easing:n,onAnimation:i})}static setScrollTop(e,t){if("number"!=typeof t)throw new TypeError("ScrollTop value must be a number.");return pt.scrollToXY(e,{targetY:t})}setScrollTop(e){return pt.setScrollTop(this,e)}static setScrollLeft(e,t){if("number"!=typeof t)throw new TypeError("ScrollLeft value must be a number.");return pt.scrollToXY(e,{targetX:t})}setScrollLeft(e){return pt.setScrollLeft(this,e)}static borderWidth(e){const t=pt._preElem(e,"borderWidth"),{borderLeftWidth:r,borderRightWidth:n,borderTopWidth:i,borderBottomWidth:o}=pt.cssFloats(t,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}borderWidth(){return pt.borderWidth(this)}static border(e){const t=pt._preElem(e,"border"),{borderLeft:r,borderRight:n,borderTop:i,borderBottom:o}=pt.cssFloats(t,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}border(){return pt.border(this)}static margin(e){const t=pt._preElem(e,"margin"),{marginLeft:r,marginRight:n,marginTop:i,marginBottom:o}=pt.cssFloats(t,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}margin(){return pt.margin(this)}static padding(e){const t=pt._preElem(e,"padding"),{paddingLeft:r,paddingRight:n,paddingTop:i,paddingBottom:o}=pt.cssFloats(t,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}padding(){return pt.padding(this)}static addClass(e,...t){return pt._preElems(e,"addClass").forEach(e=>e.classList.add(...t)),e}addClass(...e){return pt.addClass(this,...e)}static removeClass(e,...t){return pt._preElems(e,"removeClass").forEach(e=>e.classList.remove(...t)),e}removeClass(...e){return pt.removeClass(this,...e)}static replaceClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if("string"!=typeof r)throw new TypeError('The "newToken" parameter must be a string.');const n=[];return pt._preElems(e,"replaceClass").forEach(e=>n.push(e.classList.replace(t,r))),n}replaceClass(e,t){return pt.replaceClass(this,e,t)[0]}static classItem(e,t){const r=pt._preElem(e,"classItem");if("number"!=typeof t)throw new TypeError('The "index" parameter must be a number.');return r.classList.item(t)}classItem(e){return pt.classItem(this,e)}static toggleClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" parameter must be a boolean.');const n=[];return pt._preElems(e,"toggleClass").forEach(e=>n.push(e.classList.toggle(t,r))),n}toggleClass(e,t){return pt.toggleClass(this,e,t)[0]}static hasClass(e,t){const r=pt._preElem(e,"hasClass");if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');return r.classList.contains(t)}hasClass(e){return pt.hasClass(this,e)}static classLength(e){return pt._preElem(e,"classLength").classList.length}classLength(){return pt.classLength(this)}static classList(e){return pt._preElem(e,"classList").classList.values().toArray()}classList(){return pt.classList(this)}static tagName(e){return pt._preElem(e,"tagName").tagName}tagName(){return pt.tagName(this)}static id(e){return pt._preElem(e,"id").id}id(){return pt.id(this)}static toBigInt(e){const t=pt._preElem(e,"toBigInt"),r=t.textContent?.trim();let n=null;try{n=BigInt(r??"")}catch{n=null}return n}toBigInt(){return pt.toBigInt(this)}static setBigInt(e,t){if("bigint"!=typeof t)throw new Error("Value is not a valid BigInt.");const r=t.toString();return pt._preElems(e,"setBigInt").forEach(e=>e.textContent=r),e}setBigInt(e){return pt.setBigInt(this,e)}static toDate(e){const t=pt._preElem(e,"toDate"),r=t.textContent?.trim();if(!r)return null;const n=new Date(r);return Number.isNaN(n.getTime())?null:n}toDate(){return pt.toDate(this)}static setDate(e,t){if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new Error("Value is not a valid Date.");const r=t.toISOString();return pt._preElems(e,"setDate").forEach(e=>e.textContent=r),e}setDate(e){return pt.setDate(this,e)}static toJson(e){const t=pt._preElem(e,"toJson"),r=t.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return pt.toJson(this)}static setJson(e,t,r,n){const i=JSON.stringify(t,r,n);return pt._preElems(e,"setJson").forEach(e=>e.textContent=i),e}setJson(e,t,r){return pt.setJson(this,e,t,r)}static toNumber(e){const t=pt._preElem(e,"toNumber");return"string"==typeof t.textContent?parseFloat(t.textContent.trim()):null}toNumber(){return pt.toNumber(this)}static setNumber(e,t){if("number"!=typeof t)throw new Error("Value is not a valid number.");const r=t.toString();return pt._preElems(e,"setNumber").forEach(e=>e.textContent=r),e}setNumber(e){return pt.setNumber(this,e)}static toBoolean(e){const t=pt._preElem(e,"toBoolean"),r=t.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return pt.toBoolean(this)}static setBoolean(e,t){if("boolean"!=typeof t)throw new Error("Value is not a valid boolean.");const r=t.toString();return pt._preElems(e,"setBoolean").forEach(e=>e.textContent=r),e}setBoolean(e){return pt.setBoolean(this,e)}static toString(e){const t=pt._preElem(e,"toString");return"string"==typeof t.textContent?t.textContent:null}toString(){return pt.toString(this)}static setString(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return pt._preElems(e,"setString").forEach(e=>e.textContent=t),e}setString(e){return pt.setString(this,e)}static text(e){return pt._preElem(e,"text").textContent}text(){return pt.text(this)}static setText(e,t){const r=null!=t?String(t):"";return pt._preElems(e,"setText").forEach(e=>e.textContent=r),e}setText(e){return pt.setText(this,e)}static empty(e){return pt._preElems(e,"empty").forEach(e=>e.textContent=""),e}empty(){return pt.empty(this)}static html(e,t){return pt._preElem(e,"html").getHTML(t)}html(e){return pt.html(this,e)}static setHtml(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return pt._preElems(e,"setHtml").forEach(e=>e.innerHTML=t),e}setHtml(e){return pt.setHtml(this,e)}static _valHooks={option:{get:e=>{const t=e.getAttribute("value");return null!=t?t:e.textContent}},select:{get:e=>{const t=e.options,r=e.selectedIndex,n="select-one"===e.type,i=n?r+1:t.length,o=[];let s=r<0?i:n?r:0;for(;s<i;s++){const e=t[s],i=e.parentNode;if((e.selected||s===r)&&!e.disabled&&(!i||!i.disabled||"OPTGROUP"!==i.tagName)){const t=pt._valHooks.option.get(e);if(n)return t;o.push(t)}}return o},set:(e,t)=>{const r=e.options,n=Array.isArray(t)?t.map(String):[String(t)];let i=!1;for(let e=0;e<r.length;e++){const t=r[e],o=pt._valHooks.option.get(t);"string"==typeof o&&(t.selected=n.includes(o))&&(i=!0)}return i||(e.selectedIndex=-1),n}},radio:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t){const r=e.closest("label");return t&&r&&r.querySelectorAll('input[type="radio"]').forEach(t=>{t instanceof HTMLInputElement&&t!==e&&(t.checked=!1)}),e.checked=t,t}}},checkbox:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t)return e.checked=t,t}}};static setVal(e,t){return pt._preInputElems(e,"setVal").forEach(e=>{if(1!==e.nodeType)return;let r="function"==typeof t?t(e,pt.val(e)):t;null==r?r="":"number"==typeof r?r=String(r):Array.isArray(r)&&(r=((e,t)=>{const r=[];for(let n=0;n<e.length;n++)r.push(t(e[n]));return r})(r,e=>null==e?"":String(e)));const n=pt._valHooks[e.type]||pt._valHooks[e.nodeName.toLowerCase()];if(!n||"function"!=typeof n.set||void 0===n.set(e,r,"value")){if("string"!=typeof r&&"boolean"!=typeof r)throw new Error(`Invalid setValue "${typeof r}" value.`);"string"==typeof r&&(e.value=r)}}),e}setVal(e){return pt.setVal(this,e)}static _valTypes={string:e=>e.value,date:e=>e.valueAsDate,number:e=>e.valueAsNumber};static _getValByType(e,t,r){if("string"!=typeof t)throw new TypeError('The "type" must be a string.');if("string"!=typeof r)throw new TypeError('The "where" must be a string.');if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error(`Provided element is not an HTMLInputElement in ${r}().`);if("function"!=typeof pt._valTypes[t])throw new Error(`No handler found for type "${t}" in ${r}().`);return pt._valTypes[t](e)}static _val(e,t,r){const n=pt._preInputElem(e,t),i=pt._valHooks[n.type]||pt._valHooks[n.nodeName.toLowerCase()];if(i&&"function"==typeof i.get){const e=i.get(n,"value",r);if(void 0!==e)return"string"==typeof e?e.replace(/\r/g,""):e}return pt._getValByType(n,r,t)}_val(e,t){return pt._val(this,e,t)}static val(e){return pt._val(e,"val","string")}val(){return pt.val(this)}static valTxt(e){const t=pt._val(e,"valTxt","string");if("string"!=typeof t&&null!==t)throw new Error("Value is not a valid string.");return null==t?"":"string"==typeof t?t.replace(/\r/g,""):t}valTxt(){return pt.valTxt(this)}static _valArr(e,t,r){const n=pt._val(e,t,r);if(!Array.isArray(n))throw new Error(`Value expected an array but got ${typeof n}.`);return n}_valArr(e,t){return pt._valArr(this,e,t)}static valArr(e){return pt._valArr(e,"valArr","string")}valArr(){return pt.valArr(this)}static valNb(e){if(!(pt._preInputElem(e,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=pt._val(e,"valNb","number");if(Number.isNaN(t))throw new Error("Value is not a valid number.");return t}valNb(){return pt.valNb(this)}static valDate(e){if(!(pt._preInputElem(e,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=pt._val(e,"valDate","date");if(!(t instanceof Date))throw new Error("Value is not a valid date.");return t}valDate(){return pt.valDate(this)}static valBool(e){const t=pt._preInputElem(e,"valBool");if(!(t instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===pt.val(t)}valBool(){return pt.valBool(this)}static listenForPaste(e,{onFilePaste:t,onTextPaste:r}={}){if(void 0!==t&&"function"!=typeof t)throw new TypeError("onFilePaste must be a function.");if(void 0!==r&&"function"!=typeof r)throw new TypeError("onTextPaste must be a function.");const n=e=>{if(!(e instanceof ClipboardEvent))return;const n=e.clipboardData?.items||[];for(const e of n)if("file"===e.kind){if("function"==typeof t){const r=e.getAsFile();r&&t(e,r)}}else"string"===e.kind&&"function"==typeof r&&e.getAsString(t=>r(e,t))};return pt._preElemsWithDoc(e,"listenForPaste").forEach(e=>pt.on(e,"paste",n)),n}listenForPaste({onFilePaste:e,onTextPaste:t}={}){return pt.listenForPaste(this,{onFilePaste:e,onTextPaste:t})}static hasEventListener(e,t){const r=pt._preEventTargetElem(e,"hasEventListener");if(!ut.has(r))return!1;const n=ut.get(r);return!!(n&&Array.isArray(n[t])&&n[t].length>0)}hasEventListener(e){return pt.hasEventListener(this,e)}static hasExactEventListener(e,t,r){const n=pt._preEventTargetElem(e,"hasExactEventListener");if("function"!=typeof r)throw new TypeError('The "handler" must be a function.');if(!ut.has(n))return!1;const i=ut.get(n);return!(!i||!Array.isArray(i[t]))&&i[t].some(e=>e.handler===r)}hasExactEventListener(e,t){return pt.hasExactEventListener(this,e,t)}static hover(e,t,r,n){return pt.on(e,"mouseenter",t,n),pt.on(e,"mouseleave",r||t,n),e}hover(e,t,r){return pt.hover(this,e,t,r)}static on(e,t,r,n){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");pt._preEventTargetElems(e,"on").forEach(e=>{e.addEventListener(i,r,n),ut.has(e)||ut.set(e,{});const t=ut.get(e);t&&(Array.isArray(t[i])||(t[i]=[]),t[i].push({handler:r,options:n}))})}return e}on(e,t,r){return pt.on(this,e,t,r)}static once(e,t,r,n={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");pt._preEventTargetElems(e,"once").forEach(e=>{const t=n=>{pt.off(e,i,t),"function"==typeof r&&r(n)};pt.on(e,i,t,"boolean"==typeof n?n:{...n,once:!0})})}return e}once(e,t,r={}){return pt.once(this,e,t,r)}static off(e,t,r,n){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");pt._preEventTargetElems(e,"off").forEach(e=>{e.removeEventListener(i,r,n);const t=ut.get(e);t&&t[i]&&(t[i]=t[i].filter(e=>e.handler!==r),0===t[i].length&&delete t[i])})}return e}off(e,t,r){return pt.off(this,e,t,r)}static offAll(e,t){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const r of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof r)throw new TypeError("The event name must be a string.");pt._preEventTargetElems(e,"offAll").forEach(e=>{const t=ut.get(e);if(t&&t[r]){for(const n of t[r])e.removeEventListener(r,n.handler,n.options);delete t[r]}})}return e}offAll(e){return pt.offAll(this,e)}static offAllTypes(e,t=null){if(null!==t&&"function"!=typeof t)throw new TypeError('The "filterFn" must be a function.');return pt._preEventTargetElems(e,"offAllTypes").forEach(e=>{const r=ut.get(e);if(r){for(const n in r)for(const i of r[n])("function"!=typeof t||t(i.handler,n))&&e.removeEventListener(n,i.handler,i.options);ut.delete(e)}}),e}offAllTypes(e=null){return pt.offAllTypes(this,e)}static trigger(e,t,r={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");pt._preEventTargetElems(e,"trigger").forEach(e=>{const t=r instanceof Event||r instanceof CustomEvent?r:new CustomEvent(n,{bubbles:!0,cancelable:!0,detail:r});e.dispatchEvent(t)})}return e}trigger(e,t={}){return pt.trigger(this,e,t)}static#pe={for:"htmlFor",class:"className"};static propFix=new Proxy(pt.#pe,{set:(e,t,r)=>(e[t]=r,pt.attrFix[r]=t,!0)});static attrFix=Object.fromEntries(Object.entries(pt.#pe).map(([e,t])=>[t,e]));static getPropName(e){return"string"==typeof pt.propFix[e]?pt.propFix[e]:e}static getAttrName(e){return"string"==typeof pt.attrFix[e]?pt.attrFix[e]:e}static attrBigInt(e,t){const r=pt._preElem(e,"attrBigInt").getAttribute(pt.getAttrName(t));if(null==r)return null;try{return BigInt(r)}catch{return null}}attrBigInt(e){return pt.attrBigInt(this,e)}static setAttrBigInt(e,t,r){if("bigint"!=typeof r)throw new Error("Value is not a valid BigInt.");return pt.setAttr(e,t,r.toString())}setAttrBigInt(e,t){return pt.setAttrBigInt(this,e,t)}static attrDate(e,t){const r=pt._preElem(e,"attrDate").getAttribute(pt.getAttrName(t));if(!r)return null;const n=new Date(r);return Number.isNaN(n.getTime())?null:n}attrDate(e){return pt.attrDate(this,e)}static setAttrDate(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new Error("Value is not a valid Date.");return pt.setAttr(e,t,r.toISOString())}setAttrDate(e,t){return pt.setAttrDate(this,e,t)}static attrJson(e,t){const r=pt._preElem(e,"attrJson").getAttribute(pt.getAttrName(t));if(!r)return null;try{return JSON.parse(r)}catch{return null}}attrJson(e){return pt.attrJson(this,e)}static setAttrJson(e,t,r,n,i){const o=JSON.stringify(r,n,i);return pt.setAttr(e,t,o)}setAttrJson(e,t,r,n){return pt.setAttrJson(this,e,t,r,n)}static attrNumber(e,t){const r=pt._preElem(e,"attrNumber").getAttribute(pt.getAttrName(t));return null!=r?parseFloat(r):null}attrNumber(e){return pt.attrNumber(this,e)}static setAttrNumber(e,t,r){if("number"!=typeof r)throw new Error("Value is not a valid number.");return pt.setAttr(e,t,r.toString())}setAttrNumber(e,t){return pt.setAttrNumber(this,e,t)}static attrBoolean(e,t){const r=pt._preElem(e,"attrBoolean").getAttribute(pt.getAttrName(t));return null===r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}attrBoolean(e){return pt.attrBoolean(this,e)}static setAttrBoolean(e,t,r){if("boolean"!=typeof r)throw new Error("Value is not a valid boolean.");return pt.setAttr(e,t,r.toString())}setAttrBoolean(e,t){return pt.setAttrBoolean(this,e,t)}static attrString(e,t){const r=pt._preElem(e,"attrString").getAttribute(pt.getAttrName(t));return"string"==typeof r?r:null}attrString(e){return pt.attrString(this,e)}static setAttrString(e,t,r){if("string"!=typeof r)throw new Error("Value is not a valid string.");return pt.setAttr(e,t,r)}setAttrString(e,t){return pt.setAttrString(this,e,t)}static attr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return pt._preElem(e,"attr").getAttribute(pt.getAttrName(t))}attr(e){return pt.attr(this,e)}static setAttr(e,t,r=null){const n=pt._preElems(e,"setAttr");if("object"==typeof t&&null!==t)return Object.entries(t).forEach(([e,t])=>n.forEach(r=>{null===t?r.removeAttribute(pt.getAttrName(e)):r.setAttribute(pt.getAttrName(e),String(t))})),e;if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return n.forEach(e=>{null===r?e.removeAttribute(pt.getAttrName(t)):e.setAttribute(pt.getAttrName(t),String(r))}),e}setAttr(e,t){return pt.setAttr(this,e,t)}static removeAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return pt._preElems(e,"removeAttr").forEach(e=>e.removeAttribute(pt.getAttrName(t))),e}removeAttr(e){return pt.removeAttr(this,e)}static hasAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return pt._preElem(e,"hasAttr").hasAttribute(pt.getAttrName(t))}hasAttr(e){return pt.hasAttr(this,e)}static hasProp(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return!!pt._preElem(e,"hasProp")[pt.getPropName(t)]}hasProp(e){return pt.hasProp(this,e)}static addProp(e,...t){return pt._preElems(e,"addProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[pt.getPropName(t)]=!0})}),e}addProp(...e){return pt.addProp(this,...e)}static removeProp(e,...t){return pt._preElems(e,"removeProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[pt.getPropName(t)]=!1})}),e}removeProp(...e){return pt.removeProp(this,...e)}static toggleProp(e,t,r){const n=pt._preElems(e,"toggleProp");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" must be a boolean.');return(Array.isArray(t)?t:[t]).forEach(e=>{if("string"!=typeof e)throw new TypeError("Each property name must be a string.");n.forEach(t=>{(void 0===r?!t[pt.getPropName(e)]:r)?pt.addProp(t,e):pt.removeProp(t,e)})}),e}toggleProp(e,t){return pt.toggleProp(this,e,t)}static prop(e,t){if("string"!=typeof t)throw new TypeError('Invalid arguments passed to prop(). Expected string for "name".');return pt._preElem(e,"prop")[t]}prop(e){return pt.prop(this,e)}static setProp(e,t,r){if("string"!=typeof t||""===t.trim())throw new Error("Property name must be a non-empty string.");return pt._preElems(e,"setProp").forEach(e=>{e[t]=r}),e}setProp(e,t){return pt.setProp(this,e,t)}static remove(e){return pt._preElems(e,"remove").forEach(e=>e.remove()),e}remove(){return pt.remove(this)}static index(e,t=null){const r=pt._preElem(e,"index");if(!r)return-1;if(!t)return Array.prototype.indexOf.call(r.parentNode?.children||[],r);if(t){const e="string"==typeof t?document.querySelectorAll(t):pt._preElems(t,"index");return Array.prototype.indexOf.call(e,r)}return-1}index(e){return pt.index(this,e)}static _getCustomRect(e,t){const r={height:0,width:0,x:0,y:0,bottom:0,left:0,right:0,top:0,toJSON:function(){throw new Error("Function not implemented.")}};for(const t in e)"number"==typeof e[t]&&(r[t]=e[t]);if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("extraRect must be a non-null object.");const{height:n=0,width:i=0,top:o=0,bottom:s=0,left:a=0,right:l=0}=t;if("number"!=typeof n)throw new Error("extraRect.height must be a number.");if("number"!=typeof i)throw new Error("extraRect.width must be a number.");if("number"!=typeof o)throw new Error("extraRect.top must be a number.");if("number"!=typeof s)throw new Error("extraRect.bottom must be a number.");if("number"!=typeof a)throw new Error("extraRect.left must be a number.");if("number"!=typeof l)throw new Error("extraRect.right must be a number.");return r.height+=n,r.width+=i,r.top+=o,r.bottom+=s,r.left+=a,r.right+=l,r}static isCollWith(e,t,r={}){const n=pt._getCustomRect(pt._preElem(e,"isCollWith").getBoundingClientRect(),r),i=pt._preElem(t,"isCollWith").getBoundingClientRect();return nt(n,i)}isCollWith(e,t){return pt.isCollWith(this,e,t)}static isCollPerfWith(e,t,r={}){const n=pt._getCustomRect(pt._preElem(e,"isCollPerfWith").getBoundingClientRect(),r),i=pt._preElem(t,"isCollPerfWith").getBoundingClientRect();return it(n,i)}isCollPerfWith(e,t){return pt.isCollPerfWith(this,e,t)}static _isCollWithLock(e,t,r,n,i){const o=ft[i];if(e)return o.has(n)||o.set(n,!0),!0;if(o.has(n)){let e=!1;switch(i){case"top":e=ot(t,r);break;case"bottom":e=st(t,r);break;case"left":e=at(t,r);break;case"right":e=lt(t,r)}return e&&o.delete(n),o.has(n)}return!1}static isCollWithLock(e,t,r,n={}){const i=pt._preElem(e,"isCollWithLock"),o=pt._preElem(t,"isCollWithLock"),s=pt._getCustomRect(i.getBoundingClientRect(),n),a=o.getBoundingClientRect(),l=nt(s,a);return pt._isCollWithLock(l,s,a,i,r)}isCollWithLock(e,t,r){return pt.isCollWithLock(this,e,t,r)}static isCollPerfWithLock(e,t,r,n={}){const i=pt._preElem(e,"isCollPerfWithLock"),o=pt._preElem(t,"isCollPerfWithLock"),s=pt._getCustomRect(i.getBoundingClientRect(),n),a=o.getBoundingClientRect(),l=it(s,a);return pt._isCollWithLock(l,s,a,i,r)}isCollPerfWithLock(e,t,r){return pt.isCollPerfWithLock(this,e,t,r)}static resetCollLock(e){const t=pt._preElem(e,"resetCollLock");let r=!1;for(const e of["top","bottom","left","right"])ft[e].has(t)&&(ft[e].delete(t),r=!0);return r}resetCollLock(){return pt.resetCollLock(this)}static resetCollLockDir(e,t){const r=pt._preElem(e,"resetCollLockDir"),n=ft[t];return!!n.has(r)&&(n.delete(r),!0)}resetCollLockDir(e){return pt.resetCollLockDir(this,e)}static isInViewport(e){const t=pt._preElem(e,"isInViewport");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=pt.offset(t).top,n=r+pt.outerHeight(t),i=pt.scrollTop(window),o=i+pt.height(window);return n>i&&r<o}isInViewport(){return pt.isInViewport(this)}static isScrolledIntoView(e){const t=pt._preElem(e,"isScrolledIntoView");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=pt.scrollTop(window),n=r+pt.height(window),i=pt.offset(t).top;return i+pt.height(t)<=n&&i>=r}isScrolledIntoView(){return pt.isScrolledIntoView(this)}static isInContainer(e,t){const r=pt._preElem(e,"isInContainer"),n=pt._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const i=r.getBoundingClientRect(),o=n.getBoundingClientRect(),s=i.bottom>o.top&&i.top<o.bottom,a=i.right>o.left&&i.left<o.right;return s&&a}isInContainer(e){return pt.isInContainer(this,e)}static isFullyInContainer(e,t){const r=pt._preElem(e,"isScrolledIntoView"),n=pt._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const i=r.getBoundingClientRect(),o=n.getBoundingClientRect();return i.top>=o.top&&i.bottom<=o.bottom&&i.left>=o.left&&i.right<=o.right}isFullyInContainer(e){return pt.isFullyInContainer(this,e)}static hasScroll(e){const t=pt._preElem(e,"hasScroll");return{v:t.scrollHeight>t.clientHeight,h:t.scrollWidth>t.clientWidth}}hasScroll(){return pt.hasScroll(this)}}const mt=pt;class gt{static Utils={...e,TinyHtml:mt};#me=!0;#ge=!1;#ye=0;#we=0;#be=!0;#ve=!1;#Ee=!1;#Te=!1;#Se=!1;#xe=!1;#Ae=!1;#Ie=null;#Ce=[];#Me=null;#Le={start:!1,end:!1,collide:!1,move:!1};#De=null;#P;#ke="drag-hidden";#Ne="dragging";#_e="drag-active";#je="jail-drag-active";#Oe="jail-drag-disabled";#Re="dragging-collision";#Be=9999;constructor(e,t={}){const r=e instanceof mt?e.get(0):e;if(!(r instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#P=r,void 0!==t.jail&&!(t.jail instanceof HTMLElement))throw new Error('The "jail" option must be an HTMLElement if provided.');if(void 0!==t.defaultZIndex&&this.setDefaultZIndex(t.defaultZIndex),void 0!==t.vibration&&!1!==t.vibration&&!m(t.vibration))throw new Error('The "vibration" option must be an object or false.');const n=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new Error(`The "${t}" option must be a boolean.`)},i=(e,t)=>{if(void 0!==e&&"string"!=typeof e)throw new Error(`The "${t}" option must be a string.`)};n(t.mirrorElem,"mirrorElem"),n(t.collisionByMouse,"collisionByMouse"),n(t.lockInsideJail,"lockInsideJail"),n(t.dropInJailOnly,"dropInJailOnly"),n(t.revertOnDrop,"revertOnDrop"),n(t.multiCollision,"multiCollision"),i(t.classDragging,"classDragging"),i(t.classBodyDragging,"classBodyDragging"),i(t.classJailDragging,"classJailDragging"),i(t.classJailDragDisabled,"classJailDragDisabled"),i(t.classDragCollision,"classDragCollision"),i(t.classHidden,"classHidden"),t.jail instanceof HTMLElement&&(this.#De=t.jail),this.#Le=Object.assign({start:!1,end:!1,collide:!1,move:!1},m(t.vibration)?t.vibration:{}),"string"==typeof t.classDragging&&(this.#Ne=t.classDragging),"string"==typeof t.classBodyDragging&&(this.#_e=t.classBodyDragging),"string"==typeof t.classJailDragging&&(this.#je=t.classJailDragging),"string"==typeof t.classJailDragDisabled&&(this.#Oe=t.classJailDragDisabled),"string"==typeof t.classHidden&&(this.#ke=t.classHidden),"string"==typeof t.classDragCollision&&(this.#Re=t.classDragCollision),"boolean"==typeof t.collisionByMouse&&(this.#xe=t.collisionByMouse),"boolean"==typeof t.mirrorElem&&(this.#be=t.mirrorElem),"boolean"==typeof t.revertOnDrop&&(this.#Te=t.revertOnDrop),"boolean"==typeof t.lockInsideJail&&(this.#Ee=t.lockInsideJail),"boolean"==typeof t.dropInJailOnly&&(this.#Ae=t.dropInJailOnly),"boolean"==typeof t.multiCollision&&(this.#ve=t.multiCollision),this._onMouseDown=this.#$e.bind(this),this._onMouseMove=this.#Pe.bind(this),this._onMouseUp=this.#He.bind(this),this._onTouchStart=e=>this.#$e(e.touches[0]),this._onTouchMove=e=>this.#Pe(e.touches[0]),this._onTouchEnd=e=>this.#He(e.changedTouches[0]),this.#P.addEventListener("mousedown",this._onMouseDown),this.#P.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){this.#Fe(),this.#De&&this.#De.classList.add(this.#Oe),this.#me=!0}disable(){this.#De&&this.#De.classList.remove(this.#Oe),this.#me=!1}addCollidable(e){if(this.#Fe(),!(e instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#Ce.includes(e)||this.#Ce.push(e)}removeCollidable(e){if(this.#Fe(),!(e instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#Ce=this.#Ce.filter(t=>t!==e)}setVibrationPattern({startPattern:e=!1,endPattern:t=!1,collidePattern:r=!1,movePattern:n=!1}={}){this.#Fe();const i=e=>!1===e||Array.isArray(e)&&e.every(e=>"number"==typeof e);if(!i(e))throw new Error('Invalid "startPattern": must be false or an array of numbers.');if(!i(t))throw new Error('Invalid "endPattern": must be false or an array of numbers.');if(!i(r))throw new Error('Invalid "collidePattern": must be false or an array of numbers.');if(!i(n))throw new Error('Invalid "movePattern": must be false or an array of numbers.');this.#Le={start:e,end:t,collide:r,move:n}}disableVibration(){this.#Fe(),this.#Le={start:!1,end:!1,collide:!1,move:!1}}getOffset(e){if(this.#Fe(),!(e instanceof MouseEvent||e instanceof Touch)||"number"!=typeof e.clientX||"number"!=typeof e.clientY)throw new Error("getOffset expects an event with valid clientX and clientY coordinates.");const t=this.#P.getBoundingClientRect(),{left:r,top:n}=mt.borderWidth(this.#P);return{x:e.clientX-t.left+r,y:e.clientY-t.top+n}}#$e(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ge||!this.#me||!this.#P.parentElement)return;if(this.#be){const e=this.#P.cloneNode(!0);if(!(e instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#Me=e}else this.#Me=this.#P;this.#Se=!0;const t=this.#P.getBoundingClientRect();Object.assign(this.#Me.style,{position:"absolute",pointerEvents:"none",left:`${this.#P.offsetLeft}px`,top:`${this.#P.offsetTop}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:this.#Be}),this.#be&&(this.#P.classList.add(this.#ke),this.#P.parentElement.appendChild(this.#Me));const{x:r,y:n}=this.getOffset(e);this.#we=r,this.#ye=n,this.#Me.classList.add(this.#Ne),document.body.classList.add(this.#_e),this.#De&&this.#De.classList.add(this.#je),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("touchmove",this._onTouchMove,{passive:!1}),document.addEventListener("touchend",this._onTouchEnd),navigator.vibrate&&Array.isArray(this.#Le.start)&&navigator.vibrate(this.#Le.start),this.checkDragCollision(e),this.#We("drag")}#ze=[];#qe(e){e&&(e.classList.add(this.#Re),this.#ze.push(e))}#Ve(){for(;this.#ze.length>0;){const e=this.#ze.shift();e&&e.classList.remove(this.#Re)}this.#Ie&&this.#Ie.classList.remove(this.#Re)}checkDragCollision(e){const{collidedElements:t}=this.execCollision(e),r=t[0]||null;this.#Ie&&!t.includes(this.#Ie)&&this.#Ve(),t.forEach(e=>this.#qe(e)),this.#Ce.forEach(e=>{t.includes(e)||e.classList.remove(this.#Re)}),navigator.vibrate&&Array.isArray(this.#Le.collide)&&t.length>0&&navigator.vibrate(this.#Le.collide),this.#Ie=r}#Pe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ge||!this.#Se||!this.#me||!this.#Me)return;const t=(this.#Me.offsetParent||document.body).getBoundingClientRect();let r=e.clientX-t.left-this.#we,n=e.clientY-t.top-this.#ye;if(this.#Ee&&this.#De){const e=this.#De.getBoundingClientRect(),i=this.#Me.getBoundingClientRect(),o=e.left-t.left,s=e.top-t.top,{x:a,y:l}=mt.borderWidth(this.#De),u=o+e.width-i.width-l,c=s+e.height-i.height-a;r=Math.max(o,Math.min(r,u)),n=Math.max(s,Math.min(n,c))}this.#Me.style.position="absolute",this.#Me.style.left=`${r}px`,this.#Me.style.top=`${n}px`,navigator.vibrate&&Array.isArray(this.#Le.move)&&navigator.vibrate(this.#Le.move),this.checkDragCollision(e),this.#We("dragging")}execCollision(e){if(this.#ge||!this.#Me)return{inJail:!1,collidedElements:[]};let t=[],r=!0;const n=this.#De?.getBoundingClientRect();if(this.#xe){const i=e.clientX,o=e.clientY;this.#Ae&&this.#De&&n&&(r=i>=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom),t=r?this.#ve?this.getAllCollidedElements(i,o):[this.getCollidedElement(i,o)].filter(Boolean):[]}else{const e=this.#Me.getBoundingClientRect();this.#Ae&&this.#De&&n&&(r=e.left>=n.left&&e.right<=n.right&&e.top>=n.top&&e.bottom<=n.bottom),t=r?this.#ve?this.getAllCollidedElementsByRect(e):[this.getCollidedElementByRect(e)].filter(Boolean):[]}return{inJail:r,collidedElements:t}}#He(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ge||!this.#Se)return;if(this.#Se=!1,!this.#Me)return;this.#P.classList.remove(this.#Ne),document.body.classList.remove(this.#_e),this.#De&&this.#De.classList.remove(this.#je),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd);const{collidedElements:t}=this.execCollision(e);navigator.vibrate&&Array.isArray(this.#Le.end)&&navigator.vibrate(this.#Le.end);const r=this.#Me.style.left,n=this.#Me.style.top;this.#Me&&(this.#be?this.#Me.remove():Object.assign(this.#Me.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#Me=null),this.#Ie&&this.#Ve(),this.#Ie=null,this.#be&&this.#P.classList.remove(this.#ke),this.#Te||(this.#P.style.left=r,this.#P.style.top=n);const i=new CustomEvent("drop",{detail:{targets:t,first:t[0]||null}});this.#P.dispatchEvent(i)}#Ke(e,t){const r=e.getBoundingClientRect();return!(t.right<r.left||t.left>r.right||t.bottom<r.top||t.top>r.bottom)}getAllCollidedElementsByRect(e){if(this.#Fe(),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ce.filter(t=>this.#Ke(t,e))}getCollidedElementByRect(e){if(this.#Fe(),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Ce.find(t=>this.#Ke(t,e))||null}#Je(e,t,r){const n=e.getBoundingClientRect();return t>=n.left&&t<=n.right&&r>=n.top&&r<=n.bottom}getAllCollidedElements(e,t){if(this.#Fe(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ce.filter(r=>this.#Je(r,e,t))}getCollidedElement(e,t){if(this.#Fe(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Ce.find(r=>this.#Je(r,e,t))||null}#We(e){const t=new CustomEvent(e);this.#P.dispatchEvent(t)}getDragging(){return this.#Se}getLockInsideJail(){return this.#Ee}setLockInsideJail(e){if("boolean"!=typeof e)throw new Error("lockInsideJail must be a boolean.");this.#Ee=e}getRevertOnDrop(){return this.#Te}setRevertOnDrop(e){if("boolean"!=typeof e)throw new Error("revertOnDrop must be a boolean.");this.#Te=e}getCollisionByMouse(){return this.#xe}setCollisionByMouse(e){if("boolean"!=typeof e)throw new Error("collisionByMouse must be a boolean.");this.#xe=e}getDropInJailOnly(){return this.#Ae}setDropInJailOnly(e){if("boolean"!=typeof e)throw new Error("dropInJailOnly must be a boolean.");this.#Ae=e}getDefaultZIndex(){return this.#Be}setDefaultZIndex(e){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("Z-index must be a finite number.");this.#Be=e}isMirrorEnabled(){return this.#be}setMirrorEnabled(e){if("boolean"!=typeof e)throw new TypeError("Mirror setting must be a boolean.");this.#be=e}getTarget(){return this.#P}getJail(){return this.#De}getDragProxy(){return this.#Me}getLastCollision(){return this.#Ie}getCollidables(){return[...this.#Ce]}getDragHiddenClass(){return this.#ke}getClassDragging(){return this.#Ne}getClassBodyDragging(){return this.#_e}getClassJailDragging(){return this.#je}getClassJailDragDisabled(){return this.#Oe}getClassDragCollision(){return this.#Re}getVibrations(){return{...this.#Le}}getStartVibration(){return this.#Le.start}getEndVibration(){return this.#Le.end}getCollideVibration(){return this.#Le.collide}getMoveVibration(){return this.#Le.move}isEnabled(){return this.#me}#Fe(){if(this.#ge)throw new Error("This TinyDragger instance has been destroyed and can no longer be used.")}destroy(){this.#ge||(this.disable(),this.#P.removeEventListener("mousedown",this._onMouseDown),this.#P.removeEventListener("touchstart",this._onTouchStart),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),this.#Ie&&this.#Ve(),this.#Me&&(this.#be?this.#Me.remove():Object.assign(this.#Me.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#Me=null),this.#Ce=[],this.#Se=!1,this.#Ie=null,this.#be&&this.#P.classList.remove(this.#ke),this.#P.classList.remove(this.#Ne),document.body.classList.remove(this.#_e),this.#De&&this.#De.classList.remove(this.#je,this.#Oe),this.#ge=!0)}}const yt=gt,wt=class{#Ue=[];#Ge=!1;#Ye=!1;#Qe=[];#Ze(){this.#Ge&&Promise.all(this.#Qe).then(()=>{this.#Ye=!0,this.#Xe(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#Xe(e){this.#Ue.filter(t=>t.domOnly===e).sort((e,t)=>t.priority-e.priority).forEach(e=>this.#et(e)),this.#Ue=this.#Ue.filter(t=>!(t.once&&(!e||t.domOnly)))}#et(e){if("function"==typeof e.filter)try{if(!e.filter())return}catch(e){return void console.warn("[TinyDomReadyManager] Filter error:",e)}try{e.fn()}catch(e){console.error("[TinyDomReadyManager] Handler error:",e)}}_markDomReady(){this.#Ge=!0,this.#Xe(!0),this.#Ze()}init(){if(this.#Ge)throw new Error("[TinyDomReadyManager] init() has already been called.");"interactive"===document.readyState||"complete"===document.readyState?this._markDomReady():document.addEventListener("DOMContentLoaded",()=>this._markDomReady())}addPromise(e){if(!(e instanceof Promise))throw new TypeError("[TinyDomReadyManager] promise must be a valid Promise.");this.#Ye||(this.#Qe.push(e),this.#Ge&&this.#Ze())}onReady(e,{once:t=!0,priority:r=0,filter:n=null,domOnly:i=!1}={}){if("function"!=typeof e)throw new TypeError("[TinyDomReadyManager] fn must be a function.");const o={fn:e,once:t,priority:r,filter:n,domOnly:i};if(i&&this.#Ge)return this.#et(o),void(t||this.#Ue.push(o));!i&&this.#Ye?this.#et(o):this.#Ue.push(o)}isReady(){return this.#Ye}isDomReady(){return this.#Ge}},bt=class{#tt=!1;#rt=!1;#nt=null;#it=100;#ot=null;#st;constructor({audio:e=null,defaultIcon:t=null,bodyLimit:r=100,defaultOnClick:n=function(e){e.preventDefault(),window.focus&&window.focus(),this.close()}}={}){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("audio must be an instance of HTMLAudioElement or null.");if(null!==t&&"string"!=typeof t)throw new TypeError("defaultIcon must be a string or null.");if(!Number.isFinite(r)||r<0)throw new TypeError("bodyLimit must be a non-negative number.");if("function"!=typeof n)throw new TypeError("defaultOnClick must be a function.");this.#nt="string"!=typeof e?e:new Audio(e),this.#ot=t,this.#it=r,this.#st=n}requestPerm(){const e=this;return new Promise((t,r)=>{e.isCompatible()?"default"===Notification.permission?Notification.requestPermission().then(r=>{this.#rt=!0,e.#tt="granted"===r,t(e.#tt)}).catch(r):(this.#rt=!0,e.#tt="granted"===Notification.permission,t(e.#tt)):(this.#rt=!0,e.#tt=!1,t(!1))})}isCompatible(){return"Notification"in window}send(e,t={}){if(!this.#rt)throw new Error("You must call requestPerm() before sending a notification.");if("string"!=typeof e)throw new TypeError("title must be a string.");if("object"!=typeof t||null===t)throw new TypeError("config must be a non-null object.");if(!this.#tt)return null;const{icon:r=this.#ot||void 0,vibrate:n=[200,100,200]}=t,i={...t};"string"==typeof r&&(i.icon=r),Array.isArray(n)&&(i.vibrate=n),"string"==typeof i.body&&(i.body=z(i.body,this.#it));const o=new Notification(e,i);return o.addEventListener("show",()=>{this.#nt instanceof HTMLAudioElement&&(this.#nt.currentTime=0,this.#nt.play().catch(e=>console.error(e)))}),"function"==typeof this.#st&&o.addEventListener("click",this.#st),o}wasPermissionRequested(){return this.#rt}isAllowed(){return this.#tt}getAudio(){return this.#nt}setAudio(e){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("sound must be an instance of HTMLAudioElement or null.");this.#nt="string"!=typeof e?e:new Audio(e)}getBodyLimit(){return this.#it}setBodyLimit(e){if(!Number.isFinite(e)||e<0)throw new TypeError("bodyLimit must be a non-negative number.");this.#it=e}getDefaultAvatar(){return this.#ot}setDefaultAvatar(e){if("string"!=typeof e&&null!==e)throw new TypeError("defaultIcon must be a string or null.");this.#ot=e}getDefaultOnClick(){return this.#st}setDefaultOnClick(e){if("function"!=typeof e)throw new TypeError("defaultOnClick must be a function.");this.#st=e}},vt=class{#at;#lt=null;#ut=[];#ct=100;#ht=new Set;#dt=new Set;#ge=!1;constructor(e=window,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#at=e,this._checkTimer=this._checkTimer.bind(this),this.#at.addEventListener("scroll",this._checkTimer),this.#ct=t}_checkTimer=()=>{this.#lt&&clearTimeout(this.#lt),this.#lt=setTimeout(()=>{this.#lt=null,this.#ft()},this.#ct)};get inactivityTime(){return this.#ct}set inactivityTime(e){if("number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#ct=e}#ft(){if(!this.#ge){for(const e of this.#dt)"function"==typeof e&&e();for(;this.#ut.length;){const e=this.#ut.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#ut.push(e)}onStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#dt.add(e)}offStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#dt.delete(e)}onScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#at.addEventListener("scroll",e),this.#ht.add(e)}offScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#ht.has(e)&&(this.#at.removeEventListener("scroll",e),this.#ht.delete(e))}destroy(){if(!this.#ge){this.#ge=!0,this.#at.removeEventListener("scroll",this._checkTimer);for(const e of this.#ht)this.#at.removeEventListener("scroll",e);this.#ht.clear(),this.#dt.clear()}}},Et=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],Tt=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮"],St=["pudding","bean","snuggle","bloop","jelly","unicorn","floof","giggle","bubble","muffin","puff","pickle","goblin","waffle","sprinkle","cupcake","fizzle","marshmallow","duckling","sock","cloud","teacup","nugget","gnome","hug","moonbean","crayon","jiggle","glitter","carrot","goober"],xt=["wiggles","bounces","flies","splats","scoots","giggles","wigglesnacks","twirls","boops","pops","sings","hugs","floats","glows","flaps","mlems","dances","puddles","nomnoms","wigglejumps","sniffs","tumbles","slides","chirps","burps","sparkles","waddles","rambles","blinks","mews"],At=["fluffy","silly","yummy","squishy","wobbly","magical","tiny","sleepy","wiggly","bubbly","glittery","fuzzy","jiggly","sparkly","giggly","crunchy","goofy","soft","mushy","sweet","loopy","floaty","bonkers","chewy","ticklish","dreamy","pastel","cozy","teensy","grumbly"],It=["Boop!","Wiggle achieved.","Oops, {noun} everywhere!","Tiny {adj} {noun}, big {adj} {noun}.","Snuggle initiated with a {adj} {noun}.","{adj} vibes only, powered by {noun}.","No {noun}, no {noun}.","Bounce first, {verb} later.","Mlem. {verb}. {noun}.","{noun} go brrr and {verb}.","Why not? {noun} did. Then {noun} followed.","A {adj} {noun} just {verb} near the {adj} window.","That {adj} {noun} stole my {noun}!","Look, a {adj} {noun} trying to {verb} again!","Every {noun} deserves a {adj} nap.","The {adj} {noun} is my {adj} spirit animal.","Someone call the {noun}, it’s {verb}ing and {verb}ing again!","Don’t touch the {adj} {noun}. It {verb}s loudly.","{noun} forgot how {noun}s work and just {verb}ed.","There once was a {adj} {noun} who loved to {verb} with a {adj} {noun} all day.","Apparently, {noun}s are banned from {verb}ing and {verb}ing in the {noun} library.","That {adj} noise? Just a {noun} learning to {verb} on a {adj} {noun}.","I saw a {adj} {noun} {verb} so hard, it became a {adj} muffin.","The {adj} {noun} met a {adj} pickle and everything {verb}ed.","{noun}s are like {noun}: {adj}, unpredictable, and wiggly.","Don’t judge a {adj} {noun} by its ability to {verb}, or by its {adj} hat.","All I wanted was peace, but a {adj} {noun} with a {adj} {noun} had other plans.","One {adj} morning, a {adj} {noun} decided it was finally time to {verb}, but halfway through, it tripped on a {noun} and turned into a {adj} marshmallow.","I tried to be {adj} today, but then a {noun} {verb}ed across my {noun} and typed “asdfgh{noun}” repeatedly.","If you think you’ve seen everything, wait until a {adj} {noun} {verb}s on a {noun} wearing {adj} socks with tiny {noun}s.","No one ever believed the stories about the ancient {adj} {noun} who could {verb} with such {adj} grace that entire {noun}s turned pink out of embarrassment.","A curious {adj} {noun} wandered into a {noun} shop, not knowing that its destiny involved twelve {adj} {noun}s, one rubber {noun}, and a suspiciously quiet {adj} llama.","In a land where every {adj} {noun} was made of pudding and the sky was {adj} whipped cream, one brave {adj} {noun} set out to discover the legendary Spoon of {noun}s, facing obstacles like bouncing {noun}s, sassy {noun}s, and the Great Wobble of the {noun}.","Once upon a {adj} time, long before the {noun}s learned to {verb}, there existed a tiny {adj} {noun} who dreamed of swimming in a pool made entirely of {adj} glitter pudding while {verb}ing off-key lullabies to passing {noun}s with monocles.","The Council of {noun}s gathered in {adj} secret when the sacred {adj} {noun} started to {verb} uncontrollably, threatening the entire {adj} dessert-based civilization with spontaneous {noun} jiggles and uncontainable {noun} fits across the {noun}.","Hey... do you ever wonder if {noun}s dream of {noun}s?","Okay but hear me out: what if the {adj} {noun} could actually {verb} backwards?","Can we talk about the {noun} that just {verb}ed and vanished?","So I was talking to a {noun}, and it told me to stop being {adj}. Rude.","Not to alarm you, but there’s a {adj} {noun} behind you doing the {verb}.","Why does this {noun} keep staring at me like I owe it pudding?","Is this a safe space to admit I accidentally {verb}ed a {noun}?","I just walked into the room and someone shouted “{adj} {noun}!” — what did I miss?","Wait... we were supposed to bring a {noun}? No one told me!","Okay but what if the {adj} {noun} has feelings too?","Be honest, do I look like a {noun} that forgot how to {verb}?",'If I say "oops", do I still have to explain why the {noun} is glowing?',"I don’t know what’s going on but I brought snacks and a confused {noun}.","Do you think pudding knows it’s pudding? Just a thought.","Is this about the time I {verb}ed the {adj} {noun} by accident? Because I can explain.","Wait, are we talking about {noun}s or am I on the wrong chat again?",'What is this group even about? I just saw "pudding" and joined.',"Hi! I have no idea what’s happening but I’m here and I brought a {noun}.","I blinked and now there’s a {adj} {noun} in charge of everything.","Can someone please explain why the {noun} is floating and chanting?","Okay who gave the {noun} access to glitter and emotional support pickles?","I came for a calm discussion and now there’s a {adj} battle between {noun}s.","Not sure if I’m early, late, or inside a {noun} dream.","I was gone for 3 minutes and now someone’s riding a {noun} into the pudding realm.","This isn’t the pudding appreciation group, is it? ...oh no.","So... who summoned the {adj} {noun} this time? Be honest.","I came here for vibes and stayed for the {noun}s.","Does anyone else hear faint giggling or is that just the {adj} {noun} again?","I feel like I missed step one, two, and also three of this conversation.","All I asked was “what’s up?” and now I’m emotionally attached to a {noun}.",'Me: "I’ll be normal today." Also me: *{verb}s into a meeting riding a {adj} {noun}*','"It’s just pudding," they said. "It can’t hurt you," they said. They were wrong.',"I said one nice thing to a {noun} and now it follows me everywhere.","Can we take a moment to appreciate how the {adj} {noun} is just vibing?","Who put a tiny hat on the {noun}? Because that’s adorable.","My life has been different ever since the {noun} started {verb}ing.","Raise your hand if you’ve ever been personally attacked by a {adj} {noun}.",'"Don’t be weird," they said. So I became a {noun} instead.',"Do {noun}s have feelings? Asking for a {adj} friend.","I trusted the {noun} and all I got was a glitter-covered sock.","Plot twist: the {adj} {noun} was inside us all along.","The {adj} {noun} {verb} and {verb} all over the {adj} {noun}!","Oops! {noun}s {verb}ed into the {adj} {noun} while {verb}ing crazily.","{adj}, {adj}, and more {adj} {noun}s just {verb}ed by!","Why does the {adj} {noun} keep {verb}ing and {verb}ing without stopping?","Look! A {adj} {noun}, a {adj} {noun}, and a {noun} all {verb}ing together!","Sometimes, the {noun} just {verb}s, then {verb}s again, and never stops being {adj}.","{noun}, {noun}, and {noun} — all {verb}ing and {verb}ing in a {adj} {noun}.","I saw a {adj} {noun} {verb}, then another {noun} {verb}ing with a {adj} {noun}.","The {noun} {verb}s {verb} while the {adj} {noun} {verb}s and the {noun} just {verb}s.","Can a {adj} {noun} {verb} {verb} without a {adj} {noun} watching?","Whoa! The {adj} {noun} just {verb}ed... and then {verb}ed again!","Hey... did you see that {adj} {noun} {verb} over there?","Umm, the {noun} is {verb}ing but also {verb}ing and {verb}ing!","Lol! {noun}s {verb} so {adj}ly, it’s impossible not to giggle.",'"Hey! What’s up?" asked the {adj} {noun}, who {verb}ed loudly.','"I’m just a {adj} {noun} trying to {verb}, you know?"','"Did you see the {adj} {noun} that just {verb}ed in the pudding?"','"No way! The {noun} {verb}s better than me!"','"Wait, the {adj} {noun} said it would {verb}, but it {verb}ed instead!"',"Once upon a {adj} {noun}, a group of {adj} {noun}s {verb}ed through the {adj} forest, singing {adj} songs and eating {noun}s made of pudding.","The legend tells of a {adj} {noun} who could {verb} faster than any {noun} ever seen, leaving trails of {adj} sparkles behind.","Every day, the {adj} {noun} would {verb} around the {adj} meadow, trying to convince the {noun}s to join the grand pudding party.","No one knows why the {adj} {noun} suddenly {verb}ed and then {verb}ed again, but everyone agrees it was the cutest thing they ever saw.","In the kingdom of {adj} {noun}s, only the bravest {noun} dared to {verb} the giant pudding monster, armed with nothing but {adj} smiles and jellybeans.","{adj} {noun} {verb} {verb} {verb} {noun} {verb} {adj} {noun} {verb} {noun}!","{noun} {noun} {verb} {adj} {noun} and then {verb} {verb} the {adj} {noun}.","{verb} the {adj} {noun}, then {verb} the {noun} while {verb}ing {adj}ly.","Can the {adj} {noun} {verb} and {verb} the {adj} {noun} at the same time?","{noun} {verb} {noun} {verb}, but the {adj} {noun} {verb}s better.","Boop! The {adj} {noun} just {verb}ed in the pudding.","Bloop bloop, the {noun} is {verb}ing all over again!","Mlem mlem, a {adj} {noun} {verb}s quietly in the corner.","Splat! {noun} {verb}ed right on the {adj} {noun}.","Yum! A {adj} {noun} just {verb}ed in my mouth.","Do {noun}s really {verb} when nobody’s watching?","Why does the {adj} {noun} always {verb} at midnight?","Can a {noun} be too {adj} to {verb} properly?","Is it normal for a {adj} {noun} to {verb} three times in a row?","Who taught the {noun} to {verb} like that?","Wait, did the {adj} {noun} just {verb} itself?","I can’t believe the {noun} {verb}ed into a {adj} {noun}!","Suddenly, a {adj} {noun} appeared and started to {verb} wildly.","That {noun} was {verb}ing so {adj}ly it broke the pudding meter.","Everyone’s talking about the {adj} {noun} that {verb}ed out of nowhere."];class Ct{static#pt=Et;static#mt=Tt;static#gt=St;static#yt=xt;static#wt=At;static#bt=It;static#vt(e,t){if(!Array.isArray(e))throw new TypeError(`${t} must be an array of strings`);if(!e.every(e=>"string"==typeof e))throw new TypeError(`${t} must contain only strings`);if(0===e.length)throw new Error(`${t} cannot be empty`)}static get defaultWords(){return[...this.#pt]}static set defaultWords(e){this.#vt(e,"defaultWords"),this.#pt=[...e]}static get defaultEmojis(){return[...this.#mt]}static set defaultEmojis(e){this.#vt(e,"defaultEmojis"),this.#mt=[...e]}static get defaultNouns(){return[...this.#gt]}static set defaultNouns(e){this.#vt(e,"defaultNouns"),this.#gt=[...e]}static get defaultVerbs(){return[...this.#yt]}static set defaultVerbs(e){this.#vt(e,"defaultVerbs"),this.#yt=[...e]}static get defaultAdjectives(){return[...this.#wt]}static set defaultAdjectives(e){this.#vt(e,"defaultAdjectives"),this.#wt=[...e]}static get defaultTemplates(){return[...this.#bt]}static set defaultTemplates(e){this.#vt(e,"defaultTemplates"),this.#bt=[...e]}config={minLength:10,maxLength:300,readable:!0,useEmojis:!0,includeNumbers:!0,includeSymbols:!0,allowWeirdSpacing:!1,emojiSet:[],wordSet:[],mode:"mixed",grammar:{templates:[],nouns:[],verbs:[],adjectives:[]},repeatWords:!0,emojiPlacement:"inline",line:{minLength:20,maxLength:120,emojiChance:.3}};constructor(e={}){this.symbols="!@#$%^&*()-_=+[]{}|;:,.<>?/\\~".split("");const{minLength:t,maxLength:r,readable:n,useEmojis:i,includeNumbers:o,includeSymbols:s,allowWeirdSpacing:a,emojiSet:l,wordSet:u,mode:c,grammar:h,repeatWords:d,emojiPlacement:f,paragraphs:p,line:m}=e;if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.minLength must be an integer >= 1");if(void 0!==r&&(!Number.isInteger(r)||r<1))throw new TypeError("config.maxLength must be an integer >= 1");if(void 0!==t&&void 0!==r&&t>r)throw new RangeError("config.minLength cannot be greater than config.maxLength");if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("config.readable must be a boolean");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("config.useEmojis must be a boolean");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("config.includeNumbers must be a boolean");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("config.includeSymbols must be a boolean");if(void 0!==a&&"boolean"!=typeof a)throw new TypeError("config.allowWeirdSpacing must be a boolean");if(void 0!==l&&!Array.isArray(l))throw new TypeError("config.emojiSet must be an array of strings");if(void 0!==u&&!Array.isArray(u))throw new TypeError("config.wordSet must be an array of strings");if(void 0!==c&&!["mixed","readable","chaotic","natural"].includes(c))throw new RangeError('config.mode must be one of: "mixed", "readable", "chaotic", "natural');if(void 0!==h){if("object"!=typeof h||null===h)throw new TypeError("config.grammar must be an object");const{templates:e,nouns:t,verbs:r,adjectives:n}=h;if(void 0!==e&&!Array.isArray(e))throw new TypeError("config.grammar.templates must be an array of strings");if(void 0!==t&&!Array.isArray(t))throw new TypeError("config.grammar.nouns must be an array of strings");if(void 0!==r&&!Array.isArray(r))throw new TypeError("config.grammar.verbs must be an array of strings");if(void 0!==n&&!Array.isArray(n))throw new TypeError("config.grammar.adjectives must be an array of strings")}if(void 0!==d&&"boolean"!=typeof d)throw new TypeError("config.repeatWords must be a boolean");if(void 0!==f&&!["inline","end","none"].includes(f))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==p){if("object"!=typeof p)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:t}=p;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.paragraphs.min must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.paragraphs.max must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.paragraphs.min cannot be greater than config.paragraphs.max")}if(void 0!==m){if("object"!=typeof m||null===m)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:t,emojiChance:r}=m;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.line.minLength must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.line.maxLength must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.line.minLength cannot be greater than config.line.maxLength");if(void 0!==r&&("number"!=typeof r||r<0||r>1))throw new RangeError("config.line.emojiChance must be a number between 0 and 1")}this.config.emojiSet=[...Ct.#mt],this.config.wordSet=[...Ct.#pt],this.config.grammar.templates=[...Ct.#bt],this.config.grammar.nouns=[...Ct.#gt],this.config.grammar.verbs=[...Ct.#yt],this.config.grammar.adjectives=[...Ct.#wt],Object.assign(this.config,e)}configure(e={}){return Object.assign(this.config,e),this}setGrammarTemplates(...e){return this.config.grammar.templates=e.flat(),this}addGrammarTemplates(...e){return this.config.grammar.templates.push(...e.flat()),this}setGrammarNouns(...e){return this.config.grammar.nouns=e.flat(),this}addGrammarNouns(...e){return this.config.grammar.nouns.push(...e.flat()),this}setGrammarVerbs(...e){return this.config.grammar.verbs=e.flat(),this}addGrammarVerbs(...e){return this.config.grammar.verbs.push(...e.flat()),this}setGrammarAdjectives(...e){return this.config.grammar.adjectives=e.flat(),this}addGrammarAdjectives(...e){return this.config.grammar.adjectives.push(...e.flat()),this}removeGrammarTemplates(...e){const t=new Set(e.flat());return this.config.grammar.templates=this.config.grammar.templates.filter(e=>!t.has(e)),this}removeGrammarNouns(...e){const t=new Set(e.flat());return this.config.grammar.nouns=this.config.grammar.nouns.filter(e=>!t.has(e)),this}removeGrammarVerbs(...e){const t=new Set(e.flat());return this.config.grammar.verbs=this.config.grammar.verbs.filter(e=>!t.has(e)),this}removeGrammarAdjectives(...e){const t=new Set(e.flat());return this.config.grammar.adjectives=this.config.grammar.adjectives.filter(e=>!t.has(e)),this}setWords(...e){return this.config.wordSet=e.flat(),this}addWords(...e){return this.config.wordSet.push(...e.flat()),this}removeWords(...e){const t=new Set(e.flat());return this.config.wordSet=this.config.wordSet.filter(e=>!t.has(e)),this}setEmojis(...e){return this.config.emojiSet=e.flat(),this}addEmojis(...e){return this.config.emojiSet.push(...e.flat()),this}removeEmojis(...e){const t=new Set(e.flat());return this.config.emojiSet=this.config.emojiSet.filter(e=>!t.has(e)),this}_getRandomItem(e){return e[Math.floor(Math.random()*e.length)]}_generateChunk(){const{wordSet:e,emojiSet:t,includeNumbers:r,includeSymbols:n,useEmojis:i,readable:o,mode:s,emojiPlacement:a}=this.config;if("natural"===s)return this._generateNaturalSentence();const l=[];return(o||"readable"===s||"mixed"===s)&&l.push(this._getRandomItem(e)),"chaotic"!==s&&"mixed"!==s||l.push(Math.random().toString(36).slice(2)),r&&l.push(Math.floor(99999*Math.random()).toString()),n&&l.push(this._getRandomItem(this.symbols)),"inline"===a&&i&&t.length&&l.push(this._getRandomItem(t)),this._getRandomItem(l)}_generateNaturalSentence(){const{templates:e,nouns:t,verbs:r,adjectives:n}=this.config.grammar;return this._getRandomItem(e).replace(/{noun}/g,()=>this._getRandomItem(t)).replace(/{verb}/g,()=>this._getRandomItem(r)).replace(/{adj}/g,()=>this._getRandomItem(n))}_generateLine(e,t){const{allowWeirdSpacing:r,repeatWords:n,readable:i,emojiSet:o,useEmojis:s,emojiPlacement:a,line:l}=this.config,u=[];for(t??=new Set;u.join(" ").length<e;){let e=this._generateChunk();!n&&t.has(e)||(t.add(e),r&&(Math.random()<.1&&(e="\n"+e),Math.random()<.1&&(e=" "+e),Math.random()<.05&&(e=e.toUpperCase())),u.push(e))}let c=u.join(i?" ":"");return"end"===a&&s&&o.length&&Math.random()<(l?.emojiChance||0)&&(c+=" "+this._getRandomItem(o)),c}_generateParagraphLines(e){const{line:t}=this.config,r=[],n=new Set;let i=0;for(;i<e;){const o=Math.floor(Math.random()*(t.maxLength-t.minLength+1)+t.minLength),s=Math.min(o,e-i);r.push(this._generateLine(s,n)),i+=s}return r}generate(){const{minLength:e,maxLength:t,paragraphs:r}=this.config,n=Math.floor(Math.random()*(t-e+1))+e;if(r&&"object"==typeof r){const e=Math.floor(Math.random()*(r.max-r.min+1))+r.min,t=Math.floor(n/e),i=[];for(let r=0;r<e;r++){const e=this._generateParagraphLines(t);i.push(e.join("\n"))}return i.join("\n\n")}return this._generateParagraphLines(n).join("\n")}}const Mt=Ct,Lt=class{#Et=new Map;#Tt=10;#St=!1;#xt(e,t){if("string"==typeof e)return[e];if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return e;throw new TypeError(`${t}(event): event must be a string or string[]`)}setThrowOnMaxListeners(e){if("boolean"!=typeof e)throw new TypeError("setThrowOnMaxListeners(value): value must be a boolean");this.#St=e}getThrowOnMaxListeners(){return this.#St}#At(e,t,{once:r=!1}={}){let n=this.#Et.get(e);Array.isArray(n)||(n=[],this.#Et.set(e,n)),n.unshift({handler:t,config:{once:r}});const i=this.#Tt;if(i>0&&n.length>i){const t=`Possible memory leak detected. ${n.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#St)throw new Error(t);console.warn(t)}}prependListener(e,t){const r=this.#xt(e,"prependListener");if("function"!=typeof t)throw new TypeError("prependListener(event, handler): handler must be a function");for(const e of r)this.#At(e,t)}prependListenerOnce(e,t){const r=this.#xt(e,"prependListenerOnce");if("function"!=typeof t)throw new TypeError("prependListenerOnce(event, handler): handler must be a function");const n=[];for(const e of r){const r=(...n)=>{this.off(e,r),t(...n)};this.#At(e,r,{once:!0}),n.push(r)}return n}#It(e,t,{once:r=!1}={}){const n=this.#xt(e,"on");for(const e of n){let n=this.#Et.get(e);Array.isArray(n)||(n=[],this.#Et.set(e,n)),n.push({handler:t,config:{once:r}});const i=this.#Tt;if(i>0&&n.length>i){const t=`Possible memory leak detected. ${n.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#St)throw new Error(t);console.warn(t)}}}on(e,t){if("function"!=typeof t)throw new TypeError("on(event, handler): handler must be a function");return this.#It(e,t)}once(e,t){const r=this.#xt(e,"once");if("function"!=typeof t)throw new TypeError("once(event, handler): handler must be a function");const n=[];for(const e of r){const r=(...n)=>{this.off(e,r),t(...n)};this.#It(e,r,{once:!0}),n.push(r)}return n}appendListener(e,t){return this.on(e,t)}appendListenerOnce(e,t){return this.once(e,t)}off(e,t){const r=this.#xt(e,"off");if("function"!=typeof t)throw new TypeError("off(event, handler): handler must be a function");for(const e of r){const r=this.#Et.get(e);if(!Array.isArray(r))continue;const n=r.findIndex(e=>e.handler===t);-1!==n&&r.splice(n,1),0===r.length&&this.#Et.delete(e)}}offAll(e){const t=this.#xt(e,"offAll");for(const e of t)this.#Et.delete(e)}offAllTypes(){this.#Et.clear()}listenerCount(e){if("string"!=typeof e)throw new TypeError("listenerCount(event): event name must be a string");const t=this.#Et.get(e);return Array.isArray(t)?t.length:0}listeners(e){if("string"!=typeof e)throw new TypeError("listeners(event): event name must be a string");const t=this.#Et.get(e);return Array.isArray(t)?[...t].filter(e=>!e.config.once).map(e=>e.handler):[]}onceListeners(e){if("string"!=typeof e)throw new TypeError("onceListeners(event): event name must be a string");const t=this.#Et.get(e);return Array.isArray(t)?[...t].filter(e=>e.config.once).map(e=>e.handler):[]}allListeners(e){if("string"!=typeof e)throw new TypeError("allListeners(event): event name must be a string");const t=this.#Et.get(e);return Array.isArray(t)?[...t].map(e=>e.handler):[]}eventNames(){return[...this.#Et.keys()]}emit(e,...t){const r=this.#xt(e,"emit"),n=[];for(const e of r){const r=this.#Et.get(e);Array.isArray(r)&&0!==r.length?(r.forEach(e=>e.handler(...t)),n.push(!0)):n.push(!1)}return n}setMaxListeners(e){if(!Number.isInteger(e)||e<0)throw new TypeError("setMaxListeners(n): n must be a non-negative integer");this.#Tt=e}getMaxListeners(){return this.#Tt}};class Dt{static Utils={...e,TinyHtml:mt};#Ct=new Lt;setThrowOnMaxListeners(e){return this.#Ct.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Ct.getThrowOnMaxListeners()}prependListener(e,t){return this.#Ct.prependListener(e,t)}prependListenerOnce(e,t){return this.#Ct.prependListenerOnce(e,t)}appendListener(e,t){return this.#Ct.appendListener(e,t)}appendListenerOnce(e,t){return this.#Ct.appendListenerOnce(e,t)}on(e,t){return this.#Ct.on(e,t)}once(e,t){return this.#Ct.once(e,t)}off(e,t){return this.#Ct.off(e,t)}offAll(e){return this.#Ct.offAll(e)}offAllTypes(){return this.#Ct.offAllTypes()}listenerCount(e){return this.#Ct.listenerCount(e)}listeners(e){return this.#Ct.listeners(e)}onceListeners(e){return this.#Ct.onceListeners(e)}allListeners(e){return this.#Ct.allListeners(e)}eventNames(){return this.#Ct.eventNames()}emit(e,...t){return this.#Ct.emit(e,...t)}setMaxListeners(e){return this.#Ct.setMaxListeners(e)}getMaxListeners(){return this.#Ct.getMaxListeners()}#Mt=new WeakMap;#Lt=new WeakMap;#Dt=new WeakMap;#kt=new WeakMap;#Nt=new WeakMap;#_t=new WeakMap;#jt=null;#Ot=null;#Rt=new Set(["IMG","IFRAME","VIDEO"]);#Bt=null;#$t=!1;#Pt=!1;#Ht=!1;#Ft=!1;#Wt=!1;#zt=!1;#qt=!1;#Vt=!1;#Kt="";#Jt=!1;#ge=!1;#Ut=!1;#Gt=!1;#Yt=!1;#Qt=!1;#Zt=0;#Xt=0;#er=0;#tr=0;#rr=0;#nr;#P;#ir=new Set;constructor(e,{extraScrollBoundary:t=0,autoScrollBottom:r=!0,observeMutations:n=!0,preserveScrollOnLayoutShift:i=!0,debounceTime:o=100,querySelector:s=null,attributeFilter:a=["class","style","src","data-*","height","width"]}={}){if(!(e instanceof Element||e===window))throw new TypeError("TinySmartScroller: 'target' must be a DOM Element or 'window', but got "+typeof e);if("number"!=typeof t||Number.isNaN(t))throw new TypeError(`TinySmartScroller: 'extraScrollBoundary' must be a valid number, received ${t}`);if("boolean"!=typeof r)throw new TypeError("TinySmartScroller: 'autoScrollBottom' must be a boolean, received "+typeof r);if("boolean"!=typeof n)throw new TypeError("TinySmartScroller: 'observeMutations' must be a boolean, received "+typeof n);if("boolean"!=typeof i)throw new TypeError("TinySmartScroller: 'preserveScrollOnLayoutShift' must be a boolean, received "+typeof i);if("number"!=typeof o||o<0||Number.isNaN(o))throw new TypeError(`TinySmartScroller: 'debounceTime' must be a non-negative number, received ${o}`);if(null!==s&&"string"!=typeof s)throw new TypeError("TinySmartScroller: 'querySelector' must be a string or null, received "+typeof s);if(!(null===a||Array.isArray(a)||a instanceof Set))throw new TypeError("TinySmartScroller: 'attributeFilter' must be an array, Set, or null. Got "+typeof a);let l;this.#P=e instanceof Window?document.documentElement:e,this.#Jt=e instanceof Window,this.#Gt=r,this.#Yt=n,this.#Qt=i,this.#Zt=o,this.#rr=t,this.#Kt=s||"",this.#nr=new Set(a||void 0),this.#Bt=()=>{this._scrollDataUpdater(),clearTimeout(l),l=setTimeout(()=>this._onScroll(),this.#Zt)},(this.#Jt?window:this.#P).addEventListener("scroll",this.#Bt,{passive:!0}),this.#Yt&&(this._observeMutations(),this._observeResizes(this.#P.children)),this._scrollDataUpdater()}getSimpleOnHeight(e=[]){if(!Array.isArray(e))throw new TypeError("getSimpleOnHeight(filter): filter must be an array of tag names");return(t,r,n)=>{if(e.length>0&&!e.includes(t.tagName)||n.now!==n.old)return;const i=r.old;return{height:r.now.height-i.height,width:0}}}addSimpleOnHeight(e){if(!Array.isArray(e))throw new TypeError("addSimpleOnHeight(filter): filter must be an array of tag names");const t=this.getSimpleOnHeight(e);return this.onSize(t),t}getLoadTags(){return Array.from(this.#Rt)}addLoadTag(e){if("string"!=typeof e)throw new TypeError("addLoadTag(tag): tag must be a string");this.#Rt.add(e.toUpperCase())}removeLoadTag(e){if("string"!=typeof e)throw new TypeError("removeLoadTag(tag): tag must be a string");this.#Rt.delete(e.toUpperCase())}hasLoadTag(e){if("string"!=typeof e)throw new TypeError("hasLoadTag(tag): tag must be a string");return this.#Rt.has(e.toUpperCase())}resetLoadTags(e=!1){if("boolean"!=typeof e)throw new TypeError("resetLoadTags(addDefault): addDefault must be a boolean");this.#Rt.clear(),e&&(this.#Rt.add("IMG"),this.#Rt.add("IFRAME"),this.#Rt.add("VIDEO"))}getAttributeFilters(){return Array.from(this.#nr)}addAttributeFilter(e){if("string"!=typeof e)throw new TypeError("addAttributeFilter(attr): attr must be a string");this.#nr.add(e)}removeAttributeFilter(e){if("string"!=typeof e)throw new TypeError("removeAttributeFilter(attr): attr must be a string");this.#nr.delete(e)}hasAttributeFilter(e){if("string"!=typeof e)throw new TypeError("hasAttributeFilter(attr): attr must be a string");return this.#nr.has(e)}resetAttributeFilters(e=!1){if("boolean"!=typeof e)throw new TypeError("resetAttributeFilters(addDefault): addDefault must be a boolean");this.#nr.clear(),e&&["class","style","src","data-*","height","width"].forEach(e=>this.#nr.add(e))}onSize(e){if(!this.#ge){if("function"!=typeof e)throw new TypeError("onSize(handler): handler must be a function");this.#ir.add(e)}}offSize(e){if(!this.#ge){if("function"!=typeof e)throw new TypeError("offSize(handler): handler must be a function");this.#ir.delete(e)}}_scrollDataUpdater(){const e=new Map;return this.#P.querySelectorAll(this.#Kt||"*").forEach(t=>{const r=this.#Dt.get(t)??!1;this.#kt.set(t,r);const n=mt.isInContainer(this.#P,t);this.#Dt.set(t,n),e.set(t,{oldIsVisible:r,isVisible:n})}),e}_onScroll(){if(this.#ge)return;const e=this._scrollDataUpdater(),t=this.#P,r=t.scrollTop,n=t.scrollHeight,i=t.clientHeight,o={scrollTop:r,scrollHeight:n,clientHeight:i};let s=null,a=null;const l=0===r,u=r+i>=n-1,c=r<=0+this.#rr,h=r+i>=n-1-this.#rr;l&&u?s="all":l?s="top":u&&(s="bottom"),c&&h?a="all":c?a="top":h&&(a="bottom"),this.#Pt=this.#zt??!1,this.#$t=this.#Wt??!1,this.#Ht=this.#qt??!1,this.#Ft=this.#Vt??!1,this.#zt=l,this.#Wt=u,this.#qt=c,this.#Vt=h,this.#Ut=!(this.#Gt&&this.#Wt),this.#tr=n-r-i,this.emit("onScrollBoundary",{status:s,...o,scrollCache:e}),this.emit("onExtraScrollBoundary",{status:a,...o,scrollCache:e}),this.#Ut?this.emit("onScrollPause",{...o,scrollCache:e}):this.emit("onAutoScroll",{...o,scrollCache:e})}_fixScroll(e=[]){if(this.#ge)return;if(!Array.isArray(e))throw new TypeError("_fixScroll: targets must be an array of Elements");const t=this.#P.scrollHeight,r=this.#P.scrollTop,n=this.#P.scrollHeight-this.#P.scrollTop-this.#P.clientHeight,i=this.#P.scrollHeight-t,o=()=>{const t={height:0,width:0};for(const r of e){const e=this.#Mt.get(r)||{height:0,width:0},n=this.#Lt.get(r)||{height:0,width:0};this.#ir.forEach(i=>{const o=i(r,{old:e,now:n},{old:this.#er,now:this.#Xt});if(this.#Dt.get(r)||this.#Nt.get(r)){if(void 0!==o&&"object"!=typeof o)throw new Error("_fixScroll: size filter must return an object or undefined");if(void 0===o)return;t.height=o.height,t.width=o.width}})}if("number"!=typeof t.height&&t.height<0)throw new Error("_fixScroll: invalid scrollSize.height value");if("number"!=typeof t.width&&t.width<0)throw new Error("_fixScroll: invalid scrollSize.width value");if(0!==t.height||0!==t.width)for(const t of e)this.#Nt.set(t,this.#Dt.get(t)??!1),this.#_t.set(t,this.#kt.get(t)??!1);return t};if(this.#er>0&&mt.hasScroll(this.#P).v&&this.#Gt&&this.#Qt&&!this.#Wt&&!this.#zt){const e=o();this.#P.scrollTop=r+i+e.height,e.width>0&&(this.#P.scrollLeft=this.#P.scrollLeft+e.width)}else!this.#Ut&&this.#Gt?(o(),this.scrollToBottom()):this.#Gt||this.#Wt||(o(),this.#P.scrollTop=this.#P.scrollHeight-this.#P.clientHeight-n)}_observeMutations(){this.#Ot=new MutationObserver(e=>{this.#ge||(this._scrollDataUpdater(),this.#er=this.#Xt,this.#Xt=this.#P.childElementCount,e.forEach(e=>{e.addedNodes.forEach(e=>{if(e instanceof Element&&1===e.nodeType&&(this._observeResizes([e]),this._listenLoadEvents(e),this.#Kt)){const t=e.querySelectorAll(this.#Kt);this._observeResizes(t),this._listenLoadEvents(t)}})}),this._fixScroll())}),this.#Ot.observe(this.#P,{childList:!0,subtree:!0,attributes:!0,attributeFilter:this.#nr.size>0?Array.from(this.#nr):void 0})}_observeResizes(e){this.#jt||(this.#jt=new ResizeObserver(e=>{if(this.#ge)return;this._scrollDataUpdater();const t=[];for(const r of e){const e=r.target,n=this.#Lt.get(e);n&&this.#Mt.set(e,n);const{width:i,height:o}=r.contentRect;this.#Lt.set(e,{width:i,height:o}),t.push(e)}this._fixScroll(t)})),Array.from(e).forEach(e=>{if(!this.#jt)throw new Error("_observeResizes: ResizeObserver instance is not initialized");this.#jt.observe(e)})}_listenLoadEvents(e){this.#ge||(e instanceof NodeList?Array.from(e):[e]).forEach(e=>{this.#Rt.has(e.tagName)&&(e.complete||e.addEventListener("load",()=>{this._scrollDataUpdater(),!this.#Ut&&this.#Gt&&this.scrollToBottom()}))})}get target(){return this.#P}getOldSize(e){return this.#Mt.get(e)??null}getNewSize(e){return this.#Lt.get(e)??null}wasVisible(e){return this.#kt.get(e)??!1}isVisible(e){return this.#Dt.get(e)??!1}wasTimedVisible(e){return this.#_t.get(e)??!1}isTimedVisible(e){return this.#Nt.get(e)??!1}setExtraScrollBoundary(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("setExtraScrollBoundary(value): value must be a valid number");this.#rr=e}getExtraScrollBoundary(){return this.#rr}getLastKnownScrollBottomOffset(){return this.#tr}scrollToBottom(){this.#P.scrollTop=this.#P.scrollHeight}scrollToTop(){this.#P.scrollTop=0}isAtCustomBottom(){return this.#Vt}isAtCustomTop(){return this.#qt}isAtBottom(){return this.#Wt}isAtTop(){return this.#zt}isPastAtBottom(){return this.#$t}isPastAtTop(){return this.#Pt}isPastAtCustomTop(){return this.#Ht}isPastAtCustomBottom(){return this.#Ft}isScrollPaused(){return this.#Ut}isWindow(){return this.#Jt}isDestroyed(){return this.#ge}getAutoScrollBottom(){return this.#Gt}getObserveMutations(){return this.#Yt}getPreserveScrollOnLayoutShift(){return this.#Qt}getDebounceTime(){return this.#Zt}getElemAmount(){return this.#Xt}getPrevElemAmount(){return this.#er}getQuerySelector(){return this.#Kt}destroy(){if(this.#ge)return;this.#ge=!0,this.#Ot&&(this.#Ot.disconnect(),this.#Ot=null),this.#jt&&(this.#jt.disconnect(),this.#jt=null);const e=this.#Jt?window:this.#P;this.#Bt&&e.removeEventListener("scroll",this.#Bt),this.#Mt=new WeakMap,this.#Lt=new WeakMap,this.#Dt=new WeakMap,this.#kt=new WeakMap,this.#Nt=new WeakMap,this.#_t=new WeakMap,this.#Ct.offAllTypes(),this.#ir.clear(),this.#Rt.clear()}}const kt=Dt,Nt=class{#G;#or;#sr;constructor(e,{openTag:t="[",closeTag:r="]"}={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new TypeError("Element must be an input or textarea.");if("string"!=typeof t)throw new TypeError("openTag must be a string.");if("string"!=typeof r)throw new TypeError("closeTag must be a string.");this.#G=e,this.#or=t,this.#sr=r}getOpenTag(){return this.#or}getCloseTag(){return this.#sr}setOpenTag(e){if("string"!=typeof e)throw new TypeError("Open tag must be a string.");this.#or=e}setCloseTag(e){if("string"!=typeof e)throw new TypeError("Close tag must be a string.");this.#sr=e}ensureFocus(){return document.activeElement!==this.#G&&this.#G.focus(),this}focus(){return this.#G.focus(),this}getSelectionRange(){return{start:this.#G.selectionStart??NaN,end:this.#G.selectionEnd??NaN}}setSelectionRange(e,t,r=!0){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("start and end must be numbers.");if("boolean"!=typeof r)throw new TypeError("preserveScroll must be a boolean.");const n=this.#G.scrollTop,i=this.#G.scrollLeft;return this.#G.setSelectionRange(e,t),r&&(this.#G.scrollTop=n,this.#G.scrollLeft=i),this}getValue(){return this.#G.value}setValue(e){if("string"!=typeof e)throw new TypeError("Value must be a string.");return this.#G.value=e,this}getSelectedText(){const{start:e,end:t}=this.getSelectionRange();return this.#G.value.slice(e,t)}insertText(e,{newCursor:t="end",autoSpacing:r=!1,autoSpaceLeft:n=r,autoSpaceRight:i=r}={}){if("string"!=typeof e)throw new TypeError("Text must be a string.");if(!["start","end","preserve"].includes(t))throw new TypeError("newCursor must be one of 'start', 'end', or 'preserve'.");if("boolean"!=typeof r)throw new TypeError("autoSpacing must be a boolean.");if("boolean"!=typeof n)throw new TypeError("autoSpaceLeft must be a boolean.");if("boolean"!=typeof i)throw new TypeError("autoSpaceRight must be a boolean.");const{start:o,end:s}=this.getSelectionRange(),a=this.#G.value,l=a[o-1]||"",u=a[s]||"",c=`${n&&l&&!/\s/.test(l)?" ":""}${e}${i&&u&&!/\s/.test(u)?" ":""}`,h=a.slice(0,o)+c+a.slice(s);this.setValue(h);let d=o;return"end"===t?d=o+c.length:"preserve"===t&&(d=o),this.setSelectionRange(d,d),this}deleteSelection(){return this.insertText(""),this}transformSelection(e){if("function"!=typeof e)throw new TypeError("transformer must be a function.");const{start:t}=this.getSelectionRange(),r=e(this.getSelectedText());return this.insertText(r),this.setSelectionRange(t,t+r.length),this}surroundSelection(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("prefix and suffix must be strings.");const r=this.getSelectedText();return this.insertText(`${e}${r}${t}`),this}moveCaret(e){if("number"!=typeof e)throw new TypeError("offset must be a number.");const{start:t}=this.getSelectionRange(),r=Math.max(0,t+e);return this.setSelectionRange(r,r),this}selectAll(){return this.setSelectionRange(0,this.#G.value.length),this}expandSelection(e,t){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("before and after must be numbers.");const{start:r,end:n}=this.getSelectionRange(),i=Math.max(0,r-e),o=Math.min(this.#G.value.length,n+t);return this.setSelectionRange(i,o),this}replaceAll(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const r=this.#G.value.replace(e,t);return this.setValue(r),this}replaceInSelection(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const{start:r,end:n}=this.getSelectionRange(),i=this.#G.value,o=i.slice(r,n).replace(e,t),s=i.slice(0,r)+o+i.slice(n);return this.setValue(s),this.setSelectionRange(r,r+o.length),this}toggleCode(e){if("string"!=typeof e)throw new TypeError("codeName must be a string.");const t=this.getSelectedText();if(t.startsWith(e)&&t.endsWith(e)){const r=t.slice(e.length,t.length-e.length);this.insertText(r)}else this.insertText(`${e}${t}${e}`);return this}_insertAttr(e){let t="";if(Array.isArray(e)){if(!e.every(e=>"string"==typeof e))throw new TypeError("All entries in attributes array must be strings.");t=e.map(e=>`${e}`).join(" ")}else{if("object"!=typeof e||null===e)throw new TypeError("attributes must be an object or an array of strings.");t=Object.entries(e).map(([e,t])=>{if("string"!=typeof t)throw new TypeError("All entries in attributes object must be strings.");return`${e}${t.length>0?`="${t}"`:""}`}).join(" ")}return t}wrapWithTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),n=r?`${this.#or}${e} ${r}${this.#sr}`:`${this.#or}${e}${this.#sr}`,i=`${this.#or}/${e}${this.#sr}`;return this.surroundSelection(n,i),this}insertTag(e,t="",r={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");if("string"!=typeof t)throw new TypeError("content must be a string.");const n=this._insertAttr(r),i=n?`${this.#or}${e} ${n}${this.#sr}`:`${this.#or}${e}${this.#sr}`,o=`${this.#or}/${e}${this.#sr}`;return this.insertText(`${i}${t}${o}`),this}insertSelfClosingTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),n=r?`${this.#or}${e} ${r}${this.#sr}`:`${this.#or}${e}${this.#sr}`;return this.insertText(n),this}toggleTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this.getSelectedText(),n=new RegExp(`^\\[${e}(\\s+[^\\]]*)?\\]`),i=new RegExp(`\\[/${e}\\]$`),o=n.test(r),s=i.test(r);if(o&&s){const e=r.replace(n,"").replace(i,"");this.insertText(e)}else{const n=this._insertAttr(t),i=n?`${this.#or}${e} ${n}${this.#sr}`:`${this.#or}${e}${this.#sr}`,o=`${this.#or}/${e}${this.#sr}`;this.insertText(`${i}${r}${o}`)}return this}},_t=class{#ar=!1;#lr=!1;#ur=null;#cr=null;constructor(){void 0!==navigator.clipboard&&null!==navigator.clipboard&&(this.#lr=!0,this.#ur=e=>navigator.clipboard.writeText(e),this.#cr=e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})])),this.#ar=void 0!==document.execCommand&&null!==document.execCommand}setCopyText(e){if("function"!=typeof e)throw new TypeError("setCopyText expected a function that returns Promise<void>.");this.#ur=e}setCopyBlob(e){if("function"!=typeof e)throw new TypeError("setCopyBlob expected a function that returns Promise<void>.");this.#cr=e}copyText(e){if("string"!=typeof e)throw new TypeError("copyText expected a string.");if(this.#ur)return this.#ur(e);if(this.#ar){const t=document.body,r=document.createElement("input");return r.style.position="fixed",r.style.opacity="0",r.value=e,t.append(r),r.select(),r.setSelectionRange(0,99999),document.execCommand("Copy"),r.remove(),new Promise(e=>e(void 0))}throw new Error("Clipboard API not found!")}copyBlob(e){if(!(e instanceof Blob))throw new TypeError("copyBlob expected a Blob instance.");return new Promise((t,r)=>{if(this.#cr)return this.#cr(e).then(t).catch(r);throw new Error("Clipboard API not found!")})}_handleBlob(e,t){return t.getType(e)}_handleText(e,t){return this._handleBlob(e,t).then(e=>e.text())}_readData(e=0,t=null,r=null,n=!1){return new Promise((i,o)=>{this._read(e).then(s=>{if(!s)return i(null);const a=[];let l=!0;const u=async(e,i)=>{if(l)if(null!==t&&"custom"!==t||"string"!=typeof r||!(!n&&e.startsWith(r)||n&&e===r))if(null!==t&&"text"!==t||"text/plain"!==e){if(null===t){l=!1;const t=await this._handleBlob(e,i);t&&a.push(t)}}else{l=!1;const t=await this._handleText(e,i);t&&a.push(t)}else{l=!1;const t=await this._handleBlob(e,i);t&&a.push(t)}},c=[],h=e=>{if(!(e instanceof ClipboardItem))throw new Error("Expected ClipboardItem when reading data.");for(const t in e.types)c.push(u(e.types[t],e))};if("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)&&e>-1)h(s),Promise.all(c).then(()=>{a[0]?i(a[0]):i(null)}).catch(o);else if(Array.isArray(s)){for(const e in s)h(s[e]);Promise.all(c).then(()=>i(a)).catch(o)}}).catch(o)})}async readText(e=0){const t=await this._readData(e,"text");if("string"!=typeof t)throw new Error("Failed to read text: expected string result.");return t}async readCustom(e=null,t=!1,r=0){const n=await this._readData(r,"custom",e,t);if(!(n instanceof Blob))throw new Error("Failed to read custom data: expected Blob.");return n}async readAllTexts(){const e=await this._readData(null,"text");if(!Array.isArray(e))throw new Error("Expected array of strings when reading all texts.");if(!e.every(e=>"string"==typeof e))throw new Error("Some values returned were not strings.");return e}async readAllCustom(e=null,t=!1){const r=await this._readData(null,"custom",e,t);if(!Array.isArray(r))throw new Error("Expected array of blobs when reading all custom items.");if(!r.every(e=>e instanceof Blob))throw new Error("Some values returned were not Blob instances.");return r}async readAllData(e=null,t=null){const r=await this._readData(null,e,t);if(!Array.isArray(r))throw new Error("Expected array result when reading all data.");return r}_read(e){return new Promise((t,r)=>{this.#lr||r(new Error("Clipboard API not found!")),navigator.clipboard.read().then(r=>{if("number"==typeof e){if(Number.isNaN(e)||!Number.isFinite(e)||e<0)throw new Error(`Invalid index value: ${e}`);r[e]?t(r[e]):t(null)}t(r)}).catch(r)})}async readIndex(e){const t=await this._read(e);if(null!==t&&!(t instanceof ClipboardItem))throw new Error(`Value at index ${e} is not a ClipboardItem.`);return t}async readAll(){const e=await this._read(null);if(!Array.isArray(e))throw new Error("Expected array result from clipboard read.");for(const t of e)if(!(t instanceof ClipboardItem))throw new Error("Invalid item type found in clipboard result.");return e}isExecCommandAvailable(){return this.#ar}isNavigatorClipboardAvailable(){return this.#lr}getCopyTextFunc(){return this.#ur}getCopyBlobFunc(){return this.#cr}};class jt{static _rca(e,t,r){let n=127,i=128;void 0===e&&(e=24),void 0===t&&(t="rgb"),!0===r&&(n=55,i=200);const o=2*Math.PI/e,s=[];for(let r=0;r<e;++r){const e=Math.sin(o*r+2)*n+i,a=Math.sin(o*r+0)*n+i,l=Math.sin(o*r+4)*n+i;switch(t){case"hex":s.push({hex:this.rgbToHex(Math.round(e),Math.round(a),Math.round(l))});break;case"rgb":s.push({r:e,g:a,b:l});break;case"hsl":const[t,r,n]=this.rgbaToHsl(Math.round(e),Math.round(a),Math.round(l));s.push({h:t,s:r,l:n})}}return s}static rcaRgb(e,t){return jt._rca(e,"rgb",t)}static rcaHsl(e,t){return jt._rca(e,"hsl",t)}static rcaHex(e,t){return jt._rca(e,"hex",t)}static randomColor(){return`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`}static parseInput(e,t){if("string"==typeof e){if((e=e.trim().toLowerCase()).startsWith("#"))return this.hexToRgba(e);if(e.startsWith("rgb"))return this.rgbStringToRgbaArray(e);if(e.startsWith("hsl"))return this.hslStringToRgbaArray(e)}if("number"==typeof e)return this.intToRgba(e);if(Array.isArray(e)&&(3===e.length||4===e.length)&&e.every(e=>"number"==typeof e)){if(t){const[t,r,n,i]=e;if(t<=360&&r<=100&&n<=100)return this.hslToRgba(t,r,n,i)}return[...e,1].slice(0,4)}throw new Error("Unsupported color format.")}static hslToInt(e,t,r){const[n,i,o]=jt.hslToRgba(e,t,r);return jt.rgbToInt(n,i,o)}static hslToHex(e,t,r){const[n,i,o]=jt.hslToRgba(e,t,r);return jt.rgbToHex(n,i,o)}static hslStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);if(!t||t.length<3)return[0,0,0,1];const[r,n,i,o=1]=t;return this.hslToRgba(r,n,i,o)}static hslToRgba(e,t,r,n=1){r/=100;const i=t=>(t+e/30)%12,o=(t/=100)*Math.min(r,1-r),s=e=>r-o*Math.max(-1,Math.min(i(e)-3,Math.min(9-i(e),1)));return[Math.round(255*s(0)),Math.round(255*s(8)),Math.round(255*s(4)),n]}static hslToRgb(e,t,r,n=1){return jt.hslToRgba(e,t,r,n).slice(0,3)}static hexToInt(e){return parseInt(e.replace(/^#/,""),16)}static hexToHsl(e){const[t,r,n,i]=jt.hexToRgba(e);return jt.rgbaToHsl(t,r,n,i)}static hexToHsla(e){const[t,r,n,i]=jt.hexToRgba(e);return jt.rgbaToHsla(t,r,n,i)}static hexToRgba(e){3===(e=e.replace(/^#/,"")).length&&(e=e.split("").map(e=>e+e).join(""));const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t,1]}static hexToRgb(e){return this.hexToRgba(e).slice(0,3)}static rgbToHex(e,t,r){return"#"+[e,t,r].map(e=>e.toString(16).padStart(2,"0")).join("")}static rgbToInt(e,t,r){return e<<16|t<<8|r}static rgbaToHsla(e,t,r,n=1){e/=255,t/=255,r/=255;const i=Math.max(e,t,r),o=Math.min(e,t,r);let s=0,a=0,l=(i+o)/2;const u=i-o;if(0!==u){switch(a=u/(1-Math.abs(2*l-1)),i){case e:s=(t-r)/u+(t<r?6:0);break;case t:s=(r-e)/u+2;break;case r:s=(e-t)/u+4}s*=60}return[Math.round(s),Math.round(100*a),Math.round(100*l),n]}static rgbaToHsl(e,t,r,n){return this.rgbaToHsla(e,t,r,n).slice(0,3)}static rgbStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);return t?[...t,1].slice(0,4):[]}static intToHsl(e){const[t,r,n,i]=jt.intToRgba(e);return jt.rgbaToHsl(t,r,n,i)}static intToHsla(e){const[t,r,n,i]=jt.intToRgba(e);return jt.rgbaToHsla(t,r,n,i)}static intToHex(e){return"#"+e.toString(16).padStart(6,"0")}static intToRgba(e){return[e>>16&255,e>>8&255,255&e,1]}#hr="#000000";#dr=[0,0,0,0];#fr;constructor(e=null,t=!1){this.#fr=t,null!=e&&this.setColor(e)}setColor(e){this.#hr=e;const t=this.#fr&&Array.isArray(e)&&e[0]<=360&&e[1]<=100&&e[2]<=100;this.#dr=jt.parseInput(e,t)}toHslaArray(){const[e,t,r,n]=this.#dr;return jt.rgbaToHsla(e,t,r,n)}toHslString(){const[e,t,r]=this.#dr,[n,i,o]=jt.rgbaToHsl(e,t,r);return`hsl(${n}, ${i}%, ${o}%)`}toHslaString(){const[e,t,r,n]=this.#dr,[i,o,s,a]=jt.rgbaToHsla(e,t,r,n);return`hsla(${i}, ${o}%, ${s}%, ${a??1})`}toRgbaArray(){return[...this.#dr]}toRgbString(){const[e,t,r]=this.#dr;return`rgb(${e}, ${t}, ${r})`}toRgbaString(){const[e,t,r,n]=this.#dr;return`rgba(${e}, ${t}, ${r}, ${n??1})`}toHex(){const[e,t,r]=this.#dr;return jt.rgbToHex(e,t,r)}toInt(){const[e,t,r]=this.#dr;return jt.rgbToInt(e,t,r)}getOriginal(){return this.#hr}}const Ot=jt;class Rt{#pr=!1;#mr;#gr;#yr=null;#wr=new Map;constructor({cooldownWatcherTime:e=5e3,allowAutoConfigChange:t=!1}={}){if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'cooldownWatcherTime' to be a positive number.");if("boolean"!=typeof t)throw new TypeError("Expected 'allowAutoConfigChange' to be a boolean.");this.#gr=e,this.#mr=t,this.setCooldownWatcherTime(e)}isDestroyed(){return this.#pr}getAllowAutoConfigChange(){return this.#mr}getCooldownWatcherTime(){return this.#gr}setAllowAutoConfigChange(e){if("boolean"!=typeof e)throw new TypeError("Expected 'value' to be a boolean.");this.#mr=e}setCooldownWatcherTime(e){if(this.#pr)throw new Error("TinyTimeout has been destroyed.");if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'value' to be a positive number.");this.#gr=e,this.#yr&&clearInterval(this.#yr),this.#yr=setInterval(()=>{this.#wr.forEach(e=>{e.now>0&&e.now--})},this.#gr)}set(e,t,r,n=null){if(this.#pr)throw new Error("TinyTimeout has been destroyed.");if("string"!=typeof e||""===e.trim())throw new TypeError("Expected 'id' to be a non-empty string.");if("function"!=typeof t)throw new TypeError("Expected 'callback' to be a function.");if(!Number.isFinite(r)||r<0)throw new TypeError("Expected 'value' to be a non-negative number.");if(null!==n&&(!Number.isFinite(n)||n<0))throw new TypeError("Expected 'limit' to be null or a non-negative number.");let i=this.#wr.get(e);(!i||this.#mr&&r!==i.value)&&(i={value:r,now:0},this.#wr.set(e,i));const o=i.value*i.now;return i.now++,setTimeout(t,"number"==typeof n?Math.min(o,n):o)}static waitForTrue(e,t=100){if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(!Number.isFinite(t)||t<=0)throw new TypeError("Expected 'checkInterval' to be a positive number.");return new Promise(r=>{const n=setInterval(()=>{e()&&(clearInterval(n),r())},t)})}waitForTrue(e,t=100){if(this.#pr)throw new Error("TinyTimeout has been destroyed.");if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(null!==t&&(!Number.isFinite(t)||t<=0))throw new TypeError("Expected 'checkInterval' to be null or a positive number.");return Rt.waitForTrue(e,t??this.#gr)}destroy(){this.#pr||(this.#pr=!0,this.#yr&&clearInterval(this.#yr),this.#yr=null,this.#wr.clear())}}const Bt=Rt,$t=new Map,Pt=new Map,Ht=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class Ft{#Ct=new Lt;setThrowOnMaxListeners(e){return this.#Ct.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Ct.getThrowOnMaxListeners()}prependListener(e,t){return this.#Ct.prependListener(e,t)}prependListenerOnce(e,t){return this.#Ct.prependListenerOnce(e,t)}appendListener(e,t){return this.#Ct.appendListener(e,t)}appendListenerOnce(e,t){return this.#Ct.appendListenerOnce(e,t)}on(e,t){return this.#Ct.on(e,t)}once(e,t){return this.#Ct.once(e,t)}off(e,t){return this.#Ct.off(e,t)}offAll(e){return this.#Ct.offAll(e)}offAllTypes(){return this.#Ct.offAllTypes()}listenerCount(e){return this.#Ct.listenerCount(e)}listeners(e){return this.#Ct.listeners(e)}onceListeners(e){return this.#Ct.onceListeners(e)}allListeners(e){return this.#Ct.allListeners(e)}eventNames(){return this.#Ct.eventNames()}emit(e,...t){return this.#Ct.emit(e,...t)}setMaxListeners(e){return this.#Ct.setMaxListeners(e)}getMaxListeners(){return this.#Ct.getMaxListeners()}static hasJsonType(e){return $t.has(e)&&Pt.has(e)||Ht.has(e)}static registerJsonType(e,t,r,n=!1){if(Ht.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);$t.set(e,t),Pt.set(e,r),n&&Ht.add(e)}static deleteJsonType(e){if(Ht.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return $t.delete(e)&&(t=!0),Pt.delete(e)&&(t=!0),t}static encodeSpecialJson(e){if(void 0===e)return{__undefined__:!0};if(null===e)return{__null__:!0};for(const[t,r]of $t.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,Ft.encodeSpecialJson);if(Array.isArray(e))return e.map(Ft.encodeSpecialJson);if(m(e)){const t={};for(const r in e)t[r]=Ft.encodeSpecialJson(e[r]);return t}return e}static decodeSpecialJson(e){const t=m(e);if(t){if(e.__undefined__)return;if(e.__null__)return null}if(Array.isArray(e))return e.map(Ft.decodeSpecialJson);if(t){for(const[t,r]of Pt.entries())if(r.check&&r.check(e))return r.decode(e,Ft.decodeSpecialJson);const t={};for(const r in e)t[r]=Ft.decodeSpecialJson(e[r]);return t}return e}#br=window.localStorage;#vr=null;#Er=0;#Tr=e=>this.emit("storage",e);constructor(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#vr=`LSDB::${e}`),window.addEventListener("storage",this.#Tr)}#Sr(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if("string"!=typeof this.#vr)throw new Error("TinyLocalStorage: Database key is not initialized. Set a valid dbName in the constructor.");if("number"!=typeof e||Number.isNaN(e)||e<1)throw new TypeError("TinyLocalStorage: version must be a positive number.");if("function"!=typeof t)throw new TypeError("TinyLocalStorage: onUpgrade must be a function.");const r=parseInt(localStorage.getItem(this.#vr),10)||0;if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError("TinyLocalStorage: saved version in localStorage is not a valid number.");if(e<r)throw new Error(`TinyLocalStorage: Cannot downgrade database version from ${r} to ${e}.`);e>r&&(t(r,e),localStorage.setItem(this.#vr,String(e)),this.#Er=e)}getDbKey(){return this.#vr}getVersion(){return this.#Er}setLocalStorage(e){if(!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#br=e}localStorageExists(){return this.#br instanceof Storage}#xr(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return Ft.encodeSpecialJson(t)}setJson(e,t){if(this.#Sr(e),!(m(t)||Array.isArray(t)||t instanceof Map||t instanceof Set))throw new TypeError("The storage value is not a valid JSON-compatible structure.");const r=this.#xr(e,t);return this.emit("setJson",e,t),this.#br.setItem(e,JSON.stringify(r))}#Ar(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#br.getItem(e),n={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},i="function"==typeof n[t]?n[t]():null;let o;try{o=JSON.parse(r)}catch{return i}return{decoded:Ft.decodeSpecialJson(o),fallback:i}}getJson(e,t){const{decoded:r,fallback:n}=this.#Ar(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||m(r)?r:n}setDate(e,t){if(this.#Sr(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#xr(e,t);return this.emit("setDate",e,t),this.#br.setItem(e,JSON.stringify(r))}getDate(e){const t=this.#Ar(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(this.#Sr(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#xr(e,t);return this.emit("setRegExp",e,t),this.#br.setItem(e,JSON.stringify(r))}getRegExp(e){const t=this.#Ar(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(this.#Sr(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#xr(e,t);return this.emit("setBigInt",e,t),this.#br.setItem(e,JSON.stringify(r))}getBigInt(e){const t=this.#Ar(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(this.#Sr(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#xr(e,t);return this.emit("setSymbol",e,t),this.#br.setItem(e,JSON.stringify(r))}getSymbol(e){const t=this.#Ar(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return this.#Ar(e).decoded??null}setItem(e,t){if(this.#Sr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#br.setItem(e,t)}getItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#br.getItem(e)}setString(e,t){if(this.#Sr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#br.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#br.getItem(e);try{if(t=JSON.parse(t),!m(t)||!t.__string__||"string"!=typeof t.value)return null;t=t.value}catch{t=null}return"string"==typeof t?t:null}setNumber(e,t){if(this.#Sr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#br.setItem(e,String(t))}getNumber(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#br.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(this.#Sr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#br.setItem(e,String(t))}getBool(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#br.getItem(e);if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===t)return!0;if("false"===t)return!1}return null}removeItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#br.removeItem(e)}clearLocalStorage(){return this.#br.clear()}destroy(){window.removeEventListener("storage",this.#Tr),this.#Ct.offAllTypes()}}Ft.registerJsonType(Map,(e,t)=>({__map__:!0,data:Array.from(e.entries()).map(([e,r])=>[e,t(r)])}),{check:e=>e.__map__,decode:(e,t)=>new Map(e.data.map(([e,r])=>[e,t(r)]))},!0),Ft.registerJsonType(Set,(e,t)=>({__set__:!0,data:Array.from(e).map(t)}),{check:e=>e.__set__,decode:(e,t)=>new Set(e.data.map(t))},!0),Ft.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),Ft.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),Ft.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),Ft.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),Ft.registerJsonType("symbol",e=>({__symbol__:!0,key:Symbol.keyFor(e)??e.description??null}),{check:e=>e.__symbol__,decode:e=>{const t=e.key;return null!=t?Symbol.for(t):Symbol()}},!0);const Wt=Ft,zt=new WeakMap,qt=class{#Ct=new Lt;setThrowOnMaxListeners(e){return this.#Ct.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Ct.getThrowOnMaxListeners()}prependListener(e,t){return this.#Ct.prependListener(e,t)}prependListenerOnce(e,t){return this.#Ct.prependListenerOnce(e,t)}appendListener(e,t){return this.#Ct.appendListener(e,t)}appendListenerOnce(e,t){return this.#Ct.appendListenerOnce(e,t)}on(e,t){return this.#Ct.on(e,t)}once(e,t){return this.#Ct.once(e,t)}off(e,t){return this.#Ct.off(e,t)}offAll(e){return this.#Ct.offAll(e)}offAllTypes(){return this.#Ct.offAllTypes()}listenerCount(e){return this.#Ct.listenerCount(e)}listeners(e){return this.#Ct.listeners(e)}onceListeners(e){return this.#Ct.onceListeners(e)}allListeners(e){return this.#Ct.allListeners(e)}eventNames(){return this.#Ct.eventNames()}setMaxListeners(e){return this.#Ct.setMaxListeners(e)}getMaxListeners(){return this.#Ct.getMaxListeners()}#Ir;#Cr;#Mr;#pr=!1;#Lr=!1;#Dr=[];#kr="__tinyIframeEvent__";get secretEventName(){return this.#kr}set secretEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#kr=e}constructor({targetIframe:e,targetOrigin:t}={}){if(!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe" provided: expected a HTML Iframe Element, received '+typeof e);if(void 0!==t&&"string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin" provided: expected a string, received '+typeof t);if(this.#Ir=e?.contentWindow??window.parent,this.#Cr=t??window.location.origin,this.#Mr=e?"parent":"iframe",zt.has(this.#Ir))throw new Error("Duplicate window reference.");this._boundOnMessage=this.#Nr.bind(this),this._boundOnceMessage=this.#_r.bind(this),"complete"===this.#Ir.document.readyState||"interactive"===this.#Ir.document.readyState?this.#_r():(this.#Ir.addEventListener("load",this._boundOnceMessage,!1),this.#Ir.addEventListener("DOMContentLoaded",this._boundOnceMessage,!1)),window.addEventListener("message",this._boundOnMessage,!1),zt.set(this.#Ir,this)}#_r(){this.#Lr||(this.#Lr=!0,this.#jr())}#Nr(e){const{data:t,source:r}=e;if(!m(t)||!t[this.#kr])return;const{eventName:n,payload:i,direction:o}=t;r===this.#Ir&&("iframe"===this.#Mr&&"iframe"!==o||"parent"===this.#Mr&&"parent"!==o||this.#Ct.emit(n,i,e))}emit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#pr)throw new Error("Cannot emit: instance has been destroyed.");const r={[this.#kr]:!0,eventName:e,payload:t,direction:"parent"===this.#Mr?"iframe":"parent"};this.#Lr?this.#Ir.postMessage(r,this.#Cr):this.#Dr.push(r)}#jr(){for(;this.#Dr.length;){const e=this.#Dr.shift();e&&this.#Ir.postMessage(e,this.#Cr)}}isDestroyed(){return this.#pr}destroy(){this.#pr=!0,window.removeEventListener("message",this._boundOnMessage),this.#Ir.removeEventListener("load",this._boundOnceMessage,!1),this.#Ir.removeEventListener("DOMContentLoaded",this._boundOnceMessage,!1),this.#Ct.offAllTypes(),this.#Dr=[],zt.delete(this.#Ir)}},Vt=new WeakMap,Kt=class{#Ct=new Lt;setThrowOnMaxListeners(e){return this.#Ct.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Ct.getThrowOnMaxListeners()}prependListener(e,t){return this.#Ct.prependListener(e,t)}prependListenerOnce(e,t){return this.#Ct.prependListenerOnce(e,t)}appendListener(e,t){return this.#Ct.appendListener(e,t)}appendListenerOnce(e,t){return this.#Ct.appendListenerOnce(e,t)}on(e,t){return this.#Ct.on(e,t)}once(e,t){return this.#Ct.once(e,t)}off(e,t){return this.#Ct.off(e,t)}offAll(e){return this.#Ct.offAll(e)}offAllTypes(){return this.#Ct.offAllTypes()}listenerCount(e){return this.#Ct.listenerCount(e)}listeners(e){return this.#Ct.listeners(e)}onceListeners(e){return this.#Ct.onceListeners(e)}allListeners(e){return this.#Ct.allListeners(e)}eventNames(){return this.#Ct.eventNames()}setMaxListeners(e){return this.#Ct.setMaxListeners(e)}getMaxListeners(){return this.#Ct.getMaxListeners()}#Or;#Cr;#Dr=[];#Lr=!1;#Rr=!1;#Br=null;#$r="__TNE_READY__";#Pr="__TNE_ROUTE__";get readyEventName(){return this.#$r}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#$r=e}get routeEventName(){return this.#Pr}set routeEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#Pr=e}constructor({targetOrigin:e,url:t,name:r,features:n}={}){if("string"==typeof r&&"_blank"===r)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==n&&"string"!=typeof n)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#Or=window.opener:(this.#Or="string"==typeof t?window.open(t,r,n):t,this.#Rr=!0),!this.#Or||Vt.has(this.#Or))throw new Error("Invalid or duplicate window reference.");this.#Cr=e??window.location.origin,this._handleMessage=this.#Hr.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#Rr||(this.#Fr(this.#$r,null),this.#Wr())}getWin(){return this.#Or}#Hr(e){if(!e.source||this.#Or&&e.source!==this.#Or)return;const{type:t,route:r,payload:n}=e.data||{};if(t===this.#$r)return this.#Lr=!0,this.#jr(),this.#Wr(),void(this.#Rr&&this.#Fr(this.#$r,null));t===this.#Pr&&this.#Ct.emit(r,n,e)}#jr(){for(;this.#Dr.length;){const e=this.#Dr.shift();if(e){const{route:t,payload:r}=e;this.emit(t,r)}}}#Fr(e,t,r=""){this.#Or&&this.#Or.closed||this.#Or?.postMessage({type:e,route:r,payload:t},this.#Cr)}close(){if(!this.#Rr)throw new Error("Only host can close the window.");this.#Or&&!this.#Or.closed&&this.#Or.close()}emit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.isDestroyed())throw new Error("Cannot emit: instance has been destroyed.");this.#Lr?this.#Fr(this.#Pr,t,e):this.#Dr.push({route:e,payload:t})}isConnected(){return!(!this.#Lr||!this.#Or||this.#Or.closed)}#Wr(){this.#Or&&!this.#Br&&(this.#Br=setInterval(()=>{this.#Or?.closed&&(this.#Ct.emit("WINDOW_REF_CLOSED"),this.destroy())},500),Vt.set(this.#Or,this.#Br))}onClose(e){return this.#Ct.on("WINDOW_REF_CLOSED",e)}offClose(e){return this.#Ct.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#Or}destroy(){this.#Or&&(this.#Br&&(clearInterval(this.#Br),this.#Br=null,Vt.delete(this.#Or)),window.removeEventListener("message",this._handleMessage),this.#Dr=[],this.#Lr=!1,this.#Or=null,this.#Ct.offAllTypes())}},Jt=class{#zr;#qr;#Vr;#Kr=0;#Jr=0;#Ur;#Gr=null;#Yr=null;get lineHeight(){return this.#zr}get maxRows(){return this.#qr-1}get extraHeight(){return this.#Vr}get currentHeight(){return this.#Kr}get currentRows(){return this.#Jr}get textarea(){return this.#Ur}constructor(e,t={}){if(!(e instanceof HTMLTextAreaElement))throw new Error("TinyTextarea: Provided element is not a <textarea>.");if("object"!=typeof t||null===t)throw new TypeError("TinyTextarea: Options must be an object if provided.");if("maxRows"in t&&"number"!=typeof t.maxRows)throw new TypeError("TinyTextarea: `maxRows` must be a number.");if("extraHeight"in t&&"number"!=typeof t.extraHeight)throw new TypeError("TinyTextarea: `extraHeight` must be a number.");if("onResize"in t&&"function"!=typeof t.onResize)throw new TypeError("TinyTextarea: `onResize` must be a function.");if("onInput"in t&&"function"!=typeof t.onInput)throw new TypeError("TinyTextarea: `onInput` must be a function.");this.#Ur=e,this.#qr=(t.maxRows??5)+1,this.#Vr=t.extraHeight??0,this.#Gr=t.onResize??null,this.#Yr=t.onInput??null,this.#zr=this.#Qr(),e.style.overflowY="hidden",e.style.resize="none",this._handleInput=()=>this.#Zr(),e.addEventListener("input",this._handleInput),this.#Zr()}#Zr(){this.#Ur.style.height="auto";const e=window.getComputedStyle(this.#Ur),t=parseFloat(e.paddingTop)||0,r=parseFloat(e.paddingBottom)||0,n=(this.#Ur.value.match(/\n/g)||[]).length,i=this.#Ur.scrollHeight,o=this.#zr*this.#qr,s=Math.ceil(Math.min(i,o)-t-r+this.#Vr),a=this.#qr-1,l=n<a?n+1:a;this.#Ur.style.height=`${s}px`,this.#Ur.style.overflowY=i>o?"auto":"hidden",this.#Kr=s;const u={breakLines:n,rows:l,height:s,scrollHeight:i,maxHeight:o,lineHeight:this.#zr,maxRows:a};l!==this.#Jr&&(this.#Jr=l,"function"==typeof this.#Gr&&this.#Gr({...u})),"function"==typeof this.#Yr&&this.#Yr(u)}#Qr(){const e=window.getComputedStyle(this.#Ur),t=parseFloat(e.lineHeight);return Number.isNaN(t)?1.2*parseFloat(e.fontSize):t}getData(){return{rows:this.#Jr,height:this.#Kr}}refresh(){this.#Zr()}destroy(){this.#Ur.removeEventListener("input",this._handleInput)}};class Ut{#pr=!1;#Xr=new Set;#en=new Map;#tn=new Map;#rn=null;#nn=[];#in={};#on=[];#sn=null;#an=null;#ln;#un;#cn;#hn;#dn;#fn;#pn;#mn;#gn=[];#yn=0;#wn=0;#bn=[];#vn=0;#En=null;#Tn=new Set;#Sn=new Set;#xn=new Map;#An=new Map;#In=new Map;static#Cn={" ":"Space","\n":"Enter","\r":"Enter","\t":"Tab","-":"Minus",_:"Minus","=":"Equal","+":"Equal","[":"BracketLeft","{":"BracketLeft","]":"BracketRight","}":"BracketRight","\\":"Backslash","|":"Backslash",";":"Semicolon",":":"Semicolon","'":"Quote",'"':"Quote",",":"Comma","<":"Comma",".":"Period",">":"Period","/":"Slash","?":"Slash","`":"Backquote","~":"Backquote"};static addSpecialKey(e,t){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);if("string"!=typeof t)throw new TypeError("Invalid code type: expected string, got "+typeof t);Ut.#Cn[e]=t}static removeSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);delete Ut.#Cn[e]}static getSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);return Ut.#Cn[e]}static getAllSpecialKeys(){return{...Ut.#Cn}}static stringToKeys(e){if("string"!=typeof e)throw new TypeError("Invalid text type: expected string, got "+typeof e);if(!e.length)throw new Error("Invalid text: cannot be empty");return Array.from(e).map(e=>{const t=e.toUpperCase();if(t>="A"&&t<="Z")return`Key${t}`;if(t>="0"&&t<="9")return`Digit${t}`;const r=Ut.#Cn[e];if(void 0!==r)return r;throw new Error(`Unsupported character: "${e}"`)})}constructor({expectedId:e=null,inputMode:t="both",ignoreIds:r=[],deadZone:n=.1,axisActiveSensitivity:i=.3,timeoutComboKeys:o=500,allowMouse:s=!1,elementBase:a=window}={}){if(null!==e&&"string"!=typeof e)throw new TypeError('"expectedId" must be a string or null, received: '+typeof e);if(!["keyboard-only","gamepad-only","both"].includes(t))throw new TypeError(`"inputMode" must be 'keyboard-only', 'gamepad-only', or 'both', received: ${t}`);if(!Array.isArray(r)||!r.every(e=>"string"==typeof e))throw new TypeError('"ignoreIds" must be an array of strings');if("number"!=typeof n||n<0||n>1)throw new RangeError(`"deadZone" must be a number between 0 and 1, received: ${n}`);if("number"!=typeof i||i<0||i>1)throw new RangeError(`"axisActiveSensitivity" must be a number between 0 and 1, received: ${i}`);if("number"!=typeof o||o<0)throw new RangeError(`"timeoutComboKeys" must be a positive number, received: ${o}`);if("boolean"!=typeof s)throw new TypeError('"allowMouse" must be a boolean, received: '+typeof s);if(!(a instanceof Window||a instanceof Element))throw new TypeError('"elementBase" must be a Window or Element instance');this.#hn=e,this.#ln=t,this.#un=new Set(r),this.#cn=n,this.#dn=s,this.#fn=a,this.#pn=o,this.#mn=i,["gamepad-only","both"].includes(this.#ln)&&this.#Mn(),["keyboard-only","both"].includes(this.#ln)&&this.#Ln()}#Dn=e=>this.#kn(e.gamepad);#Nn=e=>this.#_n(e.gamepad);#Mn(){window.addEventListener("gamepadconnected",this.#Dn),window.addEventListener("gamepaddisconnected",this.#Nn)}#kn(e){this.#pr||this.#un.has(e.id)||this.#hn&&e.id!==this.#hn||this.#rn||(this.#rn=e,this.#hn=e.id,this.#jn(),this.#On("connected",{id:e.id,gp:e,timestamp:e.timestamp}))}#_n(e){this.#pr||this.#rn&&e.id===this.#rn.id&&(this.#rn=null,this.#sn&&(cancelAnimationFrame(this.#sn),this.#sn=null),this.#On("disconnected",{id:e.id,gp:e,timestamp:e.timestamp}))}#jn(){const e=()=>{this.#pr||(this.#Rn(),this.#sn=requestAnimationFrame(e))};e()}#Rn(){if(this.#pr)return;const e=navigator.getGamepads(),t=Array.from(e).find(e=>e&&e.id===this.#hn);t&&(this.#rn=t,t.buttons.forEach((e,r)=>{const n=`Button${r}`,i=this.#nn[r]?.pressed||!1;let o,s,a=!1;e.pressed&&!i?(s=1,o="down"):!e.pressed&&i?(s=0,o="up"):e.pressed&&i&&(s=1,o="hold"),e.pressed&&e.value>0&&e.value<1&&1!==e.value&&(s=e.value,a=!0),"number"==typeof s&&"string"==typeof o&&this.#Bn({key:n,source:"gamepad-button",value:s,value2:NaN,type:o,gp:t,isPressure:a,pressed:e.pressed,prevPressed:i,timestamp:t.timestamp,id:t.id}),this.#nn[r]={pressed:e.pressed,value:"number"==typeof s?s:this.#nn[r]?.value,value2:NaN}}),t.axes.forEach((e,r)=>{Math.abs(e)<this.#cn&&(e=0);const n=`Axis${r}`;e!==(this.#on[r]??0)&&this.#Bn({key:n,source:"gamepad-analog",value:e,value2:NaN,type:"change",timestamp:t.timestamp,id:t.id,gp:t}),this.#on[r]=e}))}#$n=e=>{if(!this.#pr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keydown listener.");this.#Xr.has(e.code)||(this.#Xr.add(e.code),this.#Bn({event:e,key:e.code,source:"keyboard",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#in[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#in[e.code]={pressed:!0})}};#Pn=e=>{if(!this.#pr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keyup listener.");this.#Xr.has(e.code)&&(this.#Xr.delete(e.code),this.#Bn({event:e,key:e.code,source:"keyboard",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#in[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#in[e.code]={pressed:!1})}};#Hn=e=>{if(this.#pr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousedown listener.");const t=`Mouse${e.button}`;this.#Xr.add(t),this.#Bn({event:e,key:t,source:"mouse",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#in[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#in[t]={pressed:!0}};#Fn=e=>{if(this.#pr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mouseup listener.");const t=`Mouse${e.button}`;this.#Xr.delete(t),this.#Bn({event:e,key:t,source:"mouse",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#in[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#in[t]={pressed:!1}};#Wn=e=>{if(!this.#pr){if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousemove listener.");if(0!==e.movementX||0!==e.movementY){const t="MouseMove",r=this.#in[t]??{pressed:!1,value:0,value2:0};this.#Bn({event:e,key:t,source:"mouse",value:e.movementX+(r.value??0),value2:e.movementY+(r.value??0),id:"native_mouse",type:"move",pressed:!0,prevPressed:null,timestamp:e.timeStamp}),this.#in[t]={pressed:!1,value:e.movementX,value2:e.movementY}}}};#Ln(){this.#fn.addEventListener("keydown",this.#$n),this.#fn.addEventListener("keyup",this.#Pn),this.#dn&&(this.#fn.addEventListener("mousedown",this.#Hn),this.#fn.addEventListener("mouseup",this.#Fn),this.#fn.addEventListener("mousemove",this.#Wn));const e=()=>{this.#pr||(this.#Xr.forEach(e=>{const t=e.startsWith("Mouse")?"mouse":"keyboard";this.#Bn({key:e,source:t,id:`native_${t}`,value:1,value2:NaN,type:"hold",pressed:!0,prevPressed:this.#in[e]?.pressed??!1,timestamp:NaN})}),this.#an=requestAnimationFrame(e))};e()}#Bn(e){if(this.#pr)return;const t=this.#tn.get("input-*")||[],{pressed:r,key:n}=e,i=n.startsWith("Axis"),o="boolean"==typeof r&&r||i&&(e.value>this.#mn||e.value<-Math.abs(this.#mn)),s=i?`${n}${e.value>0?"+":e.value<0?"-":""}`:n;let a=null;if("move"!==e.type&&"hold"!==e.type){if(o){if(!i&&!this.#Tn.has(n)||i&&!this.#Tn.has(n)&&!this.#Tn.has(`${n}+`)&&!this.#Tn.has(`${n}-`)){0===this.#vn&&(this.#vn=Date.now()),this.#Tn.add(s),a=!0,this.#bn.push(s),this.#gn.length<1&&(this.#En&&clearTimeout(this.#En),this.#En=setTimeout(()=>this.resetComboMapped(),this.#pn));const e=this.#tn.get("mapped-key-start")??[];for(const t of e)t({key:s,activeTime:this.#vn})}}else if(!i&&this.#Tn.has(n)||i&&(this.#Tn.has(n)||this.#Tn.has(`${n}+`)||this.#Tn.has(`${n}-`))){this.#Tn.delete(n),this.#Tn.delete(`${n}+`),this.#Tn.delete(`${n}-`),a=!1;const e=this.#tn.get("mapped-key-end")??[];for(const t of e)t({key:s,activeTime:this.#vn})}for(const{sequence:e,callback:t,triggered:r}of this.#An.values()){const n=this.#An.get(e.join("+"));if(!n)continue;const i=e.every((e,t)=>this.#bn[t]===e);i&&!r?(n.triggered=!0,t(this.#vn)):!i&&r&&(n.triggered=!1)}}for(const[r,l]of this.#en.entries()){const u=e=>"string"==typeof l&&e===l||Array.isArray(l)&&l.findIndex((t,r)=>e===l[r])>-1,c=u(s),h=i&&u(`${n}+`),d=i&&u(`${n}-`);if(c||h||d){if(o&&c){if(a||!this.#Sn.has(r)){0===this.#wn&&(this.#wn=Date.now()),this.#Sn.add(r),0===this.#yn&&(this.#yn=Date.now()),this.#En&&clearTimeout(this.#En),this.#gn.push(r),this.#En=setTimeout(()=>this.resetComboMapped(),this.#pn);const e=this.#tn.get("mapped-input-start")??[];for(const t of e)t({logicalName:r,activeTime:this.#wn,comboTime:this.#yn})}}else if(!a||this.#Sn.has(r)){this.#Sn.delete(r),this.#Sn.size<1&&(this.#wn=0);const e=this.#tn.get("mapped-input-end")??[];for(const t of e)t({logicalName:r,activeTime:this.#wn,comboTime:this.#yn})}for(const{sequence:e,callback:t,triggered:r}of this.#xn.values()){const n=this.#xn.get(e.join("+"));if(!n)continue;const i=Array.from(this.#Sn),o=e.every((e,t)=>i[t]===e);o&&!r?(n.triggered=!0,t(this.#wn)):!o&&r&&(n.triggered=!1)}}const f=[];if(i&&0===e.value){const{value:t}=this.#In.get(`${n}-`)??{value:0,value2:NaN},{value:r}=this.#In.get(`${n}+`)??{value:0,value2:NaN};e.value!==t&&f.push(`${n}-`),e.value!==r&&f.push(`${n}+`)}else f.push(s);f.forEach(n=>{if(!("*"===l||l===n||Array.isArray(l)&&l.includes(n)))return;const i=this.#tn.get(`input-${e.type}-${r}`)||[],o=this.#tn.get(`input-${r}`)||[];if(o.length<1&&i.length<1&&t.length<1)return;const s={...e,key:n,logicalName:r};for(const e of t)e(s);for(const e of o)e(s);for(const e of i)e(s);this.#In.set(n,{value:e.value,value2:e.value2})})}}#On(e,t){const r=this.#tn.get(e)||[];for(const e of r)e(t)}#zn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e);let i=this.#tn.get(n);Array.isArray(i)||(i=[],this.#tn.set(n,i)),i.push(t)}#qn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=i=>{this.#Vn(e,n,r),t(i)};this.#zn(e,n,r)}#Kn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e),i=this.#tn.get(n)??[];i.unshift(t),this.#tn.set(n,i)}#Vn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e),i=this.#tn.get(n);Array.isArray(i)&&this.#tn.set(n,i.filter(e=>e!==t))}awaitInputMapping({timeout:e=1e4,eventName:t="MappingInput",canMove:r=!1}={}){return new Promise((n,i)=>{if("number"!=typeof e||Number.isNaN(e)||e<0)return i(new TypeError(`Invalid "timeout": expected a positive number, got ${e}`));if("string"!=typeof t||!t.trim())return i(new TypeError(`Invalid "eventName": expected a non-empty string, got ${t}`));if("boolean"!=typeof r)return i(new TypeError(`Invalid "canMove": expected a boolean, got ${r}`));const o={key:null,source:null},s=({key:e,type:i,source:l,gp:u,value:c})=>{(r||"move"!==i)&&(o.key=e,o.source=l,o.gp=u,clearTimeout(a),this.offInputStart(t,s),this.offInputChange(t,s),r&&this.offInputMove(t,s),n(o))},a=setTimeout(()=>n(o),e);this.mapInput(t,"*"),this.onInputStart(t,s),this.onInputChange(t,s),r&&this.onInputMove(t,s)})}mapInput(e,t){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError(`Invalid "physicalInput": expected string or array of strings, got ${JSON.stringify(t)}`);this.#en.set(e,t)}unmapInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);this.#en.delete(e)}hasMappedInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);return this.#en.has(e)}getMappedInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);const t=this.#en.get(e);if(!t)throw new Error(`No physical input mapped for logicalName: "${e}"`);return t}clearMapInputs(){this.#en.clear()}registerInputSequence(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#xn.set(r,{sequence:e,callback:t,triggered:!1})}unregisterInputSequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#xn.delete(t)}unregisterAllInputSequences(){this.#xn.clear()}hasInputSequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#xn.has(t)}registerKeySequence(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#An.set(r,{sequence:e,callback:t,triggered:!1})}unregisterKeySequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#An.delete(t)}unregisterAllKeySequences(){this.#An.clear()}hasKeySequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#An.has(t)}renewComboMapped(){this.#En&&(clearTimeout(this.#En),this.#En=setTimeout(()=>this.resetComboMapped(),this.#pn))}resetComboMapped(){this.#En&&clearTimeout(this.#En),this.#bn=[],this.#En=null,this.#vn=0,this.#gn=[],this.#yn=0}onMappedKeyStart(e){return this.#zn("",e,"mapped-key-start")}onceMappedKeyStart(e){return this.#qn("",e,"mapped-key-start")}prependMappedKeyStart(e){return this.#Kn("",e,"mapped-key-start")}offMappedKeyStart(e){return this.#Vn("",e,"mapped-key-start")}offAllMappedKeyStart(){this.#tn.delete("mapped-key-start")}onMappedKeyEnd(e){return this.#zn("",e,"mapped-key-end")}onceMappedKeyEnd(e){return this.#qn("",e,"mapped-key-end")}prependMappedKeyEnd(e){return this.#Kn("",e,"mapped-key-end")}offMappedKeyEnd(e){return this.#Vn("",e,"mapped-key-end")}offAllMappedKeyEnd(){this.#tn.delete("mapped-key-end")}onMappedInputStart(e){return this.#zn("",e,"mapped-input-start")}onceMappedInputStart(e){return this.#qn("",e,"mapped-input-start")}prependMappedInputStart(e){return this.#Kn("",e,"mapped-input-start")}offMappedInputStart(e){return this.#Vn("",e,"mapped-input-start")}offAllMappedInputStart(){this.#tn.delete("mapped-input-start")}onMappedInputEnd(e){return this.#zn("",e,"mapped-input-end")}onceMappedInputEnd(e){return this.#qn("",e,"mapped-input-end")}prependMappedInputEnd(e){return this.#Kn("",e,"mapped-input-end")}offMappedInputEnd(e){return this.#Vn("",e,"mapped-input-end")}offAllMappedInputEnd(){this.#tn.delete("mapped-input-end")}onInput(e,t){return this.#zn(e,t,"input-{logicalName}")}onceInput(e,t){return this.#qn(e,t,"input-{logicalName}")}prependInput(e,t){return this.#Kn(e,t,"input-{logicalName}")}offInput(e,t){return this.#Vn(e,t,"input-{logicalName}")}onInputStart(e,t){return this.#zn(e,t,"input-down-{logicalName}")}onceInputStart(e,t){return this.#qn(e,t,"input-down-{logicalName}")}prependInputStart(e,t){return this.#Kn(e,t,"input-down-{logicalName}")}offInputStart(e,t){return this.#Vn(e,t,"input-down-{logicalName}")}onInputEnd(e,t){return this.#zn(e,t,"input-up-{logicalName}")}onceInputEnd(e,t){return this.#qn(e,t,"input-up-{logicalName}")}prependInputEnd(e,t){return this.#Kn(e,t,"input-up-{logicalName}")}offInputEnd(e,t){return this.#Vn(e,t,"input-up-{logicalName}")}onInputHold(e,t){return this.#zn(e,t,"input-hold-{logicalName}")}onceInputHold(e,t){return this.#qn(e,t,"input-hold-{logicalName}")}prependInputHold(e,t){return this.#Kn(e,t,"input-hold-{logicalName}")}offInputHold(e,t){return this.#Vn(e,t,"input-hold-{logicalName}")}onInputChange(e,t){return this.#zn(e,t,"input-change-{logicalName}")}onceInputChange(e,t){return this.#qn(e,t,"input-change-{logicalName}")}prependInputChange(e,t){return this.#Kn(e,t,"input-change-{logicalName}")}offInputChange(e,t){return this.#Vn(e,t,"input-change-{logicalName}")}onInputMove(e,t){return this.#zn(e,t,"input-move-{logicalName}")}onceInputMove(e,t){return this.#qn(e,t,"input-move-{logicalName}")}prependInputMove(e,t){return this.#Kn(e,t,"input-move-{logicalName}")}offInputMove(e,t){return this.#Vn(e,t,"input-move-{logicalName}")}getCalls(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n=`${{all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t]}${e}`,i=this.#tn.get(n);return Array.isArray(i)?[...i]:[]}offAllInputs(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t];n&&this.#tn.delete(`${n}${e}`)}getCallSize(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t],i=this.#tn.get(`${n}${e}`);return Array.isArray(i)?i.length:0}#Jn={type:"dual-rumble",params:{startDelay:0,duration:200,weakMagnitude:.5,strongMagnitude:1}};get defaultHapticEffect(){return{type:this.#Jn.type,params:{...this.#Jn.params}}}setDefaultHapticEffect(e,t){if("string"!=typeof e)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string, received ${e}`);if("object"!=typeof t||null===t)throw new TypeError(`"params" must be a non-null object, received ${t}`);this.#Jn.type=e,this.#Jn.params=t}hasHapticEffect(){const e=this.#rn;return!!e&&e.vibrationActuator instanceof GamepadHapticActuator}vibrate(e,t){if(void 0!==e&&("object"!=typeof e||null===e))throw new TypeError(`"params" must be an object if provided, received ${e}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string if provided, received ${t}`);const r=this.#rn;if(!r)return new Promise(e=>e("complete"));const n=r.vibrationActuator;return n instanceof GamepadHapticActuator?n.playEffect(t??this.#Jn.type,{...this.#Jn.params,...e}):new Promise(e=>e("complete"))}ignoreId(e){if("string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#un.add(e)}unignoreId(e){if("string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#un.delete(e)}onConnected(e){return this.#zn("",e,"connected")}onceConnected(e){return this.#qn("",e,"connected")}prependConnected(e){return this.#Kn("",e,"connected")}offConnected(e){return this.#Vn("",e,"connected")}offAllConnected(){this.#tn.delete("connected")}onDisconnected(e){return this.#zn("",e,"disconnected")}onceDisconnected(e){return this.#qn("",e,"disconnected")}prependDisconnected(e){return this.#Kn("",e,"disconnected")}offDisconnected(e){return this.#Vn("",e,"disconnected")}offAllDisconnected(){this.#tn.delete("disconnected")}hasGamepad(){return this.#rn instanceof Gamepad}getGamepad(){if(!this.#rn)throw new Error("No gamepad is currently connected.");return this.#rn}hasLastButtonState(e){return!!this.#nn[e]}getLastButtonState(e){if(!this.#nn[e])throw new Error(`No last button state found for index ${e}`);return{...this.#nn[e]}}exportConfig(){return{expectedId:this.#hn,ignoreIds:Array.from(this.#un),deadZone:this.#cn,timeoutComboKeys:this.#pn,axisActiveSensitivity:this.#mn,inputMap:Array.from(this.#en.entries())}}importConfig(e){if("string"!=typeof e&&("object"!=typeof e||null===e))throw new TypeError(`"json" must be a string or a non-null object, received: ${e}`);const t="string"==typeof e?JSON.parse(e):e;if(void 0!==t.expectedId&&"string"!=typeof t.expectedId&&null!==t.expectedId)throw new TypeError('"expectedId" must be a string or null if provided');if(void 0!==t.ignoreIds&&!Array.isArray(t.ignoreIds))throw new TypeError('"ignoreIds" must be an array if provided');if(void 0!==t.deadZone&&"number"!=typeof t.deadZone)throw new TypeError('"deadZone" must be a number if provided');if(void 0!==t.timeoutComboKeys&&"number"!=typeof t.timeoutComboKeys)throw new TypeError('"timeoutComboKeys" must be a number if provided');if(void 0!==t.axisActiveSensitivity&&"number"!=typeof t.axisActiveSensitivity)throw new TypeError('"axisActiveSensitivity" must be a number if provided');if(void 0!==t.inputMap&&!Array.isArray(t.inputMap))throw new TypeError('"inputMap" must be an array if provided');void 0!==t.expectedId&&(this.#hn=t.expectedId),Array.isArray(t.ignoreIds)&&(this.#un=new Set(t.ignoreIds)),"number"==typeof t.deadZone&&(this.#cn=t.deadZone),"number"==typeof t.timeoutComboKeys&&(this.#pn=t.timeoutComboKeys),"number"==typeof t.axisActiveSensitivity&&(this.#mn=t.axisActiveSensitivity),Array.isArray(t.inputMap)&&(this.#en=new Map(t.inputMap))}get mappedKeyStartCalls(){const e=this.#tn.get("mapped-key-start");return Array.isArray(e)?[...e]:[]}get mappedKeyEndCalls(){const e=this.#tn.get("mapped-key-end");return Array.isArray(e)?[...e]:[]}get comboMappedKeys(){return[...this.#bn]}get comboMappedInputs(){return[...this.#gn]}get keySequenceSize(){return this.#An.size}get keySequences(){const e=[];for(const[,t]of this.#An.entries())e.push(t.callback);return e}get activeMappedKeys(){return[...this.#Tn]}get mappedInputStartCalls(){const e=this.#tn.get("mapped-input-start");return Array.isArray(e)?[...e]:[]}get mappedInputEndCalls(){const e=this.#tn.get("mapped-input-end");return Array.isArray(e)?[...e]:[]}get inputSequenceSize(){return this.#xn.size}get inputSequences(){const e=[];for(const[,t]of this.#xn.entries())e.push(t.callback);return e}get activeMappedInputs(){return[...this.#Sn]}get mappedInputs(){const e={};for(const[t,r]of this.#en.entries())e[t]=r;return e}get mappedInputSize(){return this.#en.size}get connectedCalls(){const e=this.#tn.get("connected");return Array.isArray(e)?[...e]:[]}get disconnectedCalls(){const e=this.#tn.get("disconnected");return Array.isArray(e)?[...e]:[]}get ignoredDeviceIds(){return[...this.#un]}get heldKeys(){return[...this.#Xr]}get eventsSize(){let e=0;return this.#tn.forEach(t=>{e+=t.length}),e}get callSize(){return this.#tn.size}get connectedCallSize(){const e=this.#tn.get("connected");return Array.isArray(e)?e.length:0}get disconnectedCallSize(){const e=this.#tn.get("disconnected");return Array.isArray(e)?e.length:0}get mappedKeyStartCallSize(){const e=this.#tn.get("mapped-key-start");return Array.isArray(e)?e.length:0}get mappedKeyEndCallSize(){const e=this.#tn.get("mapped-key-end");return Array.isArray(e)?e.length:0}get mappedInputStartCallSize(){const e=this.#tn.get("mapped-input-start");return Array.isArray(e)?e.length:0}get mappedInputEndCallSize(){const e=this.#tn.get("mapped-input-end");return Array.isArray(e)?e.length:0}get lastButtonStates(){const e=[];return this.#nn.forEach(t=>{e.push({...t})}),e}get lastAxes(){return[...this.#on]}get inputMode(){return this.#ln}get elementBase(){return this.#fn}get timeComboInputs(){return this.#yn}get timeComboKeys(){return this.#vn}get timeMappedInputs(){return this.#wn}get timeoutComboKeys(){return this.#pn}set timeoutComboKeys(e){if("number"!=typeof e||e<0||!Number.isFinite(e))throw new TypeError("Timeout combo keys must be a non-negative finite number.");this.#pn=e}get axisActiveSensitivity(){return this.#mn}set axisActiveSensitivity(e){if("number"!=typeof e||e<0||e>1)throw new RangeError("Axis sensitivity must be a number between 0 and 1.");this.#mn=e}get deadZone(){return this.#cn}set deadZone(e){if("number"!=typeof e||e<0||e>1)throw new RangeError("Dead zone must be a number between 0 and 1.");this.#cn=e}get expectedId(){return this.#hn}set expectedId(e){if("string"!=typeof e)throw new TypeError("Expected device id be a string.");this.#hn=e}get isDestroyed(){return this.#pr}destroy(){this.#pr||(this.#pr=!0,this.#sn&&cancelAnimationFrame(this.#sn),this.#an&&cancelAnimationFrame(this.#an),this.#sn=null,this.#an=null,["keyboard-only","both"].includes(this.#ln)&&(this.#fn.removeEventListener("keydown",this.#$n),this.#fn.removeEventListener("keyup",this.#Pn),this.#dn&&(this.#fn.removeEventListener("mousedown",this.#Hn),this.#fn.removeEventListener("mouseup",this.#Fn),this.#fn.removeEventListener("mousemove",this.#Wn))),["gamepad-only","both"].includes(this.#ln)&&(window.removeEventListener("gamepadconnected",this.#Dn),window.removeEventListener("gamepaddisconnected",this.#Nn)),this.resetComboMapped(),this.#en.clear(),this.#tn.clear(),this.#Xr.clear(),this.#Sn.clear(),this.#Tn.clear(),this.#xn.clear(),this.#An.clear(),this.#un.clear(),this.#In.clear(),this.#nn=[],this.#on=[],this.#in={},this.#rn=null,this.#hn=null,this.#dn=!1,this.#wn=0)}}const Gt=Ut,Yt=class{#Un=!0;#Gn=86400;#Yn=3600;#Qn=60;#Zn=new Map;#Xn=[];#ei;#ti;#ri={main:null};#ni=0;#ii=0;#oi=0;#si="";#ai=1;#li=1;#ui=1;#pr=!1;#ci=[31,31,31,31,31,31,31,31,31,31,31,31];#hi={default:{},day:{},night:{},hours:{},seasons:{}};#di={min:60,max:180};#fi=0;get daySize(){return this.#Gn}get autoSizeAdjuste(){return this.#Un}set autoSizeAdjuste(e){if("boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#Un=e}set daySize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("daySize must be a positive finite number.");const t=this.#Yn/this.#Gn,r=this.#Qn/this.#Gn;this.#Gn=e,this.#Un&&(this.#Yn=e*t,this.#Qn=e*r)}get hourSize(){return this.#Yn}set hourSize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("hourSize must be a positive finite number.");const t=this.#Gn/this.#Yn,r=this.#Qn/this.#Yn;this.#Yn=e,this.#Un&&(this.#Gn=e*t,this.#Qn=e*r)}get minuteSize(){return this.#Qn}set minuteSize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("minuteSize must be a positive finite number.");const t=this.#Yn/this.#Qn,r=this.#Gn/this.#Qn;this.#Qn=e,this.#Un&&(this.#Yn=e*t,this.#Gn=e*r)}get isDestroyed(){return this.#pr}get currentSeconds(){return this.#ni}set currentSeconds(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentSeconds must be a finite number, received "+typeof e);if(e<0||e>=this.#Gn)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#ni=Math.floor(e),this.#ii=Math.floor(e/this.#Qn),this.#oi=Math.floor(e/this.#Yn)}get currentMinutes(){return this.#ii}set currentMinutes(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentMinutes must be a finite number, received "+typeof e);if(e<0||e>=1440)throw new RangeError(`currentMinutes must be between 0 and 1439, received ${e}`);this.#ii=Math.floor(e),this.#oi=Math.floor(e/this.#Qn),this.#ni=Math.floor(e*this.#Qn)}get currentHours(){return this.#oi}set currentHours(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentHours must be a finite number, received "+typeof e);if(e<0||e>=24)throw new RangeError(`currentHours must be between 0 and less than 24, received ${e}`);this.#oi=Math.floor(e),this.#ii=Math.floor(e*this.#Qn),this.#ni=Math.floor(e*this.#Yn)}get moons(){return this.#Xn.map(e=>this.getMoon(e))}get seasons(){return Array.from(this.#Zn.keys())}get dayStart(){return this.#ei}get nightStart(){return this.#ti}get weather(){return{...this.#ri}}get currentSeason(){return this.#si}get currentDay(){return this.#ai}get currentMonth(){return this.#li}get currentYear(){return this.#ui}get monthDays(){return[...this.#ci]}get weatherDuration(){return{...this.#di}}get weatherTimeLeft(){return this.#fi}set dayStart(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("dayStart must be a positive non-zero number, received "+typeof e);this.#ei=e}set nightStart(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("nightStart must be a positive non-zero number, received "+typeof e);this.#ti=e}set weather(e){if(this._checkDestroyed(),"object"!=typeof e||null===e||Array.isArray(e)||!Object.values(e).every(e=>"string"==typeof e))throw new TypeError("weather must be a object with strings, received "+typeof e);this.#ri=e}set currentSeason(e){if(this._checkDestroyed(),"string"!=typeof e||!this.#Zn.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#Zn).map(e=>e[0]).join(", ")}, received ${e}`);this.#si=e}set currentDay(e){if(this._checkDestroyed(),"number"!=typeof e||e<1||e>this.#ci[this.#li-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#ai=e}set currentMonth(e){if(this._checkDestroyed(),"number"!=typeof e||"number"!=typeof this.#ci[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#li=e}set currentYear(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("currentYear must be a positive number non-zero, received "+typeof e);this.#ui=e}set monthDays(e){if(this._checkDestroyed(),!Array.isArray(e))throw new TypeError("monthDays must be a array");if(!e.every(e=>"number"==typeof e))throw new TypeError("monthDays must have number values");this.#ci=[...e]}set weatherDuration(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("weatherDuration must be a non-null object");if("number"!=typeof e.min||"number"!=typeof e.max)throw new TypeError("weatherDuration.min and weatherDuration.max must be numbers");this.#di={...e}}set weatherTimeLeft(e){if(this._checkDestroyed(),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#fi=e}get weatherConfig(){const e={},t={};for(const t in this.#hi.hours)e[t]={...this.#hi.hours[t]};for(const e in this.#hi.seasons)t[e]={...this.#hi.seasons[e]};return{default:{...this.#hi.default},day:{...this.#hi.day},night:{...this.#hi.night},hours:e,seasons:t}}set weatherConfig(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError(`weatherConfig must be a non-null object, received ${e}`);const t=["default","day","night","hours","seasons"];for(const r of t)if(!(r in e))throw new TypeError(`weatherConfig is missing required property "${r}".`);const r={},n={},i=(e,t)=>{if("object"!=typeof e||null===e)throw new TypeError(`${t} must be an object, received ${e}`);for(const r in e){const n=typeof e[r];if("number"!==n&&"function"!==n)throw new TypeError(`${t}["${r}"] must be a number or function, received ${n}`)}};for(const t in e.hours)i(e.hours[t],`hours["${t}"]`),r[t]={...e.hours[t]};for(const t in e.seasons)i(e.seasons[t],`seasons["${t}"]`),n[t]={...e.seasons[t]};const o=(e,t)=>(i(e,t),{...e});this.#hi={default:o(e.default,"default"),day:o(e.day,"day"),night:o(e.night,"night"),hours:r,seasons:n}}constructor(e=6,t=18){this.#ei=e,this.#ti=t}addSeason(e,t){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);if(!Array.isArray(t)||!t.every(e=>"number"==typeof e))throw new TypeError("Season values must be an array of numbers");this.#Zn.set(e,t)}removeSeason(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#Zn.delete(e),this.#si===e&&(this.#si="")}hasSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#Zn.has(e)}getSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#Zn.get(e);if(!t)throw new Error(`Season "${e}" not found`);return[...t]}setTime({hour:e=0,minute:t=0,second:r=0}){this._checkDestroyed(),this.currentSeconds=(e*this.#Yn+t*this.#Qn+r)%this.#Gn}addTime({hours:e=0,minutes:t=0,seconds:r=0}){this._checkDestroyed();let n=this.currentSeconds+e*this.#Yn+t*this.#Qn+r;for(;n>=this.#Gn;)n-=this.#Gn,this.nextDay();for(;n<0;)n+=this.#Gn,this.prevDay();this.currentSeconds=n,this.updateWeatherTimer((e*this.#Yn+t*this.#Qn+r)/this.#Qn)}getTime({withSeconds:e=!1,hourSize:t=this.#Yn,minuteSize:r=this.#Qn}={}){const n=Math.floor(this.currentSeconds/t),i=Math.floor(this.currentSeconds%t/r),o=this.currentSeconds%r;return{hour:n,minute:i,second:o,formatted:`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`+(e?`:${o.toString().padStart(2,"0")}`:"")}}isDay(){return this.#ei<this.#ti?this.#ii>=this.#ei*this.#Qn&&this.#ii<this.#ti*this.#Qn:this.#ii>=this.#ei*this.#Qn||this.#ii<this.#ti*this.#Qn}minutesUntilDay(){return this.timeUntil(this.#ei,"minutes")}secondsUntilDay(){return this.timeUntil(this.#ei,"seconds")}hoursUntilDay(){return this.timeUntil(this.#ei,"hours")}minutesUntilNight(){return this.timeUntil(this.#ti,"minutes")}secondsUntilNight(){return this.timeUntil(this.#ti,"seconds")}hoursUntilNight(){return this.timeUntil(this.#ti,"hours")}timeUntil(e,t){this._checkDestroyed();let r=e*this.#Yn-this.#ni;switch(r<=0&&(r+=this.#Gn),t){case"minutes":return r/this.#Qn;case"hours":return r/this.#Yn;default:return r}}setTo(e){this._checkDestroyed(),"day"===e?this.setTime({hour:this.#ei}):"night"===e&&this.setTime({hour:this.#ti})}nextDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++){this.#ai++;const e=this.#ci[this.#li-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#ai>e&&(this.#ai=1,this.#li++,this.#li>this.#ci.length&&(this.#li=1,this.#ui++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++)this.#ai--,this.#ai<1&&(this.#li--,this.#li<1&&(this.#li=this.#ci.length,this.#ui--),this.#ai=this.#ci[this.#li-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){this._checkDestroyed(),this.#Zn.forEach((e,t)=>{e.includes(this.#li)&&(this.#si=t)})}setWeatherConfig(e){this._checkDestroyed(),this.#hi={...this.#hi,...e}}setWeatherDuration(e,t){this._checkDestroyed(),this.#di.min=e,this.#di.max=t}updateWeatherTimer(e){this._checkDestroyed(),this.#fi-=e,this.#fi<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){this._checkDestroyed();const n=this.#ri;n[e]=t,this.weather=n,this.#fi=r??this._randomInRange(this.#di.min,this.#di.max)}chooseNewWeather({customWeather:e,where:t="main"}={}){this._checkDestroyed();let r={};const n=e=>{for(const[t,n]of Object.entries(e)){let e=n;"function"==typeof e&&(e=e({hour:Math.floor(this.#ii/this.#Qn),minute:this.#ii%this.#Qn,currentMinutes:this.#ii,isDay:this.isDay(),season:this.#si,weather:this.#ri})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};n(this.#hi.default||{});for(const e in this.#hi.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#Qn+(r||0)}),i=this.#ii;(t<=r?i>=t&&i<=r:i>=t||i<=r)&&n(this.#hi.hours[e])}this.isDay()&&this.#hi.day?n(this.#hi.day):!this.isDay()&&this.#hi.night&&n(this.#hi.night),this.#hi.seasons?.[this.#si]&&n(this.#hi.seasons[this.#si]),e&&"object"==typeof e&&n(e);const i=Object.entries(r).filter(([,e])=>e>0);if(!i.length)return this.#ri[t]=null,null;const o=i.reduce((e,[,t])=>e+t,0);let s=Math.random()*o;for(const[e,r]of i){if(s<r)return this.#ri[t]=e,this.#fi=this._randomInRange(this.#di.min,this.#di.max),e;s-=r}return this.#ri[t]=null,null}_randomInRange(e,t){return Math.floor(Math.random()*(t-e+1))+e}addMoon(e,t,r,n=0){this._checkDestroyed();const i=Math.max(1,t);return this.#Xn.push({name:e,cycleLength:i,currentPhase:(n%i+i)%i,phaseNames:r}),this.#Xn.length-1}removeMoon(e){this._checkDestroyed(),this.#Xn=this.#Xn.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#Xn)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#Xn)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){this._checkDestroyed();const r=this.#Xn[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase+t)%r.cycleLength}rewindMoon(e,t=1){this._checkDestroyed();const r=this.#Xn[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase-t+r.cycleLength)%r.cycleLength}moonExists(e){return!!this.#Xn[e]}getMoon(e){let t;if("number"==typeof e){if(t=this.#Xn[e],!t)throw new RangeError(`No moon found at index ${e}`)}else{if(!e||"object"!=typeof e||"string"!=typeof e.name||"number"!=typeof e.cycleLength||"number"!=typeof e.currentPhase)throw new TypeError("Invalid moon reference. Expected a number index or a MoonRaw object, received "+typeof e);t=e}return{name:t.name,phaseIndex:t.currentPhase,phaseName:t.phaseNames?t.phaseNames[t.currentPhase]??String(t.currentPhase):String(t.currentPhase),cycleLength:t.cycleLength}}_checkDestroyed(){if(this.#pr)throw new Error("This instance has been destroyed and can no longer be used.")}destroy(){this.#pr||(this.#Zn.clear(),this.#Xn.length=0,this.#ei=0,this.#ti=0,this.#ni=0,this.#ii=0,this.#oi=0,this.#ai=1,this.#li=1,this.#ui=1,this.#fi=0,this.#si="",this.#ri={main:null},this.#ci=[],this.#hi.default={},this.#hi.day={},this.#hi.night={},this.#hi.hours={},this.#hi.seasons={},this.#di={min:0,max:0},this.#pr=!0)}};class Qt{#Ct=new Lt;#On(e,...t){return this.#Ct.emit(e,...t)}setThrowOnMaxListeners(e){return this.#Ct.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Ct.getThrowOnMaxListeners()}prependListener(e,t){return this.#Ct.prependListener(e,t)}prependListenerOnce(e,t){return this.#Ct.prependListenerOnce(e,t)}appendListener(e,t){return this.#Ct.appendListener(e,t)}appendListenerOnce(e,t){return this.#Ct.appendListenerOnce(e,t)}on(e,t){return this.#Ct.on(e,t)}once(e,t){return this.#Ct.once(e,t)}off(e,t){return this.#Ct.off(e,t)}offAll(e){return this.#Ct.offAll(e)}offAllTypes(){return this.#Ct.offAllTypes()}listenerCount(e){return this.#Ct.listenerCount(e)}listeners(e){return this.#Ct.listeners(e)}onceListeners(e){return this.#Ct.onceListeners(e)}allListeners(e){return this.#Ct.allListeners(e)}eventNames(){return this.#Ct.eventNames()}setMaxListeners(e){return this.#Ct.setMaxListeners(e)}getMaxListeners(){return this.#Ct.getMaxListeners()}#pr=!1;#pi;#mi;#gi=[];#yi=[];#wi=[];#bi=new Map;#vi=new Set;#Ei=new Map;#Ti;#Si=new Map;#xi=new Map;get isDestroyed(){return this.#pr}get freq(){return Object.fromEntries(this.#xi)}get size(){return this.#Si.size}get normalization(){return this.#pi}set normalization(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("normalization must be a non-empty string (e.g., 'relative', 'softmax').");this.#pi=e}get seed(){return this.#mi}set seed(e){if(this._checkDestroyed(),null!==e&&("number"!=typeof e||!Number.isFinite(e)))throw new TypeError("seed must be a finite number or null.");this.#mi=e,null!==e&&(this.#Ti=this._makeSeededRng(e))}get globalModifiers(){return[...this.#gi]}set globalModifiers(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("globalModifiers must be an array of functions (WeightsCallback).");this.#gi=e}get temporaryModifiers(){return[...this.#yi]}set temporaryModifiers(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>e&&"function"==typeof e.fn&&Number.isInteger(e.uses)&&e.uses>0))throw new TypeError("temporaryModifiers must be an array of objects { fn: function, uses: positive integer }.");this.#yi=e}get conditionalRules(){return[...this.#wi]}set conditionalRules(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#wi=e}get pitySystems(){return Object.fromEntries(this.#bi)}set pitySystems(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e&&"number"==typeof e.threshold&&"number"==typeof e.increment&&"number"==typeof e.cap&&"number"==typeof e.counter&&"number"==typeof e.currentAdd)))throw new TypeError("pitySystems must be a Map<string, Pity> with all numeric fields.");this.#bi=e}get exclusions(){return Array.from(this.#vi)}set exclusions(e){if(this._checkDestroyed(),!(e instanceof Set&&[...e].every(e=>"string"==typeof e)))throw new TypeError("exclusions must be a Set<string>.");this.#vi=e}get groups(){const e={};return this.#Ei.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e instanceof Set&&[...e].every(e=>"string"==typeof e))))throw new TypeError("groups must be a Map<string, Set<string>>.");this.#Ei=e}get rng(){return this.#Ti}set rng(e){if(this._checkDestroyed(),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#Ti=e}get items(){const e={};return this.#Si.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e&&"string"==typeof e.id&&"string"==typeof e.label&&"number"==typeof e.baseWeight&&e.groups instanceof Set&&"boolean"==typeof e.locked&&"object"==typeof e.meta)))throw new TypeError("items must be a Map<string, ItemData> with valid item structures.");this.clearList(),this.#Si=e}constructor(e={}){const{rng:t=null,seed:r=null,normalization:n="relative"}=e;this.#pi=n,this.#mi=r,"function"==typeof t?this.#Ti=t:null!==this.#mi?this.#Ti=this._makeSeededRng(this.#mi):this.#Ti=Math.random,this.#mi=r??null}_checkDestroyed(){if(this.#pr)throw new Error("This instance has been destroyed and can no longer be used.")}hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Si.has(e)}addItem(e,t={}){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("object"!=typeof t||null===t)throw new TypeError("opts must be an object");let{weight:r=1,label:n=e,meta:i={},groups:o=[]}=t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError("weight must be a non-negative number");if("string"!=typeof n)throw new TypeError("label must be a string");if("object"!=typeof i||null===i)throw new TypeError("meta must be an object");if(!(Array.isArray(o)||o instanceof Set))throw new TypeError("groups must be an array or a Set of strings");o=Array.isArray(o)?o:[...o];for(const e of o)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const s={id:e,label:n,baseWeight:Math.max(0,Number(r)||0),meta:{...i},groups:new Set(o),locked:!1};this.#Si.set(e,s);for(const t of o)this._ensureGroup(t).add(e);return this.#On("itemAdded",s),s}removeItem(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#Si.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#Ei.get(r);t&&t.delete(e)}return this.#Si.delete(e),this.#On("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("weight must be a non-negative number");const r=this.#Si.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.#On("weightChanged",{id:e,weight:r.baseWeight})}getItem(e){if("string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#Si.get(e)??null}listItems(){return Array.from(this.#Si.values()).map(e=>({...e}))}clearList(){this._checkDestroyed(),this.#Si.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#gi.includes(e)}addGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#gi.push(e)}removeGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#gi=this.#gi.filter(t=>t!==e)}hasTemporaryModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#yi.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("uses must be a number");this.#yi.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#yi.length;return this.#yi=this.#yi.filter(t=>t.fn!==e),this.#yi.length!==t}hasConditionalRule(e){if("function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#wi.includes(e)}addConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#wi.push(e)}removeConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#wi.length;return this.#wi=this.#wi.filter(t=>t!==e),this.#wi.length!==t}hasPity(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#bi.has(e)}configurePity(e,t){if(this._checkDestroyed(),!this.#Si.has(e))throw new Error("Item not found");if("object"!=typeof t||null===t)throw new TypeError("cfg must be an object");const{threshold:r,increment:n,cap:i=1/0}=t;if("number"!=typeof r||r<=0)throw new TypeError("threshold must be a positive number");if("number"!=typeof n)throw new TypeError("increment must be a number");if("number"!=typeof i)throw new TypeError("cap must be a number");this.#bi.set(e,{threshold:Math.max(1,r),increment:Number(n)||0,cap:Number(i)||1/0,counter:0,currentAdd:0})}resetPity(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#bi.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){this._checkDestroyed(),this.#bi.clear()}hasExclusion(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#vi.has(e)}excludeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#vi.add(e)}includeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#vi.delete(e)}_ensureGroup(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#Ei.get(e);return t||(t=new Set,this.#Ei.set(e,t)),t}hasInGroup(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Ei.get(t);return!!r&&r.has(e)}addToGroup(e,t){if(this._checkDestroyed(),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Si.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(this._checkDestroyed(),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Ei.get(t);r&&r.delete(e);const n=this.#Si.get(e);n&&n.groups.delete(t)}clearFreqs(){this._checkDestroyed(),this.#xi.clear()}resetFreq(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#xi.delete(e)}computeEffectiveWeights(e={}){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("computeEffectiveWeights: parameter 'context' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("computeEffectiveWeights: context.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("computeEffectiveWeights: context.metadata must be a non-null object if provided, got "+typeof e.metadata);const t=new Map;for(const[e,r]of this.#Si)t.set(e,r.baseWeight);for(const r of this.#gi){const n=r(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#yi){const n=r.fn(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#wi){const n=r(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const[e,r]of this.#bi)if(t.has(e)&&r.counter>r.threshold){r.currentAdd=Math.min(r.cap,r.currentAdd+r.increment);const n=t.get(e);n&&t.set(e,n+r.currentAdd)}for(const e of this.#vi)t.delete(e);for(const[e,r]of Array.from(t.entries()))r>0||t.delete(e);return t}_weightsToDistribution(e){if(this._checkDestroyed(),!(e instanceof Map))throw new TypeError("_weightsToDistribution: parameter 'weights' must be a Map, got "+typeof e);for(const[t,r]of e){if("string"!=typeof t)throw new TypeError("_weightsToDistribution: weights Map key must be string, got "+typeof t);if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError(`_weightsToDistribution: weights Map value must be finite non-negative number, got ${r} for key ${t}`)}const t=Array.from(e.entries()).map(([e,t])=>({id:e,weight:t}));if(0===t.length)return[];if("softmax"===this.#pi){const e=Math.max(...t.map(e=>e.weight)),r=t.map(t=>Math.exp(t.weight-e)),n=r.reduce((e,t)=>e+t,0);let i=0;return t.map((e,t)=>{const o=r[t]/n;return i+=o,{id:e.id,weight:e.weight,p:o,cumulative:i}})}{const e=t.reduce((e,t)=>e+t.weight,0);let r=0;return t.map(t=>{const n=t.weight/e;return r+=n,{id:t.id,weight:t.weight,p:n,cumulative:r}})}}drawOne(e={}){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("drawOne: parameter 'opts' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("drawOne: opts.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("drawOne: opts.metadata must be a non-null object if provided, got "+typeof e.metadata);const t={previousDraws:e.previousDraws??[],metadata:e.metadata??{},activeModifiers:[...this.#yi]},r=this.computeEffectiveWeights(t),n=this._weightsToDistribution(r);if(!n.length)return null;const i=this.#Ti(),o=n.find(e=>i<=e.cumulative)??n[n.length-1];for(const[e,t]of this.#bi)e===o.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const s=this.#Si.get(o.id);if(!s)return null;const a={id:s.id,label:s.label,meta:{...s.meta},prob:o.p};return this.#On("draw",a),a&&this.#xi.set(a.id,(this.#xi.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){this._checkDestroyed();for(let e=this.#yi.length-1;e>=0;--e){const t=this.#yi[e];t.uses-=1,t.uses<=0&&this.#yi.splice(e,1)}}drawMany(e=1,t={}){if(this._checkDestroyed(),!Number.isInteger(e)||e<=0)throw new TypeError(`drawMany: parameter 'count' must be a positive integer, got ${e}`);if("object"!=typeof t||null===t)throw new TypeError("drawMany: parameter 'opts' must be a non-null object, got "+typeof t);if("withReplacement"in t&&"boolean"!=typeof t.withReplacement)throw new TypeError("drawMany: opts.withReplacement must be boolean if provided, got "+typeof t.withReplacement);if("ensureUnique"in t&&"boolean"!=typeof t.ensureUnique)throw new TypeError("drawMany: opts.ensureUnique must be boolean if provided, got "+typeof t.ensureUnique);if("metadata"in t&&void 0!==t.metadata&&("object"!=typeof t.metadata||null===t.metadata))throw new TypeError("drawMany: opts.metadata must be a non-null object if provided, got "+typeof t.metadata);if("previousDraws"in t&&!Array.isArray(t.previousDraws))throw new TypeError("drawMany: opts.previousDraws must be an array if provided, got "+typeof t.previousDraws);const r=t.withReplacement??!0,n=t.ensureUnique??!1,i=[],o=t.previousDraws??[];if(!r&&n){const r=new Set;for(let n=0;n<e;++n){const e=new Set(this.#vi);for(const e of r)this.#vi.add(e);const n=this.drawOne({previousDraws:o,metadata:t.metadata});if(this.#vi=e,!n)break;i.push(n),r.add(n.id),o.push(n)}return i}for(let n=0;n<e;++n){const e=this.drawOne({previousDraws:o,metadata:t.metadata});if(!e)break;i.push(e),o.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of i)this.includeItem(e.id);return i}exportToJson(){return this._checkDestroyed(),{items:Array.from(this.#Si.values()).map(e=>({id:e.id,label:e.label,baseWeight:e.baseWeight,meta:e.meta,groups:Array.from(e.groups),locked:!1})),pity:Array.from(this.#bi.entries()),exclusions:Array.from(this.#vi),normalization:this.#pi,seed:this.#mi}}loadFromJson(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("data must be a non-null object");if(!Array.isArray(e.items)||!Array.isArray(e.pity)||!Array.isArray(e.exclusions))throw new TypeError("data must have items, pity, and exclusions arrays");if("string"!=typeof e.normalization)throw new TypeError("data.normalization must be a string");if(void 0!==e.seed&&null!==e.seed&&"number"!=typeof e.seed)throw new TypeError("data.seed must be a number, null, or undefined");this.clearList();for(const t of e.items){if("object"!=typeof t||null===t)throw new TypeError("Each item must be a non-null object");if("string"!=typeof t.id||!t.id.trim())throw new TypeError("Each item.id must be a non-empty string");if("string"!=typeof t.label)throw new TypeError(`Item with id "${t.id}" has invalid label; must be string`);if("number"!=typeof t.baseWeight||!Number.isFinite(t.baseWeight)||t.baseWeight<0)throw new TypeError(`Item with id "${t.id}" has invalid baseWeight; must be a finite non-negative number`);if(void 0!==t.groups&&!Array.isArray(t.groups))throw new TypeError(`Item with id "${t.id}" has invalid groups; must be an array of strings`);if(t.groups&&!t.groups.every(e=>"string"==typeof e))throw new TypeError(`Item with id "${t.id}" has groups containing non-string values`);if(void 0!==t.meta&&("object"!=typeof t.meta||null===t.meta))throw new TypeError(`Item with id "${t.id}" has invalid meta; must be an object`);this.#Si.set(t.id,{id:t.id,label:t.label,baseWeight:t.baseWeight,meta:t.meta||{},groups:new Set(t.groups||[]),locked:!1});for(const e of t.groups||[])this._ensureGroup(e).add(t.id)}this.pitySystems=new Map(e.pity||[]),this.exclusions=new Set(e.exclusions||[]),this.normalization=e.normalization,void 0!==e.seed&&(this.seed=e.seed)}clone(){this._checkDestroyed();const e=new Qt;return e.#pi=this.#pi,e.#mi=this.#mi,e.#gi=[...this.#gi],e.#yi=this.#yi.map(e=>({fn:e.fn,uses:e.uses})),e.#wi=[...this.#wi],e.#bi=new Map([...this.#bi.entries()].map(([e,t])=>[e,{...t}])),e.#vi=new Set(this.#vi),e.#Ei=new Map([...this.#Ei.entries()].map(([e,t])=>[e,new Set(t)])),e.#Ti=this.#Ti,e.#Si=new Map([...this.#Si.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#xi=new Map(this.#xi),e}_makeSeededRng(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("seed must be a finite number");let t=e>>>0;return function(){t+=1831565813;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}destroy(){this.#pr||(this.#pr=!0,this.#bi.clear(),this.#vi.clear(),this.#Ei.clear(),this.#Si.clear(),this.#xi.clear(),this.#gi=[],this.#yi=[],this.#wi=[],this.#mi=null)}}const Zt=Qt,Xt=class{#ne;get data(){return this.#ne}set data(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ne=e}get size(){return Array.isArray(this.#ne)?this.#ne.length:this.#ne.size}constructor(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ne=e}get({page:e,perPage:t,filter:r}){if(!Number.isInteger(e)||e<1)throw new RangeError("Page number must be a positive integer.");if(!Number.isInteger(t)||t<1)throw new RangeError("Items per page must be a positive integer.");const n=Array.isArray(this.#ne)?this.#ne:Array.from(this.#ne);let i=n;if(r)if("function"==typeof r)i=n.filter((e,t,n)=>r(e,t,n));else{if("object"!=typeof r)throw new TypeError("Filter must be an object or a function");i=n.filter(e=>Object.entries(r).every(([t,r])=>{const n=e[t];return r instanceof RegExp?r.test(n):n===r}))}else i=n;const o=i.length,s=Math.max(1,Math.ceil(o/t)),a=Math.min(e,s),l=(a-1)*t,u=l+t,c=a>1,h=a<s;return{items:i.slice(l,u),page:a,perPage:t,totalItems:o,totalPages:s,hasPrev:c,hasNext:h}}};class er{static#Ai=new Map;static get itemRegistry(){const e={},t=Object.fromEntries(er.#Ai);for(const r in t)e[r]={...t[r],metadata:{...t[r].metadata}};return e}static defineItem(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be a valid object.");if(!e.id||"string"!=typeof e.id)throw new TypeError("Item must have a valid string 'id'.");if(void 0!==e.weight&&("number"!=typeof e.weight||e.weight<0))throw new TypeError(`weight must be a number >= 0. Received: ${e.weight}`);if(void 0!==e.maxStack&&(!Number.isInteger(e.maxStack)||e.maxStack<=0))throw new TypeError(`maxStack must be a positive integer. Received: ${e.maxStack}`);if(void 0!==e.metadata&&"object"!=typeof e.metadata)throw new TypeError("metadata must be an object.");if(void 0!==e.onUse&&null!==e.onUse&&"function"!=typeof e.onUse)throw new TypeError("onUse must be a function or null.");if(void 0!==e.type&&null!==e.type&&"string"!=typeof e.type)throw new TypeError("type must be a string or null.");er.#Ai.set(e.id,{id:e.id,weight:e.weight||0,maxStack:e.maxStack||1,metadata:e.metadata||{},type:e.type??null,onUse:"function"==typeof e.onUse?e.onUse:null})}static removeItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return er.#Ai.delete(e)}static hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return er.#Ai.has(e)}static getItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");const t=er.#Ai.get(e);if(!t)throw new Error(`Item '${e}' not defined in registry.`);return t}#Ii=new Map;#Ct={add:[],remove:[],use:[],set:[]};#Si=[];#Ci;#Mi;#Li;#Di;get maxStack(){return this.#Ci}set maxStack(e){if(!Number.isInteger(e)||Number.isFinite(e)&&e<=0)throw new TypeError(`maxStack must be a positive integer. Received: ${e}`);this.#Ci=e}get maxSize(){return this.#Mi}set maxSize(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSize must be null or a positive integer. Received: ${e}`);this.#Mi=e}get maxSlots(){return this.#Li}set maxSlots(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSlots must be null or a positive integer. Received: ${e}`);this.#Li=e}get maxWeight(){return this.#Di}set maxWeight(e){if(null!==e&&("number"!=typeof e||e<=0))throw new TypeError(`maxWeight must be null or a positive number. Received: ${e}`);this.#Di=e}get events(){return{add:[...this.#Ct.add],remove:[...this.#Ct.remove],use:[...this.#Ct.use],set:[...this.#Ct.set]}}get items(){return[...this.#Si].map(e=>e?this.#ki(e):null)}get specialSlots(){return new Map([...this.#Ii.entries()].map(([e,t])=>[e,{type:t.type,item:t.item?this.#ki(t.item):null}]))}get size(){const e=this.getAllItems();let t=0;for(const r of e)t+=r.quantity;return t}get slotsSize(){return this.getAllItems().length}get weight(){return this.getAllItems().reduce((e,t)=>{const r=er.getItem(t.id);return e+(r?.weight||0)*t.quantity},0)}_cleanNulls(){let e=this.#Si.length-1;for(;e>=0&&null===this.#Si[e];)e--;this.#Si=this.#Si.slice(0,e+1)}constructor(e={}){if("object"!=typeof e||null===e)throw new TypeError("`options` must be an object.");if(void 0!==e.maxWeight&&null!==e.maxWeight&&"number"!=typeof e.maxWeight)throw new TypeError("`maxWeight` must be a number or null.");if(void 0!==e.maxSlots&&null!==e.maxSlots&&"number"!=typeof e.maxSlots)throw new TypeError("`maxSlots` must be a number or null.");if(void 0!==e.maxSize&&null!==e.maxSize&&"number"!=typeof e.maxSize)throw new TypeError("`maxSize` must be a number or null.");if(void 0!==e.maxStack&&"number"!=typeof e.maxStack)throw new TypeError("`maxStack` must be a number.");if(void 0!==e.specialSlots&&"object"!=typeof e.specialSlots)throw new TypeError("`specialSlots` must be an object if defined.");if(this.#Di=e.maxWeight??null,this.#Li=e.maxSlots??null,this.#Mi=e.maxSize??null,this.#Ci=e.maxStack??1/0,e.specialSlots)for(const t in e.specialSlots){const r=e.specialSlots[t];if("object"!=typeof r||null===r)throw new TypeError("Each `specialSlot` entry must be an object.");if(void 0!==r.type&&null!==r.type&&"string"!=typeof r.type)throw new TypeError("`specialSlot.type` must be a string or null.");this.#Ii.set(t,{type:r.type??null,item:null})}}hasSpace({weight:e=0,sizeLength:t=0,slotsLength:r=0}={}){if("number"!=typeof e)throw new TypeError("`weight` must be a number.");if("number"!=typeof t)throw new TypeError("`sizeLength` must be a number.");if("number"!=typeof r)throw new TypeError("`slotsLength` must be a number.");return!(this.areFull(t)||this.areFullSlots(r)||this.isHeavy(e))}isHeavy(e=0){if("number"!=typeof e)throw new TypeError("`extraWeight` must be a number.");return null!==this.#Di&&this.weight+e>this.#Di}areFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Mi&&this.size+e>this.#Mi}isFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Mi&&this.size+e>=this.#Mi}areFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Li&&this.slotsSize+e>this.#Li}isFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Li&&this.slotsSize+e>=this.#Li}#Ni(e,t){if("string"!=typeof e)throw new TypeError("`type` must be a string.");if("object"!=typeof t||null===t)throw new TypeError("`payload` must be an object.");if(this.#Ct[e])for(const r of this.#Ct[e])r(t)}off(e,t){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");if("function"!=typeof t)throw new TypeError("`callback` must be a function.");if(!this.#Ct[e])return;const r=this.#Ct[e],n=r.indexOf(t);-1!==n&&r.splice(n,1)}offAll(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");this.#Ct[e]&&(this.#Ct[e]=[])}cloneEventCallbacks(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");return this.#Ct[e]?[...this.#Ct[e]]:[]}onAddItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Ct.add.push(e)}onSetItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Ct.set.push(e)}onRemoveItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Ct.remove.push(e)}onUseItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Ct.use.push(e)}compactInventory(){this.#Si=this.#Si.filter((e,t)=>{const r=null!==e;return r||this.#Ni("remove",{index:t,item:null,isCollection:!0,specialSlot:null,remove:()=>{}}),r})}addItem({itemId:e,quantity:t=1,metadata:r={},forceSpace:n=!1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new TypeError("`quantity` must be a positive number.");if("object"!=typeof r||null===r)throw new TypeError("`metadata` must be an object.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be a boolean.");const i=er.getItem(e);let o=t;const s=i.maxStack<=this.#Ci?i.maxStack:this.#Ci,a=[],l=(e,t)=>JSON.stringify(e)===JSON.stringify(t);let u=!0;for(;o>0&&u;){u=!1;for(const t in this.#Si){const c=this.#Si[t];if(c&&c.id===e&&c.quantity<s&&l(c.metadata,r)){const e=Math.min(s-c.quantity,o);if(!n&&!this.hasSpace({weight:i.weight*e,sizeLength:e}))continue;c.quantity+=e,o-=e,u=!0;const r=Number(t),l=a.findIndex(e=>e.index===r);if(l<0?a.push({index:r,quantity:e}):a[l].quantity+=e,this.#Ni("add",{item:this.#ki(c),index:r,isCollection:!0,specialSlot:null,remove:this.#_i({locationType:"normal",slotIndex:r,forceSpace:n,item:c})}),o<=0)break}}}if(o>0)for(const t in this.#Si)if(null===this.#Si[t]){const l=Math.min(s,o);if(!n&&!this.hasSpace({weight:i.weight*l,sizeLength:l}))continue;const u={id:e,quantity:l,metadata:r};this.#Si[t]=u,o-=l;const c=Number(t),h=a.findIndex(e=>e.index===c);if(h<0?a.push({index:c,quantity:l}):a[h].quantity+=l,this.#Ni("add",{item:this.#ki(u),index:c,isCollection:!0,specialSlot:null,remove:this.#_i({locationType:"normal",slotIndex:c,forceSpace:n,item:u})}),o<=0)break}for(;o>0;){const t=Math.min(s,o);if(!n&&!this.hasSpace({weight:i.weight*t,sizeLength:t,slotsLength:1}))break;const l={id:e,quantity:t,metadata:r};this.#Si.push(l);const u=this.#Si.length-1,c=a.findIndex(e=>e.index===u);c<0?a.push({index:u,quantity:t}):a[c].quantity+=t,this.#Ni("add",{item:this.#ki(l),index:u,isCollection:!0,specialSlot:null,remove:this.#_i({locationType:"normal",slotIndex:u,forceSpace:n,item:l})}),o-=t}return{remaining:o,placesAdded:a}}getItemFrom(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if(e<0||e>=this.#Si.length)throw new Error(`Slot index '${e}' out of bounds .`);return this.#Si[e]?this.#ki(this.#Si[e]):null}setItem({slotIndex:e,item:t,forceSpace:r=!1}){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const n=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!n)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const i=t?er.#Ai.get(t.id):null;if(null!==t&&!i)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);if(i&&t){const e=i.maxStack<=this.#Ci?i.maxStack:this.#Ci;if(t.quantity>e)throw new Error(`Item '${t.id}' exceeds max stack size. Allowed: ${e}, got: ${t.quantity}.`)}if(null!==this.#Li&&(e<0||e>=this.#Li))throw new Error(`Slot index ${e} out of range.`);const o=this.#Si[e]??null,s=o?er.#Ai.get(o.id)??null:null,a=(e,t)=>t?t.weight*(e?e.quantity:0):0,l=e=>e?e.quantity:0;if(!r&&!this.hasSpace({weight:a(t,i)-a(o,s),sizeLength:l(t)-l(o)}))throw new Error("Inventory is full or overweight.");for(;this.#Si.length<=e;)this.#Si.push(null);this.#Si[e]=t,this._cleanNulls(),this.#Ni("set",{index:e,isCollection:!0,item:t?this.#ki(t):null,specialSlot:null,remove:t?this.#_i({locationType:"normal",slotIndex:e,forceSpace:r,item:t}):()=>{}})}deleteItem(e,t=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be a boolean.");this.setItem({slotIndex:e,item:null,forceSpace:t})}moveItem(e,t,r=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`fromIndex` must be an integer.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`toIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const n=this.#Si[e];if(!n)throw new Error(`No item found in slot ${e}.`);this.setItem({slotIndex:t,item:n,forceSpace:r}),this.setItem({slotIndex:e,item:null,forceSpace:r})}removeItem({itemId:e,metadata:t=null,quantity:r=1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if(null!==t&&"object"!=typeof t)throw new TypeError("`metadata` must be an object or null.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");let n=r;const i=(e,t)=>JSON.stringify(e)===JSON.stringify(t);for(let r=0;r<this.#Si.length;r++){const o=this.#Si[r];if(o&&o.id===e&&(null===t||i(o.metadata,t))){const e=Math.min(o.quantity,n);o.quantity-=e,n-=e;const t=Number(r);if(o.quantity<=0&&(this.#Si[r]=null),n<=0)return this._cleanNulls(),this.#Ni("remove",{index:t,item:this.#ki(o),isCollection:!0,specialSlot:null,remove:this.#_i({locationType:"normal",slotIndex:t,item:o})}),!0}}return this._cleanNulls(),this.#Ii.forEach((r,o)=>{if(n>0&&r.item&&r.item.id===e&&(null===t||i(r.item.metadata,t))){const e=Math.min(r.item.quantity,n);r.item.quantity-=e,r.item.quantity<0&&(r.item.quantity=0),n-=e,r.item.quantity<=0&&(r.item=null),this.#Ii.set(o,r),this.#Ni("remove",{index:null,item:r.item?this.#ki(r.item):null,isCollection:!1,specialSlot:o,remove:r.item?this.#_i({locationType:"special",specialSlot:o,item:r.item}):()=>{}})}}),n<=0}#_i({locationType:e,specialSlot:t,slotIndex:r,item:n,forceSpace:i=!1}){if("normal"!==e&&"special"!==e)throw new TypeError("`locationType` must be 'normal' or 'special'.");if("boolean"!=typeof i)throw new TypeError("`forceSpace` must be boolean.");if(!n||"object"!=typeof n)throw new TypeError("`item` must be an InventoryItem object.");if("special"===e&&t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string when locationType is 'special'.");if("normal"===e&&"number"!=typeof r)throw new TypeError("`slotIndex` must be a number when locationType is 'normal'.");return(o=i)=>{if("special"===e&&t){const e=this.#Ii.get(t);if(!e?.item)throw new Error(`Special slot '${t}' is empty.`);e.item.quantity>1?(e.item.quantity-=1,this.#Ii.set(t,e)):this.setSpecialSlot({slotId:t,item:null,forceSpace:o})}else{if("number"!=typeof r)throw new Error("Invalid remove operation: no valid slotIndex or specialSlot provided.");n.quantity>1?this.setItem({slotIndex:r,item:{...n,quantity:n.quantity-1},forceSpace:o}):this.setItem({slotIndex:r,item:null,forceSpace:o})}}}useItem({slotIndex:e,specialSlot:t,forceSpace:r=!1},...n){if(void 0!==e&&("number"!=typeof e||!Number.isInteger(e)))throw new TypeError("`slotIndex` must be an integer if provided.");if(void 0!==t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string if provided.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");let i=null,o="normal",s=null;if(t){if(!this.#Ii.has(t))throw new Error(`Special slot '${t}' not found.`);i=this.#Ii.get(t).item,o="special"}else s=this.#Si,i=s[e??-1]??null,o="normal";if(!i)throw new Error("special"===o?`No item found in special slot '${t}'.`:`No item found in slot ${e} of inventory.`);const a=er.getItem(i.id);if(a.onUse){const l={inventory:this,item:this.#ki(i),index:e??null,specialSlot:t??null,isCollection:!!s,itemDef:a,remove:this.#_i({locationType:o,specialSlot:t,slotIndex:e,forceSpace:r,item:i}),...n},u=a.onUse(l);return this.#Ni("use",l),u}return null}hasSpecialSlot(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");return this.#Ii.has(e)}getSpecialItem(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Ii.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Ii.get(e);return t?.item?this.#ki(t.item):null}getSpecialSlotType(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Ii.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Ii.get(e);return t?.type??null}setSpecialSlot({slotId:e,item:t,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Ii.has(e))throw new Error(`Special slot '${e}' not found.`);const n=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!n)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const i=t?er.#Ai.get(t.id):null;if(null!==t&&!i)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);const o=this.#Ii.get(e);if(!o)throw new Error(`Special slot ${e} out of range for slot '${e}'.`);const s=o.item?er.#Ai.get(o.item.id):null,a=(e,t)=>t?t.weight*(e?1:0):0,l=e=>e?1:0;if(!r&&!this.hasSpace({weight:a(t,i)-a(o.item,s),sizeLength:l(t)-l(o.item)}))throw new Error("Inventory is full or overweight.");o.item=t,this.#Ni("set",{index:null,item:t?this.#ki(t):null,isCollection:!1,specialSlot:e,remove:t?this.#_i({locationType:"special",specialSlot:e,forceSpace:r,item:t}):()=>{}})}deleteSpecialItem(e,t=!1){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be boolean.");this.setSpecialSlot({slotId:e,item:null,forceSpace:t})}equipItem({slotId:e,slotIndex:t,quantity:r=1,forceSpace:n=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`slotIndex` must be an integer.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be boolean.");if(r<=0||!Number.isFinite(r))throw new Error(`Invalid quantity '${r}'.`);if(!this.#Ii.has(e))throw new Error(`Special slot '${e}' does not exist.`);const i=this.getItemFrom(t);if(!i)throw new Error(`No item found in inventory slot ${t}.`);if(i.quantity<r)throw new Error(`Not enough quantity of item '${i.id}' in inventory slot.`);const o=er.getItem(i.id),s=this.#Ii.get(e);if(!s)throw new Error(`Slot '${e}' not defined in registry.`);const a=s.type??null;if(null!==a&&o.type!==a)throw new Error(`Item '${i.id}' cannot be equipped in slot '${e}'.`);const l=Math.min(o.maxStack,this.#Ci);if(s.item&&s.item.id===i.id){const t=Math.max(0,l-s.item.quantity);if(t<=0)return r;const n=Math.min(r,t);return this.removeItem({itemId:i.id,quantity:n,metadata:null}),s.item.quantity+=n,this.#Ii.set(e,s),r-n}s.item&&this.unequipItem({slotId:e,forceSpace:n});const u=Math.min(r,l);return this.removeItem({itemId:i.id,quantity:u,metadata:null}),s.item={id:i.id,quantity:u,metadata:i.metadata},this.#Ii.set(e,s),r-u}unequipItem({slotId:e,quantity:t=null,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(null!==t&&("number"!=typeof t||!Number.isFinite(t)||t<=0))throw new TypeError("`quantity` must be a positive number or null.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Ii.has(e))throw new Error(`Special slot '${e}' does not exist.`);const n=this.#Ii.get(e);if(!n)throw new Error(`Slot '${e}' not defined in registry.`);if(!n.item)return!1;const i=n.item,o=null===t?i.quantity:t;if(o<=0)throw new Error(`Invalid unequip quantity: ${o}`);if(o>i.quantity)throw new Error(`Not enough items in slot '${e}' to unequip.`);return this.addItem({itemId:i.id,quantity:o,metadata:i.metadata,forceSpace:r}),o===i.quantity?n.item=null:(i.quantity-=o,n.item=i),this.#Ii.set(e,n),!0}#ki(e){if(!e||"object"!=typeof e)throw new TypeError("`item` must be an InventoryItem object.");if("string"!=typeof e.id)throw new TypeError("`item.id` must be a string.");if("number"!=typeof e.quantity||!Number.isFinite(e.quantity))throw new TypeError("`item.quantity` must be a finite number.");if(!e.metadata||"object"!=typeof e.metadata)throw new TypeError("`item.metadata` must be an object.");return{id:e.id,quantity:e.quantity,metadata:{...e.metadata}}}getItemList(){return[...this.#Si].map((e,t)=>[e?this.#ki(e):null,t]).filter(e=>null!==e[0])}getAllItems(){const e=[...this.#Si].filter(e=>null!==e).map(this.#ki);return this.#Ii.forEach(t=>{const r=t.item;r&&e.push(r)}),e}getItemsByMetadata(e){if("function"!=typeof e)throw new TypeError("`filterFn` must be a function.");return this.getAllItems().filter(t=>{const r=er.getItem(t.id);return e(r.metadata,t)})}findItem(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().find(e)}findItems(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().filter(e)}getItemCount(e){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");return this.getAllItems().filter(t=>t.id===e).reduce((e,t)=>e+t.quantity,0)}hasItem(e,t=1){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("`quantity` must be a non-negative number.");return this.getItemCount(e)>=t}existsItemAt(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");return!!this.#Si[e]}clear(){this.clearAllItems(),this.clearAllEvents()}clearAllEvents(){this.#Ct={add:[],remove:[],use:[],set:[]}}clearAllItems(){this.clearItems(),this.clearSpecialItems()}clearItems(){for(let e=this.#Si.length-1;e>=0;e--)this.#Si[e]&&this.deleteItem(e,!0)}clearSpecialItems(){for(const e of this.#Ii.keys()){const t=this.#Ii.get(e);t?.item&&this.deleteSpecialItem(e,!0)}}clone(){const e=this.toObject();return er.fromObject(e)}toObject(){const e={};for(const[t,r]of this.#Ii.entries())e[t]={type:r?.type??null,item:r?.item?this.#ki(r.item):null};return{__schema:"TinyInventory",version:1,maxWeight:this.#Di,maxSlots:this.#Li,maxSize:this.#Mi,maxStack:this.#Ci,items:this.#Si.map(e=>e?this.#ki(e):null),specialSlots:e}}toJSON(e=0){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("`space` must be a non-negative number.");return JSON.stringify(this.toObject(),null,e)}static fromObject(e){if(!e||"object"!=typeof e)throw new TypeError("Invalid state: expected object.");if("TinyInventory"!==e.__schema||"number"!=typeof e.version)throw new TypeError("Invalid or missing schema header.");if(1!==e.version)throw new TypeError(`Unsupported TinyInventory state version: ${e.version}`);const t={};if(e.specialSlots&&"object"==typeof e.specialSlots)for(const r of Object.keys(e.specialSlots))t[r]={type:e.specialSlots[r]?.type??null};const r=new er({maxWeight:e.maxWeight??null,maxSlots:e.maxSlots??null,maxSize:e.maxSize??null,maxStack:e.maxStack??null,specialSlots:t});if(Array.isArray(e.items))for(const t in e.items){const n=e.items[t];if(null!==n){const e={id:String(n.id),quantity:Math.max(1,Number(n.quantity)||1),metadata:n.metadata&&"object"==typeof n.metadata?n.metadata:{}};r.setItem({slotIndex:Number(t),item:e,forceSpace:!0})}else r.setItem({slotIndex:Number(t),item:null,forceSpace:!0})}if(e.specialSlots&&"object"==typeof e.specialSlots)for(const[t,n]of Object.entries(e.specialSlots)){if(!r.hasSpecialSlot(t))continue;const e=n?.item;if(e&&e.id){const n={id:String(e.id),quantity:Math.max(1,Number(e.quantity)||1),metadata:e.metadata&&"object"==typeof e.metadata?e.metadata:{}};r.setSpecialSlot({slotId:t,item:n,forceSpace:!0})}}return r}static fromJSON(e){if("string"!=typeof e)throw new TypeError("`json` must be a string.");const t=JSON.parse(e);return er.fromObject(t)}}const tr=er,rr=class{#ji=null;#Oi=null;get sender(){return this.#ji}get receiver(){return this.#Oi}set sender(e){if(!(e instanceof tr&&this.receiver instanceof tr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#ji=e}set receiver(e){if(!(this.sender instanceof tr&&e instanceof tr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Oi=e}constructor(e,t){if(e||t){if(!(e instanceof tr&&t instanceof tr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.connect(e,t)}}connect(e,t){if(!(e instanceof tr&&t instanceof tr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#ji=e,this.#Oi=t}disconnect(){this.#ji=null,this.#Oi=null}invert(){const e=this.#ji,t=this.#Oi;this.#ji=t,this.#Oi=e}transferItem({slotIndex:e,specialSlot:t,quantity:r=1,receiverSlotIndex:n,forceSpace:i=!1,strict:o=!1}){if(!this.#ji||!this.#Oi)throw new Error("Sender and receiver inventories must be connected.");let s;if(t){if(s=this.#ji.getSpecialItem(t),!s)throw new Error(`No item found in sender special slot '${t}'.`)}else{if("number"!=typeof e)throw new Error("Must provide either slotIndex or specialSlot.");if(s=this.#ji.getItemFrom(e),!s)throw new Error(`No item found in sender slot ${e}.`)}if(s.quantity<r)throw new Error(`Sender does not have enough quantity of '${s.id}' to transfer.`);const a={id:s.id,quantity:r,metadata:s.metadata};let l;if(o)if("number"==typeof n){const e=this.#Oi.existsItemAt(n)?this.#Oi.getItemFrom(n):null;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${n} contains a different item.`);const t=tr.getItem(e.id).maxStack-e.quantity;if(a.quantity>t)throw new Error(`Strict mode: not enough space in receiver slot ${n}.`)}}else if(this.#Oi.clone().addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:i}).remaining>0)throw new Error("Strict mode: not enough space in receiver inventory.");if("number"==typeof n){const e=this.#Oi.existsItemAt(n)?this.#Oi.getItemFrom(n):null;let t=a.quantity;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${n} contains a different item.`);const r=tr.getItem(e.id).maxStack-e.quantity;t=Math.min(r,a.quantity),t>0&&this.#Oi.setItem({slotIndex:n,item:{...e,quantity:e.quantity+t},forceSpace:i})}else this.#Oi.setItem({slotIndex:n,item:a,forceSpace:i});l={remaining:a.quantity-t}}else l=this.#Oi.addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:i});const u=a.quantity-l.remaining;if(u>0)if(t)this.#ji.unequipItem({slotId:t,quantity:u,forceSpace:i});else if("number"==typeof e){const t=s.quantity-u;this.#ji.setItem({slotIndex:e,item:t>0?{...s,quantity:t}:null,forceSpace:i})}return l}transferMultiple(e){return e.map(e=>this.transferItem(e))}},nr=class{#Ri;#Bi={message:"We use cookies to improve your experience.",acceptText:"Accept All",rejectText:"Reject All",settingsText:"Manage Settings",categories:[],storageKey:"cookie-consent-preferences",onSave:e=>console.log("Preferences saved:",e),animationDuration:400,renderBar:null,renderModal:null};get preferences(){const e=localStorage.getItem(this.#Bi.storageKey);return e?JSON.parse(e):{}}get config(){return{...this.#Bi,categories:[...this.#Bi.categories]}}set config(e){this.validateConfig(e),this.#Bi=Object.assign(this.#Bi,e)}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be an object.");this.config=e;const t=this.loadPreferences();this.#Ri=t??{},t||this.showConsentBar()}validateConfig(e){if(void 0!==e.message&&"string"!=typeof e.message)throw new TypeError("Config.message must be a string.");if(["acceptText","rejectText","settingsText","storageKey"].forEach(t=>{if(void 0!==e[t]&&"string"!=typeof e[t])throw new TypeError(`Config.${t} must be a string.`)}),void 0!==e.categories){if(!Array.isArray(e.categories))throw new TypeError("Config.categories must be an array of Category objects.");e.categories.forEach((e,t)=>this.validateCategory(e,t))}if(void 0!==e.onSave&&"function"!=typeof e.onSave)throw new TypeError("Config.onSave must be a function.");if(void 0!==e.animationDuration&&("number"!=typeof e.animationDuration||e.animationDuration<0))throw new TypeError("Config.animationDuration must be a positive number.");if(void 0!==e.renderBar&&null!==e.renderBar&&"function"!=typeof e.renderBar)throw new TypeError("Config.renderBar must be a function or null.");if(void 0!==e.renderModal&&null!==e.renderModal&&"function"!=typeof e.renderModal)throw new TypeError("Config.renderModal must be a function or null.")}validateCategory(e,t){if(!e||"object"!=typeof e)throw new TypeError(`Category at index ${t} must be an object.`);if("string"!=typeof e.label)throw new TypeError(`Category.label at index ${t} must be a string.`);if("boolean"!=typeof e.required)throw new TypeError(`Category.required at index ${t} must be a boolean.`);if("boolean"!=typeof e.default)throw new TypeError(`Category.default at index ${t} must be a boolean.`)}loadPreferences(){const e=localStorage.getItem(this.#Bi.storageKey);return e?JSON.parse(e):null}removeWithAnimation(e){if(!(e instanceof HTMLElement))throw new TypeError("removeWithAnimation expects an HTMLElement.");e.classList.add("closing"),setTimeout(()=>e.remove(),this.#Bi.animationDuration)}savePreferences(e){if(!e||"object"!=typeof e)throw new TypeError("Preferences must be an object.");localStorage.setItem(this.#Bi.storageKey,JSON.stringify(e)),this.#Bi.onSave(e)}showConsentBar(){const e=document.createElement("div");e.className="cookie-consent-bar",e.innerHTML=this.#Bi.renderBar?this.#Bi.renderBar(this.#Bi):`\n <div><p>${this.#Bi.message}</p></div>\n <div><button class="accept">${this.#Bi.acceptText}</button></div>\n <div><button class="reject">${this.#Bi.rejectText}</button></div>\n <div><button class="settings">${this.#Bi.settingsText}</button></div>\n `,document.body.appendChild(e);const t=e.querySelector(".accept");t instanceof HTMLElement&&(t.onclick=()=>{const t={};this.#Bi.categories.forEach(e=>t[e.label]=!0),this.savePreferences(t),this.removeWithAnimation(e)});const r=e.querySelector(".reject");r instanceof HTMLElement&&(r.onclick=()=>{const t={};this.#Bi.categories.forEach(e=>t[e.label]=e.required),this.savePreferences(t),this.removeWithAnimation(e)});const n=e.querySelector(".settings");n instanceof HTMLElement&&(n.onclick=()=>this.showSettingsModal(e))}showSettingsModal(e){const t=document.createElement("div");t.className="cookie-consent-modal",t.innerHTML=this.#Bi.renderModal?this.#Bi.renderModal(this.#Bi):`\n <div class="modal-content">\n <h2>Cookie Settings</h2>\n <form class="settings-form">\n ${this.#Bi.categories.map(e=>`\n <label>\n <input type="checkbox" name="${e.label}" \n ${e.default?"checked":""} \n ${e.required?"disabled":""}>\n ${e.label}\n </label>\n `).join("")}\n </form>\n <button class="save">Save Preferences</button>\n </div>\n `,document.body.appendChild(t);const r=t.querySelector(".save");r instanceof HTMLElement&&(r.onclick=()=>{const r={};t.querySelectorAll("input[type=checkbox]").forEach(e=>{e instanceof HTMLInputElement&&(r[e.name]=e.checked)}),this.savePreferences(r),this.removeWithAnimation(t),e&&this.removeWithAnimation(e)})}isAllowed(e){if("string"!=typeof e)throw new TypeError("isAllowed expects a string as category.");return!!this.#Ri&&!!this.#Ri[e]}};var ir=r(911),or=r(766);const sr=class{static async mergeLocaleFiles({files:e,output:t,spaces:r=0}){if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError('mergeLocaleFiles: "spaces" must be a non-negative number');if(!Array.isArray(e)||0===e.length)throw new TypeError('mergeLocaleFiles: "files" must be a non-empty array of file paths');if("string"!=typeof t||!t)throw new TypeError('mergeLocaleFiles: "output" must be a non-empty string path');const n={};for(const t of e){if("string"!=typeof t||!t)throw new TypeError("mergeLocaleFiles: each file path must be a non-empty string");if(!(0,or.existsSync)(t))throw new Error(`mergeLocaleFiles: file "${t}" does not exist`);const e=await(0,ir.readFile)(t,"utf-8");let r;try{r=JSON.parse(e)}catch(e){throw new Error(`mergeLocaleFiles: file "${t}" is not valid JSON`)}Object.assign(n,r)}await(0,ir.writeFile)(t,JSON.stringify(n,null,r),"utf-8")}#$i;#Pi;#Hi=null;#Fi;#Wi=null;#zi=new Map;#qi=new Map;#Vi=new Map;#Ki=new Map;get currentLocale(){return this.#Hi}get defaultLocale(){return this.#Pi}get mode(){return this.#$i}get strict(){return this.#Fi}get basePath(){return this.#Wi}get stats(){const e=[];for(const t of this.#zi.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){const e={};for(const[t,r]of this.#zi.entries())e[t]=this.#Ji(r);return e}get patternTables(){const e={};for(const[t,r]of this.#qi.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#Ji(e.value),elseValue:this.#Ji(e.elseValue)}));return e}get helpers(){const e={};for(const[t,r]of this.#Vi.entries())e[t]=r;return e}get regexCache(){const e={};for(const[t,r]of this.#Ki.entries())e[t]=new RegExp(r.source,r.flags);return e}#Ji(e){if(null==e||"string"==typeof e||"function"==typeof e||"number"==typeof e)return e;if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(e=>this.#Ji(e));if("object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=this.#Ji(n);return t}return e}#Ui(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('#resolveOrder: "forceLocale" must be a string if provided');const t=[];return e&&"string"==typeof e&&this.#zi.has(e)?t.push(e):this.#Hi&&t.push(this.#Hi),t.push(this.#Pi),t}#Gi(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveExact: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveExact: "key" must be a non-empty string');for(const r of e){const e=this.#zi.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#Yi(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveByPattern: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveByPattern: "key" must be a non-empty string');for(const r of e){const e=this.#qi.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#Qi(e,t){if(null==e){if(this.#Fi)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#Zi(e,t);if("function"==typeof e)return e(t??{},this.#Xi());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#Vi.get(e.$fn);if("function"!=typeof r){if(this.#Fi)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#Xi())}if(this.#Fi)throw new Error("TinyI18: unsupported entry type");return""}#Zi(e,t){if("string"!=typeof e)throw new TypeError('#interpolate: "template" must be a string');if(void 0!==t&&(null===t||"object"!=typeof t))throw new TypeError('#interpolate: "params" must be an object if provided');return t&&"object"==typeof t?e.replace(/\{([a-zA-Z0-9_.$-]+)\}/g,(e,r)=>{const n=this.#eo(t,r);return null==n?"":String(n)}):e}#eo(e,t){if(!e||"object"!=typeof e)throw new TypeError('#dotGet: "obj" must be an object');if("string"!=typeof t||!t)throw new TypeError('#dotGet: "path" must be a non-empty string');const r=t.split(".");let n=e;for(const e of r){if(null==n)return;n=n[e]}return n}#Xi(){return{has:e=>this.#Vi.has(e),call:(e,t,r)=>{const n=this.#Vi.get(e);if("function"!=typeof n)throw new Error(`Helper "${e}" not found`);return n(t,r??{})}}}#to(e,t){if("string"!=typeof e||!e)throw new TypeError('#ingestLocale: "locale" must be a non-empty string');if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');if("string"!=typeof e||!e)throw new TypeError("#ingestLocale: invalid locale");if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');const r={...this.#zi.get(e)??{}},n=[...this.#qi.get(e)??[]],i=(e,t)=>{if(null!=t)if("string"==typeof t||"function"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");r[e]=t}else if(t&&"object"==typeof t){if(t.$pattern instanceof RegExp&&Object.prototype.hasOwnProperty.call(t,"value"))return void n.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,n]of Object.entries(t))i(e?`${e}.${r}`:r,n)}};i("",t),this.#zi.set(e,r),this.#qi.set(e,n),this.#zi.has(this.#Pi)||(this.#zi.set(this.#Pi,{}),this.#qi.set(this.#Pi,[]))}#ro(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#Pi&&(this.#zi.delete(e),this.#qi.delete(e))}async#no(e){if("string"!=typeof e||!e)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#Wi||!this.#Wi)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const t=(0,le.join)(this.#Wi,`${e}.json`);let r;try{const e=await(0,ir.readFile)(t,"utf8");r=JSON.parse(e)}catch(r){if(!(r instanceof Error))return;if(this.#Fi)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#zi.set(e,{}),void this.#qi.set(e,[])}const n={...this.#zi.get(e)??{}},i=[...this.#qi.get(e)??[]],o=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#io(t.$pattern);return void i.push({$pattern:e,value:this.#oo(t.value),elseValue:this.#oo(t.elseValue)})}if("string"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");n[e]=this.#oo(t)}else if(t&&"object"==typeof t)for(const[r,n]of Object.entries(t))o(e?`${e}.${r}`:r,n)}};o("",r),this.#zi.set(e,n),this.#qi.set(e,i)}#io(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#Ki.get(e);if(t)return t;try{const t=new RegExp(e);return this.#Ki.set(e,t),t}catch{if(this.#Fi)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#oo(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"string"==typeof e.$fn)return{$fn:String(e.$fn),args:e.args};if(this.#Fi)throw new Error("TinyI18: unsupported value in file JSON");return""}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("TinyI18: options must be an object");const{mode:t,defaultLocale:r,basePath:n,localResources:i,strict:o=!0}=e;if("local"!==t&&"file"!==t)throw new TypeError('TinyI18: "mode" must be "local" or "file"');if("string"!=typeof r||!r)throw new TypeError('TinyI18: "defaultLocale" must be a non-empty string');if("boolean"!=typeof o)throw new TypeError('TinyI18: "strict" must be a boolean');if("file"===t){if("string"!=typeof n||!n)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#Wi=n}if(this.#$i=t,this.#Pi=r,this.#Fi=o,"local"===t&&i&&"object"==typeof i)for(const[e,t]of Object.entries(i))this.#to(e,t);this.#zi.has(this.#Pi)||(this.#zi.set(this.#Pi,{}),this.#qi.set(this.#Pi,[]))}clearRegexCache(){this.#Ki.clear()}registerHelper(e,t){if("string"!=typeof e||!e)throw new TypeError('registerHelper: "name" must be non-empty string');if("function"!=typeof t)throw new TypeError('registerHelper: "fn" must be a function');this.#Vi.set(e,t)}unregisterHelper(e){if("string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#Vi.delete(e)}loadLocaleLocal(e,t){if("local"!==this.#$i)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#to(e,t)}async setLocale(e){if(null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#Hi;null!==e&&("file"===this.#$i?await this.#no(e):this.#zi.has(e)||(this.#zi.set(e,{}),this.#qi.set(e,[]))),"file"===this.#$i&&t&&t!==this.#Pi&&t!==e&&this.#ro(t),this.#Hi=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if("string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:n}=r||{},i=this.#Ui(n);let o=this.#Gi(i,e);if(void 0===o){if(this.#Fi)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#Qi(o,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if("string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},n=this.#Ui(r);let i=this.#Yi(n,e);if(void 0===i){if(this.#Fi)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return i}resetToDefaultOnly(){if("file"===this.#$i)for(const e of Array.from(this.#zi.keys()))e!==this.#Pi&&this.#ro(e);this.#Hi=null}getStatsForLocale(e){if("string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#zi.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#zi.get(e)??{}).length,patterns:this.#qi.get(e)?.length??0,isDefault:e===this.#Pi,isCurrent:e===this.#Hi}}};class ar{#so=new Map;#ao;#lo;#uo;get factors(){const e={};for(let[t,r]of this.#so.entries())e[t]={...r};return e}get currentPercent(){return this.#lo/this.#ao*100}set maxValue(e){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#ao=e,this.#lo=Math.min(this.#lo,e)}get maxValue(){return this.#ao}get currentValue(){return this.#lo}set infiniteValue(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("infiniteValue must be a number.");this.#uo=e,this.#lo=Math.max(0,e),this.#lo=Math.min(this.#lo,this.#ao)}get infiniteValue(){return this.#uo}constructor(e=100,t=1,r=1){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#ao=e,this.setFactor("main",t,r),this.#lo=e,this.#uo=e}getFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");const t=this.#so.get(e);if(!t)throw new Error(`Factor with key "${e}" not found.`);return{...t}}hasFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#so.has(e)}setFactor(e,t,r=1){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("Amount must be a valid number.");if("number"!=typeof r||Number.isNaN(r))throw new TypeError("Multiplier must be a valid number.");this.#so.set(e,{amount:t,multiplier:r})}removeFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#so.delete(e)}#co(e){const t=this.#uo;return this.#uo-=e,this.#lo=Math.max(0,this.#lo-e),{prevValue:t,removedTotal:e,removedPercent:e/this.#ao*100,currentPercent:this.currentPercent,remainingValue:this.#lo,infiniteRemaining:this.#uo}}tick(){let e=0;for(let[t,r]of this.#so.entries())e+=r.amount*r.multiplier;return this.#co(e)}tickWithTempFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');let t=0;for(let[e,r]of this.#so.entries())t+=r.amount*r.multiplier;return e&&(t+=e.amount*(e.multiplier??1)),this.#co(t)}tickSingleFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');if(!e)throw new Error("You must provide a factor to apply.");const t=e.amount*(e.multiplier??1);return this.#co(t)}toJSON(){return{maxValue:this.#ao,currentValue:this.#lo,infiniteValue:this.#uo,factors:this.factors}}static fromJSON(e){const t=new ar(e.maxValue,0,0);t.infiniteValue=e.infiniteValue,t.#so.clear();for(const[r,n]of Object.entries(e.factors))t.setFactor(r,n.amount,n.multiplier);return t}clone(){return ar.fromJSON(this.toJSON())}clearFactors(){this.#so.clear()}}const lr=ar,ur=class{static rollArrayIndex(e){const t=Array.isArray(e),r=e instanceof Set;if(!t&&!r)throw new TypeError("rollArrayIndex expects an array or Set.");return Math.floor(Math.random()*(t?e.length:e.size))}#ao;#ho;get maxValue(){return this.#ao}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#ao=e}get allowZero(){return this.#ho}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#ho=e}constructor({maxValue:e,allowZero:t=!0}){if("boolean"!=typeof t)throw new TypeError("allowZero must be an boolean.");if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#ao=e,this.#ho=t}roll(){const e=this.#ho?0:1;return Math.floor(Math.random()*(this.#ao-e+1))+e}},cr=class{#T=null;get overlay(){return this.#T}#do=null;get messageElement(){return this.#do}#O;get container(){return this.#O}#fo={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#fo}}set options(e){if("object"!=typeof e||null===e)throw new TypeError("options must be an object");if(void 0!==e.fadeIn&&null!==e.fadeIn&&("number"!=typeof e.fadeIn||e.fadeIn<0))throw new TypeError("fadeIn must be a non-negative number or null");if(void 0!==e.fadeOut&&null!==e.fadeOut&&("number"!=typeof e.fadeOut||e.fadeOut<0))throw new TypeError("fadeOut must be a non-negative number or null");if(void 0!==e.zIndex&&("number"!=typeof e.zIndex||!Number.isInteger(e.zIndex)))throw new TypeError("zIndex must be an integer number");this.#fo={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#po="none";get status(){return this.#po}#mo="";get defaultMessage(){return this.#mo}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#mo=e}#go=null;get message(){return this.#go}#yo=!1;get allowHtmlText(){return this.#yo}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#yo=e}#wo=null;get fadeInTimeout(){return null!==this.#wo}#bo=null;get fadeOutTimeout(){return null!==this.#bo}get visible(){return!!this.#T}#vo=null;get onChange(){return this.#vo}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#vo=e}_emitChange(){"function"==typeof this.#vo&&this.#vo(this.#po)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#O=e}_updateMessage(e=this.#mo){if(!this.#do)throw new Error("messageElement is not initialized");if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(this.#go=e,"string"==typeof e)this.#yo?this.#do.innerHTML=e:this.#do.textContent=e;else{if(!this.#yo)throw new Error("HTMLElement messages require allowHtmlText = true");this.#do.textContent="",this.#do.appendChild(e)}}_removeOldClasses(){this.#T?.classList.remove("active"),this.#T?.classList.remove("fadeIn"),this.#T?.classList.remove("fadeOut")}start(e=this.#mo){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(!this.#T){this.#T=document.createElement("div"),this.#T.classList.add("loading-overlay"),this.#T.style.zIndex=String(this.#fo.zIndex);const t=document.createElement("div");t.classList.add("loading-container");const r=document.createElement("div");r.classList.add("loading-content");const n=document.createElement("div");n.classList.add("loading-spinner"),this.#do=document.createElement("div"),this.#do.classList.add("loading-message"),r.appendChild(n),r.appendChild(this.#do),t.appendChild(r),this.#T.appendChild(t),this.#O.appendChild(this.#T),this._removeOldClasses(),this.#po="fadeIn",this.#T.classList.add("fadeIn"),this._emitChange();const i=()=>{this._removeOldClasses(),this.#wo=null,this.#po="active",this.#T?.classList.add("active"),this._emitChange()};return"number"==typeof this.#fo.fadeIn?(this.#wo&&clearTimeout(this.#wo),this.#wo=setTimeout(i,this.#fo.fadeIn)):i(),this._updateMessage(e),!0}return this.#do&&this._updateMessage(e),!1}update(e=this.#mo){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#do&&(this._updateMessage(e),!0)}stop(){if(this.#T){this._removeOldClasses(),this.#po="fadeOut",this.#T.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#bo=null,this.#po="none",this.#T?.remove(),this.#T=null,this.#do=null,this.#go=null,this._emitChange()};return"number"==typeof this.#fo.fadeOut?(this.#bo&&clearTimeout(this.#bo),this.#bo=setTimeout(e,this.#fo.fadeOut)):e(),!0}return!1}}})(),window.TinyEssentials=n})();
2
+ (()=>{var e={133:()=>{},251:(e,t)=>{t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,l=(1<<a)-1,u=l>>1,c=-7,h=r?i-1:0,d=r?-1:1,p=e[t+h];for(h+=d,o=p&(1<<-c)-1,p>>=-c,c+=a;c>0;o=256*o+e[t+h],h+=d,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+h],h+=d,c-=8);if(0===o)o=1-u;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=u}return(p?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,l,u=8*o-i-1,c=(1<<u)-1,h=c>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,f=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(t*l-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&a,p+=f,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[r+p]=255&s,p+=f,s/=256,u-=8);e[r+p-f]|=128*m}},287:(e,t,r)=>{"use strict";var n=r(526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=l,t.IS=50;var s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,l.prototype),t}function l(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!l.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|m(e,t),n=a(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(F(e,Uint8Array)){var t=new Uint8Array(e);return p(t.buffer,t.byteOffset,t.byteLength)}return d(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(F(e,ArrayBuffer)||e&&F(e.buffer,ArrayBuffer))return p(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(F(e,SharedArrayBuffer)||e&&F(e.buffer,SharedArrayBuffer)))return p(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return l.from(n,t,r);var i=function(e){if(l.isBuffer(e)){var t=0|f(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||W(e.length)?a(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return l.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return c(e),a(e<0?0:0|f(e))}function d(e){for(var t=e.length<0?0:0|f(e.length),r=a(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function p(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),Object.setPrototypeOf(n,l.prototype),n}function f(e){if(e>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function m(e,t){if(l.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||F(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(e).length;default:if(i)return n?-1:B(e).length;t=(""+t).toLowerCase(),i=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return N(this,t,r);case"utf8":case"utf-8":return I(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return L(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function w(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=l.from(t,n)),l.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){var o,s=1,a=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,l/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===l)return c*s}else-1!==c&&(o-=o-c),c=-1}else for(r+l>a&&(r=a-l),o=r;o>=0;o--){for(var h=!0,d=0;d<l;d++)if(u(e,o+d)!==u(t,d)){h=!1;break}if(h)return o}return-1}function v(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(W(a))return s;e[r+s]=a}return s}function E(e,t,r,n){return P(B(t,e.length-r),e,r,n)}function T(e,t,r,n){return P(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function S(e,t,r,n){return P($(t),e,r,n)}function x(e,t,r,n){return P(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function I(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,l,u=e[i],c=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(c=u);break;case 2:128==(192&(o=e[i+1]))&&(l=(31&u)<<6|63&o)>127&&(c=l);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(l=(15&u)<<12|(63&o)<<6|63&s)>2047&&(l<55296||l>57343)&&(c=l);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&l<1114112&&(c=l)}null===c?(c=65533,h=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(e){var t=e.length;if(t<=C)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=C));return r}(n)}l.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),l.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}}),l.poolSize=8192,l.from=function(e,t,r){return u(e,t,r)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array),l.alloc=function(e,t,r){return function(e,t,r){return c(e),e<=0?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)}(e,t,r)},l.allocUnsafe=function(e){return h(e)},l.allocUnsafeSlow=function(e){return h(e)},l.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==l.prototype},l.compare=function(e,t){if(F(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),F(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},l.isEncoding=function(e){switch(String(e).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}},l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return l.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=l.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(F(o,Uint8Array))i+o.length>n.length?l.from(o).copy(n,i):Uint8Array.prototype.set.call(n,o,i);else{if(!l.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i)}i+=o.length}return n},l.byteLength=m,l.prototype._isBuffer=!0,l.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},l.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},l.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},l.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?I(this,0,e):g.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===l.compare(this,e)},l.prototype.inspect=function(){var e="",r=t.IS;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},o&&(l.prototype[o]=l.prototype.inspect),l.prototype.compare=function(e,t,r,n,i){if(F(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),h=0;h<a;++h)if(u[h]!==c[h]){o=u[h],s=c[h];break}return o<s?-1:s<o?1:0},l.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},l.prototype.indexOf=function(e,t,r){return w(this,e,t,r,!0)},l.prototype.lastIndexOf=function(e,t,r){return w(this,e,t,r,!1)},l.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return E(this,e,t,r);case"ascii":case"latin1":case"binary":return T(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function M(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function L(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function N(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=z[e[o]];return i}function k(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function D(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function _(e,t,r,n,i,o){if(!l.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function j(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(e,t,r,n,o){return t=+t,r>>>=0,o||j(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function O(e,t,r,n,o){return t=+t,r>>>=0,o||j(e,0,r,8),i.write(e,t,r,n,52,8),r+8}l.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,l.prototype),n},l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),this[e]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]|this[e+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e>>>=0,t||D(e,2,this.length),this[e]<<8|this[e+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e>>>=0,t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e>>>=0,t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},l.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},l.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||D(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},l.prototype.readInt8=function(e,t){return e>>>=0,t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},l.prototype.readInt16LE=function(e,t){e>>>=0,t||D(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt16BE=function(e,t){e>>>=0,t||D(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},l.prototype.readInt32LE=function(e,t){return e>>>=0,t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},l.prototype.readInt32BE=function(e,t){return e>>>=0,t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},l.prototype.readFloatLE=function(e,t){return e>>>=0,t||D(e,4,this.length),i.read(this,e,!0,23,4)},l.prototype.readFloatBE=function(e,t){return e>>>=0,t||D(e,4,this.length),i.read(this,e,!1,23,4)},l.prototype.readDoubleLE=function(e,t){return e>>>=0,t||D(e,8,this.length),i.read(this,e,!0,52,8)},l.prototype.readDoubleBE=function(e,t){return e>>>=0,t||D(e,8,this.length),i.read(this,e,!1,52,8)},l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||_(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||_(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,1,255,0),this[t]=255&e,t+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);_(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},l.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var i=Math.pow(2,8*r-1);_(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},l.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},l.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},l.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},l.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},l.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||_(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},l.prototype.writeFloatLE=function(e,t,r){return R(this,e,t,!0,r)},l.prototype.writeFloatBE=function(e,t,r){return R(this,e,t,!1,r)},l.prototype.writeDoubleLE=function(e,t,r){return O(this,e,t,!0,r)},l.prototype.writeDoubleBE=function(e,t,r){return O(this,e,t,!1,r)},l.prototype.copy=function(e,t,r,n){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i=n-r;return this===e&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(t,r,n):Uint8Array.prototype.set.call(e,this.subarray(r,n),t),i},l.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=l.isBuffer(e)?e:l.from(e,n),a=s.length;if(0===a)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var H=/[^+/0-9A-Za-z-_]/g;function B(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function $(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(H,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function P(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function F(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function W(e){return e!=e}var z=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var n=16*r,i=0;i<16;++i)t[n+i]=e[r]+e[i];return t}()},370:()=>{},526:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,o=a(e),s=o[0],l=o[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,l)),c=0,h=l>0?s-4:s;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],u[c++]=t>>16&255,u[c++]=t>>8&255,u[c++]=255&t;return 2===l&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[c++]=255&t),1===l&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=16383,a=0,l=n-i;a<l;a+=s)o.push(u(e,a,a+s>l?l:a+s));return 1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e){return r[e>>18&63]+r[e>>12&63]+r[e>>6&63]+r[63&e]}function u(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(255&e[o+2]),i.push(l(n));return i.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},606:e=>{var t,r,n=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var a,l=[],u=!1,c=-1;function h(){u&&a&&(u=!1,a.length?l=a.concat(l):c=-1,l.length&&d())}function d(){if(!u){var e=s(h);u=!0;for(var t=l.length;t;){for(a=l,l=[];++c<t;)a&&a[c].run();c=-1,t=l.length}a=null,u=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function f(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new p(e,t)),1!==l.length||u||s(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=f,n.addListener=f,n.once=f,n.off=f,n.removeListener=f,n.removeAllListeners=f,n.emit=f,n.prependListener=f,n.prependOnceListener=f,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},766:()=>{},911:()=>{},975:(e,t,r)=>{"use strict";var n=r(606);function i(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function o(e,t){for(var r,n="",i=0,o=-1,s=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(o===a-1||1===s);else if(o!==a-1&&2===s){if(n.length<2||2!==i||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(n.length>2){var l=n.lastIndexOf("/");if(l!==n.length-1){-1===l?(n="",i=0):i=(n=n.slice(0,l)).length-1-n.lastIndexOf("/"),o=a,s=0;continue}}else if(2===n.length||1===n.length){n="",i=0,o=a,s=0;continue}t&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+e.slice(o+1,a):n=e.slice(o+1,a),i=a-o-1;o=a,s=0}else 46===r&&-1!==s?++s:s=-1}return n}var s={resolve:function(){for(var e,t="",r=!1,s=arguments.length-1;s>=-1&&!r;s--){var a;s>=0?a=arguments[s]:(void 0===e&&(e=n.cwd()),a=e),i(a),0!==a.length&&(t=a+"/"+t,r=47===a.charCodeAt(0))}return t=o(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(i(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=o(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return i(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var r=arguments[t];i(r),r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":s.normalize(e)},relative:function(e,t){if(i(e),i(t),e===t)return"";if((e=s.resolve(e))===(t=s.resolve(t)))return"";for(var r=1;r<e.length&&47===e.charCodeAt(r);++r);for(var n=e.length,o=n-r,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var l=t.length-a,u=o<l?o:l,c=-1,h=0;h<=u;++h){if(h===u){if(l>u){if(47===t.charCodeAt(a+h))return t.slice(a+h+1);if(0===h)return t.slice(a+h)}else o>u&&(47===e.charCodeAt(r+h)?c=h:0===h&&(c=0));break}var d=e.charCodeAt(r+h);if(d!==t.charCodeAt(a+h))break;47===d&&(c=h)}var p="";for(h=r+c+1;h<=n;++h)h!==n&&47!==e.charCodeAt(h)||(0===p.length?p+="..":p+="/..");return p.length>0?p+t.slice(a+c):(a+=c,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(i(e),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,n=-1,o=!0,s=e.length-1;s>=1;--s)if(47===(t=e.charCodeAt(s))){if(!o){n=s;break}}else o=!1;return-1===n?r?"/":".":r&&1===n?"//":e.slice(0,n)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');i(e);var r,n=0,o=-1,s=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(r=e.length-1;r>=0;--r){var u=e.charCodeAt(r);if(47===u){if(!s){n=r+1;break}}else-1===l&&(s=!1,l=r+1),a>=0&&(u===t.charCodeAt(a)?-1===--a&&(o=r):(a=-1,o=l))}return n===o?o=l:-1===o&&(o=e.length),e.slice(n,o)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!s){n=r+1;break}}else-1===o&&(s=!1,o=r+1);return-1===o?"":e.slice(n,o)},extname:function(e){i(e);for(var t=-1,r=0,n=-1,o=!0,s=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===n&&(o=!1,n=a+1),46===l?-1===t?t=a:1!==s&&(s=1):-1!==t&&(s=-1);else if(!o){r=a+1;break}}return-1===t||-1===n||0===s||1===s&&t===n-1&&t===r+1?"":e.slice(t,n)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+"/"+n:n}(0,e)},parse:function(e){i(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var r,n=e.charCodeAt(0),o=47===n;o?(t.root="/",r=1):r=0;for(var s=-1,a=0,l=-1,u=!0,c=e.length-1,h=0;c>=r;--c)if(47!==(n=e.charCodeAt(c)))-1===l&&(u=!1,l=c+1),46===n?-1===s?s=c:1!==h&&(h=1):-1!==s&&(h=-1);else if(!u){a=c+1;break}return-1===s||-1===l||0===h||1===h&&s===l-1&&s===a+1?-1!==l&&(t.base=t.name=0===a&&o?e.slice(1,l):e.slice(a,l)):(0===a&&o?(t.name=e.slice(1,s),t.base=e.slice(1,l)):(t.name=e.slice(a,s),t.base=e.slice(a,l)),t.ext=e.slice(s,l)),a>0?t.dir=e.slice(0,a-1):o&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};s.posix=s,e.exports=s}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{ColorSafeStringify:()=>K,TinyAdvancedRaffle:()=>Qt,TinyAfterScrollWatcher:()=>vt,TinyArrayPaginator:()=>Zt,TinyClipboard:()=>_t,TinyColorConverter:()=>Rt,TinyColorValidator:()=>dr,TinyCookieConsent:()=>nr,TinyDayNightCycle:()=>Yt,TinyDomReadyManager:()=>wt,TinyDragDropDetector:()=>se,TinyDragger:()=>yt,TinyElementObserver:()=>rt,TinyEvents:()=>Lt,TinyGamepad:()=>Gt,TinyHtml:()=>mt,TinyI18:()=>sr,TinyIframeEvents:()=>qt,TinyInventory:()=>tr,TinyInventoryTrader:()=>rr,TinyLevelUp:()=>i,TinyLoadingScreen:()=>cr,TinyLocalStorage:()=>Wt,TinyNeedBar:()=>lr,TinyNewWinEvents:()=>Kt,TinyNotifications:()=>bt,TinyNotifyCenter:()=>Y,TinyPromiseQueue:()=>U,TinyRateLimiter:()=>J,TinySimpleDice:()=>ur,TinySmartScroller:()=>kt,TinyTextRangeEditor:()=>Dt,TinyTextarea:()=>Ut,TinyTimeout:()=>Ht,TinyToastNotify:()=>X,UltraRandomMsgGen:()=>Mt,addAiMarkerShortcut:()=>W,areElsCollBottom:()=>$e,areElsCollLeft:()=>Pe,areElsCollPerfBottom:()=>ze,areElsCollPerfLeft:()=>qe,areElsCollPerfRight:()=>Ve,areElsCollPerfTop:()=>We,areElsCollRight:()=>Fe,areElsCollTop:()=>Be,areElsColliding:()=>Ke,areElsPerfColliding:()=>Ue,arraySortPositions:()=>o,asyncReplace:()=>t,backupFile:()=>Se,breakdownDuration:()=>d,calculateMarketcap:()=>B,checkObj:()=>S,clearDirectory:()=>de,clearDirectoryAsync:()=>De,cloneObjTypeOrder:()=>v,compareMarketcap:()=>$,countObj:()=>f,diffArrayList:()=>a,diffStrings:()=>q,dirExists:()=>fe,dirSize:()=>Te,dirSizeAsync:()=>He,documentIsFullScreen:()=>x,ensureCopyFile:()=>ge,ensureDirectory:()=>he,exitFullScreen:()=>M,extendObjType:()=>w,fetchJson:()=>ne,fetchText:()=>ie,fileExists:()=>pe,fileSize:()=>Ee,fileSizeAsync:()=>Oe,formatBytes:()=>O,formatCustomTimer:()=>u,formatDayTimer:()=>h,formatTimer:()=>c,genFibonacciSeq:()=>H,getAge:()=>R,getElsCollDetails:()=>tt,getElsCollDirDepth:()=>et,getElsCollOverlap:()=>Ye,getElsCollOverlapPos:()=>Xe,getElsColliding:()=>Je,getElsPerfColliding:()=>Ge,getElsRelativeCenterOffset:()=>Ze,getLatestBackupPath:()=>xe,getPercentage:()=>j,getRectCenter:()=>Qe,getSimplePerc:()=>_,getTimeDuration:()=>l,installWindowHiddenScript:()=>oe,isDirEmpty:()=>me,isDirEmptyAsync:()=>_e,isFullScreenMode:()=>I,isJsonObject:()=>m,isScreenFilled:()=>A,listDirs:()=>ve,listDirsAsync:()=>Re,listFiles:()=>be,listFilesAsync:()=>je,objType:()=>T,offFullScreenChange:()=>k,onFullScreenChange:()=>N,readBase64Blob:()=>Z,readFileBlob:()=>Q,readJsonBlob:()=>ee,readJsonFile:()=>ue,renameFileAddPrefixSuffix:()=>Me,renameFileBatch:()=>Ie,renameFileNormalizeCase:()=>Le,renameFilePadNumbers:()=>Ne,renameFileRegex:()=>Ce,reorderObjTypeOrder:()=>b,requestFullScreen:()=>C,restoreLatestBackup:()=>Ae,ruleOfThree:()=>D,safeTextTrim:()=>z,saveJsonFile:()=>te,shuffleArray:()=>s,toTitleCase:()=>P,toTitleCaseLowerFirst:()=>F,tryDeleteFile:()=>ye,writeJsonFile:()=>ce,writeTextFile:()=>we});var e={};async function t(e,t,r){const n=[];e.replace(t,(e,...t)=>(n.push(r(e,...t)),e));const i=await Promise.all(n);return e.replace(t,()=>i.shift())}r.r(e),r.d(e,{areElsCollBottom:()=>$e,areElsCollLeft:()=>Pe,areElsCollPerfBottom:()=>ze,areElsCollPerfLeft:()=>qe,areElsCollPerfRight:()=>Ve,areElsCollPerfTop:()=>We,areElsCollRight:()=>Fe,areElsCollTop:()=>Be,areElsColliding:()=>Ke,areElsPerfColliding:()=>Ue,getElsCollDetails:()=>tt,getElsCollDirDepth:()=>et,getElsCollOverlap:()=>Ye,getElsCollOverlapPos:()=>Xe,getElsColliding:()=>Je,getElsPerfColliding:()=>Ge,getElsRelativeCenterOffset:()=>Ze,getRectCenter:()=>Qe});const i=class{constructor(e,t){if("number"!=typeof e||Number.isNaN(e))throw new Error("giveExp must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("expLevel must be a valid number");this.giveExp=e,this.expLevel=t}createUser(){return{exp:0,level:1,totalExp:0}}validateUser(e){if("number"!=typeof e.exp||Number.isNaN(e.exp))throw new Error("exp must be a valid number");if("number"!=typeof e.level||Number.isNaN(e.level))throw new Error("level must be a valid number");if(e.level<1)throw new Error("level must be at least 1");if("number"!=typeof e.totalExp||Number.isNaN(e.totalExp))throw new Error("totalExp must be a valid number")}isValidUser(e){return!("number"!=typeof e.exp||Number.isNaN(e.exp)||"number"!=typeof e.level||Number.isNaN(e.level)||e.level<1||"number"!=typeof e.totalExp||Number.isNaN(e.totalExp))}getGiveExpBase(){if("number"!=typeof this.giveExp||Number.isNaN(this.giveExp))throw new Error("giveExp must be a valid number");return this.giveExp}getExpLevelBase(){if("number"!=typeof this.expLevel||Number.isNaN(this.expLevel))throw new Error("expLevel must be a valid number");return this.expLevel}expValidator(e){const t=this.getExpLevelBase();this.validateUser(e);let r=0;const n=t*e.level;return e.exp>=n&&(e.level++,r=e.exp-n,e.exp=0,r>0)?this.give(e,r,"extra"):e.exp<1&&e.level>1&&(e.level--,r=Math.abs(e.exp),e.exp=t*e.level,r>0)?this.remove(e,r,"extra"):e}getTotalExp(e){this.validateUser(e);let t=0;for(let r=1;r<=e.level;r++)t+=this.getExpLevelBase()*r;return t+=e.exp,t}expGenerator(e=1){if("number"!=typeof e||Number.isNaN(e))throw new Error("multi must be a valid number");return Math.floor(Math.random()*this.getGiveExpBase())*e}getMissingExp(e){return this.getProgress(e)-e.exp}progress(e){return this.getProgress(e)}getProgress(e){return this.validateUser(e),this.getExpLevelBase()*e.level}set(e,t){if("number"!=typeof t||Number.isNaN(t))throw new Error("value must be a valid number");return e.exp=t,this.expValidator(e),e.totalExp=this.getTotalExp(e),e}give(e,t=0,r="add",n=1){if("number"!=typeof n||Number.isNaN(n))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp+=this.expGenerator(n)+t:"extra"===r&&(e.exp+=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}remove(e,t=0,r="add",n=1){if("number"!=typeof n||Number.isNaN(n))throw new Error("multi must be a valid number");if("number"!=typeof t||Number.isNaN(t))throw new Error("extraExp must be a valid number");if("string"!=typeof r)throw new Error("type must be a valid string");return"add"===r?e.exp-=this.expGenerator(n)+t:"extra"===r&&(e.exp-=t),this.expValidator(e),e.totalExp=this.getTotalExp(e),e}};function o(e,t=!1){return t?function(t,r){return t[e]>r[e]?-1:t[e]<r[e]?1:0}:function(t,r){return t[e]<r[e]?-1:t[e]>r[e]?1:0}}function s(e){let t,r=e.length;for(;0!==r;)t=Math.floor(Math.random()*r),r--,[e[r],e[t]]=[e[t],e[r]];return e}function a(e,t){const r=e.filter(e=>!t.includes(e));return{added:t.filter(t=>!e.includes(t)),removed:r}}function l(e=new Date,t="asSeconds",r=null){if(e instanceof Date){const n=r instanceof Date?r:new Date,i=e.getTime()-n.getTime();switch(t){case"asMilliseconds":return i;case"asSeconds":default:return i/1e3;case"asMinutes":return i/6e4;case"asHours":return i/36e5;case"asDays":return i/864e5}}return null}function u(e,t="seconds",r="{time}"){e=Math.max(0,Math.floor(e));const n=["seconds","minutes","hours","days","months","years"].indexOf(t),i=n>=5,o=n>=4,s=n>=3,a=n>=2,l=n>=1,u=n>=0,c={years:i?0:NaN,months:o?0:NaN,days:s?0:NaN,hours:a?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,total:NaN};let h=e;if(i||o||s){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*h),r=new Date(e);if(i)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),c.years++;if(o)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;h=Math.floor((t.getTime()-r.getTime())/1e3)}a&&(c.hours=Math.floor(h/3600),h%=3600),l&&(c.minutes=Math.floor(h/60),h%=60),u&&(c.seconds=h),o&&(c.years,c.months,c.days),i&&(c.years,c.months,c.days),c.total=+e.toFixed(2).replace(/\.00$/,"");const d=e=>{const t="string"==typeof e?parseInt(e):e;return Number.isNaN(t)?"NaN":String(t).padStart(2,"0")},p=[a?d(c.hours):null,l?d(c.minutes):null,u?d(c.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(c.years)).replace(/\{months\}/g,String(c.months)).replace(/\{days\}/g,String(c.days)).replace(/\{hours\}/g,d(c.hours)).replace(/\{minutes\}/g,d(c.minutes)).replace(/\{seconds\}/g,d(c.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(c.total)).trim()}function c(e){return u(e,"hours","{hours}:{minutes}:{seconds}")}function h(e){return u(e,"days","{days}d {hours}:{minutes}:{seconds}")}function d(e,t="milliseconds"){e=Math.max(0,Math.floor(e));const r=["milliseconds","seconds","minutes","hours","days","months","years"].indexOf(t),n=r>=6,i=r>=5,o=r>=4,s=r>=3,a=r>=2,l=r>=1,u=r>=0,c={years:n?0:NaN,months:i?0:NaN,days:o?0:NaN,hours:s?0:NaN,minutes:a?0:NaN,seconds:l?0:NaN,milliseconds:u?0:NaN,total:NaN};let h=e;if(n||i||o){const e=new Date(1980,0,1),t=new Date(e.getTime()+h),r=new Date(e);if(n)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),c.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),c.months++;if(o)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),c.days++;h=t.getTime()-r.getTime()}return s&&(c.hours=Math.floor(h/36e5),h%=36e5),a&&(c.minutes=Math.floor(h/6e4),h%=6e4),l&&(c.seconds=Math.floor(h/1e3),h%=1e3),u&&(c.milliseconds=h),i&&(c.years,c.months,c.days),n&&(c.years,c.months,c.days),c.total=+e,c}var p=r(287);function f(e){return Array.isArray(e)?e.length:m(e)?Object.keys(e).length:0}function m(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const g="undefined"!=typeof window&&void 0!==window.document,y={items:{},order:[]};function w(e,t){const r=[],n=Array.isArray(e)?e:Object.entries(e);for(const[e,i]of n)if(!y.items.hasOwnProperty(e)){y.items[e]=i;let n="number"==typeof t?t:-1;if(-1===n){const e=y.order.indexOf("object");n=e>-1?e:y.order.length}n=Math.min(Math.max(0,n),y.order.length),y.order.splice(n,0,e),r.push(e)}return r}function b(e){const t=[...y.order];return!!e.every(e=>t.includes(e))&&(y.order=e.slice(),!0)}function v(){return[...y.order]}const E=e=>{if(null===e)return"null";for(const t of y.order)if("function"!=typeof y.items[t]||y.items[t](e))return t;return"unknown"};function T(e,t){if(void 0===e)return null;const r=E(e);return"string"==typeof t?r===t.toLowerCase():r}function S(e){const t={valid:null,type:null};for(const r of y.order)if("function"==typeof y.items[r]){const n=y.items[r](e);if(n){t.valid=n,t.type=r;break}}return t}w([["undefined",e=>void 0===e],["null",e=>null===e],["boolean",e=>"boolean"==typeof e],["number",e=>"number"==typeof e&&!Number.isNaN(e)],["bigint",e=>"bigint"==typeof e],["string",e=>"string"==typeof e],["symbol",e=>"symbol"==typeof e],["function",e=>"function"==typeof e],["array",e=>Array.isArray(e)]]),g||w([["buffer",e=>void 0!==p.hp&&p.hp.isBuffer(e)]]),g&&w([["file",e=>"undefined"!=typeof File&&e instanceof File]]),w([["date",e=>e instanceof Date],["regexp",e=>e instanceof RegExp],["map",e=>e instanceof Map],["set",e=>e instanceof Set],["weakmap",e=>e instanceof WeakMap],["weakset",e=>e instanceof WeakSet],["promise",e=>e instanceof Promise]]),g&&w([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),w([["object",e=>m(e)]]);const x=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),A=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,I=()=>x()||A(),C=e=>new Promise(async(t,r)=>{const n=document.documentElement;try{n.requestFullscreen?await n.requestFullscreen(e):n.mozRequestFullScreen?n.mozRequestFullScreen(e):n.webkitRequestFullScreen?n.webkitRequestFullScreen(e):n.msRequestFullscreen&&n.msRequestFullscreen(e),t()}catch(e){r(e)}}),M=()=>new Promise((e,t)=>{if(document.exitFullscreen)document.exitFullscreen().then(e).catch(t);else try{if(document.mozCancelFullScreen)document.mozCancelFullScreen();else if(document.webkitCancelFullScreen)document.webkitCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Fullscreen API is not supported");document.msExitFullscreen()}e()}catch(e){t(e)}}),L=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],N=(e,t)=>{L.forEach(r=>{document.addEventListener(r,e,t)})},k=(e,t)=>{L.forEach(r=>{document.removeEventListener(r,e,t)})};function D(e,t,r,n=!1){return n?Number(e*t)/r:Number(r*t)/e}function _(e,t){return e*(t/100)}function j(e,t){return 0===t?0:e/t*100}function R(e=0,t=null){if(null!=e&&0!==e){const r=new Date(e);if(Number.isNaN(r.getTime()))return null;const n=t instanceof Date?t:new Date;let i=n.getFullYear()-r.getFullYear();const o=n.getMonth(),s=r.getMonth(),a=n.getDate(),l=r.getDate();return(o<s||o===s&&a<l)&&i--,Math.abs(i)}return null}function O(e,t=null,r=null){if("number"!=typeof e||e<0)return{unit:null,value:null};if(0===e)return{unit:"Bytes",value:0};const n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=r&&n.includes(r)?n.indexOf(r):n.length-1,o=Math.min(Math.floor(Math.log(e)/Math.log(1024)),i);let s=e/Math.pow(1024,o);if(null!==t){const e=t<0?0:t;s=parseFloat(s.toFixed(e))}return{unit:n[o],value:s}}function H({baseValues:e=[0,1],length:t=10,combiner:r=(e,t)=>e+t}={}){if(!Array.isArray(e)||2!==e.length)throw new Error("baseValues must be an array of exactly two numbers");const n=[...e.slice(0,2)];for(let e=2;e<t;e++){const t=r(n[e-2],n[e-1],e);n.push(t)}return n}function B(e,t){if(Number.isNaN(e)||!Number.isFinite(e))throw new TypeError("Original market cap must be a number.");if(Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("Circulating supply must be a number.");if(t<=0)throw new Error("Circulating supply must be greater than zero.");return e/t}function $(e,t,r){if(Number.isNaN(r)||!Number.isFinite(r))throw new TypeError("New market cap must be a number.");const n=B(e,t),i="number"==typeof r?r/t:NaN;return{originalPrice:n,newPrice:i,priceChangePercent:"number"==typeof r?(i-n)/n*100:NaN}}function P(e){return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function F(e){const t=e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase());return t.charAt(0).toLowerCase()+t.slice(1)}function W({key:e="a",className:t="detect-made-by-ai"}={}){if("undefined"==typeof HTMLElement)throw new Error("[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.");const r=function(r){if(r.ctrlKey&&r.altKey&&r.key.toLowerCase()===e){if(r.preventDefault(),!document.body)return void console.warn("[AiMarkerShortcut] <body> element not found. Cannot toggle class. Ensure the DOM is fully loaded when using the shortcut.");document.body.classList.toggle(t)}};return document.addEventListener("keydown",r),r}function z(e,t,r=.6){if("string"!=typeof e)throw new TypeError("Expected a string for 'text', but received "+typeof e);if(!Number.isInteger(t)||t<=0)throw new TypeError(`Expected 'limit' to be a positive integer, but received ${t}`);if("number"!=typeof r||r<0||r>1)throw new TypeError(`Expected 'safeCutZone' to be a number between 0 and 1, but received ${r}`);let n=e.trim();if(n.length>t){const e=n.lastIndexOf(" ",t);return e>0&&e>=t*r?`${n.substring(0,e).trim()}...`:`${n.substring(0,t).trim()}...`}return n}function q(e,t){const r={added:{},removed:{},modified:{}};for(const n in e)n in t?e[n]!==t[n]&&(r.modified[n]={old:e[n],new:t[n]}):r.removed[n]=e[n];for(const n in t)n in e||(r.added[n]=t[n]);return r}class V{#e;static#t={default:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},solarized:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""},monokai:{reset:"",key:"",string:"",string_url:"",string_bool:"",string_number:"",number:"",boolean:"",null:"",special:"",func:""}};constructor(e={}){this.#e={...V.#t.default,...e}}#r(e,t){const r=[];e=(e=(e=e.replace(/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,`${t.number}$1${t.reset}`)).replace(/"([^"]+)":/g,(e,t)=>{const n=`___KEY${r.length}___`;return r.push({marker:n,key:t}),`${n}:`})).replace(/"(?:\\.|[^"\\])*?"/g,e=>{const r=e.slice(1,-1);return/^(https?|ftp):\/\/[^\s]+$/i.test(r)?`${t.string_url}${e}${t.reset}`:/^(true|false|null)$/.test(r)?`${t.string_bool}${e}${t.reset}`:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(r)?`${t.string_number}${e}${t.reset}`:`${t.string}${e}${t.reset}`});for(const{marker:n,key:i}of r){const r=new RegExp(n,"g");e=e.replace(r,`${t.key}"${i}"${t.reset}`)}return(e=(e=(e=(e=e.replace(/(?<!")\b(true|false)\b(?!")/g,`${t.boolean}$1${t.reset}`)).replace(/(?<!")\bnull\b(?!")/g,`${t.null}null${t.reset}`)).replace(/\[Circular\]/g,`${t.special}[Circular]${t.reset}`)).replace(/\[undefined\]/g,`${t.special}[undefined]${t.reset}`)).replace(/"function.*?[^\\]"/gs,`${t.func}$&${t.reset}`)}colorize(e,t={}){const r={...this.#e,...t};return this.#r(e,r)}getColors(){return{...this.#e}}updateColors(e){Object.assign(this.#e,e)}resetColors(){this.#e={...V.#t.default}}loadColorPreset(e){const t=V.#t[e];if(!t)throw new Error(`Preset "${e}" not found.`);this.#e={...t}}saveColorPreset(e,t){V.#t[e]={...t}}getAvailablePresets(){return Object.keys(V.#t)}}const K=V,U=class{#n=[];#i=!1;#o={};#s=new Set;isRunning(){return this.#i}async#a(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:r,reject:n,delay:i,id:o}=e;try{if(o&&this.#s.has(o))return n(new Error("The function was canceled on TinyPromiseQueue.")),this.#s.delete(o),this.#i=!1,void this.#l();i&&o&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#o[o],e(null)},i);this.#o[o]=t}),r(await t())}catch(e){n(e)}finally{this.#i=!1,this.#l()}}}async#u(){const e=[];for(;this.#n.length&&"POINT_MARKER"===this.#n[0]?.marker;)e.push(this.#n.shift());if(0===e.length)return this.#i=!1,void this.#l();await Promise.all(e.map(({task:e,resolve:t,reject:r,id:n})=>new Promise(async i=>{if(n&&this.#s.has(n))return this.#s.delete(n),r(new Error("The function was canceled on TinyPromiseQueue.")),void i(!0);await e().then(t).catch(r),i(!0)}))),this.#i=!1,this.#l()}async#l(){if(!this.#i&&0!==this.#n.length)if(this.#i=!0,"string"!=typeof this.#n[0]?.marker||"POINT_MARKER"!==this.#n[0]?.marker){const e=this.#n.shift();this.#a(e)}else this.#u()}getIndexById(e){return this.#n.findIndex(t=>t.id===e)}getQueuedIds(){return this.#n.map((e,t)=>({index:t,id:e.id})).filter(e=>"string"==typeof e.id)}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#n.length||t>=this.#n.length)return;const[r]=this.#n.splice(e,1);this.#n.splice(t,0,r)}async enqueuePoint(e,t){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&"string"!=typeof t)throw new Error('The "id" parameter must be a string.');return this.#i?new Promise((r,n)=>{this.#n.push({marker:"POINT_MARKER",task:e,resolve:r,reject:n,id:t}),this.#l()}):e()}enqueue(e,t,r){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&("number"!=typeof t||t<0))return Promise.reject(new Error("Delay must be a positive number or undefined."));if(void 0!==r&&"string"!=typeof r)throw new Error('The "id" parameter must be a string.');return new Promise((n,i)=>{this.#n.push({task:e,resolve:n,reject:i,id:r,delay:t}),this.#l()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#o&&(clearTimeout(this.#o[e]),delete this.#o[e],t=!0);const r=this.getIndexById(e);if(-1!==r){const[e]=this.#n.splice(r,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#s.add(e),t}},J=class{#c=null;#h=null;#d=null;#p=null;#f=null;#m=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#g=null;setOnMemoryExceeded(e){if("function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#g=e}clearOnMemoryExceeded(){this.#g=null}#y=null;setOnGroupExpired(e){if("function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#y=e}clearOnGroupExpired(){this.#y=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:n=3e5,maxMemory:i=1e5}){const o=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),s=o(e),a=o(t),l=o(r),u=o(n);if(!s&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==e&&!s)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==t&&!a)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==r&&!l)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!u)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof i&&Number.isFinite(i)&&i>0)this.#c=Math.floor(i);else{if(null!=i)throw new Error("maxMemory must be a positive number or null");this.#c=null}this.#d=s?e:null,this.#p=a?t:null,this.#f=l?r:null,this.#m=n,null!==this.#f&&(this.#h=setInterval(()=>this._cleanup(),this.#f))}isGroupId(e){const t=this.groupFlags.get(e);return"boolean"==typeof t&&t}getUsersInGroup(e){const t=[];for(const[r,n]of this.userToGroup.entries())n===e&&t.push(r);return t}setGroupTTL(e,t){if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new Error("TTL must be a positive number in milliseconds");this.groupTTL.set(e,t)}getGroupTTL(e){return this.groupTTL.get(e)??null}deleteGroupTTL(e){this.groupTTL.delete(e)}assignToGroup(e,t){const r=this.userToGroup.get(e);if(r&&r!==t)throw new Error(`User ${e} is already assigned to group ${r}`);if(r===t)return;const n=this.groupData.get(e);if(this.isGroupId(e)){for(const[r,n]of this.userToGroup.entries())n===e&&this.userToGroup.set(r,t);this.userToGroup.delete(e)}else this.userToGroup.set(e,t);if(!n)return;const i=this.groupData.get(t);if(i)for(const e of n)i.push(e);else{const e=[];for(const t of n)e.push(t);this.groupData.set(t,e)}this.lastSeen.set(t,Date.now()),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e),this.groupFlags.set(t,!0)}getGroupId(e){return this.userToGroup.get(e)||e}hit(e){const t=this.getGroupId(e),r=Date.now();this.groupData.has(t)||(this.groupData.set(t,[]),this.groupFlags.set(t,!1));const n=this.groupData.get(t);if(!n)throw new Error(`No data found for groupId: ${t}`);if(n.push(r),this.lastSeen.set(t,r),null!==this.#p){const e=r-this.getInterval();for(;n.length&&n[0]<e;)n.shift()}null!==this.#c&&"number"==typeof this.#c&&n.length>this.#c&&(n.splice(0,n.length-this.#c),"function"==typeof this.#g&&this.#g(t))}isRateLimited(e){const t=this.getGroupId(e);if(!this.groupData.has(t))return!1;const r=this.groupData.get(t);if(!r)throw new Error(`No data found for groupId: ${t}`);if(null!==this.#p){const e=Date.now()-this.getInterval();let t=0;for(let n=r.length-1;n>=0&&r[n]>e;n--)t++;return null!==this.#d?t>this.getMaxHits():t>0}return null!==this.#d&&r.length>this.getMaxHits()}resetGroup(e){this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e)}resetUserGroup(e){this.userToGroup.delete(e)}setData(e,t){if(!Array.isArray(t))throw new Error("timestamps must be an array of numbers.");for(const e of t)if("number"!=typeof e||!Number.isFinite(e))throw new Error("All timestamps must be finite numbers.");this.groupData.has(e)||this.groupFlags.set(e,!1),this.groupData.set(e,t),this.lastSeen.set(e,Date.now())}hasData(e){return this.groupData.has(e)}getData(e){return this.groupData.get(e)||[]}getMaxIdle(){if("number"!=typeof this.#m||!Number.isFinite(this.#m)||this.#m<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#m}setMaxIdle(e){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#m=e}_cleanup(){const e=Date.now();for(const[t,r]of this.lastSeen.entries())e-r>(this.getGroupTTL(t)??this.getMaxIdle())&&(this.groupFlags.delete(t),this.groupData.delete(t),this.lastSeen.delete(t),this.groupTTL.delete(t),"function"==typeof this.#y&&this.#y(t))}getActiveGroups(){return Array.from(this.groupData.keys())}getAllUserMappings(){return Object.fromEntries(this.userToGroup)}getInterval(){if("number"!=typeof this.#p||!Number.isFinite(this.#p))throw new Error("'interval' is not a valid finite number.");return this.#p}getMaxHits(){if("number"!=typeof this.#d||!Number.isFinite(this.#d))throw new Error("'maxHits' is not a valid finite number.");return this.#d}getTotalHits(e){const t=this.groupData.get(e);return Array.isArray(t)?t.length:0}getLastHit(e){const t=this.groupData.get(e);return t?.length?t[t.length-1]:null}getTimeSinceLastHit(e){const t=this.getLastHit(e);return null!==t?Date.now()-t:null}_calculateAverageSpacing(e){if(!Array.isArray(e)||e.length<2)return null;let t=0;for(let r=1;r<e.length;r++)t+=e[r]-e[r-1];return t/(e.length-1)}getAverageHitSpacing(e){return this._calculateAverageSpacing(this.groupData.get(e))}getMetrics(e){const t=this.groupData.get(e);if(!Array.isArray(t)||0===t.length)return{totalHits:0,lastHit:null,timeSinceLastHit:null,averageHitSpacing:null};const r=t.length,n=t[r-1];return{totalHits:r,lastHit:n,timeSinceLastHit:Date.now()-n,averageHitSpacing:this._calculateAverageSpacing(t)}}destroy(){this.#h&&clearInterval(this.#h),this._cleanup(),this.groupData.clear(),this.lastSeen.clear(),this.userToGroup.clear(),this.groupTTL.clear(),this.groupFlags.clear()}};class G{static getTemplate(){return'\n<div class="notify-overlay hidden">\n <div class="notify-center" id="notifCenter">\n <div class="header">\n <div>Notifications</div>\n <div class="options">\n <button class="clear-all" type="button">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n viewBox="0 0 24 24"\n width="24"\n height="24"\n fill="currentColor"\n >\n <path\n d="M21.6 2.4a1 1 0 0 0-1.4 0L13 9.6l-1.3-1.3a1 1 0 0 0-1.4 0L3 15.6a1 1 0 0 0 0 1.4l4 4a1 1 0 0 0 1.4 0l7.3-7.3a1 1 0 0 0 0-1.4l-1.3-1.3 7.2-7.2a1 1 0 0 0 0-1.4zM6 17l3.5-3.5 1.5 1.5L7.5 18.5 6 17z"\n />\n </svg>\n </button>\n <button class="close">×</button>\n </div>\n </div>\n <div class="list"></div>\n </div>\n</div>\n\n<button class="notify-bell" aria-label="Open notifications">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="20"\n height="20"\n fill="currentColor"\n viewBox="0 0 24 24"\n >\n <path\n d="M12 2C10.3 2 9 3.3 9 5v1.1C6.7 7.2 5 9.4 5 12v5l-1 1v1h16v-1l-1-1v-5c0-2.6-1.7-4.8-4-5.9V5c0-1.7-1.3-3-3-3zm0 20c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2z"\n />\n </svg>\n <span class="badge" id="notifBadge">0</span>\n</button>\n '}static insertTemplate(e="afterbegin"){document.body.insertAdjacentHTML(e,G.getTemplate())}#w;#b;#v;#E;#T;#S=0;#x=99;#A=300;#I=!1;#C=new WeakMap;#M(e){if(this.#C.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout(()=>{this.markAsRead(e),e.remove()},this.#A)}#L(e){this.#S=Math.max(0,e),this.#v.setAttribute("data-value",String(this.#S)),this.#v.textContent=this.#S>this.#x?`${this.#x}+`:String(this.#S)}constructor(e={}){const{center:t=document.getElementById("notifCenter"),badge:r=document.getElementById("notifBadge"),button:n=document.querySelector(".notify-bell"),overlay:i=document.querySelector(".notify-overlay")}=e;if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${t}`);if(!(i instanceof HTMLElement))throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${i}`);if(!(r instanceof HTMLElement))throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${r}`);if(!(n instanceof HTMLElement))throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${n}`);const o=t?.querySelector(".clear-all"),s=t?.querySelector(".list")??null;if(!(s instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${s}`);this.#w=t,this.#b=s,this.#v=r,this.#E=n,this.#T=i,this.#E.addEventListener("click",()=>this.toggle()),this.#w.querySelector(".close")?.addEventListener("click",()=>this.close()),o&&o.addEventListener("click",()=>this.clear()),this.#T.addEventListener("click",e=>{e.target===this.#T&&this.close()})}setMarkAllAsReadOnClose(e){if("boolean"!=typeof e)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof e);this.#I=e}setRemoveDelay(e){if("number"!=typeof e)throw new Error('NotificationCenter: "ms" must be an number.');this.#A=e}getItemMode(e){const t=this.getItem(e);return t?this.#C.get(t):null}getItem(e){const t=this.#b.children.item(e);if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${t}`);return t}hasItem(e){return e>=0&&e<this.#b.children.length}markAsRead(e){const t=e instanceof HTMLElement?e:this.getItem(e);t.classList.contains("unread")&&(t.classList.remove("unread"),this.#L(this.#S-1))}add(e,t="text"){const r=document.createElement("div");r.className="item unread";let n=null,i=null,o=null,s=null;if("object"==typeof e&&null!==e?(n=e.title,i=e.message,o=e.avatar,s=e.onClick):i=e,o){const e=document.createElement("div");e.className="avatar",e.style.backgroundImage=`url("${o}")`,r.appendChild(e)}const a=document.createElement("div");if(a.className="content",n){const e=document.createElement("div");e.className="title",e.textContent=n,a.appendChild(e)}const l=document.createElement("div");l.className="message","html"===t?l.innerHTML=i:l.textContent=i,a.appendChild(l),"function"==typeof s&&(r.classList.add("clickable"),r.addEventListener("click",e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&s(e)}));const u=document.createElement("button");u.className="notify-close",u.setAttribute("type","button"),u.innerHTML="&times;",u.addEventListener("click",e=>{e.stopPropagation(),this.#M(r)}),r.append(a,u),this.#b.prepend(r),this.#C.set(r,t),this.#L(this.#S+1)}remove(e){const t=this.getItem(e);this.#M(t)}clear(){let e=!0;for(;e;){e=!1;const t=Array.from(this.#b.children);for(const r of t)r instanceof HTMLElement&&!r.classList.contains("removing")&&(this.#M(r),e=!0)}}open(){this.#T.classList.remove("hidden"),this.#w.classList.add("open")}close(){if(this.#T.classList.add("hidden"),this.#w.classList.remove("open"),this.#I){const e=this.#b.querySelectorAll(".item.unread");for(const t of e)t instanceof HTMLElement&&this.markAsRead(t)}}toggle(){this.#w.classList.contains("open")?this.close():this.open()}recount(){const e=this.#b.querySelectorAll(".item.unread").length;this.#L(e)}get count(){return this.#S}destroy(){this.#E?.removeEventListener("click",this.toggle),this.#w?.querySelector(".close")?.removeEventListener("click",this.close),this.#w?.querySelector(".clear-all")?.removeEventListener("click",this.clear),this.#T?.removeEventListener("click",this.close),this.clear(),this.#w?.remove(),this.#T?.remove(),this.#E?.remove(),this.#S=0,this.#C=new WeakMap}}const Y=G,X=class{#N;#k;#D;#_;#j;#R;constructor(e="top",t="right",r=3e3,n=50,i=300,o=".notify-container"){this.#O(e),this.#H(t),this.#B(r,"baseDuration"),this.#B(n,"extraPerChar"),this.#B(i,"fadeOutDuration"),this.#N=e,this.#k=t,this.#D=r,this.#_=n,this.#j=i;const s=document.querySelector(`${o}.${e}.${t}`);s instanceof HTMLElement?this.#R=s:(this.#R=document.createElement("div"),this.#R.className=`notify-container ${e} ${t}`,document.body.appendChild(this.#R))}getContainer(){if(!(this.#R instanceof HTMLElement))throw new Error("Container is not a valid HTMLElement.");return this.#R}#O(e){if(!["top","bottom"].includes(e))throw new Error(`Invalid vertical direction "${e}". Expected "top" or "bottom".`)}#H(e){if(!["left","right","center"].includes(e))throw new Error(`Invalid horizontal position "${e}". Expected "left", "right" or "center".`)}#B(e,t){if("number"!=typeof e||e<0||!Number.isFinite(e))throw new Error(`Invalid value for "${t}": ${e}. Must be a non-negative finite number.`)}getY(){return this.#N}setY(e){this.#O(e);const t=this.getContainer();t.classList.remove(this.#N),t.classList.add(e),this.#N=e}getX(){return this.#k}setX(e){this.#H(e);const t=this.getContainer();t.classList.remove(this.#k),t.classList.add(e),this.#k=e}getBaseDuration(){return this.#D}setBaseDuration(e){this.#B(e,"baseDuration"),this.#D=e}getExtraPerChar(){return this.#_}setExtraPerChar(e){this.#B(e,"extraPerChar"),this.#_=e}getFadeOutDuration(){return this.#j}setFadeOutDuration(e){this.#B(e,"fadeOutDuration"),this.#j=e}show(e){let t="",r="",n=null,i=!1,o=null;const s=document.createElement("div");if(s.className="notify enter","string"==typeof e)t=e;else{if("object"!=typeof e||null===e||"string"!=typeof e.message)throw new Error("Invalid argument for show(): expected string or { message: string, title?: string, onClick?: function, html?: boolean, avatar?: string }");if(t=e.message,r="string"==typeof e.title?e.title:"",i=!0===e.html,o="string"==typeof e.avatar?e.avatar:null,void 0!==e.onClick){if("function"!=typeof e.onClick)throw new Error("onClick must be a function if defined");n=e.onClick,s.classList.add("clickable")}}const a=document.createElement("button");if(a.innerHTML="&times;",a.className="close",a.setAttribute("aria-label","Close"),a.addEventListener("mouseenter",()=>{a.style.color="var(--notify-close-color-hover)"}),a.addEventListener("mouseleave",()=>{a.style.color="var(--notify-close-color)"}),o){const e=document.createElement("img");e.src=o,e.alt="avatar",e.className="avatar",s.appendChild(e)}if(r){const e=document.createElement("strong");e.textContent=r,e.style.display="block",s.appendChild(e)}if(i){const e=document.createElement("div");e.innerHTML=t,s.appendChild(e)}else s.appendChild(document.createTextNode(t));s.appendChild(a),this.getContainer().appendChild(s);const l=this.#D+t.length*this.#_+this.#j;let u=!1;const c=()=>{u||(u=!0,s.classList.remove("enter","show"),s.classList.add("exit"),setTimeout(()=>s.remove(),this.#j))};"function"==typeof n&&s.addEventListener("click",e=>{e.target!==a&&n(e,c)}),a.addEventListener("click",e=>{e.stopPropagation(),c()}),setTimeout(()=>{s.classList.remove("enter"),s.classList.add("show")},1),setTimeout(()=>c(),l)}destroy(){this.#R instanceof HTMLElement&&(this.#R.querySelectorAll(".notify").forEach(e=>e.remove()),this.#R.parentNode&&this.#R.parentNode.removeChild(this.#R),this.#R=null)}};function Q(e,t){return new Promise((r,n)=>{const i=new FileReader;i.onload=()=>{try{r(i.result)}catch(e){n(e)}},i.onerror=()=>{n(i.error)},i[t](e)})}function Z(e,t=!1){return new Promise((r,n)=>{"string"!=typeof t&&"boolean"!=typeof t&&n(new TypeError("The isDataUrl parameter must be a boolean or a string.")),Q(e,"readAsDataURL").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const n=e.match(/^data:(.+);base64,(.*)$/);if(!n||!n[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,i,o]=n;if(!/^[\w/+]+=*$/.test(o))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:o);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${o}`)}).catch(n)})}function ee(e){return new Promise((t,r)=>Q(e,"readAsText").then(e=>{if("string"!=typeof e)throw new TypeError("Expected file content to be a string.");const r=e.trim();if(0===r.length)throw new Error("File is empty or contains only whitespace.");const n=JSON.parse(r);if("object"!=typeof n||null===n)throw new Error("Parsed content is not a valid JSON object or array.");t(n)}).catch(r))}function te(e,t,r=2){const n=JSON.stringify(t,null,r),i=new Blob([n],{type:"application/json"}),o=URL.createObjectURL(i),s=document.createElement("a");s.href=o,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}async function re(e,{method:t="GET",body:r,timeout:n=0,retries:i=0,headers:o={},signal:s=null}={}){if("string"!=typeof e||!e.startsWith("../")&&!e.startsWith("./")&&!e.startsWith("/")&&!e.startsWith("https://")&&!e.startsWith("http://"))throw new Error("Invalid URL: must be a valid http or https address.");if("string"!=typeof t||!t.trim())throw new Error("Invalid method: must be a non-empty string.");if(!s){if("number"!=typeof n||!Number.isFinite(n)||Number.isNaN(n)||n<0)throw new Error("Invalid timeout: must be a positive number.");if("number"!=typeof i||!Number.isFinite(i)||Number.isNaN(i)||i<0)throw new Error("Invalid retries: must be a positive number.")}const a=s?1:i+1;let l=null;for(let u=0;u<a;u++){const a=s?null:new AbortController,c=s||(a?.signal??null),h=!s&&n&&a?setTimeout(()=>a.abort(),n):null;try{const n=await fetch(e,{method:t.toUpperCase(),headers:{Accept:"application/json",...o},body:void 0!==r?m(r)?JSON.stringify(r):r:void 0,signal:c});if(h&&clearTimeout(h),!n.ok)throw new Error(`HTTP error: ${n.status} ${n.statusText}`);return n}catch(e){if(l=e,s)break;u<i&&await new Promise(e=>setTimeout(e,300*(u+1)))}}throw new Error(`Failed to fetch JSON from "${e}"${l?`: ${l.message}`:"."}`)}async function ne(e,t){return new Promise((r,n)=>{re(e,t).then(async e=>{const t=e.headers.get("content-type")||"";if(!t.includes("application/json"))throw new Error(`Unexpected content-type: ${t}`);const n=await e.json();if(!Array.isArray(n)&&!m(n))throw new Error("Received invalid data instead of valid JSON.");return r(n)}).catch(n)})}async function ie(e,t,r){return new Promise((n,i)=>{re(e,r).then(async e=>{const r=e.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>r.includes(e)))throw new Error(`Blocked MIME type: ${r}`);const i=await e.text();return n(i)}).catch(i)})}function oe({element:e=document.body,hiddenClass:t="windowHidden",visibleClass:r="windowVisible",onVisible:n,onHidden:i}={}){if(!(e instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof t)throw new TypeError('"hiddenClass" must be a string.');if("string"!=typeof r)throw new TypeError('"visibleClass" must be a string.');if(void 0!==n&&"function"!=typeof n)throw new TypeError('"onVisible" must be a function if provided.');if(void 0!==i&&"function"!=typeof i)throw new TypeError('"onHidden" must be a function if provided.');let o="",s="";const a=()=>{e.classList.remove(t),e.classList.remove(r)};let l=null;const u=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],c=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<c.length;e++)if(c[e]in document){l=c[e];break}const h=function(u){a();const c=u?.type,h=l&&document[l];["focus","focusin","pageshow"].includes(c)?(e.classList.add(r),n?.({type:c,oldClass:s,oldType:o}),s=r):["blur","focusout","pagehide"].includes(c)||h?(e.classList.add(t),i?.({type:c,oldClass:s,oldType:o}),s=t):(e.classList.add(r),n?.({type:c,oldClass:s,oldType:o}),s=r),o=c};let d=()=>{};if(l){const e=u[c.indexOf(l)];document.addEventListener(e,h),window.addEventListener("focus",h),window.addEventListener("blur",h),d=()=>{document.removeEventListener(e,h),window.removeEventListener("focus",h),window.removeEventListener("blur",h),a()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=h,d=()=>{document.onfocusin=document.onfocusout=null,a()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=h,d=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,a()});const p=new Event(l&&document[l]?"blur":"focus");return h(p),d}const se=class{#$;#P;#F;#W;#z;#q;#V;#K;constructor(e={}){const{target:t,fullscreen:r=!0,hoverClass:n="dnd-hover",onDrop:i,onEnter:o,onLeave:s}=e;if("boolean"!=typeof r)throw new TypeError('The "fullscreen" option must be a boolean.');const a=r?document.body:t||document.body;if(!(a instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof n)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof i)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof o)throw new TypeError('The "onEnter" option must be a function.');if("function"!=typeof s)throw new TypeError('The "onLeave" option must be a function.');this.#$=a,this.#P=r,this.#F=n,this.#W=i||(()=>{}),this.#z=o,this.#q=s,this.#V=!1,this.#K=!1,this._handleDragEnter=this._handleDragEnter.bind(this),this._handleDragOver=this._handleDragOver.bind(this),this._handleDragLeave=this._handleDragLeave.bind(this),this._handleDrop=this._handleDrop.bind(this),this.#U()}getTarget(){return this.#$}getHoverClass(){return this.#F}isFullScreen(){return this.#P}isDragging(){return this.#V}bound(){return this.#K}#U(){if(this.#K)return;const e=this.getTarget();e.addEventListener("dragenter",this._handleDragEnter),e.addEventListener("dragover",this._handleDragOver),e.addEventListener("dragleave",this._handleDragLeave),e.addEventListener("drop",this._handleDrop),this.#K=!0}#J(){if(!this.#K)return;const e=this.getTarget();e.removeEventListener("dragenter",this._handleDragEnter),e.removeEventListener("dragover",this._handleDragOver),e.removeEventListener("dragleave",this._handleDragLeave),e.removeEventListener("drop",this._handleDrop),this.#K=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#V){const t=this.getTarget();this.#V=!0,t.classList.add(this.#F),this.#z(e)}}_handleDragOver(e){e.preventDefault(),e.dataTransfer?e.dataTransfer.dropEffect="copy":console.warn("[TinyDragDropDetector] [handleDragOver] DragOver event missing dataTransfer.")}_handleDragLeave(e){e.preventDefault();const t=this.getTarget();null!==e.relatedTarget&&t.contains(e.relatedTarget)||(this.#V=!1,t.classList.remove(this.#F),this.#q(e))}_handleDrop(e){if(e.preventDefault(),!e.dataTransfer)return void console.warn("[TinyDragDropDetector] [handleDrop] DragOver event missing dataTransfer.");const t=this.getTarget();this.#V=!1,t.classList.remove(this.#F);const r=e.dataTransfer.files;r.length>0&&this.#W(r,e)}destroy(){this.#J(),this.getTarget().classList.remove(this.#F)}};var ae=r(133),le=r(975);function ue(e){if(!(0,ae.existsSync)(e))throw new Error(`File not found: ${e}`);const t=(0,ae.readFileSync)(e,"utf-8");return JSON.parse(t)}function ce(e,t,r=2){const n=JSON.stringify(t,null,r);(0,ae.writeFileSync)(e,n,"utf-8")}function he(e){(0,ae.existsSync)(e)||(0,ae.mkdirSync)(e,{recursive:!0})}function de(e){if(!(0,ae.existsSync)(e))return;const t=(0,ae.readdirSync)(e);for(const r of t){const t=(0,le.join)(e,r);(0,ae.lstatSync)(t).isDirectory()?(0,ae.rmSync)(t,{recursive:!0,force:!0}):(0,ae.unlinkSync)(t)}}function pe(e){return(0,ae.existsSync)(e)&&(0,ae.lstatSync)(e).isFile()}function fe(e){return(0,ae.existsSync)(e)&&(0,ae.lstatSync)(e).isDirectory()}function me(e){return 0===(0,ae.readdirSync)(e).length}function ge(e,t,r){he((0,le.dirname)(t)),(0,ae.copyFileSync)(e,t,r)}function ye(e){return!!pe(e)&&((0,ae.unlinkSync)(e),!0)}function we(e,t,r="utf-8"){he((0,le.dirname)(e)),(0,ae.writeFileSync)(e,t,r)}function be(e,t=!1){const r={files:[],dirs:[]};if(!fe(e))return r;const n=(0,ae.readdirSync)(e);for(const i of n){const n=(0,le.join)(e,i);if((0,ae.lstatSync)(n).isDirectory()){if(r.dirs.push(n),t){const e=be(n,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(n)}return r}function ve(e,t=!1){const r=[];if(!fe(e))return r;const n=(0,ae.readdirSync)(e);for(const i of n){const n=(0,le.join)(e,i);(0,ae.lstatSync)(n).isDirectory()&&(r.push(n),t&&r.push(...ve(n,!0)))}return r}function Ee(e){return pe(e)?(0,ae.statSync)(e).size:0}function Te(e){let t=0;const r=be(e,!0).files;for(const e of r)t+=Ee(e);return t}function Se(e,t="bak"){pe(e)&&ge(e,`${e}.${t}.${(new Date).toISOString().replace(/[:.]/g,"-")}`)}function xe(e,t="bak"){const r=(0,le.dirname)(e),n=(0,le.basename)(e),i=(0,ae.readdirSync)(r).filter(e=>e.startsWith(`${n}.${t}.`)).sort().reverse();if(0===i.length)throw new Error(`No backups found for ${e}`);return(0,le.join)(r,i[0])}function Ae(e,t="bak"){ge(xe(e,t),e)}function Ie(e,t,r=[]){if("string"!=typeof e)throw new TypeError("dirPath must be a string");if("function"!=typeof t)throw new TypeError("renameFn must be a function");if(!Array.isArray(r))throw new TypeError("extensions must be an array of strings");if(!(0,ae.existsSync)(e)||!(0,ae.statSync)(e).isDirectory())throw new Error(`Directory not found or invalid: ${e}`);for(const e of r)if("string"!=typeof e||!e.startsWith("."))throw new TypeError(`Invalid extension: ${e}`);const n=be(e).files;let i=0;for(const o of n){const n=(0,le.extname)(o);if(r.length&&!r.includes(n))continue;const s=(0,le.basename)(o),a=t(s,i++),l=(0,le.join)(e,a);s!==a&&(0,ae.renameSync)(o,l)}}function Ce(e,t,r,n=[]){Ie(e,e=>{const n=(0,le.extname)(e);return`${(0,le.basename)(e,n).replace(t,r)}${n}`},n)}function Me(e,{prefix:t="",suffix:r=""},n=[]){Ie(e,e=>{const n=(0,le.extname)(e),i=(0,le.basename)(e,n);return`${t}${i}${r}${n}`},n)}function Le(e,t="lower",r=[],n=!1){if("string"!=typeof t||!["lower","upper","title"].includes(t))throw new Error(`Invalid mode "${t}". Must be 'lower', 'upper' or 'title'.`);Ie(e,e=>{const r=e=>"lower"===t?e.toLowerCase():"upper"===t?e.toUpperCase():"title"===t?P(e):e,i=(0,le.extname)(e),o=n?r(i):i;return`${r((0,le.basename)(e,i))}${o}`},r)}function Ne(e,t=3,r=[]){Ie(e,e=>e.replace(/\d+/,e=>e.padStart(t,"0")),r)}var ke=r(370);async function De(e){if(!(0,ae.existsSync)(e))return;const t=await(0,ke.readdir)(e),r={},n=[];for(const i of t){const t=(0,le.join)(e,i),o=(0,ke.lstat)(t);o.then(e=>(r[t]=e,e)),n.push(o)}await Promise.all(n);const i=[];for(const e in r)r[e].isDirectory()?i.push((0,ke.rm)(e,{recursive:!0,force:!0})):i.push((0,ke.unlink)(e));await Promise.all(i)}async function _e(e){return 0===(await(0,ke.readdir)(e)).length}async function je(e,t=!1){const r={files:[],dirs:[]};if(!fe(e))return r;const n=await(0,ke.readdir)(e);for(const i of n){const n=(0,le.join)(e,i);if((await(0,ke.lstat)(n)).isDirectory()){if(r.dirs.push(n),t){const e=await je(n,!0);r.files.push(...e.files),r.dirs.push(...e.dirs)}}else r.files.push(n)}return r}async function Re(e,t=!1){const r=[];if(!fe(e))return r;const n=await(0,ke.readdir)(e);for(const i of n){const n=(0,le.join)(e,i);(await(0,ke.lstat)(n)).isDirectory()&&(r.push(n),t&&r.push(...await Re(n,!0)))}return r}async function Oe(e){return pe(e)?(await(0,ke.stat)(e)).size:0}async function He(e){let t=0;const{files:r}=await je(e,!0),n=[];for(const e of r){const r=Oe(e);r.then(e=>(t+=e,e)),n.push(r)}return await Promise.all(n),t}const Be=(e,t)=>e.bottom<t.top,$e=(e,t)=>e.top>t.bottom,Pe=(e,t)=>e.right<t.left,Fe=(e,t)=>e.left>t.right,We=(e,t)=>e.bottom<=t.top,ze=(e,t)=>e.top>=t.bottom,qe=(e,t)=>e.right<=t.left,Ve=(e,t)=>e.left>=t.right,Ke=(e,t)=>!(Pe(e,t)||Fe(e,t)||Be(e,t)||$e(e,t)),Ue=(e,t)=>!(qe(e,t)||Ve(e,t)||We(e,t)||ze(e,t)),Je=(e,t)=>Pe(e,t)?"left":Fe(e,t)?"right":Be(e,t)?"top":$e(e,t)?"bottom":null,Ge=(e,t)=>qe(e,t)?"left":Ve(e,t)?"right":We(e,t)?"top":ze(e,t)?"bottom":null,Ye=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),Xe=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:e<t?"right":"left",dirY:r<n?"bottom":"top"}),Qe=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function Ze(e,t){const r=e.left+e.width/2,n=e.top+e.height/2;return{x:t.left+t.width/2-r,y:t.top+t.height/2-n}}function et(e,t){if(!Ue(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:i,overlapBottom:o}=Ye(e,t),{dirX:s,dirY:a}=Xe({overlapLeft:r,overlapRight:n,overlapTop:i,overlapBottom:o}),l=Math.min(r,n),u=Math.min(i,o);let c;return c=l<u?s:a,{inDir:c,dirX:s,dirY:a,depthX:l,depthY:u}}function tt(e,t){const r=Ue(e,t),n={in:null,x:null,y:null},i={y:null,x:null},o={top:0,bottom:0,left:0,right:0},{overlapLeft:s,overlapRight:a,overlapTop:l,overlapBottom:u}=Ye(t,e);o.top=l,o.bottom=u,o.left=s,o.right=a;const c=Object.entries(o).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:h,dirY:d}=Xe({overlapLeft:a,overlapRight:s,overlapTop:u,overlapBottom:l});return n.y=d,n.x=h,o.bottom<0?i.y="bottom":o.top<0&&(i.y="top"),o.left<0?i.x="left":o.right<0&&(i.x="right"),n.in=r?o.top===o.bottom&&o.bottom===o.left&&o.left===o.right?"center":c.length?c[0][0]:"top":null,{dirs:n,depth:o,isNeg:i}}const rt=class{#G;get el(){return this.#G}set el(e){if(this.#G)throw new Error("The observed element has already been set and cannot be reassigned.");if(void 0!==e&&!(e instanceof Element))throw new TypeError("The observed element must be a valid DOM Element.");this.#G=e}#Y={};get settings(){return this.#Y}set settings(e){if("object"!=typeof e||null===e)throw new TypeError("settings must be a non-null object.");this.#Y=e}#X=null;get observer(){return this.#X}#Q=[];get detectors(){return this.#Q.map(e=>[e[0],e[1]])}set detectors(e){if(!Array.isArray(e))throw new TypeError("detectors must be an array.");const t=[];for(const[r,n]of e){if("string"!=typeof r)throw new TypeError("Detector name must be a string.");if("function"!=typeof n)throw new TypeError(`Detector handler for "${r}" must be a function.`);t.push([r,n])}this.#Q=t}get isActive(){return!!this.#X}get size(){return this.#Q.length}constructor({el:e,initDetectors:t=[],initCfg:r={}}={}){this.el=e,t.length&&(this.detectors=t),r&&(this.settings=r)}clear(){this.#Q=[]}start(){if(!this.#G)throw new Error("Cannot start observation: no target element has been set.");this.#X||(this.#X=new MutationObserver(e=>{e.forEach((e,t,r)=>this.#Q.forEach(n=>n[1](e,t,r)))}),this.#X.observe(this.#G,this.#Y))}stop(){this.#X&&(this.#X.disconnect(),this.#X=null)}add(e,t){this.#Z(e,t),this.#Q.push([e,t])}insertAtStart(e,t){this.#Z(e,t),this.#Q.unshift([e,t])}insertAt(e,t,r,n="after"){if(this.#Z(t,r),"number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for insertDetectorAt.");const i="before"===n?e:e+1;this.#Q.splice(i,0,[t,r])}removeAt(e){if("number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorAt.");this.#Q.splice(e,1)}removeAround(e,t=0,r=0){if("number"!=typeof e||e<0||e>=this.#Q.length)throw new RangeError("Invalid index for removeDetectorsAround.");const n=Math.max(0,e-t),i=t+1+r;this.#Q.splice(n,i)}isIndexUsed(e){return e>=0&&e<this.#Q.length}hasHandler(e){if("function"!=typeof e)throw new TypeError("Handler must be a function.");return this.#Q.some(([t,r])=>r===e)}#Z(e,t){if("string"!=typeof e||!e.trim())throw new TypeError("Detector name must be a non-empty string.");if("function"!=typeof t)throw new TypeError(`Detector handler for "${e}" must be a function.`)}destroy(){this.stop(),this.clear()}},{areElsColliding:nt,areElsPerfColliding:it,areElsCollTop:ot,areElsCollBottom:st,areElsCollLeft:at,areElsCollRight:lt}=e,ut=new WeakMap,ct=new WeakMap,ht=new WeakMap,dt=new WeakMap,pt={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class ft{static Utils={...e};static#ee=!1;static get elemDebug(){return ft.#ee}static set elemDebug(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value for elemDebug");ft.#ee=e}static _debugElemError(e,t){if(!ft.#ee)return;const r="[TinyHtml Debug] Element validation error";if(console.groupCollapsed(`${r}${t?" — details below":""}`),console.error(r),"undefined"!=typeof Error&&"function"==typeof Error.captureStackTrace){const e=new Error(r);Error.captureStackTrace(e,ft._debugElemError),console.error(e.stack)}else console.trace(r);if(Array.isArray(e)){const t=e.map((e,t)=>({index:t,typeOf:null===e?"null":typeof e,constructor:e?.constructor?.name??(null===e?"null":"primitive"),summary:"undefined"!=typeof Element&&e instanceof Element?`${e.tagName?.toLowerCase?.()??"element"}#${e.id||""}.${String(e.className||"").trim().replace(/\s+/g,".")}`:e&&"object"==typeof e&&"nodeType"in e?`nodeType:${e.nodeType}`:"",value:e}));console.table(t)}else console.warn('[TinyHtml Debug] "elems" is not an array:',e);arguments.length>1&&(console.error("[TinyHtml Debug] Problematic element:",t),t&&"object"==typeof t&&console.dir(t)),console.groupEnd()}static parseStyle(e){const t={};return e.split(";").forEach(e=>{const[r,n]=e.split(":").map(e=>e&&e.trim());r&&n&&(t[r]=n)}),t}static#te=!0;static get autoStartElemObserver(){return ft.#te}static set autoStartElemObserver(e){if("boolean"!=typeof e)throw new TypeError("autoStartElemObserver must be a boolean.");ft.#te=e}static#re=new rt({el:"undefined"!=typeof window&&void 0!==window.document?window.document.documentElement:void 0,initDetectors:[["tinyStyleEvent",e=>{if("attributes"!==e.type||"style"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.getAttribute("style")||"",n=q(ft.parseStyle(t),ft.parseStyle(r));(Object.keys(n.added).length||Object.keys(n.removed).length||Object.keys(n.modified).length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.stylechanged",{detail:n}))}],["tinyClassEvent",e=>{if("attributes"!==e.type||"class"!==e.attributeName||!(e.target instanceof HTMLElement))return;const t=e.oldValue||"",r=e.target.className||"",n=a(t.split(/\s+/).filter(Boolean),r.split(/\s+/).filter(Boolean));(n.added.length||n.removed.length)&&e.target.dispatchEvent(new CustomEvent("tinyhtml.classchanged",{detail:n}))}]],initCfg:{attributeOldValue:!0,attributes:!0,subtree:!0,attributeFilter:["style","class"]}});static get tinyObserver(){return ft.#re}static async fetchHtmlFile(e,t={method:"GET"}){const r=await fetch(e,t),n=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!n.includes("text/html"))throw new Error(`Invalid content type: ${n} (expected text/html)`);const i=await r.text();return ft.htmlToJson(i)}static async fetchHtmlNodes(e,t){const r=await ft.fetchHtmlFile(e,t);return ft.jsonToNodes(r)}static async fetchHtmlTinyElems(e,t){const r=await ft.fetchHtmlNodes(e,t);return ft.toTinyElm(r)}static templateToJson(e){return ft.htmlToJson([...e.content.childNodes].map(e=>e instanceof Element?e.getHTML():e instanceof Text?e.textContent:"").join(""))}static templateToNodes(e){const t=[];return[...e.content.cloneNode(!0).childNodes].map(e=>{if(!(e instanceof Element||e instanceof Text||e instanceof Comment))throw new Error(`Expected only Element nodes in <template>, but found: ${e.constructor.name}`);e instanceof Comment||t.push(e)}),t}static templateToTinyElems(e){return ft.toTinyElm(ft.templateToNodes(e))}static htmlToJson(e){const t=document.createElement("div");t.innerHTML=e.trim();const r=[],n=e=>{if(e instanceof Comment)return null;if(e instanceof Text){const t=e.textContent?.trim();return t||null}if(!(e instanceof Element))return null;const t=e.tagName.toLowerCase(),r={};for(const t of e.attributes)r[ft.getPropName(t.name)]=t.value;const i=Array.from(e.childNodes).map(n).filter(Boolean);return i.length>0?[t,r,...i]:[t,r]};for(const e of t.childNodes){const t=n(e);t&&r.push(t)}return t.innerHTML="",r}static jsonToNodes(e){const t=e=>{if("string"==typeof e)return document.createTextNode(e);if(!Array.isArray(e))return document.createTextNode("");const[r,n,...i]=e,o=document.createElement(r);for(const[e,t]of Object.entries(n))o.setAttribute(ft.getAttrName(e),t);for(const e of i){const r=t(e);r instanceof Comment||o.appendChild(r)}return o};return e.map(t).filter(e=>!(e instanceof Comment))}static jsonToTinyElems(e){return ft.toTinyElm(ft.jsonToNodes(e))}static createFrom(e,t){if("string"!=typeof e)throw new TypeError('The "tagName" must be a string.');if(void 0!==t&&"object"!=typeof t)throw new TypeError('The "attrs" must be a object.');const r=ft.createElement(e);if("object"==typeof t)for(const e in t)r.setAttr(e,t[e]);return r}static createElement(e,t){if("string"!=typeof e)throw new TypeError("[TinyHtml] createElement(): The tagName must be a string.");if(void 0!==t&&"object"!=typeof t)throw new TypeError("[TinyHtml] createElement(): The ops must be a object.");return new ft(document.createElement(e,t))}static createTextNode(e){if("string"!=typeof e)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new ft(document.createTextNode(e))}static createElementFromHTML(e){const t=document.createElement("template");if(!(e=e.trim()).startsWith("<"))return ft.createTextNode(e);if(t.innerHTML=e,!(t.content.firstChild instanceof Element))throw new Error("The HTML string must contain a valid HTML element.");return new ft(t.content.firstChild)}static createFromHTML(e){const t=document.createElement("template");e=e.trim(),t.innerHTML=e;const r=Array.from(t.content.childNodes);if(!r.every(e=>e instanceof Element||e instanceof Text))throw new Error("The HTML string must contain a valid HTML element.");return new ft(r)}static createFromHtml(e){return ft.createFromHTML(e)}static query(e,t=document){const r=t.querySelector(e);return r?new ft(r):null}querySelector(e){return ft.query(e,ft._preElem(this,"query"))}static queryAll(e,t=document){return new ft(t.querySelectorAll(e))}querySelectorAll(e){return ft.queryAll(e,ft._preElem(this,"queryAll"))}static getById(e){const t=document.getElementById(e);return t?new ft(t):null}static getByClassName(e,t=document){return new ft(t.getElementsByClassName(e))}getElementsByClassName(e){return ft.getByClassName(e,ft._preElem(this,"getByClassName"))}static getByName(e){return new ft(document.getElementsByName(e))}static getByTagNameNS(e,t="http://www.w3.org/1999/xhtml",r=document){return new ft(r.getElementsByTagNameNS(t,e))}getElementsByTagNameNS(e,t="http://www.w3.org/1999/xhtml"){return ft.getByTagNameNS(e,t,ft._preElem(this,"getByTagNameNS"))}get elements(){return[...this.#G]}forEach(e){const t=this.elements.map((e,t)=>this.extract(t));for(const r in t)e(t[r],Number(r),t);return this}get(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#G[e])throw new Error(`No element found at index ${e}.`);return this.#G[e]}extract(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");if(!this.#G[e])throw new Error(`Cannot extract: no element exists at index ${e}.`);return new ft(this.#G[e])}exists(e){if("number"!=typeof e)throw new TypeError("The index must be a number.");return!!this.#G[e]}getAll(){return[...this.#G]}_getElement(e,t){if(!(this.#G[t]instanceof Element||this.#G[t]instanceof Window||this.#G[t]instanceof Document||this.#G[t]instanceof Text))throw ft._debugElemError([...this.#G],this.#G[t]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return this.#G[t]}_getElements(e){if(!this.#G.every(e=>e instanceof Element||e instanceof Window||e instanceof Document||e instanceof Text))throw ft._debugElemError([...this.#G]),new Error(`[TinyHtml] Invalid Element in ${e}().`);return[...this.#G]}static _preElemsTemplate(e,t,r,n){const i=e=>{const i=[];return e.map(o=>(o instanceof ft?o._getElements(t):[o]).map(o=>{let s=!1;for(const e of r)if(o instanceof e){s=!0;break}if(!s)throw ft._debugElemError([...e],o),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${t}().`);return i.push(o),o})),i};return Array.isArray(e)?i(e):i([e])}static _preElemTemplate(e,t,r,n,i=!1){const o=e=>{const o=e[0],s=o instanceof ft?o._getElements(t):[o];if(s.length>1)throw ft._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${s.length}/1).`);let a=!1;for(const e of r)if(s[0]instanceof e){a=!0;break}if(!i||null!==s[0]&&void 0!==s[0]||(s[0]=null,a=!0),!a)throw ft._debugElemError([...e],s[0]),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${t}().`);return s[0]};if(!Array.isArray(e))return o([e]);if(e.length>1)throw ft._debugElemError([...e]),new Error(`[TinyHtml] Invalid element amount in ${t}() (Received ${e.length}/1).`);return o(e)}static _preElems(e,t){return ft._preElemsTemplate(e,t,[Element],["Element"])}static _preElem(e,t){return ft._preElemTemplate(e,t,[Element],["Element"])}static _preNodeElems(e,t){return ft._preElemsTemplate(e,t,[Node],["Node"])}static _preNodeElem(e,t){return ft._preElemTemplate(e,t,[Node],["Node"])}static _preNodeElemWithNull(e,t){return ft._preElemTemplate(e,t,[Node],["Node"],!0)}static _preHtmlElems(e,t){return ft._preElemsTemplate(e,t,[HTMLElement],["HTMLElement"])}static _preHtmlElem(e,t){return ft._preElemTemplate(e,t,[HTMLElement],["HTMLElement"])}static _preInputElems(e,t){return ft._preElemsTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}static _preInputElem(e,t){return ft._preElemTemplate(e,t,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}static _preEventTargetElems(e,t){return ft._preElemsTemplate(e,t,[EventTarget],["EventTarget"])}static _preEventTargetElem(e,t){return ft._preElemTemplate(e,t,[EventTarget],["EventTarget"])}static _preElemsAndWindow(e,t){return ft._preElemsTemplate(e,t,[Element,Window],["Element","Window"])}static _preElemAndWindow(e,t){return ft._preElemTemplate(e,t,[Element,Window],["Element","Window"])}static _preElemsAndWinAndDoc(e,t){return ft._preElemsTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]).map(e=>e instanceof Document?e.documentElement:e)}static _preElemAndWinAndDoc(e,t){const r=ft._preElemTemplate(e,t,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}static _preElemsWithDoc(e,t){return ft._preElemsTemplate(e,t,[Element,Document],["Element","Document"])}static _preElemWithDoc(e,t){return ft._preElemTemplate(e,t,[Element,Document],["Element","Document"])}static toTinyElm(e){const t=e=>e.map(e=>e instanceof ft?e:new ft(e));return Array.isArray(e)?t(e):t([e])}static fromTinyElm(e){const t=e=>{const t=[];return e.map(e=>(e instanceof ft?e._getElements("fromTinyElm"):[e]).map(e=>t.push(e))),t};return Array.isArray(e)?t(e):t([e])}static winnow(e,t,r,n=!1){if("boolean"!=typeof n)throw new TypeError('The "not" must be a boolean.');if("function"==typeof t)return ft._preElems(e,r).filter((e,r)=>!!t.call(e,r,e)!==n);if(t instanceof Element)return ft._preElems(e,r).filter(e=>e===t!==n);if(Array.isArray(t)||"string"!=typeof t&&null!=t.length)return ft._preElems(e,r).filter(e=>t.includes(e)!==n);let i=t;return n&&(i=`:not(${i})`),ft._preElems(e,r).filter(e=>1===e.nodeType&&e.matches(i))}static filter(e,t,r=!1){return r&&(t=`:not(${t})`),ft._preElems(e,"filter").filter(e=>1===e.nodeType&&e.matches(t))}static filterOnly(e,t){return ft.winnow(e,t,"filterOnly",!1)}static not(e,t){return ft.winnow(e,t,"not",!0)}not(e){return ft.not(this,e)}static find(e,t){const r=[];for(const n of ft._preElems(e,"find"))r.push(...n.querySelectorAll(t));return[...new Set(r)]}find(e){return ft.find(this,e)}static is(e,t){return ft.winnow(e,t,"is",!1).length>0}is(e){return ft.is(this,e)}static has(e,t){const r="string"==typeof t?[...document.querySelectorAll(t)]:ft._preElems(t,"has");return ft._preElems(e,"has").filter(e=>r.some(t=>e&&e.contains(t)))}has(e){return ft.has(this,e)}static closest(e,t,r){const n=[];for(const i of ft._preElems(e,"closest")){let e=i;for(;e&&e!==r;){if(1===e.nodeType&&("string"==typeof t?e.matches(t):e===t)){n.push(e);break}e=e.parentElement}}return[...new Set(n)]}closest(e,t){return ft.closest(this,e,t)}static isSameDom(e,t){return ft._preNodeElem(e,"isSameDom")===ft._preNodeElem(t,"isSameDom")}isSameDom(e){return ft.isSameDom(this,e)}#ne={};get _data(){return{...this.#ne}}set _data(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("value must be a non-null object.");this.#ne=e}static _dataSelector={public:(e,t)=>{const r=ft._preElem(t,e);let n=ct.get(r);return n||(n={},ct.set(r,n)),n},private:(e,t)=>{if(!(t instanceof ft))throw new Error(`Element must be a TinyHtml instance to execute ${e}().`);return t.#ne}};static data(e,t,r=!1){const n=ft._dataSelector[r?"private":"public"]("data",e);if(null==t)return{...n};if("string"!=typeof t)throw new TypeError("The key must be a string.");return n.hasOwnProperty(t)?n[t]:void 0}data(e,t){return ft.data(this,e,t)}static setData(e,t,r,n=!1){const i=ft._dataSelector[n?"private":"public"]("setData",e);if("string"!=typeof t)throw new TypeError("The key must be a string.");return void 0!==r?i[t]=r:ft.removeData(e,t),e}setData(e,t,r=!1){return ft.setData(this,e,t,r)}static hasData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");const n=ft._dataSelector[r?"private":"public"]("hasData",e);return Object.prototype.hasOwnProperty.call(n,t)}hasData(e,t=!1){return ft.hasData(this,e,t)}static removeData(e,t,r=!1){if("string"!=typeof t)throw new TypeError("The key must be a string.");return delete ft._dataSelector[r?"private":"public"]("removeData",e)[t]}removeData(e,t=!1){return ft.removeData(this,e,t)}static _getSibling(e,t,r){let n=ft._preNodeElemWithNull(e,r);for(;n&&(n=n[t])&&1!==n.nodeType;);return n instanceof Node?n:null}static _getSiblings(e,t){let r=e;const n=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==t&&n.push(r);return n}static domDir(e,t,r,n="domDir"){if("string"!=typeof t)throw new TypeError('The "direction" must be a string.');let i=ft._preNodeElemWithNull(e,n);const o=[];for(;i&&(i=i[t]);)if(1===i.nodeType){if(r&&("string"==typeof r?i.matches(r):i===r))break;o.push(i)}return o}static parent(e){let t=ft._preNodeElemWithNull(e,"parent");const r=t?t.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return ft.parent(this)}static parents(e,t){return ft.domDir(e,"parentNode",t,"parents")}parents(e){return ft.parents(this,e)}static next(e){return ft._getSibling(e,"nextSibling","next")}next(){return ft.next(this)}static prev(e){return ft._getSibling(e,"previousSibling","prev")}prev(){return ft.prev(this)}static nextAll(e){return ft.domDir(e,"nextSibling",void 0,"nextAll")}nextAll(){return ft.nextAll(this)}static prevAll(e){return ft.domDir(e,"previousSibling",void 0,"prevAll")}prevAll(){return ft.prevAll(this)}static nextUntil(e,t){return ft.domDir(e,"nextSibling",t,"nextUtil")}nextUntil(e){return ft.nextUntil(this,e)}static prevUntil(e,t){return ft.domDir(e,"previousSibling",t,"prevUtil")}prevUntil(e){return ft.prevUntil(this,e)}static siblings(e){const t=ft._preNodeElemWithNull(e,"siblings");return ft._getSiblings(t&&t.parentNode?t.parentNode.firstChild:null,t)}siblings(){return ft.siblings(this)}static children(e){const t=ft._preNodeElemWithNull(e,"children");return ft._getSiblings(t?t.firstChild:null)}children(){return ft.children(this)}static contents(e){const t=ft._preNodeElemWithNull(e,"contents");return t instanceof HTMLIFrameElement&&null!=t.contentDocument&&Object.getPrototypeOf(t.contentDocument)?[t.contentDocument]:t instanceof HTMLTemplateElement?Array.from((t.content||t).childNodes):t?Array.from(t.childNodes):[]}contents(){return ft.contents(this)}static clone(e,t=!0){if("boolean"!=typeof t)throw new TypeError('The "deep" must be a boolean.');return ft._preNodeElems(e,"clone").map(e=>e.cloneNode(t))}clone(e){return ft.clone(this,e)[0]}static _appendChecker(e,...t){const r=[];for(const n of t)if(null!=n&&!1!==n)if("string"!=typeof n&&"number"!=typeof n)if(n instanceof Node||n instanceof ft)r.push(...ft._preNodeElems(n,e));else if(Array.isArray(n))r.push(...ft._appendChecker(e,...n));else for(const t in n){const i=n[t];r.push(...ft._appendChecker(e,i))}else r.push(n);return r}static append(e,...t){return ft._preElem(e,"append").append(...ft._appendChecker("append",...t)),e}append(...e){return ft.append(this,...e)}static prepend(e,...t){return ft._preElem(e,"prepend").prepend(...ft._appendChecker("prepend",...t)),e}prepend(...e){return ft.prepend(this,...e)}static before(e,...t){return ft._preElem(e,"before").before(...ft._appendChecker("before",...t)),e}before(...e){return ft.before(this,...e)}static after(e,...t){return ft._preElem(e,"after").after(...ft._appendChecker("after",...t)),e}after(...e){return ft.after(this,...e)}static replaceWith(e,...t){return ft._preElem(e,"replaceWith").replaceWith(...ft._appendChecker("replaceWith",...t)),e}replaceWith(...e){return ft.replaceWith(this,...e)}static appendTo(e,t){const r=ft._preNodeElems(e,"appendTo"),n=ft._preNodeElems(t,"appendTo");return n.forEach((e,t)=>{r.forEach(r=>e.appendChild(t===n.length-1?r:r.cloneNode(!0)))}),e}appendTo(e){return ft.appendTo(this,e)}static prependTo(e,t){const r=ft._preElems(e,"prependTo"),n=ft._preElems(t,"prependTo");return n.forEach((e,t)=>{r.slice().reverse().forEach(r=>e.prepend(t===n.length-1?r:r.cloneNode(!0)))}),e}prependTo(e){return ft.prependTo(this,e)}static insertBefore(e,t,r=null){const n=ft._preNodeElem(e,"insertBefore"),i=ft._preNodeElem(t,"insertBefore"),o=ft._preNodeElemWithNull(r,"insertBefore");if(!i.parentNode)throw new Error("The target element has no parent node to insert before.");return i.parentNode.insertBefore(n,o||i),e}insertBefore(e,t){return ft.insertBefore(this,e,t)}static insertAfter(e,t,r=null){const n=ft._preNodeElem(e,"insertAfter"),i=ft._preNodeElem(t,"insertBefore"),o=ft._preNodeElemWithNull(r,"insertBefore");if(!i.parentNode)throw new Error("The target element has no parent node to insert after.");return i.parentNode.insertBefore(n,o||i.nextSibling),e}insertAfter(e,t){return ft.insertAfter(this,e,t)}static replaceAll(e,t){const r=ft._preNodeElems(e,"replaceAll"),n=ft._preNodeElems(t,"replaceAll");return n.forEach((e,t)=>{const i=e.parentNode;r.forEach(r=>{i&&i.replaceChild(t===n.length-1?r:r.cloneNode(!0),e)})}),e}replaceAll(e){return ft.replaceAll(this,e)}#G;get size(){return this.#G.length}static _elCheck(e){for(const t of e)if(!(t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw new Error("[TinyHtml] Invalid Target in constructor.")}add(e){return new ft([...this.#G,...ft._selector(e)])}static _selector(e){if(e instanceof ft)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const t=e=>Array.from(new Set(e)),r="string"!=typeof e?e:document.querySelectorAll(e);if(Array.isArray(r))return ft._elCheck(r),t(r);if(r instanceof NodeList||r instanceof HTMLCollection){const e=[...r];return ft._elCheck(e),t(e)}{const e=[r];return ft._elCheck(e),t(e)}}constructor(e){this.#G=ft._selector(e),this.#ie=ft.#oe}static isWindow(e){return null!=e&&e===e.window}static css(e){const t=ft._preElem(e,"css");return window.getComputedStyle(t)}css(){return ft.css(this)}static cssString(e,t){const r=ft._preElem(e,"cssString");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[t];return"string"==typeof n?n:"number"==typeof n?n.toString():null}cssString(e){return ft.cssString(this,e)}static cssList(e,t){const r=ft._preElem(e,"cssList");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),i={};for(const e of t)void 0!==e&&(i[e]=n.getPropertyValue(e));return i}cssList(e){return ft.cssList(this,e)}static cssFloat(e,t){const r=ft._preElem(e,"cssFloat");if("string"!=typeof t)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[t];return parseFloat(n)||0}cssFloat(e){return ft.cssFloat(this,e)}static cssFloats(e,t){const r=ft._preElem(e,"cssFloats");if(!Array.isArray(t))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),i={};for(const e of t)i[e]=parseFloat(n[e])||0;return i}cssFloats(e){return ft.cssFloats(this,e)}static#se={alignContent:"align-content",alignItems:"align-items",alignSelf:"align-self",animationDelay:"animation-delay",animationDirection:"animation-direction",animationDuration:"animation-duration",animationFillMode:"animation-fill-mode",animationIterationCount:"animation-iteration-count",animationName:"animation-name",animationPlayState:"animation-play-state",animationTimingFunction:"animation-timing-function",backfaceVisibility:"backface-visibility",backgroundAttachment:"background-attachment",backgroundBlendMode:"background-blend-mode",backgroundClip:"background-clip",backgroundColor:"background-color",backgroundImage:"background-image",backgroundOrigin:"background-origin",backgroundPosition:"background-position",backgroundRepeat:"background-repeat",backgroundSize:"background-size",borderBottom:"border-bottom",borderBottomColor:"border-bottom-color",borderBottomLeftRadius:"border-bottom-left-radius",borderBottomRightRadius:"border-bottom-right-radius",borderBottomStyle:"border-bottom-style",borderBottomWidth:"border-bottom-width",borderCollapse:"border-collapse",borderColor:"border-color",borderImage:"border-image",borderImageOutset:"border-image-outset",borderImageRepeat:"border-image-repeat",borderImageSlice:"border-image-slice",borderImageSource:"border-image-source",borderImageWidth:"border-image-width",borderLeft:"border-left",borderLeftColor:"border-left-color",borderLeftStyle:"border-left-style",borderLeftWidth:"border-left-width",borderRadius:"border-radius",borderRight:"border-right",borderRightColor:"border-right-color",borderRightStyle:"border-right-style",borderRightWidth:"border-right-width",borderSpacing:"border-spacing",borderStyle:"border-style",borderTop:"border-top",borderTopColor:"border-top-color",borderTopLeftRadius:"border-top-left-radius",borderTopRightRadius:"border-top-right-radius",borderTopStyle:"border-top-style",borderTopWidth:"border-top-width",borderWidth:"border-width",boxDecorationBreak:"box-decoration-break",boxShadow:"box-shadow",boxSizing:"box-sizing",breakAfter:"break-after",breakBefore:"break-before",breakInside:"break-inside",captionSide:"caption-side",caretColor:"caret-color",clipPath:"clip-path",columnCount:"column-count",columnFill:"column-fill",columnGap:"column-gap",columnRule:"column-rule",columnRuleColor:"column-rule-color",columnRuleStyle:"column-rule-style",columnRuleWidth:"column-rule-width",columnSpan:"column-span",columnWidth:"column-width",counterIncrement:"counter-increment",counterReset:"counter-reset",emptyCells:"empty-cells",flexBasis:"flex-basis",flexDirection:"flex-direction",flexFlow:"flex-flow",flexGrow:"flex-grow",flexShrink:"flex-shrink",flexWrap:"flex-wrap",fontFamily:"font-family",fontFeatureSettings:"font-feature-settings",fontKerning:"font-kerning",fontLanguageOverride:"font-language-override",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontSynthesis:"font-synthesis",fontVariant:"font-variant",fontVariantAlternates:"font-variant-alternates",fontVariantCaps:"font-variant-caps",fontVariantEastAsian:"font-variant-east-asian",fontVariantLigatures:"font-variant-ligatures",fontVariantNumeric:"font-variant-numeric",fontVariantPosition:"font-variant-position",fontWeight:"font-weight",gridArea:"grid-area",gridAutoColumns:"grid-auto-columns",gridAutoFlow:"grid-auto-flow",gridAutoRows:"grid-auto-rows",gridColumn:"grid-column",gridColumnEnd:"grid-column-end",gridColumnGap:"grid-column-gap",gridColumnStart:"grid-column-start",gridGap:"grid-gap",gridRow:"grid-row",gridRowEnd:"grid-row-end",gridRowGap:"grid-row-gap",gridRowStart:"grid-row-start",gridTemplate:"grid-template",gridTemplateAreas:"grid-template-areas",gridTemplateColumns:"grid-template-columns",gridTemplateRows:"grid-template-rows",imageRendering:"image-rendering",justifyContent:"justify-content",letterSpacing:"letter-spacing",lineBreak:"line-break",lineHeight:"line-height",listStyle:"list-style",listStyleImage:"list-style-image",listStylePosition:"list-style-position",listStyleType:"list-style-type",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",maskClip:"mask-clip",maskComposite:"mask-composite",maskImage:"mask-image",maskMode:"mask-mode",maskOrigin:"mask-origin",maskPosition:"mask-position",maskRepeat:"mask-repeat",maskSize:"mask-size",maskType:"mask-type",maxHeight:"max-height",maxWidth:"max-width",minHeight:"min-height",minWidth:"min-width",mixBlendMode:"mix-blend-mode",objectFit:"object-fit",objectPosition:"object-position",offsetAnchor:"offset-anchor",offsetDistance:"offset-distance",offsetPath:"offset-path",offsetRotate:"offset-rotate",outlineColor:"outline-color",outlineOffset:"outline-offset",outlineStyle:"outline-style",outlineWidth:"outline-width",overflowAnchor:"overflow-anchor",overflowWrap:"overflow-wrap",overflowX:"overflow-x",overflowY:"overflow-y",paddingBottom:"padding-bottom",paddingLeft:"padding-left",paddingRight:"padding-right",paddingTop:"padding-top",pageBreakAfter:"page-break-after",pageBreakBefore:"page-break-before",pageBreakInside:"page-break-inside",perspectiveOrigin:"perspective-origin",placeContent:"place-content",placeItems:"place-items",placeSelf:"place-self",pointerEvents:"pointer-events",rowGap:"row-gap",scrollBehavior:"scroll-behavior",scrollMargin:"scroll-margin",scrollMarginBlock:"scroll-margin-block",scrollMarginBlockEnd:"scroll-margin-block-end",scrollMarginBlockStart:"scroll-margin-block-start",scrollMarginBottom:"scroll-margin-bottom",scrollMarginInline:"scroll-margin-inline",scrollMarginInlineEnd:"scroll-margin-inline-end",scrollMarginInlineStart:"scroll-margin-inline-start",scrollMarginLeft:"scroll-margin-left",scrollMarginRight:"scroll-margin-right",scrollMarginTop:"scroll-margin-top",scrollPadding:"scroll-padding",scrollPaddingBlock:"scroll-padding-block",scrollPaddingBlockEnd:"scroll-padding-block-end",scrollPaddingBlockStart:"scroll-padding-block-start",scrollPaddingBottom:"scroll-padding-bottom",scrollPaddingInline:"scroll-padding-inline",scrollPaddingInlineEnd:"scroll-padding-inline-end",scrollPaddingInlineStart:"scroll-padding-inline-start",scrollPaddingLeft:"scroll-padding-left",scrollPaddingRight:"scroll-padding-right",scrollPaddingTop:"scroll-padding-top",scrollSnapAlign:"scroll-snap-align",scrollSnapStop:"scroll-snap-stop",scrollSnapType:"scroll-snap-type",shapeImageThreshold:"shape-image-threshold",shapeMargin:"shape-margin",shapeOutside:"shape-outside",tabSize:"tab-size",tableLayout:"table-layout",textAlign:"text-align",textAlignLast:"text-align-last",textCombineUpright:"text-combine-upright",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",textDecorationLine:"text-decoration-line",textDecorationStyle:"text-decoration-style",textIndent:"text-indent",textJustify:"text-justify",textOrientation:"text-orientation",textOverflow:"text-overflow",textShadow:"text-shadow",textTransform:"text-transform",transformBox:"transform-box",transformOrigin:"transform-origin",transformStyle:"transform-style",transitionDelay:"transition-delay",transitionDuration:"transition-duration",transitionProperty:"transition-property",transitionTimingFunction:"transition-timing-function",unicodeBidi:"unicode-bidi",userSelect:"user-select",verticalAlign:"vertical-align",whiteSpace:"white-space",willChange:"will-change",wordBreak:"word-break",wordSpacing:"word-spacing",wordWrap:"word-wrap",writingMode:"writing-mode",zIndex:"z-index",WebkitTransform:"-webkit-transform",WebkitTransition:"-webkit-transition",WebkitBoxShadow:"-webkit-box-shadow",MozBoxShadow:"-moz-box-shadow",MozTransform:"-moz-transform",MozTransition:"-moz-transition",msTransform:"-ms-transform",msTransition:"-ms-transition"};static cssPropAliases=new Proxy(ft.#se,{set:(e,t,r)=>(e[t]=r,ft.cssPropRevAliases[r]=t,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(ft.#se).map(([e,t])=>[t,e]));static toStyleKc(e){return"string"==typeof ft.cssPropAliases[e]?ft.cssPropAliases[e]:e}static toStyleCc(e){return"string"==typeof ft.cssPropRevAliases[e]?ft.cssPropRevAliases[e]:e}static setStyle(e,t,r=null){return ft._preHtmlElems(e,"setStyle").forEach(e=>{if("object"==typeof t)for(const[r,n]of Object.entries(t))e.style.setProperty(ft.toStyleKc(r),"string"==typeof n?n:"number"==typeof n?`${n}px`:String(n));else e.style.setProperty(ft.toStyleKc(t),r)}),e}setStyle(e,t){return ft.setStyle(this,e,t)}static getStyle(e,t){return ft._preHtmlElem(e,"getStyle").style.getPropertyValue(ft.toStyleKc(t))}getStyle(e){return ft.getStyle(this,e)}static style(e,{camelCase:t=!1,rawAttr:r=!1}={}){if("boolean"!=typeof t)throw new TypeError('"camelCase" must be a boolean. Received: '+typeof t);if("boolean"!=typeof r)throw new TypeError('"rawAttr" must be a boolean. Received: '+typeof r);const n=ft._preHtmlElem(e,"style"),i={};if(r){const e=(n.getAttribute("style")||"").split(";");for(const r of e){const[e,n]=r.split(":");if(!e||!n)continue;const o=e.trim(),s=n.trim();i[t?ft.toStyleCc(o):o]=s}}else{const e=n.style;for(let r=0;r<e.length;r++){const n=e[r],o=e.getPropertyValue(n);i[t?ft.toStyleCc(n):n]=o}}return i}style(e){return ft.style(this,e)}static removeStyle(e,t){return ft._preHtmlElems(e,"removeStyle").forEach(e=>{if(Array.isArray(t))for(const r of t)e.style.removeProperty(ft.toStyleKc(r));else e.style.removeProperty(ft.toStyleKc(t))}),e}removeStyle(e){return ft.removeStyle(this,e)}static toggleStyle(e,t,r,n){return ft._preHtmlElems(e,"toggleStyle").forEach(e=>{const i=ft.getStyle(e,t).trim()===ft.toStyleKc(r)?n:r;ft.setStyle(e,t,i)}),e}toggleStyle(e,t,r){return ft.toggleStyle(this,e,t,r)}static clearStyle(e){return ft._preElems(e,"clearStyle").forEach(e=>e.removeAttribute("style")),e}clearStyle(){return ft.clearStyle(this)}static focus(e){return ft._preHtmlElem(e,"focus").focus(),e}focus(){return ft.focus(this)}static blur(e){return ft._preHtmlElem(e,"blur").blur(),e}blur(){return ft.blur(this)}static select(e){const t=ft._preHtmlElem(e,"select");if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement))throw new Error("Element must be an <input> or <textarea> to use select().");return t.select(),e}select(){return ft.select(this)}static boolCheck(e){return void 0!==e&&("true"===e||"1"===e||!0===e||"on"===e||"number"==typeof e&&e>0)}static setWinScrollTop(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");ft.setScrollTop(window,e)}static setWinScrollLeft(e){if("number"!=typeof e)throw new TypeError("The value must be a number.");ft.setScrollLeft(window,e)}static winScrollTop(){return window.scrollY||document.documentElement.scrollTop}static winScrollLeft(){return window.scrollX||document.documentElement.scrollLeft}static winInnerHeight(){return window.innerHeight||document.documentElement.clientHeight}static winInnerWidth(){return window.innerWidth||document.documentElement.clientWidth}static isPageTop(){return 0===window.scrollY}static isPageBottom(){return window.innerHeight+window.scrollY>=document.body.offsetHeight}static getDimension(e,t,r="content"){const n=ft._preElemAndWinAndDoc(e,"getDimension");if("string"!=typeof t)throw new TypeError("The type must be a string.");if("string"!=typeof r)throw new TypeError("The extra must be a string.");const i="width"===t?"Width":"Height";if(ft.isWindow(n))return"margin"===r?n["inner"+i]:n.document.documentElement["client"+i];const o=n;if(9===o.nodeType){const e=o.documentElement;return Math.max(o.body["scroll"+i],e["scroll"+i],o.body["offset"+i],e["offset"+i],e["client"+i])}let s=o.getBoundingClientRect()[t];function a(e){return"width"===t?ft.cssFloat(o,e+"Left")+ft.cssFloat(o,e+"Right"):ft.cssFloat(o,e+"Top")+ft.cssFloat(o,e+"Bottom")}switch(r){case"content":s-=a("padding"),s-=a("border");break;case"padding":s-=a("border");break;case"border":break;case"margin":s+=a("margin")}return s}getDimension(e,t){return ft.getDimension(this,e,t)}static setHeight(e,t){const r=ft._preHtmlElem(e,"setHeight");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.height="number"==typeof t?`${t}px`:t,e}setHeight(e){return ft.setHeight(this,e)}static setWidth(e,t){const r=ft._preHtmlElem(e,"setWidth");if("number"!=typeof t&&"string"!=typeof t)throw new TypeError("The value must be a string or number.");return r.style.width="number"==typeof t?`${t}px`:t,e}setWidth(e){return ft.setWidth(this,e)}static height(e){const t=ft._preElemAndWinAndDoc(e,"height");return ft.getDimension(t,"height","content")}height(){return ft.height(this)}static width(e){const t=ft._preElemAndWinAndDoc(e,"width");return ft.getDimension(t,"width","content")}width(){return ft.width(this)}static innerHeight(e){const t=ft._preElemAndWinAndDoc(e,"innerHeight");return ft.getDimension(t,"height","padding")}innerHeight(){return ft.innerHeight(this)}static innerWidth(e){const t=ft._preElemAndWinAndDoc(e,"innerWidth");return ft.getDimension(t,"width","padding")}innerWidth(){return ft.innerWidth(this)}static outerHeight(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=ft._preElemAndWinAndDoc(e,"outerHeight");return ft.getDimension(r,"height",t?"margin":"border")}outerHeight(e){return ft.outerHeight(this,e)}static outerWidth(e,t=!1){if("boolean"!=typeof t)throw new TypeError('The "includeMargin" must be a boolean.');const r=ft._preElemAndWinAndDoc(e,"outerWidth");return ft.getDimension(r,"width",t?"margin":"border")}outerWidth(e){return ft.outerWidth(this,e)}#ie="";get mainDisplay(){return this.#ie}set mainDisplay(e){if("string"!=typeof e)throw new TypeError("mainDisplay must be a string.");this.#ie=e}static#oe="block";static get defaultDisplay(){return ft.#oe}static set defaultDisplay(e){if("string"!=typeof e)throw new TypeError("defaultDisplay must be a string.");ft.#oe=e}static getAnimateData(e,t){let r=ht.get(e);return r||(r={},ht.set(e,r)),r[t]}static setAnimateData(e,t,r){if(!(e instanceof HTMLElement))throw new TypeError("setAnimateData: el must be an HTMLElement.");if("string"!=typeof t)throw new TypeError("setAnimateData: where must be a string.");if("string"!=typeof r&&"number"!=typeof r)throw new TypeError("setAnimateData: value must be a string or number.");let n=ht.get(e);n||(n={},ht.set(e,n)),n[t]=r}static#ae=!0;static get cancelOldStyleFx(){return ft.#ae}static set cancelOldStyleFx(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean value.");ft.#ae=e}static#le={slow:{duration:600,easing:"ease"},fast:{duration:200,easing:"ease-out"},_default:{duration:400,easing:"linear"}};static get styleFxSpeeds(){const e={};for(const t in ft.#le){const r=ft.#le[t];e[t]="object"==typeof r?{...r}:r}return e}static set styleFxSpeeds(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleFxSpeeds must be an object.");for(const[t,r]of Object.entries(e))if("number"!=typeof r&&"object"!=typeof r)throw new TypeError(`styleFxSpeeds["${t}"] must be a number or KeyframeAnimationOptions.`);ft.#le={};for(const[t,r]of Object.entries(e))ft.setStyleFxSpeed(t,r)}static getStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=ft.#le[e];return"object"==typeof t?{...t}:t}static setStyleFxSpeed(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("number"!=typeof t&&"object"!=typeof t)throw new TypeError("styleFxSpeed must be a number or KeyframeAnimationOptions");ft.#le[e]="object"==typeof t?{...t}:t}static deleteStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete ft.#le[e]}static hasStyleFxSpeed(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(ft.#le,e)}static#ue=["Top","Right","Bottom","Left"];static#ce={slideDown:ft.genStyleFx("show"),slideUp:ft.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(ft.#ce))}static set styleEffects(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffects must be an object");for(const t in e)for(const[r,n]of Object.entries(e[t]))if(!("string"==typeof n||Array.isArray(n)&&n.every(e=>"string"==typeof e||"number"==typeof e)))throw new TypeError(`Invalid styleEffect["${r}"]`);ft.#ce={};for(const t in e)ft.setStyleEffect(t,e[t])}static getStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');const t=ft.#ce[e];return t?JSON.parse(JSON.stringify(t)):void 0}static setStyleEffect(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleEffect must be an object");const r={};for(const[e,n]of Object.entries(t))if("string"==typeof n)r[e]=n;else{if(!Array.isArray(n)||!n.every(e=>"string"==typeof e||"number"==typeof e))throw new TypeError(`Invalid styleEffect["${e}"]`);r[e]=[...n]}ft.#ce[e]=r}static deleteStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete ft.#ce[e]}static hasStyleEffect(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(ft.#ce,e)}static#he={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...ft.#he}}static set styleEffectInverse(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectInverse must be an object.");for(const[t,r]of Object.entries(e))if("string"!=typeof r)throw new TypeError(`styleEffectInverse["${t}"] must be a string.`);ft.#he={};for(const[t,r]of Object.entries(e))ft.setStyleEffectInverse(t,r)}static getStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return ft.#he[e]||null}static setStyleEffectInverse(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("string"!=typeof t)throw new TypeError(`styleEffectInverse["${e}"] must be a string.`);ft.#he[e]=t}static deleteStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete ft.#he[e]}static hasStyleEffectInverse(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(ft.#he,e)}static#de={slideDown:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),slideUp:e=>e.height[0]===e.height[1]&&(!e.width||e.width[0]===e.width[1]),fadeIn:e=>Number(e.opacity[0])===Number(e.opacity[1]),fadeOut:e=>Number(e.opacity[0])===Number(e.opacity[1])};static get styleEffectsRd(){return{...ft.#de}}static set styleEffectsRd(e){if("object"!=typeof e||null===e)throw new TypeError("styleEffectsRd must be an object.");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsRd["${t}"] must be a function.`);ft.#de={};for(const[t,r]of Object.entries(e))ft.setStyleEffectRd(t,r)}static getStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return ft.#de[e]||null}static setStyleEffectRd(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsRd["${e}"] must be a function.`);ft.#de[e]=t}static deleteStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete ft.#de[e]}static hasStyleEffectRd(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(ft.#de,e)}static#pe={show:(e,t,r,n)=>{if("height"===r||"width"===r){const i=ft.getAnimateData(e,`orig${r}`)||e.scrollHeight+"px";ft.setAnimateData(e,`orig${r}`,i);const o=n[r];t[r]=[o,i]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=ft.getAnimateData(e,r)||n[r];ft.setAnimateData(e,r,i),t[r]=["0px",i]}else if("opacity"===r){const e=n.opacity;t[r]=[e,1]}else{const i=ft.getAnimateData(e,r)||n[r];ft.setAnimateData(e,r,i),t[r]=[i,n[r]||1]}},hide:(e,t,r,n)=>{if("height"===r||"width"===r){const i=ft.getAnimateData(e,`orig${r}`)||n[r];ft.setAnimateData(e,`orig${r}`,i);const o=n[r];t[r]=[o,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const i=ft.getAnimateData(e,r)||n[r];ft.setAnimateData(e,r,i),t[r]=[n[r],"0px"]}else if("opacity"===r){const e=n.opacity;t[r]=[e,0]}else{const i=ft.getAnimateData(e,r)||n[r];ft.setAnimateData(e,r,i),t[r]=[i,0]}}};static get styleEffectsProps(){return{...ft.#pe}}static set styleEffectsProps(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffectsProps must be an object");for(const[t,r]of Object.entries(e))if("function"!=typeof r)throw new TypeError(`styleEffectsProps["${t}"] must be a function`);ft.#pe={};for(const[t,r]of Object.entries(e))ft.setStyleEffectProp(t,r)}static getStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return ft.#pe[e]||null}static setStyleEffectProp(e,t){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof t)throw new TypeError(`styleEffectsProps["${e}"] must be a function`);ft.#pe[e]=t}static deleteStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return delete ft.#pe[e]}static hasStyleEffectProp(e){if("string"!=typeof e)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(ft.#pe,e)}static genStyleFx(e,t=!1){if("string"!=typeof e)throw new TypeError("genStyleFx: type must be a string.");if("boolean"!=typeof t)throw new TypeError("genStyleFx: includeWidth must be a boolean.");let r,n=0;const i={height:e},o=t?1:0;for(;n<4;n+=2-o)r=ft.#ue[n],i["margin"+r]=e,i["padding"+r]=e;return t&&(i.opacity=e,i.width=e),i}static applyStyleFx(e,t,r,n){if("string"!=typeof t)throw new TypeError("applyStyleFx: id must be a string.");if("object"!=typeof r||null===r)throw new TypeError("applyStyleFx: props must be a non-null object.");if(void 0!==n&&"number"!=typeof n&&"string"!=typeof n&&("object"!=typeof n||null===n))throw new TypeError("applyStyleFx: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const i=new Map;return ft._preHtmlElems(e,"applyStyleFx").forEach(o=>{const s={};for(const[e,t]of Object.entries(r))if("string"==typeof t&&this.#pe[t]){const r=getComputedStyle(o);this.#pe[t](o,s,e,r)}else{if("object"!=typeof t)throw new TypeError(`applyStyleFx: invalid action for prop "${e}". Must be string or array.`);s[e]=t}if("function"==typeof ft.#de[t]&&ft.#de[t](s))return void i.set(o,null);const a=[],l=s[Object.keys(s)[0]].length;for(let e=0;e<l;e++){const t={};for(const r in s)t[r]=s[r][e];a.push(t)}i.set(o,ft.animate(e,a,n,t)[0])}),i}applyStyleFx(e,t,r){return ft.applyStyleFx(this,e,t,r)}static getCurrentAnimationId(e){if(!(e instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return dt.get(e)?.id??void 0}static animate(e,t,r=ft.#le._default,n=null,i=ft.#ae){const o="string"==typeof r?ft.#le[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof o&&void 0===o.fill&&(o.fill="forwards");const s=[];return ft._preHtmlElems(e,"animate").forEach(e=>{if(i){const t=dt.get(e);t&&t.animation.cancel()}const r=e.animate(t,o);s.push(r),dt.set(e,{animation:r,id:n??""}),r.addEventListener("finish",()=>{dt.get(e)?.animation===r&&dt.delete(e)})}),s}animate(e,t,r,n){return ft.animate(this,e,t,r,n)}static stop(e){const t=[];return ft._preHtmlElems(e,"stop").forEach(e=>{const r=dt.get(e);r?(r.animation.cancel(),dt.delete(e),t.push(!0)):t.push(!1)}),t}stop(){return ft.stop(this)}static slideDown(e,t){return ft.applyStyleFx(e,"slideDown",this.#ce.slideDown,t??{duration:500,easing:"ease-out"})}slideDown(e){return ft.slideDown(this,e)}static slideUp(e,t){return ft.applyStyleFx(e,"slideUp",this.#ce.slideUp,t??{duration:500,easing:"ease-out"})}slideUp(e){return ft.slideUp(this,e)}static slideToggle(e,t){const r=ft._preHtmlElem(e,"slideToggle"),n=getComputedStyle(r),i=ft.getCurrentAnimationId(r),o="none"===n.display||0===r.offsetHeight;return("string"==typeof i?"slideUp"===i:o)?ft.slideDown(e,t):ft.slideUp(e,t)}slideToggle(e){return ft.slideToggle(this,e)}static fadeIn(e,t){return ft.applyStyleFx(e,"fadeIn",this.#ce.fadeIn,t)}fadeIn(e){return ft.fadeIn(this,e)}static fadeOut(e,t){return ft.applyStyleFx(e,"fadeOut",this.#ce.fadeOut,t)}fadeOut(e){return ft.fadeOut(this,e)}static fadeToggle(e,t){const r=ft._preHtmlElem(e,"fadeToggle"),n=getComputedStyle(r),i=ft.getCurrentAnimationId(r),o="0"===n.opacity||null===r.offsetParent;return("string"==typeof i?"fadeOut"===i:o)?ft.fadeIn(e,t):ft.fadeOut(e,t)}fadeToggle(e){return ft.fadeToggle(this,e)}static fadeTo(e,t,r,n=ft.#oe){if("number"!=typeof t||isNaN(t)||t<0||t>1)throw new TypeError("fadeTo: opacity must be a number between 0 and 1.");if(void 0!==r&&"number"!=typeof r&&"string"!=typeof r&&("object"!=typeof r||null===r))throw new TypeError("fadeTo: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const i=new Map;return ft._preHtmlElems(e,"fadeTo").forEach(o=>{const s=getComputedStyle(o);if(!(e instanceof Element&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length))){const e=ft.getAnimateData(o,"origdisplay");o.style.display="string"==typeof e?e:n}const a=[s.opacity,t].map(e=>({opacity:e}));i.set(o,ft.animate(o,a,r,"fadeTo")[0])}),i}fadeTo(e,t,r=this.#ie){return ft.fadeTo(this,e,t,r)}static offset(e){const t=ft._preElem(e,"offset").getBoundingClientRect(),r=window.scrollY||document.documentElement.scrollTop,n=window.scrollX||document.documentElement.scrollLeft;return{top:t.top+r,left:t.left+n}}offset(){return ft.offset(this)}static position(e){const t=ft._preHtmlElem(e,"position");let r,n,i={top:0,left:0};if("fixed"===window.getComputedStyle(t).position)n=t.getBoundingClientRect();else{n=ft.offset(t),r=t.offsetParent||document.documentElement;const{position:e}=window.getComputedStyle(r);for(;r instanceof HTMLElement&&(r===document.body||r===document.documentElement)&&"static"===e;)r=r.parentNode;if(r instanceof HTMLElement&&r!==t&&1===r.nodeType){const{borderTopWidth:e,borderLeftWidth:t}=ft.cssFloats(r,["borderTopWidth","borderLeftWidth"]);i=ft.offset(r),i.top+=e,i.left+=t}}return{top:n.top-i.top-ft.cssFloat(t,"marginTop"),left:n.left-i.left-ft.cssFloat(t,"marginLeft")}}position(){return ft.position(this)}static offsetParent(e){let t=ft._preHtmlElem(e,"offsetParent").offsetParent;for(;t instanceof HTMLElement&&"static"===window.getComputedStyle(t).position;)t=t.offsetParent;return t instanceof HTMLElement?t:document.documentElement}offsetParent(){return ft.offsetParent(this)}static scrollTop(e){const t=ft._preElemAndWindow(e,"scrollTop");return ft.isWindow(t)?t.pageYOffset:9===t.nodeType?t.defaultView.pageYOffset:t.scrollTop}scrollTop(){return ft.scrollTop(this)}static scrollLeft(e){const t=ft._preElemAndWindow(e,"scrollLeft");return ft.isWindow(t)?t.pageXOffset:9===t.nodeType?t.defaultView.pageXOffset:t.scrollLeft}scrollLeft(){return ft.scrollLeft(this)}static easings={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>e*(2-e),easeInOutQuad:e=>e<.5?2*e*e:(4-2*e)*e-1,easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1};static scrollToXY(e,{targetX:t,targetY:r,duration:n,easing:i,onAnimation:o}={}){if(void 0!==t&&"number"!=typeof t)throw new TypeError("`targetX` must be a number if provided.");if(void 0!==r&&"number"!=typeof r)throw new TypeError("`targetY` must be a number if provided.");if(void 0!==n&&"number"!=typeof n)throw new TypeError("`duration` must be a number if provided.");if(void 0!==i&&"string"!=typeof i)throw new TypeError("`easing` must be a string if provided.");if(void 0!==i&&"function"!=typeof ft.easings[i])throw new TypeError(`Unknown easing function: "${i}".`);if(void 0!==o&&"function"!=typeof o)throw new TypeError("`onAnimation` must be a function if provided.");const s=(e,t,r,n)=>{if(e instanceof Window)window.scrollTo(t,r);else if(9===e.nodeType)e.defaultView.scrollTo(t,r);else{const n=e instanceof Window?window.scrollX:e.scrollLeft,i=e instanceof Window?window.scrollY:e.scrollTop;n!==t&&(e.scrollLeft=t),i!==r&&(e.scrollTop=r)}"function"==typeof o&&o({x:t,y:r,isComplete:n>=1,time:n})};return ft._preElemsAndWindow(e,"scrollToXY").forEach(e=>{const o=e instanceof Window?window.scrollX:e.scrollLeft,a=e instanceof Window?window.scrollY:e.scrollTop,l=t??o,u=r??a,c=l-o,h=u-a,d="string"==typeof i&&ft.easings[i]||null;if("number"!=typeof n||"function"!=typeof d)return s(e,l,u,1);const p=performance.now(),f=n??0;requestAnimationFrame(function t(r){if("function"!=typeof d)return;const n=Math.min(1,(r-p)/f),i=d(n);s(e,o+c*i,a+h*i,n),n<1&&requestAnimationFrame(t)})}),e}scrollToXY({targetX:e,targetY:t,duration:r,easing:n,onAnimation:i}={}){return ft.scrollToXY(this,{targetX:e,targetY:t,duration:r,easing:n,onAnimation:i})}static setScrollTop(e,t){if("number"!=typeof t)throw new TypeError("ScrollTop value must be a number.");return ft.scrollToXY(e,{targetY:t})}setScrollTop(e){return ft.setScrollTop(this,e)}static setScrollLeft(e,t){if("number"!=typeof t)throw new TypeError("ScrollLeft value must be a number.");return ft.scrollToXY(e,{targetX:t})}setScrollLeft(e){return ft.setScrollLeft(this,e)}static borderWidth(e){const t=ft._preElem(e,"borderWidth"),{borderLeftWidth:r,borderRightWidth:n,borderTopWidth:i,borderBottomWidth:o}=ft.cssFloats(t,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}borderWidth(){return ft.borderWidth(this)}static border(e){const t=ft._preElem(e,"border"),{borderLeft:r,borderRight:n,borderTop:i,borderBottom:o}=ft.cssFloats(t,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}border(){return ft.border(this)}static margin(e){const t=ft._preElem(e,"margin"),{marginLeft:r,marginRight:n,marginTop:i,marginBottom:o}=ft.cssFloats(t,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}margin(){return ft.margin(this)}static padding(e){const t=ft._preElem(e,"padding"),{paddingLeft:r,paddingRight:n,paddingTop:i,paddingBottom:o}=ft.cssFloats(t,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+n,y:i+o,left:r,right:n,top:i,bottom:o}}padding(){return ft.padding(this)}static#fe=!1;static get classCanWhitespace(){return this.#fe}static set classCanWhitespace(e){if("boolean"!=typeof e)throw new TypeError("classCanWhitespace must be a boolean");this.#fe=e}static addClass(e,...t){const r=[];for(const e of t)if(ft.#fe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return ft._preElems(e,"addClass").forEach(e=>e.classList.add(...r)),e}addClass(...e){return ft.addClass(this,...e)}static removeClass(e,...t){const r=[];for(const e of t)if(ft.#fe){const t=e.split(" ");for(const e of t)r.push(e)}else r.push(e);return ft._preElems(e,"removeClass").forEach(e=>e.classList.remove(...r)),e}removeClass(...e){return ft.removeClass(this,...e)}static replaceClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if("string"!=typeof r)throw new TypeError('The "newToken" parameter must be a string.');const n=[];return ft._preElems(e,"replaceClass").forEach(e=>n.push(e.classList.replace(t,r))),n}replaceClass(e,t){return ft.replaceClass(this,e,t)[0]}static classItem(e,t){const r=ft._preElem(e,"classItem");if("number"!=typeof t)throw new TypeError('The "index" parameter must be a number.');return r.classList.item(t)}classItem(e){return ft.classItem(this,e)}static toggleClass(e,t,r){if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" parameter must be a boolean.');const n=[];return ft._preElems(e,"toggleClass").forEach(e=>n.push(e.classList.toggle(t,r))),n}toggleClass(e,t){return ft.toggleClass(this,e,t)[0]}static hasClass(e,t){const r=ft._preElem(e,"hasClass");if("string"!=typeof t)throw new TypeError('The "token" parameter must be a string.');return r.classList.contains(t)}hasClass(e){return ft.hasClass(this,e)}static classLength(e){return ft._preElem(e,"classLength").classList.length}classLength(){return ft.classLength(this)}static classList(e){return ft._preElem(e,"classList").classList.values().toArray()}classList(){return ft.classList(this)}static tagName(e){return ft._preElem(e,"tagName").tagName}tagName(){return ft.tagName(this)}static id(e){return ft._preElem(e,"id").id}id(){return ft.id(this)}static toBigInt(e){const t=ft._preElem(e,"toBigInt"),r=t.textContent?.trim();let n=null;try{n=BigInt(r??"")}catch{n=null}return n}toBigInt(){return ft.toBigInt(this)}static setBigInt(e,t){if("bigint"!=typeof t)throw new Error("Value is not a valid BigInt.");const r=t.toString();return ft._preElems(e,"setBigInt").forEach(e=>e.textContent=r),e}setBigInt(e){return ft.setBigInt(this,e)}static toDate(e){const t=ft._preElem(e,"toDate"),r=t.textContent?.trim();if(!r)return null;const n=new Date(r);return Number.isNaN(n.getTime())?null:n}toDate(){return ft.toDate(this)}static setDate(e,t){if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new Error("Value is not a valid Date.");const r=t.toISOString();return ft._preElems(e,"setDate").forEach(e=>e.textContent=r),e}setDate(e){return ft.setDate(this,e)}static toJson(e){const t=ft._preElem(e,"toJson"),r=t.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return ft.toJson(this)}static setJson(e,t,r,n){const i=JSON.stringify(t,r,n);return ft._preElems(e,"setJson").forEach(e=>e.textContent=i),e}setJson(e,t,r){return ft.setJson(this,e,t,r)}static toNumber(e){const t=ft._preElem(e,"toNumber");return"string"==typeof t.textContent?parseFloat(t.textContent.trim()):null}toNumber(){return ft.toNumber(this)}static setNumber(e,t){if("number"!=typeof t)throw new Error("Value is not a valid number.");const r=t.toString();return ft._preElems(e,"setNumber").forEach(e=>e.textContent=r),e}setNumber(e){return ft.setNumber(this,e)}static toBoolean(e){const t=ft._preElem(e,"toBoolean"),r=t.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return ft.toBoolean(this)}static setBoolean(e,t){if("boolean"!=typeof t)throw new Error("Value is not a valid boolean.");const r=t.toString();return ft._preElems(e,"setBoolean").forEach(e=>e.textContent=r),e}setBoolean(e){return ft.setBoolean(this,e)}static toString(e){const t=ft._preElem(e,"toString");return"string"==typeof t.textContent?t.textContent:null}toString(){return ft.toString(this)}static setString(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return ft._preElems(e,"setString").forEach(e=>e.textContent=t),e}setString(e){return ft.setString(this,e)}static text(e){return ft._preElem(e,"text").textContent}text(){return ft.text(this)}static setText(e,t){const r=null!=t?String(t):"";return ft._preElems(e,"setText").forEach(e=>e.textContent=r),e}setText(e){return ft.setText(this,e)}static empty(e){return ft._preElems(e,"empty").forEach(e=>e.textContent=""),e}empty(){return ft.empty(this)}static html(e,t){return ft._preElem(e,"html").getHTML(t)}html(e){return ft.html(this,e)}static setHtml(e,t){if("string"!=typeof t)throw new Error("Value is not a valid string.");return ft._preElems(e,"setHtml").forEach(e=>e.innerHTML=t),e}setHtml(e){return ft.setHtml(this,e)}static _valHooks={option:{get:e=>{const t=e.getAttribute("value");return null!=t?t:e.textContent}},select:{get:e=>{const t=e.options,r=e.selectedIndex,n="select-one"===e.type,i=n?r+1:t.length,o=[];let s=r<0?i:n?r:0;for(;s<i;s++){const e=t[s],i=e.parentNode;if((e.selected||s===r)&&!e.disabled&&(!i||!i.disabled||"OPTGROUP"!==i.tagName)){const t=ft._valHooks.option.get(e);if(n)return t;o.push(t)}}return o},set:(e,t)=>{const r=e.options,n=Array.isArray(t)?t.map(String):[String(t)];let i=!1;for(let e=0;e<r.length;e++){const t=r[e],o=ft._valHooks.option.get(t);"string"==typeof o&&(t.selected=n.includes(o))&&(i=!0)}return i||(e.selectedIndex=-1),n}},radio:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t){const r=e.closest("label");return t&&r&&r.querySelectorAll('input[type="radio"]').forEach(t=>{t instanceof HTMLInputElement&&t!==e&&(t.checked=!1)}),e.checked=t,t}}},checkbox:{get:e=>e.checked?"on":"off",set(e,t){if("boolean"==typeof t)return e.checked=t,t}}};static setVal(e,t){return ft._preInputElems(e,"setVal").forEach(e=>{if(1!==e.nodeType)return;let r="function"==typeof t?t(e,ft.val(e)):t;null==r?r="":"number"==typeof r?r=String(r):Array.isArray(r)&&(r=((e,t)=>{const r=[];for(let n=0;n<e.length;n++)r.push(t(e[n]));return r})(r,e=>null==e?"":String(e)));const n=ft._valHooks[e.type]||ft._valHooks[e.nodeName.toLowerCase()];if(!n||"function"!=typeof n.set||void 0===n.set(e,r,"value")){if("string"!=typeof r&&"boolean"!=typeof r)throw new Error(`Invalid setValue "${typeof r}" value.`);"string"==typeof r&&(e.value=r)}}),e}setVal(e){return ft.setVal(this,e)}static _valTypes={string:e=>e.value,date:e=>e.valueAsDate,number:e=>e.valueAsNumber};static _getValByType(e,t,r){if("string"!=typeof t)throw new TypeError('The "type" must be a string.');if("string"!=typeof r)throw new TypeError('The "where" must be a string.');if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error(`Provided element is not an HTMLInputElement in ${r}().`);if("function"!=typeof ft._valTypes[t])throw new Error(`No handler found for type "${t}" in ${r}().`);return ft._valTypes[t](e)}static _val(e,t,r){const n=ft._preInputElem(e,t),i=ft._valHooks[n.type]||ft._valHooks[n.nodeName.toLowerCase()];if(i&&"function"==typeof i.get){const e=i.get(n,"value",r);if(void 0!==e)return"string"==typeof e?e.replace(/\r/g,""):e}return ft._getValByType(n,r,t)}_val(e,t){return ft._val(this,e,t)}static val(e){return ft._val(e,"val","string")}val(){return ft.val(this)}static valTxt(e){const t=ft._val(e,"valTxt","string");if("string"!=typeof t&&null!==t)throw new Error("Value is not a valid string.");return null==t?"":"string"==typeof t?t.replace(/\r/g,""):t}valTxt(){return ft.valTxt(this)}static _valArr(e,t,r){const n=ft._val(e,t,r);if(!Array.isArray(n))throw new Error(`Value expected an array but got ${typeof n}.`);return n}_valArr(e,t){return ft._valArr(this,e,t)}static valArr(e){return ft._valArr(e,"valArr","string")}valArr(){return ft.valArr(this)}static valNb(e){if(!(ft._preInputElem(e,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=ft._val(e,"valNb","number");if(Number.isNaN(t))throw new Error("Value is not a valid number.");return t}valNb(){return ft.valNb(this)}static valDate(e){if(!(ft._preInputElem(e,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const t=ft._val(e,"valDate","date");if(!(t instanceof Date))throw new Error("Value is not a valid date.");return t}valDate(){return ft.valDate(this)}static valBool(e){const t=ft._preInputElem(e,"valBool");if(!(t instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===ft.val(t)}valBool(){return ft.valBool(this)}static listenForPaste(e,{onFilePaste:t,onTextPaste:r}={}){if(void 0!==t&&"function"!=typeof t)throw new TypeError("onFilePaste must be a function.");if(void 0!==r&&"function"!=typeof r)throw new TypeError("onTextPaste must be a function.");const n=e=>{if(!(e instanceof ClipboardEvent))return;const n=e.clipboardData?.items||[];for(const e of n)if("file"===e.kind){if("function"==typeof t){const r=e.getAsFile();r&&t(e,r)}}else"string"===e.kind&&"function"==typeof r&&e.getAsString(t=>r(e,t))};return ft._preElemsWithDoc(e,"listenForPaste").forEach(e=>ft.on(e,"paste",n)),n}listenForPaste({onFilePaste:e,onTextPaste:t}={}){return ft.listenForPaste(this,{onFilePaste:e,onTextPaste:t})}static hasEventListener(e,t){const r=ft._preEventTargetElem(e,"hasEventListener");if(!ut.has(r))return!1;const n=ut.get(r);return!!(n&&Array.isArray(n[t])&&n[t].length>0)}hasEventListener(e){return ft.hasEventListener(this,e)}static hasExactEventListener(e,t,r){const n=ft._preEventTargetElem(e,"hasExactEventListener");if("function"!=typeof r)throw new TypeError('The "handler" must be a function.');if(!ut.has(n))return!1;const i=ut.get(n);return!(!i||!Array.isArray(i[t]))&&i[t].some(e=>e.handler===r)}hasExactEventListener(e,t){return ft.hasExactEventListener(this,e,t)}static hover(e,t,r,n){return ft.on(e,"mouseenter",t,n),ft.on(e,"mouseleave",r||t,n),e}hover(e,t,r){return ft.hover(this,e,t,r)}static on(e,t,r,n){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");ft._preEventTargetElems(e,"on").forEach(e=>{e.addEventListener(i,r,n),ut.has(e)||ut.set(e,{});const t=ut.get(e);t&&(Array.isArray(t[i])||(t[i]=[]),t[i].push({handler:r,options:n}))})}return e}on(e,t,r){return ft.on(this,e,t,r)}static once(e,t,r,n={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");ft._preEventTargetElems(e,"once").forEach(e=>{const t=n=>{ft.off(e,i,t),"function"==typeof r&&r(n)};ft.on(e,i,t,"boolean"==typeof n?n:{...n,once:!0})})}return e}once(e,t,r={}){return ft.once(this,e,t,r)}static off(e,t,r,n){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const i of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof i)throw new TypeError("The event name must be a string.");ft._preEventTargetElems(e,"off").forEach(e=>{e.removeEventListener(i,r,n);const t=ut.get(e);t&&t[i]&&(t[i]=t[i].filter(e=>e.handler!==r),0===t[i].length&&delete t[i])})}return e}off(e,t,r){return ft.off(this,e,t,r)}static offAll(e,t){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const r of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof r)throw new TypeError("The event name must be a string.");ft._preEventTargetElems(e,"offAll").forEach(e=>{const t=ut.get(e);if(t&&t[r]){for(const n of t[r])e.removeEventListener(r,n.handler,n.options);delete t[r]}})}return e}offAll(e){return ft.offAll(this,e)}static offAllTypes(e,t=null){if(null!==t&&"function"!=typeof t)throw new TypeError('The "filterFn" must be a function.');return ft._preEventTargetElems(e,"offAllTypes").forEach(e=>{const r=ut.get(e);if(r){for(const n in r)for(const i of r[n])("function"!=typeof t||t(i.handler,n))&&e.removeEventListener(n,i.handler,i.options);ut.delete(e)}}),e}offAllTypes(e=null){return ft.offAllTypes(this,e)}static trigger(e,t,r={}){if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(t)?Array.from(new Set(t)):[t]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");ft._preEventTargetElems(e,"trigger").forEach(e=>{const t=r instanceof Event||r instanceof CustomEvent?r:new CustomEvent(n,{bubbles:!0,cancelable:!0,detail:r});e.dispatchEvent(t)})}return e}trigger(e,t={}){return ft.trigger(this,e,t)}static#me={for:"htmlFor",class:"className"};static propFix=new Proxy(ft.#me,{set:(e,t,r)=>(e[t]=r,ft.attrFix[r]=t,!0)});static attrFix=Object.fromEntries(Object.entries(ft.#me).map(([e,t])=>[t,e]));static getPropName(e){return"string"==typeof ft.propFix[e]?ft.propFix[e]:e}static getAttrName(e){return"string"==typeof ft.attrFix[e]?ft.attrFix[e]:e}static attrBigInt(e,t){const r=ft._preElem(e,"attrBigInt").getAttribute(ft.getAttrName(t));if(null==r)return null;try{return BigInt(r)}catch{return null}}attrBigInt(e){return ft.attrBigInt(this,e)}static setAttrBigInt(e,t,r){if("bigint"!=typeof r)throw new Error("Value is not a valid BigInt.");return ft.setAttr(e,t,r.toString())}setAttrBigInt(e,t){return ft.setAttrBigInt(this,e,t)}static attrDate(e,t){const r=ft._preElem(e,"attrDate").getAttribute(ft.getAttrName(t));if(!r)return null;const n=new Date(r);return Number.isNaN(n.getTime())?null:n}attrDate(e){return ft.attrDate(this,e)}static setAttrDate(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new Error("Value is not a valid Date.");return ft.setAttr(e,t,r.toISOString())}setAttrDate(e,t){return ft.setAttrDate(this,e,t)}static attrJson(e,t){const r=ft._preElem(e,"attrJson").getAttribute(ft.getAttrName(t));if(!r)return null;try{return JSON.parse(r)}catch{return null}}attrJson(e){return ft.attrJson(this,e)}static setAttrJson(e,t,r,n,i){const o=JSON.stringify(r,n,i);return ft.setAttr(e,t,o)}setAttrJson(e,t,r,n){return ft.setAttrJson(this,e,t,r,n)}static attrNumber(e,t){const r=ft._preElem(e,"attrNumber").getAttribute(ft.getAttrName(t));return null!=r?parseFloat(r):null}attrNumber(e){return ft.attrNumber(this,e)}static setAttrNumber(e,t,r){if("number"!=typeof r)throw new Error("Value is not a valid number.");return ft.setAttr(e,t,r.toString())}setAttrNumber(e,t){return ft.setAttrNumber(this,e,t)}static attrBoolean(e,t){const r=ft._preElem(e,"attrBoolean").getAttribute(ft.getAttrName(t));return null===r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}attrBoolean(e){return ft.attrBoolean(this,e)}static setAttrBoolean(e,t,r){if("boolean"!=typeof r)throw new Error("Value is not a valid boolean.");return ft.setAttr(e,t,r.toString())}setAttrBoolean(e,t){return ft.setAttrBoolean(this,e,t)}static attrString(e,t){const r=ft._preElem(e,"attrString").getAttribute(ft.getAttrName(t));return"string"==typeof r?r:null}attrString(e){return ft.attrString(this,e)}static setAttrString(e,t,r){if("string"!=typeof r)throw new Error("Value is not a valid string.");return ft.setAttr(e,t,r)}setAttrString(e,t){return ft.setAttrString(this,e,t)}static attr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return ft._preElem(e,"attr").getAttribute(ft.getAttrName(t))}attr(e){return ft.attr(this,e)}static setAttr(e,t,r=null){const n=ft._preElems(e,"setAttr");if("object"==typeof t&&null!==t)return Object.entries(t).forEach(([e,t])=>n.forEach(r=>{null===t?r.removeAttribute(ft.getAttrName(e)):r.setAttribute(ft.getAttrName(e),String(t))})),e;if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return n.forEach(e=>{null===r?e.removeAttribute(ft.getAttrName(t)):e.setAttribute(ft.getAttrName(t),String(r))}),e}setAttr(e,t){return ft.setAttr(this,e,t)}static removeAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return ft._preElems(e,"removeAttr").forEach(e=>e.removeAttribute(ft.getAttrName(t))),e}removeAttr(e){return ft.removeAttr(this,e)}static hasAttr(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return ft._preElem(e,"hasAttr").hasAttribute(ft.getAttrName(t))}hasAttr(e){return ft.hasAttr(this,e)}static hasProp(e,t){if("string"!=typeof t)throw new TypeError('The "name" must be a string.');return!!ft._preElem(e,"hasProp")[ft.getPropName(t)]}hasProp(e){return ft.hasProp(this,e)}static addProp(e,...t){return ft._preElems(e,"addProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[ft.getPropName(t)]=!0})}),e}addProp(...e){return ft.addProp(this,...e)}static removeProp(e,...t){return ft._preElems(e,"removeProp").forEach(e=>{t.forEach(t=>{if("string"!=typeof t)throw new TypeError('Each "name" must be a string.');e[ft.getPropName(t)]=!1})}),e}removeProp(...e){return ft.removeProp(this,...e)}static toggleProp(e,t,r){const n=ft._preElems(e,"toggleProp");if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" must be a boolean.');return(Array.isArray(t)?t:[t]).forEach(e=>{if("string"!=typeof e)throw new TypeError("Each property name must be a string.");n.forEach(t=>{(void 0===r?!t[ft.getPropName(e)]:r)?ft.addProp(t,e):ft.removeProp(t,e)})}),e}toggleProp(e,t){return ft.toggleProp(this,e,t)}static prop(e,t){if("string"!=typeof t)throw new TypeError('Invalid arguments passed to prop(). Expected string for "name".');return ft._preElem(e,"prop")[t]}prop(e){return ft.prop(this,e)}static setProp(e,t,r){if("string"!=typeof t||""===t.trim())throw new Error("Property name must be a non-empty string.");return ft._preElems(e,"setProp").forEach(e=>{e[t]=r}),e}setProp(e,t){return ft.setProp(this,e,t)}static remove(e){return ft._preElems(e,"remove").forEach(e=>e.remove()),e}remove(){return ft.remove(this)}static index(e,t=null){const r=ft._preElem(e,"index");if(!r)return-1;if(!t)return Array.prototype.indexOf.call(r.parentNode?.children||[],r);if(t){const e="string"==typeof t?document.querySelectorAll(t):ft._preElems(t,"index");return Array.prototype.indexOf.call(e,r)}return-1}index(e){return ft.index(this,e)}static _getCustomRect(e,t){const r={height:0,width:0,x:0,y:0,bottom:0,left:0,right:0,top:0,toJSON:function(){throw new Error("Function not implemented.")}};for(const t in e)"number"==typeof e[t]&&(r[t]=e[t]);if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("extraRect must be a non-null object.");const{height:n=0,width:i=0,top:o=0,bottom:s=0,left:a=0,right:l=0}=t;if("number"!=typeof n)throw new Error("extraRect.height must be a number.");if("number"!=typeof i)throw new Error("extraRect.width must be a number.");if("number"!=typeof o)throw new Error("extraRect.top must be a number.");if("number"!=typeof s)throw new Error("extraRect.bottom must be a number.");if("number"!=typeof a)throw new Error("extraRect.left must be a number.");if("number"!=typeof l)throw new Error("extraRect.right must be a number.");return r.height+=n,r.width+=i,r.top+=o,r.bottom+=s,r.left+=a,r.right+=l,r}static isCollWith(e,t,r={}){const n=ft._getCustomRect(ft._preElem(e,"isCollWith").getBoundingClientRect(),r),i=ft._preElem(t,"isCollWith").getBoundingClientRect();return nt(n,i)}isCollWith(e,t){return ft.isCollWith(this,e,t)}static isCollPerfWith(e,t,r={}){const n=ft._getCustomRect(ft._preElem(e,"isCollPerfWith").getBoundingClientRect(),r),i=ft._preElem(t,"isCollPerfWith").getBoundingClientRect();return it(n,i)}isCollPerfWith(e,t){return ft.isCollPerfWith(this,e,t)}static _isCollWithLock(e,t,r,n,i){const o=pt[i];if(e)return o.has(n)||o.set(n,!0),!0;if(o.has(n)){let e=!1;switch(i){case"top":e=ot(t,r);break;case"bottom":e=st(t,r);break;case"left":e=at(t,r);break;case"right":e=lt(t,r)}return e&&o.delete(n),o.has(n)}return!1}static isCollWithLock(e,t,r,n={}){const i=ft._preElem(e,"isCollWithLock"),o=ft._preElem(t,"isCollWithLock"),s=ft._getCustomRect(i.getBoundingClientRect(),n),a=o.getBoundingClientRect(),l=nt(s,a);return ft._isCollWithLock(l,s,a,i,r)}isCollWithLock(e,t,r){return ft.isCollWithLock(this,e,t,r)}static isCollPerfWithLock(e,t,r,n={}){const i=ft._preElem(e,"isCollPerfWithLock"),o=ft._preElem(t,"isCollPerfWithLock"),s=ft._getCustomRect(i.getBoundingClientRect(),n),a=o.getBoundingClientRect(),l=it(s,a);return ft._isCollWithLock(l,s,a,i,r)}isCollPerfWithLock(e,t,r){return ft.isCollPerfWithLock(this,e,t,r)}static resetCollLock(e){const t=ft._preElem(e,"resetCollLock");let r=!1;for(const e of["top","bottom","left","right"])pt[e].has(t)&&(pt[e].delete(t),r=!0);return r}resetCollLock(){return ft.resetCollLock(this)}static resetCollLockDir(e,t){const r=ft._preElem(e,"resetCollLockDir"),n=pt[t];return!!n.has(r)&&(n.delete(r),!0)}resetCollLockDir(e){return ft.resetCollLockDir(this,e)}static isInViewport(e){const t=ft._preElem(e,"isInViewport");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=ft.offset(t).top,n=r+ft.outerHeight(t),i=ft.scrollTop(window),o=i+ft.height(window);return n>i&&r<o}isInViewport(){return ft.isInViewport(this)}static isScrolledIntoView(e){const t=ft._preElem(e,"isScrolledIntoView");if(!t.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=ft.scrollTop(window),n=r+ft.height(window),i=ft.offset(t).top;return i+ft.height(t)<=n&&i>=r}isScrolledIntoView(){return ft.isScrolledIntoView(this)}static isInContainer(e,t){const r=ft._preElem(e,"isInContainer"),n=ft._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const i=r.getBoundingClientRect(),o=n.getBoundingClientRect(),s=i.bottom>o.top&&i.top<o.bottom,a=i.right>o.left&&i.left<o.right;return s&&a}isInContainer(e){return ft.isInContainer(this,e)}static isFullyInContainer(e,t){const r=ft._preElem(e,"isScrolledIntoView"),n=ft._preElem(t,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const i=r.getBoundingClientRect(),o=n.getBoundingClientRect();return i.top>=o.top&&i.bottom<=o.bottom&&i.left>=o.left&&i.right<=o.right}isFullyInContainer(e){return ft.isFullyInContainer(this,e)}static hasScroll(e){const t=ft._preElem(e,"hasScroll");return{v:t.scrollHeight>t.clientHeight,h:t.scrollWidth>t.clientWidth}}hasScroll(){return ft.hasScroll(this)}}const mt=ft;class gt{static Utils={...e,TinyHtml:mt};#ge=!0;#ye=!1;#we=0;#be=0;#ve=!0;#Ee=!1;#Te=!1;#Se=!1;#xe=!1;#Ae=!1;#Ie=!1;#Ce=null;#Me=[];#Le=null;#Ne={start:!1,end:!1,collide:!1,move:!1};#ke=null;#$;#De="drag-hidden";#_e="dragging";#je="drag-active";#Re="jail-drag-active";#Oe="jail-drag-disabled";#He="dragging-collision";#Be=9999;constructor(e,t={}){const r=e instanceof mt?e.get(0):e;if(!(r instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#$=r,void 0!==t.jail&&!(t.jail instanceof HTMLElement))throw new Error('The "jail" option must be an HTMLElement if provided.');if(void 0!==t.defaultZIndex&&this.setDefaultZIndex(t.defaultZIndex),void 0!==t.vibration&&!1!==t.vibration&&!m(t.vibration))throw new Error('The "vibration" option must be an object or false.');const n=(e,t)=>{if(void 0!==e&&"boolean"!=typeof e)throw new Error(`The "${t}" option must be a boolean.`)},i=(e,t)=>{if(void 0!==e&&"string"!=typeof e)throw new Error(`The "${t}" option must be a string.`)};n(t.mirrorElem,"mirrorElem"),n(t.collisionByMouse,"collisionByMouse"),n(t.lockInsideJail,"lockInsideJail"),n(t.dropInJailOnly,"dropInJailOnly"),n(t.revertOnDrop,"revertOnDrop"),n(t.multiCollision,"multiCollision"),i(t.classDragging,"classDragging"),i(t.classBodyDragging,"classBodyDragging"),i(t.classJailDragging,"classJailDragging"),i(t.classJailDragDisabled,"classJailDragDisabled"),i(t.classDragCollision,"classDragCollision"),i(t.classHidden,"classHidden"),t.jail instanceof HTMLElement&&(this.#ke=t.jail),this.#Ne=Object.assign({start:!1,end:!1,collide:!1,move:!1},m(t.vibration)?t.vibration:{}),"string"==typeof t.classDragging&&(this.#_e=t.classDragging),"string"==typeof t.classBodyDragging&&(this.#je=t.classBodyDragging),"string"==typeof t.classJailDragging&&(this.#Re=t.classJailDragging),"string"==typeof t.classJailDragDisabled&&(this.#Oe=t.classJailDragDisabled),"string"==typeof t.classHidden&&(this.#De=t.classHidden),"string"==typeof t.classDragCollision&&(this.#He=t.classDragCollision),"boolean"==typeof t.collisionByMouse&&(this.#Ae=t.collisionByMouse),"boolean"==typeof t.mirrorElem&&(this.#ve=t.mirrorElem),"boolean"==typeof t.revertOnDrop&&(this.#Se=t.revertOnDrop),"boolean"==typeof t.lockInsideJail&&(this.#Te=t.lockInsideJail),"boolean"==typeof t.dropInJailOnly&&(this.#Ie=t.dropInJailOnly),"boolean"==typeof t.multiCollision&&(this.#Ee=t.multiCollision),this._onMouseDown=this.#$e.bind(this),this._onMouseMove=this.#Pe.bind(this),this._onMouseUp=this.#Fe.bind(this),this._onTouchStart=e=>this.#$e(e.touches[0]),this._onTouchMove=e=>this.#Pe(e.touches[0]),this._onTouchEnd=e=>this.#Fe(e.changedTouches[0]),this.#$.addEventListener("mousedown",this._onMouseDown),this.#$.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){this.#We(),this.#ke&&this.#ke.classList.add(this.#Oe),this.#ge=!0}disable(){this.#ke&&this.#ke.classList.remove(this.#Oe),this.#ge=!1}addCollidable(e){if(this.#We(),!(e instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#Me.includes(e)||this.#Me.push(e)}removeCollidable(e){if(this.#We(),!(e instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#Me=this.#Me.filter(t=>t!==e)}setVibrationPattern({startPattern:e=!1,endPattern:t=!1,collidePattern:r=!1,movePattern:n=!1}={}){this.#We();const i=e=>!1===e||Array.isArray(e)&&e.every(e=>"number"==typeof e);if(!i(e))throw new Error('Invalid "startPattern": must be false or an array of numbers.');if(!i(t))throw new Error('Invalid "endPattern": must be false or an array of numbers.');if(!i(r))throw new Error('Invalid "collidePattern": must be false or an array of numbers.');if(!i(n))throw new Error('Invalid "movePattern": must be false or an array of numbers.');this.#Ne={start:e,end:t,collide:r,move:n}}disableVibration(){this.#We(),this.#Ne={start:!1,end:!1,collide:!1,move:!1}}getOffset(e){if(this.#We(),!(e instanceof MouseEvent||e instanceof Touch)||"number"!=typeof e.clientX||"number"!=typeof e.clientY)throw new Error("getOffset expects an event with valid clientX and clientY coordinates.");const t=this.#$.getBoundingClientRect(),{left:r,top:n}=mt.borderWidth(this.#$);return{x:e.clientX-t.left+r,y:e.clientY-t.top+n}}#$e(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ye||!this.#ge||!this.#$.parentElement)return;if(this.#ve){const e=this.#$.cloneNode(!0);if(!(e instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#Le=e}else this.#Le=this.#$;this.#xe=!0;const t=this.#$.getBoundingClientRect();Object.assign(this.#Le.style,{position:"absolute",pointerEvents:"none",left:`${this.#$.offsetLeft}px`,top:`${this.#$.offsetTop}px`,width:`${t.width}px`,height:`${t.height}px`,zIndex:this.#Be}),this.#ve&&(this.#$.classList.add(this.#De),this.#$.parentElement.appendChild(this.#Le));const{x:r,y:n}=this.getOffset(e);this.#be=r,this.#we=n,this.#Le.classList.add(this.#_e),document.body.classList.add(this.#je),this.#ke&&this.#ke.classList.add(this.#Re),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("touchmove",this._onTouchMove,{passive:!1}),document.addEventListener("touchend",this._onTouchEnd),navigator.vibrate&&Array.isArray(this.#Ne.start)&&navigator.vibrate(this.#Ne.start),this.checkDragCollision(e),this.#ze("drag")}#qe=[];#Ve(e){e&&(e.classList.add(this.#He),this.#qe.push(e))}#Ke(){for(;this.#qe.length>0;){const e=this.#qe.shift();e&&e.classList.remove(this.#He)}this.#Ce&&this.#Ce.classList.remove(this.#He)}checkDragCollision(e){const{collidedElements:t}=this.execCollision(e),r=t[0]||null;this.#Ce&&!t.includes(this.#Ce)&&this.#Ke(),t.forEach(e=>this.#Ve(e)),this.#Me.forEach(e=>{t.includes(e)||e.classList.remove(this.#He)}),navigator.vibrate&&Array.isArray(this.#Ne.collide)&&t.length>0&&navigator.vibrate(this.#Ne.collide),this.#Ce=r}#Pe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ye||!this.#xe||!this.#ge||!this.#Le)return;const t=(this.#Le.offsetParent||document.body).getBoundingClientRect();let r=e.clientX-t.left-this.#be,n=e.clientY-t.top-this.#we;if(this.#Te&&this.#ke){const e=this.#ke.getBoundingClientRect(),i=this.#Le.getBoundingClientRect(),o=e.left-t.left,s=e.top-t.top,{x:a,y:l}=mt.borderWidth(this.#ke),u=o+e.width-i.width-l,c=s+e.height-i.height-a;r=Math.max(o,Math.min(r,u)),n=Math.max(s,Math.min(n,c))}this.#Le.style.position="absolute",this.#Le.style.left=`${r}px`,this.#Le.style.top=`${n}px`,navigator.vibrate&&Array.isArray(this.#Ne.move)&&navigator.vibrate(this.#Ne.move),this.checkDragCollision(e),this.#ze("dragging")}execCollision(e){if(this.#ye||!this.#Le)return{inJail:!1,collidedElements:[]};let t=[],r=!0;const n=this.#ke?.getBoundingClientRect();if(this.#Ae){const i=e.clientX,o=e.clientY;this.#Ie&&this.#ke&&n&&(r=i>=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom),t=r?this.#Ee?this.getAllCollidedElements(i,o):[this.getCollidedElement(i,o)].filter(Boolean):[]}else{const e=this.#Le.getBoundingClientRect();this.#Ie&&this.#ke&&n&&(r=e.left>=n.left&&e.right<=n.right&&e.top>=n.top&&e.bottom<=n.bottom),t=r?this.#Ee?this.getAllCollidedElementsByRect(e):[this.getCollidedElementByRect(e)].filter(Boolean):[]}return{inJail:r,collidedElements:t}}#Fe(e){if(e instanceof MouseEvent&&e.preventDefault(),this.#ye||!this.#xe)return;if(this.#xe=!1,!this.#Le)return;this.#$.classList.remove(this.#_e),document.body.classList.remove(this.#je),this.#ke&&this.#ke.classList.remove(this.#Re),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd);const{collidedElements:t}=this.execCollision(e);navigator.vibrate&&Array.isArray(this.#Ne.end)&&navigator.vibrate(this.#Ne.end);const r=this.#Le.style.left,n=this.#Le.style.top;this.#Le&&(this.#ve?this.#Le.remove():Object.assign(this.#Le.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#Le=null),this.#Ce&&this.#Ke(),this.#Ce=null,this.#ve&&this.#$.classList.remove(this.#De),this.#Se||(this.#$.style.left=r,this.#$.style.top=n);const i=new CustomEvent("drop",{detail:{targets:t,first:t[0]||null}});this.#$.dispatchEvent(i)}#Ue(e,t){const r=e.getBoundingClientRect();return!(t.right<r.left||t.left>r.right||t.bottom<r.top||t.top>r.bottom)}getAllCollidedElementsByRect(e){if(this.#We(),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Me.filter(t=>this.#Ue(t,e))}getCollidedElementByRect(e){if(this.#We(),!(e instanceof DOMRect)||"number"!=typeof e.left||"number"!=typeof e.right||"number"!=typeof e.top||"number"!=typeof e.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#Me.find(t=>this.#Ue(t,e))||null}#Je(e,t,r){const n=e.getBoundingClientRect();return t>=n.left&&t<=n.right&&r>=n.top&&r<=n.bottom}getAllCollidedElements(e,t){if(this.#We(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Me.filter(r=>this.#Je(r,e,t))}getCollidedElement(e,t){if(this.#We(),"number"!=typeof e||"number"!=typeof t)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#Me.find(r=>this.#Je(r,e,t))||null}#ze(e){const t=new CustomEvent(e);this.#$.dispatchEvent(t)}getDragging(){return this.#xe}getLockInsideJail(){return this.#Te}setLockInsideJail(e){if("boolean"!=typeof e)throw new Error("lockInsideJail must be a boolean.");this.#Te=e}getRevertOnDrop(){return this.#Se}setRevertOnDrop(e){if("boolean"!=typeof e)throw new Error("revertOnDrop must be a boolean.");this.#Se=e}getCollisionByMouse(){return this.#Ae}setCollisionByMouse(e){if("boolean"!=typeof e)throw new Error("collisionByMouse must be a boolean.");this.#Ae=e}getDropInJailOnly(){return this.#Ie}setDropInJailOnly(e){if("boolean"!=typeof e)throw new Error("dropInJailOnly must be a boolean.");this.#Ie=e}getDefaultZIndex(){return this.#Be}setDefaultZIndex(e){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("Z-index must be a finite number.");this.#Be=e}isMirrorEnabled(){return this.#ve}setMirrorEnabled(e){if("boolean"!=typeof e)throw new TypeError("Mirror setting must be a boolean.");this.#ve=e}getTarget(){return this.#$}getJail(){return this.#ke}getDragProxy(){return this.#Le}getLastCollision(){return this.#Ce}getCollidables(){return[...this.#Me]}getDragHiddenClass(){return this.#De}getClassDragging(){return this.#_e}getClassBodyDragging(){return this.#je}getClassJailDragging(){return this.#Re}getClassJailDragDisabled(){return this.#Oe}getClassDragCollision(){return this.#He}getVibrations(){return{...this.#Ne}}getStartVibration(){return this.#Ne.start}getEndVibration(){return this.#Ne.end}getCollideVibration(){return this.#Ne.collide}getMoveVibration(){return this.#Ne.move}isEnabled(){return this.#ge}#We(){if(this.#ye)throw new Error("This TinyDragger instance has been destroyed and can no longer be used.")}destroy(){this.#ye||(this.disable(),this.#$.removeEventListener("mousedown",this._onMouseDown),this.#$.removeEventListener("touchstart",this._onTouchStart),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),this.#Ce&&this.#Ke(),this.#Le&&(this.#ve?this.#Le.remove():Object.assign(this.#Le.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#Le=null),this.#Me=[],this.#xe=!1,this.#Ce=null,this.#ve&&this.#$.classList.remove(this.#De),this.#$.classList.remove(this.#_e),document.body.classList.remove(this.#je),this.#ke&&this.#ke.classList.remove(this.#Re,this.#Oe),this.#ye=!0)}}const yt=gt,wt=class{#Ge=[];#Ye=!1;#Xe=!1;#Qe=[];#Ze(){this.#Ye&&Promise.all(this.#Qe).then(()=>{this.#Xe=!0,this.#et(!1)}).catch(e=>{console.error("[TinyDomReadyManager] Promise rejected:",e)})}#et(e){this.#Ge.filter(t=>t.domOnly===e).sort((e,t)=>t.priority-e.priority).forEach(e=>this.#tt(e)),this.#Ge=this.#Ge.filter(t=>!(t.once&&(!e||t.domOnly)))}#tt(e){if("function"==typeof e.filter)try{if(!e.filter())return}catch(e){return void console.warn("[TinyDomReadyManager] Filter error:",e)}try{e.fn()}catch(e){console.error("[TinyDomReadyManager] Handler error:",e)}}_markDomReady(){this.#Ye=!0,this.#et(!0),this.#Ze()}init(){if(this.#Ye)throw new Error("[TinyDomReadyManager] init() has already been called.");"interactive"===document.readyState||"complete"===document.readyState?this._markDomReady():document.addEventListener("DOMContentLoaded",()=>this._markDomReady())}addPromise(e){if(!(e instanceof Promise))throw new TypeError("[TinyDomReadyManager] promise must be a valid Promise.");this.#Xe||(this.#Qe.push(e),this.#Ye&&this.#Ze())}onReady(e,{once:t=!0,priority:r=0,filter:n=null,domOnly:i=!1}={}){if("function"!=typeof e)throw new TypeError("[TinyDomReadyManager] fn must be a function.");const o={fn:e,once:t,priority:r,filter:n,domOnly:i};if(i&&this.#Ye)return this.#tt(o),void(t||this.#Ge.push(o));!i&&this.#Xe?this.#tt(o):this.#Ge.push(o)}isReady(){return this.#Xe}isDomReady(){return this.#Ye}},bt=class{#rt=!1;#nt=!1;#it=null;#ot=100;#st=null;#at;constructor({audio:e=null,defaultIcon:t=null,bodyLimit:r=100,defaultOnClick:n=function(e){e.preventDefault(),window.focus&&window.focus(),this.close()}}={}){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("audio must be an instance of HTMLAudioElement or null.");if(null!==t&&"string"!=typeof t)throw new TypeError("defaultIcon must be a string or null.");if(!Number.isFinite(r)||r<0)throw new TypeError("bodyLimit must be a non-negative number.");if("function"!=typeof n)throw new TypeError("defaultOnClick must be a function.");this.#it="string"!=typeof e?e:new Audio(e),this.#st=t,this.#ot=r,this.#at=n}requestPerm(){const e=this;return new Promise((t,r)=>{e.isCompatible()?"default"===Notification.permission?Notification.requestPermission().then(r=>{this.#nt=!0,e.#rt="granted"===r,t(e.#rt)}).catch(r):(this.#nt=!0,e.#rt="granted"===Notification.permission,t(e.#rt)):(this.#nt=!0,e.#rt=!1,t(!1))})}isCompatible(){return"Notification"in window}send(e,t={}){if(!this.#nt)throw new Error("You must call requestPerm() before sending a notification.");if("string"!=typeof e)throw new TypeError("title must be a string.");if("object"!=typeof t||null===t)throw new TypeError("config must be a non-null object.");if(!this.#rt)return null;const{icon:r=this.#st||void 0,vibrate:n=[200,100,200]}=t,i={...t};"string"==typeof r&&(i.icon=r),Array.isArray(n)&&(i.vibrate=n),"string"==typeof i.body&&(i.body=z(i.body,this.#ot));const o=new Notification(e,i);return o.addEventListener("show",()=>{this.#it instanceof HTMLAudioElement&&(this.#it.currentTime=0,this.#it.play().catch(e=>console.error(e)))}),"function"==typeof this.#at&&o.addEventListener("click",this.#at),o}wasPermissionRequested(){return this.#nt}isAllowed(){return this.#rt}getAudio(){return this.#it}setAudio(e){if(!(e instanceof HTMLAudioElement)&&"string"!=typeof e&&null!==e)throw new TypeError("sound must be an instance of HTMLAudioElement or null.");this.#it="string"!=typeof e?e:new Audio(e)}getBodyLimit(){return this.#ot}setBodyLimit(e){if(!Number.isFinite(e)||e<0)throw new TypeError("bodyLimit must be a non-negative number.");this.#ot=e}getDefaultAvatar(){return this.#st}setDefaultAvatar(e){if("string"!=typeof e&&null!==e)throw new TypeError("defaultIcon must be a string or null.");this.#st=e}getDefaultOnClick(){return this.#at}setDefaultOnClick(e){if("function"!=typeof e)throw new TypeError("defaultOnClick must be a function.");this.#at=e}},vt=class{#lt;#ut=null;#ct=[];#ht=100;#dt=new Set;#pt=new Set;#ye=!1;constructor(e=window,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#lt=e,this._checkTimer=this._checkTimer.bind(this),this.#lt.addEventListener("scroll",this._checkTimer),this.#ht=t}_checkTimer=()=>{this.#ut&&clearTimeout(this.#ut),this.#ut=setTimeout(()=>{this.#ut=null,this.#ft()},this.#ht)};get inactivityTime(){return this.#ht}set inactivityTime(e){if("number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#ht=e}#ft(){if(!this.#ye){for(const e of this.#pt)"function"==typeof e&&e();for(;this.#ct.length;){const e=this.#ct.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#ct.push(e)}onStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#pt.add(e)}offStop(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#pt.delete(e)}onScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#lt.addEventListener("scroll",e),this.#dt.add(e)}offScroll(e){if("function"!=typeof e)throw new TypeError("Argument must be a function.");this.#dt.has(e)&&(this.#lt.removeEventListener("scroll",e),this.#dt.delete(e))}destroy(){if(!this.#ye){this.#ye=!0,this.#lt.removeEventListener("scroll",this._checkTimer);for(const e of this.#dt)this.#lt.removeEventListener("scroll",e);this.#dt.clear(),this.#pt.clear()}}},Et=["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","sed","do","eiusmod","tempor","incididunt","ut","labore","et","dolore","magna","aliqua"],Tt=["😂","🌈","🤖","💥","🐸","🍕","🦄","🧠","🧬","🚀","🫠","💫","🍩","👾","🎉","🥴","🐙","🧃","🪐","🎈","🧸","👻","🥳","🍭","💖","😺","🌮","🪅","🎮","🥓","🍮"],St=["pudding","bean","snuggle","bloop","jelly","unicorn","floof","giggle","bubble","muffin","puff","pickle","goblin","waffle","sprinkle","cupcake","fizzle","marshmallow","duckling","sock","cloud","teacup","nugget","gnome","hug","moonbean","crayon","jiggle","glitter","carrot","goober"],xt=["wiggles","bounces","flies","splats","scoots","giggles","wigglesnacks","twirls","boops","pops","sings","hugs","floats","glows","flaps","mlems","dances","puddles","nomnoms","wigglejumps","sniffs","tumbles","slides","chirps","burps","sparkles","waddles","rambles","blinks","mews"],At=["fluffy","silly","yummy","squishy","wobbly","magical","tiny","sleepy","wiggly","bubbly","glittery","fuzzy","jiggly","sparkly","giggly","crunchy","goofy","soft","mushy","sweet","loopy","floaty","bonkers","chewy","ticklish","dreamy","pastel","cozy","teensy","grumbly"],It=["Boop!","Wiggle achieved.","Oops, {noun} everywhere!","Tiny {adj} {noun}, big {adj} {noun}.","Snuggle initiated with a {adj} {noun}.","{adj} vibes only, powered by {noun}.","No {noun}, no {noun}.","Bounce first, {verb} later.","Mlem. {verb}. {noun}.","{noun} go brrr and {verb}.","Why not? {noun} did. Then {noun} followed.","A {adj} {noun} just {verb} near the {adj} window.","That {adj} {noun} stole my {noun}!","Look, a {adj} {noun} trying to {verb} again!","Every {noun} deserves a {adj} nap.","The {adj} {noun} is my {adj} spirit animal.","Someone call the {noun}, it’s {verb}ing and {verb}ing again!","Don’t touch the {adj} {noun}. It {verb}s loudly.","{noun} forgot how {noun}s work and just {verb}ed.","There once was a {adj} {noun} who loved to {verb} with a {adj} {noun} all day.","Apparently, {noun}s are banned from {verb}ing and {verb}ing in the {noun} library.","That {adj} noise? Just a {noun} learning to {verb} on a {adj} {noun}.","I saw a {adj} {noun} {verb} so hard, it became a {adj} muffin.","The {adj} {noun} met a {adj} pickle and everything {verb}ed.","{noun}s are like {noun}: {adj}, unpredictable, and wiggly.","Don’t judge a {adj} {noun} by its ability to {verb}, or by its {adj} hat.","All I wanted was peace, but a {adj} {noun} with a {adj} {noun} had other plans.","One {adj} morning, a {adj} {noun} decided it was finally time to {verb}, but halfway through, it tripped on a {noun} and turned into a {adj} marshmallow.","I tried to be {adj} today, but then a {noun} {verb}ed across my {noun} and typed “asdfgh{noun}” repeatedly.","If you think you’ve seen everything, wait until a {adj} {noun} {verb}s on a {noun} wearing {adj} socks with tiny {noun}s.","No one ever believed the stories about the ancient {adj} {noun} who could {verb} with such {adj} grace that entire {noun}s turned pink out of embarrassment.","A curious {adj} {noun} wandered into a {noun} shop, not knowing that its destiny involved twelve {adj} {noun}s, one rubber {noun}, and a suspiciously quiet {adj} llama.","In a land where every {adj} {noun} was made of pudding and the sky was {adj} whipped cream, one brave {adj} {noun} set out to discover the legendary Spoon of {noun}s, facing obstacles like bouncing {noun}s, sassy {noun}s, and the Great Wobble of the {noun}.","Once upon a {adj} time, long before the {noun}s learned to {verb}, there existed a tiny {adj} {noun} who dreamed of swimming in a pool made entirely of {adj} glitter pudding while {verb}ing off-key lullabies to passing {noun}s with monocles.","The Council of {noun}s gathered in {adj} secret when the sacred {adj} {noun} started to {verb} uncontrollably, threatening the entire {adj} dessert-based civilization with spontaneous {noun} jiggles and uncontainable {noun} fits across the {noun}.","Hey... do you ever wonder if {noun}s dream of {noun}s?","Okay but hear me out: what if the {adj} {noun} could actually {verb} backwards?","Can we talk about the {noun} that just {verb}ed and vanished?","So I was talking to a {noun}, and it told me to stop being {adj}. Rude.","Not to alarm you, but there’s a {adj} {noun} behind you doing the {verb}.","Why does this {noun} keep staring at me like I owe it pudding?","Is this a safe space to admit I accidentally {verb}ed a {noun}?","I just walked into the room and someone shouted “{adj} {noun}!” — what did I miss?","Wait... we were supposed to bring a {noun}? No one told me!","Okay but what if the {adj} {noun} has feelings too?","Be honest, do I look like a {noun} that forgot how to {verb}?",'If I say "oops", do I still have to explain why the {noun} is glowing?',"I don’t know what’s going on but I brought snacks and a confused {noun}.","Do you think pudding knows it’s pudding? Just a thought.","Is this about the time I {verb}ed the {adj} {noun} by accident? Because I can explain.","Wait, are we talking about {noun}s or am I on the wrong chat again?",'What is this group even about? I just saw "pudding" and joined.',"Hi! I have no idea what’s happening but I’m here and I brought a {noun}.","I blinked and now there’s a {adj} {noun} in charge of everything.","Can someone please explain why the {noun} is floating and chanting?","Okay who gave the {noun} access to glitter and emotional support pickles?","I came for a calm discussion and now there’s a {adj} battle between {noun}s.","Not sure if I’m early, late, or inside a {noun} dream.","I was gone for 3 minutes and now someone’s riding a {noun} into the pudding realm.","This isn’t the pudding appreciation group, is it? ...oh no.","So... who summoned the {adj} {noun} this time? Be honest.","I came here for vibes and stayed for the {noun}s.","Does anyone else hear faint giggling or is that just the {adj} {noun} again?","I feel like I missed step one, two, and also three of this conversation.","All I asked was “what’s up?” and now I’m emotionally attached to a {noun}.",'Me: "I’ll be normal today." Also me: *{verb}s into a meeting riding a {adj} {noun}*','"It’s just pudding," they said. "It can’t hurt you," they said. They were wrong.',"I said one nice thing to a {noun} and now it follows me everywhere.","Can we take a moment to appreciate how the {adj} {noun} is just vibing?","Who put a tiny hat on the {noun}? Because that’s adorable.","My life has been different ever since the {noun} started {verb}ing.","Raise your hand if you’ve ever been personally attacked by a {adj} {noun}.",'"Don’t be weird," they said. So I became a {noun} instead.',"Do {noun}s have feelings? Asking for a {adj} friend.","I trusted the {noun} and all I got was a glitter-covered sock.","Plot twist: the {adj} {noun} was inside us all along.","The {adj} {noun} {verb} and {verb} all over the {adj} {noun}!","Oops! {noun}s {verb}ed into the {adj} {noun} while {verb}ing crazily.","{adj}, {adj}, and more {adj} {noun}s just {verb}ed by!","Why does the {adj} {noun} keep {verb}ing and {verb}ing without stopping?","Look! A {adj} {noun}, a {adj} {noun}, and a {noun} all {verb}ing together!","Sometimes, the {noun} just {verb}s, then {verb}s again, and never stops being {adj}.","{noun}, {noun}, and {noun} — all {verb}ing and {verb}ing in a {adj} {noun}.","I saw a {adj} {noun} {verb}, then another {noun} {verb}ing with a {adj} {noun}.","The {noun} {verb}s {verb} while the {adj} {noun} {verb}s and the {noun} just {verb}s.","Can a {adj} {noun} {verb} {verb} without a {adj} {noun} watching?","Whoa! The {adj} {noun} just {verb}ed... and then {verb}ed again!","Hey... did you see that {adj} {noun} {verb} over there?","Umm, the {noun} is {verb}ing but also {verb}ing and {verb}ing!","Lol! {noun}s {verb} so {adj}ly, it’s impossible not to giggle.",'"Hey! What’s up?" asked the {adj} {noun}, who {verb}ed loudly.','"I’m just a {adj} {noun} trying to {verb}, you know?"','"Did you see the {adj} {noun} that just {verb}ed in the pudding?"','"No way! The {noun} {verb}s better than me!"','"Wait, the {adj} {noun} said it would {verb}, but it {verb}ed instead!"',"Once upon a {adj} {noun}, a group of {adj} {noun}s {verb}ed through the {adj} forest, singing {adj} songs and eating {noun}s made of pudding.","The legend tells of a {adj} {noun} who could {verb} faster than any {noun} ever seen, leaving trails of {adj} sparkles behind.","Every day, the {adj} {noun} would {verb} around the {adj} meadow, trying to convince the {noun}s to join the grand pudding party.","No one knows why the {adj} {noun} suddenly {verb}ed and then {verb}ed again, but everyone agrees it was the cutest thing they ever saw.","In the kingdom of {adj} {noun}s, only the bravest {noun} dared to {verb} the giant pudding monster, armed with nothing but {adj} smiles and jellybeans.","{adj} {noun} {verb} {verb} {verb} {noun} {verb} {adj} {noun} {verb} {noun}!","{noun} {noun} {verb} {adj} {noun} and then {verb} {verb} the {adj} {noun}.","{verb} the {adj} {noun}, then {verb} the {noun} while {verb}ing {adj}ly.","Can the {adj} {noun} {verb} and {verb} the {adj} {noun} at the same time?","{noun} {verb} {noun} {verb}, but the {adj} {noun} {verb}s better.","Boop! The {adj} {noun} just {verb}ed in the pudding.","Bloop bloop, the {noun} is {verb}ing all over again!","Mlem mlem, a {adj} {noun} {verb}s quietly in the corner.","Splat! {noun} {verb}ed right on the {adj} {noun}.","Yum! A {adj} {noun} just {verb}ed in my mouth.","Do {noun}s really {verb} when nobody’s watching?","Why does the {adj} {noun} always {verb} at midnight?","Can a {noun} be too {adj} to {verb} properly?","Is it normal for a {adj} {noun} to {verb} three times in a row?","Who taught the {noun} to {verb} like that?","Wait, did the {adj} {noun} just {verb} itself?","I can’t believe the {noun} {verb}ed into a {adj} {noun}!","Suddenly, a {adj} {noun} appeared and started to {verb} wildly.","That {noun} was {verb}ing so {adj}ly it broke the pudding meter.","Everyone’s talking about the {adj} {noun} that {verb}ed out of nowhere."];class Ct{static#mt=Et;static#gt=Tt;static#yt=St;static#wt=xt;static#bt=At;static#vt=It;static#Et(e,t){if(!Array.isArray(e))throw new TypeError(`${t} must be an array of strings`);if(!e.every(e=>"string"==typeof e))throw new TypeError(`${t} must contain only strings`);if(0===e.length)throw new Error(`${t} cannot be empty`)}static get defaultWords(){return[...this.#mt]}static set defaultWords(e){this.#Et(e,"defaultWords"),this.#mt=[...e]}static get defaultEmojis(){return[...this.#gt]}static set defaultEmojis(e){this.#Et(e,"defaultEmojis"),this.#gt=[...e]}static get defaultNouns(){return[...this.#yt]}static set defaultNouns(e){this.#Et(e,"defaultNouns"),this.#yt=[...e]}static get defaultVerbs(){return[...this.#wt]}static set defaultVerbs(e){this.#Et(e,"defaultVerbs"),this.#wt=[...e]}static get defaultAdjectives(){return[...this.#bt]}static set defaultAdjectives(e){this.#Et(e,"defaultAdjectives"),this.#bt=[...e]}static get defaultTemplates(){return[...this.#vt]}static set defaultTemplates(e){this.#Et(e,"defaultTemplates"),this.#vt=[...e]}config={minLength:10,maxLength:300,readable:!0,useEmojis:!0,includeNumbers:!0,includeSymbols:!0,allowWeirdSpacing:!1,emojiSet:[],wordSet:[],mode:"mixed",grammar:{templates:[],nouns:[],verbs:[],adjectives:[]},repeatWords:!0,emojiPlacement:"inline",line:{minLength:20,maxLength:120,emojiChance:.3}};constructor(e={}){this.symbols="!@#$%^&*()-_=+[]{}|;:,.<>?/\\~".split("");const{minLength:t,maxLength:r,readable:n,useEmojis:i,includeNumbers:o,includeSymbols:s,allowWeirdSpacing:a,emojiSet:l,wordSet:u,mode:c,grammar:h,repeatWords:d,emojiPlacement:p,paragraphs:f,line:m}=e;if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.minLength must be an integer >= 1");if(void 0!==r&&(!Number.isInteger(r)||r<1))throw new TypeError("config.maxLength must be an integer >= 1");if(void 0!==t&&void 0!==r&&t>r)throw new RangeError("config.minLength cannot be greater than config.maxLength");if(void 0!==n&&"boolean"!=typeof n)throw new TypeError("config.readable must be a boolean");if(void 0!==i&&"boolean"!=typeof i)throw new TypeError("config.useEmojis must be a boolean");if(void 0!==o&&"boolean"!=typeof o)throw new TypeError("config.includeNumbers must be a boolean");if(void 0!==s&&"boolean"!=typeof s)throw new TypeError("config.includeSymbols must be a boolean");if(void 0!==a&&"boolean"!=typeof a)throw new TypeError("config.allowWeirdSpacing must be a boolean");if(void 0!==l&&!Array.isArray(l))throw new TypeError("config.emojiSet must be an array of strings");if(void 0!==u&&!Array.isArray(u))throw new TypeError("config.wordSet must be an array of strings");if(void 0!==c&&!["mixed","readable","chaotic","natural"].includes(c))throw new RangeError('config.mode must be one of: "mixed", "readable", "chaotic", "natural');if(void 0!==h){if("object"!=typeof h||null===h)throw new TypeError("config.grammar must be an object");const{templates:e,nouns:t,verbs:r,adjectives:n}=h;if(void 0!==e&&!Array.isArray(e))throw new TypeError("config.grammar.templates must be an array of strings");if(void 0!==t&&!Array.isArray(t))throw new TypeError("config.grammar.nouns must be an array of strings");if(void 0!==r&&!Array.isArray(r))throw new TypeError("config.grammar.verbs must be an array of strings");if(void 0!==n&&!Array.isArray(n))throw new TypeError("config.grammar.adjectives must be an array of strings")}if(void 0!==d&&"boolean"!=typeof d)throw new TypeError("config.repeatWords must be a boolean");if(void 0!==p&&!["inline","end","none"].includes(p))throw new RangeError('config.emojiPlacement must be one of: "inline", "end", "none"');if(void 0!==f){if("object"!=typeof f)throw new TypeError("config.paragraphs must be an object or null");const{min:e,max:t}=f;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.paragraphs.min must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.paragraphs.max must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.paragraphs.min cannot be greater than config.paragraphs.max")}if(void 0!==m){if("object"!=typeof m||null===m)throw new TypeError("config.line must be an object");const{minLength:e,maxLength:t,emojiChance:r}=m;if(void 0!==e&&(!Number.isInteger(e)||e<1))throw new TypeError("config.line.minLength must be an integer >= 1");if(void 0!==t&&(!Number.isInteger(t)||t<1))throw new TypeError("config.line.maxLength must be an integer >= 1");if(void 0!==e&&void 0!==t&&e>t)throw new RangeError("config.line.minLength cannot be greater than config.line.maxLength");if(void 0!==r&&("number"!=typeof r||r<0||r>1))throw new RangeError("config.line.emojiChance must be a number between 0 and 1")}this.config.emojiSet=[...Ct.#gt],this.config.wordSet=[...Ct.#mt],this.config.grammar.templates=[...Ct.#vt],this.config.grammar.nouns=[...Ct.#yt],this.config.grammar.verbs=[...Ct.#wt],this.config.grammar.adjectives=[...Ct.#bt],Object.assign(this.config,e)}configure(e={}){return Object.assign(this.config,e),this}setGrammarTemplates(...e){return this.config.grammar.templates=e.flat(),this}addGrammarTemplates(...e){return this.config.grammar.templates.push(...e.flat()),this}setGrammarNouns(...e){return this.config.grammar.nouns=e.flat(),this}addGrammarNouns(...e){return this.config.grammar.nouns.push(...e.flat()),this}setGrammarVerbs(...e){return this.config.grammar.verbs=e.flat(),this}addGrammarVerbs(...e){return this.config.grammar.verbs.push(...e.flat()),this}setGrammarAdjectives(...e){return this.config.grammar.adjectives=e.flat(),this}addGrammarAdjectives(...e){return this.config.grammar.adjectives.push(...e.flat()),this}removeGrammarTemplates(...e){const t=new Set(e.flat());return this.config.grammar.templates=this.config.grammar.templates.filter(e=>!t.has(e)),this}removeGrammarNouns(...e){const t=new Set(e.flat());return this.config.grammar.nouns=this.config.grammar.nouns.filter(e=>!t.has(e)),this}removeGrammarVerbs(...e){const t=new Set(e.flat());return this.config.grammar.verbs=this.config.grammar.verbs.filter(e=>!t.has(e)),this}removeGrammarAdjectives(...e){const t=new Set(e.flat());return this.config.grammar.adjectives=this.config.grammar.adjectives.filter(e=>!t.has(e)),this}setWords(...e){return this.config.wordSet=e.flat(),this}addWords(...e){return this.config.wordSet.push(...e.flat()),this}removeWords(...e){const t=new Set(e.flat());return this.config.wordSet=this.config.wordSet.filter(e=>!t.has(e)),this}setEmojis(...e){return this.config.emojiSet=e.flat(),this}addEmojis(...e){return this.config.emojiSet.push(...e.flat()),this}removeEmojis(...e){const t=new Set(e.flat());return this.config.emojiSet=this.config.emojiSet.filter(e=>!t.has(e)),this}_getRandomItem(e){return e[Math.floor(Math.random()*e.length)]}_generateChunk(){const{wordSet:e,emojiSet:t,includeNumbers:r,includeSymbols:n,useEmojis:i,readable:o,mode:s,emojiPlacement:a}=this.config;if("natural"===s)return this._generateNaturalSentence();const l=[];return(o||"readable"===s||"mixed"===s)&&l.push(this._getRandomItem(e)),"chaotic"!==s&&"mixed"!==s||l.push(Math.random().toString(36).slice(2)),r&&l.push(Math.floor(99999*Math.random()).toString()),n&&l.push(this._getRandomItem(this.symbols)),"inline"===a&&i&&t.length&&l.push(this._getRandomItem(t)),this._getRandomItem(l)}_generateNaturalSentence(){const{templates:e,nouns:t,verbs:r,adjectives:n}=this.config.grammar;return this._getRandomItem(e).replace(/{noun}/g,()=>this._getRandomItem(t)).replace(/{verb}/g,()=>this._getRandomItem(r)).replace(/{adj}/g,()=>this._getRandomItem(n))}_generateLine(e,t){const{allowWeirdSpacing:r,repeatWords:n,readable:i,emojiSet:o,useEmojis:s,emojiPlacement:a,line:l}=this.config,u=[];for(t??=new Set;u.join(" ").length<e;){let e=this._generateChunk();!n&&t.has(e)||(t.add(e),r&&(Math.random()<.1&&(e="\n"+e),Math.random()<.1&&(e=" "+e),Math.random()<.05&&(e=e.toUpperCase())),u.push(e))}let c=u.join(i?" ":"");return"end"===a&&s&&o.length&&Math.random()<(l?.emojiChance||0)&&(c+=" "+this._getRandomItem(o)),c}_generateParagraphLines(e){const{line:t}=this.config,r=[],n=new Set;let i=0;for(;i<e;){const o=Math.floor(Math.random()*(t.maxLength-t.minLength+1)+t.minLength),s=Math.min(o,e-i);r.push(this._generateLine(s,n)),i+=s}return r}generate(){const{minLength:e,maxLength:t,paragraphs:r}=this.config,n=Math.floor(Math.random()*(t-e+1))+e;if(r&&"object"==typeof r){const e=Math.floor(Math.random()*(r.max-r.min+1))+r.min,t=Math.floor(n/e),i=[];for(let r=0;r<e;r++){const e=this._generateParagraphLines(t);i.push(e.join("\n"))}return i.join("\n\n")}return this._generateParagraphLines(n).join("\n")}}const Mt=Ct,Lt=class{#Tt=new Map;#St=10;#xt=!1;#At(e,t){if("string"==typeof e)return[e];if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return e;throw new TypeError(`${t}(event): event must be a string or string[]`)}setThrowOnMaxListeners(e){if("boolean"!=typeof e)throw new TypeError("setThrowOnMaxListeners(value): value must be a boolean");this.#xt=e}getThrowOnMaxListeners(){return this.#xt}#It(e,t,{once:r=!1}={}){let n=this.#Tt.get(e);Array.isArray(n)||(n=[],this.#Tt.set(e,n)),n.unshift({handler:t,config:{once:r}});const i=this.#St;if(i>0&&n.length>i){const t=`Possible memory leak detected. ${n.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#xt)throw new Error(t);console.warn(t)}}prependListener(e,t){const r=this.#At(e,"prependListener");if("function"!=typeof t)throw new TypeError("prependListener(event, handler): handler must be a function");for(const e of r)this.#It(e,t)}prependListenerOnce(e,t){const r=this.#At(e,"prependListenerOnce");if("function"!=typeof t)throw new TypeError("prependListenerOnce(event, handler): handler must be a function");const n=[];for(const e of r){const r=(...n)=>{this.off(e,r),t(...n)};this.#It(e,r,{once:!0}),n.push(r)}return n}#Ct(e,t,{once:r=!1}={}){const n=this.#At(e,"on");for(const e of n){let n=this.#Tt.get(e);Array.isArray(n)||(n=[],this.#Tt.set(e,n)),n.push({handler:t,config:{once:r}});const i=this.#St;if(i>0&&n.length>i){const t=`Possible memory leak detected. ${n.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#xt)throw new Error(t);console.warn(t)}}}on(e,t){if("function"!=typeof t)throw new TypeError("on(event, handler): handler must be a function");return this.#Ct(e,t)}once(e,t){const r=this.#At(e,"once");if("function"!=typeof t)throw new TypeError("once(event, handler): handler must be a function");const n=[];for(const e of r){const r=(...n)=>{this.off(e,r),t(...n)};this.#Ct(e,r,{once:!0}),n.push(r)}return n}appendListener(e,t){return this.on(e,t)}appendListenerOnce(e,t){return this.once(e,t)}off(e,t){const r=this.#At(e,"off");if("function"!=typeof t)throw new TypeError("off(event, handler): handler must be a function");for(const e of r){const r=this.#Tt.get(e);if(!Array.isArray(r))continue;const n=r.findIndex(e=>e.handler===t);-1!==n&&r.splice(n,1),0===r.length&&this.#Tt.delete(e)}}offAll(e){const t=this.#At(e,"offAll");for(const e of t)this.#Tt.delete(e)}offAllTypes(){this.#Tt.clear()}listenerCount(e){if("string"!=typeof e)throw new TypeError("listenerCount(event): event name must be a string");const t=this.#Tt.get(e);return Array.isArray(t)?t.length:0}listeners(e){if("string"!=typeof e)throw new TypeError("listeners(event): event name must be a string");const t=this.#Tt.get(e);return Array.isArray(t)?[...t].filter(e=>!e.config.once).map(e=>e.handler):[]}onceListeners(e){if("string"!=typeof e)throw new TypeError("onceListeners(event): event name must be a string");const t=this.#Tt.get(e);return Array.isArray(t)?[...t].filter(e=>e.config.once).map(e=>e.handler):[]}allListeners(e){if("string"!=typeof e)throw new TypeError("allListeners(event): event name must be a string");const t=this.#Tt.get(e);return Array.isArray(t)?[...t].map(e=>e.handler):[]}eventNames(){return[...this.#Tt.keys()]}emit(e,...t){const r=this.#At(e,"emit"),n=[];for(const e of r){const r=this.#Tt.get(e);Array.isArray(r)&&0!==r.length?(r.forEach(e=>e.handler(...t)),n.push(!0)):n.push(!1)}return n}setMaxListeners(e){if(!Number.isInteger(e)||e<0)throw new TypeError("setMaxListeners(n): n must be a non-negative integer");this.#St=e}getMaxListeners(){return this.#St}};class Nt{static Utils={...e,TinyHtml:mt};#Mt=new Lt;setThrowOnMaxListeners(e){return this.#Mt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Mt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Mt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Mt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Mt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Mt.appendListenerOnce(e,t)}on(e,t){return this.#Mt.on(e,t)}once(e,t){return this.#Mt.once(e,t)}off(e,t){return this.#Mt.off(e,t)}offAll(e){return this.#Mt.offAll(e)}offAllTypes(){return this.#Mt.offAllTypes()}listenerCount(e){return this.#Mt.listenerCount(e)}listeners(e){return this.#Mt.listeners(e)}onceListeners(e){return this.#Mt.onceListeners(e)}allListeners(e){return this.#Mt.allListeners(e)}eventNames(){return this.#Mt.eventNames()}emit(e,...t){return this.#Mt.emit(e,...t)}setMaxListeners(e){return this.#Mt.setMaxListeners(e)}getMaxListeners(){return this.#Mt.getMaxListeners()}#Lt=new WeakMap;#Nt=new WeakMap;#kt=new WeakMap;#Dt=new WeakMap;#_t=new WeakMap;#jt=new WeakMap;#Rt=null;#Ot=null;#Ht=new Set(["IMG","IFRAME","VIDEO"]);#Bt=null;#$t=!1;#Pt=!1;#Ft=!1;#Wt=!1;#zt=!1;#qt=!1;#Vt=!1;#Kt=!1;#Ut="";#Jt=!1;#ye=!1;#Gt=!1;#Yt=!1;#Xt=!1;#Qt=!1;#Zt=0;#er=0;#tr=0;#rr=0;#nr=0;#ir;#$;#or=new Set;constructor(e,{extraScrollBoundary:t=0,autoScrollBottom:r=!0,observeMutations:n=!0,preserveScrollOnLayoutShift:i=!0,debounceTime:o=100,querySelector:s=null,attributeFilter:a=["class","style","src","data-*","height","width"]}={}){if(!(e instanceof Element||e===window))throw new TypeError("TinySmartScroller: 'target' must be a DOM Element or 'window', but got "+typeof e);if("number"!=typeof t||Number.isNaN(t))throw new TypeError(`TinySmartScroller: 'extraScrollBoundary' must be a valid number, received ${t}`);if("boolean"!=typeof r)throw new TypeError("TinySmartScroller: 'autoScrollBottom' must be a boolean, received "+typeof r);if("boolean"!=typeof n)throw new TypeError("TinySmartScroller: 'observeMutations' must be a boolean, received "+typeof n);if("boolean"!=typeof i)throw new TypeError("TinySmartScroller: 'preserveScrollOnLayoutShift' must be a boolean, received "+typeof i);if("number"!=typeof o||o<0||Number.isNaN(o))throw new TypeError(`TinySmartScroller: 'debounceTime' must be a non-negative number, received ${o}`);if(null!==s&&"string"!=typeof s)throw new TypeError("TinySmartScroller: 'querySelector' must be a string or null, received "+typeof s);if(!(null===a||Array.isArray(a)||a instanceof Set))throw new TypeError("TinySmartScroller: 'attributeFilter' must be an array, Set, or null. Got "+typeof a);let l;this.#$=e instanceof Window?document.documentElement:e,this.#Jt=e instanceof Window,this.#Yt=r,this.#Xt=n,this.#Qt=i,this.#Zt=o,this.#nr=t,this.#Ut=s||"",this.#ir=new Set(a||void 0),this.#Bt=()=>{this._scrollDataUpdater(),clearTimeout(l),l=setTimeout(()=>this._onScroll(),this.#Zt)},(this.#Jt?window:this.#$).addEventListener("scroll",this.#Bt,{passive:!0}),this.#Xt&&(this._observeMutations(),this._observeResizes(this.#$.children)),this._scrollDataUpdater()}getSimpleOnHeight(e=[]){if(!Array.isArray(e))throw new TypeError("getSimpleOnHeight(filter): filter must be an array of tag names");return(t,r,n)=>{if(e.length>0&&!e.includes(t.tagName)||n.now!==n.old)return;const i=r.old;return{height:r.now.height-i.height,width:0}}}addSimpleOnHeight(e){if(!Array.isArray(e))throw new TypeError("addSimpleOnHeight(filter): filter must be an array of tag names");const t=this.getSimpleOnHeight(e);return this.onSize(t),t}getLoadTags(){return Array.from(this.#Ht)}addLoadTag(e){if("string"!=typeof e)throw new TypeError("addLoadTag(tag): tag must be a string");this.#Ht.add(e.toUpperCase())}removeLoadTag(e){if("string"!=typeof e)throw new TypeError("removeLoadTag(tag): tag must be a string");this.#Ht.delete(e.toUpperCase())}hasLoadTag(e){if("string"!=typeof e)throw new TypeError("hasLoadTag(tag): tag must be a string");return this.#Ht.has(e.toUpperCase())}resetLoadTags(e=!1){if("boolean"!=typeof e)throw new TypeError("resetLoadTags(addDefault): addDefault must be a boolean");this.#Ht.clear(),e&&(this.#Ht.add("IMG"),this.#Ht.add("IFRAME"),this.#Ht.add("VIDEO"))}getAttributeFilters(){return Array.from(this.#ir)}addAttributeFilter(e){if("string"!=typeof e)throw new TypeError("addAttributeFilter(attr): attr must be a string");this.#ir.add(e)}removeAttributeFilter(e){if("string"!=typeof e)throw new TypeError("removeAttributeFilter(attr): attr must be a string");this.#ir.delete(e)}hasAttributeFilter(e){if("string"!=typeof e)throw new TypeError("hasAttributeFilter(attr): attr must be a string");return this.#ir.has(e)}resetAttributeFilters(e=!1){if("boolean"!=typeof e)throw new TypeError("resetAttributeFilters(addDefault): addDefault must be a boolean");this.#ir.clear(),e&&["class","style","src","data-*","height","width"].forEach(e=>this.#ir.add(e))}onSize(e){if(!this.#ye){if("function"!=typeof e)throw new TypeError("onSize(handler): handler must be a function");this.#or.add(e)}}offSize(e){if(!this.#ye){if("function"!=typeof e)throw new TypeError("offSize(handler): handler must be a function");this.#or.delete(e)}}_scrollDataUpdater(){const e=new Map;return this.#$.querySelectorAll(this.#Ut||"*").forEach(t=>{const r=this.#kt.get(t)??!1;this.#Dt.set(t,r);const n=mt.isInContainer(this.#$,t);this.#kt.set(t,n),e.set(t,{oldIsVisible:r,isVisible:n})}),e}_onScroll(){if(this.#ye)return;const e=this._scrollDataUpdater(),t=this.#$,r=t.scrollTop,n=t.scrollHeight,i=t.clientHeight,o={scrollTop:r,scrollHeight:n,clientHeight:i};let s=null,a=null;const l=0===r,u=r+i>=n-1,c=r<=0+this.#nr,h=r+i>=n-1-this.#nr;l&&u?s="all":l?s="top":u&&(s="bottom"),c&&h?a="all":c?a="top":h&&(a="bottom"),this.#Pt=this.#qt??!1,this.#$t=this.#zt??!1,this.#Ft=this.#Vt??!1,this.#Wt=this.#Kt??!1,this.#qt=l,this.#zt=u,this.#Vt=c,this.#Kt=h,this.#Gt=!(this.#Yt&&this.#zt),this.#rr=n-r-i,this.emit("onScrollBoundary",{status:s,...o,scrollCache:e}),this.emit("onExtraScrollBoundary",{status:a,...o,scrollCache:e}),this.#Gt?this.emit("onScrollPause",{...o,scrollCache:e}):this.emit("onAutoScroll",{...o,scrollCache:e})}_fixScroll(e=[]){if(this.#ye)return;if(!Array.isArray(e))throw new TypeError("_fixScroll: targets must be an array of Elements");const t=this.#$.scrollHeight,r=this.#$.scrollTop,n=this.#$.scrollHeight-this.#$.scrollTop-this.#$.clientHeight,i=this.#$.scrollHeight-t,o=()=>{const t={height:0,width:0};for(const r of e){const e=this.#Lt.get(r)||{height:0,width:0},n=this.#Nt.get(r)||{height:0,width:0};this.#or.forEach(i=>{const o=i(r,{old:e,now:n},{old:this.#tr,now:this.#er});if(this.#kt.get(r)||this.#_t.get(r)){if(void 0!==o&&"object"!=typeof o)throw new Error("_fixScroll: size filter must return an object or undefined");if(void 0===o)return;t.height=o.height,t.width=o.width}})}if("number"!=typeof t.height&&t.height<0)throw new Error("_fixScroll: invalid scrollSize.height value");if("number"!=typeof t.width&&t.width<0)throw new Error("_fixScroll: invalid scrollSize.width value");if(0!==t.height||0!==t.width)for(const t of e)this.#_t.set(t,this.#kt.get(t)??!1),this.#jt.set(t,this.#Dt.get(t)??!1);return t};if(this.#tr>0&&mt.hasScroll(this.#$).v&&this.#Yt&&this.#Qt&&!this.#zt&&!this.#qt){const e=o();this.#$.scrollTop=r+i+e.height,e.width>0&&(this.#$.scrollLeft=this.#$.scrollLeft+e.width)}else!this.#Gt&&this.#Yt?(o(),this.scrollToBottom()):this.#Yt||this.#zt||(o(),this.#$.scrollTop=this.#$.scrollHeight-this.#$.clientHeight-n)}_observeMutations(){this.#Ot=new MutationObserver(e=>{this.#ye||(this._scrollDataUpdater(),this.#tr=this.#er,this.#er=this.#$.childElementCount,e.forEach(e=>{e.addedNodes.forEach(e=>{if(e instanceof Element&&1===e.nodeType&&(this._observeResizes([e]),this._listenLoadEvents(e),this.#Ut)){const t=e.querySelectorAll(this.#Ut);this._observeResizes(t),this._listenLoadEvents(t)}})}),this._fixScroll())}),this.#Ot.observe(this.#$,{childList:!0,subtree:!0,attributes:!0,attributeFilter:this.#ir.size>0?Array.from(this.#ir):void 0})}_observeResizes(e){this.#Rt||(this.#Rt=new ResizeObserver(e=>{if(this.#ye)return;this._scrollDataUpdater();const t=[];for(const r of e){const e=r.target,n=this.#Nt.get(e);n&&this.#Lt.set(e,n);const{width:i,height:o}=r.contentRect;this.#Nt.set(e,{width:i,height:o}),t.push(e)}this._fixScroll(t)})),Array.from(e).forEach(e=>{if(!this.#Rt)throw new Error("_observeResizes: ResizeObserver instance is not initialized");this.#Rt.observe(e)})}_listenLoadEvents(e){this.#ye||(e instanceof NodeList?Array.from(e):[e]).forEach(e=>{this.#Ht.has(e.tagName)&&(e.complete||e.addEventListener("load",()=>{this._scrollDataUpdater(),!this.#Gt&&this.#Yt&&this.scrollToBottom()}))})}get target(){return this.#$}getOldSize(e){return this.#Lt.get(e)??null}getNewSize(e){return this.#Nt.get(e)??null}wasVisible(e){return this.#Dt.get(e)??!1}isVisible(e){return this.#kt.get(e)??!1}wasTimedVisible(e){return this.#jt.get(e)??!1}isTimedVisible(e){return this.#_t.get(e)??!1}setExtraScrollBoundary(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("setExtraScrollBoundary(value): value must be a valid number");this.#nr=e}getExtraScrollBoundary(){return this.#nr}getLastKnownScrollBottomOffset(){return this.#rr}scrollToBottom(){this.#$.scrollTop=this.#$.scrollHeight}scrollToTop(){this.#$.scrollTop=0}isAtCustomBottom(){return this.#Kt}isAtCustomTop(){return this.#Vt}isAtBottom(){return this.#zt}isAtTop(){return this.#qt}isPastAtBottom(){return this.#$t}isPastAtTop(){return this.#Pt}isPastAtCustomTop(){return this.#Ft}isPastAtCustomBottom(){return this.#Wt}isScrollPaused(){return this.#Gt}isWindow(){return this.#Jt}isDestroyed(){return this.#ye}getAutoScrollBottom(){return this.#Yt}getObserveMutations(){return this.#Xt}getPreserveScrollOnLayoutShift(){return this.#Qt}getDebounceTime(){return this.#Zt}getElemAmount(){return this.#er}getPrevElemAmount(){return this.#tr}getQuerySelector(){return this.#Ut}destroy(){if(this.#ye)return;this.#ye=!0,this.#Ot&&(this.#Ot.disconnect(),this.#Ot=null),this.#Rt&&(this.#Rt.disconnect(),this.#Rt=null);const e=this.#Jt?window:this.#$;this.#Bt&&e.removeEventListener("scroll",this.#Bt),this.#Lt=new WeakMap,this.#Nt=new WeakMap,this.#kt=new WeakMap,this.#Dt=new WeakMap,this.#_t=new WeakMap,this.#jt=new WeakMap,this.#Mt.offAllTypes(),this.#or.clear(),this.#Ht.clear()}}const kt=Nt,Dt=class{#G;#sr;#ar;constructor(e,{openTag:t="[",closeTag:r="]"}={}){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new TypeError("Element must be an input or textarea.");if("string"!=typeof t)throw new TypeError("openTag must be a string.");if("string"!=typeof r)throw new TypeError("closeTag must be a string.");this.#G=e,this.#sr=t,this.#ar=r}getOpenTag(){return this.#sr}getCloseTag(){return this.#ar}setOpenTag(e){if("string"!=typeof e)throw new TypeError("Open tag must be a string.");this.#sr=e}setCloseTag(e){if("string"!=typeof e)throw new TypeError("Close tag must be a string.");this.#ar=e}ensureFocus(){return document.activeElement!==this.#G&&this.#G.focus(),this}focus(){return this.#G.focus(),this}getSelectionRange(){return{start:this.#G.selectionStart??NaN,end:this.#G.selectionEnd??NaN}}setSelectionRange(e,t,r=!0){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("start and end must be numbers.");if("boolean"!=typeof r)throw new TypeError("preserveScroll must be a boolean.");const n=this.#G.scrollTop,i=this.#G.scrollLeft;return this.#G.setSelectionRange(e,t),r&&(this.#G.scrollTop=n,this.#G.scrollLeft=i),this}getValue(){return this.#G.value}setValue(e){if("string"!=typeof e)throw new TypeError("Value must be a string.");return this.#G.value=e,this}getSelectedText(){const{start:e,end:t}=this.getSelectionRange();return this.#G.value.slice(e,t)}insertText(e,{newCursor:t="end",autoSpacing:r=!1,autoSpaceLeft:n=r,autoSpaceRight:i=r}={}){if("string"!=typeof e)throw new TypeError("Text must be a string.");if(!["start","end","preserve"].includes(t))throw new TypeError("newCursor must be one of 'start', 'end', or 'preserve'.");if("boolean"!=typeof r)throw new TypeError("autoSpacing must be a boolean.");if("boolean"!=typeof n)throw new TypeError("autoSpaceLeft must be a boolean.");if("boolean"!=typeof i)throw new TypeError("autoSpaceRight must be a boolean.");const{start:o,end:s}=this.getSelectionRange(),a=this.#G.value,l=a[o-1]||"",u=a[s]||"",c=`${n&&l&&!/\s/.test(l)?" ":""}${e}${i&&u&&!/\s/.test(u)?" ":""}`,h=a.slice(0,o)+c+a.slice(s);this.setValue(h);let d=o;return"end"===t?d=o+c.length:"preserve"===t&&(d=o),this.setSelectionRange(d,d),this}deleteSelection(){return this.insertText(""),this}transformSelection(e){if("function"!=typeof e)throw new TypeError("transformer must be a function.");const{start:t}=this.getSelectionRange(),r=e(this.getSelectedText());return this.insertText(r),this.setSelectionRange(t,t+r.length),this}surroundSelection(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("prefix and suffix must be strings.");const r=this.getSelectedText();return this.insertText(`${e}${r}${t}`),this}moveCaret(e){if("number"!=typeof e)throw new TypeError("offset must be a number.");const{start:t}=this.getSelectionRange(),r=Math.max(0,t+e);return this.setSelectionRange(r,r),this}selectAll(){return this.setSelectionRange(0,this.#G.value.length),this}expandSelection(e,t){if("number"!=typeof e||"number"!=typeof t)throw new TypeError("before and after must be numbers.");const{start:r,end:n}=this.getSelectionRange(),i=Math.max(0,r-e),o=Math.min(this.#G.value.length,n+t);return this.setSelectionRange(i,o),this}replaceAll(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const r=this.#G.value.replace(e,t);return this.setValue(r),this}replaceInSelection(e,t){if(!(e instanceof RegExp))throw new TypeError("regex must be a RegExp.");if("function"!=typeof t)throw new TypeError("replacer must be a function.");const{start:r,end:n}=this.getSelectionRange(),i=this.#G.value,o=i.slice(r,n).replace(e,t),s=i.slice(0,r)+o+i.slice(n);return this.setValue(s),this.setSelectionRange(r,r+o.length),this}toggleCode(e){if("string"!=typeof e)throw new TypeError("codeName must be a string.");const t=this.getSelectedText();if(t.startsWith(e)&&t.endsWith(e)){const r=t.slice(e.length,t.length-e.length);this.insertText(r)}else this.insertText(`${e}${t}${e}`);return this}_insertAttr(e){let t="";if(Array.isArray(e)){if(!e.every(e=>"string"==typeof e))throw new TypeError("All entries in attributes array must be strings.");t=e.map(e=>`${e}`).join(" ")}else{if("object"!=typeof e||null===e)throw new TypeError("attributes must be an object or an array of strings.");t=Object.entries(e).map(([e,t])=>{if("string"!=typeof t)throw new TypeError("All entries in attributes object must be strings.");return`${e}${t.length>0?`="${t}"`:""}`}).join(" ")}return t}wrapWithTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),n=r?`${this.#sr}${e} ${r}${this.#ar}`:`${this.#sr}${e}${this.#ar}`,i=`${this.#sr}/${e}${this.#ar}`;return this.surroundSelection(n,i),this}insertTag(e,t="",r={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");if("string"!=typeof t)throw new TypeError("content must be a string.");const n=this._insertAttr(r),i=n?`${this.#sr}${e} ${n}${this.#ar}`:`${this.#sr}${e}${this.#ar}`,o=`${this.#sr}/${e}${this.#ar}`;return this.insertText(`${i}${t}${o}`),this}insertSelfClosingTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this._insertAttr(t),n=r?`${this.#sr}${e} ${r}${this.#ar}`:`${this.#sr}${e}${this.#ar}`;return this.insertText(n),this}toggleTag(e,t={}){if("string"!=typeof e)throw new TypeError("tagName must be a string.");const r=this.getSelectedText(),n=new RegExp(`^\\[${e}(\\s+[^\\]]*)?\\]`),i=new RegExp(`\\[/${e}\\]$`),o=n.test(r),s=i.test(r);if(o&&s){const e=r.replace(n,"").replace(i,"");this.insertText(e)}else{const n=this._insertAttr(t),i=n?`${this.#sr}${e} ${n}${this.#ar}`:`${this.#sr}${e}${this.#ar}`,o=`${this.#sr}/${e}${this.#ar}`;this.insertText(`${i}${r}${o}`)}return this}},_t=class{#lr=!1;#ur=!1;#cr=null;#hr=null;constructor(){void 0!==navigator.clipboard&&null!==navigator.clipboard&&(this.#ur=!0,this.#cr=e=>navigator.clipboard.writeText(e),this.#hr=e=>navigator.clipboard.write([new ClipboardItem({[e.type]:e})])),this.#lr=void 0!==document.execCommand&&null!==document.execCommand}setCopyText(e){if("function"!=typeof e)throw new TypeError("setCopyText expected a function that returns Promise<void>.");this.#cr=e}setCopyBlob(e){if("function"!=typeof e)throw new TypeError("setCopyBlob expected a function that returns Promise<void>.");this.#hr=e}copyText(e){if("string"!=typeof e)throw new TypeError("copyText expected a string.");if(this.#cr)return this.#cr(e);if(this.#lr){const t=document.body,r=document.createElement("input");return r.style.position="fixed",r.style.opacity="0",r.value=e,t.append(r),r.select(),r.setSelectionRange(0,99999),document.execCommand("Copy"),r.remove(),new Promise(e=>e(void 0))}throw new Error("Clipboard API not found!")}copyBlob(e){if(!(e instanceof Blob))throw new TypeError("copyBlob expected a Blob instance.");return new Promise((t,r)=>{if(this.#hr)return this.#hr(e).then(t).catch(r);throw new Error("Clipboard API not found!")})}_handleBlob(e,t){return t.getType(e)}_handleText(e,t){return this._handleBlob(e,t).then(e=>e.text())}_readData(e=0,t=null,r=null,n=!1){return new Promise((i,o)=>{this._read(e).then(s=>{if(!s)return i(null);const a=[];let l=!0;const u=async(e,i)=>{if(l)if(null!==t&&"custom"!==t||"string"!=typeof r||!(!n&&e.startsWith(r)||n&&e===r))if(null!==t&&"text"!==t||"text/plain"!==e){if(null===t){l=!1;const t=await this._handleBlob(e,i);t&&a.push(t)}}else{l=!1;const t=await this._handleText(e,i);t&&a.push(t)}else{l=!1;const t=await this._handleBlob(e,i);t&&a.push(t)}},c=[],h=e=>{if(!(e instanceof ClipboardItem))throw new Error("Expected ClipboardItem when reading data.");for(const t in e.types)c.push(u(e.types[t],e))};if("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)&&e>-1)h(s),Promise.all(c).then(()=>{a[0]?i(a[0]):i(null)}).catch(o);else if(Array.isArray(s)){for(const e in s)h(s[e]);Promise.all(c).then(()=>i(a)).catch(o)}}).catch(o)})}async readText(e=0){const t=await this._readData(e,"text");if("string"!=typeof t)throw new Error("Failed to read text: expected string result.");return t}async readCustom(e=null,t=!1,r=0){const n=await this._readData(r,"custom",e,t);if(!(n instanceof Blob))throw new Error("Failed to read custom data: expected Blob.");return n}async readAllTexts(){const e=await this._readData(null,"text");if(!Array.isArray(e))throw new Error("Expected array of strings when reading all texts.");if(!e.every(e=>"string"==typeof e))throw new Error("Some values returned were not strings.");return e}async readAllCustom(e=null,t=!1){const r=await this._readData(null,"custom",e,t);if(!Array.isArray(r))throw new Error("Expected array of blobs when reading all custom items.");if(!r.every(e=>e instanceof Blob))throw new Error("Some values returned were not Blob instances.");return r}async readAllData(e=null,t=null){const r=await this._readData(null,e,t);if(!Array.isArray(r))throw new Error("Expected array result when reading all data.");return r}_read(e){return new Promise((t,r)=>{this.#ur||r(new Error("Clipboard API not found!")),navigator.clipboard.read().then(r=>{if("number"==typeof e){if(Number.isNaN(e)||!Number.isFinite(e)||e<0)throw new Error(`Invalid index value: ${e}`);r[e]?t(r[e]):t(null)}t(r)}).catch(r)})}async readIndex(e){const t=await this._read(e);if(null!==t&&!(t instanceof ClipboardItem))throw new Error(`Value at index ${e} is not a ClipboardItem.`);return t}async readAll(){const e=await this._read(null);if(!Array.isArray(e))throw new Error("Expected array result from clipboard read.");for(const t of e)if(!(t instanceof ClipboardItem))throw new Error("Invalid item type found in clipboard result.");return e}isExecCommandAvailable(){return this.#lr}isNavigatorClipboardAvailable(){return this.#ur}getCopyTextFunc(){return this.#cr}getCopyBlobFunc(){return this.#hr}};class jt{static _rca(e,t,r){let n=127,i=128;void 0===e&&(e=24),void 0===t&&(t="rgb"),!0===r&&(n=55,i=200);const o=2*Math.PI/e,s=[];for(let r=0;r<e;++r){const e=Math.sin(o*r+2)*n+i,a=Math.sin(o*r+0)*n+i,l=Math.sin(o*r+4)*n+i;switch(t){case"hex":s.push({hex:this.rgbToHex(Math.round(e),Math.round(a),Math.round(l))});break;case"rgb":s.push({r:e,g:a,b:l});break;case"hsl":const[t,r,n]=this.rgbaToHsl(Math.round(e),Math.round(a),Math.round(l));s.push({h:t,s:r,l:n})}}return s}static rcaRgb(e,t){return jt._rca(e,"rgb",t)}static rcaHsl(e,t){return jt._rca(e,"hsl",t)}static rcaHex(e,t){return jt._rca(e,"hex",t)}static randomColor(){return`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`}static parseInput(e,t){if("string"==typeof e){if((e=e.trim().toLowerCase()).startsWith("#"))return this.hexToRgba(e);if(e.startsWith("rgb"))return this.rgbStringToRgbaArray(e);if(e.startsWith("hsl"))return this.hslStringToRgbaArray(e)}if("number"==typeof e)return this.intToRgba(e);if(Array.isArray(e)&&(3===e.length||4===e.length)&&e.every(e=>"number"==typeof e)){if(t){const[t,r,n,i]=e;if(t<=360&&r<=100&&n<=100)return this.hslToRgba(t,r,n,i)}return[...e,1].slice(0,4)}throw new Error("Unsupported color format.")}static hslToInt(e,t,r){const[n,i,o]=jt.hslToRgba(e,t,r);return jt.rgbToInt(n,i,o)}static hslToHex(e,t,r){const[n,i,o]=jt.hslToRgba(e,t,r);return jt.rgbToHex(n,i,o)}static hslStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);if(!t||t.length<3)return[0,0,0,1];const[r,n,i,o=1]=t;return this.hslToRgba(r,n,i,o)}static hslToRgba(e,t,r,n=1){r/=100;const i=t=>(t+e/30)%12,o=(t/=100)*Math.min(r,1-r),s=e=>r-o*Math.max(-1,Math.min(i(e)-3,Math.min(9-i(e),1)));return[Math.round(255*s(0)),Math.round(255*s(8)),Math.round(255*s(4)),n]}static hslToRgb(e,t,r,n=1){return jt.hslToRgba(e,t,r,n).slice(0,3)}static hexToInt(e){return parseInt(e.replace(/^#/,""),16)}static hexToHsl(e){const[t,r,n,i]=jt.hexToRgba(e);return jt.rgbaToHsl(t,r,n,i)}static hexToHsla(e){const[t,r,n,i]=jt.hexToRgba(e);return jt.rgbaToHsla(t,r,n,i)}static hexToRgba(e){3===(e=e.replace(/^#/,"")).length&&(e=e.split("").map(e=>e+e).join(""));const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t,1]}static hexToRgb(e){return this.hexToRgba(e).slice(0,3)}static rgbToHex(e,t,r){return"#"+[e,t,r].map(e=>e.toString(16).padStart(2,"0")).join("")}static rgbToInt(e,t,r){return e<<16|t<<8|r}static rgbaToHsla(e,t,r,n=1){e/=255,t/=255,r/=255;const i=Math.max(e,t,r),o=Math.min(e,t,r);let s=0,a=0,l=(i+o)/2;const u=i-o;if(0!==u){switch(a=u/(1-Math.abs(2*l-1)),i){case e:s=(t-r)/u+(t<r?6:0);break;case t:s=(r-e)/u+2;break;case r:s=(e-t)/u+4}s*=60}return[Math.round(s),Math.round(100*a),Math.round(100*l),n]}static rgbaToHsl(e,t,r,n){return this.rgbaToHsla(e,t,r,n).slice(0,3)}static rgbStringToRgbaArray(e){const t=e.match(/[\d.]+/g)?.map(Number);return t?[...t,1].slice(0,4):[]}static intToHsl(e){const[t,r,n,i]=jt.intToRgba(e);return jt.rgbaToHsl(t,r,n,i)}static intToHsla(e){const[t,r,n,i]=jt.intToRgba(e);return jt.rgbaToHsla(t,r,n,i)}static intToHex(e){return"#"+e.toString(16).padStart(6,"0")}static intToRgba(e){return[e>>16&255,e>>8&255,255&e,1]}#dr="#000000";#pr=[0,0,0,0];#fr;constructor(e=null,t=!1){this.#fr=t,null!=e&&this.setColor(e)}setColor(e){this.#dr=e;const t=this.#fr&&Array.isArray(e)&&e[0]<=360&&e[1]<=100&&e[2]<=100;this.#pr=jt.parseInput(e,t)}toHslaArray(){const[e,t,r,n]=this.#pr;return jt.rgbaToHsla(e,t,r,n)}toHslString(){const[e,t,r]=this.#pr,[n,i,o]=jt.rgbaToHsl(e,t,r);return`hsl(${n}, ${i}%, ${o}%)`}toHslaString(){const[e,t,r,n]=this.#pr,[i,o,s,a]=jt.rgbaToHsla(e,t,r,n);return`hsla(${i}, ${o}%, ${s}%, ${a??1})`}toRgbaArray(){return[...this.#pr]}toRgbString(){const[e,t,r]=this.#pr;return`rgb(${e}, ${t}, ${r})`}toRgbaString(){const[e,t,r,n]=this.#pr;return`rgba(${e}, ${t}, ${r}, ${n??1})`}toHex(){const[e,t,r]=this.#pr;return jt.rgbToHex(e,t,r)}toInt(){const[e,t,r]=this.#pr;return jt.rgbToInt(e,t,r)}getOriginal(){return this.#dr}}const Rt=jt;class Ot{#mr=!1;#gr;#yr;#wr=null;#br=new Map;constructor({cooldownWatcherTime:e=5e3,allowAutoConfigChange:t=!1}={}){if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'cooldownWatcherTime' to be a positive number.");if("boolean"!=typeof t)throw new TypeError("Expected 'allowAutoConfigChange' to be a boolean.");this.#yr=e,this.#gr=t,this.setCooldownWatcherTime(e)}isDestroyed(){return this.#mr}getAllowAutoConfigChange(){return this.#gr}getCooldownWatcherTime(){return this.#yr}setAllowAutoConfigChange(e){if("boolean"!=typeof e)throw new TypeError("Expected 'value' to be a boolean.");this.#gr=e}setCooldownWatcherTime(e){if(this.#mr)throw new Error("TinyTimeout has been destroyed.");if(!Number.isFinite(e)||e<=0)throw new TypeError("Expected 'value' to be a positive number.");this.#yr=e,this.#wr&&clearInterval(this.#wr),this.#wr=setInterval(()=>{this.#br.forEach(e=>{e.now>0&&e.now--})},this.#yr)}set(e,t,r,n=null){if(this.#mr)throw new Error("TinyTimeout has been destroyed.");if("string"!=typeof e||""===e.trim())throw new TypeError("Expected 'id' to be a non-empty string.");if("function"!=typeof t)throw new TypeError("Expected 'callback' to be a function.");if(!Number.isFinite(r)||r<0)throw new TypeError("Expected 'value' to be a non-negative number.");if(null!==n&&(!Number.isFinite(n)||n<0))throw new TypeError("Expected 'limit' to be null or a non-negative number.");let i=this.#br.get(e);(!i||this.#gr&&r!==i.value)&&(i={value:r,now:0},this.#br.set(e,i));const o=i.value*i.now;return i.now++,setTimeout(t,"number"==typeof n?Math.min(o,n):o)}static waitForTrue(e,t=100){if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(!Number.isFinite(t)||t<=0)throw new TypeError("Expected 'checkInterval' to be a positive number.");return new Promise(r=>{const n=setInterval(()=>{e()&&(clearInterval(n),r())},t)})}waitForTrue(e,t=100){if(this.#mr)throw new Error("TinyTimeout has been destroyed.");if("function"!=typeof e)throw new TypeError("Expected 'getValue' to be a function.");if(null!==t&&(!Number.isFinite(t)||t<=0))throw new TypeError("Expected 'checkInterval' to be null or a positive number.");return Ot.waitForTrue(e,t??this.#yr)}destroy(){this.#mr||(this.#mr=!0,this.#wr&&clearInterval(this.#wr),this.#wr=null,this.#br.clear())}}const Ht=Ot,Bt=new Map,$t=new Map,Pt=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class Ft{#Mt=new Lt;setThrowOnMaxListeners(e){return this.#Mt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Mt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Mt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Mt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Mt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Mt.appendListenerOnce(e,t)}on(e,t){return this.#Mt.on(e,t)}once(e,t){return this.#Mt.once(e,t)}off(e,t){return this.#Mt.off(e,t)}offAll(e){return this.#Mt.offAll(e)}offAllTypes(){return this.#Mt.offAllTypes()}listenerCount(e){return this.#Mt.listenerCount(e)}listeners(e){return this.#Mt.listeners(e)}onceListeners(e){return this.#Mt.onceListeners(e)}allListeners(e){return this.#Mt.allListeners(e)}eventNames(){return this.#Mt.eventNames()}emit(e,...t){return this.#Mt.emit(e,...t)}setMaxListeners(e){return this.#Mt.setMaxListeners(e)}getMaxListeners(){return this.#Mt.getMaxListeners()}static hasJsonType(e){return Bt.has(e)&&$t.has(e)||Pt.has(e)}static registerJsonType(e,t,r,n=!1){if(Pt.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);Bt.set(e,t),$t.set(e,r),n&&Pt.add(e)}static deleteJsonType(e){if(Pt.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return Bt.delete(e)&&(t=!0),$t.delete(e)&&(t=!0),t}static encodeSpecialJson(e){if(void 0===e)return{__undefined__:!0};if(null===e)return{__null__:!0};for(const[t,r]of Bt.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,Ft.encodeSpecialJson);if(Array.isArray(e))return e.map(Ft.encodeSpecialJson);if(m(e)){const t={};for(const r in e)t[r]=Ft.encodeSpecialJson(e[r]);return t}return e}static decodeSpecialJson(e){const t=m(e);if(t){if(e.__undefined__)return;if(e.__null__)return null}if(Array.isArray(e))return e.map(Ft.decodeSpecialJson);if(t){for(const[t,r]of $t.entries())if(r.check&&r.check(e))return r.decode(e,Ft.decodeSpecialJson);const t={};for(const r in e)t[r]=Ft.decodeSpecialJson(e[r]);return t}return e}#vr=window.localStorage;#Er=null;#Tr=0;#Sr=e=>this.emit("storage",e);constructor(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#Er=`LSDB::${e}`),window.addEventListener("storage",this.#Sr)}#xr(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if("string"!=typeof this.#Er)throw new Error("TinyLocalStorage: Database key is not initialized. Set a valid dbName in the constructor.");if("number"!=typeof e||Number.isNaN(e)||e<1)throw new TypeError("TinyLocalStorage: version must be a positive number.");if("function"!=typeof t)throw new TypeError("TinyLocalStorage: onUpgrade must be a function.");const r=parseInt(localStorage.getItem(this.#Er),10)||0;if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError("TinyLocalStorage: saved version in localStorage is not a valid number.");if(e<r)throw new Error(`TinyLocalStorage: Cannot downgrade database version from ${r} to ${e}.`);e>r&&(t(r,e),localStorage.setItem(this.#Er,String(e)),this.#Tr=e)}getDbKey(){return this.#Er}getVersion(){return this.#Tr}setLocalStorage(e){if(!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#vr=e}localStorageExists(){return this.#vr instanceof Storage}#Ar(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return Ft.encodeSpecialJson(t)}setJson(e,t){if(this.#xr(e),!(m(t)||Array.isArray(t)||t instanceof Map||t instanceof Set))throw new TypeError("The storage value is not a valid JSON-compatible structure.");const r=this.#Ar(e,t);return this.emit("setJson",e,t),this.#vr.setItem(e,JSON.stringify(r))}#Ir(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#vr.getItem(e),n={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},i="function"==typeof n[t]?n[t]():null;let o;try{o=JSON.parse(r)}catch{return i}return{decoded:Ft.decodeSpecialJson(o),fallback:i}}getJson(e,t){const{decoded:r,fallback:n}=this.#Ir(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||m(r)?r:n}setDate(e,t){if(this.#xr(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#Ar(e,t);return this.emit("setDate",e,t),this.#vr.setItem(e,JSON.stringify(r))}getDate(e){const t=this.#Ir(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(this.#xr(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#Ar(e,t);return this.emit("setRegExp",e,t),this.#vr.setItem(e,JSON.stringify(r))}getRegExp(e){const t=this.#Ir(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(this.#xr(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#Ar(e,t);return this.emit("setBigInt",e,t),this.#vr.setItem(e,JSON.stringify(r))}getBigInt(e){const t=this.#Ir(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(this.#xr(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#Ar(e,t);return this.emit("setSymbol",e,t),this.#vr.setItem(e,JSON.stringify(r))}getSymbol(e){const t=this.#Ir(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return this.#Ir(e).decoded??null}setItem(e,t){if(this.#xr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#vr.setItem(e,t)}getItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#vr.getItem(e)}setString(e,t){if(this.#xr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#vr.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#vr.getItem(e);try{if(t=JSON.parse(t),!m(t)||!t.__string__||"string"!=typeof t.value)return null;t=t.value}catch{t=null}return"string"==typeof t?t:null}setNumber(e,t){if(this.#xr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#vr.setItem(e,String(t))}getNumber(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#vr.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(this.#xr(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#vr.setItem(e,String(t))}getBool(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#vr.getItem(e);if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===t)return!0;if("false"===t)return!1}return null}removeItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#vr.removeItem(e)}clearLocalStorage(){return this.#vr.clear()}destroy(){window.removeEventListener("storage",this.#Sr),this.#Mt.offAllTypes()}}Ft.registerJsonType(Map,(e,t)=>({__map__:!0,data:Array.from(e.entries()).map(([e,r])=>[e,t(r)])}),{check:e=>e.__map__,decode:(e,t)=>new Map(e.data.map(([e,r])=>[e,t(r)]))},!0),Ft.registerJsonType(Set,(e,t)=>({__set__:!0,data:Array.from(e).map(t)}),{check:e=>e.__set__,decode:(e,t)=>new Set(e.data.map(t))},!0),Ft.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),Ft.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),Ft.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),Ft.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),Ft.registerJsonType("symbol",e=>({__symbol__:!0,key:Symbol.keyFor(e)??e.description??null}),{check:e=>e.__symbol__,decode:e=>{const t=e.key;return null!=t?Symbol.for(t):Symbol()}},!0);const Wt=Ft,zt=new WeakMap,qt=class{#Mt=new Lt;setThrowOnMaxListeners(e){return this.#Mt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Mt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Mt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Mt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Mt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Mt.appendListenerOnce(e,t)}on(e,t){return this.#Mt.on(e,t)}once(e,t){return this.#Mt.once(e,t)}off(e,t){return this.#Mt.off(e,t)}offAll(e){return this.#Mt.offAll(e)}offAllTypes(){return this.#Mt.offAllTypes()}listenerCount(e){return this.#Mt.listenerCount(e)}listeners(e){return this.#Mt.listeners(e)}onceListeners(e){return this.#Mt.onceListeners(e)}allListeners(e){return this.#Mt.allListeners(e)}eventNames(){return this.#Mt.eventNames()}setMaxListeners(e){return this.#Mt.setMaxListeners(e)}getMaxListeners(){return this.#Mt.getMaxListeners()}#Cr;#Mr;#Lr;#mr=!1;#Nr=!1;#kr=[];#Dr="__tinyIframeEvent__";get secretEventName(){return this.#Dr}set secretEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#Dr=e}constructor({targetIframe:e,targetOrigin:t}={}){if(!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe" provided: expected a HTML Iframe Element, received '+typeof e);if(void 0!==t&&"string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin" provided: expected a string, received '+typeof t);if(this.#Cr=e?.contentWindow??window.parent,this.#Mr=t??window.location.origin,this.#Lr=e?"parent":"iframe",zt.has(this.#Cr))throw new Error("Duplicate window reference.");this._boundOnMessage=this.#_r.bind(this),this._boundOnceMessage=this.#jr.bind(this),"complete"===this.#Cr.document.readyState||"interactive"===this.#Cr.document.readyState?this.#jr():(this.#Cr.addEventListener("load",this._boundOnceMessage,!1),this.#Cr.addEventListener("DOMContentLoaded",this._boundOnceMessage,!1)),window.addEventListener("message",this._boundOnMessage,!1),zt.set(this.#Cr,this)}#jr(){this.#Nr||(this.#Nr=!0,this.#Rr())}#_r(e){const{data:t,source:r}=e;if(!m(t)||!t[this.#Dr])return;const{eventName:n,payload:i,direction:o}=t;r===this.#Cr&&("iframe"===this.#Lr&&"iframe"!==o||"parent"===this.#Lr&&"parent"!==o||this.#Mt.emit(n,i,e))}emit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#mr)throw new Error("Cannot emit: instance has been destroyed.");const r={[this.#Dr]:!0,eventName:e,payload:t,direction:"parent"===this.#Lr?"iframe":"parent"};this.#Nr?this.#Cr.postMessage(r,this.#Mr):this.#kr.push(r)}#Rr(){for(;this.#kr.length;){const e=this.#kr.shift();e&&this.#Cr.postMessage(e,this.#Mr)}}isDestroyed(){return this.#mr}destroy(){this.#mr=!0,window.removeEventListener("message",this._boundOnMessage),this.#Cr.removeEventListener("load",this._boundOnceMessage,!1),this.#Cr.removeEventListener("DOMContentLoaded",this._boundOnceMessage,!1),this.#Mt.offAllTypes(),this.#kr=[],zt.delete(this.#Cr)}},Vt=new WeakMap,Kt=class{#Mt=new Lt;setThrowOnMaxListeners(e){return this.#Mt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Mt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Mt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Mt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Mt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Mt.appendListenerOnce(e,t)}on(e,t){return this.#Mt.on(e,t)}once(e,t){return this.#Mt.once(e,t)}off(e,t){return this.#Mt.off(e,t)}offAll(e){return this.#Mt.offAll(e)}offAllTypes(){return this.#Mt.offAllTypes()}listenerCount(e){return this.#Mt.listenerCount(e)}listeners(e){return this.#Mt.listeners(e)}onceListeners(e){return this.#Mt.onceListeners(e)}allListeners(e){return this.#Mt.allListeners(e)}eventNames(){return this.#Mt.eventNames()}setMaxListeners(e){return this.#Mt.setMaxListeners(e)}getMaxListeners(){return this.#Mt.getMaxListeners()}#Or;#Mr;#kr=[];#Nr=!1;#Hr=!1;#Br=null;#$r="__TNE_READY__";#Pr="__TNE_ROUTE__";get readyEventName(){return this.#$r}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#$r=e}get routeEventName(){return this.#Pr}set routeEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#Pr=e}constructor({targetOrigin:e,url:t,name:r,features:n}={}){if("string"==typeof r&&"_blank"===r)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==n&&"string"!=typeof n)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#Or=window.opener:(this.#Or="string"==typeof t?window.open(t,r,n):t,this.#Hr=!0),!this.#Or||Vt.has(this.#Or))throw new Error("Invalid or duplicate window reference.");this.#Mr=e??window.location.origin,this._handleMessage=this.#Fr.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#Hr||(this.#Wr(this.#$r,null),this.#zr())}getWin(){return this.#Or}#Fr(e){if(!e.source||this.#Or&&e.source!==this.#Or)return;const{type:t,route:r,payload:n}=e.data||{};if(t===this.#$r)return this.#Nr=!0,this.#Rr(),this.#zr(),void(this.#Hr&&this.#Wr(this.#$r,null));t===this.#Pr&&this.#Mt.emit(r,n,e)}#Rr(){for(;this.#kr.length;){const e=this.#kr.shift();if(e){const{route:t,payload:r}=e;this.emit(t,r)}}}#Wr(e,t,r=""){this.#Or&&this.#Or.closed||this.#Or?.postMessage({type:e,route:r,payload:t},this.#Mr)}close(){if(!this.#Hr)throw new Error("Only host can close the window.");this.#Or&&!this.#Or.closed&&this.#Or.close()}emit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.isDestroyed())throw new Error("Cannot emit: instance has been destroyed.");this.#Nr?this.#Wr(this.#Pr,t,e):this.#kr.push({route:e,payload:t})}isConnected(){return!(!this.#Nr||!this.#Or||this.#Or.closed)}#zr(){this.#Or&&!this.#Br&&(this.#Br=setInterval(()=>{this.#Or?.closed&&(this.#Mt.emit("WINDOW_REF_CLOSED"),this.destroy())},500),Vt.set(this.#Or,this.#Br))}onClose(e){return this.#Mt.on("WINDOW_REF_CLOSED",e)}offClose(e){return this.#Mt.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#Or}destroy(){this.#Or&&(this.#Br&&(clearInterval(this.#Br),this.#Br=null,Vt.delete(this.#Or)),window.removeEventListener("message",this._handleMessage),this.#kr=[],this.#Nr=!1,this.#Or=null,this.#Mt.offAllTypes())}},Ut=class{#qr;#Vr;#Kr;#Ur=0;#Jr=0;#Gr;#Yr=null;#Xr=null;get lineHeight(){return this.#qr}get maxRows(){return this.#Vr-1}get extraHeight(){return this.#Kr}get currentHeight(){return this.#Ur}get currentRows(){return this.#Jr}get textarea(){return this.#Gr}constructor(e,t={}){if(!(e instanceof HTMLTextAreaElement))throw new Error("TinyTextarea: Provided element is not a <textarea>.");if("object"!=typeof t||null===t)throw new TypeError("TinyTextarea: Options must be an object if provided.");if("maxRows"in t&&"number"!=typeof t.maxRows)throw new TypeError("TinyTextarea: `maxRows` must be a number.");if("extraHeight"in t&&"number"!=typeof t.extraHeight)throw new TypeError("TinyTextarea: `extraHeight` must be a number.");if("onResize"in t&&"function"!=typeof t.onResize)throw new TypeError("TinyTextarea: `onResize` must be a function.");if("onInput"in t&&"function"!=typeof t.onInput)throw new TypeError("TinyTextarea: `onInput` must be a function.");this.#Gr=e,this.#Vr=(t.maxRows??5)+1,this.#Kr=t.extraHeight??0,this.#Yr=t.onResize??null,this.#Xr=t.onInput??null,this.#qr=this.#Qr(),e.style.overflowY="hidden",e.style.resize="none",this._handleInput=()=>this.#Zr(),e.addEventListener("input",this._handleInput),this.#Zr()}#Zr(){this.#Gr.style.height="auto";const e=window.getComputedStyle(this.#Gr),t=parseFloat(e.paddingTop)||0,r=parseFloat(e.paddingBottom)||0,n=(this.#Gr.value.match(/\n/g)||[]).length,i=this.#Gr.scrollHeight,o=this.#qr*this.#Vr,s=Math.ceil(Math.min(i,o)-t-r+this.#Kr),a=this.#Vr-1,l=n<a?n+1:a;this.#Gr.style.height=`${s}px`,this.#Gr.style.overflowY=i>o?"auto":"hidden",this.#Ur=s;const u={breakLines:n,rows:l,height:s,scrollHeight:i,maxHeight:o,lineHeight:this.#qr,maxRows:a};l!==this.#Jr&&(this.#Jr=l,"function"==typeof this.#Yr&&this.#Yr({...u})),"function"==typeof this.#Xr&&this.#Xr(u)}#Qr(){const e=window.getComputedStyle(this.#Gr),t=parseFloat(e.lineHeight);return Number.isNaN(t)?1.2*parseFloat(e.fontSize):t}getData(){return{rows:this.#Jr,height:this.#Ur}}refresh(){this.#Zr()}destroy(){this.#Gr.removeEventListener("input",this._handleInput)}};class Jt{#mr=!1;#en=new Set;#tn=new Map;#rn=new Map;#nn=null;#in=[];#on={};#sn=[];#an=null;#ln=null;#un;#cn;#hn;#dn;#pn;#fn;#mn;#gn;#yn=[];#wn=0;#bn=0;#vn=[];#En=0;#Tn=null;#Sn=new Set;#xn=new Set;#An=new Map;#In=new Map;#Cn=new Map;static#Mn={" ":"Space","\n":"Enter","\r":"Enter","\t":"Tab","-":"Minus",_:"Minus","=":"Equal","+":"Equal","[":"BracketLeft","{":"BracketLeft","]":"BracketRight","}":"BracketRight","\\":"Backslash","|":"Backslash",";":"Semicolon",":":"Semicolon","'":"Quote",'"':"Quote",",":"Comma","<":"Comma",".":"Period",">":"Period","/":"Slash","?":"Slash","`":"Backquote","~":"Backquote"};static addSpecialKey(e,t){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);if("string"!=typeof t)throw new TypeError("Invalid code type: expected string, got "+typeof t);Jt.#Mn[e]=t}static removeSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);delete Jt.#Mn[e]}static getSpecialKey(e){if("string"!=typeof e)throw new TypeError("Invalid char type: expected string, got "+typeof e);if(1!==e.length)throw new Error(`Invalid char length: "${e}" (must be exactly one character)`);return Jt.#Mn[e]}static getAllSpecialKeys(){return{...Jt.#Mn}}static stringToKeys(e){if("string"!=typeof e)throw new TypeError("Invalid text type: expected string, got "+typeof e);if(!e.length)throw new Error("Invalid text: cannot be empty");return Array.from(e).map(e=>{const t=e.toUpperCase();if(t>="A"&&t<="Z")return`Key${t}`;if(t>="0"&&t<="9")return`Digit${t}`;const r=Jt.#Mn[e];if(void 0!==r)return r;throw new Error(`Unsupported character: "${e}"`)})}constructor({expectedId:e=null,inputMode:t="both",ignoreIds:r=[],deadZone:n=.1,axisActiveSensitivity:i=.3,timeoutComboKeys:o=500,allowMouse:s=!1,elementBase:a=window}={}){if(null!==e&&"string"!=typeof e)throw new TypeError('"expectedId" must be a string or null, received: '+typeof e);if(!["keyboard-only","gamepad-only","both"].includes(t))throw new TypeError(`"inputMode" must be 'keyboard-only', 'gamepad-only', or 'both', received: ${t}`);if(!Array.isArray(r)||!r.every(e=>"string"==typeof e))throw new TypeError('"ignoreIds" must be an array of strings');if("number"!=typeof n||n<0||n>1)throw new RangeError(`"deadZone" must be a number between 0 and 1, received: ${n}`);if("number"!=typeof i||i<0||i>1)throw new RangeError(`"axisActiveSensitivity" must be a number between 0 and 1, received: ${i}`);if("number"!=typeof o||o<0)throw new RangeError(`"timeoutComboKeys" must be a positive number, received: ${o}`);if("boolean"!=typeof s)throw new TypeError('"allowMouse" must be a boolean, received: '+typeof s);if(!(a instanceof Window||a instanceof Element))throw new TypeError('"elementBase" must be a Window or Element instance');this.#dn=e,this.#un=t,this.#cn=new Set(r),this.#hn=n,this.#pn=s,this.#fn=a,this.#mn=o,this.#gn=i,["gamepad-only","both"].includes(this.#un)&&this.#Ln(),["keyboard-only","both"].includes(this.#un)&&this.#Nn()}#kn=e=>this.#Dn(e.gamepad);#_n=e=>this.#jn(e.gamepad);#Ln(){window.addEventListener("gamepadconnected",this.#kn),window.addEventListener("gamepaddisconnected",this.#_n)}#Dn(e){this.#mr||this.#cn.has(e.id)||this.#dn&&e.id!==this.#dn||this.#nn||(this.#nn=e,this.#dn=e.id,this.#Rn(),this.#On("connected",{id:e.id,gp:e,timestamp:e.timestamp}))}#jn(e){this.#mr||this.#nn&&e.id===this.#nn.id&&(this.#nn=null,this.#an&&(cancelAnimationFrame(this.#an),this.#an=null),this.#On("disconnected",{id:e.id,gp:e,timestamp:e.timestamp}))}#Rn(){const e=()=>{this.#mr||(this.#Hn(),this.#an=requestAnimationFrame(e))};e()}#Hn(){if(this.#mr)return;const e=navigator.getGamepads(),t=Array.from(e).find(e=>e&&e.id===this.#dn);t&&(this.#nn=t,t.buttons.forEach((e,r)=>{const n=`Button${r}`,i=this.#in[r]?.pressed||!1;let o,s,a=!1;e.pressed&&!i?(s=1,o="down"):!e.pressed&&i?(s=0,o="up"):e.pressed&&i&&(s=1,o="hold"),e.pressed&&e.value>0&&e.value<1&&1!==e.value&&(s=e.value,a=!0),"number"==typeof s&&"string"==typeof o&&this.#Bn({key:n,source:"gamepad-button",value:s,value2:NaN,type:o,gp:t,isPressure:a,pressed:e.pressed,prevPressed:i,timestamp:t.timestamp,id:t.id}),this.#in[r]={pressed:e.pressed,value:"number"==typeof s?s:this.#in[r]?.value,value2:NaN}}),t.axes.forEach((e,r)=>{Math.abs(e)<this.#hn&&(e=0);const n=`Axis${r}`;e!==(this.#sn[r]??0)&&this.#Bn({key:n,source:"gamepad-analog",value:e,value2:NaN,type:"change",timestamp:t.timestamp,id:t.id,gp:t}),this.#sn[r]=e}))}#$n=e=>{if(!this.#mr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keydown listener.");this.#en.has(e.code)||(this.#en.add(e.code),this.#Bn({event:e,key:e.code,source:"keyboard",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#on[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#on[e.code]={pressed:!0})}};#Pn=e=>{if(!this.#mr){if(!(e instanceof KeyboardEvent))throw new Error("Expected KeyboardEvent in keyup listener.");this.#en.has(e.code)&&(this.#en.delete(e.code),this.#Bn({event:e,key:e.code,source:"keyboard",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#on[e.code]?.pressed??!1,id:"native_keyboard",timestamp:e.timeStamp}),this.#on[e.code]={pressed:!1})}};#Fn=e=>{if(this.#mr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousedown listener.");const t=`Mouse${e.button}`;this.#en.add(t),this.#Bn({event:e,key:t,source:"mouse",value:1,value2:NaN,type:"down",pressed:!0,prevPressed:this.#on[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#on[t]={pressed:!0}};#Wn=e=>{if(this.#mr)return;if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mouseup listener.");const t=`Mouse${e.button}`;this.#en.delete(t),this.#Bn({event:e,key:t,source:"mouse",value:0,value2:NaN,type:"up",pressed:!1,prevPressed:this.#on[t]?.pressed??!1,id:"native_mouse",timestamp:e.timeStamp}),this.#on[t]={pressed:!1}};#zn=e=>{if(!this.#mr){if(!(e instanceof MouseEvent))throw new Error("Expected MouseEvent in mousemove listener.");if(0!==e.movementX||0!==e.movementY){const t="MouseMove",r=this.#on[t]??{pressed:!1,value:0,value2:0};this.#Bn({event:e,key:t,source:"mouse",value:e.movementX+(r.value??0),value2:e.movementY+(r.value??0),id:"native_mouse",type:"move",pressed:!0,prevPressed:null,timestamp:e.timeStamp}),this.#on[t]={pressed:!1,value:e.movementX,value2:e.movementY}}}};#Nn(){this.#fn.addEventListener("keydown",this.#$n),this.#fn.addEventListener("keyup",this.#Pn),this.#pn&&(this.#fn.addEventListener("mousedown",this.#Fn),this.#fn.addEventListener("mouseup",this.#Wn),this.#fn.addEventListener("mousemove",this.#zn));const e=()=>{this.#mr||(this.#en.forEach(e=>{const t=e.startsWith("Mouse")?"mouse":"keyboard";this.#Bn({key:e,source:t,id:`native_${t}`,value:1,value2:NaN,type:"hold",pressed:!0,prevPressed:this.#on[e]?.pressed??!1,timestamp:NaN})}),this.#ln=requestAnimationFrame(e))};e()}#Bn(e){if(this.#mr)return;const t=this.#rn.get("input-*")||[],{pressed:r,key:n}=e,i=n.startsWith("Axis"),o="boolean"==typeof r&&r||i&&(e.value>this.#gn||e.value<-Math.abs(this.#gn)),s=i?`${n}${e.value>0?"+":e.value<0?"-":""}`:n;let a=null;if("move"!==e.type&&"hold"!==e.type){if(o){if(!i&&!this.#Sn.has(n)||i&&!this.#Sn.has(n)&&!this.#Sn.has(`${n}+`)&&!this.#Sn.has(`${n}-`)){0===this.#En&&(this.#En=Date.now()),this.#Sn.add(s),a=!0,this.#vn.push(s),this.#yn.length<1&&(this.#Tn&&clearTimeout(this.#Tn),this.#Tn=setTimeout(()=>this.resetComboMapped(),this.#mn));const e=this.#rn.get("mapped-key-start")??[];for(const t of e)t({key:s,activeTime:this.#En})}}else if(!i&&this.#Sn.has(n)||i&&(this.#Sn.has(n)||this.#Sn.has(`${n}+`)||this.#Sn.has(`${n}-`))){this.#Sn.delete(n),this.#Sn.delete(`${n}+`),this.#Sn.delete(`${n}-`),a=!1;const e=this.#rn.get("mapped-key-end")??[];for(const t of e)t({key:s,activeTime:this.#En})}for(const{sequence:e,callback:t,triggered:r}of this.#In.values()){const n=this.#In.get(e.join("+"));if(!n)continue;const i=e.every((e,t)=>this.#vn[t]===e);i&&!r?(n.triggered=!0,t(this.#En)):!i&&r&&(n.triggered=!1)}}for(const[r,l]of this.#tn.entries()){const u=e=>"string"==typeof l&&e===l||Array.isArray(l)&&l.findIndex((t,r)=>e===l[r])>-1,c=u(s),h=i&&u(`${n}+`),d=i&&u(`${n}-`);if(c||h||d){if(o&&c){if(a||!this.#xn.has(r)){0===this.#bn&&(this.#bn=Date.now()),this.#xn.add(r),0===this.#wn&&(this.#wn=Date.now()),this.#Tn&&clearTimeout(this.#Tn),this.#yn.push(r),this.#Tn=setTimeout(()=>this.resetComboMapped(),this.#mn);const e=this.#rn.get("mapped-input-start")??[];for(const t of e)t({logicalName:r,activeTime:this.#bn,comboTime:this.#wn})}}else if(!a||this.#xn.has(r)){this.#xn.delete(r),this.#xn.size<1&&(this.#bn=0);const e=this.#rn.get("mapped-input-end")??[];for(const t of e)t({logicalName:r,activeTime:this.#bn,comboTime:this.#wn})}for(const{sequence:e,callback:t,triggered:r}of this.#An.values()){const n=this.#An.get(e.join("+"));if(!n)continue;const i=Array.from(this.#xn),o=e.every((e,t)=>i[t]===e);o&&!r?(n.triggered=!0,t(this.#bn)):!o&&r&&(n.triggered=!1)}}const p=[];if(i&&0===e.value){const{value:t}=this.#Cn.get(`${n}-`)??{value:0,value2:NaN},{value:r}=this.#Cn.get(`${n}+`)??{value:0,value2:NaN};e.value!==t&&p.push(`${n}-`),e.value!==r&&p.push(`${n}+`)}else p.push(s);p.forEach(n=>{if(!("*"===l||l===n||Array.isArray(l)&&l.includes(n)))return;const i=this.#rn.get(`input-${e.type}-${r}`)||[],o=this.#rn.get(`input-${r}`)||[];if(o.length<1&&i.length<1&&t.length<1)return;const s={...e,key:n,logicalName:r};for(const e of t)e(s);for(const e of o)e(s);for(const e of i)e(s);this.#Cn.set(n,{value:e.value,value2:e.value2})})}}#On(e,t){const r=this.#rn.get(e)||[];for(const e of r)e(t)}#qn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e);let i=this.#rn.get(n);Array.isArray(i)||(i=[],this.#rn.set(n,i)),i.push(t)}#Vn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=i=>{this.#Kn(e,n,r),t(i)};this.#qn(e,n,r)}#Un(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e),i=this.#rn.get(n)??[];i.unshift(t),this.#rn.set(n,i)}#Kn(e,t,r){if("string"!=typeof e)throw new TypeError(`"logicalName" must be a string, received ${e}`);if("function"!=typeof t)throw new TypeError('"callback" must be a function, received '+typeof t);const n=r.replace("{logicalName}",e),i=this.#rn.get(n);Array.isArray(i)&&this.#rn.set(n,i.filter(e=>e!==t))}awaitInputMapping({timeout:e=1e4,eventName:t="MappingInput",canMove:r=!1}={}){return new Promise((n,i)=>{if("number"!=typeof e||Number.isNaN(e)||e<0)return i(new TypeError(`Invalid "timeout": expected a positive number, got ${e}`));if("string"!=typeof t||!t.trim())return i(new TypeError(`Invalid "eventName": expected a non-empty string, got ${t}`));if("boolean"!=typeof r)return i(new TypeError(`Invalid "canMove": expected a boolean, got ${r}`));const o={key:null,source:null},s=({key:e,type:i,source:l,gp:u,value:c})=>{(r||"move"!==i)&&(o.key=e,o.source=l,o.gp=u,clearTimeout(a),this.offInputStart(t,s),this.offInputChange(t,s),r&&this.offInputMove(t,s),n(o))},a=setTimeout(()=>n(o),e);this.mapInput(t,"*"),this.onInputStart(t,s),this.onInputChange(t,s),r&&this.onInputMove(t,s)})}mapInput(e,t){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);if(!("string"==typeof t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError(`Invalid "physicalInput": expected string or array of strings, got ${JSON.stringify(t)}`);this.#tn.set(e,t)}unmapInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);this.#tn.delete(e)}hasMappedInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);return this.#tn.has(e)}getMappedInput(e){if("string"!=typeof e||!e.trim())throw new TypeError(`Invalid "logicalName": expected a non-empty string, got ${e}`);const t=this.#tn.get(e);if(!t)throw new Error(`No physical input mapped for logicalName: "${e}"`);return t}clearMapInputs(){this.#tn.clear()}registerInputSequence(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#An.set(r,{sequence:e,callback:t,triggered:!1})}unregisterInputSequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#An.delete(t)}unregisterAllInputSequences(){this.#An.clear()}hasInputSequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#An.has(t)}registerKeySequence(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);if("function"!=typeof t)throw new TypeError("'callback' must be a function, got: "+typeof t);if(0===e.length)throw new Error("'sequence' must contain at least one input name.");const r=e.join("+");this.#In.set(r,{sequence:e,callback:t,triggered:!1})}unregisterKeySequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");this.#In.delete(t)}unregisterAllKeySequences(){this.#In.clear()}hasKeySequence(e){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError(`'sequence' must be an array of strings, got: ${JSON.stringify(e)}`);const t=e.join("+");return this.#In.has(t)}renewComboMapped(){this.#Tn&&(clearTimeout(this.#Tn),this.#Tn=setTimeout(()=>this.resetComboMapped(),this.#mn))}resetComboMapped(){this.#Tn&&clearTimeout(this.#Tn),this.#vn=[],this.#Tn=null,this.#En=0,this.#yn=[],this.#wn=0}onMappedKeyStart(e){return this.#qn("",e,"mapped-key-start")}onceMappedKeyStart(e){return this.#Vn("",e,"mapped-key-start")}prependMappedKeyStart(e){return this.#Un("",e,"mapped-key-start")}offMappedKeyStart(e){return this.#Kn("",e,"mapped-key-start")}offAllMappedKeyStart(){this.#rn.delete("mapped-key-start")}onMappedKeyEnd(e){return this.#qn("",e,"mapped-key-end")}onceMappedKeyEnd(e){return this.#Vn("",e,"mapped-key-end")}prependMappedKeyEnd(e){return this.#Un("",e,"mapped-key-end")}offMappedKeyEnd(e){return this.#Kn("",e,"mapped-key-end")}offAllMappedKeyEnd(){this.#rn.delete("mapped-key-end")}onMappedInputStart(e){return this.#qn("",e,"mapped-input-start")}onceMappedInputStart(e){return this.#Vn("",e,"mapped-input-start")}prependMappedInputStart(e){return this.#Un("",e,"mapped-input-start")}offMappedInputStart(e){return this.#Kn("",e,"mapped-input-start")}offAllMappedInputStart(){this.#rn.delete("mapped-input-start")}onMappedInputEnd(e){return this.#qn("",e,"mapped-input-end")}onceMappedInputEnd(e){return this.#Vn("",e,"mapped-input-end")}prependMappedInputEnd(e){return this.#Un("",e,"mapped-input-end")}offMappedInputEnd(e){return this.#Kn("",e,"mapped-input-end")}offAllMappedInputEnd(){this.#rn.delete("mapped-input-end")}onInput(e,t){return this.#qn(e,t,"input-{logicalName}")}onceInput(e,t){return this.#Vn(e,t,"input-{logicalName}")}prependInput(e,t){return this.#Un(e,t,"input-{logicalName}")}offInput(e,t){return this.#Kn(e,t,"input-{logicalName}")}onInputStart(e,t){return this.#qn(e,t,"input-down-{logicalName}")}onceInputStart(e,t){return this.#Vn(e,t,"input-down-{logicalName}")}prependInputStart(e,t){return this.#Un(e,t,"input-down-{logicalName}")}offInputStart(e,t){return this.#Kn(e,t,"input-down-{logicalName}")}onInputEnd(e,t){return this.#qn(e,t,"input-up-{logicalName}")}onceInputEnd(e,t){return this.#Vn(e,t,"input-up-{logicalName}")}prependInputEnd(e,t){return this.#Un(e,t,"input-up-{logicalName}")}offInputEnd(e,t){return this.#Kn(e,t,"input-up-{logicalName}")}onInputHold(e,t){return this.#qn(e,t,"input-hold-{logicalName}")}onceInputHold(e,t){return this.#Vn(e,t,"input-hold-{logicalName}")}prependInputHold(e,t){return this.#Un(e,t,"input-hold-{logicalName}")}offInputHold(e,t){return this.#Kn(e,t,"input-hold-{logicalName}")}onInputChange(e,t){return this.#qn(e,t,"input-change-{logicalName}")}onceInputChange(e,t){return this.#Vn(e,t,"input-change-{logicalName}")}prependInputChange(e,t){return this.#Un(e,t,"input-change-{logicalName}")}offInputChange(e,t){return this.#Kn(e,t,"input-change-{logicalName}")}onInputMove(e,t){return this.#qn(e,t,"input-move-{logicalName}")}onceInputMove(e,t){return this.#Vn(e,t,"input-move-{logicalName}")}prependInputMove(e,t){return this.#Un(e,t,"input-move-{logicalName}")}offInputMove(e,t){return this.#Kn(e,t,"input-move-{logicalName}")}getCalls(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n=`${{all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t]}${e}`,i=this.#rn.get(n);return Array.isArray(i)?[...i]:[]}offAllInputs(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t];n&&this.#rn.delete(`${n}${e}`)}getCallSize(e,t="all"){if("string"!=typeof e||""===e.trim())throw new TypeError(`"logicalName" must be a non-empty string, received ${e}`);const r=["all","start","end","hold","change","move"];if(!r.includes(t))throw new TypeError(`"type" must be one of ${r.join(", ")}, received ${t}`);const n={all:"input-",start:"input-down-",end:"input-up-",hold:"input-hold-",change:"input-change-",move:"input-move-"}[t],i=this.#rn.get(`${n}${e}`);return Array.isArray(i)?i.length:0}#Jn={type:"dual-rumble",params:{startDelay:0,duration:200,weakMagnitude:.5,strongMagnitude:1}};get defaultHapticEffect(){return{type:this.#Jn.type,params:{...this.#Jn.params}}}setDefaultHapticEffect(e,t){if("string"!=typeof e)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string, received ${e}`);if("object"!=typeof t||null===t)throw new TypeError(`"params" must be a non-null object, received ${t}`);this.#Jn.type=e,this.#Jn.params=t}hasHapticEffect(){const e=this.#nn;return!!e&&e.vibrationActuator instanceof GamepadHapticActuator}vibrate(e,t){if(void 0!==e&&("object"!=typeof e||null===e))throw new TypeError(`"params" must be an object if provided, received ${e}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError(`"type" must be a valid GamepadHapticEffectType string if provided, received ${t}`);const r=this.#nn;if(!r)return new Promise(e=>e("complete"));const n=r.vibrationActuator;return n instanceof GamepadHapticActuator?n.playEffect(t??this.#Jn.type,{...this.#Jn.params,...e}):new Promise(e=>e("complete"))}ignoreId(e){if("string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#cn.add(e)}unignoreId(e){if("string"!=typeof e||""===e.trim())throw new TypeError(`"id" must be a non-empty string, received ${e}`);this.#cn.delete(e)}onConnected(e){return this.#qn("",e,"connected")}onceConnected(e){return this.#Vn("",e,"connected")}prependConnected(e){return this.#Un("",e,"connected")}offConnected(e){return this.#Kn("",e,"connected")}offAllConnected(){this.#rn.delete("connected")}onDisconnected(e){return this.#qn("",e,"disconnected")}onceDisconnected(e){return this.#Vn("",e,"disconnected")}prependDisconnected(e){return this.#Un("",e,"disconnected")}offDisconnected(e){return this.#Kn("",e,"disconnected")}offAllDisconnected(){this.#rn.delete("disconnected")}hasGamepad(){return this.#nn instanceof Gamepad}getGamepad(){if(!this.#nn)throw new Error("No gamepad is currently connected.");return this.#nn}hasLastButtonState(e){return!!this.#in[e]}getLastButtonState(e){if(!this.#in[e])throw new Error(`No last button state found for index ${e}`);return{...this.#in[e]}}exportConfig(){return{expectedId:this.#dn,ignoreIds:Array.from(this.#cn),deadZone:this.#hn,timeoutComboKeys:this.#mn,axisActiveSensitivity:this.#gn,inputMap:Array.from(this.#tn.entries())}}importConfig(e){if("string"!=typeof e&&("object"!=typeof e||null===e))throw new TypeError(`"json" must be a string or a non-null object, received: ${e}`);const t="string"==typeof e?JSON.parse(e):e;if(void 0!==t.expectedId&&"string"!=typeof t.expectedId&&null!==t.expectedId)throw new TypeError('"expectedId" must be a string or null if provided');if(void 0!==t.ignoreIds&&!Array.isArray(t.ignoreIds))throw new TypeError('"ignoreIds" must be an array if provided');if(void 0!==t.deadZone&&"number"!=typeof t.deadZone)throw new TypeError('"deadZone" must be a number if provided');if(void 0!==t.timeoutComboKeys&&"number"!=typeof t.timeoutComboKeys)throw new TypeError('"timeoutComboKeys" must be a number if provided');if(void 0!==t.axisActiveSensitivity&&"number"!=typeof t.axisActiveSensitivity)throw new TypeError('"axisActiveSensitivity" must be a number if provided');if(void 0!==t.inputMap&&!Array.isArray(t.inputMap))throw new TypeError('"inputMap" must be an array if provided');void 0!==t.expectedId&&(this.#dn=t.expectedId),Array.isArray(t.ignoreIds)&&(this.#cn=new Set(t.ignoreIds)),"number"==typeof t.deadZone&&(this.#hn=t.deadZone),"number"==typeof t.timeoutComboKeys&&(this.#mn=t.timeoutComboKeys),"number"==typeof t.axisActiveSensitivity&&(this.#gn=t.axisActiveSensitivity),Array.isArray(t.inputMap)&&(this.#tn=new Map(t.inputMap))}get mappedKeyStartCalls(){const e=this.#rn.get("mapped-key-start");return Array.isArray(e)?[...e]:[]}get mappedKeyEndCalls(){const e=this.#rn.get("mapped-key-end");return Array.isArray(e)?[...e]:[]}get comboMappedKeys(){return[...this.#vn]}get comboMappedInputs(){return[...this.#yn]}get keySequenceSize(){return this.#In.size}get keySequences(){const e=[];for(const[,t]of this.#In.entries())e.push(t.callback);return e}get activeMappedKeys(){return[...this.#Sn]}get mappedInputStartCalls(){const e=this.#rn.get("mapped-input-start");return Array.isArray(e)?[...e]:[]}get mappedInputEndCalls(){const e=this.#rn.get("mapped-input-end");return Array.isArray(e)?[...e]:[]}get inputSequenceSize(){return this.#An.size}get inputSequences(){const e=[];for(const[,t]of this.#An.entries())e.push(t.callback);return e}get activeMappedInputs(){return[...this.#xn]}get mappedInputs(){const e={};for(const[t,r]of this.#tn.entries())e[t]=r;return e}get mappedInputSize(){return this.#tn.size}get connectedCalls(){const e=this.#rn.get("connected");return Array.isArray(e)?[...e]:[]}get disconnectedCalls(){const e=this.#rn.get("disconnected");return Array.isArray(e)?[...e]:[]}get ignoredDeviceIds(){return[...this.#cn]}get heldKeys(){return[...this.#en]}get eventsSize(){let e=0;return this.#rn.forEach(t=>{e+=t.length}),e}get callSize(){return this.#rn.size}get connectedCallSize(){const e=this.#rn.get("connected");return Array.isArray(e)?e.length:0}get disconnectedCallSize(){const e=this.#rn.get("disconnected");return Array.isArray(e)?e.length:0}get mappedKeyStartCallSize(){const e=this.#rn.get("mapped-key-start");return Array.isArray(e)?e.length:0}get mappedKeyEndCallSize(){const e=this.#rn.get("mapped-key-end");return Array.isArray(e)?e.length:0}get mappedInputStartCallSize(){const e=this.#rn.get("mapped-input-start");return Array.isArray(e)?e.length:0}get mappedInputEndCallSize(){const e=this.#rn.get("mapped-input-end");return Array.isArray(e)?e.length:0}get lastButtonStates(){const e=[];return this.#in.forEach(t=>{e.push({...t})}),e}get lastAxes(){return[...this.#sn]}get inputMode(){return this.#un}get elementBase(){return this.#fn}get timeComboInputs(){return this.#wn}get timeComboKeys(){return this.#En}get timeMappedInputs(){return this.#bn}get timeoutComboKeys(){return this.#mn}set timeoutComboKeys(e){if("number"!=typeof e||e<0||!Number.isFinite(e))throw new TypeError("Timeout combo keys must be a non-negative finite number.");this.#mn=e}get axisActiveSensitivity(){return this.#gn}set axisActiveSensitivity(e){if("number"!=typeof e||e<0||e>1)throw new RangeError("Axis sensitivity must be a number between 0 and 1.");this.#gn=e}get deadZone(){return this.#hn}set deadZone(e){if("number"!=typeof e||e<0||e>1)throw new RangeError("Dead zone must be a number between 0 and 1.");this.#hn=e}get expectedId(){return this.#dn}set expectedId(e){if("string"!=typeof e)throw new TypeError("Expected device id be a string.");this.#dn=e}get isDestroyed(){return this.#mr}destroy(){this.#mr||(this.#mr=!0,this.#an&&cancelAnimationFrame(this.#an),this.#ln&&cancelAnimationFrame(this.#ln),this.#an=null,this.#ln=null,["keyboard-only","both"].includes(this.#un)&&(this.#fn.removeEventListener("keydown",this.#$n),this.#fn.removeEventListener("keyup",this.#Pn),this.#pn&&(this.#fn.removeEventListener("mousedown",this.#Fn),this.#fn.removeEventListener("mouseup",this.#Wn),this.#fn.removeEventListener("mousemove",this.#zn))),["gamepad-only","both"].includes(this.#un)&&(window.removeEventListener("gamepadconnected",this.#kn),window.removeEventListener("gamepaddisconnected",this.#_n)),this.resetComboMapped(),this.#tn.clear(),this.#rn.clear(),this.#en.clear(),this.#xn.clear(),this.#Sn.clear(),this.#An.clear(),this.#In.clear(),this.#cn.clear(),this.#Cn.clear(),this.#in=[],this.#sn=[],this.#on={},this.#nn=null,this.#dn=null,this.#pn=!1,this.#bn=0)}}const Gt=Jt,Yt=class{#Gn=!0;#Yn=86400;#Xn=3600;#Qn=60;#Zn=new Map;#ei=[];#ti;#ri;#ni={main:null};#ii=0;#oi=0;#si=0;#ai="";#li=1;#ui=1;#ci=1;#mr=!1;#hi=[31,31,31,31,31,31,31,31,31,31,31,31];#di={default:{},day:{},night:{},hours:{},seasons:{}};#pi={min:60,max:180};#fi=0;get daySize(){return this.#Yn}get autoSizeAdjuste(){return this.#Gn}set autoSizeAdjuste(e){if("boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#Gn=e}set daySize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("daySize must be a positive finite number.");const t=this.#Xn/this.#Yn,r=this.#Qn/this.#Yn;this.#Yn=e,this.#Gn&&(this.#Xn=e*t,this.#Qn=e*r)}get hourSize(){return this.#Xn}set hourSize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("hourSize must be a positive finite number.");const t=this.#Yn/this.#Xn,r=this.#Qn/this.#Xn;this.#Xn=e,this.#Gn&&(this.#Yn=e*t,this.#Qn=e*r)}get minuteSize(){return this.#Qn}set minuteSize(e){if("number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("minuteSize must be a positive finite number.");const t=this.#Xn/this.#Qn,r=this.#Yn/this.#Qn;this.#Qn=e,this.#Gn&&(this.#Xn=e*t,this.#Yn=e*r)}get isDestroyed(){return this.#mr}get currentSeconds(){return this.#ii}set currentSeconds(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentSeconds must be a finite number, received "+typeof e);if(e<0||e>=this.#Yn)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#ii=Math.floor(e),this.#oi=Math.floor(e/this.#Qn),this.#si=Math.floor(e/this.#Xn)}get currentMinutes(){return this.#oi}set currentMinutes(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentMinutes must be a finite number, received "+typeof e);if(e<0||e>=1440)throw new RangeError(`currentMinutes must be between 0 and 1439, received ${e}`);this.#oi=Math.floor(e),this.#si=Math.floor(e/this.#Qn),this.#ii=Math.floor(e*this.#Qn)}get currentHours(){return this.#si}set currentHours(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentHours must be a finite number, received "+typeof e);if(e<0||e>=24)throw new RangeError(`currentHours must be between 0 and less than 24, received ${e}`);this.#si=Math.floor(e),this.#oi=Math.floor(e*this.#Qn),this.#ii=Math.floor(e*this.#Xn)}get moons(){return this.#ei.map(e=>this.getMoon(e))}get seasons(){return Array.from(this.#Zn.keys())}get dayStart(){return this.#ti}get nightStart(){return this.#ri}get weather(){return{...this.#ni}}get currentSeason(){return this.#ai}get currentDay(){return this.#li}get currentMonth(){return this.#ui}get currentYear(){return this.#ci}get monthDays(){return[...this.#hi]}get weatherDuration(){return{...this.#pi}}get weatherTimeLeft(){return this.#fi}set dayStart(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("dayStart must be a positive non-zero number, received "+typeof e);this.#ti=e}set nightStart(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("nightStart must be a positive non-zero number, received "+typeof e);this.#ri=e}set weather(e){if(this._checkDestroyed(),"object"!=typeof e||null===e||Array.isArray(e)||!Object.values(e).every(e=>"string"==typeof e))throw new TypeError("weather must be a object with strings, received "+typeof e);this.#ni=e}set currentSeason(e){if(this._checkDestroyed(),"string"!=typeof e||!this.#Zn.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#Zn).map(e=>e[0]).join(", ")}, received ${e}`);this.#ai=e}set currentDay(e){if(this._checkDestroyed(),"number"!=typeof e||e<1||e>this.#hi[this.#ui-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#li=e}set currentMonth(e){if(this._checkDestroyed(),"number"!=typeof e||"number"!=typeof this.#hi[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#ui=e}set currentYear(e){if(this._checkDestroyed(),"number"!=typeof e||e<1)throw new TypeError("currentYear must be a positive number non-zero, received "+typeof e);this.#ci=e}set monthDays(e){if(this._checkDestroyed(),!Array.isArray(e))throw new TypeError("monthDays must be a array");if(!e.every(e=>"number"==typeof e))throw new TypeError("monthDays must have number values");this.#hi=[...e]}set weatherDuration(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("weatherDuration must be a non-null object");if("number"!=typeof e.min||"number"!=typeof e.max)throw new TypeError("weatherDuration.min and weatherDuration.max must be numbers");this.#pi={...e}}set weatherTimeLeft(e){if(this._checkDestroyed(),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#fi=e}get weatherConfig(){const e={},t={};for(const t in this.#di.hours)e[t]={...this.#di.hours[t]};for(const e in this.#di.seasons)t[e]={...this.#di.seasons[e]};return{default:{...this.#di.default},day:{...this.#di.day},night:{...this.#di.night},hours:e,seasons:t}}set weatherConfig(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError(`weatherConfig must be a non-null object, received ${e}`);const t=["default","day","night","hours","seasons"];for(const r of t)if(!(r in e))throw new TypeError(`weatherConfig is missing required property "${r}".`);const r={},n={},i=(e,t)=>{if("object"!=typeof e||null===e)throw new TypeError(`${t} must be an object, received ${e}`);for(const r in e){const n=typeof e[r];if("number"!==n&&"function"!==n)throw new TypeError(`${t}["${r}"] must be a number or function, received ${n}`)}};for(const t in e.hours)i(e.hours[t],`hours["${t}"]`),r[t]={...e.hours[t]};for(const t in e.seasons)i(e.seasons[t],`seasons["${t}"]`),n[t]={...e.seasons[t]};const o=(e,t)=>(i(e,t),{...e});this.#di={default:o(e.default,"default"),day:o(e.day,"day"),night:o(e.night,"night"),hours:r,seasons:n}}constructor(e=6,t=18){this.#ti=e,this.#ri=t}addSeason(e,t){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);if(!Array.isArray(t)||!t.every(e=>"number"==typeof e))throw new TypeError("Season values must be an array of numbers");this.#Zn.set(e,t)}removeSeason(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#Zn.delete(e),this.#ai===e&&(this.#ai="")}hasSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#Zn.has(e)}getSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#Zn.get(e);if(!t)throw new Error(`Season "${e}" not found`);return[...t]}setTime({hour:e=0,minute:t=0,second:r=0}){this._checkDestroyed(),this.currentSeconds=(e*this.#Xn+t*this.#Qn+r)%this.#Yn}addTime({hours:e=0,minutes:t=0,seconds:r=0}){this._checkDestroyed();let n=this.currentSeconds+e*this.#Xn+t*this.#Qn+r;for(;n>=this.#Yn;)n-=this.#Yn,this.nextDay();for(;n<0;)n+=this.#Yn,this.prevDay();this.currentSeconds=n,this.updateWeatherTimer((e*this.#Xn+t*this.#Qn+r)/this.#Qn)}getTime({withSeconds:e=!1,hourSize:t=this.#Xn,minuteSize:r=this.#Qn}={}){const n=Math.floor(this.currentSeconds/t),i=Math.floor(this.currentSeconds%t/r),o=this.currentSeconds%r;return{hour:n,minute:i,second:o,formatted:`${n.toString().padStart(2,"0")}:${i.toString().padStart(2,"0")}`+(e?`:${o.toString().padStart(2,"0")}`:"")}}isDay(){return this.#ti<this.#ri?this.#oi>=this.#ti*this.#Qn&&this.#oi<this.#ri*this.#Qn:this.#oi>=this.#ti*this.#Qn||this.#oi<this.#ri*this.#Qn}minutesUntilDay(){return this.timeUntil(this.#ti,"minutes")}secondsUntilDay(){return this.timeUntil(this.#ti,"seconds")}hoursUntilDay(){return this.timeUntil(this.#ti,"hours")}minutesUntilNight(){return this.timeUntil(this.#ri,"minutes")}secondsUntilNight(){return this.timeUntil(this.#ri,"seconds")}hoursUntilNight(){return this.timeUntil(this.#ri,"hours")}timeUntil(e,t){this._checkDestroyed();let r=e*this.#Xn-this.#ii;switch(r<=0&&(r+=this.#Yn),t){case"minutes":return r/this.#Qn;case"hours":return r/this.#Xn;default:return r}}setTo(e){this._checkDestroyed(),"day"===e?this.setTime({hour:this.#ti}):"night"===e&&this.setTime({hour:this.#ri})}nextDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++){this.#li++;const e=this.#hi[this.#ui-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#li>e&&(this.#li=1,this.#ui++,this.#ui>this.#hi.length&&(this.#ui=1,this.#ci++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++)this.#li--,this.#li<1&&(this.#ui--,this.#ui<1&&(this.#ui=this.#hi.length,this.#ci--),this.#li=this.#hi[this.#ui-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){this._checkDestroyed(),this.#Zn.forEach((e,t)=>{e.includes(this.#ui)&&(this.#ai=t)})}setWeatherConfig(e){this._checkDestroyed(),this.#di={...this.#di,...e}}setWeatherDuration(e,t){this._checkDestroyed(),this.#pi.min=e,this.#pi.max=t}updateWeatherTimer(e){this._checkDestroyed(),this.#fi-=e,this.#fi<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){this._checkDestroyed();const n=this.#ni;n[e]=t,this.weather=n,this.#fi=r??this._randomInRange(this.#pi.min,this.#pi.max)}chooseNewWeather({customWeather:e,where:t="main"}={}){this._checkDestroyed();let r={};const n=e=>{for(const[t,n]of Object.entries(e)){let e=n;"function"==typeof e&&(e=e({hour:Math.floor(this.#oi/this.#Qn),minute:this.#oi%this.#Qn,currentMinutes:this.#oi,isDay:this.isDay(),season:this.#ai,weather:this.#ni})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};n(this.#di.default||{});for(const e in this.#di.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#Qn+(r||0)}),i=this.#oi;(t<=r?i>=t&&i<=r:i>=t||i<=r)&&n(this.#di.hours[e])}this.isDay()&&this.#di.day?n(this.#di.day):!this.isDay()&&this.#di.night&&n(this.#di.night),this.#di.seasons?.[this.#ai]&&n(this.#di.seasons[this.#ai]),e&&"object"==typeof e&&n(e);const i=Object.entries(r).filter(([,e])=>e>0);if(!i.length)return this.#ni[t]=null,null;const o=i.reduce((e,[,t])=>e+t,0);let s=Math.random()*o;for(const[e,r]of i){if(s<r)return this.#ni[t]=e,this.#fi=this._randomInRange(this.#pi.min,this.#pi.max),e;s-=r}return this.#ni[t]=null,null}_randomInRange(e,t){return Math.floor(Math.random()*(t-e+1))+e}addMoon(e,t,r,n=0){this._checkDestroyed();const i=Math.max(1,t);return this.#ei.push({name:e,cycleLength:i,currentPhase:(n%i+i)%i,phaseNames:r}),this.#ei.length-1}removeMoon(e){this._checkDestroyed(),this.#ei=this.#ei.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#ei)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#ei)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){this._checkDestroyed();const r=this.#ei[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase+t)%r.cycleLength}rewindMoon(e,t=1){this._checkDestroyed();const r=this.#ei[e];if(!r)throw new RangeError(`No moon found at index ${e}`);r.currentPhase=(r.currentPhase-t+r.cycleLength)%r.cycleLength}moonExists(e){return!!this.#ei[e]}getMoon(e){let t;if("number"==typeof e){if(t=this.#ei[e],!t)throw new RangeError(`No moon found at index ${e}`)}else{if(!e||"object"!=typeof e||"string"!=typeof e.name||"number"!=typeof e.cycleLength||"number"!=typeof e.currentPhase)throw new TypeError("Invalid moon reference. Expected a number index or a MoonRaw object, received "+typeof e);t=e}return{name:t.name,phaseIndex:t.currentPhase,phaseName:t.phaseNames?t.phaseNames[t.currentPhase]??String(t.currentPhase):String(t.currentPhase),cycleLength:t.cycleLength}}_checkDestroyed(){if(this.#mr)throw new Error("This instance has been destroyed and can no longer be used.")}destroy(){this.#mr||(this.#Zn.clear(),this.#ei.length=0,this.#ti=0,this.#ri=0,this.#ii=0,this.#oi=0,this.#si=0,this.#li=1,this.#ui=1,this.#ci=1,this.#fi=0,this.#ai="",this.#ni={main:null},this.#hi=[],this.#di.default={},this.#di.day={},this.#di.night={},this.#di.hours={},this.#di.seasons={},this.#pi={min:0,max:0},this.#mr=!0)}};class Xt{#Mt=new Lt;#On(e,...t){return this.#Mt.emit(e,...t)}setThrowOnMaxListeners(e){return this.#Mt.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#Mt.getThrowOnMaxListeners()}prependListener(e,t){return this.#Mt.prependListener(e,t)}prependListenerOnce(e,t){return this.#Mt.prependListenerOnce(e,t)}appendListener(e,t){return this.#Mt.appendListener(e,t)}appendListenerOnce(e,t){return this.#Mt.appendListenerOnce(e,t)}on(e,t){return this.#Mt.on(e,t)}once(e,t){return this.#Mt.once(e,t)}off(e,t){return this.#Mt.off(e,t)}offAll(e){return this.#Mt.offAll(e)}offAllTypes(){return this.#Mt.offAllTypes()}listenerCount(e){return this.#Mt.listenerCount(e)}listeners(e){return this.#Mt.listeners(e)}onceListeners(e){return this.#Mt.onceListeners(e)}allListeners(e){return this.#Mt.allListeners(e)}eventNames(){return this.#Mt.eventNames()}setMaxListeners(e){return this.#Mt.setMaxListeners(e)}getMaxListeners(){return this.#Mt.getMaxListeners()}#mr=!1;#mi;#gi;#yi=[];#wi=[];#bi=[];#vi=new Map;#Ei=new Set;#Ti=new Map;#Si;#xi=new Map;#Ai=new Map;get isDestroyed(){return this.#mr}get freq(){return Object.fromEntries(this.#Ai)}get size(){return this.#xi.size}get normalization(){return this.#mi}set normalization(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("normalization must be a non-empty string (e.g., 'relative', 'softmax').");this.#mi=e}get seed(){return this.#gi}set seed(e){if(this._checkDestroyed(),null!==e&&("number"!=typeof e||!Number.isFinite(e)))throw new TypeError("seed must be a finite number or null.");this.#gi=e,null!==e&&(this.#Si=this._makeSeededRng(e))}get globalModifiers(){return[...this.#yi]}set globalModifiers(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("globalModifiers must be an array of functions (WeightsCallback).");this.#yi=e}get temporaryModifiers(){return[...this.#wi]}set temporaryModifiers(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>e&&"function"==typeof e.fn&&Number.isInteger(e.uses)&&e.uses>0))throw new TypeError("temporaryModifiers must be an array of objects { fn: function, uses: positive integer }.");this.#wi=e}get conditionalRules(){return[...this.#bi]}set conditionalRules(e){if(this._checkDestroyed(),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#bi=e}get pitySystems(){return Object.fromEntries(this.#vi)}set pitySystems(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e&&"number"==typeof e.threshold&&"number"==typeof e.increment&&"number"==typeof e.cap&&"number"==typeof e.counter&&"number"==typeof e.currentAdd)))throw new TypeError("pitySystems must be a Map<string, Pity> with all numeric fields.");this.#vi=e}get exclusions(){return Array.from(this.#Ei)}set exclusions(e){if(this._checkDestroyed(),!(e instanceof Set&&[...e].every(e=>"string"==typeof e)))throw new TypeError("exclusions must be a Set<string>.");this.#Ei=e}get groups(){const e={};return this.#Ti.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e instanceof Set&&[...e].every(e=>"string"==typeof e))))throw new TypeError("groups must be a Map<string, Set<string>>.");this.#Ti=e}get rng(){return this.#Si}set rng(e){if(this._checkDestroyed(),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#Si=e}get items(){const e={};return this.#xi.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(this._checkDestroyed(),!(e instanceof Map&&[...e.values()].every(e=>e&&"string"==typeof e.id&&"string"==typeof e.label&&"number"==typeof e.baseWeight&&e.groups instanceof Set&&"boolean"==typeof e.locked&&"object"==typeof e.meta)))throw new TypeError("items must be a Map<string, ItemData> with valid item structures.");this.clearList(),this.#xi=e}constructor(e={}){const{rng:t=null,seed:r=null,normalization:n="relative"}=e;this.#mi=n,this.#gi=r,"function"==typeof t?this.#Si=t:null!==this.#gi?this.#Si=this._makeSeededRng(this.#gi):this.#Si=Math.random,this.#gi=r??null}_checkDestroyed(){if(this.#mr)throw new Error("This instance has been destroyed and can no longer be used.")}hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#xi.has(e)}addItem(e,t={}){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("object"!=typeof t||null===t)throw new TypeError("opts must be an object");let{weight:r=1,label:n=e,meta:i={},groups:o=[]}=t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError("weight must be a non-negative number");if("string"!=typeof n)throw new TypeError("label must be a string");if("object"!=typeof i||null===i)throw new TypeError("meta must be an object");if(!(Array.isArray(o)||o instanceof Set))throw new TypeError("groups must be an array or a Set of strings");o=Array.isArray(o)?o:[...o];for(const e of o)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const s={id:e,label:n,baseWeight:Math.max(0,Number(r)||0),meta:{...i},groups:new Set(o),locked:!1};this.#xi.set(e,s);for(const t of o)this._ensureGroup(t).add(e);return this.#On("itemAdded",s),s}removeItem(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#xi.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#Ti.get(r);t&&t.delete(e)}return this.#xi.delete(e),this.#On("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("weight must be a non-negative number");const r=this.#xi.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.#On("weightChanged",{id:e,weight:r.baseWeight})}getItem(e){if("string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#xi.get(e)??null}listItems(){return Array.from(this.#xi.values()).map(e=>({...e}))}clearList(){this._checkDestroyed(),this.#xi.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#yi.includes(e)}addGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#yi.push(e)}removeGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#yi=this.#yi.filter(t=>t!==e)}hasTemporaryModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#wi.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("uses must be a number");this.#wi.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#wi.length;return this.#wi=this.#wi.filter(t=>t.fn!==e),this.#wi.length!==t}hasConditionalRule(e){if("function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#bi.includes(e)}addConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#bi.push(e)}removeConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#bi.length;return this.#bi=this.#bi.filter(t=>t!==e),this.#bi.length!==t}hasPity(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#vi.has(e)}configurePity(e,t){if(this._checkDestroyed(),!this.#xi.has(e))throw new Error("Item not found");if("object"!=typeof t||null===t)throw new TypeError("cfg must be an object");const{threshold:r,increment:n,cap:i=1/0}=t;if("number"!=typeof r||r<=0)throw new TypeError("threshold must be a positive number");if("number"!=typeof n)throw new TypeError("increment must be a number");if("number"!=typeof i)throw new TypeError("cap must be a number");this.#vi.set(e,{threshold:Math.max(1,r),increment:Number(n)||0,cap:Number(i)||1/0,counter:0,currentAdd:0})}resetPity(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#vi.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){this._checkDestroyed(),this.#vi.clear()}hasExclusion(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#Ei.has(e)}excludeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ei.add(e)}includeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ei.delete(e)}_ensureGroup(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#Ti.get(e);return t||(t=new Set,this.#Ti.set(e,t)),t}hasInGroup(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Ti.get(t);return!!r&&r.has(e)}addToGroup(e,t){if(this._checkDestroyed(),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#xi.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(this._checkDestroyed(),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#Ti.get(t);r&&r.delete(e);const n=this.#xi.get(e);n&&n.groups.delete(t)}clearFreqs(){this._checkDestroyed(),this.#Ai.clear()}resetFreq(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#Ai.delete(e)}computeEffectiveWeights(e={}){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("computeEffectiveWeights: parameter 'context' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("computeEffectiveWeights: context.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("computeEffectiveWeights: context.metadata must be a non-null object if provided, got "+typeof e.metadata);const t=new Map;for(const[e,r]of this.#xi)t.set(e,r.baseWeight);for(const r of this.#yi){const n=r(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#wi){const n=r.fn(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#bi){const n=r(t,e);if(n instanceof Map)for(const[e,r]of n)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const[e,r]of this.#vi)if(t.has(e)&&r.counter>r.threshold){r.currentAdd=Math.min(r.cap,r.currentAdd+r.increment);const n=t.get(e);n&&t.set(e,n+r.currentAdd)}for(const e of this.#Ei)t.delete(e);for(const[e,r]of Array.from(t.entries()))r>0||t.delete(e);return t}_weightsToDistribution(e){if(this._checkDestroyed(),!(e instanceof Map))throw new TypeError("_weightsToDistribution: parameter 'weights' must be a Map, got "+typeof e);for(const[t,r]of e){if("string"!=typeof t)throw new TypeError("_weightsToDistribution: weights Map key must be string, got "+typeof t);if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError(`_weightsToDistribution: weights Map value must be finite non-negative number, got ${r} for key ${t}`)}const t=Array.from(e.entries()).map(([e,t])=>({id:e,weight:t}));if(0===t.length)return[];if("softmax"===this.#mi){const e=Math.max(...t.map(e=>e.weight)),r=t.map(t=>Math.exp(t.weight-e)),n=r.reduce((e,t)=>e+t,0);let i=0;return t.map((e,t)=>{const o=r[t]/n;return i+=o,{id:e.id,weight:e.weight,p:o,cumulative:i}})}{const e=t.reduce((e,t)=>e+t.weight,0);let r=0;return t.map(t=>{const n=t.weight/e;return r+=n,{id:t.id,weight:t.weight,p:n,cumulative:r}})}}drawOne(e={}){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("drawOne: parameter 'opts' must be a non-null object, got "+typeof e);if("previousDraws"in e&&!Array.isArray(e.previousDraws))throw new TypeError("drawOne: opts.previousDraws must be an array if provided, got "+typeof e.previousDraws);if("metadata"in e&&void 0!==e.metadata&&("object"!=typeof e.metadata||null===e.metadata))throw new TypeError("drawOne: opts.metadata must be a non-null object if provided, got "+typeof e.metadata);const t={previousDraws:e.previousDraws??[],metadata:e.metadata??{},activeModifiers:[...this.#wi]},r=this.computeEffectiveWeights(t),n=this._weightsToDistribution(r);if(!n.length)return null;const i=this.#Si(),o=n.find(e=>i<=e.cumulative)??n[n.length-1];for(const[e,t]of this.#vi)e===o.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const s=this.#xi.get(o.id);if(!s)return null;const a={id:s.id,label:s.label,meta:{...s.meta},prob:o.p};return this.#On("draw",a),a&&this.#Ai.set(a.id,(this.#Ai.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){this._checkDestroyed();for(let e=this.#wi.length-1;e>=0;--e){const t=this.#wi[e];t.uses-=1,t.uses<=0&&this.#wi.splice(e,1)}}drawMany(e=1,t={}){if(this._checkDestroyed(),!Number.isInteger(e)||e<=0)throw new TypeError(`drawMany: parameter 'count' must be a positive integer, got ${e}`);if("object"!=typeof t||null===t)throw new TypeError("drawMany: parameter 'opts' must be a non-null object, got "+typeof t);if("withReplacement"in t&&"boolean"!=typeof t.withReplacement)throw new TypeError("drawMany: opts.withReplacement must be boolean if provided, got "+typeof t.withReplacement);if("ensureUnique"in t&&"boolean"!=typeof t.ensureUnique)throw new TypeError("drawMany: opts.ensureUnique must be boolean if provided, got "+typeof t.ensureUnique);if("metadata"in t&&void 0!==t.metadata&&("object"!=typeof t.metadata||null===t.metadata))throw new TypeError("drawMany: opts.metadata must be a non-null object if provided, got "+typeof t.metadata);if("previousDraws"in t&&!Array.isArray(t.previousDraws))throw new TypeError("drawMany: opts.previousDraws must be an array if provided, got "+typeof t.previousDraws);const r=t.withReplacement??!0,n=t.ensureUnique??!1,i=[],o=t.previousDraws??[];if(!r&&n){const r=new Set;for(let n=0;n<e;++n){const e=new Set(this.#Ei);for(const e of r)this.#Ei.add(e);const n=this.drawOne({previousDraws:o,metadata:t.metadata});if(this.#Ei=e,!n)break;i.push(n),r.add(n.id),o.push(n)}return i}for(let n=0;n<e;++n){const e=this.drawOne({previousDraws:o,metadata:t.metadata});if(!e)break;i.push(e),o.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of i)this.includeItem(e.id);return i}exportToJson(){return this._checkDestroyed(),{items:Array.from(this.#xi.values()).map(e=>({id:e.id,label:e.label,baseWeight:e.baseWeight,meta:e.meta,groups:Array.from(e.groups),locked:!1})),pity:Array.from(this.#vi.entries()),exclusions:Array.from(this.#Ei),normalization:this.#mi,seed:this.#gi}}loadFromJson(e){if(this._checkDestroyed(),"object"!=typeof e||null===e)throw new TypeError("data must be a non-null object");if(!Array.isArray(e.items)||!Array.isArray(e.pity)||!Array.isArray(e.exclusions))throw new TypeError("data must have items, pity, and exclusions arrays");if("string"!=typeof e.normalization)throw new TypeError("data.normalization must be a string");if(void 0!==e.seed&&null!==e.seed&&"number"!=typeof e.seed)throw new TypeError("data.seed must be a number, null, or undefined");this.clearList();for(const t of e.items){if("object"!=typeof t||null===t)throw new TypeError("Each item must be a non-null object");if("string"!=typeof t.id||!t.id.trim())throw new TypeError("Each item.id must be a non-empty string");if("string"!=typeof t.label)throw new TypeError(`Item with id "${t.id}" has invalid label; must be string`);if("number"!=typeof t.baseWeight||!Number.isFinite(t.baseWeight)||t.baseWeight<0)throw new TypeError(`Item with id "${t.id}" has invalid baseWeight; must be a finite non-negative number`);if(void 0!==t.groups&&!Array.isArray(t.groups))throw new TypeError(`Item with id "${t.id}" has invalid groups; must be an array of strings`);if(t.groups&&!t.groups.every(e=>"string"==typeof e))throw new TypeError(`Item with id "${t.id}" has groups containing non-string values`);if(void 0!==t.meta&&("object"!=typeof t.meta||null===t.meta))throw new TypeError(`Item with id "${t.id}" has invalid meta; must be an object`);this.#xi.set(t.id,{id:t.id,label:t.label,baseWeight:t.baseWeight,meta:t.meta||{},groups:new Set(t.groups||[]),locked:!1});for(const e of t.groups||[])this._ensureGroup(e).add(t.id)}this.pitySystems=new Map(e.pity||[]),this.exclusions=new Set(e.exclusions||[]),this.normalization=e.normalization,void 0!==e.seed&&(this.seed=e.seed)}clone(){this._checkDestroyed();const e=new Xt;return e.#mi=this.#mi,e.#gi=this.#gi,e.#yi=[...this.#yi],e.#wi=this.#wi.map(e=>({fn:e.fn,uses:e.uses})),e.#bi=[...this.#bi],e.#vi=new Map([...this.#vi.entries()].map(([e,t])=>[e,{...t}])),e.#Ei=new Set(this.#Ei),e.#Ti=new Map([...this.#Ti.entries()].map(([e,t])=>[e,new Set(t)])),e.#Si=this.#Si,e.#xi=new Map([...this.#xi.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#Ai=new Map(this.#Ai),e}_makeSeededRng(e){if(this._checkDestroyed(),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("seed must be a finite number");let t=e>>>0;return function(){t+=1831565813;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}destroy(){this.#mr||(this.#mr=!0,this.#vi.clear(),this.#Ei.clear(),this.#Ti.clear(),this.#xi.clear(),this.#Ai.clear(),this.#yi=[],this.#wi=[],this.#bi=[],this.#gi=null)}}const Qt=Xt,Zt=class{#ne;get data(){return this.#ne}set data(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ne=e}get size(){return Array.isArray(this.#ne)?this.#ne.length:this.#ne.size}constructor(e){if(!(Array.isArray(e)||e instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#ne=e}get({page:e,perPage:t,filter:r}){if(!Number.isInteger(e)||e<1)throw new RangeError("Page number must be a positive integer.");if(!Number.isInteger(t)||t<1)throw new RangeError("Items per page must be a positive integer.");const n=Array.isArray(this.#ne)?this.#ne:Array.from(this.#ne);let i=n;if(r)if("function"==typeof r)i=n.filter((e,t,n)=>r(e,t,n));else{if("object"!=typeof r)throw new TypeError("Filter must be an object or a function");i=n.filter(e=>Object.entries(r).every(([t,r])=>{const n=e[t];return r instanceof RegExp?r.test(n):n===r}))}else i=n;const o=i.length,s=Math.max(1,Math.ceil(o/t)),a=Math.min(e,s),l=(a-1)*t,u=l+t,c=a>1,h=a<s;return{items:i.slice(l,u),page:a,perPage:t,totalItems:o,totalPages:s,hasPrev:c,hasNext:h}}};class er{static#Ii=new Map;static get itemRegistry(){const e={},t=Object.fromEntries(er.#Ii);for(const r in t)e[r]={...t[r],metadata:{...t[r].metadata}};return e}static defineItem(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be a valid object.");if(!e.id||"string"!=typeof e.id)throw new TypeError("Item must have a valid string 'id'.");if(void 0!==e.weight&&("number"!=typeof e.weight||e.weight<0))throw new TypeError(`weight must be a number >= 0. Received: ${e.weight}`);if(void 0!==e.maxStack&&(!Number.isInteger(e.maxStack)||e.maxStack<=0))throw new TypeError(`maxStack must be a positive integer. Received: ${e.maxStack}`);if(void 0!==e.metadata&&"object"!=typeof e.metadata)throw new TypeError("metadata must be an object.");if(void 0!==e.onUse&&null!==e.onUse&&"function"!=typeof e.onUse)throw new TypeError("onUse must be a function or null.");if(void 0!==e.type&&null!==e.type&&"string"!=typeof e.type)throw new TypeError("type must be a string or null.");er.#Ii.set(e.id,{id:e.id,weight:e.weight||0,maxStack:e.maxStack||1,metadata:e.metadata||{},type:e.type??null,onUse:"function"==typeof e.onUse?e.onUse:null})}static removeItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return er.#Ii.delete(e)}static hasItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");return er.#Ii.has(e)}static getItem(e){if("string"!=typeof e)throw new TypeError("itemId must be a string.");const t=er.#Ii.get(e);if(!t)throw new Error(`Item '${e}' not defined in registry.`);return t}#Ci=new Map;#Mt={add:[],remove:[],use:[],set:[]};#xi=[];#Mi;#Li;#Ni;#ki;get maxStack(){return this.#Mi}set maxStack(e){if(!Number.isInteger(e)||Number.isFinite(e)&&e<=0)throw new TypeError(`maxStack must be a positive integer. Received: ${e}`);this.#Mi=e}get maxSize(){return this.#Li}set maxSize(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSize must be null or a positive integer. Received: ${e}`);this.#Li=e}get maxSlots(){return this.#Ni}set maxSlots(e){if(null!==e&&(!Number.isInteger(e)||e<=0))throw new TypeError(`maxSlots must be null or a positive integer. Received: ${e}`);this.#Ni=e}get maxWeight(){return this.#ki}set maxWeight(e){if(null!==e&&("number"!=typeof e||e<=0))throw new TypeError(`maxWeight must be null or a positive number. Received: ${e}`);this.#ki=e}get events(){return{add:[...this.#Mt.add],remove:[...this.#Mt.remove],use:[...this.#Mt.use],set:[...this.#Mt.set]}}get items(){return[...this.#xi].map(e=>e?this.#Di(e):null)}get specialSlots(){return new Map([...this.#Ci.entries()].map(([e,t])=>[e,{type:t.type,item:t.item?this.#Di(t.item):null}]))}get size(){const e=this.getAllItems();let t=0;for(const r of e)t+=r.quantity;return t}get slotsSize(){return this.getAllItems().length}get weight(){return this.getAllItems().reduce((e,t)=>{const r=er.getItem(t.id);return e+(r?.weight||0)*t.quantity},0)}_cleanNulls(){let e=this.#xi.length-1;for(;e>=0&&null===this.#xi[e];)e--;this.#xi=this.#xi.slice(0,e+1)}constructor(e={}){if("object"!=typeof e||null===e)throw new TypeError("`options` must be an object.");if(void 0!==e.maxWeight&&null!==e.maxWeight&&"number"!=typeof e.maxWeight)throw new TypeError("`maxWeight` must be a number or null.");if(void 0!==e.maxSlots&&null!==e.maxSlots&&"number"!=typeof e.maxSlots)throw new TypeError("`maxSlots` must be a number or null.");if(void 0!==e.maxSize&&null!==e.maxSize&&"number"!=typeof e.maxSize)throw new TypeError("`maxSize` must be a number or null.");if(void 0!==e.maxStack&&"number"!=typeof e.maxStack)throw new TypeError("`maxStack` must be a number.");if(void 0!==e.specialSlots&&"object"!=typeof e.specialSlots)throw new TypeError("`specialSlots` must be an object if defined.");if(this.#ki=e.maxWeight??null,this.#Ni=e.maxSlots??null,this.#Li=e.maxSize??null,this.#Mi=e.maxStack??1/0,e.specialSlots)for(const t in e.specialSlots){const r=e.specialSlots[t];if("object"!=typeof r||null===r)throw new TypeError("Each `specialSlot` entry must be an object.");if(void 0!==r.type&&null!==r.type&&"string"!=typeof r.type)throw new TypeError("`specialSlot.type` must be a string or null.");this.#Ci.set(t,{type:r.type??null,item:null})}}hasSpace({weight:e=0,sizeLength:t=0,slotsLength:r=0}={}){if("number"!=typeof e)throw new TypeError("`weight` must be a number.");if("number"!=typeof t)throw new TypeError("`sizeLength` must be a number.");if("number"!=typeof r)throw new TypeError("`slotsLength` must be a number.");return!(this.areFull(t)||this.areFullSlots(r)||this.isHeavy(e))}isHeavy(e=0){if("number"!=typeof e)throw new TypeError("`extraWeight` must be a number.");return null!==this.#ki&&this.weight+e>this.#ki}areFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Li&&this.size+e>this.#Li}isFull(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Li&&this.size+e>=this.#Li}areFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Ni&&this.slotsSize+e>this.#Ni}isFullSlots(e=0){if("number"!=typeof e)throw new TypeError("`extraLength` must be a number.");return null!==this.#Ni&&this.slotsSize+e>=this.#Ni}#_i(e,t){if("string"!=typeof e)throw new TypeError("`type` must be a string.");if("object"!=typeof t||null===t)throw new TypeError("`payload` must be an object.");if(this.#Mt[e])for(const r of this.#Mt[e])r(t)}off(e,t){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");if("function"!=typeof t)throw new TypeError("`callback` must be a function.");if(!this.#Mt[e])return;const r=this.#Mt[e],n=r.indexOf(t);-1!==n&&r.splice(n,1)}offAll(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");this.#Mt[e]&&(this.#Mt[e]=[])}cloneEventCallbacks(e){if("string"!=typeof e)throw new TypeError("`eventType` must be a string.");return this.#Mt[e]?[...this.#Mt[e]]:[]}onAddItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Mt.add.push(e)}onSetItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Mt.set.push(e)}onRemoveItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Mt.remove.push(e)}onUseItem(e){if("function"!=typeof e)throw new TypeError("`callback` must be a function.");this.#Mt.use.push(e)}compactInventory(){this.#xi=this.#xi.filter((e,t)=>{const r=null!==e;return r||this.#_i("remove",{index:t,item:null,isCollection:!0,specialSlot:null,remove:()=>{}}),r})}addItem({itemId:e,quantity:t=1,metadata:r={},forceSpace:n=!1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<=0)throw new TypeError("`quantity` must be a positive number.");if("object"!=typeof r||null===r)throw new TypeError("`metadata` must be an object.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be a boolean.");const i=er.getItem(e);let o=t;const s=i.maxStack<=this.#Mi?i.maxStack:this.#Mi,a=[],l=(e,t)=>JSON.stringify(e)===JSON.stringify(t);let u=!0;for(;o>0&&u;){u=!1;for(const t in this.#xi){const c=this.#xi[t];if(c&&c.id===e&&c.quantity<s&&l(c.metadata,r)){const e=Math.min(s-c.quantity,o);if(!n&&!this.hasSpace({weight:i.weight*e,sizeLength:e}))continue;c.quantity+=e,o-=e,u=!0;const r=Number(t),l=a.findIndex(e=>e.index===r);if(l<0?a.push({index:r,quantity:e}):a[l].quantity+=e,this.#_i("add",{item:this.#Di(c),index:r,isCollection:!0,specialSlot:null,remove:this.#ji({locationType:"normal",slotIndex:r,forceSpace:n,item:c})}),o<=0)break}}}if(o>0)for(const t in this.#xi)if(null===this.#xi[t]){const l=Math.min(s,o);if(!n&&!this.hasSpace({weight:i.weight*l,sizeLength:l}))continue;const u={id:e,quantity:l,metadata:r};this.#xi[t]=u,o-=l;const c=Number(t),h=a.findIndex(e=>e.index===c);if(h<0?a.push({index:c,quantity:l}):a[h].quantity+=l,this.#_i("add",{item:this.#Di(u),index:c,isCollection:!0,specialSlot:null,remove:this.#ji({locationType:"normal",slotIndex:c,forceSpace:n,item:u})}),o<=0)break}for(;o>0;){const t=Math.min(s,o);if(!n&&!this.hasSpace({weight:i.weight*t,sizeLength:t,slotsLength:1}))break;const l={id:e,quantity:t,metadata:r};this.#xi.push(l);const u=this.#xi.length-1,c=a.findIndex(e=>e.index===u);c<0?a.push({index:u,quantity:t}):a[c].quantity+=t,this.#_i("add",{item:this.#Di(l),index:u,isCollection:!0,specialSlot:null,remove:this.#ji({locationType:"normal",slotIndex:u,forceSpace:n,item:l})}),o-=t}return{remaining:o,placesAdded:a}}getItemFrom(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if(e<0||e>=this.#xi.length)throw new Error(`Slot index '${e}' out of bounds .`);return this.#xi[e]?this.#Di(this.#xi[e]):null}setItem({slotIndex:e,item:t,forceSpace:r=!1}){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const n=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!n)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const i=t?er.#Ii.get(t.id):null;if(null!==t&&!i)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);if(i&&t){const e=i.maxStack<=this.#Mi?i.maxStack:this.#Mi;if(t.quantity>e)throw new Error(`Item '${t.id}' exceeds max stack size. Allowed: ${e}, got: ${t.quantity}.`)}if(null!==this.#Ni&&(e<0||e>=this.#Ni))throw new Error(`Slot index ${e} out of range.`);const o=this.#xi[e]??null,s=o?er.#Ii.get(o.id)??null:null,a=(e,t)=>t?t.weight*(e?e.quantity:0):0,l=e=>e?e.quantity:0;if(!r&&!this.hasSpace({weight:a(t,i)-a(o,s),sizeLength:l(t)-l(o)}))throw new Error("Inventory is full or overweight.");for(;this.#xi.length<=e;)this.#xi.push(null);this.#xi[e]=t,this._cleanNulls(),this.#_i("set",{index:e,isCollection:!0,item:t?this.#Di(t):null,specialSlot:null,remove:t?this.#ji({locationType:"normal",slotIndex:e,forceSpace:r,item:t}):()=>{}})}deleteItem(e,t=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be a boolean.");this.setItem({slotIndex:e,item:null,forceSpace:t})}moveItem(e,t,r=!1){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`fromIndex` must be an integer.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`toIndex` must be an integer.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be a boolean.");const n=this.#xi[e];if(!n)throw new Error(`No item found in slot ${e}.`);this.setItem({slotIndex:t,item:n,forceSpace:r}),this.setItem({slotIndex:e,item:null,forceSpace:r})}removeItem({itemId:e,metadata:t=null,quantity:r=1}){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if(null!==t&&"object"!=typeof t)throw new TypeError("`metadata` must be an object or null.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");let n=r;const i=(e,t)=>JSON.stringify(e)===JSON.stringify(t);for(let r=0;r<this.#xi.length;r++){const o=this.#xi[r];if(o&&o.id===e&&(null===t||i(o.metadata,t))){const e=Math.min(o.quantity,n);o.quantity-=e,n-=e;const t=Number(r);if(o.quantity<=0&&(this.#xi[r]=null),n<=0)return this._cleanNulls(),this.#_i("remove",{index:t,item:this.#Di(o),isCollection:!0,specialSlot:null,remove:this.#ji({locationType:"normal",slotIndex:t,item:o})}),!0}}return this._cleanNulls(),this.#Ci.forEach((r,o)=>{if(n>0&&r.item&&r.item.id===e&&(null===t||i(r.item.metadata,t))){const e=Math.min(r.item.quantity,n);r.item.quantity-=e,r.item.quantity<0&&(r.item.quantity=0),n-=e,r.item.quantity<=0&&(r.item=null),this.#Ci.set(o,r),this.#_i("remove",{index:null,item:r.item?this.#Di(r.item):null,isCollection:!1,specialSlot:o,remove:r.item?this.#ji({locationType:"special",specialSlot:o,item:r.item}):()=>{}})}}),n<=0}#ji({locationType:e,specialSlot:t,slotIndex:r,item:n,forceSpace:i=!1}){if("normal"!==e&&"special"!==e)throw new TypeError("`locationType` must be 'normal' or 'special'.");if("boolean"!=typeof i)throw new TypeError("`forceSpace` must be boolean.");if(!n||"object"!=typeof n)throw new TypeError("`item` must be an InventoryItem object.");if("special"===e&&t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string when locationType is 'special'.");if("normal"===e&&"number"!=typeof r)throw new TypeError("`slotIndex` must be a number when locationType is 'normal'.");return(o=i)=>{if("special"===e&&t){const e=this.#Ci.get(t);if(!e?.item)throw new Error(`Special slot '${t}' is empty.`);e.item.quantity>1?(e.item.quantity-=1,this.#Ci.set(t,e)):this.setSpecialSlot({slotId:t,item:null,forceSpace:o})}else{if("number"!=typeof r)throw new Error("Invalid remove operation: no valid slotIndex or specialSlot provided.");n.quantity>1?this.setItem({slotIndex:r,item:{...n,quantity:n.quantity-1},forceSpace:o}):this.setItem({slotIndex:r,item:null,forceSpace:o})}}}useItem({slotIndex:e,specialSlot:t,forceSpace:r=!1},...n){if(void 0!==e&&("number"!=typeof e||!Number.isInteger(e)))throw new TypeError("`slotIndex` must be an integer if provided.");if(void 0!==t&&"string"!=typeof t)throw new TypeError("`specialSlot` must be a string if provided.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");let i=null,o="normal",s=null;if(t){if(!this.#Ci.has(t))throw new Error(`Special slot '${t}' not found.`);i=this.#Ci.get(t).item,o="special"}else s=this.#xi,i=s[e??-1]??null,o="normal";if(!i)throw new Error("special"===o?`No item found in special slot '${t}'.`:`No item found in slot ${e} of inventory.`);const a=er.getItem(i.id);if(a.onUse){const l={inventory:this,item:this.#Di(i),index:e??null,specialSlot:t??null,isCollection:!!s,itemDef:a,remove:this.#ji({locationType:o,specialSlot:t,slotIndex:e,forceSpace:r,item:i}),...n},u=a.onUse(l);return this.#_i("use",l),u}return null}hasSpecialSlot(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");return this.#Ci.has(e)}getSpecialItem(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Ci.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Ci.get(e);return t?.item?this.#Di(t.item):null}getSpecialSlotType(e){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(!this.#Ci.has(e))throw new Error(`Special slot '${e}' does not exist.`);const t=this.#Ci.get(e);return t?.type??null}setSpecialSlot({slotId:e,item:t,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Ci.has(e))throw new Error(`Special slot '${e}' not found.`);const n=t&&"object"==typeof t&&"string"==typeof t.id&&"number"==typeof t.quantity&&!Number.isNaN(t.quantity)&&Number.isFinite(t.quantity)&&t.quantity>-1&&"object"==typeof t.metadata;if(null!==t&&!n)throw new Error("Invalid item type: must be null or a valid InventoryItem.");const i=t?er.#Ii.get(t.id):null;if(null!==t&&!i)throw new Error(`Item '${t?.id??"unknown"}' not defined in registry.`);const o=this.#Ci.get(e);if(!o)throw new Error(`Special slot ${e} out of range for slot '${e}'.`);const s=o.item?er.#Ii.get(o.item.id):null,a=(e,t)=>t?t.weight*(e?1:0):0,l=e=>e?1:0;if(!r&&!this.hasSpace({weight:a(t,i)-a(o.item,s),sizeLength:l(t)-l(o.item)}))throw new Error("Inventory is full or overweight.");o.item=t,this.#_i("set",{index:null,item:t?this.#Di(t):null,isCollection:!1,specialSlot:e,remove:t?this.#ji({locationType:"special",specialSlot:e,forceSpace:r,item:t}):()=>{}})}deleteSpecialItem(e,t=!1){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("boolean"!=typeof t)throw new TypeError("`forceSpace` must be boolean.");this.setSpecialSlot({slotId:e,item:null,forceSpace:t})}equipItem({slotId:e,slotIndex:t,quantity:r=1,forceSpace:n=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if("number"!=typeof t||!Number.isInteger(t))throw new TypeError("`slotIndex` must be an integer.");if("number"!=typeof r||!Number.isFinite(r)||r<=0)throw new TypeError("`quantity` must be a positive number.");if("boolean"!=typeof n)throw new TypeError("`forceSpace` must be boolean.");if(r<=0||!Number.isFinite(r))throw new Error(`Invalid quantity '${r}'.`);if(!this.#Ci.has(e))throw new Error(`Special slot '${e}' does not exist.`);const i=this.getItemFrom(t);if(!i)throw new Error(`No item found in inventory slot ${t}.`);if(i.quantity<r)throw new Error(`Not enough quantity of item '${i.id}' in inventory slot.`);const o=er.getItem(i.id),s=this.#Ci.get(e);if(!s)throw new Error(`Slot '${e}' not defined in registry.`);const a=s.type??null;if(null!==a&&o.type!==a)throw new Error(`Item '${i.id}' cannot be equipped in slot '${e}'.`);const l=Math.min(o.maxStack,this.#Mi);if(s.item&&s.item.id===i.id){const t=Math.max(0,l-s.item.quantity);if(t<=0)return r;const n=Math.min(r,t);return this.removeItem({itemId:i.id,quantity:n,metadata:null}),s.item.quantity+=n,this.#Ci.set(e,s),r-n}s.item&&this.unequipItem({slotId:e,forceSpace:n});const u=Math.min(r,l);return this.removeItem({itemId:i.id,quantity:u,metadata:null}),s.item={id:i.id,quantity:u,metadata:i.metadata},this.#Ci.set(e,s),r-u}unequipItem({slotId:e,quantity:t=null,forceSpace:r=!1}){if("string"!=typeof e)throw new TypeError("`slotId` must be a string.");if(null!==t&&("number"!=typeof t||!Number.isFinite(t)||t<=0))throw new TypeError("`quantity` must be a positive number or null.");if("boolean"!=typeof r)throw new TypeError("`forceSpace` must be boolean.");if(!this.#Ci.has(e))throw new Error(`Special slot '${e}' does not exist.`);const n=this.#Ci.get(e);if(!n)throw new Error(`Slot '${e}' not defined in registry.`);if(!n.item)return!1;const i=n.item,o=null===t?i.quantity:t;if(o<=0)throw new Error(`Invalid unequip quantity: ${o}`);if(o>i.quantity)throw new Error(`Not enough items in slot '${e}' to unequip.`);return this.addItem({itemId:i.id,quantity:o,metadata:i.metadata,forceSpace:r}),o===i.quantity?n.item=null:(i.quantity-=o,n.item=i),this.#Ci.set(e,n),!0}#Di(e){if(!e||"object"!=typeof e)throw new TypeError("`item` must be an InventoryItem object.");if("string"!=typeof e.id)throw new TypeError("`item.id` must be a string.");if("number"!=typeof e.quantity||!Number.isFinite(e.quantity))throw new TypeError("`item.quantity` must be a finite number.");if(!e.metadata||"object"!=typeof e.metadata)throw new TypeError("`item.metadata` must be an object.");return{id:e.id,quantity:e.quantity,metadata:{...e.metadata}}}getItemList(){return[...this.#xi].map((e,t)=>[e?this.#Di(e):null,t]).filter(e=>null!==e[0])}getAllItems(){const e=[...this.#xi].filter(e=>null!==e).map(this.#Di);return this.#Ci.forEach(t=>{const r=t.item;r&&e.push(r)}),e}getItemsByMetadata(e){if("function"!=typeof e)throw new TypeError("`filterFn` must be a function.");return this.getAllItems().filter(t=>{const r=er.getItem(t.id);return e(r.metadata,t)})}findItem(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().find(e)}findItems(e){if("function"!=typeof e)throw new TypeError("`predicate` must be a function.");return this.getAllItems().filter(e)}getItemCount(e){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");return this.getAllItems().filter(t=>t.id===e).reduce((e,t)=>e+t.quantity,0)}hasItem(e,t=1){if("string"!=typeof e)throw new TypeError("`itemId` must be a string.");if("number"!=typeof t||!Number.isFinite(t)||t<0)throw new TypeError("`quantity` must be a non-negative number.");return this.getItemCount(e)>=t}existsItemAt(e){if("number"!=typeof e||!Number.isInteger(e))throw new TypeError("`slotIndex` must be an integer.");return!!this.#xi[e]}clear(){this.clearAllItems(),this.clearAllEvents()}clearAllEvents(){this.#Mt={add:[],remove:[],use:[],set:[]}}clearAllItems(){this.clearItems(),this.clearSpecialItems()}clearItems(){for(let e=this.#xi.length-1;e>=0;e--)this.#xi[e]&&this.deleteItem(e,!0)}clearSpecialItems(){for(const e of this.#Ci.keys()){const t=this.#Ci.get(e);t?.item&&this.deleteSpecialItem(e,!0)}}clone(){const e=this.toObject();return er.fromObject(e)}toObject(){const e={};for(const[t,r]of this.#Ci.entries())e[t]={type:r?.type??null,item:r?.item?this.#Di(r.item):null};return{__schema:"TinyInventory",version:1,maxWeight:this.#ki,maxSlots:this.#Ni,maxSize:this.#Li,maxStack:this.#Mi,items:this.#xi.map(e=>e?this.#Di(e):null),specialSlots:e}}toJSON(e=0){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("`space` must be a non-negative number.");return JSON.stringify(this.toObject(),null,e)}static fromObject(e){if(!e||"object"!=typeof e)throw new TypeError("Invalid state: expected object.");if("TinyInventory"!==e.__schema||"number"!=typeof e.version)throw new TypeError("Invalid or missing schema header.");if(1!==e.version)throw new TypeError(`Unsupported TinyInventory state version: ${e.version}`);const t={};if(e.specialSlots&&"object"==typeof e.specialSlots)for(const r of Object.keys(e.specialSlots))t[r]={type:e.specialSlots[r]?.type??null};const r=new er({maxWeight:e.maxWeight??null,maxSlots:e.maxSlots??null,maxSize:e.maxSize??null,maxStack:e.maxStack??null,specialSlots:t});if(Array.isArray(e.items))for(const t in e.items){const n=e.items[t];if(null!==n){const e={id:String(n.id),quantity:Math.max(1,Number(n.quantity)||1),metadata:n.metadata&&"object"==typeof n.metadata?n.metadata:{}};r.setItem({slotIndex:Number(t),item:e,forceSpace:!0})}else r.setItem({slotIndex:Number(t),item:null,forceSpace:!0})}if(e.specialSlots&&"object"==typeof e.specialSlots)for(const[t,n]of Object.entries(e.specialSlots)){if(!r.hasSpecialSlot(t))continue;const e=n?.item;if(e&&e.id){const n={id:String(e.id),quantity:Math.max(1,Number(e.quantity)||1),metadata:e.metadata&&"object"==typeof e.metadata?e.metadata:{}};r.setSpecialSlot({slotId:t,item:n,forceSpace:!0})}}return r}static fromJSON(e){if("string"!=typeof e)throw new TypeError("`json` must be a string.");const t=JSON.parse(e);return er.fromObject(t)}}const tr=er,rr=class{#Ri=null;#Oi=null;get sender(){return this.#Ri}get receiver(){return this.#Oi}set sender(e){if(!(e instanceof tr&&this.receiver instanceof tr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Ri=e}set receiver(e){if(!(this.sender instanceof tr&&e instanceof tr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Oi=e}constructor(e,t){if(e||t){if(!(e instanceof tr&&t instanceof tr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.connect(e,t)}}connect(e,t){if(!(e instanceof tr&&t instanceof tr))throw new Error("Both sender and receiver must be TinyInventory instances.");this.#Ri=e,this.#Oi=t}disconnect(){this.#Ri=null,this.#Oi=null}invert(){const e=this.#Ri,t=this.#Oi;this.#Ri=t,this.#Oi=e}transferItem({slotIndex:e,specialSlot:t,quantity:r=1,receiverSlotIndex:n,forceSpace:i=!1,strict:o=!1}){if(!this.#Ri||!this.#Oi)throw new Error("Sender and receiver inventories must be connected.");let s;if(t){if(s=this.#Ri.getSpecialItem(t),!s)throw new Error(`No item found in sender special slot '${t}'.`)}else{if("number"!=typeof e)throw new Error("Must provide either slotIndex or specialSlot.");if(s=this.#Ri.getItemFrom(e),!s)throw new Error(`No item found in sender slot ${e}.`)}if(s.quantity<r)throw new Error(`Sender does not have enough quantity of '${s.id}' to transfer.`);const a={id:s.id,quantity:r,metadata:s.metadata};let l;if(o)if("number"==typeof n){const e=this.#Oi.existsItemAt(n)?this.#Oi.getItemFrom(n):null;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${n} contains a different item.`);const t=tr.getItem(e.id).maxStack-e.quantity;if(a.quantity>t)throw new Error(`Strict mode: not enough space in receiver slot ${n}.`)}}else if(this.#Oi.clone().addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:i}).remaining>0)throw new Error("Strict mode: not enough space in receiver inventory.");if("number"==typeof n){const e=this.#Oi.existsItemAt(n)?this.#Oi.getItemFrom(n):null;let t=a.quantity;if(e){if(e.id!==a.id)throw new Error(`Receiver slot ${n} contains a different item.`);const r=tr.getItem(e.id).maxStack-e.quantity;t=Math.min(r,a.quantity),t>0&&this.#Oi.setItem({slotIndex:n,item:{...e,quantity:e.quantity+t},forceSpace:i})}else this.#Oi.setItem({slotIndex:n,item:a,forceSpace:i});l={remaining:a.quantity-t}}else l=this.#Oi.addItem({itemId:a.id,quantity:a.quantity,metadata:a.metadata,forceSpace:i});const u=a.quantity-l.remaining;if(u>0)if(t)this.#Ri.unequipItem({slotId:t,quantity:u,forceSpace:i});else if("number"==typeof e){const t=s.quantity-u;this.#Ri.setItem({slotIndex:e,item:t>0?{...s,quantity:t}:null,forceSpace:i})}return l}transferMultiple(e){return e.map(e=>this.transferItem(e))}},nr=class{#Hi;#Bi={message:"We use cookies to improve your experience.",acceptText:"Accept All",rejectText:"Reject All",settingsText:"Manage Settings",categories:[],storageKey:"cookie-consent-preferences",onSave:e=>console.log("Preferences saved:",e),animationDuration:400,renderBar:null,renderModal:null};get preferences(){const e=localStorage.getItem(this.#Bi.storageKey);return e?JSON.parse(e):{}}get config(){return{...this.#Bi,categories:[...this.#Bi.categories]}}set config(e){this.validateConfig(e),this.#Bi=Object.assign(this.#Bi,e)}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("Config must be an object.");this.config=e;const t=this.loadPreferences();this.#Hi=t??{},t||this.showConsentBar()}validateConfig(e){if(void 0!==e.message&&"string"!=typeof e.message)throw new TypeError("Config.message must be a string.");if(["acceptText","rejectText","settingsText","storageKey"].forEach(t=>{if(void 0!==e[t]&&"string"!=typeof e[t])throw new TypeError(`Config.${t} must be a string.`)}),void 0!==e.categories){if(!Array.isArray(e.categories))throw new TypeError("Config.categories must be an array of Category objects.");e.categories.forEach((e,t)=>this.validateCategory(e,t))}if(void 0!==e.onSave&&"function"!=typeof e.onSave)throw new TypeError("Config.onSave must be a function.");if(void 0!==e.animationDuration&&("number"!=typeof e.animationDuration||e.animationDuration<0))throw new TypeError("Config.animationDuration must be a positive number.");if(void 0!==e.renderBar&&null!==e.renderBar&&"function"!=typeof e.renderBar)throw new TypeError("Config.renderBar must be a function or null.");if(void 0!==e.renderModal&&null!==e.renderModal&&"function"!=typeof e.renderModal)throw new TypeError("Config.renderModal must be a function or null.")}validateCategory(e,t){if(!e||"object"!=typeof e)throw new TypeError(`Category at index ${t} must be an object.`);if("string"!=typeof e.label)throw new TypeError(`Category.label at index ${t} must be a string.`);if("boolean"!=typeof e.required)throw new TypeError(`Category.required at index ${t} must be a boolean.`);if("boolean"!=typeof e.default)throw new TypeError(`Category.default at index ${t} must be a boolean.`)}loadPreferences(){const e=localStorage.getItem(this.#Bi.storageKey);return e?JSON.parse(e):null}removeWithAnimation(e){if(!(e instanceof HTMLElement))throw new TypeError("removeWithAnimation expects an HTMLElement.");e.classList.add("closing"),setTimeout(()=>e.remove(),this.#Bi.animationDuration)}savePreferences(e){if(!e||"object"!=typeof e)throw new TypeError("Preferences must be an object.");localStorage.setItem(this.#Bi.storageKey,JSON.stringify(e)),this.#Bi.onSave(e)}showConsentBar(){const e=document.createElement("div");e.className="cookie-consent-bar",e.innerHTML=this.#Bi.renderBar?this.#Bi.renderBar(this.#Bi):`\n <div><p>${this.#Bi.message}</p></div>\n <div><button class="accept">${this.#Bi.acceptText}</button></div>\n <div><button class="reject">${this.#Bi.rejectText}</button></div>\n <div><button class="settings">${this.#Bi.settingsText}</button></div>\n `,document.body.appendChild(e);const t=e.querySelector(".accept");t instanceof HTMLElement&&(t.onclick=()=>{const t={};this.#Bi.categories.forEach(e=>t[e.label]=!0),this.savePreferences(t),this.removeWithAnimation(e)});const r=e.querySelector(".reject");r instanceof HTMLElement&&(r.onclick=()=>{const t={};this.#Bi.categories.forEach(e=>t[e.label]=e.required),this.savePreferences(t),this.removeWithAnimation(e)});const n=e.querySelector(".settings");n instanceof HTMLElement&&(n.onclick=()=>this.showSettingsModal(e))}showSettingsModal(e){const t=document.createElement("div");t.className="cookie-consent-modal",t.innerHTML=this.#Bi.renderModal?this.#Bi.renderModal(this.#Bi):`\n <div class="modal-content">\n <h2>Cookie Settings</h2>\n <form class="settings-form">\n ${this.#Bi.categories.map(e=>`\n <label>\n <input type="checkbox" name="${e.label}" \n ${e.default?"checked":""} \n ${e.required?"disabled":""}>\n ${e.label}\n </label>\n `).join("")}\n </form>\n <button class="save">Save Preferences</button>\n </div>\n `,document.body.appendChild(t);const r=t.querySelector(".save");r instanceof HTMLElement&&(r.onclick=()=>{const r={};t.querySelectorAll("input[type=checkbox]").forEach(e=>{e instanceof HTMLInputElement&&(r[e.name]=e.checked)}),this.savePreferences(r),this.removeWithAnimation(t),e&&this.removeWithAnimation(e)})}isAllowed(e){if("string"!=typeof e)throw new TypeError("isAllowed expects a string as category.");return!!this.#Hi&&!!this.#Hi[e]}};var ir=r(911),or=r(766);const sr=class{static async mergeLocaleFiles({files:e,output:t,spaces:r=0}){if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError('mergeLocaleFiles: "spaces" must be a non-negative number');if(!Array.isArray(e)||0===e.length)throw new TypeError('mergeLocaleFiles: "files" must be a non-empty array of file paths');if("string"!=typeof t||!t)throw new TypeError('mergeLocaleFiles: "output" must be a non-empty string path');const n={};for(const t of e){if("string"!=typeof t||!t)throw new TypeError("mergeLocaleFiles: each file path must be a non-empty string");if(!(0,or.existsSync)(t))throw new Error(`mergeLocaleFiles: file "${t}" does not exist`);const e=await(0,ir.readFile)(t,"utf-8");let r;try{r=JSON.parse(e)}catch(e){throw new Error(`mergeLocaleFiles: file "${t}" is not valid JSON`)}Object.assign(n,r)}await(0,ir.writeFile)(t,JSON.stringify(n,null,r),"utf-8")}#$i;#Pi;#Fi=null;#Wi;#zi=null;#qi=new Map;#Vi=new Map;#Ki=new Map;#Ui=new Map;get currentLocale(){return this.#Fi}get defaultLocale(){return this.#Pi}get mode(){return this.#$i}get strict(){return this.#Wi}get basePath(){return this.#zi}get stats(){const e=[];for(const t of this.#qi.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){const e={};for(const[t,r]of this.#qi.entries())e[t]=this.#Ji(r);return e}get patternTables(){const e={};for(const[t,r]of this.#Vi.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#Ji(e.value),elseValue:this.#Ji(e.elseValue)}));return e}get helpers(){const e={};for(const[t,r]of this.#Ki.entries())e[t]=r;return e}get regexCache(){const e={};for(const[t,r]of this.#Ui.entries())e[t]=new RegExp(r.source,r.flags);return e}#Ji(e){if(null==e||"string"==typeof e||"function"==typeof e||"number"==typeof e)return e;if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(e=>this.#Ji(e));if("object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=this.#Ji(n);return t}return e}#Gi(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('#resolveOrder: "forceLocale" must be a string if provided');const t=[];return e&&"string"==typeof e&&this.#qi.has(e)?t.push(e):this.#Fi&&t.push(this.#Fi),t.push(this.#Pi),t}#Yi(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveExact: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveExact: "key" must be a non-empty string');for(const r of e){const e=this.#qi.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#Xi(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveByPattern: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveByPattern: "key" must be a non-empty string');for(const r of e){const e=this.#Vi.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#Qi(e,t){if(null==e){if(this.#Wi)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#Zi(e,t);if("function"==typeof e)return e(t??{},this.#eo());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#Ki.get(e.$fn);if("function"!=typeof r){if(this.#Wi)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#eo())}if(this.#Wi)throw new Error("TinyI18: unsupported entry type");return""}#Zi(e,t){if("string"!=typeof e)throw new TypeError('#interpolate: "template" must be a string');if(void 0!==t&&(null===t||"object"!=typeof t))throw new TypeError('#interpolate: "params" must be an object if provided');return t&&"object"==typeof t?e.replace(/\{([a-zA-Z0-9_.$-]+)\}/g,(e,r)=>{const n=this.#to(t,r);return null==n?"":String(n)}):e}#to(e,t){if(!e||"object"!=typeof e)throw new TypeError('#dotGet: "obj" must be an object');if("string"!=typeof t||!t)throw new TypeError('#dotGet: "path" must be a non-empty string');const r=t.split(".");let n=e;for(const e of r){if(null==n)return;n=n[e]}return n}#eo(){return{has:e=>this.#Ki.has(e),call:(e,t,r)=>{const n=this.#Ki.get(e);if("function"!=typeof n)throw new Error(`Helper "${e}" not found`);return n(t,r??{})}}}#ro(e,t){if("string"!=typeof e||!e)throw new TypeError('#ingestLocale: "locale" must be a non-empty string');if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');if("string"!=typeof e||!e)throw new TypeError("#ingestLocale: invalid locale");if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');const r={...this.#qi.get(e)??{}},n=[...this.#Vi.get(e)??[]],i=(e,t)=>{if(null!=t)if("string"==typeof t||"function"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");r[e]=t}else if(t&&"object"==typeof t){if(t.$pattern instanceof RegExp&&Object.prototype.hasOwnProperty.call(t,"value"))return void n.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,n]of Object.entries(t))i(e?`${e}.${r}`:r,n)}};i("",t),this.#qi.set(e,r),this.#Vi.set(e,n),this.#qi.has(this.#Pi)||(this.#qi.set(this.#Pi,{}),this.#Vi.set(this.#Pi,[]))}#no(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#Pi&&(this.#qi.delete(e),this.#Vi.delete(e))}async#io(e){if("string"!=typeof e||!e)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#zi||!this.#zi)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const t=(0,le.join)(this.#zi,`${e}.json`);let r;try{const e=await(0,ir.readFile)(t,"utf8");r=JSON.parse(e)}catch(r){if(!(r instanceof Error))return;if(this.#Wi)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#qi.set(e,{}),void this.#Vi.set(e,[])}const n={...this.#qi.get(e)??{}},i=[...this.#Vi.get(e)??[]],o=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#oo(t.$pattern);return void i.push({$pattern:e,value:this.#so(t.value),elseValue:this.#so(t.elseValue)})}if("string"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");n[e]=this.#so(t)}else if(t&&"object"==typeof t)for(const[r,n]of Object.entries(t))o(e?`${e}.${r}`:r,n)}};o("",r),this.#qi.set(e,n),this.#Vi.set(e,i)}#oo(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#Ui.get(e);if(t)return t;try{const t=new RegExp(e);return this.#Ui.set(e,t),t}catch{if(this.#Wi)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#so(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"string"==typeof e.$fn)return{$fn:String(e.$fn),args:e.args};if(this.#Wi)throw new Error("TinyI18: unsupported value in file JSON");return""}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("TinyI18: options must be an object");const{mode:t,defaultLocale:r,basePath:n,localResources:i,strict:o=!0}=e;if("local"!==t&&"file"!==t)throw new TypeError('TinyI18: "mode" must be "local" or "file"');if("string"!=typeof r||!r)throw new TypeError('TinyI18: "defaultLocale" must be a non-empty string');if("boolean"!=typeof o)throw new TypeError('TinyI18: "strict" must be a boolean');if("file"===t){if("string"!=typeof n||!n)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#zi=n}if(this.#$i=t,this.#Pi=r,this.#Wi=o,"local"===t&&i&&"object"==typeof i)for(const[e,t]of Object.entries(i))this.#ro(e,t);this.#qi.has(this.#Pi)||(this.#qi.set(this.#Pi,{}),this.#Vi.set(this.#Pi,[]))}clearRegexCache(){this.#Ui.clear()}registerHelper(e,t){if("string"!=typeof e||!e)throw new TypeError('registerHelper: "name" must be non-empty string');if("function"!=typeof t)throw new TypeError('registerHelper: "fn" must be a function');this.#Ki.set(e,t)}unregisterHelper(e){if("string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#Ki.delete(e)}loadLocaleLocal(e,t){if("local"!==this.#$i)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#ro(e,t)}async setLocale(e){if(null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#Fi;null!==e&&("file"===this.#$i?await this.#io(e):this.#qi.has(e)||(this.#qi.set(e,{}),this.#Vi.set(e,[]))),"file"===this.#$i&&t&&t!==this.#Pi&&t!==e&&this.#no(t),this.#Fi=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if("string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:n}=r||{},i=this.#Gi(n);let o=this.#Yi(i,e);if(void 0===o){if(this.#Wi)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#Qi(o,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if("string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},n=this.#Gi(r);let i=this.#Xi(n,e);if(void 0===i){if(this.#Wi)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return i}resetToDefaultOnly(){if("file"===this.#$i)for(const e of Array.from(this.#qi.keys()))e!==this.#Pi&&this.#no(e);this.#Fi=null}getStatsForLocale(e){if("string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#qi.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#qi.get(e)??{}).length,patterns:this.#Vi.get(e)?.length??0,isDefault:e===this.#Pi,isCurrent:e===this.#Fi}}};class ar{#ao=new Map;#lo;#uo;#co;get factors(){const e={};for(let[t,r]of this.#ao.entries())e[t]={...r};return e}get currentPercent(){return this.#uo/this.#lo*100}set maxValue(e){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#lo=e,this.#uo=Math.min(this.#uo,e)}get maxValue(){return this.#lo}get currentValue(){return this.#uo}set infiniteValue(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("infiniteValue must be a number.");this.#co=e,this.#uo=Math.max(0,e),this.#uo=Math.min(this.#uo,this.#lo)}get infiniteValue(){return this.#co}constructor(e=100,t=1,r=1){if("number"!=typeof e||Number.isNaN(e)||e<=0)throw new TypeError("maxValue must be a positive number.");this.#lo=e,this.setFactor("main",t,r),this.#uo=e,this.#co=e}getFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");const t=this.#ao.get(e);if(!t)throw new Error(`Factor with key "${e}" not found.`);return{...t}}hasFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#ao.has(e)}setFactor(e,t,r=1){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t||Number.isNaN(t))throw new TypeError("Amount must be a valid number.");if("number"!=typeof r||Number.isNaN(r))throw new TypeError("Multiplier must be a valid number.");this.#ao.set(e,{amount:t,multiplier:r})}removeFactor(e){if("string"!=typeof e||!e)throw new TypeError("Key must be a non-empty string.");return this.#ao.delete(e)}#ho(e){const t=this.#co;return this.#co-=e,this.#uo=Math.max(0,this.#uo-e),{prevValue:t,removedTotal:e,removedPercent:e/this.#lo*100,currentPercent:this.currentPercent,remainingValue:this.#uo,infiniteRemaining:this.#co}}tick(){let e=0;for(let[t,r]of this.#ao.entries())e+=r.amount*r.multiplier;return this.#ho(e)}tickWithTempFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');let t=0;for(let[e,r]of this.#ao.entries())t+=r.amount*r.multiplier;return e&&(t+=e.amount*(e.multiplier??1)),this.#ho(t)}tickSingleFactor(e){if("object"!=typeof e||null===e)throw new TypeError("You must provide a valid factor object.");if("number"!=typeof e.amount||Number.isNaN(e.amount))throw new TypeError('Temp factor "amount" must be a valid number.');if("multiplier"in e&&("number"!=typeof e.multiplier||Number.isNaN(e.multiplier)))throw new TypeError('Temp factor "multiplier" must be a valid number if provided.');if(!e)throw new Error("You must provide a factor to apply.");const t=e.amount*(e.multiplier??1);return this.#ho(t)}toJSON(){return{maxValue:this.#lo,currentValue:this.#uo,infiniteValue:this.#co,factors:this.factors}}static fromJSON(e){const t=new ar(e.maxValue,0,0);t.infiniteValue=e.infiniteValue,t.#ao.clear();for(const[r,n]of Object.entries(e.factors))t.setFactor(r,n.amount,n.multiplier);return t}clone(){return ar.fromJSON(this.toJSON())}clearFactors(){this.#ao.clear()}}const lr=ar,ur=class{static rollArrayIndex(e){const t=Array.isArray(e),r=e instanceof Set;if(!t&&!r)throw new TypeError("rollArrayIndex expects an array or Set.");return Math.floor(Math.random()*(t?e.length:e.size))}#lo;#do;get maxValue(){return this.#lo}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#lo=e}get allowZero(){return this.#do}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#do=e}constructor({maxValue:e,allowZero:t=!0}){if("boolean"!=typeof t)throw new TypeError("allowZero must be an boolean.");if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#lo=e,this.#do=t}roll(){const e=this.#do?0:1;return Math.floor(Math.random()*(this.#lo-e+1))+e}},cr=class{#T=null;get overlay(){return this.#T}#po=null;get messageElement(){return this.#po}#R;get container(){return this.#R}#fo={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#fo}}set options(e){if("object"!=typeof e||null===e)throw new TypeError("options must be an object");if(void 0!==e.fadeIn&&null!==e.fadeIn&&("number"!=typeof e.fadeIn||e.fadeIn<0))throw new TypeError("fadeIn must be a non-negative number or null");if(void 0!==e.fadeOut&&null!==e.fadeOut&&("number"!=typeof e.fadeOut||e.fadeOut<0))throw new TypeError("fadeOut must be a non-negative number or null");if(void 0!==e.zIndex&&("number"!=typeof e.zIndex||!Number.isInteger(e.zIndex)))throw new TypeError("zIndex must be an integer number");this.#fo={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#mo="none";get status(){return this.#mo}#go="";get defaultMessage(){return this.#go}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#go=e}#yo=null;get message(){return this.#yo}#wo=!1;get allowHtmlText(){return this.#wo}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#wo=e}#bo=null;get fadeInTimeout(){return null!==this.#bo}#vo=null;get fadeOutTimeout(){return null!==this.#vo}get visible(){return!!this.#T}#Eo=null;get onChange(){return this.#Eo}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#Eo=e}_emitChange(){"function"==typeof this.#Eo&&this.#Eo(this.#mo)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#R=e}_updateMessage(e=this.#go){if(!this.#po)throw new Error("messageElement is not initialized");if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(this.#yo=e,"string"==typeof e)this.#wo?this.#po.innerHTML=e:this.#po.textContent=e;else{if(!this.#wo)throw new Error("HTMLElement messages require allowHtmlText = true");this.#po.textContent="",this.#po.appendChild(e)}}_removeOldClasses(){this.#T?.classList.remove("active"),this.#T?.classList.remove("fadeIn"),this.#T?.classList.remove("fadeOut")}start(e=this.#go){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(!this.#T){this.#T=document.createElement("div"),this.#T.classList.add("loading-overlay"),this.#T.style.zIndex=String(this.#fo.zIndex);const t=document.createElement("div");t.classList.add("loading-container");const r=document.createElement("div");r.classList.add("loading-content");const n=document.createElement("div");n.classList.add("loading-spinner"),this.#po=document.createElement("div"),this.#po.classList.add("loading-message"),r.appendChild(n),r.appendChild(this.#po),t.appendChild(r),this.#T.appendChild(t),this.#R.appendChild(this.#T),this._removeOldClasses(),this.#mo="fadeIn",this.#T.classList.add("fadeIn"),this._emitChange();const i=()=>{this._removeOldClasses(),this.#bo=null,this.#mo="active",this.#T?.classList.add("active"),this._emitChange()};return"number"==typeof this.#fo.fadeIn?(this.#bo&&clearTimeout(this.#bo),this.#bo=setTimeout(i,this.#fo.fadeIn)):i(),this._updateMessage(e),!0}return this.#po&&this._updateMessage(e),!1}update(e=this.#go){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#po&&(this._updateMessage(e),!0)}stop(){if(this.#T){this._removeOldClasses(),this.#mo="fadeOut",this.#T.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#vo=null,this.#mo="none",this.#T?.remove(),this.#T=null,this.#po=null,this.#yo=null,this._emitChange()};return"number"==typeof this.#fo.fadeOut?(this.#vo&&clearTimeout(this.#vo),this.#vo=setTimeout(e,this.#fo.fadeOut)):e(),!0}return!1}};class hr{static#To=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;static#So=/^#([A-Fa-f0-9]{8})$/;static#xo="(0|1|0?\\.\\d+)";static#Ao="(0|[1-9]\\d?|1\\d{2}|2[0-4]\\d|25[0-5])";static#Io="(0|[1-9]\\d?|[1-2]\\d{2}|3[0-5]\\d|360)";static#Co="(0|[1-9]?\\d|100)";static#Mo=new RegExp(`^rgb\\(\\s*${hr.#Ao}\\s*,\\s*${hr.#Ao}\\s*,\\s*${hr.#Ao}\\s*\\)$`);static#Lo=new RegExp(`^rgba\\(\\s*${hr.#Ao}\\s*,\\s*${hr.#Ao}\\s*,\\s*${hr.#Ao}\\s*,\\s*${hr.#xo}\\s*\\)$`);static#No=new RegExp(`^hsl\\(\\s*${hr.#Io}\\s*,\\s*${hr.#Co}%\\s*,\\s*${hr.#Co}%\\s*\\)$`);static#ko=new RegExp(`^hsla\\(\\s*${hr.#Io}\\s*,\\s*${hr.#Co}%\\s*,\\s*${hr.#Co}%\\s*,\\s*${hr.#xo}\\s*\\)$`);static#Do=new RegExp(`^hwb\\(\\s*${hr.#Io}(deg|grad|rad|turn)?\\s*${hr.#Co}%\\s*${hr.#Co}%\\s*\\)$`);static#_o="(-?\\d+)";static#jo=new RegExp(`^lab\\(\\s*${hr.#Co}%?\\s*${hr.#_o}%?\\s*${hr.#_o}%?\\s*\\)$`);static#Ro=new RegExp(`^lch\\(\\s*${hr.#Co}%?\\s*${hr.#Co}%?\\s*${hr.#Io}(deg|grad|rad|turn)?\\s*\\)$`);static#Oo=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);static#Ho=new Set(["transparent","currentColor"]);static getNames(){return Array.from(hr.#Oo)}static addName(e){const t=hr.#Oo.size;return hr.#Oo.add(e.toLowerCase()),hr.#Oo.size>t}static removeName(e){return hr.#Oo.delete(e.toLowerCase())}static hasName(e){return hr.#Oo.has(e.toLowerCase())}static getSpecialNames(){return Array.from(hr.#Ho)}static addSpecialName(e){const t=hr.#Ho.size;return hr.#Ho.add(e),hr.#Ho.size>t}static removeSpecialName(e){return hr.#Ho.delete(e)}static hasSpecialName(e){return hr.#Ho.has(e)}#Bo;get code(){return this.#Bo}#$o;get type(){return this.#$o}constructor(e){this.#Bo=e,this.#$o=hr.isColor(this.#Bo)}static isHex(e){if("string"!=typeof e)throw new TypeError("isHex: input must be a string.");return hr.#To.test(e.trim())}isHex(){return hr.isHex(this.#Bo)}static isHexa(e){if("string"!=typeof e)throw new TypeError("isHexa: input must be a string.");return hr.#So.test(e.trim())}isHexa(){return hr.isHexa(this.#Bo)}static isRgb(e){if("string"!=typeof e)throw new TypeError("isRgb: input must be a string.");return hr.#Mo.test(e.trim())}isRgb(){return hr.isRgb(this.#Bo)}static isRgba(e){if("string"!=typeof e)throw new TypeError("isRgba: input must be a string.");return hr.#Lo.test(e.trim())}isRgba(){return hr.isRgba(this.#Bo)}static isHsl(e){if("string"!=typeof e)throw new TypeError("isHsl: input must be a string.");return hr.#No.test(e.trim())}isHsl(){return hr.isHsl(this.#Bo)}static isHsla(e){if("string"!=typeof e)throw new TypeError("isHsla: input must be a string.");return hr.#ko.test(e.trim())}isHsla(){return hr.isHsla(this.#Bo)}static isHwb(e){if("string"!=typeof e)throw new TypeError("isHwb: input must be a string.");return hr.#Do.test(e.trim())}isHwb(){return hr.isHwb(this.#Bo)}static isLab(e){if("string"!=typeof e)throw new TypeError("isLab: input must be a string.");return hr.#jo.test(e.trim())}isLab(){return hr.isLab(this.#Bo)}static isLch(e){if("string"!=typeof e)throw new TypeError("isLch: input must be a string.");return hr.#Ro.test(e.trim())}isLch(){return hr.isLch(this.#Bo)}static isName(e){if("string"!=typeof e)throw new TypeError("isName: input must be a string.");return hr.#Oo.has(e.trim().toLowerCase())}isName(){return hr.isName(this.#Bo)}static isSpecialName(e){if("string"!=typeof e)throw new TypeError("isSpecialName: input must be a string.");return hr.#Ho.has(e.trim())}isSpecialName(){return hr.isSpecialName(this.#Bo)}static isColor(e){if("string"!=typeof e)throw new TypeError("isColor: input must be a string.");return hr.isHex(e)?"hex":hr.isHexa(e)?"hexa":hr.isRgb(e)?"rgb":hr.isRgba(e)?"rgba":hr.isHsl(e)?"hsl":hr.isHsla(e)?"hsla":hr.isHwb(e)?"hwb":hr.isLab(e)?"lab":hr.isLch(e)?"lch":hr.isName(e)?"name":hr.isSpecialName(e)?"specialName":null}parse(){switch(this.#$o){case"hex":return hr.parseHex(this.code);case"hexa":return hr.parseHexa(this.code);case"rgb":return hr.parseRgb(this.code);case"rgba":return hr.parseRgba(this.code);case"hsl":return hr.parseHsl(this.code);case"hsla":return hr.parseHsla(this.code);case"hwb":return hr.parseHwb(this.code);case"lab":return hr.parseLab(this.code);case"lch":return hr.parseLch(this.code);case"name":case"specialName":return this.#Bo.trim().toLowerCase();default:return null}}static parseHex(e){if("string"!=typeof e)throw new TypeError("parseHex: input must be a string.");const t=new RegExp(hr.#To,"gm").exec(e.trim());return t?t[1]:null}parseHex(){return hr.parseHex(this.#Bo)}static parseHexa(e){if("string"!=typeof e)throw new TypeError("parseHexa: input must be a string.");const t=new RegExp(hr.#So,"gm").exec(e.trim());return t?t[1]:null}parseHexa(){return hr.parseHexa(this.#Bo)}static parseRgb(e){if("string"!=typeof e)throw new TypeError("parseRgb: input must be a string.");const t=new RegExp(hr.#Mo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseRgb(){return hr.parseRgb(this.#Bo)}static parseRgba(e){if("string"!=typeof e)throw new TypeError("parseRgba: input must be a string.");const t=new RegExp(hr.#Lo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseRgba(){return hr.parseRgba(this.#Bo)}static parseHsl(e){if("string"!=typeof e)throw new TypeError("parseHsl: input must be a string.");const t=new RegExp(hr.#No,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseHsl(){return hr.parseHsl(this.#Bo)}static parseHsla(e){if("string"!=typeof e)throw new TypeError("parseHsla: input must be a string.");const t=new RegExp(hr.#ko,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),parseFloat(t[4])]:null}parseHsla(){return hr.parseHsla(this.#Bo)}static parseHwb(e){if("string"!=typeof e)throw new TypeError("parseHwb: input must be a string.");const t=new RegExp(hr.#Do,"gm").exec(e.trim());return t?[parseFloat(t[1]),t[2]??null,parseFloat(t[3]),parseFloat(t[4])]:null}parseHwb(){return hr.parseHwb(this.#Bo)}static parseLab(e){if("string"!=typeof e)throw new TypeError("parseLab: input must be a string.");const t=new RegExp(hr.#jo,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}parseLab(){return hr.parseLab(this.#Bo)}static parseLch(e){if("string"!=typeof e)throw new TypeError("parseLch: input must be a string.");const t=new RegExp(hr.#Ro,"gm").exec(e.trim());return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]),t[4]??null]:null}parseLch(){return hr.parseLch(this.#Bo)}}const dr=hr})(),window.TinyEssentials=n})();