tiny-essentials 1.28.19 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (555) hide show
  1. package/README.md +1 -1
  2. package/changelog/1/28/19.md +24 -0
  3. package/changelog/1/29/0.md +58 -0
  4. package/dist/v1/ColorSafeStringify.min.js +1 -1
  5. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  6. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  7. package/dist/v1/TinyAnalogClock.min.js +1 -1
  8. package/dist/v1/TinyArrayComparator.min.js +1 -1
  9. package/dist/v1/TinyArrayPaginator.min.js +1 -1
  10. package/dist/v1/TinyBasicsEs.min.js +1 -1
  11. package/dist/v1/TinyBrowserMonitor.min.js +1 -0
  12. package/dist/v1/TinyClassManager.min.js +1 -1
  13. package/dist/v1/TinyClipboard.min.js +1 -1
  14. package/dist/v1/TinyCloner.min.js +1 -0
  15. package/dist/v1/TinyColorConverter.min.js +1 -1
  16. package/dist/v1/TinyColorValidator.min.js +1 -1
  17. package/dist/v1/TinyCookieConsent.min.js +1 -1
  18. package/dist/v1/TinyDayNightCycle.min.js +1 -1
  19. package/dist/v1/TinyDebugger.min.js +1 -1
  20. package/dist/v1/TinyDomReadyManager.min.js +1 -1
  21. package/dist/v1/TinyDragDropDetector.min.js +1 -1
  22. package/dist/v1/TinyDragger.min.js +1 -1
  23. package/dist/v1/TinyElementObserver.min.js +1 -1
  24. package/dist/v1/TinyEssentials.min.js +1 -1
  25. package/dist/v1/TinyGamepad.min.js +1 -1
  26. package/dist/v1/TinyHtml.min.js +1 -1
  27. package/dist/v1/TinyHtmlTagRegexBuilder.min.js +1 -0
  28. package/dist/v1/TinyHttpResponseRegistry.min.js +1 -0
  29. package/dist/v1/TinyI18.min.js +1 -1
  30. package/dist/v1/TinyIframeEvents.min.js +1 -1
  31. package/dist/v1/TinyInventory.min.js +1 -1
  32. package/dist/v1/TinyInventoryTrader.min.js +1 -1
  33. package/dist/v1/TinyLevelUp.min.js +1 -1
  34. package/dist/v1/TinyLoadingScreen.min.js +1 -1
  35. package/dist/v1/TinyLocalStorage.min.js +1 -1
  36. package/dist/v1/TinyMaInSys.min.js +1 -1
  37. package/dist/v1/TinyMapCache.min.js +1 -0
  38. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  39. package/dist/v1/TinyNeedBar.min.js +1 -1
  40. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  41. package/dist/v1/TinyNotificationAdapter.min.js +1 -0
  42. package/dist/v1/TinyNotifications.min.js +1 -1
  43. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  44. package/dist/v1/TinyOPFSFileSystem.min.js +1 -0
  45. package/dist/v1/TinyPasswordValidator.min.js +1 -0
  46. package/dist/v1/TinyPluginPackage.min.js +1 -0
  47. package/dist/v1/TinyPromiseQueue.min.js +1 -1
  48. package/dist/v1/TinyPushManager.min.js +1 -0
  49. package/dist/v1/TinyPushPayload.min.js +1 -0
  50. package/dist/v1/TinyPushRouter.min.js +1 -0
  51. package/dist/v1/TinyRadioFm.min.js +1 -1
  52. package/dist/v1/TinyRateLimiter.min.js +1 -1
  53. package/dist/v1/TinyRegexEs.min.js +1 -0
  54. package/dist/v1/TinyRouter.min.js +1 -0
  55. package/dist/v1/TinyServiceWorker.min.js +1 -0
  56. package/dist/v1/TinyServiceWorkerEngine.min.js +1 -0
  57. package/dist/v1/TinySetMapPackage.min.js +1 -0
  58. package/dist/v1/TinySimpleDice.min.js +1 -1
  59. package/dist/v1/TinySmartScroller.min.js +1 -1
  60. package/dist/v1/TinyStorageBucketFileSystem.min.js +1 -0
  61. package/dist/v1/TinyTextDiffer.min.js +1 -1
  62. package/dist/v1/TinyTextRangeEditor.min.js +1 -1
  63. package/dist/v1/TinyTextarea.min.js +1 -1
  64. package/dist/v1/TinyThrottledApi.min.js +1 -0
  65. package/dist/v1/TinyTimeout.min.js +1 -1
  66. package/dist/v1/TinyToastNotify.min.js +1 -1
  67. package/dist/v1/TinyUploadClicker.min.js +1 -1
  68. package/dist/v1/TinyUriParser.min.js +1 -0
  69. package/dist/v1/TinyVersion.min.js +1 -0
  70. package/dist/v1/TinyWebWorker.min.js +1 -0
  71. package/dist/v1/TinyWebWorkerEngine.min.js +1 -0
  72. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  73. package/dist/v1/basics/array.cjs +2 -2
  74. package/dist/v1/basics/array.d.mts +2 -0
  75. package/dist/v1/basics/array.d.mts.map +1 -1
  76. package/dist/v1/basics/array.mjs +2 -1
  77. package/dist/v1/basics/browserDetector.cjs +37 -12
  78. package/dist/v1/basics/browserDetector.d.mts +8 -0
  79. package/dist/v1/basics/browserDetector.d.mts.map +1 -1
  80. package/dist/v1/basics/browserDetector.mjs +32 -13
  81. package/dist/v1/basics/crypto.cjs +23 -0
  82. package/dist/v1/basics/crypto.d.mts +10 -0
  83. package/dist/v1/basics/crypto.d.mts.map +1 -0
  84. package/dist/v1/basics/crypto.mjs +18 -0
  85. package/dist/v1/basics/html.cjs +0 -3
  86. package/dist/v1/basics/html.d.mts.map +1 -1
  87. package/dist/v1/basics/html.mjs +0 -2
  88. package/dist/v1/basics/index.cjs +8 -1
  89. package/dist/v1/basics/index.d.mts +6 -5
  90. package/dist/v1/basics/index.d.mts.map +1 -1
  91. package/dist/v1/basics/index.mjs +6 -5
  92. package/dist/v1/basics/objChecker.cjs +88 -0
  93. package/dist/v1/basics/objChecker.d.mts +26 -0
  94. package/dist/v1/basics/objChecker.d.mts.map +1 -1
  95. package/dist/v1/basics/objChecker.mjs +74 -0
  96. package/dist/v1/basics/objFilter.cjs +234 -93
  97. package/dist/v1/basics/objFilter.d.mts +96 -22
  98. package/dist/v1/basics/objFilter.d.mts.map +1 -1
  99. package/dist/v1/basics/objFilter.mjs +216 -92
  100. package/dist/v1/basics/promiseUtils.cjs +48 -12
  101. package/dist/v1/basics/promiseUtils.d.mts +45 -12
  102. package/dist/v1/basics/promiseUtils.d.mts.map +1 -1
  103. package/dist/v1/basics/promiseUtils.mjs +47 -12
  104. package/dist/v1/basics/text.cjs +0 -12
  105. package/dist/v1/basics/text.d.mts +0 -10
  106. package/dist/v1/basics/text.d.mts.map +1 -1
  107. package/dist/v1/basics/text.mjs +0 -10
  108. package/dist/v1/index.cjs +88 -3
  109. package/dist/v1/index.d.mts +31 -6
  110. package/dist/v1/index.d.mts.map +1 -1
  111. package/dist/v1/index.mjs +32 -7
  112. package/dist/v1/jsdoc/EventEmitter.cjs +4 -0
  113. package/dist/v1/jsdoc/EventEmitter.d.mts +33 -0
  114. package/dist/v1/jsdoc/EventEmitter.d.mts.map +1 -0
  115. package/dist/v1/jsdoc/EventEmitter.mjs +18 -0
  116. package/dist/v1/libs/array/TinyArrayComparator.cjs +240 -25
  117. package/dist/v1/libs/array/TinyArrayComparator.d.mts +130 -22
  118. package/dist/v1/libs/array/TinyArrayComparator.d.mts.map +1 -1
  119. package/dist/v1/libs/array/TinyArrayComparator.mjs +210 -24
  120. package/dist/v1/libs/fs/constants.cjs +74 -0
  121. package/dist/v1/libs/fs/constants.d.mts +22 -0
  122. package/dist/v1/libs/fs/constants.d.mts.map +1 -0
  123. package/dist/v1/libs/fs/constants.mjs +53 -0
  124. package/dist/v1/libs/fs/encoding.cjs +118 -0
  125. package/dist/v1/libs/fs/encoding.d.mts +50 -0
  126. package/dist/v1/libs/fs/encoding.d.mts.map +1 -0
  127. package/dist/v1/libs/fs/encoding.mjs +102 -0
  128. package/dist/v1/libs/fs/error.cjs +188 -0
  129. package/dist/v1/libs/fs/error.d.mts +105 -0
  130. package/dist/v1/libs/fs/error.d.mts.map +1 -0
  131. package/dist/v1/libs/fs/error.mjs +158 -0
  132. package/dist/v1/libs/fs/handle.cjs +121 -0
  133. package/dist/v1/libs/fs/handle.d.mts +56 -0
  134. package/dist/v1/libs/fs/handle.d.mts.map +1 -0
  135. package/dist/v1/libs/fs/handle.mjs +100 -0
  136. package/dist/v1/libs/fs/index.cjs +700 -0
  137. package/dist/v1/libs/fs/index.d.mts +377 -0
  138. package/dist/v1/libs/fs/index.d.mts.map +1 -0
  139. package/dist/v1/libs/fs/index.mjs +630 -0
  140. package/dist/v1/libs/fs/path.cjs +234 -0
  141. package/dist/v1/libs/fs/path.d.mts +176 -0
  142. package/dist/v1/libs/fs/path.d.mts.map +1 -0
  143. package/dist/v1/libs/fs/path.mjs +197 -0
  144. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.cjs +202 -0
  145. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.d.mts +121 -0
  146. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.d.mts.map +1 -0
  147. package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.mjs +172 -0
  148. package/dist/v1/libs/fs/plugins/OPFS/index.cjs +334 -0
  149. package/dist/v1/libs/fs/plugins/OPFS/index.d.mts +98 -0
  150. package/dist/v1/libs/fs/plugins/OPFS/index.d.mts.map +1 -0
  151. package/dist/v1/libs/fs/plugins/OPFS/index.mjs +300 -0
  152. package/dist/v1/libs/fs/stats.cjs +245 -0
  153. package/dist/v1/libs/fs/stats.d.mts +226 -0
  154. package/dist/v1/libs/fs/stats.d.mts.map +1 -0
  155. package/dist/v1/libs/fs/stats.mjs +197 -0
  156. package/dist/v1/libs/html/events/TinyIframeEvents.cjs +10 -1
  157. package/dist/v1/libs/html/events/TinyIframeEvents.d.mts +9 -2
  158. package/dist/v1/libs/html/events/TinyIframeEvents.d.mts.map +1 -1
  159. package/dist/v1/libs/html/events/TinyIframeEvents.mjs +8 -1
  160. package/dist/v1/libs/html/events/TinyNewWinEvents.cjs +14 -3
  161. package/dist/v1/libs/html/events/TinyNewWinEvents.d.mts +21 -5
  162. package/dist/v1/libs/html/events/TinyNewWinEvents.d.mts.map +1 -1
  163. package/dist/v1/libs/html/events/TinyNewWinEvents.mjs +12 -3
  164. package/dist/v1/libs/html/scroll/TinySmartScroller.cjs +13 -1
  165. package/dist/v1/libs/html/scroll/TinySmartScroller.d.mts +29 -2
  166. package/dist/v1/libs/html/scroll/TinySmartScroller.d.mts.map +1 -1
  167. package/dist/v1/libs/html/scroll/TinySmartScroller.mjs +11 -1
  168. package/dist/v1/libs/math/TinyAdvancedRaffle.cjs +13 -1
  169. package/dist/v1/libs/math/TinyAdvancedRaffle.d.mts +32 -2
  170. package/dist/v1/libs/math/TinyAdvancedRaffle.d.mts.map +1 -1
  171. package/dist/v1/libs/math/TinyAdvancedRaffle.mjs +11 -1
  172. package/dist/v1/libs/math/TinyTimeout.cjs +0 -14
  173. package/dist/v1/libs/math/TinyTimeout.d.mts +0 -11
  174. package/dist/v1/libs/math/TinyTimeout.d.mts.map +1 -1
  175. package/dist/v1/libs/math/TinyTimeout.mjs +0 -13
  176. package/dist/v1/libs/media/TinyMediaPlayer/index.cjs +25 -1
  177. package/dist/v1/libs/media/TinyMediaPlayer/index.d.mts +35 -2
  178. package/dist/v1/libs/media/TinyMediaPlayer/index.d.mts.map +1 -1
  179. package/dist/v1/libs/media/TinyMediaPlayer/index.mjs +23 -1
  180. package/dist/v1/libs/media/TinyMediaPlayer.cjs +2 -2
  181. package/dist/v1/libs/media/TinyMediaPlayer.d.mts +2 -2
  182. package/dist/v1/libs/media/TinyMediaPlayer.d.mts.map +1 -1
  183. package/dist/v1/libs/media/TinyMediaPlayer.mjs +2 -2
  184. package/dist/v1/libs/media/TinyRadioFm.cjs +19 -1
  185. package/dist/v1/libs/media/TinyRadioFm.d.mts +78 -2
  186. package/dist/v1/libs/media/TinyRadioFm.d.mts.map +1 -1
  187. package/dist/v1/libs/media/TinyRadioFm.mjs +17 -1
  188. package/dist/v1/libs/plugin/TinyPlugin.cjs +1630 -0
  189. package/dist/v1/libs/plugin/TinyPlugin.d.mts +753 -0
  190. package/dist/v1/libs/plugin/TinyPlugin.d.mts.map +1 -0
  191. package/dist/v1/libs/plugin/TinyPlugin.mjs +1376 -0
  192. package/dist/v1/libs/plugin/TinyVersion.cjs +204 -0
  193. package/dist/v1/libs/plugin/TinyVersion.d.mts +70 -0
  194. package/dist/v1/libs/plugin/TinyVersion.d.mts.map +1 -0
  195. package/dist/v1/libs/plugin/TinyVersion.mjs +179 -0
  196. package/dist/v1/libs/router/TinyRouter.cjs +661 -0
  197. package/dist/v1/libs/router/TinyRouter.d.mts +320 -0
  198. package/dist/v1/libs/router/TinyRouter.d.mts.map +1 -0
  199. package/dist/v1/libs/router/TinyRouter.mjs +572 -0
  200. package/dist/v1/libs/storage/TinyLocalStorage.cjs +20 -1
  201. package/dist/v1/libs/storage/TinyLocalStorage.d.mts +64 -2
  202. package/dist/v1/libs/storage/TinyLocalStorage.d.mts.map +1 -1
  203. package/dist/v1/libs/storage/TinyLocalStorage.mjs +18 -1
  204. package/dist/v1/libs/storage/TinyMapCache.cjs +373 -0
  205. package/dist/v1/libs/storage/TinyMapCache.d.mts +274 -0
  206. package/dist/v1/libs/storage/TinyMapCache.d.mts.map +1 -0
  207. package/dist/v1/libs/storage/TinyMapCache.mjs +333 -0
  208. package/dist/v1/libs/storage/TinySetMapDatabase.cjs +1167 -0
  209. package/dist/v1/libs/storage/TinySetMapDatabase.d.mts +603 -0
  210. package/dist/v1/libs/storage/TinySetMapDatabase.d.mts.map +1 -0
  211. package/dist/v1/libs/storage/TinySetMapDatabase.mjs +1059 -0
  212. package/dist/v1/libs/sw/browser/TinyNotificationAdapter.cjs +126 -0
  213. package/dist/v1/libs/sw/browser/TinyNotificationAdapter.d.mts +132 -0
  214. package/dist/v1/libs/sw/browser/TinyNotificationAdapter.d.mts.map +1 -0
  215. package/dist/v1/libs/sw/browser/TinyNotificationAdapter.mjs +109 -0
  216. package/dist/v1/libs/sw/browser/TinyPushManager.cjs +310 -0
  217. package/dist/v1/libs/sw/browser/TinyPushManager.d.mts +168 -0
  218. package/dist/v1/libs/sw/browser/TinyPushManager.d.mts.map +1 -0
  219. package/dist/v1/libs/sw/browser/TinyPushManager.mjs +264 -0
  220. package/dist/v1/libs/sw/browser/TinyServiceWorker.cjs +1060 -0
  221. package/dist/v1/libs/sw/browser/TinyServiceWorker.d.mts +348 -0
  222. package/dist/v1/libs/sw/browser/TinyServiceWorker.d.mts.map +1 -0
  223. package/dist/v1/libs/sw/browser/TinyServiceWorker.mjs +933 -0
  224. package/dist/v1/libs/sw/browser/plugins/TabManager.cjs +315 -0
  225. package/dist/v1/libs/sw/browser/plugins/TabManager.d.mts +178 -0
  226. package/dist/v1/libs/sw/browser/plugins/TabManager.d.mts.map +1 -0
  227. package/dist/v1/libs/sw/browser/plugins/TabManager.mjs +274 -0
  228. package/dist/v1/libs/sw/browser/utils.cjs +28 -0
  229. package/dist/v1/libs/sw/browser/utils.d.mts +8 -0
  230. package/dist/v1/libs/sw/browser/utils.d.mts.map +1 -0
  231. package/dist/v1/libs/sw/browser/utils.mjs +21 -0
  232. package/dist/v1/libs/sw/service/TinyPushRouter.cjs +222 -0
  233. package/dist/v1/libs/sw/service/TinyPushRouter.d.mts +138 -0
  234. package/dist/v1/libs/sw/service/TinyPushRouter.d.mts.map +1 -0
  235. package/dist/v1/libs/sw/service/TinyPushRouter.mjs +201 -0
  236. package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.cjs +3016 -0
  237. package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.d.mts +993 -0
  238. package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.d.mts.map +1 -0
  239. package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.mjs +2558 -0
  240. package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.cjs +88 -0
  241. package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.d.mts +32 -0
  242. package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.d.mts.map +1 -0
  243. package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.mjs +69 -0
  244. package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.cjs +112 -0
  245. package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.d.mts +31 -0
  246. package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.d.mts.map +1 -0
  247. package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.mjs +91 -0
  248. package/dist/v1/libs/sw/service/plugins/Ping.cjs +32 -0
  249. package/dist/v1/libs/sw/service/plugins/Ping.d.mts +9 -0
  250. package/dist/v1/libs/sw/service/plugins/Ping.d.mts.map +1 -0
  251. package/dist/v1/libs/sw/service/plugins/Ping.mjs +25 -0
  252. package/dist/v1/libs/sw/service/plugins/TabManager.cjs +457 -0
  253. package/dist/v1/libs/sw/service/plugins/TabManager.d.mts +91 -0
  254. package/dist/v1/libs/sw/service/plugins/TabManager.d.mts.map +1 -0
  255. package/dist/v1/libs/sw/service/plugins/TabManager.mjs +372 -0
  256. package/dist/v1/libs/sw/service/plugins/ViteFileDetector.cjs +180 -0
  257. package/dist/v1/libs/sw/service/plugins/ViteFileDetector.d.mts +28 -0
  258. package/dist/v1/libs/sw/service/plugins/ViteFileDetector.d.mts.map +1 -0
  259. package/dist/v1/libs/sw/service/plugins/ViteFileDetector.mjs +148 -0
  260. package/dist/v1/libs/sw/service/shared/TinyPushPayload.cjs +199 -0
  261. package/dist/v1/libs/sw/service/shared/TinyPushPayload.d.mts +80 -0
  262. package/dist/v1/libs/sw/service/shared/TinyPushPayload.d.mts.map +1 -0
  263. package/dist/v1/libs/sw/service/shared/TinyPushPayload.mjs +174 -0
  264. package/dist/v1/libs/sw/utils.cjs +57 -0
  265. package/dist/v1/libs/sw/utils.d.mts +173 -0
  266. package/dist/v1/libs/sw/utils.d.mts.map +1 -0
  267. package/dist/v1/libs/sw/utils.mjs +50 -0
  268. package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.cjs +57 -0
  269. package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.d.mts +39 -0
  270. package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.d.mts.map +1 -0
  271. package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.mjs +48 -0
  272. package/dist/v1/libs/text/TinyI18/Browser.cjs +64 -0
  273. package/dist/v1/libs/text/TinyI18/Browser.d.mts +47 -0
  274. package/dist/v1/libs/text/TinyI18/Browser.d.mts.map +1 -0
  275. package/dist/v1/libs/text/TinyI18/Browser.mjs +57 -0
  276. package/dist/v1/libs/text/TinyI18/Node.cjs +49 -0
  277. package/dist/v1/libs/text/TinyI18/Node.d.mts +38 -0
  278. package/dist/v1/libs/text/TinyI18/Node.d.mts.map +1 -0
  279. package/dist/v1/libs/text/TinyI18/Node.mjs +43 -0
  280. package/dist/v1/libs/text/TinyI18/browser-utils.cjs +17 -0
  281. package/dist/v1/libs/text/TinyI18/browser-utils.d.mts +8 -0
  282. package/dist/v1/libs/text/TinyI18/browser-utils.d.mts.map +1 -0
  283. package/dist/v1/libs/text/TinyI18/browser-utils.mjs +13 -0
  284. package/dist/v1/libs/text/{TinyI18.cjs → TinyI18/index.cjs} +205 -104
  285. package/dist/v1/libs/text/{TinyI18.d.mts → TinyI18/index.d.mts} +141 -92
  286. package/dist/v1/libs/text/TinyI18/index.d.mts.map +1 -0
  287. package/dist/v1/libs/text/{TinyI18.mjs → TinyI18/index.mjs} +195 -101
  288. package/dist/v1/libs/tools/TinyBrowserMonitor.cjs +1088 -0
  289. package/dist/v1/libs/tools/TinyBrowserMonitor.d.mts +621 -0
  290. package/dist/v1/libs/tools/TinyBrowserMonitor.d.mts.map +1 -0
  291. package/dist/v1/libs/tools/TinyBrowserMonitor.mjs +940 -0
  292. package/dist/v1/libs/tools/TinyDebugger.cjs +180 -19
  293. package/dist/v1/libs/tools/TinyDebugger.d.mts +220 -24
  294. package/dist/v1/libs/tools/TinyDebugger.d.mts.map +1 -1
  295. package/dist/v1/libs/tools/TinyDebugger.mjs +161 -19
  296. package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.cjs +256 -0
  297. package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.d.mts +125 -0
  298. package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.d.mts.map +1 -0
  299. package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.mjs +223 -0
  300. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.cjs +23 -0
  301. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.d.mts +17 -0
  302. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.d.mts.map +1 -0
  303. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.mjs +19 -0
  304. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.cjs +23 -0
  305. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.d.mts +17 -0
  306. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.d.mts.map +1 -0
  307. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.mjs +19 -0
  308. package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.cjs +390 -0
  309. package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.d.mts +9 -0
  310. package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.d.mts.map +1 -0
  311. package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.mjs +387 -0
  312. package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.cjs +2 -0
  313. package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.d.mts +27 -0
  314. package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.d.mts.map +1 -0
  315. package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.mjs +12 -0
  316. package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/LICENSE +53 -0
  317. package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.cjs +405 -0
  318. package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.d.mts +34 -0
  319. package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.d.mts.map +1 -0
  320. package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.mjs +342 -0
  321. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.cjs +23 -0
  322. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.d.mts +17 -0
  323. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.d.mts.map +1 -0
  324. package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.mjs +19 -0
  325. package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.cjs +327 -0
  326. package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.d.mts +9 -0
  327. package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.d.mts.map +1 -0
  328. package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.mjs +324 -0
  329. package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.cjs +268 -0
  330. package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.d.mts +107 -0
  331. package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.d.mts.map +1 -0
  332. package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.mjs +238 -0
  333. package/dist/v1/libs/tools/TinyPasswordValidator.cjs +491 -0
  334. package/dist/v1/libs/tools/TinyPasswordValidator.d.mts +246 -0
  335. package/dist/v1/libs/tools/TinyPasswordValidator.d.mts.map +1 -0
  336. package/dist/v1/libs/tools/TinyPasswordValidator.mjs +434 -0
  337. package/dist/v1/libs/tools/TinyPkgExportValidator.cjs +48 -0
  338. package/dist/v1/libs/tools/TinyPkgExportValidator.d.mts +14 -0
  339. package/dist/v1/libs/tools/TinyPkgExportValidator.d.mts.map +1 -1
  340. package/dist/v1/libs/tools/TinyPkgExportValidator.mjs +44 -0
  341. package/dist/v1/libs/tools/TinySiteMap.cjs +1029 -0
  342. package/dist/v1/libs/tools/TinySiteMap.d.mts +429 -0
  343. package/dist/v1/libs/tools/TinySiteMap.d.mts.map +1 -0
  344. package/dist/v1/libs/tools/TinySiteMap.mjs +910 -0
  345. package/dist/v1/libs/tools/TinySiteMapStream.cjs +121 -0
  346. package/dist/v1/libs/tools/TinySiteMapStream.d.mts +51 -0
  347. package/dist/v1/libs/tools/TinySiteMapStream.d.mts.map +1 -0
  348. package/dist/v1/libs/tools/TinySiteMapStream.mjs +85 -0
  349. package/dist/v1/libs/tools/TinyURLSecurityVerifier.cjs +444 -0
  350. package/dist/v1/libs/tools/TinyURLSecurityVerifier.d.mts +217 -0
  351. package/dist/v1/libs/tools/TinyURLSecurityVerifier.d.mts.map +1 -0
  352. package/dist/v1/libs/tools/TinyURLSecurityVerifier.mjs +394 -0
  353. package/dist/v1/libs/tools/TinyUriParser/BlueSky.cjs +613 -0
  354. package/dist/v1/libs/tools/TinyUriParser/BlueSky.d.mts +152 -0
  355. package/dist/v1/libs/tools/TinyUriParser/BlueSky.d.mts.map +1 -0
  356. package/dist/v1/libs/tools/TinyUriParser/BlueSky.mjs +527 -0
  357. package/dist/v1/libs/tools/TinyUriParser/Discord.cjs +1119 -0
  358. package/dist/v1/libs/tools/TinyUriParser/Discord.d.mts +306 -0
  359. package/dist/v1/libs/tools/TinyUriParser/Discord.d.mts.map +1 -0
  360. package/dist/v1/libs/tools/TinyUriParser/Discord.mjs +968 -0
  361. package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.cjs +469 -0
  362. package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.d.mts +80 -0
  363. package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.d.mts.map +1 -0
  364. package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.mjs +379 -0
  365. package/dist/v1/libs/tools/TinyUriParser.cjs +217 -0
  366. package/dist/v1/libs/tools/TinyUriParser.d.mts +109 -0
  367. package/dist/v1/libs/tools/TinyUriParser.d.mts.map +1 -0
  368. package/dist/v1/libs/tools/TinyUriParser.mjs +183 -0
  369. package/dist/v1/libs/utils/TinyCloner.cjs +466 -0
  370. package/dist/v1/libs/utils/TinyCloner.d.mts +221 -0
  371. package/dist/v1/libs/utils/TinyCloner.d.mts.map +1 -0
  372. package/dist/v1/libs/utils/TinyCloner.mjs +416 -0
  373. package/dist/v1/libs/utils/TinyPromiseQueue.cjs +1 -1
  374. package/dist/v1/libs/utils/TinyPromiseQueue.d.mts +2 -2
  375. package/dist/v1/libs/utils/TinyPromiseQueue.d.mts.map +1 -1
  376. package/dist/v1/libs/utils/TinyPromiseQueue.mjs +1 -1
  377. package/dist/v1/libs/utils/TinyThrottledApi.cjs +333 -0
  378. package/dist/v1/libs/utils/TinyThrottledApi.d.mts +163 -0
  379. package/dist/v1/libs/utils/TinyThrottledApi.d.mts.map +1 -0
  380. package/dist/v1/libs/utils/TinyThrottledApi.mjs +294 -0
  381. package/dist/v1/libs/worker/browser/TinyWebWorker.cjs +342 -0
  382. package/dist/v1/libs/worker/browser/TinyWebWorker.d.mts +97 -0
  383. package/dist/v1/libs/worker/browser/TinyWebWorker.d.mts.map +1 -0
  384. package/dist/v1/libs/worker/browser/TinyWebWorker.mjs +305 -0
  385. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.cjs +346 -0
  386. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.d.mts +127 -0
  387. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.d.mts.map +1 -0
  388. package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.mjs +304 -0
  389. package/dist/v1/regexp/Email.cjs +185 -0
  390. package/dist/v1/regexp/Email.d.mts +73 -0
  391. package/dist/v1/regexp/Email.d.mts.map +1 -0
  392. package/dist/v1/regexp/Email.mjs +153 -0
  393. package/dist/v1/regexp/Glob.cjs +293 -0
  394. package/dist/v1/regexp/Glob.d.mts +45 -0
  395. package/dist/v1/regexp/Glob.d.mts.map +1 -0
  396. package/dist/v1/regexp/Glob.mjs +260 -0
  397. package/dist/v1/regexp/Ipv4.cjs +57 -0
  398. package/dist/v1/regexp/Ipv4.d.mts +29 -0
  399. package/dist/v1/regexp/Ipv4.d.mts.map +1 -0
  400. package/dist/v1/regexp/Ipv4.mjs +45 -0
  401. package/dist/v1/regexp/Ipv6.cjs +67 -0
  402. package/dist/v1/regexp/Ipv6.d.mts +29 -0
  403. package/dist/v1/regexp/Ipv6.d.mts.map +1 -0
  404. package/dist/v1/regexp/Ipv6.mjs +54 -0
  405. package/dist/v1/regexp/SegmentExtractor.cjs +145 -0
  406. package/dist/v1/regexp/SegmentExtractor.d.mts +91 -0
  407. package/dist/v1/regexp/SegmentExtractor.d.mts.map +1 -0
  408. package/dist/v1/regexp/SegmentExtractor.mjs +116 -0
  409. package/dist/v1/regexp/UrlDetector.cjs +125 -0
  410. package/dist/v1/regexp/UrlDetector.d.mts +67 -0
  411. package/dist/v1/regexp/UrlDetector.d.mts.map +1 -0
  412. package/dist/v1/regexp/UrlDetector.mjs +102 -0
  413. package/dist/v1/regexp/Username/index.cjs +233 -0
  414. package/dist/v1/regexp/Username/index.d.mts +77 -0
  415. package/dist/v1/regexp/Username/index.d.mts.map +1 -0
  416. package/dist/v1/regexp/Username/index.mjs +199 -0
  417. package/dist/v1/regexp/Username/jsDoc.cjs +2 -0
  418. package/dist/v1/regexp/Username/jsDoc.d.mts +57 -0
  419. package/dist/v1/regexp/Username/jsDoc.d.mts.map +1 -0
  420. package/dist/v1/regexp/Username/jsDoc.mjs +18 -0
  421. package/dist/v1/regexp/Username/templates/BlueSky.cjs +56 -0
  422. package/dist/v1/regexp/Username/templates/BlueSky.d.mts +35 -0
  423. package/dist/v1/regexp/Username/templates/BlueSky.d.mts.map +1 -0
  424. package/dist/v1/regexp/Username/templates/BlueSky.mjs +52 -0
  425. package/dist/v1/regexp/Username/templates/Discord.cjs +505 -0
  426. package/dist/v1/regexp/Username/templates/Discord.d.mts +209 -0
  427. package/dist/v1/regexp/Username/templates/Discord.d.mts.map +1 -0
  428. package/dist/v1/regexp/Username/templates/Discord.mjs +458 -0
  429. package/dist/v1/regexp/Username/templates/MatrixProtocol.cjs +143 -0
  430. package/dist/v1/regexp/Username/templates/MatrixProtocol.d.mts +70 -0
  431. package/dist/v1/regexp/Username/templates/MatrixProtocol.d.mts.map +1 -0
  432. package/dist/v1/regexp/Username/templates/MatrixProtocol.mjs +128 -0
  433. package/dist/v1/regexp/Username/templates/deprecated/Discord.cjs +24 -0
  434. package/dist/v1/regexp/Username/templates/deprecated/Discord.d.mts +17 -0
  435. package/dist/v1/regexp/Username/templates/deprecated/Discord.d.mts.map +1 -0
  436. package/dist/v1/regexp/Username/templates/deprecated/Discord.mjs +20 -0
  437. package/dist/v1/regexp/Username/templates/index.cjs +11 -0
  438. package/dist/v1/regexp/Username/templates/index.d.mts +5 -0
  439. package/dist/v1/regexp/Username/templates/index.d.mts.map +1 -0
  440. package/dist/v1/regexp/Username/templates/index.mjs +4 -0
  441. package/dist/v1/regexp/index.cjs +41 -0
  442. package/dist/v1/regexp/index.d.mts +9 -0
  443. package/dist/v1/regexp/index.d.mts.map +1 -0
  444. package/dist/v1/regexp/index.mjs +8 -0
  445. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.cjs +64 -0
  446. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.d.mts +11 -0
  447. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.d.mts.map +1 -0
  448. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.mjs +51 -0
  449. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.cjs +66 -0
  450. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.d.mts +11 -0
  451. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.d.mts.map +1 -0
  452. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.mjs +51 -0
  453. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.cjs +39 -0
  454. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.d.mts +11 -0
  455. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.d.mts.map +1 -0
  456. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.mjs +28 -0
  457. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.cjs +494 -0
  458. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.d.mts +142 -0
  459. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.d.mts.map +1 -0
  460. package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.mjs +445 -0
  461. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.cjs +30 -4
  462. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.d.mts +5 -2
  463. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.d.mts.map +1 -1
  464. package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.mjs +29 -5
  465. package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.cjs +135 -0
  466. package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.d.mts +83 -0
  467. package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.d.mts.map +1 -0
  468. package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.mjs +120 -0
  469. package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.cjs +127 -0
  470. package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.d.mts +95 -0
  471. package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.d.mts.map +1 -0
  472. package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.mjs +109 -0
  473. package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.cjs +83 -0
  474. package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.d.mts +46 -0
  475. package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.d.mts.map +1 -0
  476. package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.mjs +71 -0
  477. package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.cjs +493 -0
  478. package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.d.mts +67 -0
  479. package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.d.mts.map +1 -0
  480. package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.mjs +399 -0
  481. package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.cjs +35 -0
  482. package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.d.mts +6 -0
  483. package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.d.mts.map +1 -0
  484. package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.mjs +29 -0
  485. package/docs/info/RegExp.md +74 -0
  486. package/docs/v1/Exports.md +101 -0
  487. package/docs/v1/README.md +113 -15
  488. package/docs/v1/basics/asyncReplace.md +2 -0
  489. package/docs/v1/basics/browserDetector.md +28 -11
  490. package/docs/v1/basics/crypto.md +85 -0
  491. package/docs/v1/basics/deprecated/html.md +2 -0
  492. package/docs/v1/basics/deprecated/objFilter.md +2 -0
  493. package/docs/v1/basics/html.md +2 -0
  494. package/docs/v1/basics/objChecker.md +55 -0
  495. package/docs/v1/basics/objFilter.md +57 -86
  496. package/docs/v1/basics/promiseUtils.md +12 -3
  497. package/docs/v1/basics/text.md +0 -1
  498. package/docs/v1/libs/array/TinyArrayComparator.md +50 -39
  499. package/docs/v1/libs/fs/TinyFS.md +752 -0
  500. package/docs/v1/libs/fs/TinyOPFSFileSystem.md +495 -0
  501. package/docs/v1/libs/fs/TinyStorageBucketFileSystem.md +407 -0
  502. package/docs/v1/libs/plugin/TinyPlugin.md +441 -0
  503. package/docs/v1/libs/plugin/TinyVersion.md +145 -0
  504. package/docs/v1/libs/router/TinyRouter.md +216 -0
  505. package/docs/v1/libs/storage/TinyMapCache.md +219 -0
  506. package/docs/v1/libs/storage/TinySetMapDatabase.md +478 -0
  507. package/docs/v1/libs/sw/browser/TinyNotificationAdapter.md +280 -0
  508. package/docs/v1/libs/sw/browser/TinyPushManager.md +782 -0
  509. package/docs/v1/libs/sw/browser/TinyServiceWorker.md +365 -0
  510. package/docs/v1/libs/sw/browser/plugins/TabManager.md +133 -0
  511. package/docs/v1/libs/sw/service/TinyPushRouter.md +314 -0
  512. package/docs/v1/libs/sw/service/TinyServiceWorkerEngine.md +748 -0
  513. package/docs/v1/libs/sw/service/plugins/GlobBypassPlugin.md +229 -0
  514. package/docs/v1/libs/sw/service/plugins/GlobCachePlugin.md +91 -0
  515. package/docs/v1/libs/sw/service/plugins/Ping.md +36 -0
  516. package/docs/v1/libs/sw/service/plugins/TabManager.md +64 -0
  517. package/docs/v1/libs/sw/service/plugins/ViteFileDetector.md +92 -0
  518. package/docs/v1/libs/sw/service/shared/TinyPushPayload.md +316 -0
  519. package/docs/v1/libs/text/TinyI18.md +80 -56
  520. package/docs/v1/libs/tools/TinyBrowserMonitor.md +170 -0
  521. package/docs/v1/libs/tools/TinyDebugger.md +117 -1
  522. package/docs/v1/libs/tools/TinyHtmlTagRegexBuilder.md +141 -0
  523. package/docs/v1/libs/tools/TinyHttpResponseRegistry.md +129 -0
  524. package/docs/v1/libs/tools/TinyPasswordValidator.md +153 -0
  525. package/docs/v1/libs/tools/TinyPkgExportValidator.md +45 -1
  526. package/docs/v1/libs/tools/TinySiteMap.md +134 -0
  527. package/docs/v1/libs/tools/TinySiteMapStream.md +97 -0
  528. package/docs/v1/libs/tools/TinyURLSecurityVerifier.md +146 -0
  529. package/docs/v1/libs/tools/TinyUriParser/Discord.md +374 -0
  530. package/docs/v1/libs/tools/TinyUriParser/MatrixProtocol.md +54 -0
  531. package/docs/v1/libs/tools/TinyUriParser.md +128 -0
  532. package/docs/v1/libs/utils/TinyCloner.md +126 -0
  533. package/docs/v1/libs/utils/TinyPromiseQueue.md +1 -1
  534. package/docs/v1/libs/utils/TinyThrottledApi.md +219 -0
  535. package/docs/v1/libs/worker/browser/TinyWebWorker.md +331 -0
  536. package/docs/v1/libs/worker/engine/TinyWebWorkerEngine.md +137 -0
  537. package/docs/v1/regexp/Email.md +127 -0
  538. package/docs/v1/regexp/Glob.md +155 -0
  539. package/docs/v1/regexp/IPv4.md +103 -0
  540. package/docs/v1/regexp/IPv6.md +122 -0
  541. package/docs/v1/regexp/SegmentExtractor.md +120 -0
  542. package/docs/v1/regexp/UrlDetector.md +117 -0
  543. package/docs/v1/regexp/Username/Base.md +131 -0
  544. package/docs/v1/regexp/Username/Discord.md +267 -0
  545. package/docs/v1/regexp/Username/MatrixProtocol.md +131 -0
  546. package/docs/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters.md +569 -0
  547. package/docs/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.md +19 -7
  548. package/docs/v1/webTemplates/media/MediaValidator/v1/Browser.md +123 -0
  549. package/docs/v1/webTemplates/media/MediaValidator/v1/Node.md +136 -0
  550. package/docs/v1/webTemplates/multiformats/14.0/IPFSHasher.md +310 -0
  551. package/docs/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.md +131 -0
  552. package/docs/v1/webTemplates/vite/7.3/plugins/githubUtils.md +50 -0
  553. package/package.json +303 -13
  554. package/types/EventEmitter.d.ts +48 -0
  555. package/dist/v1/libs/text/TinyI18.d.mts.map +0 -1
@@ -0,0 +1 @@
1
+ (()=>{"use strict";const e={cw:e=>{var t;return()=>{if(e){var r=e;e=0,t={exports:{}},r.call(t.exports,t,t.exports)}return t.exports}},d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};e.d(t,{TinyRouter:()=>y});var r=e.cw(function(e,t){var r,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var n=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise(function(r,o){function i(r){e.removeListener(t,n),o(r)}function n(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}y(e,t,n,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,i)})},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var a=10;function h(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?s.defaultMaxListeners:e._maxListeners}function d(e,t,r,o){var i,n,s,a;if(h(r),void 0===(n=e._events)?(n=e._events=Object.create(null),e._eventsCount=0):(void 0!==n.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),n=e._events),s=n[t]),void 0===s)s=n[t]=r,++e._eventsCount;else if("function"==typeof s?s=n[t]=o?[r,s]:[s,r]:o?s.unshift(r):s.push(r),(i=u(e))>0&&s.length>i&&!s.warned){s.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=s.length,a=d,console&&console.warn&&console.warn(a)}return e}function 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 g(e,t,r){var o={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(o);return i.listener=r,o.wrapFn=i,i}function f(e,t,r){var o=e._events;if(void 0===o)return[];var i=o[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):p(i,i.length)}function c(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),o=0;o<t;++o)r[o]=e[o];return r}function y(e,t,r,o){if("function"==typeof e.on)o.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(n){o.once&&e.removeEventListener(t,i),r(n)})}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||n(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var o="error"===e,n=this._events;if(void 0!==n)o=o&&void 0===n.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 h=n[e];if(void 0===h)return!1;if("function"==typeof h)i(h,this,t);else{var u=h.length,d=p(h,u);for(r=0;r<u;++r)i(d[r],this,t)}return!0},s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)},s.prototype.once=function(e,t){return h(t),this.on(e,g(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return h(t),this.prependListener(e,g(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,o,i,n,s;if(h(t),void 0===(o=this._events))return this;if(void 0===(r=o[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete o[e],o.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,n=r.length-1;n>=0;n--)if(r[n]===t||r[n].listener===t){s=r[n].listener,i=n;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&&(o[e]=r[0]),void 0!==o.removeListener&&this.emit("removeListener",e,s||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,o;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,n=Object.keys(r);for(o=0;o<n.length;++o)"removeListener"!==(i=n[o])&&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(o=t.length-1;o>=0;o--)this.removeListener(e,t[o]);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):c.call(e,t)},s.prototype.listenerCount=c,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}}),o={};e.r(o),e.d(o,{q:()=>n,N:()=>s});var i={};e.r(i),e.d(i,{makeSegmentExtractor:()=>n,segmentExtractorV1:()=>s});const n=(e,t,r)=>{if(null===e||"string"!=typeof e&&!(e instanceof RegExp))throw new TypeError("The searchValue must be a string or a RegExp.");if("function"!=typeof t)throw new TypeError("The replaceValue must be a function.");if("object"!=typeof r||null===r)throw new TypeError("The errorConfig must be an object.");if("string"!=typeof r.pathPatternErrorMsg)throw new TypeError("The errorConfig.pathPatternErrorMsg property must be a string.");return o=>{if("string"!=typeof o)throw new TypeError(r.pathPatternErrorMsg);let i=!1;const n=[],s=o.replace(e,(e,...r)=>t(n,e,...r)),a=new RegExp(`^${s}$`);return{regex:a,paramNames:n,exec:e=>{const t={},r=e.match(a);return i=!0,r?(n.forEach((e,o)=>{t[e]=decodeURIComponent(r[o+1])}),{params:t,match:!0}):{params:t,match:!1}}}}},s=n(/:([^/]+)/g,(e,t,r)=>(e.push(r),"([^/]+)"),{pathPatternErrorMsg:'The argument must be a string (e.g., "/user/:id")'});r();const a="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:null,h="undefined"!=typeof document?document:null,u=["chrome","firefox","ie","edge","safari","opera","yandex","other"];const d=r().EventEmitter,l=class extends d{#e;#t;#r=null;#o;#i;#n;#s;#a=new Map([["log",""],["info",""],["warn",""],["error",""],["debug",""],["main_class",""],["sub_class",""],["reset",""],["black",""],["red",""],["green",""],["yellow",""],["blue",""],["magenta",""],["cyan",""],["white",""],["gray",""]]);#h=new Map([["log","[_log_LOG_reset_]"],["info","[_info_INFO_reset_]"],["warn","[_warn_WARN_reset_]"],["error","[_error_ERROR_reset_]"],["debug","[_debug_DEBUG_reset_]"]]);constructor({logger:e,id:t,debugMode:r,canEmitLogs:o=!1,useLogColors:i=!1,autoHideId:n=!1}){if(super(),null===(s=e)||"object"!=typeof s||Array.isArray(s))throw new TypeError("Logger must be an object that implements the Console interface.");var s;if("string"!=typeof t)throw new TypeError("Logger instance id must be a string.");if("boolean"!=typeof r)throw new TypeError("debugMode must be a boolean.");if("boolean"!=typeof o)throw new TypeError("canEmitLogs must be a boolean.");if("boolean"!=typeof i)throw new TypeError("useLogColors must be a boolean.");if("boolean"!=typeof n)throw new TypeError("autoHideId must be a boolean.");this.#t=t,this.#e=e,this.#i=r,this.#o=o,this.#s=n,this.#n="firefox"!==function(e=[]){const t=function(e=[]){if(!Array.isArray(e))throw new TypeError('The "disable" argument must be an array.');for(const t of e)if(!u.includes(t))throw new TypeError(`Invalid browser name provided in disable array: ${t}`);const t={chrome:0,firefox:0,ie:0,edge:0,safari:0,opera:0,yandex:0,other:0};t[function(){if("undefined"==typeof navigator)return"other";const e=navigator.userAgent;return-1!==e.indexOf("Chrome")?"chrome":-1!==e.indexOf("Firefox")?"firefox":-1!==e.indexOf("MSIE")?"ie":-1!==e.indexOf("Edge")?"edge":-1!==e.indexOf("Safari")?"safari":-1!==e.indexOf("Opera")?"opera":-1!==e.indexOf("YaBrowser")?"yandex":"other"}()]++;const r=function(){const e=a?.getComputedStyle?(Array.prototype.slice.call(a.getComputedStyle(document.documentElement,"")).join("").match(/-(moz|webkit|ms)-/)??["",""])[1]:"";return"moz"===e?"gecko":"webkit"===e?"webkit":"ms"===e?"trident":"other"}();"gecko"===r?e.indexOf("firefox")<0&&t.firefox++:"webkit"===r?(e.indexOf("chrome")<0&&t.chrome++,e.indexOf("safari")<0&&t.safari++,e.indexOf("opera")<0&&t.opera++,e.indexOf("edge")<0&&t.edge++):"trident"===r?e.indexOf("ie")<0&&t.ie++:e.indexOf("other")<0&&t.other++;const o=function(){const e=!!a?.opr&&!!opr.addons||!!a?.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,r=!!a?.HTMLElement&&/constructor/i.test(a.HTMLElement)||"[object SafariRemoteNotification]"===(!a.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),o=!!h?.documentMode,i=!o&&!!a?.StyleMedia,n=!!a?.chrome;return{isOpera:e,isFirefox:t,isSafari:r,isIE:o,isEdge:i,isChrome:n,isBlink:(n||e)&&!!a?.CSS}}();return o.isOpera&&e.indexOf("opera")<0&&t.opera++,o.isFirefox&&e.indexOf("firefox")<0&&t.firefox++,o.isSafari&&e.indexOf("safari")<0&&t.safari++,o.isIE&&e.indexOf("ie")<0&&t.ie++,o.isEdge&&e.indexOf("edge")<0&&t.edge++,o.isChrome&&e.indexOf("chrome")<0&&t.chrome++,t}(e);return Object.keys(t).reduce((e,r)=>t[r]>t[e]?r:e)}()&&i,this.log("info","Emit logs of debug mode set to: "+(this.#i?"ON":"OFF")),this.log("info","Custom logger assigned.")}get logId(){return this.#t}get logSubId(){if("string"!=typeof this.#r)throw new Error('logSubId has not been set yet. Assign a string to "logSubId" before reading it.');return this.#r}set logSubId(e){if("string"!=typeof e)throw new TypeError(`logSubId must be a string. Received: ${typeof e}.`);if(null!==this.#r)throw new Error(`logSubId is already set to "${this.#r}" and cannot be reassigned.`);this.#r=e,this.emit("setLogSubId",e)}get canEmitLogs(){return this.#o}get useLogColors(){return this.#n}set useLogColors(e){if("boolean"!=typeof e)throw new TypeError("useLogColors must be a boolean.");this.#n=e,this.log("info","Log Colors usage mode set to: "+(this.#n?"ON":"OFF")),this.emit("setUseLogColors",e)}get debugMode(){return this.#i}set debugMode(e){if("boolean"!=typeof e)throw new TypeError("debugMode must be a boolean.");this.#i=e,this.log("info","Debug mode set to: "+(this.#i?"ON":"OFF")),this.emit("setDebugMode",e)}_addLogColor(e,t){this.#a.set(e,t)}_removeLogColor(e){this.#a.delete(e)}_addLogPrefix(e,t){this.#h.set(e,t)}_removeLogPrefix(e){this.#h.delete(e)}#u(e){if("string"!=typeof e)return e;let t=e;for(const[e,r]of this.#h){const o=new RegExp(`\\:${e}\\:`,"g");t=t.replace(o,r)}for(const[e,r]of this.#a){const o=new RegExp(`\\_${e}\\_`,"g");t=t.replace(o,this.#n?r:"")}return t}_applyLogFormatting(e){return this.#u(e)}logClear(){if(this.#i)return this.#o&&this.emit("debug:clear"),this.#e.clear?this.#e.clear():console.clear()}logGroupEnd(){if(this.#i)return this.#o&&this.emit("debug:groupEnd"),this.#e.groupEnd?this.#e.groupEnd():console.groupEnd()}logLabel(e,t){if(!this.#i)return;const r=["count","countReset","time","timeEnd","profile","profileEnd","timeStamp"];if(!r.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${r.join(", ")}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError("The label must be a string.");const o=this.#e[e]?this.#e[e]:console[e];if(!o)throw new TypeError(`The log type "${e}" is not supported by the provided logger or console.`);return this.#o&&this.emit("debug:logLabel",e,t),o(t)}logTimeLabel(e,...t){if(this.#i)return this.#o&&this.emit("debug:timeLog",e,...t),this.#e.timeLog?this.#e.timeLog(e,...t):console.timeLog(e,...t)}logAssert(e,...t){if(this.#i)return this.#o&&this.emit("debug:assert",e,...t),this.#e.assert?this.#e.assert(e,...t):console.assert(e,...t)}logDir(e,t){if(this.#i)return this.#o&&this.emit("debug:dir",e,t),this.#e.dir?this.#e.dir(e,t):console.dir(e,t)}logTable(e,t){if(this.#i){if(!(void 0===t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("Properties must be an array of strings.");return this.#o&&this.emit("debug:table",e,t),this.#e.table?this.#e.table(e,t):console.table(e,t)}}log(e,t,...r){if(!this.#i)return;const o=["log","info","warn","error","debug","dirxml","group","groupCollapsed","trace"];if(!o.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${o.join(", ")}`);if("string"!=typeof t)throw new TypeError("The message must be a string.");let i=this.#t,n=this.#r??"",s=t;const a=!this.#s||"string"!=typeof this.#r;i=a?this.#u(i):"",n&&(n=this.#u(n)),s=this.#u(s);const h=`${i}${n?a?` ${n}`:n:""}`,u=this.#e[e]?this.#e[e]:console[e];return u?(this.#o&&this.emit("debug:log",h,s,...r),u(h,s,...r)):(this.#o&&this.emit("debug:log",h,s,...r),console.log(h,s,...r))}#d(e,t){const[r="",...o]=t;return"string"==typeof r?this.log(e,r,...o):this.log(e,"",r,...o)}toConsole(){return{log:(...e)=>this.#d("log",e),info:(...e)=>this.#d("info",e),warn:(...e)=>this.#d("warn",e),error:(...e)=>this.#d("error",e),debug:(...e)=>this.#d("debug",e),dirxml:(...e)=>this.#d("dirxml",e),group:(...e)=>this.#d("group",e),groupCollapsed:(...e)=>this.#d("groupCollapsed",e),trace:(...e)=>this.#d("trace",e),assert:(e,...t)=>this.logAssert(e,...t),dir:(e,t)=>this.logDir(e,t),table:(e,t)=>this.logTable(e,t),clear:()=>this.logClear(),groupEnd:()=>this.logGroupEnd(),count:e=>this.logLabel("count",e),countReset:e=>this.logLabel("countReset",e),time:e=>this.logLabel("time",e),timeEnd:e=>this.logLabel("timeEnd",e),timeLog:(e,...t)=>this.logTimeLabel(e,...t),timeStamp:e=>this.logLabel("timeStamp",e),profile:e=>this.logLabel("profile",e),profileEnd:e=>this.logLabel("profileEnd",e)}}},g=class{#l=[];#g=!1;#f={};#c=new Set;isRunning(){return this.#g}async#p(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:r,reject:o,delay:i,id:n}=e;try{if(n&&this.#c.has(n))return o(new Error("The function was canceled on TinyPromiseQueue.")),this.#c.delete(n),this.#g=!1,void this.#y();i&&n&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#f[n],e(null)},i);this.#f[n]=t}),r(await t())}catch(e){o(e)}finally{this.#g=!1,this.#y()}}}async#m(){const e=[];for(;this.#l.length&&"POINT_MARKER"===this.#l[0]?.marker;)e.push(this.#l.shift());if(0===e.length)return this.#g=!1,void this.#y();await Promise.all(e.map(({task:e,resolve:t,reject:r,id:o})=>new Promise(async i=>{if(o&&this.#c.has(o))return this.#c.delete(o),r(new Error("The function was canceled on TinyPromiseQueue.")),void i(!0);await e().then(t).catch(r),i(!0)}))),this.#g=!1,this.#y()}async#y(){if(!this.#g&&0!==this.#l.length)if(this.#g=!0,"string"!=typeof this.#l[0]?.marker||"POINT_MARKER"!==this.#l[0]?.marker){const e=this.#l.shift();this.#p(e)}else this.#m()}getIndexById(e){return this.#l.findIndex(t=>t.id===e)}getQueuedIds(){return this.#l.map((e,t)=>({index:t,id:e.id})).filter(e=>"string"==typeof e.id)}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#l.length||t>=this.#l.length)return;const[r]=this.#l.splice(e,1);this.#l.splice(t,0,r)}async enqueuePoint(e,t){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&"string"!=typeof t)throw new Error('The "id" parameter must be a string.');return this.#g?new Promise((r,o)=>{this.#l.push({marker:"POINT_MARKER",task:e,resolve:r,reject:o,id:t}),this.#y()}):e()}enqueue(e,t,r){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&("number"!=typeof t||t<0))return Promise.reject(new Error("Delay must be a positive number or undefined."));if(void 0!==r&&"string"!=typeof r)throw new Error('The "id" parameter must be a string.');return new Promise((o,i)=>{this.#l.push({task:e,resolve:o,reject:i,id:r,delay:t}),this.#y()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#f&&(clearTimeout(this.#f[e]),delete this.#f[e],t=!0);const r=this.getIndexById(e);if(-1!==r){const[e]=this.#l.splice(r,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#c.add(e),t}},f=e=>{if(e)throw new Error("This TinyRouter instance has been destroyed and can no longer be used.")};const{q:c,N:p}=o,y=class extends l{static SegmentExtractor=i;#w=[];#b;#v;#E=!1;#L;#x;#T=[];#R;#C=-1;#l=new g;#_=!1;constructor(e={}){if("object"!=typeof e||null===e)throw new TypeError("Options must be a non-null object.");if(void 0!==e.detectHistoryChange&&"boolean"!=typeof e.detectHistoryChange)throw new TypeError("detectHistoryChange must be a boolean.");if(void 0!==e.onRouteChanged&&"function"!=typeof e.onRouteChanged)throw new TypeError("onRouteChanged must be a function.");if(void 0!==e.onRouteNotFound&&"function"!=typeof e.onRouteNotFound)throw new TypeError("onRouteNotFound must be a function.");if(void 0!==e.historyLimit&&(!Number.isInteger(e.historyLimit)||e.historyLimit<-1))throw new TypeError("historyLimit must be an integer and greater than or equal to -1.");super({id:"[_main_class_TinyRouter_reset_]",logger:e.logger??console,debugMode:e.debugMode??!1,useLogColors:e.useLogColors??!1}),this.#b=e.onRouteChanged||(()=>{}),this.#v=e.onRouteNotFound||(()=>{}),this.#x=e.detectHistoryChange??!0,this.#C=-1,this.#R=e.historyLimit??0,this.#L=this.#O.bind(this)}get isDestroyed(){return this.#_}get historyIndex(){return f(this.#_),this.#C}get historyLimit(){return f(this.#_),this.#R}get detectHistoryChange(){return f(this.#_),this.#x}set detectHistoryChange(e){if(f(this.#_),"boolean"!=typeof e)throw new TypeError("detectHistoryChange must be a boolean.");this.#x=e}get onRouteChanged(){return f(this.#_),this.#b}set onRouteChanged(e){if(f(this.#_),"function"!=typeof e)throw new TypeError("onRouteChanged must be a function.");this.#b=e}get onRouteNotFound(){return f(this.#_),this.#v}set onRouteNotFound(e){if(f(this.#_),"function"!=typeof e)throw new TypeError("onRouteNotFound must be a function.");this.#v=e}get started(){return f(this.#_),this.#E}get size(){return f(this.#_),this.#w.length}get routes(){return f(this.#_),this.#w.map(e=>e.segmentExtractor.pattern??"")}get history(){return f(this.#_),this.#T.map(e=>({...e}))}set history(e){if(f(this.#_),!Array.isArray(e))throw new TypeError("History data must be an array.");for(const t of e){if("object"!=typeof t||null===t)throw new TypeError("Each history entry must be an object.");if("string"!=typeof t.path)throw new TypeError('Each history entry must have a string "path" property.');if("number"!=typeof t.timestamp)throw new TypeError('Each history entry must have a number "timestamp" property.')}this.#T=e.map(e=>({...e})),this.log("info","History has been successfully imported.")}add(e,t){f(this.#_);let r={};if("string"==typeof e)r=p(e),r.pattern=e;else{if("object"!=typeof e||null===e)throw new TypeError('The first argument must be a string (e.g., "/user/:id") or an object of SegmentExtractor maker.');if("function"==typeof e.callback){const t=e;t.callback(t.pattern)}else{const t=e;r=c(t.searchValue,t.replaceValue,t.errorConfig)(t.pattern)}r.pattern=e.pattern}if("function"!=typeof t)throw new TypeError("The callback must be a function.");if(this.has(r.pattern))throw new Error(`Route with pattern "${r.pattern}" is already registered.`);this.#w.push({segmentExtractor:r,callback:t}),this.emit("RouteAdded",r.pattern),this.log("info",`New route registered: ${r.pattern}`)}remove(e){if(f(this.#_),"string"!=typeof e)throw new TypeError("pathPattern must be a string.");const t=this.#w.length;this.#w=this.#w.filter(t=>t.segmentExtractor.pattern!==e),this.#w.length===t?this.log("warn",`Attempted to remove non-existent route: ${e}`):(this.emit("RouteRemoved",e),this.log("info",`Route removed: ${e}`))}has(e){if(f(this.#_),"string"!=typeof e)throw new TypeError("pathPattern must be a string.");return this.#w.some(t=>t.segmentExtractor.pattern===e)}async navigate(e,t={}){f(this.#_),window.location.pathname+window.location.search!==e&&(window.history.pushState(t,"",e),await this.#l.enqueue(()=>this.#O()),this.log("info",`Navigated to: ${e}`))}start(){return this.#E?new Promise((e,t)=>t(new Error("Router has already been started."))):(this.#L=()=>{const e=window.location.pathname;if(0!==this.#R){const t=this.#T.findIndex(t=>t.path===e);-1!==t&&(this.#C=t)}return this.#O()},window.addEventListener("popstate",this.#L),this.#E=!0,this.#l.enqueue(()=>new Promise((e,t)=>{let r;try{f(this.#_)}catch(e){r=e}if(r)return t(r);this.#O().then(()=>{this.emit("RouterStarted"),this.log("info","Router started successfully."),e()}).catch(t)})))}stop(){f(this.#_),window.removeEventListener("popstate",this.#L),this.#E=!1,this.clearAll(),this.emit("RouterStopped"),this.log("info","Router stopped and event listeners removed.")}async go(e){if(f(this.#_),!this.#E)return this.log("warn","Attempted to navigate while the router is stopped."),!1;if(!Number.isInteger(e))throw new TypeError('The "delta" parameter must be an integer.');if(0!==this.#R){const t=this.#C+e;if(t>=0&&t<this.#T.length){const e=this.#T[t].path;return window.history.pushState(null,"",e),await this.#l.enqueue(()=>this.#O()),!0}return!1}if(!this.#x)return window.history.go(e),this.log("info",`Navigation command: go(${e}) (detection disabled)`),!0;const t=window.location.pathname+window.location.search;return this.#l.enqueue(()=>new Promise(r=>{const o=()=>{window.removeEventListener("popstate",o);const e=window.location.pathname+window.location.search;r(t!==e)};window.addEventListener("popstate",o),setTimeout(()=>{window.removeEventListener("popstate",o);const e=window.location.pathname+window.location.search;r(t!==e)},100),window.history.go(e),this.log("info",`Navigation command: go(${e})`)}))}async back(){return this.go(-1)}async forward(){return this.go(1)}#I(e){f(this.#_),0!==this.#R&&(this.#C>=0&&this.#T[this.#C].path===e||(this.#C>=0&&(this.#T=this.#T.slice(0,this.#C+1)),this.#T.push({path:e,timestamp:Date.now()}),this.#C++,this.#R>0&&this.#T.length>this.#R&&(this.#T.shift(),this.#C--),this.emit("HistoryRecorded",{...this.#T[this.#C]})))}async#O(){f(this.#_);const e=window.location.pathname,t=window.location.search,r=new URLSearchParams(t);for(const t of this.#w){const{params:o,match:i}=t.segmentExtractor.exec(e);if(i){const i={path:e,params:o,query:r};return this.#I(e),this.emit("BeforeRouteChanged",i),await t.callback(i),this.#b(i),this.emit("AfterRouteChanged",i),void this.log("info",`Route matched: ${e}`)}}const o={path:e,query:r};this.#v(o),this.emit("RouteNotFound",o),this.log("warn",`No route matched the current URL: ${e}`)}removeHistoryEntry(e){if(f(this.#_),!Number.isInteger(e))throw new TypeError("The index must be an integer.");if(e<0||e>=this.#T.length)throw new RangeError("The provided index is out of bounds.");this.#T.splice(e,1),this.emit("HistoryEntryRemoved",e),this.log("info",`History entry at index ${e} was removed.`)}clearHistory(){f(this.#_),this.#T=[],this.emit("HistoryCleared"),this.log("info","Navigation history has been cleared.")}clear(){f(this.#_),this.#w=[],this.emit("RoutesCleared"),this.log("info","All routes have been cleared.")}clearAll(){f(this.#_),this.clear(),this.clearHistory()}destroy(){this.#_||(this.stop(),this.#_=!0)}};window.TinyRouter=t.TinyRouter})();
@@ -0,0 +1 @@
1
+ (()=>{"use strict";const e={cw:e=>{var t;return()=>{if(e){var r=e;e=0,t={exports:{}},r.call(t.exports,t,t.exports)}return t.exports}},d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyServiceWorker:()=>_});var r=e.cw(function(e,t){var r,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function n(){n.init.call(this)}e.exports=n,e.exports.once=function(e,t){return new Promise(function(r,i){function s(r){e.removeListener(t,o),i(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",s),r([].slice.call(arguments))}p(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&p(e,"error",t,{once:!0})}(e,s)})},n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var a=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function h(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function d(e,t,r,i){var s,o,n,a;if(l(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),n=o[t]),void 0===n)n=o[t]=r,++e._eventsCount;else if("function"==typeof n?n=o[t]=i?[r,n]:[n,r]:i?n.unshift(r):n.push(r),(s=h(e))>0&&n.length>s&&!n.warned){n.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+n.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=n.length,a=d,console&&console.warn&&console.warn(a)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function g(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},s=c.bind(i);return s.listener=r,i.wrapFn=s,s}function u(e,t,r){var i=e._events;if(void 0===i)return[];var s=i[t];return void 0===s?[]:"function"==typeof s?r?[s.listener||s]:[s]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(s):y(s,s.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function y(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function p(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function s(o){i.once&&e.removeEventListener(t,s),r(o)})}}Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return a},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+".");a=e}}),n.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},n.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||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},n.prototype.getMaxListeners=function(){return h(this)},n.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 n;if(t.length>0&&(n=t[0]),n instanceof Error)throw n;var a=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw a.context=n,a}var l=o[e];if(void 0===l)return!1;if("function"==typeof l)s(l,this,t);else{var h=l.length,d=y(l,h);for(r=0;r<h;++r)s(d[r],this,t)}return!0},n.prototype.addListener=function(e,t){return d(this,e,t,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(e,t){return d(this,e,t,!0)},n.prototype.once=function(e,t){return l(t),this.on(e,g(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,g(this,e,t)),this},n.prototype.removeListener=function(e,t){var r,i,s,o,n;if(l(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(s=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){n=r[o].listener,s=o;break}if(s<0)return this;0===s?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,s),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,n||t)}return this},n.prototype.off=n.prototype.removeListener,n.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var s,o=Object.keys(r);for(i=0;i<o.length;++i)"removeListener"!==(s=o[i])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},n.prototype.listeners=function(e){return u(this,e,!0)},n.prototype.rawListeners=function(e){return u(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},n.prototype.listenerCount=f,n.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}});function i(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}r();const s="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:null,o="undefined"!=typeof document?document:null,n=["chrome","firefox","ie","edge","safari","opera","yandex","other"];const a=r().EventEmitter,l=class extends a{#e;#t;#r=null;#i;#s;#o;#n;#a=new Map([["log",""],["info",""],["warn",""],["error",""],["debug",""],["main_class",""],["sub_class",""],["reset",""],["black",""],["red",""],["green",""],["yellow",""],["blue",""],["magenta",""],["cyan",""],["white",""],["gray",""]]);#l=new Map([["log","[_log_LOG_reset_]"],["info","[_info_INFO_reset_]"],["warn","[_warn_WARN_reset_]"],["error","[_error_ERROR_reset_]"],["debug","[_debug_DEBUG_reset_]"]]);constructor({logger:e,id:t,debugMode:r,canEmitLogs:i=!1,useLogColors:a=!1,autoHideId:l=!1}){if(super(),null===(h=e)||"object"!=typeof h||Array.isArray(h))throw new TypeError("Logger must be an object that implements the Console interface.");var h;if("string"!=typeof t)throw new TypeError("Logger instance id must be a string.");if("boolean"!=typeof r)throw new TypeError("debugMode must be a boolean.");if("boolean"!=typeof i)throw new TypeError("canEmitLogs must be a boolean.");if("boolean"!=typeof a)throw new TypeError("useLogColors must be a boolean.");if("boolean"!=typeof l)throw new TypeError("autoHideId must be a boolean.");this.#t=t,this.#e=e,this.#s=r,this.#i=i,this.#n=l,this.#o="firefox"!==function(e=[]){const t=function(e=[]){if(!Array.isArray(e))throw new TypeError('The "disable" argument must be an array.');for(const t of e)if(!n.includes(t))throw new TypeError(`Invalid browser name provided in disable array: ${t}`);const t={chrome:0,firefox:0,ie:0,edge:0,safari:0,opera:0,yandex:0,other:0};t[function(){if("undefined"==typeof navigator)return"other";const e=navigator.userAgent;return-1!==e.indexOf("Chrome")?"chrome":-1!==e.indexOf("Firefox")?"firefox":-1!==e.indexOf("MSIE")?"ie":-1!==e.indexOf("Edge")?"edge":-1!==e.indexOf("Safari")?"safari":-1!==e.indexOf("Opera")?"opera":-1!==e.indexOf("YaBrowser")?"yandex":"other"}()]++;const r=function(){const e=s?.getComputedStyle?(Array.prototype.slice.call(s.getComputedStyle(document.documentElement,"")).join("").match(/-(moz|webkit|ms)-/)??["",""])[1]:"";return"moz"===e?"gecko":"webkit"===e?"webkit":"ms"===e?"trident":"other"}();"gecko"===r?e.indexOf("firefox")<0&&t.firefox++:"webkit"===r?(e.indexOf("chrome")<0&&t.chrome++,e.indexOf("safari")<0&&t.safari++,e.indexOf("opera")<0&&t.opera++,e.indexOf("edge")<0&&t.edge++):"trident"===r?e.indexOf("ie")<0&&t.ie++:e.indexOf("other")<0&&t.other++;const i=function(){const e=!!s?.opr&&!!opr.addons||!!s?.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,r=!!s?.HTMLElement&&/constructor/i.test(s.HTMLElement)||"[object SafariRemoteNotification]"===(!s.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),i=!!o?.documentMode,n=!i&&!!s?.StyleMedia,a=!!s?.chrome;return{isOpera:e,isFirefox:t,isSafari:r,isIE:i,isEdge:n,isChrome:a,isBlink:(a||e)&&!!s?.CSS}}();return i.isOpera&&e.indexOf("opera")<0&&t.opera++,i.isFirefox&&e.indexOf("firefox")<0&&t.firefox++,i.isSafari&&e.indexOf("safari")<0&&t.safari++,i.isIE&&e.indexOf("ie")<0&&t.ie++,i.isEdge&&e.indexOf("edge")<0&&t.edge++,i.isChrome&&e.indexOf("chrome")<0&&t.chrome++,t}(e);return Object.keys(t).reduce((e,r)=>t[r]>t[e]?r:e)}()&&a,this.log("info","Emit logs of debug mode set to: "+(this.#s?"ON":"OFF")),this.log("info","Custom logger assigned.")}get logId(){return this.#t}get logSubId(){if("string"!=typeof this.#r)throw new Error('logSubId has not been set yet. Assign a string to "logSubId" before reading it.');return this.#r}set logSubId(e){if("string"!=typeof e)throw new TypeError(`logSubId must be a string. Received: ${typeof e}.`);if(null!==this.#r)throw new Error(`logSubId is already set to "${this.#r}" and cannot be reassigned.`);this.#r=e,this.emit("setLogSubId",e)}get canEmitLogs(){return this.#i}get useLogColors(){return this.#o}set useLogColors(e){if("boolean"!=typeof e)throw new TypeError("useLogColors must be a boolean.");this.#o=e,this.log("info","Log Colors usage mode set to: "+(this.#o?"ON":"OFF")),this.emit("setUseLogColors",e)}get debugMode(){return this.#s}set debugMode(e){if("boolean"!=typeof e)throw new TypeError("debugMode must be a boolean.");this.#s=e,this.log("info","Debug mode set to: "+(this.#s?"ON":"OFF")),this.emit("setDebugMode",e)}_addLogColor(e,t){this.#a.set(e,t)}_removeLogColor(e){this.#a.delete(e)}_addLogPrefix(e,t){this.#l.set(e,t)}_removeLogPrefix(e){this.#l.delete(e)}#h(e){if("string"!=typeof e)return e;let t=e;for(const[e,r]of this.#l){const i=new RegExp(`\\:${e}\\:`,"g");t=t.replace(i,r)}for(const[e,r]of this.#a){const i=new RegExp(`\\_${e}\\_`,"g");t=t.replace(i,this.#o?r:"")}return t}_applyLogFormatting(e){return this.#h(e)}logClear(){if(this.#s)return this.#i&&this.emit("debug:clear"),this.#e.clear?this.#e.clear():console.clear()}logGroupEnd(){if(this.#s)return this.#i&&this.emit("debug:groupEnd"),this.#e.groupEnd?this.#e.groupEnd():console.groupEnd()}logLabel(e,t){if(!this.#s)return;const r=["count","countReset","time","timeEnd","profile","profileEnd","timeStamp"];if(!r.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${r.join(", ")}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError("The label must be a string.");const i=this.#e[e]?this.#e[e]:console[e];if(!i)throw new TypeError(`The log type "${e}" is not supported by the provided logger or console.`);return this.#i&&this.emit("debug:logLabel",e,t),i(t)}logTimeLabel(e,...t){if(this.#s)return this.#i&&this.emit("debug:timeLog",e,...t),this.#e.timeLog?this.#e.timeLog(e,...t):console.timeLog(e,...t)}logAssert(e,...t){if(this.#s)return this.#i&&this.emit("debug:assert",e,...t),this.#e.assert?this.#e.assert(e,...t):console.assert(e,...t)}logDir(e,t){if(this.#s)return this.#i&&this.emit("debug:dir",e,t),this.#e.dir?this.#e.dir(e,t):console.dir(e,t)}logTable(e,t){if(this.#s){if(!(void 0===t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("Properties must be an array of strings.");return this.#i&&this.emit("debug:table",e,t),this.#e.table?this.#e.table(e,t):console.table(e,t)}}log(e,t,...r){if(!this.#s)return;const i=["log","info","warn","error","debug","dirxml","group","groupCollapsed","trace"];if(!i.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${i.join(", ")}`);if("string"!=typeof t)throw new TypeError("The message must be a string.");let s=this.#t,o=this.#r??"",n=t;const a=!this.#n||"string"!=typeof this.#r;s=a?this.#h(s):"",o&&(o=this.#h(o)),n=this.#h(n);const l=`${s}${o?a?` ${o}`:o:""}`,h=this.#e[e]?this.#e[e]:console[e];return h?(this.#i&&this.emit("debug:log",l,n,...r),h(l,n,...r)):(this.#i&&this.emit("debug:log",l,n,...r),console.log(l,n,...r))}#d(e,t){const[r="",...i]=t;return"string"==typeof r?this.log(e,r,...i):this.log(e,"",r,...i)}toConsole(){return{log:(...e)=>this.#d("log",e),info:(...e)=>this.#d("info",e),warn:(...e)=>this.#d("warn",e),error:(...e)=>this.#d("error",e),debug:(...e)=>this.#d("debug",e),dirxml:(...e)=>this.#d("dirxml",e),group:(...e)=>this.#d("group",e),groupCollapsed:(...e)=>this.#d("groupCollapsed",e),trace:(...e)=>this.#d("trace",e),assert:(e,...t)=>this.logAssert(e,...t),dir:(e,t)=>this.logDir(e,t),table:(e,t)=>this.logTable(e,t),clear:()=>this.logClear(),groupEnd:()=>this.logGroupEnd(),count:e=>this.logLabel("count",e),countReset:e=>this.logLabel("countReset",e),time:e=>this.logLabel("time",e),timeEnd:e=>this.logLabel("timeEnd",e),timeLog:(e,...t)=>this.logTimeLabel(e,...t),timeStamp:e=>this.logLabel("timeStamp",e),profile:e=>this.logLabel("profile",e),profileEnd:e=>this.logLabel("profileEnd",e)}}};class h{#c=0;#g=0;#u=0;#f=null;constructor(e){if("string"!=typeof e)throw new TypeError("[TinyVersion] Expected version to be a string, received type: "+typeof e);const t=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/),r=e=>{"string"==typeof e[1]&&(this.#c=parseInt(e[1],10)),"string"==typeof e[2]&&(this.#g=parseInt(e[2],10)),"string"==typeof e[3]&&(this.#u=parseInt(e[3],10)),"string"==typeof e[4]&&(this.#f=e[4])};if(t)r(t);else{const t=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);if(t)r(t);else{const t=e.match(/^(\d+)\.(\d+)$/);if(t)r(t);else{const t=e.match(/^(\d+)$/);if(!t)throw new Error(`[TinyVersion] Invalid version format: "${e}". Expected format: "X.Y.Z" or "X.Y.Z-tag".`);r(t)}}}}get major(){return this.#c}get minor(){return this.#g}get patch(){return this.#u}get tag(){return this.#f}isGreaterThan(e){if(!(e instanceof h))throw new TypeError("[TinyVersion] Comparison target must be an instance of TinyVersion. Received: "+typeof e);return this.#c!==e.major?this.#c>e.major:this.#g!==e.minor?this.#g>e.minor:this.#u!==e.patch?this.#u>e.patch:null===this.#f&&null!==e.tag||(null===this.#f||null!==e.tag)&&(null!==this.#f||null!==e.tag)&&(this.#f??"")>(e.tag??"")}isEqualTo(e){if(!(e instanceof h))throw new TypeError("[TinyVersion] Comparison target must be an instance of TinyVersion. Received: "+typeof e);return this.#c===e.major&&this.#g===e.minor&&this.#u===e.patch&&this.#f===e.tag}isLessThan(e){if(!(e instanceof h))throw new TypeError("[TinyVersion] Comparison target must be an instance of TinyVersion. Received: "+typeof e);return!this.isGreaterThan(e)&&!this.isEqualTo(e)}toString(){const e=`${this.#c}.${this.#g}.${this.#u}`;return this.#f?`${e}-${this.#f}`:e}}const d=h,c=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},g=c("TinyPlugin"),u=(e,t)=>t instanceof Set?t.has("*")||t.has(e):t.indexOf("*")>-1||t.indexOf(e)>-1,f=(e,t,r)=>{const s=(e,t)=>{if(!Array.isArray(t)||!t.every(e=>"string"==typeof e||"symbol"==typeof e))throw new TypeError(`The ${e} of sandbox blacklist must be an array of strings.`)};if(i(r)&&i(e?.sandboxBlacklist)){const{get:t,set:i}=e.sandboxBlacklist;void 0!==t&&(s("get",t),t.forEach(e=>r.get.add(e))),void 0!==i&&(s("set",i),i.forEach(e=>r.set.add(e)))}if(i(e?.accessControl)){const{mode:r,whitelist:o,blacklist:n,publicKey:a,cryptoAlgorithm:l,importAlgorithm:h,importKeyFormat:d}=e.accessControl;if("none"!==r&&"whitelist"!==r&&"blacklist"!==r&&"cryptographic"!==r)throw new TypeError('accessControl.mode must be "none", "whitelist", "blacklist", or "cryptographic".');if("cryptographic"===r&&"string"!=typeof a)throw new TypeError("In cryptographic mode, accessControl.publicKey must be a string (PEM format).");i(o)&&(void 0!==o.ids&&(s("whitelist ids",o.ids),o.ids.forEach(e=>t.whitelist.ids.add(e))),void 0!==o.authors&&(s("whistlist authors",o.authors),o.authors.forEach(e=>t.whitelist.authors.add(e))),void 0!==o.categories&&(s("whistlist categories",o.categories),o.categories.forEach(e=>t.whitelist.categories.add(e))),void 0!==o.tags&&(s("whistlist tags",o.tags),o.tags.forEach(e=>t.whitelist.tags.add(e)))),i(n)&&(void 0!==n.ids&&(s("blacklist ids",n.ids),n.ids.forEach(e=>t.blacklist.ids.add(e))),void 0!==n.authors&&(s("blacklist authors",n.authors),n.authors.forEach(e=>t.blacklist.authors.add(e))),void 0!==n.categories&&(s("blacklist categories",n.categories),n.categories.forEach(e=>t.blacklist.categories.add(e))),void 0!==n.tags&&(s("blacklist tags",n.tags),n.tags.forEach(e=>t.blacklist.tags.add(e)))),"string"==typeof r&&(t.mode=r),"string"==typeof a&&(t.publicKey=a),void 0!==l&&(t.cryptoAlgorithm=l),void 0!==h&&(t.importAlgorithm=h),void 0!==d&&(t.importKeyFormat=d)}},y=e=>{const t=globalThis.atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r.buffer},p=async(e,t,r,i,s,o,n)=>{const{publicKey:a,cryptoAlgorithm:l,importKeyFormat:h,importAlgorithm:d}=e,c=((e,t,r,i)=>{if("string"!=typeof e)throw new TypeError("Security Error: Cryptographic mode enabled, but pluginId is missing.");if(!Array.isArray(t))throw new TypeError("Security Error: Cryptographic mode enabled, but authors is missing.");if(!t.every(e=>"string"==typeof e))throw new TypeError("Security Error: Cryptographic mode enabled, but authors is invalid.");return JSON.stringify({id:e,authors:[...t].sort(),categories:[...r].sort(),tags:[...i].sort()})})(r,i,s,o);try{if("string"!=typeof a)throw new TypeError("Security Error: Cryptographic mode enabled, but public key is missing.");if(!("string"==typeof n||n instanceof ArrayBuffer||n instanceof Uint8Array))throw new TypeError("Security Error: Cryptographic mode enabled, but signature is invalid (must be string, ArrayBuffer, or Uint8Array).");const e=(new TextEncoder).encode(c);let i;i="spki"===h||"pkcs8"===h?(e=>{const t=e.replace(/(-----(BEGIN|END) [^-]+-----)/g,"").replace(/\s+/g,"");return y(t)})(a):"string"==typeof a?y(a):a;const s="string"==typeof n?y(n):n,o=await crypto.subtle.importKey(h,i,d,!1,["verify"]),g=await crypto.subtle.verify(l,o,s,e);return g&&t.add(r),g}catch(e){return console.error(e),!1}},w=(e,t,r,i,s,o,n,a)=>{if("cryptographic"===e)return a.has(t);if("whitelist"===e){const e=u(t,o.ids),n=r.some(e=>u(e,o.authors)),a=i.some(e=>u(e,o.categories)),l=s.some(e=>u(e,o.tags));return e||n||a||l}if("blacklist"===e){const e=u(t,n.ids),o=r.some(e=>u(e,n.authors)),a=i.some(e=>u(e,n.categories)),l=s.some(e=>u(e,n.tags));return!(e||o||a||l)}return!0},m=()=>({mode:"none",importKeyFormat:"spki",importAlgorithm:{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},cryptoAlgorithm:{name:"RSASSA-PKCS1-v1_5"},publicKey:null,whitelist:{ids:new Set,authors:new Set,categories:new Set,tags:new Set},blacklist:{ids:new Set,authors:new Set,categories:new Set,tags:new Set}}),b=(e,t,r,s,o,n,a)=>{const l=[...s],h=[...o],d=t??{get:[],set:[]},c=[...n??[],...d.get],g=[...c,...d.set,...a??[]];return i(r)&&(c.forEach(e=>r.get.add(e)),g.forEach(e=>r.set.add(e))),new Proxy(e,{get(e,t){if(h.includes(t)||h.includes("*")){const r=Reflect.get(e,t,e);return"function"==typeof r?r.bind(e):r}throw new Error(`Security Error: Access to property "${String(t)}" is denied by the sandbox.`)},set(e,t,r){if(l.includes(t)||l.includes("*"))return Reflect.set(e,t,r);throw new Error("Security Error: Cannot modify read-only properties on the plugin sandbox.")},setPrototypeOf(){throw new Error("Security Error: Prototype manipulation is forbidden.")}})};class v extends l{#y=!1;#p=new Set;#w=m();get isReady(){return this.#y}get accessControlWhitelist(){return Object.freeze({ids:Object.freeze([...this.#w.whitelist.ids]),authors:Object.freeze([...this.#w.whitelist.authors]),categories:Object.freeze([...this.#w.whitelist.categories]),tags:Object.freeze([...this.#w.whitelist.tags])})}get accessControlBlacklist(){return Object.freeze({ids:Object.freeze([...this.#w.blacklist.ids]),authors:Object.freeze([...this.#w.blacklist.authors]),categories:Object.freeze([...this.#w.blacklist.categories]),tags:Object.freeze([...this.#w.blacklist.tags])})}get accessControlMode(){return this.#w.mode}constructor(e){super(e?.logCfg??{id:"[_main_class_TinyPluginLayer_reset_]",logger:console,autoHideId:!0,debugMode:!1,useLogColors:!1}),f(e??{},this.#w)}_startLayer(e,t,...r){if(this.#y)throw new Error("TinyPluginLayer: The layer has already been initialized.");return this.logSubId=e.logSubId,"function"==typeof t&&t(...r),this.#y=!0,this}canAccessLayer(e,t,r,i){const{mode:s,whitelist:o,blacklist:n}=this.#w;return w(s,e,t,r,i,o,n,this.#p)}async verifyPluginSignature(e,t,r,i,s){return p(this.#w,this.#p,e,t,r,i,s)}_createSandbox(e,t){return b(this,null,null,[...e],["isReady","accessControlMode","accessControlWhitelist","accessControlBlacklist","verifyPluginSignature","canAccessLayer",...t])}}class E extends l{static#m=v;static get TinyPluginLayer(){return E.#m}static#b="pluginsDestroyed";#v={get:new Set,set:new Set};#w=m();#p=new Set;static get pluginsDestroyEventName(){return E.pluginsDestroyEventName}static set pluginsDestroyEventName(e){if("string"!=typeof e)throw new TypeError("pluginsDestroyEventName must be a string.");E.pluginsDestroyEventName=e}#E=new Map;get sandboxBlacklist(){return Object.freeze({set:Object.freeze([...this.#v.set]),get:Object.freeze([...this.#v.get])})}get plugins(){return Object.fromEntries(this.#E)}get pluginsSize(){return this.#E.size}get accessControlWhitelist(){return Object.freeze({ids:Object.freeze([...this.#w.whitelist.ids]),authors:Object.freeze([...this.#w.whitelist.authors]),categories:Object.freeze([...this.#w.whitelist.categories]),tags:Object.freeze([...this.#w.whitelist.tags])})}get accessControlBlacklist(){return Object.freeze({ids:Object.freeze([...this.#w.blacklist.ids]),authors:Object.freeze([...this.#w.blacklist.authors]),categories:Object.freeze([...this.#w.blacklist.categories]),tags:Object.freeze([...this.#w.blacklist.tags])})}get accessControlMode(){return this.#w.mode}constructor(e){super(e.logCfg),f(e,this.#w,this.#v)}canAccessEngine(e,t,r,i){const{mode:s,whitelist:o,blacklist:n}=this.#w;return w(s,e,t,r,i,o,n,this.#p)}async verifyPluginSignature(e,t,r,i,s){return p(this.#w,this.#p,e,t,r,i,s)}_addPlugin(e){if(!(e instanceof T))throw new TypeError("The provided plugin must be an instance of TinyPlugin.");if(!this.canAccessEngine(e.id,e.authors,e.categories,e.tags))throw new Error(`Security Error: Access to the core is denied for plugin "${e.id}" based on current access control rules.`);this.#E.set(e.id,e)}installPlugin(e,...t){return T._addModuleToCore(this,e,...t)}hasPlugin(e){return this.#E.has("string"==typeof e?e:e.id)}getPlugin(e){const t=this.#E.get(e);return t&&!t.isDestroyed?t:void 0}_getPlugin(e,t){if(!(t instanceof T))throw new TypeError("The provided external plugin must be an instance of TinyPlugin.");const r=this.#E.get(e);if(r&&!r.isDestroyed){if(!r.layer.canAccessLayer(t.id,t.authors,t.categories,t.tags))throw new Error(`Security Error: Access to the plugin "${e}" is denied for plugin "${t.id}" based on current plugin access control rules.`);return r}}destroyPlugins(){this.#p.clear(),this.#E.forEach(e=>e.destroy()),this.emit(E.#b)}}class T extends l{static#T={id:"[_main_class_TinyPlugin_reset_]",autoHideId:!0,logger:console,debugMode:!1,canEmitLogs:!1,useLogColors:!0};static get logCfg(){return{...T.#T}}static set logCfg(e){this.#T=e}static _addModuleToCore(e,t,...r){if(!(e instanceof E))throw new TypeError("The provided engine must be an instance of TinyPluginCore.");const i=new T({engine:e,installer:t,logCfg:{...T.#T,debugMode:e.debugMode}},...r);if(i._startPlugin(),e.hasPlugin(i))throw new Error(`A plugin with the name "${i.id}" is already registered.`);return e._addPlugin(i),i}#v={get:new Set,set:new Set};#S="";#L="";#C=new Set;#P=new Set;#A=new Set;#k=new Set;#_=null;#O;#x;#D;#y=!1;#M=null;#I=!1;#j=new Set;#R=new Set;get isDestroyed(){return this.#I}get plugins(){return g(this.#I),Object.keys(this.#O.plugins)}get pluginsSize(){return g(this.#I),this.#O.pluginsSize}getPlugin(e){return g(this.#I),this.#O._getPlugin(e,this)}hasPlugin(e){return g(this.#I),this.#O.hasPlugin(e)}get isReady(){return g(this.#I),this.#y}get id(){if(g(this.#I),0===this.#S.length)throw new Error("Plugin id is not set.");return this.#S}set id(e){if(g(this.#I),0!==this.#S.length)throw new Error("Id is already set.");if("string"!=typeof e)throw new TypeError("Id must be a string.");if(0===e.length)throw new TypeError("Id cannot be empty.");this.#S=e,this.logSubId=`${this.#O.logId} [_sub_class_${e}_reset_]`}get description(){if(g(this.#I),0===this.#L.length)throw new Error("Plugin description is not set.");return this.#L}set description(e){if(g(this.#I),0!==this.#L.length)throw new Error("Description is already set.");if("string"!=typeof e)throw new TypeError("Description must be a string.");if(0===e.length)throw new TypeError("Description cannot be empty.");this.#L=e}get authors(){if(g(this.#I),0===this.#C.size)throw new Error("Plugin authors is not set.");return Object.freeze([...this.#C])}set authors(e){if(g(this.#I),0!==this.#C.size)throw new Error("Authors is already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Authors must be a array of non-empty strings.");if(0===e.length)throw new TypeError("Authors cannot be empty.");e.forEach(e=>this.#C.add(e))}get contributors(){if(g(this.#I),0===this.#P.size)throw new Error("Plugin contributors is not set.");return Object.freeze([...this.#P])}set contributors(e){if(g(this.#I),0!==this.#P.size)throw new Error("Authors is already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Authors must be a array of non-empty strings.");if(0===e.length)throw new TypeError("Authors cannot be empty.");e.forEach(e=>this.#P.add(e))}get categories(){if(g(this.#I),0===this.#A.size)throw new Error("Plugin categories are not set.");return Object.freeze([...this.#A])}set categories(e){if(g(this.#I),0!==this.#A.size)throw new Error("Categories are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Categories must be an array of non-empty strings.");if(0===e.length)throw new TypeError("Categories cannot be empty.");e.forEach(e=>this.#A.add(e))}get tags(){if(g(this.#I),0===this.#k.size)throw new Error("Plugin tags are not set.");return Object.freeze([...this.#k])}set tags(e){if(g(this.#I),0!==this.#k.size)throw new Error("Tags are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Tags must be an array of non-empty strings.");if(0===e.length)throw new TypeError("Tags cannot be empty.");e.forEach(e=>this.#k.add(e))}get allowedSets(){return g(this.#I),[...this.#R]}set allowedSets(e){if(g(this.#I),0!==this.#R.size||this.#y)throw new Error("AllowedSets are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("AllowedSets must be an array of non-empty strings.");if(0===e.length)throw new TypeError("AllowedSets cannot be empty.");e.forEach(e=>this.#R.add(e))}get allowedGets(){return g(this.#I),[...this.#j]}set allowedGets(e){if(g(this.#I),0!==this.#j.size||this.#y)throw new Error("AllowedGets are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("AllowedGets must be an array of non-empty strings.");if(0===e.length)throw new TypeError("AllowedGets cannot be empty.");e.forEach(e=>this.#j.add(e))}get version(){if(g(this.#I),!this.#_)throw new Error("Plugin version is not set.");return this.#_.toString()}set version(e){if(g(this.#I),this.#_)throw new Error("Version is already set.");if("string"!=typeof e)throw new TypeError("Version must be a string.");if(0===e.length)throw new TypeError("Version cannot be empty.");this.#_=new d(e)}get tinyVersion(){if(g(this.#I),!this.#_)throw new Error("Plugin version is not set.");return this.#_}get layer(){if(g(this.#I),null===this.#M)throw new Error("Plugin layer is not set.");return this.#M._createSandbox([...this.#R],[...this.#j])}get engine(){if(g(this.#I),!this.#O.canAccessEngine(this.#S,[...this.#C],[...this.#A],[...this.#k]))throw new Error(`Security Error: Access to the engine is denied for plugin "${this.id}" based on current access control rules.`);const e=this.#v;return new Proxy(this.#O,{get(t,r){if(e.get.has(r))throw new Error(`Security Error: Access to property "${String(r)}" is denied by the sandbox.`);const i=Reflect.get(t,r,t);return"function"==typeof i?i.bind(t):i},set(t,r,i){if(e.set.has(r))throw new Error("Security Error: Cannot modify read-only properties on the plugin sandbox.");return Reflect.set(t,r,i)},setPrototypeOf(){throw new Error("Security Error: Prototype manipulation is forbidden.")}})}get options(){return g(this.#I),this.#D}get engineBlacklist(){return g(this.#I),this.#O.sandboxBlacklist}constructor({engine:e,logCfg:t,installer:r},...i){super(t),this.#O=e,this.#x=r,this.#D=i}#N(){const e=["id","version","description","authors","contributors","categories","tags","allowedGets","allowedSets"];return b(this,this.#O.sandboxBlacklist,this.#v,e,[...e,"tinyVersion","isReady","layer","options","engine","engineBlacklist","isDestroyed","pluginsSize","plugins","hasPlugin","getPlugin","log","logClear","logGroupEnd","logLabel","logTimeLabel","logAssert","logDir","logTable","toConsole","isDestroyed"],["getPlugin","_getPlugin","plugins","installPlugin","_addPlugin","destroyPlugins"],["accessControlMode","accessControlWhitelist","accessControlBlacklist","verifyPluginSignature","canAccessEngine"])}_startPlugin(){if(g(this.#I),this.#y)throw new Error("Plugin is already ready.");this.#D&&Object.freeze(this.#D);const e=this.#N();try{if(this.#M=this.#x(e,...this.#D),!(this.#M instanceof v))throw new TypeError("Plugin layer is not a valid TinyPluginLayer instance.");if(this.#M.debugMode=this.debugMode,this.#M.isReady||this.#M._startLayer(this),0===this.#S.length)throw new Error("Plugin id is not set.");if(0===this.#L.length)throw new Error("Plugin description is not set.");if(0===this.#C.size)throw new Error("Plugin authors are not set.");if(0===this.#P.size)throw new Error("Plugin contributors are not set.");if(0===this.#A.size)throw new Error("Plugin categories are not set.");if(0===this.#k.size)throw new Error("Plugin tags are not set.");if(!this.#_)throw new Error("Plugin version is not set.");this.#y=!0}catch(e){throw this.emit("error",e),this.destroy(),new Error(`Plugin initialization failed: ${e instanceof Error?e.message:"Unknown Error"}`)}}destroy(){this.#I||(this.emit("destroyed"),this.#M?.emit("destroyed"),this.#I=!0)}}const S=Object.freeze({NOTIFICATION:"notification",DATA:"data",SYNC:"sync",COMMAND:"command",UNKNOWN:"unknown"});class L{static PUSH_TYPE=S;static#W=Object.freeze(["actions","badge"]);static toBrowser(e,t={}){if(null!==e&&("object"!=typeof e||Array.isArray(e)))throw new TypeError("[TinyNotificationAdapter] toBrowser: notification must be a non-null object.");if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("[TinyNotificationAdapter] toBrowser: overrides must be a non-null object.");const{title:r,...i}=e??{},s={};for(const[e,t]of Object.entries(i))L.#W.includes(e)||void 0!==t&&(s[e]=t);return"auto"!==s.dir&&"ltr"!==s.dir&&"rtl"!==s.dir&&delete s.dir,!0===s.renotify&&"string"!=typeof s.tag&&delete s.renotify,{title:"string"==typeof r&&""!==r?r:"Notification",options:{...s,...t}}}static toServiceWorker(e,t={}){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("[TinyNotificationAdapter] toServiceWorker: notification must be a non-null object.");if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("[TinyNotificationAdapter] toServiceWorker: overrides must be a non-null object.");const{title:r="Notification",options:i={}}=e,s={...i,...t};return{title:r,body:"string"==typeof s.body?s.body:"",options:s}}}const C=L,P=c("TinyServiceWorker"),A=(e,t)=>{if(!("serviceWorker"in navigator)||!navigator.serviceWorker.controller)throw new Error("Service Worker is not available or not controlling the page.");return navigator.serviceWorker.controller.postMessage(e,t??[])};class k extends E{static postMessage=A;static#z=S;static get PUSH_TYPE(){return k.#z}static#$(e){if("string"!=typeof e||""===e.trim())throw new TypeError("The event type must be a non-empty string.");if(e.startsWith("sw:"))throw new TypeError(`The event type "${e}" is reserved for internal PWA lifecycle management and cannot be used for Service Worker messaging.`)}static#H(e){if("string"!=typeof e||""===e.trim())throw new TypeError("The event name must be a non-empty string.")}static async waitForReady(){return navigator.serviceWorker.ready}#B=null;#S;#F;#_;#y=!1;#U=!1;#G=null;#K=null;#V="browser";#q=new Map;#Y=new Map;#X=null;#Z=null;#J=null;#Q=new(r().EventEmitter);#I=!1;#ee=new Set;get pushEvents(){return this.#Q}get isReady(){return this.#y}get isFailed(){return this.#U}get isDestroyed(){return this.#I}#te(){this.emit("sw:NoSwControllerWarn"),this.log("warn","No active controller to receive message.")}get isSwAvailable(){return P(this.#I),"serviceWorker"in navigator&&!!navigator.serviceWorker.controller}get id(){return P(this.#I),this.#S}get swUrl(){return P(this.#I),this.#F}get version(){return P(this.#I),this.#_}get registration(){return P(this.#I),this.#B}#re=new Set;get eventListeners(){return P(this.#I),Array.from(this.#re)}get displayMode(){return P(this.#I),this.#V}#ie=!0;get autoNotifyPush(){return P(this.#I),this.#ie}set autoNotifyPush(e){if(P(this.#I),"boolean"!=typeof e)throw new TypeError("autoNotifyPush must be a boolean.");this.#ie=e}get eventBlacklist(){return P(this.#I),Array.from(this.#ee)}addToEventBlacklist(e){P(this.#I),k.#H(e),this.#ee.add(e)}removeFromEventBlacklist(e){return P(this.#I),k.#H(e),this.#ee.delete(e)}hasInEventBlacklist(e){return P(this.#I),k.#H(e),this.#ee.has(e)}clearEventBlacklist(){P(this.#I),this.#ee.clear()}constructor(e){if(Array.isArray(e)||"object"!=typeof e||null===e)throw new TypeError('The "options" argument must be a non-null object.');const{id:t,swUrl:r,version:i,logger:s,debugMode:o,useLogColors:n}=e;if("string"!=typeof t||""===t.trim())throw new TypeError('The "id" parameter must be a non-empty string.');if("string"!=typeof r&&!(r instanceof URL))throw new TypeError('The "swUrl" parameter must be a string or URL.');if("string"!=typeof i)throw new TypeError('The "version" parameter must be a string.');super({logCfg:{id:"[_sub_class_TinyServiceWorker_reset_]",logger:s??console,debugMode:o??!1,useLogColors:n??!1}}),this.#S=t,this.#F=r,this.#_=i,this.#se()}#se(){const e=window.matchMedia("(display-mode: standalone)").matches;document.referrer.startsWith("android-app://")?this.#V="twa":navigator.standalone||e?this.#V="standalone":this.#V="browser",this.emit("sw:DisplayModeChanged",{displayMode:this.#V}),this.log("info",`DISPLAY_MODE_CHANGED: ${this.#V}`)}#oe(){this.#X=()=>this.#se(),window.matchMedia("(display-mode: standalone)").addEventListener("change",this.#X),this.#Z=e=>{this.#K=e,this.emit("sw:BeforeInstallPrompt",{event:e}),this.log("info","beforeinstallprompt event fired.")},window.addEventListener("beforeinstallprompt",this.#Z),this.#J=()=>{this.#K=null,this.emit("sw:AppInstalled"),this.log("info","PWA was installed")},window.addEventListener("appinstalled",this.#J)}async promptInstallation(){if(P(this.#I),!this.#K)throw new Error("Cannot show installation prompt: beforeinstallprompt event has not fired.");this.#K.prompt();const{outcome:e}=await this.#K.userChoice;this.log("info",`User installation choice: ${e}`),this.#K=null}async waitForReady(){if(P(this.#I),this.#U)throw new Error("Service Worker registration failed. Cannot wait for ready state.");if(!this.#y||!navigator.serviceWorker.controller)return new Promise((e,t)=>{const r=()=>{this.#y&&navigator.serviceWorker.controller&&(s(),e())},i=e=>{s(),t(e instanceof Error?e:new Error(String(e)))},s=()=>{navigator.serviceWorker.removeEventListener("controllerchange",r),this.off("sw:RegistrationFailed",i)};navigator.serviceWorker.addEventListener("controllerchange",r),this.on("sw:RegistrationFailed",i),this.#y&&navigator.serviceWorker.controller&&(s(),e())})}async registerSync(e){if(P(this.#I),"string"!=typeof e||""===e.trim())throw new TypeError("[TinyServiceWorker] registerSync: tag must be a non-empty string.");const t=await k.waitForReady();if(!t.sync)throw new Error("[TinyServiceWorker] registerSync: Background Sync API is not supported in this browser.");try{await t.sync.register(e),this.log("info",`Sync tag registered: ${e}`)}catch(t){throw this.log("error",`Failed to register sync tag "${e}":`,t),t}}async requestNotificationPermission(){P(this.#I);try{const e=await(async()=>{if(!("Notification"in window))throw new Error("Notification API is not supported in this browser.");return"granted"===Notification.permission?"granted":"denied"===Notification.permission?"denied":await Notification.requestPermission()})();return"granted"===e?(this.emit("sw:NotificationPermissionChanged",{permission:"granted"}),e):"denied"===e?(this.log("warn","Notification permission was denied by the user."),this.emit("sw:NotificationPermissionChanged",{permission:"denied"}),e):(this.log("info",`Notification permission status: ${e}`),this.emit("sw:NotificationPermissionChanged",{permission:e}),e)}catch(e){throw this.log("error","Error requesting notification permission:",e),e}}#ne(e,t){const r=!0===e.notificationShown,i=e.notification??null,s=(e={})=>{if(!("Notification"in window))return this.log("warn","Push received, but the Notification API is not supported."),null;const t=C.toBrowser(i,e),r=new Notification(t.title,t.options),s=e=>{const r=C.toServiceWorker(t);this.#ae(e,r,!1)};return r.onclick=()=>s("sw:NotificationClicked"),r.onclose=()=>s("sw:NotificationClosed"),r};!r&&"browser"===this.displayMode&&this.#ie&&s(),this.#Q.emit(e.topic??"push",{data:{...e,notificationShown:r},event:t,notificationShown:r,showNotification:s})}async register(e){if(P(this.#I),void 0!==e&&(Array.isArray(e)||"object"!=typeof e||null===e))throw new TypeError('The "options" argument must be a non-null object.');if("serviceWorker"in navigator)try{const t=`${this.#S}_sw_version`,r=localStorage.getItem(t);r!==this.#_&&(this.log("warn",`Version mismatch detected: ${r} -> ${this.#_}. Signaling update...`),this.emit("sw:VersionUpdateAvailable"),this.#ae("sw:PrepareUpdate"),localStorage.setItem(t,this.#_));const i=new URL(this.#F,location.origin);i.searchParams.set("v",this.#_),this.debugMode&&i.searchParams.set("t",Date.now().toString()),this.#B=await navigator.serviceWorker.register(i.toString(),e),navigator.serviceWorker.addEventListener("controllerchange",e=>{this.emit("sw:NewVersionReady",{event:e}),this.log("info","New Service Worker is now in control.")}),this.#G=e=>{const t=e.data;if(!Array.isArray(t)&&"object"==typeof t&&null!==t&&"string"==typeof t.type)if(this.#ee.has(t.type))this.log("warn",`Ignored blacklisted event: ${t.type}`);else if(void 0===t.data||!Array.isArray(t.data)&&"object"==typeof t.data&&null!==t.data)if("sw:PushReceived"!==t.type){if("sw:ApiResponse"===t.type){if("string"!=typeof t.correlationId)return void this.log("error",'Received message with missing or invalid "correlationId" string.');const e=this.#q.get(t.correlationId);return void(e&&(clearTimeout(e.timer),this.#q.delete(t.correlationId),t.error?e.reject(new Error(t.error)):e.resolve(t.data)))}if(!0===t.isApi){if("string"!=typeof t.correlationId)return void this.log("error",'Received message with missing or invalid "correlationId" string.');const e=this.#Y.get(t.type);if(!e)return void A({correlationId:t.correlationId,type:"sw:ApiResponse",error:`No API handler registered for type: ${t.type}`});try{const r=e=>A({correlationId:t.correlationId,type:"sw:ApiResponse",data:e}),i=e({data:t.data,correlationId:t.correlationId});i instanceof Promise?i.then(r):r(i)}catch(e){A({correlationId:t.correlationId,type:"sw:ApiResponse",error:e instanceof Error?e.message:String(e)})}return}this.emit(t.type,{data:t.data,event:e})}else this.#ne(t.data,e)},navigator.serviceWorker.addEventListener("message",this.#G),this.#oe(),this.#y=!0,this.log("info","Registered successfully.")}catch(e){this.#U=!0,this.log("error","Registration error:",e)}else this.log("warn","Service Worker is not supported in this browser.")}async unregister(){if(P(this.#I),!this.#B)return this.log("warn","No active ServiceWorkerRegistration found to unregister."),this.destroy(),!1;try{const e=await this.#B.unregister();return e?this.log("info","Service Worker unregistered successfully."):this.log("warn","The unregister() method returned false (the worker might already be inactive)."),this.destroy(),e}catch(e){throw this.log("error","Error during Service Worker unregistration:",e),e}}#ae(e,t,r=!1){if(P(this.#I),"string"!=typeof e)throw new TypeError("Payload.type must be a string.");if("boolean"!=typeof r)throw new TypeError('The "strictMode" argument must be a boolean.');if(void 0!==t&&(Array.isArray(t)||"object"!=typeof t||null===t))throw new TypeError("Payload.data must be a non-null object.");return r&&k.#$(e),"serviceWorker"in navigator&&navigator.serviceWorker.controller?(navigator.serviceWorker.controller.postMessage({type:e,data:t}),!0):(this.#te(),!1)}offApi(e){if("string"!=typeof e||""===e.trim())throw new TypeError('The "type" argument must be a non-empty string.');return this.#Y.delete(e)}onApi(e,t){if("string"!=typeof e||""===e.trim())throw new TypeError('The "type" argument must be a non-empty string.');if("function"!=typeof t)throw new TypeError("Callback must be a function.");this.#Y.set(e,t)}async emitApi(e,t,r=1e4){if(P(this.#I),"string"!=typeof e||""===e.trim())throw new TypeError('The "type" argument must be a non-empty string.');if(void 0!==t&&(Array.isArray(t)||"object"!=typeof t||null===t))throw new TypeError('The "data" argument must be a non-null object.');if("number"!=typeof r)throw new TypeError('The "timeout" argument must be a number.');if(!Number.isFinite(r)||r<0)throw new RangeError('The "timeout" argument must be a finite number greater than or equal to 0.');const i=crypto.randomUUID();return new Promise((s,o)=>{const n=setTimeout(()=>{this.#q.has(i)&&(this.#q.delete(i),o(new Error(`API request timeout: ${e} (ID: ${i})`)))},r);this.#q.set(i,{resolve:s,reject:o,timer:n}),A({type:e,data:t,correlationId:i,isApi:!0})})}emitMessage(e,t){return this.#ae(e,t,!0)}postMessage(e){if(P(this.#I),Array.isArray(e)||"object"!=typeof e||null===e)throw new TypeError("Payload must be an object.");if("string"!=typeof e.type)throw new TypeError("Payload.type must be a string.");if(void 0!==e.data&&(Array.isArray(e.data)||"object"!=typeof e.data||null===e.data))throw new TypeError("Payload.data must be a non-null object.");k.#$(e.type),"serviceWorker"in navigator&&navigator.serviceWorker.controller?navigator.serviceWorker.controller.postMessage(e):this.#te()}addEventListener(e){if(P(this.#I),"function"!=typeof e)throw new TypeError("The callback must be a function.");"serviceWorker"in navigator?(navigator.serviceWorker.addEventListener("message",e),this.#re.add(e)):this.#te()}removeEventListener(e){if(P(this.#I),"function"!=typeof e)throw new TypeError("The callback must be a function.");return"serviceWorker"in navigator?(navigator.serviceWorker.removeEventListener("message",e),this.#re.delete(e)):(this.#te(),!1)}destroy(){if(!this.#I){if("serviceWorker"in navigator){this.#G&&(navigator.serviceWorker.removeEventListener("message",this.#G),this.#G=null);for(const e of this.#re)navigator.serviceWorker.removeEventListener("message",e);this.#re.clear()}this.#X&&(window.matchMedia("(display-mode: standalone)").removeEventListener("change",this.#X),this.#X=null),this.#Z&&(window.removeEventListener("beforeinstallprompt",this.#Z),this.#Z=null),this.#J&&(window.removeEventListener("appinstalled",this.#J),this.#J=null),this.removeAllListeners(),this.#Q.removeAllListeners(),this.#B=null,this.#K=null,this.destroyPlugins(),this.#I=!0,this.log("info",`[${this.#S}] Destroyed successfully.`)}}}const _=k;window.TinyServiceWorker=t.TinyServiceWorker})();
@@ -0,0 +1 @@
1
+ (()=>{"use strict";const e={cw:e=>{var t;return()=>{if(e){var r=e;e=0,t={exports:{}},r.call(t.exports,t,t.exports)}return t.exports}},d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyServiceWorkerEngine:()=>te});var r=e.cw(function(e,t){var r,i="object"==typeof Reflect?Reflect:null,n=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(r,i){function n(r){e.removeListener(t,s),i(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}y(e,t,s,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,n)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var a=10;function l(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,i){var n,s,o,a;if(l(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=c(e))>0&&o.length>n&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,a=u,console&&console.warn&&console.warn(a)}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 g(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=h.bind(i);return n.listener=r,i.wrapFn=n,n}function f(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]: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}(n):p(n,n.length)}function d(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function y(e,t,r,i){if("function"==typeof e.on)i.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function n(s){i.once&&e.removeEventListener(t,n),r(s)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");a=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,s=this._events;if(void 0!==s)i=i&&void 0===s.error;else if(!i)return!1;if(i){var 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 l=s[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var c=l.length,u=p(l,c);for(r=0;r<c;++r)n(u[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 l(t),this.on(e,g(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,g(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,i,n,s,o;if(l(t),void 0===(i=this._events))return this;if(void 0===(r=i[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(n=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,n),1===r.length&&(i[e]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",e,o||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,i;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var n,s=Object.keys(r);for(i=0;i<s.length;++i)"removeListener"!==(n=s[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(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?r(this._events):[]}});const i=Object.freeze({NOTIFICATION:"notification",DATA:"data",SYNC:"sync",COMMAND:"command",UNKNOWN:"unknown"});class n{static#e=i;static get PUSH_TYPE(){return n.#e}#t=new Map;#r=[];#i=[];#n=null;#s=null;use(e){if("function"!=typeof e)throw new TypeError("[TinyPushRouter] use: guard must be a function.");return this.#i.push(e),this}on(e,t){if("string"!=typeof e||""===e.trim())throw new TypeError("[TinyPushRouter] on: type must be a non-empty string.");if("function"!=typeof t)throw new TypeError("[TinyPushRouter] on: handler must be a function.");return this.#t.set(e,t),this}onMatch(e,t){if(!(e instanceof RegExp))throw new TypeError("[TinyPushRouter] onMatch: pattern must be a RegExp.");if("function"!=typeof t)throw new TypeError("[TinyPushRouter] onMatch: handler must be a function.");return this.#r.push({source:e.source,regex:e,handler:t}),this}otherwise(e){if("function"!=typeof e)throw new TypeError("[TinyPushRouter] otherwise: handler must be a function.");return this.#n=e,this}catch(e){if("function"!=typeof e)throw new TypeError("[TinyPushRouter] catch: handler must be a function.");return this.#s=e,this}has(e){return!!this.#t.has(e)||this.#r.some(({regex:t})=>t.test(e))}get size(){return this.#t.size+this.#r.length}async dispatch(e,t){if("object"!=typeof e||null===e)throw new TypeError("[TinyPushRouter] dispatch: message must be a non-null object.");if("object"!=typeof t||null===t)throw new TypeError("[TinyPushRouter] dispatch: context must be a non-null object.");try{for(const r of this.#i)if(!1===await r(e,t))return!0;const r=this.#t.get(e.type);if(r&&!1!==await r(e,t))return!0;for(const{regex:r,handler:i}of this.#r)if(r.test(e.type)&&!1!==await i(e,t))return!0;return!!this.#n&&(await this.#n(e,t),!0)}catch(t){if(this.#s)return this.#s(t,e),!0;throw t}}}const s=n,o=2419200;class a{static#e=i;static get PUSH_TYPE(){return a.#e}static VERSION=1;static MAX_TTL=o;static from(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("[TinyPushPayload] from: raw must be a non-null object.");const t=e,r="string"==typeof t.type&&""!==t.type?t.type:i.UNKNOWN,n={v:"number"==typeof t.v?t.v:a.VERSION,type:r};return"string"==typeof t.id&&(n.id=t.id),"string"==typeof t.topic&&(n.topic=t.topic),"number"==typeof t.expiresAt&&(n.expiresAt=t.expiresAt),"number"==typeof t.ttl&&Number.isFinite(t.ttl)&&(n.ttl=Math.min(Math.max(0,Math.trunc(t.ttl)),o)),"object"!=typeof t.data||null===t.data||Array.isArray(t.data)||(n.data=t.data),"object"==typeof t.notification&&null!==t.notification&&(n.notification=a.#o(t.notification)),Object.freeze(n)}static async fromEvent(e){if("object"!=typeof e||null===e||!("data"in e))throw new TypeError("[TinyPushPayload] fromEvent: event must be a PushEvent.");if(!e.data)return Object.freeze({v:a.VERSION,type:i.UNKNOWN});let t;try{t=await e.data.text()}catch{return Object.freeze({v:a.VERSION,type:i.UNKNOWN})}if(""===t)return Object.freeze({v:a.VERSION,type:i.UNKNOWN});try{return a.from(JSON.parse(t))}catch{return Object.freeze({v:a.VERSION,type:i.UNKNOWN,notification:{title:"Notification",body:t}})}}static isExpired(e,t=Date.now()){if("object"!=typeof e||null===e)throw new TypeError("[TinyPushPayload] isExpired: message must be a non-null object.");if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("[TinyPushPayload] isExpired: now must be a finite number.");return"number"==typeof e.expiresAt&&e.expiresAt<=t}static toNotification(e,t={}){if("object"!=typeof e||null===e)throw new TypeError("[TinyPushPayload] toNotification: message must be a non-null object.");const r=e.notification??{title:"Notification"},{title:i,body:n,url:s,actions:o,data:a,...l}=r;return{title:i??"Notification",options:{...l,body:n??"",icon:r.icon??t.defaultIcon,badge:r.badge??t.defaultBadge,actions:o,data:{...a,url:s??t.defaultUrl??"/",actions:Object.fromEntries((o??[]).map(e=>[e.action,e.url??s??"/"])),pushId:e.id,pushType:e.type}}}}static#o(e){const t=e;if("string"!=typeof t.title||""===t.title.trim())throw new TypeError("[TinyPushPayload] notification.title must be a non-empty string.");return{...t}}}const l=a,c=((e,t,r)=>{if(null===e||"string"!=typeof e&&!(e instanceof RegExp))throw new TypeError("The searchValue must be a string or a RegExp.");if(null===r)throw new TypeError("The errorConfig must be an object.");if("string"!=typeof r.pathPatternErrorMsg)throw new TypeError("The errorConfig.pathPatternErrorMsg property must be a string.");return i=>{if("string"!=typeof i)throw new TypeError(r.pathPatternErrorMsg);let n=!1;const s=[],o=i.replace(e,(e,...r)=>t(s,e,...r)),a=new RegExp(`^${o}$`);return{regex:a,paramNames:s,exec:e=>{const t={},r=e.match(a);return n=!0,r?(s.forEach((e,i)=>{t[e]=decodeURIComponent(r[i+1])}),{params:t,match:!0}):{params:t,match:!1}}}}})(/:([^/]+)/g,(e,t,r)=>(e.push(r),"([^/]+)"),{pathPatternErrorMsg:'The argument must be a string (e.g., "/user/:id")'});function u(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}const h="undefined"!=typeof window&&void 0!==window.document,g={items:{},order:[]};function f(e,t){if("object"!=typeof e||null===e)throw new TypeError("Argument 'ni' must be an object or an array.");if(void 0!==t&&"number"!=typeof t)throw new TypeError("Argument 'index' must be a number.");const r=[];let i;i=Array.isArray(e)?e.length>0&&Array.isArray(e[0])?e:e.length>0?[e]:[]:Object.entries(e);for(const e of i){if(!Array.isArray(e)||e.length<2)throw new TypeError("Each item in the input must be a [key, function] pair.");const[i,n,s]=e;if(void 0!==s&&"function"!=typeof s)throw new TypeError(`Cloner for key '${i}' must be a function.`);const o="function"==typeof s?s:e=>e;if("string"!=typeof i)throw new TypeError("Validator key must be a string.");if("function"!=typeof n)throw new TypeError(`Validator for key '${i}' must be a function.`);if(!g.items.hasOwnProperty(i)){g.items[i]={validator:n,cloner:o};let e="number"==typeof t?t:-1;if(-1===e){const t=g.order.indexOf("object");e=t>-1?t:g.order.length}e=Math.min(Math.max(0,e),g.order.length),g.order.splice(e,0,i),r.push(i)}}return r}f([["undefined",e=>void 0===e],["null",e=>null===e],["boolean",e=>"boolean"==typeof e],["number",e=>"number"==typeof e&&!Number.isNaN(e)],["nannumber",e=>"number"==typeof e&&Number.isNaN(e)],["bigint",e=>"bigint"==typeof e],["string",e=>"string"==typeof e],["symbol",e=>"symbol"==typeof e],["function",e=>"function"==typeof e]]),f(["array",e=>Array.isArray(e),(e,t,r)=>e.map(e=>t?r.clone(e,t):e)]),h&&f(["file",e=>"undefined"!=typeof File&&e instanceof File,e=>new File([e],e.name,{type:e.type,lastModified:e.lastModified})]),f(["date",e=>e instanceof Date,e=>new Date(e.getTime())]),f(["regexp",e=>e instanceof RegExp,e=>new RegExp(e.source,e.flags)]),f(["map",e=>e instanceof Map,(e,t,r)=>{const i=new Map;for(const[n,s]of e.entries())i.set(n,t?r.clone(s,t):s);return i}]),f(["set",e=>e instanceof Set,(e,t,r)=>{const i=new Set;for(const n of e)i.add(t?r.clone(n,t):n);return i}]),f([["weakmap",e=>e instanceof WeakMap],["weakset",e=>e instanceof WeakSet],["promise",e=>e instanceof Promise]]),f(["url",e=>e instanceof URL,e=>new URL(e.href)]),h&&f(["htmlelement",e=>"undefined"!=typeof HTMLElement&&e instanceof HTMLElement,e=>e.cloneNode(!0)]),f(["object",e=>u(e),(e,t,r)=>{const i={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=t?r.clone(e[n],t):e[n]);return i}]);const d=Object.fromEntries(Object.entries(g.items).map(([e,t])=>[e,{...t}])),p=[...g.order];class y{#a=!1;get isolationMode(){return this.#a}static#l=!0;static get defaultIsDeep(){return y.#l}static set defaultIsDeep(e){if("boolean"!=typeof e)throw new TypeError("The defaultIsDeep property must be a boolean.");y.#l=e}constructor(e={isolationMode:!1}){if("object"!=typeof e||null===e)throw new TypeError("Options must be a non-null object.");if(void 0!==e.isolationMode&&"boolean"!=typeof e.isolationMode)throw new TypeError('The property "isolationMode" must be a boolean.');this.#a=!!e.isolationMode,this.#a&&(this.#c=y.#u.map(e=>({...e})))}static _createObjectPlugin(e){if("string"!=typeof e)throw new TypeError("Id must be a string.");return{id:e,canHandle:e=>null!==e&&"object"==typeof e,clone:(e,t,r)=>{const i={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=t?r.clone(e[n],t):e[n]);return i}}}static#u=[];static validatePlugin(e){if("function"!=typeof e?.canHandle||"function"!=typeof e?.clone)throw new TypeError("Each plugin must implement the required interface: canHandle(item) and clone(item, cloner).");if("string"!=typeof e?.id)throw new TypeError("Each plugin must implement the required interface: the plugin id string.")}static get plugins(){return y.#u.map(e=>({...e}))}static get size(){return y.#u.length}static get ids(){return y.#u.map(e=>e.id)}static set plugins(e){if(!Array.isArray(e))throw new TypeError("The defaultPlugins property must be an array.");y.#u=e.map(e=>(y.validatePlugin(e),{...e}))}static addPlugin(e,t="start",r=0){if(y.validatePlugin(e),y.hasPlugin(e.id))throw new TypeError(`A plugin with the ID "${e.id}" already exists in the global registry.`);const i={...e};if("start"===t)y.#u.unshift(i);else if("end"===t)y.#u.push(i);else{if("index"!==t)throw new TypeError('Position must be "start", "end", or "index".');if(!Number.isInteger(r)||r<0)throw new TypeError('When position is "index", the index must be a non-negative integer.');y.#u.splice(r,0,i)}}static hasPlugin(e){if("string"!=typeof e)throw new TypeError("The ID must be a string.");return y.#u.some(t=>t.id===e)}static removePlugin(e){if("string"!=typeof e)throw new TypeError("The ID must be a string.");const t=y.#u.findIndex(t=>t.id===e);return-1!==t&&(y.#u.splice(t,1),!0)}static filterPlugins(e){if("function"!=typeof e)throw new TypeError("Predicate must be a function.");y.#u=y.#u.filter(t=>!e({...t}))}static updatePlugin(e,t){if(e<0||e>=y.#u.length)throw new RangeError("Index out of bounds.");y.validatePlugin(t),y.#u[e]={...t}}static reorderPlugins(e){y.#u=y.#u.sort(e?(t,r)=>e({...t},{...r}):void 0)}#c=[];get size(){return this.#c.length}get ids(){return this.#c.map(e=>e.id)}get plugins(){return this.#c.map(e=>({...e}))}set plugins(e){if(!Array.isArray(e))throw new TypeError("The plugins property must be an array.");this.#c=e.map(e=>(y.validatePlugin(e),{...e}))}addPlugin(e,t="start",r=0){if(y.validatePlugin(e),this.hasPlugin(e.id))throw new TypeError(`A plugin with the ID "${e.id}" already exists in this instance.`);const i={...e};if("start"===t)this.#c.unshift(i);else if("end"===t)this.#c.push(i);else{if("index"!==t)throw new TypeError('Position must be "start", "end", or "index".');if(!Number.isInteger(r)||r<0)throw new TypeError('When position is "index", the index must be a non-negative integer.');this.#c.splice(r,0,i)}}hasPlugin(e){if("string"!=typeof e)throw new TypeError("The ID must be a string.");return this.#c.some(t=>t.id===e)}removePlugin(e){if("string"!=typeof e)throw new TypeError("The ID must be a string.");const t=this.#c.findIndex(t=>t.id===e);return-1!==t&&(this.#c.splice(t,1),!0)}filterPlugins(e){if("function"!=typeof e)throw new TypeError("Predicate must be a function.");this.#c=this.#c.filter(t=>!e({...t}))}updatePlugin(e,t){if(e<0||e>=this.#c.length)throw new RangeError("Index out of bounds.");y.validatePlugin(t),this.#c[e]={...t}}reorderPlugins(e){this.#c=this.#c.sort(e?(t,r)=>e({...t},{...r}):void 0)}static clone(e,t=y.#l){for(const r of y.#u)if(r.canHandle(e))return r.clone(e,t,y);return e}clone(e,t=y.#l){for(const r of this.#c)if(r.canHandle(e))return r.clone(e,t,this);if(!this.#a)for(const r of y.#u)if(r.canHandle(e))return r.clone(e,t,this);return e}}y.plugins=p.filter(e=>d[e]).map(e=>({id:e,canHandle:d[e].validator,clone:d[e].cloner}));const m=y;Object.freeze({F_OK:0,R_OK:4,W_OK:2,X_OK:1,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4,O_RDONLY:0,O_WRONLY:1,O_RDWR:2,O_CREAT:64,O_EXCL:128,O_TRUNC:512,O_APPEND:1024}),Object.freeze({OWNER_READ:256,OWNER_WRITE:128,OWNER_EXECUTE:64,GROUP_READ:32,GROUP_WRITE:16,GROUP_EXECUTE:8,OTHER_READ:4,OTHER_WRITE:2,OTHER_EXECUTE:1,SETUID:2048,SETGID:1024,STICKY:512}),Object.freeze({FILE:32768,DIRECTORY:16384,SYMBOLIC_LINK:40960}),Object.freeze(["utf8","utf-8","base64","hex"]);const w=e=>t=>{if(t)throw new Error(`This ${e} instance has been destroyed and can no longer be used.`)},b=w("TinyI18");class E{static#h=null;static#g=null;static#f=null;static#d=null;static set _join(e){if("function"!=typeof e)throw new TypeError('TinyI18: "_join" must be a function');if(null!==E.#h)throw new Error('TinyI18: "_join" has already been set');E.#h=e}static set _existsSync(e){if("function"!=typeof e&&!1!==e)throw new TypeError('TinyI18: "_existsSync" must be a function or false');if(null!==E.#g)throw new Error('TinyI18: "_existsSync" has already been set');E.#g=e}static set _readFile(e){if("function"!=typeof e)throw new TypeError('TinyI18: "_readFile" must be a function');if(null!==E.#f)throw new Error('TinyI18: "_readFile" has already been set');E.#f=e}static set _writeFile(e){if("function"!=typeof e)throw new TypeError('TinyI18: "_writeFile" must be a function');if(null!==E.#d)throw new Error('TinyI18: "_writeFile" has already been set');E.#d=e}static async mergeLocaleFiles({files:e,output:t,spaces:r=0}){if(null===E.#g||null===E.#f||null===E.#d)throw new Error('TinyI18: "mergeLocaleFiles" requires "_existsSync", "_readFile", and "_writeFile" to be set');if("number"!=typeof r||Number.isNaN(r)||r<0)throw new TypeError('mergeLocaleFiles: "spaces" must be a non-negative number');if(!Array.isArray(e)||0===e.length)throw new TypeError('mergeLocaleFiles: "files" must be a non-empty array of file paths');if("string"!=typeof t||!t)throw new TypeError('mergeLocaleFiles: "output" must be a non-empty string path');const i={};for(const t of e){if("string"!=typeof t||!t)throw new TypeError("mergeLocaleFiles: each file path must be a non-empty string");if(!1!==E.#g&&!E.#g(t))throw new Error(`mergeLocaleFiles: file "${t}" does not exist`);const e=await E.#f(t,"utf-8");let r;try{r=JSON.parse(e)}catch(e){throw new Error(`mergeLocaleFiles: file "${t}" is not valid JSON`)}Object.assign(i,r)}await E.#d(t,JSON.stringify(i,null,r),"utf-8")}#p=!1;get destroyed(){return this.#p}#y;#m;#w=null;#b;#E=!1;#v=null;#T=new Map;#L=new Map;#C=new Map;#S=new Map;get currentLocale(){return b(this.#p),this.#w}get defaultLocale(){return b(this.#p),this.#m}get mode(){return b(this.#p),this.#y}get strict(){return b(this.#p),this.#b}get acceptNullResults(){return b(this.#p),this.#E}get basePath(){return b(this.#p),this.#v}get stats(){b(this.#p);const e=[];for(const t of this.#T.keys())e.push(this.getStatsForLocale(t));return e}get stringTables(){b(this.#p);const e={};for(const[t,r]of this.#T.entries())e[t]=this.#P(r);return e}get patternTables(){b(this.#p);const e={};for(const[t,r]of this.#L.entries())e[t]=r.map(e=>({$pattern:new RegExp(e.$pattern.source,e.$pattern.flags),value:this.#P(e.value),elseValue:this.#P(e.elseValue)}));return e}get helpers(){b(this.#p);const e={};for(const[t,r]of this.#C.entries())e[t]=r;return e}get regexCache(){b(this.#p);const e={};for(const[t,r]of this.#S.entries())e[t]=new RegExp(r.source,r.flags);return e}#P(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.#P(e));if("object"==typeof e){const t={};for(const[r,i]of Object.entries(e))t[r]=this.#P(i);return t}return e}#R(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.#T.has(e)?t.push(e):this.#w&&t.push(this.#w),t.push(this.#m),t}#M(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.#T.get(r);if(e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}}#k(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.#L.get(r)||[];for(const r of e)return r.$pattern.test(t)?r.value:r.elseValue??void 0}}#x(e,t){if(null==e){if(this.#b)throw new TypeError('#materialize: "value" cannot be null or undefined');return""}if("string"==typeof e)return this.#A(e,t);if("function"==typeof e)return e(t??{},this.#j());if(e&&"object"==typeof e&&"string"==typeof e.$fn){const r=this.#C.get(e.$fn);if("function"!=typeof r){if(this.#b)throw new Error(`TinyI18: helper "${e.$fn}" is not registered`);return""}return r({...t??{},args:void 0!==e.args?e.args:void 0},this.#j())}if(this.#b)throw new Error("TinyI18: unsupported entry type");return""}#A(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 i=this.#O(t,r);return null==i?"":String(i)}):e}#O(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 i=e;for(const e of r){if(null==i)return;i=i[e]}return i}#j(){return{has:e=>this.#C.has(e),call:(e,t,r)=>{const i=this.#C.get(e);if("function"!=typeof i)throw new Error(`Helper "${e}" not found`);return i(t,r??{})}}}#I(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.#T.get(e)??{}},i=[...this.#L.get(e)??[]],n=(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 i.push({$pattern:t.$pattern,value:t.value,elseValue:t.elseValue});for(const[r,i]of Object.entries(t))n(e?`${e}.${r}`:r,i)}};n("",t),this.#T.set(e,r),this.#L.set(e,i),this.#T.has(this.#m)||(this.#T.set(this.#m,{}),this.#L.set(this.#m,[]))}#_(e){if("string"!=typeof e||!e)throw new TypeError('#unloadLocale: "locale" must be a non-empty string');e!==this.#m&&(this.#T.delete(e),this.#L.delete(e))}async#F(e){if(null===E.#h||null===E.#f)throw new Error('TinyI18: "file" mode requires "_join" and "_readFile" to be set');if("string"!=typeof e||!e)throw new TypeError('#loadLocaleFromFile: "locale" must be a non-empty string');if("string"!=typeof this.#v||!this.#v)throw new TypeError('#loadLocaleFromFile: "this.#basePath" must be a non-empty string');const t=E.#h(this.#v,`${e}.json`);let r;try{const e=await E.#f(t,"utf8");r=JSON.parse(e)}catch(r){if(!(r instanceof Error))return;if(this.#b)throw new Error(`TinyI18: failed to load or parse ${t}: ${r.message}`);return this.#T.set(e,{}),void this.#L.set(e,[])}const i={...this.#T.get(e)??{}},n=[...this.#L.get(e)??[]],s=(e,t)=>{if(null!=t){if(t&&"object"==typeof t&&"string"==typeof t.$pattern&&Object.prototype.hasOwnProperty.call(t,"value")){const e=this.#N(t.$pattern);return void n.push({$pattern:e,value:this.#$(t.value),elseValue:this.#$(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.#$(t)}else if(t&&"object"==typeof t)for(const[r,i]of Object.entries(t))s(e?`${e}.${r}`:r,i)}};s("",r),this.#T.set(e,i),this.#L.set(e,n)}#N(e){if("string"!=typeof e||!e)throw new TypeError('#safeRegExp: "src" must be a non-empty string');const t=this.#S.get(e);if(t)return t;try{const t=new RegExp(e);return this.#S.set(e,t),t}catch{if(this.#b)throw new Error(`TinyI18: invalid regex "${e}" in file`);return/^$/}}#$(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.#b)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:i,localResources:n,strict:s=!0,acceptNullResults:o=!1}=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("boolean"!=typeof o)throw new TypeError('TinyI18: "acceptNullResults" must be a boolean');if("file"===t){if("string"!=typeof i||!i)throw new TypeError('TinyI18: "basePath" is required in file mode');this.#v=i}if(this.#y=t,this.#m=r,this.#b=s,this.#E=o,"local"===t&&n&&"object"==typeof n)for(const[e,t]of Object.entries(n))this.#I(e,t);this.#T.has(this.#m)||(this.#T.set(this.#m,{}),this.#L.set(this.#m,[]))}clearRegexCache(){b(this.#p),this.#S.clear()}registerHelper(e,t){if(b(this.#p),"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.#C.set(e,t)}unregisterHelper(e){if(b(this.#p),"string"!=typeof e||!e)throw new TypeError('unregisterHelper: "name" must be a non-empty string');return this.#C.delete(e)}loadLocaleLocal(e,t){if(b(this.#p),"local"!==this.#y)throw new TypeError('loadLocaleLocal is only available in "local" mode');this.#I(e,t)}async setLocale(e){if(b(this.#p),null!==e&&("string"!=typeof e||!e))throw new TypeError('setLocale: "locale" must be string or null');const t=this.#w;null!==e&&("file"===this.#y?await this.#F(e):this.#T.has(e)||(this.#T.set(e,{}),this.#L.set(e,[]))),"file"===this.#y&&t&&t!==this.#m&&t!==e&&this.#_(t),this.#w=e}t(e,t=void 0,r=void 0){return this.get(e,t,r)}get(e,t=void 0,r=void 0){if(b(this.#p),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:i}=r||{},n=this.#R(i);let s=this.#M(n,e);if(void 0===s){if(this.#b)throw new Error(`TinyI18: missing translation for key "${e}"`);return this.#E?null:e}return this.#x(s,t)}p(e,t){return this.resolveByPattern(e,t)}resolveByPattern(e,t){if(b(this.#p),"string"!=typeof e||!e)throw new TypeError('get: "key" must be a non-empty string');const{locale:r}=t||{},i=this.#R(r);let n=this.#k(i,e);if(void 0===n){if(this.#b)throw new Error(`TinyI18: missing translation for key "${e}"`);return this.#E?null:e}return n}resetToDefaultOnly(){if(b(this.#p),"file"===this.#y)for(const e of Array.from(this.#T.keys()))e!==this.#m&&this.#_(e);this.#w=null}getStatsForLocale(e){if(b(this.#p),"string"!=typeof e||!e)throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');if(!this.#T.has(e))throw new Error(`getStatsForLocale: locale "${e}" is not registered`);return{locale:e,strings:Object.keys(this.#T.get(e)??{}).length,patterns:this.#L.get(e)?.length??0,isDefault:e===this.#m,isCurrent:e===this.#w}}destroy(){this.#p||(this.#T.clear(),this.#L.clear(),this.#C.clear(),this.#S.clear(),this.#w=null,this.#v=null,this.#p=!0)}}const v=E;class T extends v{constructor(e){super(e)}}T._writeFile=()=>{throw new Error('TinyI18: "mergeLocaleFiles" is not available in the browser; run it in Node.js at build time')},T._join=(...e)=>"/"+(e=>{const t=[];for(const r of e.split("/"))0!==r.length&&"."!==r&&(".."!==r?t.push(r):t.pop());return t})(e.join("/")).join("/"),T._existsSync=!1,T._readFile=async e=>{const t=await fetch(e);if(!t.ok)throw new Error(`TinyI18: failed to load "${e}": ${t.status} ${t.statusText}`);return t.text()};const L=T,C={100:{name:"Continue",summary:"",description:""},101:{name:"Switching Protocols",summary:"",description:""},102:{name:"Processing",summary:"",description:""},103:{name:"Early Hints",summary:"",description:""},200:{name:"OK",summary:"",description:""},201:{name:"Created",summary:"",description:""},202:{name:"Accepted",summary:"",description:""},203:{name:"Non-Authoritative Information",summary:"",description:""},204:{name:"No Content",summary:"",description:""},205:{name:"Reset Content",summary:"",description:""},206:{name:"Partial Content",summary:"",description:""},207:{name:"Multi-Status",summary:"",description:""},208:{name:"Already Reported",summary:"",description:""},226:{name:"IM Used",summary:"",description:""},300:{name:"Multiple Choices",summary:"",description:""},301:{name:"Moved Permanently",summary:"",description:""},302:{name:"Found",summary:"",description:""},303:{name:"See Other",summary:"",description:""},304:{name:"Not Modified",summary:"",description:""},305:{name:"Use Proxy",summary:"",description:""},306:{name:"Unused",summary:"",description:""},307:{name:"Temporary Redirect",summary:"",description:""},308:{name:"Permanent Redirect",summary:"",description:""},400:{name:"Bad Request",summary:"",description:""},401:{name:"Unauthorized",summary:"",description:""},402:{name:"Payment Required",summary:"",description:""},403:{name:"Forbidden",summary:"",description:""},404:{name:"Not Found",summary:"",description:""},405:{name:"Method Not Allowed",summary:"",description:""},406:{name:"Not Acceptable",summary:"",description:""},407:{name:"Proxy Authentication Required",summary:"",description:""},408:{name:"Request Timeout",summary:"",description:""},409:{name:"Conflict",summary:"",description:""},410:{name:"Gone",summary:"",description:""},411:{name:"Length Required",summary:"",description:""},412:{name:"Precondition Failed",summary:"",description:""},413:{name:"Content Too Large",summary:"",description:""},414:{name:"URI Too Long",summary:"",description:""},415:{name:"Unsupported Media Type",summary:"",description:""},416:{name:"Range Not Satisfiable",summary:"",description:""},417:{name:"Expectation Failed",summary:"",description:""},418:{name:"I'm a teapot",summary:"",description:""},421:{name:"Misdirected Request",summary:"",description:""},422:{name:"Unprocessable Content",summary:"",description:""},423:{name:"Locked",summary:"",description:""},424:{name:"Failed Dependency",summary:"",description:""},425:{name:"Too Early",summary:"",description:""},426:{name:"Upgrade Required",summary:"",description:""},428:{name:"Precondition Required",summary:"",description:""},429:{name:"Too Many Requests",summary:"",description:""},431:{name:"Request Header Fields Too Large",summary:"",description:""},451:{name:"Unavailable For Legal Reasons",summary:"",description:""},500:{name:"Internal Server Error",summary:"",description:""},501:{name:"Not Implemented",summary:"",description:""},502:{name:"Bad Gateway",summary:"",description:""},503:{name:"Service Unavailable",summary:"",description:""},504:{name:"Gateway Timeout",summary:"",description:""},505:{name:"HTTP Version Not Supported",summary:"",description:""},506:{name:"Variant Also Negotiates",summary:"",description:""},507:{name:"Insufficient Storage",summary:"",description:""},508:{name:"Loop Detected",summary:"",description:""},510:{name:"Not Extended",summary:"",description:""},511:{name:"Network Authentication Required",summary:"",description:""}};class S{static#U=C;static codeIs=Object.freeze({info:e=>{if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The status code must be a valid number.");return e>=100&&e<=199},success:e=>{if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The status code must be a valid number.");return e>=200&&e<=299},redirect:e=>{if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The status code must be a valid number.");return e>=300&&e<=399},clientError:e=>{if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The status code must be a valid number.");return e>=400&&e<=499},serverError:e=>{if("number"!=typeof e||Number.isNaN(e))throw new TypeError("The status code must be a valid number.");return e>=500&&e<=599}});static get defaultRequestCodes(){return structuredClone(S.#U)}static set defaultRequestCodes(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("The value must be a non-null object.");for(const[t,r]of Object.entries(e)){if(Number.isNaN(Number(t)))throw new TypeError(`Invalid key: "${t}". Status code keys must be numeric.`);if("object"!=typeof r||null===r||Array.isArray(r))throw new TypeError(`The value for status code ${t} must be an object.`);if("string"!=typeof r.name)throw new TypeError(`Property 'name' in status ${t} must be a string.`);if("string"!=typeof r.summary)throw new TypeError(`Property 'summary' in status ${t} must be a string.`);if("string"!=typeof r.description)throw new TypeError(`Property 'description' in status ${t} must be a string.`)}S.#U=structuredClone(e)}#W=new Set;#D;#z="en";constructor(e,t={}){if(!u(t))throw new TypeError("Initial responses must be an object.");if(this.#D=new e({defaultLocale:"en",mode:"local",strict:!1,acceptNullResults:!0}),!(this.#D instanceof v))throw new TypeError('The "i18" must be an instance of TinyI18.');this.#D.loadLocaleLocal(this.#z,{});for(const e in S.#U){const t=S.#U[e];this.addResponse(Number(e),t)}for(const e in t){const r=t[e];this.addResponse(Number(e),r)}}#G(e,t){if("object"!=typeof t||null===t)throw new TypeError("Response must be a non-null object.");if("string"!=typeof t.name)throw new TypeError('The "name" property must be a string.');if("string"!=typeof t.summary)throw new TypeError('The "summary" property must be a string.');if("string"!=typeof t.description)throw new TypeError('The "description" property must be a string.');if(this.#D.get(String(e)))throw new Error(`Response with ID ${e} already exists in the registry.`)}addResponse(e,t,r=this.#z){this.#G(e,t),this.#W.add(e),this.#D.loadLocaleLocal(r,{[e]:{name:t.name,summary:t.summary,description:t.description}})}get(e,t={},r=this.#z){const i=this.#D.get(`${e}.name`,t,{locale:r}),n=this.#D.get(`${e}.summary`,t,{locale:r}),s=this.#D.get(`${e}.description`,t,{locale:r});return"string"!=typeof i||"string"!=typeof n||"string"!=typeof s?null:{name:i,summary:n,description:s}}has(e){return!!this.#D.get(String(e))}getAll(){const e={};return this.#W.forEach(t=>{const r=this.get(t);r&&(e[t]=r)}),e}}const P=S;r();const R="undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:null,M="undefined"!=typeof document?document:null,k=["chrome","firefox","ie","edge","safari","opera","yandex","other"];const x=r().EventEmitter,A=class extends x{#q;#B;#H=null;#V;#K;#Y;#X;#J=new Map([["log",""],["info",""],["warn",""],["error",""],["debug",""],["main_class",""],["sub_class",""],["reset",""],["black",""],["red",""],["green",""],["yellow",""],["blue",""],["magenta",""],["cyan",""],["white",""],["gray",""]]);#Z=new Map([["log","[_log_LOG_reset_]"],["info","[_info_INFO_reset_]"],["warn","[_warn_WARN_reset_]"],["error","[_error_ERROR_reset_]"],["debug","[_debug_DEBUG_reset_]"]]);constructor({logger:e,id:t,debugMode:r,canEmitLogs:i=!1,useLogColors:n=!1,autoHideId:s=!1}){if(super(),null===(o=e)||"object"!=typeof o||Array.isArray(o))throw new TypeError("Logger must be an object that implements the Console interface.");var o;if("string"!=typeof t)throw new TypeError("Logger instance id must be a string.");if("boolean"!=typeof r)throw new TypeError("debugMode must be a boolean.");if("boolean"!=typeof i)throw new TypeError("canEmitLogs must be a boolean.");if("boolean"!=typeof n)throw new TypeError("useLogColors must be a boolean.");if("boolean"!=typeof s)throw new TypeError("autoHideId must be a boolean.");this.#B=t,this.#q=e,this.#K=r,this.#V=i,this.#X=s,this.#Y="firefox"!==function(e=[]){const t=function(e=[]){if(!Array.isArray(e))throw new TypeError('The "disable" argument must be an array.');for(const t of e)if(!k.includes(t))throw new TypeError(`Invalid browser name provided in disable array: ${t}`);const t={chrome:0,firefox:0,ie:0,edge:0,safari:0,opera:0,yandex:0,other:0};t[function(){if("undefined"==typeof navigator)return"other";const e=navigator.userAgent;return-1!==e.indexOf("Chrome")?"chrome":-1!==e.indexOf("Firefox")?"firefox":-1!==e.indexOf("MSIE")?"ie":-1!==e.indexOf("Edge")?"edge":-1!==e.indexOf("Safari")?"safari":-1!==e.indexOf("Opera")?"opera":-1!==e.indexOf("YaBrowser")?"yandex":"other"}()]++;const r=function(){const e=R?.getComputedStyle?(Array.prototype.slice.call(R.getComputedStyle(document.documentElement,"")).join("").match(/-(moz|webkit|ms)-/)??["",""])[1]:"";return"moz"===e?"gecko":"webkit"===e?"webkit":"ms"===e?"trident":"other"}();"gecko"===r?e.indexOf("firefox")<0&&t.firefox++:"webkit"===r?(e.indexOf("chrome")<0&&t.chrome++,e.indexOf("safari")<0&&t.safari++,e.indexOf("opera")<0&&t.opera++,e.indexOf("edge")<0&&t.edge++):"trident"===r?e.indexOf("ie")<0&&t.ie++:e.indexOf("other")<0&&t.other++;const i=function(){const e=!!R?.opr&&!!opr.addons||!!R?.opera||navigator.userAgent.indexOf(" OPR/")>=0,t="undefined"!=typeof InstallTrigger,r=!!R?.HTMLElement&&/constructor/i.test(R.HTMLElement)||"[object SafariRemoteNotification]"===(!R.safari||"undefined"!=typeof safari&&safari.pushNotification).toString(),i=!!M?.documentMode,n=!i&&!!R?.StyleMedia,s=!!R?.chrome;return{isOpera:e,isFirefox:t,isSafari:r,isIE:i,isEdge:n,isChrome:s,isBlink:(s||e)&&!!R?.CSS}}();return i.isOpera&&e.indexOf("opera")<0&&t.opera++,i.isFirefox&&e.indexOf("firefox")<0&&t.firefox++,i.isSafari&&e.indexOf("safari")<0&&t.safari++,i.isIE&&e.indexOf("ie")<0&&t.ie++,i.isEdge&&e.indexOf("edge")<0&&t.edge++,i.isChrome&&e.indexOf("chrome")<0&&t.chrome++,t}(e);return Object.keys(t).reduce((e,r)=>t[r]>t[e]?r:e)}()&&n,this.log("info","Emit logs of debug mode set to: "+(this.#K?"ON":"OFF")),this.log("info","Custom logger assigned.")}get logId(){return this.#B}get logSubId(){if("string"!=typeof this.#H)throw new Error('logSubId has not been set yet. Assign a string to "logSubId" before reading it.');return this.#H}set logSubId(e){if("string"!=typeof e)throw new TypeError(`logSubId must be a string. Received: ${typeof e}.`);if(null!==this.#H)throw new Error(`logSubId is already set to "${this.#H}" and cannot be reassigned.`);this.#H=e,this.emit("setLogSubId",e)}get canEmitLogs(){return this.#V}get useLogColors(){return this.#Y}set useLogColors(e){if("boolean"!=typeof e)throw new TypeError("useLogColors must be a boolean.");this.#Y=e,this.log("info","Log Colors usage mode set to: "+(this.#Y?"ON":"OFF")),this.emit("setUseLogColors",e)}get debugMode(){return this.#K}set debugMode(e){if("boolean"!=typeof e)throw new TypeError("debugMode must be a boolean.");this.#K=e,this.log("info","Debug mode set to: "+(this.#K?"ON":"OFF")),this.emit("setDebugMode",e)}_addLogColor(e,t){this.#J.set(e,t)}_removeLogColor(e){this.#J.delete(e)}_addLogPrefix(e,t){this.#Z.set(e,t)}_removeLogPrefix(e){this.#Z.delete(e)}#Q(e){if("string"!=typeof e)return e;let t=e;for(const[e,r]of this.#Z){const i=new RegExp(`\\:${e}\\:`,"g");t=t.replace(i,r)}for(const[e,r]of this.#J){const i=new RegExp(`\\_${e}\\_`,"g");t=t.replace(i,this.#Y?r:"")}return t}_applyLogFormatting(e){return this.#Q(e)}logClear(){if(this.#K)return this.#V&&this.emit("debug:clear"),this.#q.clear?this.#q.clear():console.clear()}logGroupEnd(){if(this.#K)return this.#V&&this.emit("debug:groupEnd"),this.#q.groupEnd?this.#q.groupEnd():console.groupEnd()}logLabel(e,t){if(!this.#K)return;const r=["count","countReset","time","timeEnd","profile","profileEnd","timeStamp"];if(!r.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${r.join(", ")}`);if(void 0!==t&&"string"!=typeof t)throw new TypeError("The label must be a string.");const i=this.#q[e]?this.#q[e]:console[e];if(!i)throw new TypeError(`The log type "${e}" is not supported by the provided logger or console.`);return this.#V&&this.emit("debug:logLabel",e,t),i(t)}logTimeLabel(e,...t){if(this.#K)return this.#V&&this.emit("debug:timeLog",e,...t),this.#q.timeLog?this.#q.timeLog(e,...t):console.timeLog(e,...t)}logAssert(e,...t){if(this.#K)return this.#V&&this.emit("debug:assert",e,...t),this.#q.assert?this.#q.assert(e,...t):console.assert(e,...t)}logDir(e,t){if(this.#K)return this.#V&&this.emit("debug:dir",e,t),this.#q.dir?this.#q.dir(e,t):console.dir(e,t)}logTable(e,t){if(this.#K){if(!(void 0===t||Array.isArray(t)&&t.every(e=>"string"==typeof e)))throw new TypeError("Properties must be an array of strings.");return this.#V&&this.emit("debug:table",e,t),this.#q.table?this.#q.table(e,t):console.table(e,t)}}log(e,t,...r){if(!this.#K)return;const i=["log","info","warn","error","debug","dirxml","group","groupCollapsed","trace"];if(!i.includes(e))throw new TypeError(`Invalid logType. Expected one of: ${i.join(", ")}`);if("string"!=typeof t)throw new TypeError("The message must be a string.");let n=this.#B,s=this.#H??"",o=t;const a=!this.#X||"string"!=typeof this.#H;n=a?this.#Q(n):"",s&&(s=this.#Q(s)),o=this.#Q(o);const l=`${n}${s?a?` ${s}`:s:""}`,c=this.#q[e]?this.#q[e]:console[e];return c?(this.#V&&this.emit("debug:log",l,o,...r),c(l,o,...r)):(this.#V&&this.emit("debug:log",l,o,...r),console.log(l,o,...r))}#ee(e,t){const[r="",...i]=t;return"string"==typeof r?this.log(e,r,...i):this.log(e,"",r,...i)}toConsole(){return{log:(...e)=>this.#ee("log",e),info:(...e)=>this.#ee("info",e),warn:(...e)=>this.#ee("warn",e),error:(...e)=>this.#ee("error",e),debug:(...e)=>this.#ee("debug",e),dirxml:(...e)=>this.#ee("dirxml",e),group:(...e)=>this.#ee("group",e),groupCollapsed:(...e)=>this.#ee("groupCollapsed",e),trace:(...e)=>this.#ee("trace",e),assert:(e,...t)=>this.logAssert(e,...t),dir:(e,t)=>this.logDir(e,t),table:(e,t)=>this.logTable(e,t),clear:()=>this.logClear(),groupEnd:()=>this.logGroupEnd(),count:e=>this.logLabel("count",e),countReset:e=>this.logLabel("countReset",e),time:e=>this.logLabel("time",e),timeEnd:e=>this.logLabel("timeEnd",e),timeLog:(e,...t)=>this.logTimeLabel(e,...t),timeStamp:e=>this.logLabel("timeStamp",e),profile:e=>this.logLabel("profile",e),profileEnd:e=>this.logLabel("profileEnd",e)}}};class j{#te=0;#re=0;#ie=0;#ne=null;constructor(e){if("string"!=typeof e)throw new TypeError("[TinyVersion] Expected version to be a string, received type: "+typeof e);const t=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/),r=e=>{"string"==typeof e[1]&&(this.#te=parseInt(e[1],10)),"string"==typeof e[2]&&(this.#re=parseInt(e[2],10)),"string"==typeof e[3]&&(this.#ie=parseInt(e[3],10)),"string"==typeof e[4]&&(this.#ne=e[4])};if(t)r(t);else{const t=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);if(t)r(t);else{const t=e.match(/^(\d+)\.(\d+)$/);if(t)r(t);else{const t=e.match(/^(\d+)$/);if(!t)throw new Error(`[TinyVersion] Invalid version format: "${e}". Expected format: "X.Y.Z" or "X.Y.Z-tag".`);r(t)}}}}get major(){return this.#te}get minor(){return this.#re}get patch(){return this.#ie}get tag(){return this.#ne}isGreaterThan(e){if(!(e instanceof j))throw new TypeError("[TinyVersion] Comparison target must be an instance of TinyVersion. Received: "+typeof e);return this.#te!==e.major?this.#te>e.major:this.#re!==e.minor?this.#re>e.minor:this.#ie!==e.patch?this.#ie>e.patch:null===this.#ne&&null!==e.tag||(null===this.#ne||null!==e.tag)&&(null!==this.#ne||null!==e.tag)&&(this.#ne??"")>(e.tag??"")}isEqualTo(e){if(!(e instanceof j))throw new TypeError("[TinyVersion] Comparison target must be an instance of TinyVersion. Received: "+typeof e);return this.#te===e.major&&this.#re===e.minor&&this.#ie===e.patch&&this.#ne===e.tag}isLessThan(e){if(!(e instanceof j))throw new TypeError("[TinyVersion] Comparison target must be an instance of TinyVersion. Received: "+typeof e);return!this.isGreaterThan(e)&&!this.isEqualTo(e)}toString(){const e=`${this.#te}.${this.#re}.${this.#ie}`;return this.#ne?`${e}-${this.#ne}`:e}}const O=j,I=w("TinyPlugin"),_=(e,t)=>t instanceof Set?t.has("*")||t.has(e):t.indexOf("*")>-1||t.indexOf(e)>-1,F=(e,t,r)=>{const i=(e,t)=>{if(!Array.isArray(t)||!t.every(e=>"string"==typeof e||"symbol"==typeof e))throw new TypeError(`The ${e} of sandbox blacklist must be an array of strings.`)};if(u(r)&&u(e?.sandboxBlacklist)){const{get:t,set:n}=e.sandboxBlacklist;void 0!==t&&(i("get",t),t.forEach(e=>r.get.add(e))),void 0!==n&&(i("set",n),n.forEach(e=>r.set.add(e)))}if(u(e?.accessControl)){const{mode:r,whitelist:n,blacklist:s,publicKey:o,cryptoAlgorithm:a,importAlgorithm:l,importKeyFormat:c}=e.accessControl;if("none"!==r&&"whitelist"!==r&&"blacklist"!==r&&"cryptographic"!==r)throw new TypeError('accessControl.mode must be "none", "whitelist", "blacklist", or "cryptographic".');if("cryptographic"===r&&"string"!=typeof o)throw new TypeError("In cryptographic mode, accessControl.publicKey must be a string (PEM format).");u(n)&&(void 0!==n.ids&&(i("whitelist ids",n.ids),n.ids.forEach(e=>t.whitelist.ids.add(e))),void 0!==n.authors&&(i("whistlist authors",n.authors),n.authors.forEach(e=>t.whitelist.authors.add(e))),void 0!==n.categories&&(i("whistlist categories",n.categories),n.categories.forEach(e=>t.whitelist.categories.add(e))),void 0!==n.tags&&(i("whistlist tags",n.tags),n.tags.forEach(e=>t.whitelist.tags.add(e)))),u(s)&&(void 0!==s.ids&&(i("blacklist ids",s.ids),s.ids.forEach(e=>t.blacklist.ids.add(e))),void 0!==s.authors&&(i("blacklist authors",s.authors),s.authors.forEach(e=>t.blacklist.authors.add(e))),void 0!==s.categories&&(i("blacklist categories",s.categories),s.categories.forEach(e=>t.blacklist.categories.add(e))),void 0!==s.tags&&(i("blacklist tags",s.tags),s.tags.forEach(e=>t.blacklist.tags.add(e)))),"string"==typeof r&&(t.mode=r),"string"==typeof o&&(t.publicKey=o),void 0!==a&&(t.cryptoAlgorithm=a),void 0!==l&&(t.importAlgorithm=l),void 0!==c&&(t.importKeyFormat=c)}},N=e=>{const t=globalThis.atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r.buffer},$=async(e,t,r,i,n,s,o)=>{const{publicKey:a,cryptoAlgorithm:l,importKeyFormat:c,importAlgorithm:u}=e,h=((e,t,r,i)=>{if("string"!=typeof e)throw new TypeError("Security Error: Cryptographic mode enabled, but pluginId is missing.");if(!Array.isArray(t))throw new TypeError("Security Error: Cryptographic mode enabled, but authors is missing.");if(!t.every(e=>"string"==typeof e))throw new TypeError("Security Error: Cryptographic mode enabled, but authors is invalid.");return JSON.stringify({id:e,authors:[...t].sort(),categories:[...r].sort(),tags:[...i].sort()})})(r,i,n,s);try{if("string"!=typeof a)throw new TypeError("Security Error: Cryptographic mode enabled, but public key is missing.");if(!("string"==typeof o||o instanceof ArrayBuffer||o instanceof Uint8Array))throw new TypeError("Security Error: Cryptographic mode enabled, but signature is invalid (must be string, ArrayBuffer, or Uint8Array).");const e=(new TextEncoder).encode(h);let i;i="spki"===c||"pkcs8"===c?(e=>{const t=e.replace(/(-----(BEGIN|END) [^-]+-----)/g,"").replace(/\s+/g,"");return N(t)})(a):"string"==typeof a?N(a):a;const n="string"==typeof o?N(o):o,s=await crypto.subtle.importKey(c,i,u,!1,["verify"]),g=await crypto.subtle.verify(l,s,n,e);return g&&t.add(r),g}catch(e){return console.error(e),!1}},U=(e,t,r,i,n,s,o,a)=>{if("cryptographic"===e)return a.has(t);if("whitelist"===e){const e=_(t,s.ids),o=r.some(e=>_(e,s.authors)),a=i.some(e=>_(e,s.categories)),l=n.some(e=>_(e,s.tags));return e||o||a||l}if("blacklist"===e){const e=_(t,o.ids),s=r.some(e=>_(e,o.authors)),a=i.some(e=>_(e,o.categories)),l=n.some(e=>_(e,o.tags));return!(e||s||a||l)}return!0},W=()=>({mode:"none",importKeyFormat:"spki",importAlgorithm:{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},cryptoAlgorithm:{name:"RSASSA-PKCS1-v1_5"},publicKey:null,whitelist:{ids:new Set,authors:new Set,categories:new Set,tags:new Set},blacklist:{ids:new Set,authors:new Set,categories:new Set,tags:new Set}}),D=(e,t,r,i,n,s,o)=>{const a=[...i],l=[...n],c=t??{get:[],set:[]},h=[...s??[],...c.get],g=[...h,...c.set,...o??[]];return u(r)&&(h.forEach(e=>r.get.add(e)),g.forEach(e=>r.set.add(e))),new Proxy(e,{get(e,t){if(l.includes(t)||l.includes("*")){const r=Reflect.get(e,t,e);return"function"==typeof r?r.bind(e):r}throw new Error(`Security Error: Access to property "${String(t)}" is denied by the sandbox.`)},set(e,t,r){if(a.includes(t)||a.includes("*"))return Reflect.set(e,t,r);throw new Error("Security Error: Cannot modify read-only properties on the plugin sandbox.")},setPrototypeOf(){throw new Error("Security Error: Prototype manipulation is forbidden.")}})};class z extends A{#se=!1;#oe=new Set;#ae=W();get isReady(){return this.#se}get accessControlWhitelist(){return Object.freeze({ids:Object.freeze([...this.#ae.whitelist.ids]),authors:Object.freeze([...this.#ae.whitelist.authors]),categories:Object.freeze([...this.#ae.whitelist.categories]),tags:Object.freeze([...this.#ae.whitelist.tags])})}get accessControlBlacklist(){return Object.freeze({ids:Object.freeze([...this.#ae.blacklist.ids]),authors:Object.freeze([...this.#ae.blacklist.authors]),categories:Object.freeze([...this.#ae.blacklist.categories]),tags:Object.freeze([...this.#ae.blacklist.tags])})}get accessControlMode(){return this.#ae.mode}constructor(e){super(e?.logCfg??{id:"[_main_class_TinyPluginLayer_reset_]",logger:console,autoHideId:!0,debugMode:!1,useLogColors:!1}),F(e??{},this.#ae)}_startLayer(e,t,...r){if(this.#se)throw new Error("TinyPluginLayer: The layer has already been initialized.");return this.logSubId=e.logSubId,"function"==typeof t&&t(...r),this.#se=!0,this}canAccessLayer(e,t,r,i){const{mode:n,whitelist:s,blacklist:o}=this.#ae;return U(n,e,t,r,i,s,o,this.#oe)}async verifyPluginSignature(e,t,r,i,n){return $(this.#ae,this.#oe,e,t,r,i,n)}_createSandbox(e,t){return D(this,null,null,[...e],["isReady","accessControlMode","accessControlWhitelist","accessControlBlacklist","verifyPluginSignature","canAccessLayer",...t])}}class G extends A{static#le=z;static get TinyPluginLayer(){return G.#le}static#ce="pluginsDestroyed";#ue={get:new Set,set:new Set};#ae=W();#oe=new Set;static get pluginsDestroyEventName(){return G.pluginsDestroyEventName}static set pluginsDestroyEventName(e){if("string"!=typeof e)throw new TypeError("pluginsDestroyEventName must be a string.");G.pluginsDestroyEventName=e}#c=new Map;get sandboxBlacklist(){return Object.freeze({set:Object.freeze([...this.#ue.set]),get:Object.freeze([...this.#ue.get])})}get plugins(){return Object.fromEntries(this.#c)}get pluginsSize(){return this.#c.size}get accessControlWhitelist(){return Object.freeze({ids:Object.freeze([...this.#ae.whitelist.ids]),authors:Object.freeze([...this.#ae.whitelist.authors]),categories:Object.freeze([...this.#ae.whitelist.categories]),tags:Object.freeze([...this.#ae.whitelist.tags])})}get accessControlBlacklist(){return Object.freeze({ids:Object.freeze([...this.#ae.blacklist.ids]),authors:Object.freeze([...this.#ae.blacklist.authors]),categories:Object.freeze([...this.#ae.blacklist.categories]),tags:Object.freeze([...this.#ae.blacklist.tags])})}get accessControlMode(){return this.#ae.mode}constructor(e){super(e.logCfg),F(e,this.#ae,this.#ue)}canAccessEngine(e,t,r,i){const{mode:n,whitelist:s,blacklist:o}=this.#ae;return U(n,e,t,r,i,s,o,this.#oe)}async verifyPluginSignature(e,t,r,i,n){return $(this.#ae,this.#oe,e,t,r,i,n)}_addPlugin(e){if(!(e instanceof q))throw new TypeError("The provided plugin must be an instance of TinyPlugin.");if(!this.canAccessEngine(e.id,e.authors,e.categories,e.tags))throw new Error(`Security Error: Access to the core is denied for plugin "${e.id}" based on current access control rules.`);this.#c.set(e.id,e)}installPlugin(e,...t){return q._addModuleToCore(this,e,...t)}hasPlugin(e){return this.#c.has("string"==typeof e?e:e.id)}getPlugin(e){const t=this.#c.get(e);return t&&!t.isDestroyed?t:void 0}_getPlugin(e,t){if(!(t instanceof q))throw new TypeError("The provided external plugin must be an instance of TinyPlugin.");const r=this.#c.get(e);if(r&&!r.isDestroyed){if(!r.layer.canAccessLayer(t.id,t.authors,t.categories,t.tags))throw new Error(`Security Error: Access to the plugin "${e}" is denied for plugin "${t.id}" based on current plugin access control rules.`);return r}}destroyPlugins(){this.#oe.clear(),this.#c.forEach(e=>e.destroy()),this.emit(G.#ce)}}class q extends A{static#he={id:"[_main_class_TinyPlugin_reset_]",autoHideId:!0,logger:console,debugMode:!1,canEmitLogs:!1,useLogColors:!0};static get logCfg(){return{...q.#he}}static set logCfg(e){this.#he=e}static _addModuleToCore(e,t,...r){if(!(e instanceof G))throw new TypeError("The provided engine must be an instance of TinyPluginCore.");const i=new q({engine:e,installer:t,logCfg:{...q.#he,debugMode:e.debugMode}},...r);if(i._startPlugin(),e.hasPlugin(i))throw new Error(`A plugin with the name "${i.id}" is already registered.`);return e._addPlugin(i),i}#ue={get:new Set,set:new Set};#ge="";#fe="";#de=new Set;#pe=new Set;#ye=new Set;#me=new Set;#we=null;#be;#Ee;#ve;#se=!1;#Te=null;#Le=!1;#Ce=new Set;#Se=new Set;get isDestroyed(){return this.#Le}get plugins(){return I(this.#Le),Object.keys(this.#be.plugins)}get pluginsSize(){return I(this.#Le),this.#be.pluginsSize}getPlugin(e){return I(this.#Le),this.#be._getPlugin(e,this)}hasPlugin(e){return I(this.#Le),this.#be.hasPlugin(e)}get isReady(){return I(this.#Le),this.#se}get id(){if(I(this.#Le),0===this.#ge.length)throw new Error("Plugin id is not set.");return this.#ge}set id(e){if(I(this.#Le),0!==this.#ge.length)throw new Error("Id is already set.");if("string"!=typeof e)throw new TypeError("Id must be a string.");if(0===e.length)throw new TypeError("Id cannot be empty.");this.#ge=e,this.logSubId=`${this.#be.logId} [_sub_class_${e}_reset_]`}get description(){if(I(this.#Le),0===this.#fe.length)throw new Error("Plugin description is not set.");return this.#fe}set description(e){if(I(this.#Le),0!==this.#fe.length)throw new Error("Description is already set.");if("string"!=typeof e)throw new TypeError("Description must be a string.");if(0===e.length)throw new TypeError("Description cannot be empty.");this.#fe=e}get authors(){if(I(this.#Le),0===this.#de.size)throw new Error("Plugin authors is not set.");return Object.freeze([...this.#de])}set authors(e){if(I(this.#Le),0!==this.#de.size)throw new Error("Authors is already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Authors must be a array of non-empty strings.");if(0===e.length)throw new TypeError("Authors cannot be empty.");e.forEach(e=>this.#de.add(e))}get contributors(){if(I(this.#Le),0===this.#pe.size)throw new Error("Plugin contributors is not set.");return Object.freeze([...this.#pe])}set contributors(e){if(I(this.#Le),0!==this.#pe.size)throw new Error("Authors is already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Authors must be a array of non-empty strings.");if(0===e.length)throw new TypeError("Authors cannot be empty.");e.forEach(e=>this.#pe.add(e))}get categories(){if(I(this.#Le),0===this.#ye.size)throw new Error("Plugin categories are not set.");return Object.freeze([...this.#ye])}set categories(e){if(I(this.#Le),0!==this.#ye.size)throw new Error("Categories are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Categories must be an array of non-empty strings.");if(0===e.length)throw new TypeError("Categories cannot be empty.");e.forEach(e=>this.#ye.add(e))}get tags(){if(I(this.#Le),0===this.#me.size)throw new Error("Plugin tags are not set.");return Object.freeze([...this.#me])}set tags(e){if(I(this.#Le),0!==this.#me.size)throw new Error("Tags are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("Tags must be an array of non-empty strings.");if(0===e.length)throw new TypeError("Tags cannot be empty.");e.forEach(e=>this.#me.add(e))}get allowedSets(){return I(this.#Le),[...this.#Se]}set allowedSets(e){if(I(this.#Le),0!==this.#Se.size||this.#se)throw new Error("AllowedSets are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("AllowedSets must be an array of non-empty strings.");if(0===e.length)throw new TypeError("AllowedSets cannot be empty.");e.forEach(e=>this.#Se.add(e))}get allowedGets(){return I(this.#Le),[...this.#Ce]}set allowedGets(e){if(I(this.#Le),0!==this.#Ce.size||this.#se)throw new Error("AllowedGets are already set.");if(!Array.isArray(e)||!e.every(e=>"string"==typeof e&&0!==e.trim().length))throw new TypeError("AllowedGets must be an array of non-empty strings.");if(0===e.length)throw new TypeError("AllowedGets cannot be empty.");e.forEach(e=>this.#Ce.add(e))}get version(){if(I(this.#Le),!this.#we)throw new Error("Plugin version is not set.");return this.#we.toString()}set version(e){if(I(this.#Le),this.#we)throw new Error("Version is already set.");if("string"!=typeof e)throw new TypeError("Version must be a string.");if(0===e.length)throw new TypeError("Version cannot be empty.");this.#we=new O(e)}get tinyVersion(){if(I(this.#Le),!this.#we)throw new Error("Plugin version is not set.");return this.#we}get layer(){if(I(this.#Le),null===this.#Te)throw new Error("Plugin layer is not set.");return this.#Te._createSandbox([...this.#Se],[...this.#Ce])}get engine(){if(I(this.#Le),!this.#be.canAccessEngine(this.#ge,[...this.#de],[...this.#ye],[...this.#me]))throw new Error(`Security Error: Access to the engine is denied for plugin "${this.id}" based on current access control rules.`);const e=this.#ue;return new Proxy(this.#be,{get(t,r){if(e.get.has(r))throw new Error(`Security Error: Access to property "${String(r)}" is denied by the sandbox.`);const i=Reflect.get(t,r,t);return"function"==typeof i?i.bind(t):i},set(t,r,i){if(e.set.has(r))throw new Error("Security Error: Cannot modify read-only properties on the plugin sandbox.");return Reflect.set(t,r,i)},setPrototypeOf(){throw new Error("Security Error: Prototype manipulation is forbidden.")}})}get options(){return I(this.#Le),this.#ve}get engineBlacklist(){return I(this.#Le),this.#be.sandboxBlacklist}constructor({engine:e,logCfg:t,installer:r},...i){super(t),this.#be=e,this.#Ee=r,this.#ve=i}#Pe(){const e=["id","version","description","authors","contributors","categories","tags","allowedGets","allowedSets"];return D(this,this.#be.sandboxBlacklist,this.#ue,e,[...e,"tinyVersion","isReady","layer","options","engine","engineBlacklist","isDestroyed","pluginsSize","plugins","hasPlugin","getPlugin","log","logClear","logGroupEnd","logLabel","logTimeLabel","logAssert","logDir","logTable","toConsole","isDestroyed"],["getPlugin","_getPlugin","plugins","installPlugin","_addPlugin","destroyPlugins"],["accessControlMode","accessControlWhitelist","accessControlBlacklist","verifyPluginSignature","canAccessEngine"])}_startPlugin(){if(I(this.#Le),this.#se)throw new Error("Plugin is already ready.");this.#ve&&Object.freeze(this.#ve);const e=this.#Pe();try{if(this.#Te=this.#Ee(e,...this.#ve),!(this.#Te instanceof z))throw new TypeError("Plugin layer is not a valid TinyPluginLayer instance.");if(this.#Te.debugMode=this.debugMode,this.#Te.isReady||this.#Te._startLayer(this),0===this.#ge.length)throw new Error("Plugin id is not set.");if(0===this.#fe.length)throw new Error("Plugin description is not set.");if(0===this.#de.size)throw new Error("Plugin authors are not set.");if(0===this.#pe.size)throw new Error("Plugin contributors are not set.");if(0===this.#ye.size)throw new Error("Plugin categories are not set.");if(0===this.#me.size)throw new Error("Plugin tags are not set.");if(!this.#we)throw new Error("Plugin version is not set.");this.#se=!0}catch(e){throw this.emit("error",e),this.destroy(),new Error(`Plugin initialization failed: ${e instanceof Error?e.message:"Unknown Error"}`)}}destroy(){this.#Le||(this.emit("destroyed"),this.#Te?.emit("destroyed"),this.#Le=!0)}}const B=class extends P{constructor(e){super(L,e)}}.codeIs,H=Object.freeze(["immediate","wait","manual"]),V=Object.freeze(["immediate","wait","manual"]),K=Object.freeze(["before","after"]),Y=Object.freeze([["installStrategy",H],["activateStrategy",V],["installOrder",K],["activateOrder",K]]),X=Object.freeze({install:"installOrder",activate:"activateOrder"}),J=self,Z=(e,t)=>({event:t,error:e instanceof Error?e:new Error("Unknown Error")});class Q extends Event{#Re;#Me;#ke;get notification(){return this.#ke}get action(){return this.#Me}constructor(e,t,r=""){super("notificationclick"),this.#Re=e,this.#Me=r,this.#ke={title:t.title,body:t.body,...t.options,close:()=>{}}}waitUntil(e){return this.#Re.waitUntil(e)}}class ee extends G{static#e=i;static get PUSH_TYPE(){return ee.#e}static#xe(e){if(e.startsWith("sw:"))throw new TypeError(`The event type "${e}" is reserved for internal PWA lifecycle management and cannot be used for Service Worker messaging.`)}static#Ae(e,t,r=!1){if("string"!=typeof e)throw new TypeError("[TinyServiceWorkerEngine] replyTemplate: type must be a string. Received: "+typeof e);if(void 0!==t&&(Array.isArray(t)||"object"!=typeof t||null===t))throw new TypeError("[TinyServiceWorkerEngine] replyTemplate: payload must be a non-null object when provided.");if("boolean"!=typeof r)throw new TypeError("[TinyServiceWorkerEngine] replyTemplate: strict must be a boolean. Received: "+typeof r);return r&&ee.#xe(e),{type:e,data:t}}static replyTemplate(e,t){return ee.#Ae(e,t,!0)}static#je(e,t,r,i=!1){if(!(e instanceof Client))throw new TypeError("[TinyServiceWorkerEngine] replyTo: targetSource must be a valid Client with a postMessage method.");if("boolean"!=typeof i)throw new TypeError("[TinyServiceWorkerEngine] replyTo: strict must be a boolean. Received: "+typeof i);e.postMessage(ee.#Ae(t,r,i))}static replyTo(e,t,r){return ee.#je(e,t,r,!0)}static async#Oe(e,t=!1){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("[TinyServiceWorkerEngine] replyToAll: ops must be a non-null object.");if("boolean"!=typeof t)throw new TypeError("[TinyServiceWorkerEngine] replyToAll: strict must be a boolean. Received: "+typeof t);const{type:r,data:i,options:n={type:"window",includeUncontrolled:!0}}=e;if("string"!=typeof r||""===r.trim())throw new TypeError("[TinyServiceWorkerEngine] replyToAll: ops.type must be a non-empty string.");if(void 0!==i&&(Array.isArray(i)||"object"!=typeof i||null===i))throw new TypeError("[TinyServiceWorkerEngine] replyToAll: ops.data must be a non-null object when provided.");if("object"!=typeof n||null===n||Array.isArray(n))throw new TypeError("[TinyServiceWorkerEngine] replyToAll: ops.options must be a non-null object when provided.");return J.clients.matchAll(n).then(e=>e.forEach(e=>{ee.#je(e,r,i,t)}))}static async replyToAll(e){return ee.#Oe(e,!0)}static isNavigate(e){return"navigate"===e.mode}static isSameOrigin(e){return(e instanceof Request?new URL(e.url):e).origin===self.location.origin}getCodeCfg(e){if("number"!=typeof e)throw new TypeError("Code must be a number.");let t;return t=this.#Ie.fetch.router.codes.get(e),t||(t=this.#_e[e].data),t||(t=this.createFetchRes({isError:!0,msg:this.#Fe.unknown.msg,logMsg:this.#Fe.unknown.logMsg,pathGetter:()=>this.globalPathGetter(this.#Fe.unknown.path)})),{...t}}set spaMode(e){if("boolean"!=typeof e)throw new TypeError('Invalid type for "spaMode": expected boolean, got '+typeof e);this.#Ie.spaMode=e}get spaMode(){return this.#Ie.spaMode}get lifecycle(){return m.clone(this.#Ie.lifecycle)}set lifecycle(e){ee.#Ne(e),this.#$e({lifecycle:e})}globalPathGetter(e){if("string"!=typeof e||""===e.trim())throw new TypeError("[TinyServiceWorkerEngine] globalPathGetter: path must be a non-empty string.");return this.#Ie.spaMode?this.#Fe.spaPath:e}#Ue=new Map;#We=new Map;#De=new Map;#ze=new Map;#Ge=new Map;#Fe={spaPath:"/index.html",unknown:{path:"/500.html",msg:"Unknown",logMsg:"Unknown route error"},200:{path:null,msg:"Success",logMsg:"Valid route"},404:{path:"/404.html",msg:"Not Found",logMsg:"Route not found"},500:{path:"/500.html",msg:"Internal Server Error",logMsg:"Route server error"}};#_e={200:{pathGetter:e=>this.globalPathGetter(e),data:{fn:e=>this.fetchFn(this.#Fe[200].msg,this.#Fe[200].logMsg,this.#_e[200].pathGetter,e),msg:this.#Fe[200].msg,logMsg:this.#Fe[200].logMsg}},404:{pathGetter:()=>this.globalPathGetter(this.#Fe[404].path),data:{fn:e=>this.fetchErrorFn(this.#Fe[404].msg,this.#Fe[404].logMsg,this.#_e[404].pathGetter,e),msg:this.#Fe[404].msg,logMsg:this.#Fe[404].logMsg}},500:{pathGetter:()=>this.globalPathGetter(this.#Fe[500].path),data:{fn:e=>this.fetchErrorFn(this.#Fe[500].msg,this.#Fe[500].logMsg,this.#_e[500].pathGetter,e),msg:this.#Fe[500].msg,logMsg:this.#Fe[500].logMsg}}};async fetchFn(e,t,r,i){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("[TinyServiceWorkerEngine] fetchFn: msg and logMsg must be strings.");if("string"!=typeof r&&"function"!=typeof r)throw new TypeError("[TinyServiceWorkerEngine] fetchFn: pathGetter must be a string or a function.");if("object"!=typeof i||null===i||!(i.url instanceof URL))throw new TypeError("[TinyServiceWorkerEngine] fetchFn: options.url must be a valid URL.");const{url:n,code:s,request:o,customPath:a}=i,l="string"==typeof a?a:"string"==typeof r?r:r(n.toString());this.log("info",`${s} - ${t}: ${n.pathname}`);try{return await fetch(l===n.toString()?o:l)}catch(e){return this.getCodeCfg(500).fn(i)}}async fetchErrorFn(e,t,r,i){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("[TinyServiceWorkerEngine] fetchErrorFn: msg and logMsg must be strings.");if("string"!=typeof r&&"function"!=typeof r)throw new TypeError("[TinyServiceWorkerEngine] fetchErrorFn: pathGetter must be a string or a function.");if("object"!=typeof i||null===i||!(i.url instanceof URL))throw new TypeError("[TinyServiceWorkerEngine] fetchErrorFn: options.url must be a valid URL.");const{url:n,code:s,event:o,request:a,resType:l,customMsg:c,customPath:u}=i,h="string"==typeof u?u:"string"==typeof r?r:r(n.toString());this.log("warn",`${s} - ${t}: ${n.pathname}`);const g="string"==typeof c?c:e;this.emit("fetchError",{event:o,request:a,error:new Error(`${s} ${g}`),url:n,resType:l});try{const e=await fetch(h);return new Response(e.body,{status:s,statusText:g,headers:e.headers})}catch{return new Response(this.#Fe[500].msg,{status:500})}}createFetchRes({isError:e,msg:t,logMsg:r,pathGetter:i}){if("boolean"!=typeof e)throw new TypeError("[TinyServiceWorkerEngine] createFetchRes: isError must be a boolean.");if("string"!=typeof t)throw new TypeError("[TinyServiceWorkerEngine] createFetchRes: msg must be a string.");if("string"!=typeof r)throw new TypeError("[TinyServiceWorkerEngine] createFetchRes: logMsg must be a string.");if("string"!=typeof i&&"function"!=typeof i)throw new TypeError("[TinyServiceWorkerEngine] createFetchRes: pathGetter must be a string or a function.");return{fn:n=>e?this.fetchErrorFn(t,r,i,n):this.fetchFn(t,r,i,n),msg:t,logMsg:r}}#qe=new s;set pushRouter(e){if(!(e instanceof s))throw new TypeError("[TinyServiceWorkerEngine] pushRouter must be a TinyPushRouter.");this.#qe=e}get pushRouter(){return this.#qe}#Ie={spaMode:!1,lifecycle:{installStrategy:"immediate",activateStrategy:"immediate",installOrder:"after",activateOrder:"after"},push:{enabled:!0,vapidPublicKey:"",subscribeEndpoint:"",defaultIcon:"/icons/notification-192.png",defaultBadge:"/icons/badge-72.png",defaultUrl:"/"},sync:{enabled:!0},fetch:{enabled:!0,router:{enabled:!1,codes:new Map}},messaging:{enabled:!0}};set config(e){this.#$e(e,!0)}get config(){return m.clone(this.#Ie)}#Be=new Map;#He=new Set;#Ve=new Map;#Ke=new Map;#Ye=new Map;#Xe=!1;get started(){return this.#Xe}#Je(e,t=!1){if("object"!=typeof e||null===e)throw new TypeError("Configuration must be a non-null object.");const r=(e,r,i,n)=>{const s=e[r];if(t&&void 0===s)throw new TypeError(`Missing required property: "${n}.${r}"`);if(void 0!==s&&typeof s!==i)throw new TypeError(`Invalid type for "${n}.${r}": expected ${i}, got ${typeof s}`)};if(r(e,"spaMode","boolean","root"),void 0!==e.fetch){if("object"!=typeof e.fetch||null===e.fetch)throw new TypeError("Fetch configuration must be a non-null object.");if(r(e.fetch,"enabled","boolean","fetch"),void 0!==e.fetch.router){if("object"!=typeof e.fetch.router||null===e.fetch.router)throw new TypeError("Fetch router configuration must be a non-null object.");if(r(e.fetch.router,"enabled","boolean","fetch.router"),void 0!==e.fetch.router.codes){if(!(e.fetch.router.codes instanceof Map))throw new TypeError("[TinyServiceWorkerEngine] validateConfig: fetch.router.codes must be a Map.");for(const[t,r]of e.fetch.router.codes.entries()){if("number"!=typeof t)throw new TypeError("[TinyServiceWorkerEngine] validateConfig: Map key must be a number. Received: "+typeof t);if("object"!=typeof r||null===r)throw new TypeError(`[TinyServiceWorkerEngine] validateConfig: Value for code ${t} must be an object.`);if("function"!=typeof r.fn)throw new TypeError(`[TinyServiceWorkerEngine] validateConfig: cfg.fn for code ${t} must be a function.`);if("string"!=typeof r.msg)throw new TypeError(`[TinyServiceWorkerEngine] validateConfig: cfg.msg for code ${t} must be a string.`);if("string"!=typeof r.logMsg)throw new TypeError(`[TinyServiceWorkerEngine] validateConfig: cfg.logMsg for code ${t} must be a string.`)}}else if(t)throw new TypeError('Missing required property: "fetch.router.codes"')}else if(t)throw new TypeError('Missing required property: "fetch.router"')}else if(t)throw new TypeError('Missing required property: "fetch"');if(void 0!==e.lifecycle){if(ee.#Ne(e.lifecycle),t)for(const[t]of Y)if(void 0===e.lifecycle[t])throw new TypeError(`Missing required property: "lifecycle.${t}"`)}else if(t)throw new TypeError('Missing required property: "lifecycle"');if(void 0!==e.sync){if("object"!=typeof e.sync||null===e.sync)throw new TypeError("Sync configuration must be a non-null object.");r(e.sync,"enabled","boolean","sync")}else if(t)throw new TypeError('Missing required property: "sync"');if(void 0!==e.messaging){if("object"!=typeof e.messaging||null===e.messaging)throw new TypeError("Messaging configuration must be a non-null object.");r(e.messaging,"enabled","boolean","messaging")}else if(t)throw new TypeError('Missing required property: "messaging"')}#$e(e,t=!1){this.#Je(e,t);const r=e.messaging?{...this.#Ie.messaging,...e.messaging}:this.#Ie.messaging;let i=this.#Ie.fetch.router;e.fetch?.router&&(i={...this.#Ie.fetch.router,...e.fetch.router},i.codes instanceof Map&&(i.codes=new Map(Array.from(i.codes,([e,t])=>[e,{...t}]))));const n=e.fetch?{...this.#Ie.fetch,...e.fetch,router:i}:this.#Ie.fetch,s=e.push?{...this.#Ie.push,...e.push}:this.#Ie.push,o=e.lifecycle?{...this.#Ie.lifecycle,...e.lifecycle}:this.#Ie.lifecycle,a=e.sync?{...this.#Ie.sync,...e.sync}:this.#Ie.sync;this.#Ie={spaMode:e.spaMode??this.#Ie.spaMode,lifecycle:o,fetch:n,push:s,sync:a,messaging:r},this.#Je(this.#Ie,!0)}constructor(e={},t={}){super({logCfg:{id:"[_main_class_TinySW-Engine_reset_]",logger:t.logger??console,debugMode:t.debugMode??!1,useLogColors:t.useLogColors??!1}}),this.#$e(e)}static#Ze(e,t){if("string"!=typeof e||""===e.trim())throw new TypeError(`[TinyServiceWorkerEngine] ${t}: type must be a non-empty string.`)}static#Qe(e,t){if("function"!=typeof e)throw new TypeError(`[TinyServiceWorkerEngine] ${t}: callback must be a function.`)}get fetchRegExpSize(){return this.#Ve.size}addFetchRegExpListener(e,t){ee.#Ze(e,"addFetchRegExpListener"),ee.#Qe(t,"addFetchRegExpListener"),this.#Ve.set(e,t)}removeFetchRegExpListener(e){return ee.#Ze(e,"removeFetchRegExpListener"),this.#Ve.delete(e)}getFetchRegExpListener(e){return ee.#Ze(e,"getFetchRegExpListener"),this.#Ve.get(e)}hasFetchRegExp(e){return ee.#Ze(e,"hasFetchRegExp"),this.#Ve.has(e)}clearFetchRegExps(){return this.#Ve.clear()}get fetchUrlSize(){return this.#Ke.size}addFetchUrlListener(e,t){ee.#Ze(e,"addFetchUrlListener"),ee.#Qe(t,"addFetchUrlListener"),this.#Ke.set(e,t)}removeFetchUrlListener(e){return ee.#Ze(e,"removeFetchUrlListener"),this.#Ke.delete(e)}getFetchUrlListener(e){return ee.#Ze(e,"getFetchUrlListener"),this.#Ke.get(e)}hasFetchUrl(e){return ee.#Ze(e,"hasFetchUrl"),this.#Ke.has(e)}clearFetchUrls(){return this.#Ke.clear()}get fetchGlobalSize(){return this.#Ye.size}addFetchGlobalListener(e,t){ee.#Ze(e,"addFetchGlobalListener"),ee.#Qe(t,"addFetchGlobalListener"),this.#Ye.set(e,t)}removeFetchGlobalListener(e){return ee.#Ze(e,"removeFetchGlobalListener"),this.#Ye.delete(e)}getFetchGlobalListener(e){return ee.#Ze(e,"getFetchGlobalListener"),this.#Ye.get(e)}hasFetchGlobal(e){return ee.#Ze(e,"hasFetchGlobal"),this.#Ye.has(e)}clearFetchGlobals(){return this.#Ye.clear()}get messagesSize(){return this.#Be.size}addMessageListener(e,t){ee.#Ze(e,"addMessageListener"),ee.#Qe(t,"addMessageListener"),this.#Be.set(e,t)}removeMessageListener(e){return ee.#Ze(e,"removeMessageListener"),this.#Be.delete(e)}getMessageListener(e){return ee.#Ze(e,"getMessageListener"),this.#Be.get(e)}hasMessageListener(e){return ee.#Ze(e,"hasMessageListener"),this.#Be.has(e)}clearMessageListeners(){return this.#Be.clear()}get eventBlacklist(){return Array.from(this.#He)}addToEventBlacklist(e){ee.#Ze(e,"addToEventBlacklist"),this.#He.add(e)}removeFromEventBlacklist(e){return ee.#Ze(e,"removeFromEventBlacklist"),this.#He.delete(e)}hasInEventBlacklist(e){return ee.#Ze(e,"hasInEventBlacklist"),this.#He.has(e)}clearEventBlacklist(){this.#He.clear()}async skipWaiting(e){if(!(e instanceof ExtendableEvent))throw new TypeError("[TinyServiceWorkerEngine] skipWaiting: event must be an ExtendableEvent when provided.");return this.emit("beforeSkipWaiting",{event:e}),await J.skipWaiting(),this.emit("afterSkipWaiting",{event:e}),this.log("info","skipWaiting: activation requested."),!0}async claimClients(e={type:"window",includeUncontrolled:!0}){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("[TinyServiceWorkerEngine] claimClients: query must be a non-null object when provided.");this.emit("beforeClaim",{query:e}),await J.clients.claim();const t=await J.clients.matchAll(e);return this.emit("afterClaim",{query:e,clients:t}),this.log("info",`claimClients: ${t.length} client(s) claimed.`),t}async reloadClients(e){if(void 0!==e&&("string"!=typeof e||""===e.trim()))throw new TypeError("[TinyServiceWorkerEngine] reloadClients: url must be a non-empty string when provided.");const t=await J.clients.matchAll({type:"window",includeUncontrolled:!1});let r=0;for(const i of t)"function"==typeof i.navigate&&(await i.navigate(e??i.url),r+=1);return this.log("info",`reloadClients: ${r} client(s) navigated.`),r}static#et=Object.freeze({unknown:{nullablePath:!1},200:{nullablePath:!0},404:{nullablePath:!1},500:{nullablePath:!1}});static#tt(e,t,r){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError(`[TinyServiceWorkerEngine] globalMsgCode: "${t}" must be a non-null object.`);const{path:i,msg:n,logMsg:s}=e;if(null===i&&!r)throw new TypeError(`[TinyServiceWorkerEngine] globalMsgCode: "${t}.path" must be a non-empty string.`);if(null!==i&&("string"!=typeof i||""===i.trim()))throw new TypeError(`[TinyServiceWorkerEngine] globalMsgCode: "${t}.path" must be a non-empty string${r?" or null":""}.`);if("string"!=typeof n||""===n.trim())throw new TypeError(`[TinyServiceWorkerEngine] globalMsgCode: "${t}.msg" must be a non-empty string.`);if("string"!=typeof s||""===s.trim())throw new TypeError(`[TinyServiceWorkerEngine] globalMsgCode: "${t}.logMsg" must be a non-empty string.`)}static#rt(e,t=!1){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("[TinyServiceWorkerEngine] globalMsgCode must be a non-null object.");const r=["spaPath",...Object.keys(ee.#et)],i=new Set(Object.keys(e));if(t){const e=r.filter(e=>!i.has(e));if(e.length>0)throw new TypeError(`[TinyServiceWorkerEngine] globalMsgCode: missing required key(s): ${e.map(e=>`"${e}"`).join(", ")}.`)}for(const t of i){if(!r.includes(t))throw new TypeError(`[TinyServiceWorkerEngine] globalMsgCode: unknown key "${t}". Expected one of: ${r.map(e=>`"${e}"`).join(", ")}.`);if("spaPath"===t){const{spaPath:t}=e;if("string"!=typeof t||""===t.trim())throw new TypeError('[TinyServiceWorkerEngine] globalMsgCode: "spaPath" must be a non-empty string.');continue}const i=ee.#et[t];ee.#tt(e[t],t,i.nullablePath)}}static#Ne(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("[TinyServiceWorkerEngine] lifecycle must be a non-null object.");const t=e;for(const e of Object.keys(t))if(!Y.some(([t])=>t===e))throw new TypeError(`[TinyServiceWorkerEngine] lifecycle: unknown key "${e}". Expected one of: ${Y.map(([e])=>`"${e}"`).join(", ")}.`);for(const[e,r]of Y){const i=t[e];if(void 0!==i&&!r.includes(i))throw new TypeError(`[TinyServiceWorkerEngine] lifecycle.${e} must be one of ${r.join(", ")}. Received: ${String(i)}`)}}get globalMsgCode(){return m.clone(this.#Fe)}set globalMsgCode(e){ee.#rt(e,!0),this.#Fe=m.clone(e)}updateGlobalMsgCode(e){ee.#rt(e,!1),this.#Fe=m.clone({...this.#Fe,...e})}addRouterCode(e,t){if("number"!=typeof e)throw new TypeError("Code must be a number.");if("object"!=typeof t||null===t)throw new TypeError("Config must be an object.");if("function"!=typeof t.fn||"string"!=typeof t.msg||"string"!=typeof t.logMsg)throw new TypeError("Invalid RouterCodeConfig: fn must be a function, and msg/logMsg must be strings.");const r=new Map(this.#Ie.fetch.router.codes);r.set(e,m.clone(t)),this.#$e({fetch:{router:{codes:r}}})}removeRouterCode(e){if("number"!=typeof e)throw new TypeError("[TinyServiceWorkerEngine] removeRouterCode: code must be a number.");const t=new Map(this.#Ie.fetch.router.codes);return!!t.delete(e)&&(this.#$e({fetch:{router:{codes:t}}}),!0)}getRouterCode(e){if("number"!=typeof e)throw new TypeError("[TinyServiceWorkerEngine] getRouterCode: code must be a number.");const t=this.#Ie.fetch.router.codes.get(e);return t?m.clone(t):void 0}async#it(e,t){const r=e.request,i=ee.isSameOrigin(r),n={code:404,needValidation:i,continueCheck:!0},s={isSameOrigin:i,event:e,request:r,url:t,params:{},replyTemplate:ee.replyTemplate,replyTo:ee.replyTo,replyToAll:ee.replyToAll};for(const e of this.#Ye.values()){if(!n.continueCheck)break;try{await e(s,n)}catch(e){this.log("error","Error in global fetch tracking listener:",e),this.emit("fetchGlobalError",{error:e,fetchObj:s})}}if(n.continueCheck){const e=async e=>{try{this.emit("beforeFetchPlugin",s),await e(s,n),this.emit("afterFetchPlugin",s)}catch(e){n.code=500,s.error=e instanceof Error?e:new Error("Unknown Error."),n.continueCheck=!1,n.needValidation=!0,this.log("error",`Error executing fetch plugin for "${t.pathname}":`,e),this.emit("fetchPluginError",s)}};for(const[r,i]of this.#Ke.entries()){if(!n.continueCheck)break;if(r.includes("/:")){const n=c(r),{match:o,params:a}=n.exec(t.pathname);if(s.params={...s.params,...a},o){await e(i);continue}}t.pathname===r&&await e(i)}for(const[r,i]of this.#Ve.entries()){if(!n.continueCheck)break;new RegExp(r).test(t.pathname)&&await e(i)}}return n}addSyncListener(e,t){if("string"!=typeof e||""===e.trim())throw new TypeError("Tag must be a non-empty string.");if("function"!=typeof t)throw new TypeError("Callback must be a function.");this.#We.set(e,t)}removeSyncListener(e){if("string"!=typeof e||""===e.trim())throw new TypeError("[TinyServiceWorkerEngine] removeSyncListener: tag must be a non-empty string.");return this.#We.delete(e)}get syncListenerSize(){return this.#We.size}clearSyncListeners(){return this.#We.clear()}get installListenerSize(){return this.#De.size}addInstallListener(e,t){ee.#Ze(e,"addInstallListener"),ee.#Qe(t,"addInstallListener"),this.#De.set(e,t)}removeInstallListener(e){return ee.#Ze(e,"removeInstallListener"),this.#De.delete(e)}getInstallListener(e){return ee.#Ze(e,"getInstallListener"),this.#De.get(e)}hasInstallListener(e){return ee.#Ze(e,"hasInstallListener"),this.#De.has(e)}clearInstallListeners(){return this.#De.clear()}get activateListenerSize(){return this.#ze.size}addActivateListener(e,t){ee.#Ze(e,"addActivateListener"),ee.#Qe(t,"addActivateListener"),this.#ze.set(e,t)}removeActivateListener(e){return ee.#Ze(e,"removeActivateListener"),this.#ze.delete(e)}getActivateListener(e){return ee.#Ze(e,"getActivateListener"),this.#ze.get(e)}hasActivateListener(e){return ee.#Ze(e,"hasActivateListener"),this.#ze.has(e)}clearActivateListeners(){return this.#ze.clear()}offApi(e){return ee.#Ze(e,"offApi"),this.#Ue.delete(e)}onApi(e,t){ee.#Ze(e,"onApi"),ee.#Qe(t,"onApi"),this.#Ue.set(e,t)}async emitApi(e,t,r,i=1e4){if(!(e instanceof Client))throw new TypeError("[TinyServiceWorkerEngine] emitApi: client must be a valid Client.");if("string"!=typeof t||""===t.trim())throw new TypeError("[TinyServiceWorkerEngine] emitApi: type must be a non-empty string.");if(void 0!==r&&(Array.isArray(r)||"object"!=typeof r||null===r))throw new TypeError("[TinyServiceWorkerEngine] emitApi: data must be a non-null object when provided.");if("number"!=typeof i||!Number.isFinite(i)||i<0)throw new TypeError("[TinyServiceWorkerEngine] emitApi: timeout must be a non-negative finite number.");const n=crypto.randomUUID();return new Promise((s,o)=>{const a=setTimeout(()=>{this.#Ge.has(n)&&(this.#Ge.delete(n),o(new Error(`API timeout: ${t}`)))},i);this.#Ge.set(n,{resolve:s,reject:o,timer:a}),e.postMessage({type:t,data:r,correlationId:n,isApi:!0})})}async#nt(e){const t=this.#Ie.push,r=await l.fromEvent(e);if(l.isExpired(r))return void this.log("warn",`Discarded expired push: ${r.id??r.type}.`);const i={event:e,message:r,engine:this,handled:!1,notificationShown:!1};this.emit("push",i);let n=null;try{if(!await this.#qe.dispatch(r,i)&&r.notification){const{title:e,options:n}=l.toNotification(r,t);await this.showNotification(e,n.body??"",n),i.notificationShown=!0}}catch(t){const r=Z(t,e);n=r.error,this.emit("pushError",r),this.log("error","Failed to handle push message.",t)}finally{await ee.#Oe({type:"sw:PushReceived",data:{...r,notificationShown:!0===i.notificationShown,error:n?n.message:null}},!1)}}async#st(e){const t=e.action||null,r=e.notification.data??{},i=t?r.actions?.[t]:r.url;if(this.emit("notificationclick",{event:e,action:t,data:r}),!i)return void e.notification.close();const n=new URL(i,J.location.origin).href,s=await J.clients.matchAll({type:"window",includeUncontrolled:!0});for(const t of s)if(t.url===n&&"focus"in t)return await t.focus(),void e.notification.close();await J.clients.openWindow(n),e.notification.close()}async#ot(e){this.emit("pushsubscriptionchange",{event:e}),await ee.#Oe({type:"sw:PushSubscriptionChange"},!1)}async showNotification(e,t,r={}){if(!this.#Ie.push.enabled)throw new Error("[TinyServiceWorkerEngine] showNotification: Push notifications are disabled in the configuration.");if("string"!=typeof e||""===e.trim())throw new TypeError("Notification title must be a non-empty string.");if("string"!=typeof t)throw new TypeError("Notification body must be a string.");return J.registration.showNotification(e,{body:t,...r})}async#at(e,t,r,i){if("function"!=typeof i)throw new TypeError("[TinyServiceWorkerEngine] runLifecycleListeners: resolveStrategy must be a function. Received: "+typeof i);const n=X[r];if(void 0===n)throw new TypeError(`[TinyServiceWorkerEngine] runLifecycleListeners: unknown phase "${String(r)}".`);const s="before"===this.#Ie.lifecycle[n];s&&await i(t);for(const[i,n]of e.entries())try{await n({event:t})}catch(e){this.log("error",`Error in ${r} handler for tag "${i}":`,e),this.emit(`${r}ListenerError`,{event:t,tag:i,error:e})}s||await i(t)}async#lt(e){const{installStrategy:t}=this.#Ie.lifecycle;switch(t){case"immediate":return void await this.skipWaiting(e);case"wait":return void this.log("info",'install: strategy "wait" active, the worker stays in the waiting state.');case"manual":return this.log("info",'install: strategy "manual" active, call skipWaiting() to activate.'),void this.emit("waitingForActivation",{event:e});default:throw new TypeError(`[TinyServiceWorkerEngine] resolveInstall: unknown install strategy "${String(t)}".`)}}async#ct(e){const{activateStrategy:t}=this.#Ie.lifecycle;switch(t){case"immediate":return void await this.claimClients();case"wait":return void this.log("info",'activate: strategy "wait" active, clients will not be claimed.');case"manual":return this.log("info",'activate: strategy "manual" active, call claimClients() to claim.'),void this.emit("waitingForClaim",{event:e});default:throw new TypeError(`[TinyServiceWorkerEngine] resolveActivate: unknown activate strategy "${String(t)}".`)}}init(){if(this.#Xe)throw new Error("TinyServiceWorkerEngine is already initialized.");J.addEventListener("install",e=>{e.waitUntil(this.#at(this.#De,e,"install",e=>this.#lt(e)).catch(t=>this.emit("installError",Z(t,e))))}),J.addEventListener("activate",e=>{this.emit("beforeActivated",{event:e}),e.waitUntil(this.#at(this.#ze,e,"activate",e=>this.#ct(e)).then(()=>{this.emit("afterActivated",{event:e}),this.log("info","Activated.")}).catch(t=>this.emit("activateError",Z(t,e))))}),this.#Ie.push.enabled&&(J.addEventListener("push",e=>{e.waitUntil(this.#nt(e).catch(t=>{this.emit("pushError",Z(t,e))}))}),J.addEventListener("notificationclick",e=>{e.waitUntil(this.#st(e))}),J.addEventListener("notificationclose",e=>{this.emit("notificationclose",{event:e})}),J.addEventListener("pushsubscriptionchange",e=>{e.waitUntil(this.#ot(e))})),this.#Ie.sync.enabled&&J.addEventListener("sync",e=>{const t=e.tag,r=this.#We.get(t);this.emit("beforeSync",{event:e,tag:t}),r?e.waitUntil((async()=>{try{await r({event:e,tag:t}),this.emit("afterSync",{event:e,tag:t})}catch(r){this.log("error",`Error in sync handler for tag "${t}":`,r),this.emit("syncError",{event:e,tag:t,error:r})}})()):this.emit("afterSync",{event:e,tag:t})});const e=this.#Ie.fetch;e.enabled&&J.addEventListener("fetch",t=>{const r=t.request,i=new URL(r.url);this.emit("fetchRequested",{event:t,request:r,url:i});const n=e.router;t.respondWith((async()=>{const e=await this.#it(t,i),s=(e,s,o)=>{if(n.enabled){const n=(e=>B.info(e)?"info":B.success(e)?"success":B.redirect(e)?"redirect":B.clientError(e)?"client-error":B.serverError(e)?"server-error":"unknown")(e);return this.getCodeCfg(e).fn({code:e,resType:n,url:i,request:r,event:t,customMsg:s,customPath:o})}return null};if("boolean"!=typeof e.continueCheck){const e=s(500,"Received fetch result data with invalid continueCheck format (expected boolean).");if(null!==e)return e}if(!e.continueCheck)return fetch(r);if(void 0!==e.customPath&&"string"!=typeof e.customPath){const e=s(500,"Received fetch result data with invalid customPath format (expected string).");if(null!==e)return e}if(void 0!==e.customMsg&&"string"!=typeof e.customMsg){const e=s(500,"Received fetch result data with invalid customMsg format (expected string).");if(null!==e)return e}if(void 0!==e.customResponse&&!(e.customResponse instanceof Response)){const e=s(500,"Received fetch result data with invalid customResponse format (expected Response).");if(null!==e)return e}if("boolean"!=typeof e.needValidation){const e=s(500,"Received fetch result data with invalid needValidation format (expected boolean).");if(null!==e)return e}if("number"!=typeof e.code||Number.isNaN(e.code)||e.code<1){const e=s(500,"Received fetch result data with invalid code format (expected number greater than 0).");if(null!==e)return e}if(e.customResponse instanceof Response)return e.customResponse;if(e.needValidation){const t=s(e.code,e.customMsg,e.customPath);if(null!==t)return t}return fetch(r)})())}),this.#Ie.messaging.enabled&&J.addEventListener("message",e=>{if(!(e.source instanceof Client))return void this.log("error","Message received from an invalid source (not a Client).");if(Array.isArray(e.data)||"object"!=typeof e.data||null===e.data)return void this.log("error","Received message with invalid data format (expected object).");if(void 0!==e.data.data&&(Array.isArray(e.data.data)||"object"!=typeof e.data.data||null===e.data.data))return void this.log("error","Received message data with invalid data format (expected object).");if("string"!=typeof e.data.type)return void this.log("error",'Received message with missing or invalid "type" string.');if(this.#He.has(e.data.type))return void this.log("warn",`Ignored blacklisted event: ${e.data.type}`);const t=e.data.type,r=e.data.data,i=e.source,n=i.id,s=e.data.correlationId,o=e.data.isApi,a=(t,r)=>{e.source instanceof Client?ee.replyTo(e.source,t,r):this.log("warn","Attempted to reply to a non-client source.")};if("sw:ApiResponse"===t){if("string"!=typeof s)return void this.log("error",'Received message with missing or invalid "correlationId" string.');const t=this.#Ge.get(s);return void(t&&(this.#Ge.delete(s),r&&r.error?t.reject(new Error(e.data.error||r.error)):t.resolve(r)))}if("sw:SkipWaiting"===t)return void e.waitUntil(this.skipWaiting(e).catch(t=>{this.emit("skipWaitingError",Z(t,e))}));if("sw:NotificationClicked"===t){const t=new Q(e,{title:r?.title,body:r?.body,options:r?.options});return void e.waitUntil(this.#st(t))}if("sw:NotificationClosed"===t)return void this.emit("notificationclose",{event:e,data:r});if(!0===o){if("string"!=typeof s)return void this.log("error",'Received message with missing or invalid "correlationId" string.');const o=this.#Ue.get(t);if(!o)return void i.postMessage({correlationId:s,type:"sw:ApiResponse",error:`No API handler registered for type: ${t}`});try{const t=e=>i.postMessage({correlationId:s,type:"sw:ApiResponse",data:e}),l=o({data:r,correlationId:s,clientId:n,reply:a,replyTemplate:ee.replyTemplate,replyTo:ee.replyTo,replyToAll:ee.replyToAll,replyApi:async(t,r,n)=>{if(e.source instanceof Client)return this.emitApi(i,t,r,n);this.log("warn","Attempted to reply to a non-client source.")}});l instanceof Promise?l.then(t):t(l)}catch(e){i.postMessage({correlationId:s,type:"sw:ApiResponse",error:e instanceof Error?e.message:String(e)})}return}"sw:PrepareUpdate"===e.data.type&&(this.log("info","Update signal received. Starting installation..."),this.emit("beforeUpdated",{event:e}),e.waitUntil(J.registration.update().then(()=>{this.emit("afterUpdated",{event:e}),ee.#Oe({type:"sw:Updated"}),this.log("info","Update successful, waiting for activation.")}).catch(t=>{const r=t instanceof Error?t:new Error("Unknown Error.");this.emit("updateError",Z(r,e)),ee.#Oe({type:"sw:UpdateError",data:{message:r.message,name:r.name,stack:r.stack}}),this.log("error","Update failed:",r)})));const l=this.#Be.get(t),c={event:e,data:r,clientId:n,reply:a,replyTemplate:ee.replyTemplate,replyTo:ee.replyTo,replyToAll:ee.replyToAll};let u=null;this.emit("beforeMessage",{event:e,type:t,data:c});const h=()=>({event:e,type:t,error:u,data:c});if(l){const r=e=>{u=e instanceof Error?e:new Error("Unknown Error"),this.log("error",`Error executing handler for message type "${t}":`,e),this.emit("messageError",h())};try{const t=l(c);t instanceof Promise?e.waitUntil(t.then(()=>this.emit("afterMessage",h())).catch(r)):this.emit("afterMessage",h())}catch(e){r(e)}}else this.emit("afterMessage",h())}),this.#Xe=!0,this.log("info","Initialized with custom configuration.")}}const te=ee;window.TinyServiceWorkerEngine=t.TinyServiceWorkerEngine})();
@@ -0,0 +1 @@
1
+ (()=>{"use strict";const e={d:(t,a)=>{for(var r in a)e.o(a,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:a[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};e.r(t),e.d(t,{TinyMapDb:()=>n,TinySetDb:()=>i,TinySetMapDatabase:()=>o,TinyTableDb:()=>s});const a=class{#e=[];#t=!1;#a={};#r=new Set;isRunning(){return this.#t}async#s(e){if(e&&"function"==typeof e.task&&"function"==typeof e.resolve&&"function"==typeof e.reject){const{task:t,resolve:a,reject:r,delay:s,id:i}=e;try{if(i&&this.#r.has(i))return r(new Error("The function was canceled on TinyPromiseQueue.")),this.#r.delete(i),this.#t=!1,void this.#i();s&&i&&await new Promise(e=>{const t=setTimeout(()=>{delete this.#a[i],e(null)},s);this.#a[i]=t}),a(await t())}catch(e){r(e)}finally{this.#t=!1,this.#i()}}}async#n(){const e=[];for(;this.#e.length&&"POINT_MARKER"===this.#e[0]?.marker;)e.push(this.#e.shift());if(0===e.length)return this.#t=!1,void this.#i();await Promise.all(e.map(({task:e,resolve:t,reject:a,id:r})=>new Promise(async s=>{if(r&&this.#r.has(r))return this.#r.delete(r),a(new Error("The function was canceled on TinyPromiseQueue.")),void s(!0);await e().then(t).catch(a),s(!0)}))),this.#t=!1,this.#i()}async#i(){if(!this.#t&&0!==this.#e.length)if(this.#t=!0,"string"!=typeof this.#e[0]?.marker||"POINT_MARKER"!==this.#e[0]?.marker){const e=this.#e.shift();this.#s(e)}else this.#n()}getIndexById(e){return this.#e.findIndex(t=>t.id===e)}getQueuedIds(){return this.#e.map((e,t)=>({index:t,id:e.id})).filter(e=>"string"==typeof e.id)}reorderQueue(e,t){if("number"!=typeof e||"number"!=typeof t||e<0||t<0||e>=this.#e.length||t>=this.#e.length)return;const[a]=this.#e.splice(e,1);this.#e.splice(t,0,a)}async enqueuePoint(e,t){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&"string"!=typeof t)throw new Error('The "id" parameter must be a string.');return this.#t?new Promise((a,r)=>{this.#e.push({marker:"POINT_MARKER",task:e,resolve:a,reject:r,id:t}),this.#i()}):e()}enqueue(e,t,a){if("function"!=typeof e)return Promise.reject(new Error("Task must be a function returning a Promise."));if(void 0!==t&&("number"!=typeof t||t<0))return Promise.reject(new Error("Delay must be a positive number or undefined."));if(void 0!==a&&"string"!=typeof a)throw new Error('The "id" parameter must be a string.');return new Promise((r,s)=>{this.#e.push({task:e,resolve:r,reject:s,id:a,delay:t}),this.#i()})}cancelTask(e){if("string"!=typeof e)throw new Error('The "id" parameter must be a string.');let t=!1;e in this.#a&&(clearTimeout(this.#a[e]),delete this.#a[e],t=!0);const a=this.getIndexById(e);if(-1!==a){const[e]=this.#e.splice(a,1);e?.reject?.(new Error("The function was canceled on TinyPromiseQueue.")),t=!0}return t&&this.#r.add(e),t}};function r(e,t="value"){if("string"!=typeof e||0===e.length)throw new TypeError(`The "${t}" argument must be a non-empty string.`)}class s{#o;#c;#h=new a;#u=new a;#l=null;#y=!1;constructor({storeName:e,openDatabase:t}){if(r(e,"storeName"),"function"!=typeof t)throw new TypeError('The "openDatabase" option must be a function.');this.#o=e,this.#c=t}get storeName(){return this.#o}get isReady(){return this.#y}get[Symbol.toStringTag](){return this.constructor.name}hydrate(){return this.#l??=this.#d(),this.#l}_action(e){return this.#u.enqueue(e)}_write(e){return this.#h.enqueue(e)}async _persist(e){const t=await this.#c();await new Promise((a,r)=>{const s=t.transaction(this.#o,"readwrite").objectStore(this.#o).put(e);s.onsuccess=()=>a(void 0),s.onerror=()=>r(s.error)})}async _remove(e){const t=await this.#c();await new Promise((a,r)=>{const s=t.transaction(this.#o,"readwrite").objectStore(this.#o).delete(e);s.onsuccess=()=>a(void 0),s.onerror=()=>r(s.error)})}async _clear(){const e=await this.#c();await new Promise((t,a)=>{const r=e.transaction(this.#o,"readwrite").objectStore(this.#o).clear();r.onsuccess=()=>t(void 0),r.onerror=()=>a(r.error)})}async#d(){const e=await this.#c(),t=await s.#f(e,this.#o);this._load(t),this.#y=!0}_load(e){throw new Error(`The "_load" method of "${this.constructor.name}" is not implemented.`)}static#f(e,t){return new Promise((a,r)=>{const s=e.transaction(t,"readonly").objectStore(t).getAll();s.onsuccess=()=>a(s.result),s.onerror=()=>r(s.error)})}}class i extends s{#w;#m=new Set;constructor({storeName:e,openDatabase:t,validate:a=null}){if(super({storeName:e,openDatabase:t}),null!==a&&"function"!=typeof a)throw new TypeError('The "validate" option must be a function or null.');this.#w=a}get size(){return this.#m.size}async has(e){r(e),this.#p(e),await this.hydrate();let t=!1;return await this._action(async()=>{t=this.#m.has(e)}),t}async add(e){r(e),this.#p(e),await this.hydrate();let t=!1;return await this._action(async()=>{this.#m.has(e)||(await this._write(()=>this._persist({value:e,timestamp:Date.now()})),this.#m.add(e),t=!0)}),t}async delete(e){r(e),this.#p(e),await this.hydrate();let t=!1;return await this._action(async()=>{this.#m.has(e)&&(await this._write(()=>this._remove(e)),this.#m.delete(e),t=!0)}),t}async clear(){await this.hydrate(),await this._action(async()=>{await this._write(()=>this._clear()),this.#m.clear()})}async toArray(){return await this.hydrate(),[...this.#m]}async toJSON(){return this.toArray()}async*values(){await this.hydrate();for(const e of[...this.#m])yield e}keys(){return this.values()}async*entries(){for await(const e of this.values())yield[e,e]}[Symbol.asyncIterator](){return this.values()}async forEach(e,t){if("function"!=typeof e)throw new TypeError('The "callbackFn" argument must be a function.');await this.hydrate();for(const a of[...this.#m])e.call(t,a,a,this)}async union(...e){await this.hydrate();const t=new Set(this.#m);for(const a of e){const e=await i.#b(a);for(const a of e)t.add(a)}return t}async intersection(e){const t=await i.#b(e);await this.hydrate();const a=new Set;for(const e of this.#m)t.has(e)&&a.add(e);return a}async difference(e){const t=await i.#b(e);await this.hydrate();const a=new Set;for(const e of this.#m)t.has(e)||a.add(e);return a}async symmetricDifference(e){const t=await i.#b(e);await this.hydrate();const a=new Set;for(const e of this.#m)t.has(e)||a.add(e);for(const e of t)this.#m.has(e)||a.add(e);return a}async isSubsetOf(e){const t=await i.#b(e);await this.hydrate();for(const e of this.#m)if(!t.has(e))return!1;return!0}async isSupersetOf(e){const t=await i.#b(e);await this.hydrate();for(const e of t)if(!this.#m.has(e))return!1;return!0}async isDisjointFrom(e){const t=await i.#b(e);await this.hydrate();for(const e of this.#m)if(t.has(e))return!1;return!0}_load(e){for(const t of e.sort((e,t)=>e.timestamp-t.timestamp))this.#m.add(t.value)}static async#b(e){if(e instanceof i)return new Set(await e.toArray());if(e instanceof Set)return new Set(e);if(Array.isArray(e))return new Set(e);throw new TypeError('The "other" argument must be a TinySetDb, a Set, or an Array.')}#p(e){if(null!==this.#w&&!this.#w(e))throw new TypeError(`The value is rejected by the "${this.storeName}" table validator.`)}}class n extends s{#w;#m=new Map;constructor({storeName:e,openDatabase:t,validate:a=null}){if(super({storeName:e,openDatabase:t}),null!==a&&"function"!=typeof a)throw new TypeError('The "validate" option must be a function or null.');this.#w=a}get size(){return this.#m.size}async has(e){r(e,"key"),await this.hydrate();let t=!1;return await this._action(async()=>{t=this.#m.has(e)}),t}async get(e){let t;return r(e,"key"),await this.hydrate(),await this._action(async()=>{t=this.#m.get(e)}),t}async set(e,t){return r(e,"key"),this.#p(e,t),await this.hydrate(),await this._action(async()=>{await this._write(()=>this._persist({key:e,value:t,timestamp:Date.now()})),this.#m.set(e,t)}),this}async delete(e){r(e,"key"),await this.hydrate();let t=!1;return await this._action(async()=>{this.#m.has(e)&&(await this._write(()=>this._remove(e)),this.#m.delete(e),t=!0)}),t}async clear(){await this.hydrate(),await this._action(async()=>{await this._write(()=>this._clear()),this.#m.clear()})}async toArray(){return await this.hydrate(),[...this.#m.entries()]}async toJSON(){return this.toArray()}async*keys(){await this.hydrate();for(const e of[...this.#m.keys()])yield e}async*values(){await this.hydrate();for(const e of[...this.#m.values()])yield e}async*entries(){await this.hydrate();for(const e of[...this.#m.entries()])yield e}[Symbol.asyncIterator](){return this.entries()}async forEach(e,t){if("function"!=typeof e)throw new TypeError('The "callbackFn" argument must be a function.');await this.hydrate();for(const[a,r]of[...this.#m])e.call(t,r,a,this)}_load(e){for(const t of e.sort((e,t)=>e.timestamp-t.timestamp))this.#m.set(t.key,t.value)}#p(e,t){if(null!==this.#w&&!this.#w(e,t))throw new TypeError(`The entry is rejected by the "${this.storeName}" table validator.`)}}class o{#g;#v;#T=new Map;#E;#l;constructor(e,t){if(r(e,"name"),!Array.isArray(t)||0===t.length)throw new TypeError('The "migrations" argument must be a non-empty array.');this.#g=e,this.#v=t.length;const a=t.map((e,t)=>o.#S(e,t)),s=o.#_(a);this.#E=o.#c(e,a);for(const e of s.values()){const t={storeName:e.name,validate:e.validate,openDatabase:()=>this.#E};"map"===e.type?this.#T.set(e.name,new n(t)):this.#T.set(e.name,new i(t))}this.#l=this.#E.then(()=>Promise.all([...this.#T.values()].map(e=>e.hydrate())).then(()=>{})),this.#l.catch(()=>{})}get name(){return this.#g}get version(){return this.#v}get tableNames(){return[...this.#T.keys()]}get ready(){return this.#l}tableSet(e){r(e,"tableName");const t=this.#T.get(e);if(void 0===t)throw new RangeError(`The "${e}" table is not declared in this database.`);if(!(t instanceof i))throw new Error(`The "${e}" table is not a Set instance.`);return t}tableMap(e){r(e,"tableName");const t=this.#T.get(e);if(void 0===t)throw new RangeError(`The "${e}" table is not declared in this database.`);if(!(t instanceof n))throw new Error(`The "${e}" table is not a Map instance.`);return t}has(e){return r(e,"tableName"),this.#T.has(e)}async close(){(await this.#E).close()}static#k(e){if("string"==typeof e)return{name:e,type:"set",validate:null};if("object"!=typeof e||null===e)throw new TypeError('Each table must be a string or an object with a "name" property.');const{name:t,type:a,validate:s=null}=e;if(r(t,"table.name"),"set"!==a&&"map"!==a)throw new TypeError(`The "type" option of the "${t}" table must be "set" or "map".`);if(null!==s&&"function"!=typeof s)throw new TypeError(`The "validate" option of the "${t}" table must be a function.`);return{name:t,type:a,validate:s}}static#c(e,t){return new Promise((a,r)=>{if("undefined"==typeof indexedDB)return void r(new ReferenceError("IndexedDB is not available in the current environment."));const s=indexedDB.open(e,t.length);s.onupgradeneeded=e=>{try{for(let a=e.oldVersion+1;a<=t.length;a+=1)o.#P(s.result,t[a-1])}catch(e){r(e),s.transaction?.abort()}},s.onsuccess=()=>{const e=s.result;e.onversionchange=()=>e.close(),a(e)},s.onerror=()=>r(s.error)})}static#P(e,t){for(const a of t.delete)e.objectStoreNames.contains(a)&&e.deleteObjectStore(a);for(const a of t.create)e.createObjectStore(a.name,{keyPath:"map"===a.type?"key":"value"})}static#S(e,t){if("object"!=typeof e||null===e)throw new TypeError(`The migration at index ${t} must be an object.`);const{create:a=[],delete:s=[]}=e;if(!Array.isArray(a))throw new TypeError(`The "create" list of the migration at index ${t} must be an array.`);if(!Array.isArray(s))throw new TypeError(`The "delete" list of the migration at index ${t} must be an array.`);for(const e of s)r(e,`migrations[${t}].delete[]`);return{create:a.map(e=>o.#k(e)),delete:[...s]}}static#_(e){const t=new Map;for(const a of e){for(const e of a.delete)t.delete(e);for(const e of a.create){if(t.has(e.name))throw new Error(`The "${e.name}" table is created twice.`);t.set(e.name,e)}}return t}}window.TinySetMapPackage=t})();
@@ -1 +1 @@
1
- (()=>{"use strict";const e={d:(r,t)=>{if(Array.isArray(t))for(var o=0;o<t.length;){var n=t[o++],s=t[o++];e.o(r,n)?0===s&&o++:0===s?Object.defineProperty(r,n,{enumerable:!0,value:t[o++]}):Object.defineProperty(r,n,{enumerable:!0,get:s})}else for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)};let r={};function t(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}e.d(r,{TinySimpleDice:()=>n});class o{static _safeEvaluate(e){if(!/^[\d+\-*/%.()\s^]+$/.test(e))throw new Error(`Invalid characters in expression: "${e}"`);const r=e.replace(/\^/g,"**");try{return Function(`"use strict"; return (${r})`)()}catch(r){if(!(r instanceof Error))throw new Error("Unknown Error");throw new Error(`Invalid expression "${e}": ${r.message}`)}}static replaceValues(e,r){let t=0;return e.replace(/(\d*)d(\d+)/g,(e,o)=>{const n=o?Number(o):1;let s=0;for(let e=0;e<n;e++){const e=r[t++];s+=void 0!==e?e:0}return String(s)})}static tokenizeValues(e,r){const t=o.replaceValues(e,r),n=[],s=/\d+|[()+\-*/]/g;let a;for(;null!==(a=s.exec(t));)/^\d+$/.test(a[0])?n.push(Number(a[0])):n.push(a[0]);return{tokens:n,text:t}}static parseString(e){if("string"!=typeof e)throw new TypeError("Input must be a string.");const r=e.split(",").map(e=>e.trim()).filter(Boolean),t=[],o=[];if(r.forEach((e,r)=>{const n=/\b(?:(\d+)?d(\d+))\b/g;let s;const a=[],i=e.replace(/\(([^()]+?\|[^()]+?)\)/g,(e,r)=>{const t="string"==typeof r?r.split("|").map(e=>e.trim()).filter(Boolean):[];if(0===t.length)throw new Error(`Invalid random-choice group: "${e}"`);return t[Math.floor(Math.random()*t.length)]});for(;null!==(s=n.exec(i));){const e=parseInt(s[1]||"1",10),t=parseInt(s[2],10);if(isNaN(t))throw new Error(`Invalid dice sides in expression "${s[0]}" at position ${r+1}.`);a.push({count:e,sides:t})}if(0===a.length&&Number.isNaN(parseFloat(i)))throw new Error(`Invalid dice expression at position ${r+1}: "${e}"`);t.push(...a),o.push({index:r,original:e,expression:i})}),0===t.length)throw new Error("Invalid dice amount.");return{sides:t,modifiers:o}}static applyModifiers(e,r){if(!Array.isArray(e)||!e.every(e=>"number"==typeof e&&!Number.isNaN(e)||t(e)&&"number"==typeof e.value&&!Number.isNaN(e.value)&&"number"==typeof e.sides&&!Number.isNaN(e.sides)))throw new TypeError("Bases must be a valid numbers.");if(!Array.isArray(r))throw new TypeError("Modifiers must be an array of modifier objects.");let n=0;const s=[],a=[...e];for(const e in r){const i=r[e];if("string"!=typeof i.expression)throw new Error("Each modifier must include an expression string.");const l=i.original,u=i.expression,c=[],p=[],f=[],h=e=>e.match(/\(\s*[^()]+\|\s*[^()]+\s*\)|\b\d*d\d+\b|[-+]?\d+(?:\.\d+)?|[+\-*/%^()]/g)||[],d=h(u),m=h(l),w=[...d],b=[],y=u.replace(/\b\d*d\d+\b/g,e=>{const r=e.split("d"),o=()=>{for(const r in d)if(d[r]===e&&b.indexOf(r)<0){b.push(r),f.push(Number(r));break}},n=e=>{if(e.value>e.sides)throw new Error(`Invalid dice roll: value (${e.value}) must be between 1 and ${e.sides}.`)};if(0===r[0].trim().length){const r=a.shift(),s="number"==typeof r?r:t(r)?r.value:0;t(r)&&n(r),c.push([s]);for(const r in w)if(w[r]===e){w[r]=String(s),p.push(Number(r));break}return o(),s}const s=[],i=Number(r[0]),l=["("];let u="(";for(let e=0;e<i;e++){const r=a.shift(),o="number"==typeof r?r:t(r)?r.value:0;t(r)&&n(r),l.push(String(o));const c=e<i-1?" + ":")";l.push(c),u+=`${o}${c}`,s.push(o)}for(const r in w){const t=Number(r);if(w[t]===e){w.splice(t,1,...l);let e=1;for(let r=0;r<i;r++)p.push(t+r+e),e++;break}}return c.push(s),o(),u});let g;try{g=o._safeEvaluate(y)}catch(e){if(!(e instanceof Error))throw new Error("Unknown Error");throw new Error(`Error evaluating expression "${y}" (from "${u}"): ${e.message}`)}s.push({rawTokensP:d,rawTokens:m,tokens:w,rawDiceTokenSlots:f,diceTokenSlots:p,dicesResult:c,total:g}),n+=g}return{final:n,steps:s}}static rollArrayIndex(e){const r=Array.isArray(e),t=e instanceof Set;if(!r&&!t)throw new TypeError("rollArrayIndex expects an array or Set.");return Math.floor(Math.random()*(r?e.length:e.size))}#e;#r;get maxValue(){return this.#e}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#e=e}get allowZero(){return this.#r}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#r=e}constructor({maxValue:e,allowZero:r=!0}){if("boolean"!=typeof r)throw new TypeError("allowZero must be an boolean.");if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#e=e,this.#r=r}roll(){const e=this.#r?0:1;return Math.floor(Math.random()*(this.#e-e+1))+e}}const n=o;window.TinySimpleDice=r.TinySimpleDice})();
1
+ (()=>{"use strict";const e={d:(r,t)=>{for(var o in t)e.o(t,o)&&!e.o(r,o)&&Object.defineProperty(r,o,{enumerable:!0,get:t[o]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)};let r={};function t(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&"[object Object]"===Object.prototype.toString.call(e)}e.d(r,{TinySimpleDice:()=>n});class o{static _safeEvaluate(e){if(!/^[\d+\-*/%.()\s^]+$/.test(e))throw new Error(`Invalid characters in expression: "${e}"`);const r=e.replace(/\^/g,"**");try{return Function(`"use strict"; return (${r})`)()}catch(r){if(!(r instanceof Error))throw new Error("Unknown Error");throw new Error(`Invalid expression "${e}": ${r.message}`)}}static replaceValues(e,r){let t=0;return e.replace(/(\d*)d(\d+)/g,(e,o)=>{const n=o?Number(o):1;let s=0;for(let e=0;e<n;e++){const e=r[t++];s+=void 0!==e?e:0}return String(s)})}static tokenizeValues(e,r){const t=o.replaceValues(e,r),n=[],s=/\d+|[()+\-*/]/g;let a;for(;null!==(a=s.exec(t));)/^\d+$/.test(a[0])?n.push(Number(a[0])):n.push(a[0]);return{tokens:n,text:t}}static parseString(e){if("string"!=typeof e)throw new TypeError("Input must be a string.");const r=e.split(",").map(e=>e.trim()).filter(Boolean),t=[],o=[];if(r.forEach((e,r)=>{const n=/\b(?:(\d+)?d(\d+))\b/g;let s;const a=[],i=e.replace(/\(([^()]+?\|[^()]+?)\)/g,(e,r)=>{const t="string"==typeof r?r.split("|").map(e=>e.trim()).filter(Boolean):[];if(0===t.length)throw new Error(`Invalid random-choice group: "${e}"`);return t[Math.floor(Math.random()*t.length)]});for(;null!==(s=n.exec(i));){const e=parseInt(s[1]||"1",10),t=parseInt(s[2],10);if(isNaN(t))throw new Error(`Invalid dice sides in expression "${s[0]}" at position ${r+1}.`);a.push({count:e,sides:t})}if(0===a.length&&Number.isNaN(parseFloat(i)))throw new Error(`Invalid dice expression at position ${r+1}: "${e}"`);t.push(...a),o.push({index:r,original:e,expression:i})}),0===t.length)throw new Error("Invalid dice amount.");return{sides:t,modifiers:o}}static applyModifiers(e,r){if(!Array.isArray(e)||!e.every(e=>"number"==typeof e&&!Number.isNaN(e)||t(e)&&"number"==typeof e.value&&!Number.isNaN(e.value)&&"number"==typeof e.sides&&!Number.isNaN(e.sides)))throw new TypeError("Bases must be a valid numbers.");if(!Array.isArray(r))throw new TypeError("Modifiers must be an array of modifier objects.");let n=0;const s=[],a=[...e];for(const e in r){const i=r[e];if("string"!=typeof i.expression)throw new Error("Each modifier must include an expression string.");const l=i.original,u=i.expression,c=[],p=[],f=[],h=e=>e.match(/\(\s*[^()]+\|\s*[^()]+\s*\)|\b\d*d\d+\b|[-+]?\d+(?:\.\d+)?|[+\-*/%^()]/g)||[],d=h(u),m=h(l),w=[...d],b=[],y=u.replace(/\b\d*d\d+\b/g,e=>{const r=e.split("d"),o=()=>{for(const r in d)if(d[r]===e&&b.indexOf(r)<0){b.push(r),f.push(Number(r));break}},n=e=>{if(e.value>e.sides)throw new Error(`Invalid dice roll: value (${e.value}) must be between 1 and ${e.sides}.`)};if(0===r[0].trim().length){const r=a.shift(),s="number"==typeof r?r:t(r)?r.value:0;t(r)&&n(r),c.push([s]);for(const r in w)if(w[r]===e){w[r]=String(s),p.push(Number(r));break}return o(),s}const s=[],i=Number(r[0]),l=["("];let u="(";for(let e=0;e<i;e++){const r=a.shift(),o="number"==typeof r?r:t(r)?r.value:0;t(r)&&n(r),l.push(String(o));const c=e<i-1?" + ":")";l.push(c),u+=`${o}${c}`,s.push(o)}for(const r in w){const t=Number(r);if(w[t]===e){w.splice(t,1,...l);let e=1;for(let r=0;r<i;r++)p.push(t+r+e),e++;break}}return c.push(s),o(),u});let g;try{g=o._safeEvaluate(y)}catch(e){if(!(e instanceof Error))throw new Error("Unknown Error");throw new Error(`Error evaluating expression "${y}" (from "${u}"): ${e.message}`)}s.push({rawTokensP:d,rawTokens:m,tokens:w,rawDiceTokenSlots:f,diceTokenSlots:p,dicesResult:c,total:g}),n+=g}return{final:n,steps:s}}static rollArrayIndex(e){const r=Array.isArray(e),t=e instanceof Set;if(!r&&!t)throw new TypeError("rollArrayIndex expects an array or Set.");return Math.floor(Math.random()*(r?e.length:e.size))}#e;#r;get maxValue(){return this.#e}set maxValue(e){if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#e=e}get allowZero(){return this.#r}set allowZero(e){if("boolean"!=typeof e)throw new TypeError("allowZero must be a boolean.");this.#r=e}constructor({maxValue:e,allowZero:r=!0}){if("boolean"!=typeof r)throw new TypeError("allowZero must be an boolean.");if(!Number.isInteger(e)||e<0)throw new TypeError("maxValue must be an integer greater than -1.");this.#e=e,this.#r=r}roll(){const e=this.#r?0:1;return Math.floor(Math.random()*(this.#e-e+1))+e}}const n=o;window.TinySimpleDice=r.TinySimpleDice})();