tiny-essentials 1.28.19 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (555) hide show
  1. package/README.md +1 -1
  2. package/changelog/1/28/19.md +24 -0
  3. package/changelog/1/29/0.md +58 -0
  4. package/dist/v1/ColorSafeStringify.min.js +1 -1
  5. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  6. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  7. package/dist/v1/TinyAnalogClock.min.js +1 -1
  8. package/dist/v1/TinyArrayComparator.min.js +1 -1
  9. package/dist/v1/TinyArrayPaginator.min.js +1 -1
  10. package/dist/v1/TinyBasicsEs.min.js +1 -1
  11. package/dist/v1/TinyBrowserMonitor.min.js +1 -0
  12. package/dist/v1/TinyClassManager.min.js +1 -1
  13. package/dist/v1/TinyClipboard.min.js +1 -1
  14. package/dist/v1/TinyCloner.min.js +1 -0
  15. package/dist/v1/TinyColorConverter.min.js +1 -1
  16. package/dist/v1/TinyColorValidator.min.js +1 -1
  17. package/dist/v1/TinyCookieConsent.min.js +1 -1
  18. package/dist/v1/TinyDayNightCycle.min.js +1 -1
  19. package/dist/v1/TinyDebugger.min.js +1 -1
  20. package/dist/v1/TinyDomReadyManager.min.js +1 -1
  21. package/dist/v1/TinyDragDropDetector.min.js +1 -1
  22. package/dist/v1/TinyDragger.min.js +1 -1
  23. package/dist/v1/TinyElementObserver.min.js +1 -1
  24. package/dist/v1/TinyEssentials.min.js +1 -1
  25. package/dist/v1/TinyGamepad.min.js +1 -1
  26. package/dist/v1/TinyHtml.min.js +1 -1
  27. package/dist/v1/TinyHtmlTagRegexBuilder.min.js +1 -0
  28. package/dist/v1/TinyHttpResponseRegistry.min.js +1 -0
  29. package/dist/v1/TinyI18.min.js +1 -1
  30. package/dist/v1/TinyIframeEvents.min.js +1 -1
  31. package/dist/v1/TinyInventory.min.js +1 -1
  32. package/dist/v1/TinyInventoryTrader.min.js +1 -1
  33. package/dist/v1/TinyLevelUp.min.js +1 -1
  34. package/dist/v1/TinyLoadingScreen.min.js +1 -1
  35. package/dist/v1/TinyLocalStorage.min.js +1 -1
  36. package/dist/v1/TinyMaInSys.min.js +1 -1
  37. package/dist/v1/TinyMapCache.min.js +1 -0
  38. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  39. package/dist/v1/TinyNeedBar.min.js +1 -1
  40. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  41. package/dist/v1/TinyNotificationAdapter.min.js +1 -0
  42. package/dist/v1/TinyNotifications.min.js +1 -1
  43. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  44. package/dist/v1/TinyOPFSFileSystem.min.js +1 -0
  45. package/dist/v1/TinyPasswordValidator.min.js +1 -0
  46. package/dist/v1/TinyPluginPackage.min.js +1 -0
  47. package/dist/v1/TinyPromiseQueue.min.js +1 -1
  48. package/dist/v1/TinyPushManager.min.js +1 -0
  49. package/dist/v1/TinyPushPayload.min.js +1 -0
  50. package/dist/v1/TinyPushRouter.min.js +1 -0
  51. package/dist/v1/TinyRadioFm.min.js +1 -1
  52. package/dist/v1/TinyRateLimiter.min.js +1 -1
  53. package/dist/v1/TinyRegexEs.min.js +1 -0
  54. package/dist/v1/TinyRouter.min.js +1 -0
  55. package/dist/v1/TinyServiceWorker.min.js +1 -0
  56. package/dist/v1/TinyServiceWorkerEngine.min.js +1 -0
  57. package/dist/v1/TinySetMapPackage.min.js +1 -0
  58. package/dist/v1/TinySimpleDice.min.js +1 -1
  59. package/dist/v1/TinySmartScroller.min.js +1 -1
  60. package/dist/v1/TinyStorageBucketFileSystem.min.js +1 -0
  61. package/dist/v1/TinyTextDiffer.min.js +1 -1
  62. package/dist/v1/TinyTextRangeEditor.min.js +1 -1
  63. package/dist/v1/TinyTextarea.min.js +1 -1
  64. package/dist/v1/TinyThrottledApi.min.js +1 -0
  65. package/dist/v1/TinyTimeout.min.js +1 -1
  66. package/dist/v1/TinyToastNotify.min.js +1 -1
  67. package/dist/v1/TinyUploadClicker.min.js +1 -1
  68. package/dist/v1/TinyUriParser.min.js +1 -0
  69. package/dist/v1/TinyVersion.min.js +1 -0
  70. package/dist/v1/TinyWebWorker.min.js +1 -0
  71. package/dist/v1/TinyWebWorkerEngine.min.js +1 -0
  72. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  73. package/dist/v1/basics/array.cjs +2 -2
  74. package/dist/v1/basics/array.d.mts +2 -0
  75. package/dist/v1/basics/array.d.mts.map +1 -1
  76. package/dist/v1/basics/array.mjs +2 -1
  77. package/dist/v1/basics/browserDetector.cjs +37 -12
  78. package/dist/v1/basics/browserDetector.d.mts +8 -0
  79. package/dist/v1/basics/browserDetector.d.mts.map +1 -1
  80. package/dist/v1/basics/browserDetector.mjs +32 -13
  81. package/dist/v1/basics/crypto.cjs +23 -0
  82. package/dist/v1/basics/crypto.d.mts +10 -0
  83. package/dist/v1/basics/crypto.d.mts.map +1 -0
  84. package/dist/v1/basics/crypto.mjs +18 -0
  85. package/dist/v1/basics/html.cjs +0 -3
  86. package/dist/v1/basics/html.d.mts.map +1 -1
  87. package/dist/v1/basics/html.mjs +0 -2
  88. package/dist/v1/basics/index.cjs +8 -1
  89. package/dist/v1/basics/index.d.mts +6 -5
  90. package/dist/v1/basics/index.d.mts.map +1 -1
  91. package/dist/v1/basics/index.mjs +6 -5
  92. package/dist/v1/basics/objChecker.cjs +88 -0
  93. package/dist/v1/basics/objChecker.d.mts +26 -0
  94. package/dist/v1/basics/objChecker.d.mts.map +1 -1
  95. package/dist/v1/basics/objChecker.mjs +74 -0
  96. package/dist/v1/basics/objFilter.cjs +234 -93
  97. package/dist/v1/basics/objFilter.d.mts +96 -22
  98. package/dist/v1/basics/objFilter.d.mts.map +1 -1
  99. package/dist/v1/basics/objFilter.mjs +216 -92
  100. package/dist/v1/basics/promiseUtils.cjs +48 -12
  101. package/dist/v1/basics/promiseUtils.d.mts +45 -12
  102. package/dist/v1/basics/promiseUtils.d.mts.map +1 -1
  103. package/dist/v1/basics/promiseUtils.mjs +47 -12
  104. package/dist/v1/basics/text.cjs +0 -12
  105. package/dist/v1/basics/text.d.mts +0 -10
  106. package/dist/v1/basics/text.d.mts.map +1 -1
  107. package/dist/v1/basics/text.mjs +0 -10
  108. package/dist/v1/index.cjs +88 -3
  109. package/dist/v1/index.d.mts +31 -6
  110. package/dist/v1/index.d.mts.map +1 -1
  111. package/dist/v1/index.mjs +32 -7
  112. package/dist/v1/jsdoc/EventEmitter.cjs +4 -0
  113. package/dist/v1/jsdoc/EventEmitter.d.mts +33 -0
  114. package/dist/v1/jsdoc/EventEmitter.d.mts.map +1 -0
  115. package/dist/v1/jsdoc/EventEmitter.mjs +18 -0
  116. package/dist/v1/libs/array/TinyArrayComparator.cjs +240 -25
  117. package/dist/v1/libs/array/TinyArrayComparator.d.mts +130 -22
  118. package/dist/v1/libs/array/TinyArrayComparator.d.mts.map +1 -1
  119. package/dist/v1/libs/array/TinyArrayComparator.mjs +210 -24
  120. package/dist/v1/libs/fs/constants.cjs +74 -0
  121. package/dist/v1/libs/fs/constants.d.mts +22 -0
  122. package/dist/v1/libs/fs/constants.d.mts.map +1 -0
  123. package/dist/v1/libs/fs/constants.mjs +53 -0
  124. package/dist/v1/libs/fs/encoding.cjs +118 -0
  125. package/dist/v1/libs/fs/encoding.d.mts +50 -0
  126. package/dist/v1/libs/fs/encoding.d.mts.map +1 -0
  127. package/dist/v1/libs/fs/encoding.mjs +102 -0
  128. package/dist/v1/libs/fs/error.cjs +188 -0
  129. package/dist/v1/libs/fs/error.d.mts +105 -0
  130. package/dist/v1/libs/fs/error.d.mts.map +1 -0
  131. package/dist/v1/libs/fs/error.mjs +158 -0
  132. package/dist/v1/libs/fs/handle.cjs +121 -0
  133. package/dist/v1/libs/fs/handle.d.mts +56 -0
  134. package/dist/v1/libs/fs/handle.d.mts.map +1 -0
  135. package/dist/v1/libs/fs/handle.mjs +100 -0
  136. package/dist/v1/libs/fs/index.cjs +700 -0
  137. package/dist/v1/libs/fs/index.d.mts +377 -0
  138. package/dist/v1/libs/fs/index.d.mts.map +1 -0
  139. package/dist/v1/libs/fs/index.mjs +630 -0
  140. package/dist/v1/libs/fs/path.cjs +234 -0
  141. package/dist/v1/libs/fs/path.d.mts +176 -0
  142. package/dist/v1/libs/fs/path.d.mts.map +1 -0
  143. package/dist/v1/libs/fs/path.mjs +197 -0
  144. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.cjs +202 -0
  145. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.d.mts +121 -0
  146. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.d.mts.map +1 -0
  147. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.mjs +172 -0
  148. package/dist/v1/libs/fs/plugins/OPFS/index.cjs +334 -0
  149. package/dist/v1/libs/fs/plugins/OPFS/index.d.mts +98 -0
  150. package/dist/v1/libs/fs/plugins/OPFS/index.d.mts.map +1 -0
  151. package/dist/v1/libs/fs/plugins/OPFS/index.mjs +300 -0
  152. package/dist/v1/libs/fs/stats.cjs +245 -0
  153. package/dist/v1/libs/fs/stats.d.mts +226 -0
  154. package/dist/v1/libs/fs/stats.d.mts.map +1 -0
  155. package/dist/v1/libs/fs/stats.mjs +197 -0
  156. package/dist/v1/libs/html/events/TinyIframeEvents.cjs +10 -1
  157. package/dist/v1/libs/html/events/TinyIframeEvents.d.mts +9 -2
  158. package/dist/v1/libs/html/events/TinyIframeEvents.d.mts.map +1 -1
  159. package/dist/v1/libs/html/events/TinyIframeEvents.mjs +8 -1
  160. package/dist/v1/libs/html/events/TinyNewWinEvents.cjs +14 -3
  161. package/dist/v1/libs/html/events/TinyNewWinEvents.d.mts +21 -5
  162. package/dist/v1/libs/html/events/TinyNewWinEvents.d.mts.map +1 -1
  163. package/dist/v1/libs/html/events/TinyNewWinEvents.mjs +12 -3
  164. package/dist/v1/libs/html/scroll/TinySmartScroller.cjs +13 -1
  165. package/dist/v1/libs/html/scroll/TinySmartScroller.d.mts +29 -2
  166. package/dist/v1/libs/html/scroll/TinySmartScroller.d.mts.map +1 -1
  167. package/dist/v1/libs/html/scroll/TinySmartScroller.mjs +11 -1
  168. package/dist/v1/libs/math/TinyAdvancedRaffle.cjs +13 -1
  169. package/dist/v1/libs/math/TinyAdvancedRaffle.d.mts +32 -2
  170. package/dist/v1/libs/math/TinyAdvancedRaffle.d.mts.map +1 -1
  171. package/dist/v1/libs/math/TinyAdvancedRaffle.mjs +11 -1
  172. package/dist/v1/libs/math/TinyTimeout.cjs +0 -14
  173. package/dist/v1/libs/math/TinyTimeout.d.mts +0 -11
  174. package/dist/v1/libs/math/TinyTimeout.d.mts.map +1 -1
  175. package/dist/v1/libs/math/TinyTimeout.mjs +0 -13
  176. package/dist/v1/libs/media/TinyMediaPlayer/index.cjs +25 -1
  177. package/dist/v1/libs/media/TinyMediaPlayer/index.d.mts +35 -2
  178. package/dist/v1/libs/media/TinyMediaPlayer/index.d.mts.map +1 -1
  179. package/dist/v1/libs/media/TinyMediaPlayer/index.mjs +23 -1
  180. package/dist/v1/libs/media/TinyMediaPlayer.cjs +2 -2
  181. package/dist/v1/libs/media/TinyMediaPlayer.d.mts +2 -2
  182. package/dist/v1/libs/media/TinyMediaPlayer.d.mts.map +1 -1
  183. package/dist/v1/libs/media/TinyMediaPlayer.mjs +2 -2
  184. package/dist/v1/libs/media/TinyRadioFm.cjs +19 -1
  185. package/dist/v1/libs/media/TinyRadioFm.d.mts +78 -2
  186. package/dist/v1/libs/media/TinyRadioFm.d.mts.map +1 -1
  187. package/dist/v1/libs/media/TinyRadioFm.mjs +17 -1
  188. package/dist/v1/libs/plugin/TinyPlugin.cjs +1630 -0
  189. package/dist/v1/libs/plugin/TinyPlugin.d.mts +753 -0
  190. package/dist/v1/libs/plugin/TinyPlugin.d.mts.map +1 -0
  191. package/dist/v1/libs/plugin/TinyPlugin.mjs +1376 -0
  192. package/dist/v1/libs/plugin/TinyVersion.cjs +204 -0
  193. package/dist/v1/libs/plugin/TinyVersion.d.mts +70 -0
  194. package/dist/v1/libs/plugin/TinyVersion.d.mts.map +1 -0
  195. package/dist/v1/libs/plugin/TinyVersion.mjs +179 -0
  196. package/dist/v1/libs/router/TinyRouter.cjs +661 -0
  197. package/dist/v1/libs/router/TinyRouter.d.mts +320 -0
  198. package/dist/v1/libs/router/TinyRouter.d.mts.map +1 -0
  199. package/dist/v1/libs/router/TinyRouter.mjs +572 -0
  200. package/dist/v1/libs/storage/TinyLocalStorage.cjs +20 -1
  201. package/dist/v1/libs/storage/TinyLocalStorage.d.mts +64 -2
  202. package/dist/v1/libs/storage/TinyLocalStorage.d.mts.map +1 -1
  203. package/dist/v1/libs/storage/TinyLocalStorage.mjs +18 -1
  204. package/dist/v1/libs/storage/TinyMapCache.cjs +373 -0
  205. package/dist/v1/libs/storage/TinyMapCache.d.mts +274 -0
  206. package/dist/v1/libs/storage/TinyMapCache.d.mts.map +1 -0
  207. package/dist/v1/libs/storage/TinyMapCache.mjs +333 -0
  208. package/dist/v1/libs/storage/TinySetMapDatabase.cjs +1167 -0
  209. package/dist/v1/libs/storage/TinySetMapDatabase.d.mts +603 -0
  210. package/dist/v1/libs/storage/TinySetMapDatabase.d.mts.map +1 -0
  211. package/dist/v1/libs/storage/TinySetMapDatabase.mjs +1059 -0
  212. package/dist/v1/libs/sw/browser/TinyNotificationAdapter.cjs +126 -0
  213. package/dist/v1/libs/sw/browser/TinyNotificationAdapter.d.mts +132 -0
  214. package/dist/v1/libs/sw/browser/TinyNotificationAdapter.d.mts.map +1 -0
  215. package/dist/v1/libs/sw/browser/TinyNotificationAdapter.mjs +109 -0
  216. package/dist/v1/libs/sw/browser/TinyPushManager.cjs +310 -0
  217. package/dist/v1/libs/sw/browser/TinyPushManager.d.mts +168 -0
  218. package/dist/v1/libs/sw/browser/TinyPushManager.d.mts.map +1 -0
  219. package/dist/v1/libs/sw/browser/TinyPushManager.mjs +264 -0
  220. package/dist/v1/libs/sw/browser/TinyServiceWorker.cjs +1060 -0
  221. package/dist/v1/libs/sw/browser/TinyServiceWorker.d.mts +348 -0
  222. package/dist/v1/libs/sw/browser/TinyServiceWorker.d.mts.map +1 -0
  223. package/dist/v1/libs/sw/browser/TinyServiceWorker.mjs +933 -0
  224. package/dist/v1/libs/sw/browser/plugins/TabManager.cjs +315 -0
  225. package/dist/v1/libs/sw/browser/plugins/TabManager.d.mts +178 -0
  226. package/dist/v1/libs/sw/browser/plugins/TabManager.d.mts.map +1 -0
  227. package/dist/v1/libs/sw/browser/plugins/TabManager.mjs +274 -0
  228. package/dist/v1/libs/sw/browser/utils.cjs +28 -0
  229. package/dist/v1/libs/sw/browser/utils.d.mts +8 -0
  230. package/dist/v1/libs/sw/browser/utils.d.mts.map +1 -0
  231. package/dist/v1/libs/sw/browser/utils.mjs +21 -0
  232. package/dist/v1/libs/sw/service/TinyPushRouter.cjs +222 -0
  233. package/dist/v1/libs/sw/service/TinyPushRouter.d.mts +138 -0
  234. package/dist/v1/libs/sw/service/TinyPushRouter.d.mts.map +1 -0
  235. package/dist/v1/libs/sw/service/TinyPushRouter.mjs +201 -0
  236. package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.cjs +3016 -0
  237. package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.d.mts +993 -0
  238. package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.d.mts.map +1 -0
  239. package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.mjs +2558 -0
  240. package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.cjs +88 -0
  241. package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.d.mts +32 -0
  242. package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.d.mts.map +1 -0
  243. package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.mjs +69 -0
  244. package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.cjs +112 -0
  245. package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.d.mts +31 -0
  246. package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.d.mts.map +1 -0
  247. package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.mjs +91 -0
  248. package/dist/v1/libs/sw/service/plugins/Ping.cjs +32 -0
  249. package/dist/v1/libs/sw/service/plugins/Ping.d.mts +9 -0
  250. package/dist/v1/libs/sw/service/plugins/Ping.d.mts.map +1 -0
  251. package/dist/v1/libs/sw/service/plugins/Ping.mjs +25 -0
  252. package/dist/v1/libs/sw/service/plugins/TabManager.cjs +457 -0
  253. package/dist/v1/libs/sw/service/plugins/TabManager.d.mts +91 -0
  254. package/dist/v1/libs/sw/service/plugins/TabManager.d.mts.map +1 -0
  255. package/dist/v1/libs/sw/service/plugins/TabManager.mjs +372 -0
  256. package/dist/v1/libs/sw/service/plugins/ViteFileDetector.cjs +180 -0
  257. package/dist/v1/libs/sw/service/plugins/ViteFileDetector.d.mts +28 -0
  258. package/dist/v1/libs/sw/service/plugins/ViteFileDetector.d.mts.map +1 -0
  259. package/dist/v1/libs/sw/service/plugins/ViteFileDetector.mjs +148 -0
  260. package/dist/v1/libs/sw/service/shared/TinyPushPayload.cjs +199 -0
  261. package/dist/v1/libs/sw/service/shared/TinyPushPayload.d.mts +80 -0
  262. package/dist/v1/libs/sw/service/shared/TinyPushPayload.d.mts.map +1 -0
  263. package/dist/v1/libs/sw/service/shared/TinyPushPayload.mjs +174 -0
  264. package/dist/v1/libs/sw/utils.cjs +57 -0
  265. package/dist/v1/libs/sw/utils.d.mts +173 -0
  266. package/dist/v1/libs/sw/utils.d.mts.map +1 -0
  267. package/dist/v1/libs/sw/utils.mjs +50 -0
  268. package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.cjs +57 -0
  269. package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.d.mts +39 -0
  270. package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.d.mts.map +1 -0
  271. package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.mjs +48 -0
  272. package/dist/v1/libs/text/TinyI18/Browser.cjs +64 -0
  273. package/dist/v1/libs/text/TinyI18/Browser.d.mts +47 -0
  274. package/dist/v1/libs/text/TinyI18/Browser.d.mts.map +1 -0
  275. package/dist/v1/libs/text/TinyI18/Browser.mjs +57 -0
  276. package/dist/v1/libs/text/TinyI18/Node.cjs +49 -0
  277. package/dist/v1/libs/text/TinyI18/Node.d.mts +38 -0
  278. package/dist/v1/libs/text/TinyI18/Node.d.mts.map +1 -0
  279. package/dist/v1/libs/text/TinyI18/Node.mjs +43 -0
  280. package/dist/v1/libs/text/TinyI18/browser-utils.cjs +17 -0
  281. package/dist/v1/libs/text/TinyI18/browser-utils.d.mts +8 -0
  282. package/dist/v1/libs/text/TinyI18/browser-utils.d.mts.map +1 -0
  283. package/dist/v1/libs/text/TinyI18/browser-utils.mjs +13 -0
  284. package/dist/v1/libs/text/{TinyI18.cjs → TinyI18/index.cjs} +205 -104
  285. package/dist/v1/libs/text/{TinyI18.d.mts → TinyI18/index.d.mts} +141 -92
  286. package/dist/v1/libs/text/TinyI18/index.d.mts.map +1 -0
  287. package/dist/v1/libs/text/{TinyI18.mjs → TinyI18/index.mjs} +195 -101
  288. package/dist/v1/libs/tools/TinyBrowserMonitor.cjs +1088 -0
  289. package/dist/v1/libs/tools/TinyBrowserMonitor.d.mts +621 -0
  290. package/dist/v1/libs/tools/TinyBrowserMonitor.d.mts.map +1 -0
  291. package/dist/v1/libs/tools/TinyBrowserMonitor.mjs +940 -0
  292. package/dist/v1/libs/tools/TinyDebugger.cjs +180 -19
  293. package/dist/v1/libs/tools/TinyDebugger.d.mts +220 -24
  294. package/dist/v1/libs/tools/TinyDebugger.d.mts.map +1 -1
  295. package/dist/v1/libs/tools/TinyDebugger.mjs +161 -19
  296. package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.cjs +256 -0
  297. package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.d.mts +125 -0
  298. package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.d.mts.map +1 -0
  299. package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.mjs +223 -0
  300. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.cjs +23 -0
  301. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.d.mts +17 -0
  302. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.d.mts.map +1 -0
  303. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.mjs +19 -0
  304. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.cjs +23 -0
  305. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.d.mts +17 -0
  306. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.d.mts.map +1 -0
  307. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.mjs +19 -0
  308. package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.cjs +390 -0
  309. package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.d.mts +9 -0
  310. package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.d.mts.map +1 -0
  311. package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.mjs +387 -0
  312. package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.cjs +2 -0
  313. package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.d.mts +27 -0
  314. package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.d.mts.map +1 -0
  315. package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.mjs +12 -0
  316. package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/LICENSE +53 -0
  317. package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.cjs +405 -0
  318. package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.d.mts +34 -0
  319. package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.d.mts.map +1 -0
  320. package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.mjs +342 -0
  321. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.cjs +23 -0
  322. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.d.mts +17 -0
  323. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.d.mts.map +1 -0
  324. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.mjs +19 -0
  325. package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.cjs +327 -0
  326. package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.d.mts +9 -0
  327. package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.d.mts.map +1 -0
  328. package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.mjs +324 -0
  329. package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.cjs +268 -0
  330. package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.d.mts +107 -0
  331. package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.d.mts.map +1 -0
  332. package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.mjs +238 -0
  333. package/dist/v1/libs/tools/TinyPasswordValidator.cjs +491 -0
  334. package/dist/v1/libs/tools/TinyPasswordValidator.d.mts +246 -0
  335. package/dist/v1/libs/tools/TinyPasswordValidator.d.mts.map +1 -0
  336. package/dist/v1/libs/tools/TinyPasswordValidator.mjs +434 -0
  337. package/dist/v1/libs/tools/TinyPkgExportValidator.cjs +48 -0
  338. package/dist/v1/libs/tools/TinyPkgExportValidator.d.mts +14 -0
  339. package/dist/v1/libs/tools/TinyPkgExportValidator.d.mts.map +1 -1
  340. package/dist/v1/libs/tools/TinyPkgExportValidator.mjs +44 -0
  341. package/dist/v1/libs/tools/TinySiteMap.cjs +1029 -0
  342. package/dist/v1/libs/tools/TinySiteMap.d.mts +429 -0
  343. package/dist/v1/libs/tools/TinySiteMap.d.mts.map +1 -0
  344. package/dist/v1/libs/tools/TinySiteMap.mjs +910 -0
  345. package/dist/v1/libs/tools/TinySiteMapStream.cjs +121 -0
  346. package/dist/v1/libs/tools/TinySiteMapStream.d.mts +51 -0
  347. package/dist/v1/libs/tools/TinySiteMapStream.d.mts.map +1 -0
  348. package/dist/v1/libs/tools/TinySiteMapStream.mjs +85 -0
  349. package/dist/v1/libs/tools/TinyURLSecurityVerifier.cjs +444 -0
  350. package/dist/v1/libs/tools/TinyURLSecurityVerifier.d.mts +217 -0
  351. package/dist/v1/libs/tools/TinyURLSecurityVerifier.d.mts.map +1 -0
  352. package/dist/v1/libs/tools/TinyURLSecurityVerifier.mjs +394 -0
  353. package/dist/v1/libs/tools/TinyUriParser/BlueSky.cjs +613 -0
  354. package/dist/v1/libs/tools/TinyUriParser/BlueSky.d.mts +152 -0
  355. package/dist/v1/libs/tools/TinyUriParser/BlueSky.d.mts.map +1 -0
  356. package/dist/v1/libs/tools/TinyUriParser/BlueSky.mjs +527 -0
  357. package/dist/v1/libs/tools/TinyUriParser/Discord.cjs +1119 -0
  358. package/dist/v1/libs/tools/TinyUriParser/Discord.d.mts +306 -0
  359. package/dist/v1/libs/tools/TinyUriParser/Discord.d.mts.map +1 -0
  360. package/dist/v1/libs/tools/TinyUriParser/Discord.mjs +968 -0
  361. package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.cjs +469 -0
  362. package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.d.mts +80 -0
  363. package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.d.mts.map +1 -0
  364. package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.mjs +379 -0
  365. package/dist/v1/libs/tools/TinyUriParser.cjs +217 -0
  366. package/dist/v1/libs/tools/TinyUriParser.d.mts +109 -0
  367. package/dist/v1/libs/tools/TinyUriParser.d.mts.map +1 -0
  368. package/dist/v1/libs/tools/TinyUriParser.mjs +183 -0
  369. package/dist/v1/libs/utils/TinyCloner.cjs +466 -0
  370. package/dist/v1/libs/utils/TinyCloner.d.mts +221 -0
  371. package/dist/v1/libs/utils/TinyCloner.d.mts.map +1 -0
  372. package/dist/v1/libs/utils/TinyCloner.mjs +416 -0
  373. package/dist/v1/libs/utils/TinyPromiseQueue.cjs +1 -1
  374. package/dist/v1/libs/utils/TinyPromiseQueue.d.mts +2 -2
  375. package/dist/v1/libs/utils/TinyPromiseQueue.d.mts.map +1 -1
  376. package/dist/v1/libs/utils/TinyPromiseQueue.mjs +1 -1
  377. package/dist/v1/libs/utils/TinyThrottledApi.cjs +333 -0
  378. package/dist/v1/libs/utils/TinyThrottledApi.d.mts +163 -0
  379. package/dist/v1/libs/utils/TinyThrottledApi.d.mts.map +1 -0
  380. package/dist/v1/libs/utils/TinyThrottledApi.mjs +294 -0
  381. package/dist/v1/libs/worker/browser/TinyWebWorker.cjs +342 -0
  382. package/dist/v1/libs/worker/browser/TinyWebWorker.d.mts +97 -0
  383. package/dist/v1/libs/worker/browser/TinyWebWorker.d.mts.map +1 -0
  384. package/dist/v1/libs/worker/browser/TinyWebWorker.mjs +305 -0
  385. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.cjs +346 -0
  386. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.d.mts +127 -0
  387. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.d.mts.map +1 -0
  388. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.mjs +304 -0
  389. package/dist/v1/regexp/Email.cjs +185 -0
  390. package/dist/v1/regexp/Email.d.mts +73 -0
  391. package/dist/v1/regexp/Email.d.mts.map +1 -0
  392. package/dist/v1/regexp/Email.mjs +153 -0
  393. package/dist/v1/regexp/Glob.cjs +293 -0
  394. package/dist/v1/regexp/Glob.d.mts +45 -0
  395. package/dist/v1/regexp/Glob.d.mts.map +1 -0
  396. package/dist/v1/regexp/Glob.mjs +260 -0
  397. package/dist/v1/regexp/Ipv4.cjs +57 -0
  398. package/dist/v1/regexp/Ipv4.d.mts +29 -0
  399. package/dist/v1/regexp/Ipv4.d.mts.map +1 -0
  400. package/dist/v1/regexp/Ipv4.mjs +45 -0
  401. package/dist/v1/regexp/Ipv6.cjs +67 -0
  402. package/dist/v1/regexp/Ipv6.d.mts +29 -0
  403. package/dist/v1/regexp/Ipv6.d.mts.map +1 -0
  404. package/dist/v1/regexp/Ipv6.mjs +54 -0
  405. package/dist/v1/regexp/SegmentExtractor.cjs +145 -0
  406. package/dist/v1/regexp/SegmentExtractor.d.mts +91 -0
  407. package/dist/v1/regexp/SegmentExtractor.d.mts.map +1 -0
  408. package/dist/v1/regexp/SegmentExtractor.mjs +116 -0
  409. package/dist/v1/regexp/UrlDetector.cjs +125 -0
  410. package/dist/v1/regexp/UrlDetector.d.mts +67 -0
  411. package/dist/v1/regexp/UrlDetector.d.mts.map +1 -0
  412. package/dist/v1/regexp/UrlDetector.mjs +102 -0
  413. package/dist/v1/regexp/Username/index.cjs +233 -0
  414. package/dist/v1/regexp/Username/index.d.mts +77 -0
  415. package/dist/v1/regexp/Username/index.d.mts.map +1 -0
  416. package/dist/v1/regexp/Username/index.mjs +199 -0
  417. package/dist/v1/regexp/Username/jsDoc.cjs +2 -0
  418. package/dist/v1/regexp/Username/jsDoc.d.mts +57 -0
  419. package/dist/v1/regexp/Username/jsDoc.d.mts.map +1 -0
  420. package/dist/v1/regexp/Username/jsDoc.mjs +18 -0
  421. package/dist/v1/regexp/Username/templates/BlueSky.cjs +56 -0
  422. package/dist/v1/regexp/Username/templates/BlueSky.d.mts +35 -0
  423. package/dist/v1/regexp/Username/templates/BlueSky.d.mts.map +1 -0
  424. package/dist/v1/regexp/Username/templates/BlueSky.mjs +52 -0
  425. package/dist/v1/regexp/Username/templates/Discord.cjs +505 -0
  426. package/dist/v1/regexp/Username/templates/Discord.d.mts +209 -0
  427. package/dist/v1/regexp/Username/templates/Discord.d.mts.map +1 -0
  428. package/dist/v1/regexp/Username/templates/Discord.mjs +458 -0
  429. package/dist/v1/regexp/Username/templates/MatrixProtocol.cjs +143 -0
  430. package/dist/v1/regexp/Username/templates/MatrixProtocol.d.mts +70 -0
  431. package/dist/v1/regexp/Username/templates/MatrixProtocol.d.mts.map +1 -0
  432. package/dist/v1/regexp/Username/templates/MatrixProtocol.mjs +128 -0
  433. package/dist/v1/regexp/Username/templates/deprecated/Discord.cjs +24 -0
  434. package/dist/v1/regexp/Username/templates/deprecated/Discord.d.mts +17 -0
  435. package/dist/v1/regexp/Username/templates/deprecated/Discord.d.mts.map +1 -0
  436. package/dist/v1/regexp/Username/templates/deprecated/Discord.mjs +20 -0
  437. package/dist/v1/regexp/Username/templates/index.cjs +11 -0
  438. package/dist/v1/regexp/Username/templates/index.d.mts +5 -0
  439. package/dist/v1/regexp/Username/templates/index.d.mts.map +1 -0
  440. package/dist/v1/regexp/Username/templates/index.mjs +4 -0
  441. package/dist/v1/regexp/index.cjs +41 -0
  442. package/dist/v1/regexp/index.d.mts +9 -0
  443. package/dist/v1/regexp/index.d.mts.map +1 -0
  444. package/dist/v1/regexp/index.mjs +8 -0
  445. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.cjs +64 -0
  446. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.d.mts +11 -0
  447. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.d.mts.map +1 -0
  448. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.mjs +51 -0
  449. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.cjs +66 -0
  450. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.d.mts +11 -0
  451. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.d.mts.map +1 -0
  452. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.mjs +51 -0
  453. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.cjs +39 -0
  454. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.d.mts +11 -0
  455. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.d.mts.map +1 -0
  456. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.mjs +28 -0
  457. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.cjs +494 -0
  458. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.d.mts +142 -0
  459. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.d.mts.map +1 -0
  460. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.mjs +445 -0
  461. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.cjs +30 -4
  462. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.d.mts +5 -2
  463. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.d.mts.map +1 -1
  464. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.mjs +29 -5
  465. package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.cjs +135 -0
  466. package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.d.mts +83 -0
  467. package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.d.mts.map +1 -0
  468. package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.mjs +120 -0
  469. package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.cjs +127 -0
  470. package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.d.mts +95 -0
  471. package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.d.mts.map +1 -0
  472. package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.mjs +109 -0
  473. package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.cjs +83 -0
  474. package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.d.mts +46 -0
  475. package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.d.mts.map +1 -0
  476. package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.mjs +71 -0
  477. package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.cjs +493 -0
  478. package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.d.mts +67 -0
  479. package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.d.mts.map +1 -0
  480. package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.mjs +399 -0
  481. package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.cjs +35 -0
  482. package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.d.mts +6 -0
  483. package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.d.mts.map +1 -0
  484. package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.mjs +29 -0
  485. package/docs/info/RegExp.md +74 -0
  486. package/docs/v1/Exports.md +101 -0
  487. package/docs/v1/README.md +113 -15
  488. package/docs/v1/basics/asyncReplace.md +2 -0
  489. package/docs/v1/basics/browserDetector.md +28 -11
  490. package/docs/v1/basics/crypto.md +85 -0
  491. package/docs/v1/basics/deprecated/html.md +2 -0
  492. package/docs/v1/basics/deprecated/objFilter.md +2 -0
  493. package/docs/v1/basics/html.md +2 -0
  494. package/docs/v1/basics/objChecker.md +55 -0
  495. package/docs/v1/basics/objFilter.md +57 -86
  496. package/docs/v1/basics/promiseUtils.md +12 -3
  497. package/docs/v1/basics/text.md +0 -1
  498. package/docs/v1/libs/array/TinyArrayComparator.md +50 -39
  499. package/docs/v1/libs/fs/TinyFS.md +752 -0
  500. package/docs/v1/libs/fs/TinyOPFSFileSystem.md +495 -0
  501. package/docs/v1/libs/fs/TinyStorageBucketFileSystem.md +407 -0
  502. package/docs/v1/libs/plugin/TinyPlugin.md +441 -0
  503. package/docs/v1/libs/plugin/TinyVersion.md +145 -0
  504. package/docs/v1/libs/router/TinyRouter.md +216 -0
  505. package/docs/v1/libs/storage/TinyMapCache.md +219 -0
  506. package/docs/v1/libs/storage/TinySetMapDatabase.md +478 -0
  507. package/docs/v1/libs/sw/browser/TinyNotificationAdapter.md +280 -0
  508. package/docs/v1/libs/sw/browser/TinyPushManager.md +782 -0
  509. package/docs/v1/libs/sw/browser/TinyServiceWorker.md +365 -0
  510. package/docs/v1/libs/sw/browser/plugins/TabManager.md +133 -0
  511. package/docs/v1/libs/sw/service/TinyPushRouter.md +314 -0
  512. package/docs/v1/libs/sw/service/TinyServiceWorkerEngine.md +748 -0
  513. package/docs/v1/libs/sw/service/plugins/GlobBypassPlugin.md +229 -0
  514. package/docs/v1/libs/sw/service/plugins/GlobCachePlugin.md +91 -0
  515. package/docs/v1/libs/sw/service/plugins/Ping.md +36 -0
  516. package/docs/v1/libs/sw/service/plugins/TabManager.md +64 -0
  517. package/docs/v1/libs/sw/service/plugins/ViteFileDetector.md +92 -0
  518. package/docs/v1/libs/sw/service/shared/TinyPushPayload.md +316 -0
  519. package/docs/v1/libs/text/TinyI18.md +80 -56
  520. package/docs/v1/libs/tools/TinyBrowserMonitor.md +170 -0
  521. package/docs/v1/libs/tools/TinyDebugger.md +117 -1
  522. package/docs/v1/libs/tools/TinyHtmlTagRegexBuilder.md +141 -0
  523. package/docs/v1/libs/tools/TinyHttpResponseRegistry.md +129 -0
  524. package/docs/v1/libs/tools/TinyPasswordValidator.md +153 -0
  525. package/docs/v1/libs/tools/TinyPkgExportValidator.md +45 -1
  526. package/docs/v1/libs/tools/TinySiteMap.md +134 -0
  527. package/docs/v1/libs/tools/TinySiteMapStream.md +97 -0
  528. package/docs/v1/libs/tools/TinyURLSecurityVerifier.md +146 -0
  529. package/docs/v1/libs/tools/TinyUriParser/Discord.md +374 -0
  530. package/docs/v1/libs/tools/TinyUriParser/MatrixProtocol.md +54 -0
  531. package/docs/v1/libs/tools/TinyUriParser.md +128 -0
  532. package/docs/v1/libs/utils/TinyCloner.md +126 -0
  533. package/docs/v1/libs/utils/TinyPromiseQueue.md +1 -1
  534. package/docs/v1/libs/utils/TinyThrottledApi.md +219 -0
  535. package/docs/v1/libs/worker/browser/TinyWebWorker.md +331 -0
  536. package/docs/v1/libs/worker/engine/TinyWebWorkerEngine.md +137 -0
  537. package/docs/v1/regexp/Email.md +127 -0
  538. package/docs/v1/regexp/Glob.md +155 -0
  539. package/docs/v1/regexp/IPv4.md +103 -0
  540. package/docs/v1/regexp/IPv6.md +122 -0
  541. package/docs/v1/regexp/SegmentExtractor.md +120 -0
  542. package/docs/v1/regexp/UrlDetector.md +117 -0
  543. package/docs/v1/regexp/Username/Base.md +131 -0
  544. package/docs/v1/regexp/Username/Discord.md +267 -0
  545. package/docs/v1/regexp/Username/MatrixProtocol.md +131 -0
  546. package/docs/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters.md +569 -0
  547. package/docs/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.md +19 -7
  548. package/docs/v1/webTemplates/media/MediaValidator/v1/Browser.md +123 -0
  549. package/docs/v1/webTemplates/media/MediaValidator/v1/Node.md +136 -0
  550. package/docs/v1/webTemplates/multiformats/14.0/IPFSHasher.md +310 -0
  551. package/docs/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.md +131 -0
  552. package/docs/v1/webTemplates/vite/7.3/plugins/githubUtils.md +50 -0
  553. package/package.json +303 -13
  554. package/types/EventEmitter.d.ts +48 -0
  555. package/dist/v1/libs/text/TinyI18.d.mts.map +0 -1
@@ -0,0 +1 @@
1
+ (()=>{"use strict";const e={cw:e=>{var t;return()=>{if(e){var r=e;e=0,t={exports:{}},r.call(t.exports,t,t.exports)}return t.exports}},d:(t,r)=>{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),r:e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};e.r(t),e.d(t,{TinyPlugin:()=>T,TinyPluginCore:()=>L,TinyPluginLayer:()=>v,createPluginIdChecker:()=>f,signPluginIdentity:()=>d,verifyPluginSignature:()=>w});var r=e.cw(function(e,t){var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=i&&"function"==typeof i.ownKeys?i.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 n(){n.init.call(this)}e.exports=n,e.exports.once=function(e,t){return new Promise(function(r,i){function o(r){e.removeListener(t,s),i(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}p(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&p(e,"error",t,{once:!0})}(e,o)})},n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var a=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function g(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function h(e,t,r,i){var o,s,n,a;if(l(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),n=s[t]),void 0===n)n=s[t]=r,++e._eventsCount;else if("function"==typeof n?n=s[t]=i?[r,n]:[n,r]:i?n.unshift(r):n.push(r),(o=g(e))>0&&n.length>o&&!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,a=h,console&&console.warn&&console.warn(a)}return e}function c(){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 u(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=c.bind(i);return o.listener=r,i.wrapFn=o,o}function d(e,t,r){var i=e._events;if(void 0===i)return[];var o=i[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]: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}(o):y(o,o.length)}function f(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 y(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function p(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 o(s){i.once&&e.removeEventListener(t,o),r(s)})}}Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return a},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+".");a=e}}),n.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},n.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},n.prototype.getMaxListeners=function(){return g(this)},n.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,s=this._events;if(void 0!==s)i=i&&void 0===s.error;else if(!i)return!1;if(i){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 l=s[e];if(void 0===l)return!1;if("function"==typeof l)o(l,this,t);else{var g=l.length,h=y(l,g);for(r=0;r<g;++r)o(h[r],this,t)}return!0},n.prototype.addListener=function(e,t){return h(this,e,t,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(e,t){return h(this,e,t,!0)},n.prototype.once=function(e,t){return l(t),this.on(e,u(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,u(this,e,t)),this},n.prototype.removeListener=function(e,t){var r,i,o,s,n;if(l(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(o=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){n=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,n||t)}return this},n.prototype.off=n.prototype.removeListener,n.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 o,s=Object.keys(r);for(i=0;i<s.length;++i)"removeListener"!==(o=s[i])&&this.removeAllListeners(o);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},n.prototype.listeners=function(e){return d(this,e,!0)},n.prototype.rawListeners=function(e){return d(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},n.prototype.listenerCount=f,n.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});function i(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}r();const o="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:null,s="undefined"!=typeof document?document:null,n=["chrome","firefox","ie","edge","safari","opera","yandex","other"];const a=r().EventEmitter,l=class extends a{#e;#t;#r=null;#i;#o;#s;#n;#a=new Map([["log",""],["info",""],["warn",""],["error",""],["debug",""],["main_class",""],["sub_class",""],["reset",""],["black",""],["red",""],["green",""],["yellow",""],["blue",""],["magenta",""],["cyan",""],["white",""],["gray",""]]);#l=new Map([["log","[_log_LOG_reset_]"],["info","[_info_INFO_reset_]"],["warn","[_warn_WARN_reset_]"],["error","[_error_ERROR_reset_]"],["debug","[_debug_DEBUG_reset_]"]]);constructor({logger:e,id:t,debugMode:r,canEmitLogs:i=!1,useLogColors:a=!1,autoHideId:l=!1}){if(super(),null===(g=e)||"object"!=typeof g||Array.isArray(g))throw new TypeError("Logger must be an object that implements the Console interface.");var g;if("string"!=typeof t)throw new TypeError("Logger instance id must be a string.");if("boolean"!=typeof r)throw new TypeError("debugMode must be a boolean.");if("boolean"!=typeof i)throw new TypeError("canEmitLogs must be a boolean.");if("boolean"!=typeof a)throw new TypeError("useLogColors must be a boolean.");if("boolean"!=typeof l)throw new TypeError("autoHideId must be a boolean.");this.#t=t,this.#e=e,this.#o=r,this.#i=i,this.#n=l,this.#s="firefox"!==function(e=[]){const t=function(e=[]){if(!Array.isArray(e))throw new TypeError('The "disable" argument must be an array.');for(const t of e)if(!n.includes(t))throw new TypeError(`Invalid browser name provided in disable array: ${t}`);const t={chrome:0,firefox:0,ie:0,edge:0,safari:0,opera:0,yandex:0,other:0};t[function(){if("undefined"==typeof navigator)return"other";const e=navigator.userAgent;return-1!==e.indexOf("Chrome")?"chrome":-1!==e.indexOf("Firefox")?"firefox":-1!==e.indexOf("MSIE")?"ie":-1!==e.indexOf("Edge")?"edge":-1!==e.indexOf("Safari")?"safari":-1!==e.indexOf("Opera")?"opera":-1!==e.indexOf("YaBrowser")?"yandex":"other"}()]++;const r=function(){const e=o?.getComputedStyle?(Array.prototype.slice.call(o.getComputedStyle(document.documentElement,"")).join("").match(/-(moz|webkit|ms)-/)??["",""])[1]:"";return"moz"===e?"gecko":"webkit"===e?"webkit":"ms"===e?"trident":"other"}();"gecko"===r?e.indexOf("firefox")<0&&t.firefox++:"webkit"===r?(e.indexOf("chrome")<0&&t.chrome++,e.indexOf("safari")<0&&t.safari++,e.indexOf("opera")<0&&t.opera++,e.indexOf("edge")<0&&t.edge++):"trident"===r?e.indexOf("ie")<0&&t.ie++:e.indexOf("other")<0&&t.other++;const i=function(){const e=!!o?.opr&&!!opr.addons||!!o?.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,r=!!o?.HTMLElement&&/constructor/i.test(o.HTMLElement)||"[object SafariRemoteNotification]"===(!o.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),i=!!s?.documentMode,n=!i&&!!o?.StyleMedia,a=!!o?.chrome;return{isOpera:e,isFirefox:t,isSafari:r,isIE:i,isEdge:n,isChrome:a,isBlink:(a||e)&&!!o?.CSS}}();return i.isOpera&&e.indexOf("opera")<0&&t.opera++,i.isFirefox&&e.indexOf("firefox")<0&&t.firefox++,i.isSafari&&e.indexOf("safari")<0&&t.safari++,i.isIE&&e.indexOf("ie")<0&&t.ie++,i.isEdge&&e.indexOf("edge")<0&&t.edge++,i.isChrome&&e.indexOf("chrome")<0&&t.chrome++,t}(e);return Object.keys(t).reduce((e,r)=>t[r]>t[e]?r:e)}()&&a,this.log("info","Emit logs of debug mode set to: "+(this.#o?"ON":"OFF")),this.log("info","Custom logger assigned.")}get logId(){return this.#t}get logSubId(){if("string"!=typeof this.#r)throw new Error('logSubId has not been set yet. Assign a string to "logSubId" before reading it.');return this.#r}set logSubId(e){if("string"!=typeof e)throw new TypeError(`logSubId must be a string. Received: ${typeof e}.`);if(null!==this.#r)throw new Error(`logSubId is already set to "${this.#r}" and cannot be reassigned.`);this.#r=e,this.emit("setLogSubId",e)}get canEmitLogs(){return this.#i}get useLogColors(){return this.#s}set useLogColors(e){if("boolean"!=typeof e)throw new TypeError("useLogColors must be a boolean.");this.#s=e,this.log("info","Log Colors usage mode set to: "+(this.#s?"ON":"OFF")),this.emit("setUseLogColors",e)}get debugMode(){return this.#o}set debugMode(e){if("boolean"!=typeof e)throw new TypeError("debugMode must be a boolean.");this.#o=e,this.log("info","Debug mode set to: "+(this.#o?"ON":"OFF")),this.emit("setDebugMode",e)}_addLogColor(e,t){this.#a.set(e,t)}_removeLogColor(e){this.#a.delete(e)}_addLogPrefix(e,t){this.#l.set(e,t)}_removeLogPrefix(e){this.#l.delete(e)}#g(e){if("string"!=typeof e)return e;let t=e;for(const[e,r]of this.#l){const i=new RegExp(`\\:${e}\\:`,"g");t=t.replace(i,r)}for(const[e,r]of this.#a){const i=new RegExp(`\\_${e}\\_`,"g");t=t.replace(i,this.#s?r:"")}return t}_applyLogFormatting(e){return this.#g(e)}logClear(){if(this.#o)return this.#i&&this.emit("debug:clear"),this.#e.clear?this.#e.clear():console.clear()}logGroupEnd(){if(this.#o)return this.#i&&this.emit("debug:groupEnd"),this.#e.groupEnd?this.#e.groupEnd():console.groupEnd()}logLabel(e,t){if(!this.#o)return;const r=["count","countReset","time","timeEnd","profile","profileEnd","timeStamp"];if(!r.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${r.join(", ")}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError("The label must be a string.");const i=this.#e[e]?this.#e[e]:console[e];if(!i)throw new TypeError(`The log type "${e}" is not supported by the provided logger or console.`);return this.#i&&this.emit("debug:logLabel",e,t),i(t)}logTimeLabel(e,...t){if(this.#o)return this.#i&&this.emit("debug:timeLog",e,...t),this.#e.timeLog?this.#e.timeLog(e,...t):console.timeLog(e,...t)}logAssert(e,...t){if(this.#o)return this.#i&&this.emit("debug:assert",e,...t),this.#e.assert?this.#e.assert(e,...t):console.assert(e,...t)}logDir(e,t){if(this.#o)return this.#i&&this.emit("debug:dir",e,t),this.#e.dir?this.#e.dir(e,t):console.dir(e,t)}logTable(e,t){if(this.#o){if(!(void 0===t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("Properties must be an array of strings.");return this.#i&&this.emit("debug:table",e,t),this.#e.table?this.#e.table(e,t):console.table(e,t)}}log(e,t,...r){if(!this.#o)return;const i=["log","info","warn","error","debug","dirxml","group","groupCollapsed","trace"];if(!i.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${i.join(", ")}`);if("string"!=typeof t)throw new TypeError("The message must be a string.");let o=this.#t,s=this.#r??"",n=t;const a=!this.#n||"string"!=typeof this.#r;o=a?this.#g(o):"",s&&(s=this.#g(s)),n=this.#g(n);const l=`${o}${s?a?` ${s}`:s:""}`,g=this.#e[e]?this.#e[e]:console[e];return g?(this.#i&&this.emit("debug:log",l,n,...r),g(l,n,...r)):(this.#i&&this.emit("debug:log",l,n,...r),console.log(l,n,...r))}#h(e,t){const[r="",...i]=t;return"string"==typeof r?this.log(e,r,...i):this.log(e,"",r,...i)}toConsole(){return{log:(...e)=>this.#h("log",e),info:(...e)=>this.#h("info",e),warn:(...e)=>this.#h("warn",e),error:(...e)=>this.#h("error",e),debug:(...e)=>this.#h("debug",e),dirxml:(...e)=>this.#h("dirxml",e),group:(...e)=>this.#h("group",e),groupCollapsed:(...e)=>this.#h("groupCollapsed",e),trace:(...e)=>this.#h("trace",e),assert:(e,...t)=>this.logAssert(e,...t),dir:(e,t)=>this.logDir(e,t),table:(e,t)=>this.logTable(e,t),clear:()=>this.logClear(),groupEnd:()=>this.logGroupEnd(),count:e=>this.logLabel("count",e),countReset:e=>this.logLabel("countReset",e),time:e=>this.logLabel("time",e),timeEnd:e=>this.logLabel("timeEnd",e),timeLog:(e,...t)=>this.logTimeLabel(e,...t),timeStamp:e=>this.logLabel("timeStamp",e),profile:e=>this.logLabel("profile",e),profileEnd:e=>this.logLabel("profileEnd",e)}}};class g{#c=0;#u=0;#d=0;#f=null;constructor(e){if("string"!=typeof e)throw new TypeError("[TinyVersion] Expected version to be a string, received type: "+typeof e);const t=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/),r=e=>{"string"==typeof e[1]&&(this.#c=parseInt(e[1],10)),"string"==typeof e[2]&&(this.#u=parseInt(e[2],10)),"string"==typeof e[3]&&(this.#d=parseInt(e[3],10)),"string"==typeof e[4]&&(this.#f=e[4])};if(t)r(t);else{const t=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);if(t)r(t);else{const t=e.match(/^(\d+)\.(\d+)$/);if(t)r(t);else{const t=e.match(/^(\d+)$/);if(!t)throw new Error(`[TinyVersion] Invalid version format: "${e}". Expected format: "X.Y.Z" or "X.Y.Z-tag".`);r(t)}}}}get major(){return this.#c}get minor(){return this.#u}get patch(){return this.#d}get tag(){return this.#f}isGreaterThan(e){if(!(e instanceof g))throw new TypeError("[TinyVersion] Comparison target must be an instance of TinyVersion. Received: "+typeof e);return this.#c!==e.major?this.#c>e.major:this.#u!==e.minor?this.#u>e.minor:this.#d!==e.patch?this.#d>e.patch:null===this.#f&&null!==e.tag||(null===this.#f||null!==e.tag)&&(null!==this.#f||null!==e.tag)&&(this.#f??"")>(e.tag??"")}isEqualTo(e){if(!(e instanceof g))throw new TypeError("[TinyVersion] Comparison target must be an instance of TinyVersion. Received: "+typeof e);return this.#c===e.major&&this.#u===e.minor&&this.#d===e.patch&&this.#f===e.tag}isLessThan(e){if(!(e instanceof g))throw new TypeError("[TinyVersion] Comparison target must be an instance of TinyVersion. Received: "+typeof e);return!this.isGreaterThan(e)&&!this.isEqualTo(e)}toString(){const e=`${this.#c}.${this.#u}.${this.#d}`;return this.#f?`${e}-${this.#f}`:e}}const h=g,c=e=>{if(e)throw new Error("This TinyPlugin instance has been destroyed and can no longer be used.")};const u=(e,t)=>t instanceof Set?t.has("*")||t.has(e):t.indexOf("*")>-1||t.indexOf(e)>-1;async function d(e,t,r,i,o,s={name:"RSASSA-PKCS1-v1_5"}){if("string"!=typeof e||0===e.length)throw new TypeError("pluginId must be a non-empty string.");if(!Array.isArray(t)||t.some(e=>"string"!=typeof e))throw new TypeError("authors must be an array of strings.");if(!Array.isArray(r)||r.some(e=>"string"!=typeof e))throw new TypeError("categories must be an array of strings.");if(!Array.isArray(i)||i.some(e=>"string"!=typeof e))throw new TypeError("tags must be an array of strings.");if(!(o instanceof CryptoKey))throw new TypeError("privateKey must be a valid CryptoKey instance.");const n={id:e,authors:[...t].sort(),categories:[...r].sort(),tags:[...i].sort()},a=JSON.stringify(n),l=(new TextEncoder).encode(a);try{return await crypto.subtle.sign(s,o,l)}catch(e){throw new Error(`Failed to sign plugin identity: ${e instanceof Error?e.message:"Unknown error"}`)}}const f=(e,t,r,i)=>{if("string"!=typeof e)throw new TypeError("Security Error: Cryptographic mode enabled, but pluginId is missing.");if(!Array.isArray(t))throw new TypeError("Security Error: Cryptographic mode enabled, but authors is missing.");if(!t.every(e=>"string"==typeof e))throw new TypeError("Security Error: Cryptographic mode enabled, but authors is invalid.");return JSON.stringify({id:e,authors:[...t].sort(),categories:[...r].sort(),tags:[...i].sort()})},y=(e,t,r)=>{const o=(e,t)=>{if(!Array.isArray(t)||!t.every(e=>"string"==typeof e||"symbol"==typeof e))throw new TypeError(`The ${e} of sandbox blacklist must be an array of strings.`)};if(i(r)&&i(e?.sandboxBlacklist)){const{get:t,set:i}=e.sandboxBlacklist;void 0!==t&&(o("get",t),t.forEach(e=>r.get.add(e))),void 0!==i&&(o("set",i),i.forEach(e=>r.set.add(e)))}if(i(e?.accessControl)){const{mode:r,whitelist:s,blacklist:n,publicKey:a,cryptoAlgorithm:l,importAlgorithm:g,importKeyFormat:h}=e.accessControl;if("none"!==r&&"whitelist"!==r&&"blacklist"!==r&&"cryptographic"!==r)throw new TypeError('accessControl.mode must be "none", "whitelist", "blacklist", or "cryptographic".');if("cryptographic"===r&&"string"!=typeof a)throw new TypeError("In cryptographic mode, accessControl.publicKey must be a string (PEM format).");i(s)&&(void 0!==s.ids&&(o("whitelist ids",s.ids),s.ids.forEach(e=>t.whitelist.ids.add(e))),void 0!==s.authors&&(o("whistlist authors",s.authors),s.authors.forEach(e=>t.whitelist.authors.add(e))),void 0!==s.categories&&(o("whistlist categories",s.categories),s.categories.forEach(e=>t.whitelist.categories.add(e))),void 0!==s.tags&&(o("whistlist tags",s.tags),s.tags.forEach(e=>t.whitelist.tags.add(e)))),i(n)&&(void 0!==n.ids&&(o("blacklist ids",n.ids),n.ids.forEach(e=>t.blacklist.ids.add(e))),void 0!==n.authors&&(o("blacklist authors",n.authors),n.authors.forEach(e=>t.blacklist.authors.add(e))),void 0!==n.categories&&(o("blacklist categories",n.categories),n.categories.forEach(e=>t.blacklist.categories.add(e))),void 0!==n.tags&&(o("blacklist tags",n.tags),n.tags.forEach(e=>t.blacklist.tags.add(e)))),"string"==typeof r&&(t.mode=r),"string"==typeof a&&(t.publicKey=a),void 0!==l&&(t.cryptoAlgorithm=l),void 0!==g&&(t.importAlgorithm=g),void 0!==h&&(t.importKeyFormat=h)}},p=e=>{const t=globalThis.atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r.buffer},w=async(e,t,r,i,o,s,n)=>{const{publicKey:a,cryptoAlgorithm:l,importKeyFormat:g,importAlgorithm:h}=e,c=f(r,i,o,s);try{if("string"!=typeof a)throw new TypeError("Security Error: Cryptographic mode enabled, but public key is missing.");if(!("string"==typeof n||n instanceof ArrayBuffer||n instanceof Uint8Array))throw new TypeError("Security Error: Cryptographic mode enabled, but signature is invalid (must be string, ArrayBuffer, or Uint8Array).");const e=(new TextEncoder).encode(c);let i;i="spki"===g||"pkcs8"===g?(e=>{const t=e.replace(/(-----(BEGIN|END) [^-]+-----)/g,"").replace(/\s+/g,"");return p(t)})(a):"string"==typeof a?p(a):a;const o="string"==typeof n?p(n):n,s=await crypto.subtle.importKey(g,i,h,!1,["verify"]),u=await crypto.subtle.verify(l,s,o,e);return u&&t.add(r),u}catch(e){return console.error(e),!1}},m=(e,t,r,i,o,s,n,a)=>{if("cryptographic"===e)return a.has(t);if("whitelist"===e){const e=u(t,s.ids),n=r.some(e=>u(e,s.authors)),a=i.some(e=>u(e,s.categories)),l=o.some(e=>u(e,s.tags));return e||n||a||l}if("blacklist"===e){const e=u(t,n.ids),s=r.some(e=>u(e,n.authors)),a=i.some(e=>u(e,n.categories)),l=o.some(e=>u(e,n.tags));return!(e||s||a||l)}return!0},b=()=>({mode:"none",importKeyFormat:"spki",importAlgorithm:{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},cryptoAlgorithm:{name:"RSASSA-PKCS1-v1_5"},publicKey:null,whitelist:{ids:new Set,authors:new Set,categories:new Set,tags:new Set},blacklist:{ids:new Set,authors:new Set,categories:new Set,tags:new Set}}),E=(e,t,r,o,s,n,a)=>{const l=[...o],g=[...s],h=t??{get:[],set:[]},c=[...n??[],...h.get],u=[...c,...h.set,...a??[]];return i(r)&&(c.forEach(e=>r.get.add(e)),u.forEach(e=>r.set.add(e))),new Proxy(e,{get(e,t){if(g.includes(t)||g.includes("*")){const r=Reflect.get(e,t,e);return"function"==typeof r?r.bind(e):r}throw new Error(`Security Error: Access to property "${String(t)}" is denied by the sandbox.`)},set(e,t,r){if(l.includes(t)||l.includes("*"))return Reflect.set(e,t,r);throw new Error("Security Error: Cannot modify read-only properties on the plugin sandbox.")},setPrototypeOf(){throw new Error("Security Error: Prototype manipulation is forbidden.")}})};class v extends l{#y=!1;#p=new Set;#w=b();get isReady(){return this.#y}get accessControlWhitelist(){return Object.freeze({ids:Object.freeze([...this.#w.whitelist.ids]),authors:Object.freeze([...this.#w.whitelist.authors]),categories:Object.freeze([...this.#w.whitelist.categories]),tags:Object.freeze([...this.#w.whitelist.tags])})}get accessControlBlacklist(){return Object.freeze({ids:Object.freeze([...this.#w.blacklist.ids]),authors:Object.freeze([...this.#w.blacklist.authors]),categories:Object.freeze([...this.#w.blacklist.categories]),tags:Object.freeze([...this.#w.blacklist.tags])})}get accessControlMode(){return this.#w.mode}constructor(e){super(e?.logCfg??{id:"[_main_class_TinyPluginLayer_reset_]",logger:console,autoHideId:!0,debugMode:!1,useLogColors:!1}),y(e??{},this.#w)}_startLayer(e,t,...r){if(this.#y)throw new Error("TinyPluginLayer: The layer has already been initialized.");return this.logSubId=e.logSubId,"function"==typeof t&&t(...r),this.#y=!0,this}canAccessLayer(e,t,r,i){const{mode:o,whitelist:s,blacklist:n}=this.#w;return m(o,e,t,r,i,s,n,this.#p)}async verifyPluginSignature(e,t,r,i,o){return w(this.#w,this.#p,e,t,r,i,o)}_createSandbox(e,t){return E(this,null,null,[...e],["isReady","accessControlMode","accessControlWhitelist","accessControlBlacklist","verifyPluginSignature","canAccessLayer",...t])}}class L extends l{static#m=v;static get TinyPluginLayer(){return L.#m}static#b="pluginsDestroyed";#E={get:new Set,set:new Set};#w=b();#p=new Set;static get pluginsDestroyEventName(){return L.pluginsDestroyEventName}static set pluginsDestroyEventName(e){if("string"!=typeof e)throw new TypeError("pluginsDestroyEventName must be a string.");L.pluginsDestroyEventName=e}#v=new Map;get sandboxBlacklist(){return Object.freeze({set:Object.freeze([...this.#E.set]),get:Object.freeze([...this.#E.get])})}get plugins(){return Object.fromEntries(this.#v)}get pluginsSize(){return this.#v.size}get accessControlWhitelist(){return Object.freeze({ids:Object.freeze([...this.#w.whitelist.ids]),authors:Object.freeze([...this.#w.whitelist.authors]),categories:Object.freeze([...this.#w.whitelist.categories]),tags:Object.freeze([...this.#w.whitelist.tags])})}get accessControlBlacklist(){return Object.freeze({ids:Object.freeze([...this.#w.blacklist.ids]),authors:Object.freeze([...this.#w.blacklist.authors]),categories:Object.freeze([...this.#w.blacklist.categories]),tags:Object.freeze([...this.#w.blacklist.tags])})}get accessControlMode(){return this.#w.mode}constructor(e){super(e.logCfg),y(e,this.#w,this.#E)}canAccessEngine(e,t,r,i){const{mode:o,whitelist:s,blacklist:n}=this.#w;return m(o,e,t,r,i,s,n,this.#p)}async verifyPluginSignature(e,t,r,i,o){return w(this.#w,this.#p,e,t,r,i,o)}_addPlugin(e){if(!(e instanceof T))throw new TypeError("The provided plugin must be an instance of TinyPlugin.");if(!this.canAccessEngine(e.id,e.authors,e.categories,e.tags))throw new Error(`Security Error: Access to the core is denied for plugin "${e.id}" based on current access control rules.`);this.#v.set(e.id,e)}installPlugin(e,...t){return T._addModuleToCore(this,e,...t)}hasPlugin(e){return this.#v.has("string"==typeof e?e:e.id)}getPlugin(e){const t=this.#v.get(e);return t&&!t.isDestroyed?t:void 0}_getPlugin(e,t){if(!(t instanceof T))throw new TypeError("The provided external plugin must be an instance of TinyPlugin.");const r=this.#v.get(e);if(r&&!r.isDestroyed){if(!r.layer.canAccessLayer(t.id,t.authors,t.categories,t.tags))throw new Error(`Security Error: Access to the plugin "${e}" is denied for plugin "${t.id}" based on current plugin access control rules.`);return r}}destroyPlugins(){this.#p.clear(),this.#v.forEach(e=>e.destroy()),this.emit(L.#b)}}class T extends l{static#L={id:"[_main_class_TinyPlugin_reset_]",autoHideId:!0,logger:console,debugMode:!1,canEmitLogs:!1,useLogColors:!0};static get logCfg(){return{...T.#L}}static set logCfg(e){this.#L=e}static _addModuleToCore(e,t,...r){if(!(e instanceof L))throw new TypeError("The provided engine must be an instance of TinyPluginCore.");const i=new T({engine:e,installer:t,logCfg:{...T.#L,debugMode:e.debugMode}},...r);if(i._startPlugin(),e.hasPlugin(i))throw new Error(`A plugin with the name "${i.id}" is already registered.`);return e._addPlugin(i),i}#E={get:new Set,set:new Set};#T="";#C="";#S=new Set;#x=new Set;#O=new Set;#P=new Set;#_=null;#A;#j;#k;#y=!1;#M=null;#D=!1;#I=new Set;#z=new Set;get isDestroyed(){return this.#D}get plugins(){return c(this.#D),Object.keys(this.#A.plugins)}get pluginsSize(){return c(this.#D),this.#A.pluginsSize}getPlugin(e){return c(this.#D),this.#A._getPlugin(e,this)}hasPlugin(e){return c(this.#D),this.#A.hasPlugin(e)}get isReady(){return c(this.#D),this.#y}get id(){if(c(this.#D),0===this.#T.length)throw new Error("Plugin id is not set.");return this.#T}set id(e){if(c(this.#D),0!==this.#T.length)throw new Error("Id is already set.");if("string"!=typeof e)throw new TypeError("Id must be a string.");if(0===e.length)throw new TypeError("Id cannot be empty.");this.#T=e,this.logSubId=`${this.#A.logId} [_sub_class_${e}_reset_]`}get description(){if(c(this.#D),0===this.#C.length)throw new Error("Plugin description is not set.");return this.#C}set description(e){if(c(this.#D),0!==this.#C.length)throw new Error("Description is already set.");if("string"!=typeof e)throw new TypeError("Description must be a string.");if(0===e.length)throw new TypeError("Description cannot be empty.");this.#C=e}get authors(){if(c(this.#D),0===this.#S.size)throw new Error("Plugin authors is not set.");return Object.freeze([...this.#S])}set authors(e){if(c(this.#D),0!==this.#S.size)throw new Error("Authors is already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Authors must be a array of non-empty strings.");if(0===e.length)throw new TypeError("Authors cannot be empty.");e.forEach(e=>this.#S.add(e))}get contributors(){if(c(this.#D),0===this.#x.size)throw new Error("Plugin contributors is not set.");return Object.freeze([...this.#x])}set contributors(e){if(c(this.#D),0!==this.#x.size)throw new Error("Authors is already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Authors must be a array of non-empty strings.");if(0===e.length)throw new TypeError("Authors cannot be empty.");e.forEach(e=>this.#x.add(e))}get categories(){if(c(this.#D),0===this.#O.size)throw new Error("Plugin categories are not set.");return Object.freeze([...this.#O])}set categories(e){if(c(this.#D),0!==this.#O.size)throw new Error("Categories are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Categories must be an array of non-empty strings.");if(0===e.length)throw new TypeError("Categories cannot be empty.");e.forEach(e=>this.#O.add(e))}get tags(){if(c(this.#D),0===this.#P.size)throw new Error("Plugin tags are not set.");return Object.freeze([...this.#P])}set tags(e){if(c(this.#D),0!==this.#P.size)throw new Error("Tags are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Tags must be an array of non-empty strings.");if(0===e.length)throw new TypeError("Tags cannot be empty.");e.forEach(e=>this.#P.add(e))}get allowedSets(){return c(this.#D),[...this.#z]}set allowedSets(e){if(c(this.#D),0!==this.#z.size||this.#y)throw new Error("AllowedSets are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("AllowedSets must be an array of non-empty strings.");if(0===e.length)throw new TypeError("AllowedSets cannot be empty.");e.forEach(e=>this.#z.add(e))}get allowedGets(){return c(this.#D),[...this.#I]}set allowedGets(e){if(c(this.#D),0!==this.#I.size||this.#y)throw new Error("AllowedGets are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("AllowedGets must be an array of non-empty strings.");if(0===e.length)throw new TypeError("AllowedGets cannot be empty.");e.forEach(e=>this.#I.add(e))}get version(){if(c(this.#D),!this.#_)throw new Error("Plugin version is not set.");return this.#_.toString()}set version(e){if(c(this.#D),this.#_)throw new Error("Version is already set.");if("string"!=typeof e)throw new TypeError("Version must be a string.");if(0===e.length)throw new TypeError("Version cannot be empty.");this.#_=new h(e)}get tinyVersion(){if(c(this.#D),!this.#_)throw new Error("Plugin version is not set.");return this.#_}get layer(){if(c(this.#D),null===this.#M)throw new Error("Plugin layer is not set.");return this.#M._createSandbox([...this.#z],[...this.#I])}get engine(){if(c(this.#D),!this.#A.canAccessEngine(this.#T,[...this.#S],[...this.#O],[...this.#P]))throw new Error(`Security Error: Access to the engine is denied for plugin "${this.id}" based on current access control rules.`);const e=this.#E;return new Proxy(this.#A,{get(t,r){if(e.get.has(r))throw new Error(`Security Error: Access to property "${String(r)}" is denied by the sandbox.`);const i=Reflect.get(t,r,t);return"function"==typeof i?i.bind(t):i},set(t,r,i){if(e.set.has(r))throw new Error("Security Error: Cannot modify read-only properties on the plugin sandbox.");return Reflect.set(t,r,i)},setPrototypeOf(){throw new Error("Security Error: Prototype manipulation is forbidden.")}})}get options(){return c(this.#D),this.#k}get engineBlacklist(){return c(this.#D),this.#A.sandboxBlacklist}constructor({engine:e,logCfg:t,installer:r},...i){super(t),this.#A=e,this.#j=r,this.#k=i}#R(){const e=["id","version","description","authors","contributors","categories","tags","allowedGets","allowedSets"];return E(this,this.#A.sandboxBlacklist,this.#E,e,[...e,"tinyVersion","isReady","layer","options","engine","engineBlacklist","isDestroyed","pluginsSize","plugins","hasPlugin","getPlugin","log","logClear","logGroupEnd","logLabel","logTimeLabel","logAssert","logDir","logTable","toConsole","isDestroyed"],["getPlugin","_getPlugin","plugins","installPlugin","_addPlugin","destroyPlugins"],["accessControlMode","accessControlWhitelist","accessControlBlacklist","verifyPluginSignature","canAccessEngine"])}_startPlugin(){if(c(this.#D),this.#y)throw new Error("Plugin is already ready.");this.#k&&Object.freeze(this.#k);const e=this.#R();try{if(this.#M=this.#j(e,...this.#k),!(this.#M instanceof v))throw new TypeError("Plugin layer is not a valid TinyPluginLayer instance.");if(this.#M.debugMode=this.debugMode,this.#M.isReady||this.#M._startLayer(this),0===this.#T.length)throw new Error("Plugin id is not set.");if(0===this.#C.length)throw new Error("Plugin description is not set.");if(0===this.#S.size)throw new Error("Plugin authors are not set.");if(0===this.#x.size)throw new Error("Plugin contributors are not set.");if(0===this.#O.size)throw new Error("Plugin categories are not set.");if(0===this.#P.size)throw new Error("Plugin tags are not set.");if(!this.#_)throw new Error("Plugin version is not set.");this.#y=!0}catch(e){throw this.emit("error",e),this.destroy(),new Error(`Plugin initialization failed: ${e instanceof Error?e.message:"Unknown Error"}`)}}destroy(){this.#D||(this.emit("destroyed"),this.#M?.emit("destroyed"),this.#D=!0)}}window.TinyPluginPackage=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,{TinyPromiseQueue:()=>r});const r=class{#e=[];#t=!1;#r={};#i=new Set;isRunning(){return this.#t}async#s(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:r,reject:i,delay:s,id:n}=e;try{if(n&&this.#i.has(n))return i(new Error("The function was canceled on TinyPromiseQueue.")),this.#i.delete(n),this.#t=!1,void this.#n();s&&n&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#r[n],e(null)},s);this.#r[n]=t}),r(await t())}catch(e){i(e)}finally{this.#t=!1,this.#n()}}}async#u(){const e=[];for(;this.#e.length&&"POINT_MARKER"===this.#e[0]?.marker;)e.push(this.#e.shift());if(0===e.length)return this.#t=!1,void this.#n();await Promise.all(e.map(({task:e,resolve:t,reject:r,id:i})=>new Promise(async s=>{if(i&&this.#i.has(i))return this.#i.delete(i),r(new Error("The function was canceled on TinyPromiseQueue.")),void s(!0);await e().then(t).catch(r),s(!0)}))),this.#t=!1,this.#n()}async#n(){if(!this.#t&&0!==this.#e.length)if(this.#t=!0,"string"!=typeof this.#e[0]?.marker||"POINT_MARKER"!==this.#e[0]?.marker){const e=this.#e.shift();this.#s(e)}else this.#u()}getIndexById(e){return this.#e.findIndex(t=>t.id===e)}getQueuedIds(){return this.#e.map((e,t)=>({index:t,id:e.id})).filter(e=>"string"==typeof e.id)}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#e.length||t>=this.#e.length)return;const[r]=this.#e.splice(e,1);this.#e.splice(t,0,r)}async enqueuePoint(e,t){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&"string"!=typeof t)throw new Error('The "id" parameter must be a string.');return this.#t?new Promise((r,i)=>{this.#e.push({marker:"POINT_MARKER",task:e,resolve:r,reject:i,id:t}),this.#n()}):e()}enqueue(e,t,r){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&("number"!=typeof t||t<0))return Promise.reject(new Error("Delay must be a positive number or undefined."));if(void 0!==r&&"string"!=typeof r)throw new Error('The "id" parameter must be a string.');return new Promise((i,s)=>{this.#e.push({task:e,resolve:i,reject:s,id:r,delay:t}),this.#n()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#r&&(clearTimeout(this.#r[e]),delete this.#r[e],t=!0);const r=this.getIndexById(e);if(-1!==r){const[e]=this.#e.splice(r,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#i.add(e),t}};window.TinyPromiseQueue=t.TinyPromiseQueue})();
1
+ (()=>{"use strict";const e={d:(t,i)=>{for(var r in i)e.o(i,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:i[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyPromiseQueue:()=>i});const i=class{#e=[];#t=!1;#i={};#r=new Set;isRunning(){return this.#t}async#s(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:i,reject:r,delay:s,id:n}=e;try{if(n&&this.#r.has(n))return r(new Error("The function was canceled on TinyPromiseQueue.")),this.#r.delete(n),this.#t=!1,void this.#n();s&&n&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#i[n],e(null)},s);this.#i[n]=t}),i(await t())}catch(e){r(e)}finally{this.#t=!1,this.#n()}}}async#u(){const e=[];for(;this.#e.length&&"POINT_MARKER"===this.#e[0]?.marker;)e.push(this.#e.shift());if(0===e.length)return this.#t=!1,void this.#n();await Promise.all(e.map(({task:e,resolve:t,reject:i,id:r})=>new Promise(async s=>{if(r&&this.#r.has(r))return this.#r.delete(r),i(new Error("The function was canceled on TinyPromiseQueue.")),void s(!0);await e().then(t).catch(i),s(!0)}))),this.#t=!1,this.#n()}async#n(){if(!this.#t&&0!==this.#e.length)if(this.#t=!0,"string"!=typeof this.#e[0]?.marker||"POINT_MARKER"!==this.#e[0]?.marker){const e=this.#e.shift();this.#s(e)}else this.#u()}getIndexById(e){return this.#e.findIndex(t=>t.id===e)}getQueuedIds(){return this.#e.map((e,t)=>({index:t,id:e.id})).filter(e=>"string"==typeof e.id)}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#e.length||t>=this.#e.length)return;const[i]=this.#e.splice(e,1);this.#e.splice(t,0,i)}async enqueuePoint(e,t){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&"string"!=typeof t)throw new Error('The "id" parameter must be a string.');return this.#t?new Promise((i,r)=>{this.#e.push({marker:"POINT_MARKER",task:e,resolve:i,reject:r,id:t}),this.#n()}):e()}enqueue(e,t,i){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&("number"!=typeof t||t<0))return Promise.reject(new Error("Delay must be a positive number or undefined."));if(void 0!==i&&"string"!=typeof i)throw new Error('The "id" parameter must be a string.');return new Promise((r,s)=>{this.#e.push({task:e,resolve:r,reject:s,id:i,delay:t}),this.#n()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#i&&(clearTimeout(this.#i[e]),delete this.#i[e],t=!0);const i=this.getIndexById(e);if(-1!==i){const[e]=this.#e.splice(i,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#r.add(e),t}};window.TinyPromiseQueue=t.TinyPromiseQueue})();
@@ -0,0 +1 @@
1
+ (()=>{"use strict";const t={d:(e,i)=>{for(var s in i)t.o(i,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:i[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};let e={};t.d(e,{TinyPushManager:()=>n});const i=Object.freeze({NOTIFICATION:"notification",DATA:"data",SYNC:"sync",COMMAND:"command",UNKNOWN:"unknown"});class s{static#t=i;static get PUSH_TYPE(){return s.#t}static#e=null;static#i=null;static isSupported(){return"undefined"!=typeof globalThis&&"serviceWorker"in navigator&&"PushManager"in globalThis&&"Notification"in globalThis}static get permission(){return s.isSupported()?Notification.permission:"denied"}static async requestPermission(){if(!s.isSupported())throw new Error("[TinyPushManager] Push API is not supported in this browser.");return await(async()=>{if(!("Notification"in window))throw new Error("Notification API is not supported in this browser.");return"granted"===Notification.permission?"granted":"denied"===Notification.permission?"denied":await Notification.requestPermission()})()}static decodeVapidKey(t){if("string"!=typeof t||""===t)throw new TypeError("[TinyPushManager] decodeVapidKey: base64 must be a non-empty string.");if(s.#i===t&&s.#e)return s.#e;const e=(t+"=".repeat((4-t.length%4)%4)).replace(/-/g,"+").replace(/_/g,"/"),i=atob(e),n=Uint8Array.from(i,t=>t.charCodeAt(0));return s.#e=n,s.#i=t,n}#s;#n;#r;#o;#a;#u={status:"unsubscribed",subscription:null,error:null};constructor(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("[TinyPushManager] constructor: options must be a non-null object.");const{registration:e,vapidPublicKey:i,endpoints:s={},fetch:n,onChange:r}=t;if("object"!=typeof e||null===e)throw new TypeError("[TinyPushManager] constructor: options.registration is required.");if("string"!=typeof i||""===i)throw new TypeError("[TinyPushManager] constructor: options.vapidPublicKey is required.");if(void 0!==s.subscribe&&"string"!=typeof s.subscribe)throw new TypeError("[TinyPushManager] constructor: endpoints.subscribe must be a string.");if(void 0!==s.unsubscribe&&"string"!=typeof s.unsubscribe)throw new TypeError("[TinyPushManager] constructor: endpoints.unsubscribe must be a string.");if(void 0!==r&&"function"!=typeof r)throw new TypeError("[TinyPushManager] constructor: onChange must be a function.");this.#s=e,this.#n=i,this.#r=s,this.#o=n??globalThis.fetch.bind(globalThis),this.#a=r??null}get state(){return Object.freeze({...this.#u})}async getSubscription(){return s.isSupported()?this.#s.pushManager.getSubscription():null}async subscribe(t={}){if(!s.isSupported())throw new Error("[TinyPushManager] Push API is not supported in this browser.");this.#c({status:"pending",error:null});const e=await s.requestPermission();if("granted"!==e)throw this.#c({status:"denied",subscription:null}),new Error(`[TinyPushManager] Notification permission was not granted: ${e}.`);const i=await this.getSubscription()??await this.#s.pushManager.subscribe({...t,userVisibleOnly:!0,applicationServerKey:s.decodeVapidKey(this.#n)});return await this.#h(i),this.#c({status:"subscribed",subscription:i,error:null}),i}async unsubscribe(){const t=await this.getSubscription();return t?(this.#r.unsubscribe&&await this.#o(this.#r.unsubscribe,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({endpoint:t.endpoint})}).catch(()=>{}),await t.unsubscribe(),this.#c({status:"unsubscribed",subscription:null,error:null}),!0):(this.#c({status:"unsubscribed",subscription:null}),!1)}async syncWithServer(){const t=await this.getSubscription();return t?(await this.#h(t),this.#c({status:"subscribed",subscription:t,error:null}),t):null}async#h(t){if(!this.#r.subscribe)return;const e=await this.#o(this.#r.subscribe,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.toJSON())});if(!e.ok)throw new Error(`[TinyPushManager] Failed to upload subscription: ${e.status}.`)}#c(t){this.#u={...this.#u,...t},this.#a?.(this.state)}}const n=s;window.TinyPushManager=e.TinyPushManager})();
@@ -0,0 +1 @@
1
+ (()=>{"use strict";const t={d:(e,i)=>{for(var o in i)t.o(i,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:i[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};let e={};t.d(e,{TinyPushPayload:()=>a});const i=Object.freeze({NOTIFICATION:"notification",DATA:"data",SYNC:"sync",COMMAND:"command",UNKNOWN:"unknown"}),o=2419200;class n{static#t=i;static get PUSH_TYPE(){return n.#t}static VERSION=1;static MAX_TTL=o;static from(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("[TinyPushPayload] from: raw must be a non-null object.");const e=t,a="string"==typeof e.type&&""!==e.type?e.type:i.UNKNOWN,r={v:"number"==typeof e.v?e.v:n.VERSION,type:a};return"string"==typeof e.id&&(r.id=e.id),"string"==typeof e.topic&&(r.topic=e.topic),"number"==typeof e.expiresAt&&(r.expiresAt=e.expiresAt),"number"==typeof e.ttl&&Number.isFinite(e.ttl)&&(r.ttl=Math.min(Math.max(0,Math.trunc(e.ttl)),o)),"object"!=typeof e.data||null===e.data||Array.isArray(e.data)||(r.data=e.data),"object"==typeof e.notification&&null!==e.notification&&(r.notification=n.#e(e.notification)),Object.freeze(r)}static async fromEvent(t){if("object"!=typeof t||null===t||!("data"in t))throw new TypeError("[TinyPushPayload] fromEvent: event must be a PushEvent.");if(!t.data)return Object.freeze({v:n.VERSION,type:i.UNKNOWN});let e;try{e=await t.data.text()}catch{return Object.freeze({v:n.VERSION,type:i.UNKNOWN})}if(""===e)return Object.freeze({v:n.VERSION,type:i.UNKNOWN});try{return n.from(JSON.parse(e))}catch{return Object.freeze({v:n.VERSION,type:i.UNKNOWN,notification:{title:"Notification",body:e}})}}static isExpired(t,e=Date.now()){if("object"!=typeof t||null===t)throw new TypeError("[TinyPushPayload] isExpired: message must be a non-null object.");if("number"!=typeof e||!Number.isFinite(e))throw new TypeError("[TinyPushPayload] isExpired: now must be a finite number.");return"number"==typeof t.expiresAt&&t.expiresAt<=e}static toNotification(t,e={}){if("object"!=typeof t||null===t)throw new TypeError("[TinyPushPayload] toNotification: message must be a non-null object.");const i=t.notification??{title:"Notification"},{title:o,body:n,url:a,actions:r,data:c,...s}=i;return{title:o??"Notification",options:{...s,body:n??"",icon:i.icon??e.defaultIcon,badge:i.badge??e.defaultBadge,actions:r,data:{...c,url:a??e.defaultUrl??"/",actions:Object.fromEntries((r??[]).map(t=>[t.action,t.url??a??"/"])),pushId:t.id,pushType:t.type}}}}static#e(t){const e=t;if("string"!=typeof e.title||""===e.title.trim())throw new TypeError("[TinyPushPayload] notification.title must be a non-empty string.");return{...e}}}const a=n;window.TinyPushPayload=e.TinyPushPayload})();
@@ -0,0 +1 @@
1
+ (()=>{"use strict";const t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};let e={};t.d(e,{TinyPushRouter:()=>o});const r=Object.freeze({NOTIFICATION:"notification",DATA:"data",SYNC:"sync",COMMAND:"command",UNKNOWN:"unknown"});class n{static#t=r;static get PUSH_TYPE(){return n.#t}#e=new Map;#r=[];#n=[];#o=null;#s=null;use(t){if("function"!=typeof t)throw new TypeError("[TinyPushRouter] use: guard must be a function.");return this.#n.push(t),this}on(t,e){if("string"!=typeof t||""===t.trim())throw new TypeError("[TinyPushRouter] on: type must be a non-empty string.");if("function"!=typeof e)throw new TypeError("[TinyPushRouter] on: handler must be a function.");return this.#e.set(t,e),this}onMatch(t,e){if(!(t instanceof RegExp))throw new TypeError("[TinyPushRouter] onMatch: pattern must be a RegExp.");if("function"!=typeof e)throw new TypeError("[TinyPushRouter] onMatch: handler must be a function.");return this.#r.push({source:t.source,regex:t,handler:e}),this}otherwise(t){if("function"!=typeof t)throw new TypeError("[TinyPushRouter] otherwise: handler must be a function.");return this.#o=t,this}catch(t){if("function"!=typeof t)throw new TypeError("[TinyPushRouter] catch: handler must be a function.");return this.#s=t,this}has(t){return!!this.#e.has(t)||this.#r.some(({regex:e})=>e.test(t))}get size(){return this.#e.size+this.#r.length}async dispatch(t,e){if("object"!=typeof t||null===t)throw new TypeError("[TinyPushRouter] dispatch: message must be a non-null object.");if("object"!=typeof e||null===e)throw new TypeError("[TinyPushRouter] dispatch: context must be a non-null object.");try{for(const r of this.#n)if(!1===await r(t,e))return!0;const r=this.#e.get(t.type);if(r&&!1!==await r(t,e))return!0;for(const{regex:r,handler:n}of this.#r)if(r.test(t.type)&&!1!==await n(t,e))return!0;return!!this.#o&&(await this.#o(t,e),!0)}catch(e){if(this.#s)return this.#s(e,t),!0;throw e}}}const o=n;window.TinyPushRouter=e.TinyPushRouter})();
@@ -1 +1 @@
1
- (()=>{"use strict";var e={450(e,t,r){r.d(t,{TinyRadioFm:()=>k});var i=r.cjs(function(e,t){var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise(function(r,i){function o(r){e.removeListener(t,n),i(r)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}y(e,t,n,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,o)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function d(e,t,r,i){var o,n,s,a;if(u(r),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),s=n[t]),void 0===s)s=n[t]=r,++e._eventsCount;else if("function"==typeof s?s=n[t]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(o=l(e))>0&&s.length>o&&!s.warned){s.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=s.length,a=d,console&&console.warn&&console.warn(a)}return e}function c(){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 m(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=c.bind(i);return o.listener=r,i.wrapFn=o,o}function f(e,t,r){var i=e._events;if(void 0===i)return[];var o=i[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]: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}(o):p(o,o.length)}function h(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 p(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function y(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 o(n){i.once&&e.removeEventListener(t,o),r(n)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),s.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},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(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},s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,n=this._events;if(void 0!==n)i=i&&void 0===n.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=n[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var l=u.length,d=p(u,l);for(r=0;r<l;++r)o(d[r],this,t)}return!0},s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)},s.prototype.once=function(e,t){return u(t),this.on(e,m(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,m(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,i,o,n,s;if(u(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(o=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){s=r[n].listener,o=n;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},s.prototype.off=s.prototype.removeListener,s.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 o,n=Object.keys(r);for(i=0;i<n.length;++i)"removeListener"!==(o=n[i])&&this.removeAllListeners(o);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},s.prototype.listeners=function(e){return f(this,e,!0)},s.prototype.rawListeners=function(e){return f(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});function o(e){if(!Array.isArray(e)&&!n(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 n(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function s(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function a(e,t){if(void 0!==t.obj&&"function"!=typeof t.obj)throw new TypeError("filter.obj must be a function if provided.");if(void 0!==t.value&&"function"!=typeof t.value)throw new TypeError("filter.value must be a function if provided.");if(void 0!==t.array&&"function"!=typeof t.array)throw new TypeError("filter.array must be a function if provided.");let r;r=e instanceof Map?new Map:e instanceof Set?new Set:{};const i=(o=e)instanceof Map?Array.from(o.entries()):o instanceof Set?Array.from(o.values()).map(e=>[void 0,e]):Object.entries(o);var o;const n=(e,r)=>{const i=[];for(let o=0;o<e.length;o++){const u=e[o];if(Array.isArray(u))i.push(n(u,r));else if(s(u)){const r=a(u,t);(void 0===t.obj||t.obj(r,o,e))&&i.push(r)}else(void 0===t.value||t.value([r,u],o,e))&&i.push(u)}return i};for(let e=0;e<i.length;e++){const[o,u]=i[e];if(Array.isArray(u)){const s=n(u,o);(void 0===t.array||t.array([o,s],e,i))&&(r instanceof Map||r instanceof Set?r instanceof Map?r.set(o,s):r.add(s):r[o]=s)}else if(s(u)){const n=a(u,t);(void 0===t.obj||t.obj(n,e,i))&&(r instanceof Map?r.set(o,n):r instanceof Set?r.add(n):r[o]=n)}else(void 0===t.value||t.value([o,u],e,i))&&(r instanceof Map?r.set(o,u):r instanceof Set?r.add(u):r[o]=u)}return r}const u=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof e)throw new TypeError(`Expected "${t}" to be a string, but received ${typeof e}.`)},l=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof e)throw new TypeError(`Expected "${t}" to be a function, but received ${typeof e}.`)},d=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');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}.`)},c=(e,t=!1)=>!t&&void 0===e,m=(e,t=!1)=>c(e,t)||"string"==typeof e||!t&&null===e,f=(e,t=!1)=>c(e,t)||"number"==typeof e||!t&&null===e,h=(e,t=!1)=>c(e,t)||"boolean"==typeof e||!t&&null===e,p=(e,t)=>!!c(e)||(l(t,"valueValidator"),Array.isArray(e)&&e.every(t)),y=new Map;class g extends Error{constructor(e,t,r){if(u(e,"message"),u(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 w=async e=>{u(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)},b=(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}.`);u(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=y.get(t);return y.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 i=e.split(",")[1],o=atob(i),n=new Uint8Array(o.length);for(let e=0;e<o.length;e++)n[e]=o.charCodeAt(e);return r(new Blob([n],{type:t}))}return"string"==typeof e?e:""},v=async e=>{if(u(e,"url"),!e.startsWith("blob:"))return e;try{const t=await fetch(e),r=await t.blob();return await new Promise((e,t)=>{const i=new FileReader;i.onloadend=()=>e(String(i.result)),i.onerror=t,i.readAsDataURL(r)})}catch(t){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${e}`,t),e}},E=e=>{d(e,"content"),e&&Array.isArray(e.picture)&&e.picture.forEach(e=>{if("string"==typeof e.data&&e.data.startsWith("blob:")){const t=y.get(e.data)??0;t>1?y.set(e.data,t-1):y.delete(e.data),t<=1&&URL.revokeObjectURL(e.data)}})},T=(e,t=!1)=>{if(n(e)){if(4!==o(e)){if(t)return!1;throw new TypeError("Invalid fetch data: Object must be an MediaContentFetchData.")}M(e.common),d(e.native,"_fetchData.native"),d(e.format,"_fetchData.format"),d(e.quality,"_fetchData.quality");for(const r in e.native){const i=e.native[r];if(!p(i,e=>"string"==typeof e.id)){if(t)return!1;throw new TypeError(`Invalid native data: "${r}" must be an array of native fetch data.`)}}}return!0},M=e=>{if(d(e,"common"),T(e._fetchData),!m(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!m(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!m(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a a string or null.');if(!m(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(!h(e.compilation))throw new TypeError('Invalid metadata: "compilation" must be a boolean or null.');if(!h(e.podcast))throw new TypeError('Invalid metadata: "podcast" must be a boolean or null.');if(!h(e.gapless))throw new TypeError('Invalid metadata: "gapless" must be a boolean or null.');if(!h(e.showMovement))throw new TypeError('Invalid metadata: "showMovement" must be a boolean or null.');if(!f(e.averageLevel))throw new TypeError('Invalid metadata: "averageLevel" must be a number or null.');if(!f(e.peakLevel))throw new TypeError('Invalid metadata: "peakLevel" must be a number or null.');if(!f(e.hdVideo))throw new TypeError('Invalid metadata: "hdVideo" must be a number or null.');if(!f(e.stik))throw new TypeError('Invalid metadata: "stik" must be a number or null.');if(!f(e.playCounter))throw new TypeError('Invalid metadata: "playCounter" must be a number or null.');if(!f(e.tvSeason))throw new TypeError('Invalid metadata: "tvSeason" must be a number or null.');if(!f(e.tvEpisode))throw new TypeError('Invalid metadata: "tvEpisode" must be a number or null.');if(!f(e.year))throw new TypeError('Invalid metadata: "year" must be a number or null.');if(!f(e.bpm))throw new TypeError('Invalid metadata: "bpm" must be a number or null.');if(!f(e.originalyear))throw new TypeError('Invalid metadata: "originalyear" must be a number or null.');if(!f(e.movementTotal))throw new TypeError('Invalid metadata: "movementTotal" must be a number or null.');if(!m(e.date))throw new TypeError('Invalid metadata: "date" must be a string or null.');if(!m(e.originaldate))throw new TypeError('Invalid metadata: "originaldate" must be a string or null.');if(!m(e.releasedate))throw new TypeError('Invalid metadata: "releasedate" must be a string or null.');if(!m(e.albumsort))throw new TypeError('Invalid metadata: "albumsort" must be a string or null.');if(!m(e.titlesort))throw new TypeError('Invalid metadata: "titlesort" must be a string or null.');if(!m(e.work))throw new TypeError('Invalid metadata: "work" must be a string or null.');if(!m(e.artistsort))throw new TypeError('Invalid metadata: "artistsort" must be a string or null.');if(!m(e.albumartistsort))throw new TypeError('Invalid metadata: "albumartistsort" must be a string or null.');if(!m(e.composersort))throw new TypeError('Invalid metadata: "composersort" must be a string or null.');if(!m(e.grouping))throw new TypeError('Invalid metadata: "grouping" must be a string or null.');if(!m(e.longDescription))throw new TypeError('Invalid metadata: "longDescription" must be a string or null.');if(!m(e.totaltracks))throw new TypeError('Invalid metadata: "totaltracks" must be a string or null.');if(!m(e.totaldiscs))throw new TypeError('Invalid metadata: "totaldiscs" must be a string or null.');if(!m(e.mood))throw new TypeError('Invalid metadata: "mood" must be a string or null.');if(!m(e.media))throw new TypeError('Invalid metadata: "media" must be a string or null.');if(!m(e.tvShow))throw new TypeError('Invalid metadata: "tvShow" must be a string or null.');if(!m(e.tvShowSort))throw new TypeError('Invalid metadata: "tvShowSort" must be a string or null.');if(!m(e.tvEpisodeId))throw new TypeError('Invalid metadata: "tvEpisodeId" must be a string or null.');if(!m(e.tvNetwork))throw new TypeError('Invalid metadata: "tvNetwork" must be a string or null.');if(!m(e.podcasturl))throw new TypeError('Invalid metadata: "podcasturl" must be a string or null.');if(!m(e.releasestatus))throw new TypeError('Invalid metadata: "releasestatus" must be a string or null.');if(!m(e.releasecountry))throw new TypeError('Invalid metadata: "releasecountry" must be a string or null.');if(!m(e.script))throw new TypeError('Invalid metadata: "script" must be a string or null.');if(!m(e.language))throw new TypeError('Invalid metadata: "language" must be a string or null.');if(!m(e.copyright))throw new TypeError('Invalid metadata: "copyright" must be a string or null.');if(!m(e.license))throw new TypeError('Invalid metadata: "license" must be a string or null.');if(!m(e.encodedby))throw new TypeError('Invalid metadata: "encodedby" must be a string or null.');if(!m(e.encodersettings))throw new TypeError('Invalid metadata: "encodersettings" must be a string or null.');if(!m(e.barcode))throw new TypeError('Invalid metadata: "barcode" must be a string or null.');if(!m(e.asin))throw new TypeError('Invalid metadata: "asin" must be a string or null.');if(!m(e.website))throw new TypeError('Invalid metadata: "website" must be a string or null.');if(!m(e.originalalbum))throw new TypeError('Invalid metadata: "originalalbum" must be a string or null.');if(!m(e.originalartist))throw new TypeError('Invalid metadata: "originalartist" must be a string or null.');if(!m(e.key))throw new TypeError('Invalid metadata: "key" must be a string or null.');if(!m(e.movement))throw new TypeError('Invalid metadata: "movement" must be a string or null.');if(!m(e.podcastId))throw new TypeError('Invalid metadata: "podcastId" must be a string or null.');if(!p(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of strings.');if(!p(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of strings.');if(!p(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of strings.');if(!p(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of strings.');if(!p(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of strings.');if(!p(e.lyricist,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "lyricist" must be an array of strings.');if(!p(e.writer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "writer" must be an array of strings.');if(!p(e.conductor,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "conductor" must be an array of strings.');if(!p(e.remixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "remixer" must be an array of strings.');if(!p(e.arranger,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "arranger" must be an array of strings.');if(!p(e.engineer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "engineer" must be an array of strings.');if(!p(e.publisher,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "publisher" must be an array of strings.');if(!p(e.producer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "producer" must be an array of strings.');if(!p(e.djmixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "djmixer" must be an array of strings.');if(!p(e.mixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "mixer" must be an array of strings.');if(!p(e.technician,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "technician" must be an array of strings.');if(!p(e.subtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "subtitle" must be an array of strings.');if(!p(e.description,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "description" must be an array of strings.');if(!p(e.discsubtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "discsubtitle" must be an array of strings.');if(!p(e.releasetype,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "releasetype" must be an array of strings.');if(!p(e.isrc,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "isrc" must be an array of strings.');if(!p(e.performer_instrument,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "performer_instrument" must be an array of strings.');if(!p(e.notes,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "notes" must be an array of strings.');if(!p(e.category,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "category" must be an array of strings.');if(!p(e.keywords,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "keywords" must be an array of strings.');if(!p(e.catalognumber,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "catalognumber" must be an array of strings.');if(!p(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.');if(!p(e.comment,e=>null!==e&&"object"==typeof e&&m(e.descriptor)&&m(e.language)&&m(e.text)))throw new TypeError('Invalid metadata: "comment" must be an array of valid IComment objects.');if(!p(e.lyrics,e=>null!==e&&"object"==typeof e&&m(e.text)&&m(e.descriptor)&&m(e.language)&&(!Array.isArray(e)||p(e.syncText,e=>null!==e&&"object"==typeof e&&m(e.text)&&f(e.timestamp)))&&(e=>void 0===e||null!==e&&"object"==typeof e&&f(e.notSynchronized)&&f(e.mpegFrameNumber)&&f(e.milliseconds))(e.timeStampFormat)&&(e=>void 0===e||null!==e&&"object"==typeof e&&f(e.other)&&f(e.lyrics)&&f(e.text)&&f(e.movement_part)&&f(e.events)&&f(e.chord)&&f(e.trivia_pop))(e.contentType)))throw new TypeError('Invalid metadata: "lyrics" must be an array of valid ILyricsTag objects.');if(!p(e.rating,e=>null!==e&&"object"==typeof e&&m(e.source)&&f(e.rating)))throw new TypeError('Invalid metadata: "rating" must be an array of valid IRating objects.');const t=(e,t)=>{if(!c(t)&&null!==t){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.`)}};t("disk",e.disk),t("track",e.track),t("movementIndex",e.movementIndex)},I=async(e,t,r=!0)=>{u(e,"url"),l(t,"parseFile");const i=await fetch(e);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const n=await i.blob(),s=await t(n);if(!s||"object"!=typeof s.common)throw new TypeError('Invalid metadata: "common" property is missing.');void 0!==typeof s.common["performer:instrument"]&&(s.common.performer_instrument=s.common["performer:instrument"]),T(s);const d=s.common;M(d);const c=d?.picture?.map(e=>({...e,data:r?b(e.data,e.format):e.data}))??[];s.common={...s.common,picture:c.map(e=>({...e,data:""}))},r&&Object.keys(s.native).forEach(e=>{s.native[e]=s.native[e].map(e=>{if(e.value&&"object"==typeof e.value&&e.value.data instanceof Uint8Array){const t=d?.picture?.findIndex(t=>t.data===e.value.data&&t.format===e.value.format&&t.description===e.value.description&&t.name===e.value.name)??-1;if(c[t])return{...e,value:{...e.value,data:""}}}return e})});const m=a({title:d?.title,album:d?.album,albumartist:d?.albumartist,albumartists:d?.albumartists,genre:d?.genre,label:d?.label,composer:d?.composer,year:d?.year,artist:d?.artist,artists:d?.artists,disk:d?.disk?{no:d.disk.no,of:d.disk.of}:void 0,track:d?.track?{no:d.track.no,of:d.track.of}:void 0,movementIndex:d?.movementIndex?{no:d.movementIndex.no,of:d.movementIndex.of}:void 0,picture:c,date:d?.date,originaldate:d?.originaldate,originalyear:d?.originalyear,releasedate:d?.releasedate,comment:d?.comment,lyrics:d?.lyrics,albumsort:d?.albumsort,titlesort:d?.titlesort,work:d?.work,artistsort:d?.artistsort,albumartistsort:d?.albumartistsort,composersort:d?.composersort,lyricist:d?.lyricist,writer:d?.writer,conductor:d?.conductor,remixer:d?.remixer,arranger:d?.arranger,engineer:d?.engineer,publisher:d?.publisher,producer:d?.producer,djmixer:d?.djmixer,mixer:d?.mixer,technician:d?.technician,grouping:d?.grouping,subtitle:d?.subtitle,description:d?.description,longDescription:d?.longDescription,discsubtitle:d?.discsubtitle,totaltracks:d?.totaltracks,totaldiscs:d?.totaldiscs,movementTotal:d?.movementTotal,compilation:d?.compilation,rating:d?.rating,bpm:d?.bpm,mood:d?.mood,media:d?.media,catalognumber:d?.catalognumber,tvShow:d?.tvShow,tvShowSort:d?.tvShowSort,tvSeason:d?.tvSeason,tvEpisode:d?.tvEpisode,tvEpisodeId:d?.tvEpisodeId,tvNetwork:d?.tvNetwork,podcast:d?.podcast,podcasturl:d?.podcasturl,releasestatus:d?.releasestatus,releasetype:d?.releasetype,releasecountry:d?.releasecountry,script:d?.script,language:d?.language,copyright:d?.copyright,license:d?.license,encodedby:d?.encodedby,encodersettings:d?.encodersettings,gapless:d?.gapless,barcode:d?.barcode,isrc:d?.isrc,asin:d?.asin,website:d?.website,performer_instrument:d?.performer_instrument,averageLevel:d?.averageLevel,peakLevel:d?.peakLevel,notes:d?.notes,originalalbum:d?.originalalbum,originalartist:d?.originalartist,key:d?.key,category:d?.category,hdVideo:d?.hdVideo,keywords:d?.keywords,movement:d?.movement,podcastId:d?.podcastId,showMovement:d?.showMovement,stik:d?.stik,playCounter:d?.playCounter},{value:([e,t])=>null!=t,obj:e=>o(e)>0,array:([e,t])=>t.length>0});return m._fetchData=s,m},D=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},x=D("TinyAdvancedRaffle");class L extends i.EventEmitter{#e=!1;#t;#r;#i=[];#o=[];#n=[];#s=new Map;#a=new Set;#u=new Map;#l;#d=new Map;#c=new Map;get isDestroyed(){return this.#e}get freq(){return x(this.#e),Object.fromEntries(this.#c)}get size(){return x(this.#e),this.#d.size}get normalization(){return x(this.#e),this.#t}set normalization(e){if(x(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 x(this.#e),this.#r}set seed(e){if(x(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.#l=this._makeSeededRng(e))}get globalModifiers(){return x(this.#e),[...this.#i]}set globalModifiers(e){if(x(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 x(this.#e),[...this.#o]}set temporaryModifiers(e){if(x(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.#o=e}get conditionalRules(){return x(this.#e),[...this.#n]}set conditionalRules(e){if(x(this.#e),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#n=e}get pitySystems(){return x(this.#e),Object.fromEntries(this.#s)}set pitySystems(e){if(x(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.#s=e}get exclusions(){return x(this.#e),Array.from(this.#a)}set exclusions(e){if(x(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(){x(this.#e);const e={};return this.#u.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(x(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 x(this.#e),this.#l}set rng(e){if(x(this.#e),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#l=e}get items(){x(this.#e);const e={};return this.#d.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(x(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.#d=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.#l=t:null!==this.#r?this.#l=this._makeSeededRng(this.#r):this.#l=Math.random,this.#r=r??null}hasItem(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#d.has(e)}addItem(e,t={}){if(x(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:o={},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 o||null===o)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 s={id:e,label:i,baseWeight:Math.max(0,Number(r)||0),meta:{...o},groups:new Set(n),locked:!1};this.#d.set(e,s);for(const t of n)this._ensureGroup(t).add(e);return this.emit("itemAdded",s),s}removeItem(e){if(x(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#d.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#u.get(r);t&&t.delete(e)}return this.#d.delete(e),this.emit("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(x(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.#d.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(x(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#d.get(e)??null}listItems(){return x(this.#e),Array.from(this.#d.values()).map(e=>({...e}))}clearList(){x(this.#e),this.#d.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#i.includes(e)}addGlobalModifier(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");this.#i.push(e)}removeGlobalModifier(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");this.#i=this.#i.filter(t=>t!==e)}hasTemporaryModifier(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#o.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(x(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.#o.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#o.length;return this.#o=this.#o.filter(t=>t.fn!==e),this.#o.length!==t}hasConditionalRule(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#n.includes(e)}addConditionalRule(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#n.push(e)}removeConditionalRule(e){if(x(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#n.length;return this.#n=this.#n.filter(t=>t!==e),this.#n.length!==t}hasPity(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#s.has(e)}configurePity(e,t){if(x(this.#e),!this.#d.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:o=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 o)throw new TypeError("cap must be a number");this.#s.set(e,{threshold:Math.max(1,r),increment:Number(i)||0,cap:Number(o)||1/0,counter:0,currentAdd:0})}resetPity(e){if(x(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#s.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){x(this.#e),this.#s.clear()}hasExclusion(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#a.has(e)}excludeItem(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#a.add(e)}includeItem(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#a.delete(e)}_ensureGroup(e){if(x(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(x(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(x(this.#e),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#d.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(x(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.#d.get(e);i&&i.groups.delete(t)}clearFreqs(){x(this.#e),this.#c.clear()}resetFreq(e){if(x(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#c.delete(e)}computeEffectiveWeights(e={}){if(x(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.#d)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.#o){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.#n){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.#s)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 o=0;return t.map((e,t)=>{const n=r[t]/i;return o+=n,{id:e.id,weight:e.weight,p:n,cumulative:o}})}{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(x(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.#o]},r=this.computeEffectiveWeights(t),i=this._weightsToDistribution(r);if(!i.length)return null;const o=this.#l(),n=i.find(e=>o<=e.cumulative)??i[i.length-1];for(const[e,t]of this.#s)e===n.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const s=this.#d.get(n.id);if(!s)return null;const a={id:s.id,label:s.label,meta:{...s.meta},prob:n.p};return this.emit("draw",a),a&&this.#c.set(a.id,(this.#c.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){for(let e=this.#o.length-1;e>=0;--e){const t=this.#o[e];t.uses-=1,t.uses<=0&&this.#o.splice(e,1)}}drawMany(e=1,t={}){if(x(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,o=[],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;o.push(i),r.add(i.id),n.push(i)}return o}for(let i=0;i<e;++i){const e=this.drawOne({previousDraws:n,metadata:t.metadata});if(!e)break;o.push(e),n.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of o)this.includeItem(e.id);return o}exportToJson(){return x(this.#e),{items:Array.from(this.#d.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.#s.entries()),exclusions:Array.from(this.#a),normalization:this.#t,seed:this.#r}}loadFromJson(e){if(x(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.#d.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(){x(this.#e);const e=new L;return e.#t=this.#t,e.#r=this.#r,e.#i=[...this.#i],e.#o=this.#o.map(e=>({fn:e.fn,uses:e.uses})),e.#n=[...this.#n],e.#s=new Map([...this.#s.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.#l=this.#l,e.#d=new Map([...this.#d.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#c=new Map(this.#c),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.#s.clear(),this.#a.clear(),this.#u.clear(),this.#d.clear(),this.#c.clear(),this.#i=[],this.#o=[],this.#n=[],this.#r=null,this.#e=!0)}}const A=L,C=D("TinyRadioFm");class S extends i.EventEmitter{static async parseContent(e,t,r,i,o,s=!0){return(async(e,t={},r={},i=e=>{if(!(e instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((e,t)=>t(new TypeError("parseFile library not found.")))},o={},s=!0,a="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(d(t,"defaultMetadata"),d(r,"metadata"),l(i,"parseFile"),d(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 a&&"function"!=typeof a)throw new TypeError("unknownArtist must be a string or a function returning a string.");let c,m="";const f=(t,r)=>{if(u(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');o.onProgress&&o.onProgress({event:r,status:"loading",stage:t,url:m||(e instanceof HTMLMediaElement?e.src:"unknown")})},h=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');u(r,"stage"),o.onError&&o.onError({error:t instanceof Error?t:new Error(String(t)),url:m||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{f("INITIALIZING"),"string"==typeof e?(m=e,c=new Audio(m)):(c=e,m=c.src);try{await new Promise((e,t)=>{const r=e=>f("DOWNLOADING",e),i=()=>{n(),e(void 0)},o=e=>{n(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},n=()=>{c.removeEventListener("progress",r),c.removeEventListener("loadedmetadata",i),c.removeEventListener("error",o)};c.addEventListener("progress",r),c.addEventListener("loadedmetadata",i),c.addEventListener("error",o),c.readyState>=1&&(n(),e(void 0))}),f("METADATA_LOADED")}catch(e){throw new g(e instanceof Error?e.message:"UNKNOWN ERROR",m,"METADATA")}const l={id:r.id||await w(m),duration:Math.floor(1e3*c.duration),url:m,weight:r.weight??1};let d={};f("EXTRACTING_ID3");try{d=await I(m,i,s)}catch(e){h(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${m}. Falling back to filename.`)}const p=e=>{u(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},y=e=>{const t={...e};return n(t._fetchData)&&(n(d._fetchData)&&(t._fetchData={...d._fetchData}),n(e._fetchData)&&(void 0!==e._fetchData.common&&(t._fetchData.common=e._fetchData.common),void 0!==e._fetchData.native&&(t._fetchData.native=e._fetchData.native),void 0!==e._fetchData.format&&(t._fetchData.format=e._fetchData.format),void 0!==e._fetchData.quality&&(t._fetchData.quality=e._fetchData.quality))),t},b={...l,...y(t),...d,...y(r),title:d.title||r.title||p(m),artist:d.artist||r.artist||("string"==typeof a?a:String(a()))};return o.onProgress&&o.onProgress({status:"success",stage:"COMPLETE",url:m}),b}catch(e){if(e instanceof g)throw e;const t=new g(e instanceof Error?e.message:"UNKNOWN ERROR",m,"INITIALIZING");throw h(t,"INITIALIZING"),t}})(e,t,r,i,o,s,S.#m)}static#m="Unknown Artist";static get unknownArtist(){return S.#m}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");S.#m=e}#f=!1;get destroyed(){return this.#f}get size(){return C(this.#f),this.#h.length+this.#p.length}get musicSize(){return C(this.#f),this.#h.length}get voiceSize(){return C(this.#f),this.#p.length}get customPosSize(){return C(this.#f),this.#y.length}get tasksSize(){return C(this.#f),this.#g.length}get cycleCacheSize(){return C(this.#f),this.#w.size}#h=[];get musicList(){return C(this.#f),structuredClone(this.#h)}#p=[];get voiceList(){return C(this.#f),structuredClone(this.#p)}#y=[];get customPositions(){return C(this.#f),structuredClone(this.#y)}#g=[];get scheduledTasks(){return C(this.#f),structuredClone(this.#g)}get allList(){return C(this.#f),[...this.musicList,...this.voiceList]}#r=0;get seed(){return C(this.#f),this.#r}set seed(e){if(C(this.#f),"number"!=typeof e)throw new TypeError("Seed must be a number.");this.#r=e,this.#w.clear(),this.emit("seedChanged",{seed:e})}#b=Date.now();get anchorDate(){return C(this.#f),this.#b}#w=new Map;#v={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,voiceWeight:1,musicMaxConsecutive:0,musicMinConsecutive:0,voiceMaxConsecutive:0,voiceMinConsecutive:0};get config(){return C(this.#f),structuredClone(this.#v)}set config(e){C(this.#f),this.#E(e),this.#v=structuredClone(e),this.#w.clear(),this.emit("configChanged",{config:this.config})}#E(e){if("object"!=typeof e||null===e)throw new TypeError("Configuration must be a valid object.");const t=["playlist","random"];if(void 0!==e.mode&&!t.includes(e.mode))throw new TypeError(`Invalid mode: "${e.mode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.voiceMode&&!t.includes(e.voiceMode))throw new TypeError(`Invalid voiceMode: "${e.voiceMode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.silenceDuration&&("number"!=typeof e.silenceDuration||e.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==e.queryLimit&&("number"!=typeof e.queryLimit||e.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==e.voiceAfterMusic&&"boolean"!=typeof e.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");const r=(e,t)=>{if(void 0!==e&&("number"!=typeof e||e<0))throw new TypeError(`${t} must be a non-negative number.`)};r(e.voiceWeight,"voiceWeight"),r(e.voiceMin,"voiceMin"),r(e.voiceMax,"voiceMax"),r(e.musicMinConsecutive,"musicMinConsecutive"),r(e.musicMaxConsecutive,"musicMaxConsecutive"),r(e.voiceMinConsecutive,"voiceMinConsecutive"),r(e.voiceMaxConsecutive,"voiceMaxConsecutive");const i=e.voiceMin??this.#v.voiceMin,o=e.voiceMax??this.#v.voiceMax;if(o<i)throw new RangeError(`Logical error: voiceMax (${o}) cannot be less than voiceMin (${i}).`);const n=e.musicMinConsecutive??this.#v.musicMinConsecutive,s=e.musicMaxConsecutive??this.#v.musicMaxConsecutive;if(-1!==s&&n>s)throw new RangeError(`Logical error: musicMinConsecutive (${n}) cannot be greater than musicMaxConsecutive (${s}).`)}#T=!0;get optimizeMediaMemory(){return C(this.#f),this.#T}set optimizeMediaMemory(e){if(C(this.#f),"boolean"!=typeof e)throw new TypeError("optimizeMediaMemory must be a boolean.");this.#T=e}#M=!0;get optimizePictureMemory(){return C(this.#f),this.#M}set optimizePictureMemory(e){if(C(this.#f),"boolean"!=typeof e)throw new TypeError("optimizePictureMemory must be a boolean.");this.#M=e}constructor(e=null,t=0){if(super(),null!==e&&"object"!=typeof e)throw new TypeError("initialData must be an object or null.");if("number"!=typeof t)throw new TypeError("seed must be a number.");this.#r=t,e?this.#I(e):this.#b=Date.now()}_ccBase64ToBlobUrl(e){this.#T&&"string"==typeof e.url&&e.url.startsWith("data:")&&(e.url=b(e.url)),e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(e=>{if(this.#M){const t="string"==typeof e.data&&e.data.startsWith("data:"),r=e.data instanceof Uint8Array;if(t||r)return{...e,data:b(e.data,e.format)}}return e}))}async _rcblobUrlToBase64(e){this.#T&&"string"==typeof e.url&&e.url.startsWith("blob:")&&(e.url=await v(e.url)),this.#M&&e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async e=>"string"==typeof e.data&&e.data.startsWith("blob:")?{...e,data:await v(e.data)}:e)))}add(e,t,r=!0){if(C(this.#f),!["music","voice","custom"].includes(e))throw new TypeError('Type must be "music", "voice", or "custom".');if(!t||"string"!=typeof t.id||"number"!=typeof t.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof r)throw new TypeError("smartQueue must be a boolean.");M(t);const i=structuredClone(t);this._ccBase64ToBlobUrl(i),"music"===e?(this.#h.push(i),this.#w.clear()):"voice"===e?(this.#p.push(i),this.#w.clear()):"custom"===e&&this.#D(i,r),this.#x(Date.now()),this.emit("contentAdded",{type:e,data:structuredClone(i)})}scheduleTask(e,t,r,i,o=!0){if(C(this.#f),"number"!=typeof e||isNaN(e))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(t))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(r))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof o)throw new TypeError("smartQueue must be a boolean.");if("add"===t){if("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===t){if("string"!=typeof i)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===t&&("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let s=e;if(o){const t=this.#L(e,e);t&&(s=t.absoluteEnd)}n(i)&&"number"!=typeof i.newIndex&&M(i);const a={timestamp:s,action:t,type:r,payload:i};this.#g.push(a),this.#x(Date.now()),this.emit("taskScheduled",structuredClone(a))}remove(e){if(C(this.#f),"string"!=typeof e)throw new TypeError("id must be a string.");this.#h.filter(t=>t.id===e).forEach(e=>E(e)),this.#p.filter(t=>t.id===e).forEach(e=>E(e)),this.#y.filter(t=>t.content?.id===e).forEach(e=>E(e.content));const t=t=>t.id!==e&&t.content?.id!==e;this.#h=this.#h.filter(t),this.#p=this.#p.filter(t),this.#y=this.#y.filter(t),this.#g=this.#g.filter(t=>"add"===t.action&&"object"==typeof t.payload&&null!==t.payload&&"id"in t.payload?t.payload.id!==e||(E(t.payload),!1):t.payload!==e),this.#w.clear(),this.emit("contentRemoved",{id:e})}setConfig(e){C(this.#f),this.#E(e);const t={...this.#v,...e};this.#E(t),this.#v=t,this.#w.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){C(this.#f);const e=Date.now();return this.#x(e),this.#L(e,e)}queryTimeline(e,t=10){if(C(this.#f),"number"!=typeof t||isNaN(t))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(t>this.#v.queryLimit||t<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#v.queryLimit}.`);const r=new S(JSON.parse(this._exportState())),i=[];let o=e;for(let n=0;n<t;n++){r.#x(o);const t=r.#A(o,e);if(!t)break;i.push(t),o=t.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:e,limit:t,resultCount:i.length}),i}searchCustomPositions(){return C(this.#f),this.#x(Date.now()),[...this.#y]}async _processListForExport(e){return Promise.all(e.map(async e=>{M(e);const t=structuredClone(e);return await this._rcblobUrlToBase64(t),t}))}_exportState(){return JSON.stringify({music:this.#h,voice:this.#p,custom:this.#y,tasks:this.#g,seed:this.#r,anchorDate:this.#b,config:this.#v})}async exportState(){C(this.#f);const e=await this._processListForExport(this.#h),t=await this._processListForExport(this.#p),r=await Promise.all(this.#y.map(async e=>{const t=await this._processListForExport([e.content]);return{...e,content:t[0]}})),i=await Promise.all(this.#g.map(async e=>{if("add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload){const t=await this._processListForExport([e.payload]);return{...e,payload:t[0]}}return e}));return JSON.stringify({music:e,voice:t,custom:r,tasks:i,seed:this.#r,anchorDate:this.#b,config:this.#v})}importState(e){let t;if(C(this.#f),"string"==typeof e)try{t=JSON.parse(e)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof e||null===e)throw new TypeError("Import data must be a valid JSON string or an object.");t=e}this.#I(t),this.emit("stateImported",{data:structuredClone(t)})}_prng(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}#C(e,t,r,i=0,o=0,n=null,s=0){if(0===e.length)return{items:[],lastId:n,consecutiveCount:s};if("random"!==r){const t=[...e],r=t[t.length-1];return{items:t,lastId:r.id,consecutiveCount:n===r.id?s+1:1}}const a=this._prng(t),u=[];let l=n,d=s;const c=new A({rng:a,normalization:"relative"}),m=[...e];for(m.forEach(e=>{const t=e.weight??1,r=c.getItem(e.id);r?c.setBaseWeight(e.id,r.baseWeight+t):c.addItem(e.id,{weight:t})});m.length>0;){let e=null,t=-1;if(null!==l&&d<i&&(t=m.findIndex(e=>e.id===l),-1!==t?e=m[t]:u.length>0&&(e=u[u.length-1])),!e){let r=null;null!==l&&-1!==o&&d>=o&&m.some(e=>e.id!==l)&&(c.excludeItem(l),r=l);const i=c.drawOne();i&&(t=m.findIndex(e=>e.id===i.id),-1!==t&&(e=m[t])),r&&c.includeItem(r)}if(e||(e=m[0],t=0),u.push(e),-1!==t)if(m.splice(t,1),m.some(t=>t.id===e.id)){const t=c.getItem(e.id);if(t){const r=Math.max(0,t.baseWeight-(e.weight??1));r<=0?c.removeItem(e.id):c.setBaseWeight(e.id,r)}}else c.removeItem(e.id);e.id===l?d++:(l=e.id,d=1)}return c.destroy(),{items:u,lastId:l,consecutiveCount:d}}#S(e){const t=this.#r+e,r=this._prng(10*t);let i=null,o=0,n=null,s=0;if(e>0){const t=this.#w.get(e-1);t&&(i=t.lastMusicId??null,o=t.musicConsecutiveCount??0,n=t.lastVoiceId??null,s=t.voiceConsecutiveCount??0)}const a=this.#C(this.#h,t+1,this.#v.mode,this.#v.musicMinConsecutive,this.#v.musicMaxConsecutive,i,o),u=a.items,l=this.#C(this.#p,t+2,this.#v.voiceMode,this.#v.voiceMinConsecutive,this.#v.voiceMaxConsecutive,n,s),d=l.items,c=[];let m=0,f=0;for(let e=0;e<u.length;e++){const t=u[e];if(c.push({...t,cycleStart:m,cycleEnd:m+t.duration}),m+=t.duration+this.#v.silenceDuration,this.#v.voiceAfterMusic&&d.length>0){const e=this.#v.voiceWeight/(this.#v.voiceWeight+1);if(r()<e){const e=this.#v.voiceMax-this.#v.voiceMin+1,t=Math.floor(r()*e)+this.#v.voiceMin;for(let e=0;e<t;e++){const e=d[f%d.length];f++,c.push({...e,cycleStart:m,cycleEnd:m+e.duration}),m+=e.duration+this.#v.silenceDuration}}}}return{items:c,duration:m,lastMusicId:a.lastId,musicConsecutiveCount:a.consecutiveCount,lastVoiceId:l.lastId,voiceConsecutiveCount:l.consecutiveCount}}#k(e){if(0===this.#h.length)return null;let t=this.#b,r=0;for(;;){if(r>this.#v.queryLimit)throw new Error("Safety limit hit during cycle location.");let i=this.#w.get(r);if(i||(i=this.#S(r),this.#w.set(r,i)),0===i.duration)return null;if(e>=t&&e<t+i.duration)return{block:i,startTimestamp:t,loopIndex:r};t+=i.duration,r++}}#A(e,t){const r=this.#y.filter(t=>t.intendedTimestamp+t.content.duration>e).sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp)[0];let i=null;if(r){const e=Math.max(t,r.intendedTimestamp);i=this.#j(r.content,r.intendedTimestamp,e,!0)}const o=this.#_(e,t);return o||i?o?i?i.absoluteStart<=o.absoluteStart?i:(i.absoluteStart<o.absoluteEnd&&(o.absoluteEnd=i.absoluteStart,o.duration=o.absoluteEnd-o.absoluteStart,o.remainingTime=Math.max(0,o.absoluteEnd-t),o.progress=Math.min(1,o.elapsedTime/o.duration)),o):o:i:null}#_(e,t){let r=this.#k(e);if(!r)return null;const{block:i,startTimestamp:o}=r,n=e-o;let s,a=i.items.find(e=>e.cycleEnd>n);if(a)s=o+a.cycleStart;else{if(r=this.#k(o+i.duration),!r||0===r.block.items.length)return null;a=r.block.items[0],s=r.startTimestamp+a.cycleStart}const u=Math.max(t,s);return this.#j(a,s,u,!1)}#L(e,t){const r=this.#y.find(t=>e>=t.intendedTimestamp&&e<t.intendedTimestamp+t.content.duration);if(r)return this.#j(r.content,r.intendedTimestamp,t,!0);const i=this.#k(e);if(!i)return null;const{block:o,startTimestamp:n}=i,s=e-n,a=o.items.find(e=>s>=e.cycleStart&&s<e.cycleEnd);return a?this.#j(a,n+a.cycleStart,t,!1):null}#j(e,t,r,i){const o=r-t;return{id:e.id,title:e.title,artist:e.artist,duration:e.duration,url:e.url,absoluteStart:t,absoluteEnd:t+e.duration,elapsedTime:o,remainingTime:e.duration-o,progress:Math.min(1,o/e.duration),isCustom:i}}#D(e,t){let r=e.timestamp||Date.now();const i=e.duration;if(t){const e=this.#L(r,r);e&&(r=e.absoluteEnd)}const o=[...this.#y].sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp);let n=r;if(o.some(e=>r<e.intendedTimestamp+e.content.duration&&r+i>e.intendedTimestamp)){const e=[];let t=Date.now();for(const r of o)r.intendedTimestamp>t&&e.push({start:t,end:r.intendedTimestamp}),t=Math.max(t,r.intendedTimestamp+r.content.duration+this.#v.silenceDuration);e.push({start:t,end:1/0});let s=1/0;for(const t of e)if(t.end-t.start>=i){let e=null;if(r>=t.start&&r+i<=t.end?e=r:r<t.start?e=t.start:r>t.end&&(e=t.end-i),null!==e){const t=Math.abs(r-e);t<s&&(s=t,n=e)}}}this.#y.push({content:e,intendedTimestamp:n,originalTimestamp:e.timestamp||Date.now()})}#x(e){const t=this.#g.filter(t=>t.timestamp<=e);this.#g=this.#g.filter(t=>t.timestamp>e);const r=this.#y.filter(t=>t.intendedTimestamp+t.content.duration<=e);this.#y=this.#y.filter(t=>t.intendedTimestamp+t.content.duration>e);let i=!1;r.forEach(e=>{E(e.content),this.#r+=e.content.id.length,i=!0,this.emit("customPositionExpired",{contentId:e.content.id})}),t.length>0&&t.sort((e,t)=>e.timestamp-t.timestamp).forEach(e=>{const t="music"===e.type?this.#h:this.#p;if("add"===e.action)t.push(e.payload);else if("remove"===e.action){const r=t.findIndex(t=>t.id===e.payload);if(-1!==r){const[e]=t.splice(r,1);E(e)}}else if("move"===e.action){const r=e.payload,i=t.findIndex(e=>e.id===r.id);if(-1!==i){const[e]=t.splice(i,1);t.splice(r.newIndex,0,e)}}this.#b=e.timestamp,this.#r+=1,i=!0,this.emit("taskExecuted",structuredClone(e))}),i&&this.#w.clear()}#I(e){this.#h.forEach(e=>E(e)),this.#p.forEach(e=>E(e)),this.#y.forEach(e=>E(e.content)),this.#g.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&E(e.payload)});const t=e=>e.map(e=>{M(e);const t=structuredClone(e);return this._ccBase64ToBlobUrl(t),t});this.#h=t(e.music),this.#p=t(e.voice),this.#r=e.seed||0,this.#b=e.anchorDate||Date.now(),this.#v={...this.#v,...e.config||{}},this.#y=e.custom.map(e=>({...e,content:t([e.content])[0]})),this.#g=e.tasks.map(e=>"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload?{...e,payload:t([e.payload])[0]}:e)}destroy(e=!0){this.#f||(e&&(this.#h.forEach(e=>E(e)),this.#p.forEach(e=>E(e)),this.#y.forEach(e=>E(e.content)),this.#g.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&E(e.payload)})),this.#h=[],this.#p=[],this.#y=[],this.#g=[],this.#w.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#f=!0)}}const k=S}};const t={};function r(i){const o=t[i];if(void 0!==o)return o.exports;const n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var i=0;i<t.length;){var o=t[i++],n=t[i++];r.o(e,o)?0===n&&i++:0===n?Object.defineProperty(e,o,{enumerable:!0,value:t[i++]}):Object.defineProperty(e,o,{enumerable:!0,get:n})}else for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.cjs=e=>{const t={exports:{}};return e.call(t.exports,t,t.exports),t.exports};let i=r(450);window.TinyRadioFm=i.TinyRadioFm})();
1
+ (()=>{"use strict";const e={cw:e=>{var t;return()=>{if(e){var r=e;e=0,t={exports:{}},r.call(t.exports,t,t.exports)}return t.exports}},d:(t,r)=>{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,{TinyRadioFm:()=>j});var r=e.cw(function(e,t){var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise(function(r,i){function o(r){e.removeListener(t,n),i(r)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}y(e,t,n,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,o)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function d(e,t,r,i){var o,n,s,a;if(u(r),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),s=n[t]),void 0===s)s=n[t]=r,++e._eventsCount;else if("function"==typeof s?s=n[t]=i?[r,s]:[s,r]:i?s.unshift(r):s.push(r),(o=l(e))>0&&s.length>o&&!s.warned){s.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=s.length,a=d,console&&console.warn&&console.warn(a)}return e}function c(){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 m(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=c.bind(i);return o.listener=r,i.wrapFn=o,o}function f(e,t,r){var i=e._events;if(void 0===i)return[];var o=i[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]: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}(o):p(o,o.length)}function h(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 p(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function y(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 o(n){i.once&&e.removeEventListener(t,o),r(n)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),s.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},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(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},s.prototype.getMaxListeners=function(){return l(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,n=this._events;if(void 0!==n)i=i&&void 0===n.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=n[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var l=u.length,d=p(u,l);for(r=0;r<l;++r)o(d[r],this,t)}return!0},s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)},s.prototype.once=function(e,t){return u(t),this.on(e,m(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return u(t),this.prependListener(e,m(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,i,o,n,s;if(u(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(o=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){s=r[n].listener,o=n;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,s||t)}return this},s.prototype.off=s.prototype.removeListener,s.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 o,n=Object.keys(r);for(i=0;i<n.length;++i)"removeListener"!==(o=n[i])&&this.removeAllListeners(o);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},s.prototype.listeners=function(e){return f(this,e,!0)},s.prototype.rawListeners=function(e){return f(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});function i(e){if(!Array.isArray(e)&&!o(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 o(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}function n(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function s(e,t){if(void 0!==t.obj&&"function"!=typeof t.obj)throw new TypeError("filter.obj must be a function if provided.");if(void 0!==t.value&&"function"!=typeof t.value)throw new TypeError("filter.value must be a function if provided.");if(void 0!==t.array&&"function"!=typeof t.array)throw new TypeError("filter.array must be a function if provided.");let r;r=e instanceof Map?new Map:e instanceof Set?new Set:{};const i=(o=e)instanceof Map?Array.from(o.entries()):o instanceof Set?Array.from(o.values()).map(e=>[void 0,e]):Object.entries(o);var o;const a=(e,r)=>{const i=[];for(let o=0;o<e.length;o++){const u=e[o];if(Array.isArray(u))i.push(a(u,r));else if(n(u)){const r=s(u,t);(void 0===t.obj||t.obj(r,o,e))&&i.push(r)}else(void 0===t.value||t.value([r,u],o,e))&&i.push(u)}return i};for(let e=0;e<i.length;e++){const[o,u]=i[e];if(Array.isArray(u)){const n=a(u,o);(void 0===t.array||t.array([o,n],e,i))&&(r instanceof Map||r instanceof Set?r instanceof Map?r.set(o,n):r.add(n):r[o]=n)}else if(n(u)){const n=s(u,t);(void 0===t.obj||t.obj(n,e,i))&&(r instanceof Map?r.set(o,n):r instanceof Set?r.add(n):r[o]=n)}else(void 0===t.value||t.value([o,u],e,i))&&(r instanceof Map?r.set(o,u):r instanceof Set?r.add(u):r[o]=u)}return r}r();const a=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof e)throw new TypeError(`Expected "${t}" to be a string, but received ${typeof e}.`)},u=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof e)throw new TypeError(`Expected "${t}" to be a function, but received ${typeof e}.`)},l=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');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}.`)},d=(e,t=!1)=>!t&&void 0===e,c=(e,t=!1)=>d(e,t)||"string"==typeof e||!t&&null===e,m=(e,t=!1)=>d(e,t)||"number"==typeof e||!t&&null===e,f=(e,t=!1)=>d(e,t)||"boolean"==typeof e||!t&&null===e,h=(e,t)=>!!d(e)||(u(t,"valueValidator"),Array.isArray(e)&&e.every(t)),p=new Map;class y extends Error{constructor(e,t,r){if(a(e,"message"),a(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 g=async e=>{a(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)},w=(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}.`);a(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=p.get(t);return p.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 i=e.split(",")[1],o=atob(i),n=new Uint8Array(o.length);for(let e=0;e<o.length;e++)n[e]=o.charCodeAt(e);return r(new Blob([n],{type:t}))}return"string"==typeof e?e:""},b=async e=>{if(a(e,"url"),!e.startsWith("blob:"))return e;try{const t=await fetch(e),r=await t.blob();return await new Promise((e,t)=>{const i=new FileReader;i.onloadend=()=>e(String(i.result)),i.onerror=t,i.readAsDataURL(r)})}catch(t){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${e}`,t),e}},v=e=>{l(e,"content"),e&&Array.isArray(e.picture)&&e.picture.forEach(e=>{if("string"==typeof e.data&&e.data.startsWith("blob:")){const t=p.get(e.data)??0;t>1?p.set(e.data,t-1):p.delete(e.data),t<=1&&URL.revokeObjectURL(e.data)}})},E=(e,t=!1)=>{if(o(e)){if(4!==i(e)){if(t)return!1;throw new TypeError("Invalid fetch data: Object must be an MediaContentFetchData.")}T(e.common),l(e.native,"_fetchData.native"),l(e.format,"_fetchData.format"),l(e.quality,"_fetchData.quality");for(const r in e.native){const i=e.native[r];if(!h(i,e=>"string"==typeof e.id)){if(t)return!1;throw new TypeError(`Invalid native data: "${r}" must be an array of native fetch data.`)}}}return!0},T=e=>{if(l(e,"common"),E(e._fetchData),!c(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!c(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!c(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a a string or null.');if(!c(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(!f(e.compilation))throw new TypeError('Invalid metadata: "compilation" must be a boolean or null.');if(!f(e.podcast))throw new TypeError('Invalid metadata: "podcast" must be a boolean or null.');if(!f(e.gapless))throw new TypeError('Invalid metadata: "gapless" must be a boolean or null.');if(!f(e.showMovement))throw new TypeError('Invalid metadata: "showMovement" must be a boolean or null.');if(!m(e.averageLevel))throw new TypeError('Invalid metadata: "averageLevel" must be a number or null.');if(!m(e.peakLevel))throw new TypeError('Invalid metadata: "peakLevel" must be a number or null.');if(!m(e.hdVideo))throw new TypeError('Invalid metadata: "hdVideo" must be a number or null.');if(!m(e.stik))throw new TypeError('Invalid metadata: "stik" must be a number or null.');if(!m(e.playCounter))throw new TypeError('Invalid metadata: "playCounter" must be a number or null.');if(!m(e.tvSeason))throw new TypeError('Invalid metadata: "tvSeason" must be a number or null.');if(!m(e.tvEpisode))throw new TypeError('Invalid metadata: "tvEpisode" must be a number or null.');if(!m(e.year))throw new TypeError('Invalid metadata: "year" must be a number or null.');if(!m(e.bpm))throw new TypeError('Invalid metadata: "bpm" must be a number or null.');if(!m(e.originalyear))throw new TypeError('Invalid metadata: "originalyear" must be a number or null.');if(!m(e.movementTotal))throw new TypeError('Invalid metadata: "movementTotal" must be a number or null.');if(!c(e.date))throw new TypeError('Invalid metadata: "date" must be a string or null.');if(!c(e.originaldate))throw new TypeError('Invalid metadata: "originaldate" must be a string or null.');if(!c(e.releasedate))throw new TypeError('Invalid metadata: "releasedate" must be a string or null.');if(!c(e.albumsort))throw new TypeError('Invalid metadata: "albumsort" must be a string or null.');if(!c(e.titlesort))throw new TypeError('Invalid metadata: "titlesort" must be a string or null.');if(!c(e.work))throw new TypeError('Invalid metadata: "work" must be a string or null.');if(!c(e.artistsort))throw new TypeError('Invalid metadata: "artistsort" must be a string or null.');if(!c(e.albumartistsort))throw new TypeError('Invalid metadata: "albumartistsort" must be a string or null.');if(!c(e.composersort))throw new TypeError('Invalid metadata: "composersort" must be a string or null.');if(!c(e.grouping))throw new TypeError('Invalid metadata: "grouping" must be a string or null.');if(!c(e.longDescription))throw new TypeError('Invalid metadata: "longDescription" must be a string or null.');if(!c(e.totaltracks))throw new TypeError('Invalid metadata: "totaltracks" must be a string or null.');if(!c(e.totaldiscs))throw new TypeError('Invalid metadata: "totaldiscs" must be a string or null.');if(!c(e.mood))throw new TypeError('Invalid metadata: "mood" must be a string or null.');if(!c(e.media))throw new TypeError('Invalid metadata: "media" must be a string or null.');if(!c(e.tvShow))throw new TypeError('Invalid metadata: "tvShow" must be a string or null.');if(!c(e.tvShowSort))throw new TypeError('Invalid metadata: "tvShowSort" must be a string or null.');if(!c(e.tvEpisodeId))throw new TypeError('Invalid metadata: "tvEpisodeId" must be a string or null.');if(!c(e.tvNetwork))throw new TypeError('Invalid metadata: "tvNetwork" must be a string or null.');if(!c(e.podcasturl))throw new TypeError('Invalid metadata: "podcasturl" must be a string or null.');if(!c(e.releasestatus))throw new TypeError('Invalid metadata: "releasestatus" must be a string or null.');if(!c(e.releasecountry))throw new TypeError('Invalid metadata: "releasecountry" must be a string or null.');if(!c(e.script))throw new TypeError('Invalid metadata: "script" must be a string or null.');if(!c(e.language))throw new TypeError('Invalid metadata: "language" must be a string or null.');if(!c(e.copyright))throw new TypeError('Invalid metadata: "copyright" must be a string or null.');if(!c(e.license))throw new TypeError('Invalid metadata: "license" must be a string or null.');if(!c(e.encodedby))throw new TypeError('Invalid metadata: "encodedby" must be a string or null.');if(!c(e.encodersettings))throw new TypeError('Invalid metadata: "encodersettings" must be a string or null.');if(!c(e.barcode))throw new TypeError('Invalid metadata: "barcode" must be a string or null.');if(!c(e.asin))throw new TypeError('Invalid metadata: "asin" must be a string or null.');if(!c(e.website))throw new TypeError('Invalid metadata: "website" must be a string or null.');if(!c(e.originalalbum))throw new TypeError('Invalid metadata: "originalalbum" must be a string or null.');if(!c(e.originalartist))throw new TypeError('Invalid metadata: "originalartist" must be a string or null.');if(!c(e.key))throw new TypeError('Invalid metadata: "key" must be a string or null.');if(!c(e.movement))throw new TypeError('Invalid metadata: "movement" must be a string or null.');if(!c(e.podcastId))throw new TypeError('Invalid metadata: "podcastId" must be a string or null.');if(!h(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of strings.');if(!h(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of strings.');if(!h(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of strings.');if(!h(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of strings.');if(!h(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of strings.');if(!h(e.lyricist,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "lyricist" must be an array of strings.');if(!h(e.writer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "writer" must be an array of strings.');if(!h(e.conductor,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "conductor" must be an array of strings.');if(!h(e.remixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "remixer" must be an array of strings.');if(!h(e.arranger,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "arranger" must be an array of strings.');if(!h(e.engineer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "engineer" must be an array of strings.');if(!h(e.publisher,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "publisher" must be an array of strings.');if(!h(e.producer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "producer" must be an array of strings.');if(!h(e.djmixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "djmixer" must be an array of strings.');if(!h(e.mixer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "mixer" must be an array of strings.');if(!h(e.technician,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "technician" must be an array of strings.');if(!h(e.subtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "subtitle" must be an array of strings.');if(!h(e.description,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "description" must be an array of strings.');if(!h(e.discsubtitle,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "discsubtitle" must be an array of strings.');if(!h(e.releasetype,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "releasetype" must be an array of strings.');if(!h(e.isrc,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "isrc" must be an array of strings.');if(!h(e.performer_instrument,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "performer_instrument" must be an array of strings.');if(!h(e.notes,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "notes" must be an array of strings.');if(!h(e.category,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "category" must be an array of strings.');if(!h(e.keywords,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "keywords" must be an array of strings.');if(!h(e.catalognumber,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "catalognumber" must be an array of strings.');if(!h(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.');if(!h(e.comment,e=>null!==e&&"object"==typeof e&&c(e.descriptor)&&c(e.language)&&c(e.text)))throw new TypeError('Invalid metadata: "comment" must be an array of valid IComment objects.');if(!h(e.lyrics,e=>null!==e&&"object"==typeof e&&c(e.text)&&c(e.descriptor)&&c(e.language)&&(!Array.isArray(e)||h(e.syncText,e=>null!==e&&"object"==typeof e&&c(e.text)&&m(e.timestamp)))&&(e=>void 0===e||null!==e&&"object"==typeof e&&m(e.notSynchronized)&&m(e.mpegFrameNumber)&&m(e.milliseconds))(e.timeStampFormat)&&(e=>void 0===e||null!==e&&"object"==typeof e&&m(e.other)&&m(e.lyrics)&&m(e.text)&&m(e.movement_part)&&m(e.events)&&m(e.chord)&&m(e.trivia_pop))(e.contentType)))throw new TypeError('Invalid metadata: "lyrics" must be an array of valid ILyricsTag objects.');if(!h(e.rating,e=>null!==e&&"object"==typeof e&&c(e.source)&&m(e.rating)))throw new TypeError('Invalid metadata: "rating" must be an array of valid IRating objects.');const t=(e,t)=>{if(!d(t)&&null!==t){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.`)}};t("disk",e.disk),t("track",e.track),t("movementIndex",e.movementIndex)},M=async(e,t,r=!0)=>{a(e,"url"),u(t,"parseFile");const o=await fetch(e);if(!o.ok)throw new Error(`Failed to fetch audio file: ${o.status} ${o.statusText}`);const n=await o.blob(),l=await t(n);if(!l||"object"!=typeof l.common)throw new TypeError('Invalid metadata: "common" property is missing.');void 0!==typeof l.common["performer:instrument"]&&(l.common.performer_instrument=l.common["performer:instrument"]),E(l);const d=l.common;T(d);const c=d?.picture?.map(e=>({...e,data:r?w(e.data,e.format):e.data}))??[];l.common={...l.common,picture:c.map(e=>({...e,data:""}))},r&&Object.keys(l.native).forEach(e=>{l.native[e]=l.native[e].map(e=>{if(e.value&&"object"==typeof e.value&&e.value.data instanceof Uint8Array){const t=d?.picture?.findIndex(t=>t.data===e.value.data&&t.format===e.value.format&&t.description===e.value.description&&t.name===e.value.name)??-1;if(c[t])return{...e,value:{...e.value,data:""}}}return e})});const m=s({title:d?.title,album:d?.album,albumartist:d?.albumartist,albumartists:d?.albumartists,genre:d?.genre,label:d?.label,composer:d?.composer,year:d?.year,artist:d?.artist,artists:d?.artists,disk:d?.disk?{no:d.disk.no,of:d.disk.of}:void 0,track:d?.track?{no:d.track.no,of:d.track.of}:void 0,movementIndex:d?.movementIndex?{no:d.movementIndex.no,of:d.movementIndex.of}:void 0,picture:c,date:d?.date,originaldate:d?.originaldate,originalyear:d?.originalyear,releasedate:d?.releasedate,comment:d?.comment,lyrics:d?.lyrics,albumsort:d?.albumsort,titlesort:d?.titlesort,work:d?.work,artistsort:d?.artistsort,albumartistsort:d?.albumartistsort,composersort:d?.composersort,lyricist:d?.lyricist,writer:d?.writer,conductor:d?.conductor,remixer:d?.remixer,arranger:d?.arranger,engineer:d?.engineer,publisher:d?.publisher,producer:d?.producer,djmixer:d?.djmixer,mixer:d?.mixer,technician:d?.technician,grouping:d?.grouping,subtitle:d?.subtitle,description:d?.description,longDescription:d?.longDescription,discsubtitle:d?.discsubtitle,totaltracks:d?.totaltracks,totaldiscs:d?.totaldiscs,movementTotal:d?.movementTotal,compilation:d?.compilation,rating:d?.rating,bpm:d?.bpm,mood:d?.mood,media:d?.media,catalognumber:d?.catalognumber,tvShow:d?.tvShow,tvShowSort:d?.tvShowSort,tvSeason:d?.tvSeason,tvEpisode:d?.tvEpisode,tvEpisodeId:d?.tvEpisodeId,tvNetwork:d?.tvNetwork,podcast:d?.podcast,podcasturl:d?.podcasturl,releasestatus:d?.releasestatus,releasetype:d?.releasetype,releasecountry:d?.releasecountry,script:d?.script,language:d?.language,copyright:d?.copyright,license:d?.license,encodedby:d?.encodedby,encodersettings:d?.encodersettings,gapless:d?.gapless,barcode:d?.barcode,isrc:d?.isrc,asin:d?.asin,website:d?.website,performer_instrument:d?.performer_instrument,averageLevel:d?.averageLevel,peakLevel:d?.peakLevel,notes:d?.notes,originalalbum:d?.originalalbum,originalartist:d?.originalartist,key:d?.key,category:d?.category,hdVideo:d?.hdVideo,keywords:d?.keywords,movement:d?.movement,podcastId:d?.podcastId,showMovement:d?.showMovement,stik:d?.stik,playCounter:d?.playCounter},{value:([e,t])=>null!=t,obj:e=>i(e)>0,array:([e,t])=>t.length>0});return m._fetchData=l,m},I=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},D=I("TinyAdvancedRaffle"),x=r().EventEmitter;class L extends x{#e=!1;#t;#r;#i=[];#o=[];#n=[];#s=new Map;#a=new Set;#u=new Map;#l;#d=new Map;#c=new Map;get isDestroyed(){return this.#e}get freq(){return D(this.#e),Object.fromEntries(this.#c)}get size(){return D(this.#e),this.#d.size}get normalization(){return D(this.#e),this.#t}set normalization(e){if(D(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 D(this.#e),this.#r}set seed(e){if(D(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.#l=this._makeSeededRng(e))}get globalModifiers(){return D(this.#e),[...this.#i]}set globalModifiers(e){if(D(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 D(this.#e),[...this.#o]}set temporaryModifiers(e){if(D(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.#o=e}get conditionalRules(){return D(this.#e),[...this.#n]}set conditionalRules(e){if(D(this.#e),!Array.isArray(e)||!e.every(e=>"function"==typeof e))throw new TypeError("conditionalRules must be an array of functions (WeightsCallback).");this.#n=e}get pitySystems(){return D(this.#e),Object.fromEntries(this.#s)}set pitySystems(e){if(D(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.#s=e}get exclusions(){return D(this.#e),Array.from(this.#a)}set exclusions(e){if(D(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(){D(this.#e);const e={};return this.#u.forEach((t,r)=>e[r]=Array.from(t)),e}set groups(e){if(D(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 D(this.#e),this.#l}set rng(e){if(D(this.#e),"function"!=typeof e||"number"!=typeof e())throw new TypeError("rng must be a function returning a number (RngGenerator).");this.#l=e}get items(){D(this.#e);const e={};return this.#d.forEach((t,r)=>{e[r]={...t,groups:Array.from(t.groups)}}),e}set items(e){if(D(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.#d=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.#l=t:null!==this.#r?this.#l=this._makeSeededRng(this.#r):this.#l=Math.random,this.#r=r??null}hasItem(e){if(D(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#d.has(e)}addItem(e,t={}){if(D(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:o={},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 o||null===o)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 s={id:e,label:i,baseWeight:Math.max(0,Number(r)||0),meta:{...o},groups:new Set(n),locked:!1};this.#d.set(e,s);for(const t of n)this._ensureGroup(t).add(e);return this.emit("itemAdded",s),s}removeItem(e){if(D(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");const t=this.#d.get(e);if(!t)return!1;for(const r of t.groups){const t=this.#u.get(r);t&&t.delete(e)}return this.#d.delete(e),this.emit("itemRemoved",e),this.resetFreq(e),this.resetPity(e),!0}setBaseWeight(e,t){if(D(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.#d.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(D(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("id must be a non-empty string");return this.#d.get(e)??null}listItems(){return D(this.#e),Array.from(this.#d.values()).map(e=>({...e}))}clearList(){D(this.#e),this.#d.clear(),this.clearFreqs(),this.clearPities()}hasGlobalModifier(e){if(D(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#i.includes(e)}addGlobalModifier(e){if(D(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");this.#i.push(e)}removeGlobalModifier(e){if(D(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");this.#i=this.#i.filter(t=>t!==e)}hasTemporaryModifier(e){if(D(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");return this.#o.some(t=>t.fn===e)}addTemporaryModifier(e,t=1){if(D(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.#o.push({fn:e,uses:Math.max(1,Math.floor(t))})}removeTemporaryModifier(e){if(D(this.#e),"function"!=typeof e)throw new TypeError("fn must be a function");const t=this.#o.length;return this.#o=this.#o.filter(t=>t.fn!==e),this.#o.length!==t}hasConditionalRule(e){if(D(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");return this.#n.includes(e)}addConditionalRule(e){if(D(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");this.#n.push(e)}removeConditionalRule(e){if(D(this.#e),"function"!=typeof e)throw new TypeError("ruleFn must be a function");const t=this.#n.length;return this.#n=this.#n.filter(t=>t!==e),this.#n.length!==t}hasPity(e){if(D(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#s.has(e)}configurePity(e,t){if(D(this.#e),!this.#d.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:o=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 o)throw new TypeError("cap must be a number");this.#s.set(e,{threshold:Math.max(1,r),increment:Number(i)||0,cap:Number(o)||1/0,counter:0,currentAdd:0})}resetPity(e){if(D(this.#e),"string"!=typeof e||!e.trim())throw new TypeError("itemId must be a non-empty string");const t=this.#s.get(e);t&&(t.counter=0,t.currentAdd=0)}clearPities(){D(this.#e),this.#s.clear()}hasExclusion(e){if(D(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");return this.#a.has(e)}excludeItem(e){if(D(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#a.add(e)}includeItem(e){if(D(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#a.delete(e)}_ensureGroup(e){if(D(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(D(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(D(this.#e),"string"!=typeof e||"string"!=typeof t)throw new TypeError("itemId and groupName must be strings");const r=this.#d.get(e);if(!r)throw new Error("Item missing");r.groups.add(t),this._ensureGroup(t).add(e)}removeFromGroup(e,t){if(D(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.#d.get(e);i&&i.groups.delete(t)}clearFreqs(){D(this.#e),this.#c.clear()}resetFreq(e){if(D(this.#e),"string"!=typeof e)throw new TypeError("itemId must be a string");this.#c.delete(e)}computeEffectiveWeights(e={}){if(D(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.#d)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.#o){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.#n){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.#s)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 o=0;return t.map((e,t)=>{const n=r[t]/i;return o+=n,{id:e.id,weight:e.weight,p:n,cumulative:o}})}{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(D(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.#o]},r=this.computeEffectiveWeights(t),i=this._weightsToDistribution(r);if(!i.length)return null;const o=this.#l(),n=i.find(e=>o<=e.cumulative)??i[i.length-1];for(const[e,t]of this.#s)e===n.id?(t.counter=0,t.currentAdd=0):t.counter++;this._consumeTemporaryModifiers();const s=this.#d.get(n.id);if(!s)return null;const a={id:s.id,label:s.label,meta:{...s.meta},prob:n.p};return this.emit("draw",a),a&&this.#c.set(a.id,(this.#c.get(a.id)||0)+1),a}_consumeTemporaryModifiers(){for(let e=this.#o.length-1;e>=0;--e){const t=this.#o[e];t.uses-=1,t.uses<=0&&this.#o.splice(e,1)}}drawMany(e=1,t={}){if(D(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,o=[],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;o.push(i),r.add(i.id),n.push(i)}return o}for(let i=0;i<e;++i){const e=this.drawOne({previousDraws:n,metadata:t.metadata});if(!e)break;o.push(e),n.push(e),r||this.excludeItem(e.id)}if(!r)for(const e of o)this.includeItem(e.id);return o}exportToJson(){return D(this.#e),{items:Array.from(this.#d.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.#s.entries()),exclusions:Array.from(this.#a),normalization:this.#t,seed:this.#r}}loadFromJson(e){if(D(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.#d.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(){D(this.#e);const e=new L;return e.#t=this.#t,e.#r=this.#r,e.#i=[...this.#i],e.#o=this.#o.map(e=>({fn:e.fn,uses:e.uses})),e.#n=[...this.#n],e.#s=new Map([...this.#s.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.#l=this.#l,e.#d=new Map([...this.#d.entries()].map(([e,t])=>[e,{...t,groups:new Set(t.groups),meta:{...t.meta}}])),e.#c=new Map(this.#c),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.#s.clear(),this.#a.clear(),this.#u.clear(),this.#d.clear(),this.#c.clear(),this.#i=[],this.#o=[],this.#n=[],this.#r=null,this.#e=!0)}}const A=L,C=I("TinyRadioFm"),S=r().EventEmitter;class k extends S{static async parseContent(e,t,r,i,n,s=!0){return(async(e,t={},r={},i=e=>{if(!(e instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((e,t)=>t(new TypeError("parseFile library not found.")))},n={},s=!0,d="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(l(t,"defaultMetadata"),l(r,"metadata"),u(i,"parseFile"),l(n,"callbacks"),n.onProgress&&"function"!=typeof n.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(n.onError&&"function"!=typeof n.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof d&&"function"!=typeof d)throw new TypeError("unknownArtist must be a string or a function returning a string.");let c,m="";const f=(t,r)=>{if(a(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');n.onProgress&&n.onProgress({event:r,status:"loading",stage:t,url:m||(e instanceof HTMLMediaElement?e.src:"unknown")})},h=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');a(r,"stage"),n.onError&&n.onError({error:t instanceof Error?t:new Error(String(t)),url:m||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{f("INITIALIZING"),"string"==typeof e?(m=e,c=new Audio(m)):(c=e,m=c.src);try{await new Promise((e,t)=>{const r=e=>f("DOWNLOADING",e),i=()=>{n(),e(void 0)},o=e=>{n(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},n=()=>{c.removeEventListener("progress",r),c.removeEventListener("loadedmetadata",i),c.removeEventListener("error",o)};c.addEventListener("progress",r),c.addEventListener("loadedmetadata",i),c.addEventListener("error",o),c.readyState>=1&&(n(),e(void 0))}),f("METADATA_LOADED")}catch(e){throw new y(e instanceof Error?e.message:"UNKNOWN ERROR",m,"METADATA")}const u={id:r.id||await g(m),duration:Math.floor(1e3*c.duration),url:m,weight:r.weight??1};let l={};f("EXTRACTING_ID3");try{l=await M(m,i,s)}catch(e){h(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${m}. Falling back to filename.`)}const p=e=>{a(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},w=e=>{const t={...e};return o(t._fetchData)&&(o(l._fetchData)&&(t._fetchData={...l._fetchData}),o(e._fetchData)&&(void 0!==e._fetchData.common&&(t._fetchData.common=e._fetchData.common),void 0!==e._fetchData.native&&(t._fetchData.native=e._fetchData.native),void 0!==e._fetchData.format&&(t._fetchData.format=e._fetchData.format),void 0!==e._fetchData.quality&&(t._fetchData.quality=e._fetchData.quality))),t},b={...u,...w(t),...l,...w(r),title:l.title||r.title||p(m),artist:l.artist||r.artist||("string"==typeof d?d:String(d()))};return n.onProgress&&n.onProgress({status:"success",stage:"COMPLETE",url:m}),b}catch(e){if(e instanceof y)throw e;const t=new y(e instanceof Error?e.message:"UNKNOWN ERROR",m,"INITIALIZING");throw h(t,"INITIALIZING"),t}})(e,t,r,i,n,s,k.#m)}static#m="Unknown Artist";static get unknownArtist(){return k.#m}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");k.#m=e}#f=!1;get destroyed(){return this.#f}get size(){return C(this.#f),this.#h.length+this.#p.length}get musicSize(){return C(this.#f),this.#h.length}get voiceSize(){return C(this.#f),this.#p.length}get customPosSize(){return C(this.#f),this.#y.length}get tasksSize(){return C(this.#f),this.#g.length}get cycleCacheSize(){return C(this.#f),this.#w.size}#h=[];get musicList(){return C(this.#f),structuredClone(this.#h)}#p=[];get voiceList(){return C(this.#f),structuredClone(this.#p)}#y=[];get customPositions(){return C(this.#f),structuredClone(this.#y)}#g=[];get scheduledTasks(){return C(this.#f),structuredClone(this.#g)}get allList(){return C(this.#f),[...this.musicList,...this.voiceList]}#r=0;get seed(){return C(this.#f),this.#r}set seed(e){if(C(this.#f),"number"!=typeof e)throw new TypeError("Seed must be a number.");this.#r=e,this.#w.clear(),this.emit("seedChanged",{seed:e})}#b=Date.now();get anchorDate(){return C(this.#f),this.#b}#w=new Map;#v={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,voiceWeight:1,musicMaxConsecutive:0,musicMinConsecutive:0,voiceMaxConsecutive:0,voiceMinConsecutive:0};get config(){return C(this.#f),structuredClone(this.#v)}set config(e){C(this.#f),this.#E(e),this.#v=structuredClone(e),this.#w.clear(),this.emit("configChanged",{config:this.config})}#E(e){if("object"!=typeof e||null===e)throw new TypeError("Configuration must be a valid object.");const t=["playlist","random"];if(void 0!==e.mode&&!t.includes(e.mode))throw new TypeError(`Invalid mode: "${e.mode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.voiceMode&&!t.includes(e.voiceMode))throw new TypeError(`Invalid voiceMode: "${e.voiceMode}". Must be one of: ${t.join(", ")}.`);if(void 0!==e.silenceDuration&&("number"!=typeof e.silenceDuration||e.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==e.queryLimit&&("number"!=typeof e.queryLimit||e.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==e.voiceAfterMusic&&"boolean"!=typeof e.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");const r=(e,t)=>{if(void 0!==e&&("number"!=typeof e||e<0))throw new TypeError(`${t} must be a non-negative number.`)};r(e.voiceWeight,"voiceWeight"),r(e.voiceMin,"voiceMin"),r(e.voiceMax,"voiceMax"),r(e.musicMinConsecutive,"musicMinConsecutive"),r(e.musicMaxConsecutive,"musicMaxConsecutive"),r(e.voiceMinConsecutive,"voiceMinConsecutive"),r(e.voiceMaxConsecutive,"voiceMaxConsecutive");const i=e.voiceMin??this.#v.voiceMin,o=e.voiceMax??this.#v.voiceMax;if(o<i)throw new RangeError(`Logical error: voiceMax (${o}) cannot be less than voiceMin (${i}).`);const n=e.musicMinConsecutive??this.#v.musicMinConsecutive,s=e.musicMaxConsecutive??this.#v.musicMaxConsecutive;if(-1!==s&&n>s)throw new RangeError(`Logical error: musicMinConsecutive (${n}) cannot be greater than musicMaxConsecutive (${s}).`)}#T=!0;get optimizeMediaMemory(){return C(this.#f),this.#T}set optimizeMediaMemory(e){if(C(this.#f),"boolean"!=typeof e)throw new TypeError("optimizeMediaMemory must be a boolean.");this.#T=e}#M=!0;get optimizePictureMemory(){return C(this.#f),this.#M}set optimizePictureMemory(e){if(C(this.#f),"boolean"!=typeof e)throw new TypeError("optimizePictureMemory must be a boolean.");this.#M=e}constructor(e=null,t=0){if(super(),null!==e&&"object"!=typeof e)throw new TypeError("initialData must be an object or null.");if("number"!=typeof t)throw new TypeError("seed must be a number.");this.#r=t,e?this.#I(e):this.#b=Date.now()}_ccBase64ToBlobUrl(e){this.#T&&"string"==typeof e.url&&e.url.startsWith("data:")&&(e.url=w(e.url)),e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(e=>{if(this.#M){const t="string"==typeof e.data&&e.data.startsWith("data:"),r=e.data instanceof Uint8Array;if(t||r)return{...e,data:w(e.data,e.format)}}return e}))}async _rcblobUrlToBase64(e){this.#T&&"string"==typeof e.url&&e.url.startsWith("blob:")&&(e.url=await b(e.url)),this.#M&&e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async e=>"string"==typeof e.data&&e.data.startsWith("blob:")?{...e,data:await b(e.data)}:e)))}add(e,t,r=!0){if(C(this.#f),!["music","voice","custom"].includes(e))throw new TypeError('Type must be "music", "voice", or "custom".');if(!t||"string"!=typeof t.id||"number"!=typeof t.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof r)throw new TypeError("smartQueue must be a boolean.");T(t);const i=structuredClone(t);this._ccBase64ToBlobUrl(i),"music"===e?(this.#h.push(i),this.#w.clear()):"voice"===e?(this.#p.push(i),this.#w.clear()):"custom"===e&&this.#D(i,r),this.#x(Date.now()),this.emit("contentAdded",{type:e,data:structuredClone(i)})}scheduleTask(e,t,r,i,n=!0){if(C(this.#f),"number"!=typeof e||isNaN(e))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(t))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(r))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof n)throw new TypeError("smartQueue must be a boolean.");if("add"===t){if("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===t){if("string"!=typeof i)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===t&&("object"!=typeof i||null===i||"string"!=typeof i.id||"number"!=typeof i.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let s=e;if(n){const t=this.#L(e,e);t&&(s=t.absoluteEnd)}o(i)&&"number"!=typeof i.newIndex&&T(i);const a={timestamp:s,action:t,type:r,payload:i};this.#g.push(a),this.#x(Date.now()),this.emit("taskScheduled",structuredClone(a))}remove(e){if(C(this.#f),"string"!=typeof e)throw new TypeError("id must be a string.");this.#h.filter(t=>t.id===e).forEach(e=>v(e)),this.#p.filter(t=>t.id===e).forEach(e=>v(e)),this.#y.filter(t=>t.content?.id===e).forEach(e=>v(e.content));const t=t=>t.id!==e&&t.content?.id!==e;this.#h=this.#h.filter(t),this.#p=this.#p.filter(t),this.#y=this.#y.filter(t),this.#g=this.#g.filter(t=>"add"===t.action&&"object"==typeof t.payload&&null!==t.payload&&"id"in t.payload?t.payload.id!==e||(v(t.payload),!1):t.payload!==e),this.#w.clear(),this.emit("contentRemoved",{id:e})}setConfig(e){C(this.#f),this.#E(e);const t={...this.#v,...e};this.#E(t),this.#v=t,this.#w.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){C(this.#f);const e=Date.now();return this.#x(e),this.#L(e,e)}queryTimeline(e,t=10){if(C(this.#f),"number"!=typeof t||isNaN(t))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(t>this.#v.queryLimit||t<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#v.queryLimit}.`);const r=new k(JSON.parse(this._exportState())),i=[];let o=e;for(let n=0;n<t;n++){r.#x(o);const t=r.#A(o,e);if(!t)break;i.push(t),o=t.absoluteEnd}return r.destroy(!1),this.emit("timelineQueried",{targetDate:e,limit:t,resultCount:i.length}),i}searchCustomPositions(){return C(this.#f),this.#x(Date.now()),[...this.#y]}async _processListForExport(e){return Promise.all(e.map(async e=>{T(e);const t=structuredClone(e);return await this._rcblobUrlToBase64(t),t}))}_exportState(){return JSON.stringify({music:this.#h,voice:this.#p,custom:this.#y,tasks:this.#g,seed:this.#r,anchorDate:this.#b,config:this.#v})}async exportState(){C(this.#f);const e=await this._processListForExport(this.#h),t=await this._processListForExport(this.#p),r=await Promise.all(this.#y.map(async e=>{const t=await this._processListForExport([e.content]);return{...e,content:t[0]}})),i=await Promise.all(this.#g.map(async e=>{if("add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload){const t=await this._processListForExport([e.payload]);return{...e,payload:t[0]}}return e}));return JSON.stringify({music:e,voice:t,custom:r,tasks:i,seed:this.#r,anchorDate:this.#b,config:this.#v})}importState(e){let t;if(C(this.#f),"string"==typeof e)try{t=JSON.parse(e)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof e||null===e)throw new TypeError("Import data must be a valid JSON string or an object.");t=e}this.#I(t),this.emit("stateImported",{data:structuredClone(t)})}_prng(e){return function(){let t=e+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}#C(e,t,r,i=0,o=0,n=null,s=0){if(0===e.length)return{items:[],lastId:n,consecutiveCount:s};if("random"!==r){const t=[...e],r=t[t.length-1];return{items:t,lastId:r.id,consecutiveCount:n===r.id?s+1:1}}const a=this._prng(t),u=[];let l=n,d=s;const c=new A({rng:a,normalization:"relative"}),m=[...e];for(m.forEach(e=>{const t=e.weight??1,r=c.getItem(e.id);r?c.setBaseWeight(e.id,r.baseWeight+t):c.addItem(e.id,{weight:t})});m.length>0;){let e=null,t=-1;if(null!==l&&d<i&&(t=m.findIndex(e=>e.id===l),-1!==t?e=m[t]:u.length>0&&(e=u[u.length-1])),!e){let r=null;null!==l&&-1!==o&&d>=o&&m.some(e=>e.id!==l)&&(c.excludeItem(l),r=l);const i=c.drawOne();i&&(t=m.findIndex(e=>e.id===i.id),-1!==t&&(e=m[t])),r&&c.includeItem(r)}if(e||(e=m[0],t=0),u.push(e),-1!==t)if(m.splice(t,1),m.some(t=>t.id===e.id)){const t=c.getItem(e.id);if(t){const r=Math.max(0,t.baseWeight-(e.weight??1));r<=0?c.removeItem(e.id):c.setBaseWeight(e.id,r)}}else c.removeItem(e.id);e.id===l?d++:(l=e.id,d=1)}return c.destroy(),{items:u,lastId:l,consecutiveCount:d}}#S(e){const t=this.#r+e,r=this._prng(10*t);let i=null,o=0,n=null,s=0;if(e>0){const t=this.#w.get(e-1);t&&(i=t.lastMusicId??null,o=t.musicConsecutiveCount??0,n=t.lastVoiceId??null,s=t.voiceConsecutiveCount??0)}const a=this.#C(this.#h,t+1,this.#v.mode,this.#v.musicMinConsecutive,this.#v.musicMaxConsecutive,i,o),u=a.items,l=this.#C(this.#p,t+2,this.#v.voiceMode,this.#v.voiceMinConsecutive,this.#v.voiceMaxConsecutive,n,s),d=l.items,c=[];let m=0,f=0;for(let e=0;e<u.length;e++){const t=u[e];if(c.push({...t,cycleStart:m,cycleEnd:m+t.duration}),m+=t.duration+this.#v.silenceDuration,this.#v.voiceAfterMusic&&d.length>0){const e=this.#v.voiceWeight/(this.#v.voiceWeight+1);if(r()<e){const e=this.#v.voiceMax-this.#v.voiceMin+1,t=Math.floor(r()*e)+this.#v.voiceMin;for(let e=0;e<t;e++){const e=d[f%d.length];f++,c.push({...e,cycleStart:m,cycleEnd:m+e.duration}),m+=e.duration+this.#v.silenceDuration}}}}return{items:c,duration:m,lastMusicId:a.lastId,musicConsecutiveCount:a.consecutiveCount,lastVoiceId:l.lastId,voiceConsecutiveCount:l.consecutiveCount}}#k(e){if(0===this.#h.length)return null;let t=this.#b,r=0;for(;;){if(r>this.#v.queryLimit)throw new Error("Safety limit hit during cycle location.");let i=this.#w.get(r);if(i||(i=this.#S(r),this.#w.set(r,i)),0===i.duration)return null;if(e>=t&&e<t+i.duration)return{block:i,startTimestamp:t,loopIndex:r};t+=i.duration,r++}}#A(e,t){const r=this.#y.filter(t=>t.intendedTimestamp+t.content.duration>e).sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp)[0];let i=null;if(r){const e=Math.max(t,r.intendedTimestamp);i=this.#j(r.content,r.intendedTimestamp,e,!0)}const o=this.#_(e,t);return o||i?o?i?i.absoluteStart<=o.absoluteStart?i:(i.absoluteStart<o.absoluteEnd&&(o.absoluteEnd=i.absoluteStart,o.duration=o.absoluteEnd-o.absoluteStart,o.remainingTime=Math.max(0,o.absoluteEnd-t),o.progress=Math.min(1,o.elapsedTime/o.duration)),o):o:i:null}#_(e,t){let r=this.#k(e);if(!r)return null;const{block:i,startTimestamp:o}=r,n=e-o;let s,a=i.items.find(e=>e.cycleEnd>n);if(a)s=o+a.cycleStart;else{if(r=this.#k(o+i.duration),!r||0===r.block.items.length)return null;a=r.block.items[0],s=r.startTimestamp+a.cycleStart}const u=Math.max(t,s);return this.#j(a,s,u,!1)}#L(e,t){const r=this.#y.find(t=>e>=t.intendedTimestamp&&e<t.intendedTimestamp+t.content.duration);if(r)return this.#j(r.content,r.intendedTimestamp,t,!0);const i=this.#k(e);if(!i)return null;const{block:o,startTimestamp:n}=i,s=e-n,a=o.items.find(e=>s>=e.cycleStart&&s<e.cycleEnd);return a?this.#j(a,n+a.cycleStart,t,!1):null}#j(e,t,r,i){const o=r-t;return{id:e.id,title:e.title,artist:e.artist,duration:e.duration,url:e.url,absoluteStart:t,absoluteEnd:t+e.duration,elapsedTime:o,remainingTime:e.duration-o,progress:Math.min(1,o/e.duration),isCustom:i}}#D(e,t){let r=e.timestamp||Date.now();const i=e.duration;if(t){const e=this.#L(r,r);e&&(r=e.absoluteEnd)}const o=[...this.#y].sort((e,t)=>e.intendedTimestamp-t.intendedTimestamp);let n=r;if(o.some(e=>r<e.intendedTimestamp+e.content.duration&&r+i>e.intendedTimestamp)){const e=[];let t=Date.now();for(const r of o)r.intendedTimestamp>t&&e.push({start:t,end:r.intendedTimestamp}),t=Math.max(t,r.intendedTimestamp+r.content.duration+this.#v.silenceDuration);e.push({start:t,end:1/0});let s=1/0;for(const t of e)if(t.end-t.start>=i){let e=null;if(r>=t.start&&r+i<=t.end?e=r:r<t.start?e=t.start:r>t.end&&(e=t.end-i),null!==e){const t=Math.abs(r-e);t<s&&(s=t,n=e)}}}this.#y.push({content:e,intendedTimestamp:n,originalTimestamp:e.timestamp||Date.now()})}#x(e){const t=this.#g.filter(t=>t.timestamp<=e);this.#g=this.#g.filter(t=>t.timestamp>e);const r=this.#y.filter(t=>t.intendedTimestamp+t.content.duration<=e);this.#y=this.#y.filter(t=>t.intendedTimestamp+t.content.duration>e);let i=!1;r.forEach(e=>{v(e.content),this.#r+=e.content.id.length,i=!0,this.emit("customPositionExpired",{contentId:e.content.id})}),t.length>0&&t.sort((e,t)=>e.timestamp-t.timestamp).forEach(e=>{const t="music"===e.type?this.#h:this.#p;if("add"===e.action)t.push(e.payload);else if("remove"===e.action){const r=t.findIndex(t=>t.id===e.payload);if(-1!==r){const[e]=t.splice(r,1);v(e)}}else if("move"===e.action){const r=e.payload,i=t.findIndex(e=>e.id===r.id);if(-1!==i){const[e]=t.splice(i,1);t.splice(r.newIndex,0,e)}}this.#b=e.timestamp,this.#r+=1,i=!0,this.emit("taskExecuted",structuredClone(e))}),i&&this.#w.clear()}#I(e){this.#h.forEach(e=>v(e)),this.#p.forEach(e=>v(e)),this.#y.forEach(e=>v(e.content)),this.#g.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&v(e.payload)});const t=e=>e.map(e=>{T(e);const t=structuredClone(e);return this._ccBase64ToBlobUrl(t),t});this.#h=t(e.music),this.#p=t(e.voice),this.#r=e.seed||0,this.#b=e.anchorDate||Date.now(),this.#v={...this.#v,...e.config||{}},this.#y=e.custom.map(e=>({...e,content:t([e.content])[0]})),this.#g=e.tasks.map(e=>"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload?{...e,payload:t([e.payload])[0]}:e)}destroy(e=!0){this.#f||(e&&(this.#h.forEach(e=>v(e)),this.#p.forEach(e=>v(e)),this.#y.forEach(e=>v(e.content)),this.#g.forEach(e=>{"add"===e.action&&e.payload&&"object"==typeof e.payload&&"title"in e.payload&&v(e.payload)})),this.#h=[],this.#p=[],this.#y=[],this.#g=[],this.#w.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#f=!0)}}const j=k;window.TinyRadioFm=t.TinyRadioFm})();
@@ -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++],o=r[s++];e.o(t,i)?0===o&&s++:0===o?Object.defineProperty(t,i,{enumerable:!0,value:r[s++]}):Object.defineProperty(t,i,{enumerable:!0,get:o})}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,{TinyRateLimiter:()=>s});const r=e=>{if(e)throw new Error("This TinyRateLimiter instance has been destroyed and can no longer be used.")};const s=class{#e=!1;get destroyed(){return this.#e}#t=null;#r=null;#s=null;#i=null;#o=null;#n=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#a=null;setOnMemoryExceeded(e){if(r(this.#e),"function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#a=e}clearOnMemoryExceeded(){r(this.#e),this.#a=null}#u=null;setOnGroupExpired(e){if(r(this.#e),"function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#u=e}clearOnGroupExpired(){r(this.#e),this.#u=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:s=3e5,maxMemory:i=1e5}){const o=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),n=o(e),a=o(t),u=o(r),l=o(s);if(!n&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==e&&!n)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==t&&!a)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==r&&!u)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!l)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof i&&Number.isFinite(i)&&i>0)this.#t=Math.floor(i);else{if(null!=i)throw new Error("maxMemory must be a positive number or null");this.#t=null}this.#s=n?e:null,this.#i=a?t:null,this.#o=u?r:null,this.#n=s,null!==this.#o&&(this.#r=setInterval(()=>this._cleanup(),this.#o))}isGroupId(e){r(this.#e);const t=this.groupFlags.get(e);return"boolean"==typeof t&&t}getUsersInGroup(e){r(this.#e);const t=[];for(const[r,s]of this.userToGroup.entries())s===e&&t.push(r);return t}setGroupTTL(e,t){if(r(this.#e),"number"!=typeof t||!Number.isFinite(t)||t<=0)throw new Error("TTL must be a positive number in milliseconds");this.groupTTL.set(e,t)}getGroupTTL(e){return r(this.#e),this.groupTTL.get(e)??null}deleteGroupTTL(e){r(this.#e),this.groupTTL.delete(e)}assignToGroup(e,t){r(this.#e);const s=this.userToGroup.get(e);if(s&&s!==t)throw new Error(`User ${e} is already assigned to group ${s}`);if(s===t)return;const i=this.groupData.get(e);if(this.isGroupId(e)){for(const[r,s]of this.userToGroup.entries())s===e&&this.userToGroup.set(r,t);this.userToGroup.delete(e)}else this.userToGroup.set(e,t);if(!i)return;const o=this.groupData.get(t);if(o)for(const e of i)o.push(e);else{const e=[];for(const t of i)e.push(t);this.groupData.set(t,e)}this.lastSeen.set(t,Date.now()),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e),this.groupFlags.set(t,!0)}getGroupId(e){return r(this.#e),this.userToGroup.get(e)||e}hit(e){r(this.#e);const t=this.getGroupId(e),s=Date.now();this.groupData.has(t)||(this.groupData.set(t,[]),this.groupFlags.set(t,!1));const i=this.groupData.get(t);if(!i)throw new Error(`No data found for groupId: ${t}`);if(i.push(s),this.lastSeen.set(t,s),null!==this.#i){const e=s-this.getInterval();for(;i.length&&i[0]<e;)i.shift()}null!==this.#t&&"number"==typeof this.#t&&i.length>this.#t&&(i.splice(0,i.length-this.#t),"function"==typeof this.#a&&this.#a(t))}isRateLimited(e){r(this.#e);const t=this.getGroupId(e);if(!this.groupData.has(t))return!1;const s=this.groupData.get(t);if(!s)throw new Error(`No data found for groupId: ${t}`);if(null!==this.#i){const e=Date.now()-this.getInterval();let t=0;for(let r=s.length-1;r>=0&&s[r]>e;r--)t++;return null!==this.#s?t>this.getMaxHits():t>0}return null!==this.#s&&s.length>this.getMaxHits()}resetGroup(e){r(this.#e),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e)}resetUserGroup(e){r(this.#e),this.userToGroup.delete(e)}setData(e,t){if(r(this.#e),!Array.isArray(t))throw new Error("timestamps must be an array of numbers.");for(const e of t)if("number"!=typeof e||!Number.isFinite(e))throw new Error("All timestamps must be finite numbers.");this.groupData.has(e)||this.groupFlags.set(e,!1),this.groupData.set(e,t),this.lastSeen.set(e,Date.now())}hasData(e){return r(this.#e),this.groupData.has(e)}getData(e){return r(this.#e),this.groupData.get(e)||[]}getMaxIdle(){if(r(this.#e),"number"!=typeof this.#n||!Number.isFinite(this.#n)||this.#n<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#n}setMaxIdle(e){if(r(this.#e),"number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#n=e}_cleanup(){const e=Date.now();for(const[t,r]of this.lastSeen.entries())e-r>(this.getGroupTTL(t)??this.getMaxIdle())&&(this.groupFlags.delete(t),this.groupData.delete(t),this.lastSeen.delete(t),this.groupTTL.delete(t),"function"==typeof this.#u&&this.#u(t))}getActiveGroups(){return r(this.#e),Array.from(this.groupData.keys())}getAllUserMappings(){return r(this.#e),Object.fromEntries(this.userToGroup)}getInterval(){if(r(this.#e),"number"!=typeof this.#i||!Number.isFinite(this.#i))throw new Error("'interval' is not a valid finite number.");return this.#i}getMaxHits(){if(r(this.#e),"number"!=typeof this.#s||!Number.isFinite(this.#s))throw new Error("'maxHits' is not a valid finite number.");return this.#s}getTotalHits(e){r(this.#e);const t=this.groupData.get(e);return Array.isArray(t)?t.length:0}getLastHit(e){r(this.#e);const t=this.groupData.get(e);return t?.length?t[t.length-1]:null}getTimeSinceLastHit(e){r(this.#e);const t=this.getLastHit(e);return null!==t?Date.now()-t:null}_calculateAverageSpacing(e){if(!Array.isArray(e)||e.length<2)return null;let t=0;for(let r=1;r<e.length;r++)t+=e[r]-e[r-1];return t/(e.length-1)}getAverageHitSpacing(e){return r(this.#e),this._calculateAverageSpacing(this.groupData.get(e))}getMetrics(e){r(this.#e);const t=this.groupData.get(e);if(!Array.isArray(t)||0===t.length)return{totalHits:0,lastHit:null,timeSinceLastHit:null,averageHitSpacing:null};const s=t.length,i=t[s-1];return{totalHits:s,lastHit:i,timeSinceLastHit:Date.now()-i,averageHitSpacing:this._calculateAverageSpacing(t)}}destroy(){this.destroyed||(this.#r&&clearInterval(this.#r),this._cleanup(),this.groupData.clear(),this.lastSeen.clear(),this.userToGroup.clear(),this.groupTTL.clear(),this.groupFlags.clear(),this.#e=!0)}};window.TinyRateLimiter=t.TinyRateLimiter})();
1
+ (()=>{"use strict";const 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)};let t={};e.d(t,{TinyRateLimiter:()=>s});const r=e=>{if(e)throw new Error("This TinyRateLimiter instance has been destroyed and can no longer be used.")};const s=class{#e=!1;get destroyed(){return this.#e}#t=null;#r=null;#s=null;#i=null;#o=null;#n=null;groupData=new Map;lastSeen=new Map;userToGroup=new Map;groupFlags=new Map;groupTTL=new Map;#a=null;setOnMemoryExceeded(e){if(r(this.#e),"function"!=typeof e)throw new Error("onMemoryExceeded must be a function");this.#a=e}clearOnMemoryExceeded(){r(this.#e),this.#a=null}#u=null;setOnGroupExpired(e){if(r(this.#e),"function"!=typeof e)throw new Error("onGroupExpired must be a function");this.#u=e}clearOnGroupExpired(){r(this.#e),this.#u=null}constructor({maxHits:e,interval:t,cleanupInterval:r,maxIdle:s=3e5,maxMemory:i=1e5}){const o=e=>"number"==typeof e&&Number.isFinite(e)&&e>=1&&Number.isInteger(e),n=o(e),a=o(t),u=o(r),l=o(s);if(!n&&!a)throw new Error("RateLimiter requires at least one valid option: 'maxHits' or 'interval'.");if(void 0!==e&&!n)throw new Error("'maxHits' must be a positive integer if defined.");if(void 0!==t&&!a)throw new Error("'interval' must be a positive integer in milliseconds if defined.");if(void 0!==r&&!u)throw new Error("'cleanupInterval' must be a positive integer in milliseconds if defined.");if(!l)throw new Error("'maxIdle' must be a positive integer in milliseconds.");if("number"==typeof i&&Number.isFinite(i)&&i>0)this.#t=Math.floor(i);else{if(null!=i)throw new Error("maxMemory must be a positive number or null");this.#t=null}this.#s=n?e:null,this.#i=a?t:null,this.#o=u?r:null,this.#n=s,null!==this.#o&&(this.#r=setInterval(()=>this._cleanup(),this.#o))}isGroupId(e){r(this.#e);const t=this.groupFlags.get(e);return"boolean"==typeof t&&t}getUsersInGroup(e){r(this.#e);const t=[];for(const[r,s]of this.userToGroup.entries())s===e&&t.push(r);return t}setGroupTTL(e,t){if(r(this.#e),"number"!=typeof t||!Number.isFinite(t)||t<=0)throw new Error("TTL must be a positive number in milliseconds");this.groupTTL.set(e,t)}getGroupTTL(e){return r(this.#e),this.groupTTL.get(e)??null}deleteGroupTTL(e){r(this.#e),this.groupTTL.delete(e)}assignToGroup(e,t){r(this.#e);const s=this.userToGroup.get(e);if(s&&s!==t)throw new Error(`User ${e} is already assigned to group ${s}`);if(s===t)return;const i=this.groupData.get(e);if(this.isGroupId(e)){for(const[r,s]of this.userToGroup.entries())s===e&&this.userToGroup.set(r,t);this.userToGroup.delete(e)}else this.userToGroup.set(e,t);if(!i)return;const o=this.groupData.get(t);if(o)for(const e of i)o.push(e);else{const e=[];for(const t of i)e.push(t);this.groupData.set(t,e)}this.lastSeen.set(t,Date.now()),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e),this.groupFlags.set(t,!0)}getGroupId(e){return r(this.#e),this.userToGroup.get(e)||e}hit(e){r(this.#e);const t=this.getGroupId(e),s=Date.now();this.groupData.has(t)||(this.groupData.set(t,[]),this.groupFlags.set(t,!1));const i=this.groupData.get(t);if(!i)throw new Error(`No data found for groupId: ${t}`);if(i.push(s),this.lastSeen.set(t,s),null!==this.#i){const e=s-this.getInterval();for(;i.length&&i[0]<e;)i.shift()}null!==this.#t&&"number"==typeof this.#t&&i.length>this.#t&&(i.splice(0,i.length-this.#t),"function"==typeof this.#a&&this.#a(t))}isRateLimited(e){r(this.#e);const t=this.getGroupId(e);if(!this.groupData.has(t))return!1;const s=this.groupData.get(t);if(!s)throw new Error(`No data found for groupId: ${t}`);if(null!==this.#i){const e=Date.now()-this.getInterval();let t=0;for(let r=s.length-1;r>=0&&s[r]>e;r--)t++;return null!==this.#s?t>this.getMaxHits():t>0}return null!==this.#s&&s.length>this.getMaxHits()}resetGroup(e){r(this.#e),this.groupFlags.delete(e),this.groupData.delete(e),this.lastSeen.delete(e),this.groupTTL.delete(e)}resetUserGroup(e){r(this.#e),this.userToGroup.delete(e)}setData(e,t){if(r(this.#e),!Array.isArray(t))throw new Error("timestamps must be an array of numbers.");for(const e of t)if("number"!=typeof e||!Number.isFinite(e))throw new Error("All timestamps must be finite numbers.");this.groupData.has(e)||this.groupFlags.set(e,!1),this.groupData.set(e,t),this.lastSeen.set(e,Date.now())}hasData(e){return r(this.#e),this.groupData.has(e)}getData(e){return r(this.#e),this.groupData.get(e)||[]}getMaxIdle(){if(r(this.#e),"number"!=typeof this.#n||!Number.isFinite(this.#n)||this.#n<0)throw new Error("'maxIdle' must be a non-negative finite number.");return this.#n}setMaxIdle(e){if(r(this.#e),"number"!=typeof e||!Number.isFinite(e)||e<0)throw new Error("'maxIdle' must be a non-negative finite number.");this.#n=e}_cleanup(){const e=Date.now();for(const[t,r]of this.lastSeen.entries())e-r>(this.getGroupTTL(t)??this.getMaxIdle())&&(this.groupFlags.delete(t),this.groupData.delete(t),this.lastSeen.delete(t),this.groupTTL.delete(t),"function"==typeof this.#u&&this.#u(t))}getActiveGroups(){return r(this.#e),Array.from(this.groupData.keys())}getAllUserMappings(){return r(this.#e),Object.fromEntries(this.userToGroup)}getInterval(){if(r(this.#e),"number"!=typeof this.#i||!Number.isFinite(this.#i))throw new Error("'interval' is not a valid finite number.");return this.#i}getMaxHits(){if(r(this.#e),"number"!=typeof this.#s||!Number.isFinite(this.#s))throw new Error("'maxHits' is not a valid finite number.");return this.#s}getTotalHits(e){r(this.#e);const t=this.groupData.get(e);return Array.isArray(t)?t.length:0}getLastHit(e){r(this.#e);const t=this.groupData.get(e);return t?.length?t[t.length-1]:null}getTimeSinceLastHit(e){r(this.#e);const t=this.getLastHit(e);return null!==t?Date.now()-t:null}_calculateAverageSpacing(e){if(!Array.isArray(e)||e.length<2)return null;let t=0;for(let r=1;r<e.length;r++)t+=e[r]-e[r-1];return t/(e.length-1)}getAverageHitSpacing(e){return r(this.#e),this._calculateAverageSpacing(this.groupData.get(e))}getMetrics(e){r(this.#e);const t=this.groupData.get(e);if(!Array.isArray(t)||0===t.length)return{totalHits:0,lastHit:null,timeSinceLastHit:null,averageHitSpacing:null};const s=t.length,i=t[s-1];return{totalHits:s,lastHit:i,timeSinceLastHit:Date.now()-i,averageHitSpacing:this._calculateAverageSpacing(t)}}destroy(){this.destroyed||(this.#r&&clearInterval(this.#r),this._cleanup(),this.groupData.clear(),this.lastSeen.clear(),this.userToGroup.clear(),this.groupTTL.clear(),this.groupFlags.clear(),this.#e=!0)}};window.TinyRateLimiter=t.TinyRateLimiter})();
@@ -0,0 +1 @@
1
+ (()=>{"use strict";const e={d:(r,t)=>{for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let r={};e.r(r),e.d(r,{compileGlob:()=>P,compileGlobRegExp:()=>M,decompileGlob:()=>G,emailRegex:()=>U,emailStringRegexBuilder:()=>k,extractEmails:()=>O,extractIPsV4:()=>s,extractIPsV6:()=>h,extractUrls:()=>L,extractUsernames:()=>d,findEmailRegex:()=>S,findIPv4Regex:()=>i,findIPv6Regex:()=>c,findUrlRegex:()=>D,findUsernameRegex:()=>$,ipv4Regex:()=>n,ipv6Regex:()=>u,isValidEmail:()=>V,isValidGlob:()=>z,isValidIPv4:()=>o,isValidIPv6:()=>f,isValidUrl:()=>R,isValidUsername:()=>E,makeSegmentExtractor:()=>T,segmentExtractorV1:()=>x,urlRegex:()=>v,urlStringRegexBuilder:()=>A,usernameRegex:()=>b,usernameStringRegexBuilder:()=>g});const t="(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)";function n(){return new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`)}function o(e,r){if("string"!=typeof e)throw new TypeError("The input must be a string.");return(r??n()).test(e)}function i(){return new RegExp(`\\b${t}(?:\\.${t}){3}\\b`,"g")}function s(e,r){if("string"!=typeof e)throw new TypeError("The input must be a string.");return e.match(r??i())??[]}const a="[0-9a-fA-F]{1,4}",p=`((${a}:){7}${a}|(${a}:){1,7}:|(${a}:){1,6}:${a}|(${a}:){1,5}(:${a}){1,2}|(${a}:){1,4}(:${a}){1,3}|(${a}:){1,3}(:${a}){1,4}|(${a}:){1,2}(:${a}){1,5}|${a}:((:${a}){1,6})|:((:${a}){1,7}|:))`;function u(){return new RegExp(`^${p}$`)}function f(e,r){if("string"!=typeof e)throw new TypeError("The input must be a string.");return(r??u()).test(e)}function c(){return new RegExp(`\\b${p}\\b`,"g")}function h(e,r){if("string"!=typeof e)throw new TypeError("The input must be a string.");return e.match(r??c())??[]}const y=e=>String(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=(e,r)=>{if(null!=r&&"function"!=typeof r&&"lowercase"!==r&&"uppercase"!==r)throw new TypeError('The "transform" property must be a function, "lowercase", or "uppercase".');return"function"==typeof r?r(e):"lowercase"===r?e.toLowerCase():"uppercase"===r?e.toUpperCase():e},g=({validValues:e="[a-zA-Z0-9_]",length:r=[3,20]}={})=>{if(void 0!==e&&"string"!=typeof e)throw new TypeError('The "validValues" property must be a string.');if(void 0!==r){if(!Array.isArray(r)||"number"!=typeof r[0]||"number"!=typeof r[1])throw new TypeError('The "length" property must be an array of two numbers.');if(r[0]>r[1])throw new RangeError("The minimum length (length[0]) cannot be greater than the maximum length (length[1]).");if(r[0]<0)throw new RangeError("The length cannot be negative.")}return`(?:${e}){${String(r[0])},${String(r[1])}}`};function m(e){return`${function({prefix:e,start:r}={}){if(void 0!==r&&"string"!=typeof r)throw new TypeError('The "start" property must be a string.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('The "prefix" property must be a string.');return`${r??""}${e?y(e):""}`}(e)}${g(e)}${function({domain:e,domainPattern:r,end:t}={}){if(void 0!==t&&"string"!=typeof t)throw new TypeError('The "end" property must be a string.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('The "domain" property must be a string.');if(void 0!==r&&"string"!=typeof r)throw new TypeError('The "domainPattern" property must be a string.');return r?`(?:${r})${t??""}`:e?`(?:${y(e)})${t??""}`:t??""}(e)}`}const w=e=>{if(void 0===e)return;const r=Array.isArray(e)?e:[e];for(const e of r)if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("Options must be a plain object or an array of plain objects.")};function b(e){if(w(e),Array.isArray(e)){const r=e.map(m).join("|");return new RegExp(`^(?:${r})$`)}return new RegExp(`^${m(e)}$`)}function E(e,r,t){if("string"!=typeof e)throw new TypeError("The input must be a string.");return(t??b(r)).test(e)}function $(e){w(e);const r=Array.isArray(e)?e[0]:e,t=r?.prefix||r?.start,n=t?"(?:^|(?<=\\W))":"\\b",o=t?"(?=\\W|$)":"\\b";if(Array.isArray(e)){const r=e.map(m).join("|");return new RegExp(`${n}(?:${r})${o}`,"g")}return new RegExp(`${n}${m(e)}${o}`,"g")}function d(e,r,t){if("string"!=typeof e)throw new TypeError("The input must be a string.");const n=e.match(t??$(r));if(!n)return[];const o=Array.isArray(r)?r[0]?.transform:r?.transform;return o?n.map(e=>l(e,o)):n}const T=(e,r,t)=>{if(null===e||"string"!=typeof e&&!(e instanceof RegExp))throw new TypeError("The searchValue must be a string or a RegExp.");if("function"!=typeof r)throw new TypeError("The replaceValue must be a function.");if("object"!=typeof t||null===t)throw new TypeError("The errorConfig must be an object.");if("string"!=typeof t.pathPatternErrorMsg)throw new TypeError("The errorConfig.pathPatternErrorMsg property must be a string.");return n=>{if("string"!=typeof n)throw new TypeError(t.pathPatternErrorMsg);let o=!1;const i=[],s=n.replace(e,(e,...t)=>r(i,e,...t)),a=new RegExp(`^${s}$`);return{regex:a,paramNames:i,exec:e=>{const r={},t=e.match(a);return o=!0,t?(i.forEach((e,n)=>{r[e]=decodeURIComponent(t[n+1])}),{params:r,match:!0}):{params:r,match:!1}}}}},x=T(/:([^/]+)/g,(e,r,t)=>(e.push(t),"([^/]+)"),{pathPatternErrorMsg:'The argument must be a string (e.g., "/user/:id")'}),A=(e={})=>{(e=>{if(void 0!==e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("Options must be an object.");if(void 0!==e.protocol&&"string"!=typeof e.protocol)throw new TypeError('The "protocol" property must be a string.');if(void 0!==e.subDomain&&"string"!=typeof e.subDomain)throw new TypeError('The "subDomain" property must be a string.');if(void 0!==e.subDomainOptional&&"boolean"!=typeof e.subDomainOptional)throw new TypeError('The "subDomainOptional" property must be a boolean.');if(void 0!==e.nameMaxLength&&(!Array.isArray(e.nameMaxLength)||2!==e.nameMaxLength.length||"number"!=typeof e.nameMaxLength[0]||"number"!=typeof e.nameMaxLength[1]))throw new TypeError('The "nameMaxLength" property must be an array of two numbers.');if(void 0!==e.topLevelDomainLength&&(!Array.isArray(e.topLevelDomainLength)||2!==e.topLevelDomainLength.length||"number"!=typeof e.topLevelDomainLength[0]||"number"!=typeof e.topLevelDomainLength[1]))throw new TypeError('The "topLevelDomainLength" property must be an array of two numbers.')}})(e);const{protocol:r="https?",subDomain:t="",subDomainOptional:n=!0,nameMaxLength:o=[1,256],topLevelDomainLength:i=[1,6]}=e;return`${r}:\\/\\/${t?`(${t}\\.)${n?"?":""}`:""}[-a-zA-Z0-9@:%._\\+~#=]{${String(o[0])},${String(o[1])}}\\.[a-zA-Z0-9()]{${String(i[0])},${String(i[1])}}\\b([-a-zA-Z0-9()@:%_\\+.~#?&//=]*)`};function v(e){return new RegExp(`^${A(e)}$`)}function R(e,r,t){if("string"!=typeof e)throw new TypeError("The input must be a string.");return(t??v(r)).test(e)}function D(e){return new RegExp(`\\b${A(e)}\\b`,"g")}function L(e,r,t){if("string"!=typeof e)throw new TypeError("The input must be a string.");return e.match(t??D(r))??[]}const k=(e={})=>{(e=>{if(void 0===e)return;if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("Options must be an object.");const r=(e,r)=>{if(void 0!==e){if(!Array.isArray(e))throw new TypeError(`${r} must be an array.`);for(let t=0;t<e.length;t++)if("string"!=typeof e[t])throw new TypeError(`All elements in ${r} must be strings.`)}};if(r(e.blacklistDomains,"blacklistDomains"),r(e.whitelistDomains,"whitelistDomains"),r(e.blacklistUsernames,"blacklistUsernames"),r(e.whitelistUsernames,"whitelistUsernames"),void 0!==e.customValidator&&"function"!=typeof e.customValidator)throw new TypeError("customValidator must be a function.")})(e);const{validName:r="[a-zA-Z0-9._%+-]+",validDomain:t="[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}"}=e;return`${r}@${t}`};function U(e){return new RegExp(`^${k(e)}$`)}function j(e,r={}){if("function"==typeof r.customValidator&&!r.customValidator(e))return!1;const[t,n]=e.split("@");return!(Array.isArray(r.whitelistDomains)&&r.whitelistDomains.length>0&&!r.whitelistDomains.includes(n)||Array.isArray(r.whitelistUsernames)&&r.whitelistUsernames.length>0&&!r.whitelistUsernames.includes(t)||Array.isArray(r.blacklistDomains)&&r.blacklistDomains.length>0&&r.blacklistDomains.includes(n)||Array.isArray(r.blacklistUsernames)&&r.blacklistUsernames.length>0&&r.blacklistUsernames.includes(t))}function V(e,r={},t){if("string"!=typeof e)throw new TypeError("The input must be a string.");return!!(t??U(r)).test(e)&&j(e,r)}function S(e){return new RegExp(`\\b${k(e)}\\b`,"g")}function O(e,r,t){if("string"!=typeof e)throw new TypeError("The input must be a string.");return e.match(t??S(r))?.filter(e=>j(e,r))??[]}const P=(e,r=!0)=>{if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("GLOB pattern must be a string or an array of strings.");if(Array.isArray(e)&&!e.every(e=>"string"==typeof e))throw new TypeError("All elements in the GLOB array must be strings.");if("boolean"!=typeof r)throw new TypeError("Strict mode must be a boolean.");const t=Array.isArray(e)?e.join(""):e,n=["^"];let o=0,i=!1,s=!1;for(;o<t.length;){const e=t[o];if("\\"===e){const e=t[o+1]||"";n.push("\\"+e),o+=2;continue}if(s)"]"===e?(s=!1,n.push("]")):"!"===e&&"["===t[o-1]?n.push("^"):n.push(e),o++;else{switch(e){case"/":case"$":case"^":case"+":case".":case"(":case")":case"=":case"!":case"|":n.push("\\"+e);break;case"?":n.push("[^/]");break;case"[":s=!0,n.push(e);break;case"]":n.push("\\]");break;case"{":i=!0,n.push("(");break;case"}":i?(i=!1,n.push(")")):n.push("\\}");break;case",":n.push(i?"|":"\\,");break;case"*":let r=1;for(;"*"===t[o+1];)r++,o++;r>1?n.push(".*"):n.push("[^/]*");break;default:n.push(e)}o++}}if(r){if(s)throw new SyntaxError('Unmatched bracket "[" in GLOB pattern.');if(i)throw new SyntaxError('Unmatched brace "{" in GLOB pattern.')}return n.push("$"),n},M=(e,r="",t=!0)=>{if("string"!=typeof r)throw new TypeError("RegExp flags must be a string.");return new RegExp(P(e,t).join(""),r)},G=e=>{if(!(e instanceof RegExp||"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e)))throw new TypeError("Argument must be a RegExp instance or string stuff.");let r="string"==typeof e?e:Array.isArray(e)?e.join(""):e.source;const t=[];r.startsWith("^")&&(r=r.slice(1)),r.endsWith("$")&&(r=r.slice(0,-1));let n=0;for(;n<r.length;){const e=r[n];if("\\"===e){const e=r[n+1]||"";t.push(e),n+=2;continue}if("."!==e||"*"!==r[n+1]){if("["===e){if("[^/]*"===r.slice(n,n+5)){t.push("*"),n+=5;continue}if("[^/]"===r.slice(n,n+4)){t.push("?"),n+=4;continue}if("^"===r[n+1]){t.push("[!"),n+=2;continue}}"("!==e?"|"!==e?")"!==e?(t.push(e),n++):(t.push("}"),n++):(t.push(","),n++):(t.push("{"),n++)}else t.push("**"),n+=2}return t},z=e=>{try{return P(e,!0),!0}catch(e){if(e instanceof SyntaxError)return!1;throw e}};window.TinyRegexEs=r})();