tiny-essentials 1.8.5 → 1.9.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.
@@ -2145,6 +2145,7 @@ __webpack_require__.d(__webpack_exports__, {
2145
2145
  ColorSafeStringify: () => (/* reexport */ libs_ColorSafeStringify),
2146
2146
  TinyLevelUp: () => (/* reexport */ userLevel),
2147
2147
  TinyPromiseQueue: () => (/* reexport */ libs_TinyPromiseQueue),
2148
+ TinyRateLimiter: () => (/* reexport */ libs_TinyRateLimiter),
2148
2149
  addAiMarkerShortcut: () => (/* reexport */ addAiMarkerShortcut),
2149
2150
  arraySortPositions: () => (/* reexport */ arraySortPositions),
2150
2151
  asyncReplace: () => (/* reexport */ asyncReplace),
@@ -3555,6 +3556,203 @@ class TinyPromiseQueue {
3555
3556
 
3556
3557
  /* harmony default export */ const libs_TinyPromiseQueue = (TinyPromiseQueue);
3557
3558
 
3559
+ ;// ./src/v1/libs/TinyRateLimiter.mjs
3560
+ /**
3561
+ * Class representing a flexible rate limiter per user.
3562
+ *
3563
+ * This rate limiter can be configured by maximum number of hits,
3564
+ * time interval, or a combination of both. It supports automatic
3565
+ * cleanup of inactive users to optimize memory usage.
3566
+ *
3567
+ * @class
3568
+ */
3569
+ class TinyRateLimiter {
3570
+ /**
3571
+ * @param {Object} options
3572
+ * @param {number} [options.maxHits] - Max interactions allowed
3573
+ * @param {number} [options.interval] - Time window in milliseconds
3574
+ * @param {number} [options.cleanupInterval] - Interval for automatic cleanup (ms)
3575
+ * @param {number} [options.maxIdle=300000] - Max idle time for a user before being cleaned (ms)
3576
+ */
3577
+ constructor({ maxHits, interval, cleanupInterval, maxIdle = 300000 }) {
3578
+ /** @param {number|undefined} val */
3579
+ const isPositiveInteger = (val) =>
3580
+ typeof val === 'number' && Number.isFinite(val) && val >= 1 && Number.isInteger(val);
3581
+
3582
+ const isMaxHitsValid = isPositiveInteger(maxHits);
3583
+ const isIntervalValid = isPositiveInteger(interval);
3584
+ const isCleanupValid = isPositiveInteger(cleanupInterval);
3585
+ const isMaxIdleValid = isPositiveInteger(maxIdle);
3586
+
3587
+ if (!isMaxHitsValid && !isIntervalValid)
3588
+ throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");
3589
+ if (maxHits !== undefined && !isMaxHitsValid)
3590
+ throw new Error("'maxHits' must be a positive integer if defined.");
3591
+ if (interval !== undefined && !isIntervalValid)
3592
+ throw new Error("'interval' must be a positive integer in milliseconds if defined.");
3593
+ if (cleanupInterval !== undefined && !isCleanupValid)
3594
+ throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");
3595
+ if (!isMaxIdleValid) throw new Error("'maxIdle' must be a positive integer in milliseconds.");
3596
+
3597
+ this.maxHits = isMaxHitsValid ? maxHits : null;
3598
+ this.interval = isIntervalValid ? interval : null;
3599
+ this.cleanupInterval = isCleanupValid ? cleanupInterval : null;
3600
+ this.maxIdle = maxIdle;
3601
+
3602
+ /** @type {Map<string, number[]>} */
3603
+ this.userData = new Map();
3604
+
3605
+ /** @type {Map<string, number>} */
3606
+ this.lastSeen = new Map();
3607
+
3608
+ // Start automatic cleanup only if cleanupInterval is valid
3609
+ if (this.cleanupInterval !== null)
3610
+ this._cleanupTimer = setInterval(() => this._cleanup(), this.cleanupInterval);
3611
+ }
3612
+
3613
+ /**
3614
+ * Get the interval window in milliseconds.
3615
+ *
3616
+ * @returns {number} The interval value.
3617
+ * @throws {Error} If interval is not a valid finite number.
3618
+ */
3619
+ getInterval() {
3620
+ if (typeof this.interval !== 'number' || !Number.isFinite(this.interval))
3621
+ throw new Error("'interval' is not a valid finite number.");
3622
+ return this.interval;
3623
+ }
3624
+
3625
+ /**
3626
+ * Get the maximum number of allowed hits.
3627
+ *
3628
+ * @returns {number} The maxHits value.
3629
+ * @throws {Error} If maxHits is not a valid finite number.
3630
+ */
3631
+ getMaxHits() {
3632
+ if (typeof this.maxHits !== 'number' || !Number.isFinite(this.maxHits)) {
3633
+ throw new Error("'maxHits' is not a valid finite number.");
3634
+ }
3635
+ return this.maxHits;
3636
+ }
3637
+
3638
+ /**
3639
+ * Register a hit for a specific user
3640
+ * @param {string} userId
3641
+ */
3642
+ hit(userId) {
3643
+ const now = Date.now();
3644
+
3645
+ if (!this.userData.has(userId)) {
3646
+ this.userData.set(userId, []);
3647
+ }
3648
+
3649
+ const history = this.userData.get(userId);
3650
+ if (!history) throw new Error(`No data found for userId: ${userId}`);
3651
+
3652
+ history.push(now);
3653
+ this.lastSeen.set(userId, now);
3654
+
3655
+ // Clean up old entries
3656
+ if (this.interval !== null) {
3657
+ const interval = this.getInterval();
3658
+ const cutoff = now - interval;
3659
+ while (history.length && history[0] < cutoff) {
3660
+ history.shift();
3661
+ }
3662
+ }
3663
+
3664
+ // Optional: keep only the last N entries for memory optimization
3665
+ if (this.maxHits !== null) {
3666
+ const maxHits = this.getMaxHits();
3667
+ if (history.length > maxHits) {
3668
+ history.splice(0, history.length - maxHits);
3669
+ }
3670
+ }
3671
+ }
3672
+
3673
+ /**
3674
+ * Check if the user is currently rate limited
3675
+ * @param {string} userId
3676
+ * @returns {boolean}
3677
+ */
3678
+ isRateLimited(userId) {
3679
+ const now = Date.now();
3680
+
3681
+ if (!this.userData.has(userId)) return false;
3682
+
3683
+ const history = this.userData.get(userId);
3684
+ if (!history) throw new Error(`No data found for userId: ${userId}`);
3685
+
3686
+ if (this.interval !== null) {
3687
+ const interval = this.getInterval();
3688
+ const recent = history.filter((t) => t > now - interval);
3689
+ if (this.maxHits !== null) {
3690
+ return recent.length >= this.getMaxHits();
3691
+ }
3692
+ return recent.length > 0;
3693
+ }
3694
+
3695
+ if (this.maxHits !== null) {
3696
+ return history.length >= this.getMaxHits();
3697
+ }
3698
+
3699
+ return false;
3700
+ }
3701
+
3702
+ /**
3703
+ * Manually reset user data
3704
+ * @param {string} userId
3705
+ */
3706
+ reset(userId) {
3707
+ this.userData.delete(userId);
3708
+ this.lastSeen.delete(userId);
3709
+ }
3710
+
3711
+ /**
3712
+ * Set hit timestamps for a user
3713
+ * @param {string} userId
3714
+ * @param {number[]} timestamps
3715
+ */
3716
+ setData(userId, timestamps) {
3717
+ this.userData.set(userId, timestamps);
3718
+ this.lastSeen.set(userId, Date.now());
3719
+ }
3720
+
3721
+ /**
3722
+ * Get timestamps from user
3723
+ * @param {string} userId
3724
+ * @returns {number[]}
3725
+ */
3726
+ getData(userId) {
3727
+ return this.userData.get(userId) || [];
3728
+ }
3729
+
3730
+ /**
3731
+ * Cleanup old/inactive users
3732
+ * @private
3733
+ */
3734
+ _cleanup() {
3735
+ const now = Date.now();
3736
+ for (const [userId, last] of this.lastSeen.entries()) {
3737
+ if (now - last > this.maxIdle) {
3738
+ this.userData.delete(userId);
3739
+ this.lastSeen.delete(userId);
3740
+ }
3741
+ }
3742
+ }
3743
+
3744
+ /**
3745
+ * Destroy the rate limiter, stopping all intervals
3746
+ */
3747
+ destroy() {
3748
+ if (this._cleanupTimer) clearInterval(this._cleanupTimer);
3749
+ this.userData.clear();
3750
+ this.lastSeen.clear();
3751
+ }
3752
+ }
3753
+
3754
+ /* harmony default export */ const libs_TinyRateLimiter = (TinyRateLimiter);
3755
+
3558
3756
  ;// ./src/v1/index.mjs
3559
3757
 
3560
3758
 
@@ -3569,6 +3767,7 @@ class TinyPromiseQueue {
3569
3767
 
3570
3768
 
3571
3769
 
3770
+
3572
3771
  })();
3573
3772
 
3574
3773
  window.TinyEssentials = __webpack_exports__;
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see TinyEssentials.min.js.LICENSE.txt */
2
- (()=>{var t={251:(t,e)=>{e.read=function(t,e,r,n,o){var i,s,u=8*o-n-1,a=(1<<u)-1,f=a>>1,h=-7,l=r?o-1:0,c=r?-1:1,p=t[e+l];for(l+=c,i=p&(1<<-h)-1,p>>=-h,h+=u;h>0;i=256*i+t[e+l],l+=c,h-=8);for(s=i&(1<<-h)-1,i>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=c,h-=8);if(0===i)i=1-f;else{if(i===a)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=f}return(p?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,u,a,f=8*i-o-1,h=(1<<f)-1,l=h>>1,c=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+l>=1?c/a:c*Math.pow(2,1-l))*a>=2&&(s++,a/=2),s+l>=h?(u=0,s=h):s+l>=1?(u=(e*a-1)*Math.pow(2,o),s+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;t[r+p]=255&u,p+=y,u/=256,o-=8);for(s=s<<o|u,f+=o;f>0;t[r+p]=255&s,p+=y,s/=256,f-=8);t[r+p-y]|=128*g}},287:(t,e,r)=>{"use strict";var n=r(526),o=r(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=a,e.IS=50;var s=2147483647;function u(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return f(t,e,r)}function f(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|g(t,e),n=u(r),o=n.write(t,e);return o!==r&&(n=n.slice(0,o)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(q(t,Uint8Array)){var e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return a.from(n,e,r);var o=function(t){if(a.isBuffer(t)){var e=0|y(t.length),r=u(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||F(t.length)?u(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return h(t),u(t<0?0:0|y(t))}function c(t){for(var e=t.length<0?0:0|y(t.length),r=u(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,a.prototype),n}function y(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function g(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return D(t).length;default:if(o)return n?-1:$(t).length;e=(""+e).toLowerCase(),o=!0}}function d(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return k(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return U(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),F(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,o){var i,s=1,u=t.length,a=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var h=-1;for(i=r;i<u;i++)if(f(t,i)===f(e,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===a)return h*s}else-1!==h&&(i-=i-h),h=-1}else for(r+a>u&&(r=u-a),i=r;i>=0;i--){for(var l=!0,c=0;c<a;c++)if(f(t,i+c)!==f(e,c)){l=!1;break}if(l)return i}return-1}function v(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var s=0;s<n;++s){var u=parseInt(e.substr(2*s,2),16);if(F(u))return s;t[r+s]=u}return s}function E(t,e,r,n){return _($(e,t.length-r),t,r,n)}function A(t,e,r,n){return _(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function T(t,e,r,n){return _(D(e),t,r,n)}function B(t,e,r,n){return _(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function x(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,u,a,f=t[o],h=null,l=f>239?4:f>223?3:f>191?2:1;if(o+l<=r)switch(l){case 1:f<128&&(h=f);break;case 2:128==(192&(i=t[o+1]))&&(a=(31&f)<<6|63&i)>127&&(h=a);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(a=(15&f)<<12|(63&i)<<6|63&s)>2047&&(a<55296||a>57343)&&(h=a);break;case 4:i=t[o+1],s=t[o+2],u=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&u)&&(a=(15&f)<<18|(63&i)<<12|(63&s)<<6|63&u)>65535&&a<1114112&&(h=a)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=l}return function(t){var e=t.length;if(e<=M)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=M));return r}(n)}a.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.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(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,r){return f(t,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,r){return function(t,e,r){return h(t),t<=0?u(t):void 0!==e?"string"==typeof r?u(t).fill(e,r):u(t).fill(e):u(t)}(t,e,r)},a.allocUnsafe=function(t){return l(t)},a.allocUnsafeSlow=function(t){return l(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if(q(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),q(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=a.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var i=t[r];if(q(i,Uint8Array))o+i.length>n.length?a.from(i).copy(n,o):Uint8Array.prototype.set.call(n,i,o);else{if(!a.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o)}o+=i.length}return n},a.byteLength=g,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)m(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?S(this,0,t):d.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},i&&(a.prototype[i]=a.prototype.inspect),a.prototype.compare=function(t,e,r,n,o){if(q(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),u=Math.min(i,s),f=this.slice(n,o),h=t.slice(e,r),l=0;l<u;++l)if(f[l]!==h[l]){i=f[l],s=h[l];break}return i<s?-1:s<i?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return A(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var M=4096;function U(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function O(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function k(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=Q[t[i]];return o}function L(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length-1;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function P(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,r,n,o,i){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function C(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function R(t,e,r,n,i){return e=+e,r>>>=0,i||C(t,0,r,8),o.write(t,e,r,n,52,8),r+8}a.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||P(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||P(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},a.prototype.readInt8=function(t,e){return t>>>=0,e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||P(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||P(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t>>>=0,e||P(t,4,this.length),o.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||P(t,4,this.length),o.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||P(t,8,this.length),o.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||P(t,8,this.length),o.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||N(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||N(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);N(this,t,e,r,o-1,-o)}var i=0,s=1,u=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===u&&0!==this[e+i-1]&&(u=1),this[e+i]=(t/s|0)-u&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);N(this,t,e,r,o-1,-o)}var i=r-1,s=1,u=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===u&&0!==this[e+i+1]&&(u=1),this[e+i]=(t/s|0)-u&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return R(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return R(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<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),t.length-e<n-r&&(n=t.length-e+r);var o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=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&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=a.isBuffer(t)?t:a.from(t,n),u=s.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=s[i%u]}return this};var j=/[^+/0-9A-Za-z-_]/g;function $(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function D(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function _(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}var Q=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=16*r,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()},526:(t,e)=>{"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,i=u(t),s=i[0],a=i[1],f=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),h=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],f[h++]=e>>16&255,f[h++]=e>>8&255,f[h++]=255&e;return 2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,f[h++]=255&e),1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,f[h++]=e>>8&255,f[h++]=255&e),f},e.fromByteArray=function(t){for(var e,n=t.length,o=n%3,i=[],s=16383,u=0,f=n-o;u<f;u+=s)i.push(a(t,u,u+s>f?f:u+s));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],n[i.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function a(t,e,n){for(var o,i,s=[],u=e;u<n;u+=3)o=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),s.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";async function t(t,e,r){const n=[];t.replace(e,((t,...e)=>(n.push(r(t,...e)),t)));const o=await Promise.all(n);return t.replace(e,(()=>o.shift()))}r.r(n),r.d(n,{ColorSafeStringify:()=>M,TinyLevelUp:()=>e,TinyPromiseQueue:()=>U,addAiMarkerShortcut:()=>x,arraySortPositions:()=>o,asyncReplace:()=>t,checkObj:()=>m,cloneObjTypeOrder:()=>y,countObj:()=>w,extendObjType:()=>c,formatBytes:()=>A,formatCustomTimer:()=>u,formatDayTimer:()=>f,formatTimer:()=>a,getAge:()=>E,getSimplePerc:()=>v,getTimeDuration:()=>s,objType:()=>d,reorderObjTypeOrder:()=>p,ruleOfThree:()=>b,shuffleArray:()=>i,toTitleCase:()=>T,toTitleCaseLowerFirst:()=>B});const e=class{constructor(t,e){this.giveExp=t,this.expLevel=e}expValidator(t){let e=0;const r=this.expLevel*t.level;return t.exp>=r&&(t.level++,e=t.exp-r,t.exp=0,e>0)?this.give(t,e,"extra"):t.exp<1&&t.level>1&&(t.level--,e=Math.abs(t.exp),t.exp=this.expLevel*t.level,e>0)?this.remove(t,e,"extra"):t}getTotalExp(t){let e=0;for(let r=1;r<=t.level;r++)e+=this.expLevel*r;return e+=t.exp,e}expGenerator(t=1){return Math.floor(Math.random()*this.giveExp)+1*t}progress(t){return this.expLevel*t.level}getProgress(t){return this.expLevel*t.level}set(t,e){return t.exp=e,this.expValidator(t),t.totalExp=this.getTotalExp(t),t}give(t,e=0,r="add",n=1){return"add"===r?t.exp+=this.expGenerator(n)+e:"extra"===r&&(t.exp+=e),this.expValidator(t),t.totalExp=this.getTotalExp(t),t}remove(t,e=0,r="add",n=1){return"add"===r?t.exp-=this.expGenerator(n)+e:"extra"===r&&(t.exp-=e),this.expValidator(t),t.totalExp=this.getTotalExp(t),t}};function o(t,e=!1){return e?function(e,r){return e[t]>r[t]?-1:e[t]<r[t]?1:0}:function(e,r){return e[t]<r[t]?-1:e[t]>r[t]?1:0}}function i(t){let e,r=t.length;for(;0!==r;)e=Math.floor(Math.random()*r),r--,[t[r],t[e]]=[t[e],t[r]];return t}function s(t=new Date,e="asSeconds",r=null){if(t instanceof Date){const n=r instanceof Date?r:new Date,o=t.getTime()-n.getTime();switch(e){case"asMilliseconds":return o;case"asSeconds":default:return o/1e3;case"asMinutes":return o/6e4;case"asHours":return o/36e5;case"asDays":return o/864e5}}return null}function u(t,e="seconds",r="{time}"){t=Math.max(0,Math.floor(t));const n=["seconds","minutes","hours","days","months","years"].indexOf(e),o=n>=5,i=n>=4,s=n>=3,u=n>=2,a=n>=1,f=n>=0,h={years:o?0:NaN,months:i?0:NaN,days:s?0:NaN,hours:u?0:NaN,minutes:a?0:NaN,seconds:f?0:NaN,total:NaN};let l=t;if(o||i||s){const t=new Date(1980,0,1),e=new Date(t.getTime()+1e3*l),r=new Date(t);if(o)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=e.getTime();)r.setFullYear(r.getFullYear()+1),h.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=e.getTime();)r.setMonth(r.getMonth()+1),h.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=e.getTime();)r.setDate(r.getDate()+1),h.days++;l=Math.floor((e.getTime()-r.getTime())/1e3)}u&&(h.hours=Math.floor(l/3600),l%=3600),a&&(h.minutes=Math.floor(l/60),l%=60),f&&(h.seconds=l);const c={seconds:f?t:NaN,minutes:a?t/60:NaN,hours:u?t/3600:NaN,days:s?t/86400:NaN,months:i?12*h.years+h.months+(h.days||0)/30:NaN,years:o?h.years+(h.months||0)/12+(h.days||0)/365:NaN};h.total=+(c[e]||0).toFixed(2).replace(/\.00$/,"");const p=t=>{const e="string"==typeof t?parseInt(t):t;return Number.isNaN(e)?"NaN":String(e).padStart(2,"0")},y=[u?p(h.hours):null,a?p(h.minutes):null,f?p(h.seconds):null].filter((t=>null!==t)).join(":");return r.replace(/\{years\}/g,String(h.years)).replace(/\{months\}/g,String(h.months)).replace(/\{days\}/g,String(h.days)).replace(/\{hours\}/g,p(h.hours)).replace(/\{minutes\}/g,p(h.minutes)).replace(/\{seconds\}/g,p(h.seconds)).replace(/\{time\}/g,y).replace(/\{total\}/g,String(h.total)).trim()}function a(t){return u(t,"hours","{hours}:{minutes}:{seconds}")}function f(t){return u(t,"days","{days}d {hours}:{minutes}:{seconds}")}var h=r(287);const l={items:{undefined:t=>void 0===t,null:t=>null===t,boolean:t=>"boolean"==typeof t,number:t=>"number"==typeof t&&!isNaN(t),bigint:t=>"bigint"==typeof t,string:t=>"string"==typeof t,symbol:t=>"symbol"==typeof t,function:t=>"function"==typeof t,array:t=>Array.isArray(t),date:t=>t instanceof Date,regexp:t=>t instanceof RegExp,map:t=>t instanceof Map,set:t=>t instanceof Set,weakmap:t=>t instanceof WeakMap,weakset:t=>t instanceof WeakSet,promise:t=>t instanceof Promise,buffer:t=>void 0!==h.hp&&h.hp.isBuffer(t),file:t=>"undefined"!=typeof File&&t instanceof File,htmlelement:t=>"undefined"!=typeof HTMLElement&&t instanceof HTMLElement,object:t=>"object"==typeof t&&null!==t&&!Array.isArray(t)},order:["undefined","null","boolean","number","bigint","string","symbol","function","array","buffer","file","date","regexp","map","set","weakmap","weakset","promise","htmlelement","object"]};function c(t,e){const r=[];for(const[n,o]of Object.entries(t))if(!l.items.hasOwnProperty(n)){l.items[n]=o;let t="number"==typeof e?e:-1;if(-1===t){const e=l.order.indexOf("object");t=e>-1?e:l.order.length}t=Math.min(Math.max(0,t),l.order.length),l.order.splice(t,0,n),r.push(n)}return r}function p(t){const e=[...l.order];return!!t.every((t=>e.includes(t)))&&(l.order=t.slice(),!0)}function y(){return[...l.order]}const g=t=>{if(null===t)return"null";for(const e of l.order)if("function"!=typeof l.items[e]||l.items[e](t))return e;return"unknown"};function d(t,e){if(void 0===t)return null;const r=g(t);return"string"==typeof e?r===e.toLowerCase():r}function m(t){const e={valid:null,type:null};for(const r of l.order)if("function"==typeof l.items[r]){const n=l.items[r](t);if(n){e.valid=n,e.type=r;break}}return e}function w(t){return Array.isArray(t)?t.length:d(t,"object")?Object.keys(t).length:0}function b(t,e,r,n=!1){return n?Number(t*e)/r:Number(r*e)/t}function v(t,e){return t*(e/100)}function E(t=0,e=null){if(null!=t&&0!==t){const r=new Date(t);if(Number.isNaN(r.getTime()))return null;const n=e instanceof Date?e:new Date;let o=n.getFullYear()-r.getFullYear();const i=n.getMonth(),s=r.getMonth(),u=n.getDate(),a=r.getDate();return(i<s||i===s&&u<a)&&o--,Math.abs(o)}return null}function A(t,e=null,r=null){if("number"!=typeof t||t<0)return{unit:null,value:null};if(0===t)return{unit:"Bytes",value:0};const n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=r&&n.includes(r)?n.indexOf(r):n.length-1,i=Math.min(Math.floor(Math.log(t)/Math.log(1024)),o);let s=t/Math.pow(1024,i);if(null!==e){const t=e<0?0:e;s=parseFloat(s.toFixed(t))}return{unit:n[i],value:s}}function T(t){return t.replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()))}function B(t){const e=t.replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()));return e.charAt(0).toLowerCase()+e.slice(1)}function x(t="a"){"undefined"!=typeof HTMLElement?document.addEventListener("keydown",(function(e){if(e.ctrlKey&&e.altKey&&e.key.toLowerCase()===t){if(e.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("detect-made-by-ai")}})):console.error("[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.")}class S{#t;static#e={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(t={}){this.#t={...S.#e.default,...t}}#r(t,e){const r=[];t=(t=(t=t.replace(/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,`${e.number}$1${e.reset}`)).replace(/"([^"]+)":/g,((t,e)=>{const n=`___KEY${r.length}___`;return r.push({marker:n,key:e}),`${n}:`}))).replace(/"(?:\\.|[^"\\])*?"/g,(t=>{const r=t.slice(1,-1);return/^(https?|ftp):\/\/[^\s]+$/i.test(r)?`${e.string_url}${t}${e.reset}`:/^(true|false|null)$/.test(r)?`${e.string_bool}${t}${e.reset}`:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(r)?`${e.string_number}${t}${e.reset}`:`${e.string}${t}${e.reset}`}));for(const{marker:n,key:o}of r){const r=new RegExp(n,"g");t=t.replace(r,`${e.key}"${o}"${e.reset}`)}return(t=(t=(t=(t=t.replace(/(?<!")\b(true|false)\b(?!")/g,`${e.boolean}$1${e.reset}`)).replace(/(?<!")\bnull\b(?!")/g,`${e.null}null${e.reset}`)).replace(/\[Circular\]/g,`${e.special}[Circular]${e.reset}`)).replace(/\[undefined\]/g,`${e.special}[undefined]${e.reset}`)).replace(/"function.*?[^\\]"/gs,`${e.func}$&${e.reset}`)}colorize(t,e={}){const r={...this.#t,...e};return this.#r(t,r)}getColors(){return{...this.#t}}updateColors(t){Object.assign(this.#t,t)}resetColors(){this.#t={...S.#e.default}}loadColorPreset(t){const e=S.#e[t];if(!e)throw new Error(`Preset "${t}" not found.`);this.#t={...e}}saveColorPreset(t,e){S.#e[t]={...e}}getAvailablePresets(){return Object.keys(S.#e)}}const M=S,U=class{#n=[];#o=!1;#i={};#s=new Set;isRunning(){return this.#o}async#u(t){if(t&&"function"==typeof t.task&&"function"==typeof t.resolve&&"function"==typeof t.reject){const{task:e,resolve:r,reject:n,delay:o,id:i}=t;try{if(i&&this.#s.has(i))return n(new Error("The function was canceled on TinyPromiseQueue.")),this.#s.delete(i),this.#o=!1,void this.#a();o&&i&&await new Promise((t=>{const e=setTimeout((()=>{delete this.#i[i],t(null)}),o);this.#i[i]=e})),r(await e())}catch(t){n(t)}finally{this.#o=!1,this.#a()}}}async#f(){const t=[];for(;this.#n.length&&"POINT_MARKER"===this.#n[0]?.marker;)t.push(this.#n.shift());if(0===t.length)return this.#o=!1,void this.#a();await Promise.all(t.map((({task:t,resolve:e,reject:r,id:n})=>new Promise((async o=>{if(n&&this.#s.has(n))return this.#s.delete(n),r(new Error("The function was canceled on TinyPromiseQueue.")),void o(!0);await t().then(e).catch(r),o(!0)}))))),this.#o=!1,this.#a()}async#a(){if(!this.#o&&0!==this.#n.length)if(this.#o=!0,"string"!=typeof this.#n[0]?.marker||"POINT_MARKER"!==this.#n[0]?.marker){const t=this.#n.shift();this.#u(t)}else this.#f()}getIndexById(t){return this.#n.findIndex((e=>e.id===t))}getQueuedIds(){return this.#n.map(((t,e)=>({index:e,id:t.id}))).filter((t=>"string"==typeof t.id))}reorderQueue(t,e){if("number"!=typeof t||"number"!=typeof e||t<0||e<0||t>=this.#n.length||e>=this.#n.length)return;const[r]=this.#n.splice(t,1);this.#n.splice(e,0,r)}async enqueuePoint(t,e){return this.#o?new Promise(((r,n)=>{this.#n.push({marker:"POINT_MARKER",task:t,resolve:r,reject:n,id:e}),this.#a()})):t()}enqueue(t,e,r){return new Promise(((n,o)=>{this.#n.push({task:t,resolve:n,reject:o,id:r,delay:e}),this.#a()}))}cancelTask(t){if(!t)return!1;let e=!1;t in this.#i&&(clearTimeout(this.#i[t]),delete this.#i[t],e=!0);const r=this.getIndexById(t);if(-1!==r){const[t]=this.#n.splice(r,1);t?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),e=!0}return e&&this.#s.add(t),e}}})(),window.TinyEssentials=n})();
2
+ (()=>{var t={251:(t,e)=>{e.read=function(t,e,r,n,i){var o,s,u=8*i-n-1,a=(1<<u)-1,f=a>>1,l=-7,h=r?i-1:0,c=r?-1:1,p=t[e+h];for(h+=c,o=p&(1<<-l)-1,p>>=-l,l+=u;l>0;o=256*o+t[e+h],h+=c,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+h],h+=c,l-=8);if(0===o)o=1-f;else{if(o===a)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=f}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,u,a,f=8*o-i-1,l=(1<<f)-1,h=l>>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+h>=1?c/a:c*Math.pow(2,1-h))*a>=2&&(s++,a/=2),s+h>=l?(u=0,s=l):s+h>=1?(u=(e*a-1)*Math.pow(2,i),s+=h):(u=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&u,p+=y,u/=256,i-=8);for(s=s<<i|u,f+=i;f>0;t[r+p]=255&s,p+=y,s/=256,f-=8);t[r+p-y]|=128*g}},287:(t,e,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;e.hp=a,e.IS=50;var s=2147483647;function u(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return f(t,e,r)}function f(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|g(t,e),n=u(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(q(t,Uint8Array)){var e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return c(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(q(t,ArrayBuffer)||t&&q(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(q(t,SharedArrayBuffer)||t&&q(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return a.from(n,e,r);var i=function(t){if(a.isBuffer(t)){var e=0|y(t.length),r=u(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||F(t.length)?u(0):c(t):"Buffer"===t.type&&Array.isArray(t.data)?c(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return l(t),u(t<0?0:0|y(t))}function c(t){for(var e=t.length<0?0:0|y(t.length),r=u(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,a.prototype),n}function y(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function g(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||q(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(t).length;default:if(i)return n?-1:j(t).length;e=(""+e).toLowerCase(),i=!0}}function d(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return O(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return U(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),F(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){var o,s=1,u=t.length,a=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var l=-1;for(o=r;o<u;o++)if(f(t,o)===f(e,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===a)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+a>u&&(r=u-a),o=r;o>=0;o--){for(var h=!0,c=0;c<a;c++)if(f(t,o+c)!==f(e,c)){h=!1;break}if(h)return o}return-1}function v(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=e.length;n>o/2&&(n=o/2);for(var s=0;s<n;++s){var u=parseInt(e.substr(2*s,2),16);if(F(u))return s;t[r+s]=u}return s}function E(t,e,r,n){return _(j(e,t.length-r),t,r,n)}function x(t,e,r,n){return _(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function A(t,e,r,n){return _($(e),t,r,n)}function T(t,e,r,n){return _(function(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function B(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,s,u,a,f=t[i],l=null,h=f>239?4:f>223?3:f>191?2:1;if(i+h<=r)switch(h){case 1:f<128&&(l=f);break;case 2:128==(192&(o=t[i+1]))&&(a=(31&f)<<6|63&o)>127&&(l=a);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(a=(15&f)<<12|(63&o)<<6|63&s)>2047&&(a<55296||a>57343)&&(l=a);break;case 4:o=t[i+1],s=t[i+2],u=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&u)&&(a=(15&f)<<18|(63&o)<<12|(63&s)<<6|63&u)>65535&&a<1114112&&(l=a)}null===l?(l=65533,h=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=h}return function(t){var e=t.length;if(e<=M)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=M));return r}(n)}a.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.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(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,r){return f(t,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?u(t):void 0!==e?"string"==typeof r?u(t).fill(e,r):u(t).fill(e):u(t)}(t,e,r)},a.allocUnsafe=function(t){return h(t)},a.allocUnsafeSlow=function(t){return h(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if(q(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),q(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=a.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(q(o,Uint8Array))i+o.length>n.length?a.from(o).copy(n,i):Uint8Array.prototype.set.call(n,o,i);else{if(!a.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i)}i+=o.length}return n},a.byteLength=g,a.prototype._isBuffer=!0,a.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)m(this,e,e+1);return this},a.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},a.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},a.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?S(this,0,t):d.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){var t="",r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(a.prototype[o]=a.prototype.inspect),a.prototype.compare=function(t,e,r,n,i){if(q(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),u=Math.min(o,s),f=this.slice(n,i),l=t.slice(e,r),h=0;h<u;++h)if(f[h]!==l[h]){o=f[h],s=l[h];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>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,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var M=4096;function I(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function U(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function O(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=H[t[o]];return i}function L(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function N(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function k(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function P(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,o){return e=+e,r>>>=0,o||P(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function C(t,e,r,n,o){return e=+e,r>>>=0,o||P(t,0,r,8),i.write(t,e,r,n,52,8),r+8}a.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},a.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readFloatLE=function(t,e){return t>>>=0,e||N(t,4,this.length),i.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),i.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),i.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),i.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||k(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||k(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);k(this,t,e,r,i-1,-i)}var o=0,s=1,u=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===u&&0!==this[e+o-1]&&(u=1),this[e+o]=(t/s|0)-u&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);k(this,t,e,r,i-1,-i)}var o=r-1,s=1,u=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===u&&0!==this[e+o+1]&&(u=1),this[e+o]=(t/s|0)-u&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||k(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<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),t.length-e<n-r&&(n=t.length-e+r);var i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=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&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var s=a.isBuffer(t)?t:a.from(t,n),u=s.length;if(0===u)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=s[o%u]}return this};var D=/[^+/0-9A-Za-z-_]/g;function j(t,e){var r;e=e||1/0;for(var n=t.length,i=null,o=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=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((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function $(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(D,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function _(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function q(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function F(t){return t!=t}var H=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=16*r,i=0;i<16;++i)e[n+i]=t[r]+t[i];return e}()},526:(t,e)=>{"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=u(t),s=o[0],a=o[1],f=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),l=0,h=a>0?s-4:s;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],f[l++]=e>>16&255,f[l++]=e>>8&255,f[l++]=255&e;return 2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,f[l++]=255&e),1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,f[l++]=e>>8&255,f[l++]=255&e),f},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,u=0,f=n-i;u<f;u+=s)o.push(a(t,u,u+s>f?f:u+s));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<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 u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function a(t,e,n){for(var i,o,s=[],u=e;u<n;u+=3)i=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};(()=>{"use strict";async function t(t,e,r){const n=[];t.replace(e,((t,...e)=>(n.push(r(t,...e)),t)));const i=await Promise.all(n);return t.replace(e,(()=>i.shift()))}r.r(n),r.d(n,{ColorSafeStringify:()=>M,TinyLevelUp:()=>e,TinyPromiseQueue:()=>I,TinyRateLimiter:()=>U,addAiMarkerShortcut:()=>B,arraySortPositions:()=>i,asyncReplace:()=>t,checkObj:()=>m,cloneObjTypeOrder:()=>y,countObj:()=>w,extendObjType:()=>c,formatBytes:()=>x,formatCustomTimer:()=>u,formatDayTimer:()=>f,formatTimer:()=>a,getAge:()=>E,getSimplePerc:()=>v,getTimeDuration:()=>s,objType:()=>d,reorderObjTypeOrder:()=>p,ruleOfThree:()=>b,shuffleArray:()=>o,toTitleCase:()=>A,toTitleCaseLowerFirst:()=>T});const e=class{constructor(t,e){this.giveExp=t,this.expLevel=e}expValidator(t){let e=0;const r=this.expLevel*t.level;return t.exp>=r&&(t.level++,e=t.exp-r,t.exp=0,e>0)?this.give(t,e,"extra"):t.exp<1&&t.level>1&&(t.level--,e=Math.abs(t.exp),t.exp=this.expLevel*t.level,e>0)?this.remove(t,e,"extra"):t}getTotalExp(t){let e=0;for(let r=1;r<=t.level;r++)e+=this.expLevel*r;return e+=t.exp,e}expGenerator(t=1){return Math.floor(Math.random()*this.giveExp)+1*t}progress(t){return this.expLevel*t.level}getProgress(t){return this.expLevel*t.level}set(t,e){return t.exp=e,this.expValidator(t),t.totalExp=this.getTotalExp(t),t}give(t,e=0,r="add",n=1){return"add"===r?t.exp+=this.expGenerator(n)+e:"extra"===r&&(t.exp+=e),this.expValidator(t),t.totalExp=this.getTotalExp(t),t}remove(t,e=0,r="add",n=1){return"add"===r?t.exp-=this.expGenerator(n)+e:"extra"===r&&(t.exp-=e),this.expValidator(t),t.totalExp=this.getTotalExp(t),t}};function i(t,e=!1){return e?function(e,r){return e[t]>r[t]?-1:e[t]<r[t]?1:0}:function(e,r){return e[t]<r[t]?-1:e[t]>r[t]?1:0}}function o(t){let e,r=t.length;for(;0!==r;)e=Math.floor(Math.random()*r),r--,[t[r],t[e]]=[t[e],t[r]];return t}function s(t=new Date,e="asSeconds",r=null){if(t instanceof Date){const n=r instanceof Date?r:new Date,i=t.getTime()-n.getTime();switch(e){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(t,e="seconds",r="{time}"){t=Math.max(0,Math.floor(t));const n=["seconds","minutes","hours","days","months","years"].indexOf(e),i=n>=5,o=n>=4,s=n>=3,u=n>=2,a=n>=1,f=n>=0,l={years:i?0:NaN,months:o?0:NaN,days:s?0:NaN,hours:u?0:NaN,minutes:a?0:NaN,seconds:f?0:NaN,total:NaN};let h=t;if(i||o||s){const t=new Date(1980,0,1),e=new Date(t.getTime()+1e3*h),r=new Date(t);if(i)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=e.getTime();)r.setFullYear(r.getFullYear()+1),l.years++;if(o)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=e.getTime();)r.setMonth(r.getMonth()+1),l.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=e.getTime();)r.setDate(r.getDate()+1),l.days++;h=Math.floor((e.getTime()-r.getTime())/1e3)}u&&(l.hours=Math.floor(h/3600),h%=3600),a&&(l.minutes=Math.floor(h/60),h%=60),f&&(l.seconds=h);const c={seconds:f?t:NaN,minutes:a?t/60:NaN,hours:u?t/3600:NaN,days:s?t/86400:NaN,months:o?12*l.years+l.months+(l.days||0)/30:NaN,years:i?l.years+(l.months||0)/12+(l.days||0)/365:NaN};l.total=+(c[e]||0).toFixed(2).replace(/\.00$/,"");const p=t=>{const e="string"==typeof t?parseInt(t):t;return Number.isNaN(e)?"NaN":String(e).padStart(2,"0")},y=[u?p(l.hours):null,a?p(l.minutes):null,f?p(l.seconds):null].filter((t=>null!==t)).join(":");return r.replace(/\{years\}/g,String(l.years)).replace(/\{months\}/g,String(l.months)).replace(/\{days\}/g,String(l.days)).replace(/\{hours\}/g,p(l.hours)).replace(/\{minutes\}/g,p(l.minutes)).replace(/\{seconds\}/g,p(l.seconds)).replace(/\{time\}/g,y).replace(/\{total\}/g,String(l.total)).trim()}function a(t){return u(t,"hours","{hours}:{minutes}:{seconds}")}function f(t){return u(t,"days","{days}d {hours}:{minutes}:{seconds}")}var l=r(287);const h={items:{undefined:t=>void 0===t,null:t=>null===t,boolean:t=>"boolean"==typeof t,number:t=>"number"==typeof t&&!isNaN(t),bigint:t=>"bigint"==typeof t,string:t=>"string"==typeof t,symbol:t=>"symbol"==typeof t,function:t=>"function"==typeof t,array:t=>Array.isArray(t),date:t=>t instanceof Date,regexp:t=>t instanceof RegExp,map:t=>t instanceof Map,set:t=>t instanceof Set,weakmap:t=>t instanceof WeakMap,weakset:t=>t instanceof WeakSet,promise:t=>t instanceof Promise,buffer:t=>void 0!==l.hp&&l.hp.isBuffer(t),file:t=>"undefined"!=typeof File&&t instanceof File,htmlelement:t=>"undefined"!=typeof HTMLElement&&t instanceof HTMLElement,object:t=>"object"==typeof t&&null!==t&&!Array.isArray(t)},order:["undefined","null","boolean","number","bigint","string","symbol","function","array","buffer","file","date","regexp","map","set","weakmap","weakset","promise","htmlelement","object"]};function c(t,e){const r=[];for(const[n,i]of Object.entries(t))if(!h.items.hasOwnProperty(n)){h.items[n]=i;let t="number"==typeof e?e:-1;if(-1===t){const e=h.order.indexOf("object");t=e>-1?e:h.order.length}t=Math.min(Math.max(0,t),h.order.length),h.order.splice(t,0,n),r.push(n)}return r}function p(t){const e=[...h.order];return!!t.every((t=>e.includes(t)))&&(h.order=t.slice(),!0)}function y(){return[...h.order]}const g=t=>{if(null===t)return"null";for(const e of h.order)if("function"!=typeof h.items[e]||h.items[e](t))return e;return"unknown"};function d(t,e){if(void 0===t)return null;const r=g(t);return"string"==typeof e?r===e.toLowerCase():r}function m(t){const e={valid:null,type:null};for(const r of h.order)if("function"==typeof h.items[r]){const n=h.items[r](t);if(n){e.valid=n,e.type=r;break}}return e}function w(t){return Array.isArray(t)?t.length:d(t,"object")?Object.keys(t).length:0}function b(t,e,r,n=!1){return n?Number(t*e)/r:Number(r*e)/t}function v(t,e){return t*(e/100)}function E(t=0,e=null){if(null!=t&&0!==t){const r=new Date(t);if(Number.isNaN(r.getTime()))return null;const n=e instanceof Date?e:new Date;let i=n.getFullYear()-r.getFullYear();const o=n.getMonth(),s=r.getMonth(),u=n.getDate(),a=r.getDate();return(o<s||o===s&&u<a)&&i--,Math.abs(i)}return null}function x(t,e=null,r=null){if("number"!=typeof t||t<0)return{unit:null,value:null};if(0===t)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(t)/Math.log(1024)),i);let s=t/Math.pow(1024,o);if(null!==e){const t=e<0?0:e;s=parseFloat(s.toFixed(t))}return{unit:n[o],value:s}}function A(t){return t.replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()))}function T(t){const e=t.replace(/\w\S*/g,(t=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()));return e.charAt(0).toLowerCase()+e.slice(1)}function B(t="a"){"undefined"!=typeof HTMLElement?document.addEventListener("keydown",(function(e){if(e.ctrlKey&&e.altKey&&e.key.toLowerCase()===t){if(e.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("detect-made-by-ai")}})):console.error("[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.")}class S{#t;static#e={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(t={}){this.#t={...S.#e.default,...t}}#r(t,e){const r=[];t=(t=(t=t.replace(/(?<!")\b(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\b(?!")/g,`${e.number}$1${e.reset}`)).replace(/"([^"]+)":/g,((t,e)=>{const n=`___KEY${r.length}___`;return r.push({marker:n,key:e}),`${n}:`}))).replace(/"(?:\\.|[^"\\])*?"/g,(t=>{const r=t.slice(1,-1);return/^(https?|ftp):\/\/[^\s]+$/i.test(r)?`${e.string_url}${t}${e.reset}`:/^(true|false|null)$/.test(r)?`${e.string_bool}${t}${e.reset}`:/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(r)?`${e.string_number}${t}${e.reset}`:`${e.string}${t}${e.reset}`}));for(const{marker:n,key:i}of r){const r=new RegExp(n,"g");t=t.replace(r,`${e.key}"${i}"${e.reset}`)}return(t=(t=(t=(t=t.replace(/(?<!")\b(true|false)\b(?!")/g,`${e.boolean}$1${e.reset}`)).replace(/(?<!")\bnull\b(?!")/g,`${e.null}null${e.reset}`)).replace(/\[Circular\]/g,`${e.special}[Circular]${e.reset}`)).replace(/\[undefined\]/g,`${e.special}[undefined]${e.reset}`)).replace(/"function.*?[^\\]"/gs,`${e.func}$&${e.reset}`)}colorize(t,e={}){const r={...this.#t,...e};return this.#r(t,r)}getColors(){return{...this.#t}}updateColors(t){Object.assign(this.#t,t)}resetColors(){this.#t={...S.#e.default}}loadColorPreset(t){const e=S.#e[t];if(!e)throw new Error(`Preset "${t}" not found.`);this.#t={...e}}saveColorPreset(t,e){S.#e[t]={...e}}getAvailablePresets(){return Object.keys(S.#e)}}const M=S,I=class{#n=[];#i=!1;#o={};#s=new Set;isRunning(){return this.#i}async#u(t){if(t&&"function"==typeof t.task&&"function"==typeof t.resolve&&"function"==typeof t.reject){const{task:e,resolve:r,reject:n,delay:i,id:o}=t;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.#a();i&&o&&await new Promise((t=>{const e=setTimeout((()=>{delete this.#o[o],t(null)}),i);this.#o[o]=e})),r(await e())}catch(t){n(t)}finally{this.#i=!1,this.#a()}}}async#f(){const t=[];for(;this.#n.length&&"POINT_MARKER"===this.#n[0]?.marker;)t.push(this.#n.shift());if(0===t.length)return this.#i=!1,void this.#a();await Promise.all(t.map((({task:t,resolve:e,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 t().then(e).catch(r),i(!0)}))))),this.#i=!1,this.#a()}async#a(){if(!this.#i&&0!==this.#n.length)if(this.#i=!0,"string"!=typeof this.#n[0]?.marker||"POINT_MARKER"!==this.#n[0]?.marker){const t=this.#n.shift();this.#u(t)}else this.#f()}getIndexById(t){return this.#n.findIndex((e=>e.id===t))}getQueuedIds(){return this.#n.map(((t,e)=>({index:e,id:t.id}))).filter((t=>"string"==typeof t.id))}reorderQueue(t,e){if("number"!=typeof t||"number"!=typeof e||t<0||e<0||t>=this.#n.length||e>=this.#n.length)return;const[r]=this.#n.splice(t,1);this.#n.splice(e,0,r)}async enqueuePoint(t,e){return this.#i?new Promise(((r,n)=>{this.#n.push({marker:"POINT_MARKER",task:t,resolve:r,reject:n,id:e}),this.#a()})):t()}enqueue(t,e,r){return new Promise(((n,i)=>{this.#n.push({task:t,resolve:n,reject:i,id:r,delay:e}),this.#a()}))}cancelTask(t){if(!t)return!1;let e=!1;t in this.#o&&(clearTimeout(this.#o[t]),delete this.#o[t],e=!0);const r=this.getIndexById(t);if(-1!==r){const[t]=this.#n.splice(r,1);t?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),e=!0}return e&&this.#s.add(t),e}},U=class{constructor({maxHits:t,interval:e,cleanupInterval:r,maxIdle:n=3e5}){const i=t=>"number"==typeof t&&Number.isFinite(t)&&t>=1&&Number.isInteger(t),o=i(t),s=i(e),u=i(r),a=i(n);if(!o&&!s)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==t&&!o)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==e&&!s)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==r&&!u)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!a)throw new Error("'maxIdle' must be a positive integer in milliseconds.");this.maxHits=o?t:null,this.interval=s?e:null,this.cleanupInterval=u?r:null,this.maxIdle=n,this.userData=new Map,this.lastSeen=new Map,null!==this.cleanupInterval&&(this._cleanupTimer=setInterval((()=>this._cleanup()),this.cleanupInterval))}getInterval(){if("number"!=typeof this.interval||!Number.isFinite(this.interval))throw new Error("'interval' is not a valid finite number.");return this.interval}getMaxHits(){if("number"!=typeof this.maxHits||!Number.isFinite(this.maxHits))throw new Error("'maxHits' is not a valid finite number.");return this.maxHits}hit(t){const e=Date.now();this.userData.has(t)||this.userData.set(t,[]);const r=this.userData.get(t);if(!r)throw new Error(`No data found for userId: ${t}`);if(r.push(e),this.lastSeen.set(t,e),null!==this.interval){const t=e-this.getInterval();for(;r.length&&r[0]<t;)r.shift()}if(null!==this.maxHits){const t=this.getMaxHits();r.length>t&&r.splice(0,r.length-t)}}isRateLimited(t){const e=Date.now();if(!this.userData.has(t))return!1;const r=this.userData.get(t);if(!r)throw new Error(`No data found for userId: ${t}`);if(null!==this.interval){const t=this.getInterval(),n=r.filter((r=>r>e-t));return null!==this.maxHits?n.length>=this.getMaxHits():n.length>0}return null!==this.maxHits&&r.length>=this.getMaxHits()}reset(t){this.userData.delete(t),this.lastSeen.delete(t)}setData(t,e){this.userData.set(t,e),this.lastSeen.set(t,Date.now())}getData(t){return this.userData.get(t)||[]}_cleanup(){const t=Date.now();for(const[e,r]of this.lastSeen.entries())t-r>this.maxIdle&&(this.userData.delete(e),this.lastSeen.delete(e))}destroy(){this._cleanupTimer&&clearInterval(this._cleanupTimer),this.userData.clear(),this.lastSeen.clear()}}})(),window.TinyEssentials=n})();
@@ -0,0 +1,236 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ // The require scope
4
+ /******/ var __webpack_require__ = {};
5
+ /******/
6
+ /************************************************************************/
7
+ /******/ /* webpack/runtime/define property getters */
8
+ /******/ (() => {
9
+ /******/ // define getter functions for harmony exports
10
+ /******/ __webpack_require__.d = (exports, definition) => {
11
+ /******/ for(var key in definition) {
12
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14
+ /******/ }
15
+ /******/ }
16
+ /******/ };
17
+ /******/ })();
18
+ /******/
19
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
20
+ /******/ (() => {
21
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22
+ /******/ })();
23
+ /******/
24
+ /************************************************************************/
25
+ var __webpack_exports__ = {};
26
+
27
+ // EXPORTS
28
+ __webpack_require__.d(__webpack_exports__, {
29
+ TinyRateLimiter: () => (/* reexport */ libs_TinyRateLimiter)
30
+ });
31
+
32
+ ;// ./src/v1/libs/TinyRateLimiter.mjs
33
+ /**
34
+ * Class representing a flexible rate limiter per user.
35
+ *
36
+ * This rate limiter can be configured by maximum number of hits,
37
+ * time interval, or a combination of both. It supports automatic
38
+ * cleanup of inactive users to optimize memory usage.
39
+ *
40
+ * @class
41
+ */
42
+ class TinyRateLimiter {
43
+ /**
44
+ * @param {Object} options
45
+ * @param {number} [options.maxHits] - Max interactions allowed
46
+ * @param {number} [options.interval] - Time window in milliseconds
47
+ * @param {number} [options.cleanupInterval] - Interval for automatic cleanup (ms)
48
+ * @param {number} [options.maxIdle=300000] - Max idle time for a user before being cleaned (ms)
49
+ */
50
+ constructor({ maxHits, interval, cleanupInterval, maxIdle = 300000 }) {
51
+ /** @param {number|undefined} val */
52
+ const isPositiveInteger = (val) =>
53
+ typeof val === 'number' && Number.isFinite(val) && val >= 1 && Number.isInteger(val);
54
+
55
+ const isMaxHitsValid = isPositiveInteger(maxHits);
56
+ const isIntervalValid = isPositiveInteger(interval);
57
+ const isCleanupValid = isPositiveInteger(cleanupInterval);
58
+ const isMaxIdleValid = isPositiveInteger(maxIdle);
59
+
60
+ if (!isMaxHitsValid && !isIntervalValid)
61
+ throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");
62
+ if (maxHits !== undefined && !isMaxHitsValid)
63
+ throw new Error("'maxHits' must be a positive integer if defined.");
64
+ if (interval !== undefined && !isIntervalValid)
65
+ throw new Error("'interval' must be a positive integer in milliseconds if defined.");
66
+ if (cleanupInterval !== undefined && !isCleanupValid)
67
+ throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");
68
+ if (!isMaxIdleValid) throw new Error("'maxIdle' must be a positive integer in milliseconds.");
69
+
70
+ this.maxHits = isMaxHitsValid ? maxHits : null;
71
+ this.interval = isIntervalValid ? interval : null;
72
+ this.cleanupInterval = isCleanupValid ? cleanupInterval : null;
73
+ this.maxIdle = maxIdle;
74
+
75
+ /** @type {Map<string, number[]>} */
76
+ this.userData = new Map();
77
+
78
+ /** @type {Map<string, number>} */
79
+ this.lastSeen = new Map();
80
+
81
+ // Start automatic cleanup only if cleanupInterval is valid
82
+ if (this.cleanupInterval !== null)
83
+ this._cleanupTimer = setInterval(() => this._cleanup(), this.cleanupInterval);
84
+ }
85
+
86
+ /**
87
+ * Get the interval window in milliseconds.
88
+ *
89
+ * @returns {number} The interval value.
90
+ * @throws {Error} If interval is not a valid finite number.
91
+ */
92
+ getInterval() {
93
+ if (typeof this.interval !== 'number' || !Number.isFinite(this.interval))
94
+ throw new Error("'interval' is not a valid finite number.");
95
+ return this.interval;
96
+ }
97
+
98
+ /**
99
+ * Get the maximum number of allowed hits.
100
+ *
101
+ * @returns {number} The maxHits value.
102
+ * @throws {Error} If maxHits is not a valid finite number.
103
+ */
104
+ getMaxHits() {
105
+ if (typeof this.maxHits !== 'number' || !Number.isFinite(this.maxHits)) {
106
+ throw new Error("'maxHits' is not a valid finite number.");
107
+ }
108
+ return this.maxHits;
109
+ }
110
+
111
+ /**
112
+ * Register a hit for a specific user
113
+ * @param {string} userId
114
+ */
115
+ hit(userId) {
116
+ const now = Date.now();
117
+
118
+ if (!this.userData.has(userId)) {
119
+ this.userData.set(userId, []);
120
+ }
121
+
122
+ const history = this.userData.get(userId);
123
+ if (!history) throw new Error(`No data found for userId: ${userId}`);
124
+
125
+ history.push(now);
126
+ this.lastSeen.set(userId, now);
127
+
128
+ // Clean up old entries
129
+ if (this.interval !== null) {
130
+ const interval = this.getInterval();
131
+ const cutoff = now - interval;
132
+ while (history.length && history[0] < cutoff) {
133
+ history.shift();
134
+ }
135
+ }
136
+
137
+ // Optional: keep only the last N entries for memory optimization
138
+ if (this.maxHits !== null) {
139
+ const maxHits = this.getMaxHits();
140
+ if (history.length > maxHits) {
141
+ history.splice(0, history.length - maxHits);
142
+ }
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Check if the user is currently rate limited
148
+ * @param {string} userId
149
+ * @returns {boolean}
150
+ */
151
+ isRateLimited(userId) {
152
+ const now = Date.now();
153
+
154
+ if (!this.userData.has(userId)) return false;
155
+
156
+ const history = this.userData.get(userId);
157
+ if (!history) throw new Error(`No data found for userId: ${userId}`);
158
+
159
+ if (this.interval !== null) {
160
+ const interval = this.getInterval();
161
+ const recent = history.filter((t) => t > now - interval);
162
+ if (this.maxHits !== null) {
163
+ return recent.length >= this.getMaxHits();
164
+ }
165
+ return recent.length > 0;
166
+ }
167
+
168
+ if (this.maxHits !== null) {
169
+ return history.length >= this.getMaxHits();
170
+ }
171
+
172
+ return false;
173
+ }
174
+
175
+ /**
176
+ * Manually reset user data
177
+ * @param {string} userId
178
+ */
179
+ reset(userId) {
180
+ this.userData.delete(userId);
181
+ this.lastSeen.delete(userId);
182
+ }
183
+
184
+ /**
185
+ * Set hit timestamps for a user
186
+ * @param {string} userId
187
+ * @param {number[]} timestamps
188
+ */
189
+ setData(userId, timestamps) {
190
+ this.userData.set(userId, timestamps);
191
+ this.lastSeen.set(userId, Date.now());
192
+ }
193
+
194
+ /**
195
+ * Get timestamps from user
196
+ * @param {string} userId
197
+ * @returns {number[]}
198
+ */
199
+ getData(userId) {
200
+ return this.userData.get(userId) || [];
201
+ }
202
+
203
+ /**
204
+ * Cleanup old/inactive users
205
+ * @private
206
+ */
207
+ _cleanup() {
208
+ const now = Date.now();
209
+ for (const [userId, last] of this.lastSeen.entries()) {
210
+ if (now - last > this.maxIdle) {
211
+ this.userData.delete(userId);
212
+ this.lastSeen.delete(userId);
213
+ }
214
+ }
215
+ }
216
+
217
+ /**
218
+ * Destroy the rate limiter, stopping all intervals
219
+ */
220
+ destroy() {
221
+ if (this._cleanupTimer) clearInterval(this._cleanupTimer);
222
+ this.userData.clear();
223
+ this.lastSeen.clear();
224
+ }
225
+ }
226
+
227
+ /* harmony default export */ const libs_TinyRateLimiter = (TinyRateLimiter);
228
+
229
+ ;// ./src/v1/build/TinyRateLimiter.mjs
230
+
231
+
232
+
233
+
234
+ window.TinyRateLimiter = __webpack_exports__.TinyRateLimiter;
235
+ /******/ })()
236
+ ;
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{TinyRateLimiter:()=>i});const i=class{constructor({maxHits:t,interval:e,cleanupInterval:i,maxIdle:s=3e5}){const r=t=>"number"==typeof t&&Number.isFinite(t)&&t>=1&&Number.isInteger(t),n=r(t),a=r(e),l=r(i),o=r(s);if(!n&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==t&&!n)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==e&&!a)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==i&&!l)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!o)throw new Error("'maxIdle' must be a positive integer in milliseconds.");this.maxHits=n?t:null,this.interval=a?e:null,this.cleanupInterval=l?i:null,this.maxIdle=s,this.userData=new Map,this.lastSeen=new Map,null!==this.cleanupInterval&&(this._cleanupTimer=setInterval((()=>this._cleanup()),this.cleanupInterval))}getInterval(){if("number"!=typeof this.interval||!Number.isFinite(this.interval))throw new Error("'interval' is not a valid finite number.");return this.interval}getMaxHits(){if("number"!=typeof this.maxHits||!Number.isFinite(this.maxHits))throw new Error("'maxHits' is not a valid finite number.");return this.maxHits}hit(t){const e=Date.now();this.userData.has(t)||this.userData.set(t,[]);const i=this.userData.get(t);if(!i)throw new Error(`No data found for userId: ${t}`);if(i.push(e),this.lastSeen.set(t,e),null!==this.interval){const t=e-this.getInterval();for(;i.length&&i[0]<t;)i.shift()}if(null!==this.maxHits){const t=this.getMaxHits();i.length>t&&i.splice(0,i.length-t)}}isRateLimited(t){const e=Date.now();if(!this.userData.has(t))return!1;const i=this.userData.get(t);if(!i)throw new Error(`No data found for userId: ${t}`);if(null!==this.interval){const t=this.getInterval(),s=i.filter((i=>i>e-t));return null!==this.maxHits?s.length>=this.getMaxHits():s.length>0}return null!==this.maxHits&&i.length>=this.getMaxHits()}reset(t){this.userData.delete(t),this.lastSeen.delete(t)}setData(t,e){this.userData.set(t,e),this.lastSeen.set(t,Date.now())}getData(t){return this.userData.get(t)||[]}_cleanup(){const t=Date.now();for(const[e,i]of this.lastSeen.entries())t-i>this.maxIdle&&(this.userData.delete(e),this.lastSeen.delete(e))}destroy(){this._cleanupTimer&&clearInterval(this._cleanupTimer),this.userData.clear(),this.lastSeen.clear()}};window.TinyRateLimiter=e.TinyRateLimiter})();