tiny-essentials 1.28.0 → 1.28.2

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 (323) hide show
  1. package/changelog/1/28/1.md +23 -0
  2. package/changelog/1/28/2.md +43 -0
  3. package/dist/_/numbers.d.mts +91 -16
  4. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  5. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  6. package/dist/v1/TinyAnalogClock.min.js +1 -1
  7. package/dist/v1/TinyBasicsEs.min.js +1 -1
  8. package/dist/v1/TinyDayNightCycle.min.js +1 -1
  9. package/dist/v1/TinyDragDropDetector.min.js +1 -1
  10. package/dist/v1/TinyDragger.min.js +1 -1
  11. package/dist/v1/TinyElementObserver.min.js +1 -1
  12. package/dist/v1/TinyEssentials.min.js +1 -1
  13. package/dist/v1/TinyGamepad.min.js +1 -1
  14. package/dist/v1/TinyHtml.min.js +1 -1
  15. package/dist/v1/TinyI18.min.js +1 -1
  16. package/dist/v1/TinyIframeEvents.min.js +1 -1
  17. package/dist/v1/TinyLocalStorage.min.js +1 -1
  18. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  19. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  20. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  21. package/dist/v1/TinyRadioFm.min.js +1 -1
  22. package/dist/v1/TinyRateLimiter.min.js +1 -1
  23. package/dist/v1/TinySmartScroller.min.js +1 -1
  24. package/dist/v1/TinyTextDiffer.min.js +1 -1
  25. package/dist/v1/TinyTextarea.min.js +1 -1
  26. package/dist/v1/TinyTimeout.min.js +1 -1
  27. package/dist/v1/TinyToastNotify.min.js +1 -1
  28. package/dist/v1/TinyUploadClicker.min.js +1 -1
  29. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  30. package/dist/v1/basics/array.cjs +57 -9
  31. package/dist/v1/basics/array.d.mts +28 -12
  32. package/dist/v1/basics/array.mjs +51 -9
  33. package/dist/v1/basics/clock.cjs +94 -42
  34. package/dist/v1/basics/clock.d.mts +22 -22
  35. package/dist/v1/basics/clock.mjs +91 -54
  36. package/dist/v1/basics/collision.d.mts +245 -104
  37. package/dist/v1/basics/deprecated/html.cjs +246 -0
  38. package/dist/v1/basics/deprecated/html.d.mts +63 -0
  39. package/dist/v1/basics/deprecated/html.mjs +190 -0
  40. package/dist/v1/basics/extendObjType/Buffer.d.mts +1 -1
  41. package/dist/v1/basics/fullScreen.d.mts +47 -7
  42. package/dist/v1/basics/html.cjs +149 -130
  43. package/dist/v1/basics/html.d.mts +69 -113
  44. package/dist/v1/basics/html.mjs +113 -105
  45. package/dist/v1/basics/index.cjs +2 -0
  46. package/dist/v1/basics/index.d.mts +11 -65
  47. package/dist/v1/basics/index.mjs +3 -3
  48. package/dist/v1/basics/mediaContent.cjs +116 -32
  49. package/dist/v1/basics/mediaContent.d.mts +143 -159
  50. package/dist/v1/basics/mediaContent.mjs +105 -33
  51. package/dist/v1/basics/objChecker.cjs +7 -5
  52. package/dist/v1/basics/objChecker.d.mts +5 -4
  53. package/dist/v1/basics/objChecker.mjs +6 -6
  54. package/dist/v1/basics/objFilter.cjs +71 -14
  55. package/dist/v1/basics/objFilter.d.mts +16 -19
  56. package/dist/v1/basics/objFilter.mjs +63 -14
  57. package/dist/v1/basics/simpleMath.cjs +81 -25
  58. package/dist/v1/basics/simpleMath.d.mts +22 -22
  59. package/dist/v1/basics/simpleMath.mjs +70 -27
  60. package/dist/v1/basics/text.cjs +76 -31
  61. package/dist/v1/basics/text.d.mts +64 -14
  62. package/dist/v1/basics/text.mjs +62 -31
  63. package/dist/v1/build/ColorSafeStringify.d.mts +1 -1
  64. package/dist/v1/build/TinyAdvancedRaffle.d.mts +1 -1
  65. package/dist/v1/build/TinyAfterScrollWatcher.d.mts +1 -1
  66. package/dist/v1/build/TinyAnalogClock.d.mts +1 -1
  67. package/dist/v1/build/TinyArrayComparator.d.mts +1 -1
  68. package/dist/v1/build/TinyArrayPaginator.d.mts +1 -1
  69. package/dist/v1/build/TinyClassManager.d.mts +1 -1
  70. package/dist/v1/build/TinyClipboard.d.mts +1 -1
  71. package/dist/v1/build/TinyColorConverter.d.mts +1 -1
  72. package/dist/v1/build/TinyColorValidator.d.mts +1 -1
  73. package/dist/v1/build/TinyCookieConsent.d.mts +1 -1
  74. package/dist/v1/build/TinyDayNightCycle.d.mts +1 -1
  75. package/dist/v1/build/TinyDomReadyManager.d.mts +1 -1
  76. package/dist/v1/build/TinyDragDropDetector.d.mts +1 -1
  77. package/dist/v1/build/TinyDragger.d.mts +1 -1
  78. package/dist/v1/build/TinyElementObserver.d.mts +1 -1
  79. package/dist/v1/build/TinyGamepad.d.mts +1 -1
  80. package/dist/v1/build/TinyHtml.d.mts +1 -1
  81. package/dist/v1/build/TinyI18.d.mts +1 -1
  82. package/dist/v1/build/TinyIframeEvents.d.mts +1 -1
  83. package/dist/v1/build/TinyInventory.d.mts +1 -1
  84. package/dist/v1/build/TinyInventoryTrader.d.mts +1 -1
  85. package/dist/v1/build/TinyLevelUp.d.mts +1 -1
  86. package/dist/v1/build/TinyLoadingScreen.d.mts +1 -1
  87. package/dist/v1/build/TinyLocalStorage.d.mts +1 -1
  88. package/dist/v1/build/TinyMediaPlayer.d.mts +1 -1
  89. package/dist/v1/build/TinyNeedBar.d.mts +1 -1
  90. package/dist/v1/build/TinyNewWinEvents.d.mts +1 -1
  91. package/dist/v1/build/TinyNotifications.d.mts +1 -1
  92. package/dist/v1/build/TinyNotifyCenter.d.mts +1 -1
  93. package/dist/v1/build/TinyPromiseQueue.d.mts +1 -1
  94. package/dist/v1/build/TinyRadioFm.d.mts +1 -1
  95. package/dist/v1/build/TinyRateLimiter.d.mts +1 -1
  96. package/dist/v1/build/TinySimpleDice.d.mts +1 -1
  97. package/dist/v1/build/TinySmartScroller.d.mts +1 -1
  98. package/dist/v1/build/TinyTextDiffer.d.mts +1 -1
  99. package/dist/v1/build/TinyTextRangeEditor.d.mts +1 -1
  100. package/dist/v1/build/TinyTextarea.d.mts +1 -1
  101. package/dist/v1/build/TinyTimeout.d.mts +1 -1
  102. package/dist/v1/build/TinyToastNotify.d.mts +1 -1
  103. package/dist/v1/build/TinyUploadClicker.d.mts +1 -1
  104. package/dist/v1/build/UltraRandomMsgGen.d.mts +1 -1
  105. package/dist/v1/fileManager/asyncFuncs.d.mts +13 -13
  106. package/dist/v1/fileManager/index.d.mts +3 -29
  107. package/dist/v1/fileManager/normalFuncs.d.mts +22 -22
  108. package/dist/v1/index.cjs +4 -0
  109. package/dist/v1/index.d.mts +54 -137
  110. package/dist/v1/index.mjs +4 -3
  111. package/dist/v1/libs/ColorSafeStringify.d.mts +3 -12
  112. package/dist/v1/libs/TinyAdvancedRaffle.cjs +64 -50
  113. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +64 -116
  114. package/dist/v1/libs/TinyAdvancedRaffle.mjs +62 -49
  115. package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
  116. package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +15 -19
  117. package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
  118. package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
  119. package/dist/v1/libs/TinyAnalogClock.d.mts +12 -9
  120. package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
  121. package/dist/v1/libs/TinyArrayComparator.d.mts +14 -20
  122. package/dist/v1/libs/TinyArrayPaginator.d.mts +22 -26
  123. package/dist/v1/libs/TinyClassManager/TinyPluginInliner.d.mts +8 -8
  124. package/dist/v1/libs/TinyClassManager.cjs +5 -7
  125. package/dist/v1/libs/TinyClassManager.d.mts +16 -16
  126. package/dist/v1/libs/TinyClassManager.mjs +5 -6
  127. package/dist/v1/libs/TinyClipboard.cjs +2 -0
  128. package/dist/v1/libs/TinyClipboard.d.mts +12 -5
  129. package/dist/v1/libs/TinyClipboard.mjs +2 -0
  130. package/dist/v1/libs/TinyColorConverter.cjs +1 -0
  131. package/dist/v1/libs/TinyColorConverter.d.mts +10 -32
  132. package/dist/v1/libs/TinyColorConverter.mjs +1 -0
  133. package/dist/v1/libs/TinyColorValidator.d.mts +145 -184
  134. package/dist/v1/libs/TinyCookieConsent.d.mts +17 -17
  135. package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
  136. package/dist/v1/libs/TinyDayNightCycle.d.mts +87 -117
  137. package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
  138. package/dist/v1/libs/TinyDomReadyManager.d.mts +8 -16
  139. package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
  140. package/dist/v1/libs/TinyDragDropDetector.d.mts +32 -26
  141. package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
  142. package/dist/v1/libs/TinyDragger.cjs +46 -19
  143. package/dist/v1/libs/TinyDragger.d.mts +82 -81
  144. package/dist/v1/libs/TinyDragger.mjs +45 -18
  145. package/dist/v1/libs/TinyElementObserver.cjs +39 -0
  146. package/dist/v1/libs/TinyElementObserver.d.mts +28 -25
  147. package/dist/v1/libs/TinyElementObserver.mjs +36 -0
  148. package/dist/v1/libs/TinyGamepad.cjs +131 -2
  149. package/dist/v1/libs/TinyGamepad.d.mts +50 -122
  150. package/dist/v1/libs/TinyGamepad.mjs +129 -2
  151. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.cjs +2 -25
  152. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.d.mts +19 -25
  153. package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.mjs +3 -27
  154. package/dist/v1/libs/TinyHtml/TinyHtmlButton.cjs +2 -1
  155. package/dist/v1/libs/TinyHtml/TinyHtmlButton.d.mts +55 -55
  156. package/dist/v1/libs/TinyHtml/TinyHtmlButton.mjs +2 -1
  157. package/dist/v1/libs/TinyHtml/TinyHtmlCanvas.d.mts +6 -6
  158. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.cjs +8 -4
  159. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.d.mts +19 -21
  160. package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.mjs +7 -4
  161. package/dist/v1/libs/TinyHtml/TinyHtmlEmbed.d.mts +8 -8
  162. package/dist/v1/libs/TinyHtml/TinyHtmlForm.d.mts +18 -18
  163. package/dist/v1/libs/TinyHtml/TinyHtmlIcon.d.mts +5 -6
  164. package/dist/v1/libs/TinyHtml/TinyHtmlIframe.d.mts +19 -19
  165. package/dist/v1/libs/TinyHtml/TinyHtmlImage.cjs +0 -28
  166. package/dist/v1/libs/TinyHtml/TinyHtmlImage.d.mts +22 -28
  167. package/dist/v1/libs/TinyHtml/TinyHtmlImage.mjs +1 -27
  168. package/dist/v1/libs/TinyHtml/TinyHtmlInput.d.mts +11 -11
  169. package/dist/v1/libs/TinyHtml/TinyHtmlLink.d.mts +23 -23
  170. package/dist/v1/libs/TinyHtml/TinyHtmlMedia.d.mts +26 -26
  171. package/dist/v1/libs/TinyHtml/TinyHtmlScript.cjs +4 -30
  172. package/dist/v1/libs/TinyHtml/TinyHtmlScript.d.mts +20 -26
  173. package/dist/v1/libs/TinyHtml/TinyHtmlScript.mjs +5 -32
  174. package/dist/v1/libs/TinyHtml/TinyHtmlSelect.d.mts +19 -19
  175. package/dist/v1/libs/TinyHtml/TinyHtmlStyle.d.mts +8 -8
  176. package/dist/v1/libs/TinyHtml/TinyHtmlTemplate.d.mts +26 -28
  177. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.cjs +14 -15
  178. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.d.mts +32 -32
  179. package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.mjs +15 -15
  180. package/dist/v1/libs/TinyHtml/index.d.mts +102 -45
  181. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.cjs +11 -9
  182. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.d.mts +21 -21
  183. package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.mjs +11 -9
  184. package/dist/v1/libs/TinyHtml/input/TinyHtmlFileInput.d.mts +11 -11
  185. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.cjs +4 -4
  186. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.d.mts +17 -13
  187. package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.mjs +4 -4
  188. package/dist/v1/libs/TinyHtml/input/TinyHtmlImageInput.d.mts +21 -21
  189. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.cjs +5 -4
  190. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.d.mts +14 -14
  191. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.mjs +5 -4
  192. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.cjs +4 -3
  193. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.d.mts +10 -10
  194. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.mjs +4 -3
  195. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.cjs +4 -3
  196. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.d.mts +19 -19
  197. package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.mjs +4 -3
  198. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.cjs +5 -4
  199. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.d.mts +11 -11
  200. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.mjs +5 -4
  201. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.cjs +4 -3
  202. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.d.mts +15 -11
  203. package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.mjs +4 -3
  204. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.cjs +49 -21
  205. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.d.mts +34 -20
  206. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.mjs +45 -20
  207. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.cjs +1 -1
  208. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.d.mts +14 -14
  209. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.mjs +1 -1
  210. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.cjs +1 -1
  211. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.d.mts +14 -14
  212. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.mjs +1 -1
  213. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.cjs +48 -25
  214. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.d.mts +27 -21
  215. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.mjs +40 -27
  216. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.cjs +1 -1
  217. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.d.mts +14 -14
  218. package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.mjs +1 -1
  219. package/dist/v1/libs/TinyHtml/input/number/TinyHtmlNumberInput.d.mts +14 -14
  220. package/dist/v1/libs/TinyHtml/input/number/TinyHtmlRangeInput.d.mts +14 -14
  221. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlEmailInput.d.mts +25 -21
  222. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlPasswordInput.d.mts +18 -18
  223. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlSearchInput.d.mts +33 -29
  224. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTelInput.d.mts +22 -22
  225. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTextInput.d.mts +18 -18
  226. package/dist/v1/libs/TinyHtml/input/text/TinyHtmlUrlInput.d.mts +31 -27
  227. package/dist/v1/libs/TinyHtml/media/TinyHtmlAudio.d.mts +35 -11
  228. package/dist/v1/libs/TinyHtml/media/TinyHtmlObject.d.mts +10 -10
  229. package/dist/v1/libs/TinyHtml/media/TinyHtmlSource.d.mts +12 -12
  230. package/dist/v1/libs/TinyHtml/media/TinyHtmlVideo.d.mts +35 -27
  231. package/dist/v1/libs/TinyHtml.cjs +4 -5
  232. package/dist/v1/libs/TinyHtml.d.mts +1503 -1731
  233. package/dist/v1/libs/TinyHtml.mjs +5 -6
  234. package/dist/v1/libs/TinyI18.cjs +61 -0
  235. package/dist/v1/libs/TinyI18.d.mts +34 -58
  236. package/dist/v1/libs/TinyI18.mjs +55 -0
  237. package/dist/v1/libs/TinyIframeEvents.cjs +19 -2
  238. package/dist/v1/libs/TinyIframeEvents.d.mts +29 -38
  239. package/dist/v1/libs/TinyIframeEvents.mjs +19 -2
  240. package/dist/v1/libs/TinyInventory.d.mts +78 -141
  241. package/dist/v1/libs/TinyInventoryTrader.d.mts +19 -22
  242. package/dist/v1/libs/TinyLevelUp.d.mts +10 -13
  243. package/dist/v1/libs/TinyLoadingScreen.d.mts +21 -31
  244. package/dist/v1/libs/TinyLocalStorage.cjs +48 -0
  245. package/dist/v1/libs/TinyLocalStorage.d.mts +11 -30
  246. package/dist/v1/libs/TinyLocalStorage.mjs +45 -0
  247. package/dist/v1/libs/TinyMamdaniInferenceSystem.d.mts +37 -23
  248. package/dist/v1/libs/TinyMediaPlayer.cjs +77 -3
  249. package/dist/v1/libs/TinyMediaPlayer.d.mts +109 -106
  250. package/dist/v1/libs/TinyMediaPlayer.mjs +71 -3
  251. package/dist/v1/libs/TinyNeedBar.d.mts +25 -37
  252. package/dist/v1/libs/TinyNewWinEvents.cjs +29 -0
  253. package/dist/v1/libs/TinyNewWinEvents.d.mts +32 -29
  254. package/dist/v1/libs/TinyNewWinEvents.mjs +26 -0
  255. package/dist/v1/libs/TinyNotifications.d.mts +6 -6
  256. package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
  257. package/dist/v1/libs/TinyNotifyCenter.d.mts +15 -15
  258. package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
  259. package/dist/v1/libs/TinyPromiseQueue.d.mts +11 -11
  260. package/dist/v1/libs/TinyRadioFm.cjs +70 -12
  261. package/dist/v1/libs/TinyRadioFm.d.mts +45 -80
  262. package/dist/v1/libs/TinyRadioFm.mjs +64 -12
  263. package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
  264. package/dist/v1/libs/TinyRateLimiter.d.mts +29 -36
  265. package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
  266. package/dist/v1/libs/TinySimpleDice.d.mts +17 -36
  267. package/dist/v1/libs/TinySmartScroller.cjs +52 -3
  268. package/dist/v1/libs/TinySmartScroller.d.mts +62 -70
  269. package/dist/v1/libs/TinySmartScroller.mjs +51 -5
  270. package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
  271. package/dist/v1/libs/TinyTextDiffer.d.mts +11 -13
  272. package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
  273. package/dist/v1/libs/TinyTextRangeEditor.d.mts +8 -8
  274. package/dist/v1/libs/TinyTextarea.cjs +19 -0
  275. package/dist/v1/libs/TinyTextarea.d.mts +34 -28
  276. package/dist/v1/libs/TinyTextarea.mjs +17 -0
  277. package/dist/v1/libs/TinyTimeout.cjs +11 -1
  278. package/dist/v1/libs/TinyTimeout.d.mts +14 -14
  279. package/dist/v1/libs/TinyTimeout.mjs +9 -1
  280. package/dist/v1/libs/TinyToastNotify.cjs +36 -1
  281. package/dist/v1/libs/TinyToastNotify.d.mts +15 -17
  282. package/dist/v1/libs/TinyToastNotify.mjs +32 -1
  283. package/dist/v1/libs/TinyUploadClicker.cjs +19 -0
  284. package/dist/v1/libs/TinyUploadClicker.d.mts +38 -8
  285. package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
  286. package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
  287. package/dist/v1/libs/UltraRandomMsgGen.d.mts +52 -78
  288. package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
  289. package/dist/v1/libs/utils.cjs +21 -0
  290. package/dist/v1/libs/utils.d.mts +6 -0
  291. package/dist/v1/libs/utils.mjs +16 -0
  292. package/docs/v1/README.md +1 -0
  293. package/docs/v1/basics/array.md +2 -2
  294. package/docs/v1/basics/deprecated/html.md +17 -0
  295. package/docs/v1/basics/fullScreen.md +1 -1
  296. package/docs/v1/basics/html.md +12 -26
  297. package/docs/v1/basics/mediaContent.md +1 -1
  298. package/docs/v1/basics/objChecker.md +1 -1
  299. package/docs/v1/basics/text.md +2 -2
  300. package/docs/v1/fileManager/main.md +1 -1
  301. package/docs/v1/libs/ColorSafeStringify.md +1 -1
  302. package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
  303. package/docs/v1/libs/TinyAnalogClock.md +1 -1
  304. package/docs/v1/libs/TinyArrayComparator.md +1 -1
  305. package/docs/v1/libs/TinyArrayPaginator.md +1 -1
  306. package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
  307. package/docs/v1/libs/TinyClassManager.md +1 -1
  308. package/docs/v1/libs/TinyClipboard.md +1 -1
  309. package/docs/v1/libs/TinyCookieConsent.md +1 -1
  310. package/docs/v1/libs/TinyDomReadyManager.md +1 -1
  311. package/docs/v1/libs/TinyDragDropDetector.md +1 -1
  312. package/docs/v1/libs/TinyDragger.md +1 -1
  313. package/docs/v1/libs/TinyElementObserver.md +1 -1
  314. package/docs/v1/libs/TinyHtml.md +1 -1
  315. package/docs/v1/libs/TinyIframeEvents.md +2 -2
  316. package/docs/v1/libs/TinyLevelUp.md +1 -1
  317. package/docs/v1/libs/TinyLoadingScreen.md +1 -1
  318. package/docs/v1/libs/TinyNewWinEvents.md +2 -2
  319. package/docs/v1/libs/TinyNotifications.md +1 -1
  320. package/docs/v1/libs/TinyPromiseQueue.md +2 -2
  321. package/docs/v1/libs/TinyTextDiffer.md +1 -1
  322. package/docs/v1/libs/TinyTextarea.md +1 -1
  323. package/package.json +11 -2
@@ -1 +1 @@
1
- (()=>{var e={975(e,t,r){"use strict";var n=r(606);function o(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function i(e,t){for(var r,n="",o=0,i=-1,s=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(i===a-1||1===s);else if(i!==a-1&&2===s){if(n.length<2||2!==o||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(n.length>2){var l=n.lastIndexOf("/");if(l!==n.length-1){-1===l?(n="",o=0):o=(n=n.slice(0,l)).length-1-n.lastIndexOf("/"),i=a,s=0;continue}}else if(2===n.length||1===n.length){n="",o=0,i=a,s=0;continue}t&&(n.length>0?n+="/..":n="..",o=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),o=a-i-1;i=a,s=0}else 46===r&&-1!==s?++s:s=-1}return n}var s={resolve:function(){for(var e,t="",r=!1,s=arguments.length-1;s>=-1&&!r;s--){var a;s>=0?a=arguments[s]:(void 0===e&&(e=n.cwd()),a=e),o(a),0!==a.length&&(t=a+"/"+t,r=47===a.charCodeAt(0))}return t=i(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(o(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=i(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return o(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var r=arguments[t];o(r),r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":s.normalize(e)},relative:function(e,t){if(o(e),o(t),e===t)return"";if((e=s.resolve(e))===(t=s.resolve(t)))return"";for(var r=1;r<e.length&&47===e.charCodeAt(r);++r);for(var n=e.length,i=n-r,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var l=t.length-a,c=i<l?i:l,f=-1,h=0;h<=c;++h){if(h===c){if(l>c){if(47===t.charCodeAt(a+h))return t.slice(a+h+1);if(0===h)return t.slice(a+h)}else i>c&&(47===e.charCodeAt(r+h)?f=h:0===h&&(f=0));break}var u=e.charCodeAt(r+h);if(u!==t.charCodeAt(a+h))break;47===u&&(f=h)}var p="";for(h=r+f+1;h<=n;++h)h!==n&&47!==e.charCodeAt(h)||(0===p.length?p+="..":p+="/..");return p.length>0?p+t.slice(a+f):(a+=f,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(o(e),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,n=-1,i=!0,s=e.length-1;s>=1;--s)if(47===(t=e.charCodeAt(s))){if(!i){n=s;break}}else i=!1;return-1===n?r?"/":".":r&&1===n?"//":e.slice(0,n)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');o(e);var r,n=0,i=-1,s=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(r=e.length-1;r>=0;--r){var c=e.charCodeAt(r);if(47===c){if(!s){n=r+1;break}}else-1===l&&(s=!1,l=r+1),a>=0&&(c===t.charCodeAt(a)?-1===--a&&(i=r):(a=-1,i=l))}return n===i?i=l:-1===i&&(i=e.length),e.slice(n,i)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!s){n=r+1;break}}else-1===i&&(s=!1,i=r+1);return-1===i?"":e.slice(n,i)},extname:function(e){o(e);for(var t=-1,r=0,n=-1,i=!0,s=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===n&&(i=!1,n=a+1),46===l?-1===t?t=a:1!==s&&(s=1):-1!==t&&(s=-1);else if(!i){r=a+1;break}}return-1===t||-1===n||0===s||1===s&&t===n-1&&t===r+1?"":e.slice(t,n)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+"/"+n:n}(0,e)},parse:function(e){o(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var r,n=e.charCodeAt(0),i=47===n;i?(t.root="/",r=1):r=0;for(var s=-1,a=0,l=-1,c=!0,f=e.length-1,h=0;f>=r;--f)if(47!==(n=e.charCodeAt(f)))-1===l&&(c=!1,l=f+1),46===n?-1===s?s=f:1!==h&&(h=1):-1!==s&&(h=-1);else if(!c){a=f+1;break}return-1===s||-1===l||0===h||1===h&&s===l-1&&s===a+1?-1!==l&&(t.base=t.name=0===a&&i?e.slice(1,l):e.slice(a,l)):(0===a&&i?(t.name=e.slice(1,s),t.base=e.slice(1,l)):(t.name=e.slice(a,s),t.base=e.slice(a,l)),t.ext=e.slice(s,l)),a>0?t.dir=e.slice(0,a-1):i&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};s.posix=s,e.exports=s},606(e){var t,r,n=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var a,l=[],c=!1,f=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):f=-1,l.length&&u())}function u(){if(!c){var e=s(h);c=!0;for(var t=l.length;t;){for(a=l,l=[];++f<t;)a&&a[f].run();f=-1,t=l.length}a=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function g(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new p(e,t)),1!==l.length||c||s(u)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=g,n.addListener=g,n.once=g,n.off=g,n.removeListener=g,n.removeAllListeners=g,n.emit=g,n.prependListener=g,n.prependOnceListener=g,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},766(){},911(){}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],i=t[n++];r.o(e,o)?0===i&&n++:0===i?Object.defineProperty(e,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:i})}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);let n={};(()=>{"use strict";r.d(n,{TinyI18:()=>i});var e=r(911),t=r(766),o=r(975);const i=class{static async mergeLocaleFiles({files:r,output:n,spaces:o=0}){if("number"!=typeof o||Number.isNaN(o)||o<0)throw new TypeError('mergeLocaleFiles: "spaces" must be a non-negative number');if(!Array.isArray(r)||0===r.length)throw new TypeError('mergeLocaleFiles: "files" must be a non-empty array of file paths');if("string"!=typeof n||!n)throw new TypeError('mergeLocaleFiles: "output" must be a non-empty string path');const i={};for(const n of r){if("string"!=typeof n||!n)throw new TypeError("mergeLocaleFiles: each file path must be a non-empty string");if(!(0,t.existsSync)(n))throw new Error(`mergeLocaleFiles: file "${n}" does not exist`);const r=await(0,e.readFile)(n,"utf-8");let o;try{o=JSON.parse(r)}catch(e){throw new Error(`mergeLocaleFiles: file "${n}" is not valid JSON`)}Object.assign(i,o)}await(0,e.writeFile)(n,JSON.stringify(i,null,o),"utf-8")}#e;#t;#r=null;#n;#o=null;#i=new Map;#s=new Map;#a=new Map;#l=new Map;get currentLocale(){return this.#r}get defaultLocale(){return this.#t}get mode(){return this.#e}get strict(){return this.#n}get basePath(){return this.#o}get stats(){const e=[];for(const t of this.#i.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){const e={};for(const[t,r]of this.#i.entries())e[t]=this.#c(r);return e}get patternTables(){const e={};for(const[t,r]of this.#s.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#c(e.value),elseValue:this.#c(e.elseValue)}));return e}get helpers(){const e={};for(const[t,r]of this.#a.entries())e[t]=r;return e}get regexCache(){const e={};for(const[t,r]of this.#l.entries())e[t]=new RegExp(r.source,r.flags);return e}#c(e){if(null==e||"string"==typeof e||"function"==typeof e||"number"==typeof e)return e;if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(e=>this.#c(e));if("object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=this.#c(n);return t}return e}#f(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('#resolveOrder: "forceLocale" must be a string if provided');const t=[];return e&&"string"==typeof e&&this.#i.has(e)?t.push(e):this.#r&&t.push(this.#r),t.push(this.#t),t}#h(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveExact: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveExact: "key" must be a non-empty string');for(const r of e){const e=this.#i.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#u(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveByPattern: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveByPattern: "key" must be a non-empty string');for(const r of e){const e=this.#s.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#p(e,t){if(null==e){if(this.#n)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#g(e,t);if("function"==typeof e)return e(t??{},this.#y());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#a.get(e.$fn);if("function"!=typeof r){if(this.#n)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#y())}if(this.#n)throw new Error("TinyI18: unsupported entry type");return""}#g(e,t){if("string"!=typeof e)throw new TypeError('#interpolate: "template" must be a string');if(void 0!==t&&(null===t||"object"!=typeof t))throw new TypeError('#interpolate: "params" must be an object if provided');return t&&"object"==typeof t?e.replace(/\{([a-zA-Z0-9_.$-]+)\}/g,(e,r)=>{const n=this.#d(t,r);return null==n?"":String(n)}):e}#d(e,t){if(!e||"object"!=typeof e)throw new TypeError('#dotGet: "obj" must be an object');if("string"!=typeof t||!t)throw new TypeError('#dotGet: "path" must be a non-empty string');const r=t.split(".");let n=e;for(const e of r){if(null==n)return;n=n[e]}return n}#y(){return{has:e=>this.#a.has(e),call:(e,t,r)=>{const n=this.#a.get(e);if("function"!=typeof n)throw new Error(`Helper "${e}" not found`);return n(t,r??{})}}}#b(e,t){if("string"!=typeof e||!e)throw new TypeError('#ingestLocale: "locale" must be a non-empty string');if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');if("string"!=typeof e||!e)throw new TypeError("#ingestLocale: invalid locale");if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');const r={...this.#i.get(e)??{}},n=[...this.#s.get(e)??[]],o=(e,t)=>{if(null!=t)if("string"==typeof t||"function"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");r[e]=t}else if(t&&"object"==typeof t){if(t.$pattern instanceof RegExp&&Object.prototype.hasOwnProperty.call(t,"value"))return void n.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,n]of Object.entries(t))o(e?`${e}.${r}`:r,n)}};o("",t),this.#i.set(e,r),this.#s.set(e,n),this.#i.has(this.#t)||(this.#i.set(this.#t,{}),this.#s.set(this.#t,[]))}#w(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#t&&(this.#i.delete(e),this.#s.delete(e))}async#m(t){if("string"!=typeof t||!t)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#o||!this.#o)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const r=(0,o.join)(this.#o,`${t}.json`);let n;try{const t=await(0,e.readFile)(r,"utf8");n=JSON.parse(t)}catch(e){if(!(e instanceof Error))return;if(this.#n)throw new Error(`TinyI18: failed to load or parse ${r}: ${e.message}`);return this.#i.set(t,{}),void this.#s.set(t,[])}const i={...this.#i.get(t)??{}},s=[...this.#s.get(t)??[]],a=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#T(t.$pattern);return void s.push({$pattern:e,value:this.#v(t.value),elseValue:this.#v(t.elseValue)})}if("string"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");i[e]=this.#v(t)}else if(t&&"object"==typeof t)for(const[r,n]of Object.entries(t))a(e?`${e}.${r}`:r,n)}};a("",n),this.#i.set(t,i),this.#s.set(t,s)}#T(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#l.get(e);if(t)return t;try{const t=new RegExp(e);return this.#l.set(e,t),t}catch{if(this.#n)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#v(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"string"==typeof e.$fn)return{$fn:String(e.$fn),args:e.args};if(this.#n)throw new Error("TinyI18: unsupported value in file JSON");return""}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("TinyI18: options must be an object");const{mode:t,defaultLocale:r,basePath:n,localResources:o,strict:i=!0}=e;if("local"!==t&&"file"!==t)throw new TypeError('TinyI18: "mode" must be "local" or "file"');if("string"!=typeof r||!r)throw new TypeError('TinyI18: "defaultLocale" must be a non-empty string');if("boolean"!=typeof i)throw new TypeError('TinyI18: "strict" must be a boolean');if("file"===t){if("string"!=typeof n||!n)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#o=n}if(this.#e=t,this.#t=r,this.#n=i,"local"===t&&o&&"object"==typeof o)for(const[e,t]of Object.entries(o))this.#b(e,t);this.#i.has(this.#t)||(this.#i.set(this.#t,{}),this.#s.set(this.#t,[]))}clearRegexCache(){this.#l.clear()}registerHelper(e,t){if("string"!=typeof e||!e)throw new TypeError('registerHelper: "name" must be non-empty string');if("function"!=typeof t)throw new TypeError('registerHelper: "fn" must be a function');this.#a.set(e,t)}unregisterHelper(e){if("string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#a.delete(e)}loadLocaleLocal(e,t){if("local"!==this.#e)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#b(e,t)}async setLocale(e){if(null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#r;null!==e&&("file"===this.#e?await this.#m(e):this.#i.has(e)||(this.#i.set(e,{}),this.#s.set(e,[]))),"file"===this.#e&&t&&t!==this.#t&&t!==e&&this.#w(t),this.#r=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if("string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:n}=r||{},o=this.#f(n);let i=this.#h(o,e);if(void 0===i){if(this.#n)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#p(i,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if("string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},n=this.#f(r);let o=this.#u(n,e);if(void 0===o){if(this.#n)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return o}resetToDefaultOnly(){if("file"===this.#e)for(const e of Array.from(this.#i.keys()))e!==this.#t&&this.#w(e);this.#r=null}getStatsForLocale(e){if("string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#i.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#i.get(e)??{}).length,patterns:this.#s.get(e)?.length??0,isDefault:e===this.#t,isCurrent:e===this.#r}}}})(),window.TinyI18=n.TinyI18})();
1
+ (()=>{var e={975(e,t,r){"use strict";var n=r(606);function o(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function s(e,t){for(var r,n="",o=0,s=-1,i=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(s===a-1||1===i);else if(s!==a-1&&2===i){if(n.length<2||2!==o||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(n.length>2){var l=n.lastIndexOf("/");if(l!==n.length-1){-1===l?(n="",o=0):o=(n=n.slice(0,l)).length-1-n.lastIndexOf("/"),s=a,i=0;continue}}else if(2===n.length||1===n.length){n="",o=0,s=a,i=0;continue}t&&(n.length>0?n+="/..":n="..",o=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),o=a-s-1;s=a,i=0}else 46===r&&-1!==i?++i:i=-1}return n}var i={resolve:function(){for(var e,t="",r=!1,i=arguments.length-1;i>=-1&&!r;i--){var a;i>=0?a=arguments[i]:(void 0===e&&(e=n.cwd()),a=e),o(a),0!==a.length&&(t=a+"/"+t,r=47===a.charCodeAt(0))}return t=s(t,!r),r?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(e){if(o(e),0===e.length)return".";var t=47===e.charCodeAt(0),r=47===e.charCodeAt(e.length-1);return 0!==(e=s(e,!t)).length||t||(e="."),e.length>0&&r&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return o(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var r=arguments[t];o(r),r.length>0&&(void 0===e?e=r:e+="/"+r)}return void 0===e?".":i.normalize(e)},relative:function(e,t){if(o(e),o(t),e===t)return"";if((e=i.resolve(e))===(t=i.resolve(t)))return"";for(var r=1;r<e.length&&47===e.charCodeAt(r);++r);for(var n=e.length,s=n-r,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var l=t.length-a,c=s<l?s:l,f=-1,h=0;h<=c;++h){if(h===c){if(l>c){if(47===t.charCodeAt(a+h))return t.slice(a+h+1);if(0===h)return t.slice(a+h)}else s>c&&(47===e.charCodeAt(r+h)?f=h:0===h&&(f=0));break}var u=e.charCodeAt(r+h);if(u!==t.charCodeAt(a+h))break;47===u&&(f=h)}var p="";for(h=r+f+1;h<=n;++h)h!==n&&47!==e.charCodeAt(h)||(0===p.length?p+="..":p+="/..");return p.length>0?p+t.slice(a+f):(a+=f,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(o(e),0===e.length)return".";for(var t=e.charCodeAt(0),r=47===t,n=-1,s=!0,i=e.length-1;i>=1;--i)if(47===(t=e.charCodeAt(i))){if(!s){n=i;break}}else s=!1;return-1===n?r?"/":".":r&&1===n?"//":e.slice(0,n)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');o(e);var r,n=0,s=-1,i=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,l=-1;for(r=e.length-1;r>=0;--r){var c=e.charCodeAt(r);if(47===c){if(!i){n=r+1;break}}else-1===l&&(i=!1,l=r+1),a>=0&&(c===t.charCodeAt(a)?-1===--a&&(s=r):(a=-1,s=l))}return n===s?s=l:-1===s&&(s=e.length),e.slice(n,s)}for(r=e.length-1;r>=0;--r)if(47===e.charCodeAt(r)){if(!i){n=r+1;break}}else-1===s&&(i=!1,s=r+1);return-1===s?"":e.slice(n,s)},extname:function(e){o(e);for(var t=-1,r=0,n=-1,s=!0,i=0,a=e.length-1;a>=0;--a){var l=e.charCodeAt(a);if(47!==l)-1===n&&(s=!1,n=a+1),46===l?-1===t?t=a:1!==i&&(i=1):-1!==t&&(i=-1);else if(!s){r=a+1;break}}return-1===t||-1===n||0===i||1===i&&t===n-1&&t===r+1?"":e.slice(t,n)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+"/"+n:n}(0,e)},parse:function(e){o(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var r,n=e.charCodeAt(0),s=47===n;s?(t.root="/",r=1):r=0;for(var i=-1,a=0,l=-1,c=!0,f=e.length-1,h=0;f>=r;--f)if(47!==(n=e.charCodeAt(f)))-1===l&&(c=!1,l=f+1),46===n?-1===i?i=f:1!==h&&(h=1):-1!==i&&(h=-1);else if(!c){a=f+1;break}return-1===i||-1===l||0===h||1===h&&i===l-1&&i===a+1?-1!==l&&(t.base=t.name=0===a&&s?e.slice(1,l):e.slice(a,l)):(0===a&&s?(t.name=e.slice(1,i),t.base=e.slice(1,l)):(t.name=e.slice(a,i),t.base=e.slice(a,l)),t.ext=e.slice(i,l)),a>0?t.dir=e.slice(0,a-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};i.posix=i,e.exports=i},606(e){var t,r,n=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function i(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}}();var a,l=[],c=!1,f=-1;function h(){c&&a&&(c=!1,a.length?l=a.concat(l):f=-1,l.length&&u())}function u(){if(!c){var e=i(h);c=!0;for(var t=l.length;t;){for(a=l,l=[];++f<t;)a&&a[f].run();f=-1,t=l.length}a=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===s||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{return r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function y(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];l.push(new p(e,t)),1!==l.length||c||i(u)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=y,n.addListener=y,n.once=y,n.off=y,n.removeListener=y,n.removeAllListeners=y,n.emit=y,n.prependListener=y,n.prependOnceListener=y,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},766(){},911(){}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],s=t[n++];r.o(e,o)?0===s&&n++:0===s?Object.defineProperty(e,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:s})}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);let n={};(()=>{"use strict";r.d(n,{TinyI18:()=>i});var e=r(911),t=r(766),o=r(975);const s=e=>{if(e)throw new Error("This TinyI18 instance has been destroyed and can no longer be used.")};const i=class{static async mergeLocaleFiles({files:r,output:n,spaces:o=0}){if("number"!=typeof o||Number.isNaN(o)||o<0)throw new TypeError('mergeLocaleFiles: "spaces" must be a non-negative number');if(!Array.isArray(r)||0===r.length)throw new TypeError('mergeLocaleFiles: "files" must be a non-empty array of file paths');if("string"!=typeof n||!n)throw new TypeError('mergeLocaleFiles: "output" must be a non-empty string path');const s={};for(const n of r){if("string"!=typeof n||!n)throw new TypeError("mergeLocaleFiles: each file path must be a non-empty string");if(!(0,t.existsSync)(n))throw new Error(`mergeLocaleFiles: file "${n}" does not exist`);const r=await(0,e.readFile)(n,"utf-8");let o;try{o=JSON.parse(r)}catch(e){throw new Error(`mergeLocaleFiles: file "${n}" is not valid JSON`)}Object.assign(s,o)}await(0,e.writeFile)(n,JSON.stringify(s,null,o),"utf-8")}#e=!1;get destroyed(){return this.#e}#t;#r;#n=null;#o;#s=null;#i=new Map;#a=new Map;#l=new Map;#c=new Map;get currentLocale(){return s(this.#e),this.#n}get defaultLocale(){return s(this.#e),this.#r}get mode(){return s(this.#e),this.#t}get strict(){return s(this.#e),this.#o}get basePath(){return s(this.#e),this.#s}get stats(){s(this.#e);const e=[];for(const t of this.#i.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){s(this.#e);const e={};for(const[t,r]of this.#i.entries())e[t]=this.#f(r);return e}get patternTables(){s(this.#e);const e={};for(const[t,r]of this.#a.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#f(e.value),elseValue:this.#f(e.elseValue)}));return e}get helpers(){s(this.#e);const e={};for(const[t,r]of this.#l.entries())e[t]=r;return e}get regexCache(){s(this.#e);const e={};for(const[t,r]of this.#c.entries())e[t]=new RegExp(r.source,r.flags);return e}#f(e){if(null==e||"string"==typeof e||"function"==typeof e||"number"==typeof e)return e;if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(e=>this.#f(e));if("object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=this.#f(n);return t}return e}#h(e){if(void 0!==e&&"string"!=typeof e)throw new TypeError('#resolveOrder: "forceLocale" must be a string if provided');const t=[];return e&&"string"==typeof e&&this.#i.has(e)?t.push(e):this.#n&&t.push(this.#n),t.push(this.#r),t}#u(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveExact: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveExact: "key" must be a non-empty string');for(const r of e){const e=this.#i.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#p(e,t){if(!Array.isArray(e)||!e.every(e=>"string"==typeof e))throw new TypeError('#resolveByPattern: "order" must be an array of strings');if("string"!=typeof t||!t)throw new TypeError('#resolveByPattern: "key" must be a non-empty string');for(const r of e){const e=this.#a.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#y(e,t){if(null==e){if(this.#o)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#g(e,t);if("function"==typeof e)return e(t??{},this.#d());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#l.get(e.$fn);if("function"!=typeof r){if(this.#o)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#d())}if(this.#o)throw new Error("TinyI18: unsupported entry type");return""}#g(e,t){if("string"!=typeof e)throw new TypeError('#interpolate: "template" must be a string');if(void 0!==t&&(null===t||"object"!=typeof t))throw new TypeError('#interpolate: "params" must be an object if provided');return t&&"object"==typeof t?e.replace(/\{([a-zA-Z0-9_.$-]+)\}/g,(e,r)=>{const n=this.#b(t,r);return null==n?"":String(n)}):e}#b(e,t){if(!e||"object"!=typeof e)throw new TypeError('#dotGet: "obj" must be an object');if("string"!=typeof t||!t)throw new TypeError('#dotGet: "path" must be a non-empty string');const r=t.split(".");let n=e;for(const e of r){if(null==n)return;n=n[e]}return n}#d(){return{has:e=>this.#l.has(e),call:(e,t,r)=>{const n=this.#l.get(e);if("function"!=typeof n)throw new Error(`Helper "${e}" not found`);return n(t,r??{})}}}#w(e,t){if("string"!=typeof e||!e)throw new TypeError('#ingestLocale: "locale" must be a non-empty string');if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');if("string"!=typeof e||!e)throw new TypeError("#ingestLocale: invalid locale");if(!t||"object"!=typeof t)throw new TypeError('#ingestLocale: "raw" must be an object');const r={...this.#i.get(e)??{}},n=[...this.#a.get(e)??[]],o=(e,t)=>{if(null!=t)if("string"==typeof t||"function"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");r[e]=t}else if(t&&"object"==typeof t){if(t.$pattern instanceof RegExp&&Object.prototype.hasOwnProperty.call(t,"value"))return void n.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,n]of Object.entries(t))o(e?`${e}.${r}`:r,n)}};o("",t),this.#i.set(e,r),this.#a.set(e,n),this.#i.has(this.#r)||(this.#i.set(this.#r,{}),this.#a.set(this.#r,[]))}#m(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#r&&(this.#i.delete(e),this.#a.delete(e))}async#T(t){if("string"!=typeof t||!t)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#s||!this.#s)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const r=(0,o.join)(this.#s,`${t}.json`);let n;try{const t=await(0,e.readFile)(r,"utf8");n=JSON.parse(t)}catch(e){if(!(e instanceof Error))return;if(this.#o)throw new Error(`TinyI18: failed to load or parse ${r}: ${e.message}`);return this.#i.set(t,{}),void this.#a.set(t,[])}const s={...this.#i.get(t)??{}},i=[...this.#a.get(t)??[]],a=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#v(t.$pattern);return void i.push({$pattern:e,value:this.#E(t.value),elseValue:this.#E(t.elseValue)})}if("string"==typeof t||t&&"object"==typeof t&&"string"==typeof t.$fn){if(!e)throw new TypeError("Leaf value requires a key path");s[e]=this.#E(t)}else if(t&&"object"==typeof t)for(const[r,n]of Object.entries(t))a(e?`${e}.${r}`:r,n)}};a("",n),this.#i.set(t,s),this.#a.set(t,i)}#v(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#c.get(e);if(t)return t;try{const t=new RegExp(e);return this.#c.set(e,t),t}catch{if(this.#o)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#E(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"string"==typeof e.$fn)return{$fn:String(e.$fn),args:e.args};if(this.#o)throw new Error("TinyI18: unsupported value in file JSON");return""}constructor(e){if(!e||"object"!=typeof e)throw new TypeError("TinyI18: options must be an object");const{mode:t,defaultLocale:r,basePath:n,localResources:o,strict:s=!0}=e;if("local"!==t&&"file"!==t)throw new TypeError('TinyI18: "mode" must be "local" or "file"');if("string"!=typeof r||!r)throw new TypeError('TinyI18: "defaultLocale" must be a non-empty string');if("boolean"!=typeof s)throw new TypeError('TinyI18: "strict" must be a boolean');if("file"===t){if("string"!=typeof n||!n)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#s=n}if(this.#t=t,this.#r=r,this.#o=s,"local"===t&&o&&"object"==typeof o)for(const[e,t]of Object.entries(o))this.#w(e,t);this.#i.has(this.#r)||(this.#i.set(this.#r,{}),this.#a.set(this.#r,[]))}clearRegexCache(){s(this.#e),this.#c.clear()}registerHelper(e,t){if(s(this.#e),"string"!=typeof e||!e)throw new TypeError('registerHelper: "name" must be non-empty string');if("function"!=typeof t)throw new TypeError('registerHelper: "fn" must be a function');this.#l.set(e,t)}unregisterHelper(e){if(s(this.#e),"string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be non-empty string');return this.#l.delete(e)}loadLocaleLocal(e,t){if(s(this.#e),"local"!==this.#t)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#w(e,t)}async setLocale(e){if(s(this.#e),null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#n;null!==e&&("file"===this.#t?await this.#T(e):this.#i.has(e)||(this.#i.set(e,{}),this.#a.set(e,[]))),"file"===this.#t&&t&&t!==this.#r&&t!==e&&this.#m(t),this.#n=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if(s(this.#e),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:n}=r||{},o=this.#h(n);let i=this.#u(o,e);if(void 0===i){if(this.#o)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return this.#y(i,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if(s(this.#e),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},n=this.#h(r);let o=this.#p(n,e);if(void 0===o){if(this.#o)throw new Error(`TinyI18: missing translation for key "${e}"`);return e}return o}resetToDefaultOnly(){if(s(this.#e),"file"===this.#t)for(const e of Array.from(this.#i.keys()))e!==this.#r&&this.#m(e);this.#n=null}getStatsForLocale(e){if(s(this.#e),"string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#i.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#i.get(e)??{}).length,patterns:this.#a.get(e)?.length??0,isDefault:e===this.#r,isCurrent:e===this.#n}}destroy(){this.#e||(this.#i.clear(),this.#a.clear(),this.#l.clear(),this.#c.clear(),this.#n=null,this.#s=null,this.#e=!0)}}})(),window.TinyI18=n.TinyI18})();
@@ -1 +1 @@
1
- (()=>{"use strict";var e={7(e){var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=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(n,r){function i(n){e.removeListener(t,s),r(n)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}l(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&l(e,"error",t,{once:!0})}(e,i)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function u(e,t,n,r){var i,s,o,u;if(a(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),void 0===o)o=s[t]=n,++e._eventsCount;else if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),(i=h(e))>0&&o.length>i&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=o.length,u=f,console&&console.warn&&console.warn(u)}return e}function f(){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 d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):c(i,i.length)}function v(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function c(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function l(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);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 i(s){r.once&&e.removeEventListener(t,i),n(s)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=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||i(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 h(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);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 o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=s[e];if(void 0===h)return!1;if("function"==typeof h)r(h,this,t);else{var u=h.length,f=c(h,u);for(n=0;n<u;++n)r(f[n],this,t)}return!0},s.prototype.addListener=function(e,t){return u(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return u(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,s,o;if(a(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,s=Object.keys(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},s.prototype.listenerCount=v,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function n(r){const i=t[r];if(void 0!==i)return i.exports;const s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var i=t[r++],s=t[r++];n.o(e,i)?0===s&&r++:0===s?Object.defineProperty(e,i,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:s})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let r={};n.d(r,{TinyIframeEvents:()=>h});var i=n(7);function s(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const o=new WeakMap;class a extends i.EventEmitter{#e;get targetWindow(){return this.#e}#t;get targetIframeElement(){return this.#t}#n;get targetOrigin(){return this.#n}#r;get selfType(){return this.#r}#i=!1;#s=!1;get ready(){return this.#s}onReady(e){this.#s?e():this.once(this.#o,e)}#a=null;#h=[];#u;#f;#o;#d=null;constructor({targetIframe:e,targetOrigin:t=window.location.origin,secretEventName:n="__tinyIframeEvent__",handshakeEventName:r="__tinyIframeHandshake__",readyEventName:i="__tinyIframeReady__"}={}){if(super(),!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received '+typeof e);if("string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin": expected string, received '+typeof t);if(this.#t=e,this.#e=e?.contentWindow??window.parent,this.#n=t,this.#r=e?"parent":"iframe",this.#u=n,this.#f=r,this.#o=i,o.has(this.#e))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#p.bind(this),this._boundPortMessage=this.#v.bind(this),this.#c(),o.set(this.#e,this)}get secretEventName(){return this.#u}set secretEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#u=e}get handshakeEventName(){return this.#f}set handshakeEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#f=e}get readyEventName(){return this.#o}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#o=e}#c(){"parent"===this.#r?(this.#d=()=>{if(this.#i)return;this.#a&&this.#a.close();const e=new MessageChannel;this.#a=e.port1,this.#a.onmessage=this._boundPortMessage,this.#s=!1,this.#e.postMessage({type:this.#f},this.#n,[e.port2])},this.#t&&(this.#t.addEventListener("load",this.#d),this.#d())):window.addEventListener("message",this._boundWindowMessage,!1)}#p(e){const t=e.data,n=e.ports;s(t)&&t.type===this.#f&&0!==n.length&&(this.#a=n[0],this.#a.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#a.postMessage({type:`${this.#f}_ACK`}),this.#l())}#v(e){const t=e.data;if(s(t)&&t.type===`${this.#f}_ACK`)return void this.#l();if(!s(t)||!t[this.#u])return;const n=t.eventName,r=t.payload,i=t.direction;"string"!=typeof n||"iframe"===this.#r&&"iframe"!==i||"parent"===this.#r&&"parent"!==i||this.emit(`win:${n}`,r,e)}#l(){this.#s||(this.#s=!0,this.#m(),this.emit(this.#o))}#m(){for(;this.#h.length>0;){const e=this.#h.shift();e&&this.#a&&this.#a.postMessage(e)}}winEmit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#i)throw new Error("Cannot emit: instance has been destroyed.");const n={[this.#u]:!0,eventName:e,payload:t,direction:"parent"===this.#r?"iframe":"parent"};this.#s&&this.#a?this.#a.postMessage(n):this.#h.push(n)}isDestroyed(){return this.#i}destroy(){this.#i=!0,this.#s=!1,window.removeEventListener("message",this._boundWindowMessage),this.#t&&this.#d&&this.#t.removeEventListener("load",this.#d),this.#a&&(this.#a.close(),this.#a=null),this.removeAllListeners(),this.#h=[],o.delete(this.#e)}}const h=a;window.TinyIframeEvents=r.TinyIframeEvents})();
1
+ (()=>{"use strict";var e={7(e){var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=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(n,r){function i(n){e.removeListener(t,s),r(n)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}c(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&c(e,"error",t,{once:!0})}(e,i)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function d(e,t,n,r){var i,s,o,d;if(a(n),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),s=e._events),o=s[t]),void 0===o)o=s[t]=n,++e._eventsCount;else if("function"==typeof o?o=s[t]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),(i=h(e))>0&&o.length>i&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=o.length,d=f,console&&console.warn&&console.warn(d)}return e}function f(){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,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):y(i,i.length)}function v(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function y(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function c(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);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 i(s){r.once&&e.removeEventListener(t,i),n(s)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=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||i(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 h(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);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 o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=s[e];if(void 0===h)return!1;if("function"==typeof h)r(h,this,t);else{var d=h.length,f=y(h,d);for(n=0;n<d;++n)r(f[n],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 a(t),this.on(e,u(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,u(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,s,o;if(a(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,s=n.length-1;s>=0;s--)if(n[s]===t||n[s].listener===t){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,s=Object.keys(n);for(r=0;r<s.length;++r)"removeListener"!==(i=s[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},s.prototype.listenerCount=v,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function n(r){const i=t[r];if(void 0!==i)return i.exports;const s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var i=t[r++],s=t[r++];n.o(e,i)?0===s&&r++:0===s?Object.defineProperty(e,i,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:s})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let r={};n.d(r,{TinyIframeEvents:()=>d});var i=n(7);function s(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const o=e=>{if(e)throw new Error("This TinyIframeEvents instance has been destroyed and can no longer be used.")};const a=new WeakMap;class h extends i.EventEmitter{#e;get targetWindow(){return o(this.#t),this.#e}#n;get targetIframeElement(){return o(this.#t),this.#n}#r;get targetOrigin(){return o(this.#t),this.#r}#i;get selfType(){return o(this.#t),this.#i}#t=!1;#s=!1;get ready(){return o(this.#t),this.#s}onReady(e){o(this.#t),this.#s?e():this.once(this.#o,e)}#a=null;#h=[];#d;#f;#o;#u=null;constructor({targetIframe:e,targetOrigin:t=window.location.origin,secretEventName:n="__tinyIframeEvent__",handshakeEventName:r="__tinyIframeHandshake__",readyEventName:i="__tinyIframeReady__"}={}){if(super(),!(void 0===e||e instanceof HTMLIFrameElement&&e.contentWindow))throw new TypeError('[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received '+typeof e);if("string"!=typeof t)throw new TypeError('[TinyIframeEvents] Invalid "targetOrigin": expected string, received '+typeof t);if(this.#n=e,this.#e=e?.contentWindow??window.parent,this.#r=t,this.#i=e?"parent":"iframe",this.#d=n,this.#f=r,this.#o=i,a.has(this.#e))throw new Error("Duplicate window reference.");this._boundWindowMessage=this.#p.bind(this),this._boundPortMessage=this.#v.bind(this),this.#y(),a.set(this.#e,this)}get secretEventName(){return o(this.#t),this.#d}set secretEventName(e){if(o(this.#t),"string"!=typeof e)throw new TypeError("TinyIframeEvents: secretEventName must be a string.");this.#d=e}get handshakeEventName(){return o(this.#t),this.#f}set handshakeEventName(e){if(o(this.#t),"string"!=typeof e)throw new TypeError("TinyIframeEvents: handshakeEventName must be a string.");this.#f=e}get readyEventName(){return o(this.#t),this.#o}set readyEventName(e){if(o(this.#t),"string"!=typeof e)throw new TypeError("TinyIframeEvents: readyEventName must be a string.");this.#o=e}#y(){"parent"===this.#i?(this.#u=()=>{if(this.#t)return;this.#a&&this.#a.close();const e=new MessageChannel;this.#a=e.port1,this.#a.onmessage=this._boundPortMessage,this.#s=!1,this.#e.postMessage({type:this.#f},this.#r,[e.port2])},this.#n&&(this.#n.addEventListener("load",this.#u),this.#u())):window.addEventListener("message",this._boundWindowMessage,!1)}#p(e){const t=e.data,n=e.ports;s(t)&&t.type===this.#f&&0!==n.length&&(this.#a=n[0],this.#a.onmessage=this._boundPortMessage,window.removeEventListener("message",this._boundWindowMessage),this.#a.postMessage({type:`${this.#f}_ACK`}),this.#c())}#v(e){const t=e.data;if(s(t)&&t.type===`${this.#f}_ACK`)return void this.#c();if(!s(t)||!t[this.#d])return;const n=t.eventName,r=t.payload,i=t.direction;"string"!=typeof n||"iframe"===this.#i&&"iframe"!==i||"parent"===this.#i&&"parent"!==i||this.emit(`win:${n}`,r,e)}#c(){this.#s||(this.#s=!0,this.#l(),this.emit(this.#o))}#l(){for(;this.#h.length>0;){const e=this.#h.shift();e&&this.#a&&this.#a.postMessage(e)}}winEmit(e,t){if(o(this.#t),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.#t)throw new Error("Cannot emit: instance has been destroyed.");const n={[this.#d]:!0,eventName:e,payload:t,direction:"parent"===this.#i?"iframe":"parent"};this.#s&&this.#a?this.#a.postMessage(n):this.#h.push(n)}isDestroyed(){return this.#t}destroy(){this.#t||(this.#s=!1,window.removeEventListener("message",this._boundWindowMessage),this.#n&&this.#u&&this.#n.removeEventListener("load",this.#u),this.#a&&(this.#a.close(),this.#a=null),this.removeAllListeners(),this.#h=[],a.delete(this.#e),this.#t=!0)}}const d=h;window.TinyIframeEvents=r.TinyIframeEvents})();
@@ -1 +1 @@
1
- (()=>{"use strict";var e={7(e){var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise(function(r,n){function o(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}h(e,t,i,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&h(e,"error",t,{once:!0})}(e,o)})},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var s=10;function a(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?i.defaultMaxListeners:e._maxListeners}function c(e,t,r,n){var o,i,s,c;if(a(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]),void 0===s)s=i[t]=r,++e._eventsCount;else if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=l(e))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=s.length,c=u,console&&console.warn&&console.warn(c)}return e}function u(){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 f(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=u.bind(n);return o.listener=r,n.wrapFn=o,o}function p(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[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):g(o,o.length)}function y(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 g(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function h(e,t,r,n){if("function"==typeof e.on)n.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(i){n.once&&e.removeEventListener(t,o),r(i)})}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),i.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},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(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},i.prototype.getMaxListeners=function(){return l(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var o="error"===e,i=this._events;if(void 0!==i)o=o&&void 0===i.error;else if(!o)return!1;if(o){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 l=i[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var c=l.length,u=g(l,c);for(r=0;r<c;++r)n(u[r],this,t)}return!0},i.prototype.addListener=function(e,t){return c(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return c(this,e,t,!0)},i.prototype.once=function(e,t){return a(t),this.on(e,f(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,f(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,n,o,i,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){s=r[i].listener,o=i;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&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,n;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,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&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(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return p(this,e,!0)},i.prototype.rawListeners=function(e){return p(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},i.prototype.listenerCount=y,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],i=t[n++];r.o(e,o)?0===i&&n++:0===i?Object.defineProperty(e,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:i})}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);let n={};r.d(n,{TinyLocalStorage:()=>u});var o=r(7);function i(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const s=new Map,a=new Map,l=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class c extends o.EventEmitter{static hasJsonType(e){return s.has(e)&&a.has(e)||l.has(e)}static registerJsonType(e,t,r,n=!1){if(l.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);s.set(e,t),a.set(e,r),n&&l.add(e)}static deleteJsonType(e){if(l.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return s.delete(e)&&(t=!0),a.delete(e)&&(t=!0),t}static encodeSpecialJson(e){if(void 0===e)return{__undefined__:!0};if(null===e)return{__null__:!0};for(const[t,r]of s.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,c.encodeSpecialJson);if(Array.isArray(e))return e.map(c.encodeSpecialJson);if(i(e)){const t={};for(const r in e)t[r]=c.encodeSpecialJson(e[r]);return t}return e}static decodeSpecialJson(e){const t=i(e);if(t){if(e.__undefined__)return;if(e.__null__)return null}if(Array.isArray(e))return e.map(c.decodeSpecialJson);if(t){for(const[t,r]of a.entries())if(r.check&&r.check(e))return r.decode(e,c.decodeSpecialJson);const t={};for(const r in e)t[r]=c.decodeSpecialJson(e[r]);return t}return e}#e=window.localStorage;#t=null;#r=0;#n=e=>this.emit("storage",e);constructor(e){if(super(),void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#t=`LSDB::${e}`),window.addEventListener("storage",this.#n)}#o(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if("string"!=typeof this.#t)throw new Error("TinyLocalStorage: Database key is not initialized. Set a valid dbName in the constructor.");if("number"!=typeof e||Number.isNaN(e)||e<1)throw new TypeError("TinyLocalStorage: version must be a positive number.");if("function"!=typeof t)throw new TypeError("TinyLocalStorage: onUpgrade must be a function.");const r=parseInt(localStorage.getItem(this.#t),10)||0;if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError("TinyLocalStorage: saved version in localStorage is not a valid number.");if(e<r)throw new Error(`TinyLocalStorage: Cannot downgrade database version from ${r} to ${e}.`);e>r&&(t(r,e),localStorage.setItem(this.#t,String(e)),this.#r=e)}getDbKey(){return this.#t}getVersion(){return this.#r}setLocalStorage(e){if(!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#e=e}localStorageExists(){return this.#e instanceof Storage}#i(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return c.encodeSpecialJson(t)}setJson(e,t){if(this.#o(e),!(i(t)||Array.isArray(t)||t instanceof Map||t instanceof Set))throw new TypeError("The storage value is not a valid JSON-compatible structure.");const r=this.#i(e,t);return this.emit("setJson",e,t),this.#e.setItem(e,JSON.stringify(r))}#s(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#e.getItem(e),n={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},o="function"==typeof n[t]?n[t]():null;let i;try{i=JSON.parse(r)}catch{return o}return{decoded:c.decodeSpecialJson(i),fallback:o}}getJson(e,t){const{decoded:r,fallback:n}=this.#s(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||i(r)?r:n}setDate(e,t){if(this.#o(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#i(e,t);return this.emit("setDate",e,t),this.#e.setItem(e,JSON.stringify(r))}getDate(e){const t=this.#s(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(this.#o(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#i(e,t);return this.emit("setRegExp",e,t),this.#e.setItem(e,JSON.stringify(r))}getRegExp(e){const t=this.#s(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(this.#o(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#i(e,t);return this.emit("setBigInt",e,t),this.#e.setItem(e,JSON.stringify(r))}getBigInt(e){const t=this.#s(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(this.#o(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#i(e,t);return this.emit("setSymbol",e,t),this.#e.setItem(e,JSON.stringify(r))}getSymbol(e){const t=this.#s(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return this.#s(e).decoded??null}setItem(e,t){if(this.#o(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#e.setItem(e,t)}getItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#e.getItem(e)}setString(e,t){if(this.#o(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#e.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#e.getItem(e);try{if(t=JSON.parse(t),!i(t)||!t.__string__||"string"!=typeof t.value)return null;t=t.value}catch{t=null}return"string"==typeof t?t:null}setNumber(e,t){if(this.#o(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#e.setItem(e,String(t))}getNumber(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#e.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(this.#o(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#e.setItem(e,String(t))}getBool(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#e.getItem(e);if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===t)return!0;if("false"===t)return!1}return null}removeItem(e){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#e.removeItem(e)}clearLocalStorage(){return this.#e.clear()}destroy(){window.removeEventListener("storage",this.#n),this.removeAllListeners()}}c.registerJsonType(Map,(e,t)=>({__map__:!0,data:Array.from(e.entries()).map(([e,r])=>[e,t(r)])}),{check:e=>e.__map__,decode:(e,t)=>new Map(e.data.map(([e,r])=>[e,t(r)]))},!0),c.registerJsonType(Set,(e,t)=>({__set__:!0,data:Array.from(e).map(t)}),{check:e=>e.__set__,decode:(e,t)=>new Set(e.data.map(t))},!0),c.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),c.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),c.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),c.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),c.registerJsonType("symbol",e=>({__symbol__:!0,key:Symbol.keyFor(e)??e.description??null}),{check:e=>e.__symbol__,decode:e=>{const t=e.key;return null!=t?Symbol.for(t):Symbol()}},!0);const u=c;window.TinyLocalStorage=n.TinyLocalStorage})();
1
+ (()=>{"use strict";var e={7(e){var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=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,n){function o(r){e.removeListener(t,s),n(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)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var i=10;function a(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 c(e,t,r,n){var o,s,i,c;if(a(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),i=s[t]),void 0===i)i=s[t]=r,++e._eventsCount;else if("function"==typeof i?i=s[t]=n?[r,i]:[i,r]:n?i.unshift(r):i.push(r),(o=l(e))>0&&i.length>o&&!i.warned){i.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=i.length,c=u,console&&console.warn&&console.warn(c)}return e}function u(){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 y(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=u.bind(n);return o.listener=r,n.wrapFn=o,o}function f(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[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):d(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 d(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function p(e,t,r,n){if("function"==typeof e.on)n.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){n.once&&e.removeEventListener(t,o),r(s)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return i},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");i=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||o(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 o="error"===e,s=this._events;if(void 0!==s)o=o&&void 0===s.error;else if(!o)return!1;if(o){var i;if(t.length>0&&(i=t[0]),i instanceof Error)throw i;var a=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw a.context=i,a}var l=s[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var c=l.length,u=d(l,c);for(r=0;r<c;++r)n(u[r],this,t)}return!0},s.prototype.addListener=function(e,t){return c(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return c(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,y(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,y(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,n,o,s,i;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.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){i=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&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,i||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,n;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(n=0;n<s.length;++n)"removeListener"!==(o=s[n])&&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(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);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?t(this._events):[]}}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],s=t[n++];r.o(e,o)?0===s&&n++:0===s?Object.defineProperty(e,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:s})}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);let n={};r.d(n,{TinyLocalStorage:()=>y});var o=r(7);function s(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const i=e=>{if(e)throw new Error("This TinyLocalStorage instance has been destroyed and can no longer be used.")};const a=new Map,l=new Map,c=new Set(["string","boolean","object","array",String,Boolean,Number,Object,Array,BigInt,Symbol]);class u extends o.EventEmitter{static hasJsonType(e){return a.has(e)&&l.has(e)||c.has(e)}static registerJsonType(e,t,r,n=!1){if(c.has(e))throw new Error(`Cannot register type "${e}" because it is frozen.`);a.set(e,t),l.set(e,r),n&&c.add(e)}static deleteJsonType(e){if(c.has(e))throw new Error(`Cannot remove type "${e}" because it is frozen.`);let t=!1;return a.delete(e)&&(t=!0),l.delete(e)&&(t=!0),t}static encodeSpecialJson(e){if(void 0===e)return{__undefined__:!0};if(null===e)return{__null__:!0};for(const[t,r]of a.entries())if("string"!=typeof t&&e instanceof t||typeof e===t)return r(e,u.encodeSpecialJson);if(Array.isArray(e))return e.map(u.encodeSpecialJson);if(s(e)){const t={};for(const r in e)t[r]=u.encodeSpecialJson(e[r]);return t}return e}static decodeSpecialJson(e){const t=s(e);if(t){if(e.__undefined__)return;if(e.__null__)return null}if(Array.isArray(e))return e.map(u.decodeSpecialJson);if(t){for(const[t,r]of l.entries())if(r.check&&r.check(e))return r.decode(e,u.decodeSpecialJson);const t={};for(const r in e)t[r]=u.decodeSpecialJson(e[r]);return t}return e}#e=!1;get destroyed(){return this.#e}#t=window.localStorage;#r=null;#n=0;#o=e=>this.emit("storage",e);constructor(e){if(super(),void 0!==e&&"string"!=typeof e)throw new TypeError("TinyLocalStorage: dbName must be a string if provided.");"string"==typeof e&&(this.#r=`LSDB::${e}`),window.addEventListener("storage",this.#o)}#s(e){if("string"==typeof e&&e.startsWith("LSDB::"))throw new Error(`TinyLocalStorage: Key "${e}" may conflict with reserved dbKeys.`)}updateStorageVersion(e,t){if(i(this.#e),"string"!=typeof this.#r)throw new Error("TinyLocalStorage: Database key is not initialized. Set a valid dbName in the constructor.");if("number"!=typeof e||Number.isNaN(e)||e<1)throw new TypeError("TinyLocalStorage: version must be a positive number.");if("function"!=typeof t)throw new TypeError("TinyLocalStorage: onUpgrade must be a function.");const r=parseInt(localStorage.getItem(this.#r),10)||0;if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError("TinyLocalStorage: saved version in localStorage is not a valid number.");if(e<r)throw new Error(`TinyLocalStorage: Cannot downgrade database version from ${r} to ${e}.`);e>r&&(t(r,e),localStorage.setItem(this.#r,String(e)),this.#n=e)}getDbKey(){return i(this.#e),this.#r}getVersion(){return i(this.#e),this.#n}setLocalStorage(e){if(i(this.#e),!(e instanceof Storage))throw new TypeError("Argument must be a valid instance of Storage.");this.#t=e}localStorageExists(){return i(this.#e),this.#t instanceof Storage}#i(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return u.encodeSpecialJson(t)}setJson(e,t){if(i(this.#e),this.#s(e),!(s(t)||Array.isArray(t)||t instanceof Map||t instanceof Set))throw new TypeError("The storage value is not a valid JSON-compatible structure.");const r=this.#i(e,t);return this.emit("setJson",e,t),this.#t.setItem(e,JSON.stringify(r))}#a(e,t){if("string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const r=this.#t.getItem(e),n={obj:()=>({}),array:()=>[],map:()=>new Map,set:()=>new Set},o="function"==typeof n[t]?n[t]():null;let s;try{s=JSON.parse(r)}catch{return o}return{decoded:u.decodeSpecialJson(s),fallback:o}}getJson(e,t){i(this.#e);const{decoded:r,fallback:n}=this.#a(e,t);return r instanceof Map||r instanceof Set||Array.isArray(r)||s(r)?r:n}setDate(e,t){if(i(this.#e),this.#s(e),!(t instanceof Date))throw new TypeError("Value must be a Date.");const r=this.#i(e,t);return this.emit("setDate",e,t),this.#t.setItem(e,JSON.stringify(r))}getDate(e){i(this.#e);const t=this.#a(e).decoded;return t instanceof Date?t:null}setRegExp(e,t){if(i(this.#e),this.#s(e),!(t instanceof RegExp))throw new TypeError("Value must be a RegExp.");const r=this.#i(e,t);return this.emit("setRegExp",e,t),this.#t.setItem(e,JSON.stringify(r))}getRegExp(e){i(this.#e);const t=this.#a(e).decoded;return t instanceof RegExp?t:null}setBigInt(e,t){if(i(this.#e),this.#s(e),"bigint"!=typeof t)throw new TypeError("Value must be a BigInt.");const r=this.#i(e,t);return this.emit("setBigInt",e,t),this.#t.setItem(e,JSON.stringify(r))}getBigInt(e){i(this.#e);const t=this.#a(e).decoded;return"bigint"==typeof t?t:null}setSymbol(e,t){if(i(this.#e),this.#s(e),"symbol"!=typeof t)throw new TypeError("Value must be a Symbol.");const r=this.#i(e,t);return this.emit("setSymbol",e,t),this.#t.setItem(e,JSON.stringify(r))}getSymbol(e){i(this.#e);const t=this.#a(e).decoded;return"symbol"==typeof t?t:null}getValue(e){return i(this.#e),this.#a(e).decoded??null}setItem(e,t){if(i(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("setItem",e,t),this.#t.setItem(e,t)}getItem(e){if(i(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.#t.getItem(e)}setString(e,t){if(i(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Value must be a string.");return this.emit("setString",e,t),this.#t.setItem(e,JSON.stringify({__string__:!0,value:t}))}getString(e){if(i(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#t.getItem(e);try{if(t=JSON.parse(t),!s(t)||!t.__string__||"string"!=typeof t.value)return null;t=t.value}catch{t=null}return"string"==typeof t?t:null}setNumber(e,t){if(i(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("number"!=typeof t)throw new TypeError("Value must be a number.");return this.emit("setNumber",e,t),this.#t.setItem(e,String(t))}getNumber(e){if(i(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");let t=this.#t.getItem(e);return"number"==typeof t||"string"==typeof t&&t.length>0&&(t=parseFloat(t),!Number.isNaN(t))?t:null}setBool(e,t){if(i(this.#e),this.#s(e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");if("boolean"!=typeof t)throw new TypeError("Value must be a boolean.");return this.emit("setBool",e,t),this.#t.setItem(e,String(t))}getBool(e){if(i(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");const t=this.#t.getItem(e);if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===t)return!0;if("false"===t)return!1}return null}removeItem(e){if(i(this.#e),"string"!=typeof e||!e.length)throw new TypeError("Key must be a non-empty string.");return this.emit("removeItem",e),this.#t.removeItem(e)}clearLocalStorage(){return i(this.#e),this.#t.clear()}destroy(){this.#e||(window.removeEventListener("storage",this.#o),this.removeAllListeners(),this.#e=!0)}}u.registerJsonType(Map,(e,t)=>({__map__:!0,data:Array.from(e.entries()).map(([e,r])=>[e,t(r)])}),{check:e=>e.__map__,decode:(e,t)=>new Map(e.data.map(([e,r])=>[e,t(r)]))},!0),u.registerJsonType(Set,(e,t)=>({__set__:!0,data:Array.from(e).map(t)}),{check:e=>e.__set__,decode:(e,t)=>new Set(e.data.map(t))},!0),u.registerJsonType(Date,e=>({__date__:!0,value:e.toISOString()}),{check:e=>e.__date__,decode:e=>new Date(e.value)},!0),u.registerJsonType(RegExp,e=>({__regexp__:!0,source:e.source,flags:e.flags}),{check:e=>e.__regexp__,decode:e=>new RegExp(e.source,e.flags)},!0),u.registerJsonType("number",e=>({__number__:!0,value:e.toString()}),{check:e=>e.__number__,decode:e=>Number(e.value)},!0),u.registerJsonType("bigint",e=>({__bigint__:!0,value:e.toString()}),{check:e=>e.__bigint__,decode:e=>BigInt(e.value)},!0),u.registerJsonType("symbol",e=>({__symbol__:!0,key:Symbol.keyFor(e)??e.description??null}),{check:e=>e.__symbol__,decode:e=>{const t=e.key;return null!=t?Symbol.for(t):Symbol()}},!0);const y=u;window.TinyLocalStorage=n.TinyLocalStorage})();
@@ -1 +1 @@
1
- (()=>{"use strict";var t={7(t){var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise(function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}f(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&f(t,"error",e,{once:!0})}(t,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,r,n){var i,o,s,u;if(a(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=l(t))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,u=c,console&&console.warn&&console.warn(u)}return t}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 h(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=c.bind(n);return i.listener=r,n.wrapFn=i,i}function p(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):y(i,i.length)}function d(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function y(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function f(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return l(this)},o.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var l=o[t];if(void 0===l)return!1;if("function"==typeof l)n(l,this,e);else{var u=l.length,c=y(l,u);for(r=0;r<u;++r)n(c[r],this,e)}return!0},o.prototype.addListener=function(t,e){return u(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return u(this,t,e,!0)},o.prototype.once=function(t,e){return a(e),this.on(t,h(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return a(e),this.prependListener(t,h(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,s;if(a(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,r,n;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[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return p(this,t,!0)},o.prototype.rawListeners=function(t){return p(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},o.prototype.listenerCount=d,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}}};const e={};function r(n){const i=e[n];if(void 0!==i)return i.exports;const o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.d=(t,e)=>{if(Array.isArray(e))for(var n=0;n<e.length;){var i=e[n++],o=e[n++];r.o(t,i)?0===o&&n++:0===o?Object.defineProperty(t,i,{enumerable:!0,value:e[n++]}):Object.defineProperty(t,i,{enumerable:!0,get:o})}else for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let n={};r.d(n,{TinyMediaPlayer:()=>d});var i=r(7);const o=new Map;class s extends Error{constructor(t,e,r){super(t),this.name="MediaLoadingError",this.url=e,this.stage=r}}const a=async t=>{const e=(new TextEncoder).encode(t),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,8)},l=(t,e="image/jpeg")=>{const r=t=>{const e=URL.createObjectURL(t),r=o.get(e);return o.set(e,"number"==typeof r?r+1:1),e};if(t instanceof Uint8Array)return r(new Blob([t],{type:e}));if("string"==typeof t&&t.startsWith("data:")){const n=t.split(",")[1],i=atob(n),o=new Uint8Array(i.length);for(let t=0;t<i.length;t++)o[t]=i.charCodeAt(t);return r(new Blob([o],{type:e}))}return"string"==typeof t?t:""},u=(t,e)=>{const r=t=>e&&void 0===t,n=t=>r(t)||"string"==typeof t||null===t,i=(t,e)=>!!r(t)||!(!Array.isArray(t)||!t.every(e));if(!n(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(o=t.year,!r(o)&&"number"!=typeof o&&null!==o)throw new TypeError('Invalid metadata: "year" must be a number or null.');var o;if(!i(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!i(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!i(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!i(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!i(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!i(t.picture,t=>!(void 0!==t.description&&"string"!=typeof t.description||void 0!==t.name&&"string"!=typeof t.name||void 0!==t.type&&"string"!=typeof t.type||"string"!=typeof t.format||!(t.data instanceof Uint8Array||"string"==typeof t.data))))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const s=(t,e)=>{if(!r(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};s(t.disk,"disk"),s(t.track,"track")},c=t=>u(t,!1);class h{constructor(){if(new.target===h)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.")}canHandle(t){throw new Error('Method "canHandle" must be implemented by the subclass.')}async play(t){throw new Error('Method "play" must be implemented by the subclass.')}async pause(){throw new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw new Error('Method "stop" must be implemented by the subclass.')}async seek(t){throw new Error('Method "seek" must be implemented by the subclass.')}getCurrentTime(){throw new Error('Method "getCurrentTime" must be implemented by the subclass.')}setVolume(t){throw new Error('Method "setVolume" must be implemented by the subclass.')}}class p extends i.EventEmitter{static BaseMediaAdapter=h;static#t="Unknown Artist";static get unknownArtist(){return p.#t}static set unknownArtist(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("unknownArtist must have an string or function.");p.#t=t}static async parseContent(t,e,r,n,i){return(async(t,e={},r={},n=t=>new Promise((t,e)=>e(new TypeError("parseFile library not found."))),i={},o="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(i.onProgress&&"function"!=typeof i.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(i.onError&&"function"!=typeof i.onError)throw new TypeError("callbacks.onError must be a function.");let c,h="";const p=(e,r)=>{i.onProgress&&i.onProgress({event:r,status:"loading",stage:e,url:h||(t instanceof HTMLMediaElement?t.src:"unknown")})},d=(e,r)=>{i.onError&&i.onError({error:e,url:h||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:r})};try{p("INITIALIZING"),"string"==typeof t?(h=t,c=new Audio(h)):(c=t,h=c.src);try{await new Promise((t,e)=>{const r=t=>p("DOWNLOADING",t),n=()=>{o(),t(void 0)},i=t=>{o(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},o=()=>{c.removeEventListener("progress",r),c.removeEventListener("loadedmetadata",n),c.removeEventListener("error",i)};c.addEventListener("progress",r),c.addEventListener("loadedmetadata",n),c.addEventListener("error",i),c.readyState>=1&&(o(),t(void 0))}),p("METADATA_LOADED")}catch(t){throw new s(t instanceof Error?t.message:"UNKNOWN ERROR",h,"METADATA")}const y={id:r.id||await a(h),duration:Math.floor(1e3*c.duration),url:h,weight:r.weight??1};let f={};p("EXTRACTING_ID3");try{f=await(async(t,e)=>{if("string"!=typeof t)throw new TypeError(`Expected url to be a string, but received ${typeof t}.`);if("function"!=typeof e)throw new TypeError(`Expected parseFile to be a function, but received ${typeof e}.`);try{const r=await fetch(t);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),i=await e(n);if(!i||"object"!=typeof i.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const o=i.common;return(t=>{u(t,!0)})(o),{title:o?.title??null,album:o?.album??null,albumartist:o?.albumartist??null,albumartists:o?.albumartists??[],genre:o?.genre??[],label:o?.label??[],composer:o?.composer??[],year:o?.year??null,artist:o?.artist??null,artists:o?.artists??[],disk:o?.disk?{no:o.disk.no,of:o.disk.of}:{no:null,of:null},track:o?.track?{no:o.track.no,of:o.track.of}:{no:null,of:null},picture:o?.picture?.map(t=>({...t,data:l(t.data,t.format)}))??[]}}catch(t){throw t}})(h,n)}catch(t){d(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${h}. Falling back to filename.`)}const m=t=>{try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},g={...y,...e,...f,...r,title:f.title||r.title||m(h),artist:f.artist||r.artist||("string"==typeof o?o:String(o()))};return i.onProgress&&i.onProgress({status:"success",stage:"COMPLETE",url:h}),g}catch(t){if(t instanceof s)throw t;{const e=new s(t instanceof Error?t.message:"UNKNOWN ERROR",h,"INITIALIZING");throw d(e,"INITIALIZING"),e}}})(t,e,r,n,i,p.#t)}#e=new Map;#r=[];#n=-1;#i="NONE";#o=!1;#s=!1;#a=1;#l;#u;constructor(t={}){super(),this.#l=Boolean(t.persistVolume),this.#u="string"==typeof t.volumeStorageKey?t.volumeStorageKey:"tiny_media_player_volume",this.#l&&this.#c()}#c(){try{if("undefined"!=typeof window&&window.localStorage){const t=window.localStorage.getItem(this.#u);if(null!==t){const e=parseFloat(t);!isNaN(e)&&e>=0&&e<=1&&(this.#a=e)}}}catch(t){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",t)}}#h(){try{this.#l&&"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(this.#u,this.#a.toString())}catch(t){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",t)}}_getWeightedRandomIndex(){if(0===this.#r.length)return-1;if(1===this.#r.length)return 0;let t=0;for(let e=0;e<this.#r.length;e++){if(e===this.#n)continue;const r=this.#r[e];t+="number"==typeof r.weight&&r.weight>0?r.weight:1}let e=Math.random()*t;for(let t=0;t<this.#r.length;t++){if(t===this.#n)continue;const r=this.#r[t],n="number"==typeof r.weight&&r.weight>0?r.weight:1;if(e<n)return t;e-=n}return this.#n===this.#r.length-1?0:this.#r.length-1}get playlist(){return[...this.#r]}set playlist(t){if(!Array.isArray(t))throw new TypeError("Playlist must be an array of MediaContent objects.");t.forEach(t=>c(t));const e=this.#s;let r=null;if(-1!==this.#n&&this.#r.length>0)try{r=this.#p()}catch(t){}this.#r=t,this.emit("playlistUpdate",this.playlist),0===this.#r.length?this.#n=-1:(this.#n>=this.#r.length||-1===this.#n)&&(this.#n=0),this.emit("trackChange",this.#n),e&&(async()=>{try{r&&await r.stop(),-1!==this.#n&&await this.play()}catch(t){console.warn("[TinyMediaPlayer] Background transition error on playlist update:",t)}})()}get currentIndex(){return this.#n}set currentIndex(t){if("number"!=typeof t)throw new TypeError("Current index must be a number.");if(t<-1||t>=this.#r.length&&this.#r.length>0)throw new RangeError(`Index ${t} is out of bounds for the current playlist.`);if(this.#n===t)return;const e=this.#s;let r=null;if(-1!==this.#n&&this.#r.length>0)try{r=this.#p()}catch(t){}this.#n=t,this.emit("trackChange",this.#n),e&&(async()=>{try{r&&await r.stop(),-1!==this.#n&&await this.play()}catch(t){console.warn("[TinyMediaPlayer] Background transition error on index update:",t)}})()}get loopMode(){return this.#i}set loopMode(t){const e=["NONE","TRACK","PLAYLIST"];if(!e.includes(t))throw new TypeError(`Loop mode must be one of: ${e.join(", ")}.`);this.#i=t,this.emit("loopModeChange",this.#i)}get isRandom(){return this.#o}set isRandom(t){if("boolean"!=typeof t)throw new TypeError("Random mode state must be a boolean.");this.#o=t,this.emit("randomModeChange",this.#o)}get isPlaying(){return this.#s}get volume(){return this.#a}set volume(t){if("number"!=typeof t)throw new TypeError("Volume must be a number.");if(t<0||t>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#a=t,this.#h(),this.emit("volumeChange",this.#a),-1!==this.#n&&this.#r.length>0)try{const t=this.#p();t&&t.setVolume(this.#a)}catch(t){}}get persistVolume(){return this.#l}set persistVolume(t){if("boolean"!=typeof t)throw new TypeError("Persist volume parameter must be a boolean.");this.#l=t,t&&this.#h()}get volumeStorageKey(){return this.#u}set volumeStorageKey(t){if("string"!=typeof t)throw new TypeError("Volume storage key must be a string.");if(""===t.trim())throw new TypeError("Volume storage key cannot be an empty string.");const e=this.#u;this.#u=t;try{this.#l&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(e),this.#h())}catch(t){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",t)}}registerAdapter(t,e){if("string"!=typeof t)throw new TypeError("Adapter ID must be a string.");if(!(e instanceof h))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.#e.set(t,e)}#p(){if(-1===this.#n||0===this.#r.length)return null;const t=this.#r[this.#n];for(const e of this.#e.values())if(e.canHandle(t))return e;throw new Error(`No compatible adapter found for content ID: ${t.id}.`)}addTrack(t){if(!t||"object"!=typeof t||"string"!=typeof t.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const e={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...t};c(e);const r=this.#r.push(e);return-1===this.#n&&(this.#n=0,this.emit("trackChange",this.#n)),this.emit("playlistUpdate",this.playlist),r}existsTrack(t){if("number"!=typeof t)throw new TypeError("Index must be a number.");return t>=0&&t<this.#r.length}getTrack(t){if("number"!=typeof t)throw new TypeError("Index must be a number.");if(!this.existsTrack(t))throw new RangeError(`Index ${t} is out of bounds for the current playlist.`);return this.#r[t]}async removeTrack(t){if("number"!=typeof t)throw new TypeError("Index must be a number.");if(!this.existsTrack(t))throw new RangeError(`Index ${t} is out of bounds for the current playlist.`);t===this.#n?(await this.stop(),this.#r.splice(t,1),0===this.#r.length?this.#n=-1:this.#n>=this.#r.length&&(this.#n=0),this.emit("trackChange",this.#n)):(this.#r.splice(t,1),t<this.#n&&(this.#n-=1,this.emit("trackChange",this.#n))),this.emit("playlistUpdate",this.playlist)}searchTrack(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("Search query must be a string or a boolean evaluation function.");const e=[];for(let r=0;r<this.#r.length;r++){const n=this.#r[r];let i=!1;if("function"==typeof t)i=Boolean(t(n));else{const e=t.toLowerCase(),r=n.title&&n.title.toLowerCase().includes(e),o=n.artist&&n.artist.toLowerCase().includes(e),s=n.album&&n.album.toLowerCase().includes(e);i=Boolean(r||o||s)}i&&e.push({track:n,index:r})}return e}async clearPlaylist(){await this.stop(),this.#r=[],this.#n=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#n)}async play(){const t=this.#p();t&&(t.setVolume(this.#a),await t.play(this.#r[this.#n]),this.#s=!0,this.emit("play",this.#n))}async pause(){const t=this.#p();t&&(await t.pause(),this.#s=!1,this.emit("pause",this.#n))}async stop(){const t=this.#p();t&&(await t.stop(),this.#s=!1,this.emit("stop",this.#n))}async next(){if(0!==this.#r.length)if(await this.stop(),"TRACK"!==this.#i){if(this.#o)this.#n=this._getWeightedRandomIndex();else{let t=this.#n+1;if(t>=this.#r.length){if("PLAYLIST"!==this.#i)return;t=0}this.#n=t}this.emit("trackChange",this.#n),await this.play()}else await this.play()}async prev(){if(0!==this.#r.length){if(await this.stop(),this.#o)this.#n=this._getWeightedRandomIndex();else{let t=this.#n-1;if(t<0){if("PLAYLIST"!==this.#i)return;t=this.#r.length-1}this.#n=t}this.emit("trackChange",this.#n),await this.play()}}async seek(t){if("number"!=typeof t)throw new TypeError("Seek time must be a number in milliseconds.");if(t<0)throw new RangeError("Seek time cannot be negative.");const e=this.#p();e&&(await e.seek(t),this.emit("seek",t))}async step(t){if("number"!=typeof t)throw new TypeError("Step amount must be a number in milliseconds.");const e=this.#p();if(!e)return;let r=e.getCurrentTime()+t;r<0&&(r=0),await this.seek(r)}}const d=p;window.TinyMediaPlayer=n.TinyMediaPlayer})();
1
+ (()=>{"use strict";var e={7(e){var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}f(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&f(e,"error",t,{once:!0})}(e,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(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?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=l(e))>0&&s.length>i&&!s.warned){s.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=s.length,u=h,console&&console.warn&&console.warn(u)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=h.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]: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}(i):y(i,i.length)}function p(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),n=0;n<t;++n)r[n]=e[n];return r}function f(e,t,r,n){if("function"==typeof e.on)n.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 i(o){n.once&&e.removeEventListener(t,i),r(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return l(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.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 l=o[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var u=l.length,h=y(l,u);for(r=0;r<u;++r)n(h[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,c(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,c(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;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 i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);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(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function r(n){const i=t[n];if(void 0!==i)return i.exports;const o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var i=t[n++],o=t[n++];r.o(e,i)?0===o&&n++:0===o?Object.defineProperty(e,i,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,i,{enumerable:!0,get:o})}else for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let n={};r.d(n,{TinyMediaPlayer:()=>w});var i=r(7);const o=(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}.`)},s=(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}.`)},a=(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}.`)},l=new Map;class u extends Error{constructor(e,t,r){if(o(e,"message"),o(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 h=async e=>{o(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)},c=(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}.`);o(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=l.get(t);return l.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const n=e.split(",")[1],i=atob(n),o=new Uint8Array(i.length);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return r(new Blob([o],{type:t}))}return"string"==typeof e?e:""},d=(e,t)=>{if(a(e,"common"),"boolean"!=typeof t)throw new TypeError('Expected "isPartial" to be a boolean.');const r=e=>t&&void 0===e,n=e=>r(e)||"string"==typeof e||null===e,i=(e,t)=>(s(t,"valueValidator"),!!r(e)||!(!Array.isArray(e)||!e.every(t)));if(!n(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(l=e.year,!r(l)&&"number"!=typeof l&&null!==l)throw new TypeError('Invalid metadata: "year" must be a number or null.');var l;if(!i(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!i(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!i(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!i(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!i(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!i(e.picture,e=>e&&"object"==typeof e&&(void 0===e.description||"string"==typeof e.description)&&(void 0===e.name||"string"==typeof e.name)&&(void 0===e.type||"string"==typeof e.type)&&"string"==typeof e.format&&(e.data instanceof Uint8Array||"string"==typeof e.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const u=(e,t)=>{if(o(e,"name"),!r(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};u("disk",e.disk),u("track",e.track)},p=e=>(a(e,"common"),d(e,!1)),y=e=>{if(e)throw new Error("This TinyMediaPlayer instance has been destroyed and can no longer be used.")};class f{constructor(){if(new.target===f)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.")}canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}async play(e){throw new Error('Method "play" must be implemented by the subclass.')}async pause(){throw new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw new Error('Method "seek" must be implemented by the subclass.')}getCurrentTime(){throw new Error('Method "getCurrentTime" must be implemented by the subclass.')}setVolume(e){throw new Error('Method "setVolume" must be implemented by the subclass.')}}class m extends i.EventEmitter{static BaseMediaAdapter=f;static#e="Unknown Artist";static get unknownArtist(){return m.#e}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");m.#e=e}static async parseContent(e,t,r,n,i){return(async(e,t={},r={},n=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.")))},i={},l="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(a(t,"defaultMetadata"),a(r,"metadata"),s(n,"parseFile"),a(i,"callbacks"),i.onProgress&&"function"!=typeof i.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(i.onError&&"function"!=typeof i.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof l&&"function"!=typeof l)throw new TypeError("unknownArtist must be a string or a function returning a string.");let p,y="";const f=(t,r)=>{if(o(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');i.onProgress&&i.onProgress({event:r,status:"loading",stage:t,url:y||(e instanceof HTMLMediaElement?e.src:"unknown")})},m=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');o(r,"stage"),i.onError&&i.onError({error:t,url:y||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{f("INITIALIZING"),"string"==typeof e?(y=e,p=new Audio(y)):(p=e,y=p.src);try{await new Promise((e,t)=>{const r=e=>f("DOWNLOADING",e),n=()=>{o(),e(void 0)},i=e=>{o(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},o=()=>{p.removeEventListener("progress",r),p.removeEventListener("loadedmetadata",n),p.removeEventListener("error",i)};p.addEventListener("progress",r),p.addEventListener("loadedmetadata",n),p.addEventListener("error",i),p.readyState>=1&&(o(),e(void 0))}),f("METADATA_LOADED")}catch(e){throw new u(e instanceof Error?e.message:"UNKNOWN ERROR",y,"METADATA")}const w={id:r.id||await h(y),duration:Math.floor(1e3*p.duration),url:y,weight:r.weight??1};let g={};f("EXTRACTING_ID3");try{g=await(async(e,t)=>{o(e,"url"),s(t,"parseFile");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),i=await t(n);if(!i||"object"!=typeof i.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const o=i.common;return(e=>{a(e,"common"),d(e,!0)})(o),{title:o?.title??null,album:o?.album??null,albumartist:o?.albumartist??null,albumartists:o?.albumartists??[],genre:o?.genre??[],label:o?.label??[],composer:o?.composer??[],year:o?.year??null,artist:o?.artist??null,artists:o?.artists??[],disk:o?.disk?{no:o.disk.no,of:o.disk.of}:{no:null,of:null},track:o?.track?{no:o.track.no,of:o.track.of}:{no:null,of:null},picture:o?.picture?.map(e=>({...e,data:c(e.data,e.format)}))??[]}}catch(e){throw e}})(y,n)}catch(e){m(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${y}. Falling back to filename.`)}const v=e=>{o(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},b={...w,...t,...g,...r,title:g.title||r.title||v(y),artist:g.artist||r.artist||("string"==typeof l?l:String(l()))};return i.onProgress&&i.onProgress({status:"success",stage:"COMPLETE",url:y}),b}catch(e){if(e instanceof u)throw e;{const t=new u(e instanceof Error?e.message:"UNKNOWN ERROR",y,"INITIALIZING");throw m(t,"INITIALIZING"),t}}})(e,t,r,n,i,m.#e)}#t=!1;get destroyed(){return this.#t}#r=new Map;#n=[];#i=-1;#o="NONE";#s=!1;#a=!1;#l=1;#u;#h;constructor(e={}){super(),this.#u=Boolean(e.persistVolume),this.#h="string"==typeof e.volumeStorageKey?e.volumeStorageKey:"tiny_media_player_volume",this.#u&&this.#c()}#c(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#h);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#l=t)}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#d(){try{this.#u&&"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(this.#h,this.#l.toString())}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#n.length)return-1;if(1===this.#n.length)return 0;let e=0;for(let t=0;t<this.#n.length;t++){if(t===this.#i)continue;const r=this.#n[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#n.length;e++){if(e===this.#i)continue;const r=this.#n[e],n="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<n)return e;t-=n}return this.#i===this.#n.length-1?0:this.#n.length-1}get playlist(){return y(this.#t),[...this.#n]}set playlist(e){if(y(this.#t),!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>p(e));const t=this.#a;let r=null;if(-1!==this.#i&&this.#n.length>0)try{r=this.#p()}catch(e){}this.#n=e,this.emit("playlistUpdate",this.playlist),0===this.#n.length?this.#i=-1:(this.#i>=this.#n.length||-1===this.#i)&&(this.#i=0),this.emit("trackChange",this.#i),t&&(async()=>{try{r&&await r.stop(),-1!==this.#i&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return y(this.#t),this.#i}set currentIndex(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#n.length&&this.#n.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#i===e)return;const t=this.#a;let r=null;if(-1!==this.#i&&this.#n.length>0)try{r=this.#p()}catch(e){}this.#i=e,this.emit("trackChange",this.#i),t&&(async()=>{try{r&&await r.stop(),-1!==this.#i&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return y(this.#t),this.#o}set loopMode(e){y(this.#t);const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#o=e,this.emit("loopModeChange",this.#o)}get isRandom(){return y(this.#t),this.#s}set isRandom(e){if(y(this.#t),"boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#s=e,this.emit("randomModeChange",this.#s)}get isPlaying(){return y(this.#t),this.#a}get volume(){return y(this.#t),this.#l}set volume(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Volume must be a number.");if(e<0||e>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#l=e,this.#d(),this.emit("volumeChange",this.#l),-1!==this.#i&&this.#n.length>0)try{const e=this.#p();e&&e.setVolume(this.#l)}catch(e){}}get persistVolume(){return y(this.#t),this.#u}set persistVolume(e){if(y(this.#t),"boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#u=e,e&&this.#d()}get volumeStorageKey(){return y(this.#t),this.#h}set volumeStorageKey(e){if(y(this.#t),"string"!=typeof e)throw new TypeError("Volume storage key must be a string.");if(""===e.trim())throw new TypeError("Volume storage key cannot be an empty string.");const t=this.#h;this.#h=e;try{this.#u&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#d())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}registerAdapter(e,t){if(y(this.#t),"string"!=typeof e)throw new TypeError("Adapter ID must be a string.");if(!(t instanceof f))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.#r.set(e,t)}#p(){if(-1===this.#i||0===this.#n.length)return null;const e=this.#n[this.#i];for(const t of this.#r.values())if(t.canHandle(e))return t;throw new Error(`No compatible adapter found for content ID: ${e.id}.`)}addTrack(e){if(y(this.#t),!e||"object"!=typeof e||"string"!=typeof e.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const t={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...e};p(t);const r=this.#n.push(t);return-1===this.#i&&(this.#i=0,this.emit("trackChange",this.#i)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#n.length}getTrack(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);return this.#n[e]}async removeTrack(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);e===this.#i?(await this.stop(),this.#n.splice(e,1),0===this.#n.length?this.#i=-1:this.#i>=this.#n.length&&(this.#i=0),this.emit("trackChange",this.#i)):(this.#n.splice(e,1),e<this.#i&&(this.#i-=1,this.emit("trackChange",this.#i))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if(y(this.#t),"string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");const t=[];for(let r=0;r<this.#n.length;r++){const n=this.#n[r];let i=!1;if("function"==typeof e)i=Boolean(e(n));else{const t=e.toLowerCase(),r=n.title&&n.title.toLowerCase().includes(t),o=n.artist&&n.artist.toLowerCase().includes(t),s=n.album&&n.album.toLowerCase().includes(t);i=Boolean(r||o||s)}i&&t.push({track:n,index:r})}return t}async clearPlaylist(){y(this.#t),await this.stop(),this.#n=[],this.#i=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#i)}async play(){y(this.#t);const e=this.#p();e&&(e.setVolume(this.#l),await e.play(this.#n[this.#i]),this.#a=!0,this.emit("play",this.#i))}async pause(){y(this.#t);const e=this.#p();e&&(await e.pause(),this.#a=!1,this.emit("pause",this.#i))}async stop(){y(this.#t);const e=this.#p();e&&(await e.stop(),this.#a=!1,this.emit("stop",this.#i))}async next(){if(y(this.#t),0!==this.#n.length)if(await this.stop(),"TRACK"!==this.#o){if(this.#s)this.#i=this._getWeightedRandomIndex();else{let e=this.#i+1;if(e>=this.#n.length){if("PLAYLIST"!==this.#o)return;e=0}this.#i=e}this.emit("trackChange",this.#i),await this.play()}else await this.play()}async prev(){if(y(this.#t),0!==this.#n.length){if(await this.stop(),this.#s)this.#i=this._getWeightedRandomIndex();else{let e=this.#i-1;if(e<0){if("PLAYLIST"!==this.#o)return;e=this.#n.length-1}this.#i=e}this.emit("trackChange",this.#i),await this.play()}}async seek(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Seek time must be a number in milliseconds.");if(e<0)throw new RangeError("Seek time cannot be negative.");const t=this.#p();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");const t=this.#p();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}async destroy(){if(!this.#t){try{this.#a&&await this.stop()}catch(e){console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",e)}this.#n=[],this.#i=-1,this.#a=!1,this.#r.clear(),this.removeAllListeners(),this.#t=!0}}}const w=m;window.TinyMediaPlayer=n.TinyMediaPlayer})();
@@ -1 +1 @@
1
- (()=>{"use strict";var e={7(e){var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}c(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&c(e,"error",t,{once:!0})}(e,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function h(e,t,n,r){var i,o,s,h;if(a(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=u(e))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=s.length,h=f,console&&console.warn&&console.warn(h)}return e}function f(){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 l(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}function v(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):p(i,i.length)}function d(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function c(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);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 i(o){r.once&&e.removeEventListener(t,i),n(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.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=o[e];if(void 0===u)return!1;if("function"==typeof u)r(u,this,t);else{var h=u.length,f=p(u,h);for(n=0;n<h;++n)r(f[n],this,t)}return!0},o.prototype.addListener=function(e,t){return h(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return h(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,l(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,l(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,r,i,o,s;if(a(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},o.prototype.listeners=function(e){return v(this,e,!0)},o.prototype.rawListeners=function(e){return v(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},o.prototype.listenerCount=d,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function n(r){const i=t[r];if(void 0!==i)return i.exports;const o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var i=t[r++],o=t[r++];n.o(e,i)?0===o&&r++:0===o?Object.defineProperty(e,i,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:o})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let r={};n.d(r,{TinyNewWinEvents:()=>a});var i=n(7);const o=new WeakMap;class s extends i.EventEmitter{#e;#t;#n=[];#r=!1;#i=!1;#o=null;#s="__TNE_READY__";#a="__TNE_ROUTE__";get readyEventName(){return this.#s}set readyEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#s=e}get routeEventName(){return this.#a}set routeEventName(e){if("string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#a=e}constructor({targetOrigin:e,url:t,name:n,features:r}={}){if(super(),"string"==typeof n&&"_blank"===n)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==r&&"string"!=typeof r)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#e=window.opener:(this.#e="string"==typeof t?window.open(t,n,r):t,this.#i=!0),!this.#e||o.has(this.#e))throw new Error("Invalid or duplicate window reference.");this.#t=e??window.location.origin,this._handleMessage=this.#u.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#i||(this.#h(this.#s,null),this.#f())}getWin(){return this.#e}#u(e){if(!e.source||this.#e&&e.source!==this.#e)return;const{type:t,route:n,payload:r}=e.data||{};if(t===this.#s)return this.#r=!0,this.#l(),this.#f(),void(this.#i&&this.#h(this.#s,null));t===this.#a&&this.emit(`win:${n}`,r,e)}#l(){for(;this.#n.length;){const e=this.#n.shift();if(e){const{route:t,payload:n}=e;this.winEmit(t,n)}}}#h(e,t,n=""){this.#e&&this.#e.closed||this.#e?.postMessage({type:e,route:n,payload:t},this.#t)}close(){if(!this.#i)throw new Error("Only host can close the window.");this.#e&&!this.#e.closed&&this.#e.close()}winEmit(e,t){if("string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.isDestroyed())throw new Error("Cannot emit: instance has been destroyed.");this.#r?this.#h(this.#a,t,e):this.#n.push({route:e,payload:t})}isConnected(){return!(!this.#r||!this.#e||this.#e.closed)}#f(){this.#e&&!this.#o&&(this.#o=setInterval(()=>{this.#e?.closed&&(this.emit("WINDOW_REF_CLOSED"),this.destroy())},500),o.set(this.#e,this.#o))}onClose(e){this.on("WINDOW_REF_CLOSED",e)}offClose(e){this.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#e}destroy(){this.#e&&(this.#o&&(clearInterval(this.#o),this.#o=null,o.delete(this.#e)),window.removeEventListener("message",this._handleMessage),this.#n=[],this.#r=!1,this.#e=null,this.removeAllListeners())}}const a=s;window.TinyNewWinEvents=r.TinyNewWinEvents})();
1
+ (()=>{"use strict";var e={7(e){var t,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};t=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,o),r(n)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),n([].slice.call(arguments))}c(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&c(e,"error",t,{once:!0})}(e,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,n,r){var i,o,s,u;if(a(n),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=h(e))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return e}function f(){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 d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}function l(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):p(i,i.length)}function v(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function p(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function c(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);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 i(o){r.once&&e.removeEventListener(t,i),n(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return h(this)},o.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.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 h=o[e];if(void 0===h)return!1;if("function"==typeof h)r(h,this,t);else{var u=h.length,f=p(h,u);for(n=0;n<u;++n)r(f[n],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},o.prototype.removeListener=function(e,t){var n,r,i,o,s;if(a(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},o.prototype.listeners=function(e){return l(this,e,!0)},o.prototype.rawListeners=function(e){return l(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},o.prototype.listenerCount=v,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function n(r){const i=t[r];if(void 0!==i)return i.exports;const o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.d=(e,t)=>{if(Array.isArray(t))for(var r=0;r<t.length;){var i=t[r++],o=t[r++];n.o(e,i)?0===o&&r++:0===o?Object.defineProperty(e,i,{enumerable:!0,value:t[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:o})}else for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let r={};n.d(r,{TinyNewWinEvents:()=>h});var i=n(7);const o=e=>{if(e)throw new Error("This TinyNewWinEvents instance has been destroyed and can no longer be used.")};const s=new WeakMap;class a extends i.EventEmitter{#e;#t;#n=[];#r=!1;#i=!1;#o=null;#s="__TNE_READY__";#a="__TNE_ROUTE__";#h=!1;get destroyed(){return this.#h}get readyEventName(){return o(this.#h),this.#s}set readyEventName(e){if(o(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: readyEventName must be a string.");this.#s=e}get routeEventName(){return o(this.#h),this.#a}set routeEventName(e){if(o(this.#h),"string"!=typeof e)throw new TypeError("TinyNewWinEvents: routeEventName must be a string.");this.#a=e}constructor({targetOrigin:e,url:t,name:n,features:r}={}){if(super(),"string"==typeof n&&"_blank"===n)throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');if(void 0!==e&&"string"!=typeof e)throw new TypeError('TinyNewWinEvents: The "targetOrigin" option must be a string.');if(void 0!==t&&"string"!=typeof t)throw new TypeError('TinyNewWinEvents: The "url" option must be a string.');if(void 0!==r&&"string"!=typeof r)throw new TypeError('TinyNewWinEvents: The "features" option must be a string if provided.');if(void 0===t?this.#e=window.opener:(this.#e="string"==typeof t?window.open(t,n,r):t,this.#i=!0),!this.#e||s.has(this.#e))throw new Error("Invalid or duplicate window reference.");this.#t=e??window.location.origin,this._handleMessage=this.#u.bind(this),window.addEventListener("message",this._handleMessage,!1),this.#i||(this.#f(this.#s,null),this.#d())}getWin(){return o(this.#h),this.#e}#u(e){if(!e.source||this.#e&&e.source!==this.#e)return;const{type:t,route:n,payload:r}=e.data||{};if(t===this.#s)return this.#r=!0,this.#l(),this.#d(),void(this.#i&&this.#f(this.#s,null));t===this.#a&&this.emit(`win:${n}`,r,e)}#l(){for(;this.#n.length;){const e=this.#n.shift();if(e){const{route:t,payload:n}=e;this.winEmit(t,n)}}}#f(e,t,n=""){this.#e&&this.#e.closed||this.#e?.postMessage({type:e,route:n,payload:t},this.#t)}close(){if(o(this.#h),!this.#i)throw new Error("Only host can close the window.");this.#e&&!this.#e.closed&&this.#e.close()}winEmit(e,t){if(o(this.#h),"string"!=typeof e)throw new TypeError("Event name must be a string.");if(this.isDestroyed())throw new Error("Cannot emit: instance has been destroyed.");this.#r?this.#f(this.#a,t,e):this.#n.push({route:e,payload:t})}isConnected(){return o(this.#h),!(!this.#r||!this.#e||this.#e.closed)}#d(){this.#e&&!this.#o&&(this.#o=setInterval(()=>{this.#e?.closed&&(this.emit("WINDOW_REF_CLOSED"),this.destroy())},500),s.set(this.#e,this.#o))}onClose(e){o(this.#h),this.on("WINDOW_REF_CLOSED",e)}offClose(e){o(this.#h),this.off("WINDOW_REF_CLOSED",e)}isDestroyed(){return!this.#e}destroy(){this.#e&&(this.#o&&(clearInterval(this.#o),this.#o=null,s.delete(this.#e)),window.removeEventListener("message",this._handleMessage),this.#n=[],this.#r=!1,this.#e=null,this.removeAllListeners(),this.#h=!0)}}const h=a;window.TinyNewWinEvents=r.TinyNewWinEvents})();
@@ -1 +1 @@
1
- (()=>{"use strict";const e={d:(t,n)=>{if(Array.isArray(n))for(var o=0;o<n.length;){var s=n[o++],i=n[o++];e.o(t,s)?0===i&&o++:0===i?Object.defineProperty(t,s,{enumerable:!0,value:n[o++]}):Object.defineProperty(t,s,{enumerable:!0,get:i})}else for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyNotifyCenter:()=>o});class n{static getTemplate(){return'\n<div class="notify-overlay hidden">\n <div class="notify-center" id="notifCenter">\n <div class="header">\n <div>Notifications</div>\n <div class="options">\n <button class="clear-all" type="button">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n viewBox="0 0 24 24"\n width="24"\n height="24"\n fill="currentColor"\n >\n <path\n d="M21.6 2.4a1 1 0 0 0-1.4 0L13 9.6l-1.3-1.3a1 1 0 0 0-1.4 0L3 15.6a1 1 0 0 0 0 1.4l4 4a1 1 0 0 0 1.4 0l7.3-7.3a1 1 0 0 0 0-1.4l-1.3-1.3 7.2-7.2a1 1 0 0 0 0-1.4zM6 17l3.5-3.5 1.5 1.5L7.5 18.5 6 17z"\n />\n </svg>\n </button>\n <button class="close">×</button>\n </div>\n </div>\n <div class="list"></div>\n </div>\n</div>\n\n<button class="notify-bell" aria-label="Open notifications">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="20"\n height="20"\n fill="currentColor"\n viewBox="0 0 24 24"\n >\n <path\n d="M12 2C10.3 2 9 3.3 9 5v1.1C6.7 7.2 5 9.4 5 12v5l-1 1v1h16v-1l-1-1v-5c0-2.6-1.7-4.8-4-5.9V5c0-1.7-1.3-3-3-3zm0 20c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2z"\n />\n </svg>\n <span class="badge" id="notifBadge">0</span>\n</button>\n '}static insertTemplate(e="afterbegin"){document.body.insertAdjacentHTML(e,n.getTemplate())}#e;#t;#n;#o;#s;#i=0;#r=99;#l=300;#a=!1;#c=new WeakMap;#d(e){if(this.#c.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout(()=>{this.markAsRead(e),e.remove()},this.#l)}#m(e){this.#i=Math.max(0,e),this.#n.setAttribute("data-value",String(this.#i)),this.#n.textContent=this.#i>this.#r?`${this.#r}+`:String(this.#i)}constructor(e={}){const{center:t=document.getElementById("notifCenter"),badge:n=document.getElementById("notifBadge"),button:o=document.querySelector(".notify-bell"),overlay:s=document.querySelector(".notify-overlay")}=e;if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${t}`);if(!(s instanceof HTMLElement))throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${s}`);if(!(n instanceof HTMLElement))throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${n}`);if(!(o instanceof HTMLElement))throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${o}`);const i=t?.querySelector(".clear-all"),r=t?.querySelector(".list")??null;if(!(r instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${r}`);this.#e=t,this.#t=r,this.#n=n,this.#o=o,this.#s=s,this.#o.addEventListener("click",()=>this.toggle()),this.#e.querySelector(".close")?.addEventListener("click",()=>this.close()),i&&i.addEventListener("click",()=>this.clear()),this.#s.addEventListener("click",e=>{e.target===this.#s&&this.close()})}setMarkAllAsReadOnClose(e){if("boolean"!=typeof e)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof e);this.#a=e}setRemoveDelay(e){if("number"!=typeof e)throw new Error('NotificationCenter: "ms" must be an number.');this.#l=e}getItemMode(e){const t=this.getItem(e);return t?this.#c.get(t):null}getItem(e){const t=this.#t.children.item(e);if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${t}`);return t}hasItem(e){return e>=0&&e<this.#t.children.length}markAsRead(e){const t=e instanceof HTMLElement?e:this.getItem(e);t.classList.contains("unread")&&(t.classList.remove("unread"),this.#m(this.#i-1))}add(e,t="text"){const n=document.createElement("div");n.className="item unread";let o=null,s=null,i=null,r=null;if("object"==typeof e&&null!==e?(o=e.title,s=e.message,i=e.avatar,r=e.onClick):s=e,i){const e=document.createElement("div");e.className="avatar",e.style.backgroundImage=`url("${i}")`,n.appendChild(e)}const l=document.createElement("div");if(l.className="content",o){const e=document.createElement("div");e.className="title",e.textContent=o,l.appendChild(e)}const a=document.createElement("div");a.className="message","html"===t?a.innerHTML=s:a.textContent=s,l.appendChild(a),"function"==typeof r&&(n.classList.add("clickable"),n.addEventListener("click",e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&r(e)}));const c=document.createElement("button");c.className="notify-close",c.setAttribute("type","button"),c.innerHTML="&times;",c.addEventListener("click",e=>{e.stopPropagation(),this.#d(n)}),n.append(l,c),this.#t.prepend(n),this.#c.set(n,t),this.#m(this.#i+1)}remove(e){const t=this.getItem(e);this.#d(t)}clear(){let e=!0;for(;e;){e=!1;const t=Array.from(this.#t.children);for(const n of t)n instanceof HTMLElement&&!n.classList.contains("removing")&&(this.#d(n),e=!0)}}open(){this.#s.classList.remove("hidden"),this.#e.classList.add("open")}close(){if(this.#s.classList.add("hidden"),this.#e.classList.remove("open"),this.#a){const e=this.#t.querySelectorAll(".item.unread");for(const t of e)t instanceof HTMLElement&&this.markAsRead(t)}}toggle(){this.#e.classList.contains("open")?this.close():this.open()}recount(){const e=this.#t.querySelectorAll(".item.unread").length;this.#m(e)}get count(){return this.#i}destroy(){this.#o?.removeEventListener("click",this.toggle),this.#e?.querySelector(".close")?.removeEventListener("click",this.close),this.#e?.querySelector(".clear-all")?.removeEventListener("click",this.clear),this.#s?.removeEventListener("click",this.close),this.clear(),this.#e?.remove(),this.#s?.remove(),this.#o?.remove(),this.#i=0,this.#c=new WeakMap}}const o=n;window.TinyNotifyCenter=t.TinyNotifyCenter})();
1
+ (()=>{"use strict";const e={d:(t,n)=>{if(Array.isArray(n))for(var s=0;s<n.length;){var o=n[s++],i=n[s++];e.o(t,o)?0===i&&s++:0===i?Object.defineProperty(t,o,{enumerable:!0,value:n[s++]}):Object.defineProperty(t,o,{enumerable:!0,get:i})}else for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyNotifyCenter:()=>o});const n=e=>{if(e)throw new Error("This TinyNotifyCenter instance has been destroyed and can no longer be used.")};class s{static getTemplate(){return'\n<div class="notify-overlay hidden">\n <div class="notify-center" id="notifCenter">\n <div class="header">\n <div>Notifications</div>\n <div class="options">\n <button class="clear-all" type="button">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n viewBox="0 0 24 24"\n width="24"\n height="24"\n fill="currentColor"\n >\n <path\n d="M21.6 2.4a1 1 0 0 0-1.4 0L13 9.6l-1.3-1.3a1 1 0 0 0-1.4 0L3 15.6a1 1 0 0 0 0 1.4l4 4a1 1 0 0 0 1.4 0l7.3-7.3a1 1 0 0 0 0-1.4l-1.3-1.3 7.2-7.2a1 1 0 0 0 0-1.4zM6 17l3.5-3.5 1.5 1.5L7.5 18.5 6 17z"\n />\n </svg>\n </button>\n <button class="close">×</button>\n </div>\n </div>\n <div class="list"></div>\n </div>\n</div>\n\n<button class="notify-bell" aria-label="Open notifications">\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="20"\n height="20"\n fill="currentColor"\n viewBox="0 0 24 24"\n >\n <path\n d="M12 2C10.3 2 9 3.3 9 5v1.1C6.7 7.2 5 9.4 5 12v5l-1 1v1h16v-1l-1-1v-5c0-2.6-1.7-4.8-4-5.9V5c0-1.7-1.3-3-3-3zm0 20c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2z"\n />\n </svg>\n <span class="badge" id="notifBadge">0</span>\n</button>\n '}static insertTemplate(e="afterbegin"){document.body.insertAdjacentHTML(e,s.getTemplate())}#e=!1;get destroyed(){return this.#e}#t;#n;#s;#o;#i;#r=0;#l=99;#a=300;#c=!1;#d=new WeakMap;#h(e){if(this.#d.delete(e),!(e instanceof HTMLElement))throw new Error("Invalid HTMLElement to clear.");e.classList.add("removing"),setTimeout(()=>{this.markAsRead(e),e.remove()},this.#a)}#m(e){this.#r=Math.max(0,e),this.#s.setAttribute("data-value",String(this.#r)),this.#s.textContent=this.#r>this.#l?`${this.#l}+`:String(this.#r)}constructor(e={}){const{center:t=document.getElementById("notifCenter"),badge:n=document.getElementById("notifBadge"),button:s=document.querySelector(".notify-bell"),overlay:o=document.querySelector(".notify-overlay")}=e;if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${t}`);if(!(o instanceof HTMLElement))throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${o}`);if(!(n instanceof HTMLElement))throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${n}`);if(!(s instanceof HTMLElement))throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${s}`);const i=t?.querySelector(".clear-all"),r=t?.querySelector(".list")??null;if(!(r instanceof HTMLElement))throw new Error(`NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${r}`);this.#t=t,this.#n=r,this.#s=n,this.#o=s,this.#i=o,this.#o.addEventListener("click",()=>this.toggle()),this.#t.querySelector(".close")?.addEventListener("click",()=>this.close()),i&&i.addEventListener("click",()=>this.clear()),this.#i.addEventListener("click",e=>{e.target===this.#i&&this.close()})}setMarkAllAsReadOnClose(e){if(n(this.#e),"boolean"!=typeof e)throw new TypeError("Expected boolean for markAllAsReadOnClose, got "+typeof e);this.#c=e}setRemoveDelay(e){if(n(this.#e),"number"!=typeof e)throw new Error('NotificationCenter: "ms" must be an number.');this.#a=e}getItemMode(e){n(this.#e);const t=this.getItem(e);return t?this.#d.get(t):null}getItem(e){n(this.#e);const t=this.#n.children.item(e);if(!(t instanceof HTMLElement))throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${t}`);return t}hasItem(e){return n(this.#e),e>=0&&e<this.#n.children.length}markAsRead(e){n(this.#e);const t=e instanceof HTMLElement?e:this.getItem(e);t.classList.contains("unread")&&(t.classList.remove("unread"),this.#m(this.#r-1))}add(e,t="text"){n(this.#e);const s=document.createElement("div");s.className="item unread";let o=null,i=null,r=null,l=null;if("object"==typeof e&&null!==e?(o=e.title,i=e.message,r=e.avatar,l=e.onClick):i=e,r){const e=document.createElement("div");e.className="avatar",e.style.backgroundImage=`url("${r}")`,s.appendChild(e)}const a=document.createElement("div");if(a.className="content",o){const e=document.createElement("div");e.className="title",e.textContent=o,a.appendChild(e)}const c=document.createElement("div");c.className="message","html"===t?c.innerHTML=i:c.textContent=i,a.appendChild(c),"function"==typeof l&&(s.classList.add("clickable"),s.addEventListener("click",e=>{e.target instanceof HTMLElement&&!e.target.closest(".notify-close")&&l(e)}));const d=document.createElement("button");d.className="notify-close",d.setAttribute("type","button"),d.innerHTML="&times;",d.addEventListener("click",e=>{e.stopPropagation(),this.#h(s)}),s.append(a,d),this.#n.prepend(s),this.#d.set(s,t),this.#m(this.#r+1)}remove(e){n(this.#e);const t=this.getItem(e);this.#h(t)}clear(){n(this.#e);let e=!0;for(;e;){e=!1;const t=Array.from(this.#n.children);for(const n of t)n instanceof HTMLElement&&!n.classList.contains("removing")&&(this.#h(n),e=!0)}}open(){n(this.#e),this.#i.classList.remove("hidden"),this.#t.classList.add("open")}close(){if(n(this.#e),this.#i.classList.add("hidden"),this.#t.classList.remove("open"),this.#c){const e=this.#n.querySelectorAll(".item.unread");for(const t of e)t instanceof HTMLElement&&this.markAsRead(t)}}toggle(){n(this.#e),this.#t.classList.contains("open")?this.close():this.open()}recount(){n(this.#e);const e=this.#n.querySelectorAll(".item.unread").length;this.#m(e)}get count(){return this.#r}destroy(){this.#e||(this.#o?.removeEventListener("click",this.toggle),this.#t?.querySelector(".close")?.removeEventListener("click",this.close),this.#t?.querySelector(".clear-all")?.removeEventListener("click",this.clear),this.#i?.removeEventListener("click",this.close),this.clear(),this.#t?.remove(),this.#i?.remove(),this.#o?.remove(),this.#r=0,this.#d=new WeakMap,this.#e=!0)}}const o=s;window.TinyNotifyCenter=t.TinyNotifyCenter})();
@@ -1 +1 @@
1
- (()=>{"use strict";var t={7(t){var e,i="object"==typeof Reflect?Reflect:null,n=i&&"function"==typeof i.apply?i.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)};e=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var r=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise(function(i,n){function r(i){t.removeListener(e,o),n(i)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",r),i([].slice.call(arguments))}p(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&p(t,"error",e,{once:!0})}(t,r)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,i,n){var r,o,s,u;if(a(i),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),o=t._events),s=o[e]),void 0===s)s=o[e]=i,++t._eventsCount;else if("function"==typeof s?s=o[e]=n?[i,s]:[s,i]:n?s.unshift(i):s.push(i),(r=c(t))>0&&s.length>r&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return t}function l(){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 d(t,e,i){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},r=l.bind(n);return r.listener=i,n.wrapFn=r,r}function h(t,e,i){var n=t._events;if(void 0===n)return[];var r=n[e];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(r):f(r,r.length)}function m(t){var e=this._events;if(void 0!==e){var i=e[t];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function f(t,e){for(var i=new Array(e),n=0;n<e;++n)i[n]=t[n];return i}function p(t,e,i,n){if("function"==typeof t.on)n.once?t.once(e,i):t.on(e,i);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function r(o){n.once&&t.removeEventListener(e,r),i(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||r(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||r(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var r="error"===t,o=this._events;if(void 0!==o)r=r&&void 0===o.error;else if(!r)return!1;if(r){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)n(c,this,e);else{var u=c.length,l=f(c,u);for(i=0;i<u;++i)n(l[i],this,e)}return!0},o.prototype.addListener=function(t,e){return u(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return u(this,t,e,!0)},o.prototype.once=function(t,e){return a(e),this.on(t,d(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return a(e),this.prependListener(t,d(this,t,e)),this},o.prototype.removeListener=function(t,e){var i,n,r,o,s;if(a(e),void 0===(n=this._events))return this;if(void 0===(i=n[t]))return this;if(i===e||i.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(r=-1,o=i.length-1;o>=0;o--)if(i[o]===e||i[o].listener===e){s=i[o].listener,r=o;break}if(r<0)return this;0===r?i.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(i,r),1===i.length&&(n[t]=i[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,i,n;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete i[t]),this;if(0===arguments.length){var r,o=Object.keys(i);for(n=0;n<o.length;++n)"removeListener"!==(r=o[n])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},o.prototype.listenerCount=m,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}}};const e={};function i(n){const r=e[n];if(void 0!==r)return r.exports;const o=e[n]={exports:{}};return t[n](o,o.exports,i),o.exports}i.d=(t,e)=>{if(Array.isArray(e))for(var n=0;n<e.length;){var r=e[n++],o=e[n++];i.o(t,r)?0===o&&n++:0===o?Object.defineProperty(t,r,{enumerable:!0,value:e[n++]}):Object.defineProperty(t,r,{enumerable:!0,get:o})}else for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let n={};i.d(n,{TinyRadioFm:()=>m});var r=i(7);const o=new Map;class s extends Error{constructor(t,e,i){super(t),this.name="MediaLoadingError",this.url=e,this.stage=i}}const a=async t=>{const e=(new TextEncoder).encode(t),i=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(i)).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,8)},c=(t,e="image/jpeg")=>{const i=t=>{const e=URL.createObjectURL(t),i=o.get(e);return o.set(e,"number"==typeof i?i+1:1),e};if(t instanceof Uint8Array)return i(new Blob([t],{type:e}));if("string"==typeof t&&t.startsWith("data:")){const n=t.split(",")[1],r=atob(n),o=new Uint8Array(r.length);for(let t=0;t<r.length;t++)o[t]=r.charCodeAt(t);return i(new Blob([o],{type:e}))}return"string"==typeof t?t:""},u=async t=>{if("string"!=typeof t||!t.startsWith("blob:"))return t;try{const e=await fetch(t),i=await e.blob();return await new Promise((t,e)=>{const n=new FileReader;n.onloadend=()=>t(String(n.result)),n.onerror=e,n.readAsDataURL(i)})}catch(e){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${t}`,e),t}},l=t=>{t&&Array.isArray(t.picture)&&t.picture.forEach(t=>{if("string"==typeof t.data&&t.data.startsWith("blob:")){const e=o.get(t.data)??0;e>1?o.set(t.data,e-1):o.delete(t.data),e<=1&&URL.revokeObjectURL(t.data)}})},d=async(t,e)=>{if("string"!=typeof t)throw new TypeError(`Expected url to be a string, but received ${typeof t}.`);if("function"!=typeof e)throw new TypeError(`Expected parseFile to be a function, but received ${typeof e}.`);try{const i=await fetch(t);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const n=await i.blob(),r=await e(n);if(!r||"object"!=typeof r.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const o=r.common;return(t=>{((t,e)=>{const i=t=>e&&void 0===t,n=t=>i(t)||"string"==typeof t||null===t,r=(t,e)=>!!i(t)||!(!Array.isArray(t)||!t.every(e));if(!n(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(o=t.year,!i(o)&&"number"!=typeof o&&null!==o)throw new TypeError('Invalid metadata: "year" must be a number or null.');var o;if(!r(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!r(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!r(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!r(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!r(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!r(t.picture,t=>!(void 0!==t.description&&"string"!=typeof t.description||void 0!==t.name&&"string"!=typeof t.name||void 0!==t.type&&"string"!=typeof t.type||"string"!=typeof t.format||!(t.data instanceof Uint8Array||"string"==typeof t.data))))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const s=(t,e)=>{if(!i(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};s(t.disk,"disk"),s(t.track,"track")})(t,!0)})(o),{title:o?.title??null,album:o?.album??null,albumartist:o?.albumartist??null,albumartists:o?.albumartists??[],genre:o?.genre??[],label:o?.label??[],composer:o?.composer??[],year:o?.year??null,artist:o?.artist??null,artists:o?.artists??[],disk:o?.disk?{no:o.disk.no,of:o.disk.of}:{no:null,of:null},track:o?.track?{no:o.track.no,of:o.track.of}:{no:null,of:null},picture:o?.picture?.map(t=>({...t,data:c(t.data,t.format)}))??[]}}catch(t){throw t}};class h extends r.EventEmitter{static async parseContent(t,e,i,n,r){return(async(t,e={},i={},n=t=>new Promise((t,e)=>e(new TypeError("parseFile library not found."))),r={},o="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(r.onProgress&&"function"!=typeof r.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(r.onError&&"function"!=typeof r.onError)throw new TypeError("callbacks.onError must be a function.");let c,u="";const l=(e,i)=>{r.onProgress&&r.onProgress({event:i,status:"loading",stage:e,url:u||(t instanceof HTMLMediaElement?t.src:"unknown")})},h=(e,i)=>{r.onError&&r.onError({error:e,url:u||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:i})};try{l("INITIALIZING"),"string"==typeof t?(u=t,c=new Audio(u)):(c=t,u=c.src);try{await new Promise((t,e)=>{const i=t=>l("DOWNLOADING",t),n=()=>{o(),t(void 0)},r=t=>{o(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},o=()=>{c.removeEventListener("progress",i),c.removeEventListener("loadedmetadata",n),c.removeEventListener("error",r)};c.addEventListener("progress",i),c.addEventListener("loadedmetadata",n),c.addEventListener("error",r),c.readyState>=1&&(o(),t(void 0))}),l("METADATA_LOADED")}catch(t){throw new s(t instanceof Error?t.message:"UNKNOWN ERROR",u,"METADATA")}const m={id:i.id||await a(u),duration:Math.floor(1e3*c.duration),url:u,weight:i.weight??1};let f={};l("EXTRACTING_ID3");try{f=await d(u,n)}catch(t){h(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${u}. Falling back to filename.`)}const p=t=>{try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},y={...m,...e,...f,...i,title:f.title||i.title||p(u),artist:f.artist||i.artist||("string"==typeof o?o:String(o()))};return r.onProgress&&r.onProgress({status:"success",stage:"COMPLETE",url:u}),y}catch(t){if(t instanceof s)throw t;{const e=new s(t instanceof Error?t.message:"UNKNOWN ERROR",u,"INITIALIZING");throw h(e,"INITIALIZING"),e}}})(t,e,i,n,r,h.#t)}static#t="Unknown Artist";static get unknownArtist(){return h.#t}static set unknownArtist(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("unknownArtist must have an string or function.");h.#t=t}get size(){return this.#e.length+this.#i.length}get musicSize(){return this.#e.length}get voiceSize(){return this.#i.length}get customPosSize(){return this.#n.length}get tasksSize(){return this.#r.length}get cycleCacheSize(){return this.#o.size}#e=[];get musicList(){return structuredClone(this.#e)}#i=[];get voiceList(){return structuredClone(this.#i)}#n=[];get customPositions(){return structuredClone(this.#n)}#r=[];get scheduledTasks(){return structuredClone(this.#r)}get allList(){return[...this.musicList,...this.voiceList]}#s=0;get seed(){return this.#s}set seed(t){if("number"!=typeof t)throw new TypeError("Seed must be a number.");this.#s=t,this.#o.clear(),this.emit("seedChanged",{seed:t})}#a=Date.now();get anchorDate(){return this.#a}#o=new Map;#c={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,voiceMaxConsecutive:0};get config(){return structuredClone(this.#c)}set config(t){this.#u(t),this.#c=structuredClone(t),this.#o.clear(),this.emit("configChanged",{config:this.config})}#u(t){if("object"!=typeof t||null===t)throw new TypeError("Configuration must be a valid object.");const e=["playlist","random"];if(void 0!==t.mode&&!e.includes(t.mode))throw new TypeError(`Invalid mode: "${t.mode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.voiceMode&&!e.includes(t.voiceMode))throw new TypeError(`Invalid voiceMode: "${t.voiceMode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.silenceDuration&&("number"!=typeof t.silenceDuration||t.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==t.queryLimit&&("number"!=typeof t.queryLimit||t.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==t.voiceAfterMusic&&"boolean"!=typeof t.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");if(void 0!==t.voiceMin&&("number"!=typeof t.voiceMin||t.voiceMin<0))throw new TypeError("voiceMin must be a non-negative number.");if(void 0!==t.voiceMax&&("number"!=typeof t.voiceMax||t.voiceMax<0))throw new TypeError("voiceMax must be a non-negative number.");if(void 0!==t.musicMaxConsecutive&&("number"!=typeof t.musicMaxConsecutive||t.musicMaxConsecutive<-1))throw new TypeError("musicMaxConsecutive must be a number >= -1.");if(void 0!==t.voiceMaxConsecutive&&("number"!=typeof t.voiceMaxConsecutive||t.voiceMaxConsecutive<-1))throw new TypeError("voiceMaxConsecutive must be a number >= -1.");const i=t.voiceMin??this.#c.voiceMin,n=t.voiceMax??this.#c.voiceMax;if(n<i)throw new RangeError(`Logical error: voiceMax (${n}) cannot be less than voiceMin (${i}).`)}constructor(t=null,e=0){if(super(),null!==t&&"object"!=typeof t)throw new TypeError("initialData must be an object or null.");if("number"!=typeof e)throw new TypeError("seed must be a number.");this.#s=e,t?this.#l(t):this.#a=Date.now()}add(t,e,i=!0){if(!["music","voice","custom"].includes(t))throw new TypeError('Type must be "music", "voice", or "custom".');if(!e||"string"!=typeof e.id||"number"!=typeof e.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof i)throw new TypeError("smartQueue must be a boolean.");"music"===t?(this.#e.push(e),this.#o.clear()):"voice"===t?(this.#i.push(e),this.#o.clear()):"custom"===t&&this.#d(e,i),this.#h(Date.now()),this.emit("contentAdded",{type:t,data:structuredClone(e)})}scheduleTask(t,e,i,n,r=!0){if("number"!=typeof t||isNaN(t))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(e))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(i))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof r)throw new TypeError("smartQueue must be a boolean.");if("add"===e){if("object"!=typeof n||null===n||"string"!=typeof n.id||"number"!=typeof n.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===e){if("string"!=typeof n)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===e&&("object"!=typeof n||null===n||"string"!=typeof n.id||"number"!=typeof n.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let o=t;if(r){const e=this.#m(t,t);e&&(o=e.absoluteEnd)}const s={timestamp:o,action:e,type:i,payload:n};this.#r.push(s),this.#h(Date.now()),this.emit("taskScheduled",structuredClone(s))}remove(t){if("string"!=typeof t)throw new TypeError("id must be a string.");this.#e.filter(e=>e.id===t).forEach(t=>l(t)),this.#i.filter(e=>e.id===t).forEach(t=>l(t)),this.#n.filter(e=>e.content?.id===t).forEach(t=>l(t.content));const e=e=>e.id!==t&&e.content?.id!==t;this.#e=this.#e.filter(e),this.#i=this.#i.filter(e),this.#n=this.#n.filter(e),this.#r=this.#r.filter(e=>"add"===e.action&&"object"==typeof e.payload&&null!==e.payload&&"id"in e.payload?e.payload.id!==t||(l(e.payload),!1):e.payload!==t),this.#o.clear(),this.emit("contentRemoved",{id:t})}setConfig(t){this.#u(t);const e={...this.#c,...t};this.#u(e),this.#c=e,this.#o.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){const t=Date.now();return this.#h(t),this.#m(t,t)}queryTimeline(t,e=10){if("number"!=typeof e||isNaN(e))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(e>this.#c.queryLimit||e<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#c.queryLimit}.`);const i=new h(JSON.parse(this._exportState())),n=[];let r=t;for(let o=0;o<e;o++){i.#h(r);const e=i.#f(r,t);if(!e)break;n.push(e),r=e.absoluteEnd}return i.destroy(!1),this.emit("timelineQueried",{targetDate:t,limit:e,resultCount:n.length}),n}searchCustomPositions(){return this.#h(Date.now()),[...this.#n]}async _processListForExport(t){return Promise.all(t.map(async t=>{const e=structuredClone(t);return e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async t=>({...t,data:await u(t.data)})))),e}))}_exportState(){return JSON.stringify({music:this.#e,voice:this.#i,custom:this.#n,tasks:this.#r,seed:this.#s,anchorDate:this.#a,config:this.#c})}async exportState(){const t=await this._processListForExport(this.#e),e=await this._processListForExport(this.#i),i=await Promise.all(this.#n.map(async t=>{const e=await this._processListForExport([t.content]);return{...t,content:e[0]}})),n=await Promise.all(this.#r.map(async t=>{if("add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload){const e=await this._processListForExport([t.payload]);return{...t,payload:e[0]}}return t}));return JSON.stringify({music:t,voice:e,custom:i,tasks:n,seed:this.#s,anchorDate:this.#a,config:this.#c})}importState(t){let e;if("string"==typeof t)try{e=JSON.parse(t)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof t||null===t)throw new TypeError("Import data must be a valid JSON string or an object.");e=t}this.#l(e),this.emit("stateImported",{data:structuredClone(e)})}_prng(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}#p(t,e,i,n=0){if(0===t.length)return[];if("random"!==i)return[...t];const r=t.map(t=>({...t,weight:t.weight??1})),o=this._prng(e),s=[];let a=null,c=0;for(;r.length>0;){let t=r;-1!==n&&null!==a&&c>n&&(t=r.filter(t=>t.id!==a),0===t.length&&(t=r));const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0){s.push(...t);break}const i=o()*e;let u=0,l=null,d=-1;for(let e=0;e<t.length;e++)if(u+=t[e].weight,i<=u){l=t[e],d=r.findIndex(t=>l&&t.id===l.id);break}l&&-1!==d||(l=t[0],d=r.findIndex(t=>l&&t.id===l.id)),s.push(l),r.splice(d,1),l.id===a?c++:(a=l.id,c=1)}return s}#y(t){const e=this.#s+t,i=this._prng(10*e),n=this.#p(this.#e,e+1,this.#c.mode,this.#c.musicMaxConsecutive),r=this.#p(this.#i,e+2,this.#c.voiceMode,this.#c.voiceMaxConsecutive),o=[];let s=0,a=0;for(let t=0;t<n.length;t++){const e=n[t];if(o.push({...e,cycleStart:s,cycleEnd:s+e.duration}),s+=e.duration+this.#c.silenceDuration,this.#c.voiceAfterMusic&&r.length>0){const t=this.#c.voiceMax-this.#c.voiceMin+1,e=Math.floor(i()*t)+this.#c.voiceMin;for(let t=0;t<e;t++){const t=r[a%r.length];a++,o.push({...t,cycleStart:s,cycleEnd:s+t.duration}),s+=t.duration+this.#c.silenceDuration}}}return{items:o,duration:s}}#v(t){if(0===this.#e.length)return null;let e=this.#a,i=0;for(;;){if(i>this.#c.queryLimit)throw new Error("Safety limit hit during cycle location.");let n=this.#o.get(i);if(n||(n=this.#y(i),this.#o.set(i,n)),0===n.duration)return null;if(t>=e&&t<e+n.duration)return{block:n,startTimestamp:e,loopIndex:i};e+=n.duration,i++}}#f(t,e){const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t).sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp)[0];let n=null;if(i){const t=Math.max(e,i.intendedTimestamp);n=this.#g(i.content,i.intendedTimestamp,t,!0)}const r=this.#w(t,e);return r||n?r?n?n.absoluteStart<=r.absoluteStart?n:(n.absoluteStart<r.absoluteEnd&&(r.absoluteEnd=n.absoluteStart,r.duration=r.absoluteEnd-r.absoluteStart,r.remainingTime=Math.max(0,r.absoluteEnd-e),r.progress=Math.min(1,r.elapsedTime/r.duration)),r):r:n:null}#w(t,e){let i=this.#v(t);if(!i)return null;const{block:n,startTimestamp:r}=i,o=t-r;let s,a=n.items.find(t=>t.cycleEnd>o);if(a)s=r+a.cycleStart;else{if(i=this.#v(r+n.duration),!i||0===i.block.items.length)return null;a=i.block.items[0],s=i.startTimestamp+a.cycleStart}const c=Math.max(e,s);return this.#g(a,s,c,!1)}#m(t,e){const i=this.#n.find(e=>t>=e.intendedTimestamp&&t<e.intendedTimestamp+e.content.duration);if(i)return this.#g(i.content,i.intendedTimestamp,e,!0);const n=this.#v(t);if(!n)return null;const{block:r,startTimestamp:o}=n,s=t-o,a=r.items.find(t=>s>=t.cycleStart&&s<t.cycleEnd);return a?this.#g(a,o+a.cycleStart,e,!1):null}#g(t,e,i,n){const r=i-e;return{id:t.id,title:t.title,artist:t.artist,duration:t.duration,url:t.url,absoluteStart:e,absoluteEnd:e+t.duration,elapsedTime:r,remainingTime:t.duration-r,progress:Math.min(1,r/t.duration),isCustom:n}}#d(t,e){let i=t.timestamp||Date.now();const n=t.duration;if(e){const t=this.#m(i,i);t&&(i=t.absoluteEnd)}const r=[...this.#n].sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp);let o=i;if(r.some(t=>i<t.intendedTimestamp+t.content.duration&&i+n>t.intendedTimestamp)){const t=[];let e=Date.now();for(const i of r)i.intendedTimestamp>e&&t.push({start:e,end:i.intendedTimestamp}),e=Math.max(e,i.intendedTimestamp+i.content.duration+this.#c.silenceDuration);t.push({start:e,end:1/0});let s=1/0;for(const e of t)if(e.end-e.start>=n){let t=null;if(i>=e.start&&i+n<=e.end?t=i:i<e.start?t=e.start:i>e.end&&(t=e.end-n),null!==t){const e=Math.abs(i-t);e<s&&(s=e,o=t)}}}this.#n.push({content:t,intendedTimestamp:o,originalTimestamp:t.timestamp||Date.now()})}#h(t){const e=this.#r.filter(e=>e.timestamp<=t);this.#r=this.#r.filter(e=>e.timestamp>t);const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration<=t);this.#n=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t);let n=!1;i.forEach(t=>{l(t.content),this.#s+=t.content.id.length,n=!0,this.emit("customPositionExpired",{contentId:t.content.id})}),e.length>0&&e.sort((t,e)=>t.timestamp-e.timestamp).forEach(t=>{const e="music"===t.type?this.#e:this.#i;if("add"===t.action)e.push(t.payload);else if("remove"===t.action){const i=t.payload,n=e.findIndex(t=>t.id===i);if(-1!==n){const[t]=e.splice(n,1);l(t)}}else if("move"===t.action){const i=t.payload,n=e.findIndex(t=>t.id===i.id);if(-1!==n){const[t]=e.splice(n,1);e.splice(i.newIndex,0,t)}}this.#a=t.timestamp,this.#s+=1,n=!0,this.emit("taskExecuted",structuredClone(t))}),n&&this.#o.clear()}#l(t){this.#e.forEach(t=>l(t)),this.#i.forEach(t=>l(t)),this.#n.forEach(t=>l(t.content)),this.#r.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&l(t.payload)});const e=t=>t.map(t=>{const e={...t};return e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(t=>({...t,data:c(t.data,t.format)}))),e});this.#e=e(t.music),this.#i=e(t.voice),this.#s=t.seed||0,this.#a=t.anchorDate||Date.now(),this.#c={...this.#c,...t.config||{}},this.#n=t.custom.map(t=>({...t,content:e([t.content])[0]})),this.#r=t.tasks.map(t=>"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload?{...t,payload:e([t.payload])[0]}:t)}destroy(t=!0){t&&(this.#e.forEach(t=>l(t)),this.#i.forEach(t=>l(t)),this.#n.forEach(t=>l(t.content)),this.#r.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&l(t.payload)})),this.#e=[],this.#i=[],this.#n=[],this.#r=[],this.#o.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners()}}const m=h;window.TinyRadioFm=n.TinyRadioFm})();
1
+ (()=>{"use strict";var t={7(t){var e,i="object"==typeof Reflect?Reflect:null,r=i&&"function"==typeof i.apply?i.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)};e=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var n=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise(function(i,r){function n(i){t.removeListener(e,o),r(i)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",n),i([].slice.call(arguments))}p(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&p(t,"error",e,{once:!0})}(t,n)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,i,r){var n,o,s,u;if(a(i),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),o=t._events),s=o[e]),void 0===s)s=o[e]=i,++t._eventsCount;else if("function"==typeof s?s=o[e]=r?[i,s]:[s,i]:r?s.unshift(i):s.push(i),(n=c(t))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return t}function l(){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 d(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=l.bind(r);return n.listener=i,r.wrapFn=n,n}function h(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(n):m(n,n.length)}function f(t){var e=this._events;if(void 0!==e){var i=e[t];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function m(t,e){for(var i=new Array(e),r=0;r<e;++r)i[r]=t[r];return i}function p(t,e,i,r){if("function"==typeof t.on)r.once?t.once(e,i):t.on(e,i);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function n(o){r.once&&t.removeEventListener(e,n),i(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||n(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||n(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)r(c,this,e);else{var u=c.length,l=m(c,u);for(i=0;i<u;++i)r(l[i],this,e)}return!0},o.prototype.addListener=function(t,e){return u(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return u(this,t,e,!0)},o.prototype.once=function(t,e){return a(e),this.on(t,d(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return a(e),this.prependListener(t,d(this,t,e)),this},o.prototype.removeListener=function(t,e){var i,r,n,o,s;if(a(e),void 0===(r=this._events))return this;if(void 0===(i=r[t]))return this;if(i===e||i.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(n=-1,o=i.length-1;o>=0;o--)if(i[o]===e||i[o].listener===e){s=i[o].listener,n=o;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(i,n),1===i.length&&(r[t]=i[0]),void 0!==r.removeListener&&this.emit("removeListener",t,s||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,i,r;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete i[t]),this;if(0===arguments.length){var n,o=Object.keys(i);for(r=0;r<o.length;++r)"removeListener"!==(n=o[r])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}}};const e={};function i(r){const n=e[r];if(void 0!==n)return n.exports;const o=e[r]={exports:{}};return t[r](o,o.exports,i),o.exports}i.d=(t,e)=>{if(Array.isArray(e))for(var r=0;r<e.length;){var n=e[r++],o=e[r++];i.o(t,n)?0===o&&r++:0===o?Object.defineProperty(t,n,{enumerable:!0,value:e[r++]}):Object.defineProperty(t,n,{enumerable:!0,get:o})}else for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r={};i.d(r,{TinyRadioFm:()=>v});var n=i(7);const o=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof t)throw new TypeError(`Expected "${e}" to be a string, but received ${typeof t}.`)},s=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof t)throw new TypeError(`Expected "${e}" to be a function, but received ${typeof t}.`)},a=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError(`Expected "${e}" to be a plain object, but received ${null===t?"null":Array.isArray(t)?"array":typeof t}.`)},c=new Map;class u extends Error{constructor(t,e,i){if(o(t,"message"),o(e,"url"),"string"!=typeof i)throw new TypeError(`Expected "stage" to be a string, but received ${typeof i}.`);super(t),this.name="MediaLoadingError",this.url=e,this.stage=i}}const l=async t=>{o(t,"str");const e=(new TextEncoder).encode(t),i=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(i)).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,8)},d=(t,e="image/jpeg")=>{if(!(t instanceof Uint8Array)&&"string"!=typeof t)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof t}.`);o(e,"format");const i=t=>{const e=URL.createObjectURL(t),i=c.get(e);return c.set(e,"number"==typeof i?i+1:1),e};if(t instanceof Uint8Array)return i(new Blob([t],{type:e}));if("string"==typeof t&&t.startsWith("data:")){const r=t.split(",")[1],n=atob(r),o=new Uint8Array(n.length);for(let t=0;t<n.length;t++)o[t]=n.charCodeAt(t);return i(new Blob([o],{type:e}))}return"string"==typeof t?t:""},h=async t=>{if(o(t,"url"),!t.startsWith("blob:"))return t;try{const e=await fetch(t),i=await e.blob();return await new Promise((t,e)=>{const r=new FileReader;r.onloadend=()=>t(String(r.result)),r.onerror=e,r.readAsDataURL(i)})}catch(e){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${t}`,e),t}},f=t=>{a(t,"content"),t&&Array.isArray(t.picture)&&t.picture.forEach(t=>{if("string"==typeof t.data&&t.data.startsWith("blob:")){const e=c.get(t.data)??0;e>1?c.set(t.data,e-1):c.delete(t.data),e<=1&&URL.revokeObjectURL(t.data)}})},m=async(t,e)=>{o(t,"url"),s(e,"parseFile");try{const i=await fetch(t);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const r=await i.blob(),n=await e(r);if(!n||"object"!=typeof n.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const c=n.common;return(t=>{a(t,"common"),((t,e)=>{if(a(t,"common"),"boolean"!=typeof e)throw new TypeError('Expected "isPartial" to be a boolean.');const i=t=>e&&void 0===t,r=t=>i(t)||"string"==typeof t||null===t,n=(t,e)=>(s(e,"valueValidator"),!!i(t)||!(!Array.isArray(t)||!t.every(e)));if(!r(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!r(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!r(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!r(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(c=t.year,!i(c)&&"number"!=typeof c&&null!==c)throw new TypeError('Invalid metadata: "year" must be a number or null.');var c;if(!n(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!n(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!n(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!n(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!n(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!n(t.picture,t=>t&&"object"==typeof t&&(void 0===t.description||"string"==typeof t.description)&&(void 0===t.name||"string"==typeof t.name)&&(void 0===t.type||"string"==typeof t.type)&&"string"==typeof t.format&&(t.data instanceof Uint8Array||"string"==typeof t.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const u=(t,e)=>{if(o(t,"name"),!i(e)){if(null==e)throw new TypeError(`Invalid metadata: "${t}" is required.`);if("object"!=typeof e)throw new TypeError(`Invalid metadata: "${t}" must be an object or null.`);if("number"!=typeof e.no&&null!==e.no)throw new TypeError(`Invalid metadata: "${t}.no" must be a number or null.`);if("number"!=typeof e.of&&null!==e.of)throw new TypeError(`Invalid metadata: "${t}.of" must be a number or null.`)}};u("disk",t.disk),u("track",t.track)})(t,!0)})(c),{title:c?.title??null,album:c?.album??null,albumartist:c?.albumartist??null,albumartists:c?.albumartists??[],genre:c?.genre??[],label:c?.label??[],composer:c?.composer??[],year:c?.year??null,artist:c?.artist??null,artists:c?.artists??[],disk:c?.disk?{no:c.disk.no,of:c.disk.of}:{no:null,of:null},track:c?.track?{no:c.track.no,of:c.track.of}:{no:null,of:null},picture:c?.picture?.map(t=>({...t,data:d(t.data,t.format)}))??[]}}catch(t){throw t}},p=t=>{if(t)throw new Error("This TinyRadioFm instance has been destroyed and can no longer be used.")};class y extends n.EventEmitter{static async parseContent(t,e,i,r,n){return(async(t,e={},i={},r=t=>{if(!(t instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((t,e)=>e(new TypeError("parseFile library not found.")))},n={},c="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(a(e,"defaultMetadata"),a(i,"metadata"),s(r,"parseFile"),a(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 c&&"function"!=typeof c)throw new TypeError("unknownArtist must be a string or a function returning a string.");let d,h="";const f=(e,i)=>{if(o(e,"stage"),void 0!==i&&!(i instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');n.onProgress&&n.onProgress({event:i,status:"loading",stage:e,url:h||(t instanceof HTMLMediaElement?t.src:"unknown")})},p=(e,i)=>{if(!(e instanceof Error))throw new TypeError('Expected "error" to be an Error.');o(i,"stage"),n.onError&&n.onError({error:e,url:h||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:i})};try{f("INITIALIZING"),"string"==typeof t?(h=t,d=new Audio(h)):(d=t,h=d.src);try{await new Promise((t,e)=>{const i=t=>f("DOWNLOADING",t),r=()=>{o(),t(void 0)},n=t=>{o(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},o=()=>{d.removeEventListener("progress",i),d.removeEventListener("loadedmetadata",r),d.removeEventListener("error",n)};d.addEventListener("progress",i),d.addEventListener("loadedmetadata",r),d.addEventListener("error",n),d.readyState>=1&&(o(),t(void 0))}),f("METADATA_LOADED")}catch(t){throw new u(t instanceof Error?t.message:"UNKNOWN ERROR",h,"METADATA")}const s={id:i.id||await l(h),duration:Math.floor(1e3*d.duration),url:h,weight:i.weight??1};let a={};f("EXTRACTING_ID3");try{a=await m(h,r)}catch(t){p(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${h}. Falling back to filename.`)}const y=t=>{o(t,"url");try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},v={...s,...e,...a,...i,title:a.title||i.title||y(h),artist:a.artist||i.artist||("string"==typeof c?c:String(c()))};return n.onProgress&&n.onProgress({status:"success",stage:"COMPLETE",url:h}),v}catch(t){if(t instanceof u)throw t;{const e=new u(t instanceof Error?t.message:"UNKNOWN ERROR",h,"INITIALIZING");throw p(e,"INITIALIZING"),e}}})(t,e,i,r,n,y.#t)}static#t="Unknown Artist";static get unknownArtist(){return y.#t}static set unknownArtist(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("unknownArtist must have an string or function.");y.#t=t}#e=!1;get destroyed(){return this.#e}get size(){return p(this.#e),this.#i.length+this.#r.length}get musicSize(){return p(this.#e),this.#i.length}get voiceSize(){return p(this.#e),this.#r.length}get customPosSize(){return p(this.#e),this.#n.length}get tasksSize(){return p(this.#e),this.#o.length}get cycleCacheSize(){return p(this.#e),this.#s.size}#i=[];get musicList(){return p(this.#e),structuredClone(this.#i)}#r=[];get voiceList(){return p(this.#e),structuredClone(this.#r)}#n=[];get customPositions(){return p(this.#e),structuredClone(this.#n)}#o=[];get scheduledTasks(){return p(this.#e),structuredClone(this.#o)}get allList(){return p(this.#e),[...this.musicList,...this.voiceList]}#a=0;get seed(){return p(this.#e),this.#a}set seed(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Seed must be a number.");this.#a=t,this.#s.clear(),this.emit("seedChanged",{seed:t})}#c=Date.now();get anchorDate(){return p(this.#e),this.#c}#s=new Map;#u={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,voiceMaxConsecutive:0};get config(){return p(this.#e),structuredClone(this.#u)}set config(t){p(this.#e),this.#l(t),this.#u=structuredClone(t),this.#s.clear(),this.emit("configChanged",{config:this.config})}#l(t){if("object"!=typeof t||null===t)throw new TypeError("Configuration must be a valid object.");const e=["playlist","random"];if(void 0!==t.mode&&!e.includes(t.mode))throw new TypeError(`Invalid mode: "${t.mode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.voiceMode&&!e.includes(t.voiceMode))throw new TypeError(`Invalid voiceMode: "${t.voiceMode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.silenceDuration&&("number"!=typeof t.silenceDuration||t.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==t.queryLimit&&("number"!=typeof t.queryLimit||t.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==t.voiceAfterMusic&&"boolean"!=typeof t.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");if(void 0!==t.voiceMin&&("number"!=typeof t.voiceMin||t.voiceMin<0))throw new TypeError("voiceMin must be a non-negative number.");if(void 0!==t.voiceMax&&("number"!=typeof t.voiceMax||t.voiceMax<0))throw new TypeError("voiceMax must be a non-negative number.");if(void 0!==t.musicMaxConsecutive&&("number"!=typeof t.musicMaxConsecutive||t.musicMaxConsecutive<-1))throw new TypeError("musicMaxConsecutive must be a number >= -1.");if(void 0!==t.voiceMaxConsecutive&&("number"!=typeof t.voiceMaxConsecutive||t.voiceMaxConsecutive<-1))throw new TypeError("voiceMaxConsecutive must be a number >= -1.");const i=t.voiceMin??this.#u.voiceMin,r=t.voiceMax??this.#u.voiceMax;if(r<i)throw new RangeError(`Logical error: voiceMax (${r}) cannot be less than voiceMin (${i}).`)}constructor(t=null,e=0){if(super(),null!==t&&"object"!=typeof t)throw new TypeError("initialData must be an object or null.");if("number"!=typeof e)throw new TypeError("seed must be a number.");this.#a=e,t?this.#d(t):this.#c=Date.now()}add(t,e,i=!0){if(p(this.#e),!["music","voice","custom"].includes(t))throw new TypeError('Type must be "music", "voice", or "custom".');if(!e||"string"!=typeof e.id||"number"!=typeof e.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof i)throw new TypeError("smartQueue must be a boolean.");"music"===t?(this.#i.push(e),this.#s.clear()):"voice"===t?(this.#r.push(e),this.#s.clear()):"custom"===t&&this.#h(e,i),this.#f(Date.now()),this.emit("contentAdded",{type:t,data:structuredClone(e)})}scheduleTask(t,e,i,r,n=!0){if(p(this.#e),"number"!=typeof t||isNaN(t))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(e))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(i))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof n)throw new TypeError("smartQueue must be a boolean.");if("add"===e){if("object"!=typeof r||null===r||"string"!=typeof r.id||"number"!=typeof r.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===e){if("string"!=typeof r)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===e&&("object"!=typeof r||null===r||"string"!=typeof r.id||"number"!=typeof r.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let o=t;if(n){const e=this.#m(t,t);e&&(o=e.absoluteEnd)}const s={timestamp:o,action:e,type:i,payload:r};this.#o.push(s),this.#f(Date.now()),this.emit("taskScheduled",structuredClone(s))}remove(t){if(p(this.#e),"string"!=typeof t)throw new TypeError("id must be a string.");this.#i.filter(e=>e.id===t).forEach(t=>f(t)),this.#r.filter(e=>e.id===t).forEach(t=>f(t)),this.#n.filter(e=>e.content?.id===t).forEach(t=>f(t.content));const e=e=>e.id!==t&&e.content?.id!==t;this.#i=this.#i.filter(e),this.#r=this.#r.filter(e),this.#n=this.#n.filter(e),this.#o=this.#o.filter(e=>"add"===e.action&&"object"==typeof e.payload&&null!==e.payload&&"id"in e.payload?e.payload.id!==t||(f(e.payload),!1):e.payload!==t),this.#s.clear(),this.emit("contentRemoved",{id:t})}setConfig(t){p(this.#e),this.#l(t);const e={...this.#u,...t};this.#l(e),this.#u=e,this.#s.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){p(this.#e);const t=Date.now();return this.#f(t),this.#m(t,t)}queryTimeline(t,e=10){if(p(this.#e),"number"!=typeof e||isNaN(e))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(e>this.#u.queryLimit||e<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#u.queryLimit}.`);const i=new y(JSON.parse(this._exportState())),r=[];let n=t;for(let o=0;o<e;o++){i.#f(n);const e=i.#p(n,t);if(!e)break;r.push(e),n=e.absoluteEnd}return i.destroy(!1),this.emit("timelineQueried",{targetDate:t,limit:e,resultCount:r.length}),r}searchCustomPositions(){return p(this.#e),this.#f(Date.now()),[...this.#n]}async _processListForExport(t){return Promise.all(t.map(async t=>{const e=structuredClone(t);return e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async t=>"string"==typeof t.data&&t.data.startsWith("blob:")?{...t,data:await h(t.data)}:t))),e}))}_exportState(){return JSON.stringify({music:this.#i,voice:this.#r,custom:this.#n,tasks:this.#o,seed:this.#a,anchorDate:this.#c,config:this.#u})}async exportState(){p(this.#e);const t=await this._processListForExport(this.#i),e=await this._processListForExport(this.#r),i=await Promise.all(this.#n.map(async t=>{const e=await this._processListForExport([t.content]);return{...t,content:e[0]}})),r=await Promise.all(this.#o.map(async t=>{if("add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload){const e=await this._processListForExport([t.payload]);return{...t,payload:e[0]}}return t}));return JSON.stringify({music:t,voice:e,custom:i,tasks:r,seed:this.#a,anchorDate:this.#c,config:this.#u})}importState(t){let e;if(p(this.#e),"string"==typeof t)try{e=JSON.parse(t)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof t||null===t)throw new TypeError("Import data must be a valid JSON string or an object.");e=t}this.#d(e),this.emit("stateImported",{data:structuredClone(e)})}_prng(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}#y(t,e,i,r=0){if(0===t.length)return[];if("random"!==i)return[...t];const n=t.map(t=>({...t,weight:t.weight??1})),o=this._prng(e),s=[];let a=null,c=0;for(;n.length>0;){let t=n;-1!==r&&null!==a&&c>r&&(t=n.filter(t=>t.id!==a),0===t.length&&(t=n));const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0){s.push(...t);break}const i=o()*e;let u=0,l=null,d=-1;for(let e=0;e<t.length;e++)if(u+=t[e].weight,i<=u){l=t[e],d=n.findIndex(t=>l&&t.id===l.id);break}l&&-1!==d||(l=t[0],d=n.findIndex(t=>l&&t.id===l.id)),s.push(l),n.splice(d,1),l.id===a?c++:(a=l.id,c=1)}return s}#v(t){const e=this.#a+t,i=this._prng(10*e),r=this.#y(this.#i,e+1,this.#u.mode,this.#u.musicMaxConsecutive),n=this.#y(this.#r,e+2,this.#u.voiceMode,this.#u.voiceMaxConsecutive),o=[];let s=0,a=0;for(let t=0;t<r.length;t++){const e=r[t];if(o.push({...e,cycleStart:s,cycleEnd:s+e.duration}),s+=e.duration+this.#u.silenceDuration,this.#u.voiceAfterMusic&&n.length>0){const t=this.#u.voiceMax-this.#u.voiceMin+1,e=Math.floor(i()*t)+this.#u.voiceMin;for(let t=0;t<e;t++){const t=n[a%n.length];a++,o.push({...t,cycleStart:s,cycleEnd:s+t.duration}),s+=t.duration+this.#u.silenceDuration}}}return{items:o,duration:s}}#g(t){if(0===this.#i.length)return null;let e=this.#c,i=0;for(;;){if(i>this.#u.queryLimit)throw new Error("Safety limit hit during cycle location.");let r=this.#s.get(i);if(r||(r=this.#v(i),this.#s.set(i,r)),0===r.duration)return null;if(t>=e&&t<e+r.duration)return{block:r,startTimestamp:e,loopIndex:i};e+=r.duration,i++}}#p(t,e){const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t).sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp)[0];let r=null;if(i){const t=Math.max(e,i.intendedTimestamp);r=this.#w(i.content,i.intendedTimestamp,t,!0)}const n=this.#b(t,e);return n||r?n?r?r.absoluteStart<=n.absoluteStart?r:(r.absoluteStart<n.absoluteEnd&&(n.absoluteEnd=r.absoluteStart,n.duration=n.absoluteEnd-n.absoluteStart,n.remainingTime=Math.max(0,n.absoluteEnd-e),n.progress=Math.min(1,n.elapsedTime/n.duration)),n):n:r:null}#b(t,e){let i=this.#g(t);if(!i)return null;const{block:r,startTimestamp:n}=i,o=t-n;let s,a=r.items.find(t=>t.cycleEnd>o);if(a)s=n+a.cycleStart;else{if(i=this.#g(n+r.duration),!i||0===i.block.items.length)return null;a=i.block.items[0],s=i.startTimestamp+a.cycleStart}const c=Math.max(e,s);return this.#w(a,s,c,!1)}#m(t,e){const i=this.#n.find(e=>t>=e.intendedTimestamp&&t<e.intendedTimestamp+e.content.duration);if(i)return this.#w(i.content,i.intendedTimestamp,e,!0);const r=this.#g(t);if(!r)return null;const{block:n,startTimestamp:o}=r,s=t-o,a=n.items.find(t=>s>=t.cycleStart&&s<t.cycleEnd);return a?this.#w(a,o+a.cycleStart,e,!1):null}#w(t,e,i,r){const n=i-e;return{id:t.id,title:t.title,artist:t.artist,duration:t.duration,url:t.url,absoluteStart:e,absoluteEnd:e+t.duration,elapsedTime:n,remainingTime:t.duration-n,progress:Math.min(1,n/t.duration),isCustom:r}}#h(t,e){let i=t.timestamp||Date.now();const r=t.duration;if(e){const t=this.#m(i,i);t&&(i=t.absoluteEnd)}const n=[...this.#n].sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp);let o=i;if(n.some(t=>i<t.intendedTimestamp+t.content.duration&&i+r>t.intendedTimestamp)){const t=[];let e=Date.now();for(const i of n)i.intendedTimestamp>e&&t.push({start:e,end:i.intendedTimestamp}),e=Math.max(e,i.intendedTimestamp+i.content.duration+this.#u.silenceDuration);t.push({start:e,end:1/0});let s=1/0;for(const e of t)if(e.end-e.start>=r){let t=null;if(i>=e.start&&i+r<=e.end?t=i:i<e.start?t=e.start:i>e.end&&(t=e.end-r),null!==t){const e=Math.abs(i-t);e<s&&(s=e,o=t)}}}this.#n.push({content:t,intendedTimestamp:o,originalTimestamp:t.timestamp||Date.now()})}#f(t){const e=this.#o.filter(e=>e.timestamp<=t);this.#o=this.#o.filter(e=>e.timestamp>t);const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration<=t);this.#n=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t);let r=!1;i.forEach(t=>{f(t.content),this.#a+=t.content.id.length,r=!0,this.emit("customPositionExpired",{contentId:t.content.id})}),e.length>0&&e.sort((t,e)=>t.timestamp-e.timestamp).forEach(t=>{const e="music"===t.type?this.#i:this.#r;if("add"===t.action)e.push(t.payload);else if("remove"===t.action){const i=t.payload,r=e.findIndex(t=>t.id===i);if(-1!==r){const[t]=e.splice(r,1);f(t)}}else if("move"===t.action){const i=t.payload,r=e.findIndex(t=>t.id===i.id);if(-1!==r){const[t]=e.splice(r,1);e.splice(i.newIndex,0,t)}}this.#c=t.timestamp,this.#a+=1,r=!0,this.emit("taskExecuted",structuredClone(t))}),r&&this.#s.clear()}#d(t){this.#i.forEach(t=>f(t)),this.#r.forEach(t=>f(t)),this.#n.forEach(t=>f(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&f(t.payload)});const e=t=>t.map(t=>{const e={...t};return e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(t=>{const e="string"==typeof t.data&&t.data.startsWith("data:"),i=t.data instanceof Uint8Array;return e||i?{...t,data:d(t.data,t.format)}:t})),e});this.#i=e(t.music),this.#r=e(t.voice),this.#a=t.seed||0,this.#c=t.anchorDate||Date.now(),this.#u={...this.#u,...t.config||{}},this.#n=t.custom.map(t=>({...t,content:e([t.content])[0]})),this.#o=t.tasks.map(t=>"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload?{...t,payload:e([t.payload])[0]}:t)}destroy(t=!0){this.#e||(t&&(this.#i.forEach(t=>f(t)),this.#r.forEach(t=>f(t)),this.#n.forEach(t=>f(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&f(t.payload)})),this.#i=[],this.#r=[],this.#n=[],this.#o=[],this.#s.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#e=!0)}}const v=y;window.TinyRadioFm=r.TinyRadioFm})();