tiny-essentials 1.20.3 → 1.21.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.
Files changed (126) hide show
  1. package/README.md +13 -11
  2. package/dist/_/numbers.cjs +136 -0
  3. package/dist/_/numbers.d.mts +24 -0
  4. package/dist/_/numbers.mjs +102 -0
  5. package/dist/v1/TinyAdvancedRaffle.min.js +1 -0
  6. package/dist/v1/TinyArrayPaginator.min.js +1 -0
  7. package/dist/v1/TinyBasicsEs.min.js +1 -1
  8. package/dist/v1/TinyCookieConsent.min.js +1 -0
  9. package/dist/v1/TinyDayNightCycle.min.js +1 -0
  10. package/dist/v1/TinyEssentials.min.js +1 -1
  11. package/dist/v1/TinyGamepad.min.js +1 -0
  12. package/dist/v1/TinyI18.min.js +1 -0
  13. package/dist/v1/TinyInventory.min.js +1 -0
  14. package/dist/v1/TinyInventoryTrader.min.js +1 -0
  15. package/dist/v1/TinyLocalStorage.min.js +1 -1
  16. package/dist/v1/TinyNeedBar.min.js +1 -0
  17. package/dist/v1/TinyRateLimiter.min.js +1 -1
  18. package/dist/v1/TinySmartScroller.min.js +1 -1
  19. package/dist/v1/TinyToastNotify.min.js +1 -1
  20. package/dist/v1/TinyUploadClicker.min.js +1 -1
  21. package/dist/v1/basics/array.cjs +21 -0
  22. package/dist/v1/basics/array.d.mts +8 -0
  23. package/dist/v1/basics/array.mjs +18 -0
  24. package/dist/v1/basics/clock.cjs +127 -11
  25. package/dist/v1/basics/clock.d.mts +26 -0
  26. package/dist/v1/basics/clock.mjs +96 -1
  27. package/dist/v1/basics/index.cjs +2 -8
  28. package/dist/v1/basics/index.d.mts +3 -8
  29. package/dist/v1/basics/index.mjs +2 -3
  30. package/dist/v1/basics/simpleMath.cjs +46 -0
  31. package/dist/v1/basics/simpleMath.d.mts +27 -0
  32. package/dist/v1/basics/simpleMath.mjs +42 -0
  33. package/dist/v1/build/TinyAdvancedRaffle.cjs +7 -0
  34. package/dist/v1/build/TinyAdvancedRaffle.d.mts +3 -0
  35. package/dist/v1/build/TinyAdvancedRaffle.mjs +2 -0
  36. package/dist/v1/build/TinyArrayPaginator.cjs +7 -0
  37. package/dist/v1/build/TinyArrayPaginator.d.mts +3 -0
  38. package/dist/v1/build/TinyArrayPaginator.mjs +2 -0
  39. package/dist/v1/build/TinyCookieConsent.cjs +7 -0
  40. package/dist/v1/build/TinyCookieConsent.d.mts +3 -0
  41. package/dist/v1/build/TinyCookieConsent.mjs +2 -0
  42. package/dist/v1/build/TinyDayNightCycle.cjs +7 -0
  43. package/dist/v1/build/TinyDayNightCycle.d.mts +3 -0
  44. package/dist/v1/build/TinyDayNightCycle.mjs +2 -0
  45. package/dist/v1/build/TinyGamepad.cjs +7 -0
  46. package/dist/v1/build/TinyGamepad.d.mts +3 -0
  47. package/dist/v1/build/TinyGamepad.mjs +2 -0
  48. package/dist/v1/build/TinyI18.cjs +7 -0
  49. package/dist/v1/build/TinyI18.d.mts +3 -0
  50. package/dist/v1/build/TinyI18.mjs +2 -0
  51. package/dist/v1/build/TinyInventory.cjs +7 -0
  52. package/dist/v1/build/TinyInventory.d.mts +3 -0
  53. package/dist/v1/build/TinyInventory.mjs +2 -0
  54. package/dist/v1/build/TinyInventoryTrader.cjs +7 -0
  55. package/dist/v1/build/TinyInventoryTrader.d.mts +3 -0
  56. package/dist/v1/build/TinyInventoryTrader.mjs +2 -0
  57. package/dist/v1/build/TinyNeedBar.cjs +7 -0
  58. package/dist/v1/build/TinyNeedBar.d.mts +3 -0
  59. package/dist/v1/build/TinyNeedBar.mjs +2 -0
  60. package/dist/v1/css/TinyCookieConsent.min.css +1 -0
  61. package/dist/v1/index.cjs +20 -8
  62. package/dist/v1/index.d.mts +12 -8
  63. package/dist/v1/index.mjs +11 -3
  64. package/dist/v1/libs/TinyAdvancedRaffle.cjs +1654 -0
  65. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +851 -0
  66. package/dist/v1/libs/TinyAdvancedRaffle.mjs +1477 -0
  67. package/dist/v1/libs/TinyArrayPaginator.cjs +132 -0
  68. package/dist/v1/libs/TinyArrayPaginator.d.mts +78 -0
  69. package/dist/v1/libs/TinyArrayPaginator.mjs +119 -0
  70. package/dist/v1/libs/TinyCookieConsent.cjs +278 -0
  71. package/dist/v1/libs/TinyCookieConsent.d.mts +142 -0
  72. package/dist/v1/libs/TinyCookieConsent.mjs +248 -0
  73. package/dist/v1/libs/TinyDayNightCycle.cjs +1389 -0
  74. package/dist/v1/libs/TinyDayNightCycle.d.mts +673 -0
  75. package/dist/v1/libs/TinyDayNightCycle.mjs +1232 -0
  76. package/dist/v1/libs/TinyGamepad.cjs +2690 -0
  77. package/dist/v1/libs/TinyGamepad.d.mts +1286 -0
  78. package/dist/v1/libs/TinyGamepad.mjs +2386 -0
  79. package/dist/v1/libs/TinyHtml.d.mts +2 -2
  80. package/dist/v1/libs/TinyI18.cjs +946 -0
  81. package/dist/v1/libs/TinyI18.d.mts +418 -0
  82. package/dist/v1/libs/TinyI18.mjs +873 -0
  83. package/dist/v1/libs/TinyInventory.cjs +1788 -0
  84. package/dist/v1/libs/TinyInventory.d.mts +871 -0
  85. package/dist/v1/libs/TinyInventory.mjs +1650 -0
  86. package/dist/v1/libs/TinyInventoryTrader.cjs +242 -0
  87. package/dist/v1/libs/TinyInventoryTrader.d.mts +95 -0
  88. package/dist/v1/libs/TinyInventoryTrader.mjs +212 -0
  89. package/dist/v1/libs/TinyLocalStorage.cjs +14 -1
  90. package/dist/v1/libs/TinyLocalStorage.mjs +8 -1
  91. package/dist/v1/libs/TinyNeedBar.cjs +272 -0
  92. package/dist/v1/libs/TinyNeedBar.d.mts +223 -0
  93. package/dist/v1/libs/TinyNeedBar.mjs +241 -0
  94. package/dist/v1/libs/TinyRateLimiter.cjs +0 -13
  95. package/dist/v1/libs/TinyRateLimiter.d.mts +0 -8
  96. package/dist/v1/libs/TinyRateLimiter.mjs +0 -12
  97. package/dist/v1/libs/TinySmartScroller.cjs +0 -51
  98. package/dist/v1/libs/TinySmartScroller.d.mts +0 -36
  99. package/dist/v1/libs/TinySmartScroller.mjs +0 -46
  100. package/dist/v1/libs/TinyToastNotify.cjs +2 -2
  101. package/dist/v1/libs/TinyToastNotify.mjs +2 -2
  102. package/dist/v1/libs/TinyUploadClicker.cjs +1 -1
  103. package/docs/v1/Ai-Tips.md +51 -0
  104. package/docs/v1/Personal-Ai-Prompts(portuguese).md +134 -0
  105. package/docs/v1/Personal-Ai-Prompts.md +113 -0
  106. package/docs/v1/README.md +24 -0
  107. package/docs/v1/basics/array.md +17 -0
  108. package/docs/v1/basics/clock.md +51 -11
  109. package/docs/v1/basics/simpleMath.md +73 -0
  110. package/docs/v1/libs/TinyAdvancedRaffle.md +674 -0
  111. package/docs/v1/libs/TinyArrayPaginator.md +150 -0
  112. package/docs/v1/libs/TinyCookieConsent.md +152 -0
  113. package/docs/v1/libs/TinyDayNightCycle.md +711 -0
  114. package/docs/v1/libs/TinyGamepad.md +980 -0
  115. package/docs/v1/libs/TinyI18.md +515 -0
  116. package/docs/v1/libs/TinyInventory.md +777 -0
  117. package/docs/v1/libs/TinyInventoryTrader.md +114 -0
  118. package/docs/v1/libs/TinyNeedBar.md +226 -0
  119. package/package.json +7 -5
  120. package/dist/v1/basics/html_deprecated.cjs +0 -124
  121. package/dist/v1/basics/html_deprecated.d.mts +0 -40
  122. package/dist/v1/basics/html_deprecated.mjs +0 -97
  123. package/dist/v1/css/TinyDraggerExample.css +0 -21
  124. package/dist/v1/css/TinyNotify.css +0 -350
  125. package/dist/v1/css/aiMarker.css +0 -4
  126. package/docs/v1/basics/html_deprecated.md +0 -127
package/README.md CHANGED
@@ -37,17 +37,6 @@ npm install tiny-essentials
37
37
 
38
38
  Or download the scripts directly from this repository.
39
39
 
40
- ## 🗃️ Legacy Code
41
-
42
- Some scripts in this repository have been preserved for backwards compatibility. These include modules like:
43
-
44
- - `@tinypudding/firebase-lib`
45
- - `@tinypudding/discord-oauth2`
46
- - `@tinypudding/mysql-connector`
47
- - `@tinypudding/puddy-lib`
48
-
49
- These modules have been updated to work with modern environments but may not be actively developed further.
50
-
51
40
  ## 🧪 Module Versions
52
41
 
53
42
  The core version of Tiny Essentials (version 1) is located in the folder [`/src/v1`](./src/v1).
@@ -83,6 +72,19 @@ Although not part of Tiny Essentials, we recommend using [**JsStore**](https://w
83
72
 
84
73
  ---
85
74
 
75
+ ## 🗃️ Legacy Code
76
+
77
+ Some scripts in this repository have been preserved for backwards compatibility. These include modules like:
78
+
79
+ - `@tinypudding/firebase-lib`
80
+ - `@tinypudding/discord-oauth2`
81
+ - `@tinypudding/mysql-connector`
82
+ - `@tinypudding/puddy-lib`
83
+
84
+ These modules have been updated to work with modern environments but may not be actively developed further.
85
+
86
+ ---
87
+
86
88
  ## 🤝 Contributions
87
89
 
88
90
  Feel free to fork, contribute, and create pull requests for improvements! Whether it's a bug fix or an additional feature, contributions are always welcome.
@@ -0,0 +1,136 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Always returns 3 by summing the number three times and dividing once.
5
+ * Mathematically: (n + n + n) / n = 3
6
+ *
7
+ * @param {number} n - Any non-zero number.
8
+ * @returns {number} The constant value 3.
9
+ */
10
+ function getTripleRatio(n) {
11
+ const sum = n + n + n;
12
+ const result = sum / n;
13
+ return result;
14
+ }
15
+
16
+ /**
17
+ * Sums the number 3 times and divides by itself.
18
+ * @param {number} n
19
+ * @returns {number} Always 3
20
+ */
21
+ const tripleSumOverSelf = (n) => (n + n + n) / n;
22
+
23
+ /**
24
+ * Multiplies the number by 5 and divides by itself.
25
+ * @param {number} n
26
+ * @returns {number} Always 5
27
+ */
28
+ const fiveTimesOverSelf = (n) => (5 * n) / n;
29
+
30
+ /**
31
+ * Performs linear operations that simplify to 3n/n.
32
+ * @param {number} n
33
+ * @returns {number} Always 3
34
+ */
35
+ const mixedMultipliersToThree = (n) => (n * 7 - n * 4) / n;
36
+
37
+ /**
38
+ * Squares the number and divides by itself.
39
+ * @param {number} n
40
+ * @returns {number} Same as input n
41
+ */
42
+ const squareOverSelf = (n) => (n * n) / n;
43
+
44
+ /**
45
+ * A long expression that simplifies to 3n / n.
46
+ * @param {number} n
47
+ * @returns {number} Always 3
48
+ */
49
+ const complexToThree = (n) => (10 * n - 7 * n + 6 * n - 6 * n) / n;
50
+
51
+ /**
52
+ * Sums weighted values and divides by sum of weights.
53
+ * @param {number} n
54
+ * @returns {number} Always 3
55
+ */
56
+ const weightedAverageToThree = (n) => (2 * n + 4 * n) / (n + n);
57
+
58
+ /**
59
+ * Simplifies to 3 regardless of n.
60
+ * @param {number} n
61
+ * @returns {number} Always 3
62
+ */
63
+ const nestedMultiplicationToThree = (n) => (3 * (2 * n)) / (2 * n);
64
+
65
+ /**
66
+ * Adds three self-divisions.
67
+ * @param {number} n
68
+ * @returns {number} Always 3
69
+ */
70
+ const repeatedDivisionSum = (n) => n / n + n / n + n / n;
71
+
72
+ /**
73
+ * Simplifies exponential division.
74
+ * @param {number} n
75
+ * @returns {number} Same as input n
76
+ */
77
+ const cubicOverSquare = (n) => n ** 3 / n ** 2;
78
+
79
+ /**
80
+ * Multiplies and then uses modulus.
81
+ * @param {number} n
82
+ * @returns {number} Always 0
83
+ */
84
+ const multipleModSelf = (n) => (n * 3) % n;
85
+
86
+ /**
87
+ * Expression that simplifies and divides by 1.
88
+ * @param {number} n
89
+ * @returns {number} Always 3
90
+ */
91
+ const divideByOne = (n) => (3 * n) / n / 1;
92
+
93
+ /**
94
+ * Absolute value divided by itself.
95
+ * @param {number} n
96
+ * @returns {number} 1 if n > 0, -1 if n < 0, NaN if n = 0
97
+ */
98
+ const absRatio = (n) => Math.abs(n) / n;
99
+
100
+ /**
101
+ * Returns minimum between fixed set and input.
102
+ * @param {number} n
103
+ * @returns {number} Always 3 if n ≥ 3
104
+ */
105
+ const minClampToThree = (n) => Math.min(3, 5, 7, n);
106
+
107
+ /**
108
+ * Complex sum that simplifies to 1.
109
+ * @param {number} n
110
+ * @returns {number} Always 1
111
+ */
112
+ const balancedReductionToOne = (n) => (3 * n - 2 * n + 6 * n - 6 * n) / n;
113
+
114
+ /**
115
+ * Weighted sum of multipliers simplifying to 3.
116
+ * @param {number} n
117
+ * @returns {number} Always 3
118
+ */
119
+ const alternateSumToThree = (n) => (4 * n + 2 * n - 3 * n) / n;
120
+
121
+ exports.absRatio = absRatio;
122
+ exports.alternateSumToThree = alternateSumToThree;
123
+ exports.balancedReductionToOne = balancedReductionToOne;
124
+ exports.complexToThree = complexToThree;
125
+ exports.cubicOverSquare = cubicOverSquare;
126
+ exports.divideByOne = divideByOne;
127
+ exports.fiveTimesOverSelf = fiveTimesOverSelf;
128
+ exports.getTripleRatio = getTripleRatio;
129
+ exports.minClampToThree = minClampToThree;
130
+ exports.mixedMultipliersToThree = mixedMultipliersToThree;
131
+ exports.multipleModSelf = multipleModSelf;
132
+ exports.nestedMultiplicationToThree = nestedMultiplicationToThree;
133
+ exports.repeatedDivisionSum = repeatedDivisionSum;
134
+ exports.squareOverSelf = squareOverSelf;
135
+ exports.tripleSumOverSelf = tripleSumOverSelf;
136
+ exports.weightedAverageToThree = weightedAverageToThree;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Always returns 3 by summing the number three times and dividing once.
3
+ * Mathematically: (n + n + n) / n = 3
4
+ *
5
+ * @param {number} n - Any non-zero number.
6
+ * @returns {number} The constant value 3.
7
+ */
8
+ export function getTripleRatio(n: number): number;
9
+ export function tripleSumOverSelf(n: number): number;
10
+ export function fiveTimesOverSelf(n: number): number;
11
+ export function mixedMultipliersToThree(n: number): number;
12
+ export function squareOverSelf(n: number): number;
13
+ export function complexToThree(n: number): number;
14
+ export function weightedAverageToThree(n: number): number;
15
+ export function nestedMultiplicationToThree(n: number): number;
16
+ export function repeatedDivisionSum(n: number): number;
17
+ export function cubicOverSquare(n: number): number;
18
+ export function multipleModSelf(n: number): number;
19
+ export function divideByOne(n: number): number;
20
+ export function absRatio(n: number): number;
21
+ export function minClampToThree(n: number): number;
22
+ export function balancedReductionToOne(n: number): number;
23
+ export function alternateSumToThree(n: number): number;
24
+ //# sourceMappingURL=numbers.d.mts.map
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Always returns 3 by summing the number three times and dividing once.
3
+ * Mathematically: (n + n + n) / n = 3
4
+ *
5
+ * @param {number} n - Any non-zero number.
6
+ * @returns {number} The constant value 3.
7
+ */
8
+ export function getTripleRatio(n) {
9
+ const sum = n + n + n;
10
+ const result = sum / n;
11
+ return result;
12
+ }
13
+ /**
14
+ * Sums the number 3 times and divides by itself.
15
+ * @param {number} n
16
+ * @returns {number} Always 3
17
+ */
18
+ export const tripleSumOverSelf = (n) => (n + n + n) / n;
19
+ /**
20
+ * Multiplies the number by 5 and divides by itself.
21
+ * @param {number} n
22
+ * @returns {number} Always 5
23
+ */
24
+ export const fiveTimesOverSelf = (n) => (5 * n) / n;
25
+ /**
26
+ * Performs linear operations that simplify to 3n/n.
27
+ * @param {number} n
28
+ * @returns {number} Always 3
29
+ */
30
+ export const mixedMultipliersToThree = (n) => (n * 7 - n * 4) / n;
31
+ /**
32
+ * Squares the number and divides by itself.
33
+ * @param {number} n
34
+ * @returns {number} Same as input n
35
+ */
36
+ export const squareOverSelf = (n) => (n * n) / n;
37
+ /**
38
+ * A long expression that simplifies to 3n / n.
39
+ * @param {number} n
40
+ * @returns {number} Always 3
41
+ */
42
+ export const complexToThree = (n) => (10 * n - 7 * n + 6 * n - 6 * n) / n;
43
+ /**
44
+ * Sums weighted values and divides by sum of weights.
45
+ * @param {number} n
46
+ * @returns {number} Always 3
47
+ */
48
+ export const weightedAverageToThree = (n) => (2 * n + 4 * n) / (n + n);
49
+ /**
50
+ * Simplifies to 3 regardless of n.
51
+ * @param {number} n
52
+ * @returns {number} Always 3
53
+ */
54
+ export const nestedMultiplicationToThree = (n) => (3 * (2 * n)) / (2 * n);
55
+ /**
56
+ * Adds three self-divisions.
57
+ * @param {number} n
58
+ * @returns {number} Always 3
59
+ */
60
+ export const repeatedDivisionSum = (n) => n / n + n / n + n / n;
61
+ /**
62
+ * Simplifies exponential division.
63
+ * @param {number} n
64
+ * @returns {number} Same as input n
65
+ */
66
+ export const cubicOverSquare = (n) => n ** 3 / n ** 2;
67
+ /**
68
+ * Multiplies and then uses modulus.
69
+ * @param {number} n
70
+ * @returns {number} Always 0
71
+ */
72
+ export const multipleModSelf = (n) => (n * 3) % n;
73
+ /**
74
+ * Expression that simplifies and divides by 1.
75
+ * @param {number} n
76
+ * @returns {number} Always 3
77
+ */
78
+ export const divideByOne = (n) => (3 * n) / n / 1;
79
+ /**
80
+ * Absolute value divided by itself.
81
+ * @param {number} n
82
+ * @returns {number} 1 if n > 0, -1 if n < 0, NaN if n = 0
83
+ */
84
+ export const absRatio = (n) => Math.abs(n) / n;
85
+ /**
86
+ * Returns minimum between fixed set and input.
87
+ * @param {number} n
88
+ * @returns {number} Always 3 if n ≥ 3
89
+ */
90
+ export const minClampToThree = (n) => Math.min(3, 5, 7, n);
91
+ /**
92
+ * Complex sum that simplifies to 1.
93
+ * @param {number} n
94
+ * @returns {number} Always 1
95
+ */
96
+ export const balancedReductionToOne = (n) => (3 * n - 2 * n + 6 * n - 6 * n) / n;
97
+ /**
98
+ * Weighted sum of multipliers simplifying to 3.
99
+ * @param {number} n
100
+ * @returns {number} Always 3
101
+ */
102
+ export const alternateSumToThree = (n) => (4 * n + 2 * n - 3 * n) / n;
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={d:(t,r)=>{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)},t={};e.d(t,{TinyAdvancedRaffle:()=>i});const r=class{#e=new Map;#t=10;#r=!1;setThrowOnMaxListeners(e){if("boolean"!=typeof e)throw new TypeError("setThrowOnMaxListeners(value): value must be a boolean");this.#r=e}getThrowOnMaxListeners(){return this.#r}#s(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){if("string"!=typeof e)throw new TypeError("prepend(event, handler): event name must be a string");if("function"!=typeof t)throw new TypeError("prepend(event, handler): handler must be a function");this.#s(e,t)}prependListenerOnce(e,t){if("string"!=typeof e)throw new TypeError("prependOnceListener(event, handler): event name must be a string");if("function"!=typeof t)throw new TypeError("prependOnceListener(event, handler): handler must be a function");const r=(...s)=>{this.off(e,r),t(...s)};return this.#s(e,r,{once:!0}),r}#i(e,t,{once:r=!1}={}){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("string"!=typeof e)throw new TypeError("on(event, handler): event name must be a string");if("function"!=typeof t)throw new TypeError("on(event, handler): handler must be a function");return this.#i(e,t)}once(e,t){if("string"!=typeof e)throw new TypeError("The event name must be a string.");if("function"!=typeof t)throw new TypeError("once(event, handler): handler must be a function");const r=s=>{this.off(e,r),"function"==typeof t&&t(s)};return this.#i(e,r,{once:!0}),r}appendListener(e,t){return this.on(e,t)}appendListenerOnce(e,t){return this.once(e,t)}off(e,t){if("string"!=typeof e)throw new TypeError("off(event, handler): event name must be a string");if("function"!=typeof t)throw new TypeError("off(event, handler): handler must be a function");const r=this.#e.get(e);if(!Array.isArray(r))return;const s=r.findIndex(e=>e.handler===t);-1!==s&&r.splice(s,1),0===r.length&&this.#e.delete(e)}offAll(e){if("string"!=typeof e)throw new TypeError("The event name must be a string.");this.#e.delete(e)}offAllTypes(){this.#e.clear()}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){if("string"!=typeof e)throw new TypeError("emit(event, data): event name must be a string");const r=this.#e.get(e);return!(!Array.isArray(r)||0===r.length||(r.forEach(e=>e.handler(...t)),0))}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{#n=new r;#o(e,...t){return this.#n.emit(e,...t)}setThrowOnMaxListeners(e){return this.#n.setThrowOnMaxListeners(e)}getThrowOnMaxListeners(){return this.#n.getThrowOnMaxListeners()}prependListener(e,t){return this.#n.prependListener(e,t)}prependListenerOnce(e,t){return this.#n.prependListenerOnce(e,t)}appendListener(e,t){return this.#n.appendListener(e,t)}appendListenerOnce(e,t){return this.#n.appendListenerOnce(e,t)}on(e,t){return this.#n.on(e,t)}once(e,t){return this.#n.once(e,t)}off(e,t){return this.#n.off(e,t)}offAll(e){return this.#n.offAll(e)}offAllTypes(){return this.#n.offAllTypes()}listenerCount(e){return this.#n.listenerCount(e)}listeners(e){return this.#n.listeners(e)}onceListeners(e){return this.#n.onceListeners(e)}allListeners(e){return this.#n.allListeners(e)}eventNames(){return this.#n.eventNames()}setMaxListeners(e){return this.#n.setMaxListeners(e)}getMaxListeners(){return this.#n.getMaxListeners()}#a=!1;#h;#u;#f=[];#p=[];#m=[];#y=new Map;#d=new Set;#c=new Map;#l;#w=new Map;#g=new Map;get isDestroyed(){return this.#a}get freq(){return Object.fromEntries(this.#g)}get size(){return this.#w.size}get normalization(){return this.#h}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.#h=e}get seed(){return this.#u}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.#u=e,null!==e&&(this.#l=this._makeSeededRng(e))}get globalModifiers(){return[...this.#f]}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.#f=e}get temporaryModifiers(){return[...this.#p]}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.#p=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.#y)}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.#y=e}get exclusions(){return Array.from(this.#d)}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.#d=e}get groups(){const e={};return this.#c.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.#c=e}get rng(){return this.#l}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.#l=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.#h=s,this.#u=r,"function"==typeof t?this.#l=t:null!==this.#u?this.#l=this._makeSeededRng(this.#u):this.#l=Math.random,this.#u=r??null}_checkDestroyed(){if(this.#a)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.#o("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.#c.get(r);t&&t.delete(e)}return this.#w.delete(e),this.#o("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.#o("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.#f.includes(e)}addGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#f.push(e)}removeGlobalModifier(e){if(this._checkDestroyed(),"function"!=typeof e)throw new TypeError("fn must be a function");this.#f=this.#f.filter(t=>t!==e)}hasTemporaryModifier(e){if("function"!=typeof e)throw new TypeError("fn must be a function");return this.#p.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.#p.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.#p.length;return this.#p=this.#p.filter(t=>t.fn!==e),this.#p.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.#y.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.#y.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.#y.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){this._checkDestroyed(),this.#y.clear()}hasExclusion(e){if("string"!=typeof e)throw new TypeError("itemId must be a string");return this.#d.has(e)}excludeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#d.add(e)}includeItem(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#d.delete(e)}_ensureGroup(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("name must be a string");let t=this.#c.get(e);return t||(t=new Set,this.#c.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.#c.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.#c.get(t);r&&r.delete(e);const s=this.#w.get(e);s&&s.groups.delete(t)}clearFreqs(){this._checkDestroyed(),this.#g.clear()}resetFreq(e){if(this._checkDestroyed(),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#g.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.#f){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.#p){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.#y)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.#d)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.#h){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.#p]},r=this.computeEffectiveWeights(t),s=this._weightsToDistribution(r);if(!s.length)return null;const i=this.#l(),n=s.find(e=>i<=e.cumulative)??s[s.length-1];for(const[e,t]of this.#y)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.#o("draw",a),a&&this.#g.set(a.id,(this.#g.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){this._checkDestroyed();for(let e=this.#p.length-1;e>=0;--e){const t=this.#p[e];t.uses-=1,t.uses<=0&&this.#p.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.#d);for(const e of r)this.#d.add(e);const s=this.drawOne({previousDraws:n,metadata:t.metadata});if(this.#d=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.#y.entries()),exclusions:Array.from(this.#d),normalization:this.#h,seed:this.#u}}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.#h=this.#h,e.#u=this.#u,e.#f=[...this.#f],e.#p=this.#p.map(e=>({fn:e.fn,uses:e.uses})),e.#m=[...this.#m],e.#y=new Map([...this.#y.entries()].map(([e,t])=>[e,{...t}])),e.#d=new Set(this.#d),e.#c=new Map([...this.#c.entries()].map(([e,t])=>[e,new Set(t)])),e.#l=this.#l,e.#w=new Map([...this.#w.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#g=new Map(this.#g),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.#a||(this.#a=!0,this.#y.clear(),this.#d.clear(),this.#c.clear(),this.#w.clear(),this.#g.clear(),this.#f=[],this.#p=[],this.#m=[],this.#u=null)}}const i=s;window.TinyAdvancedRaffle=t.TinyAdvancedRaffle})();
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var t={d:(e,r)=>{for(var a in r)t.o(r,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:r[a]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{TinyArrayPaginator:()=>r});const r=class{#t;get data(){return this.#t}set data(t){if(!(Array.isArray(t)||t instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#t=t}get size(){return Array.isArray(this.#t)?this.#t.length:this.#t.size}constructor(t){if(!(Array.isArray(t)||t instanceof Set))throw new TypeError("Paginator expects an array or Set as data source.");this.#t=t}get({page:t,perPage:e,filter:r}){if(!Number.isInteger(t)||t<1)throw new RangeError("Page number must be a positive integer.");if(!Number.isInteger(e)||e<1)throw new RangeError("Items per page must be a positive integer.");const a=Array.isArray(this.#t)?this.#t:Array.from(this.#t);let i=a;if(r)if("function"==typeof r)i=a.filter((t,e,a)=>r(t,e,a));else{if("object"!=typeof r)throw new TypeError("Filter must be an object or a function");i=a.filter(t=>Object.entries(r).every(([e,r])=>{const a=t[e];return r instanceof RegExp?r.test(a):a===r}))}else i=a;const s=i.length,n=Math.max(1,Math.ceil(s/e)),o=Math.min(t,n),y=(o-1)*e,c=y+e,g=o>1,h=o<n;return{items:i.slice(y,c),page:o,perPage:e,totalItems:s,totalPages:n,hasPrev:g,hasNext:h}}};window.TinyArrayPaginator=e.TinyArrayPaginator})();