tiny-essentials 1.27.1 → 1.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/changelog/1/28/0.md +16 -0
- package/changelog/1/28/1.md +23 -0
- package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
- package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
- package/dist/v1/TinyAnalogClock.min.js +1 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -2
- package/dist/v1/TinyDayNightCycle.min.js +1 -1
- package/dist/v1/TinyDragDropDetector.min.js +1 -1
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyElementObserver.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -2
- package/dist/v1/TinyGamepad.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinyI18.min.js +1 -1
- package/dist/v1/TinyIframeEvents.min.js +1 -1
- package/dist/v1/TinyLocalStorage.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyNewWinEvents.min.js +1 -1
- package/dist/v1/TinyNotifyCenter.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/TinyRateLimiter.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyTextDiffer.min.js +1 -1
- package/dist/v1/TinyTextarea.min.js +1 -1
- package/dist/v1/TinyTimeout.min.js +1 -1
- package/dist/v1/TinyToastNotify.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -2
- package/dist/v1/UltraRandomMsgGen.min.js +1 -1
- package/dist/v1/basics/array.cjs +57 -9
- package/dist/v1/basics/array.d.mts +27 -11
- package/dist/v1/basics/array.mjs +51 -9
- package/dist/v1/basics/clock.cjs +94 -42
- package/dist/v1/basics/clock.d.mts +10 -10
- package/dist/v1/basics/clock.mjs +91 -54
- package/dist/v1/basics/deprecated/html.cjs +246 -0
- package/dist/v1/basics/deprecated/html.d.mts +63 -0
- package/dist/v1/basics/deprecated/html.mjs +190 -0
- package/dist/v1/basics/extendObjType/Buffer.cjs +13 -0
- package/dist/v1/basics/extendObjType/Buffer.d.mts +4 -0
- package/dist/v1/basics/extendObjType/Buffer.mjs +8 -0
- package/dist/v1/basics/html.cjs +149 -130
- package/dist/v1/basics/html.d.mts +26 -61
- package/dist/v1/basics/html.mjs +113 -105
- package/dist/v1/basics/index.cjs +2 -0
- package/dist/v1/basics/index.d.mts +3 -1
- package/dist/v1/basics/index.mjs +3 -3
- package/dist/v1/basics/mediaContent.cjs +51 -9
- package/dist/v1/basics/mediaContent.d.mts +0 -87
- package/dist/v1/basics/mediaContent.mjs +40 -10
- package/dist/v1/basics/objChecker.cjs +7 -5
- package/dist/v1/basics/objChecker.d.mts +3 -2
- package/dist/v1/basics/objChecker.mjs +6 -6
- package/dist/v1/basics/objFilter.cjs +40 -18
- package/dist/v1/basics/objFilter.d.mts +6 -6
- package/dist/v1/basics/objFilter.mjs +32 -17
- package/dist/v1/basics/simpleMath.cjs +81 -25
- package/dist/v1/basics/simpleMath.d.mts +2 -2
- package/dist/v1/basics/simpleMath.mjs +70 -27
- package/dist/v1/basics/text.cjs +76 -31
- package/dist/v1/basics/text.d.mts +69 -7
- package/dist/v1/basics/text.mjs +62 -31
- package/dist/v1/index.cjs +4 -2
- package/dist/v1/index.d.mts +4 -2
- package/dist/v1/index.mjs +4 -4
- package/dist/v1/libs/TinyAdvancedRaffle.cjs +71 -255
- package/dist/v1/libs/TinyAdvancedRaffle.d.mts +6 -134
- package/dist/v1/libs/TinyAdvancedRaffle.mjs +69 -228
- package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +4 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
- package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
- package/dist/v1/libs/TinyAnalogClock.d.mts +6 -0
- package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
- package/dist/v1/libs/TinyClipboard.cjs +2 -0
- package/dist/v1/libs/TinyClipboard.d.mts +4 -2
- package/dist/v1/libs/TinyClipboard.mjs +2 -0
- package/dist/v1/libs/TinyColorConverter.cjs +1 -0
- package/dist/v1/libs/TinyColorConverter.d.mts +2 -1
- package/dist/v1/libs/TinyColorConverter.mjs +1 -0
- package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
- package/dist/v1/libs/TinyDayNightCycle.d.mts +2 -7
- package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
- package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
- package/dist/v1/libs/TinyDragDropDetector.d.mts +6 -0
- package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
- package/dist/v1/libs/TinyDragger.cjs +46 -19
- package/dist/v1/libs/TinyDragger.mjs +45 -18
- package/dist/v1/libs/TinyElementObserver.cjs +39 -0
- package/dist/v1/libs/TinyElementObserver.d.mts +6 -0
- package/dist/v1/libs/TinyElementObserver.mjs +36 -0
- package/dist/v1/libs/TinyGamepad.cjs +131 -1
- package/dist/v1/libs/TinyGamepad.mjs +129 -1
- package/dist/v1/libs/TinyHtml.cjs +1 -1
- package/dist/v1/libs/TinyHtml.mjs +2 -2
- package/dist/v1/libs/TinyI18.cjs +61 -0
- package/dist/v1/libs/TinyI18.d.mts +14 -0
- package/dist/v1/libs/TinyI18.mjs +55 -0
- package/dist/v1/libs/TinyIframeEvents.cjs +26 -196
- package/dist/v1/libs/TinyIframeEvents.d.mts +3 -122
- package/dist/v1/libs/TinyIframeEvents.mjs +26 -171
- package/dist/v1/libs/TinyLocalStorage.cjs +53 -205
- package/dist/v1/libs/TinyLocalStorage.d.mts +6 -127
- package/dist/v1/libs/TinyLocalStorage.mjs +50 -178
- package/dist/v1/libs/TinyMediaPlayer.cjs +74 -2
- package/dist/v1/libs/TinyMediaPlayer.d.mts +12 -2
- package/dist/v1/libs/TinyMediaPlayer.mjs +68 -2
- package/dist/v1/libs/TinyNewWinEvents.cjs +39 -197
- package/dist/v1/libs/TinyNewWinEvents.d.mts +6 -119
- package/dist/v1/libs/TinyNewWinEvents.mjs +36 -172
- package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
- package/dist/v1/libs/TinyNotifyCenter.d.mts +6 -0
- package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
- package/dist/v1/libs/TinyRadioFm.cjs +40 -3
- package/dist/v1/libs/TinyRadioFm.d.mts +3 -3
- package/dist/v1/libs/TinyRadioFm.mjs +37 -3
- package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
- package/dist/v1/libs/TinyRateLimiter.d.mts +6 -0
- package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
- package/dist/v1/libs/TinySmartScroller.cjs +56 -205
- package/dist/v1/libs/TinySmartScroller.d.mts +19 -152
- package/dist/v1/libs/TinySmartScroller.mjs +55 -181
- package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
- package/dist/v1/libs/TinyTextDiffer.d.mts +1 -0
- package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
- package/dist/v1/libs/TinyTextarea.cjs +19 -0
- package/dist/v1/libs/TinyTextarea.d.mts +6 -0
- package/dist/v1/libs/TinyTextarea.mjs +17 -0
- package/dist/v1/libs/TinyTimeout.cjs +11 -1
- package/dist/v1/libs/TinyTimeout.mjs +9 -1
- package/dist/v1/libs/TinyToastNotify.cjs +35 -0
- package/dist/v1/libs/TinyToastNotify.d.mts +6 -0
- package/dist/v1/libs/TinyToastNotify.mjs +31 -0
- package/dist/v1/libs/TinyUploadClicker.cjs +20 -0
- package/dist/v1/libs/TinyUploadClicker.d.mts +6 -0
- package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
- package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +17 -3
- package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
- package/dist/v1/libs/utils.cjs +21 -0
- package/dist/v1/libs/utils.d.mts +2 -0
- package/dist/v1/libs/utils.mjs +16 -0
- package/docs/v1/Exports.md +0 -1
- package/docs/v1/README.md +1 -1
- package/docs/v1/basics/array.md +2 -2
- package/docs/v1/basics/deprecated/html.md +17 -0
- package/docs/v1/basics/fullScreen.md +1 -1
- package/docs/v1/basics/html.md +12 -26
- package/docs/v1/basics/mediaContent.md +1 -1
- package/docs/v1/basics/objChecker.md +1 -1
- package/docs/v1/basics/objFilter.md +1 -1
- package/docs/v1/basics/text.md +2 -2
- package/docs/v1/fileManager/main.md +1 -1
- package/docs/v1/libs/ColorSafeStringify.md +1 -1
- package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
- package/docs/v1/libs/TinyAnalogClock.md +1 -1
- package/docs/v1/libs/TinyArrayComparator.md +1 -1
- package/docs/v1/libs/TinyArrayPaginator.md +1 -1
- package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
- package/docs/v1/libs/TinyClassManager.md +1 -1
- package/docs/v1/libs/TinyClipboard.md +1 -1
- package/docs/v1/libs/TinyCookieConsent.md +1 -1
- package/docs/v1/libs/TinyDomReadyManager.md +1 -1
- package/docs/v1/libs/TinyDragDropDetector.md +1 -1
- package/docs/v1/libs/TinyDragger.md +1 -1
- package/docs/v1/libs/TinyElementObserver.md +1 -1
- package/docs/v1/libs/TinyHtml.md +1 -1
- package/docs/v1/libs/TinyIframeEvents.md +10 -10
- package/docs/v1/libs/TinyLevelUp.md +1 -1
- package/docs/v1/libs/TinyLoadingScreen.md +1 -1
- package/docs/v1/libs/TinyLocalStorage.md +3 -3
- package/docs/v1/libs/TinyNewWinEvents.md +10 -11
- package/docs/v1/libs/TinyNotifications.md +1 -1
- package/docs/v1/libs/TinyPromiseQueue.md +2 -2
- package/docs/v1/libs/TinyTextDiffer.md +1 -1
- package/docs/v1/libs/TinyTextarea.md +1 -1
- package/package.json +15 -5
- package/dist/v1/TinyBasicsEs.min.js.LICENSE.txt +0 -8
- package/dist/v1/TinyEssentials.min.js.LICENSE.txt +0 -8
- package/dist/v1/TinyEvents.min.js +0 -1
- package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +0 -8
- package/dist/v1/build/TinyEvents.cjs +0 -7
- package/dist/v1/build/TinyEvents.d.mts +0 -3
- package/dist/v1/build/TinyEvents.mjs +0 -2
- package/dist/v1/libs/TinyEvents.cjs +0 -395
- package/dist/v1/libs/TinyEvents.d.mts +0 -164
- package/dist/v1/libs/TinyEvents.mjs +0 -360
- package/docs/v1/libs/TinyEvents.md +0 -187
package/README.md
CHANGED
|
@@ -59,6 +59,7 @@ Check out the full documentation here:
|
|
|
59
59
|
- 🖥️ [**tiny-server-essentials**](https://github.com/Tiny-Essentials/Tiny-Server-Essentials) — Node.js server utilities.
|
|
60
60
|
- 🪟 [**tiny-electron-essentials**](https://github.com/Tiny-Essentials/Tiny-Electron-Essentials) — Essential tools for Electron apps.
|
|
61
61
|
- 🗃️ [**puddysql**](https://github.com/Tiny-Essentials/PuddySQL) — Smart SQL engine for structured data, tags, and advanced queries.
|
|
62
|
+
- 📢 [**my-tiny-events**](https://github.com/Tiny-Essentials/My-Tiny-Events) — A event emitter system for JavaScript, inspired by Node.js EventEmitter with support for multi-event handling and listener management.
|
|
62
63
|
|
|
63
64
|
---
|
|
64
65
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## 🛠️ Summary of Changes
|
|
2
|
+
|
|
3
|
+
### 💎 `TinyNewWinEvents` & `TinyIframeEvents`
|
|
4
|
+
|
|
5
|
+
* **New Feature:** Added `winEmit` to emit events directly to a window. The standard `emit` function will now fall back to the native `EventEmitter` implementation.
|
|
6
|
+
* **Security & Namespacing:** To enforce strict isolation and improve event tracking, all events dispatched via `winEmit` are now automatically prefixed. They will always return in the format: `win:{EventName}`.
|
|
7
|
+
|
|
8
|
+
### 📦 `Buffer` Module Optimization
|
|
9
|
+
|
|
10
|
+
* **Breaking Change:** To make the core package lighter, the `Buffer` utility has been **removed** from `objType.mjs`.
|
|
11
|
+
* **How to Restore:** If your project relies on this functionality, you can easily re-introduce it manually by importing it from `basics/extendObjType/Buffer.mjs`.
|
|
12
|
+
|
|
13
|
+
### 🔄 `TinyEvents` Migration to `MyTinyEvents`
|
|
14
|
+
|
|
15
|
+
* **Repository Migration:** `TinyEvents` has officially been migrated to a dedicated repository. It is now maintained as **MyTinyEvents** at [Tiny-Essentials/My-Tiny-Events](https://github.com/Tiny-Essentials/My-Tiny-Events).
|
|
16
|
+
* **Architecture Update:** All modules within the `tiny-essentials` ecosystem have been refactored to natively use `EventEmitter` for robust and standardized event handling.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## 🚀 New Features
|
|
2
|
+
* **Destroy Detectors:** Added destroy detectors for the following modules:
|
|
3
|
+
* `TinyTextDiffer`, `TinySmartScroller`, `TinyRadioFm`, `TinyMediaPlayer`, `TinyDragger`, `TinyAfterScrollWatcher`, `UltraRandomMsgGen`, `TinyUploadClicker`, `TinyToastNotify`, `TinyTimeout`, `TinyTextarea`, `TinyRateLimiter`, `TinyNotifyCenter`, `TinyNewWinEvents`, `TinyLocalStorage`, `TinyIframeEvents`, `TinyI18`, `TinyGamepad`, `TinyElementObserver`, `TinyDragDropDetector`, `TinyDayNightCycle`, `TinyAnalogClock`, and `TinyAdvancedRaffle`.
|
|
4
|
+
* **UltraRandomMsgGen:** Expanded with new values.
|
|
5
|
+
* **jsDoc Enhancements:** Added support for template types in jsDoc (e.g., `<string>`) for the following functions:
|
|
6
|
+
* `multiplyArrayBlocks`
|
|
7
|
+
* `diffArrayList`
|
|
8
|
+
* `diffStrings`
|
|
9
|
+
|
|
10
|
+
## 🛠️ Improvements
|
|
11
|
+
* **Enhanced Validation:**
|
|
12
|
+
* Improved argument validation across all JavaScript files in the `/basics` directory (Note: `fullScreen.mjs` and `collision.mjs` were excluded from this update).
|
|
13
|
+
* `countObj` now throws an error if the provided argument is not an `Array` or an `Object`.
|
|
14
|
+
* **Array Sorting:** `arraySortPositions` now accepts `null` values, enabling direct comparison of elements within the array (optimized for arrays of numbers or strings).
|
|
15
|
+
* **Fetch API Refactor:** In `/basics/html`, the functions `fetchJson`, `fetchText`, and `fetchBlob` have been refactored to use the native Fetch API directly.
|
|
16
|
+
|
|
17
|
+
## 🐛 Bug Fixes
|
|
18
|
+
* **jsDoc Corrections:** Fixed private jsDoc annotations for:
|
|
19
|
+
* `TinyAdvancedRaffle`, `TinyAfterScrollWatcher`, `TinyClipboard`, `TinyColorConverter`, `TinyDayNightCycle`, and `TinySmartScroller`.
|
|
20
|
+
|
|
21
|
+
## ⚠️ Breaking Changes & Deprecations
|
|
22
|
+
* **Renaming:** `diffStrings` has been renamed to `diffObjList`.
|
|
23
|
+
* **Deprecation:** The legacy versions of `fetchJson`, `fetchText`, and `fetchBlob` have been moved to `/basics/deprecated/html`. Please update your imports to the new implementations in `/basics/html`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var s=0;s<r.length;){var i=r[s++],n=r[s++];e.o(t,i)?0===n&&s++:0===n?Object.defineProperty(t,i,{enumerable:!0,value:r[s++]}):Object.defineProperty(t,i,{enumerable:!0,get:n})}else for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyAdvancedRaffle:()=>i});const r=class{#e=new Map;#t=10;#r=!1;#s(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.#r=e}getThrowOnMaxListeners(){return this.#r}#i(e,t,{once:r=!1}={}){let s=this.#e.get(e);Array.isArray(s)||(s=[],this.#e.set(e,s)),s.unshift({handler:t,config:{once:r}});const i=this.#t;if(i>0&&s.length>i){const t=`Possible memory leak detected. ${s.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#r)throw new Error(t);console.warn(t)}}prependListener(e,t){const r=this.#s(e,"prependListener");if("function"!=typeof t)throw new TypeError("prependListener(event, handler): handler must be a function");for(const e of r)this.#i(e,t)}prependListenerOnce(e,t){const r=this.#s(e,"prependListenerOnce");if("function"!=typeof t)throw new TypeError("prependListenerOnce(event, handler): handler must be a function");const s=[];for(const e of r){const r=(...s)=>{this.off(e,r),t(...s)};this.#i(e,r,{once:!0}),s.push(r)}return s}#n(e,t,{once:r=!1}={}){const s=this.#s(e,"on");for(const e of s){let s=this.#e.get(e);Array.isArray(s)||(s=[],this.#e.set(e,s)),s.push({handler:t,config:{once:r}});const i=this.#t;if(i>0&&s.length>i){const t=`Possible memory leak detected. ${s.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#r)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.#n(e,t)}once(e,t){const r=this.#s(e,"once");if("function"!=typeof t)throw new TypeError("once(event, handler): handler must be a function");const s=[];for(const e of r){const r=(...s)=>{this.off(e,r),t(...s)};this.#n(e,r,{once:!0}),s.push(r)}return s}appendListener(e,t){return this.on(e,t)}appendListenerOnce(e,t){return this.once(e,t)}off(e,t){const r=this.#s(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.#e.get(e);if(!Array.isArray(r))continue;const s=r.findIndex(e=>e.handler===t);-1!==s&&r.splice(s,1),0===r.length&&this.#e.delete(e)}}offAll(e){const t=this.#s(e,"offAll");for(const e of t)this.#e.delete(e)}offAllTypes(){this.#e.clear()}removeAllListeners(){return this.offAllTypes()}listenerCount(e){if("string"!=typeof e)throw new TypeError("listenerCount(event): event name must be a string");const t=this.#e.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.#e.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.#e.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.#e.get(e);return Array.isArray(t)?[...t].map(e=>e.handler):[]}eventNames(){return[...this.#e.keys()]}emit(e,...t){const r=this.#s(e,"emit"),s=[];for(const e of r){const r=this.#e.get(e);Array.isArray(r)&&0!==r.length?(r.forEach(e=>e.handler(...t)),s.push(!0)):s.push(!1)}return s}setMaxListeners(e){if(!Number.isInteger(e)||e<0)throw new TypeError("setMaxListeners(n): n must be a non-negative integer");this.#t=e}getMaxListeners(){return this.#t}};class s{#o=new r;#a(e,...t){return this.#o.emit(e,...t)}setThrowOnMaxListeners(e){return this.#o.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#o.getThrowOnMaxListeners()}prependListener(e,t){return this.#o.prependListener(e,t)}prependListenerOnce(e,t){return this.#o.prependListenerOnce(e,t)}appendListener(e,t){return this.#o.appendListener(e,t)}appendListenerOnce(e,t){return this.#o.appendListenerOnce(e,t)}on(e,t){return this.#o.on(e,t)}once(e,t){return this.#o.once(e,t)}off(e,t){return this.#o.off(e,t)}offAll(e){return this.#o.offAll(e)}offAllTypes(){return this.#o.offAllTypes()}listenerCount(e){return this.#o.listenerCount(e)}listeners(e){return this.#o.listeners(e)}onceListeners(e){return this.#o.onceListeners(e)}allListeners(e){return this.#o.allListeners(e)}eventNames(){return this.#o.eventNames()}setMaxListeners(e){return this.#o.setMaxListeners(e)}getMaxListeners(){return this.#o.getMaxListeners()}#h=!1;#u;#f;#p=[];#c=[];#m=[];#l=new Map;#y=new Set;#d=new Map;#g;#w=new Map;#b=new Map;get isDestroyed(){return this.#h}get freq(){return Object.fromEntries(this.#b)}get size(){return this.#w.size}get normalization(){return this.#u}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.#u=e}get seed(){return this.#f}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.#f=e,null!==e&&(this.#g=this._makeSeededRng(e))}get globalModifiers(){return[...this.#p]}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.#p=e}get temporaryModifiers(){return[...this.#c]}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.#c=e}get conditionalRules(){return[...this.#m]}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.#m=e}get pitySystems(){return Object.fromEntries(this.#l)}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.#l=e}get exclusions(){return Array.from(this.#y)}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.#y=e}get groups(){const e={};return this.#d.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.#d=e}get rng(){return this.#g}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.#g=e}get items(){const e={};return this.#w.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.#w=e}constructor(e={}){const{rng:t=null,seed:r=null,normalization:s="relative"}=e;this.#u=s,this.#f=r,"function"==typeof t?this.#g=t:null!==this.#f?this.#g=this._makeSeededRng(this.#f):this.#g=Math.random,this.#f=r??null}_checkDestroyed(){if(this.#h)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.#w.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:s=e,meta:i={},groups:n=[]}=t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError("weight must be a non-negative number");if("string"!=typeof s)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(n)||n instanceof Set))throw new TypeError("groups must be an array or a Set of strings");n=Array.isArray(n)?n:[...n];for(const e of n)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const o={id:e,label:s,baseWeight:Math.max(0,Number(r)||0),meta:{...i},groups:new Set(n),locked:!1};this.#w.set(e,o);for(const t of n)this._ensureGroup(t).add(e);return this.#a("itemAdded",o),o}removeItem(e){if(this._checkDestroyed(),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#w.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#d.get(r);t&&t.delete(e)}return this.#w.delete(e),this.#a("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.#w.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.#a("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.#w.get(e)??null}listItems(){return Array.from(this.#w.values()).map(e=>({...e}))}clearList(){this._checkDestroyed(),this.#w.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#p.includes(e)}addGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#p.push(e)}removeGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#p=this.#p.filter(t=>t!==e)}hasTemporaryModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#c.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.#c.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.#c.length;return this.#c=this.#c.filter(t=>t.fn!==e),this.#c.length!==t}hasConditionalRule(e){if("function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#m.includes(e)}addConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#m.push(e)}removeConditionalRule(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#m.length;return this.#m=this.#m.filter(t=>t!==e),this.#m.length!==t}hasPity(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#l.has(e)}configurePity(e,t){if(this._checkDestroyed(),!this.#w.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:s,cap:i=1/0}=t;if("number"!=typeof r||r<=0)throw new TypeError("threshold must be a positive number");if("number"!=typeof s)throw new TypeError("increment must be a number");if("number"!=typeof i)throw new TypeError("cap must be a number");this.#l.set(e,{threshold:Math.max(1,r),increment:Number(s)||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.#l.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){this._checkDestroyed(),this.#l.clear()}hasExclusion(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#y.has(e)}excludeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#y.add(e)}includeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#y.delete(e)}_ensureGroup(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#d.get(e);return t||(t=new Set,this.#d.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.#d.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.#w.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.#d.get(t);r&&r.delete(e);const s=this.#w.get(e);s&&s.groups.delete(t)}clearFreqs(){this._checkDestroyed(),this.#b.clear()}resetFreq(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#b.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.#w)t.set(e,r.baseWeight);for(const r of this.#p){const s=r(t,e);if(s instanceof Map)for(const[e,r]of s)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#c){const s=r.fn(t,e);if(s instanceof Map)for(const[e,r]of s)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#m){const s=r(t,e);if(s instanceof Map)for(const[e,r]of s)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const[e,r]of this.#l)if(t.has(e)&&r.counter>r.threshold){r.currentAdd=Math.min(r.cap,r.currentAdd+r.increment);const s=t.get(e);s&&t.set(e,s+r.currentAdd)}for(const e of this.#y)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.#u){const e=Math.max(...t.map(e=>e.weight)),r=t.map(t=>Math.exp(t.weight-e)),s=r.reduce((e,t)=>e+t,0);let i=0;return t.map((e,t)=>{const n=r[t]/s;return i+=n,{id:e.id,weight:e.weight,p:n,cumulative:i}})}{const e=t.reduce((e,t)=>e+t.weight,0);let r=0;return t.map(t=>{const s=t.weight/e;return r+=s,{id:t.id,weight:t.weight,p:s,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.#c]},r=this.computeEffectiveWeights(t),s=this._weightsToDistribution(r);if(!s.length)return null;const i=this.#g(),n=s.find(e=>i<=e.cumulative)??s[s.length-1];for(const[e,t]of this.#l)e===n.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const o=this.#w.get(n.id);if(!o)return null;const a={id:o.id,label:o.label,meta:{...o.meta},prob:n.p};return this.#a("draw",a),a&&this.#b.set(a.id,(this.#b.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){this._checkDestroyed();for(let e=this.#c.length-1;e>=0;--e){const t=this.#c[e];t.uses-=1,t.uses<=0&&this.#c.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,s=t.ensureUnique??!1,i=[],n=t.previousDraws??[];if(!r&&s){const r=new Set;for(let s=0;s<e;++s){const e=new Set(this.#y);for(const e of r)this.#y.add(e);const s=this.drawOne({previousDraws:n,metadata:t.metadata});if(this.#y=e,!s)break;i.push(s),r.add(s.id),n.push(s)}return i}for(let s=0;s<e;++s){const e=this.drawOne({previousDraws:n,metadata:t.metadata});if(!e)break;i.push(e),n.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.#w.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.#l.entries()),exclusions:Array.from(this.#y),normalization:this.#u,seed:this.#f}}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.#w.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 s;return e.#u=this.#u,e.#f=this.#f,e.#p=[...this.#p],e.#c=this.#c.map(e=>({fn:e.fn,uses:e.uses})),e.#m=[...this.#m],e.#l=new Map([...this.#l.entries()].map(([e,t])=>[e,{...t}])),e.#y=new Set(this.#y),e.#d=new Map([...this.#d.entries()].map(([e,t])=>[e,new Set(t)])),e.#g=this.#g,e.#w=new Map([...this.#w.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#b=new Map(this.#b),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.#h||(this.#h=!0,this.#l.clear(),this.#y.clear(),this.#d.clear(),this.#w.clear(),this.#b.clear(),this.#p=[],this.#c=[],this.#m=[],this.#f=null)}}const i=s;window.TinyAdvancedRaffle=t.TinyAdvancedRaffle})();
|
|
1
|
+
(()=>{"use strict";var e={7(e){var t,r="object"==typeof Reflect?Reflect:null,i=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(r,i){function s(r){e.removeListener(t,o),i(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}l(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&l(e,"error",t,{once:!0})}(e,s)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var n=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function f(e,t,r,i){var s,o,n,f;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),n=o[t]),void 0===n)n=o[t]=r,++e._eventsCount;else if("function"==typeof n?n=o[t]=i?[r,n]:[n,r]:i?n.unshift(r):n.push(r),(s=u(e))>0&&n.length>s&&!n.warned){n.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+n.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=n.length,f=h,console&&console.warn&&console.warn(f)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=h.bind(i);return s.listener=r,i.wrapFn=s,s}function y(e,t,r){var i=e._events;if(void 0===i)return[];var s=i[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(s):d(s,s.length)}function m(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function l(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function s(o){i.once&&e.removeEventListener(t,s),r(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return n},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");n=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var s="error"===e,o=this._events;if(void 0!==o)s=s&&void 0===o.error;else if(!s)return!1;if(s){var n;if(t.length>0&&(n=t[0]),n instanceof Error)throw n;var a=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw a.context=n,a}var u=o[e];if(void 0===u)return!1;if("function"==typeof u)i(u,this,t);else{var f=u.length,h=d(u,f);for(r=0;r<f;++r)i(h[r],this,t)}return!0},o.prototype.addListener=function(e,t){return f(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return f(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,p(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,p(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,i,s,o,n;if(a(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){n=r[o].listener,s=o;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,s),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,n||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var s,o=Object.keys(r);for(i=0;i<o.length;++i)"removeListener"!==(s=o[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return y(this,e,!0)},o.prototype.rawListeners=function(e){return y(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},o.prototype.listenerCount=m,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function r(i){const s=t[i];if(void 0!==s)return s.exports;const o=t[i]={exports:{}};return e[i](o,o.exports,r),o.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var i=0;i<t.length;){var s=t[i++],o=t[i++];r.o(e,s)?0===o&&i++:0===o?Object.defineProperty(e,s,{enumerable:!0,value:t[i++]}):Object.defineProperty(e,s,{enumerable:!0,get:o})}else for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let i={};r.d(i,{TinyAdvancedRaffle:()=>a});var s=r(7);const o=e=>{if(e)throw new Error("This TinyAdvancedRaffle instance has been destroyed and can no longer be used.")};class n extends s.EventEmitter{#e=!1;#t;#r;#i=[];#s=[];#o=[];#n=new Map;#a=new Set;#u=new Map;#f;#h=new Map;#p=new Map;get isDestroyed(){return this.#e}get freq(){return o(this.#e),Object.fromEntries(this.#p)}get size(){return o(this.#e),this.#h.size}get normalization(){return o(this.#e),this.#t}set normalization(e){if(o(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("normalization must be a non-empty string (e.g., 'relative', 'softmax').");this.#t=e}get seed(){return o(this.#e),this.#r}set seed(e){if(o(this.#e),null!==e&&("number"!=typeof e||!Number.isFinite(e)))throw new TypeError("seed must be a finite number or null.");this.#r=e,null!==e&&(this.#f=this._makeSeededRng(e))}get globalModifiers(){return o(this.#e),[...this.#i]}set globalModifiers(e){if(o(this.#e),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("globalModifiers must be an array of functions (WeightsCallback).");this.#i=e}get temporaryModifiers(){return o(this.#e),[...this.#s]}set temporaryModifiers(e){if(o(this.#e),!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.#s=e}get conditionalRules(){return o(this.#e),[...this.#o]}set conditionalRules(e){if(o(this.#e),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#o=e}get pitySystems(){return o(this.#e),Object.fromEntries(this.#n)}set pitySystems(e){if(o(this.#e),!(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.#n=e}get exclusions(){return o(this.#e),Array.from(this.#a)}set exclusions(e){if(o(this.#e),!(e instanceof Set&&[...e].every(e=>"string"==typeof e)))throw new TypeError("exclusions must be a Set<string>.");this.#a=e}get groups(){o(this.#e);const e={};return this.#u.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(o(this.#e),!(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.#u=e}get rng(){return o(this.#e),this.#f}set rng(e){if(o(this.#e),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#f=e}get items(){o(this.#e);const e={};return this.#h.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(o(this.#e),!(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.#h=e}constructor(e={}){super();const{rng:t=null,seed:r=null,normalization:i="relative"}=e;this.#t=i,this.#r=r,"function"==typeof t?this.#f=t:null!==this.#r?this.#f=this._makeSeededRng(this.#r):this.#f=Math.random,this.#r=r??null}hasItem(e){if(o(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#h.has(e)}addItem(e,t={}){if(o(this.#e),"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:i=e,meta:s={},groups:n=[]}=t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError("weight must be a non-negative number");if("string"!=typeof i)throw new TypeError("label must be a string");if("object"!=typeof s||null===s)throw new TypeError("meta must be an object");if(!(Array.isArray(n)||n instanceof Set))throw new TypeError("groups must be an array or a Set of strings");n=Array.isArray(n)?n:[...n];for(const e of n)if("string"!=typeof e)throw new TypeError("groups must contain only strings");const a={id:e,label:i,baseWeight:Math.max(0,Number(r)||0),meta:{...s},groups:new Set(n),locked:!1};this.#h.set(e,a);for(const t of n)this._ensureGroup(t).add(e);return this.emit("itemAdded",a),a}removeItem(e){if(o(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#h.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#u.get(r);t&&t.delete(e)}return this.#h.delete(e),this.emit("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(o(this.#e),"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.#h.get(e);if(!r)throw new Error("Item not found");r.baseWeight=Math.max(0,Number(t)||0),this.emit("weightChanged",{id:e,weight:r.baseWeight})}getItem(e){if(o(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#h.get(e)??null}listItems(){return o(this.#e),Array.from(this.#h.values()).map(e=>({...e}))}clearList(){o(this.#e),this.#h.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if(o(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#i.includes(e)}addGlobalModifier(e){if(o(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");this.#i.push(e)}removeGlobalModifier(e){if(o(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");this.#i=this.#i.filter(t=>t!==e)}hasTemporaryModifier(e){if(o(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#s.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(o(this.#e),"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.#s.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(o(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#s.length;return this.#s=this.#s.filter(t=>t.fn!==e),this.#s.length!==t}hasConditionalRule(e){if(o(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#o.includes(e)}addConditionalRule(e){if(o(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#o.push(e)}removeConditionalRule(e){if(o(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#o.length;return this.#o=this.#o.filter(t=>t!==e),this.#o.length!==t}hasPity(e){if(o(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#n.has(e)}configurePity(e,t){if(o(this.#e),!this.#h.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:i,cap:s=1/0}=t;if("number"!=typeof r||r<=0)throw new TypeError("threshold must be a positive number");if("number"!=typeof i)throw new TypeError("increment must be a number");if("number"!=typeof s)throw new TypeError("cap must be a number");this.#n.set(e,{threshold:Math.max(1,r),increment:Number(i)||0,cap:Number(s)||1/0,counter:0,currentAdd:0})}resetPity(e){if(o(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#n.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){o(this.#e),this.#n.clear()}hasExclusion(e){if(o(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#a.has(e)}excludeItem(e){if(o(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#a.add(e)}includeItem(e){if(o(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#a.delete(e)}_ensureGroup(e){if(o(this.#e),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#u.get(e);return t||(t=new Set,this.#u.set(e,t)),t}hasInGroup(e,t){if(o(this.#e),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#u.get(t);return!!r&&r.has(e)}addToGroup(e,t){if(o(this.#e),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#h.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(o(this.#e),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#u.get(t);r&&r.delete(e);const i=this.#h.get(e);i&&i.groups.delete(t)}clearFreqs(){o(this.#e),this.#p.clear()}resetFreq(e){if(o(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#p.delete(e)}computeEffectiveWeights(e={}){if(o(this.#e),"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.#h)t.set(e,r.baseWeight);for(const r of this.#i){const i=r(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#s){const i=r.fn(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const r of this.#o){const i=r(t,e);if(i instanceof Map)for(const[e,r]of i)t.set(e,Math.max(0,(t.get(e)||0)+r))}for(const[e,r]of this.#n)if(t.has(e)&&r.counter>r.threshold){r.currentAdd=Math.min(r.cap,r.currentAdd+r.increment);const i=t.get(e);i&&t.set(e,i+r.currentAdd)}for(const e of this.#a)t.delete(e);for(const[e,r]of Array.from(t.entries()))r>0||t.delete(e);return t}_weightsToDistribution(e){if(!(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.#t){const e=Math.max(...t.map(e=>e.weight)),r=t.map(t=>Math.exp(t.weight-e)),i=r.reduce((e,t)=>e+t,0);let s=0;return t.map((e,t)=>{const o=r[t]/i;return s+=o,{id:e.id,weight:e.weight,p:o,cumulative:s}})}{const e=t.reduce((e,t)=>e+t.weight,0);let r=0;return t.map(t=>{const i=t.weight/e;return r+=i,{id:t.id,weight:t.weight,p:i,cumulative:r}})}}drawOne(e={}){if(o(this.#e),"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.#s]},r=this.computeEffectiveWeights(t),i=this._weightsToDistribution(r);if(!i.length)return null;const s=this.#f(),n=i.find(e=>s<=e.cumulative)??i[i.length-1];for(const[e,t]of this.#n)e===n.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const a=this.#h.get(n.id);if(!a)return null;const u={id:a.id,label:a.label,meta:{...a.meta},prob:n.p};return this.emit("draw",u),u&&this.#p.set(u.id,(this.#p.get(u.id)||0)+1),u}_consumeTemporaryModifiers(){for(let e=this.#s.length-1;e>=0;--e){const t=this.#s[e];t.uses-=1,t.uses<=0&&this.#s.splice(e,1)}}drawMany(e=1,t={}){if(o(this.#e),!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,i=t.ensureUnique??!1,s=[],n=t.previousDraws??[];if(!r&&i){const r=new Set;for(let i=0;i<e;++i){const e=new Set(this.#a);for(const e of r)this.#a.add(e);const i=this.drawOne({previousDraws:n,metadata:t.metadata});if(this.#a=e,!i)break;s.push(i),r.add(i.id),n.push(i)}return s}for(let i=0;i<e;++i){const e=this.drawOne({previousDraws:n,metadata:t.metadata});if(!e)break;s.push(e),n.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of s)this.includeItem(e.id);return s}exportToJson(){return o(this.#e),{items:Array.from(this.#h.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.#n.entries()),exclusions:Array.from(this.#a),normalization:this.#t,seed:this.#r}}loadFromJson(e){if(o(this.#e),"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.#h.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(){o(this.#e);const e=new n;return e.#t=this.#t,e.#r=this.#r,e.#i=[...this.#i],e.#s=this.#s.map(e=>({fn:e.fn,uses:e.uses})),e.#o=[...this.#o],e.#n=new Map([...this.#n.entries()].map(([e,t])=>[e,{...t}])),e.#a=new Set(this.#a),e.#u=new Map([...this.#u.entries()].map(([e,t])=>[e,new Set(t)])),e.#f=this.#f,e.#h=new Map([...this.#h.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#p=new Map(this.#p),e}_makeSeededRng(e){if("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.#e||(this.#n.clear(),this.#a.clear(),this.#u.clear(),this.#h.clear(),this.#p.clear(),this.#i=[],this.#s=[],this.#o=[],this.#r=null,this.#e=!0)}}const a=n;window.TinyAdvancedRaffle=i.TinyAdvancedRaffle})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var i=0;i<r.length;){var o=r[i++],s=r[i++];e.o(t,o)?0===s&&i++:0===s?Object.defineProperty(t,o,{enumerable:!0,value:r[i++]}):Object.defineProperty(t,o,{enumerable:!0,get:s})}else for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyAfterScrollWatcher:()=>
|
|
1
|
+
(()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var i=0;i<r.length;){var o=r[i++],s=r[i++];e.o(t,o)?0===s&&i++:0===s?Object.defineProperty(t,o,{enumerable:!0,value:r[i++]}):Object.defineProperty(t,o,{enumerable:!0,get:s})}else for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyAfterScrollWatcher:()=>i});const r=e=>{if(e)throw new Error("This TinyAfterScrollWatcher instance has been destroyed and can no longer be used.")};const i=class{#e;get scrollTarget(){return r(this.#t),this.#e}#r=null;#i=[];get afterScrollQueueSize(){return r(this.#t),this.#i.length}#o=100;#s=new Set;#n=new Set;#t=!1;get destroyed(){return this.#t}constructor(e,t=100){if(!(e instanceof Element||e instanceof Window))throw new TypeError("scrollTarget must be an Element or the Window object.");this.#e=e,this._checkTimer=this._checkTimer.bind(this),this.#e.addEventListener("scroll",this._checkTimer),this.#o=t}_checkTimer=()=>{this.#r&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.#l()},this.#o)};get inactivityTime(){return r(this.#t),this.#o}set inactivityTime(e){if(r(this.#t),"number"!=typeof e||e<=0||!Number.isFinite(e))throw new Error("inactivityTime must be a positive number in milliseconds.");this.#o=e}#l(){if(!this.#t){for(const e of this.#n)"function"==typeof e&&e();for(;this.#i.length;){const e=this.#i.pop();"function"==typeof e&&e()}}}doAfterScroll(e){if(r(this.#t),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.lastScrollTime=Date.now(),this.#i.push(e)}onStop(e){if(r(this.#t),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#n.add(e)}offStop(e){if(r(this.#t),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#n.delete(e)}onScroll(e){if(r(this.#t),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#e.addEventListener("scroll",e),this.#s.add(e)}offScroll(e){if(r(this.#t),"function"!=typeof e)throw new TypeError("Argument must be a function.");this.#s.has(e)&&(this.#e.removeEventListener("scroll",e),this.#s.delete(e))}destroy(){if(!this.#t){this.#e.removeEventListener("scroll",this._checkTimer);for(const e of this.#s)this.#e.removeEventListener("scroll",e);this.#s.clear(),this.#n.clear(),this.#t=!0}}};window.TinyAfterScrollWatcher=t.TinyAfterScrollWatcher})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const e={d:(t,n)=>{if(Array.isArray(n))for(var o=0;o<n.length;){var i=n[o++],r=n[o++];e.o(t,i)?0===r&&o++:0===r?Object.defineProperty(t,i,{enumerable:!0,value:n[o++]}):Object.defineProperty(t,i,{enumerable:!0,get:r})}else for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyAnalogClock:()=>n});const n=class{#e;#t;#n;#o;#i=null;_getDate(){const e=new Date,t=e.getSeconds(),n=e.getMinutes(),o=e.getHours();return{now:e,s:t,m:n,h:o}}constructor(e={}){this.#o={bgColor:"#f0f0f0",borderColor:"#333",borderWidth:8,markColor:"#333",hourHandColor:"#000",minuteHandColor:"#444",secondHandColor:"#d81c1c",textColor:"#000",skinUrl:null,showNumbers:!0,showSeconds:!0,size:800,sizeAdjust:.04,padding:45,angleDistance:.95,pwH:.008,phH:.08,pwM:.005,phM:.03,...e},this.#e=document.createElement("div"),this.#e.className="analog-clock-container",this.#e.style.position="relative",this.#e.style.borderRadius="50%",this.#e.style.overflow="hidden",this.#e.style.boxSizing="border-box",this.#n=document.createElement("div"),this.#n.style.position="absolute",this.#n.style.inset="0",this.#n.style.backgroundSize="cover",this.#n.style.backgroundPosition="center",this.#n.style.zIndex="0",this.#t=document.createElement("div"),this.#t.style.position="absolute",this.#t.style.inset="0",this.#t.style.zIndex="1",this.#t.style.pointerEvents="none";const t=document.createElement("div");t.style.position="absolute",t.style.inset="0",t.style.zIndex="2",t.style.pointerEvents="none",t.innerHTML='\n <div class="hand hour-hand"></div>\n <div class="hand minute-hand"></div>\n <div class="hand second-hand"></div>\n <div class="center-pin"></div>\n ',this.#e.appendChild(this.#n),this.#e.appendChild(this.#t),this.#e.appendChild(t);const n=document.createElement("style");n.textContent="\n .analog-clock-container .hand {\n position: absolute;\n bottom: 50%;\n left: 50%;\n transform-origin: bottom center;\n border-radius: 4px;\n transform: translateX(-50%) rotate(0deg);\n z-index: 5;\n }\n .analog-clock-container .center-pin {\n position: absolute;\n top: 50%; left: 50%;\n width: 12px; height: 12px;\n background: #333;\n border-radius: 50%;\n transform: translate(-50%, -50%);\n z-index: 10;\n }\n .analog-clock-container .clock-mark {\n position: absolute;\n top: 50%; left: 50%;\n background: currentColor;\n transform-origin: center center;\n }\n .analog-clock-container .clock-number {\n position: absolute;\n top: 50%; left: 50%;\n transform: translate(-50%, -50%);\n font-family: sans-serif;\n font-weight: bold;\n text-align: center;\n line-height: 1;\n }\n ",this.#e.appendChild(n),this._applyConfig(),this._renderFace(),this._startTicker()}_applyConfig(){const e=this.#e.style,t=this.#o;e.width=`${t.size}px`,e.height=`${t.size}px`,e.border=`${t.borderWidth}px solid ${t.borderColor}`,e.backgroundColor=t.bgColor,t.skinUrl?(this.#n.style.backgroundImage=`url(${t.skinUrl})`,this.#n.style.display="block"):this.#n.style.display="none";const n=e=>{const t=this.#e.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`TinyAnalogClock: Element ${e} not found.`);return t},o=n(".hour-hand");o.style.backgroundColor=t.hourHandColor,o.style.width=.025*t.size+"px",o.style.height=.25*t.size+"px",o.style.marginLeft=.025*t.size/-2+"px",o.style.bottom="50%",o.style.left="50%",o.style.transformOrigin="bottom center";const i=n(".minute-hand");i.style.backgroundColor=t.minuteHandColor,i.style.width=.015*t.size+"px",i.style.height=.35*t.size+"px",i.style.marginLeft=.015*t.size/-2+"px";const r=n(".second-hand");t.showSeconds?(r.style.display="block",r.style.backgroundColor=t.secondHandColor,r.style.width=.005*t.size+"px",r.style.height=.4*t.size+"px",r.style.marginLeft=.005*t.size/-2+"px"):r.style.display="none",n(".center-pin").style.background=t.borderColor}_renderFace(){this.#t.innerHTML="";const e=this.#o.size/2-this.#o.borderWidth;for(let t=0;t<60;t++){const n=t%5==0,o=document.createElement("div");o.className="clock-mark";const i=n?this.#o.size*this.#o.pwH:this.#o.size*this.#o.pwM,r=n?this.#o.size*this.#o.phH:this.#o.size*this.#o.phM,s=this.#o.markColor;o.style.width=`${i}px`,o.style.height=`${r}px`,o.style.color=s;const a=e-this.#o.padding-r/2;o.style.transform=`translate(-50%, -50%) rotate(${6*t}deg) translate(0, -${a}px)`,this.#t.appendChild(o)}if(this.#o.showNumbers)for(let t=1;t<=12;t++){const n=30*t*(Math.PI/180),o=e*this.#o.angleDistance,i=e+Math.sin(n)*o,r=e-Math.cos(n)*o,s=document.createElement("div");s.className="clock-number",s.innerText=t.toString(),s.style.left=`${i}px`,s.style.top=`${r}px`,s.style.color=this.#o.textColor,s.style.fontSize=this.#o.size*this.#o.sizeAdjust+"px",this.#t.appendChild(s)}}_startTicker(){if(this.#i)return;const e=()=>{const{s:t,m:n,h:o}=this._getDate(),i=6*t,r=6*n+.1*t,s=o%12*30+.5*n,a=e=>{const t=this.#e.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`${e} not found.`);return t};this.#e.querySelector(".second-hand")&&(a(".second-hand").style.transform=`rotate(${i}deg)`),a(".minute-hand").style.transform=`rotate(${r}deg)`,a(".hour-hand").style.transform=`rotate(${s}deg)`,this.#i=requestAnimationFrame(e)};e()}get element(){return this.#e}set size(e){if("number"!=typeof e||e<=0||isNaN(e))throw new Error(`TinyAnalogClock: 'size' must be a positive number. Received: ${e}`);this.#o.size=e,this._applyConfig(),this._renderFace()}get size(){return this.#o.size}set skinUrl(e){if(null!==e&&"string"!=typeof e)throw new Error("TinyAnalogClock: 'skin' must be a URL string or null. Received type: "+typeof e);this.#o.skinUrl=e,this._applyConfig()}get skinUrl(){return this.#o.skinUrl}set borderColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'borderColor' must be a non-empty string. Received: ${e}`);this.#o.borderColor=e,this._applyConfig(),this._renderFace()}get borderColor(){return this.#o.borderColor}set markColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'markColor' must be a non-empty string. Received: ${e}`);this.#o.markColor=e,this._applyConfig(),this._renderFace()}get markColor(){return this.#o.markColor}set textColor(e){if("string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'textColor' must be a non-empty string. Received: ${e}`);this.#o.textColor=e,this._applyConfig(),this._renderFace()}get textColor(){return this.#o.textColor}set showNumbers(e){if("boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showNumbers' must be a boolean. Received type: "+typeof e);this.#o.showNumbers=e,this._renderFace()}get showNumbers(){return this.#o.showNumbers}set bgColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'bgColor' must be a non-empty string.");this.#o.bgColor=e,this._applyConfig()}get bgColor(){return this.#o.bgColor}set borderWidth(e){if("number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'borderWidth' must be a non-negative number.");this.#o.borderWidth=e,this._applyConfig(),this._renderFace()}get borderWidth(){return this.#o.borderWidth}set hourHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'hourHandColor' must be a non-empty string.");this.#o.hourHandColor=e,this._applyConfig()}get hourHandColor(){return this.#o.hourHandColor}set minuteHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'minuteHandColor' must be a non-empty string.");this.#o.minuteHandColor=e,this._applyConfig()}get minuteHandColor(){return this.#o.minuteHandColor}set secondHandColor(e){if("string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'secondHandColor' must be a non-empty string.");this.#o.secondHandColor=e,this._applyConfig()}get secondHandColor(){return this.#o.secondHandColor}set showSeconds(e){if("boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showSeconds' must be a boolean.");this.#o.showSeconds=e,this._applyConfig()}get showSeconds(){return this.#o.showSeconds}set sizeAdjust(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'sizeAdjust' must be a positive number.");this.#o.sizeAdjust=e,this._renderFace()}get sizeAdjust(){return this.#o.sizeAdjust}set padding(e){if("number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'padding' must be a non-negative number.");this.#o.padding=e,this._renderFace()}get padding(){return this.#o.padding}set angleDistance(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'angleDistance' must be a positive number.");this.#o.angleDistance=e,this._renderFace()}get angleDistance(){return this.#o.angleDistance}set pwH(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwH' must be a positive number.");this.#o.pwH=e,this._renderFace()}get pwH(){return this.#o.pwH}set phH(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phH' must be a positive number.");this.#o.phH=e,this._renderFace()}get phH(){return this.#o.phH}set pwM(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwM' must be a positive number.");this.#o.pwM=e,this._renderFace()}get pwM(){return this.#o.pwM}set phM(e){if("number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phM' must be a positive number.");this.#o.phM=e,this._renderFace()}get phM(){return this.#o.phM}destroy(){this.#i&&(cancelAnimationFrame(this.#i),this.#i=null),this.#e.remove()}};window.TinyAnalogClock=t.TinyAnalogClock})();
|
|
1
|
+
(()=>{"use strict";const e={d:(t,o)=>{if(Array.isArray(o))for(var n=0;n<o.length;){var i=o[n++],r=o[n++];e.o(t,i)?0===r&&n++:0===r?Object.defineProperty(t,i,{enumerable:!0,value:o[n++]}):Object.defineProperty(t,i,{enumerable:!0,get:r})}else for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyAnalogClock:()=>n});const o=e=>{if(e)throw new Error("This TinyAnalogClock instance has been destroyed and can no longer be used.")};const n=class{#e;#t;#o;#n;#i=null;#r=!1;get destroyed(){return this.#r}_getDate(){const e=new Date,t=e.getSeconds(),o=e.getMinutes(),n=e.getHours();return{now:e,s:t,m:o,h:n}}constructor(e={}){this.#n={bgColor:"#f0f0f0",borderColor:"#333",borderWidth:8,markColor:"#333",hourHandColor:"#000",minuteHandColor:"#444",secondHandColor:"#d81c1c",textColor:"#000",skinUrl:null,showNumbers:!0,showSeconds:!0,size:800,sizeAdjust:.04,padding:45,angleDistance:.95,pwH:.008,phH:.08,pwM:.005,phM:.03,...e},this.#e=document.createElement("div"),this.#e.className="analog-clock-container",this.#e.style.position="relative",this.#e.style.borderRadius="50%",this.#e.style.overflow="hidden",this.#e.style.boxSizing="border-box",this.#o=document.createElement("div"),this.#o.style.position="absolute",this.#o.style.inset="0",this.#o.style.backgroundSize="cover",this.#o.style.backgroundPosition="center",this.#o.style.zIndex="0",this.#t=document.createElement("div"),this.#t.style.position="absolute",this.#t.style.inset="0",this.#t.style.zIndex="1",this.#t.style.pointerEvents="none";const t=document.createElement("div");t.style.position="absolute",t.style.inset="0",t.style.zIndex="2",t.style.pointerEvents="none",t.innerHTML='\n <div class="hand hour-hand"></div>\n <div class="hand minute-hand"></div>\n <div class="hand second-hand"></div>\n <div class="center-pin"></div>\n ',this.#e.appendChild(this.#o),this.#e.appendChild(this.#t),this.#e.appendChild(t);const o=document.createElement("style");o.textContent="\n .analog-clock-container .hand {\n position: absolute;\n bottom: 50%;\n left: 50%;\n transform-origin: bottom center;\n border-radius: 4px;\n transform: translateX(-50%) rotate(0deg);\n z-index: 5;\n }\n .analog-clock-container .center-pin {\n position: absolute;\n top: 50%; left: 50%;\n width: 12px; height: 12px;\n background: #333;\n border-radius: 50%;\n transform: translate(-50%, -50%);\n z-index: 10;\n }\n .analog-clock-container .clock-mark {\n position: absolute;\n top: 50%; left: 50%;\n background: currentColor;\n transform-origin: center center;\n }\n .analog-clock-container .clock-number {\n position: absolute;\n top: 50%; left: 50%;\n transform: translate(-50%, -50%);\n font-family: sans-serif;\n font-weight: bold;\n text-align: center;\n line-height: 1;\n }\n ",this.#e.appendChild(o),this._applyConfig(),this._renderFace(),this._startTicker()}_applyConfig(){const e=this.#e.style,t=this.#n;e.width=`${t.size}px`,e.height=`${t.size}px`,e.border=`${t.borderWidth}px solid ${t.borderColor}`,e.backgroundColor=t.bgColor,t.skinUrl?(this.#o.style.backgroundImage=`url(${t.skinUrl})`,this.#o.style.display="block"):this.#o.style.display="none";const o=e=>{const t=this.#e.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`TinyAnalogClock: Element ${e} not found.`);return t},n=o(".hour-hand");n.style.backgroundColor=t.hourHandColor,n.style.width=.025*t.size+"px",n.style.height=.25*t.size+"px",n.style.marginLeft=.025*t.size/-2+"px",n.style.bottom="50%",n.style.left="50%",n.style.transformOrigin="bottom center";const i=o(".minute-hand");i.style.backgroundColor=t.minuteHandColor,i.style.width=.015*t.size+"px",i.style.height=.35*t.size+"px",i.style.marginLeft=.015*t.size/-2+"px";const r=o(".second-hand");t.showSeconds?(r.style.display="block",r.style.backgroundColor=t.secondHandColor,r.style.width=.005*t.size+"px",r.style.height=.4*t.size+"px",r.style.marginLeft=.005*t.size/-2+"px"):r.style.display="none",o(".center-pin").style.background=t.borderColor}_renderFace(){this.#t.innerHTML="";const e=this.#n.size/2-this.#n.borderWidth;for(let t=0;t<60;t++){const o=t%5==0,n=document.createElement("div");n.className="clock-mark";const i=o?this.#n.size*this.#n.pwH:this.#n.size*this.#n.pwM,r=o?this.#n.size*this.#n.phH:this.#n.size*this.#n.phM,s=this.#n.markColor;n.style.width=`${i}px`,n.style.height=`${r}px`,n.style.color=s;const a=e-this.#n.padding-r/2;n.style.transform=`translate(-50%, -50%) rotate(${6*t}deg) translate(0, -${a}px)`,this.#t.appendChild(n)}if(this.#n.showNumbers)for(let t=1;t<=12;t++){const o=30*t*(Math.PI/180),n=e*this.#n.angleDistance,i=e+Math.sin(o)*n,r=e-Math.cos(o)*n,s=document.createElement("div");s.className="clock-number",s.innerText=t.toString(),s.style.left=`${i}px`,s.style.top=`${r}px`,s.style.color=this.#n.textColor,s.style.fontSize=this.#n.size*this.#n.sizeAdjust+"px",this.#t.appendChild(s)}}_startTicker(){if(this.#i)return;const e=()=>{const{s:t,m:o,h:n}=this._getDate(),i=6*t,r=6*o+.1*t,s=n%12*30+.5*o,a=e=>{const t=this.#e.querySelector(e);if(!(t instanceof HTMLDivElement))throw new Error(`${e} not found.`);return t};this.#e.querySelector(".second-hand")&&(a(".second-hand").style.transform=`rotate(${i}deg)`),a(".minute-hand").style.transform=`rotate(${r}deg)`,a(".hour-hand").style.transform=`rotate(${s}deg)`,this.#i=requestAnimationFrame(e)};e()}get element(){return o(this.#r),this.#e}set size(e){if(o(this.#r),"number"!=typeof e||e<=0||isNaN(e))throw new Error(`TinyAnalogClock: 'size' must be a positive number. Received: ${e}`);this.#n.size=e,this._applyConfig(),this._renderFace()}get size(){return o(this.#r),this.#n.size}set skinUrl(e){if(o(this.#r),null!==e&&"string"!=typeof e)throw new Error("TinyAnalogClock: 'skin' must be a URL string or null. Received type: "+typeof e);this.#n.skinUrl=e,this._applyConfig()}get skinUrl(){return o(this.#r),this.#n.skinUrl}set borderColor(e){if(o(this.#r),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'borderColor' must be a non-empty string. Received: ${e}`);this.#n.borderColor=e,this._applyConfig(),this._renderFace()}get borderColor(){return o(this.#r),this.#n.borderColor}set markColor(e){if(o(this.#r),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'markColor' must be a non-empty string. Received: ${e}`);this.#n.markColor=e,this._applyConfig(),this._renderFace()}get markColor(){return o(this.#r),this.#n.markColor}set textColor(e){if(o(this.#r),"string"!=typeof e||""===e.trim())throw new Error(`TinyAnalogClock: 'textColor' must be a non-empty string. Received: ${e}`);this.#n.textColor=e,this._applyConfig(),this._renderFace()}get textColor(){return o(this.#r),this.#n.textColor}set showNumbers(e){if(o(this.#r),"boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showNumbers' must be a boolean. Received type: "+typeof e);this.#n.showNumbers=e,this._renderFace()}get showNumbers(){return o(this.#r),this.#n.showNumbers}set bgColor(e){if(o(this.#r),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'bgColor' must be a non-empty string.");this.#n.bgColor=e,this._applyConfig()}get bgColor(){return o(this.#r),this.#n.bgColor}set borderWidth(e){if(o(this.#r),"number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'borderWidth' must be a non-negative number.");this.#n.borderWidth=e,this._applyConfig(),this._renderFace()}get borderWidth(){return o(this.#r),this.#n.borderWidth}set hourHandColor(e){if(o(this.#r),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'hourHandColor' must be a non-empty string.");this.#n.hourHandColor=e,this._applyConfig()}get hourHandColor(){return o(this.#r),this.#n.hourHandColor}set minuteHandColor(e){if(o(this.#r),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'minuteHandColor' must be a non-empty string.");this.#n.minuteHandColor=e,this._applyConfig()}get minuteHandColor(){return o(this.#r),this.#n.minuteHandColor}set secondHandColor(e){if(o(this.#r),"string"!=typeof e||!e)throw new Error("TinyAnalogClock: 'secondHandColor' must be a non-empty string.");this.#n.secondHandColor=e,this._applyConfig()}get secondHandColor(){return o(this.#r),this.#n.secondHandColor}set showSeconds(e){if(o(this.#r),"boolean"!=typeof e)throw new Error("TinyAnalogClock: 'showSeconds' must be a boolean.");this.#n.showSeconds=e,this._applyConfig()}get showSeconds(){return o(this.#r),this.#n.showSeconds}set sizeAdjust(e){if(o(this.#r),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'sizeAdjust' must be a positive number.");this.#n.sizeAdjust=e,this._renderFace()}get sizeAdjust(){return o(this.#r),this.#n.sizeAdjust}set padding(e){if(o(this.#r),"number"!=typeof e||e<0)throw new Error("TinyAnalogClock: 'padding' must be a non-negative number.");this.#n.padding=e,this._renderFace()}get padding(){return o(this.#r),this.#n.padding}set angleDistance(e){if(o(this.#r),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'angleDistance' must be a positive number.");this.#n.angleDistance=e,this._renderFace()}get angleDistance(){return o(this.#r),this.#n.angleDistance}set pwH(e){if(o(this.#r),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwH' must be a positive number.");this.#n.pwH=e,this._renderFace()}get pwH(){return o(this.#r),this.#n.pwH}set phH(e){if(o(this.#r),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phH' must be a positive number.");this.#n.phH=e,this._renderFace()}get phH(){return o(this.#r),this.#n.phH}set pwM(e){if(o(this.#r),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'pwM' must be a positive number.");this.#n.pwM=e,this._renderFace()}get pwM(){return o(this.#r),this.#n.pwM}set phM(e){if(o(this.#r),"number"!=typeof e||e<=0)throw new Error("TinyAnalogClock: 'phM' must be a positive number.");this.#n.phM=e,this._renderFace()}get phM(){return o(this.#r),this.#n.phM}destroy(){this.#r||(this.#i&&(cancelAnimationFrame(this.#i),this.#i=null),this.#e.remove(),this.#r=!0)}};window.TinyAnalogClock=t.TinyAnalogClock})();
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
/*! For license information please see TinyBasicsEs.min.js.LICENSE.txt */
|
|
2
|
-
(()=>{var t={526(t,e){"use strict";e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,i=s(t),a=i[0],u=i[1],f=new o(function(t,e,r){return 3*(e+r)/4-r}(0,a,u)),l=0,c=u>0?a-4:a;for(r=0;r<c;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===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,f[l++]=255&e),1===u&&(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,o=n%3,i=[],a=16383,s=0,u=n-o;s<u;s+=a)i.push(f(t,s,s+a>u?u:s+a));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+/",a=0;a<64;++a)r[a]=i[a],n[i.charCodeAt(a)]=a;function s(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 u(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function f(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(255&t[i+2]),o.push(u(n));return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},251(t,e){e.read=function(t,e,r,n,o){var i,a,s=8*o-n-1,u=(1<<s)-1,f=u>>1,l=-7,c=r?o-1:0,h=r?-1:1,p=t[e+c];for(c+=h,i=p&(1<<-l)-1,p>>=-l,l+=s;l>0;i=256*i+t[e+c],c+=h,l-=8);for(a=i&(1<<-l)-1,i>>=-l,l+=n;l>0;a=256*a+t[e+c],c+=h,l-=8);if(0===i)i=1-f;else{if(i===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),i-=f}return(p?-1:1)*a*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var a,s,u,f=8*i-o-1,l=(1<<f)-1,c=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+c>=1?h/u:h*Math.pow(2,1-c))*u>=2&&(a++,u/=2),a+c>=l?(s=0,a=l):a+c>=1?(s=(e*u-1)*Math.pow(2,o),a+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,o),a=0));o>=8;t[r+p]=255&s,p+=d,s/=256,o-=8);for(a=a<<o|s,f+=o;f>0;t[r+p]=255&a,p+=d,a/=256,f-=8);t[r+p-d]|=128*y}},271(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=u,e.IS=50;var a=2147483647;function s(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(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 c(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"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|y(t,e),n=s(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(Y(t,Uint8Array)){var e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(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(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(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 u.from(n,e,r);var o=function(t){if(u.isBuffer(t)){var e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||z(t.length)?s(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.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 c(t){return l(t),s(t<0?0:0|d(t))}function h(t){for(var e=t.length<0?0:0|d(t.length),r=s(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,u.prototype),n}function d(t){if(t>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(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 D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(t).length;default:if(o)return n?-1:D(t).length;e=(""+e).toLowerCase(),o=!0}}function g(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 U(this,e,r);case"utf8":case"utf-8":return N(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return S(this,e,r);case"base64":return M(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(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),z(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=u.from(e,n)),u.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,a=1,s=t.length,u=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;a=2,s/=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(o){var l=-1;for(i=r;i<s;i++)if(f(t,i)===f(e,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===u)return l*a}else-1!==l&&(i-=i-l),l=-1}else for(r+u>s&&(r=s-u),i=r;i>=0;i--){for(var c=!0,h=0;h<u;h++)if(f(t,i+h)!==f(e,h)){c=!1;break}if(c)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 a=0;a<n;++a){var s=parseInt(e.substr(2*a,2),16);if(z(s))return a;t[r+a]=s}return a}function E(t,e,r,n){return $(D(e,t.length-r),t,r,n)}function T(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 $(j(e),t,r,n)}function B(t,e,r,n){return $(function(t,e){for(var r,n,o,i=[],a=0;a<t.length&&!((e-=2)<0);++a)n=(r=t.charCodeAt(a))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function M(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function N(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,a,s,u,f=t[o],l=null,c=f>239?4:f>223?3:f>191?2:1;if(o+c<=r)switch(c){case 1:f<128&&(l=f);break;case 2:128==(192&(i=t[o+1]))&&(u=(31&f)<<6|63&i)>127&&(l=u);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(u=(15&f)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=t[o+1],a=t[o+2],s=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&i)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(l=u)}null===l?(l=65533,c=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),o+=c}return function(t){var e=t.length;if(e<=L)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=L));return r}(n)}u.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}}(),u.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(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return f(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return c(t)},u.allocUnsafeSlow=function(t){return c(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(Y(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),Y(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.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},u.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}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=u.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var i=t[r];if(Y(i,Uint8Array))o+i.length>n.length?u.from(i).copy(n,o):Uint8Array.prototype.set.call(n,i,o);else{if(!u.isBuffer(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o)}o+=i.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.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},u.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},u.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},u.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?N(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.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&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,o){if(Y(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.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),a=(r>>>=0)-(e>>>=0),s=Math.min(i,a),f=this.slice(n,o),l=t.slice(e,r),c=0;c<s;++c)if(f[c]!==l[c]){i=f[c],a=l[c];break}return i<a?-1:a<i?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},u.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 T(this,t,e,r);case"base64":return A(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}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var L=4096;function I(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 S(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 U(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+=H[t[i]];return o}function C(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 O(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,o,i){if(!u.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 x(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 R(t,e,r,n,i){return e=+e,r>>>=0,i||x(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,i){return e=+e,r>>>=0,i||x(t,0,r,8),o.write(t,e,r,n,52,8),r+8}u.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,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||O(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||O(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},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||O(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},u.prototype.readInt8=function(t,e){return t>>>=0,e||O(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||O(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||O(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readFloatLE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||O(t,4,this.length),o.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||O(t,8,this.length),o.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.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 o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUintBE=u.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 o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUint8=u.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},u.prototype.writeUint16LE=u.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},u.prototype.writeUint16BE=u.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},u.prototype.writeUint32LE=u.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},u.prototype.writeUint32BE=u.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},u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);k(this,t,e,r,o-1,-o)}var i=0,a=1,s=0;for(this[e]=255&t;++i<r&&(a*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/a|0)-s&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);k(this,t,e,r,o-1,-o)}var i=r-1,a=1,s=0;for(this[e+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/a|0)-s&255;return e+r},u.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},u.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},u.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},u.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},u.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},u.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.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},u.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&&!u.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 a=u.isBuffer(t)?t:u.from(t,n),s=a.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=a[i%s]}return this};var P=/[^+/0-9A-Za-z-_]/g;function D(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],a=0;a<n;++a){if((r=t.charCodeAt(a))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(a+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 j(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(P,"")).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 Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function z(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,o=0;o<16;++o)e[n+o]=t[r]+t[o];return e}()}};const e={};function r(n){const o=e[n];if(void 0!==o)return o.exports;const i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.d=(t,e)=>{if(Array.isArray(e))for(var n=0;n<e.length;){var o=e[n++],i=e[n++];r.o(t,o)?0===i&&n++:0===i?Object.defineProperty(t,o,{enumerable:!0,value:e[n++]}):Object.defineProperty(t,o,{enumerable:!0,get:i})}else for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let n={};(()=>{"use strict";function t(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 e(t,e){const r=t.filter(t=>!e.includes(t));return{added:e.filter(e=>!t.includes(e)),removed:r}}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=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 a(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,a=n>=3,s=n>=2,u=n>=1,f=n>=0,l={years:o?0:NaN,months:i?0:NaN,days:a?0:NaN,hours:s?0:NaN,minutes:u?0:NaN,seconds:f?0:NaN,total:NaN};let c=t;if(o||i||a){const t=new Date(1980,0,1),e=new Date(t.getTime()+1e3*c),r=new Date(t);if(o)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=e.getTime();)r.setFullYear(r.getFullYear()+1),l.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=e.getTime();)r.setMonth(r.getMonth()+1),l.months++;if(a)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=e.getTime();)r.setDate(r.getDate()+1),l.days++;c=Math.floor((e.getTime()-r.getTime())/1e3)}s&&(l.hours=Math.floor(c/3600),c%=3600),u&&(l.minutes=Math.floor(c/60),c%=60),f&&(l.seconds=c),i&&(l.years,l.months,l.days),o&&(l.years,l.months,l.days),l.total=+t.toFixed(2).replace(/\.00$/,"");const h=t=>{const e="string"==typeof t?parseInt(t):t;return Number.isNaN(e)?"NaN":String(e).padStart(2,"0")},p=[s?h(l.hours):null,u?h(l.minutes):null,f?h(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,h(l.hours)).replace(/\{minutes\}/g,h(l.minutes)).replace(/\{seconds\}/g,h(l.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(l.total)).trim()}function s(t){return a(t,"hours","{hours}:{minutes}:{seconds}")}function u(t){return a(t,"days","{days}d {hours}:{minutes}:{seconds}")}function f(t,e="milliseconds"){t=Math.max(0,Math.floor(t));const r=["milliseconds","seconds","minutes","hours","days","months","years"].indexOf(e),n=r>=6,o=r>=5,i=r>=4,a=r>=3,s=r>=2,u=r>=1,f=r>=0,l={years:n?0:NaN,months:o?0:NaN,days:i?0:NaN,hours:a?0:NaN,minutes:s?0:NaN,seconds:u?0:NaN,milliseconds:f?0:NaN,total:NaN};let c=t;if(n||o||i){const t=new Date(1980,0,1),e=new Date(t.getTime()+c),r=new Date(t);if(n)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(i)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=e.getTime();)r.setDate(r.getDate()+1),l.days++;c=e.getTime()-r.getTime()}return a&&(l.hours=Math.floor(c/36e5),c%=36e5),s&&(l.minutes=Math.floor(c/6e4),c%=6e4),u&&(l.seconds=Math.floor(c/1e3),c%=1e3),f&&(l.milliseconds=c),o&&(l.years,l.months,l.days),n&&(l.years,l.months,l.days),l.total=+t,l}function l(t){return Array.isArray(t)?t.length:c(t)?Object.keys(t).length:0}function c(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"===Object.prototype.toString.call(t)}function h(t,e){return new Promise((r,n)=>{const o=new FileReader;o.onload=()=>{try{r(o.result)}catch(t){n(t)}},o.onerror=()=>{n(o.error)},o[e](t)})}function p(t,e=!1){return new Promise((r,n)=>{"string"!=typeof e&&"boolean"!=typeof e&&n(new TypeError("The isDataUrl parameter must be a boolean or a string.")),h(t,"readAsDataURL").then(t=>{if("string"!=typeof t)throw new TypeError("Expected file content to be a string.");const n=t.match(/^data:(.+);base64,(.*)$/);if(!n||!n[2])throw new Error("Invalid data URL format or missing Base64 content.");const[,o,i]=n;if(!/^[\w/+]+=*$/.test(i))throw new Error("Base64 content is malformed.");if("boolean"==typeof e)return r(e?t:i);if(!/^[\w-]+\/[\w.+-]+$/.test(e))throw new Error(`Invalid MIME type string: ${e}`);return r(`data:${e};base64,${i}`)}).catch(n)})}function d(t){return new Promise((e,r)=>h(t,"readAsText").then(t=>{if("string"!=typeof t)throw new TypeError("Expected file content to be a string.");const r=t.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.");e(n)}).catch(r))}function y(t,e,r=2){const n=JSON.stringify(e,null,r),o=new Blob([n],{type:"application/json"}),i=URL.createObjectURL(o),a=document.createElement("a");a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function g(t,e){if("function"!=typeof e)throw new TypeError('The "onProgress" argument must be a function.');if(!t.body)return t;const r=t.headers.get("content-length"),n=r?parseInt(r,10):0;let o=0;const i=t.body.getReader(),a=new ReadableStream({async start(t){for(;;){const{done:r,value:a}=await i.read();if(r)break;o+=a.byteLength,e(o,n),t.enqueue(a)}t.close()}});return new Response(a,{headers:t.headers,status:t.status,statusText:t.statusText})}async function m(t,{method:e="GET",body:r,timeout:n=0,retries:o=0,headers:i={},signal:a=null,onProgress:s}={}){if("string"!=typeof t||!t.startsWith("../")&&!t.startsWith("./")&&!t.startsWith("/")&&!t.startsWith("https://")&&!t.startsWith("http://"))throw new Error("Invalid URL: must be a valid http or https address.");if("string"!=typeof e||!e.trim())throw new Error("Invalid method: must be a non-empty string.");if(!a){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 o||!Number.isFinite(o)||Number.isNaN(o)||o<0)throw new Error("Invalid retries: must be a positive number.")}const u=a?1:o+1;let f=null;for(let l=0;l<u;l++){const u=a?null:new AbortController,h=a||(u?.signal??null),p=!a&&n&&u?setTimeout(()=>u.abort(),n):null;try{const n=await fetch(t,{method:e.toUpperCase(),headers:{Accept:"application/json",...i},body:void 0!==r?c(r)?JSON.stringify(r):r:void 0,signal:h});if(p&&clearTimeout(p),!n.ok)throw new Error(`HTTP error: ${n.status} ${n.statusText}`);return s?g(n,s):n}catch(t){if(f=t,a)break;l<o&&await new Promise(t=>setTimeout(t,300*(l+1)))}}throw new Error(`Failed to fetch JSON from "${t}"${f?`: ${f.message}`:"."}`)}async function w(t,e){return new Promise((r,n)=>{m(t,e).then(async t=>{const e=t.headers.get("content-type")||"";if(!e.includes("application/json"))throw new Error(`Unexpected content-type: ${e}`);const n=await t.json();if(!Array.isArray(n)&&!c(n))throw new Error("Received invalid data instead of valid JSON.");return r(n)}).catch(n)})}async function b(t,e,r){return new Promise((n,o)=>{m(t,r).then(async t=>{const r=t.headers.get("content-type")||"";if(Array.isArray(e)&&e.length>0&&!e.some(t=>r.includes(t)))throw new Error(`Blocked MIME type: ${r}`);const o=await t.text();return n(o)}).catch(o)})}function v({element:t=document.body,hiddenClass:e="windowHidden",visibleClass:r="windowVisible",onVisible:n,onHidden:o}={}){if(!(t instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof e)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!==o&&"function"!=typeof o)throw new TypeError('"onHidden" must be a function if provided.');let i="",a="";const s=()=>{t.classList.remove(e),t.classList.remove(r)};let u=null;const f=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],l=["hidden","mozHidden","webkitHidden","msHidden"];for(let t=0;t<l.length;t++)if(l[t]in document){u=l[t];break}const c=function(f){s();const l=f?.type,c=u&&document[u];["focus","focusin","pageshow"].includes(l)?(t.classList.add(r),n?.({type:l,oldClass:a,oldType:i}),a=r):["blur","focusout","pagehide"].includes(l)||c?(t.classList.add(e),o?.({type:l,oldClass:a,oldType:i}),a=e):(t.classList.add(r),n?.({type:l,oldClass:a,oldType:i}),a=r),i=l};let h=()=>{};if(u){const t=f[l.indexOf(u)];document.addEventListener(t,c),window.addEventListener("focus",c),window.addEventListener("blur",c),h=()=>{document.removeEventListener(t,c),window.removeEventListener("focus",c),window.removeEventListener("blur",c),s()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=c,h=()=>{document.onfocusin=document.onfocusout=null,s()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=c,h=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,s()});const p=new Event(u&&document[u]?"blur":"focus");return c(p),h}r.r(n),r.d(n,{addAiMarkerShortcut:()=>X,areElsCollBottom:()=>K,areElsCollLeft:()=>Q,areElsCollPerfBottom:()=>rt,areElsCollPerfLeft:()=>nt,areElsCollPerfRight:()=>ot,areElsCollPerfTop:()=>et,areElsCollRight:()=>tt,areElsCollTop:()=>Z,areElsColliding:()=>it,areElsPerfColliding:()=>at,arraySortPositions:()=>o,asyncReplace:()=>W,breakdownDuration:()=>f,calculateMarketcap:()=>H,cloneObjTypeOrder:()=>N,compareMarketcap:()=>q,countObj:()=>l,diffArrayList:()=>e,diffStrings:()=>V,documentIsFullScreen:()=>S,exitFullScreen:()=>k,extendObjType:()=>B,extractMediaId3Tags:()=>Tt,fetchJson:()=>w,fetchText:()=>b,formatBytes:()=>Y,formatCustomTimer:()=>a,formatDayTimer:()=>u,formatTimer:()=>s,genFibonacciSeq:()=>z,getAge:()=>$,getElsCollDetails:()=>dt,getElsCollDirDepth:()=>pt,getElsCollOverlap:()=>ft,getElsCollOverlapPos:()=>lt,getElsColliding:()=>st,getElsPerfColliding:()=>ut,getElsRelativeCenterOffset:()=>ht,getPercentage:()=>j,getRectCenter:()=>ct,getSimplePerc:()=>D,getTimeDuration:()=>i,installWindowHiddenScript:()=>v,isFullScreenMode:()=>C,isJsonObject:()=>c,isScreenFilled:()=>U,objType:()=>I,offFullScreenChange:()=>F,onFullScreenChange:()=>R,parseMediaMetadata:()=>At,readBase64Blob:()=>p,readFileBlob:()=>h,readJsonBlob:()=>d,reorderObjTypeOrder:()=>M,requestFullScreen:()=>O,ruleOfThree:()=>P,safeTextTrim:()=>G,saveJsonFile:()=>y,shuffleArray:()=>t,toTitleCase:()=>_,toTitleCaseLowerFirst:()=>J,valMediaContentMetadata:()=>vt,valMediaContentMetadataPartial:()=>Et});var E=r(271);const T="undefined"!=typeof window&&void 0!==window.document,A={items:{},order:[]};function B(t,e){const r=[],n=Array.isArray(t)?t:Object.entries(t);for(const[t,o]of n)if(!A.items.hasOwnProperty(t)){A.items[t]=o;let n="number"==typeof e?e:-1;if(-1===n){const t=A.order.indexOf("object");n=t>-1?t:A.order.length}n=Math.min(Math.max(0,n),A.order.length),A.order.splice(n,0,t),r.push(t)}return r}function M(t){const e=[...A.order];return!!t.every(t=>e.includes(t))&&(A.order=t.slice(),!0)}function N(){return[...A.order]}const L=t=>{if(null===t)return"null";for(const e of A.order)if("function"!=typeof A.items[e]||A.items[e](t))return e;return"unknown"};function I(t,e){if(void 0===t)return null;const r=L(t);return"string"==typeof e?r===e.toLowerCase():r}B([["undefined",t=>void 0===t],["null",t=>null===t],["boolean",t=>"boolean"==typeof t],["number",t=>"number"==typeof t&&!Number.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)]]),T||B([["buffer",t=>void 0!==E.hp&&E.hp.isBuffer(t)]]),T&&B([["file",t=>"undefined"!=typeof File&&t instanceof File]]),B([["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]]),T&&B([["htmlelement",t=>"undefined"!=typeof HTMLElement&&t instanceof HTMLElement]]),B([["object",t=>c(t)]]);const S=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),U=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,C=()=>S()||U(),O=t=>new Promise(async(e,r)=>{const n=document.documentElement;try{n.requestFullscreen?await n.requestFullscreen(t):n.mozRequestFullScreen?n.mozRequestFullScreen(t):n.webkitRequestFullScreen?n.webkitRequestFullScreen(t):n.msRequestFullscreen&&n.msRequestFullscreen(t),e()}catch(t){r(t)}}),k=()=>new Promise((t,e)=>{if(document.exitFullscreen)document.exitFullscreen().then(t).catch(e);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()}t()}catch(t){e(t)}}),x=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],R=(t,e)=>{x.forEach(r=>{document.addEventListener(r,t,e)})},F=(t,e)=>{x.forEach(r=>{document.removeEventListener(r,t,e)})};function P(t,e,r,n=!1){return n?Number(t*e)/r:Number(r*e)/t}function D(t,e){return t*(e/100)}function j(t,e){return 0===e?0:t/e*100}function $(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(),a=r.getMonth(),s=n.getDate(),u=r.getDate();return(i<a||i===a&&s<u)&&o--,Math.abs(o)}return null}function Y(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 a=t/Math.pow(1024,i);if(null!==e){const t=e<0?0:e;a=parseFloat(a.toFixed(t))}return{unit:n[i],value:a}}function z({baseValues:t=[0,1],length:e=10,combiner:r=(t,e)=>t+e}={}){if(!Array.isArray(t)||2!==t.length)throw new Error("baseValues must be an array of exactly two numbers");const n=[...t.slice(0,2)];for(let t=2;t<e;t++){const e=r(n[t-2],n[t-1],t);n.push(e)}return n}function H(t,e){if(Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("Original market cap must be a number.");if(Number.isNaN(e)||!Number.isFinite(e))throw new TypeError("Circulating supply must be a number.");if(e<=0)throw new Error("Circulating supply must be greater than zero.");return t/e}function q(t,e,r){if(Number.isNaN(r)||!Number.isFinite(r))throw new TypeError("New market cap must be a number.");const n=H(t,e),o="number"==typeof r?r/e:NaN;return{originalPrice:n,newPrice:o,priceChangePercent:"number"==typeof r?(o-n)/n*100:NaN}}async function W(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())}function _(t){return t.replace(/\w\S*/g,t=>t.charAt(0).toUpperCase()+t.substr(1).toLowerCase())}function J(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({key:t="a",className:e="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()===t){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(e)}};return document.addEventListener("keydown",r),r}function G(t,e,r=.6){if("string"!=typeof t)throw new TypeError("Expected a string for 'text', but received "+typeof t);if(!Number.isInteger(e)||e<=0)throw new TypeError(`Expected 'limit' to be a positive integer, but received ${e}`);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=t.trim();if(n.length>e){const t=n.lastIndexOf(" ",e);return t>0&&t>=e*r?`${n.substring(0,t).trim()}...`:`${n.substring(0,e).trim()}...`}return n}function V(t,e){const r={added:{},removed:{},modified:{}};for(const n in t)n in e?t[n]!==e[n]&&(r.modified[n]={old:t[n],new:e[n]}):r.removed[n]=t[n];for(const n in e)n in t||(r.added[n]=e[n]);return r}const Z=(t,e)=>t.bottom<e.top,K=(t,e)=>t.top>e.bottom,Q=(t,e)=>t.right<e.left,tt=(t,e)=>t.left>e.right,et=(t,e)=>t.bottom<=e.top,rt=(t,e)=>t.top>=e.bottom,nt=(t,e)=>t.right<=e.left,ot=(t,e)=>t.left>=e.right,it=(t,e)=>!(Q(t,e)||tt(t,e)||Z(t,e)||K(t,e)),at=(t,e)=>!(nt(t,e)||ot(t,e)||et(t,e)||rt(t,e)),st=(t,e)=>Q(t,e)?"left":tt(t,e)?"right":Z(t,e)?"top":K(t,e)?"bottom":null,ut=(t,e)=>nt(t,e)?"left":ot(t,e)?"right":et(t,e)?"top":rt(t,e)?"bottom":null,ft=(t,e)=>({overlapLeft:e.right-t.left,overlapRight:t.right-e.left,overlapTop:e.bottom-t.top,overlapBottom:t.bottom-e.top}),lt=({overlapLeft:t=-1,overlapRight:e=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:t<e?"right":"left",dirY:r<n?"bottom":"top"}),ct=t=>({x:t.left+t.width/2,y:t.top+t.height/2});function ht(t,e){const r=t.left+t.width/2,n=t.top+t.height/2;return{x:e.left+e.width/2-r,y:e.top+e.height/2-n}}function pt(t,e){if(!at(t,e))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}=ft(t,e),{dirX:a,dirY:s}=lt({overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}),u=Math.min(r,n),f=Math.min(o,i);let l;return l=u<f?a:s,{inDir:l,dirX:a,dirY:s,depthX:u,depthY:f}}function dt(t,e){const r=at(t,e),n={in:null,x:null,y:null},o={y:null,x:null},i={top:0,bottom:0,left:0,right:0},{overlapLeft:a,overlapRight:s,overlapTop:u,overlapBottom:f}=ft(e,t);i.top=u,i.bottom=f,i.left=a,i.right=s;const l=Object.entries(i).filter(([,t])=>t>0).sort((t,e)=>t[1]-e[1]),{dirX:c,dirY:h}=lt({overlapLeft:s,overlapRight:a,overlapTop:f,overlapBottom:u});return n.y=h,n.x=c,i.bottom<0?o.y="bottom":i.top<0&&(o.y="top"),i.left<0?o.x="left":i.right<0&&(o.x="right"),n.in=r?i.top===i.bottom&&i.bottom===i.left&&i.left===i.right?"center":l.length?l[0][0]:"top":null,{dirs:n,depth:i,isNeg:o}}const yt=new Map;class gt extends Error{constructor(t,e,r){super(t),this.name="MediaLoadingError",this.url=e,this.stage=r}}const mt=async t=>{const e=(new TextEncoder).encode(t),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,8)},wt=(t,e="image/jpeg")=>{const r=t=>{const e=URL.createObjectURL(t),r=yt.get(e);return yt.set(e,"number"==typeof r?r+1:1),e};if(t instanceof Uint8Array)return r(new Blob([t],{type:e}));if("string"==typeof t&&t.startsWith("data:")){const n=t.split(",")[1],o=atob(n),i=new Uint8Array(o.length);for(let t=0;t<o.length;t++)i[t]=o.charCodeAt(t);return r(new Blob([i],{type:e}))}return"string"==typeof t?t:""},bt=(t,e)=>{const r=t=>e&&void 0===t,n=t=>r(t)||"string"==typeof t||null===t,o=(t,e)=>!!r(t)||!(!Array.isArray(t)||!t.every(e));if(!n(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(i=t.year,!r(i)&&"number"!=typeof i&&null!==i)throw new TypeError('Invalid metadata: "year" must be a number or null.');var i;if(!o(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!o(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!o(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!o(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!o(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!o(t.picture,t=>!(void 0!==t.description&&"string"!=typeof t.description||void 0!==t.name&&"string"!=typeof t.name||void 0!==t.type&&"string"!=typeof t.type||"string"!=typeof t.format||!(t.data instanceof Uint8Array||"string"==typeof t.data))))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const a=(t,e)=>{if(!r(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};a(t.disk,"disk"),a(t.track,"track")},vt=t=>bt(t,!1),Et=t=>bt(t,!0),Tt=async(t,e)=>{if("string"!=typeof t)throw new TypeError(`Expected url to be a string, but received ${typeof t}.`);if("function"!=typeof e)throw new TypeError(`Expected parseFile to be a function, but received ${typeof e}.`);try{const r=await fetch(t);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),o=await e(n);if(!o||"object"!=typeof o.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const i=o.common;return Et(i),{title:i?.title??null,album:i?.album??null,albumartist:i?.albumartist??null,albumartists:i?.albumartists??[],genre:i?.genre??[],label:i?.label??[],composer:i?.composer??[],year:i?.year??null,artist:i?.artist??null,artists:i?.artists??[],disk:i?.disk?{no:i.disk.no,of:i.disk.of}:{no:null,of:null},track:i?.track?{no:i.track.no,of:i.track.of}:{no:null,of:null},picture:i?.picture?.map(t=>({...t,data:wt(t.data,t.format)}))??[]}}catch(t){throw t}},At=async(t,e={},r={},n=t=>new Promise((t,e)=>e(new TypeError("parseFile library not found."))),o={},i="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(o.onProgress&&"function"!=typeof o.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(o.onError&&"function"!=typeof o.onError)throw new TypeError("callbacks.onError must be a function.");let a,s="";const u=(e,r)=>{o.onProgress&&o.onProgress({event:r,status:"loading",stage:e,url:s||(t instanceof HTMLMediaElement?t.src:"unknown")})},f=(e,r)=>{o.onError&&o.onError({error:e,url:s||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:r})};try{u("INITIALIZING"),"string"==typeof t?(s=t,a=new Audio(s)):(a=t,s=a.src);try{await new Promise((t,e)=>{const r=t=>u("DOWNLOADING",t),n=()=>{i(),t(void 0)},o=t=>{i(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},i=()=>{a.removeEventListener("progress",r),a.removeEventListener("loadedmetadata",n),a.removeEventListener("error",o)};a.addEventListener("progress",r),a.addEventListener("loadedmetadata",n),a.addEventListener("error",o),a.readyState>=1&&(i(),t(void 0))}),u("METADATA_LOADED")}catch(t){throw new gt(t instanceof Error?t.message:"UNKNOWN ERROR",s,"METADATA")}const l={id:r.id||await mt(s),duration:Math.floor(1e3*a.duration),url:s,weight:r.weight??1};let c={};u("EXTRACTING_ID3");try{c=await Tt(s,n)}catch(t){f(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${s}. Falling back to filename.`)}const h=t=>{try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},p={...l,...e,...c,...r,title:c.title||r.title||h(s),artist:c.artist||r.artist||("string"==typeof i?i:String(i()))};return o.onProgress&&o.onProgress({status:"success",stage:"COMPLETE",url:s}),p}catch(t){if(t instanceof gt)throw t;{const e=new gt(t instanceof Error?t.message:"UNKNOWN ERROR",s,"INITIALIZING");throw f(e,"INITIALIZING"),e}}}})(),window.TinyBasicsEs=n})();
|
|
1
|
+
(()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var n=0;n<r.length;){var o=r[n++],i=r[n++];e.o(t,o)?0===i&&n++:0===i?Object.defineProperty(t,o,{enumerable:!0,value:r[n++]}):Object.defineProperty(t,o,{enumerable:!0,get:i})}else for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};function r(e){if(!Array.isArray(e))throw new TypeError("Argument 'items' must be an array.");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 n(e,t){if(!Array.isArray(e))throw new TypeError("Argument 'phases' must be an array.");if(!Array.isArray(t))throw new TypeError("Argument 'counts' must be an array.");if(e.length!==t.length)throw new RangeError("The 'phases' and 'counts' arrays must have the same length.");const r=[];for(let n=0;n<e.length;n++){if("number"!=typeof t[n]||Number.isNaN(t[n]))throw new TypeError(`Element at counts[${n}] must be a valid number.`);for(let o=0;o<t[n];o++)r.push(e[n])}return r}function o(e,t){if(!Array.isArray(e))throw new TypeError("Argument 'oldItems' must be an array.");if(!Array.isArray(t))throw new TypeError("Argument 'newItems' must be an array.");const r=e.filter(e=>!t.includes(e));return{added:t.filter(t=>!e.includes(t)),removed:r}}function i(e,t=!1){if(null!=e&&"string"!=typeof e)throw new TypeError("Argument 'item' must be a string or null.");if("boolean"!=typeof t)throw new TypeError("Argument 'isReverse' must be a boolean.");return t?function(t,r){return(e?t[e]:t)>(e?r[e]:r)?-1:(e?t[e]:t)<(e?r[e]:r)?1:0}:function(t,r){return(e?t[e]:t)<(e?r[e]:r)?-1:(e?t[e]:t)>(e?r[e]:r)?1:0}}function a(e=new Date,t="asSeconds",r=null){if(!(e instanceof Date))throw new TypeError("The 'timeData' argument must be an instance of Date.");if("string"!=typeof t)throw new TypeError("The 'durationType' argument must be a string.");const n=["asMilliseconds","asSeconds","asMinutes","asHours","asDays"];if(!n.includes(t))throw new RangeError(`The 'durationType' must be one of: ${n.join(", ")}.`);if(null!==r&&!(r instanceof Date))throw new TypeError("The 'now' argument must be an instance of Date or null.");const o=r instanceof Date?r:new Date,i=e.getTime()-o.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}}function s(e,t="seconds",r="{time}"){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'totalSeconds' argument must be a valid number.");if("string"!=typeof t)throw new TypeError("The 'level' argument must be a string.");const n=["seconds","minutes","hours","days","months","years"];if(!n.includes(t))throw new RangeError(`The 'level' must be one of: ${n.join(", ")}.`);if("string"!=typeof r)throw new TypeError("The 'format' argument must be a string.");e=Math.max(0,Math.floor(e));const o=n.indexOf(t),i=o>=5,a=o>=4,s=o>=3,l=o>=2,u=o>=1,c=o>=0,f={years:i?0:NaN,months:a?0:NaN,days:s?0:NaN,hours:l?0:NaN,minutes:u?0:NaN,seconds:c?0:NaN,total:NaN};let m=e;if(i||a||s){const e=new Date(1980,0,1),t=new Date(e.getTime()+1e3*m),r=new Date(e);if(i)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),f.years++;if(a)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),f.months++;if(s)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),f.days++;m=Math.floor((t.getTime()-r.getTime())/1e3)}l&&(f.hours=Math.floor(m/3600),m%=3600),u&&(f.minutes=Math.floor(m/60),m%=60),c&&(f.seconds=m),f.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=[l?d(f.hours):null,u?d(f.minutes):null,c?d(f.seconds):null].filter(e=>null!==e).join(":");return r.replace(/\{years\}/g,String(f.years)).replace(/\{months\}/g,String(f.months)).replace(/\{days\}/g,String(f.days)).replace(/\{hours\}/g,d(f.hours)).replace(/\{minutes\}/g,d(f.minutes)).replace(/\{seconds\}/g,d(f.seconds)).replace(/\{time\}/g,p).replace(/\{total\}/g,String(f.total)).trim()}function l(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return s(e,"hours","{hours}:{minutes}:{seconds}")}function u(e){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'seconds' argument must be a valid number.");return s(e,"days","{days}d {hours}:{minutes}:{seconds}")}function c(e,t="milliseconds"){if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The 'totalMs' argument must be a valid number.");if("string"!=typeof t)throw new TypeError("The 'level' argument must be a string.");const r=["milliseconds","seconds","minutes","hours","days","months","years"];if(!r.includes(t))throw new RangeError(`The 'level' must be one of: ${r.join(", ")}.`);e=Math.max(0,Math.floor(e));const n=r.indexOf(t),o=n>=6,i=n>=5,a=n>=4,s=n>=3,l=n>=2,u=n>=1,c=n>=0,f={years:o?0:NaN,months:i?0:NaN,days:a?0:NaN,hours:s?0:NaN,minutes:l?0:NaN,seconds:u?0:NaN,milliseconds:c?0:NaN,total:NaN};let m=e;if(o||i||a){const e=new Date(1980,0,1),t=new Date(e.getTime()+m),r=new Date(e);if(o)for(;new Date(r.getFullYear()+1,r.getMonth(),r.getDate()).getTime()<=t.getTime();)r.setFullYear(r.getFullYear()+1),f.years++;if(i)for(;new Date(r.getFullYear(),r.getMonth()+1,r.getDate()).getTime()<=t.getTime();)r.setMonth(r.getMonth()+1),f.months++;if(a)for(;new Date(r.getFullYear(),r.getMonth(),r.getDate()+1).getTime()<=t.getTime();)r.setDate(r.getDate()+1),f.days++;m=t.getTime()-r.getTime()}return s&&(f.hours=Math.floor(m/36e5),m%=36e5),l&&(f.minutes=Math.floor(m/6e4),m%=6e4),u&&(f.seconds=Math.floor(m/1e3),m%=1e3),c&&(f.milliseconds=m),f.total=+e,f}function f(e){if(!Array.isArray(e)&&!m(e))throw new TypeError("Argument must be either an Array or a pure JSON Object.");return Array.isArray(e)?e.length:Object.keys(e).length}function m(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function d(e,t){if(!(e instanceof Blob))return Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'));const r=["readAsArrayBuffer","readAsDataURL","readAsText","readAsBinaryString"];return"string"==typeof t&&r.includes(t)?new Promise((r,n)=>{const o=new FileReader;o.onload=()=>{try{r(o.result)}catch(e){n(e)}},o.onerror=()=>{n(o.error)},o[t](e)}):Promise.reject(new TypeError(`The "method" argument must be one of: ${r.join(", ")}.`))}function p(e,t=!1){return e instanceof Blob?"string"!=typeof t&&"boolean"!=typeof t?Promise.reject(new TypeError("The isDataUrl parameter must be a boolean or a string.")):new Promise((r,n)=>{d(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[,o,i]=n;if(!/^[\w/+]+=*$/.test(i))throw new Error("Base64 content is malformed.");if("boolean"==typeof t)return r(t?e:i);if(!/^[\w-]+\/[\w.+-]+$/.test(t))throw new Error(`Invalid MIME type string: ${t}`);return r(`data:${t};base64,${i}`)}).catch(n)}):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function y(e){return e instanceof Blob?new Promise((t,r)=>d(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)):Promise.reject(new TypeError('The "file" argument must be an instance of Blob or File.'))}function w(e,t,r=2){if("string"!=typeof e)throw new TypeError('The "filename" argument must be a string.');if("number"!=typeof r||!Number.isInteger(r)||r<0)throw new TypeError('The "spaces" argument must be a non-negative integer.');const n=JSON.stringify(t,null,r),o=new Blob([n],{type:"application/json"}),i=URL.createObjectURL(o),a=document.createElement("a");a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function b(e,t,r=e=>({headers:e.headers,status:e.status,statusText:e.statusText})){if(!(e instanceof Response))throw new TypeError('The "response" argument must be an instance of Response.');if("function"!=typeof t)throw new TypeError('The "onProgress" argument must be a function.');if(!e.body)return e;const n=e.headers.get("content-length"),o=n?parseInt(n,10):0;let i=0;const a=e.body.getReader(),s=new ReadableStream({async start(e){for(;;){const{done:r,value:n}=await a.read();if(r)break;i+=n.byteLength,t(i,o),e.enqueue(n)}e.close()}});return new Response(s,r(e))}async function g(e,t,r){return"string"!=typeof e?Promise.reject(new TypeError('The "url" argument must be a string.')):void 0!==t&&"object"!=typeof t?Promise.reject(new TypeError('The "options" argument must be an object.')):void 0!==r&&"function"!=typeof r?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((n,o)=>{fetch(e,t??void 0).then(async e=>{const t=r?b(e,r):e,o=t.headers.get("content-type")||"";if(!o.includes("application/json"))throw new Error(`Unexpected content-type: ${o}`);const i=await t.json();if(!Array.isArray(i)&&!m(i))throw new Error("Received invalid data instead of valid JSON.");return n(i)}).catch(o)})}async function h(e,t,r,n){return"string"!=typeof e?Promise.reject(new TypeError('The "url" argument must be a string.')):void 0===t||Array.isArray(t)?void 0!==r&&"object"!=typeof r?Promise.reject(new TypeError('The "options" argument must be an object.')):void 0!==n&&"function"!=typeof n?Promise.reject(new TypeError('The "onProgress" option must be a function.')):new Promise((o,i)=>{fetch(e,r??void 0).then(async e=>{const r=n?b(e,n):e,i=r.headers.get("content-type")||"";if(Array.isArray(t)&&t.length>0&&!t.some(e=>i.includes(e)))throw new Error(`Blocked MIME type: ${i}`);const a=await r.text();return o(a)}).catch(i)}):Promise.reject(new TypeError('The "allowedMimeTypes" argument must be an array of strings.'))}function E(e={}){if(null===e||"object"!=typeof e)throw new TypeError('The "settings" argument must be an object.');const{element:t=document.body,hiddenClass:r="windowHidden",visibleClass:n="windowVisible",onVisible:o,onHidden:i}=e;if(!(t instanceof Element))throw new TypeError('"element" must be an instance of Element.');if("string"!=typeof r)throw new TypeError('"hiddenClass" must be a string.');if("string"!=typeof n)throw new TypeError('"visibleClass" must be a string.');if(void 0!==o&&"function"!=typeof o)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 a="",s="";const l=()=>{t.classList.remove(r),t.classList.remove(n)};let u=null;const c=["visibilitychange","mozvisibilitychange","webkitvisibilitychange","msvisibilitychange"],f=["hidden","mozHidden","webkitHidden","msHidden"];for(let e=0;e<f.length;e++)if(f[e]in document){u=f[e];break}const m=function(e){l();const c=e?.type,f=u&&document[u];["focus","focusin","pageshow"].includes(c)?(t.classList.add(n),o?.({type:c,oldClass:s,oldType:a}),s=n):["blur","focusout","pagehide"].includes(c)||f?(t.classList.add(r),i?.({type:c,oldClass:s,oldType:a}),s=r):(t.classList.add(n),o?.({type:c,oldClass:s,oldType:a}),s=n),a=c};let d=()=>{};if(u){const e=c[f.indexOf(u)];document.addEventListener(e,m),window.addEventListener("focus",m),window.addEventListener("blur",m),d=()=>{document.removeEventListener(e,m),window.removeEventListener("focus",m),window.removeEventListener("blur",m),l()}}else"onfocusin"in document?(document.onfocusin=document.onfocusout=m,d=()=>{document.onfocusin=document.onfocusout=null,l()}):(window.onpageshow=window.onpagehide=window.onfocus=window.onblur=m,d=()=>{window.onpageshow=window.onpagehide=window.onfocus=window.onblur=null,l()});const p=new Event(u&&document[u]?"blur":"focus");return m(p),d}e.r(t),e.d(t,{addAiMarkerShortcut:()=>X,areElsCollBottom:()=>_,areElsCollLeft:()=>Q,areElsCollPerfBottom:()=>re,areElsCollPerfLeft:()=>ne,areElsCollPerfRight:()=>oe,areElsCollPerfTop:()=>te,areElsCollRight:()=>ee,areElsCollTop:()=>Z,areElsColliding:()=>ie,areElsPerfColliding:()=>ae,arraySortPositions:()=>i,asyncReplace:()=>z,breakdownDuration:()=>c,calculateMarketcap:()=>H,cloneObjTypeOrder:()=>M,compareMarketcap:()=>q,countObj:()=>f,diffArrayList:()=>o,diffObjList:()=>G,diffStrings:()=>K,documentIsFullScreen:()=>x,exitFullScreen:()=>S,extendObjType:()=>N,extractMediaId3Tags:()=>Me,fetchJson:()=>g,fetchText:()=>h,formatBytes:()=>U,formatCustomTimer:()=>s,formatDayTimer:()=>u,formatTimer:()=>l,genFibonacciSeq:()=>Y,getAge:()=>$,getElsCollDetails:()=>pe,getElsCollDirDepth:()=>de,getElsCollOverlap:()=>ue,getElsCollOverlapPos:()=>ce,getElsColliding:()=>se,getElsPerfColliding:()=>le,getElsRelativeCenterOffset:()=>me,getPercentage:()=>B,getRectCenter:()=>fe,getSimplePerc:()=>R,getTimeDuration:()=>a,installWindowHiddenScript:()=>E,isFullScreenMode:()=>k,isJsonObject:()=>m,isScreenFilled:()=>D,multiplyArrayBlocks:()=>n,objType:()=>j,offFullScreenChange:()=>I,onFullScreenChange:()=>C,parseMediaMetadata:()=>Fe,readBase64Blob:()=>p,readFileBlob:()=>d,readJsonBlob:()=>y,reorderObjTypeOrder:()=>A,requestFullScreen:()=>L,ruleOfThree:()=>O,safeTextTrim:()=>V,saveJsonFile:()=>w,shuffleArray:()=>r,toTitleCase:()=>J,toTitleCaseLowerFirst:()=>W,valMediaContentMetadata:()=>Ne,valMediaContentMetadataPartial:()=>Ae});const T="undefined"!=typeof window&&void 0!==window.document,v={items:{},order:[]};function N(e,t){if("object"!=typeof e||null===e)throw new TypeError("Argument 'newItems' must be an object or an array.");if(void 0!==t&&"number"!=typeof t)throw new TypeError("Argument 'index' must be a number.");const r=[],n=Array.isArray(e)?e:Object.entries(e);for(const e of n){if(!Array.isArray(e)||e.length<2)throw new TypeError("Each item in 'newItems' array must be a [key, function] pair.");const[n,o]=e;if("string"!=typeof n)throw new TypeError("Validator key must be a string.");if("function"!=typeof o)throw new TypeError(`Validator for key '${n}' must be a function.`);if(!v.items.hasOwnProperty(n)){v.items[n]=o;let e="number"==typeof t?t:-1;if(-1===e){const t=v.order.indexOf("object");e=t>-1?t:v.order.length}e=Math.min(Math.max(0,e),v.order.length),v.order.splice(e,0,n),r.push(n)}}return r}function A(e){if(!Array.isArray(e))throw new TypeError("Argument 'newOrder' must be an array of strings.");if(!e.every(e=>"string"==typeof e))throw new TypeError("All elements in 'newOrder' must be strings.");const t=[...v.order];return!!e.every(e=>t.includes(e))&&(v.order=e.slice(),!0)}function M(){return[...v.order]}const F=e=>{if(null===e)return"null";for(const t of v.order)if("function"!=typeof v.items[t]||v.items[t](e))return t;return"unknown"};function j(e,t){if(void 0===e)return null;if(void 0!==t&&"string"!=typeof t)throw new TypeError("Argument 'type' must be a string.");const r=F(e);return"string"==typeof t?r===t.toLowerCase():r}N([["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)]]),T&&N([["file",e=>"undefined"!=typeof File&&e instanceof File]]),N([["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]]),T&&N([["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement]]),N([["object",e=>m(e)]]);const x=()=>!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitIsFullScreen||document.mozFullScreen),D=()=>window.innerHeight===screen.height&&window.innerWidth===screen.width,k=()=>x()||D(),L=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)}}),S=()=>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)}}),P=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"],C=(e,t)=>{P.forEach(r=>{document.addEventListener(r,e,t)})},I=(e,t)=>{P.forEach(r=>{document.removeEventListener(r,e,t)})};function O(e,t,r,n=!1){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("val1 must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("val2 must be a finite number.");if("number"!=typeof r||!Number.isFinite(r))throw new TypeError("val3 must be a finite number.");if("boolean"!=typeof n)throw new TypeError("inverse must be a boolean.");return n?Number(e*t)/r:Number(r*t)/e}function R(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("price must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("percentage must be a finite number.");return e*(t/100)}function B(e,t){if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("part must be a finite number.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("total must be a finite number.");return 0===t?0:e/t*100}function $(e=0,t=null){if("number"!=typeof e&&"string"!=typeof e&&!(e instanceof Date))throw new TypeError("timeData must be a number, string, or Date object.");if(null!==t&&!(t instanceof Date))throw new TypeError("now must be a Date object or null.");const r=new Date(e);if(Number.isNaN(r.getTime()))return null;const n=t instanceof Date?t:new Date;let o=n.getFullYear()-r.getFullYear();const i=n.getMonth(),a=r.getMonth(),s=n.getDate(),l=r.getDate();return(i<a||i===a&&s<l)&&o--,Math.abs(o)}function U(e,t=null,r=null){if("number"!=typeof e||!Number.isFinite(e)||e<0)throw new TypeError("bytes must be a positive number.");if(0===e)return{unit:"Bytes",value:0};if(null!==t&&("number"!=typeof t||!Number.isFinite(t)))throw new TypeError("decimals must be a number or null.");const n=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(null!==r){if("string"!=typeof r)throw new TypeError("maxUnit must be a string or null.");if(!n.includes(r))throw new RangeError(`maxUnit must be one of: ${n.join(", ")}`)}const o=r&&n.includes(r)?n.indexOf(r):n.length-1,i=Math.min(Math.floor(Math.log(e)/Math.log(1024)),o);let a=e/Math.pow(1024,i);if(null!==t){const e=t<0?0:t;a=parseFloat(a.toFixed(e))}return{unit:n[i],value:a}}function Y({baseValues:e=[0,1],length:t=10,combiner:r=(e,t)=>e+t}={}){if(!Array.isArray(e)||2!==e.length||!e.every(e=>"number"==typeof e))throw new Error("baseValues must be an array of exactly two numbers.");if("number"!=typeof t||!Number.isInteger(t))throw new RangeError("length must be an integer.");if("function"!=typeof r)throw new TypeError("combiner must be a function.");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 H(e,t){if("number"!=typeof e||Number.isNaN(e)||!Number.isFinite(e))throw new TypeError("Original market cap must be a finite number.");if("number"!=typeof t||Number.isNaN(t)||!Number.isFinite(t))throw new TypeError("Circulating supply must be a finite number.");if(t<=0)throw new RangeError("Circulating supply must be greater than zero.");return e/t}function q(e,t,r){if("number"!=typeof r||Number.isNaN(r)||!Number.isFinite(r))throw new TypeError("New market cap must be a finite number.");const n=H(e,t),o="number"==typeof r?r/t:NaN;return{originalPrice:n,newPrice:o,priceChangePercent:"number"==typeof r?(o-n)/n*100:NaN}}async function z(e,t,r){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);if(!(t instanceof RegExp))throw new TypeError("Expected a RegExp for 'regex', but received "+typeof t);if("function"!=typeof r)throw new TypeError("Expected a function for 'asyncFn', but received "+typeof r);const n=[];e.replace(t,(e,...t)=>(n.push(r(e,...t)),e));const o=await Promise.all(n);return e.replace(t,()=>o.shift())}function J(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof e);return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase())}function W(e){if("string"!=typeof e)throw new TypeError("Expected a string for 'str', but received "+typeof 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 X({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.");if("string"!=typeof e)throw new TypeError("Expected a string for 'config.key', but received "+typeof e);if("string"!=typeof t)throw new TypeError("Expected a string for 'config.className', but received "+typeof t);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 V(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 G(e,t){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("Expected an object for 'oldStrings', but received "+(null===e?"null":typeof e));if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("Expected an object for 'newStrings', but received "+(null===t?"null":typeof 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}const K=G,Z=(e,t)=>e.bottom<t.top,_=(e,t)=>e.top>t.bottom,Q=(e,t)=>e.right<t.left,ee=(e,t)=>e.left>t.right,te=(e,t)=>e.bottom<=t.top,re=(e,t)=>e.top>=t.bottom,ne=(e,t)=>e.right<=t.left,oe=(e,t)=>e.left>=t.right,ie=(e,t)=>!(Q(e,t)||ee(e,t)||Z(e,t)||_(e,t)),ae=(e,t)=>!(ne(e,t)||oe(e,t)||te(e,t)||re(e,t)),se=(e,t)=>Q(e,t)?"left":ee(e,t)?"right":Z(e,t)?"top":_(e,t)?"bottom":null,le=(e,t)=>ne(e,t)?"left":oe(e,t)?"right":te(e,t)?"top":re(e,t)?"bottom":null,ue=(e,t)=>({overlapLeft:t.right-e.left,overlapRight:e.right-t.left,overlapTop:t.bottom-e.top,overlapBottom:e.bottom-t.top}),ce=({overlapLeft:e=-1,overlapRight:t=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:e<t?"right":"left",dirY:r<n?"bottom":"top"}),fe=e=>({x:e.left+e.width/2,y:e.top+e.height/2});function me(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 de(e,t){if(!ae(e,t))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}=ue(e,t),{dirX:a,dirY:s}=ce({overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}),l=Math.min(r,n),u=Math.min(o,i);let c;return c=l<u?a:s,{inDir:c,dirX:a,dirY:s,depthX:l,depthY:u}}function pe(e,t){const r=ae(e,t),n={in:null,x:null,y:null},o={y:null,x:null},i={top:0,bottom:0,left:0,right:0},{overlapLeft:a,overlapRight:s,overlapTop:l,overlapBottom:u}=ue(t,e);i.top=l,i.bottom=u,i.left=a,i.right=s;const c=Object.entries(i).filter(([,e])=>e>0).sort((e,t)=>e[1]-t[1]),{dirX:f,dirY:m}=ce({overlapLeft:s,overlapRight:a,overlapTop:u,overlapBottom:l});return n.y=m,n.x=f,i.bottom<0?o.y="bottom":i.top<0&&(o.y="top"),i.left<0?o.x="left":i.right<0&&(o.x="right"),n.in=r?i.top===i.bottom&&i.bottom===i.left&&i.left===i.right?"center":c.length?c[0][0]:"top":null,{dirs:n,depth:i,isNeg:o}}const ye=(e,t)=>{if("string"!=typeof e)throw new TypeError(`Expected "${t}" to be a string, but received ${typeof e}.`)},we=(e,t)=>{if("function"!=typeof e)throw new TypeError(`Expected "${t}" to be a function, but received ${typeof e}.`)},be=(e,t)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError(`Expected "${t}" to be a plain object, but received ${null===e?"null":Array.isArray(e)?"array":typeof e}.`)},ge=new Map;class he extends Error{constructor(e,t,r){if(ye(e,"message"),ye(t,"url"),"string"!=typeof r)throw new TypeError(`Expected "stage" to be a string, but received ${typeof r}.`);super(e),this.name="MediaLoadingError",this.url=t,this.stage=r}}const Ee=async e=>{ye(e,"str");const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-1",t);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("").substring(0,8)},Te=(e,t="image/jpeg")=>{if(!(e instanceof Uint8Array)&&"string"!=typeof e)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof e}.`);ye(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=ge.get(t);return ge.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const n=e.split(",")[1],o=atob(n),i=new Uint8Array(o.length);for(let e=0;e<o.length;e++)i[e]=o.charCodeAt(e);return r(new Blob([i],{type:t}))}return"string"==typeof e?e:""},ve=(e,t)=>{if(be(e,"common"),"boolean"!=typeof t)throw new TypeError('Expected "isPartial" to be a boolean.');const r=e=>t&&void 0===e,n=e=>r(e)||"string"==typeof e||null===e,o=(e,t)=>!!r(e)||!(!Array.isArray(e)||!e.every(t));if(!n(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(i=e.year,!r(i)&&"number"!=typeof i&&null!==i)throw new TypeError('Invalid metadata: "year" must be a number or null.');var i;if(!o(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!o(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!o(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!o(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!o(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!o(e.picture,e=>e&&"object"==typeof e&&(void 0===e.description||"string"==typeof e.description)&&(void 0===e.name||"string"==typeof e.name)&&(void 0===e.type||"string"==typeof e.type)&&"string"==typeof e.format&&(e.data instanceof Uint8Array||"string"==typeof e.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const a=(e,t)=>{if(!r(e)){if(null==e)throw new TypeError(`Invalid metadata: "${t}" is required.`);if("object"!=typeof e)throw new TypeError(`Invalid metadata: "${t}" must be an object or null.`);if("number"!=typeof e.no&&null!==e.no)throw new TypeError(`Invalid metadata: "${t}.no" must be a number or null.`);if("number"!=typeof e.of&&null!==e.of)throw new TypeError(`Invalid metadata: "${t}.of" must be a number or null.`)}};a(e.disk,"disk"),a(e.track,"track")},Ne=e=>ve(e,!1),Ae=e=>ve(e,!0),Me=async(e,t)=>{ye(e,"url"),we(t,"parseFile");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),o=await t(n);if(!o||"object"!=typeof o.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const i=o.common;return Ae(i),{title:i?.title??null,album:i?.album??null,albumartist:i?.albumartist??null,albumartists:i?.albumartists??[],genre:i?.genre??[],label:i?.label??[],composer:i?.composer??[],year:i?.year??null,artist:i?.artist??null,artists:i?.artists??[],disk:i?.disk?{no:i.disk.no,of:i.disk.of}:{no:null,of:null},track:i?.track?{no:i.track.no,of:i.track.of}:{no:null,of:null},picture:i?.picture?.map(e=>({...e,data:Te(e.data,e.format)}))??[]}}catch(e){throw e}},Fe=async(e,t={},r={},n=e=>new Promise((e,t)=>t(new TypeError("parseFile library not found."))),o={},i="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(be(t,"defaultMetadata"),be(r,"metadata"),we(n,"parseFile"),be(o,"callbacks"),o.onProgress&&"function"!=typeof o.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(o.onError&&"function"!=typeof o.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof i&&"function"!=typeof i)throw new TypeError("unknownArtist must be a string or a function returning a string.");let a,s="";const l=(t,r)=>{o.onProgress&&o.onProgress({event:r,status:"loading",stage:t,url:s||(e instanceof HTMLMediaElement?e.src:"unknown")})},u=(t,r)=>{o.onError&&o.onError({error:t,url:s||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{l("INITIALIZING"),"string"==typeof e?(s=e,a=new Audio(s)):(a=e,s=a.src);try{await new Promise((e,t)=>{const r=e=>l("DOWNLOADING",e),n=()=>{i(),e(void 0)},o=e=>{i(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},i=()=>{a.removeEventListener("progress",r),a.removeEventListener("loadedmetadata",n),a.removeEventListener("error",o)};a.addEventListener("progress",r),a.addEventListener("loadedmetadata",n),a.addEventListener("error",o),a.readyState>=1&&(i(),e(void 0))}),l("METADATA_LOADED")}catch(e){throw new he(e instanceof Error?e.message:"UNKNOWN ERROR",s,"METADATA")}const c={id:r.id||await Ee(s),duration:Math.floor(1e3*a.duration),url:s,weight:r.weight??1};let f={};l("EXTRACTING_ID3");try{f=await Me(s,n)}catch(e){u(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${s}. Falling back to filename.`)}const m=e=>{try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},d={...c,...t,...f,...r,title:f.title||r.title||m(s),artist:f.artist||r.artist||("string"==typeof i?i:String(i()))};return o.onProgress&&o.onProgress({status:"success",stage:"COMPLETE",url:s}),d}catch(e){if(e instanceof he)throw e;{const t=new he(e instanceof Error?e.message:"UNKNOWN ERROR",s,"INITIALIZING");throw u(t,"INITIALIZING"),t}}};window.TinyBasicsEs=t})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var i=0;i<r.length;){var s=r[i++],n=r[i++];e.o(t,s)?0===n&&i++:0===n?Object.defineProperty(t,s,{enumerable:!0,value:r[i++]}):Object.defineProperty(t,s,{enumerable:!0,get:n})}else for(var s in r)e.o(r,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:r[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyDayNightCycle:()=>r});const r=class{#e=!0;#t=86400;#r=3600;#i=60;#s=new Map;#n=[];#o;#h;#a={main:null};#u=0;#c=0;#y=0;#m="";#d=1;#f=1;#w=1;#S=!1;#g=[31,31,31,31,31,31,31,31,31,31,31,31];#p={default:{},day:{},night:{},hours:{},seasons:{}};#l={min:60,max:180};#b=0;get daySize(){return this.#t}get autoSizeAdjuste(){return this.#e}set autoSizeAdjuste(e){if("boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#e=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.#r/this.#t,r=this.#i/this.#t;this.#t=e,this.#e&&(this.#r=e*t,this.#i=e*r)}get hourSize(){return this.#r}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.#t/this.#r,r=this.#i/this.#r;this.#r=e,this.#e&&(this.#t=e*t,this.#i=e*r)}get minuteSize(){return this.#i}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.#r/this.#i,r=this.#t/this.#i;this.#i=e,this.#e&&(this.#r=e*t,this.#t=e*r)}get isDestroyed(){return this.#S}get currentSeconds(){return this.#u}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.#t)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#u=Math.floor(e),this.#c=Math.floor(e/this.#i),this.#y=Math.floor(e/this.#r)}get currentMinutes(){return this.#c}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.#c=Math.floor(e),this.#y=Math.floor(e/this.#i),this.#u=Math.floor(e*this.#i)}get currentHours(){return this.#y}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.#y=Math.floor(e),this.#c=Math.floor(e*this.#i),this.#u=Math.floor(e*this.#r)}get moons(){return this.#n.map(e=>this.getMoon(e))}get seasons(){return Array.from(this.#s.keys())}get dayStart(){return this.#o}get nightStart(){return this.#h}get weather(){return{...this.#a}}get currentSeason(){return this.#m}get currentDay(){return this.#d}get currentMonth(){return this.#f}get currentYear(){return this.#w}get monthDays(){return[...this.#g]}get weatherDuration(){return{...this.#l}}get weatherTimeLeft(){return this.#b}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.#o=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.#h=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.#a=e}set currentSeason(e){if(this._checkDestroyed(),"string"!=typeof e||!this.#s.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#s).map(e=>e[0]).join(", ")}, received ${e}`);this.#m=e}set currentDay(e){if(this._checkDestroyed(),"number"!=typeof e||e<1||e>this.#g[this.#f-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#d=e}set currentMonth(e){if(this._checkDestroyed(),"number"!=typeof e||"number"!=typeof this.#g[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#f=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.#w=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.#g=[...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.#l={...e}}set weatherTimeLeft(e){if(this._checkDestroyed(),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#b=e}get weatherConfig(){const e={},t={};for(const t in this.#p.hours)e[t]={...this.#p.hours[t]};for(const e in this.#p.seasons)t[e]={...this.#p.seasons[e]};return{default:{...this.#p.default},day:{...this.#p.day},night:{...this.#p.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={},i={},s=(e,t)=>{if("object"!=typeof e||null===e)throw new TypeError(`${t} must be an object, received ${e}`);for(const r in e){const i=typeof e[r];if("number"!==i&&"function"!==i)throw new TypeError(`${t}["${r}"] must be a number or function, received ${i}`)}};for(const t in e.hours)s(e.hours[t],`hours["${t}"]`),r[t]={...e.hours[t]};for(const t in e.seasons)s(e.seasons[t],`seasons["${t}"]`),i[t]={...e.seasons[t]};const n=(e,t)=>(s(e,t),{...e});this.#p={default:n(e.default,"default"),day:n(e.day,"day"),night:n(e.night,"night"),hours:r,seasons:i}}constructor(e=6,t=18){this.#o=e,this.#h=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.#s.set(e,t)}removeSeason(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#s.delete(e),this.#m===e&&(this.#m="")}hasSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#s.has(e)}getSeason(e){if("string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#s.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.#r+t*this.#i+r)%this.#t}addTime({hours:e=0,minutes:t=0,seconds:r=0}){this._checkDestroyed();let i=this.currentSeconds+e*this.#r+t*this.#i+r;for(;i>=this.#t;)i-=this.#t,this.nextDay();for(;i<0;)i+=this.#t,this.prevDay();this.currentSeconds=i,this.updateWeatherTimer((e*this.#r+t*this.#i+r)/this.#i)}getTime({withSeconds:e=!1,hourSize:t=this.#r,minuteSize:r=this.#i}={}){const i=Math.floor(this.currentSeconds/t),s=Math.floor(this.currentSeconds%t/r),n=this.currentSeconds%r;return{hour:i,minute:s,second:n,formatted:`${i.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`+(e?`:${n.toString().padStart(2,"0")}`:"")}}isDay(){return this.#o<this.#h?this.#c>=this.#o*this.#i&&this.#c<this.#h*this.#i:this.#c>=this.#o*this.#i||this.#c<this.#h*this.#i}minutesUntilDay(){return this.timeUntil(this.#o,"minutes")}secondsUntilDay(){return this.timeUntil(this.#o,"seconds")}hoursUntilDay(){return this.timeUntil(this.#o,"hours")}minutesUntilNight(){return this.timeUntil(this.#h,"minutes")}secondsUntilNight(){return this.timeUntil(this.#h,"seconds")}hoursUntilNight(){return this.timeUntil(this.#h,"hours")}timeUntil(e,t){this._checkDestroyed();let r=e*this.#r-this.#u;switch(r<=0&&(r+=this.#t),t){case"minutes":return r/this.#i;case"hours":return r/this.#r;default:return r}}setTo(e){this._checkDestroyed(),"day"===e?this.setTime({hour:this.#o}):"night"===e&&this.setTime({hour:this.#h})}nextDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++){this.#d++;const e=this.#g[this.#f-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#d>e&&(this.#d=1,this.#f++,this.#f>this.#g.length&&(this.#f=1,this.#w++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){this._checkDestroyed();for(let t=0;t<e;t++)this.#d--,this.#d<1&&(this.#f--,this.#f<1&&(this.#f=this.#g.length,this.#w--),this.#d=this.#g[this.#f-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){this._checkDestroyed(),this.#s.forEach((e,t)=>{e.includes(this.#f)&&(this.#m=t)})}setWeatherConfig(e){this._checkDestroyed(),this.#p={...this.#p,...e}}setWeatherDuration(e,t){this._checkDestroyed(),this.#l.min=e,this.#l.max=t}updateWeatherTimer(e){this._checkDestroyed(),this.#b-=e,this.#b<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:r=null}){this._checkDestroyed();const i=this.#a;i[e]=t,this.weather=i,this.#b=r??this._randomInRange(this.#l.min,this.#l.max)}chooseNewWeather({customWeather:e,where:t="main"}={}){this._checkDestroyed();let r={};const i=e=>{for(const[t,i]of Object.entries(e)){let e=i;"function"==typeof e&&(e=e({hour:Math.floor(this.#c/this.#i),minute:this.#c%this.#i,currentMinutes:this.#c,isDay:this.isDay(),season:this.#m,weather:this.#a})),"number"!=typeof e||Number.isNaN(e)||(r[t]=(r[t]||0)+e)}};i(this.#p.default||{});for(const e in this.#p.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#i+(r||0)}),s=this.#c;(t<=r?s>=t&&s<=r:s>=t||s<=r)&&i(this.#p.hours[e])}this.isDay()&&this.#p.day?i(this.#p.day):!this.isDay()&&this.#p.night&&i(this.#p.night),this.#p.seasons?.[this.#m]&&i(this.#p.seasons[this.#m]),e&&"object"==typeof e&&i(e);const s=Object.entries(r).filter(([,e])=>e>0);if(!s.length)return this.#a[t]=null,null;const n=s.reduce((e,[,t])=>e+t,0);let o=Math.random()*n;for(const[e,r]of s){if(o<r)return this.#a[t]=e,this.#b=this._randomInRange(this.#l.min,this.#l.max),e;o-=r}return this.#a[t]=null,null}_randomInRange(e,t){return Math.floor(Math.random()*(t-e+1))+e}addMoon(e,t,r,i=0){this._checkDestroyed();const s=Math.max(1,t);return this.#n.push({name:e,cycleLength:s,currentPhase:(i%s+s)%s,phaseNames:r}),this.#n.length-1}removeMoon(e){this._checkDestroyed(),this.#n=this.#n.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#n)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#n)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){this._checkDestroyed();const r=this.#n[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.#n[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.#n[e]}getMoon(e){let t;if("number"==typeof e){if(t=this.#n[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.#S)throw new Error("This instance has been destroyed and can no longer be used.")}destroy(){this.#S||(this.#s.clear(),this.#n.length=0,this.#o=0,this.#h=0,this.#u=0,this.#c=0,this.#y=0,this.#d=1,this.#f=1,this.#w=1,this.#b=0,this.#m="",this.#a={main:null},this.#g=[],this.#p.default={},this.#p.day={},this.#p.night={},this.#p.hours={},this.#p.seasons={},this.#l={min:0,max:0},this.#S=!0)}};window.TinyDayNightCycle=t.TinyDayNightCycle})();
|
|
1
|
+
(()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var s=0;s<r.length;){var i=r[s++],n=r[s++];e.o(t,i)?0===n&&s++:0===n?Object.defineProperty(t,i,{enumerable:!0,value:r[s++]}):Object.defineProperty(t,i,{enumerable:!0,get:n})}else for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyDayNightCycle:()=>s});const r=e=>{if(e)throw new Error("This TinyDayNightCycle instance has been destroyed and can no longer be used.")};const s=class{#e=!0;#t=86400;#r=3600;#s=60;#i=new Map;#n=[];#o;#h;#a={main:null};#u=0;#y=0;#c=0;#d="";#m=1;#f=1;#w=1;#S=!1;#g=[31,31,31,31,31,31,31,31,31,31,31,31];#D={default:{},day:{},night:{},hours:{},seasons:{}};#p={min:60,max:180};#l=0;get daySize(){return r(this.#S),this.#t}get autoSizeAdjuste(){return r(this.#S),this.#e}set autoSizeAdjuste(e){if(r(this.#S),"boolean"!=typeof e)throw new TypeError("autoSizeAdjuste must be a boolean.");this.#e=e}set daySize(e){if(r(this.#S),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("daySize must be a positive finite number.");const t=this.#r/this.#t,s=this.#s/this.#t;this.#t=e,this.#e&&(this.#r=e*t,this.#s=e*s)}get hourSize(){return r(this.#S),this.#r}set hourSize(e){if(r(this.#S),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("hourSize must be a positive finite number.");const t=this.#t/this.#r,s=this.#s/this.#r;this.#r=e,this.#e&&(this.#t=e*t,this.#s=e*s)}get minuteSize(){return r(this.#S),this.#s}set minuteSize(e){if(r(this.#S),"number"!=typeof e||!Number.isFinite(e)||e<=0)throw new Error("minuteSize must be a positive finite number.");const t=this.#r/this.#s,s=this.#t/this.#s;this.#s=e,this.#e&&(this.#r=e*t,this.#t=e*s)}get isDestroyed(){return this.#S}get currentSeconds(){return r(this.#S),this.#u}set currentSeconds(e){if(r(this.#S),"number"!=typeof e||!Number.isFinite(e))throw new TypeError("currentSeconds must be a finite number, received "+typeof e);if(e<0||e>=this.#t)throw new RangeError(`currentSeconds must be between 0 and 86399, received ${e}`);this.#u=Math.floor(e),this.#y=Math.floor(e/this.#s),this.#c=Math.floor(e/this.#r)}get currentMinutes(){return r(this.#S),this.#y}set currentMinutes(e){if(r(this.#S),"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.#y=Math.floor(e),this.#c=Math.floor(e/this.#s),this.#u=Math.floor(e*this.#s)}get currentHours(){return r(this.#S),this.#c}set currentHours(e){if(r(this.#S),"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.#c=Math.floor(e),this.#y=Math.floor(e*this.#s),this.#u=Math.floor(e*this.#r)}get moons(){return r(this.#S),this.#n.map(e=>this.getMoon(e))}get seasons(){return r(this.#S),Array.from(this.#i.keys())}get dayStart(){return r(this.#S),this.#o}get nightStart(){return r(this.#S),this.#h}get weather(){return r(this.#S),{...this.#a}}get currentSeason(){return r(this.#S),this.#d}get currentDay(){return r(this.#S),this.#m}get currentMonth(){return r(this.#S),this.#f}get currentYear(){return r(this.#S),this.#w}get monthDays(){return r(this.#S),[...this.#g]}get weatherDuration(){return r(this.#S),{...this.#p}}get weatherTimeLeft(){return r(this.#S),this.#l}set dayStart(e){if(r(this.#S),"number"!=typeof e||e<1)throw new TypeError("dayStart must be a positive non-zero number, received "+typeof e);this.#o=e}set nightStart(e){if(r(this.#S),"number"!=typeof e||e<1)throw new TypeError("nightStart must be a positive non-zero number, received "+typeof e);this.#h=e}set weather(e){if(r(this.#S),"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.#a=e}set currentSeason(e){if(r(this.#S),"string"!=typeof e||!this.#i.has(e))throw new TypeError(`currentSeason must be one of ${Array.from(this.#i).map(e=>e[0]).join(", ")}, received ${e}`);this.#d=e}set currentDay(e){if(r(this.#S),"number"!=typeof e||e<1||e>this.#g[this.#f-1])throw new TypeError("currentDay must be a valid day number, received "+typeof e);this.#m=e}set currentMonth(e){if(r(this.#S),"number"!=typeof e||"number"!=typeof this.#g[e-1])throw new TypeError("currentMonth must be a valid month number, received "+typeof e);this.#f=e}set currentYear(e){if(r(this.#S),"number"!=typeof e||e<1)throw new TypeError("currentYear must be a positive number non-zero, received "+typeof e);this.#w=e}set monthDays(e){if(r(this.#S),!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.#g=[...e]}set weatherDuration(e){if(r(this.#S),"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.#p={...e}}set weatherTimeLeft(e){if(r(this.#S),"number"!=typeof e)throw new TypeError("weatherTimeLeft must be a number, received "+typeof e);this.#l=e}get weatherConfig(){r(this.#S);const e={},t={};for(const t in this.#D.hours)e[t]={...this.#D.hours[t]};for(const e in this.#D.seasons)t[e]={...this.#D.seasons[e]};return{default:{...this.#D.default},day:{...this.#D.day},night:{...this.#D.night},hours:e,seasons:t}}set weatherConfig(e){if(r(this.#S),"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 s={},i={},n=(e,t)=>{if("object"!=typeof e||null===e)throw new TypeError(`${t} must be an object, received ${e}`);for(const r in e){const s=typeof e[r];if("number"!==s&&"function"!==s)throw new TypeError(`${t}["${r}"] must be a number or function, received ${s}`)}};for(const t in e.hours)n(e.hours[t],`hours["${t}"]`),s[t]={...e.hours[t]};for(const t in e.seasons)n(e.seasons[t],`seasons["${t}"]`),i[t]={...e.seasons[t]};const o=(e,t)=>(n(e,t),{...e});this.#D={default:o(e.default,"default"),day:o(e.day,"day"),night:o(e.night,"night"),hours:s,seasons:i}}constructor(e=6,t=18){this.#o=e,this.#h=t}addSeason(e,t){if(r(this.#S),"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.#i.set(e,t)}removeSeason(e){if(r(this.#S),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);this.#i.delete(e),this.#d===e&&(this.#d="")}hasSeason(e){if(r(this.#S),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);return this.#i.has(e)}getSeason(e){if(r(this.#S),"string"!=typeof e)throw new TypeError("Season name must be a string, received "+typeof e);const t=this.#i.get(e);if(!t)throw new Error(`Season "${e}" not found`);return[...t]}setTime({hour:e=0,minute:t=0,second:s=0}){r(this.#S),this.currentSeconds=(e*this.#r+t*this.#s+s)%this.#t}addTime({hours:e=0,minutes:t=0,seconds:s=0}){r(this.#S);let i=this.currentSeconds+e*this.#r+t*this.#s+s;for(;i>=this.#t;)i-=this.#t,this.nextDay();for(;i<0;)i+=this.#t,this.prevDay();this.currentSeconds=i,this.updateWeatherTimer((e*this.#r+t*this.#s+s)/this.#s)}getTime({withSeconds:e=!1,hourSize:t=this.#r,minuteSize:s=this.#s}={}){r(this.#S);const i=Math.floor(this.currentSeconds/t),n=Math.floor(this.currentSeconds%t/s),o=this.currentSeconds%s;return{hour:i,minute:n,second:o,formatted:`${i.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`+(e?`:${o.toString().padStart(2,"0")}`:"")}}isDay(){return r(this.#S),this.#o<this.#h?this.#y>=this.#o*this.#s&&this.#y<this.#h*this.#s:this.#y>=this.#o*this.#s||this.#y<this.#h*this.#s}minutesUntilDay(){return this.timeUntil(this.#o,"minutes")}secondsUntilDay(){return this.timeUntil(this.#o,"seconds")}hoursUntilDay(){return this.timeUntil(this.#o,"hours")}minutesUntilNight(){return this.timeUntil(this.#h,"minutes")}secondsUntilNight(){return this.timeUntil(this.#h,"seconds")}hoursUntilNight(){return this.timeUntil(this.#h,"hours")}timeUntil(e,t){r(this.#S);let s=e*this.#r-this.#u;switch(s<=0&&(s+=this.#t),t){case"minutes":return s/this.#s;case"hours":return s/this.#r;default:return s}}setTo(e){r(this.#S),"day"===e?this.setTime({hour:this.#o}):"night"===e&&this.setTime({hour:this.#h})}nextDay(e=1){r(this.#S);for(let t=0;t<e;t++){this.#m++;const e=this.#g[this.#f-1];if(Number.isNaN(e)||!Number.isFinite(e))throw new Error("Invalid month day count: monthDays must be a finite number.");this.#m>e&&(this.#m=1,this.#f++,this.#f>this.#g.length&&(this.#f=1,this.#w++)),this.updateSeason(),this.advanceMoons(1)}}prevDay(e=1){r(this.#S);for(let t=0;t<e;t++)this.#m--,this.#m<1&&(this.#f--,this.#f<1&&(this.#f=this.#g.length,this.#w--),this.#m=this.#g[this.#f-1]||30),this.updateSeason(),this.rewindMoons(1)}updateSeason(){r(this.#S),this.#i.forEach((e,t)=>{e.includes(this.#f)&&(this.#d=t)})}setWeatherConfig(e){r(this.#S),this.#D={...this.#D,...e}}setWeatherDuration(e,t){r(this.#S),this.#p.min=e,this.#p.max=t}updateWeatherTimer(e){r(this.#S),this.#l-=e,this.#l<=0&&this.chooseNewWeather()}forceWeather({where:e="main",type:t,duration:s=null}){r(this.#S);const i=this.#a;i[e]=t,this.weather=i,this.#l=s??this._randomInRange(this.#p.min,this.#p.max)}chooseNewWeather({customWeather:e,where:t="main"}={}){r(this.#S);let s={};const i=e=>{for(const[t,r]of Object.entries(e)){let e=r;"function"==typeof e&&(e=e({hour:Math.floor(this.#y/this.#s),minute:this.#y%this.#s,currentMinutes:this.#y,isDay:this.isDay(),season:this.#d,weather:this.#a})),"number"!=typeof e||Number.isNaN(e)||(s[t]=(s[t]||0)+e)}};i(this.#D.default||{});for(const e in this.#D.hours){const[t,r]=e.split("-").map(e=>{const[t,r]=e.split(":").map(Number);return t*this.#s+(r||0)}),s=this.#y;(t<=r?s>=t&&s<=r:s>=t||s<=r)&&i(this.#D.hours[e])}this.isDay()&&this.#D.day?i(this.#D.day):!this.isDay()&&this.#D.night&&i(this.#D.night),this.#D.seasons?.[this.#d]&&i(this.#D.seasons[this.#d]),e&&"object"==typeof e&&i(e);const n=Object.entries(s).filter(([,e])=>e>0);if(!n.length)return this.#a[t]=null,null;const o=n.reduce((e,[,t])=>e+t,0);let h=Math.random()*o;for(const[e,r]of n){if(h<r)return this.#a[t]=e,this.#l=this._randomInRange(this.#p.min,this.#p.max),e;h-=r}return this.#a[t]=null,null}_randomInRange(e,t){return Math.floor(Math.random()*(t-e+1))+e}addMoon(e,t,s,i=0){r(this.#S);const n=Math.max(1,t);return this.#n.push({name:e,cycleLength:n,currentPhase:(i%n+n)%n,phaseNames:s}),this.#n.length-1}removeMoon(e){r(this.#S),this.#n=this.#n.filter(t=>t.name!==e)}advanceMoons(e=1){for(const t in this.#n)this.advanceMoon(parseInt(t),e)}rewindMoons(e=1){for(const t in this.#n)this.rewindMoon(parseInt(t),e)}advanceMoon(e,t=1){r(this.#S);const s=this.#n[e];if(!s)throw new RangeError(`No moon found at index ${e}`);s.currentPhase=(s.currentPhase+t)%s.cycleLength}rewindMoon(e,t=1){r(this.#S);const s=this.#n[e];if(!s)throw new RangeError(`No moon found at index ${e}`);s.currentPhase=(s.currentPhase-t+s.cycleLength)%s.cycleLength}moonExists(e){return r(this.#S),!!this.#n[e]}getMoon(e){let t;if(r(this.#S),"number"==typeof e){if(t=this.#n[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}}destroy(){this.#S||(this.#i.clear(),this.#n.length=0,this.#o=0,this.#h=0,this.#u=0,this.#y=0,this.#c=0,this.#m=1,this.#f=1,this.#w=1,this.#l=0,this.#d="",this.#a={main:null},this.#g=[],this.#D.default={},this.#D.day={},this.#D.night={},this.#D.hours={},this.#D.seasons={},this.#p={min:0,max:0},this.#S=!0)}};window.TinyDayNightCycle=t.TinyDayNightCycle})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var n=0;n<r.length;){var a=r[n++],s=r[n++];e.o(t,a)?0===s&&n++:0===s?Object.defineProperty(t,a,{enumerable:!0,value:r[n++]}):Object.defineProperty(t,a,{enumerable:!0,get:s})}else for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyDragDropDetector:()=>
|
|
1
|
+
(()=>{"use strict";const e={d:(t,r)=>{if(Array.isArray(r))for(var n=0;n<r.length;){var a=r[n++],s=r[n++];e.o(t,a)?0===s&&n++:0===s?Object.defineProperty(t,a,{enumerable:!0,value:r[n++]}):Object.defineProperty(t,a,{enumerable:!0,get:s})}else for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyDragDropDetector:()=>n});const r=e=>{if(e)throw new Error("This TinyDragDropDetector instance has been destroyed and can no longer be used.")};const n=class{#e;#t;#r;#n;#a;#s;#o;#i=!1;get destroyed(){return this.#i}constructor(e,t){const{hoverClass:r="dnd-hover",onDrop:n,onEnter:a,onLeave:s}=t;if(!(e instanceof HTMLElement))throw new TypeError('The "target" option must be an instance of HTMLElement.');if("string"!=typeof r)throw new TypeError('The "hoverClass" option must be a string.');if("function"!=typeof n)throw new TypeError('The "onDrop" option must be a function.');if("function"!=typeof a)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.#e=e,this.#t=r,this.#r=n||(()=>{}),this.#n=a,this.#a=s,this.#s=!1,this.#o=!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.#h()}getTarget(){return r(this.#i),this.#e}getHoverClass(){return r(this.#i),this.#t}isDragging(){return r(this.#i),this.#s}bound(){return r(this.#i),this.#o}#h(){if(this.#o)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.#o=!0}#d(){if(!this.#o)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.#o=!1}_handleDragEnter(e){if(e.preventDefault(),!this.#s){const t=this.getTarget();this.#s=!0,t.classList.add(this.#t),this.#n(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.#s=!1,t.classList.remove(this.#t),this.#a(e))}_handleDrop(e){if(e.preventDefault(),!e.dataTransfer)return void console.warn("[TinyDragDropDetector] [handleDrop] DragOver event missing dataTransfer.");const t=this.getTarget();this.#s=!1,t.classList.remove(this.#t);const r=e.dataTransfer.files;r.length>0&&this.#r(r,e)}destroy(){this.#i||(this.#d(),this.getTarget().classList.remove(this.#t),this.#i=!0)}};window.TinyDragDropDetector=t.TinyDragDropDetector})();
|